1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix usage of array_push results

This commit is contained in:
Brown 2020-07-16 13:44:51 -04:00
parent 262bb9fd89
commit a2dbd31371
3 changed files with 16 additions and 2 deletions

View File

@ -144,6 +144,10 @@ class ArrayFunctionArgumentsAnalyzer
if ($is_push && !$unpacked_args) {
for ($i = 1; $i < count($args); $i++) {
$was_inside_assignment = $context->inside_assignment;
$context->inside_assignment = true;
if (ExpressionAnalyzer::analyze(
$statements_analyzer,
$args[$i]->value,
@ -152,6 +156,8 @@ class ArrayFunctionArgumentsAnalyzer
return false;
}
$context->inside_assignment = $was_inside_assignment;
$old_node_data = $statements_analyzer->node_data;
$statements_analyzer->node_data = clone $statements_analyzer->node_data;

View File

@ -147,7 +147,7 @@ class SimpleNegatedAssertionReconciler extends Reconciler
);
}
if ($assertion === 'null' && !$existing_var_type->isMixed()) {
if ($assertion === 'null' && !$existing_var_type->hasMixed()) {
return self::reconcileNull(
$existing_var_type,
$key,
@ -158,7 +158,7 @@ class SimpleNegatedAssertionReconciler extends Reconciler
);
}
if ($assertion === 'false' && !$existing_var_type->isMixed()) {
if ($assertion === 'false' && !$existing_var_type->hasMixed()) {
return self::reconcileFalse(
$existing_var_type,
$key,

View File

@ -736,6 +736,14 @@ class UnusedCodeTest extends TestCase
return $nextKey;
}'
],
'arrayPushFunctionCall' => [
'<?php
$a = [];
array_push($a, strlen("hello"));
echo $a[0];'
],
];
}