Skip to content

Commit

Permalink
Merge branch '4.x' into patch-route-context-base-path
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansuter committed Oct 4, 2019
2 parents f5faf0c + 80a52f7 commit 948bae0
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To install the Slim-Http library simply run the following command:
composer require slim/http
```

The `ServerRequest` and `Response` object decorators are automatically detected and applied by the internal factories. If you have installed Slim-Http and wish to turn off automatic object decoration you can use the following statements:
The `ServerRequest` and `Response` object decorators are automatically detected and applied by the internal factories. If you have installed Slim-Http and wish to turn off automatic object decoration then you can use the following statements:
```php
<?php

Expand Down Expand Up @@ -74,7 +74,7 @@ $app = AppFactory::create();
$app->addErrorMiddleware(true, true, true);

// Add routes
$app->get('/', function () {
$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write('<a href="/hello/world">Try /hello/world</a>');
return $response;
});
Expand Down
1 change: 1 addition & 0 deletions Slim/Exception/HttpMethodNotAllowedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getAllowedMethods(): array
public function setAllowedMethods(array $methods): HttpMethodNotAllowedException
{
$this->allowedMethods = $methods;
$this->message = 'Method not allowed. Must be one of: ' . implode(', ', $methods);
return $this;
}
}
4 changes: 2 additions & 2 deletions Slim/Routing/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Slim\Routing;

use FastRoute\RouteCollector;
use FastRoute\RouteCollector as FastRouteCollector;
use FastRoute\RouteParser\Std;
use Slim\Interfaces\DispatcherInterface;
use Slim\Interfaces\RouteCollectorInterface;
Expand Down Expand Up @@ -37,7 +37,7 @@ protected function createDispatcher(): FastRouteDispatcher
return $this->dispatcher;
}

$routeDefinitionCallback = function (RouteCollector $r) {
$routeDefinitionCallback = function (FastRouteCollector $r) {
$basePath = $this->routeCollector->getBasePath();

foreach ($this->routeCollector->getRoutes() as $route) {
Expand Down
1 change: 0 additions & 1 deletion Slim/Routing/RouteCollectorProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Slim\Routing;

use Closure;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Slim\Interfaces\CallableResolverInterface;
Expand Down
1 change: 0 additions & 1 deletion tests/CallableResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use Slim\CallableResolver;
use Slim\Tests\Mocks\CallableTest;
use Slim\Tests\Mocks\InvokableTest;
Expand Down
2 changes: 2 additions & 0 deletions tests/Exception/HttpExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ public function testHttpNotAllowedExceptionGetAllowedMethods()
$exception = new HttpMethodNotAllowedException($request);
$exception->setAllowedMethods(['GET']);
$this->assertEquals(['GET'], $exception->getAllowedMethods());
$this->assertEquals('Method not allowed. Must be one of: GET', $exception->getMessage());

$exception = new HttpMethodNotAllowedException($request);
$this->assertEquals([], $exception->getAllowedMethods());
$this->assertEquals('Method not allowed.', $exception->getMessage());
}
}
1 change: 0 additions & 1 deletion tests/Factory/AppFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use ReflectionProperty;
use RuntimeException;
use Slim\Factory\AppFactory;
use Slim\Factory\Psr17\GuzzlePsr17Factory;
use Slim\Factory\Psr17\NyholmPsr17Factory;
Expand Down
1 change: 0 additions & 1 deletion tests/Factory/Psr17/Psr17FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Slim\Tests\Factory\Psr17;

use RuntimeException;
use Slim\Tests\Mocks\MockPsr17Factory;
use Slim\Tests\TestCase;

Expand Down
1 change: 0 additions & 1 deletion tests/Factory/Psr17/SlimHttpServerRequestCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Psr\Http\Message\ServerRequestInterface;
use ReflectionProperty;
use RuntimeException;
use Slim\Factory\Psr17\SlimHttpServerRequestCreator;
use Slim\Http\ServerRequest;
use Slim\Interfaces\ServerRequestCreatorInterface;
Expand Down
2 changes: 0 additions & 2 deletions tests/Factory/ServerRequestCreatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use GuzzleHttp\Psr7\ServerRequest as GuzzleServerRequest;
use Nyholm\Psr7\ServerRequest as NyholmServerRequest;
use Psr\Http\Message\ServerRequestInterface;
use RuntimeException;
use Slim\Factory\Psr17\GuzzlePsr17Factory;
use Slim\Factory\Psr17\NyholmPsr17Factory;
use Slim\Factory\Psr17\Psr17FactoryProvider;
Expand All @@ -22,7 +21,6 @@
use Slim\Factory\ServerRequestCreatorFactory;
use Slim\Http\ServerRequest;
use Slim\Interfaces\ServerRequestCreatorInterface;
use Slim\Psr7\Factory\ServerRequestFactory;
use Slim\Psr7\Request as SlimServerRequest;
use Slim\Tests\TestCase;
use Zend\Diactoros\ServerRequest as ZendServerRequest;
Expand Down
1 change: 0 additions & 1 deletion tests/Middleware/RoutingMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Prophecy\Argument;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use Slim\CallableResolver;
use Slim\Exception\HttpMethodNotAllowedException;
use Slim\Exception\HttpNotFoundException;
Expand Down
3 changes: 3 additions & 0 deletions tests/Mocks/RequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function handle(ServerRequestInterface $request): ResponseInterface

public function custom(ServerRequestInterface $request): ResponseInterface
{
$psr7ObjectProvider = new PSR7ObjectProvider();
$responseFactory = $psr7ObjectProvider->getResponseFactory();

return $responseFactory->createResponse();
}
}
1 change: 0 additions & 1 deletion tests/Routing/RouteContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Slim\Tests\Routing;

use Psr\Http\Message\ServerRequestInterface;
use RuntimeException;
use Slim\Interfaces\RouteInterface;
use Slim\Interfaces\RouteParserInterface;
use Slim\Routing\RouteContext;
Expand Down
1 change: 0 additions & 1 deletion tests/Routing/RouteRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\CallableResolver;
use Slim\MiddlewareDispatcher;
use Slim\Routing\RouteCollector;
use Slim\Routing\RouteParser;
Expand Down

0 comments on commit 948bae0

Please sign in to comment.