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
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;
continue;
}
$report = true;
break 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,11 @@ public function testBug9240(): void
$this->analyse([__DIR__ . '/data/bug-9240.php'], []);
}

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

#[RequiresPhp('>= 8.4.0')]
public function testArrayFindKeyExisting(): void
{
Expand Down
19 changes: 19 additions & 0 deletions tests/PHPStan/Rules/Arrays/data/bug-13688.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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";
}

function directComparison(): void
{
/** @var 'a'|'abc' $s */
$s = 'a';
echo $s[0];
}
Loading