Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: static analysis issues
  • Loading branch information
Scarbous committed Oct 22, 2025
commit 410eaa3f4dd8b7d63ffcdd131e62f0edaf9b988a
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?php

namespace Runtime\FrankenPhpSymfony\Exception;
declare(strict_types=1);

use Throwable;
namespace Runtime\FrankenPhpSymfony\Exception;

class InvalidMiddlewareException extends \Exception
{
function __construct(
public string $className,
int $code = 0,
?Throwable $previous = null
) {
public function __construct(public string $className, int $code = 0, ?\Throwable $previous = null)
{
parent::__construct(
"The middleware class '$className' is invalid.",
$code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

interface MiddlewareInterface
{
function wrap(callable $handler, array $server): void;
public function wrap(callable $handler, array $server): void;
}
1 change: 1 addition & 0 deletions src/frankenphp-symfony/src/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Runtime extends SymfonyRuntime
/**
* @param array{
* frankenphp_loop_max?: int,
* frankenphp_middlewares?: string
* } $options
*/
public function __construct(array $options = [])
Expand Down
27 changes: 12 additions & 15 deletions src/frankenphp-symfony/tests/RunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Runtime\FrankenPhpSymfony\Tests;

require_once __DIR__ . '/function-mock.php';
require_once __DIR__.'/function-mock.php';

use PHPUnit\Framework\TestCase;
use Runtime\FrankenPhpSymfony\Exception\InvalidMiddlewareException;
Expand All @@ -25,16 +25,17 @@ interface TestAppInterface extends HttpKernelInterface, TerminableInterface
*/
class RunnerTest extends TestCase
{

static function runData(): iterable
public static function runData(): iterable
{
yield 'basic' => [];

yield 'middleware' => [
'middleware' => TestMiddleware::class
'middleware' => TestMiddleware::class,
];

yield 'Invalid middleware' => [
'middleware' => InvalidMiddleware::class,
'expectException' => InvalidMiddlewareException::class
'expectException' => InvalidMiddlewareException::class,
];
}

Expand All @@ -43,15 +44,11 @@ static function runData(): iterable
*/
public function testRun(
?string $middleware = null,
?string $expectException = null
?string $expectException = null,
): void {
if ($expectException !== null) {
$this->expectException($expectException);
}

$application = $this->createMock(TestAppInterface::class);

if ($expectException === null) {
if (null === $expectException) {
$application
->expects($this->once())
->method('handle')
Expand All @@ -67,15 +64,15 @@ function (
}
);
$application->expects($this->once())->method('terminate');
} else {
$this->expectException($expectException);
}

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

$runner = new Runner($application, 500, array_filter([
$middleware
]));
$runner = new Runner($application, 500, array_filter([$middleware]));

$assertMiddlewareInvoked = $expectException === null && $middleware && method_exists($middleware, 'isInvoked');
$assertMiddlewareInvoked = null === $expectException && $middleware && method_exists($middleware, 'isInvoked');
if ($assertMiddlewareInvoked) {
$this->assertFalse($middleware::isInvoked());
}
Expand Down
3 changes: 2 additions & 1 deletion src/frankenphp-symfony/tests/Support/InvalidMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

declare(strict_types=1);

namespace Runtime\FrankenPhpSymfony\Tests\Support;

class InvalidMiddleware
{

}
2 changes: 1 addition & 1 deletion src/frankenphp-symfony/tests/Support/TestMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class TestMiddleware implements MiddlewareInterface
{
function __construct()
public function __construct()
{
self::$invoked = false;
}
Expand Down
Loading