Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
clxmstaab committed Mar 23, 2022
1 parent 495e9c2 commit da019ca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Type/Php/InArrayFunctionTypeSpecifyingExtension.php
Expand Up @@ -10,10 +10,12 @@
use PHPStan\Analyser\TypeSpecifierContext;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Type\Accessory\NonEmptyArrayType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\FunctionTypeSpecifyingExtension;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\TypeUtils;
use PHPStan\Type\UnionType;
use function count;
use function strtolower;

Expand Down Expand Up @@ -47,12 +49,15 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n
$arrayValueType = $arrayType->getIterableValueType();

$specifiedTypes = new SpecifiedTypes([], []);
if ($context->true() && $arrayType->isArray()->yes() && !$arrayType->isIterableAtLeastOnce()->yes()) {
$arrayType = TypeCombinator::intersect($arrayType, new NonEmptyArrayType());

if ($context->true()
&& $arrayType->isArray()->yes()
&& !$arrayType->isIterableAtLeastOnce()->yes()
&& !($arrayType instanceof ConstantArrayType && $arrayType->isEmpty())
&& !$arrayType instanceof UnionType)
{
$specifiedTypes = $specifiedTypes->unionWith($this->typeSpecifier->create(
$node->getArgs()[1]->value,
$arrayType,
new NonEmptyArrayType(),
$context,
false,
$scope,
Expand Down

0 comments on commit da019ca

Please sign in to comment.