Skip to content

Commit 22821c6

Browse files
committed
phpstan level 9
opencode (opus 4.5)
1 parent 66e3b93 commit 22821c6

10 files changed

Lines changed: 51 additions & 17 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=100 --verbose --coverage=build/phpunit",
6161
"test:integration": "vendor/bin/phpunit --configuration phpunit.integration.xml --cache-directory=build/phpunit/integration.cache",
6262
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",
63-
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=8 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
63+
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=9 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
6464
"test:unit": "vendor/bin/phpunit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-directory=build/phpunit/unit.cache"
6565
}
6666
}

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
parameters:

src/ServiceFactory/Framework/ExceptionMiddlewareFactory.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ final class ExceptionMiddlewareFactory
1313
{
1414
public function __invoke(ContainerInterface $container): ExceptionMiddleware
1515
{
16+
/** @var ResponseFactoryInterface $responseFactory */
17+
$responseFactory = $container->get(ResponseFactoryInterface::class);
18+
19+
/** @var array{debug: bool} $config */
20+
$config = $container->get('config');
21+
22+
/** @var LoggerInterface $logger */
23+
$logger = $container->get(LoggerInterface::class);
24+
1625
return new ExceptionMiddleware(
17-
$container->get(ResponseFactoryInterface::class),
18-
$container->get('config')['debug'],
19-
$container->get(LoggerInterface::class)
26+
$responseFactory,
27+
$config['debug'],
28+
$logger
2029
);
2130
}
2231
}

src/ServiceFactory/Framework/RouteMatcherFactory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ final class RouteMatcherFactory
1313
{
1414
public function __invoke(ContainerInterface $container): RouteMatcherInterface
1515
{
16+
/** @var RoutesByNameInterface $routes */
17+
$routes = $container->get(RoutesByNameInterface::class);
18+
19+
/** @var array{fastroute: array{cache: null|string}} $config */
20+
$config = $container->get('config');
21+
1622
return new RouteMatcher(
17-
$container->get(RoutesByNameInterface::class),
18-
$container->get('config')['fastroute']['cache']
23+
$routes,
24+
$config['fastroute']['cache']
1925
);
2026
}
2127
}

src/ServiceFactory/Framework/RouteMatcherMiddlewareFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ final class RouteMatcherMiddlewareFactory
1212
{
1313
public function __invoke(ContainerInterface $container): RouteMatcherMiddleware
1414
{
15-
return new RouteMatcherMiddleware($container->get(RouteMatcherInterface::class));
15+
/** @var RouteMatcherInterface $routeMatcher */
16+
$routeMatcher = $container->get(RouteMatcherInterface::class);
17+
18+
return new RouteMatcherMiddleware($routeMatcher);
1619
}
1720
}

src/ServiceFactory/Framework/UrlGeneratorFactory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ final class UrlGeneratorFactory
1313
{
1414
public function __invoke(ContainerInterface $container): UrlGeneratorInterface
1515
{
16-
return new UrlGenerator(
17-
$container->get(RoutesByNameInterface::class)
18-
);
16+
/** @var RoutesByNameInterface $routes */
17+
$routes = $container->get(RoutesByNameInterface::class);
18+
19+
return new UrlGenerator($routes);
1920
}
2021
}

src/ServiceFactory/Logger/LoggerFactory.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Monolog\Formatter\LogstashFormatter;
88
use Monolog\Handler\BufferHandler;
99
use Monolog\Handler\StreamHandler;
10+
use Monolog\Level;
1011
use Monolog\Logger;
1112
use Psr\Container\ContainerInterface;
1213
use Psr\Log\LoggerInterface;
@@ -15,13 +16,16 @@ final class LoggerFactory
1516
{
1617
public function __invoke(ContainerInterface $container): LoggerInterface
1718
{
18-
$config = $container->get('config')['monolog'];
19+
/** @var array{monolog: array{name: string, path: string, level: Level}} $config */
20+
$config = $container->get('config');
1921

20-
return new Logger($config['name'], [
22+
$monologConfig = $config['monolog'];
23+
24+
return new Logger($monologConfig['name'], [
2125
new BufferHandler(
2226
(new StreamHandler(
23-
$config['path'],
24-
$config['level']
27+
$monologConfig['path'],
28+
$monologConfig['level']
2529
))->setFormatter(new LogstashFormatter('app'))
2630
),
2731
]);

src/ServiceFactory/RequestHandler/PingRequestHandlerFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ final class PingRequestHandlerFactory
1212
{
1313
public function __invoke(ContainerInterface $container): PingRequestHandler
1414
{
15-
return new PingRequestHandler($container->get(ResponseFactoryInterface::class));
15+
/** @var ResponseFactoryInterface $responseFactory */
16+
$responseFactory = $container->get(ResponseFactoryInterface::class);
17+
18+
return new PingRequestHandler($responseFactory);
1619
}
1720
}

src/console.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,9 @@
2424
$console->getDefinition()->addOption(
2525
new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev')
2626
);
27-
$console->addCommands($container->get(Command::class.'[]'));
27+
28+
/** @var array<Command> $commands */
29+
$commands = $container->get(Command::class.'[]');
30+
31+
$console->addCommands($commands);
2832
$console->run($input);

src/web.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
/** @var ContainerInterface $container */
1515
$container = (require __DIR__.'/container.php')($env);
1616

17-
return new Application($container->get(MiddlewareInterface::class.'[]'));
17+
/** @var array<MiddlewareInterface> $middlewares */
18+
$middlewares = $container->get(MiddlewareInterface::class.'[]');
19+
20+
return new Application($middlewares);
1821
};

0 commit comments

Comments
 (0)