Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 14 additions & 2 deletions src/Analyser/TypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,16 @@
$resultTypes = [];
foreach ($type->getArrays() as $arrayType) {
$isSizeSuperTypeOfArraySize = $sizeType->isSuperTypeOf($arrayType->getArraySize());
if ($isSizeSuperTypeOfArraySize->no()) {

if ($context->falsey()) {

Check warning on line 1278 in src/Analyser/TypeSpecifier.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrueTruthyFalseFalseyTypeSpecifierContextMutator": @@ @@ foreach ($type->getArrays() as $arrayType) { $isSizeSuperTypeOfArraySize = $sizeType->isSuperTypeOf($arrayType->getArraySize()); - if ($context->falsey()) { + if ($context->false()) { if ($isSizeSuperTypeOfArraySize->yes()) { continue; }

Check warning on line 1278 in src/Analyser/TypeSpecifier.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrueTruthyFalseFalseyTypeSpecifierContextMutator": @@ @@ foreach ($type->getArrays() as $arrayType) { $isSizeSuperTypeOfArraySize = $sizeType->isSuperTypeOf($arrayType->getArraySize()); - if ($context->falsey()) { + if ($context->false()) { if ($isSizeSuperTypeOfArraySize->yes()) { continue; }
if ($isSizeSuperTypeOfArraySize->yes()) {
continue;
}
$resultTypes[] = $arrayType;
continue;
}

if ($context->falsey() && $isSizeSuperTypeOfArraySize->maybe()) {
if ($isSizeSuperTypeOfArraySize->no()) {
continue;
}

Expand Down Expand Up @@ -1371,6 +1376,13 @@
$resultTypes[] = TypeCombinator::intersect($arrayType, new NonEmptyArrayType());
}

if ($context->falsey()) {

Check warning on line 1379 in src/Analyser/TypeSpecifier.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrueTruthyFalseFalseyTypeSpecifierContextMutator": @@ @@ $resultTypes[] = TypeCombinator::intersect($arrayType, new NonEmptyArrayType()); } - if ($context->falsey()) { + if ($context->false()) { if (count($resultTypes) === 0) { return null; }

Check warning on line 1379 in src/Analyser/TypeSpecifier.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrueTruthyFalseFalseyTypeSpecifierContextMutator": @@ @@ $resultTypes[] = TypeCombinator::intersect($arrayType, new NonEmptyArrayType()); } - if ($context->falsey()) { + if ($context->false()) { if (count($resultTypes) === 0) { return null; }
if (count($resultTypes) === 0) {
return null;
}
return $this->create($countFuncCall->getArgs()[0]->value, TypeCombinator::union(...$resultTypes), TypeSpecifierContext::createTrue(), $scope)->setRootExpr($rootExpr);
}

return $this->create($countFuncCall->getArgs()[0]->value, TypeCombinator::union(...$resultTypes), $context, $scope)->setRootExpr($rootExpr);
}

Expand Down
24 changes: 24 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-11488.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types = 1);

namespace Bug11488;

use function PHPStan\Testing\assertType;

class Foo
{
/**
* @param array{mixed}|array{mixed, string|null, mixed} $row
*/
protected function test(array $row): string
{
if (count($row) !== 1) {
assertType('array{mixed, string|null, mixed}', $row);

[$field, $operator, $value] = $row;
assertType('string|null', $operator);
return $operator ?? '=';
}

return '';
}
}
Loading