Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Simplify condition and used proper constant name #50

Merged
merged 7 commits into from
Mar 7, 2018
Merged

Simplify condition and used proper constant name #50

merged 7 commits into from
Mar 7, 2018

Conversation

michalbundyra
Copy link
Member

@michalbundyra michalbundyra commented Mar 6, 2018

The wrong constant name was used: Route::METHOD_ANY instead of Route::HTTP_METHOD_ANY.

Also simplify condition as in both case we call RouteResult::fromRouteFailure.

In case when there is a route without any allowed method the result
should contain empty array of allowed methods and `isMethodFailure` should
be true.
@@ -444,10 +435,6 @@ private function injectRoute(Route $route) : void
$methods = self::HTTP_METHODS_STANDARD;
}

if (empty($methods)) {
$methods = self::HTTP_METHODS_EMPTY;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't add default empty methods if any method is not allowed.

I think it is better to throw an exception when we try add route without any methods.

rc3 updates `Route` to raise an exception for an empty list of HTTP
methods, removing the need for `testNoMethodsAllowedForRoute`, and
making it possible to simply `return
RouteResult::forRouteFailure($allowedMethods)` within
`marshalMethodNotAllowedResult()`.
@@ -650,4 +634,11 @@ public function testGenerateUriRaisesExceptionForMissingMandatoryParameters()

$router->generateUri('foo');
}

public function method() : Generator
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this method anymore, and also we can remove import Generator in top.

use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ProphecyInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriInterface;
use Psr\Http\Server\MiddlewareInterface;
use Zend\Diactoros\ServerRequest;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also not used.

@weierophinney weierophinney merged commit 3453903 into zendframework:release-3.0.0 Mar 7, 2018
@michalbundyra michalbundyra deleted the hotfix/const branch March 7, 2018 17:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants