Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13995231
D14623.id35393.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
D14623.id35393.diff
View Options
diff --git a/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule.php
@@ -37,7 +37,13 @@
// one parameter.
if (count($parameters->getChildren()) == 1) {
$parameter = $parameters->getChildByIndex(0);
- $replacement = '('.$cast_name.')'.$parameter->getConcreteString();
+ $replacement = '('.$cast_name.')';
+
+ if ($parameter->getTypeName() == 'n_BINARY_EXPRESSION') {
+ $replacement .= '('.$parameter->getConcreteString().')';
+ } else {
+ $replacement .= $parameter->getConcreteString();
+ }
}
if (strtolower($function_name) == 'intval') {
diff --git a/src/lint/linter/xhpast/rules/__tests__/function-call-should-be-type-cast/binary-expression.lint-test b/src/lint/linter/xhpast/rules/__tests__/function-call-should-be-type-cast/binary-expression.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/function-call-should-be-type-cast/binary-expression.lint-test
@@ -0,0 +1,7 @@
+<?php
+intval($x / 2) + 1;
+~~~~~~~~~~
+advice:2:1
+~~~~~~~~~~
+<?php
+(int)($x / 2) + 1;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 24, 11:31 AM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713612
Default Alt Text
D14623.id35393.diff (1 KB)
Attached To
Mode
D14623: Fix another edge case for "function call should be type cast" linter rule
Attached
Detach File
Event Timeline
Log In to Comment