Skip to content

Commit bea4709

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

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

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

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

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

7+
use Exception;
58
use Throwable;
69

7-
class InvalidMiddlewareException extends \Exception
10+
class InvalidMiddlewareException extends Exception
811
{
9-
function __construct(
10-
public string $className,
11-
int $code = 0,
12-
?Throwable $previous = null
13-
) {
12+
function __construct(public string $className, int $code = 0, ?Throwable $previous = null)
13+
{
1414
parent::__construct(
1515
"The middleware class '$className' is invalid.",
1616
$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: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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,6 +64,8 @@ function (
6764
}
6865
);
6966
$application->expects($this->once())->method('terminate');
67+
} else {
68+
$this->expectException($expectException);
7069
}
7170

7271
$_SERVER['FOO'] = 'bar';
@@ -75,7 +74,7 @@ function (
7574
$middleware
7675
]));
7776

78-
$assertMiddlewareInvoked = $expectException === null && $middleware && method_exists($middleware, 'isInvoked');
77+
$assertMiddlewareInvoked = null === $expectException && $middleware && method_exists($middleware, 'isInvoked');
7978
if ($assertMiddlewareInvoked) {
8079
$this->assertFalse($middleware::isInvoked());
8180
}
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)