mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 09:50:49 +00:00
[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:
parent
b54fb77073
commit
1f6c7a6a20
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,14 @@ use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
final class BootstrapFilesIncluder
|
final class BootstrapFilesIncluder
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
private const STUBS = [
|
||||||
|
'/../../stubs-rector/PHPUnit/Framework/TestCase.php',
|
||||||
|
'/../../stubs-rector/Internal/EnumInterfaces.php',
|
||||||
|
];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly ParameterProvider $parameterProvider
|
private readonly ParameterProvider $parameterProvider
|
||||||
) {
|
) {
|
||||||
|
@ -49,8 +57,10 @@ final class BootstrapFilesIncluder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_file(__DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php')) {
|
foreach (self::STUBS as $stub) {
|
||||||
require_once __DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php';
|
if (is_file(__DIR__ . $stub)) {
|
||||||
|
require_once __DIR__ . $stub;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user