mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Warn about array_walk_recursive over objects
This commit is contained in:
parent
b370ce92aa
commit
103b2b7244
@ -404,7 +404,11 @@ class NamedFunctionCallHandler
|
||||
}
|
||||
}
|
||||
|
||||
if ($first_arg && $function_id === 'array_walk') {
|
||||
if ($first_arg
|
||||
&& ($function_id === 'array_walk'
|
||||
|| $function_id === 'array_walk_recursive'
|
||||
)
|
||||
) {
|
||||
$first_arg_type = $statements_analyzer->node_data->getType($first_arg->value);
|
||||
|
||||
if ($first_arg_type && $first_arg_type->hasObjectType()) {
|
||||
|
@ -2177,6 +2177,13 @@ class ArrayFunctionCallTest extends TestCase
|
||||
',
|
||||
'error_message' => 'RawObjectIteration',
|
||||
],
|
||||
'arrayWalkRecursiveOverObject' => [
|
||||
'<?php
|
||||
$o = new stdClass();
|
||||
array_walk_recursive($o, "var_dump");
|
||||
',
|
||||
'error_message' => 'RawObjectIteration',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user