Skip to content

Commit cd2f4af

Browse files
committed
Update TypeSpecifier.php
1 parent b8de415 commit cd2f4af

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/Analyser/TypeSpecifier.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,21 +872,20 @@ public function specifyTypesInCondition(
872872
&& count($expr->expr->getArgs()) >= 2
873873
) {
874874
$funcName = $expr->expr->name->toLowerString();
875-
$arrayArgIndex = null;
875+
$arrayArg = null;
876876
$sentinelType = null;
877877
$isStrictArraySearch = false;
878878

879879
if ($funcName === 'array_search') {
880-
$arrayArgIndex = 1;
880+
$arrayArg = $expr->expr->getArgs()[1]->value;
881881
$sentinelType = new ConstantBooleanType(false);
882882
$isStrictArraySearch = count($expr->expr->getArgs()) >= 3 && $scope->getType($expr->expr->getArgs()[2]->value)->isTrue()->yes();
883883
} elseif ($funcName === 'array_find_key') {
884-
$arrayArgIndex = 0;
884+
$arrayArg = $expr->expr->getArgs()[0]->value;
885885
$sentinelType = new NullType();
886886
}
887887

888-
if ($arrayArgIndex !== null) {
889-
$arrayArg = $expr->expr->getArgs()[$arrayArgIndex]->value;
888+
if ($arrayArg !== null) {
890889
$arrayType = $scope->getType($arrayArg);
891890

892891
if ($arrayType->isArray()->yes()) {

0 commit comments

Comments
 (0)