Skip to content

Commit

Permalink
Fix phpunit error on rector/rector:dev-main due to container cache (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed May 16, 2023
1 parent cc3354a commit 5d78e95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -800,3 +800,13 @@ parameters:
-
message: '#Do not use static property#'
path: src/Kernel/RectorKernel.php

# this is due to compare VersionResolver::PACKAGE_VERSION to verify on rector-src
-
message: '#Public method "Rector\\Core\\Kernel\\RectorKernel\:\:clearCache\(\)" is never used#'
path: src/Kernel/RectorKernel.php

# '@package_version@' compare with '@package_version@' to verify on rector-src
-
message: '#Strict comparison using \!\=\= between .* and .* will always evaluate to false#'
path: src/Kernel/RectorKernel.php
13 changes: 10 additions & 3 deletions src/Kernel/RectorKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Core\Kernel;

use Rector\Core\Application\VersionResolver;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Util\FileHasher;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
Expand All @@ -27,10 +28,16 @@ final class RectorKernel
public function __construct()
{
// while running tests we use different DI containers a lot,
// therefore make sure we don't compile them over and over again.
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
$this->dumpFileCache = true;
// therefore make sure we don't compile them over and over again on rector-src.
if (! StaticPHPUnitEnvironment::isPHPUnitRun()) {
return;
}

if (VersionResolver::PACKAGE_VERSION !== '@package_version@') {
return;
}

$this->dumpFileCache = true;
}

/**
Expand Down

0 comments on commit 5d78e95

Please sign in to comment.