Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"psr/http-message": "^2.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"respect/parameter": "^1.0"
"respect/parameter": "^3.0"
},
"require-dev": {
"nyholm/psr7": "^1.8",
Expand Down
3 changes: 2 additions & 1 deletion src/DispatchContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Respect\Parameter\ContainerResolver;
use Respect\Parameter\Resolver;
use Respect\Rest\Handlers\ErrorHandler;
use Respect\Rest\Handlers\ExceptionHandler;
Expand Down Expand Up @@ -224,7 +225,7 @@ public function forward(AbstractRoute $route): ResponseInterface|null

public function resolver(): Resolver
{
return $this->resolver ??= new Resolver($this);
return $this->resolver ??= new ContainerResolver($this);
}

public function has(string $id): bool
Expand Down
4 changes: 2 additions & 2 deletions src/Routes/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use ReflectionFunctionAbstract;
use Respect\Fluent\Factories\NamespaceLookup;
use Respect\Parameter\Resolver;
use Respect\Parameter\ContainerResolver;
use Respect\Rest\DispatchContext;

use function array_merge;
Expand All @@ -30,7 +30,7 @@ public function __construct(

public function getCallbackReflection(): ReflectionFunctionAbstract
{
return Resolver::reflectCallable($this->callback);
return ContainerResolver::reflectCallable($this->callback);
}

public function getReflection(string $method): ReflectionFunctionAbstract
Expand Down
6 changes: 3 additions & 3 deletions src/Routines/AuthBasic.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use ReflectionFunctionAbstract;
use Respect\Parameter\Resolver;
use Respect\Parameter\ContainerResolver;
use Respect\Rest\DispatchContext;

use function array_merge;
Expand Down Expand Up @@ -63,14 +63,14 @@ private function unauthorizedResponse(DispatchContext $context): ResponseInterfa

private function callbackAcceptsPsr7(): bool
{
return Resolver::acceptsType(
return ContainerResolver::acceptsType(
$this->getCallbackReflection(),
ServerRequestInterface::class,
);
}

private function getCallbackReflection(): ReflectionFunctionAbstract
{
return $this->reflection ??= Resolver::reflectCallable($this->getCallback());
return $this->reflection ??= ContainerResolver::reflectCallable($this->getCallback());
}
}
4 changes: 2 additions & 2 deletions src/Routines/By.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Respect\Rest\Routines;

use ReflectionFunctionAbstract;
use Respect\Parameter\Resolver;
use Respect\Parameter\ContainerResolver;
use Respect\Rest\DispatchContext;

/** Generic routine executed before the route */
Expand All @@ -17,7 +17,7 @@ final class By extends AbstractRoutine implements ProxyableBy
// phpcs:ignore Generic.NamingConventions.ConstructorName.OldStyle
public function by(DispatchContext $context, array $params): mixed
{
$this->reflection ??= Resolver::reflectCallable($this->getCallback());
$this->reflection ??= ContainerResolver::reflectCallable($this->getCallback());
$args = $context->resolver()->resolve($this->reflection, $params);

return ($this->getCallback())(...$args);
Expand Down
4 changes: 2 additions & 2 deletions src/Routines/Through.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Respect\Rest\Routines;

use ReflectionFunctionAbstract;
use Respect\Parameter\Resolver;
use Respect\Parameter\ContainerResolver;
use Respect\Rest\DispatchContext;

/** Generic routine executed after the route */
Expand All @@ -17,7 +17,7 @@ final class Through extends AbstractRoutine implements ProxyableThrough
// phpcs:ignore Generic.NamingConventions.ConstructorName.OldStyle
public function through(DispatchContext $context, array $params): mixed
{
$this->reflection ??= Resolver::reflectCallable($this->getCallback());
$this->reflection ??= ContainerResolver::reflectCallable($this->getCallback());
$args = $context->resolver()->resolve($this->reflection, $params);

return ($this->getCallback())(...$args);
Expand Down
4 changes: 2 additions & 2 deletions src/Routines/When.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Respect\Rest\Routines;

use ReflectionFunctionAbstract;
use Respect\Parameter\Resolver;
use Respect\Parameter\ContainerResolver;
use Respect\Rest\DispatchContext;

/** Generic routine executed before route matching */
Expand All @@ -17,7 +17,7 @@ final class When extends AbstractRoutine implements ProxyableWhen
// phpcs:ignore Generic.NamingConventions.ConstructorName.OldStyle
public function when(DispatchContext $context, array $params): mixed
{
$this->reflection ??= Resolver::reflectCallable($this->getCallback());
$this->reflection ??= ContainerResolver::reflectCallable($this->getCallback());
$args = $context->resolver()->resolve($this->reflection, $params);

return ($this->getCallback())(...$args);
Expand Down
5 changes: 2 additions & 3 deletions tests/DispatchContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,11 @@ protected function getMockForRoute(

if ($hasTarget) {
if ($targetParams) {
$expectation = $route->expects($this->any())
$expectation = $route->expects($this->atLeastOnce())
->method('runTarget')
->with($targetMethod, $targetParams);
} else {
$expectation = $route->expects($this->any())
->method('runTarget');
$expectation = $route->method('runTarget');
}

if (is_callable($target)) {
Expand Down
12 changes: 6 additions & 6 deletions tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public function testMagicConstructorCanCreateCallbackRoutes(): void
'When there are no arguments the Routes\Callback should have none as well',
);

self::assertEquals(
$callbackRoute,
$concreteCallbackRoute,
self::assertSame(
[$concreteCallbackRoute->method, $concreteCallbackRoute->pattern, $concreteCallbackRoute->arguments],
[$callbackRoute->method, $callbackRoute->pattern, $callbackRoute->arguments],
'The magic and concrete instances of Routes\Callback should be equivalent',
);
}
Expand Down Expand Up @@ -147,9 +147,9 @@ public function testMagicConstructorCanCreateCallbackRoutesWithExtraParams(): vo
'The "extra" appended to the magic constructor should be present on the arguments list',
);

self::assertEquals(
$callbackRoute,
$concreteCallbackRoute,
self::assertSame(
[$concreteCallbackRoute->method, $concreteCallbackRoute->pattern, $concreteCallbackRoute->arguments],
[$callbackRoute->method, $callbackRoute->pattern, $callbackRoute->arguments],
'The magic and concrete instances of Routes\Callback should be equivalent',
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Routines/AbstractRoutineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ static function () {
public function test_invalid_constructor_arguments(): void
{
self::expectException(TypeError::class);
new Stub('this_function_name_does_not_exist'); // @phpstan-ignore argument.type
new Stub('this_function_name_does_not_exist'); // @phpstan-ignore argument.type, new.resultUnused
}
}