Commit fbb6e926 authored by webchick's avatar webchick

Issue #2400407 by hussainweb: Update Zend Framework library to latest version.

parent a012eff4
......@@ -25,7 +25,7 @@
"symfony-cmf/routing": "1.3.*",
"easyrdf/easyrdf": "0.9.*",
"phpunit/phpunit": "4.8.*",
"zendframework/zend-feed": "2.4.*",
"zendframework/zend-feed": "~2.4",
"mikey179/vfsStream": "~1.2",
"stack/builder": "1.0.*",
"egulias/email-validator": "1.2.*",
......@@ -34,7 +34,7 @@
"fabpot/goutte": "~3.1",
"masterminds/html5": "~2.1",
"symfony/psr-http-message-bridge": "v0.2",
"zendframework/zend-diactoros": "1.1.0"
"zendframework/zend-diactoros": "~1.1"
},
"replace": {
"drupal/action": "self.version",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "98540c017d14f1cad9f0b1bc722600ad",
"hash": "32a7f1295f8f5ccdf8b5759f9eb6e626",
"packages": [
{
"name": "behat/mink",
......@@ -3163,16 +3163,16 @@
},
{
"name": "zendframework/zend-diactoros",
"version": "1.1.0",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-diactoros.git",
"reference": "df65f70fc36f24d51a90ad706a09cd9b74fc4dd8"
"reference": "e2f5c12916c74da384058d0dfbc7fbc0b03d1181"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/df65f70fc36f24d51a90ad706a09cd9b74fc4dd8",
"reference": "df65f70fc36f24d51a90ad706a09cd9b74fc4dd8",
"url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/e2f5c12916c74da384058d0dfbc7fbc0b03d1181",
"reference": "e2f5c12916c74da384058d0dfbc7fbc0b03d1181",
"shasum": ""
},
"require": {
......@@ -3209,73 +3209,79 @@
"psr",
"psr-7"
],
"time": "2015-06-24 20:42:54"
"time": "2015-08-10 20:04:20"
},
{
"name": "zendframework/zend-escaper",
"version": "2.4.0",
"version": "2.5.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-escaper.git",
"reference": "65b3328627362b0be1d5e9067bc846511d1fbc96"
"reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/15e5769e4fcdb4bf07ebd76500810e7070e23a97",
"reference": "65b3328627362b0be1d5e9067bc846511d1fbc96",
"url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73",
"reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73",
"shasum": ""
},
"require": {
"php": ">=5.3.23"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev",
"dev-develop": "2.4-dev"
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Escaper\\": ""
"Zend\\Escaper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://github.com/zendframework/zf2",
"homepage": "https://github.com/zendframework/zend-escaper",
"keywords": [
"escaper",
"zf2"
],
"time": "2015-04-01 18:02:07"
"time": "2015-06-03 14:05:37"
},
{
"name": "zendframework/zend-feed",
"version": "2.4.0",
"version": "2.5.2",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-feed.git",
"reference": "aca2b42ecf06d94c621e3c3be8e95d61d3a79bf5"
"reference": "0661345b82b51428619e05d3aadd3de65b57fa54"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-feed/zipball/0f59e560364f1f1fcb09a96874328ae3ff690db2",
"reference": "aca2b42ecf06d94c621e3c3be8e95d61d3a79bf5",
"url": "https://api.github.com/repos/zendframework/zend-feed/zipball/0661345b82b51428619e05d3aadd3de65b57fa54",
"reference": "0661345b82b51428619e05d3aadd3de65b57fa54",
"shasum": ""
},
"require": {
"php": ">=5.3.23",
"zendframework/zend-escaper": "self.version",
"zendframework/zend-stdlib": "self.version"
"php": ">=5.5",
"zendframework/zend-escaper": "~2.5",
"zendframework/zend-stdlib": "~2.5"
},
"require-dev": {
"zendframework/zend-cache": "self.version",
"zendframework/zend-db": "self.version",
"zendframework/zend-http": "self.version",
"zendframework/zend-servicemanager": "self.version",
"zendframework/zend-validator": "self.version"
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0",
"zendframework/zend-cache": "~2.5",
"zendframework/zend-db": "~2.5",
"zendframework/zend-http": "~2.5",
"zendframework/zend-servicemanager": "~2.5",
"zendframework/zend-validator": "~2.5"
},
"suggest": {
"zendframework/zend-cache": "Zend\\Cache component",
......@@ -3287,13 +3293,13 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev",
"dev-develop": "2.4-dev"
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Feed\\": ""
"Zend\\Feed\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
......@@ -3301,35 +3307,39 @@
"BSD-3-Clause"
],
"description": "provides functionality for consuming RSS and Atom feeds",
"homepage": "https://github.com/zendframework/zf2",
"homepage": "https://github.com/zendframework/zend-feed",
"keywords": [
"feed",
"zf2"
],
"time": "2015-04-01 18:09:25"
"time": "2015-08-04 21:39:18"
},
{
"name": "zendframework/zend-stdlib",
"version": "2.4.0",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-stdlib.git",
"reference": "eab586f4c18af3fa63c977611939f1f4a3cf1030"
"reference": "a35758803fc9051ec1aff43989e679b6b451b1b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cf05c5ba75606e47ffee91cedc72778da46f74c3",
"reference": "eab586f4c18af3fa63c977611939f1f4a3cf1030",
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/a35758803fc9051ec1aff43989e679b6b451b1b4",
"reference": "a35758803fc9051ec1aff43989e679b6b451b1b4",
"shasum": ""
},
"require": {
"php": ">=5.3.23"
"php": ">=5.5"
},
"require-dev": {
"zendframework/zend-eventmanager": "self.version",
"zendframework/zend-filter": "self.version",
"zendframework/zend-serializer": "self.version",
"zendframework/zend-servicemanager": "self.version"
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0",
"zendframework/zend-config": "~2.5",
"zendframework/zend-eventmanager": "~2.5",
"zendframework/zend-filter": "~2.5",
"zendframework/zend-inputfilter": "~2.5",
"zendframework/zend-serializer": "~2.5",
"zendframework/zend-servicemanager": "~2.5"
},
"suggest": {
"zendframework/zend-eventmanager": "To support aggregate hydrator usage",
......@@ -3340,25 +3350,25 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev",
"dev-develop": "2.4-dev"
"dev-master": "2.6-dev",
"dev-develop": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Stdlib\\": ""
"Zend\\Stdlib\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://github.com/zendframework/zf2",
"homepage": "https://github.com/zendframework/zend-stdlib",
"keywords": [
"stdlib",
"zf2"
],
"time": "2015-04-01 18:09:29"
"time": "2015-07-21 17:08:05"
}
],
"packages-dev": [],
......
......@@ -6,9 +6,9 @@
$baseDir = dirname($vendorDir);
return array(
'Zend\\Stdlib\\' => array($vendorDir . '/zendframework/zend-stdlib'),
'Zend\\Feed\\' => array($vendorDir . '/zendframework/zend-feed'),
'Zend\\Escaper\\' => array($vendorDir . '/zendframework/zend-escaper'),
'Zend\\Stdlib\\' => array($vendorDir . '/zendframework/zend-stdlib/src'),
'Zend\\Feed\\' => array($vendorDir . '/zendframework/zend-feed/src'),
'Zend\\Escaper\\' => array($vendorDir . '/zendframework/zend-escaper/src'),
'Zend\\Diactoros\\' => array($vendorDir . '/zendframework/zend-diactoros/src'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Symfony\\Component\\Validator\\' => array($vendorDir . '/symfony/validator'),
......
This diff is collapsed.
......@@ -2,6 +2,77 @@
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 1.1.3 - 2015-08-10
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#71](https://github.com/zendframework/zend-diactoros/pull/71) fixes the
docblock of the `JsonResponse` constructor to typehint the `$data` argument
as `mixed`.
- [#73](https://github.com/zendframework/zend-diactoros/pull/73) changes the
behavior in `Request` such that if it marshals a stream during instantiation,
the stream is marked as writeable (specifically, mode `wb+`).
- [#85](https://github.com/zendframework/zend-diactoros/pull/85) updates the
behavior of `Zend\Diactoros\Uri`'s various `with*()` methods that are
documented as accepting strings to raise exceptions on non-string input.
Previously, several simply passed non-string input on verbatim, others
normalized the input, and a few correctly raised the exceptions. Behavior is
now consistent across each.
- [#87](https://github.com/zendframework/zend-diactoros/pull/87) fixes
`UploadedFile` to ensure that `moveTo()` works correctly in non-SAPI
environments when the file provided to the constructor is a path.
## 1.1.2 - 2015-07-12
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#67](https://github.com/zendframework/zend-diactoros/pull/67) ensures that
the `Stream` class only accepts `stream` resources, not any resource.
## 1.1.1 - 2015-06-25
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#64](https://github.com/zendframework/zend-diactoros/pull/64) fixes the
behavior of `JsonResponse` with regards to serialization of `null` and scalar
values; the new behavior is to serialize them verbatim, without any casting.
## 1.1.0 - 2015-06-24
### Added
......
......@@ -34,7 +34,7 @@ $ php -S 0.0.0.0:8080 -t doc/html/ # then browse to http://localhost:8080/
[Master image]: https://secure.travis-ci.org/zendframework/zend-diactoros.svg?branch=master
[Master coverage image]: https://img.shields.io/coveralls/zendframework/zend-diactoros/master.svg
[Master coverage]: https://coveralls.io/r/zendframework/zend-diactoros?branch=master
[Develop]: https://github.com/zendframeowork/zend-diactoros/tree/develop
[Develop]: https://github.com/zendframework/zend-diactoros/tree/develop
[Develop image]: https://secure.travis-ci.org/zendframework/zend-diactoros.svg?branch=develop
[Develop coverage image]: https://coveralls.io/repos/zendframework/zend-diactoros/badge.svg?branch=develop
[Develop coverage]: https://coveralls.io/r/zendframework/zend-diactoros?branch=develop
......@@ -82,7 +82,7 @@ private function initialize($uri = null, $method = null, $body = 'php://memory',
$this->method = $method ?: '';
$this->uri = $uri ?: new Uri();
$this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'r');
$this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'wb+');
list($this->headerNames, $headers) = $this->filterHeaders($headers);
$this->assertHeaders($headers);
......
......@@ -9,27 +9,23 @@
namespace Zend\Diactoros\Response;
use ArrayObject;
use InvalidArgumentException;
use Zend\Diactoros\Response;
use Zend\Diactoros\Stream;
/**
* HTML response.
* JSON response.
*
* Allows creating a response by passing an HTML string to the constructor;
* by default, sets a status code of 200 and sets the Content-Type header to
* text/html.
* Allows creating a response by passing data to the constructor; by default,
* serializes the data to JSON, sets a status code of 200 and sets the
* Content-Type header to application/json.
*/
class JsonResponse extends Response
{
use InjectContentTypeTrait;
/**
* Create a JSON response with the given array of data.
*
* If the data provided is null, an empty ArrayObject is used; if the data
* is scalar, it is cast to an array prior to serialization.
* Create a JSON response with the given data.
*
* Default JSON encoding is performed with the following options, which
* produces RFC4627-compliant JSON, capable of embedding into HTML.
......@@ -39,7 +35,7 @@ class JsonResponse extends Response
* - JSON_HEX_AMP
* - JSON_HEX_QUOT
*
* @param string $data Data to convert to JSON.
* @param mixed $data Data to convert to JSON.
* @param int $status Integer status code for the response; 200 by default.
* @param array $headers Array of headers to use at initialization.
* @param int $encodingOptions JSON encoding options to use.
......@@ -69,15 +65,6 @@ private function jsonEncode($data, $encodingOptions)
throw new InvalidArgumentException('Cannot JSON encode resources');
}
if ($data === null) {
// Use an ArrayObject to force an empty JSON object.
$data = new ArrayObject();
}
if (is_scalar($data)) {
$data = (array) $data;
}
// Clear json_last_error()
json_encode(null);
......
......@@ -35,23 +35,7 @@ class Stream implements StreamInterface
*/
public function __construct($stream, $mode = 'r')
{
$this->stream = $stream;
if (is_resource($stream)) {
$this->resource = $stream;
} elseif (is_string($stream)) {
set_error_handler(function ($errno, $errstr) {
throw new InvalidArgumentException(
'Invalid file provided for stream; must be a valid path with valid permissions'
);
}, E_WARNING);
$this->resource = fopen($stream, $mode);
restore_error_handler();
} else {
throw new InvalidArgumentException(
'Invalid stream provided; must be a string stream identifier or resource'
);
}
$this->setStream($stream, $mode);
}
/**
......@@ -105,26 +89,7 @@ public function detach()
*/
public function attach($resource, $mode = 'r')
{
$error = null;
if (! is_resource($resource) && is_string($resource)) {
set_error_handler(function ($e) use (&$error) {
$error = $e;
}, E_WARNING);
$resource = fopen($resource, $mode);
restore_error_handler();
}
if ($error) {
throw new InvalidArgumentException('Invalid stream reference provided');
}
if (! is_resource($resource)) {
throw new InvalidArgumentException(
'Invalid stream provided; must be a string stream identifier or resource'
);
}
$this->resource = $resource;
$this->setStream($resource, $mode);
}
/**
......@@ -323,4 +288,41 @@ public function getMetadata($key = null)
return $metadata[$key];
}
/**
* Set the internal stream resource.
*
* @param string|resource $stream String stream target or stream resource.
* @param string $mode Resource mode for stream target.
* @throws InvalidArgumentException for invalid streams or resources.
*/
private function setStream($stream, $mode = 'r')
{
$error = null;
$resource = $stream;
if (is_string($stream)) {
set_error_handler(function ($e) use (&$error) {
$error = $e;
}, E_WARNING);
$resource = fopen($stream, $mode);
restore_error_handler();
}
if ($error) {
throw new InvalidArgumentException('Invalid stream reference provided');
}
if (! is_resource($resource) || 'stream' !== get_resource_type($resource)) {
throw new InvalidArgumentException(
'Invalid stream provided; must be a string stream identifier or stream resource'
);
}
if ($stream !== $resource) {
$this->stream = $stream;
}
$this->resource = $resource;
}
}
......@@ -223,9 +223,10 @@ private function writeFile($path)
throw new RuntimeException('Unable to write to designated path');
}
$this->stream->rewind();
while (! $this->stream->eof()) {
fwrite($handle, $this->stream->read(4096));
$stream = $this->getStream();
$stream->rewind();
while (! $stream->eof()) {
fwrite($handle, $stream->read(4096));
}
fclose($handle);
......
......@@ -220,6 +220,14 @@ public function getFragment()
*/
public function withScheme($scheme)
{
if (! is_string($scheme)) {
throw new InvalidArgumentException(sprintf(
'%s expects a string argument; received %s',
__METHOD__,
(is_object($scheme) ? get_class($scheme) : gettype($scheme))
));
}
$scheme = $this->filterScheme($scheme);
if ($scheme === $this->scheme) {
......@@ -238,6 +246,21 @@ public function withScheme($scheme)
*/
public function withUserInfo($user, $password = null)
{
if (! is_string($user)) {
throw new InvalidArgumentException(sprintf(
'%s expects a string user argument; received %s',
__METHOD__,
(is_object($user) ? get_class($user) : gettype($user))
));
}
if (null !== $password && ! is_string($password)) {
throw new InvalidArgumentException(sprintf(
'%s expects a string password argument; received %s',
__METHOD__,
(is_object($password) ? get_class($password) : gettype($password))
));
}
$info = $user;
if ($password) {
$info .= ':' . $password;
......@@ -259,6 +282,14 @@ public function withUserInfo($user, $password = null)
*/
public function withHost($host)
{
if (! is_string($host)) {
throw new InvalidArgumentException(sprintf(
'%s expects a string argument; received %s',
__METHOD__,
(is_object($host) ? get_class($host) : gettype($host))
));
}
if ($host === $this->host) {
// Do nothing if no change was made.
return clone $this;
......@@ -373,6 +404,14 @@ public function withQuery($query)