[Scoper] Clean up bootstrap.php: move enum definitions to dedicated file and require in BootstrapFilesIncluder (#2248)

* [Scoper] Clean up bootstrap.php: move enum definitions to dedicated file and require in BootstrapFilesIncluder

* eol

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2022-05-07 15:41:36 +07:00 committed by GitHub
parent b54fb77073
commit 1f6c7a6a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 34 deletions

View File

@ -39,35 +39,3 @@ spl_autoload_register(function (string $class): void {
}
}
});
if (! interface_exists('UnitEnum')) {
/**
* @since 8.1
*/
interface UnitEnum
{
/**
* @return static[]
*/
public static function cases(): array;
}
}
if (! interface_exists('BackedEnum')) {
/**
* @since 8.1
*/
interface BackedEnum extends UnitEnum {
/**
* @param int|string $value
* @return $this
*/
public static function from($value);
/**
* @param int|string $value
* @return $this|null
*/
public static function tryFrom($value);
}
}

View File

@ -0,0 +1,33 @@
<?php
if (! interface_exists('UnitEnum')) {
/**
* @since 8.1
*/
interface UnitEnum
{
/**
* @return static[]
*/
public static function cases(): array;
}
}
if (! interface_exists('BackedEnum')) {
/**
* @since 8.1
*/
interface BackedEnum extends UnitEnum {
/**
* @param int|string $value
* @return $this
*/
public static function from($value);
/**
* @param int|string $value
* @return $this|null
*/
public static function tryFrom($value);
}
}

View File

@ -12,6 +12,14 @@ use Webmozart\Assert\Assert;
final class BootstrapFilesIncluder
{
/**
* @var string[]
*/
private const STUBS = [
'/../../stubs-rector/PHPUnit/Framework/TestCase.php',
'/../../stubs-rector/Internal/EnumInterfaces.php',
];
public function __construct(
private readonly ParameterProvider $parameterProvider
) {
@ -49,8 +57,10 @@ final class BootstrapFilesIncluder
}
}
if (is_file(__DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php')) {
require_once __DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php';
foreach (self::STUBS as $stub) {
if (is_file(__DIR__ . $stub)) {
require_once __DIR__ . $stub;
}
}
}
}