Skip to content

Commit

Permalink
use psr http message 0.2 package
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Oct 11, 2014
1 parent e79e328 commit a708210
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 412 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"require": {
"php": ">=5.4",
"psr/log": "~1.0",
"psr/http-message": "0.2@dev",
"monolog/monolog": "~1.0",
"symfony/event-dispatcher": "~2.0",
"symfony/dependency-injection": "~2.0",
"doctrine/dbal": "2.5.0-RC2"
"doctrine/dbal": "~2.5@RC"
},
"require-dev": {
"phpunit/phpunit": "~4.1",
Expand All @@ -26,7 +27,7 @@
"autoload": {
"psr-0": {
"PSX\\": "library/",
"Psr\\": "library/"
"Psr\\Cache\\": "library/"
}
}
}
4 changes: 2 additions & 2 deletions library/PSX/ControllerAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use InvalidArgumentException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Data\NotFoundException;
use PSX\Data\ReaderFactory;
use PSX\Data\RecordInterface;
Expand Down Expand Up @@ -401,7 +401,7 @@ protected function setBody($data, $writerType = null)
{
$this->response->getBody()->write($data);
}
else if($data instanceof StreamInterface)
else if($data instanceof StreamableInterface)
{
$this->response->setBody($data);
}
Expand Down
4 changes: 2 additions & 2 deletions library/PSX/Http/DeleteRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace PSX\Http;

use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Url;

/**
Expand All @@ -40,7 +40,7 @@ class DeleteRequest extends Request
*
* @param PSX\Url|string $url
* @param array $header
* @param Psr\Http\Message\StreamInterface|string|array $body
* @param Psr\Http\Message\StreamableInterface|string|array $body
*/
public function __construct($url, array $header = array(), $body = null)
{
Expand Down
14 changes: 7 additions & 7 deletions library/PSX/Http/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

use InvalidArgumentException;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Http\Stream\StringStream;

/**
Expand All @@ -43,7 +43,7 @@ class Message implements MessageInterface

/**
* @param array $header
* @param Psr\Http\Message\StreamInterface|string $body
* @param Psr\Http\Message\StreamableInterface|string $body
* @param string $scheme
*/
public function __construct(array $header = array(), $body = null, $scheme = null)
Expand Down Expand Up @@ -133,7 +133,7 @@ public function removeHeader($name)
/**
* Returns the message body
*
* @return Psr\Http\StreamInterface
* @return Psr\Http\StreamableInterface
*/
public function getBody()
{
Expand All @@ -143,17 +143,17 @@ public function getBody()
/**
* Sets the message body
*
* @param Psr\Http\StreamInterface $body
* @param Psr\Http\StreamableInterface $body
* @return void
*/
public function setBody(StreamInterface $body = null)
public function setBody(StreamableInterface $body = null)
{
$this->body = $body;
}

protected function prepareBody($body)
{
if($body === null || $body instanceof StreamInterface)
if($body === null || $body instanceof StreamableInterface)
{
return $body;
}
Expand All @@ -163,7 +163,7 @@ protected function prepareBody($body)
}
else
{
throw new InvalidArgumentException('Body must be either an Psr\Http\Message\StreamInterface or string');
throw new InvalidArgumentException('Body must be either an Psr\Http\Message\StreamableInterface or string');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/PSX/Http/PostRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace PSX\Http;

use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Url;

/**
Expand All @@ -40,7 +40,7 @@ class PostRequest extends Request
*
* @param PSX\Url|string $url
* @param array $header
* @param Psr\Http\Message\StreamInterface|string|array $body
* @param Psr\Http\Message\StreamableInterface|string|array $body
*/
public function __construct($url, array $header = array(), $body = null)
{
Expand Down
4 changes: 2 additions & 2 deletions library/PSX/Http/PutRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace PSX\Http;

use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Url;

/**
Expand All @@ -40,7 +40,7 @@ class PutRequest extends Request
*
* @param PSX\Url|string $url
* @param array $header
* @param Psr\Http\Message\StreamInterface|string|array $body
* @param Psr\Http\Message\StreamableInterface|string|array $body
*/
public function __construct($url, array $header = array(), $body = null)
{
Expand Down
2 changes: 1 addition & 1 deletion library/PSX/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace PSX\Http;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Http;
use PSX\Url;

Expand Down
2 changes: 1 addition & 1 deletion library/PSX/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace PSX\Http;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;
use PSX\Http;
use PSX\Exception;

Expand Down
3 changes: 0 additions & 3 deletions library/PSX/Http/Stream/FileStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

namespace PSX\Http\Stream;

use InvalidArgumentException;
use Psr\Http\Message\StreamInterface;

/**
* FileStream
*
Expand Down
14 changes: 12 additions & 2 deletions library/PSX/Http/Stream/MultipartStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace PSX\Http\Stream;

use InvalidArgumentException;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;

/**
* MultipartStream
Expand All @@ -33,7 +33,7 @@
* @license http://www.gnu.org/licenses/gpl.html GPLv3
* @link http://phpsx.org
*/
class MultipartStream implements StreamInterface, \Iterator, \Countable
class MultipartStream implements StreamableInterface, \Iterator, \Countable
{
protected $streams;

Expand All @@ -54,6 +54,11 @@ public function detach()
return $this->current()->detach();
}

public function attach($stream)
{
return $this->current()->attach($stream);
}

public function getSize()
{
return $this->current()->getSize();
Expand Down Expand Up @@ -104,6 +109,11 @@ public function getContents($length = -1)
return $this->current()->getContents($length);
}

public function getMetadata($key = null)
{
return $this->current()->getMetadata($key);
}

public function __toString()
{
return $this->current()->__toString();
Expand Down
11 changes: 10 additions & 1 deletion library/PSX/Http/Stream/SocksStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace PSX\Http\Stream;

use InvalidArgumentException;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;

/**
* The socks stream is used by the socks http handler. When you read data from
Expand Down Expand Up @@ -57,6 +57,10 @@ public function detach()
return parent::detach();
}

public function attach($stream)
{
}

public function getSize()
{
return $this->contentLength;
Expand Down Expand Up @@ -96,6 +100,11 @@ public function getContents($length = -1)
}
}

public function getMetadata($key = null)
{
return null;
}

public function isChunkEncoded()
{
return $this->chunkedEncoding;
Expand Down
13 changes: 11 additions & 2 deletions library/PSX/Http/Stream/StringStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace PSX\Http\Stream;

use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;

/**
* Stream wich works on an string therefore the size of the stream is limited to
Expand All @@ -33,7 +33,7 @@
* @license http://www.gnu.org/licenses/gpl.html GPLv3
* @link http://phpsx.org
*/
class StringStream implements StreamInterface
class StringStream implements StreamableInterface
{
protected $data;
protected $length;
Expand Down Expand Up @@ -68,6 +68,10 @@ public function detach()
return null;
}

public function attach($stream)
{
}

public function getSize()
{
return $this->length;
Expand Down Expand Up @@ -179,6 +183,11 @@ public function getContents($maxLength = -1)
return $data;
}

public function getMetadata($key = null)
{
return null;
}

public function __toString()
{
return $this->data === null ? '' : $this->data;
Expand Down
13 changes: 11 additions & 2 deletions library/PSX/Http/Stream/TempStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace PSX\Http\Stream;

use InvalidArgumentException;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\StreamableInterface;

/**
* The curl handler writes the http body response into an php://temp stream
Expand All @@ -36,7 +36,7 @@
* @license http://www.gnu.org/licenses/gpl.html GPLv3
* @link http://phpsx.org
*/
class TempStream implements StreamInterface
class TempStream implements StreamableInterface
{
protected $resource;
protected $seekable;
Expand Down Expand Up @@ -79,6 +79,10 @@ public function detach()
return $handle;
}

public function attach($stream)
{
}

public function getSize()
{
if($this->resource)
Expand Down Expand Up @@ -166,6 +170,11 @@ public function getContents($length = -1)
return null;
}

public function getMetadata($key = null)
{
return null;
}

public function __toString()
{
if($this->resource)
Expand Down
Loading

0 comments on commit a708210

Please sign in to comment.