Updated Rector to commit 2ec55701f292770fc7be3ca6e434d437e59c333b

2ec55701f2 [Performance] Fix filter cache on SkippedClassResolver (#5460)
This commit is contained in:
Tomas Votruba 2024-01-13 01:44:47 +00:00
parent bebd959a24
commit 8b20f236c0
4 changed files with 12 additions and 10 deletions

View File

@ -81,8 +81,8 @@ CODE_SAMPLE
// only default → basically unwrap
if (!$onlyCase->cond instanceof Expr) {
// remove default clause because it cause syntax error
return \array_filter($onlyCase->stmts, function (Stmt $statement) {
return !$statement instanceof Break_;
return \array_filter($onlyCase->stmts, static function (Stmt $stmt) : bool {
return !$stmt instanceof Break_;
});
}
$if = new If_(new Identical($node->cond, $onlyCase->cond));

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ac072bc8af186b2c86256aa7d29e52bb608ece27';
public const PACKAGE_VERSION = '2ec55701f292770fc7be3ca6e434d437e59c333b';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-01-12 00:00:19';
public const RELEASE_DATE = '2024-01-13 08:42:30';
/**
* @var int
*/

View File

@ -9,23 +9,25 @@ use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
final class SkippedClassResolver
{
/**
* @var array<string, string[]|null>
* @var null|array<string, string[]|null>
*/
private $skippedClasses = [];
private $skippedClasses = null;
/**
* @return array<string, string[]|null>
*/
public function resolve() : array
{
// disable cache in tests
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
// disable cache in tests
$this->skippedClasses = [];
$this->skippedClasses = null;
}
// skip cache in tests
if ($this->skippedClasses !== []) {
// already cached, even only empty array
if ($this->skippedClasses !== null) {
return $this->skippedClasses;
}
$skip = SimpleParameterProvider::provideArrayParameter(Option::SKIP);
$this->skippedClasses = [];
foreach ($skip as $key => $value) {
// e.g. [SomeClass::class] → shift values to [SomeClass::class => null]
if (\is_int($key)) {

View File

@ -34,7 +34,7 @@ final class SkippedPathsResolver
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
$this->skippedPaths = null;
}
// already filled, even empty array
// already cached, even only empty array
if ($this->skippedPaths !== null) {
return $this->skippedPaths;
}