summaryrefslogtreecommitdiff
path: root/src/Http
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-04-17 10:09:50 +0200
committermsquare <msquare@notrademark.de>2019-04-17 13:11:39 +0200
commit58ca7113f3cd3158a8ae1b02853ece0c4dba4eda (patch)
tree59d1dd3ef685027d312909acd314d9e33c3fa1d2 /src/Http
parentd7ad7b0b13368ef7f3aa10209935f163dc58aa57 (diff)
PSR-7: Replaced implementation with `Nyholm\Psr7`
Diffstat (limited to 'src/Http')
-rw-r--r--src/Http/MessageTrait.php5
-rw-r--r--src/Http/Psr7ServiceProvider.php29
-rw-r--r--src/Http/Request.php18
3 files changed, 28 insertions, 24 deletions
diff --git a/src/Http/MessageTrait.php b/src/Http/MessageTrait.php
index 63ff3682..17fbf5db 100644
--- a/src/Http/MessageTrait.php
+++ b/src/Http/MessageTrait.php
@@ -3,7 +3,7 @@
namespace Engelsystem\Http;
-use PhpExtended\HttpMessage\StringStream;
+use Nyholm\Psr7\Stream;
use Psr\Http\Message\StreamInterface;
/**
@@ -213,7 +213,8 @@ trait MessageTrait
*/
public function getBody()
{
- $stream = new StringStream($this->getContent());
+ $stream = Stream::create($this->getContent());
+ $stream->rewind();
return $stream;
}
diff --git a/src/Http/Psr7ServiceProvider.php b/src/Http/Psr7ServiceProvider.php
index fe4449ff..a9194272 100644
--- a/src/Http/Psr7ServiceProvider.php
+++ b/src/Http/Psr7ServiceProvider.php
@@ -3,10 +3,7 @@
namespace Engelsystem\Http;
use Engelsystem\Container\ServiceProvider;
-use PhpExtended\HttpMessage\ResponseFactory;
-use PhpExtended\HttpMessage\ServerRequestFactory;
-use PhpExtended\HttpMessage\StreamFactory;
-use PhpExtended\HttpMessage\UploadedFileFactory;
+use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
@@ -21,20 +18,26 @@ class Psr7ServiceProvider extends ServiceProvider
{
public function register()
{
+ $psr17Factory = Psr17Factory::class;
+
foreach (
[
- ServerRequestFactory::class => ['psr7.factory.request', ServerRequestFactoryInterface::class],
- ResponseFactory::class => ['psr7.factory.response', ResponseFactoryInterface::class],
- UploadedFileFactory::class => ['psr7.factory.upload', UploadedFileFactoryInterface::class],
- StreamFactory::class => ['psr7.factory.stream', StreamFactoryInterface::class],
- PsrHttpFactory::class => ['psr7.factory', HttpMessageFactoryInterface::class],
- ] as $class => $aliases
+ 'psr7.factory.request',
+ ServerRequestFactoryInterface::class,
+ 'psr7.factory.response',
+ ResponseFactoryInterface::class,
+ 'psr7.factory.upload',
+ UploadedFileFactoryInterface::class,
+ 'psr7.factory.stream',
+ StreamFactoryInterface::class,
+ ] as $alias
) {
- foreach ($aliases as $alias) {
- $this->app->bind($alias, $class);
- }
+ $this->app->bind($alias, $psr17Factory);
}
+ $this->app->bind('psr7.factory', PsrHttpFactory::class);
+ $this->app->bind(HttpMessageFactoryInterface::class, PsrHttpFactory::class);
+
$this->app->bind('psr7.request', 'request');
$this->app->bind(ServerRequestInterface::class, 'psr7.request');
diff --git a/src/Http/Request.php b/src/Http/Request.php
index ee496035..8b5abf2f 100644
--- a/src/Http/Request.php
+++ b/src/Http/Request.php
@@ -2,8 +2,8 @@
namespace Engelsystem\Http;
-use PhpExtended\HttpMessage\UploadedFile;
-use PhpExtended\HttpMessage\Uri;
+use Nyholm\Psr7\UploadedFile;
+use Nyholm\Psr7\Uri;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\UriInterface;
@@ -207,7 +207,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
{
$uri = parent::getUri();
- return Uri::parseFromString($uri);
+ return new Uri($uri);
}
/**
@@ -332,11 +332,11 @@ class Request extends SymfonyRequest implements ServerRequestInterface
/** @var SymfonyFile $file */
$files[] = new UploadedFile(
- $file->getClientOriginalName(),
$file->getRealPath(),
- $file->getMimeType(),
$file->getSize(),
- $file->getError()
+ $file->getError(),
+ $file->getClientOriginalName(),
+ $file->getMimeType()
);
}
@@ -464,10 +464,10 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* This method obviates the need for a hasAttribute() method, as it allows
* specifying a default value to return if the attribute is not found.
*
- * @see getAttributes()
* @param string $name The attribute name.
* @param mixed $default Default value to return if the attribute does not exist.
* @return mixed
+ * @see getAttributes()
*/
public function getAttribute($name, $default = null)
{
@@ -484,10 +484,10 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* immutability of the message, and MUST return an instance that has the
* updated attribute.
*
- * @see getAttributes()
* @param string $name The attribute name.
* @param mixed $value The value of the attribute.
* @return static
+ * @see getAttributes()
*/
public function withAttribute($name, $value)
{
@@ -509,9 +509,9 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* immutability of the message, and MUST return an instance that removes
* the attribute.
*
- * @see getAttributes()
* @param string $name The attribute name.
* @return static
+ * @see getAttributes()
*/
public function withoutAttribute($name)
{