diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..3069da26 --- /dev/null +++ b/rector.php @@ -0,0 +1,31 @@ +parameters(); + + $parameters->set(Option::AUTO_IMPORT_NAMES, true); + + $parameters->set(Option::SETS, [ + SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION, + SetList::ARRAY_STR_FUNCTIONS_TO_STATIC_CALL, + SetList::CODE_QUALITY, + SetList::PHP_53, + SetList::PHP_54, + SetList::PHP_56, + SetList::PHP_70, + SetList::PHP_71, + SetList::PHP_72, + SetList::PHP_73, + SetList::PHPSTAN, + SetList::PHPUNIT_CODE_QUALITY, + SetList::SOLID, + ]); + + $parameters->set(Option::PATHS, [__DIR__.'/src', __DIR__.'/tests']); +}; diff --git a/rector.yaml b/rector.yaml deleted file mode 100644 index bf3cd023..00000000 --- a/rector.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# rector.yaml -parameters: - sets: - - 'action-injection-to-constructor-injection' - - 'array-str-functions-to-static-call' - - 'phpstan' - - 'phpunit-code-quality' - - 'solid' - - 'doctrine-code-quality' - - 'code-quality' - - 'php53' - - 'php54' - - 'php55' - - 'php56' - - 'php70' - - 'php71' - - 'php72' - - 'php73' diff --git a/src/Concerns/TestCase.php b/src/Concerns/TestCase.php index 6c1d98ce..58d17059 100644 --- a/src/Concerns/TestCase.php +++ b/src/Concerns/TestCase.php @@ -9,6 +9,7 @@ use Pest\Expectation; use Pest\Support\ExceptionTrace; use Pest\TestSuite; use PHPUnit\Util\Test; +use Throwable; /** * To avoid inheritance conflicts, all the fields related @@ -143,7 +144,7 @@ trait TestCase * * @return mixed * - * @throws \Throwable + * @throws Throwable */ public function __test() { @@ -153,7 +154,7 @@ trait TestCase /** * @return mixed * - * @throws \Throwable + * @throws Throwable */ private function __callClosure(Closure $closure, array $arguments) { diff --git a/src/Laravel/Commands/PestInstallCommand.php b/src/Laravel/Commands/PestInstallCommand.php index c5247548..b1f34a45 100644 --- a/src/Laravel/Commands/PestInstallCommand.php +++ b/src/Laravel/Commands/PestInstallCommand.php @@ -6,6 +6,7 @@ namespace Pest\Laravel\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\File; +use Pest\Console\Thanks; use Pest\Exceptions\InvalidConsoleArgument; use Pest\Support\Str; @@ -61,7 +62,7 @@ final class PestInstallCommand extends Command $this->output->success('`tests/Helpers.php` created successfully.'); if (!(bool) $this->option('no-interaction')) { - (new \Pest\Console\Thanks($this->output))(); + (new Thanks($this->output))(); } } diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index 09242448..cf36319e 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -11,6 +11,7 @@ use Pest\Exceptions\TestCaseClassOrTraitNotFound; use Pest\Factories\TestCaseFactory; use Pest\Support\Str; use Pest\TestSuite; +use PHPUnit\Framework\TestCase; /** * @internal @@ -52,7 +53,7 @@ final class TestRepository if ((!is_dir($path) && $filename === $path) || (is_dir($path) && $startsWith($filename, $path))) { foreach ($classOrTraits as $class) { if (class_exists($class)) { - if ($testCase->class !== \PHPUnit\Framework\TestCase::class) { + if ($testCase->class !== TestCase::class) { throw new TestCaseAlreadyInUse($testCase->class, $class, $filename); } $testCase->class = $class; diff --git a/src/Support/ExceptionTrace.php b/src/Support/ExceptionTrace.php index 72a1d829..014b88df 100644 --- a/src/Support/ExceptionTrace.php +++ b/src/Support/ExceptionTrace.php @@ -20,7 +20,7 @@ final class ExceptionTrace * * @return mixed * - * @throws \Throwable + * @throws Throwable */ public static function ensure(Closure $closure) { diff --git a/src/Support/HigherOrderMessage.php b/src/Support/HigherOrderMessage.php index 75e351b6..9f363b5a 100644 --- a/src/Support/HigherOrderMessage.php +++ b/src/Support/HigherOrderMessage.php @@ -77,7 +77,7 @@ final class HigherOrderMessage Reflection::setPropertyValue($throwable, 'line', $this->line); if ($throwable->getMessage() === self::getUndefinedMethodMessage($target, $this->methodName)) { - /** @var \ReflectionClass $reflection */ + /** @var ReflectionClass $reflection */ $reflection = new ReflectionClass($target); /* @phpstan-ignore-next-line */ $reflection = $reflection->getParentClass() ?: $reflection; diff --git a/src/Support/HigherOrderTapProxy.php b/src/Support/HigherOrderTapProxy.php index 9e9506d2..4b5664d3 100644 --- a/src/Support/HigherOrderTapProxy.php +++ b/src/Support/HigherOrderTapProxy.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Pest\Support; use ReflectionClass; +use Throwable; /** * @internal @@ -51,12 +52,12 @@ final class HigherOrderTapProxy try { // @phpstan-ignore-next-line return $this->target->{$property}; - } catch (\Throwable $throwable) { + } catch (Throwable $throwable) { Reflection::setPropertyValue($throwable, 'file', Backtrace::file()); Reflection::setPropertyValue($throwable, 'line', Backtrace::line()); if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_PROPERTY)) { - /** @var \ReflectionClass $reflection */ + /** @var ReflectionClass $reflection */ $reflection = (new ReflectionClass($this->target))->getParentClass(); Reflection::setPropertyValue($throwable, 'message', sprintf('Undefined property %s::$%s', $reflection->getName(), $property)); } diff --git a/src/TestSuite.php b/src/TestSuite.php index b9c232b2..63e58f4e 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -10,6 +10,7 @@ use Pest\Repositories\AfterEachRepository; use Pest\Repositories\BeforeAllRepository; use Pest\Repositories\BeforeEachRepository; use Pest\Repositories\TestRepository; +use PHPUnit\Framework\TestCase; /** * @internal @@ -19,7 +20,7 @@ final class TestSuite /** * Holds the current test case. * - * @var \PHPUnit\Framework\TestCase|null + * @var TestCase|null */ public $test;