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:
parent
991fd90a12
commit
b7a0950aea
@ -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
|
||||
|| (
|
||||
|
@ -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'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user