Summary: Fix a minor issue in which changing a function call to a type cast affects the result of an expression.
Test Plan: Added test case.
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D14623
// 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') {
--- /dev/null
+<?php
+intval($x / 2) + 1;
+~~~~~~~~~~
+advice:2:1
+~~~~~~~~~~
+<?php
+(int)($x / 2) + 1;