Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
if (
$innerType->hasOffsetValueType($innerDimType)->no()
) {
if ($innerType->isString()->yes() && $innerDimType->isInteger()->yes()) {

Check warning on line 129 in src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php

View workflow job for this annotation

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

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ( $innerType->hasOffsetValueType($innerDimType)->no() ) { - if ($innerType->isString()->yes() && $innerDimType->isInteger()->yes()) { + if ($innerType->isString()->yes() && !$innerDimType->isInteger()->no()) { continue; } $report = true;

Check warning on line 129 in src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php

View workflow job for this annotation

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

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ( $innerType->hasOffsetValueType($innerDimType)->no() ) { - if ($innerType->isString()->yes() && $innerDimType->isInteger()->yes()) { + if (!$innerType->isString()->no() && $innerDimType->isInteger()->yes()) { continue; } $report = true;

Check warning on line 129 in src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php

View workflow job for this annotation

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

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ( $innerType->hasOffsetValueType($innerDimType)->no() ) { - if ($innerType->isString()->yes() && $innerDimType->isInteger()->yes()) { + if ($innerType->isString()->yes() && !$innerDimType->isInteger()->no()) { continue; } $report = true;

Check warning on line 129 in src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php

View workflow job for this annotation

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

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ( $innerType->hasOffsetValueType($innerDimType)->no() ) { - if ($innerType->isString()->yes() && $innerDimType->isInteger()->yes()) { + if (!$innerType->isString()->no() && $innerDimType->isInteger()->yes()) { continue; } $report = true;
Comment thread
staabm marked this conversation as resolved.
Outdated
continue;
}
$report = true;
break 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1343,4 +1343,9 @@ public function testArrayFindKeyExisting(): void
]);
}

public function testBug13688(): void
{
$this->analyse([__DIR__ . '/data/bug-13688.php'], []);
}

}
28 changes: 28 additions & 0 deletions tests/PHPStan/Rules/Arrays/data/bug-13688.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types = 1);

namespace Bug13688;

$inputs = [ '', ':' ];

foreach ( $inputs as $input )
{
$inputLen = \strlen($input);
$hasTrailingColon = $inputLen > 0 && $input[$inputLen-1] === ':';
echo $hasTrailingColon ? "{$input} has trailing colon\n" : "{$input} does not have trailing colon\n";
}

/** @var 'a'|'abc' $str */
$str = 'a';
echo $str[0];

/** @var 'a'|'abc' $str2 */
$str2 = 'a';
echo $str2[2];

/** @var ''|'foo'|'barbaz' $str3 */
$str3 = 'foo';
echo $str3[4];

/** @var string|array<int, string> $mixed */
$mixed = 'test';
echo $mixed[0];
Loading