Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14080799
D9239.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D9239.diff
View Options
diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php
--- a/src/lint/linter/ArcanistXHPASTLinter.php
+++ b/src/lint/linter/ArcanistXHPASTLinter.php
@@ -1202,11 +1202,11 @@
}
}
- $catches = $body
- ->selectDescendantsOfType('n_CATCH')
- ->selectDescendantsOfType('n_VARIABLE');
- foreach ($catches as $var) {
- $vars[] = $var;
+ // Include "catch (Exception $ex)", but not variables in the body of the
+ // catch block.
+ $catches = $body->selectDescendantsOfType('n_CATCH');
+ foreach ($catches as $catch) {
+ $vars[] = $catch->getChildOfType(1, 'n_VARIABLE');
}
$binary = $body->selectDescendantsOfType('n_BINARY_EXPRESSION');
diff --git a/src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test b/src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test
--- a/src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test
+++ b/src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test
@@ -166,6 +166,14 @@
echo "$b";
}
+function catchy() {
+ try {
+ dangerous();
+ } catch (Exception $ex) {
+ $y->z();
+ }
+}
+
~~~~~~~~~~
disabled:3:1
error:30:3
@@ -185,3 +193,4 @@
error:146:8
error:152:9
error:166:9
+error:173:5
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 4:49 PM (18 h, 32 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6778938
Default Alt Text
D9239.diff (1 KB)
Attached To
Mode
D9239: Fix XHPAST to detect use of undeclared variables in `catch`
Attached
Detach File
Event Timeline
Log In to Comment