Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Type/Constant/ConstantArrayTypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
return;
}

$this->isList = TrinaryLogic::createNo();

$scalarTypes = $offsetType->getConstantScalarTypes();
if (count($scalarTypes) === 0) {
$integerRanges = TypeUtils::getIntegerRanges($offsetType);
Expand Down Expand Up @@ -257,6 +255,8 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
return;
}
}

$this->isList = TrinaryLogic::createNo();
}

if ($offsetType === null) {
Expand Down
19 changes: 19 additions & 0 deletions tests/PHPStan/Analyser/nsrt/array-is-list-offset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace ArrayIsListUnset;

use function PHPStan\Testing\assertType;

class Foo {
/**
* @param array{bool, bool, bool} $array
* @param int<0, 1> $key
*/
public function test(array $array, int $key) {
assertType('int<0, 1>', $key);
assertType('true', array_is_list($array));

$array[$key] = false;
assertType('true', array_is_list($array));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to this PR, it was considered as false.

}
}
Loading