1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Prevent passing casts to byref vars

This commit is contained in:
Brown 2019-02-21 13:26:37 -05:00
parent 991fd90a12
commit b7a0950aea
2 changed files with 10 additions and 0 deletions

View File

@ -1211,6 +1211,7 @@ class CallAnalyzer
array $template_types = null
) {
if ($arg->value instanceof PhpParser\Node\Scalar
|| $arg->value instanceof PhpParser\Node\Expr\Cast
|| $arg->value instanceof PhpParser\Node\Expr\Array_
|| $arg->value instanceof PhpParser\Node\Expr\ClassConstFetch
|| (

View File

@ -1953,6 +1953,15 @@ class FunctionCallTest extends TestCase
}',
'error_message' => 'NullArgument',
],
'intCastByRef' => [
'<?php
function foo(int &$i) : void {}
$a = rand(0, 1) ? null : 5;
/** @psalm-suppress MixedArgument */
foo((int) $a);',
'InvalidPassByReference'
],
];
}
}