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

Commit b6c79d8

Browse files
committed
Merge branch 'hotfix/revert-unwanted-merge-changes' into develop
Ready for 3.0.0rc4.
2 parents c7a1689 + 9a643db commit b6c79d8

9 files changed

+71
-63
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ install:
4343
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
4444
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
4545
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
46-
- if [[ $TEST_COVERAGE == 'true' ]]; then cp phpunit.xml.dist-coverage phpunit.xml.dist ; fi
4746
- stty cols 120 && composer show
4847
- cat phpunit.xml.dist
4948

CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 3.0.0rc4 - 2018-03-13
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Changed
12+
13+
- Forward ports a change made in [#581](https://github.com/zendframework/zend-expressive/pull/581)
14+
to how the `ApplicationConfigInjectionDelegator::injectPipelineFromConfig()`
15+
method works. Previously, it would auto-inject routing and dispatch middleware
16+
if routes were configured, but no `middleware_pipeline` was present.
17+
Considering that this method will always be called manually, this
18+
functionality was removed; the method now becomes a no-op if no
19+
`middleware_pipeline` is present.
20+
21+
### Deprecated
22+
23+
- Nothing.
24+
25+
### Removed
26+
27+
- Nothing.
28+
29+
### Fixed
30+
31+
- Nothing.
32+
533
## 3.0.0rc3 - 2018-03-07
634

735
### Added

phpcs.xml

-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@
55
<!-- Paths to check -->
66
<file>src</file>
77
<file>test</file>
8-
9-
<rule ref="PSR1.Files.SideEffects">
10-
<exclude-pattern>src/AppFactory.php</exclude-pattern>
11-
</rule>
128
</ruleset>

phpunit.xml.dist-coverage

-18
This file was deleted.

src/Container/ApplicationConfigInjectionDelegator.php

+33-5
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
6161
* Inspects the configuration provided to determine if a middleware pipeline
6262
* exists to inject in the application.
6363
*
64-
* If no pipeline is defined, but routes *are*, then the method will inject
65-
* the routing and dispatch middleware.
66-
*
6764
* Use the following configuration format:
6865
*
6966
* <code>
@@ -129,7 +126,38 @@ public static function injectPipelineFromConfig(Application $application, array
129126
/**
130127
* Inject routes from configuration.
131128
*
132-
* Proxies to ApplicationConfigInjectionDelegator::injectRoutesFromConfig
129+
* Introspects the provided configuration for routes to inject in the
130+
* application instance.
131+
*
132+
* The following configuration structure can be used to define routes:
133+
*
134+
* <code>
135+
* return [
136+
* 'routes' => [
137+
* [
138+
* 'path' => '/path/to/match',
139+
* 'middleware' => 'Middleware Service Name or Callable',
140+
* 'allowed_methods' => ['GET', 'POST', 'PATCH'],
141+
* 'options' => [
142+
* 'stuff' => 'to',
143+
* 'pass' => 'to',
144+
* 'the' => 'underlying router',
145+
* ],
146+
* ],
147+
* // etc.
148+
* ],
149+
* ];
150+
* </code>
151+
*
152+
* Each route MUST have a path and middleware key at the minimum.
153+
*
154+
* The "allowed_methods" key may be omitted, can be either an array or the
155+
* value of the Zend\Expressive\Router\Route::HTTP_METHOD_ANY constant; any
156+
* valid HTTP method token is allowed, which means you can specify custom HTTP
157+
* methods as well.
158+
*
159+
* The "options" key may also be omitted, and its interpretation will be
160+
* dependent on the underlying router used.
133161
*
134162
* @throws InvalidArgumentException
135163
*/
@@ -144,7 +172,7 @@ public static function injectRoutesFromConfig(Application $application, array $c
144172
continue;
145173
}
146174

147-
$methods = null;
175+
$methods = Route::HTTP_METHOD_ANY;
148176
if (isset($spec['allowed_methods'])) {
149177
$methods = $spec['allowed_methods'];
150178
if (! is_array($methods)) {

test/ConfigProviderTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,17 @@ public function testProviderDefinesExpectedFactoryServices()
6363
$factories = $config['factories'];
6464

6565
$this->assertArrayHasKey(Application::class, $factories);
66+
$this->assertArrayHasKey(ApplicationPipeline::class, $factories);
67+
$this->assertArrayHasKey(EmitterInterface::class, $factories);
6668
$this->assertArrayHasKey(ErrorHandler::class, $factories);
69+
$this->assertArrayHasKey(MiddlewareContainer::class, $factories);
70+
$this->assertArrayHasKey(MiddlewareFactory::class, $factories);
6771
$this->assertArrayHasKey(Middleware\ErrorResponseGenerator::class, $factories);
6872
$this->assertArrayHasKey(NotFoundHandler::class, $factories);
73+
$this->assertArrayHasKey(RequestHandlerRunner::class, $factories);
6974
$this->assertArrayHasKey(ResponseInterface::class, $factories);
75+
$this->assertArrayHasKey(ServerRequestInterface::class, $factories);
76+
$this->assertArrayHasKey(ServerRequestErrorResponseGenerator::class, $factories);
7077
$this->assertArrayHasKey(StreamInterface::class, $factories);
7178
}
7279

test/Container/ApplicationConfigInjectionDelegatorTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use Zend\HttpHandlerRunner\RequestHandlerRunner;
3232
use Zend\Stratigility\MiddlewarePipe;
3333
use ZendTest\Expressive\ContainerTrait;
34-
use ZendTest\Expressive\TestAsset\CallableInteropMiddleware;
3534
use ZendTest\Expressive\TestAsset\InvokableMiddleware;
3635

3736
class ApplicationConfigInjectionDelegatorTest extends TestCase
@@ -200,12 +199,12 @@ public static function assertMethodNotAllowedMiddleware(MiddlewareInterface $mid
200199
public function callableMiddlewares()
201200
{
202201
return [
203-
[CallableInteropMiddleware::class],
202+
['HelloWorld'],
204203
[
205-
function ($request, DelegateInterface $delegate) {
204+
function () {
206205
},
207206
],
208-
[[CallableInteropMiddleware::class, 'staticallyCallableMiddleware']],
207+
[[InvokableMiddleware::class, 'staticallyCallableMiddleware']],
209208
];
210209
}
211210

test/Router/IntegrationTest.php

-25
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,6 @@ public function setUp()
5959
};
6060
$this->router = $this->prophesize(RouterInterface::class);
6161
$this->container = $this->mockContainerInterface();
62-
$this->disregardDeprecationNotices();
63-
}
64-
65-
public function tearDown()
66-
{
67-
restore_error_handler();
68-
}
69-
70-
public function disregardDeprecationNotices()
71-
{
72-
set_error_handler(function ($errno, $errstr) {
73-
if (strstr($errstr, 'pipe() the middleware directly')) {
74-
return true;
75-
}
76-
if (strstr($errstr, 'doublePassMiddleware()')) {
77-
return true;
78-
}
79-
if (strstr($errstr, 'ImplicitHeadMiddleware is deprecated')) {
80-
return true;
81-
}
82-
if (strstr($errstr, 'ImplicitOptionsMiddleware is deprecated')) {
83-
return true;
84-
}
85-
return false;
86-
}, E_USER_DEPRECATED);
8762
}
8863

8964
public function getApplication()

test/TestAsset/CallableInteropMiddleware.php

-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,4 @@ public function __invoke(ServerRequestInterface $request, RequestHandlerInterfac
2020

2121
return $response->withHeader('X-Callable-Interop-Middleware', __CLASS__);
2222
}
23-
24-
public static function staticallyCallableMiddleware(ServerRequestInterface $request, DelegateInterface $delegate)
25-
{
26-
$response = $delegate->process($request);
27-
return $response->withHeader('X-Invoked', __CLASS__);
28-
}
2923
}

0 commit comments

Comments
 (0)