Fix stub PHPUnit\Framework\TestCase (#1954)

* Fix stub PHPUnit\Framework\TestCase

* final touch: clean up

* final touch: clean up

* load after bootstrap loaded

* move to target-repository

* final touch: remove stubs-rector on remote-repository first when exists
This commit is contained in:
Abdul Malik Ikhsan 2022-03-22 21:32:53 +07:00 committed by GitHub
parent e7c028396b
commit 8f86f525f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 69 deletions

View File

@ -100,7 +100,7 @@ jobs:
token: ${{ secrets.ACCESS_TOKEN }}
# remove remote files, to avoid piling up dead code in remote repository
- run: rm -rf remote-repository/.github remote-repository/e2e remote-repository/config remote-repository/src remote-repository/rules remote-repository/packages remote-repository/vendor
- run: rm -rf remote-repository/.github remote-repository/e2e remote-repository/config remote-repository/src remote-repository/rules remote-repository/packages remote-repository/vendor remote-repository/stubs-rector
- run: cp -a rector-prefixed-downgraded/. remote-repository

View File

@ -124,7 +124,6 @@ PHP;
->notPath('#\/tests\/#')
->notPath('#\/config\/#')
->notPath('#\/set\/#')
->in($vendorDir . '/symplify/symfony-php-config')
->sortByName();
return iterator_to_array($finder->getIterator());

View File

@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
$phpStanStubLoader = new PHPStanStubLoader();
$phpStanStubLoader->loadStubs();
require_once __DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php';
require_once __DIR__ . '/../target-repository/stubs-rector/PHPUnit/Framework/TestCase.php';
require_once __DIR__ . '/../../stubs/Composer/EventDispatcher/EventSubscriberInterface.php';
require_once __DIR__ . '/../../stubs/Composer/Plugin/PluginInterface.php';
require_once __DIR__ . '/../../stubs/Nette/DI/CompilerExtension.php';

View File

@ -2,10 +2,8 @@
declare(strict_types = 1);
namespace
{
// inspired by https://github.com/phpstan/phpstan/blob/master/bootstrap.php
spl_autoload_register(function (string $class): void {
// inspired by https://github.com/phpstan/phpstan/blob/master/bootstrap.php
spl_autoload_register(function (string $class): void {
static $composerAutoloader;
// already loaded in bin/rector.php
@ -36,9 +34,9 @@ namespace
return;
}
}
});
});
if (! interface_exists('UnitEnum')) {
if (! interface_exists('UnitEnum')) {
/**
* @since 8.1
*/
@ -49,9 +47,9 @@ namespace
*/
public static function cases(): array;
}
}
}
if (! interface_exists('BackedEnum')) {
if (! interface_exists('BackedEnum')) {
/**
* @since 8.1
*/
@ -68,15 +66,4 @@ namespace
*/
public static function tryFrom($value);
}
}
}
// @see https://github.com/rectorphp/rector/issues/6531
namespace PHPUnit\Framework
{
if (! class_exists('PHPUnit\Framework\TestCase')) {
abstract class TestCase
{
}
}
}

View File

@ -48,5 +48,9 @@ final class BootstrapFilesIncluder
throw new ShouldNotHappenException($errorMessage, $throwable->getCode(), $throwable);
}
}
if (is_file(__DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php')) {
require_once __DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php';
}
}
}