You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$original = "I just wanna tell you how I'm feeling\nGotta make you understand";
$encrypted = '';
$decrypted = '';
if (! @\openssl_public_encrypt($original, $encrypted, $pupKey, OPENSSL_PKCS1_OAEP_PADDING)) {
thrownewException('Unable to encrypt data, invalid key provided?');
}
The openssl_public_encrypt() function sets $decrypted, but PHPStan reports the condition is always true
as it doesn't take-in the fact the the $decrypted variable is mutated as argument.
Removing $decrypted = ''; fixes the issue.
Expected output
No errors!
The text was updated successfully, but these errors were encountered:
sstok
changed the title
Reference parameter not as variable mutation
Reference parameter not considered as variable mutation
Oct 25, 2020
Some implementation details: This is a bug in BooleanOrConstantConditionRule. This rule and similar rules like BooleanAndConstantConditionRule are buggy as they evaluate the right side of || as just $scope->filterByFalseyValue($node->left) but they miss that more can happen on the left side.
The right solution is to introduce a virtual node that will carry the correct scopes to evaluate the expressions against and invoke BooleanOrConstantConditionRule for that node. There are already examples of such nodes under PHPStan\Node namespace, like LiteralArrayNode, that solve similar problems.
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/d14466f0-f81e-4594-8ba9-8d87badb70f6
The
openssl_public_encrypt()
function sets$decrypted
, but PHPStan reports the condition is always trueas it doesn't take-in the fact the the
$decrypted
variable is mutated as argument.Removing
$decrypted = '';
fixes the issue.Expected output
No errors!
The text was updated successfully, but these errors were encountered: