Skip to content

Commit

Permalink
Improve array_search type specifier performance
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanvelzen authored and ondrejmirtes committed Oct 11, 2022
1 parent ed762e8 commit 9bf5694
Show file tree
Hide file tree
Showing 3 changed files with 4,032 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function specifyTypes(

return $this->typeSpecifier->create(
$arrayArg,
TypeCombinator::intersect(TypeCombinator::intersect(new ArrayType(new MixedType(), new MixedType()), $scope->getType($arrayArg)), new NonEmptyArrayType()),
TypeCombinator::intersect(new ArrayType(new MixedType(), new MixedType()), new NonEmptyArrayType()),
$context,
false,
$scope,
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,16 @@ public function testBug3865(): void
$this->assertSame(14, $errors[0]->getLine());
}

public function testBug8147(): void
{
if (PHP_VERSION_ID < 80000) {
$this->markTestSkipped('Test requires PHP 8.0.');
}

$errors = $this->runAnalyse(__DIR__ . '/data/bug-8147.php');
$this->assertNoErrors($errors);
}

/**
* @param string[]|null $allAnalysedFiles
* @return Error[]
Expand Down

0 comments on commit 9bf5694

Please sign in to comment.