File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -284,4 +284,6 @@ final class AttributeKey
284284 public const PHP_VERSION_CONDITIONED = 'php_version_conditioned ' ;
285285
286286 public const HAS_CLOSURE_WITH_VARIADIC_ARGS = 'has_closure_with_variadic_args ' ;
287+
288+ public const IS_IN_TRY_BLOCK = 'is_in_try_block ' ;
287289}
Original file line number Diff line number Diff line change 3131use PhpParser \Node \Stmt \Function_ ;
3232use PhpParser \Node \Stmt \If_ ;
3333use PhpParser \Node \Stmt \Switch_ ;
34+ use PhpParser \Node \Stmt \TryCatch ;
3435use PhpParser \Node \Stmt \Unset_ ;
3536use PhpParser \Node \Stmt \While_ ;
3637use PhpParser \NodeVisitor ;
3738use PhpParser \NodeVisitorAbstract ;
3839use Rector \Contract \PhpParser \DecoratingNodeVisitorInterface ;
3940use Rector \NodeTypeResolver \Node \AttributeKey ;
4041use Rector \PhpDocParser \NodeTraverser \SimpleCallableNodeTraverser ;
42+ use Rector \PhpParser \NodeTraverser \SimpleNodeTraverser ;
4143
4244final class ContextNodeVisitor extends NodeVisitorAbstract implements DecoratingNodeVisitorInterface
4345{
@@ -66,6 +68,12 @@ public function enterNode(Node $node): ?Node
6668 return null ;
6769 }
6870
71+ if ($ node instanceof TryCatch) {
72+ SimpleNodeTraverser::decorateWithAttributeValue ($ node ->stmts , AttributeKey::IS_IN_TRY_BLOCK , true );
73+
74+ return null ;
75+ }
76+
6977 if ($ node instanceof Isset_) {
7078 foreach ($ node ->vars as $ var ) {
7179 $ var ->setAttribute (AttributeKey::IS_ISSET_VAR , true );
You can’t perform that action at this time.
0 commit comments