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

Commit 036d3ba

Browse files
committed
Use ServerRequestInterface as name for factory producing server request instance
Matches response factory and stream factory.
1 parent da2d8c3 commit 036d3ba

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

src/ConfigProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Zend\Expressive;
1111

1212
use Psr\Http\Message\ResponseInterface;
13+
use Psr\Http\Message\ServerRequestInterface;
1314
use Psr\Http\Message\StreamInterface;
1415
use Zend\HttpHandlerRunner\Emitter\EmitterInterface;
1516
use Zend\HttpHandlerRunner\RequestHandlerRunner;
@@ -53,7 +54,7 @@ public function getDependencies() : array
5354
RequestHandlerRunner::class => Container\RequestHandlerRunnerFactory::class,
5455
ResponseInterface::class => Container\ResponseFactoryFactory::class,
5556
SERVER_REQUEST_ERROR_RESPONSE_GENERATOR => Container\ServerRequestErrorResponseGeneratorFactory::class,
56-
SERVER_REQUEST_FACTORY => Container\ServerRequestFactoryFactory::class,
57+
ServerRequestInterface::class => Container\ServerRequestFactoryFactory::class,
5758
StreamInterface::class => Container\StreamFactoryFactory::class,
5859
],
5960
];

src/Container/RequestHandlerRunnerFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace Zend\Expressive\Container;
1111

1212
use Psr\Container\ContainerInterface;
13+
use Psr\Http\Message\ServerRequestInterface;
1314
use Zend\Expressive\ApplicationPipeline;
1415
use Zend\Expressive\ServerRequestErrorResponseGenerator;
15-
use Zend\Expressive\ServerRequestFactory;
1616
use Zend\HttpHandlerRunner\Emitter\EmitterInterface;
1717
use Zend\HttpHandlerRunner\RequestHandlerRunner;
1818

@@ -25,7 +25,7 @@
2525
* - Zend\Expressive\ApplicationPipeline, which should resolve to a
2626
* Zend\Stratigility\MiddlewarePipeInterface and/or
2727
* Psr\Http\Server\RequestHandlerInterface instance.
28-
* - Zend\Expressive\ServerRequestFactory, which should resolve to a PHP
28+
* - Psr\Http\Message\ServerRequestInterface, which should resolve to a PHP
2929
* callable that will return a Psr\Http\Message\ServerRequestInterface
3030
* instance.
3131
* - Zend\Expressive\ServerRequestErrorResponseGenerator, which should resolve
@@ -41,7 +41,7 @@ public function __invoke(ContainerInterface $container) : RequestHandlerRunner
4141
return new RequestHandlerRunner(
4242
$container->get(ApplicationPipeline::class),
4343
$container->get(EmitterInterface::class),
44-
$container->get(ServerRequestFactory::class),
44+
$container->get(ServerRequestInterface::class),
4545
$container->get(ServerRequestErrorResponseGenerator::class)
4646
);
4747
}

src/constants.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace Zend\Expressive;
1111

12+
use Psr\Http\Message\ServerRequestInterface;
13+
1214
/**
1315
* Legacy service name for the default delegate referenced in version 2.
1416
* Should resolve to the Handler\NotFoundHandler class.
@@ -77,9 +79,11 @@
7779
const SERVER_REQUEST_ERROR_RESPONSE_GENERATOR = __NAMESPACE__ . '\ServerRequestErrorResponseGenerator';
7880

7981
/**
80-
* Virtual service name that should resolve to a service capable of producing
81-
* a PSR-7 ServerRequestInterface instance for the application.
82+
* Legacy/transitional service name for the ServerRequestFactory virtual
83+
* service introduced in 3.0.0alpha6. Should resolve to the
84+
* Psr\Http\Message\ServerRequestInterface service.
8285
*
86+
* @deprecated To remove in version 4.0.0.
8387
* @var string
8488
*/
85-
const SERVER_REQUEST_FACTORY = __NAMESPACE__ . '\ServerRequestFactory';
89+
const SERVER_REQUEST_FACTORY = ServerRequestInterface::class;

test/Container/RequestHandlerRunnerFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
use PHPUnit\Framework\TestCase;
1313
use Psr\Container\ContainerInterface;
14+
use Psr\Http\Message\ServerRequestInterface;
1415
use Psr\Http\Server\RequestHandlerInterface;
1516
use Zend\Expressive\ApplicationPipeline;
1617
use Zend\Expressive\Container\RequestHandlerRunnerFactory;
1718
use Zend\Expressive\ServerRequestErrorResponseGenerator;
18-
use Zend\Expressive\ServerRequestFactory;
1919
use Zend\HttpHandlerRunner\Emitter\EmitterInterface;
2020
use Zend\HttpHandlerRunner\RequestHandlerRunner;
2121

@@ -58,7 +58,7 @@ public function registerServerRequestFactoryInContainer($container) : callable
5858
{
5959
$factory = function () {
6060
};
61-
$container->get(ServerRequestFactory::class)->willReturn($factory);
61+
$container->get(ServerRequestInterface::class)->willReturn($factory);
6262
return $factory;
6363
}
6464

0 commit comments

Comments
 (0)