Fixed null handling.

This commit is contained in:
flash 2025-03-22 19:59:44 +00:00
parent 8df1d32304
commit d99562db16
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
3 changed files with 18 additions and 7 deletions

View file

@ -1 +1 @@
0.2503.211818
0.2503.221959

View file

@ -1,7 +1,7 @@
<?php
// Dependencies.php
// Created: 2025-01-18
// Updated: 2025-03-21
// Updated: 2025-03-22
namespace Index;
@ -68,10 +68,8 @@ class Dependencies {
if($value === null) {
if(count($seqArgs) > 0) {
$value = $seqArgs[array_key_first($seqArgs)];
if($typeInfo instanceof ReflectionNamedType && (!$typeInfo->isBuiltin() || $typeInfo->getName() === gettype($value)))
array_shift($seqArgs);
else
$value = array_shift($seqArgs);
if(!$typeInfo instanceof ReflectionNamedType || !(!$typeInfo->isBuiltin() || $typeInfo->getName() === gettype($value)))
$value = null;
}

View file

@ -1,7 +1,7 @@
<?php
// RouterTest.php
// Created: 2022-01-20
// Updated: 2025-03-21
// Updated: 2025-03-22
declare(strict_types=1);
@ -120,6 +120,15 @@ final class RouterTest extends TestCase {
return $key;
}
#[PatternRoute('GET', '/uploads/([A-Za-z0-9]+|[A-Za-z0-9\-_]{32})(?:-([a-z0-9]+))?(?:\.([A-Za-z0-9\-_]+))?')]
public function getEepromEdgeCase(
string $uploadId,
string $variant = '',
string $extension = ''
): string {
return sprintf('%s//%s//%s', $uploadId, $variant, $extension);
}
public function hasNoAttr(): string {
return 'not a route';
}
@ -138,6 +147,10 @@ final class RouterTest extends TestCase {
$this->assertSame('empty', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/announce.php'))->getBody());
$this->assertSame('Z643QANLgGNkF4D4h4qvFpyeXjx4TcDE', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/announce/Z643QANLgGNkF4D4h4qvFpyeXjx4TcDE'))->getBody());
$this->assertSame('1aKq8VaGyHohNUUR7RzU1W57Z3hQ6m0YMazAkr2IoiSPsvQJ6QoQutywwiOBlNka', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/announce.php/1aKq8VaGyHohNUUR7RzU1W57Z3hQ6m0YMazAkr2IoiSPsvQJ6QoQutywwiOBlNka'))->getBody());
$this->assertSame('1RJNSRYmxrvXUr////', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/uploads/1RJNSRYmxrvXUr'))->getBody());
$this->assertSame('1RJNSRYmxrvXUr//thumb//', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/uploads/1RJNSRYmxrvXUr-thumb'))->getBody());
$this->assertSame('1RJNSRYmxrvXUr//thumb//jpg', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/uploads/1RJNSRYmxrvXUr-thumb.jpg'))->getBody());
$this->assertSame('1RJNSRYmxrvXUr////jpg', (string)$router->handle(HttpRequest::createRequestWithoutBody('GET', '/uploads/1RJNSRYmxrvXUr.jpg'))->getBody());
}
public function testEEPROMSituation(): void {