Skip to content

Commit 410eaa3

Browse files
committed
fix: static analysis issues
1 parent 8964184 commit 410eaa3

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

src/frankenphp-symfony/src/Exception/InvalidMiddlewareException.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<?php
22

3-
namespace Runtime\FrankenPhpSymfony\Exception;
3+
declare(strict_types=1);
44

5-
use Throwable;
5+
namespace Runtime\FrankenPhpSymfony\Exception;
66

77
class InvalidMiddlewareException extends \Exception
88
{
9-
function __construct(
10-
public string $className,
11-
int $code = 0,
12-
?Throwable $previous = null
13-
) {
9+
public function __construct(public string $className, int $code = 0, ?\Throwable $previous = null)
10+
{
1411
parent::__construct(
1512
"The middleware class '$className' is invalid.",
1613
$code,

src/frankenphp-symfony/src/Middleware/MiddlewareInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
interface MiddlewareInterface
88
{
9-
function wrap(callable $handler, array $server): void;
9+
public function wrap(callable $handler, array $server): void;
1010
}

src/frankenphp-symfony/src/Runtime.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Runtime extends SymfonyRuntime
1818
/**
1919
* @param array{
2020
* frankenphp_loop_max?: int,
21+
* frankenphp_middlewares?: string
2122
* } $options
2223
*/
2324
public function __construct(array $options = [])

src/frankenphp-symfony/tests/RunnerTest.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Runtime\FrankenPhpSymfony\Tests;
66

7-
require_once __DIR__ . '/function-mock.php';
7+
require_once __DIR__.'/function-mock.php';
88

99
use PHPUnit\Framework\TestCase;
1010
use Runtime\FrankenPhpSymfony\Exception\InvalidMiddlewareException;
@@ -25,16 +25,17 @@ interface TestAppInterface extends HttpKernelInterface, TerminableInterface
2525
*/
2626
class RunnerTest extends TestCase
2727
{
28-
29-
static function runData(): iterable
28+
public static function runData(): iterable
3029
{
3130
yield 'basic' => [];
31+
3232
yield 'middleware' => [
33-
'middleware' => TestMiddleware::class
33+
'middleware' => TestMiddleware::class,
3434
];
35+
3536
yield 'Invalid middleware' => [
3637
'middleware' => InvalidMiddleware::class,
37-
'expectException' => InvalidMiddlewareException::class
38+
'expectException' => InvalidMiddlewareException::class,
3839
];
3940
}
4041

@@ -43,15 +44,11 @@ static function runData(): iterable
4344
*/
4445
public function testRun(
4546
?string $middleware = null,
46-
?string $expectException = null
47+
?string $expectException = null,
4748
): void {
48-
if ($expectException !== null) {
49-
$this->expectException($expectException);
50-
}
51-
5249
$application = $this->createMock(TestAppInterface::class);
5350

54-
if ($expectException === null) {
51+
if (null === $expectException) {
5552
$application
5653
->expects($this->once())
5754
->method('handle')
@@ -67,15 +64,15 @@ function (
6764
}
6865
);
6966
$application->expects($this->once())->method('terminate');
67+
} else {
68+
$this->expectException($expectException);
7069
}
7170

7271
$_SERVER['FOO'] = 'bar';
7372

74-
$runner = new Runner($application, 500, array_filter([
75-
$middleware
76-
]));
73+
$runner = new Runner($application, 500, array_filter([$middleware]));
7774

78-
$assertMiddlewareInvoked = $expectException === null && $middleware && method_exists($middleware, 'isInvoked');
75+
$assertMiddlewareInvoked = null === $expectException && $middleware && method_exists($middleware, 'isInvoked');
7976
if ($assertMiddlewareInvoked) {
8077
$this->assertFalse($middleware::isInvoked());
8178
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Runtime\FrankenPhpSymfony\Tests\Support;
46

57
class InvalidMiddleware
68
{
7-
89
}

src/frankenphp-symfony/tests/Support/TestMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class TestMiddleware implements MiddlewareInterface
1010
{
11-
function __construct()
11+
public function __construct()
1212
{
1313
self::$invoked = false;
1414
}

0 commit comments

Comments
 (0)