diff --git a/.gitignore b/.gitignore index 2475613d8..b07fd1d68 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,3 @@ clover.xml .env builds build - -/src/Prototype/tests/runtime/cache/ -/src/Scaffolder/tests/App/runtime/cache/ diff --git a/rector.php b/rector.php index 654e35a72..531e2f46e 100644 --- a/rector.php +++ b/rector.php @@ -3,12 +3,15 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector; +use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector; use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector; use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPublicMethodParameterRector; +use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector; use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector; use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector; use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector; @@ -17,6 +20,7 @@ return RectorConfig::configure() ->withPaths([ __DIR__ . '/src/*/src', + __DIR__ . '/src/*/tests', __DIR__ . '/tests', ]) ->withParallel() @@ -30,6 +34,7 @@ __DIR__ . '/src/Scaffolder/src/Command/FilterCommand.php', __DIR__ . '/src/Scaffolder/src/Command/JobHandlerCommand.php', __DIR__ . '/src/Scaffolder/src/Command/MiddlewareCommand.php', + __DIR__ . '/src/Console/tests/PromptArgumentsTest.php', ], RemoveUnusedPrivateMethodRector::class => [ __DIR__ . '/src/Boot/src/Bootloader/ConfigurationBootloader.php', @@ -37,6 +42,9 @@ __DIR__ . '/src/Cache/src/Bootloader/CacheBootloader.php', __DIR__ . '/src/Serializer/src/Bootloader/SerializerBootloader.php', __DIR__ . '/src/Validation/src/Bootloader/ValidationBootloader.php', + __DIR__ . '/src/Translator/tests/IndexerTest.php', + __DIR__ . '/src/Tokenizer/tests/ReflectionFileTest.php', + __DIR__ . '/src/Core/tests/SingletonsTest.php', ], RemoveUselessVarTagRector::class => [ __DIR__ . '/src/Console/src/Traits/HelpersTrait.php', @@ -54,16 +62,37 @@ ], RemoveUnusedPrivateMethodParameterRector::class => [ __DIR__ . '/src/Core/src/Internal/Factory.php', + __DIR__ . '/src/Core/tests/InjectableTest.php', + ], + RemoveDoubleAssignRector::class => [ + __DIR__ . '/src/Core/tests/Scope/FinalizeAttributeTest.php', + ], + RemoveUnusedVariableAssignRector::class => [ + __DIR__ . '/src/Core/tests/ExceptionsTest.php', + ], + RemoveDeadStmtRector::class => [ + __DIR__ . '/src/Core/tests/ExceptionsTest.php', ], - // to be enabled later after upgrade to 1.2.4 merged - // to easier to review + // to be enabled later for bc break 4.x RemoveUnusedPublicMethodParameterRector::class, RemoveEmptyClassMethodRector::class, RemoveUnusedPromotedPropertyRector::class, // start with short open tag + __DIR__ . '/src/Views/tests/fixtures/other/var.php', __DIR__ . '/tests/app/views/native.php', + + // example code for test + '*/Fixtures/*', + '*/Stub/*', + '*/Stubs/*', + '*/tests/Classes/*', + '*/tests/Internal/*', + __DIR__ . '/src/Console/tests/Configurator', + + // cache + '*/runtime/cache/*', ]) ->withPhpSets(php74: true) ->withPreparedSets(deadCode: true); diff --git a/src/AnnotatedRoutes/tests/RouteLocatorListenerTest.php b/src/AnnotatedRoutes/tests/RouteLocatorListenerTest.php index e79aa0990..506461143 100644 --- a/src/AnnotatedRoutes/tests/RouteLocatorListenerTest.php +++ b/src/AnnotatedRoutes/tests/RouteLocatorListenerTest.php @@ -54,9 +54,14 @@ private function configureRouter(): void $this->container = new Container(); $this->container->bindSingleton(UriFactoryInterface::class, new Psr17Factory()); - $this->container->bindSingleton(RouterInterface::class, static function (UriHandler $handler, Container $container) { - return new Router('/', $handler, $container); - }); + $this->container->bindSingleton( + RouterInterface::class, + static fn(UriHandler $handler, Container $container) => new Router( + '/', + $handler, + $container, + ), + ); $this->container->bindSingleton(GroupRegistry::class, new GroupRegistry($this->container)); $this->listener = new RouteLocatorListener( diff --git a/src/AuthHttp/tests/Diactoros/ResponseFactory.php b/src/AuthHttp/tests/Diactoros/ResponseFactory.php index 8b13e8d40..f4f1ae603 100644 --- a/src/AuthHttp/tests/Diactoros/ResponseFactory.php +++ b/src/AuthHttp/tests/Diactoros/ResponseFactory.php @@ -14,20 +14,12 @@ final class ResponseFactory implements ResponseFactoryInterface /** @var HttpConfig */ protected $config; - /** - * @param HttpConfig $config - */ public function __construct(HttpConfig $config) { $this->config = $config; } - /** - * @param int $code - * @param string $reasonPhrase - * - * @return ResponseInterface - */ + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { $response = new Response($code); diff --git a/src/AuthHttp/tests/Diactoros/UriFactory.php b/src/AuthHttp/tests/Diactoros/UriFactory.php index 40b88a7b0..e85fd0eca 100644 --- a/src/AuthHttp/tests/Diactoros/UriFactory.php +++ b/src/AuthHttp/tests/Diactoros/UriFactory.php @@ -10,10 +10,6 @@ final class UriFactory implements UriFactoryInterface { - /** - * @param string $uri - * @return UriInterface - */ public function createUri(string $uri = ''): UriInterface { return new Uri($uri); diff --git a/src/Boot/tests/ConfigsTest.php b/src/Boot/tests/ConfigsTest.php index b24eed86a..e8a43131b 100644 --- a/src/Boot/tests/ConfigsTest.php +++ b/src/Boot/tests/ConfigsTest.php @@ -30,7 +30,7 @@ public function testCustomConfigLoader(): void 'config' => __DIR__ . '/config', ])->run(); - /** @var ConfiguratorInterface $config */ + /** @var ConfiguratorInterface $configurator */ $configurator = $core->getContainer()->get(ConfiguratorInterface::class); $this->assertSame(['test-key' => 'test value'], $configurator->getConfig('yaml')); diff --git a/src/Boot/tests/EnvironmentTest.php b/src/Boot/tests/EnvironmentTest.php index 3b2a25859..e2e128ed0 100644 --- a/src/Boot/tests/EnvironmentTest.php +++ b/src/Boot/tests/EnvironmentTest.php @@ -84,8 +84,6 @@ public function testSetNullValueWithoutOverwriting(): void } /** - * @param array $env - * @return EnvironmentInterface * @throws \Throwable */ protected function getEnv(array $env, bool $overwite= true): EnvironmentInterface diff --git a/src/Broadcasting/tests/Middleware/AuthorizationMiddlewareTest.php b/src/Broadcasting/tests/Middleware/AuthorizationMiddlewareTest.php index e4ef2aa39..20f639785 100644 --- a/src/Broadcasting/tests/Middleware/AuthorizationMiddlewareTest.php +++ b/src/Broadcasting/tests/Middleware/AuthorizationMiddlewareTest.php @@ -151,9 +151,7 @@ public function testAuthorizationEventsShouldBeDispatched(string $event, bool $a $handler = m::mock(RequestHandlerInterface::class); $dispatcher = m::mock(EventDispatcherInterface::class); $status = new AuthorizationStatus($authStatus, ['topic_name'], ['foo' => 'bar']); - $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $e) use($event, $status) { - return $e->status === $status && $e::class === $event; - }); + $dispatcher->shouldReceive('dispatch')->once()->withArgs(fn(Authorized $e) => $e->status === $status && $e::class === $event); $middleware = new AuthorizationMiddleware( $broadcast = m::mock(BroadcastInterface::class, GuardInterface::class), @@ -179,11 +177,9 @@ public function testAuthorizationEventsWithoutGuardShouldBeDispatched(): void $request = m::mock(ServerRequestInterface::class); $handler = m::mock(RequestHandlerInterface::class); $dispatcher = m::mock(EventDispatcherInterface::class); - $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $event) { - return $event->status->success === true - && $event->status->topics === null - && $event->status->response === null; - }); + $dispatcher->shouldReceive('dispatch')->once()->withArgs(fn(Authorized $event) => $event->status->success === true + && $event->status->topics === null + && $event->status->response === null); $middleware = new AuthorizationMiddleware( m::mock(BroadcastInterface::class), diff --git a/src/Console/tests/ConfigureTest.php b/src/Console/tests/ConfigureTest.php index c3dee7cfe..d903959ff 100644 --- a/src/Console/tests/ConfigureTest.php +++ b/src/Console/tests/ConfigureTest.php @@ -125,9 +125,6 @@ public function testNoBreakFailure(): void $this->assertEquals(1, $output->getCode()); } - /** - * @return Console - */ private function bindFailure(): Console { $core = $this->getCore( diff --git a/src/Console/tests/InterceptorTest.php b/src/Console/tests/InterceptorTest.php index 0678e896a..d4299ef41 100644 --- a/src/Console/tests/InterceptorTest.php +++ b/src/Console/tests/InterceptorTest.php @@ -27,16 +27,19 @@ public function testInterceptorShouldBeResolved(): void $interceptor->shouldReceive('process') ->once() - ->withArgs(function (string $controller, string $action, array $parameters, CoreInterface $core) { - return $controller === TestCommand::class - && $action === 'perform' - && $parameters['input'] instanceof InputInterface - && $parameters['output'] instanceof OutputInterface - && $parameters['command'] instanceof TestCommand; - }) - ->andReturnUsing(function (string $controller, string $action, array $parameters, CoreInterface $core) { - return $core->callAction($controller, $action, $parameters); - }); + ->withArgs(fn(string $controller, string $action, array $parameters, CoreInterface $core) => $controller === TestCommand::class + && $action === 'perform' + && $parameters['input'] instanceof InputInterface + && $parameters['output'] instanceof OutputInterface + && $parameters['command'] instanceof TestCommand) + ->andReturnUsing( + fn( + string $controller, + string $action, + array $parameters, + CoreInterface $core, + ) => $core->callAction($controller, $action, $parameters), + ); $core = $this->getCore($this->getStaticLocator([ TestCommand::class diff --git a/src/Console/tests/UpdateTest.php b/src/Console/tests/UpdateTest.php index 254558f78..20446fdcd 100644 --- a/src/Console/tests/UpdateTest.php +++ b/src/Console/tests/UpdateTest.php @@ -122,9 +122,6 @@ public function testNoBreakFailure(): void $this->assertEquals(1, $output->getCode()); } - /** - * @return Console - */ private function bindFailure(): Console { $core = $this->getCore( diff --git a/src/Cookies/tests/CookiesTest.php b/src/Cookies/tests/CookiesTest.php index c87fc0d91..974508b3f 100644 --- a/src/Cookies/tests/CookiesTest.php +++ b/src/Cookies/tests/CookiesTest.php @@ -104,9 +104,7 @@ public function testSetNotProtectedCookie(): void public function testDecrypt(): void { $core = $this->httpCore([CookiesMiddleware::class]); - $core->setHandler(function (ServerRequestInterface $r) { - return $r->getCookieParams()['name']; - }); + $core->setHandler(fn(ServerRequestInterface $r) => $r->getCookieParams()['name']); $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value'); @@ -118,9 +116,7 @@ public function testDecrypt(): void public function testDecryptArray(): void { $core = $this->httpCore([CookiesMiddleware::class]); - $core->setHandler(function (ServerRequestInterface $r) { - return $r->getCookieParams()['name'][0]; - }); + $core->setHandler(fn(ServerRequestInterface $r) => $r->getCookieParams()['name'][0]); $value[] = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value'); @@ -132,9 +128,7 @@ public function testDecryptArray(): void public function testDecryptBroken(): void { $core = $this->httpCore([CookiesMiddleware::class]); - $core->setHandler(function (ServerRequestInterface $r) { - return $r->getCookieParams()['name']; - }); + $core->setHandler(fn(ServerRequestInterface $r) => $r->getCookieParams()['name']); $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value') . 'BROKEN'; @@ -195,9 +189,7 @@ public function testGetUnprotected(): void ])); $core = $this->httpCore([CookiesMiddleware::class]); - $core->setHandler(function (ServerRequestInterface $r) { - return $r->getCookieParams()['name']; - }); + $core->setHandler(fn(ServerRequestInterface $r) => $r->getCookieParams()['name']); $value = 'cookie-value'; @@ -228,9 +220,7 @@ public function testHMAC(): void $cookies = $this->fetchCookies($response); $this->assertArrayHasKey('name', $cookies); - $core->setHandler(function ($r) { - return $r->getCookieParams()['name']; - }); + $core->setHandler(fn($r) => $r->getCookieParams()['name']); $response = $this->get($core, '/', [], [], $cookies); $this->assertSame(200, $response->getStatusCode()); @@ -286,9 +276,9 @@ private function fetchCookies(ResponseInterface $response): array foreach ($response->getHeaders() as $line) { $cookie = explode('=', implode('', $line)); $result[$cookie[0]] = rawurldecode(substr( - (string)$cookie[1], + $cookie[1], 0, - (int)strpos((string)$cookie[1], ';') + (int)strpos($cookie[1], ';') )); } diff --git a/src/Cookies/tests/TestResponseFactory.php b/src/Cookies/tests/TestResponseFactory.php index bd7c8c7e8..ed4844669 100644 --- a/src/Cookies/tests/TestResponseFactory.php +++ b/src/Cookies/tests/TestResponseFactory.php @@ -14,20 +14,12 @@ final class TestResponseFactory implements ResponseFactoryInterface /** @var HttpConfig */ protected $config; - /** - * @param HttpConfig $config - */ public function __construct(HttpConfig $config) { $this->config = $config; } - /** - * @param int $code - * @param string $reasonPhrase - * - * @return ResponseInterface - */ + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { $response = new Response($code); diff --git a/src/Core/tests/BindingsTest.php b/src/Core/tests/BindingsTest.php index 7ca035bac..1b145df3b 100644 --- a/src/Core/tests/BindingsTest.php +++ b/src/Core/tests/BindingsTest.php @@ -20,9 +20,7 @@ public function testBasicBinding(): void $this->assertFalse($container->has('abc')); - $container->bind('abc', function () { - return 'hello'; - }); + $container->bind('abc', fn() => 'hello'); $this->assertTrue($container->has('abc')); $this->assertEquals('hello', $container->get('abc')); @@ -33,9 +31,7 @@ public function testStringBinding(): void $container = new Container(); $this->assertFalse($container->has('abc')); - $container->bind('abc', function () { - return 'hello'; - }); + $container->bind('abc', fn() => 'hello'); $container->bind('dce', 'abc'); diff --git a/src/Core/tests/InjectableTest.php b/src/Core/tests/InjectableTest.php index e9f3c9ee9..2a5eb82cc 100644 --- a/src/Core/tests/InjectableTest.php +++ b/src/Core/tests/InjectableTest.php @@ -102,9 +102,7 @@ public function testInjector(): void $container->bind(ConfigsInterface::class, $configurator); $configurator->shouldReceive('createInjection') - ->with(m::on(static function (ReflectionClass $r) { - return $r->getName() === TestConfig::class; - }), null) + ->with(m::on(static fn(ReflectionClass $r) => $r->getName() === TestConfig::class), null) ->andReturn($expected); $this->assertSame($expected, $container->get(TestConfig::class)); @@ -119,9 +117,7 @@ public function testInjectorWithContext(): void $container->bind(ConfigsInterface::class, $configurator); $configurator->shouldReceive('createInjection') - ->with(m::on(static function (ReflectionClass $r) { - return $r->getName() === TestConfig::class; - }), 'context') + ->with(m::on(static fn(ReflectionClass $r) => $r->getName() === TestConfig::class), 'context') ->andReturn($expected); $this->assertSame($expected, $container->get(TestConfig::class, 'context')); @@ -236,9 +232,6 @@ public function createInjection(\ReflectionClass $class, mixed $context = null): $this->assertInstanceOf(\ReflectionParameter::class, $result->context); } - /** - * @param TestConfig $contextArgument - */ private function methodInjection(TestConfig $contextArgument): void { } diff --git a/src/Core/tests/InvokerTest.php b/src/Core/tests/InvokerTest.php index a53bb8519..0d46dbd20 100644 --- a/src/Core/tests/InvokerTest.php +++ b/src/Core/tests/InvokerTest.php @@ -95,9 +95,7 @@ public function testCallValidClosure(): void $this->container->bindSingleton(Bucket::class, $bucket = new Bucket('foo')); $result = $this->container->invoke( - static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') { - return \compact('bucket', 'class', 'name', 'path'); - }, + static fn(Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') => \compact('bucket', 'class', 'name', 'path'), ['name' => 'bar'] ); @@ -113,9 +111,7 @@ public function testCallValidClosureWithNotResolvableDependencies(): void $this->expectExceptionMessage('Unable to resolve required argument `name` when resolving'); $this->container->invoke( - static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') { - return \compact('bucket', 'class', 'name', 'path'); - }, + static fn(Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') => \compact('bucket', 'class', 'name', 'path'), ['name' => 'bar'] ); } diff --git a/src/Core/tests/Scope/ExceptionsTest.php b/src/Core/tests/Scope/ExceptionsTest.php index dccdbf5d8..38cb1b719 100644 --- a/src/Core/tests/Scope/ExceptionsTest.php +++ b/src/Core/tests/Scope/ExceptionsTest.php @@ -15,7 +15,7 @@ final class ExceptionsTest extends BaseTestCase { public function testParentScopeResolvingCustomException(): void { - // $this->expectException(\InvalidArgumentException::class); + $this->expectException(\Exception::class); $this->expectExceptionMessage(ExceptionConstructor::MESSAGE); $container = new Container(); @@ -25,7 +25,7 @@ public function testParentScopeResolvingCustomException(): void $c1->get(ExceptionConstructor::class); self::fail('Exception should be thrown'); } catch (\Throwable $e) { - // self::assertInstanceOf(\InvalidArgumentException::class, $e); + self::assertInstanceOf(\Exception::class, $e); throw $e; } }); @@ -33,7 +33,7 @@ public function testParentScopeResolvingCustomException(): void public function testParentScopeThrowConstructorErrorOnResolving(): void { - // $this->expectException(\InvalidArgumentException::class); + $this->expectException(\Exception::class); $this->expectExceptionMessage(ExceptionConstructor::MESSAGE); $container = new Container(); @@ -43,7 +43,7 @@ public function testParentScopeThrowConstructorErrorOnResolving(): void $c1->get(ExceptionConstructor::class); self::fail('Exception should be thrown'); } catch (\Throwable $e) { - // self::assertInstanceOf(\InvalidArgumentException::class, $e); + self::assertInstanceOf(\Exception::class, $e); throw $e; } }); diff --git a/src/Core/tests/Scope/FiberHelper.php b/src/Core/tests/Scope/FiberHelper.php index 3e8b3a475..a3a7600d3 100644 --- a/src/Core/tests/Scope/FiberHelper.php +++ b/src/Core/tests/Scope/FiberHelper.php @@ -39,7 +39,6 @@ public static function runInFiber(callable $callable, ?callable $check = null): /** * Runs a sequence of callables in fibers asynchronously. * - * @param callable ...$callables * * @return array The results of each callable. */ diff --git a/src/Core/tests/Scope/FibersTest.php b/src/Core/tests/Scope/FibersTest.php index a56628139..bde3df1e7 100644 --- a/src/Core/tests/Scope/FibersTest.php +++ b/src/Core/tests/Scope/FibersTest.php @@ -92,49 +92,39 @@ public function testExceptionProxy(): void $this->expectExceptionMessage('test'); FiberHelper::runInFiber( - static function () { - return (new Container())->runScoped( - function (): string { - $result = ''; - $result .= Fiber::suspend('foo'); - $result .= Fiber::suspend('bar'); - $result .= Fiber::suspend('error'); - return $result; - } - ); - }, - static function (string $suspendValue): string { - return $suspendValue !== 'error' - ? $suspendValue - : throw new \RuntimeException('test'); - }, + static fn() => (new Container())->runScoped( + function (): string { + $result = ''; + $result .= Fiber::suspend('foo'); + $result .= Fiber::suspend('bar'); + return $result . Fiber::suspend('error'); + } + ), + static fn(string $suspendValue): string => $suspendValue !== 'error' + ? $suspendValue + : throw new \RuntimeException('test'), ); } public function testCatchThrownException(): void { $result = FiberHelper::runInFiber( - static function () { - return (new Container())->runScoped( - function (): string { - $result = ''; - $result .= Fiber::suspend('foo'); - $result .= Fiber::suspend('bar'); - try { - $result .= Fiber::suspend('error'); - } catch (\Throwable $e) { - $result .= $e->getMessage(); - } - $result .= Fiber::suspend('baz'); - return $result; + static fn() => (new Container())->runScoped( + function (): string { + $result = ''; + $result .= Fiber::suspend('foo'); + $result .= Fiber::suspend('bar'); + try { + $result .= Fiber::suspend('error'); + } catch (\Throwable $e) { + $result .= $e->getMessage(); } - ); - }, - static function (string $suspendValue): string { - return $suspendValue !== 'error' - ? $suspendValue - : throw new \RuntimeException('test'); - }, + return $result . Fiber::suspend('baz'); + } + ), + static fn(string $suspendValue): string => $suspendValue !== 'error' + ? $suspendValue + : throw new \RuntimeException('test'), ); self::assertSame('foobartestbaz', $result); diff --git a/src/Core/tests/ScopesTest.php b/src/Core/tests/ScopesTest.php index 2780594e2..1f61afaab 100644 --- a/src/Core/tests/ScopesTest.php +++ b/src/Core/tests/ScopesTest.php @@ -21,9 +21,7 @@ public function testScope(): void $this->assertNull(ContainerScope::getContainer()); - $this->assertTrue(ContainerScope::runScope($container, function () use ($container) { - return $container === ContainerScope::getContainer(); - })); + $this->assertTrue(ContainerScope::runScope($container, fn() => $container === ContainerScope::getContainer())); $this->assertNull(ContainerScope::getContainer()); } @@ -108,9 +106,13 @@ public function testContainerInScope(): void ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container) ); - $result = ContainerScope::runScope($container, static function (Container $container) { - return $container->runScope([], static fn (Container $container) => $container); - }); + $result = ContainerScope::runScope( + $container, + static fn(Container $container) => $container->runScope( + [], + static fn (Container $container) => $container, + ), + ); $this->assertSame($container, $result); } diff --git a/src/Core/tests/SingletonsTest.php b/src/Core/tests/SingletonsTest.php index 535a4ffd9..382e9c536 100644 --- a/src/Core/tests/SingletonsTest.php +++ b/src/Core/tests/SingletonsTest.php @@ -58,9 +58,7 @@ public function testSingletonClosure(): void $instance = new SampleClass(); - $container->bindSingleton('sampleClass', function () use ($instance) { - return $instance; - }); + $container->bindSingleton('sampleClass', fn() => $instance); $this->assertSame($instance, $container->get('sampleClass')); } @@ -69,9 +67,7 @@ public function testSingletonClosureTwice(): void { $container = new Container(); - $container->bindSingleton('sampleClass', function () { - return new SampleClass(); - }); + $container->bindSingleton('sampleClass', fn() => new SampleClass()); $instance = $container->get('sampleClass'); @@ -143,9 +139,7 @@ public function testDelayedSingleton(): void $container = new Container(); $container->bindSingleton('singleton', 'sampleClass'); - $container->bind('sampleClass', function () { - return new SampleClass(); - }); + $container->bind('sampleClass', fn() => new SampleClass()); $instance = $container->get('singleton'); diff --git a/src/Csrf/tests/CsrfTest.php b/src/Csrf/tests/CsrfTest.php index 9888cab99..01e5701e3 100644 --- a/src/Csrf/tests/CsrfTest.php +++ b/src/Csrf/tests/CsrfTest.php @@ -51,9 +51,7 @@ public function testGet(): void { $core = $this->httpCore([CsrfMiddleware::class]); $core->setHandler( - static function ($r) { - return $r->getAttribute(CsrfMiddleware::ATTRIBUTE); - } + static fn($r) => $r->getAttribute(CsrfMiddleware::ATTRIBUTE) ); $response = $this->get($core, '/'); @@ -81,21 +79,17 @@ public function testLengthException(): void $core = $this->httpCore([CsrfMiddleware::class]); $core->setHandler( - static function () { - return 'all good'; - } + static fn() => 'all good' ); - $response = $this->get($core, '/'); + $this->get($core, '/'); } public function testPostForbidden(): void { $core = $this->httpCore([CsrfMiddleware::class, CsrfFirewall::class]); $core->setHandler( - static function () { - return 'all good'; - } + static fn() => 'all good' ); $response = $this->post($core, '/'); @@ -107,21 +101,17 @@ public function testLogicException(): void $this->expectException(\LogicException::class); $core = $this->httpCore([CsrfFirewall::class]); $core->setHandler( - static function () { - return 'all good'; - } + static fn() => 'all good' ); - $response = $this->post($core, '/'); + $this->post($core, '/'); } public function testPostOK(): void { $core = $this->httpCore([CsrfMiddleware::class, CsrfFirewall::class]); $core->setHandler( - static function () { - return 'all good'; - } + static fn() => 'all good' ); $response = $this->get($core, '/'); @@ -152,9 +142,7 @@ public function testHeaderOK(): void { $core = $this->httpCore([CsrfMiddleware::class, CsrfFirewall::class]); $core->setHandler( - static function () { - return 'all good'; - } + static fn() => 'all good' ); $response = $this->get($core, '/'); @@ -185,9 +173,7 @@ public function testHeaderOKStrict(): void { $core = $this->httpCore([CsrfMiddleware::class, StrictCsrfFirewall::class]); $core->setHandler( - static function () { - return 'all good'; - } + static fn() => 'all good' ); $response = $this->get($core, '/'); @@ -274,7 +260,7 @@ private function fetchCookies(ResponseInterface $response): array foreach ($response->getHeaders() as $header) { foreach ($header as $headerLine) { $chunk = explode(';', $headerLine); - if (!count($chunk) || mb_strpos($chunk[0], '=') === false) { + if (mb_strpos($chunk[0], '=') === false) { continue; } diff --git a/src/Csrf/tests/TestResponseFactory.php b/src/Csrf/tests/TestResponseFactory.php index 99af44c6d..718dc9ff2 100644 --- a/src/Csrf/tests/TestResponseFactory.php +++ b/src/Csrf/tests/TestResponseFactory.php @@ -13,20 +13,12 @@ final class TestResponseFactory implements ResponseFactoryInterface { protected readonly HttpConfig $config; - /** - * @param HttpConfig $config - */ public function __construct(HttpConfig $config) { $this->config = $config; } - /** - * @param int $code - * @param string $reasonPhrase - * - * @return ResponseInterface - */ + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { $response = new Response($code); diff --git a/src/Distribution/tests/TestCase.php b/src/Distribution/tests/TestCase.php index 5814962d5..bb90c87af 100644 --- a/src/Distribution/tests/TestCase.php +++ b/src/Distribution/tests/TestCase.php @@ -13,10 +13,6 @@ */ abstract class TestCase extends BaseTestCase { - /** - * @param string $uri - * @return UriInterface - */ protected function uri(string $uri): UriInterface { return new Uri($uri); diff --git a/src/Encrypter/tests/EncrypterTest.php b/src/Encrypter/tests/EncrypterTest.php index 54313d7b1..b4209701a 100644 --- a/src/Encrypter/tests/EncrypterTest.php +++ b/src/Encrypter/tests/EncrypterTest.php @@ -62,7 +62,7 @@ public function testBadKey(): void { $this->expectException(EncrypterException::class); - $encrypter = new Encrypter('bad-key'); + new Encrypter('bad-key'); } public function testBadWithKey(): void @@ -70,6 +70,6 @@ public function testBadWithKey(): void $this->expectException(EncrypterException::class); $encrypter = new Encrypter(Key::CreateNewRandomKey()->saveToAsciiSafeString()); - $encrypter = $encrypter->withKey('bad-key'); + $encrypter->withKey('bad-key'); } } diff --git a/src/Events/tests/Processor/AttributeProcessorTest.php b/src/Events/tests/Processor/AttributeProcessorTest.php index 71b6b641c..fb8361fcb 100644 --- a/src/Events/tests/Processor/AttributeProcessorTest.php +++ b/src/Events/tests/Processor/AttributeProcessorTest.php @@ -51,7 +51,7 @@ public function testEventListenerShouldNotBeRegisteredWithListenerRegistry(): vo ->once() ->withArgs(fn (AttributeProcessor $attributeProcessor) => true); - $processor = new AttributeProcessor($tokenizerRegistry, $reader, $factory, $listenerRegistry); + new AttributeProcessor($tokenizerRegistry, $reader, $factory, $listenerRegistry); } public function testEventListenerShouldThrowAnExceptionWhenListenerNotFinalized(): void diff --git a/src/Http/tests/Diactoros/ResponseFactory.php b/src/Http/tests/Diactoros/ResponseFactory.php index 5718a4ded..0ab6dedec 100644 --- a/src/Http/tests/Diactoros/ResponseFactory.php +++ b/src/Http/tests/Diactoros/ResponseFactory.php @@ -14,20 +14,11 @@ final class ResponseFactory implements ResponseFactoryInterface /** @var HttpConfig */ protected $config; - /** - * @param HttpConfig $config - */ public function __construct(HttpConfig $config) { $this->config = $config; } - /** - * @param int $code - * @param string $reasonPhrase - * - * @return ResponseInterface - */ public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { $response = new Response($code); diff --git a/src/Http/tests/Diactoros/ServerRequestFactory.php b/src/Http/tests/Diactoros/ServerRequestFactory.php index 6ab3f86fa..3f4fa2ed9 100644 --- a/src/Http/tests/Diactoros/ServerRequestFactory.php +++ b/src/Http/tests/Diactoros/ServerRequestFactory.php @@ -12,10 +12,7 @@ final class ServerRequestFactory implements ServerRequestFactoryInterface { /** - * @param string $method * @param UriInterface|string $uri - * @param array $serverParams - * @return ServerRequestInterface */ public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface { diff --git a/src/Http/tests/Diactoros/UriFactory.php b/src/Http/tests/Diactoros/UriFactory.php index 00d5b2303..bf3027076 100644 --- a/src/Http/tests/Diactoros/UriFactory.php +++ b/src/Http/tests/Diactoros/UriFactory.php @@ -10,10 +10,6 @@ final class UriFactory implements UriFactoryInterface { - /** - * @param string $uri - * @return UriInterface - */ public function createUri(string $uri = ''): UriInterface { return new Uri($uri); diff --git a/src/Http/tests/HttpTest.php b/src/Http/tests/HttpTest.php index 87d985dd8..72a17b632 100644 --- a/src/Http/tests/HttpTest.php +++ b/src/Http/tests/HttpTest.php @@ -47,9 +47,7 @@ public function testRunHandler(): void { $core = $this->getCore(); - $core->setHandler(function () { - return 'hello world'; - }); + $core->setHandler(fn() => 'hello world'); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame('hello world', (string)$response->getBody()); @@ -69,9 +67,7 @@ public function testHandlerInterface(): void { $core = $this->getCore(); $core->setHandler( - new CallableHandler(function () { - return 'hello world'; - }, new ResponseFactory(new HttpConfig(['headers' => []]))) + new CallableHandler(fn() => 'hello world', new ResponseFactory(new HttpConfig(['headers' => []]))) ); $response = $core->handle(new ServerRequest('GET', '')); @@ -82,9 +78,7 @@ public function testDefaultHeaders(): void { $core = $this->getCore(); - $core->setHandler(function ($req, $resp) { - return $resp->withAddedHeader('hello', 'value'); - }); + $core->setHandler(fn($req, $resp) => $resp->withAddedHeader('hello', 'value')); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); @@ -149,12 +143,10 @@ public function testJson(): void { $core = $this->getCore(); - $core->setHandler(function () { - return [ - 'status' => 404, - 'message' => 'not found', - ]; - }); + $core->setHandler(fn() => [ + 'status' => 404, + 'message' => 'not found', + ]); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame(404, $response->getStatusCode()); @@ -165,12 +157,10 @@ public function testJsonSerializable(): void { $core = $this->getCore(); - $core->setHandler(function () { - return new Json([ - 'status' => 404, - 'message' => 'not found', - ]); - }); + $core->setHandler(fn() => new Json([ + 'status' => 404, + 'message' => 'not found', + ])); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame(404, $response->getStatusCode()); @@ -181,9 +171,7 @@ public function testMiddleware(): void { $core = $this->getCore([HeaderMiddleware::class]); - $core->setHandler(function () { - return 'hello?'; - }); + $core->setHandler(fn() => 'hello?'); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); @@ -198,9 +186,7 @@ public function testMiddlewareTrait(): void $core->getPipeline()->pushMiddleware(new Header2Middleware()); $core->getPipeline()->riseMiddleware(new HeaderMiddleware()); - $core->setHandler(function () { - return 'hello?'; - }); + $core->setHandler(fn() => 'hello?'); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); @@ -215,9 +201,7 @@ public function testMiddlewareTraitReversed(): void $core->getPipeline()->pushMiddleware(new HeaderMiddleware()); $core->getPipeline()->riseMiddleware(new Header2Middleware()); - $core->setHandler(function () { - return 'hello?'; - }); + $core->setHandler(fn() => 'hello?'); $response = $core->handle(new ServerRequest('GET', '')); $this->assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); @@ -253,9 +237,7 @@ public function testEventsShouldBeDispatched(): void $core = $this->getCore(); - $core->setHandler(function () { - return 'hello world'; - }); + $core->setHandler(fn() => 'hello world'); $response = $core->handle($request); $this->assertSame('hello world', (string)$response->getBody()); @@ -274,9 +256,7 @@ public function testPassingTracerIntoScope(): void $tracerFactory = m::mock(TracerFactoryInterface::class), ); - $http->setHandler(function () { - return 'hello world'; - }); + $http->setHandler(fn() => 'hello world'); $tracerFactory ->shouldReceive('make') @@ -339,9 +319,7 @@ function ($name, $callback, $attributes, $scoped, $traceKind) { $tracerFactory, ); - $http->setHandler(function () { - return 'hello world'; - }); + $http->setHandler(fn() => 'hello world'); $response = $http->handle($request); $this->assertSame('hello world', (string)$response->getBody()); @@ -360,9 +338,7 @@ public function testTraceContextIsAppliedToResponse(): void $tracerFactory = m::mock(TracerFactoryInterface::class), ); - $http->setHandler(function () { - return 'hello world'; - }); + $http->setHandler(fn() => 'hello world'); $tracerFactory ->shouldReceive('make') @@ -372,9 +348,11 @@ public function testTraceContextIsAppliedToResponse(): void $tracer ->shouldReceive('trace') ->once() - ->andReturnUsing(function($name, $callback, $attributes, $scoped, $traceKind) { - return $this->container->get(TracerInterface::class)->trace($name, $callback, $attributes, $scoped, $traceKind); - }); + ->andReturnUsing(fn($name, $callback, $attributes, $scoped, $traceKind) => $this + ->container + ->get(TracerInterface::class) + ->trace($name, $callback, $attributes, $scoped, $traceKind), + ); $tracer ->shouldReceive('getContext') diff --git a/src/Http/tests/PipelineTest.php b/src/Http/tests/PipelineTest.php index 492488954..6efa2fa8a 100644 --- a/src/Http/tests/PipelineTest.php +++ b/src/Http/tests/PipelineTest.php @@ -28,9 +28,7 @@ public function testTarget(): void { $pipeline = new Pipeline($this->container); - $handler = new CallableHandler(function () { - return 'response'; - }, new ResponseFactory(new HttpConfig(['headers' => []]))); + $handler = new CallableHandler(fn() => 'response', new ResponseFactory(new HttpConfig(['headers' => []]))); $response = $pipeline->withHandler($handler)->handle(new ServerRequest('GET', '')); @@ -43,9 +41,7 @@ public function testHandle(): void { $pipeline = new Pipeline($this->container); - $handler = new CallableHandler(function () { - return 'response'; - }, new ResponseFactory(new HttpConfig(['headers' => []]))); + $handler = new CallableHandler(fn() => 'response', new ResponseFactory(new HttpConfig(['headers' => []]))); $response = $pipeline->process(new ServerRequest('GET', ''), $handler); @@ -71,9 +67,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface } }; $request = new ServerRequest('GET', ''); - $handler = new CallableHandler(function () { - return 'response'; - }, new ResponseFactory(new HttpConfig(['headers' => []]))); + $handler = new CallableHandler(fn() => 'response', new ResponseFactory(new HttpConfig(['headers' => []]))); $dispatcher = $this->createMock(EventDispatcherInterface::class); $dispatcher @@ -115,9 +109,7 @@ public function process( new \Spiral\Core\Scope(name: 'http'), function (ScopeInterface $c) use ($middleware) { $request = new ServerRequest('GET', ''); - $handler = new CallableHandler(function () { - return 'response'; - }, new ResponseFactory(new HttpConfig(['headers' => []]))); + $handler = new CallableHandler(fn() => 'response', new ResponseFactory(new HttpConfig(['headers' => []]))); $pipeline = new Pipeline($c, null, new NullTracer($c)); diff --git a/src/Http/tests/ResponsesTest.php b/src/Http/tests/ResponsesTest.php index 23414f55f..e908d1526 100644 --- a/src/Http/tests/ResponsesTest.php +++ b/src/Http/tests/ResponsesTest.php @@ -43,7 +43,7 @@ public function testHtml(): void $response = $this->getWrapper()->html('hello world'); $this->assertSame('hello world', (string)$response->getBody()); $this->assertSame(200, $response->getStatusCode()); - $ff = $response->getHeader('Content-Type'); + $response->getHeader('Content-Type'); $this->assertSame(['text/html; charset=utf-8'], $response->getHeader('Content-Type')); } @@ -54,7 +54,7 @@ public function testAttachment(): void $this->assertSame(200, $response->getStatusCode()); $this->assertStringEqualsFile(__FILE__, (string)$response->getBody()); $this->assertSame(filesize(__FILE__), $response->getBody()->getSize()); - $this->assertSame('application/octet-stream', (string)$response->getHeaderLine('Content-Type')); + $this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); } public function testAttachmentResource(): void @@ -64,7 +64,7 @@ public function testAttachmentResource(): void $this->assertSame(200, $response->getStatusCode()); $this->assertStringEqualsFile(__FILE__, (string)$response->getBody()); $this->assertSame(filesize(__FILE__), $response->getBody()->getSize()); - $this->assertSame('application/octet-stream', (string)$response->getHeaderLine('Content-Type')); + $this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); } public function testAttachmentStream(): void @@ -74,7 +74,7 @@ public function testAttachmentStream(): void $this->assertSame(200, $response->getStatusCode()); $this->assertStringEqualsFile(__FILE__, (string)$response->getBody()); $this->assertSame(filesize(__FILE__), $response->getBody()->getSize()); - $this->assertSame('application/octet-stream', (string)$response->getHeaderLine('Content-Type')); + $this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); } public function testAttachmentStreamable(): void @@ -87,7 +87,7 @@ public function testAttachmentStreamable(): void $this->assertSame(200, $response->getStatusCode()); $this->assertStringEqualsFile(__FILE__, (string)$response->getBody()); $this->assertSame(filesize(__FILE__), $response->getBody()->getSize()); - $this->assertSame('application/octet-stream', (string)$response->getHeaderLine('Content-Type')); + $this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); } public function testCreate(): void diff --git a/src/Http/tests/Stream/GeneratorStreamTest.php b/src/Http/tests/Stream/GeneratorStreamTest.php index b32767dd6..bc1a7814b 100644 --- a/src/Http/tests/Stream/GeneratorStreamTest.php +++ b/src/Http/tests/Stream/GeneratorStreamTest.php @@ -48,10 +48,6 @@ public function testRewindOnInit(): void public function testRewindAfterRead(): void { - if (PHP_VERSION_ID < 80000) { - $this->markTestSkipped('See issue https://bugs.php.net/bug.php?id=79927.'); - } - $stream = $this->createStream(); $stream->read(1); $stream->read(1); diff --git a/src/Http/tests/Streamable.php b/src/Http/tests/Streamable.php index 67ce6ecc4..77e58dbb4 100644 --- a/src/Http/tests/Streamable.php +++ b/src/Http/tests/Streamable.php @@ -16,9 +16,6 @@ public function __construct(StreamInterface $stream) $this->stream = $stream; } - /** - * @return StreamInterface - */ public function getStream(): StreamInterface { return $this->stream; diff --git a/src/Interceptors/tests/Unit/Context/TargetTest.php b/src/Interceptors/tests/Unit/Context/TargetTest.php index f11c390bb..000ea67a7 100644 --- a/src/Interceptors/tests/Unit/Context/TargetTest.php +++ b/src/Interceptors/tests/Unit/Context/TargetTest.php @@ -44,10 +44,10 @@ public function testCreateFromReflectionMethodClassName(): void { $reflection = new \ReflectionMethod($this, __FUNCTION__); - $target = Target::fromReflectionMethod($reflection, __CLASS__); + $target = Target::fromReflectionMethod($reflection, self::class); self::assertSame($reflection, $target->getReflection()); - self::assertSame(__CLASS__ . '->' . __FUNCTION__, (string)$target); + self::assertSame(self::class . '->' . __FUNCTION__, (string)$target); self::assertNull($target->getObject()); } @@ -58,7 +58,7 @@ public function testCreateFromReflectionMethodObject(): void $target = Target::fromReflectionMethod($reflection, $this); self::assertSame($reflection, $target->getReflection()); - self::assertSame(__CLASS__ . '->' . __FUNCTION__, (string)$target); + self::assertSame(self::class . '->' . __FUNCTION__, (string)$target); self::assertNotNull($target->getObject()); } diff --git a/src/Interceptors/tests/Unit/Handler/InterceptorPipelineTest.php b/src/Interceptors/tests/Unit/Handler/InterceptorPipelineTest.php index 96b381db3..06f19ed8c 100644 --- a/src/Interceptors/tests/Unit/Handler/InterceptorPipelineTest.php +++ b/src/Interceptors/tests/Unit/Handler/InterceptorPipelineTest.php @@ -45,7 +45,7 @@ public function handle(CallContextInterface $context): mixed return null; } } - )->handle($context, []); + )->handle($context); } public function testCallActionWithoutCore(): void diff --git a/src/Prototype/.gitignore b/src/Prototype/.gitignore index 5b340c146..5619cadfc 100644 --- a/src/Prototype/.gitignore +++ b/src/Prototype/.gitignore @@ -17,3 +17,4 @@ Thumbs.db clover.xml .env builds +tests/runtime/ diff --git a/src/Prototype/tests/ClassNode/ConflictResolver/ConflictResolverTest.php b/src/Prototype/tests/ClassNode/ConflictResolver/ConflictResolverTest.php index ab323e01b..05da377f0 100644 --- a/src/Prototype/tests/ClassNode/ConflictResolver/ConflictResolverTest.php +++ b/src/Prototype/tests/ClassNode/ConflictResolver/ConflictResolverTest.php @@ -115,10 +115,7 @@ public function testDuplicateProperty(): void } /** - * @param string $filename - * @param array $dependencies * - * @return ClassNode * @throws \Throwable */ private function getDefinition(string $filename, array $dependencies): ClassNode @@ -127,7 +124,6 @@ private function getDefinition(string $filename, array $dependencies): ClassNode } /** - * @return NodeExtractor * @throws \Throwable */ private function getExtractor(): NodeExtractor diff --git a/src/Prototype/tests/InjectorTest.php b/src/Prototype/tests/InjectorTest.php index 9398b712c..9504643c5 100644 --- a/src/Prototype/tests/InjectorTest.php +++ b/src/Prototype/tests/InjectorTest.php @@ -273,10 +273,6 @@ public function testParentConstructorParamsTypeDefinition(): void } /** - * @param string $filename - * @param array $dependencies - * - * @return ClassNode * @throws \ReflectionException * @throws ClassNotDeclaredException */ diff --git a/src/Prototype/tests/TraitTest.php b/src/Prototype/tests/TraitTest.php index abb5753d3..c91563d88 100644 --- a/src/Prototype/tests/TraitTest.php +++ b/src/Prototype/tests/TraitTest.php @@ -57,9 +57,7 @@ public function testOK(): void $c->bindSingleton(TestClass::class, $t); $p->bindProperty('testClass', TestClass::class); - $r = ContainerScope::runScope($c, static function () use ($t) { - return $t->getTest(); - }); + $r = ContainerScope::runScope($c, static fn() => $t->getTest()); $this->assertSame($t, $r); } diff --git a/src/Prototype/tests/Traverse/ConstructorParamsVisitor.php b/src/Prototype/tests/Traverse/ConstructorParamsVisitor.php index eff54d3da..9344f0358 100644 --- a/src/Prototype/tests/Traverse/ConstructorParamsVisitor.php +++ b/src/Prototype/tests/Traverse/ConstructorParamsVisitor.php @@ -43,9 +43,6 @@ public function leaveNode(Node $node): void } } - /** - * @return array - */ public function getParams(): array { return $this->params; diff --git a/src/Prototype/tests/Traverse/Extractor.php b/src/Prototype/tests/Traverse/Extractor.php index 3148b22ad..d681f9b82 100644 --- a/src/Prototype/tests/Traverse/Extractor.php +++ b/src/Prototype/tests/Traverse/Extractor.php @@ -19,19 +19,11 @@ public function __construct(Parser $parser = null) $this->parser = $parser ?? (new ParserFactory())->create(ParserFactory::ONLY_PHP7); } - /** - * @param string $filename - * @return array - */ public function extractFromFilename(string $filename): array { return $this->extractFromString(file_get_contents($filename)); } - /** - * @param string $code - * @return array - */ public function extractFromString(string $code): array { $params = new ConstructorParamsVisitor(); @@ -40,10 +32,6 @@ public function extractFromString(string $code): array return $params->getParams(); } - /** - * @param string $code - * @param NodeVisitor ...$visitors - */ private function traverse(string $code, NodeVisitor ...$visitors): void { $tr = new NodeTraverser(); diff --git a/src/Queue/tests/Interceptor/Push/CoreTest.php b/src/Queue/tests/Interceptor/Push/CoreTest.php index ebe9067b4..97812d506 100644 --- a/src/Queue/tests/Interceptor/Push/CoreTest.php +++ b/src/Queue/tests/Interceptor/Push/CoreTest.php @@ -30,9 +30,10 @@ public function testCallActionWithNullOptions(mixed $payload): void } $queue->shouldReceive('push')->once() - ->withArgs(function (string $name, mixed $p = [], OptionsInterface $options = null) use($payload) { - return $name === 'foo' && $payload === $p && $options instanceof Options; - }); + ->withArgs(fn(string $name, mixed $p = [], OptionsInterface $options = null) => $name === 'foo' + && $payload === $p + && $options instanceof Options, + ); $core->callAction('foo', 'bar', [ 'id' => 'job-id', @@ -76,16 +77,12 @@ public function testCallWithTracerContext(): void $tracer->shouldReceive('getContext')->once()->andReturn(['foo' => ['bar']]); - $tracer->shouldReceive('trace')->once()->andReturnUsing(function ($name, $callback) { - return $callback(); - }); + $tracer->shouldReceive('trace')->once()->andReturnUsing(fn($name, $callback) => $callback()); $queue->shouldReceive('push')->once() - ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) { - return $name === 'foo' - && $payload === ['baz' => 'baf'] - && $options->getHeader('foo') === ['bar']; - }); + ->withArgs(fn(string $name, array $payload = [], OptionsInterface $options = null) => $name === 'foo' + && $payload === ['baz' => 'baf'] + && $options->getHeader('foo') === ['bar']); ContainerScope::runScope($container, function() use($core) { $core->callAction('foo', 'bar', [ @@ -106,11 +103,9 @@ public function testCallWithTracerContextWitoutOptionsWithHeadersSupport(): void $tracer->shouldNotReceive('getContext'); $queue->shouldReceive('push')->once() - ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) { - return $name === 'foo' - && $payload === ['baz' => 'baf'] - && $options !== null; - }); + ->withArgs(fn(string $name, array $payload = [], OptionsInterface $options = null) => $name === 'foo' + && $payload === ['baz' => 'baf'] + && $options !== null); $core->callAction('foo', 'bar', [ 'id' => 'job-id', diff --git a/src/Router/tests/CallableTest.php b/src/Router/tests/CallableTest.php index d7cb78991..d283c5324 100644 --- a/src/Router/tests/CallableTest.php +++ b/src/Router/tests/CallableTest.php @@ -16,9 +16,7 @@ public function testFunctionRoute(): void $router = $this->makeRouter(); $router->setRoute( 'action', - new Route('/something', function () { - return 'hello world'; - }) + new Route('/something', fn() => 'hello world') ); $response = $router->handle(new ServerRequest('GET', new Uri('/something'))); diff --git a/src/Router/tests/CoreTest.php b/src/Router/tests/CoreTest.php index fb8977cc7..e31b8c16e 100644 --- a/src/Router/tests/CoreTest.php +++ b/src/Router/tests/CoreTest.php @@ -95,7 +95,7 @@ public function testForbidden(): void $this->expectException(ForbiddenException::class); $action = new Action(TestController::class, 'forbidden'); - $r = $action->getHandler($this->container, [])->handle(new ServerRequest('GET', '')); + $action->getHandler($this->container, [])->handle(new ServerRequest('GET', '')); } public function testNotFound(): void @@ -103,7 +103,7 @@ public function testNotFound(): void $this->expectException(NotFoundException::class); $action = new Action(TestController::class, 'not-found'); - $r = $action->getHandler($this->container, [])->handle(new ServerRequest('GET', '')); + $action->getHandler($this->container, [])->handle(new ServerRequest('GET', '')); } public function testBadRequest(): void @@ -111,7 +111,7 @@ public function testBadRequest(): void $this->expectException(BadRequestException::class); $action = new Action(TestController::class, 'weird'); - $r = $action->getHandler($this->container, [])->handle(new ServerRequest('GET', '')); + $action->getHandler($this->container, [])->handle(new ServerRequest('GET', '')); } public function testCoreException(): void diff --git a/src/Router/tests/Diactoros/ResponseFactory.php b/src/Router/tests/Diactoros/ResponseFactory.php index 80e467406..ae6d5c579 100644 --- a/src/Router/tests/Diactoros/ResponseFactory.php +++ b/src/Router/tests/Diactoros/ResponseFactory.php @@ -14,20 +14,11 @@ final class ResponseFactory implements ResponseFactoryInterface /** @var HttpConfig */ protected $config; - /** - * @param HttpConfig $config - */ public function __construct(HttpConfig $config) { $this->config = $config; } - /** - * @param int $code - * @param string $reasonPhrase - * - * @return ResponseInterface - */ public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { $response = new Response($code); diff --git a/src/Router/tests/Diactoros/ServerRequestFactory.php b/src/Router/tests/Diactoros/ServerRequestFactory.php index a4b928d78..e749f7fd7 100644 --- a/src/Router/tests/Diactoros/ServerRequestFactory.php +++ b/src/Router/tests/Diactoros/ServerRequestFactory.php @@ -12,10 +12,7 @@ final class ServerRequestFactory implements ServerRequestFactoryInterface { /** - * @param string $method * @param UriInterface|string $uri - * @param array $serverParams - * @return ServerRequestInterface */ public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface { diff --git a/src/Router/tests/Diactoros/UriFactory.php b/src/Router/tests/Diactoros/UriFactory.php index d62ee804f..ee402d476 100644 --- a/src/Router/tests/Diactoros/UriFactory.php +++ b/src/Router/tests/Diactoros/UriFactory.php @@ -10,10 +10,6 @@ final class UriFactory implements UriFactoryInterface { - /** - * @param string $uri - * @return UriInterface - */ public function createUri(string $uri = ''): UriInterface { return new Uri($uri); diff --git a/src/Router/tests/GroupTest.php b/src/Router/tests/GroupTest.php index bfe99e9fa..562a1462f 100644 --- a/src/Router/tests/GroupTest.php +++ b/src/Router/tests/GroupTest.php @@ -76,7 +76,7 @@ public function testUriInvalid(): void ])) ); - $uri = $router->uri('group/test'); + $router->uri('group/test'); } public function testUriInvalidNoAction(): void @@ -91,7 +91,7 @@ public function testUriInvalidNoAction(): void ])) ); - $uri = $router->getRoute('group')->uri(['controller' => 'test']); + $router->getRoute('group')->uri(['controller' => 'test']); } public function testClientException(): void diff --git a/src/Router/tests/HostsTest.php b/src/Router/tests/HostsTest.php index 54e730529..bbdc302ec 100644 --- a/src/Router/tests/HostsTest.php +++ b/src/Router/tests/HostsTest.php @@ -22,7 +22,7 @@ public function testRouteException(): void new Action(TestController::class, 'test') )); - $match = $router->handle(new ServerRequest('GET', '')); + $router->handle(new ServerRequest('GET', '')); } public function testRoute(): void diff --git a/src/Router/tests/PipelineFactoryTest.php b/src/Router/tests/PipelineFactoryTest.php index f090717e3..1725da574 100644 --- a/src/Router/tests/PipelineFactoryTest.php +++ b/src/Router/tests/PipelineFactoryTest.php @@ -82,9 +82,7 @@ public function testCreates(): void new Autowire('bar'), ])); - $handle = function (ServerRequestInterface $request, RequestHandlerInterface $handler) { - return $handler->handle($request); - }; + $handle = fn(ServerRequestInterface $request, RequestHandlerInterface $handler) => $handler->handle($request); $middleware1->expects($this->once())->method('process')->willReturnCallback($handle); $middleware2->expects($this->once())->method('process')->willReturnCallback($handle); diff --git a/src/Scaffolder/.gitignore b/src/Scaffolder/.gitignore index 5b340c146..72eb60cb4 100644 --- a/src/Scaffolder/.gitignore +++ b/src/Scaffolder/.gitignore @@ -17,3 +17,4 @@ Thumbs.db clover.xml .env builds +tests/App/runtime/ diff --git a/src/Scaffolder/tests/App/Command/CommandWithNamespace.php b/src/Scaffolder/tests/App/Command/CommandWithNamespace.php index 287f45c1c..e33f6defc 100644 --- a/src/Scaffolder/tests/App/Command/CommandWithNamespace.php +++ b/src/Scaffolder/tests/App/Command/CommandWithNamespace.php @@ -35,7 +35,7 @@ final class CommandWithNamespace extends AbstractCommand public function __invoke(): int { - $declaration = $this->createDeclaration(CommandDeclaration::class); + $this->createDeclaration(CommandDeclaration::class); return self::SUCCESS; } diff --git a/src/Scaffolder/tests/App/Command/CommandWithoutNamespace.php b/src/Scaffolder/tests/App/Command/CommandWithoutNamespace.php index 729752776..524bd3bdf 100644 --- a/src/Scaffolder/tests/App/Command/CommandWithoutNamespace.php +++ b/src/Scaffolder/tests/App/Command/CommandWithoutNamespace.php @@ -19,7 +19,7 @@ final class CommandWithoutNamespace extends AbstractCommand public function __invoke(): int { - $declaration = $this->createDeclaration(CommandDeclaration::class); + $this->createDeclaration(CommandDeclaration::class); return self::SUCCESS; } diff --git a/src/Scaffolder/tests/App/TestApp.php b/src/Scaffolder/tests/App/TestApp.php index 8ac122ac1..a4e4d312e 100644 --- a/src/Scaffolder/tests/App/TestApp.php +++ b/src/Scaffolder/tests/App/TestApp.php @@ -18,7 +18,6 @@ class TestApp extends Boot\AbstractKernel ]; /** - * @param string $target * @return mixed|object|null * @throws Throwable */ @@ -33,8 +32,6 @@ public function getContainer(): Container } /** - * @param string $directory - * @return string * @throws Throwable */ public function directory(string $directory): string @@ -54,9 +51,6 @@ protected function bootstrap(): void /** * Normalizes directory list and adds all required aliases. - * - * @param array $directories - * @return array */ protected function mapDirectories(array $directories): array { diff --git a/src/Scaffolder/tests/Command/AbstractCommandTestCase.php b/src/Scaffolder/tests/Command/AbstractCommandTestCase.php index b9015b3f7..cda544ee3 100644 --- a/src/Scaffolder/tests/Command/AbstractCommandTestCase.php +++ b/src/Scaffolder/tests/Command/AbstractCommandTestCase.php @@ -14,9 +14,6 @@ abstract class AbstractCommandTestCase extends BaseTestCase { protected ?string $className = null; - /** - * @param string $class - */ protected function deleteDeclaration(string $class): void { if (class_exists($class)) { @@ -30,7 +27,6 @@ protected function deleteDeclaration(string $class): void } /** - * @return Console * @throws Throwable */ protected function console(): Console @@ -39,7 +35,6 @@ protected function console(): Console } /** - * @return FilesInterface * @throws Throwable */ protected function files(): FilesInterface diff --git a/src/Scaffolder/tests/Command/BootloaderTest.php b/src/Scaffolder/tests/Command/BootloaderTest.php index 9014d70b9..fe5e8f675 100644 --- a/src/Scaffolder/tests/Command/BootloaderTest.php +++ b/src/Scaffolder/tests/Command/BootloaderTest.php @@ -90,7 +90,7 @@ public function testScaffoldForDomainBootloader(): void $content = $this->files()->read($reflection->getFileName()); $this->assertStringContainsString( - 'Spiral\Bootloader\DomainBootloader', + \Spiral\Bootloader\DomainBootloader::class, $content ); diff --git a/src/Scaffolder/tests/Command/ConfigTest.php b/src/Scaffolder/tests/Command/ConfigTest.php index cce5a69e5..b07eefa40 100644 --- a/src/Scaffolder/tests/Command/ConfigTest.php +++ b/src/Scaffolder/tests/Command/ConfigTest.php @@ -17,7 +17,7 @@ class ConfigTest extends AbstractCommandTestCase */ public function testScaffold(): void { - $this->className = $class = '\\Spiral\\Tests\\Scaffolder\\App\\Config\\SampleConfig'; + $this->className = $class = \Spiral\Tests\Scaffolder\App\Config\SampleConfig::class; $this->console()->run('create:config', [ 'name' => 'sample', @@ -256,7 +256,6 @@ public function testShowInstructionAfterInstallation(): void } /** - * @param string $filename * @throws Throwable */ private function deleteConfigFile(string $filename): void @@ -265,9 +264,6 @@ private function deleteConfigFile(string $filename): void } /** - * @param string $name - * @param string $comment - * @return string * @throws Throwable */ private function createConfig(string $name, string $comment): string diff --git a/src/Security/tests/RuleManagerTest.php b/src/Security/tests/RuleManagerTest.php index 7e53b3e52..cbe16b1cc 100644 --- a/src/Security/tests/RuleManagerTest.php +++ b/src/Security/tests/RuleManagerTest.php @@ -52,9 +52,7 @@ public function testFlow(): void // other rule types $manager->set('RuleInterface', $this->rule); $this->assertEquals($this->rule, $manager->get('RuleInterface')); - $manager->set('Closure', function () { - return true; - }); + $manager->set('Closure', fn() => true); $this->assertTrue($manager->get('Closure') instanceof CallableRule); $manager->set('Array', [$this, 'testFlow']); $this->assertTrue($manager->get('Array') instanceof CallableRule); diff --git a/src/Security/tests/Rules/CompositeRuleTest.php b/src/Security/tests/Rules/CompositeRuleTest.php index 9c998cab5..29eb8426a 100644 --- a/src/Security/tests/Rules/CompositeRuleTest.php +++ b/src/Security/tests/Rules/CompositeRuleTest.php @@ -53,11 +53,7 @@ public static function allowsProvider(): \Traversable yield [false, OneCompositeRule::class, [$forbidRule, $forbidRule, $forbidRule]]; } - /** - * @param array $rules - * - * @return RulesInterface - */ + private function createRepository(array $rules): RulesInterface { /** @var \PHPUnit_Framework_MockObject_MockObject|RulesInterface $repository */ diff --git a/src/SendIt/tests/App/App.php b/src/SendIt/tests/App/App.php index 6b4dcb23d..b25924e45 100644 --- a/src/SendIt/tests/App/App.php +++ b/src/SendIt/tests/App/App.php @@ -23,8 +23,6 @@ class App extends Kernel ]; /** - * @param MessageInterface $message - * @return Email * @throws \Throwable */ public function send(MessageInterface $message): Email diff --git a/src/SendIt/tests/JobTest.php b/src/SendIt/tests/JobTest.php index 028049af5..6a1497a2d 100644 --- a/src/SendIt/tests/JobTest.php +++ b/src/SendIt/tests/JobTest.php @@ -130,14 +130,12 @@ function (Message $message) { private function getHandler(?EventDispatcherInterface $dispatcher = null): MailJob { - $handler = new MailJob( + return new MailJob( new MailerConfig(['from' => 'no-reply@spiral.dev']), $this->mailer, $this->renderer, $dispatcher ); - - return $handler; } private function getMail(): Message diff --git a/src/Stempler/tests/Compiler/BaseTestCase.php b/src/Stempler/tests/Compiler/BaseTestCase.php index 7aec8dc39..69cd3ca88 100644 --- a/src/Stempler/tests/Compiler/BaseTestCase.php +++ b/src/Stempler/tests/Compiler/BaseTestCase.php @@ -20,10 +20,6 @@ abstract class BaseTestCase extends TestCase /* RENDERER */ ]; - /** - * @param Template $document - * @return string - */ protected function compile(Template $document): string { $compiler = new Compiler(); @@ -34,10 +30,6 @@ protected function compile(Template $document): string return $compiler->compile($document)->getContent(); } - /** - * @param string $string - * @return Template - */ protected function parse(string $string): Template { $parser = new Parser(); diff --git a/src/Stempler/tests/Directive/BaseTestCase.php b/src/Stempler/tests/Directive/BaseTestCase.php index 1349f14a6..2a8111c6f 100644 --- a/src/Stempler/tests/Directive/BaseTestCase.php +++ b/src/Stempler/tests/Directive/BaseTestCase.php @@ -28,10 +28,6 @@ abstract class BaseTestCase extends \Spiral\Tests\Stempler\Compiler\BaseTestCase protected const DIRECTIVES = []; - /** - * @param Template $document - * @return string - */ protected function compile(Template $document): string { $compiler = new Compiler(); diff --git a/src/Stempler/tests/Directive/OnlyKnownTest.php b/src/Stempler/tests/Directive/OnlyKnownTest.php index 8011dde63..0e2913fae 100644 --- a/src/Stempler/tests/Directive/OnlyKnownTest.php +++ b/src/Stempler/tests/Directive/OnlyKnownTest.php @@ -30,10 +30,6 @@ public function testForeachEndForeach(): void ); } - /** - * @param string $string - * @return Template - */ protected function parse(string $string): Template { $parser = new Parser(); diff --git a/src/Stempler/tests/Grammar/BaseTestCase.php b/src/Stempler/tests/Grammar/BaseTestCase.php index 31014bb49..db130aebd 100644 --- a/src/Stempler/tests/Grammar/BaseTestCase.php +++ b/src/Stempler/tests/Grammar/BaseTestCase.php @@ -12,10 +12,6 @@ abstract class BaseTestCase extends TestCase { protected const GRAMMARS = []; - /** - * @param array $tokens - * @param string $source - */ protected function assertTokens(array $tokens, string $source): void { $parsed = $this->tokens($source); diff --git a/src/Stempler/tests/Syntax/BaseTestCase.php b/src/Stempler/tests/Syntax/BaseTestCase.php index 68708a5b7..61d46cf22 100644 --- a/src/Stempler/tests/Syntax/BaseTestCase.php +++ b/src/Stempler/tests/Syntax/BaseTestCase.php @@ -15,10 +15,6 @@ abstract class BaseTestCase extends TestCase /* GRAMMAR => SYNTAX */ ]; - /** - * @param string $string - * @return Template - */ protected function parse(string $string): Template { $parser = new Parser(); diff --git a/src/Stempler/tests/Transform/AttributesTest.php b/src/Stempler/tests/Transform/AttributesTest.php index 7c923c5d5..f1868d38b 100644 --- a/src/Stempler/tests/Transform/AttributesTest.php +++ b/src/Stempler/tests/Transform/AttributesTest.php @@ -16,7 +16,7 @@ class AttributesTest extends BaseTestCase { public function testAggregatedAttribute(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -36,7 +36,7 @@ public function testAggregatedAttribute(): void public function testAggregatedAttributePattern(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -57,7 +57,7 @@ public function testAggregatedAttributePattern(): void public function testAggregateInclude(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -78,7 +78,7 @@ public function testAggregateInclude(): void public function testAggregateExclude(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -99,7 +99,7 @@ public function testAggregateExclude(): void public function testAggregateSimple(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -120,7 +120,7 @@ public function testAggregateSimple(): void public function testAggregateVoid(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -140,7 +140,7 @@ public function testAggregateVoid(): void public function testAggregateBlock(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -161,7 +161,7 @@ public function testAggregateBlock(): void public function testAggregatePHP(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -182,7 +182,7 @@ public function testAggregatePHP(): void public function testAggregateVerbatim(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -202,7 +202,7 @@ public function testAggregateVerbatim(): void public function testEqualsToPHP(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '/>' diff --git a/src/Stempler/tests/Transform/BaseTestCase.php b/src/Stempler/tests/Transform/BaseTestCase.php index 4fee4829e..381179c83 100644 --- a/src/Stempler/tests/Transform/BaseTestCase.php +++ b/src/Stempler/tests/Transform/BaseTestCase.php @@ -39,7 +39,7 @@ protected function compile(string $source, array $visitors = [], LoaderInterface protected function parse(string $source, array $visitors = [], LoaderInterface $loader = null) { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', $source); $builder = $this->getBuilder($loader, $visitors); @@ -78,9 +78,6 @@ protected function getVisitors(): array return []; } - /** - * @return LoaderInterface - */ protected function getFixtureLoader(): LoaderInterface { return new DirectoryLoader(__DIR__ . '/../fixtures'); diff --git a/src/Stempler/tests/Transform/ExtendsTest.php b/src/Stempler/tests/Transform/ExtendsTest.php index 97b2f7a5e..b790fec16 100644 --- a/src/Stempler/tests/Transform/ExtendsTest.php +++ b/src/Stempler/tests/Transform/ExtendsTest.php @@ -18,7 +18,7 @@ class ExtendsTest extends BaseTestCase { public function testNoExtends(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello world'); $builder = $this->getBuilder($loader, []); @@ -31,7 +31,7 @@ public function testNoExtends(): void public function testExtendsParent(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello world'); $loader->set('parent', 'parent world'); @@ -45,7 +45,7 @@ public function testExtendsParent(): void public function testExtendsParentBlock(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello ${parent}'); $loader->set('parent', 'parent world'); @@ -59,7 +59,7 @@ public function testExtendsParentBlock(): void public function testExtendsParentBlockWithNoAttribute(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello ${parent}'); $loader->set('parent', 'parent world'); @@ -73,7 +73,7 @@ public function testExtendsParentBlockWithNoAttribute(): void public function testExtendsParentBlockWithAttribute(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello ${parent}'); $loader->set('parent', 'parent world'); @@ -87,7 +87,7 @@ public function testExtendsParentBlockWithAttribute(): void public function testExtendsAttribute(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello ${parent}'); $loader->set('parent', 'parent world'); @@ -101,7 +101,7 @@ public function testExtendsAttribute(): void public function testExtendsViaPath(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello ${parent}'); $loader->set('parent', 'parent world'); @@ -115,7 +115,7 @@ public function testExtendsViaPath(): void public function testExtendsMultiple(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'root'); $loader->set('child', ''); $loader->set('parent', ''); @@ -130,7 +130,7 @@ public function testExtendsMultiple(): void public function testExtendsInline(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello root'); $loader->set('child', ''); $loader->set('parent', ''); diff --git a/src/Stempler/tests/Transform/ImportBundleTest.php b/src/Stempler/tests/Transform/ImportBundleTest.php index 1d34c0c1c..ee0760051 100644 --- a/src/Stempler/tests/Transform/ImportBundleTest.php +++ b/src/Stempler/tests/Transform/ImportBundleTest.php @@ -18,7 +18,7 @@ class ImportBundleTest extends BaseTestCase { public function testNoImport(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello world'); $loader->set('import', '${context}'); @@ -32,7 +32,7 @@ public function testNoImport(): void public function testInlineBundle(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', ' hello world @@ -56,7 +56,7 @@ public function testInlineBundle(): void public function testImportElementViaBundle(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', ' hello world diff --git a/src/Stempler/tests/Transform/ImportElementTest.php b/src/Stempler/tests/Transform/ImportElementTest.php index 7d22cb244..3b5b551a5 100644 --- a/src/Stempler/tests/Transform/ImportElementTest.php +++ b/src/Stempler/tests/Transform/ImportElementTest.php @@ -19,7 +19,7 @@ class ImportElementTest extends BaseTestCase { public function testNoImport(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello world'); $loader->set('import', '${context}'); @@ -33,7 +33,7 @@ public function testNoImport(): void public function testSimpleImport(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'hello world' @@ -50,7 +50,7 @@ public function testSimpleImport(): void public function testImportWithPHP(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'hello world' @@ -67,7 +67,7 @@ public function testImportWithPHP(): void public function testImportWithOutput(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'hello world' @@ -85,7 +85,7 @@ public function testImportWithOutput(): void public function testStringValueIntoPHP(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'hello world' @@ -104,7 +104,7 @@ public function testStringValueIntoPHP(): void public function testOutputValueIntoPHPFromAttribute(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'abc' @@ -123,7 +123,7 @@ public function testOutputValueIntoPHPFromAttribute(): void public function testOutputValueIntoPHPFromAttributeUsingOutput(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'abc' @@ -142,7 +142,7 @@ public function testOutputValueIntoPHPFromAttributeUsingOutput(): void public function testValueIntoPHPFromMultiValue(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'abc' @@ -161,7 +161,7 @@ public function testValueIntoPHPFromMultiValue(): void public function testValueIntoPHPFromMultiValueWithSpacing(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'abc' @@ -181,7 +181,7 @@ public function testValueIntoPHPFromMultiValueWithSpacing(): void public function testValueIntoPHPFromMultiValueWithSpacingAround(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -202,7 +202,7 @@ public function testValueIntoPHPFromMultiValueWithSpacingAround(): void public function testDefaultPHPValue(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -222,7 +222,7 @@ public function testDefaultPHPValue(): void public function testDefaultPHPValueArray(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' @@ -242,7 +242,7 @@ public function testDefaultPHPValueArray(): void public function testHasInjectionEmpty(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'hello world' @@ -263,7 +263,7 @@ public function testHasInjectionEmpty(): void public function testHasInjection(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'abchello world' @@ -284,7 +284,7 @@ public function testHasInjection(): void public function testParentBlock(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', 'a' @@ -300,7 +300,7 @@ public function testParentBlock(): void public function testParentBlockShort(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', '' diff --git a/src/Stempler/tests/Transform/ImportInlineTest.php b/src/Stempler/tests/Transform/ImportInlineTest.php index c82d1278f..5cc800a24 100644 --- a/src/Stempler/tests/Transform/ImportInlineTest.php +++ b/src/Stempler/tests/Transform/ImportInlineTest.php @@ -18,7 +18,7 @@ class ImportInlineTest extends BaseTestCase { public function testNoImport(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', 'hello world'); $loader->set('import', '${context}'); @@ -32,7 +32,7 @@ public function testNoImport(): void public function testInlineImport(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', ' ${context} @@ -50,7 +50,7 @@ public function testInlineImport(): void public function testInlineImportN(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set('root', ' ${context} diff --git a/src/Stempler/tests/Transform/ImportedStackTest.php b/src/Stempler/tests/Transform/ImportedStackTest.php index 80e1aa10d..c0dc7e8c3 100644 --- a/src/Stempler/tests/Transform/ImportedStackTest.php +++ b/src/Stempler/tests/Transform/ImportedStackTest.php @@ -31,7 +31,7 @@ public function testEmptyStack(): void public function testImportedStack(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', ' @@ -54,7 +54,7 @@ public function testImportedStack(): void public function testStackDefinedInParent(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', ' @@ -89,7 +89,7 @@ public function testStackDefinedInParent(): void public function testStackDefinedInParentWithChild(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', ' @@ -126,7 +126,7 @@ public function testStackDefinedInParentWithChild(): void public function testGrid(): void { - $loader = $loader ?? new StringLoader(); + $loader ??= new StringLoader(); $loader->set( 'root', ' diff --git a/src/Storage/tests/TestCase.php b/src/Storage/tests/TestCase.php index a25447572..37c3f6886 100644 --- a/src/Storage/tests/TestCase.php +++ b/src/Storage/tests/TestCase.php @@ -26,9 +26,6 @@ abstract class TestCase extends BaseTestCase */ protected $second; - /** - * @return void - */ public function setUp(): void { parent::setUp(); @@ -42,9 +39,6 @@ public function setUp(): void ); } - /** - * @return void - */ public function tearDown(): void { $this->cleanTempDirectory(); @@ -52,9 +46,6 @@ public function tearDown(): void parent::tearDown(); } - /** - * @return void - */ protected function cleanTempDirectory(): void { $iterator = new \RecursiveIteratorIterator( diff --git a/src/Tokenizer/tests/ClassLocatorTest.php b/src/Tokenizer/tests/ClassLocatorTest.php index 8f815081b..e6c7717de 100644 --- a/src/Tokenizer/tests/ClassLocatorTest.php +++ b/src/Tokenizer/tests/ClassLocatorTest.php @@ -27,7 +27,7 @@ public function testClassesAll(): void $this->assertArrayHasKey(ClassD::class, $classes); //Excluded - $this->assertArrayNotHasKey('Spiral\Tests\Tokenizer\Classes\Excluded\ClassXX', $classes); + $this->assertArrayNotHasKey(\Spiral\Tests\Tokenizer\Classes\Excluded\ClassXX::class, $classes); $this->assertArrayNotHasKey('Spiral\Tests\Tokenizer\Classes\Bad_Class', $classes); } diff --git a/src/Tokenizer/tests/ReflectionFileTest.php b/src/Tokenizer/tests/ReflectionFileTest.php index ae0b27b94..333ccb873 100644 --- a/src/Tokenizer/tests/ReflectionFileTest.php +++ b/src/Tokenizer/tests/ReflectionFileTest.php @@ -56,7 +56,7 @@ public function testReflectionFileWithNamedParameters(): void $reflection = new ReflectionFile(__DIR__ . '/Classes/ClassWithNamedParameter.php'); $this->assertSame([ - 'Spiral\Tests\Tokenizer\Classes\ClassWithNamedParameter', + \Spiral\Tests\Tokenizer\Classes\ClassWithNamedParameter::class, ], $reflection->getClasses()); } @@ -65,7 +65,7 @@ public function testReflectionFileAnonymousClass(): void $reflection = new ReflectionFile(__DIR__ . '/Classes/ClassWithAnonymousClass.php'); $this->assertSame([ - 'Spiral\Tests\Tokenizer\Classes\ClassWithAnonymousClass', + \Spiral\Tests\Tokenizer\Classes\ClassWithAnonymousClass::class, ], $reflection->getClasses()); } @@ -83,7 +83,7 @@ public function testReflectionEnum(): void $reflection = new ReflectionFile(__DIR__ . '/Classes/ClassD.php'); $this->assertSame([ - 'Spiral\Tests\Tokenizer\Classes\ClassD', + \Spiral\Tests\Tokenizer\Classes\ClassD::class, ], $reflection->getEnums()); } @@ -92,7 +92,7 @@ public function testReflectionTypedEnum(): void $reflection = new ReflectionFile(__DIR__ . '/Classes/ClassE.php'); $this->assertSame([ - 'Spiral\Tests\Tokenizer\Classes\ClassE', + \Spiral\Tests\Tokenizer\Classes\ClassE::class, ], $reflection->getEnums()); } @@ -101,7 +101,7 @@ public function testReflectionInterface(): void $reflection = new ReflectionFile(__DIR__ . '/Interfaces/InterfaceA.php'); $this->assertSame([ - 'Spiral\Tests\Tokenizer\Interfaces\InterfaceA', + \Spiral\Tests\Tokenizer\Interfaces\InterfaceA::class, ], $reflection->getInterfaces()); } diff --git a/src/Tokenizer/tests/ScopedClassLocatorTest.php b/src/Tokenizer/tests/ScopedClassLocatorTest.php index bb1762bf5..9892f021b 100644 --- a/src/Tokenizer/tests/ScopedClassLocatorTest.php +++ b/src/Tokenizer/tests/ScopedClassLocatorTest.php @@ -39,7 +39,7 @@ public function testGetsClassesForExistsScope(): void $this->assertArrayNotHasKey(ClassA::class, $classes); $this->assertArrayNotHasKey(ClassB::class, $classes); $this->assertArrayNotHasKey(ClassC::class, $classes); - $this->assertArrayNotHasKey('Spiral\Tests\Tokenizer\Classes\Excluded\ClassXX', $classes); + $this->assertArrayNotHasKey(\Spiral\Tests\Tokenizer\Classes\Excluded\ClassXX::class, $classes); $this->assertArrayNotHasKey('Spiral\Tests\Tokenizer\Classes\Bad_Class', $classes); } @@ -54,7 +54,7 @@ public function testGetsClassesForNotExistScope(): void $this->assertArrayHasKey(ClassD::class, $classes); // Excluded - $this->assertArrayNotHasKey('Spiral\Tests\Tokenizer\Classes\Excluded\ClassXX', $classes); + $this->assertArrayNotHasKey(\Spiral\Tests\Tokenizer\Classes\Excluded\ClassXX::class, $classes); $this->assertArrayNotHasKey('Spiral\Tests\Tokenizer\Classes\Bad_Class', $classes); } }