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

Commit

Permalink
Merge branch 'develop' into dev-2.0.0
Browse files Browse the repository at this point in the history
Forward ported changes from:

- #22
- #23
- #24
- #25

The changes in #23 allowed removing the changes introduced in #21, as
the route path is now accessible via the composed `Route` instance
(assuming that `fromRoute()` was used to create the `RouteResult`
instance).

Conflicts:
	src/RouteResultObserverInterface.php
	src/RouteResultSubjectInterface.php
	test/RouteResultTest.php
  • Loading branch information
weierophinney committed Dec 13, 2016
2 parents 4c5ff70 + f4881af commit 34948cf
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 102 deletions.
5 changes: 5 additions & 0 deletions .docheader
@@ -0,0 +1,5 @@
/**
* @see https://github.com/zendframework/zend-expressive-router for the canonical source repository
* @copyright Copyright (c) %regexp:(20\d{2}-)?%%year% Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-router/blob/master/LICENSE.md New BSD License
*/
17 changes: 8 additions & 9 deletions .travis.yml
Expand Up @@ -12,32 +12,31 @@ matrix:
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- CS_CHECK=true
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- TEST_COVERAGE=true
- php: 7
- php: hhvm
allow_failures:
- php: 7
- php: hhvm

before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls:^1.0 ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls:^1.0 ; fi

install:
- travis_retry composer install --no-interaction
- composer info -i

script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer test-coverage ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then composer test ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then composer cs ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer license-check ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer coveralls ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer coveralls ; fi

notifications:
email: true
18 changes: 16 additions & 2 deletions CHANGELOG.md
Expand Up @@ -27,11 +27,25 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#23](https://github.com/zendframework/zend-expressive-router/pull/23) adds a
new static method on the `RouteResult` class, `fromRoute(Route $route, array
$params = [])`, for creating a new `RouteResult` instance. It also adds
`getMatchedRoute()` for retrieving the `Route` instance provided to that
method. Doing so allows retrieving the list of supported HTTP methods, path,
and route options from the matched route.

- [#24](https://github.com/zendframework/zend-expressive-router/pull/24) adds
two new methods to the `Route` class, `implicitHead()` and
`implicitOptions()`. These can be used by routers or dispatchers to determine
if a match based on `HEAD` or `OPTIONS` requests was due to the developer
specifying the methods explicitly when creating the route (the `implicit*()`
methods will return `false` if explicitly specified).

### Deprecated

- Nothing.
- [#23](https://github.com/zendframework/zend-expressive-router/pull/23)
deprecates `RouteResult::fromRouteMatch()` in favor of the new `fromRoute()`
method.

### Removed

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Expand Up @@ -19,11 +19,13 @@
},
"require": {
"php": "^5.5 || ^7.0",
"psr/http-message": "^1.0"
"psr/http-message": "^1.0",
"fig/http-message-util": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^4.7",
"squizlabs/php_codesniffer": "^2.3"
"zendframework/zend-coding-standard": "~1.0.0",
"malukenho/docheader": "^0.1.5"
},
"autoload": {
"psr-4": {
Expand All @@ -43,11 +45,13 @@
"scripts": {
"check": [
"@cs",
"@license-check",
"@test"
],
"coveralls": "coveralls -v",
"cs": "phpcs",
"cs-fix": "phpcbf",
"license-check": "docheader check src/ test/",
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover clover.xml"
}
Expand Down
15 changes: 1 addition & 14 deletions phpcs.xml
@@ -1,19 +1,6 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<description>Zend Framework coding standard</description>

<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
Expand Down
8 changes: 3 additions & 5 deletions src/Exception/ExceptionInterface.php
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
* @see https://github.com/zendframework/zend-expressive-router for the canonical source repository
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-router/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Expressive\Router\Exception;
Expand Down
8 changes: 3 additions & 5 deletions src/Exception/InvalidArgumentException.php
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
* @see https://github.com/zendframework/zend-expressive-router for the canonical source repository
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-router/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Expressive\Router\Exception;
Expand Down
8 changes: 3 additions & 5 deletions src/Exception/RuntimeException.php
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
* @see https://github.com/zendframework/zend-expressive-router for the canonical source repository
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-router/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Expressive\Router\Exception;
Expand Down
51 changes: 44 additions & 7 deletions src/Route.php
@@ -1,14 +1,14 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
* @see https://github.com/zendframework/zend-expressive-router for the canonical source repository
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-router/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Expressive\Router;

use Fig\Http\Message\RequestMethodInterface as RequestMethod;

/**
* Value object representing a single route.
*
Expand All @@ -29,6 +29,18 @@ class Route
const HTTP_METHOD_ANY = 0xff;
const HTTP_METHOD_SEPARATOR = ':';

/**
* @var bool If HEAD was not provided to the Route instance, indicate
* support for the method is implicit.
*/
private $implicitHead = true;

/**
* @var bool If OPTIONS was not provided to the Route instance, indicate
* support for the method is implicit.
*/
private $implicitOptions = true;

/**
* @var int|string[] HTTP methods allowed with this route.
*/
Expand Down Expand Up @@ -90,6 +102,11 @@ public function __construct($path, $middleware, $methods = self::HTTP_METHOD_ANY
: $path . '^' . implode(self::HTTP_METHOD_SEPARATOR, $this->methods);
}
$this->name = $name;

$this->implicitHead = is_array($this->methods)
&& ! in_array(RequestMethod::METHOD_HEAD, $this->methods, true);
$this->implicitOptions = is_array($this->methods)
&& ! in_array(RequestMethod::METHOD_OPTIONS, $this->methods, true);
}

/**
Expand Down Expand Up @@ -143,8 +160,8 @@ public function getAllowedMethods()
public function allowsMethod($method)
{
$method = strtoupper($method);
if ('HEAD' === $method
|| 'OPTIONS' === $method
if (RequestMethod::METHOD_HEAD === $method
|| RequestMethod::METHOD_OPTIONS === $method
|| $this->methods === self::HTTP_METHOD_ANY
|| in_array($method, $this->methods, true)
) {
Expand All @@ -170,6 +187,26 @@ public function getOptions()
return $this->options;
}

/**
* Whether or not HEAD support is implicit (i.e., not explicitly specified)
*
* @return bool
*/
public function implicitHead()
{
return $this->implicitHead;
}

/**
* Whether or not OPTIONS support is implicit (i.e., not explicitly specified)
*
* @return bool
*/
public function implicitOptions()
{
return $this->implicitOptions;
}

/**
* Validate the provided HTTP method names.
*
Expand Down

0 comments on commit 34948cf

Please sign in to comment.