mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
обновление библиотек
This commit is contained in:
parent
e7e5666aec
commit
97de02e919
216 changed files with 1595 additions and 591 deletions
2
library/TorrentPier/ReCaptcha/ReCaptcha.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/ReCaptcha.php
Executable file → Normal file
|
@ -94,4 +94,4 @@ class ReCaptcha
|
||||||
$rawResponse = $this->requestMethod->submit($params);
|
$rawResponse = $this->requestMethod->submit($params);
|
||||||
return Response::fromJson($rawResponse);
|
return Response::fromJson($rawResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
library/TorrentPier/ReCaptcha/RequestMethod.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/RequestMethod.php
Executable file → Normal file
|
@ -39,4 +39,4 @@ interface RequestMethod
|
||||||
* @return string Body of the reCAPTCHA response
|
* @return string Body of the reCAPTCHA response
|
||||||
*/
|
*/
|
||||||
public function submit(RequestParameters $params);
|
public function submit(RequestParameters $params);
|
||||||
}
|
}
|
||||||
|
|
2
library/TorrentPier/ReCaptcha/RequestMethod/Post.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/RequestMethod/Post.php
Executable file → Normal file
|
@ -67,4 +67,4 @@ class Post implements RequestMethod
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
return file_get_contents(self::SITE_VERIFY_URL, false, $context);
|
return file_get_contents(self::SITE_VERIFY_URL, false, $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
library/TorrentPier/ReCaptcha/RequestMethod/Socket.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/RequestMethod/Socket.php
Executable file → Normal file
|
@ -101,4 +101,4 @@ class Socket
|
||||||
{
|
{
|
||||||
return fclose($this->handle);
|
return fclose($this->handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
library/TorrentPier/ReCaptcha/RequestMethod/SocketPost.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/RequestMethod/SocketPost.php
Executable file → Normal file
|
@ -117,4 +117,4 @@ class SocketPost implements RequestMethod
|
||||||
|
|
||||||
return self::BAD_REQUEST;
|
return self::BAD_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
library/TorrentPier/ReCaptcha/RequestParameters.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/RequestParameters.php
Executable file → Normal file
|
@ -100,4 +100,4 @@ class RequestParameters
|
||||||
{
|
{
|
||||||
return http_build_query($this->toArray(), '', '&');
|
return http_build_query($this->toArray(), '', '&');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
library/TorrentPier/ReCaptcha/Response.php
Executable file → Normal file
2
library/TorrentPier/ReCaptcha/Response.php
Executable file → Normal file
|
@ -99,4 +99,4 @@ class Response
|
||||||
{
|
{
|
||||||
return $this->errorCodes;
|
return $this->errorCodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ abstract class AbstractAdapter extends BaseAdapter
|
||||||
*/
|
*/
|
||||||
public function getDbSelect()
|
public function getDbSelect()
|
||||||
{
|
{
|
||||||
if ($this->dbSelect == null) {
|
if ($this->dbSelect === null) {
|
||||||
$this->dbSelect = new Sql\Select();
|
$this->dbSelect = new Sql\Select();
|
||||||
}
|
}
|
||||||
return $this->dbSelect;
|
return $this->dbSelect;
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,7 +375,7 @@ class Image extends AbstractRenderer
|
||||||
$color & 0x0000FF
|
$color & 0x0000FF
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($font == null) {
|
if ($font === null) {
|
||||||
$font = 3;
|
$font = 3;
|
||||||
}
|
}
|
||||||
$position[0] += $this->leftOffset;
|
$position[0] += $this->leftOffset;
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ class MongoDbOptions extends AdapterOptions
|
||||||
private $namespaceSeparator = ':';
|
private $namespaceSeparator = ':';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The redis resource manager
|
* The mongo DB resource manager
|
||||||
*
|
*
|
||||||
* @var null|RedisResourceManager
|
* @var null|MongoDbResourceManager
|
||||||
*/
|
*/
|
||||||
private $resourceManager;
|
private $resourceManager;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class MongoDbOptions extends AdapterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the redis resource id
|
* Set the mongodb resource id
|
||||||
*
|
*
|
||||||
* @param string $resourceId
|
* @param string $resourceId
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -943,6 +943,8 @@ class ClassGenerator extends AbstractGenerator
|
||||||
|
|
||||||
if ($this->isAbstract()) {
|
if ($this->isAbstract()) {
|
||||||
$output .= 'abstract ';
|
$output .= 'abstract ';
|
||||||
|
} elseif ($this->isFinal()) {
|
||||||
|
$output .= 'final ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= static::OBJECT_TYPE . ' ' . $this->getName();
|
$output .= static::OBJECT_TYPE . ' ' . $this->getName();
|
||||||
|
|
|
@ -302,7 +302,7 @@ class FileGenerator extends AbstractGenerator
|
||||||
*/
|
*/
|
||||||
public function getClass($name = null)
|
public function getClass($name = null)
|
||||||
{
|
{
|
||||||
if ($name == null) {
|
if ($name === null) {
|
||||||
reset($this->classes);
|
reset($this->classes);
|
||||||
|
|
||||||
return current($this->classes);
|
return current($this->classes);
|
||||||
|
|
|
@ -27,7 +27,7 @@ class FileGeneratorRegistry
|
||||||
*/
|
*/
|
||||||
public static function registerFileCodeGenerator(FileGenerator $fileCodeGenerator, $fileName = null)
|
public static function registerFileCodeGenerator(FileGenerator $fileCodeGenerator, $fileName = null)
|
||||||
{
|
{
|
||||||
if ($fileName == null) {
|
if ($fileName === null) {
|
||||||
$fileName = $fileCodeGenerator->getFilename();
|
$fileName = $fileCodeGenerator->getFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ class PropertyGenerator extends AbstractMemberGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isConst()) {
|
if ($this->isConst()) {
|
||||||
if ($defaultValue != null && !$defaultValue->isValidConstantType()) {
|
if ($defaultValue !== null && !$defaultValue->isValidConstantType()) {
|
||||||
throw new Exception\RuntimeException(sprintf(
|
throw new Exception\RuntimeException(sprintf(
|
||||||
'The property %s is said to be '
|
'The property %s is said to be '
|
||||||
. 'constant but does not have a valid constant value.',
|
. 'constant but does not have a valid constant value.',
|
||||||
|
|
|
@ -58,7 +58,7 @@ class NameInformation
|
||||||
*/
|
*/
|
||||||
public function hasNamespace()
|
public function hasNamespace()
|
||||||
{
|
{
|
||||||
return ($this->namespace != null);
|
return ($this->namespace !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -177,11 +177,16 @@ class ClassReflection extends ReflectionClass implements ReflectionInterface
|
||||||
return $methods;
|
return $methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of reflection classes of traits used by this class.
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function getTraits()
|
public function getTraits()
|
||||||
{
|
{
|
||||||
$vals = array();
|
$vals = array();
|
||||||
$traits = parent::getTraits();
|
$traits = parent::getTraits();
|
||||||
if (! $traits) {
|
if ($traits === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ParameterReflection extends ReflectionParameter implements ReflectionInter
|
||||||
public function getClass()
|
public function getClass()
|
||||||
{
|
{
|
||||||
$phpReflection = parent::getClass();
|
$phpReflection = parent::getClass();
|
||||||
if ($phpReflection == null) {
|
if ($phpReflection === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@ class ClassScanner implements ScannerInterface
|
||||||
public function hasParentClass()
|
public function hasParentClass()
|
||||||
{
|
{
|
||||||
$this->scan();
|
$this->scan();
|
||||||
return ($this->parentClass != null);
|
return ($this->parentClass !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,7 +123,7 @@ class DerivedClassScanner extends ClassScanner
|
||||||
*/
|
*/
|
||||||
public function hasParentClass()
|
public function hasParentClass()
|
||||||
{
|
{
|
||||||
return ($this->classScanner->getParentClass() != null);
|
return ($this->classScanner->getParentClass() !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -587,7 +587,7 @@ class TokenArrayScanner implements ScannerInterface
|
||||||
|| ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function'))
|
|| ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function'))
|
||||||
) {
|
) {
|
||||||
$infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1];
|
$infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1];
|
||||||
$infos[$infoIndex]['name'] = (($namespace != null) ? $namespace . '\\' : '') . $infos[$infoIndex]['shortName'];
|
$infos[$infoIndex]['name'] = (($namespace !== null) ? $namespace . '\\' : '') . $infos[$infoIndex]['shortName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tokenType === null) {
|
if ($tokenType === null) {
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,10 @@ class Response extends Message implements ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function setErrorLevel($errorLevel)
|
public function setErrorLevel($errorLevel)
|
||||||
{
|
{
|
||||||
|
if (is_string($errorLevel) && !ctype_digit($errorLevel)) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->setMetadata('errorLevel', $errorLevel);
|
$this->setMetadata('errorLevel', $errorLevel);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface
|
||||||
$driver->checkEnvironment();
|
$driver->checkEnvironment();
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
|
|
||||||
if ($platform == null) {
|
if ($platform === null) {
|
||||||
$platform = $this->createPlatform($parameters);
|
$platform = $this->createPlatform($parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface
|
||||||
*/
|
*/
|
||||||
public function getDriver()
|
public function getDriver()
|
||||||
{
|
{
|
||||||
if ($this->driver == null) {
|
if ($this->driver === null) {
|
||||||
throw new Exception\RuntimeException('Driver has not been set or configured for this adapter.');
|
throw new Exception\RuntimeException('Driver has not been set or configured for this adapter.');
|
||||||
}
|
}
|
||||||
return $this->driver;
|
return $this->driver;
|
||||||
|
@ -209,7 +209,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface
|
||||||
public function createStatement($initialSql = null, $initialParameters = null)
|
public function createStatement($initialSql = null, $initialParameters = null)
|
||||||
{
|
{
|
||||||
$statement = $this->driver->createStatement($initialSql);
|
$statement = $this->driver->createStatement($initialSql);
|
||||||
if ($initialParameters == null || !$initialParameters instanceof ParameterContainer && is_array($initialParameters)) {
|
if ($initialParameters === null || !$initialParameters instanceof ParameterContainer && is_array($initialParameters)) {
|
||||||
$initialParameters = new ParameterContainer((is_array($initialParameters) ? $initialParameters : array()));
|
$initialParameters = new ParameterContainer((is_array($initialParameters) ? $initialParameters : array()));
|
||||||
}
|
}
|
||||||
$statement->setParameterContainer($initialParameters);
|
$statement->setParameterContainer($initialParameters);
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface
|
||||||
throw new Exception\RuntimeException('This statement has been prepared already');
|
throw new Exception\RuntimeException('This statement has been prepared already');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sql == null) {
|
if ($sql === null) {
|
||||||
$sql = $this->sql;
|
$sql = $this->sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,7 @@ class Pdo implements DriverInterface, DriverFeatureInterface, Profiler\ProfilerA
|
||||||
*/
|
*/
|
||||||
public function formatParameterName($name, $type = null)
|
public function formatParameterName($name, $type = null)
|
||||||
{
|
{
|
||||||
if ($type == null && !is_numeric($name) || $type == self::PARAMETERIZATION_NAMED) {
|
if ($type === null && !is_numeric($name) || $type == self::PARAMETERIZATION_NAMED) {
|
||||||
return ':' . $name;
|
return ':' . $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface
|
||||||
throw new Exception\RuntimeException('This statement has been prepared already');
|
throw new Exception\RuntimeException('This statement has been prepared already');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sql == null) {
|
if ($sql === null) {
|
||||||
$sql = $this->sql;
|
$sql = $this->sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@ class Connection extends AbstractConnection
|
||||||
*/
|
*/
|
||||||
protected $driver = null;
|
protected $driver = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null|int PostgreSQL connection type
|
||||||
|
*/
|
||||||
|
protected $type = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -46,6 +51,26 @@ class Connection extends AbstractConnection
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int|null $type
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setType($type)
|
||||||
|
{
|
||||||
|
$invalidConectionType = ($type !== PGSQL_CONNECT_FORCE_NEW);
|
||||||
|
|
||||||
|
// Compatibility with PHP < 5.6
|
||||||
|
if ($invalidConectionType && defined('PGSQL_CONNECT_ASYNC')) {
|
||||||
|
$invalidConectionType = ($type !== PGSQL_CONNECT_ASYNC);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($invalidConectionType) {
|
||||||
|
throw new Exception\InvalidArgumentException('Connection type is not valid. (See: http://php.net/manual/en/function.pg-connect.php)');
|
||||||
|
}
|
||||||
|
$this->type = $type;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -109,6 +134,7 @@ class Connection extends AbstractConnection
|
||||||
public function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
pg_close($this->resource);
|
pg_close($this->resource);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +233,7 @@ class Connection extends AbstractConnection
|
||||||
*/
|
*/
|
||||||
public function getLastGeneratedValue($name = null)
|
public function getLastGeneratedValue($name = null)
|
||||||
{
|
{
|
||||||
if ($name == null) {
|
if ($name === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$result = pg_query($this->resource, 'SELECT CURRVAL(\'' . str_replace('\'', '\\\'', $name) . '\') as "currval"');
|
$result = pg_query($this->resource, 'SELECT CURRVAL(\'' . str_replace('\'', '\\\'', $name) . '\') as "currval"');
|
||||||
|
|
|
@ -165,7 +165,7 @@ class Sqlsrv implements DriverInterface, Profiler\ProfilerAwareInterface
|
||||||
$statement->initialize($this->connection->getResource());
|
$statement->initialize($this->connection->getResource());
|
||||||
if (is_string($sqlOrResource)) {
|
if (is_string($sqlOrResource)) {
|
||||||
$statement->setSql($sqlOrResource);
|
$statement->setSql($sqlOrResource);
|
||||||
} elseif ($sqlOrResource != null) {
|
} elseif ($sqlOrResource !== null) {
|
||||||
throw new Exception\InvalidArgumentException('createStatement() only accepts an SQL string or a Sqlsrv resource');
|
throw new Exception\InvalidArgumentException('createStatement() only accepts an SQL string or a Sqlsrv resource');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
0
library/TorrentPier/Zend/Db/Adapter/Platform/AbstractPlatform.php
Normal file → Executable file
0
library/TorrentPier/Zend/Db/Adapter/Platform/AbstractPlatform.php
Normal file → Executable file
|
@ -90,7 +90,7 @@ abstract class AbstractResultSet implements Iterator, ResultSetInterface
|
||||||
throw new Exception\InvalidArgumentException('DataSource provided is not an array, nor does it implement Iterator or IteratorAggregate');
|
throw new Exception\InvalidArgumentException('DataSource provided is not an array, nor does it implement Iterator or IteratorAggregate');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->count == null && $this->dataSource instanceof Countable) {
|
if ($this->count === null && $this->dataSource instanceof Countable) {
|
||||||
$this->count = $this->dataSource->count();
|
$this->count = $this->dataSource->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ abstract class AbstractRowGateway implements ArrayAccess, Countable, RowGatewayI
|
||||||
throw new Exception\RuntimeException('This row object does not have a valid table set.');
|
throw new Exception\RuntimeException('This row object does not have a valid table set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->primaryKeyColumn == null) {
|
if ($this->primaryKeyColumn === null) {
|
||||||
throw new Exception\RuntimeException('This row object does not have a primary key column set.');
|
throw new Exception\RuntimeException('This row object does not have a primary key column set.');
|
||||||
} elseif (is_string($this->primaryKeyColumn)) {
|
} elseif (is_string($this->primaryKeyColumn)) {
|
||||||
$this->primaryKeyColumn = (array) $this->primaryKeyColumn;
|
$this->primaryKeyColumn = (array) $this->primaryKeyColumn;
|
||||||
|
|
|
@ -47,18 +47,26 @@ abstract class AbstractSql implements SqlInterface
|
||||||
* @param PlatformInterface $platform
|
* @param PlatformInterface $platform
|
||||||
* @param null|DriverInterface $driver
|
* @param null|DriverInterface $driver
|
||||||
* @param null|ParameterContainer $parameterContainer
|
* @param null|ParameterContainer $parameterContainer
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function buildSqlString(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
|
protected function buildSqlString(
|
||||||
{
|
PlatformInterface $platform,
|
||||||
|
DriverInterface $driver = null,
|
||||||
|
ParameterContainer $parameterContainer = null
|
||||||
|
) {
|
||||||
$this->localizeVariables();
|
$this->localizeVariables();
|
||||||
|
|
||||||
$sqls = array();
|
$sqls = array();
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
foreach ($this->specifications as $name => $specification) {
|
foreach ($this->specifications as $name => $specification) {
|
||||||
$parameters[$name] = $this->{'process' . $name}($platform, $driver, $parameterContainer, $sqls, $parameters);
|
$parameters[$name] = $this->{'process' . $name}(
|
||||||
|
$platform,
|
||||||
|
$driver,
|
||||||
|
$parameterContainer,
|
||||||
|
$sqls,
|
||||||
|
$parameters
|
||||||
|
);
|
||||||
|
|
||||||
if ($specification && is_array($parameters[$name])) {
|
if ($specification && is_array($parameters[$name])) {
|
||||||
$sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
|
$sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
|
||||||
|
@ -74,26 +82,32 @@ abstract class AbstractSql implements SqlInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @staticvar int $runtimeExpressionPrefix
|
* @staticvar int $runtimeExpressionPrefix
|
||||||
* @param ExpressionInterface $expression
|
* @param ExpressionInterface $expression
|
||||||
* @param PlatformInterface $platform
|
* @param PlatformInterface $platform
|
||||||
* @param null|DriverInterface $driver
|
* @param null|DriverInterface $driver
|
||||||
* @param null|ParameterContainer $parameterContainer
|
* @param null|ParameterContainer $parameterContainer
|
||||||
* @param null|string $namedParameterPrefix
|
* @param null|string $namedParameterPrefix
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*
|
|
||||||
* @throws Exception\RuntimeException
|
* @throws Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, $namedParameterPrefix = null)
|
protected function processExpression(
|
||||||
{
|
ExpressionInterface $expression,
|
||||||
$namedParameterPrefix = !$namedParameterPrefix ? $namedParameterPrefix : $this->processInfo['paramPrefix'] . $namedParameterPrefix;
|
PlatformInterface $platform,
|
||||||
|
DriverInterface $driver = null,
|
||||||
|
ParameterContainer $parameterContainer = null,
|
||||||
|
$namedParameterPrefix = null
|
||||||
|
) {
|
||||||
|
$namedParameterPrefix = ! $namedParameterPrefix
|
||||||
|
? $namedParameterPrefix
|
||||||
|
: $this->processInfo['paramPrefix'] . $namedParameterPrefix;
|
||||||
// static counter for the number of times this method was invoked across the PHP runtime
|
// static counter for the number of times this method was invoked across the PHP runtime
|
||||||
static $runtimeExpressionPrefix = 0;
|
static $runtimeExpressionPrefix = 0;
|
||||||
|
|
||||||
if ($parameterContainer && ((!is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) {
|
if ($parameterContainer && ((!is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) {
|
||||||
$namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix);
|
$namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix);
|
||||||
|
} else {
|
||||||
|
$namedParameterPrefix = preg_replace('/\s/', '__', $namedParameterPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
@ -108,10 +122,17 @@ abstract class AbstractSql implements SqlInterface
|
||||||
$expressionParamIndex = &$this->instanceParameterIndex[$namedParameterPrefix];
|
$expressionParamIndex = &$this->instanceParameterIndex[$namedParameterPrefix];
|
||||||
|
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
// if it is a string, simply tack it onto the return sql "specification" string
|
// #7407: use $expression->getExpression() to get the unescaped
|
||||||
|
// version of the expression
|
||||||
|
if (is_string($part) && $expression instanceof Expression) {
|
||||||
|
$sql .= $expression->getExpression();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it is a string, simply tack it onto the return sql
|
||||||
|
// "specification" string
|
||||||
if (is_string($part)) {
|
if (is_string($part)) {
|
||||||
$sql .= $part;
|
$sql .= $part;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +142,8 @@ abstract class AbstractSql implements SqlInterface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process values and types (the middle and last position of the expression data)
|
// Process values and types (the middle and last position of the
|
||||||
|
// expression data)
|
||||||
$values = $part[1];
|
$values = $part[1];
|
||||||
$types = isset($part[2]) ? $part[2] : array();
|
$types = isset($part[2]) ? $part[2] : array();
|
||||||
foreach ($values as $vIndex => $value) {
|
foreach ($values as $vIndex => $value) {
|
||||||
|
@ -131,10 +153,18 @@ abstract class AbstractSql implements SqlInterface
|
||||||
$type = $types[$vIndex];
|
$type = $types[$vIndex];
|
||||||
if ($value instanceof Select) {
|
if ($value instanceof Select) {
|
||||||
// process sub-select
|
// process sub-select
|
||||||
$values[$vIndex] = '(' . $this->processSubSelect($value, $platform, $driver, $parameterContainer) . ')';
|
$values[$vIndex] = '('
|
||||||
|
. $this->processSubSelect($value, $platform, $driver, $parameterContainer)
|
||||||
|
. ')';
|
||||||
} elseif ($value instanceof ExpressionInterface) {
|
} elseif ($value instanceof ExpressionInterface) {
|
||||||
// recursive call to satisfy nested expressions
|
// recursive call to satisfy nested expressions
|
||||||
$values[$vIndex] = $this->processExpression($value, $platform, $driver, $parameterContainer, $namedParameterPrefix . $vIndex . 'subpart');
|
$values[$vIndex] = $this->processExpression(
|
||||||
|
$value,
|
||||||
|
$platform,
|
||||||
|
$driver,
|
||||||
|
$parameterContainer,
|
||||||
|
$namedParameterPrefix . $vIndex . 'subpart'
|
||||||
|
);
|
||||||
} elseif ($type == ExpressionInterface::TYPE_IDENTIFIER) {
|
} elseif ($type == ExpressionInterface::TYPE_IDENTIFIER) {
|
||||||
$values[$vIndex] = $platform->quoteIdentifierInFragment($value);
|
$values[$vIndex] = $platform->quoteIdentifierInFragment($value);
|
||||||
} elseif ($type == ExpressionInterface::TYPE_VALUE) {
|
} elseif ($type == ExpressionInterface::TYPE_VALUE) {
|
||||||
|
@ -154,7 +184,8 @@ abstract class AbstractSql implements SqlInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// after looping the values, interpolate them into the sql string (they might be placeholder names, or values)
|
// After looping the values, interpolate them into the sql string
|
||||||
|
// (they might be placeholder names, or values)
|
||||||
$sql .= vsprintf($part[0], $values);
|
$sql .= vsprintf($part[0], $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +229,10 @@ abstract class AbstractSql implements SqlInterface
|
||||||
foreach ($paramsForPosition as $multiParamsForPosition) {
|
foreach ($paramsForPosition as $multiParamsForPosition) {
|
||||||
$ppCount = count($multiParamsForPosition);
|
$ppCount = count($multiParamsForPosition);
|
||||||
if (!isset($paramSpecs[$position][$ppCount])) {
|
if (!isset($paramSpecs[$position][$ppCount])) {
|
||||||
throw new Exception\RuntimeException('A number of parameters (' . $ppCount . ') was found that is not supported by this specification');
|
throw new Exception\RuntimeException(sprintf(
|
||||||
|
'A number of parameters (%d) was found that is not supported by this specification',
|
||||||
|
$ppCount
|
||||||
|
));
|
||||||
}
|
}
|
||||||
$multiParamValues[] = vsprintf($paramSpecs[$position][$ppCount], $multiParamsForPosition);
|
$multiParamValues[] = vsprintf($paramSpecs[$position][$ppCount], $multiParamsForPosition);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +240,10 @@ abstract class AbstractSql implements SqlInterface
|
||||||
} elseif ($paramSpecs[$position] !== null) {
|
} elseif ($paramSpecs[$position] !== null) {
|
||||||
$ppCount = count($paramsForPosition);
|
$ppCount = count($paramsForPosition);
|
||||||
if (!isset($paramSpecs[$position][$ppCount])) {
|
if (!isset($paramSpecs[$position][$ppCount])) {
|
||||||
throw new Exception\RuntimeException('A number of parameters (' . $ppCount . ') was found that is not supported by this specification');
|
throw new Exception\RuntimeException(sprintf(
|
||||||
|
'A number of parameters (%d) was found that is not supported by this specification',
|
||||||
|
$ppCount
|
||||||
|
));
|
||||||
}
|
}
|
||||||
$topParameters[] = vsprintf($paramSpecs[$position][$ppCount], $paramsForPosition);
|
$topParameters[] = vsprintf($paramSpecs[$position][$ppCount], $paramsForPosition);
|
||||||
} else {
|
} else {
|
||||||
|
@ -223,8 +260,12 @@ abstract class AbstractSql implements SqlInterface
|
||||||
* @param null|ParameterContainer $parameterContainer
|
* @param null|ParameterContainer $parameterContainer
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function processSubSelect(Select $subselect, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
|
protected function processSubSelect(
|
||||||
{
|
Select $subselect,
|
||||||
|
PlatformInterface $platform,
|
||||||
|
DriverInterface $driver = null,
|
||||||
|
ParameterContainer $parameterContainer = null
|
||||||
|
) {
|
||||||
if ($this instanceof PlatformDecoratorInterface) {
|
if ($this instanceof PlatformDecoratorInterface) {
|
||||||
$decorator = clone $this;
|
$decorator = clone $this;
|
||||||
$decorator->setSubject($subselect);
|
$decorator->setSubject($subselect);
|
||||||
|
@ -237,7 +278,8 @@ abstract class AbstractSql implements SqlInterface
|
||||||
$processInfoContext = ($decorator instanceof PlatformDecoratorInterface) ? $subselect : $decorator;
|
$processInfoContext = ($decorator instanceof PlatformDecoratorInterface) ? $subselect : $decorator;
|
||||||
$this->processInfo['subselectCount']++;
|
$this->processInfo['subselectCount']++;
|
||||||
$processInfoContext->processInfo['subselectCount'] = $this->processInfo['subselectCount'];
|
$processInfoContext->processInfo['subselectCount'] = $this->processInfo['subselectCount'];
|
||||||
$processInfoContext->processInfo['paramPrefix'] = 'subselect' . $processInfoContext->processInfo['subselectCount'];
|
$processInfoContext->processInfo['paramPrefix'] = 'subselect'
|
||||||
|
. $processInfoContext->processInfo['subselectCount'];
|
||||||
|
|
||||||
$sql = $decorator->buildSqlString($platform, $driver, $parameterContainer);
|
$sql = $decorator->buildSqlString($platform, $driver, $parameterContainer);
|
||||||
|
|
||||||
|
@ -257,9 +299,16 @@ abstract class AbstractSql implements SqlInterface
|
||||||
* @param null|ParameterContainer $parameterContainer
|
* @param null|ParameterContainer $parameterContainer
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function resolveColumnValue($column, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, $namedParameterPrefix = null)
|
protected function resolveColumnValue(
|
||||||
{
|
$column,
|
||||||
$namedParameterPrefix = !$namedParameterPrefix ? $namedParameterPrefix : $this->processInfo['paramPrefix'] . $namedParameterPrefix;
|
PlatformInterface $platform,
|
||||||
|
DriverInterface $driver = null,
|
||||||
|
ParameterContainer $parameterContainer = null,
|
||||||
|
$namedParameterPrefix = null
|
||||||
|
) {
|
||||||
|
$namedParameterPrefix = ! $namedParameterPrefix
|
||||||
|
? $namedParameterPrefix
|
||||||
|
: $this->processInfo['paramPrefix'] . $namedParameterPrefix;
|
||||||
$isIdentifier = false;
|
$isIdentifier = false;
|
||||||
$fromTable = '';
|
$fromTable = '';
|
||||||
if (is_array($column)) {
|
if (is_array($column)) {
|
||||||
|
@ -293,8 +342,12 @@ abstract class AbstractSql implements SqlInterface
|
||||||
* @param ParameterContainer $parameterContainer
|
* @param ParameterContainer $parameterContainer
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function resolveTable($table, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
|
protected function resolveTable(
|
||||||
{
|
$table,
|
||||||
|
PlatformInterface $platform,
|
||||||
|
DriverInterface $driver = null,
|
||||||
|
ParameterContainer $parameterContainer = null
|
||||||
|
) {
|
||||||
$schema = null;
|
$schema = null;
|
||||||
if ($table instanceof TableIdentifier) {
|
if ($table instanceof TableIdentifier) {
|
||||||
list($table, $schema) = $table->getTableAndSchema();
|
list($table, $schema) = $table->getTableAndSchema();
|
||||||
|
|
|
@ -135,7 +135,8 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa
|
||||||
if ($insert) {
|
if ($insert) {
|
||||||
$j = isset($j) ? $j : 0;
|
$j = isset($j) ? $j : 0;
|
||||||
$sql = substr_replace($sql, $insert, $insertStart[$j], 0);
|
$sql = substr_replace($sql, $insert, $insertStart[$j], 0);
|
||||||
for (; $j < count($insertStart); ++$j) {
|
$insertStartCount = count($insertStart);
|
||||||
|
for (; $j < $insertStartCount; ++$j) {
|
||||||
$insertStart[$j] += strlen($insert);
|
$insertStart[$j] += strlen($insert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,7 +200,8 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa
|
||||||
if ($insert) {
|
if ($insert) {
|
||||||
$j = isset($j) ? $j : 0;
|
$j = isset($j) ? $j : 0;
|
||||||
$sql = substr_replace($sql, $insert, $insertStart[$j], 0);
|
$sql = substr_replace($sql, $insert, $insertStart[$j], 0);
|
||||||
for (; $j < count($insertStart); ++$j) {
|
$insertStartCount = count($insertStart);
|
||||||
|
for (; $j < $insertStartCount; ++$j) {
|
||||||
$insertStart[$j] += strlen($insert);
|
$insertStart[$j] += strlen($insert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,8 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter
|
||||||
if ($insert) {
|
if ($insert) {
|
||||||
$j = isset($j) ? $j : 0;
|
$j = isset($j) ? $j : 0;
|
||||||
$sql = substr_replace($sql, $insert, $insertStart[$j], 0);
|
$sql = substr_replace($sql, $insert, $insertStart[$j], 0);
|
||||||
for (; $j < count($insertStart); ++$j) {
|
$insertStartCount = count($insertStart);
|
||||||
|
for (; $j < $insertStartCount; ++$j) {
|
||||||
$insertStart[$j] += strlen($insert);
|
$insertStart[$j] += strlen($insert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Predicate extends PredicateSet
|
||||||
*/
|
*/
|
||||||
public function unnest()
|
public function unnest()
|
||||||
{
|
{
|
||||||
if ($this->unnest == null) {
|
if ($this->unnest === null) {
|
||||||
throw new RuntimeException('Not nested');
|
throw new RuntimeException('Not nested');
|
||||||
}
|
}
|
||||||
$unnest = $this->unnest;
|
$unnest = $this->unnest;
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Sql
|
||||||
|
|
||||||
public function hasTable()
|
public function hasTable()
|
||||||
{
|
{
|
||||||
return ($this->table != null);
|
return ($this->table !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTable($table)
|
public function setTable($table)
|
||||||
|
|
|
@ -85,7 +85,7 @@ class TableIdentifier
|
||||||
*/
|
*/
|
||||||
public function hasSchema()
|
public function hasSchema()
|
||||||
{
|
{
|
||||||
return ($this->schema != null);
|
return ($this->schema !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Update extends AbstractPreparableSql
|
||||||
*/
|
*/
|
||||||
public function set(array $values, $flag = self::VALUES_SET)
|
public function set(array $values, $flag = self::VALUES_SET)
|
||||||
{
|
{
|
||||||
if ($values == null) {
|
if ($values === null) {
|
||||||
throw new Exception\InvalidArgumentException('set() expects an array of values');
|
throw new Exception\InvalidArgumentException('set() expects an array of values');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class MasterSlaveFeature extends AbstractFeature
|
||||||
public function postInitialize()
|
public function postInitialize()
|
||||||
{
|
{
|
||||||
$this->masterSql = $this->tableGateway->sql;
|
$this->masterSql = $this->tableGateway->sql;
|
||||||
if ($this->slaveSql == null) {
|
if ($this->slaveSql === null) {
|
||||||
$this->slaveSql = new Sql(
|
$this->slaveSql = new Sql(
|
||||||
$this->slaveAdapter,
|
$this->slaveAdapter,
|
||||||
$this->tableGateway->sql->getTable(),
|
$this->tableGateway->sql->getTable(),
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MetadataFeature extends AbstractFeature
|
||||||
|
|
||||||
public function postInitialize()
|
public function postInitialize()
|
||||||
{
|
{
|
||||||
if ($this->metadata == null) {
|
if ($this->metadata === null) {
|
||||||
$this->metadata = new Metadata($this->tableGateway->adapter);
|
$this->metadata = new Metadata($this->tableGateway->adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ class CompilerDefinition implements DefinitionInterface
|
||||||
*/
|
*/
|
||||||
public function addCodeScannerFile(FileScanner $fileScanner)
|
public function addCodeScannerFile(FileScanner $fileScanner)
|
||||||
{
|
{
|
||||||
if ($this->directoryScanner == null) {
|
if ($this->directoryScanner === null) {
|
||||||
$this->directoryScanner = new DirectoryScanner();
|
$this->directoryScanner = new DirectoryScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class CompilerDefinition implements DefinitionInterface
|
||||||
|
|
||||||
$def['supertypes'] = $supertypes;
|
$def['supertypes'] = $supertypes;
|
||||||
|
|
||||||
if ($def['instantiator'] == null) {
|
if ($def['instantiator'] === null) {
|
||||||
if ($rClass->isInstantiable()) {
|
if ($rClass->isInstantiable()) {
|
||||||
$def['instantiator'] = '__construct';
|
$def['instantiator'] = '__construct';
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ class RuntimeDefinition implements DefinitionInterface
|
||||||
|
|
||||||
$def['supertypes'] = array_keys(array_flip($supertypes));
|
$def['supertypes'] = array_keys(array_flip($supertypes));
|
||||||
|
|
||||||
if ($def['instantiator'] == null) {
|
if ($def['instantiator'] === null) {
|
||||||
if ($rClass->isInstantiable()) {
|
if ($rClass->isInstantiable()) {
|
||||||
$def['instantiator'] = '__construct';
|
$def['instantiator'] = '__construct';
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
namespace Zend\Di;
|
namespace Zend\Di;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use ReflectionClass;
|
|
||||||
use Zend\Di\Exception\RuntimeException as DiRuntimeException;
|
use Zend\Di\Exception\RuntimeException as DiRuntimeException;
|
||||||
use Zend\ServiceManager\Exception\ExceptionInterface as ServiceManagerException;
|
use Zend\ServiceManager\Exception\ExceptionInterface as ServiceManagerException;
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
||||||
$date = date_create_from_format($standard, $dateModified);
|
$date = date_create_from_format($standard, $dateModified);
|
||||||
break;
|
break;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($standard == null) {
|
if ($standard === null) {
|
||||||
throw new Exception\RuntimeException(
|
throw new Exception\RuntimeException(
|
||||||
'Could not load date due to unrecognised'
|
'Could not load date due to unrecognised'
|
||||||
.' format (should follow RFC 822 or 2822):'
|
.' format (should follow RFC 822 or 2822):'
|
||||||
|
|
|
@ -212,7 +212,7 @@ class Rss extends AbstractFeed
|
||||||
$date = DateTime::createFromFormat($standard, $dateModified);
|
$date = DateTime::createFromFormat($standard, $dateModified);
|
||||||
break;
|
break;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($standard == null) {
|
if ($standard === null) {
|
||||||
throw new Exception\RuntimeException(
|
throw new Exception\RuntimeException(
|
||||||
'Could not load date due to unrecognised'
|
'Could not load date due to unrecognised'
|
||||||
.' format (should follow RFC 822 or 2822):'
|
.' format (should follow RFC 822 or 2822):'
|
||||||
|
@ -272,7 +272,7 @@ class Rss extends AbstractFeed
|
||||||
$date = DateTime::createFromFormat($standard, $lastBuildDateParsed);
|
$date = DateTime::createFromFormat($standard, $lastBuildDateParsed);
|
||||||
break;
|
break;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($standard == null) {
|
if ($standard === null) {
|
||||||
throw new Exception\RuntimeException(
|
throw new Exception\RuntimeException(
|
||||||
'Could not load date due to unrecognised'
|
'Could not load date due to unrecognised'
|
||||||
.' format (should follow RFC 822 or 2822):'
|
.' format (should follow RFC 822 or 2822):'
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,7 +441,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface
|
||||||
*/
|
*/
|
||||||
public function getValidators($files = null)
|
public function getValidators($files = null)
|
||||||
{
|
{
|
||||||
if ($files == null) {
|
if ($files === null) {
|
||||||
return $this->validators;
|
return $this->validators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ class SeparatorToSeparator extends AbstractFilter
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->searchSeparator == null) {
|
if ($this->searchSeparator === null) {
|
||||||
throw new Exception\RuntimeException('You must provide a search separator for this filter to work.');
|
throw new Exception\RuntimeException('You must provide a search separator for this filter to work.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
0
library/TorrentPier/Zend/Filter/Word/UnderscoreToStudlyCase.php
Normal file → Executable file
0
library/TorrentPier/Zend/Filter/Word/UnderscoreToStudlyCase.php
Normal file → Executable file
|
@ -29,8 +29,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,8 @@ class Collection extends Fieldset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if elements have been replaced or removed
|
// Check to see if elements have been replaced or removed
|
||||||
foreach ($this->iterator as $name => $elementOrFieldset) {
|
$toRemove = array();
|
||||||
|
foreach ($this as $name => $elementOrFieldset) {
|
||||||
if (isset($data[$name])) {
|
if (isset($data[$name])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -221,6 +222,10 @@ class Collection extends Fieldset
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$toRemove[] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($toRemove as $name) {
|
||||||
$this->remove($name);
|
$this->remove($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +387,8 @@ class Collection extends Fieldset
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to true, a template prototype is automatically added to the form to ease the creation of dynamic elements through JavaScript
|
* If set to true, a template prototype is automatically added to the form
|
||||||
|
* to ease the creation of dynamic elements through JavaScript
|
||||||
*
|
*
|
||||||
* @param bool $shouldCreateTemplate
|
* @param bool $shouldCreateTemplate
|
||||||
* @return Collection
|
* @return Collection
|
||||||
|
@ -485,7 +491,8 @@ class Collection extends Fieldset
|
||||||
|
|
||||||
parent::prepareElement($form);
|
parent::prepareElement($form);
|
||||||
|
|
||||||
// The template element has been prepared, but we don't want it to be rendered nor validated, so remove it from the list
|
// The template element has been prepared, but we don't want it to be
|
||||||
|
// rendered nor validated, so remove it from the list.
|
||||||
if ($this->shouldCreateTemplate) {
|
if ($this->shouldCreateTemplate) {
|
||||||
$this->remove($this->templatePlaceholder);
|
$this->remove($this->templatePlaceholder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ class Fieldset extends Element implements FieldsetInterface
|
||||||
*/
|
*/
|
||||||
public function has($elementOrFieldset)
|
public function has($elementOrFieldset)
|
||||||
{
|
{
|
||||||
return $this->iterator->get($elementOrFieldset) != null;
|
return $this->iterator->get($elementOrFieldset) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -788,7 +788,12 @@ class Form extends Fieldset implements FormInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$inputFilter->add($input, $name);
|
// Add element input filter to CollectionInputFilter
|
||||||
|
if ($inputFilter instanceof CollectionInputFilter && !$inputFilter->getInputFilter()->has($name)) {
|
||||||
|
$inputFilter->getInputFilter()->add($input, $name);
|
||||||
|
} else {
|
||||||
|
$inputFilter->add($input, $name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fieldset === $this && $fieldset instanceof InputFilterProviderInterface) {
|
if ($fieldset === $this && $fieldset instanceof InputFilterProviderInterface) {
|
||||||
|
@ -807,8 +812,27 @@ class Form extends Fieldset implements FormInterface
|
||||||
if ($childFieldset->getObject() instanceof InputFilterAwareInterface) {
|
if ($childFieldset->getObject() instanceof InputFilterAwareInterface) {
|
||||||
$inputFilter->add($childFieldset->getObject()->getInputFilter(), $name);
|
$inputFilter->add($childFieldset->getObject()->getInputFilter(), $name);
|
||||||
} else {
|
} else {
|
||||||
if ($fieldset instanceof Collection && $inputFilter instanceof CollectionInputFilter) {
|
// Add input filter for collections via getInputFilterSpecification()
|
||||||
continue;
|
if ($childFieldset instanceof Collection
|
||||||
|
&& $childFieldset->getTargetElement() instanceof InputFilterProviderInterface
|
||||||
|
&& $childFieldset->getTargetElement()->getInputFilterSpecification()
|
||||||
|
) {
|
||||||
|
$collectionContainerFilter = new CollectionInputFilter();
|
||||||
|
|
||||||
|
$spec = $childFieldset->getTargetElement()->getInputFilterSpecification();
|
||||||
|
$filter = $inputFactory->createInputFilter($spec);
|
||||||
|
|
||||||
|
$collectionContainerFilter->setInputFilter($filter);
|
||||||
|
|
||||||
|
$inputFilter->add($collectionContainerFilter, $name);
|
||||||
|
|
||||||
|
// We need to copy the inputs to the collection input filter
|
||||||
|
if ($inputFilter instanceof CollectionInputFilter) {
|
||||||
|
$inputFilter = $this->addInputsToCollectionInputFilter($inputFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add child elements from target element
|
||||||
|
$childFieldset = $childFieldset->getTargetElement();
|
||||||
} else {
|
} else {
|
||||||
$inputFilter->add(new InputFilter(), $name);
|
$inputFilter->add(new InputFilter(), $name);
|
||||||
}
|
}
|
||||||
|
@ -840,9 +864,31 @@ class Form extends Fieldset implements FormInterface
|
||||||
|
|
||||||
// Recursively attach sub filters
|
// Recursively attach sub filters
|
||||||
$this->attachInputFilterDefaults($filter, $childFieldset);
|
$this->attachInputFilterDefaults($filter, $childFieldset);
|
||||||
|
|
||||||
|
// We need to copy the inputs to the collection input filter to ensure that all sub filters are added
|
||||||
|
if ($inputFilter instanceof CollectionInputFilter) {
|
||||||
|
$inputFilter = $this->addInputsToCollectionInputFilter($inputFilter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add inputs to CollectionInputFilter
|
||||||
|
*
|
||||||
|
* @param CollectionInputFilter $inputFilter
|
||||||
|
* @return CollectionInputFilter
|
||||||
|
*/
|
||||||
|
private function addInputsToCollectionInputFilter(CollectionInputFilter $inputFilter)
|
||||||
|
{
|
||||||
|
foreach ($inputFilter->getInputs() as $name => $input) {
|
||||||
|
if (!$inputFilter->getInputFilter()->has($name)) {
|
||||||
|
$inputFilter->getInputFilter()->add($input, $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $inputFilter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are the form elements/fieldsets names wrapped by the form name ?
|
* Are the form elements/fieldsets names wrapped by the form name ?
|
||||||
*
|
*
|
||||||
|
|
|
@ -42,8 +42,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev",
|
"dev-master": "2.4-dev",
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,8 @@ abstract class AbstractAccept implements HeaderInterface
|
||||||
$value = $headerLine;
|
$value = $headerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
|
||||||
foreach ($this->getFieldValuePartsFromHeaderLine($value) as $value) {
|
foreach ($this->getFieldValuePartsFromHeaderLine($value) as $value) {
|
||||||
$this->addFieldValuePartToQueue($value);
|
$this->addFieldValuePartToQueue($value);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +110,6 @@ abstract class AbstractAccept implements HeaderInterface
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach ($values[0] as $value) {
|
foreach ($values[0] as $value) {
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
$out[] = $this->parseFieldValuePart($value);
|
$out[] = $this->parseFieldValuePart($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ abstract class AbstractLocation implements HeaderInterface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeaderValue::assertValid($uri);
|
||||||
$locationHeader->setUri(trim($uri));
|
$locationHeader->setUri(trim($uri));
|
||||||
|
|
||||||
return $locationHeader;
|
return $locationHeader;
|
||||||
|
|
|
@ -24,7 +24,9 @@ class AcceptRanges implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'accept-ranges') {
|
if (strtolower($name) !== 'accept-ranges') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Accept-Ranges string');
|
throw new Exception\InvalidArgumentException(
|
||||||
|
'Invalid header line for Accept-Ranges string'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = new static($value);
|
$header = new static($value);
|
||||||
|
@ -34,7 +36,9 @@ class AcceptRanges implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($rangeUnit = null)
|
public function __construct($rangeUnit = null)
|
||||||
{
|
{
|
||||||
$this->rangeUnit = $rangeUnit;
|
if ($rangeUnit) {
|
||||||
|
$this->setRangeUnit($rangeUnit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
@ -49,6 +53,7 @@ class AcceptRanges implements HeaderInterface
|
||||||
|
|
||||||
public function setRangeUnit($rangeUnit)
|
public function setRangeUnit($rangeUnit)
|
||||||
{
|
{
|
||||||
|
HeaderValue::assertValid($rangeUnit);
|
||||||
$this->rangeUnit = $rangeUnit;
|
$this->rangeUnit = $rangeUnit;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,9 @@ class Age implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setDeltaSeconds($delta)
|
public function setDeltaSeconds($delta)
|
||||||
{
|
{
|
||||||
|
if (! is_int($delta) && ! is_numeric($delta)) {
|
||||||
|
throw new Exception\InvalidArgumentException('Invalid delta provided');
|
||||||
|
}
|
||||||
$this->deltaSeconds = (int) $delta;
|
$this->deltaSeconds = (int) $delta;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,12 @@ class Allow implements HeaderInterface
|
||||||
{
|
{
|
||||||
foreach ((array) $allowedMethods as $method) {
|
foreach ((array) $allowedMethods as $method) {
|
||||||
$method = trim(strtoupper($method));
|
$method = trim(strtoupper($method));
|
||||||
|
if (preg_match('/\s/', $method)) {
|
||||||
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Unable to whitelist method; "%s" is not a valid method',
|
||||||
|
$method
|
||||||
|
));
|
||||||
|
}
|
||||||
$this->methods[$method] = true;
|
$this->methods[$method] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +132,12 @@ class Allow implements HeaderInterface
|
||||||
{
|
{
|
||||||
foreach ((array) $disallowedMethods as $method) {
|
foreach ((array) $disallowedMethods as $method) {
|
||||||
$method = trim(strtoupper($method));
|
$method = trim(strtoupper($method));
|
||||||
|
if (preg_match('/\s/', $method)) {
|
||||||
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Unable to blacklist method; "%s" is not a valid method',
|
||||||
|
$method
|
||||||
|
));
|
||||||
|
}
|
||||||
$this->methods[$method] = false;
|
$this->methods[$method] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class AuthenticationInfo implements HeaderInterface
|
class AuthenticationInfo implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class AuthenticationInfo implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'authentication-info') {
|
if (strtolower($name) !== 'authentication-info') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Authentication-Info string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Authentication-Info string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class AuthenticationInfo implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class Authorization implements HeaderInterface
|
class Authorization implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class Authorization implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'authorization') {
|
if (strtolower($name) !== 'authorization') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Authorization string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Authorization string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class Authorization implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class CacheControl implements HeaderInterface
|
class CacheControl implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +46,7 @@ class CacheControl implements HeaderInterface
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
$directives = static::parseValue($value);
|
$directives = static::parseValue($value);
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -86,6 +89,10 @@ class CacheControl implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function addDirective($key, $value = true)
|
public function addDirective($key, $value = true)
|
||||||
{
|
{
|
||||||
|
HeaderValue::assertValid($key);
|
||||||
|
if (! is_bool($value)) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
}
|
||||||
$this->directives[$key] = $value;
|
$this->directives[$key] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,11 +55,9 @@ class Connection implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setPersistent($flag)
|
public function setPersistent($flag)
|
||||||
{
|
{
|
||||||
if ((bool) $flag === true) {
|
$this->value = (bool) $flag
|
||||||
$this->value = self::CONNECTION_KEEP_ALIVE;
|
? self::CONNECTION_KEEP_ALIVE
|
||||||
} else {
|
: self::CONNECTION_CLOSE;
|
||||||
$this->value = self::CONNECTION_CLOSE;
|
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +80,7 @@ class Connection implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setValue($value)
|
public function setValue($value)
|
||||||
{
|
{
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
$this->value = strtolower($value);
|
$this->value = strtolower($value);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentDisposition implements HeaderInterface
|
class ContentDisposition implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class ContentDisposition implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-disposition') {
|
if (strtolower($name) !== 'content-disposition') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Disposition string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Content-Disposition string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class ContentDisposition implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentEncoding implements HeaderInterface
|
class ContentEncoding implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,9 @@ class ContentEncoding implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-encoding') {
|
if (strtolower($name) !== 'content-encoding') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Encoding string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(
|
||||||
|
'Invalid header line for Content-Encoding string: "' . $name . '"'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +39,10 @@ class ContentEncoding implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentLanguage implements HeaderInterface
|
class ContentLanguage implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class ContentLanguage implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-language') {
|
if (strtolower($name) !== 'content-language') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Language string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Content-Language string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class ContentLanguage implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentLength implements HeaderInterface
|
class ContentLength implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class ContentLength implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-length') {
|
if (strtolower($name) !== 'content-length') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Length string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Content-Length string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class ContentLength implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentMD5 implements HeaderInterface
|
class ContentMD5 implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class ContentMD5 implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentRange implements HeaderInterface
|
class ContentRange implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class ContentRange implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-range') {
|
if (strtolower($name) !== 'content-range') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Range string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Content-Range string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class ContentRange implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ContentSecurityPolicy implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setDirective($name, array $sources)
|
public function setDirective($name, array $sources)
|
||||||
{
|
{
|
||||||
if (!in_array($name, $this->validDirectiveNames, true)) {
|
if (! in_array($name, $this->validDirectiveNames, true)) {
|
||||||
throw new Exception\InvalidArgumentException(sprintf(
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
'%s expects a valid directive name; received "%s"',
|
'%s expects a valid directive name; received "%s"',
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
|
@ -74,9 +74,12 @@ class ContentSecurityPolicy implements HeaderInterface
|
||||||
}
|
}
|
||||||
if (empty($sources)) {
|
if (empty($sources)) {
|
||||||
$this->directives[$name] = "'none'";
|
$this->directives[$name] = "'none'";
|
||||||
} else {
|
return $this;
|
||||||
$this->directives[$name] = implode(' ', $sources);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
array_walk($sources, array(__NAMESPACE__ . '\HeaderValue', 'assertValid'));
|
||||||
|
|
||||||
|
$this->directives[$name] = implode(' ', $sources);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +110,7 @@ class ContentSecurityPolicy implements HeaderInterface
|
||||||
if ($token) {
|
if ($token) {
|
||||||
list($directiveName, $directiveValue) = explode(' ', $token, 2);
|
list($directiveName, $directiveValue) = explode(' ', $token, 2);
|
||||||
if (!isset($header->directives[$directiveName])) {
|
if (!isset($header->directives[$directiveName])) {
|
||||||
$header->directives[$directiveName] = $directiveValue;
|
$header->setDirective($directiveName, array($directiveValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class ContentTransferEncoding implements HeaderInterface
|
class ContentTransferEncoding implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class ContentTransferEncoding implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-transfer-encoding') {
|
if (strtolower($name) !== 'content-transfer-encoding') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Transfer-Encoding string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Content-Transfer-Encoding string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class ContentTransferEncoding implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -44,7 +44,10 @@ class ContentType implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'content-type') {
|
if (strtolower($name) !== 'content-type') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Type string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Content-Type string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = explode(';', $value);
|
$parts = explode(';', $value);
|
||||||
|
@ -68,7 +71,10 @@ class ContentType implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null, $mediaType = null)
|
public function __construct($value = null, $mediaType = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
$this->mediaType = $mediaType;
|
$this->mediaType = $mediaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +161,7 @@ class ContentType implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setMediaType($mediaType)
|
public function setMediaType($mediaType)
|
||||||
{
|
{
|
||||||
|
HeaderValue::assertValid($mediaType);
|
||||||
$this->mediaType = strtolower($mediaType);
|
$this->mediaType = strtolower($mediaType);
|
||||||
$this->value = null;
|
$this->value = null;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -178,6 +185,10 @@ class ContentType implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setParameters(array $parameters)
|
public function setParameters(array $parameters)
|
||||||
{
|
{
|
||||||
|
foreach ($parameters as $key => $value) {
|
||||||
|
HeaderValue::assertValid($key);
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
}
|
||||||
$this->parameters = array_merge($this->parameters, $parameters);
|
$this->parameters = array_merge($this->parameters, $parameters);
|
||||||
$this->value = null;
|
$this->value = null;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -201,6 +212,7 @@ class ContentType implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function setCharset($charset)
|
public function setCharset($charset)
|
||||||
{
|
{
|
||||||
|
HeaderValue::assertValid($charset);
|
||||||
$this->parameters['charset'] = $charset;
|
$this->parameters['charset'] = $charset;
|
||||||
$this->value = null;
|
$this->value = null;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -22,17 +22,25 @@ class Cookie extends ArrayObject implements HeaderInterface
|
||||||
public static function fromSetCookieArray(array $setCookies)
|
public static function fromSetCookieArray(array $setCookies)
|
||||||
{
|
{
|
||||||
$nvPairs = array();
|
$nvPairs = array();
|
||||||
/* @var $setCookie SetCookie */
|
|
||||||
foreach ($setCookies as $setCookie) {
|
foreach ($setCookies as $setCookie) {
|
||||||
if (!$setCookie instanceof SetCookie) {
|
if (! $setCookie instanceof SetCookie) {
|
||||||
throw new Exception\InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . ' requires an array of SetCookie objects');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'%s requires an array of SetCookie objects',
|
||||||
|
__METHOD__
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists($setCookie->getName(), $nvPairs)) {
|
if (array_key_exists($setCookie->getName(), $nvPairs)) {
|
||||||
throw new Exception\InvalidArgumentException('Two cookies with the same name were provided to ' . __CLASS__ . '::' . __METHOD__);
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Two cookies with the same name were provided to %s',
|
||||||
|
__METHOD__
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$nvPairs[$setCookie->getName()] = $setCookie->getValue();
|
$nvPairs[$setCookie->getName()] = $setCookie->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new static($nvPairs);
|
return new static($nvPairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class Etag implements HeaderInterface
|
class Etag implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class Etag implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class Expect implements HeaderInterface
|
class Expect implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class Expect implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class From implements HeaderInterface
|
class From implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class From implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -53,6 +53,10 @@ class GenericHeader implements HeaderInterface
|
||||||
throw new Exception\InvalidArgumentException('Header must match with the format "name:value"');
|
throw new Exception\InvalidArgumentException('Header must match with the format "name:value"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! HeaderValue::isValid($parts[1])) {
|
||||||
|
throw new Exception\InvalidArgumentException('Invalid header value detected');
|
||||||
|
}
|
||||||
|
|
||||||
$parts[1] = ltrim($parts[1]);
|
$parts[1] = ltrim($parts[1]);
|
||||||
|
|
||||||
return $parts;
|
return $parts;
|
||||||
|
@ -126,6 +130,7 @@ class GenericHeader implements HeaderInterface
|
||||||
public function setFieldValue($fieldValue)
|
public function setFieldValue($fieldValue)
|
||||||
{
|
{
|
||||||
$fieldValue = (string) $fieldValue;
|
$fieldValue = (string) $fieldValue;
|
||||||
|
HeaderValue::assertValid($fieldValue);
|
||||||
|
|
||||||
if (preg_match('/^\s+$/', $fieldValue)) {
|
if (preg_match('/^\s+$/', $fieldValue)) {
|
||||||
$fieldValue = '';
|
$fieldValue = '';
|
||||||
|
|
107
library/TorrentPier/Zend/Http/Header/HeaderValue.php
Normal file
107
library/TorrentPier/Zend/Http/Header/HeaderValue.php
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Zend Framework (http://framework.zend.com/)
|
||||||
|
*
|
||||||
|
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||||
|
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Zend\Http\Header;
|
||||||
|
|
||||||
|
final class HeaderValue
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Private constructor; non-instantiable.
|
||||||
|
*/
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter a header value
|
||||||
|
*
|
||||||
|
* Ensures CRLF header injection vectors are filtered.
|
||||||
|
*
|
||||||
|
* Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal
|
||||||
|
* tabs are allowed in values; only one whitespace character is allowed
|
||||||
|
* between visible characters.
|
||||||
|
*
|
||||||
|
* @see http://en.wikipedia.org/wiki/HTTP_response_splitting
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function filter($value)
|
||||||
|
{
|
||||||
|
$value = (string) $value;
|
||||||
|
$length = strlen($value);
|
||||||
|
$string = '';
|
||||||
|
for ($i = 0; $i < $length; $i += 1) {
|
||||||
|
$ascii = ord($value[$i]);
|
||||||
|
|
||||||
|
// Non-visible, non-whitespace characters
|
||||||
|
// 9 === horizontal tab
|
||||||
|
// 32-126, 128-254 === visible
|
||||||
|
// 127 === DEL
|
||||||
|
// 255 === null byte
|
||||||
|
if (($ascii < 32 && $ascii !== 9)
|
||||||
|
|| $ascii === 127
|
||||||
|
|| $ascii > 254
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$string .= $value[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate a header value.
|
||||||
|
*
|
||||||
|
* Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal
|
||||||
|
* tabs are allowed in values; only one whitespace character is allowed
|
||||||
|
* between visible characters.
|
||||||
|
*
|
||||||
|
* @see http://en.wikipedia.org/wiki/HTTP_response_splitting
|
||||||
|
* @param string $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isValid($value)
|
||||||
|
{
|
||||||
|
$value = (string) $value;
|
||||||
|
$length = strlen($value);
|
||||||
|
for ($i = 0; $i < $length; $i += 1) {
|
||||||
|
$ascii = ord($value[$i]);
|
||||||
|
|
||||||
|
// Non-visible, non-whitespace characters
|
||||||
|
// 9 === horizontal tab
|
||||||
|
// 32-126, 128-254 === visible
|
||||||
|
// 127 === DEL
|
||||||
|
// 255 === null byte
|
||||||
|
if (($ascii < 32 && $ascii !== 9)
|
||||||
|
|| $ascii === 127
|
||||||
|
|| $ascii > 254
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert a header value is valid.
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @throws Exception\RuntimeException for invalid values
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function assertValid($value)
|
||||||
|
{
|
||||||
|
if (! self::isValid($value)) {
|
||||||
|
throw new Exception\InvalidArgumentException('Invalid header value');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class Host implements HeaderInterface
|
class Host implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class Host implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class IfMatch implements HeaderInterface
|
class IfMatch implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class IfMatch implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class IfNoneMatch implements HeaderInterface
|
class IfNoneMatch implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class IfNoneMatch implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'if-none-match') {
|
if (strtolower($name) !== 'if-none-match') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for If-None-Match string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for If-None-Match string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class IfNoneMatch implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class IfRange implements HeaderInterface
|
class IfRange implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class IfRange implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class KeepAlive implements HeaderInterface
|
class KeepAlive implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class KeepAlive implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class MaxForwards implements HeaderInterface
|
class MaxForwards implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -24,7 +26,10 @@ class MaxForwards implements HeaderInterface
|
||||||
|
|
||||||
// check to ensure proper header type for this factory
|
// check to ensure proper header type for this factory
|
||||||
if (strtolower($name) !== 'max-forwards') {
|
if (strtolower($name) !== 'max-forwards') {
|
||||||
throw new Exception\InvalidArgumentException('Invalid header line for Max-Forwards string: "' . $name . '"');
|
throw new Exception\InvalidArgumentException(sprintf(
|
||||||
|
'Invalid header line for Max-Forwards string: "%s"',
|
||||||
|
$name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implementation details
|
// @todo implementation details
|
||||||
|
@ -35,7 +40,10 @@ class MaxForwards implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Origin implements HeaderInterface
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $value;
|
protected $value = '';
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,10 @@ class Origin implements HeaderInterface
|
||||||
*/
|
*/
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = (string) $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Zend\Http\Header;
|
||||||
*/
|
*/
|
||||||
class Pragma implements HeaderInterface
|
class Pragma implements HeaderInterface
|
||||||
{
|
{
|
||||||
/** @var string */
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public static function fromString($headerLine)
|
public static function fromString($headerLine)
|
||||||
|
@ -35,7 +37,10 @@ class Pragma implements HeaderInterface
|
||||||
|
|
||||||
public function __construct($value = null)
|
public function __construct($value = null)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
if ($value) {
|
||||||
|
HeaderValue::assertValid($value);
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldName()
|
public function getFieldName()
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue