diff --git a/library/Zend/Authentication/Adapter/AbstractAdapter.php b/library/Zend/Authentication/Adapter/AbstractAdapter.php index 2f394f9e..5ca7457a 100644 --- a/library/Zend/Authentication/Adapter/AbstractAdapter.php +++ b/library/Zend/Authentication/Adapter/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/AdapterInterface.php b/library/Zend/Authentication/Adapter/AdapterInterface.php index d23d0793..a741dd61 100644 --- a/library/Zend/Authentication/Adapter/AdapterInterface.php +++ b/library/Zend/Authentication/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Callback.php b/library/Zend/Authentication/Adapter/Callback.php new file mode 100644 index 00000000..dd399563 --- /dev/null +++ b/library/Zend/Authentication/Adapter/Callback.php @@ -0,0 +1,90 @@ +setCallback($callback); + } + } + + /** + * Authenticate using the provided callback + * + * @return Result The authentication result + * @throws RuntimeException + */ + public function authenticate() + { + $callback = $this->getCallback(); + if (! $callback) { + throw new RuntimeException('No callback provided'); + } + + try { + $identity = call_user_func($callback, $this->getIdentity(), $this->getCredential()); + } catch (Exception $e) { + return new Result(Result::FAILURE_UNCATEGORIZED, null, array($e->getMessage())); + } + + if (! $identity) { + return new Result(Result::FAILURE, null, array('Authentication failure')); + } + + return new Result(Result::SUCCESS, $identity, array('Authentication success')); + } + + /** + * Gets the value of callback. + * + * @return null|callable + */ + public function getCallback() + { + return $this->callback; + } + + /** + * Sets the value of callback. + * + * @param callable $callback the callback + * @throws InvalidArgumentException + */ + public function setCallback($callback) + { + if (! is_callable($callback)) { + throw new InvalidArgumentException('Invalid callback provided'); + } + + $this->callback = $callback; + } +} diff --git a/library/Zend/Authentication/Adapter/DbTable.php b/library/Zend/Authentication/Adapter/DbTable.php index 917fa3fd..0edfbf2b 100644 --- a/library/Zend/Authentication/Adapter/DbTable.php +++ b/library/Zend/Authentication/Adapter/DbTable.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/DbTable/AbstractAdapter.php b/library/Zend/Authentication/Adapter/DbTable/AbstractAdapter.php index 612c0fec..f99cd967 100644 --- a/library/Zend/Authentication/Adapter/DbTable/AbstractAdapter.php +++ b/library/Zend/Authentication/Adapter/DbTable/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -148,7 +148,7 @@ abstract class AbstractAdapter extends BaseAdapter public function setAmbiguityIdentity($flag) { if (is_int($flag)) { - $this->ambiguityIdentity = (1 === $flag ? true : false); + $this->ambiguityIdentity = (1 === $flag); } elseif (is_bool($flag)) { $this->ambiguityIdentity = $flag; } @@ -173,7 +173,7 @@ abstract class AbstractAdapter extends BaseAdapter */ public function getDbSelect() { - if ($this->dbSelect == null) { + if ($this->dbSelect === null) { $this->dbSelect = new Sql\Select(); } return $this->dbSelect; diff --git a/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php b/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php index d585e353..48b9ebd7 100644 --- a/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php +++ b/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php b/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php index b31cc5f7..a3da9972 100644 --- a/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php +++ b/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php b/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php index 5365808f..913784ae 100644 --- a/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php +++ b/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/DbTable/Exception/InvalidArgumentException.php b/library/Zend/Authentication/Adapter/DbTable/Exception/InvalidArgumentException.php index dfda938e..bcba5644 100644 --- a/library/Zend/Authentication/Adapter/DbTable/Exception/InvalidArgumentException.php +++ b/library/Zend/Authentication/Adapter/DbTable/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/DbTable/Exception/RuntimeException.php b/library/Zend/Authentication/Adapter/DbTable/Exception/RuntimeException.php index bf4cc273..54e90241 100644 --- a/library/Zend/Authentication/Adapter/DbTable/Exception/RuntimeException.php +++ b/library/Zend/Authentication/Adapter/DbTable/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Digest.php b/library/Zend/Authentication/Adapter/Digest.php index 0ddb901e..a1a0414e 100644 --- a/library/Zend/Authentication/Adapter/Digest.php +++ b/library/Zend/Authentication/Adapter/Digest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php b/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php index 4c9b9d4b..e64b410c 100644 --- a/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php +++ b/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Exception/InvalidArgumentException.php b/library/Zend/Authentication/Adapter/Exception/InvalidArgumentException.php index 6c315aed..2d0452d4 100644 --- a/library/Zend/Authentication/Adapter/Exception/InvalidArgumentException.php +++ b/library/Zend/Authentication/Adapter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Exception/RuntimeException.php b/library/Zend/Authentication/Adapter/Exception/RuntimeException.php index 79109367..8cf08495 100644 --- a/library/Zend/Authentication/Adapter/Exception/RuntimeException.php +++ b/library/Zend/Authentication/Adapter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Exception/UnexpectedValueException.php b/library/Zend/Authentication/Adapter/Exception/UnexpectedValueException.php index 962403da..1f2a5227 100644 --- a/library/Zend/Authentication/Adapter/Exception/UnexpectedValueException.php +++ b/library/Zend/Authentication/Adapter/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Http.php b/library/Zend/Authentication/Adapter/Http.php index bc145197..5a56adc4 100644 --- a/library/Zend/Authentication/Adapter/Http.php +++ b/library/Zend/Authentication/Adapter/Http.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -125,14 +125,14 @@ class Http implements AdapterInterface * * @var bool */ - protected $imaProxy; + protected $imaProxy = false; /** * Flag indicating the client is IE and didn't bother to return the opaque string * * @var bool */ - protected $ieNoOpaque; + protected $ieNoOpaque = false; /** * Constructor @@ -149,10 +149,6 @@ class Http implements AdapterInterface */ public function __construct(array $config) { - $this->request = null; - $this->response = null; - $this->ieNoOpaque = false; - if (empty($config['accept_schemes'])) { throw new Exception\InvalidArgumentException('Config key "accept_schemes" is required'); } @@ -181,6 +177,9 @@ class Http implements AdapterInterface } if (in_array('digest', $this->acceptSchemes)) { + $this->useOpaque = true; + $this->algo = 'MD5'; + if (empty($config['digest_domains']) || !ctype_print($config['digest_domains']) || strpos($config['digest_domains'], '"') !== false) { @@ -204,22 +203,16 @@ class Http implements AdapterInterface // We use the opaque value unless explicitly told not to if (isset($config['use_opaque']) && false == (bool) $config['use_opaque']) { $this->useOpaque = false; - } else { - $this->useOpaque = true; } if (isset($config['algorithm']) && in_array($config['algorithm'], $this->supportedAlgos)) { - $this->algo = $config['algorithm']; - } else { - $this->algo = 'MD5'; + $this->algo = (string) $config['algorithm']; } } // Don't be a proxy unless explicitly told to do so if (isset($config['proxy_auth']) && true == (bool) $config['proxy_auth']) { $this->imaProxy = true; // I'm a Proxy - } else { - $this->imaProxy = false; } } @@ -727,7 +720,7 @@ class Http implements AdapterInterface if (!$ret || empty($temp[1])) { return false; } - if (32 != strlen($temp[1]) || !ctype_xdigit($temp[1])) { + if (!$this->isValidMd5Hash($temp[1])) { return false; } @@ -778,7 +771,7 @@ class Http implements AdapterInterface // This implementation only sends MD5 hex strings in the opaque value if (!$this->ieNoOpaque && - (32 != strlen($temp[1]) || !ctype_xdigit($temp[1]))) { + !$this->isValidMd5Hash($temp[1])) { return false; } @@ -811,8 +804,17 @@ class Http implements AdapterInterface } $data['nc'] = $temp[1]; - $temp = null; return $data; } + + /** + * validates if $value is a valid Md5 hash + * @param string $value + * @return bool + */ + private function isValidMd5Hash($value) + { + return 32 == strlen($value) && ctype_xdigit($value); + } } diff --git a/library/Zend/Authentication/Adapter/Http/ApacheResolver.php b/library/Zend/Authentication/Adapter/Http/ApacheResolver.php index a7b8b3d6..cd916e7d 100644 --- a/library/Zend/Authentication/Adapter/Http/ApacheResolver.php +++ b/library/Zend/Authentication/Adapter/Http/ApacheResolver.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php b/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php index 4ec6a3f7..cd849a07 100644 --- a/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php +++ b/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Http/Exception/InvalidArgumentException.php b/library/Zend/Authentication/Adapter/Http/Exception/InvalidArgumentException.php index 5e8fe751..80bad62b 100644 --- a/library/Zend/Authentication/Adapter/Http/Exception/InvalidArgumentException.php +++ b/library/Zend/Authentication/Adapter/Http/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Http/Exception/RuntimeException.php b/library/Zend/Authentication/Adapter/Http/Exception/RuntimeException.php index 94a9f9e1..f3ced1dd 100644 --- a/library/Zend/Authentication/Adapter/Http/Exception/RuntimeException.php +++ b/library/Zend/Authentication/Adapter/Http/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Http/FileResolver.php b/library/Zend/Authentication/Adapter/Http/FileResolver.php index 947027ab..bdcfb99b 100644 --- a/library/Zend/Authentication/Adapter/Http/FileResolver.php +++ b/library/Zend/Authentication/Adapter/Http/FileResolver.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Http/ResolverInterface.php b/library/Zend/Authentication/Adapter/Http/ResolverInterface.php index b236f845..f36c1941 100644 --- a/library/Zend/Authentication/Adapter/Http/ResolverInterface.php +++ b/library/Zend/Authentication/Adapter/Http/ResolverInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/Ldap.php b/library/Zend/Authentication/Adapter/Ldap.php index d9384c59..a4c8e331 100644 --- a/library/Zend/Authentication/Adapter/Ldap.php +++ b/library/Zend/Authentication/Adapter/Ldap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php b/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php index 3c4f01b2..9c711d2e 100644 --- a/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php +++ b/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/AuthenticationService.php b/library/Zend/Authentication/AuthenticationService.php index 76a26d3a..06e82e2e 100644 --- a/library/Zend/Authentication/AuthenticationService.php +++ b/library/Zend/Authentication/AuthenticationService.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -144,7 +144,7 @@ class AuthenticationService implements AuthenticationServiceInterface $storage = $this->getStorage(); if ($storage->isEmpty()) { - return null; + return; } return $storage->read(); diff --git a/library/Zend/Authentication/AuthenticationServiceInterface.php b/library/Zend/Authentication/AuthenticationServiceInterface.php index fcf74ea1..d3e347b6 100644 --- a/library/Zend/Authentication/AuthenticationServiceInterface.php +++ b/library/Zend/Authentication/AuthenticationServiceInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Exception/ExceptionInterface.php b/library/Zend/Authentication/Exception/ExceptionInterface.php index ed122ba7..87b39c4d 100644 --- a/library/Zend/Authentication/Exception/ExceptionInterface.php +++ b/library/Zend/Authentication/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Exception/InvalidArgumentException.php b/library/Zend/Authentication/Exception/InvalidArgumentException.php index 851fb73c..e837be44 100644 --- a/library/Zend/Authentication/Exception/InvalidArgumentException.php +++ b/library/Zend/Authentication/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Exception/RuntimeException.php b/library/Zend/Authentication/Exception/RuntimeException.php index 78bc6730..cf8fc4b8 100644 --- a/library/Zend/Authentication/Exception/RuntimeException.php +++ b/library/Zend/Authentication/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Exception/UnexpectedValueException.php b/library/Zend/Authentication/Exception/UnexpectedValueException.php index e1269290..0b04b8e9 100644 --- a/library/Zend/Authentication/Exception/UnexpectedValueException.php +++ b/library/Zend/Authentication/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Result.php b/library/Zend/Authentication/Result.php index 00f23f6c..086613c0 100644 --- a/library/Zend/Authentication/Result.php +++ b/library/Zend/Authentication/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -85,7 +85,7 @@ class Result */ public function isValid() { - return ($this->code > 0) ? true : false; + return ($this->code > 0); } /** diff --git a/library/Zend/Authentication/Storage/Chain.php b/library/Zend/Authentication/Storage/Chain.php index 8d995a2c..f32916e3 100644 --- a/library/Zend/Authentication/Storage/Chain.php +++ b/library/Zend/Authentication/Storage/Chain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Storage/NonPersistent.php b/library/Zend/Authentication/Storage/NonPersistent.php index 8d120493..13aa7868 100644 --- a/library/Zend/Authentication/Storage/NonPersistent.php +++ b/library/Zend/Authentication/Storage/NonPersistent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Storage/Session.php b/library/Zend/Authentication/Storage/Session.php index 6c66bec8..a91d8f22 100644 --- a/library/Zend/Authentication/Storage/Session.php +++ b/library/Zend/Authentication/Storage/Session.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Storage/StorageInterface.php b/library/Zend/Authentication/Storage/StorageInterface.php index 4a9d41b9..f9752086 100644 --- a/library/Zend/Authentication/Storage/StorageInterface.php +++ b/library/Zend/Authentication/Storage/StorageInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/Validator/Authentication.php b/library/Zend/Authentication/Validator/Authentication.php index d8bb0a84..5c834e5d 100644 --- a/library/Zend/Authentication/Validator/Authentication.php +++ b/library/Zend/Authentication/Validator/Authentication.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Authentication/composer.json b/library/Zend/Authentication/composer.json index fd6d242b..d1fa8914 100644 --- a/library/Zend/Authentication/composer.json +++ b/library/Zend/Authentication/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Authentication\\": "" } }, - "target-dir": "Zend/Authentication", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -37,8 +36,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Barcode/Barcode.php b/library/Zend/Barcode/Barcode.php index b2176b47..7cbc7ec4 100644 --- a/library/Zend/Barcode/Barcode.php +++ b/library/Zend/Barcode/Barcode.php @@ -3,13 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Barcode; use Traversable; +use Zend\Barcode\Renderer\RendererInterface; use Zend\Stdlib\ArrayUtils; /** @@ -92,7 +93,7 @@ abstract class Barcode * @param mixed $barcodeConfig OPTIONAL; an array or Traversable object with barcode parameters. * @param mixed $rendererConfig OPTIONAL; an array or Traversable object with renderer parameters. * @param bool $automaticRenderError OPTIONAL; set the automatic rendering of exception - * @return Barcode + * @return RendererInterface * @throws Exception\ExceptionInterface */ public static function factory( @@ -146,7 +147,7 @@ abstract class Barcode * @param mixed $barcode String name of barcode class, or Traversable object, or barcode object. * @param mixed $barcodeConfig OPTIONAL; an array or Traversable object with barcode parameters. * @throws Exception\InvalidArgumentException - * @return Object + * @return Object\ObjectInterface */ public static function makeBarcode($barcode, $barcodeConfig = array()) { diff --git a/library/Zend/Barcode/Exception/ExceptionInterface.php b/library/Zend/Barcode/Exception/ExceptionInterface.php index f421ceb9..4325f0f1 100644 --- a/library/Zend/Barcode/Exception/ExceptionInterface.php +++ b/library/Zend/Barcode/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Exception/InvalidArgumentException.php b/library/Zend/Barcode/Exception/InvalidArgumentException.php index 5f66af8e..1b263914 100644 --- a/library/Zend/Barcode/Exception/InvalidArgumentException.php +++ b/library/Zend/Barcode/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Exception/OutOfRangeException.php b/library/Zend/Barcode/Exception/OutOfRangeException.php index 0227ed6c..4a78781d 100644 --- a/library/Zend/Barcode/Exception/OutOfRangeException.php +++ b/library/Zend/Barcode/Exception/OutOfRangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Exception/RendererCreationException.php b/library/Zend/Barcode/Exception/RendererCreationException.php index d66442e9..b9d06e7d 100644 --- a/library/Zend/Barcode/Exception/RendererCreationException.php +++ b/library/Zend/Barcode/Exception/RendererCreationException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Exception/RuntimeException.php b/library/Zend/Barcode/Exception/RuntimeException.php index 36ac0148..f09d1aa4 100644 --- a/library/Zend/Barcode/Exception/RuntimeException.php +++ b/library/Zend/Barcode/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Exception/UnexpectedValueException.php b/library/Zend/Barcode/Exception/UnexpectedValueException.php index c5ecd352..32b8523f 100644 --- a/library/Zend/Barcode/Exception/UnexpectedValueException.php +++ b/library/Zend/Barcode/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/AbstractObject.php b/library/Zend/Barcode/Object/AbstractObject.php index 7fac057c..b7761fe9 100644 --- a/library/Zend/Barcode/Object/AbstractObject.php +++ b/library/Zend/Barcode/Object/AbstractObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -21,48 +21,56 @@ abstract class AbstractObject implements ObjectInterface { /** * Namespace of the barcode for autoloading + * * @var string */ protected $barcodeNamespace = 'Zend\Barcode\Object'; /** * Set of drawing instructions + * * @var array */ protected $instructions = array(); /** * Barcode type + * * @var string */ protected $type = null; /** * Height of the object + * * @var int */ protected $height = null; /** * Width of the object + * * @var int */ protected $width = null; /** * Height of the bar + * * @var int */ protected $barHeight = 50; /** * Width of a thin bar + * * @var int */ protected $barThinWidth = 1; /** * Width of a thick bar + * * @var int */ protected $barThickWidth = 3; @@ -70,42 +78,49 @@ abstract class AbstractObject implements ObjectInterface /** * Factor to multiply bar and font measure * (barHeight, barThinWidth, barThickWidth & fontSize) + * * @var int */ protected $factor = 1; /** * Font and bars color of the object + * * @var int */ protected $foreColor = 0x000000; /** * Background color of the object + * * @var int */ protected $backgroundColor = 0xFFFFFF; /** * Activate/deactivate border of the object + * * @var bool */ protected $withBorder = false; /** * Activate/deactivate drawing of quiet zones + * * @var bool */ protected $withQuietZones = true; /** * Force quiet zones even if + * * @var bool */ protected $mandatoryQuietZones = false; /** * Orientation of the barcode in degrees + * * @var float */ protected $orientation = 0; @@ -113,6 +128,7 @@ abstract class AbstractObject implements ObjectInterface /** * Offset from the top the object * (calculated from the orientation) + * * @var int */ protected $offsetTop = null; @@ -120,24 +136,28 @@ abstract class AbstractObject implements ObjectInterface /** * Offset from the left the object * (calculated from the orientation) + * * @var int */ protected $offsetLeft = null; /** * Text to display + * * @var string */ protected $text = null; /** * Display (or not) human readable text + * * @var bool */ protected $drawText = true; /** * Adjust (or not) position of human readable characters with barcode + * * @var bool */ protected $stretchText = false; @@ -146,30 +166,35 @@ abstract class AbstractObject implements ObjectInterface * Font resource * - integer (1 to 5): corresponds to GD included fonts * - string: corresponds to path of a TTF font + * * @var int|string */ protected $font = null; /** * Font size + * * @var float */ protected $fontSize = 10; /** * Drawing of checksum + * * @var bool */ protected $withChecksum = false; /** * Drawing of checksum inside text + * * @var bool */ protected $withChecksumInText = false; /** * Fix barcode length (numeric or string like 'even') + * * @var int | string */ protected $barcodeLength = null; @@ -177,6 +202,7 @@ abstract class AbstractObject implements ObjectInterface /** * Activate automatic addition of leading zeros * if barcode length is fixed + * * @var bool */ protected $addLeadingZeros = true; @@ -184,18 +210,21 @@ abstract class AbstractObject implements ObjectInterface /** * Activation of mandatory checksum * to deactivate unauthorized modification + * * @var bool */ protected $mandatoryChecksum = false; /** * Character used to substitute checksum character for validation + * * @var mixed */ protected $substituteChecksumCharacter = 0; /** * Constructor + * * @param array|Traversable $options */ public function __construct($options = null) @@ -217,7 +246,6 @@ abstract class AbstractObject implements ObjectInterface /** * Set default options for particular object - * @return void */ protected function getDefaultOptions() { @@ -225,6 +253,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set barcode state from options array + * * @param array $options * @return \Zend\Barcode\Object\ObjectInterface */ @@ -263,6 +292,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve type of barcode + * * @return string */ public function getType() @@ -272,6 +302,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set height of the barcode bar + * * @param int $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -289,6 +320,7 @@ abstract class AbstractObject implements ObjectInterface /** * Get height of the barcode bar + * * @return int */ public function getBarHeight() @@ -298,6 +330,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set thickness of thin bar + * * @param int $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -315,6 +348,7 @@ abstract class AbstractObject implements ObjectInterface /** * Get thickness of thin bar + * * @return int */ public function getBarThinWidth() @@ -324,6 +358,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set thickness of thick bar + * * @param int $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -341,6 +376,7 @@ abstract class AbstractObject implements ObjectInterface /** * Get thickness of thick bar + * * @return int */ public function getBarThickWidth() @@ -351,7 +387,8 @@ abstract class AbstractObject implements ObjectInterface /** * Set factor applying to * thinBarWidth - thickBarWidth - barHeight - fontSize - * @param float $value + * + * @param int|float|string|bool $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface */ @@ -369,6 +406,7 @@ abstract class AbstractObject implements ObjectInterface /** * Get factor applying to * thinBarWidth - thickBarWidth - barHeight - fontSize + * * @return int */ public function getFactor() @@ -378,6 +416,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set color of the barcode and text + * * @param string $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -398,6 +437,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve color of the barcode and text + * * @return int */ public function getForeColor() @@ -407,6 +447,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set the color of the background + * * @param int $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -427,6 +468,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve background color of the image + * * @return int */ public function getBackgroundColor() @@ -436,6 +478,7 @@ abstract class AbstractObject implements ObjectInterface /** * Activate/deactivate drawing of the bar + * * @param bool $value * @return \Zend\Barcode\Object\ObjectInterface */ @@ -447,6 +490,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve if border are draw or not + * * @return bool */ public function getWithBorder() @@ -456,6 +500,7 @@ abstract class AbstractObject implements ObjectInterface /** * Activate/deactivate drawing of the quiet zones + * * @param bool $value * @return AbstractObject */ @@ -467,6 +512,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve if quiet zones are draw or not + * * @return bool */ public function getWithQuietZones() @@ -476,6 +522,7 @@ abstract class AbstractObject implements ObjectInterface /** * Allow fast inversion of font/bars color and background color + * * @return \Zend\Barcode\Object\ObjectInterface */ public function setReverseColor() @@ -488,7 +535,8 @@ abstract class AbstractObject implements ObjectInterface /** * Set orientation of barcode and text - * @param float $value + * + * @param int|float|string|bool $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface */ @@ -500,6 +548,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve orientation of barcode and text + * * @return float */ public function getOrientation() @@ -509,6 +558,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set text to encode + * * @param string $value * @return \Zend\Barcode\Object\ObjectInterface */ @@ -520,6 +570,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve text to encode + * * @return string */ public function getText() @@ -533,8 +584,9 @@ abstract class AbstractObject implements ObjectInterface /** * Automatically add leading zeros if barcode length is fixed - * @param string $text - * @param bool $withoutChecksum + * + * @param string $text + * @param bool $withoutChecksum * @return string */ protected function addLeadingZeros($text, $withoutChecksum = false) @@ -557,6 +609,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve text to encode + * * @return string */ public function getRawText() @@ -566,6 +619,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve text to display + * * @return string */ public function getTextToDisplay() @@ -579,6 +633,7 @@ abstract class AbstractObject implements ObjectInterface /** * Activate/deactivate drawing of text to encode + * * @param bool $value * @return \Zend\Barcode\Object\ObjectInterface */ @@ -590,6 +645,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve if drawing of text to encode is enabled + * * @return bool */ public function getDrawText() @@ -600,6 +656,7 @@ abstract class AbstractObject implements ObjectInterface /** * Activate/deactivate the adjustment of the position * of the characters to the position of the bars + * * @param bool $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -613,6 +670,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve if the adjustment of the position of the characters * to the position of the bars is enabled + * * @return bool */ public function getStretchText() @@ -624,6 +682,7 @@ abstract class AbstractObject implements ObjectInterface * Activate/deactivate the automatic generation * of the checksum character * added to the barcode text + * * @param bool $value * @return \Zend\Barcode\Object\ObjectInterface */ @@ -638,6 +697,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve if the checksum character is automatically * added to the barcode text + * * @return bool */ public function getWithChecksum() @@ -649,6 +709,7 @@ abstract class AbstractObject implements ObjectInterface * Activate/deactivate the automatic generation * of the checksum character * added to the barcode text + * * @param bool $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -664,6 +725,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve if the checksum character is automatically * added to the barcode text + * * @return bool */ public function getWithChecksumInText() @@ -675,6 +737,7 @@ abstract class AbstractObject implements ObjectInterface * Set the font: * - if integer between 1 and 5, use gd built-in fonts * - if string, $value is assumed to be the path to a TTF font + * * @param int|string $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -706,6 +769,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve the font + * * @return int|string */ public function getFont() @@ -715,6 +779,7 @@ abstract class AbstractObject implements ObjectInterface /** * Set the size of the font in case of TTF + * * @param float $value * @return \Zend\Barcode\Object\ObjectInterface * @throws \Zend\Barcode\Object\Exception\ExceptionInterface @@ -748,6 +813,7 @@ abstract class AbstractObject implements ObjectInterface /** * Quiet zone before first bar * and after the last bar + * * @return int */ public function getQuietZone() @@ -761,6 +827,7 @@ abstract class AbstractObject implements ObjectInterface /** * Add an instruction in the array of instructions + * * @param array $instruction */ protected function addInstruction(array $instruction) @@ -770,6 +837,7 @@ abstract class AbstractObject implements ObjectInterface /** * Retrieve the set of drawing instructions + * * @return array */ public function getInstructions() @@ -779,9 +847,10 @@ abstract class AbstractObject implements ObjectInterface /** * Add a polygon drawing instruction in the set of instructions + * * @param array $points - * @param int $color - * @param bool $filled + * @param int $color + * @param bool $filled */ protected function addPolygon(array $points, $color = null, $filled = true) { @@ -798,13 +867,14 @@ abstract class AbstractObject implements ObjectInterface /** * Add a text drawing instruction in the set of instructions + * * @param string $text - * @param float $size - * @param int[] $position + * @param float $size + * @param int[] $position * @param string $font - * @param int $color + * @param int $color * @param string $alignment - * @param float $orientation + * @param float|int $orientation */ protected function addText( $text, @@ -832,6 +902,7 @@ abstract class AbstractObject implements ObjectInterface /** * Checking of parameters after all settings + * * @return bool */ public function checkParams() @@ -844,8 +915,8 @@ abstract class AbstractObject implements ObjectInterface /** * Check if a text is really provided to barcode + * * @param string|null $value - * @return void * @throws \Zend\Barcode\Object\Exception\ExceptionInterface */ protected function checkText($value = null) @@ -863,9 +934,9 @@ abstract class AbstractObject implements ObjectInterface /** * Check the ratio between the thick and the thin bar + * * @param int $min * @param int $max - * @return void * @throws \Zend\Barcode\Object\Exception\ExceptionInterface */ protected function checkRatio($min = 2, $max = 3) @@ -883,7 +954,7 @@ abstract class AbstractObject implements ObjectInterface /** * Drawing with an angle is just allow TTF font - * @return void + * * @throws \Zend\Barcode\Object\Exception\ExceptionInterface */ protected function checkFontAndOrientation() @@ -898,6 +969,7 @@ abstract class AbstractObject implements ObjectInterface /** * Width of the result image * (before any rotation) + * * @return int */ protected function calculateWidth() @@ -909,12 +981,14 @@ abstract class AbstractObject implements ObjectInterface /** * Calculate the width of the barcode + * * @return int */ abstract protected function calculateBarcodeWidth(); /** * Height of the result object + * * @return int */ protected function calculateHeight() @@ -926,6 +1000,7 @@ abstract class AbstractObject implements ObjectInterface /** * Height of the barcode + * * @return int */ protected function calculateBarcodeHeight() @@ -941,6 +1016,7 @@ abstract class AbstractObject implements ObjectInterface /** * Get height of the result object + * * @param bool $recalculate * @return int */ @@ -956,6 +1032,7 @@ abstract class AbstractObject implements ObjectInterface /** * Get width of the result object + * * @param bool $recalculate * @return int */ @@ -972,6 +1049,7 @@ abstract class AbstractObject implements ObjectInterface /** * Calculate the offset from the left of the object * if an orientation is activated + * * @param bool $recalculate * @return float */ @@ -993,6 +1071,7 @@ abstract class AbstractObject implements ObjectInterface /** * Calculate the offset from the top of the object * if an orientation is activated + * * @param bool $recalculate * @return float */ @@ -1013,9 +1092,10 @@ abstract class AbstractObject implements ObjectInterface /** * Apply rotation on a point in X/Y dimensions - * @param float $x1 x-position before rotation - * @param float $y1 y-position before rotation - * @return int[] Array of two elements corresponding to the new XY point + * + * @param float $x1 x-position before rotation + * @param float $y1 y-position before rotation + * @return array Array of two elements corresponding to the new XY point */ protected function rotate($x1, $y1) { @@ -1030,6 +1110,7 @@ abstract class AbstractObject implements ObjectInterface /** * Complete drawing of the barcode + * * @return array Table of instructions */ public function draw() @@ -1043,7 +1124,6 @@ abstract class AbstractObject implements ObjectInterface /** * Draw the barcode - * @return void */ protected function drawBarcode() { @@ -1100,7 +1180,6 @@ abstract class AbstractObject implements ObjectInterface /** * Partial function to draw border - * @return void */ protected function drawBorder() { @@ -1124,7 +1203,6 @@ abstract class AbstractObject implements ObjectInterface /** * Partial function to draw text - * @return void */ protected function drawText() { @@ -1167,8 +1245,8 @@ abstract class AbstractObject implements ObjectInterface /** * Check for invalid characters - * @param string $value Text to be checked - * @return void + * + * @param string $value Text to be checked */ public function validateText($value) { @@ -1177,6 +1255,7 @@ abstract class AbstractObject implements ObjectInterface /** * Standard validation for most of barcode objects + * * @param string $value * @param array $options */ @@ -1222,15 +1301,11 @@ abstract class AbstractObject implements ObjectInterface /** * Checking of parameters after all settings - * - * @return void */ abstract protected function checkSpecificParams(); /** * Allow each child to draw something else - * - * @return void */ protected function preDrawBarcode() { @@ -1239,8 +1314,6 @@ abstract class AbstractObject implements ObjectInterface /** * Allow each child to draw something else * (ex: bearer bars in interleaved 2 of 5 code) - * - * @return void */ protected function postDrawBarcode() { diff --git a/library/Zend/Barcode/Object/Codabar.php b/library/Zend/Barcode/Object/Codabar.php index 71120c60..e9766788 100644 --- a/library/Zend/Barcode/Object/Codabar.php +++ b/library/Zend/Barcode/Object/Codabar.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Code128.php b/library/Zend/Barcode/Object/Code128.php index 3bb0cc0c..c4e8916f 100644 --- a/library/Zend/Barcode/Object/Code128.php +++ b/library/Zend/Barcode/Object/Code128.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Code25.php b/library/Zend/Barcode/Object/Code25.php index 2f32ca7a..8d0af026 100644 --- a/library/Zend/Barcode/Object/Code25.php +++ b/library/Zend/Barcode/Object/Code25.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Code25interleaved.php b/library/Zend/Barcode/Object/Code25interleaved.php index 0fb3ec33..766a8433 100644 --- a/library/Zend/Barcode/Object/Code25interleaved.php +++ b/library/Zend/Barcode/Object/Code25interleaved.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Code39.php b/library/Zend/Barcode/Object/Code39.php index c70e289e..54b85534 100644 --- a/library/Zend/Barcode/Object/Code39.php +++ b/library/Zend/Barcode/Object/Code39.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Ean13.php b/library/Zend/Barcode/Object/Ean13.php index 602668d9..25bcc892 100644 --- a/library/Zend/Barcode/Object/Ean13.php +++ b/library/Zend/Barcode/Object/Ean13.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Ean2.php b/library/Zend/Barcode/Object/Ean2.php index b260a62d..94db63f4 100644 --- a/library/Zend/Barcode/Object/Ean2.php +++ b/library/Zend/Barcode/Object/Ean2.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Ean5.php b/library/Zend/Barcode/Object/Ean5.php index c04708bd..7ec26c04 100644 --- a/library/Zend/Barcode/Object/Ean5.php +++ b/library/Zend/Barcode/Object/Ean5.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Ean8.php b/library/Zend/Barcode/Object/Ean8.php index b36ec3e4..d3d7c9fe 100644 --- a/library/Zend/Barcode/Object/Ean8.php +++ b/library/Zend/Barcode/Object/Ean8.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Error.php b/library/Zend/Barcode/Object/Error.php index 15c36bca..2f5ddefd 100644 --- a/library/Zend/Barcode/Object/Error.php +++ b/library/Zend/Barcode/Object/Error.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php b/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php index 64f3ea56..d0071d16 100644 --- a/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php +++ b/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Exception/ExceptionInterface.php b/library/Zend/Barcode/Object/Exception/ExceptionInterface.php index d0488d79..87260822 100644 --- a/library/Zend/Barcode/Object/Exception/ExceptionInterface.php +++ b/library/Zend/Barcode/Object/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Exception/ExtensionNotLoadedException.php b/library/Zend/Barcode/Object/Exception/ExtensionNotLoadedException.php index 340b724e..a219a49f 100644 --- a/library/Zend/Barcode/Object/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Barcode/Object/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Exception/InvalidArgumentException.php b/library/Zend/Barcode/Object/Exception/InvalidArgumentException.php index be38887c..e5f31ddc 100644 --- a/library/Zend/Barcode/Object/Exception/InvalidArgumentException.php +++ b/library/Zend/Barcode/Object/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Exception/OutOfRangeException.php b/library/Zend/Barcode/Object/Exception/OutOfRangeException.php index f56edfed..95f952c7 100644 --- a/library/Zend/Barcode/Object/Exception/OutOfRangeException.php +++ b/library/Zend/Barcode/Object/Exception/OutOfRangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Exception/RuntimeException.php b/library/Zend/Barcode/Object/Exception/RuntimeException.php index 735c7d56..2909f082 100644 --- a/library/Zend/Barcode/Object/Exception/RuntimeException.php +++ b/library/Zend/Barcode/Object/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Identcode.php b/library/Zend/Barcode/Object/Identcode.php index b0505382..f8512302 100644 --- a/library/Zend/Barcode/Object/Identcode.php +++ b/library/Zend/Barcode/Object/Identcode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Itf14.php b/library/Zend/Barcode/Object/Itf14.php index 361f9bd5..226f17a9 100644 --- a/library/Zend/Barcode/Object/Itf14.php +++ b/library/Zend/Barcode/Object/Itf14.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Leitcode.php b/library/Zend/Barcode/Object/Leitcode.php index f82f3a5c..06f6d202 100644 --- a/library/Zend/Barcode/Object/Leitcode.php +++ b/library/Zend/Barcode/Object/Leitcode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/ObjectInterface.php b/library/Zend/Barcode/Object/ObjectInterface.php index 836e0138..c1844c1e 100644 --- a/library/Zend/Barcode/Object/ObjectInterface.php +++ b/library/Zend/Barcode/Object/ObjectInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Planet.php b/library/Zend/Barcode/Object/Planet.php index e06e6109..7da86f16 100644 --- a/library/Zend/Barcode/Object/Planet.php +++ b/library/Zend/Barcode/Object/Planet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Postnet.php b/library/Zend/Barcode/Object/Postnet.php index 07b1d3c2..fc55fb7a 100644 --- a/library/Zend/Barcode/Object/Postnet.php +++ b/library/Zend/Barcode/Object/Postnet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Royalmail.php b/library/Zend/Barcode/Object/Royalmail.php index 23d8a709..7828dad9 100644 --- a/library/Zend/Barcode/Object/Royalmail.php +++ b/library/Zend/Barcode/Object/Royalmail.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Upca.php b/library/Zend/Barcode/Object/Upca.php index 1add66c7..6b9e50e8 100644 --- a/library/Zend/Barcode/Object/Upca.php +++ b/library/Zend/Barcode/Object/Upca.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Object/Upce.php b/library/Zend/Barcode/Object/Upce.php index 2114b11e..696fc7f2 100644 --- a/library/Zend/Barcode/Object/Upce.php +++ b/library/Zend/Barcode/Object/Upce.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/ObjectPluginManager.php b/library/Zend/Barcode/ObjectPluginManager.php index 40345f83..80af078b 100644 --- a/library/Zend/Barcode/ObjectPluginManager.php +++ b/library/Zend/Barcode/ObjectPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/AbstractRenderer.php b/library/Zend/Barcode/Renderer/AbstractRenderer.php index 8a625e85..0d2b631c 100644 --- a/library/Zend/Barcode/Renderer/AbstractRenderer.php +++ b/library/Zend/Barcode/Renderer/AbstractRenderer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -52,13 +52,13 @@ abstract class AbstractRenderer implements RendererInterface /** * Horizontal position of the barcode in the rendering resource - * @var int + * @var string */ protected $horizontalPosition = 'left'; /** * Vertical position of the barcode in the rendering resource - * @var int + * @var string */ protected $verticalPosition = 'top'; @@ -501,7 +501,7 @@ abstract class AbstractRenderer implements RendererInterface * @param string $font * @param int $color * @param string $alignment - * @param float $orientation + * @param float|int $orientation */ abstract protected function drawText( $text, diff --git a/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php b/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php index f7f4d445..5ae1e5b1 100644 --- a/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php +++ b/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/Exception/InvalidArgumentException.php b/library/Zend/Barcode/Renderer/Exception/InvalidArgumentException.php index bbdb502b..b58c2e67 100644 --- a/library/Zend/Barcode/Renderer/Exception/InvalidArgumentException.php +++ b/library/Zend/Barcode/Renderer/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/Exception/OutOfRangeException.php b/library/Zend/Barcode/Renderer/Exception/OutOfRangeException.php index 2d3d7ce8..3a218d39 100644 --- a/library/Zend/Barcode/Renderer/Exception/OutOfRangeException.php +++ b/library/Zend/Barcode/Renderer/Exception/OutOfRangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/Exception/RuntimeException.php b/library/Zend/Barcode/Renderer/Exception/RuntimeException.php index 2eb1c345..5873436f 100644 --- a/library/Zend/Barcode/Renderer/Exception/RuntimeException.php +++ b/library/Zend/Barcode/Renderer/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/Exception/UnexpectedValueException.php b/library/Zend/Barcode/Renderer/Exception/UnexpectedValueException.php index 8fa8d64f..ea86988f 100644 --- a/library/Zend/Barcode/Renderer/Exception/UnexpectedValueException.php +++ b/library/Zend/Barcode/Renderer/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/Image.php b/library/Zend/Barcode/Renderer/Image.php index e8fae09b..0dca09cc 100644 --- a/library/Zend/Barcode/Renderer/Image.php +++ b/library/Zend/Barcode/Renderer/Image.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -204,6 +204,11 @@ class Image extends AbstractRenderer $height = $this->userHeight; } + // Cast width and height to ensure they are correct type for image + // operations + $width = (int) $width; + $height = (int) $height; + $this->resource = imagecreatetruecolor($width, $height); $white = imagecolorallocate($this->resource, 255, 255, 255); @@ -238,8 +243,8 @@ class Image extends AbstractRenderer $this->resource, $this->leftOffset, $this->topOffset, - $this->leftOffset + $barcodeWidth - 1, - $this->topOffset + $barcodeHeight - 1, + (int) ($this->leftOffset + $barcodeWidth - 1), + (int) ($this->topOffset + $barcodeHeight - 1), $this->imageBackgroundColor ); } @@ -358,7 +363,7 @@ class Image extends AbstractRenderer * @param string $font * @param int $color * @param string $alignment - * @param float $orientation + * @param float|int $orientation * @throws Exception\RuntimeException */ protected function drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0) @@ -370,7 +375,7 @@ class Image extends AbstractRenderer $color & 0x0000FF ); - if ($font == null) { + if ($font === null) { $font = 3; } $position[0] += $this->leftOffset; @@ -382,7 +387,7 @@ class Image extends AbstractRenderer * imagestring() doesn't allow orientation, if orientation * needed: a TTF font is required. * Throwing an exception here, allow to use automaticRenderError - * to informe user of the problem instead of simply not drawing + * to inform user of the problem instead of simply not drawing * the text */ throw new Exception\RuntimeException( diff --git a/library/Zend/Barcode/Renderer/Pdf.php b/library/Zend/Barcode/Renderer/Pdf.php index e4e084d4..5e83dc25 100644 --- a/library/Zend/Barcode/Renderer/Pdf.php +++ b/library/Zend/Barcode/Renderer/Pdf.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/RendererInterface.php b/library/Zend/Barcode/Renderer/RendererInterface.php index 795654f3..0d77ce7b 100644 --- a/library/Zend/Barcode/Renderer/RendererInterface.php +++ b/library/Zend/Barcode/Renderer/RendererInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/Renderer/Svg.php b/library/Zend/Barcode/Renderer/Svg.php index 45cc0822..3906d425 100644 --- a/library/Zend/Barcode/Renderer/Svg.php +++ b/library/Zend/Barcode/Renderer/Svg.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/RendererPluginManager.php b/library/Zend/Barcode/RendererPluginManager.php index 0c8c2f8a..d81b84d2 100644 --- a/library/Zend/Barcode/RendererPluginManager.php +++ b/library/Zend/Barcode/RendererPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Barcode/composer.json b/library/Zend/Barcode/composer.json index f351302e..72cefc47 100644 --- a/library/Zend/Barcode/composer.json +++ b/library/Zend/Barcode/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Barcode\\": "" } }, - "target-dir": "Zend/Barcode", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version", @@ -28,8 +27,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Cache/Exception/BadMethodCallException.php b/library/Zend/Cache/Exception/BadMethodCallException.php index dc8af1fc..c851fc8b 100644 --- a/library/Zend/Cache/Exception/BadMethodCallException.php +++ b/library/Zend/Cache/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/ExceptionInterface.php b/library/Zend/Cache/Exception/ExceptionInterface.php index 1457349d..4119228d 100644 --- a/library/Zend/Cache/Exception/ExceptionInterface.php +++ b/library/Zend/Cache/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/ExtensionNotLoadedException.php b/library/Zend/Cache/Exception/ExtensionNotLoadedException.php index 17621c5a..94ec19db 100644 --- a/library/Zend/Cache/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Cache/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/InvalidArgumentException.php b/library/Zend/Cache/Exception/InvalidArgumentException.php index b3b8eeb3..57a72630 100644 --- a/library/Zend/Cache/Exception/InvalidArgumentException.php +++ b/library/Zend/Cache/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/LogicException.php b/library/Zend/Cache/Exception/LogicException.php index f0fbf67b..0832f41c 100644 --- a/library/Zend/Cache/Exception/LogicException.php +++ b/library/Zend/Cache/Exception/LogicException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/MissingDependencyException.php b/library/Zend/Cache/Exception/MissingDependencyException.php index 94f6ec0f..4ce85ff8 100644 --- a/library/Zend/Cache/Exception/MissingDependencyException.php +++ b/library/Zend/Cache/Exception/MissingDependencyException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/MissingKeyException.php b/library/Zend/Cache/Exception/MissingKeyException.php index 24564ef6..8ddf128f 100644 --- a/library/Zend/Cache/Exception/MissingKeyException.php +++ b/library/Zend/Cache/Exception/MissingKeyException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/OutOfSpaceException.php b/library/Zend/Cache/Exception/OutOfSpaceException.php index a8a3c198..7cbbe18b 100644 --- a/library/Zend/Cache/Exception/OutOfSpaceException.php +++ b/library/Zend/Cache/Exception/OutOfSpaceException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/RuntimeException.php b/library/Zend/Cache/Exception/RuntimeException.php index a72f5068..dd6aec3e 100644 --- a/library/Zend/Cache/Exception/RuntimeException.php +++ b/library/Zend/Cache/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/UnexpectedValueException.php b/library/Zend/Cache/Exception/UnexpectedValueException.php index 9b168bee..af3c5bf9 100644 --- a/library/Zend/Cache/Exception/UnexpectedValueException.php +++ b/library/Zend/Cache/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Exception/UnsupportedMethodCallException.php b/library/Zend/Cache/Exception/UnsupportedMethodCallException.php index 92855748..28af6a54 100644 --- a/library/Zend/Cache/Exception/UnsupportedMethodCallException.php +++ b/library/Zend/Cache/Exception/UnsupportedMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Pattern/AbstractPattern.php b/library/Zend/Cache/Pattern/AbstractPattern.php index eef7ef9e..2818c41e 100644 --- a/library/Zend/Cache/Pattern/AbstractPattern.php +++ b/library/Zend/Cache/Pattern/AbstractPattern.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Pattern/CallbackCache.php b/library/Zend/Cache/Pattern/CallbackCache.php index a26a0074..ea5f0aef 100644 --- a/library/Zend/Cache/Pattern/CallbackCache.php +++ b/library/Zend/Cache/Pattern/CallbackCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -59,7 +59,7 @@ class CallbackCache extends AbstractPattern $cacheOutput = $options->getCacheOutput(); if ($cacheOutput) { ob_start(); - ob_implicit_flush(false); + ob_implicit_flush(0); } // TODO: do not cache on errors using [set|restore]_error_handler @@ -137,9 +137,11 @@ class CallbackCache extends AbstractPattern $callbackKey = strtolower($callbackKey); // generate a unique key of object callbacks - if (is_object($callback)) { // Closures & __invoke + if (is_object($callback)) { + // Closures & __invoke $object = $callback; - } elseif (isset($callback[0])) { // array($object, 'method') + } elseif (isset($callback[0])) { + // array($object, 'method') $object = $callback[0]; } if (isset($object)) { diff --git a/library/Zend/Cache/Pattern/CaptureCache.php b/library/Zend/Cache/Pattern/CaptureCache.php index 7d5cec69..03fa037a 100644 --- a/library/Zend/Cache/Pattern/CaptureCache.php +++ b/library/Zend/Cache/Pattern/CaptureCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ class CaptureCache extends AbstractPattern return false; }); - ob_implicit_flush(false); + ob_implicit_flush(0); } /** @@ -301,14 +301,14 @@ class CaptureCache extends AbstractPattern // build-in mkdir function is enough $umask = ($umask !== false) ? umask($umask) : false; - $res = mkdir($pathname, ($perm !== false) ? $perm : 0777, true); + $res = mkdir($pathname, ($perm !== false) ? $perm : 0775, true); if ($umask !== false) { umask($umask); } if (!$res) { - $oct = ($perm === false) ? '777' : decoct($perm); + $oct = ($perm === false) ? '775' : decoct($perm); $err = ErrorHandler::stop(); throw new Exception\RuntimeException("mkdir('{$pathname}', 0{$oct}, true) failed", 0, $err); } @@ -341,13 +341,13 @@ class CaptureCache extends AbstractPattern // create a single directory, set and reset umask immediately $umask = ($umask !== false) ? umask($umask) : false; - $res = mkdir($path, ($perm === false) ? 0777 : $perm, false); + $res = mkdir($path, ($perm === false) ? 0775 : $perm, false); if ($umask !== false) { umask($umask); } if (!$res) { - $oct = ($perm === false) ? '777' : decoct($perm); + $oct = ($perm === false) ? '775' : decoct($perm); ErrorHandler::stop(); throw new Exception\RuntimeException( "mkdir('{$path}', 0{$oct}, false) failed" diff --git a/library/Zend/Cache/Pattern/ClassCache.php b/library/Zend/Cache/Pattern/ClassCache.php index 238feed5..d6c9335b 100644 --- a/library/Zend/Cache/Pattern/ClassCache.php +++ b/library/Zend/Cache/Pattern/ClassCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Pattern/ObjectCache.php b/library/Zend/Cache/Pattern/ObjectCache.php index 9ef2a241..6ca6a15b 100644 --- a/library/Zend/Cache/Pattern/ObjectCache.php +++ b/library/Zend/Cache/Pattern/ObjectCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Pattern/OutputCache.php b/library/Zend/Cache/Pattern/OutputCache.php index 549e1712..419e264e 100644 --- a/library/Zend/Cache/Pattern/OutputCache.php +++ b/library/Zend/Cache/Pattern/OutputCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -60,7 +60,7 @@ class OutputCache extends AbstractPattern } ob_start(); - ob_implicit_flush(false); + ob_implicit_flush(0); $this->keyStack[] = $key; return false; } diff --git a/library/Zend/Cache/Pattern/PatternInterface.php b/library/Zend/Cache/Pattern/PatternInterface.php index a79bf518..53505706 100644 --- a/library/Zend/Cache/Pattern/PatternInterface.php +++ b/library/Zend/Cache/Pattern/PatternInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Pattern/PatternOptions.php b/library/Zend/Cache/Pattern/PatternOptions.php index 224578a3..d62a12a7 100644 --- a/library/Zend/Cache/Pattern/PatternOptions.php +++ b/library/Zend/Cache/Pattern/PatternOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -375,7 +375,7 @@ class PatternOptions extends AbstractOptions } // normalize - $umask = $umask & 0777; + $umask = $umask & ~0002; } $this->umask = $umask; @@ -574,7 +574,7 @@ class PatternOptions extends AbstractOptions * Used by: * - ObjectCache * - * @param mixed $objectKey + * @param null|string $objectKey The object key or NULL to use the objects class name * @return PatternOptions */ public function setObjectKey($objectKey) @@ -597,7 +597,7 @@ class PatternOptions extends AbstractOptions */ public function getObjectKey() { - if (!$this->objectKey) { + if ($this->objectKey === null) { return get_class($this->getObject()); } return $this->objectKey; diff --git a/library/Zend/Cache/PatternFactory.php b/library/Zend/Cache/PatternFactory.php index dceed003..0f6db572 100644 --- a/library/Zend/Cache/PatternFactory.php +++ b/library/Zend/Cache/PatternFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/PatternPluginManager.php b/library/Zend/Cache/PatternPluginManager.php index 7d5d0e1a..5a77b7c8 100644 --- a/library/Zend/Cache/PatternPluginManager.php +++ b/library/Zend/Cache/PatternPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php b/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php index 66eb6505..36e7d789 100644 --- a/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php +++ b/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Service/StorageCacheFactory.php b/library/Zend/Cache/Service/StorageCacheFactory.php index f2c20499..faae5960 100644 --- a/library/Zend/Cache/Service/StorageCacheFactory.php +++ b/library/Zend/Cache/Service/StorageCacheFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php b/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php index 71edf763..fdf8182f 100644 --- a/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php +++ b/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -217,11 +217,10 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa { $postEvent = new PostEvent($eventName . '.post', $this, $args, $result); $eventRs = $this->getEventManager()->trigger($postEvent); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - return $postEvent->getResult(); + return $eventRs->stopped() + ? $eventRs->last() + : $postEvent->getResult(); } /** @@ -246,11 +245,9 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa throw $exceptionEvent->getException(); } - if ($eventRs->stopped()) { - return $eventRs->last(); - } - - return $exceptionEvent->getResult(); + return $eventRs->stopped() + ? $eventRs->last() + : $exceptionEvent->getResult(); } /** @@ -338,7 +335,7 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa { if (!$this->getOptions()->getReadable()) { $success = false; - return null; + return; } $this->normalizeKey($key); @@ -357,20 +354,21 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - if ($args->offsetExists('success') && $args->offsetExists('casToken')) { + if ($eventRs->stopped()) { + $result = $eventRs->last(); + } elseif ($args->offsetExists('success') && $args->offsetExists('casToken')) { $result = $this->internalGetItem($args['key'], $args['success'], $args['casToken']); } elseif ($args->offsetExists('success')) { $result = $this->internalGetItem($args['key'], $args['success']); } else { $result = $this->internalGetItem($args['key']); } + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { - $result = false; + $result = null; + $success = false; return $this->triggerException(__FUNCTION__, $args, $result, $e); } } @@ -410,11 +408,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalGetItems($args['keys']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalGetItems($args['keys']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array(); @@ -467,11 +465,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalHasItem($args['key']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalHasItem($args['key']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -517,11 +515,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalHasItems($args['keys']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalHasItems($args['keys']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array(); @@ -571,11 +569,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalGetMetadata($args['key']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalGetMetadata($args['key']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -623,11 +621,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalGetMetadatas($args['keys']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalGetMetadatas($args['keys']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array(); @@ -682,11 +680,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalSetItem($args['key'], $args['value']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalSetItem($args['key'], $args['value']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -728,11 +726,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalSetItems($args['keyValuePairs']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalSetItems($args['keyValuePairs']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array_keys($keyValuePairs); @@ -784,11 +782,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalAddItem($args['key'], $args['value']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalAddItem($args['key'], $args['value']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -836,11 +834,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalAddItems($args['keyValuePairs']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalAddItems($args['keyValuePairs']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array_keys($keyValuePairs); @@ -892,11 +890,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalReplaceItem($args['key'], $args['value']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalReplaceItem($args['key'], $args['value']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -945,11 +943,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalReplaceItems($args['keyValuePairs']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalReplaceItems($args['keyValuePairs']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array_keys($keyValuePairs); @@ -1004,11 +1002,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalCheckAndSetItem($args['token'], $args['key'], $args['value']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalCheckAndSetItem($args['token'], $args['key'], $args['value']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -1061,11 +1059,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalTouchItem($args['key']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalTouchItem($args['key']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -1115,11 +1113,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalTouchItems($args['keys']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalTouchItems($args['keys']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { return $this->triggerException(__FUNCTION__, $args, $keys, $e); @@ -1168,11 +1166,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalRemoveItem($args['key']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalRemoveItem($args['key']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -1213,11 +1211,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalRemoveItems($args['keys']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalRemoveItems($args['keys']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { return $this->triggerException(__FUNCTION__, $args, $keys, $e); @@ -1268,11 +1266,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalIncrementItem($args['key'], $args['value']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalIncrementItem($args['key'], $args['value']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -1328,11 +1326,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalIncrementItems($args['keyValuePairs']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalIncrementItems($args['keyValuePairs']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array(); @@ -1385,11 +1383,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalDecrementItem($args['key'], $args['value']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalDecrementItem($args['key'], $args['value']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; @@ -1445,11 +1443,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalDecrementItems($args['keyValuePairs']); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalDecrementItems($args['keyValuePairs']); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = array(); @@ -1492,11 +1490,11 @@ abstract class AbstractAdapter implements StorageInterface, EventsCapableInterfa try { $eventRs = $this->triggerPre(__FUNCTION__, $args); - if ($eventRs->stopped()) { - return $eventRs->last(); - } - $result = $this->internalGetCapabilities(); + $result = $eventRs->stopped() + ? $eventRs->last() + : $this->internalGetCapabilities(); + return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { $result = false; diff --git a/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php b/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php index 22933beb..5caeb967 100644 --- a/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php +++ b/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/AdapterOptions.php b/library/Zend/Cache/Storage/Adapter/AdapterOptions.php index b3669ffa..b49e6957 100644 --- a/library/Zend/Cache/Storage/Adapter/AdapterOptions.php +++ b/library/Zend/Cache/Storage/Adapter/AdapterOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,7 +25,7 @@ class AdapterOptions extends AbstractOptions /** * The adapter using these options * - * @var null|Filesystem + * @var null|StorageInterface */ protected $adapter; diff --git a/library/Zend/Cache/Storage/Adapter/Apc.php b/library/Zend/Cache/Storage/Adapter/Apc.php index c2336e96..ddfcc1d3 100644 --- a/library/Zend/Cache/Storage/Adapter/Apc.php +++ b/library/Zend/Cache/Storage/Adapter/Apc.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -221,7 +221,7 @@ class Apc extends AbstractAdapter implements $result = apc_fetch($internalKey, $success); if (!$success) { - return null; + return; } $casToken = $result; @@ -361,16 +361,19 @@ class Apc extends AbstractAdapter implements $options = $this->getOptions(); $namespace = $options->getNamespace(); + $prefixL = 0; + if ($namespace === '') { $pattern = '/^(' . implode('|', $keysRegExp) . ')' . '$/'; } else { $prefix = $namespace . $options->getNamespaceSeparator(); + $prefixL = strlen($prefix); $pattern = '/^' . preg_quote($prefix, '/') . '(' . implode('|', $keysRegExp) . ')' . '$/'; } + $format = APC_ITER_ALL ^ APC_ITER_VALUE ^ APC_ITER_TYPE ^ APC_ITER_REFCOUNT; $it = new BaseApcIterator('user', $pattern, $format, 100, APC_LIST_ACTIVE); $result = array(); - $prefixL = strlen($prefix); foreach ($it as $internalKey => $metadata) { // @see http://pecl.php.net/bugs/bug.php?id=22564 if (!apc_exists($internalKey)) { @@ -378,7 +381,7 @@ class Apc extends AbstractAdapter implements } $this->normalizeMetadata($metadata); - $result[substr($internalKey, $prefixL)] = & $metadata; + $result[substr($internalKey, $prefixL)] = $metadata; } return $result; @@ -717,20 +720,16 @@ class Apc extends AbstractAdapter implements */ protected function normalizeMetadata(array & $metadata) { - $metadata['internal_key'] = $metadata['key']; - $metadata['ctime'] = $metadata['creation_time']; - $metadata['atime'] = $metadata['access_time']; - $metadata['rtime'] = $metadata['deletion_time']; - $metadata['size'] = $metadata['mem_size']; - $metadata['hits'] = $metadata['num_hits']; - - unset( - $metadata['key'], - $metadata['creation_time'], - $metadata['access_time'], - $metadata['deletion_time'], - $metadata['mem_size'], - $metadata['num_hits'] + $apcMetadata = $metadata; + $metadata = array( + 'internal_key' => isset($metadata['key']) ? $metadata['key'] : $metadata['info'], + 'atime' => isset($metadata['access_time']) ? $metadata['access_time'] : $metadata['atime'], + 'ctime' => isset($metadata['creation_time']) ? $metadata['creation_time'] : $metadata['ctime'], + 'mtime' => isset($metadata['modified_time']) ? $metadata['modified_time'] : $metadata['mtime'], + 'rtime' => isset($metadata['deletion_time']) ? $metadata['deletion_time'] : $metadata['dtime'], + 'size' => $metadata['mem_size'], + 'hits' => isset($metadata['nhits']) ? $metadata['nhits'] : $metadata['num_hits'], + 'ttl' => $metadata['ttl'], ); } @@ -746,6 +745,10 @@ class Apc extends AbstractAdapter implements */ protected function internalCheckAndSetItem(& $token, & $normalizedKey, & $value) { - return apc_cas($normalizedKey, $token, $value); + if (is_int($token) && is_int($value)) { + return apc_cas($normalizedKey, $token, $value); + } + + return parent::internalCheckAndSetItem($token, $normalizedKey, $value); } } diff --git a/library/Zend/Cache/Storage/Adapter/ApcIterator.php b/library/Zend/Cache/Storage/Adapter/ApcIterator.php index 3cdcbf1c..41ff8336 100644 --- a/library/Zend/Cache/Storage/Adapter/ApcIterator.php +++ b/library/Zend/Cache/Storage/Adapter/ApcIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/ApcOptions.php b/library/Zend/Cache/Storage/Adapter/ApcOptions.php index 0299d944..969bbfbc 100644 --- a/library/Zend/Cache/Storage/Adapter/ApcOptions.php +++ b/library/Zend/Cache/Storage/Adapter/ApcOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/BlackHole.php b/library/Zend/Cache/Storage/Adapter/BlackHole.php index 2938cfde..9feadbb9 100644 --- a/library/Zend/Cache/Storage/Adapter/BlackHole.php +++ b/library/Zend/Cache/Storage/Adapter/BlackHole.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -113,7 +113,7 @@ class BlackHole implements public function getItem($key, & $success = null, & $casToken = null) { $success = false; - return null; + return; } /** diff --git a/library/Zend/Cache/Storage/Adapter/Dba.php b/library/Zend/Cache/Storage/Adapter/Dba.php index bb2860d7..eb338503 100644 --- a/library/Zend/Cache/Storage/Adapter/Dba.php +++ b/library/Zend/Cache/Storage/Adapter/Dba.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -81,7 +81,7 @@ class Dba extends AbstractAdapter implements * Set options. * * @param array|Traversable|DbaOptions $options - * @return Apc + * @return self * @see getOptions() */ public function setOptions($options) @@ -153,7 +153,7 @@ class Dba extends AbstractAdapter implements /** * Get available space in bytes * - * @return int|float + * @return float */ public function getAvailableSpace() { @@ -225,7 +225,8 @@ class Dba extends AbstractAdapter implements $this->_open(); - do { // Workaround for PHP-Bug #62491 & #62492 + do { + // Workaround for PHP-Bug #62491 & #62492 $recheck = false; $internalKey = dba_firstkey($this->handle); while ($internalKey !== false && $internalKey !== null) { @@ -263,7 +264,8 @@ class Dba extends AbstractAdapter implements $this->_open(); - do { // Workaround for PHP-Bug #62491 & #62492 + // Workaround for PHP-Bug #62491 & #62492 + do { $recheck = false; $internalKey = dba_firstkey($this->handle); while ($internalKey !== false && $internalKey !== null) { @@ -284,7 +286,7 @@ class Dba extends AbstractAdapter implements /** * Get the storage iterator * - * @return ApcIterator + * @return DbaIterator */ public function getIterator() { @@ -334,7 +336,7 @@ class Dba extends AbstractAdapter implements if ($value === false) { $success = false; - return null; + return; } $success = true; @@ -376,8 +378,10 @@ class Dba extends AbstractAdapter implements $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator(); $internalKey = $prefix . $normalizedKey; + $cacheableValue = (string) $value; // dba_replace requires a string + $this->_open(); - if (!dba_replace($internalKey, $value, $this->handle)) { + if (!dba_replace($internalKey, $cacheableValue, $this->handle)) { throw new Exception\RuntimeException("dba_replace('{$internalKey}', ...) failed"); } diff --git a/library/Zend/Cache/Storage/Adapter/DbaIterator.php b/library/Zend/Cache/Storage/Adapter/DbaIterator.php index a895ce54..a4d46e2a 100644 --- a/library/Zend/Cache/Storage/Adapter/DbaIterator.php +++ b/library/Zend/Cache/Storage/Adapter/DbaIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,7 +17,7 @@ class DbaIterator implements IteratorInterface /** * The apc storage instance * - * @var Apc + * @var Dba */ protected $storage; diff --git a/library/Zend/Cache/Storage/Adapter/DbaOptions.php b/library/Zend/Cache/Storage/Adapter/DbaOptions.php index 13172b74..c913e673 100644 --- a/library/Zend/Cache/Storage/Adapter/DbaOptions.php +++ b/library/Zend/Cache/Storage/Adapter/DbaOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -117,6 +117,12 @@ class DbaOptions extends AdapterOptions throw new Exception\ExtensionNotLoadedException("DBA-Handler '{$handler}' not supported"); } + if ($handler === 'inifile') { + throw new Exception\ExtensionNotLoadedException( + "DBA-Handler 'inifile' does not reliably support write operations" + ); + } + $this->triggerOptionEvent('handler', $handler); $this->handler = $handler; return $this; diff --git a/library/Zend/Cache/Storage/Adapter/Filesystem.php b/library/Zend/Cache/Storage/Adapter/Filesystem.php index ef1c2a7d..a4b35107 100644 --- a/library/Zend/Cache/Storage/Adapter/Filesystem.php +++ b/library/Zend/Cache/Storage/Adapter/Filesystem.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -433,7 +433,7 @@ class Filesystem extends AbstractAdapter implements * Get available space in bytes * * @throws Exception\RuntimeException - * @return int|float + * @return float */ public function getAvailableSpace() { @@ -508,14 +508,15 @@ class Filesystem extends AbstractAdapter implements * @param string $normalizedKey * @param bool $success * @param mixed $casToken - * @return mixed Data on success, null on failure + * @return null|mixed Data on success, null on failure * @throws Exception\ExceptionInterface + * @throws BaseException */ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null) { if (!$this->internalHasItem($normalizedKey)) { $success = false; - return null; + return; } try { @@ -915,8 +916,6 @@ class Filesystem extends AbstractAdapter implements */ protected function internalSetItems(array & $normalizedKeyValuePairs) { - $oldUmask = null; - // create an associated array of files and contents to write $contents = array(); foreach ($normalizedKeyValuePairs as $key => & $value) { @@ -1406,7 +1405,7 @@ class Filesystem extends AbstractAdapter implements // build-in mkdir function is enough $umask = ($umask !== false) ? umask($umask) : false; - $res = mkdir($pathname, ($perm !== false) ? $perm : 0777, true); + $res = mkdir($pathname, ($perm !== false) ? $perm : 0775, true); if ($umask !== false) { umask($umask); @@ -1422,7 +1421,7 @@ class Filesystem extends AbstractAdapter implements return; } - $oct = ($perm === false) ? '777' : decoct($perm); + $oct = ($perm === false) ? '775' : decoct($perm); throw new Exception\RuntimeException("mkdir('{$pathname}', 0{$oct}, true) failed", 0, $err); } @@ -1454,7 +1453,7 @@ class Filesystem extends AbstractAdapter implements // create a single directory, set and reset umask immediately $umask = ($umask !== false) ? umask($umask) : false; - $res = mkdir($path, ($perm === false) ? 0777 : $perm, false); + $res = mkdir($path, ($perm === false) ? 0775 : $perm, false); if ($umask !== false) { umask($umask); } @@ -1467,7 +1466,7 @@ class Filesystem extends AbstractAdapter implements continue; } - $oct = ($perm === false) ? '777' : decoct($perm); + $oct = ($perm === false) ? '775' : decoct($perm); ErrorHandler::stop(); throw new Exception\RuntimeException( "mkdir('{$path}', 0{$oct}, false) failed" @@ -1499,6 +1498,11 @@ class Filesystem extends AbstractAdapter implements */ protected function putFileContent($file, $data, $nonBlocking = false, & $wouldblock = null) { + if (! is_string($data)) { + // Ensure we have a string + $data = (string) $data; + } + $options = $this->getOptions(); $locking = $options->getFileLocking(); $nonBlocking = $locking && $nonBlocking; diff --git a/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php b/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php index 447cfb3d..b615104f 100644 --- a/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php +++ b/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php b/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php index 5eabbdf3..32f24d2a 100644 --- a/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php +++ b/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -434,7 +434,7 @@ class FilesystemOptions extends AdapterOptions } // normalize - $umask = $umask & 0777; + $umask = $umask & ~0002; } if ($this->umask !== $umask) { diff --git a/library/Zend/Cache/Storage/Adapter/KeyListIterator.php b/library/Zend/Cache/Storage/Adapter/KeyListIterator.php index 86bcbe16..d67c7035 100644 --- a/library/Zend/Cache/Storage/Adapter/KeyListIterator.php +++ b/library/Zend/Cache/Storage/Adapter/KeyListIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/Memcache.php b/library/Zend/Cache/Storage/Adapter/Memcache.php index 953e52cd..8f2512a0 100644 --- a/library/Zend/Cache/Storage/Adapter/Memcache.php +++ b/library/Zend/Cache/Storage/Adapter/Memcache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -67,7 +67,7 @@ class Memcache extends AbstractAdapter implements // reset initialized flag on update option(s) $initialized = & $this->initialized; - $this->getEventManager()->attach('option', function ($event) use (& $initialized) { + $this->getEventManager()->attach('option', function () use (& $initialized) { $initialized = false; }); } @@ -220,7 +220,7 @@ class Memcache extends AbstractAdapter implements $result = $memc->get($internalKey); $success = ($result !== false); if ($result === false) { - return null; + return; } $casToken = $result; diff --git a/library/Zend/Cache/Storage/Adapter/MemcacheOptions.php b/library/Zend/Cache/Storage/Adapter/MemcacheOptions.php index 5fcdc342..b12730cc 100644 --- a/library/Zend/Cache/Storage/Adapter/MemcacheOptions.php +++ b/library/Zend/Cache/Storage/Adapter/MemcacheOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/MemcacheResourceManager.php b/library/Zend/Cache/Storage/Adapter/MemcacheResourceManager.php index 1fbff182..5a530757 100644 --- a/library/Zend/Cache/Storage/Adapter/MemcacheResourceManager.php +++ b/library/Zend/Cache/Storage/Adapter/MemcacheResourceManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -95,6 +95,8 @@ class MemcacheResourceManager * * @param string $id * @param array|Traversable|MemcacheResource $resource + * @param callable $failureCallback + * @param array|Traversable $serverDefaults * @return MemcacheResourceManager */ public function setResource($id, $resource, $failureCallback = null, $serverDefaults = array()) @@ -184,7 +186,8 @@ class MemcacheResourceManager * Set compress threshold on a Memcache resource * * @param MemcacheResource $resource - * @param array $libOptions + * @param int $threshold + * @param float $minSavings */ protected function setResourceAutoCompressThreshold(MemcacheResource $resource, $threshold, $minSavings) { @@ -396,7 +399,7 @@ class MemcacheResourceManager * Get callback for server connection failures * * @param string $id - * @return callable|null + * @return callable * @throws Exception\RuntimeException */ public function getFailureCallback($id) diff --git a/library/Zend/Cache/Storage/Adapter/Memcached.php b/library/Zend/Cache/Storage/Adapter/Memcached.php index 54bbed78..14bcefb6 100644 --- a/library/Zend/Cache/Storage/Adapter/Memcached.php +++ b/library/Zend/Cache/Storage/Adapter/Memcached.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -79,7 +79,7 @@ class Memcached extends AbstractAdapter implements // reset initialized flag on update option(s) $initialized = & $this->initialized; - $this->getEventManager()->attach('option', function ($event) use (& $initialized) { + $this->getEventManager()->attach('option', function () use (& $initialized) { $initialized = false; }); } diff --git a/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php b/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php index fabf3033..5a2b6a1d 100644 --- a/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php +++ b/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php b/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php index 10edb99a..b3bf8101 100644 --- a/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php +++ b/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/Memory.php b/library/Zend/Cache/Storage/Adapter/Memory.php index 85aa32e6..6973d039 100644 --- a/library/Zend/Cache/Storage/Adapter/Memory.php +++ b/library/Zend/Cache/Storage/Adapter/Memory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -84,7 +84,7 @@ class Memory extends AbstractAdapter implements /** * Get total space in bytes * - * @return int|float + * @return int */ public function getTotalSpace() { @@ -307,7 +307,7 @@ class Memory extends AbstractAdapter implements } if (!$success) { - return null; + return; } $casToken = $data[0]; diff --git a/library/Zend/Cache/Storage/Adapter/MemoryOptions.php b/library/Zend/Cache/Storage/Adapter/MemoryOptions.php index be48418c..a10088d9 100644 --- a/library/Zend/Cache/Storage/Adapter/MemoryOptions.php +++ b/library/Zend/Cache/Storage/Adapter/MemoryOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/MongoDb.php b/library/Zend/Cache/Storage/Adapter/MongoDb.php new file mode 100644 index 00000000..f962fbd8 --- /dev/null +++ b/library/Zend/Cache/Storage/Adapter/MongoDb.php @@ -0,0 +1,285 @@ +initialized; + + $this->getEventManager()->attach( + 'option', + function () use (& $initialized) { + $initialized = false; + } + ); + } + + /** + * get mongodb resource + * + * @return MongoResource + */ + private function getMongoDbResource() + { + if (! $this->initialized) { + $options = $this->getOptions(); + + $this->resourceManager = $options->getResourceManager(); + $this->resourceId = $options->getResourceId(); + $namespace = $options->getNamespace(); + $this->namespacePrefix = ($namespace === '' ? '' : $namespace . $options->getNamespaceSeparator()); + $this->initialized = true; + } + + return $this->resourceManager->getResource($this->resourceId); + } + + /** + * {@inheritDoc} + */ + public function setOptions($options) + { + return parent::setOptions($options instanceof MongoDbOptions ? $options : new MongoDbOptions($options)); + } + + /** + * Get options. + * + * @return MongoDbOptions + * @see setOptions() + */ + public function getOptions() + { + return $this->options; + } + + /** + * {@inheritDoc} + * + * @throws Exception\RuntimeException + */ + protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null) + { + $result = $this->fetchFromCollection($normalizedKey); + $success = false; + + if (null === $result) { + return; + } + + if (isset($result['expires'])) { + if (! $result['expires'] instanceof MongoDate) { + throw new Exception\RuntimeException(sprintf( + "The found item _id '%s' for key '%s' is not a valid cache item" + . ": the field 'expired' isn't an instance of MongoDate, '%s' found instead", + (string) $result['_id'], + $this->namespacePrefix . $normalizedKey, + is_object($result['expires']) ? get_class($result['expires']) : gettype($result['expires']) + )); + } + + if ($result['expires']->sec < time()) { + $this->internalRemoveItem($key); + + return; + } + } + + if (! array_key_exists('value', $result)) { + throw new Exception\RuntimeException(sprintf( + "The found item _id '%s' for key '%s' is not a valid cache item: missing the field 'value'", + (string) $result['_id'], + $this->namespacePrefix . $normalizedKey + )); + } + + $success = true; + + return $casToken = $result['value']; + } + + /** + * {@inheritDoc} + * + * @throws Exception\RuntimeException + */ + protected function internalSetItem(& $normalizedKey, & $value) + { + $mongo = $this->getMongoDbResource(); + $key = $this->namespacePrefix . $normalizedKey; + $ttl = $this->getOptions()->getTTl(); + $expires = null; + $cacheItem = array( + 'key' => $key, + 'value' => $value, + ); + + if ($ttl > 0) { + $expiresMicro = microtime(true) + $ttl; + $expiresSecs = (int) $expiresMicro; + $cacheItem['expires'] = new MongoDate($expiresSecs, $expiresMicro - $expiresSecs); + } + + try { + $mongo->remove(array('key' => $key)); + + $result = $mongo->insert($cacheItem); + } catch (MongoResourceException $e) { + throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); + } + + return null !== $result && ((double) 1) === $result['ok']; + } + + /** + * {@inheritDoc} + * + * @throws Exception\RuntimeException + */ + protected function internalRemoveItem(& $normalizedKey) + { + try { + $result = $this->getMongoDbResource()->remove(array('key' => $this->namespacePrefix . $normalizedKey)); + } catch (MongoResourceException $e) { + throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); + } + + return false !== $result + && ((double) 1) === $result['ok'] + && $result['n'] > 0; + } + + /** + * {@inheritDoc} + */ + public function flush() + { + $result = $this->getMongoDbResource()->drop(); + + return ((double) 1) === $result['ok']; + } + + /** + * {@inheritDoc} + */ + protected function internalGetCapabilities() + { + if ($this->capabilities) { + return $this->capabilities; + } + + return $this->capabilities = new Capabilities( + $this, + $this->capabilityMarker = new stdClass(), + array( + 'supportedDatatypes' => array( + 'NULL' => true, + 'boolean' => true, + 'integer' => true, + 'double' => true, + 'string' => true, + 'array' => true, + 'object' => false, + 'resource' => false, + ), + 'supportedMetadata' => array( + '_id', + ), + 'minTtl' => 0, + 'maxTtl' => 0, + 'staticTtl' => true, + 'ttlPrecision' => 1, + 'useRequestTime' => false, + 'expiredRead' => false, + 'maxKeyLength' => 255, + 'namespaceIsPrefix' => true, + ) + ); + } + + /** + * {@inheritDoc} + * + * @throws Exception\ExceptionInterface + */ + protected function internalGetMetadata(& $normalizedKey) + { + $result = $this->fetchFromCollection($normalizedKey); + + return null !== $result ? array('_id' => $result['_id']) : false; + } + + /** + * Return raw records from MongoCollection + * + * @param string $normalizedKey + * + * @return array|null + * + * @throws Exception\RuntimeException + */ + private function fetchFromCollection(& $normalizedKey) + { + try { + return $this->getMongoDbResource()->findOne(array('key' => $this->namespacePrefix . $normalizedKey)); + } catch (MongoResourceException $e) { + throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); + } + } +} diff --git a/library/Zend/Cache/Storage/Adapter/MongoDbOptions.php b/library/Zend/Cache/Storage/Adapter/MongoDbOptions.php new file mode 100644 index 00000000..b0e1e8be --- /dev/null +++ b/library/Zend/Cache/Storage/Adapter/MongoDbOptions.php @@ -0,0 +1,158 @@ +namespaceSeparator !== $namespaceSeparator) { + $this->triggerOptionEvent('namespace_separator', $namespaceSeparator); + + $this->namespaceSeparator = $namespaceSeparator; + } + + return $this; + } + + /** + * Get namespace separator + * + * @return string + */ + public function getNamespaceSeparator() + { + return $this->namespaceSeparator; + } + + /** + * Set the mongodb resource manager to use + * + * @param null|MongoDbResourceManager $resourceManager + * + * @return self + */ + public function setResourceManager(MongoDbResourceManager $resourceManager = null) + { + if ($this->resourceManager !== $resourceManager) { + $this->triggerOptionEvent('resource_manager', $resourceManager); + + $this->resourceManager = $resourceManager; + } + + return $this; + } + + /** + * Get the mongodb resource manager + * + * @return MongoDbResourceManager + */ + public function getResourceManager() + { + return $this->resourceManager ?: $this->resourceManager = new MongoDbResourceManager(); + } + + /** + * Get the mongodb resource id + * + * @return string + */ + public function getResourceId() + { + return $this->resourceId; + } + + /** + * Set the mongodb resource id + * + * @param string $resourceId + * + * @return self + */ + public function setResourceId($resourceId) + { + $resourceId = (string) $resourceId; + + if ($this->resourceId !== $resourceId) { + $this->triggerOptionEvent('resource_id', $resourceId); + + $this->resourceId = $resourceId; + } + + return $this; + } + + /** + * Set the mongo DB server + * + * @param string $server + * @return self + */ + public function setServer($server) + { + $this->getResourceManager()->setServer($this->getResourceId(), $server); + return $this; + } + + public function setConnectionOptions(array $connectionOptions) + { + $this->getResourceManager()->setConnectionOptions($this->getResourceId(), $connectionOptions); + return $this; + } + + public function setDriverOptions(array $driverOptions) + { + $this->getResourceManager()->setDriverOptions($this->getResourceId(), $driverOptions); + return $this; + } + + public function setDatabase($database) + { + $this->getResourceManager()->setDatabase($this->getResourceId(), $database); + return $this; + } + + public function setCollection($collection) + { + $this->getResourceManager()->setCollection($this->getResourceId(), $collection); + return $this; + } +} diff --git a/library/Zend/Cache/Storage/Adapter/MongoDbResourceManager.php b/library/Zend/Cache/Storage/Adapter/MongoDbResourceManager.php new file mode 100644 index 00000000..fa1878be --- /dev/null +++ b/library/Zend/Cache/Storage/Adapter/MongoDbResourceManager.php @@ -0,0 +1,204 @@ +resources[$id]); + } + + /** + * Set a resource + * + * @param string $id + * @param array|MongoCollection $resource + * + * @return self + * + * @throws Exception\RuntimeException + */ + public function setResource($id, $resource) + { + if ($resource instanceof MongoCollection) { + $this->resources[$id] = array( + 'db' => (string) $resource->db, + 'db_instance' => $resource->db, + 'collection' => (string) $resource, + 'collection_instance' => $resource, + ); + return $this; + } + + if (! is_array($resource)) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects an array or MongoCollection; received %s', + __METHOD__, + (is_object($resource) ? get_class($resource) : gettype($resource)) + )); + } + + $this->resources[$id] = $resource; + return $this; + } + + /** + * Instantiate and return the MongoCollection resource + * + * @param string $id + * @return MongoCollection + * @throws Exception\RuntimeException + */ + public function getResource($id) + { + if (!$this->hasResource($id)) { + throw new Exception\RuntimeException("No resource with id '{$id}'"); + } + + $resource = $this->resources[$id]; + if (!isset($resource['collection_instance'])) { + try { + if (!isset($resource['db_instance'])) { + if (!isset($resource['client_instance'])) { + $clientClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; + $resource['client_instance'] = new $clientClass( + isset($resource['server']) ? $resource['server'] : null, + isset($resource['connection_options']) ? $resource['connection_options'] : array(), + isset($resource['driver_options']) ? $resource['driver_options'] : array() + ); + } + + $resource['db_instance'] = $resource['client_instance']->selectDB( + isset($resource['db']) ? $resource['db'] : '' + ); + } + + $collection = $resource['db_instance']->selectCollection( + isset($resource['collection']) ? $resource['collection'] : '' + ); + $collection->ensureIndex(array('key' => 1)); + + $this->resources[$id]['collection_instance'] = $collection; + } catch (MongoException $e) { + throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); + } + } + + return $this->resources[$id]['collection_instance']; + } + + public function setServer($id, $server) + { + $this->resources[$id]['server'] = (string)$server; + + unset($this->resource[$id]['client_instance']); + unset($this->resource[$id]['db_instance']); + unset($this->resource[$id]['collection_instance']); + } + + public function getServer($id) + { + if (!$this->hasResource($id)) { + throw new Exception\RuntimeException("No resource with id '{$id}'"); + } + + return isset($this->resources[$id]['server']) ? $this->resources[$id]['server'] : null; + } + + public function setConnectionOptions($id, array $connectionOptions) + { + $this->resources[$id]['connection_options'] = $connectionOptions; + + unset($this->resource[$id]['client_instance']); + unset($this->resource[$id]['db_instance']); + unset($this->resource[$id]['collection_instance']); + } + + public function getConnectionOptions($id) + { + if (!$this->hasResource($id)) { + throw new Exception\RuntimeException("No resource with id '{$id}'"); + } + + return isset($this->resources[$id]['connection_options']) + ? $this->resources[$id]['connection_options'] + : array(); + } + + public function setDriverOptions($id, array $driverOptions) + { + $this->resources[$id]['driver_options'] = $driverOptions; + + unset($this->resource[$id]['client_instance']); + unset($this->resource[$id]['db_instance']); + unset($this->resource[$id]['collection_instance']); + } + + public function getDriverOptions($id) + { + if (!$this->hasResource($id)) { + throw new Exception\RuntimeException("No resource with id '{$id}'"); + } + + return isset($this->resources[$id]['driver_options']) ? $this->resources[$id]['driver_options'] : array(); + } + + public function setDatabase($id, $database) + { + $this->resources[$id]['db'] = (string)$database; + + unset($this->resource[$id]['db_instance']); + unset($this->resource[$id]['collection_instance']); + } + + public function getDatabase($id) + { + if (!$this->hasResource($id)) { + throw new Exception\RuntimeException("No resource with id '{$id}'"); + } + + return isset($this->resources[$id]['db']) ? $this->resources[$id]['db'] : ''; + } + + public function setCollection($id, $collection) + { + $this->resources[$id]['collection'] = (string)$collection; + + unset($this->resource[$id]['collection_instance']); + } + + public function getCollection($id) + { + if (!$this->hasResource($id)) { + throw new Exception\RuntimeException("No resource with id '{$id}'"); + } + + return isset($this->resources[$id]['collection']) ? $this->resources[$id]['collection'] : ''; + } +} diff --git a/library/Zend/Cache/Storage/Adapter/Redis.php b/library/Zend/Cache/Storage/Adapter/Redis.php index 1adb3d4a..da76c1ff 100644 --- a/library/Zend/Cache/Storage/Adapter/Redis.php +++ b/library/Zend/Cache/Storage/Adapter/Redis.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,12 +13,14 @@ use Redis as RedisResource; use RedisException as RedisResourceException; use stdClass; use Traversable; +use Zend\Cache\Storage\ClearByPrefixInterface; use Zend\Cache\Exception; use Zend\Cache\Storage\Capabilities; use Zend\Cache\Storage\FlushableInterface; use Zend\Cache\Storage\TotalSpaceCapableInterface; class Redis extends AbstractAdapter implements + ClearByPrefixInterface, FlushableInterface, TotalSpaceCapableInterface { @@ -66,7 +68,7 @@ class Redis extends AbstractAdapter implements // reset initialized flag on update option(s) $initialized = & $this->initialized; - $this->getEventManager()->attach('option', function ($event) use (& $initialized) { + $this->getEventManager()->attach('option', function () use (& $initialized) { $initialized = false; }); } @@ -151,7 +153,7 @@ class Redis extends AbstractAdapter implements if ($value === false) { $success = false; - return null; + return; } $success = true; @@ -368,6 +370,32 @@ class Redis extends AbstractAdapter implements } } + /* ClearByPrefixInterface */ + + /** + * Remove items matching given prefix + * + * @param string $prefix + * @return bool + */ + public function clearByPrefix($prefix) + { + $redis = $this->getRedisResource(); + + $prefix = (string) $prefix; + if ($prefix === '') { + throw new Exception\InvalidArgumentException('No prefix given'); + } + + $options = $this->getOptions(); + $namespace = $options->getNamespace(); + $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator() . $prefix; + + $redis->delete($redis->keys($prefix.'*')); + + return true; + } + /* TotalSpaceCapableInterface */ /** diff --git a/library/Zend/Cache/Storage/Adapter/RedisOptions.php b/library/Zend/Cache/Storage/Adapter/RedisOptions.php index f5e67487..256cb265 100644 --- a/library/Zend/Cache/Storage/Adapter/RedisOptions.php +++ b/library/Zend/Cache/Storage/Adapter/RedisOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php b/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php index ed8ee214..3425dc4d 100644 --- a/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php +++ b/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -105,7 +105,7 @@ class RedisResourceManager * Gets a redis resource * * @param string $id - * @return RedisResource + * @return RedisResourceManager * @throws Exception\RuntimeException */ public function getResource($id) @@ -233,14 +233,14 @@ class RedisResourceManager } if (! is_string($serverUri)) { - return null; + return; } // parse server from URI host{:?port} $server = trim($serverUri); if (strpos($server, '/') === 0) { - return null; + return; } //non unix domain socket connection @@ -627,7 +627,7 @@ class RedisResourceManager * * @param string $id * @param int $database - * @return RedisResource + * @return RedisResourceManager */ public function setDatabase($id, $database) { diff --git a/library/Zend/Cache/Storage/Adapter/Session.php b/library/Zend/Cache/Storage/Adapter/Session.php index 4603c231..65f4fcbc 100644 --- a/library/Zend/Cache/Storage/Adapter/Session.php +++ b/library/Zend/Cache/Storage/Adapter/Session.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -152,13 +152,13 @@ class Session extends AbstractAdapter implements if (!$cntr->offsetExists($ns)) { $success = false; - return null; + return; } $data = $cntr->offsetGet($ns); $success = array_key_exists($normalizedKey, $data); if (!$success) { - return null; + return; } $casToken = $value = $data[$normalizedKey]; diff --git a/library/Zend/Cache/Storage/Adapter/SessionOptions.php b/library/Zend/Cache/Storage/Adapter/SessionOptions.php index 8e4c6d5c..2dbfddec 100644 --- a/library/Zend/Cache/Storage/Adapter/SessionOptions.php +++ b/library/Zend/Cache/Storage/Adapter/SessionOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/WinCache.php b/library/Zend/Cache/Storage/Adapter/WinCache.php index b911e040..42d4c9d4 100644 --- a/library/Zend/Cache/Storage/Adapter/WinCache.php +++ b/library/Zend/Cache/Storage/Adapter/WinCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php b/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php index 8c9789ae..9b8dbbd4 100644 --- a/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php +++ b/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/XCache.php b/library/Zend/Cache/Storage/Adapter/XCache.php index 18073e9f..57ac50fc 100644 --- a/library/Zend/Cache/Storage/Adapter/XCache.php +++ b/library/Zend/Cache/Storage/Adapter/XCache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -45,7 +45,7 @@ class XCache extends AbstractAdapter implements /** * Constructor * - * @param null|array|Traversable|ApcOptions $options + * @param null|array|Traversable|XCacheOptions $options * @throws Exception\ExceptionInterface */ public function __construct($options = null) @@ -74,7 +74,7 @@ class XCache extends AbstractAdapter implements /** * Set options. * - * @param array|Traversable|ApcOptions $options + * @param array|Traversable|XCacheOptions $options * @return XCache * @see getOptions() */ diff --git a/library/Zend/Cache/Storage/Adapter/XCacheOptions.php b/library/Zend/Cache/Storage/Adapter/XCacheOptions.php index 4c97136b..9c5b17c9 100644 --- a/library/Zend/Cache/Storage/Adapter/XCacheOptions.php +++ b/library/Zend/Cache/Storage/Adapter/XCacheOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php b/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php index c48992a5..95dd9008 100644 --- a/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php +++ b/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Adapter/ZendServerShm.php b/library/Zend/Cache/Storage/Adapter/ZendServerShm.php index 6b226d7c..3c5d5e90 100644 --- a/library/Zend/Cache/Storage/Adapter/ZendServerShm.php +++ b/library/Zend/Cache/Storage/Adapter/ZendServerShm.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/AdapterPluginManager.php b/library/Zend/Cache/Storage/AdapterPluginManager.php index 665b36c8..f852cab1 100644 --- a/library/Zend/Cache/Storage/AdapterPluginManager.php +++ b/library/Zend/Cache/Storage/AdapterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,6 +34,7 @@ class AdapterPluginManager extends AbstractPluginManager 'memcache' => 'Zend\Cache\Storage\Adapter\Memcache', 'memcached' => 'Zend\Cache\Storage\Adapter\Memcached', 'memory' => 'Zend\Cache\Storage\Adapter\Memory', + 'mongodb' => 'Zend\Cache\Storage\Adapter\MongoDb', 'redis' => 'Zend\Cache\Storage\Adapter\Redis', 'session' => 'Zend\Cache\Storage\Adapter\Session', 'xcache' => 'Zend\Cache\Storage\Adapter\XCache', diff --git a/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php b/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php index 5088fe25..0576c6a7 100644 --- a/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php +++ b/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Capabilities.php b/library/Zend/Cache/Storage/Capabilities.php index c81e08cb..b09922d2 100644 --- a/library/Zend/Cache/Storage/Capabilities.php +++ b/library/Zend/Cache/Storage/Capabilities.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -40,8 +40,8 @@ class Capabilities /** * Expire read * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|bool */ @@ -50,8 +50,8 @@ class Capabilities /** * Max. key length * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|int */ @@ -60,8 +60,8 @@ class Capabilities /** * Min. TTL (0 means items never expire) * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|int */ @@ -70,8 +70,8 @@ class Capabilities /** * Max. TTL (0 means infinite) * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|int */ @@ -80,8 +80,8 @@ class Capabilities /** * Namespace is prefix * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|bool */ @@ -90,8 +90,8 @@ class Capabilities /** * Namespace separator * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|string */ @@ -100,28 +100,28 @@ class Capabilities /** * Static ttl * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|bool */ protected $staticTtl; - /** - * Supported datatypes - * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. - * - * @var null|array - */ + /** + * Supported datatypes + * + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. + * + * @var null|array + */ protected $supportedDatatypes; /** * Supported metdata * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|array */ @@ -130,8 +130,8 @@ class Capabilities /** * TTL precision * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|int */ @@ -140,8 +140,8 @@ class Capabilities /** * Use request time * - * If it's NULL the capability isn't set and the getter - * returns the base capability or the default value. + * If it's NULL the capability isn't set and the getter + * returns the base capability or the default value. * * @var null|bool */ diff --git a/library/Zend/Cache/Storage/ClearByNamespaceInterface.php b/library/Zend/Cache/Storage/ClearByNamespaceInterface.php index 15fb4e75..ed2aac94 100644 --- a/library/Zend/Cache/Storage/ClearByNamespaceInterface.php +++ b/library/Zend/Cache/Storage/ClearByNamespaceInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/ClearByPrefixInterface.php b/library/Zend/Cache/Storage/ClearByPrefixInterface.php index eb2fb5e0..f1279576 100644 --- a/library/Zend/Cache/Storage/ClearByPrefixInterface.php +++ b/library/Zend/Cache/Storage/ClearByPrefixInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/ClearExpiredInterface.php b/library/Zend/Cache/Storage/ClearExpiredInterface.php index 6f7b0a36..264e7eb2 100644 --- a/library/Zend/Cache/Storage/ClearExpiredInterface.php +++ b/library/Zend/Cache/Storage/ClearExpiredInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Event.php b/library/Zend/Cache/Storage/Event.php index 62c32f4f..b82cbb12 100644 --- a/library/Zend/Cache/Storage/Event.php +++ b/library/Zend/Cache/Storage/Event.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/ExceptionEvent.php b/library/Zend/Cache/Storage/ExceptionEvent.php index e9ffb4a0..1882c6ad 100644 --- a/library/Zend/Cache/Storage/ExceptionEvent.php +++ b/library/Zend/Cache/Storage/ExceptionEvent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/FlushableInterface.php b/library/Zend/Cache/Storage/FlushableInterface.php index 6c72541e..2fe06053 100644 --- a/library/Zend/Cache/Storage/FlushableInterface.php +++ b/library/Zend/Cache/Storage/FlushableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/IterableInterface.php b/library/Zend/Cache/Storage/IterableInterface.php index 68c4ba2c..af24b7f8 100644 --- a/library/Zend/Cache/Storage/IterableInterface.php +++ b/library/Zend/Cache/Storage/IterableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/IteratorInterface.php b/library/Zend/Cache/Storage/IteratorInterface.php index ec76261d..e60f52f8 100644 --- a/library/Zend/Cache/Storage/IteratorInterface.php +++ b/library/Zend/Cache/Storage/IteratorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/OptimizableInterface.php b/library/Zend/Cache/Storage/OptimizableInterface.php index 0f57022f..f7ce2984 100644 --- a/library/Zend/Cache/Storage/OptimizableInterface.php +++ b/library/Zend/Cache/Storage/OptimizableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Plugin/AbstractPlugin.php b/library/Zend/Cache/Storage/Plugin/AbstractPlugin.php index 0e1ab90c..cc918f5a 100644 --- a/library/Zend/Cache/Storage/Plugin/AbstractPlugin.php +++ b/library/Zend/Cache/Storage/Plugin/AbstractPlugin.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php b/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php index 0b257be7..5fc1bcb0 100644 --- a/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php +++ b/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php b/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php index e6acace0..11e0abda 100644 --- a/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php +++ b/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php b/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php index ddec6354..64f0d990 100644 --- a/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php +++ b/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -85,7 +85,7 @@ class IgnoreUserAbort extends AbstractPlugin public function onBefore(Event $event) { if ($this->activatedTarget === null && !ignore_user_abort(true)) { - $this->activatedTarget = $event->getTarget(); + $this->activatedTarget = $event->getStorage(); } } @@ -101,7 +101,7 @@ class IgnoreUserAbort extends AbstractPlugin */ public function onAfter(Event $event) { - if ($this->activatedTarget === $event->getTarget()) { + if ($this->activatedTarget === $event->getStorage()) { // exit if connection aborted if ($this->getOptions()->getExitOnAbort() && connection_aborted()) { exit; diff --git a/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php b/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php index 42643df7..9d432048 100644 --- a/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php +++ b/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Plugin/PluginInterface.php b/library/Zend/Cache/Storage/Plugin/PluginInterface.php index af3d007c..cad0b455 100644 --- a/library/Zend/Cache/Storage/Plugin/PluginInterface.php +++ b/library/Zend/Cache/Storage/Plugin/PluginInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/Plugin/PluginOptions.php b/library/Zend/Cache/Storage/Plugin/PluginOptions.php index cd32a295..5226dd75 100644 --- a/library/Zend/Cache/Storage/Plugin/PluginOptions.php +++ b/library/Zend/Cache/Storage/Plugin/PluginOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,7 @@ class PluginOptions extends AbstractOptions /** * Used by: * - ExceptionHandler - * @var callable + * @var null|callable */ protected $exceptionCallback; @@ -99,7 +99,7 @@ class PluginOptions extends AbstractOptions * Used by: * - ExceptionHandler * - * @param callable $exceptionCallback + * @param null|callable $exceptionCallback * @throws Exception\InvalidArgumentException * @return PluginOptions */ @@ -118,7 +118,7 @@ class PluginOptions extends AbstractOptions * Used by: * - ExceptionHandler * - * @return callable + * @return null|callable */ public function getExceptionCallback() { diff --git a/library/Zend/Cache/Storage/Plugin/Serializer.php b/library/Zend/Cache/Storage/Plugin/Serializer.php index c785e751..d79f221a 100644 --- a/library/Zend/Cache/Storage/Plugin/Serializer.php +++ b/library/Zend/Cache/Storage/Plugin/Serializer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/PluginManager.php b/library/Zend/Cache/Storage/PluginManager.php index a799a37d..ebdaa67c 100644 --- a/library/Zend/Cache/Storage/PluginManager.php +++ b/library/Zend/Cache/Storage/PluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/PostEvent.php b/library/Zend/Cache/Storage/PostEvent.php index 9302b081..8ca7877f 100644 --- a/library/Zend/Cache/Storage/PostEvent.php +++ b/library/Zend/Cache/Storage/PostEvent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/StorageInterface.php b/library/Zend/Cache/Storage/StorageInterface.php index c89ca5be..2b0910fe 100644 --- a/library/Zend/Cache/Storage/StorageInterface.php +++ b/library/Zend/Cache/Storage/StorageInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/TaggableInterface.php b/library/Zend/Cache/Storage/TaggableInterface.php index 3917b0e4..1bf63bd0 100644 --- a/library/Zend/Cache/Storage/TaggableInterface.php +++ b/library/Zend/Cache/Storage/TaggableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/Storage/TotalSpaceCapableInterface.php b/library/Zend/Cache/Storage/TotalSpaceCapableInterface.php index be543e82..737a0333 100644 --- a/library/Zend/Cache/Storage/TotalSpaceCapableInterface.php +++ b/library/Zend/Cache/Storage/TotalSpaceCapableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/StorageFactory.php b/library/Zend/Cache/StorageFactory.php index 86fca3a3..8023bc9a 100644 --- a/library/Zend/Cache/StorageFactory.php +++ b/library/Zend/Cache/StorageFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Cache/composer.json b/library/Zend/Cache/composer.json index 3d20dff9..fef8d4ec 100644 --- a/library/Zend/Cache/composer.json +++ b/library/Zend/Cache/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Cache\\": "" } }, - "target-dir": "Zend/Cache", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version", @@ -29,12 +28,14 @@ "ext-apc": "APC >= 3.1.6 to use the APC storage adapter", "ext-dba": "DBA, to use the DBA storage adapter", "ext-memcached": "Memcached >= 1.0.0 to use the Memcached storage adapter", - "ext-wincache": "WinCache, to use the WinCache storage adapter" + "ext-mongo": "Mongo, to use MongoDb storage adapter", + "ext-wincache": "WinCache, to use the WinCache storage adapter", + "mongofill/mongofill": "Alternative to ext-mongo - a pure PHP implementation designed as a drop in replacement" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Captcha/AbstractAdapter.php b/library/Zend/Captcha/AbstractAdapter.php index 11784d69..70642e65 100644 --- a/library/Zend/Captcha/AbstractAdapter.php +++ b/library/Zend/Captcha/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/AbstractWord.php b/library/Zend/Captcha/AbstractWord.php index 5ad80366..dc45550f 100644 --- a/library/Zend/Captcha/AbstractWord.php +++ b/library/Zend/Captcha/AbstractWord.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -309,10 +309,12 @@ abstract class AbstractWord extends AbstractAdapter $vowels = $this->useNumbers ? static::$VN : static::$V; $consonants = $this->useNumbers ? static::$CN : static::$C; + $totIndexCon = count($consonants) - 1; + $totIndexVow = count($vowels) - 1; for ($i=0; $i < $wordLen; $i = $i + 2) { // generate word with mix of vowels and consonants - $consonant = $consonants[array_rand($consonants)]; - $vowel = $vowels[array_rand($vowels)]; + $consonant = $consonants[Rand::getInteger(0, $totIndexCon, true)]; + $vowel = $vowels[Rand::getInteger(0, $totIndexVow, true)]; $word .= $consonant . $vowel; } diff --git a/library/Zend/Captcha/AdapterInterface.php b/library/Zend/Captcha/AdapterInterface.php index 227daa5c..4827952f 100644 --- a/library/Zend/Captcha/AdapterInterface.php +++ b/library/Zend/Captcha/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Dumb.php b/library/Zend/Captcha/Dumb.php index 9461adf0..975cb6f1 100644 --- a/library/Zend/Captcha/Dumb.php +++ b/library/Zend/Captcha/Dumb.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/DomainException.php b/library/Zend/Captcha/Exception/DomainException.php index ac900097..94e43438 100644 --- a/library/Zend/Captcha/Exception/DomainException.php +++ b/library/Zend/Captcha/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/ExceptionInterface.php b/library/Zend/Captcha/Exception/ExceptionInterface.php index a42e6a86..afb8edbd 100644 --- a/library/Zend/Captcha/Exception/ExceptionInterface.php +++ b/library/Zend/Captcha/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/ExtensionNotLoadedException.php b/library/Zend/Captcha/Exception/ExtensionNotLoadedException.php index 78c31911..127c5d17 100644 --- a/library/Zend/Captcha/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Captcha/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/ImageNotLoadableException.php b/library/Zend/Captcha/Exception/ImageNotLoadableException.php index 718091a9..c6533d67 100644 --- a/library/Zend/Captcha/Exception/ImageNotLoadableException.php +++ b/library/Zend/Captcha/Exception/ImageNotLoadableException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/InvalidArgumentException.php b/library/Zend/Captcha/Exception/InvalidArgumentException.php index 955fcd4e..c8d7ff5e 100644 --- a/library/Zend/Captcha/Exception/InvalidArgumentException.php +++ b/library/Zend/Captcha/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/NoFontProvidedException.php b/library/Zend/Captcha/Exception/NoFontProvidedException.php index eaf04472..28b2293c 100644 --- a/library/Zend/Captcha/Exception/NoFontProvidedException.php +++ b/library/Zend/Captcha/Exception/NoFontProvidedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Exception/RuntimeException.php b/library/Zend/Captcha/Exception/RuntimeException.php index 4545d4f8..bb03210d 100644 --- a/library/Zend/Captcha/Exception/RuntimeException.php +++ b/library/Zend/Captcha/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Factory.php b/library/Zend/Captcha/Factory.php index 04f15d86..ff7e6b82 100644 --- a/library/Zend/Captcha/Factory.php +++ b/library/Zend/Captcha/Factory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Figlet.php b/library/Zend/Captcha/Figlet.php index 002f5f30..a660549c 100644 --- a/library/Zend/Captcha/Figlet.php +++ b/library/Zend/Captcha/Figlet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/Image.php b/library/Zend/Captcha/Image.php index 7f91b912..b95550d0 100644 --- a/library/Zend/Captcha/Image.php +++ b/library/Zend/Captcha/Image.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/ReCaptcha.php b/library/Zend/Captcha/ReCaptcha.php index 7e5c0193..d701b00d 100644 --- a/library/Zend/Captcha/ReCaptcha.php +++ b/library/Zend/Captcha/ReCaptcha.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Captcha/composer.json b/library/Zend/Captcha/composer.json index fec1684f..aad0a586 100644 --- a/library/Zend/Captcha/composer.json +++ b/library/Zend/Captcha/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Captcha\\": "" } }, - "target-dir": "Zend/Captcha", "require": { "php": ">=5.3.23", "zendframework/zend-math": "self.version", @@ -33,8 +32,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Code/Annotation/AnnotationCollection.php b/library/Zend/Code/Annotation/AnnotationCollection.php index 7b9aa51d..48a71fc0 100644 --- a/library/Zend/Code/Annotation/AnnotationCollection.php +++ b/library/Zend/Code/Annotation/AnnotationCollection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Annotation/AnnotationInterface.php b/library/Zend/Code/Annotation/AnnotationInterface.php index a67439cc..f8fcc7ac 100644 --- a/library/Zend/Code/Annotation/AnnotationInterface.php +++ b/library/Zend/Code/Annotation/AnnotationInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Annotation/AnnotationManager.php b/library/Zend/Code/Annotation/AnnotationManager.php index a82ebb77..f49bef5d 100644 --- a/library/Zend/Code/Annotation/AnnotationManager.php +++ b/library/Zend/Code/Annotation/AnnotationManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php b/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php index 5168e327..d462985f 100644 --- a/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php +++ b/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php b/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php index b3f75662..f142ac46 100644 --- a/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php +++ b/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Annotation/Parser/ParserInterface.php b/library/Zend/Code/Annotation/Parser/ParserInterface.php index bb6746e8..9d84642f 100644 --- a/library/Zend/Code/Annotation/Parser/ParserInterface.php +++ b/library/Zend/Code/Annotation/Parser/ParserInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Exception/BadMethodCallException.php b/library/Zend/Code/Exception/BadMethodCallException.php index f97274d2..03465969 100644 --- a/library/Zend/Code/Exception/BadMethodCallException.php +++ b/library/Zend/Code/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Exception/ExceptionInterface.php b/library/Zend/Code/Exception/ExceptionInterface.php index 58787666..cb3e15ee 100644 --- a/library/Zend/Code/Exception/ExceptionInterface.php +++ b/library/Zend/Code/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Exception/InvalidArgumentException.php b/library/Zend/Code/Exception/InvalidArgumentException.php index 1a8df9e7..65fe03e6 100644 --- a/library/Zend/Code/Exception/InvalidArgumentException.php +++ b/library/Zend/Code/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Exception/RuntimeException.php b/library/Zend/Code/Exception/RuntimeException.php index 8d890a6a..fabca693 100644 --- a/library/Zend/Code/Exception/RuntimeException.php +++ b/library/Zend/Code/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/AbstractGenerator.php b/library/Zend/Code/Generator/AbstractGenerator.php index 3dc6de56..ef6aa67d 100644 --- a/library/Zend/Code/Generator/AbstractGenerator.php +++ b/library/Zend/Code/Generator/AbstractGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/AbstractMemberGenerator.php b/library/Zend/Code/Generator/AbstractMemberGenerator.php index dec0d8dc..10684a3e 100644 --- a/library/Zend/Code/Generator/AbstractMemberGenerator.php +++ b/library/Zend/Code/Generator/AbstractMemberGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/BodyGenerator.php b/library/Zend/Code/Generator/BodyGenerator.php index 4851e5ca..03e4f409 100644 --- a/library/Zend/Code/Generator/BodyGenerator.php +++ b/library/Zend/Code/Generator/BodyGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/ClassGenerator.php b/library/Zend/Code/Generator/ClassGenerator.php index e8455874..749edfe0 100644 --- a/library/Zend/Code/Generator/ClassGenerator.php +++ b/library/Zend/Code/Generator/ClassGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,6 +13,8 @@ use Zend\Code\Reflection\ClassReflection; class ClassGenerator extends AbstractGenerator { + const OBJECT_TYPE = "class"; + const FLAG_ABSTRACT = 0x01; const FLAG_FINAL = 0x02; @@ -56,15 +58,20 @@ class ClassGenerator extends AbstractGenerator */ protected $properties = array(); + /** + * @var PropertyGenerator[] Array of constants + */ + protected $constants = array(); + /** * @var MethodGenerator[] Array of methods */ protected $methods = array(); /** - * @var array Array of string names + * @var TraitUsageGenerator Object to encapsulate trait usage logic */ - protected $uses = array(); + protected $traitUsageGenerator; /** * Build a Code Generation Php Object from a Class Reflection @@ -74,7 +81,6 @@ class ClassGenerator extends AbstractGenerator */ public static function fromReflection(ClassReflection $classReflection) { - // class generator $cg = new static($classReflection->getName()); $cg->setSourceContent($cg->getSourceContent()); @@ -93,11 +99,12 @@ class ClassGenerator extends AbstractGenerator /* @var \Zend\Code\Reflection\ClassReflection $parentClass */ $parentClass = $classReflection->getParentClass(); + $interfaces = $classReflection->getInterfaces(); + if ($parentClass) { $cg->setExtendedClass($parentClass->getName()); - $interfaces = array_diff($classReflection->getInterfaces(), $parentClass->getInterfaces()); - } else { - $interfaces = $classReflection->getInterfaces(); + + $interfaces = array_diff($interfaces, $parentClass->getInterfaces()); } $interfaceNames = array(); @@ -109,20 +116,36 @@ class ClassGenerator extends AbstractGenerator $cg->setImplementedInterfaces($interfaceNames); $properties = array(); + foreach ($classReflection->getProperties() as $reflectionProperty) { if ($reflectionProperty->getDeclaringClass()->getName() == $classReflection->getName()) { $properties[] = PropertyGenerator::fromReflection($reflectionProperty); } } + $cg->addProperties($properties); + $constants = array(); + + foreach ($classReflection->getConstants() as $name => $value) { + $constants[] = array( + 'name' => $name, + 'value' => $value + ); + } + + $cg->addConstants($constants); + $methods = array(); + foreach ($classReflection->getMethods() as $reflectionMethod) { - $className = ($cg->getNamespaceName())? $cg->getNamespaceName() . "\\" . $cg->getName() : $cg->getName(); + $className = ($cg->getNamespaceName()) ? $cg->getNamespaceName() . "\\" . $cg->getName() : $cg->getName(); + if ($reflectionMethod->getDeclaringClass()->getName() == $className) { $methods[] = MethodGenerator::fromReflection($reflectionMethod); } } + $cg->addMethods($methods); return $cg; @@ -208,6 +231,8 @@ class ClassGenerator extends AbstractGenerator $methods = array(), $docBlock = null ) { + $this->traitUsageGenerator = new TraitUsageGenerator($this); + if ($name !== null) { $this->setName($name); } @@ -421,6 +446,114 @@ class ClassGenerator extends AbstractGenerator return $this->implementedInterfaces; } + /** + * @param string $constantName + * + * @return PropertyGenerator|false + */ + public function getConstant($constantName) + { + if (isset($this->constants[$constantName])) { + return $this->constants[$constantName]; + } + + return false; + } + + /** + * @return PropertyGenerator[] indexed by constant name + */ + public function getConstants() + { + return $this->constants; + } + + /** + * @param string $constantName + * @return bool + */ + public function hasConstant($constantName) + { + return isset($this->constants[$constantName]); + } + + /** + * Add constant from PropertyGenerator + * + * @param PropertyGenerator $constant + * @throws Exception\InvalidArgumentException + * @return ClassGenerator + */ + public function addConstantFromGenerator(PropertyGenerator $constant) + { + $constantName = $constant->getName(); + + if (isset($this->constants[$constantName])) { + throw new Exception\InvalidArgumentException(sprintf( + 'A constant by name %s already exists in this class.', + $constantName + )); + } + + if (! $constant->isConst()) { + throw new Exception\InvalidArgumentException(sprintf( + 'The value %s is not defined as a constant.', + $constantName + )); + } + + $this->constants[$constantName] = $constant; + + return $this; + } + + /** + * Add Constant + * + * @param string $name + * @param string $value + * @throws Exception\InvalidArgumentException + * @return ClassGenerator + */ + public function addConstant($name, $value) + { + if (!is_string($name)) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects string for name', + __METHOD__ + )); + } + + if (empty($value) || !is_string($value)) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects value for constant, value must be a string', + __METHOD__ + )); + } + + return $this->addConstantFromGenerator(new PropertyGenerator($name, $value, PropertyGenerator::FLAG_CONSTANT)); + } + + /** + * @param PropertyGenerator[]|array[] $constants + * + * @return ClassGenerator + */ + public function addConstants(array $constants) + { + foreach ($constants as $constant) { + if ($constant instanceof PropertyGenerator) { + $this->addPropertyFromGenerator($constant); + } else { + if (is_array($constant)) { + call_user_func_array(array($this, 'addConstant'), $constant); + } + } + } + + return $this; + } + /** * @param array $properties * @return ClassGenerator @@ -455,11 +588,18 @@ class ClassGenerator extends AbstractGenerator { if (!is_string($name)) { throw new Exception\InvalidArgumentException(sprintf( - '%s expects string for name', - __METHOD__ + '%s::%s expects string for name', + get_class($this), + __FUNCTION__ )); } + // backwards compatibility + // @todo remove this on next major version + if ($flags === PropertyGenerator::FLAG_CONSTANT) { + return $this->addConstant($name, $defaultValue); + } + return $this->addPropertyFromGenerator(new PropertyGenerator($name, $defaultValue, $flags)); } @@ -481,24 +621,13 @@ class ClassGenerator extends AbstractGenerator )); } - $this->properties[$propertyName] = $property; - return $this; - } - - /** - * Add a class to "use" classes - * - * @param string $use - * @param string|null $useAlias - * @return ClassGenerator - */ - public function addUse($use, $useAlias = null) - { - if (!empty($useAlias)) { - $use .= ' as ' . $useAlias; + // backwards compatibility + // @todo remove this on next major version + if ($property->isConst()) { + return $this->addConstantFromGenerator($property); } - $this->uses[$use] = $use; + $this->properties[$propertyName] = $property; return $this; } @@ -525,6 +654,19 @@ class ClassGenerator extends AbstractGenerator return false; } + /** + * Add a class to "use" classes + * + * @param string $use + * @param string|null $useAlias + * @return ClassGenerator + */ + public function addUse($use, $useAlias = null) + { + $this->traitUsageGenerator->addUse($use, $useAlias); + return $this; + } + /** * Returns the "use" classes * @@ -532,7 +674,7 @@ class ClassGenerator extends AbstractGenerator */ public function getUses() { - return array_values($this->uses); + return $this->traitUsageGenerator->getUses(); } /** @@ -585,8 +727,9 @@ class ClassGenerator extends AbstractGenerator ) { if (!is_string($name)) { throw new Exception\InvalidArgumentException(sprintf( - '%s expects string for name', - __METHOD__ + '%s::%s expects string for name', + get_class($this), + __FUNCTION__ )); } @@ -654,6 +797,92 @@ class ClassGenerator extends AbstractGenerator return isset($this->methods[strtolower($methodName)]); } + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTrait($trait) + { + $this->traitUsageGenerator->addTrait($trait); + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTraits(array $traits) + { + $this->traitUsageGenerator->addTraits($traits); + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function hasTrait($traitName) + { + return $this->traitUsageGenerator->hasTrait($traitName); + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getTraits() + { + return $this->traitUsageGenerator->getTraits(); + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function removeTrait($traitName) + { + return $this->traitUsageGenerator->removeTrait($traitName); + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTraitAlias($method, $alias, $visibility = null) + { + $this->traitUsageGenerator->addTraitAlias($method, $alias, $visibility); + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getTraitAliases() + { + return $this->traitUsageGenerator->getTraitAliases(); + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTraitOverride($method, $traitsToReplace) + { + $this->traitUsageGenerator->addTraitOverride($method, $traitsToReplace); + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function removeTraitOverride($method, $overridesToRemove = null) + { + $this->traitUsageGenerator->removeTraitOverride($method, $overridesToRemove); + + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getTraitOverrides() + { + return $this->traitUsageGenerator->getTraitOverrides(); + } + /** * @return bool */ @@ -679,7 +908,7 @@ class ClassGenerator extends AbstractGenerator } /** - * @return string + * @inherit Zend\Code\Generator\GeneratorInterface */ public function generate() { @@ -690,6 +919,7 @@ class ClassGenerator extends AbstractGenerator } } + $indent = $this->getIndentation(); $output = ''; if (null !== ($namespace = $this->getNamespaceName())) { @@ -697,10 +927,12 @@ class ClassGenerator extends AbstractGenerator } $uses = $this->getUses(); + if (!empty($uses)) { foreach ($uses as $use) { $output .= 'use ' . $use . ';' . self::LINE_FEED; } + $output .= self::LINE_FEED; } @@ -711,33 +943,41 @@ class ClassGenerator extends AbstractGenerator if ($this->isAbstract()) { $output .= 'abstract '; + } elseif ($this->isFinal()) { + $output .= 'final '; } - $output .= 'class ' . $this->getName(); + $output .= static::OBJECT_TYPE . ' ' . $this->getName(); if (!empty($this->extendedClass)) { $output .= ' extends ' . $this->extendedClass; } $implemented = $this->getImplementedInterfaces(); + if (!empty($implemented)) { $output .= ' implements ' . implode(', ', $implemented); } $output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED; + $output .= $this->traitUsageGenerator->generate(); + + $constants = $this->getConstants(); + + foreach ($constants as $constant) { + $output .= $constant->generate() . self::LINE_FEED . self::LINE_FEED; + } $properties = $this->getProperties(); - if (!empty($properties)) { - foreach ($properties as $property) { - $output .= $property->generate() . self::LINE_FEED . self::LINE_FEED; - } + + foreach ($properties as $property) { + $output .= $property->generate() . self::LINE_FEED . self::LINE_FEED; } $methods = $this->getMethods(); - if (!empty($methods)) { - foreach ($methods as $method) { - $output .= $method->generate() . self::LINE_FEED; - } + + foreach ($methods as $method) { + $output .= $method->generate() . self::LINE_FEED; } $output .= self::LINE_FEED . '}' . self::LINE_FEED; diff --git a/library/Zend/Code/Generator/DocBlock/Tag.php b/library/Zend/Code/Generator/DocBlock/Tag.php index 58bd045e..5901fb13 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/AbstractTypeableTag.php b/library/Zend/Code/Generator/DocBlock/Tag/AbstractTypeableTag.php index 1ecf5dc0..3d95e908 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/AbstractTypeableTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/AbstractTypeableTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php b/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php index 333912dc..a6b54086 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/GenericTag.php b/library/Zend/Code/Generator/DocBlock/Tag/GenericTag.php index 4ff98d9f..d4ea1084 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/GenericTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/GenericTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php b/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php index 91a97415..832d4346 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/MethodTag.php b/library/Zend/Code/Generator/DocBlock/Tag/MethodTag.php index e3c84c4c..fc68c6d9 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/MethodTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/MethodTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php b/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php index 75d8f86c..4753eee0 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/PropertyTag.php b/library/Zend/Code/Generator/DocBlock/Tag/PropertyTag.php index 26699a89..6a1de98f 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/PropertyTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/PropertyTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php b/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php index f3b356eb..d2015577 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/TagInterface.php b/library/Zend/Code/Generator/DocBlock/Tag/TagInterface.php index 4d4ef3fc..70d46b9b 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/TagInterface.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/TagInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/Tag/ThrowsTag.php b/library/Zend/Code/Generator/DocBlock/Tag/ThrowsTag.php index 6350746e..20df0b4f 100644 --- a/library/Zend/Code/Generator/DocBlock/Tag/ThrowsTag.php +++ b/library/Zend/Code/Generator/DocBlock/Tag/ThrowsTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlock/TagManager.php b/library/Zend/Code/Generator/DocBlock/TagManager.php index 4ff3a2bc..00531f65 100644 --- a/library/Zend/Code/Generator/DocBlock/TagManager.php +++ b/library/Zend/Code/Generator/DocBlock/TagManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/DocBlockGenerator.php b/library/Zend/Code/Generator/DocBlockGenerator.php index e983fa6b..1a84335c 100644 --- a/library/Zend/Code/Generator/DocBlockGenerator.php +++ b/library/Zend/Code/Generator/DocBlockGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/Exception/ExceptionInterface.php b/library/Zend/Code/Generator/Exception/ExceptionInterface.php index d6abfd42..226b37ca 100644 --- a/library/Zend/Code/Generator/Exception/ExceptionInterface.php +++ b/library/Zend/Code/Generator/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/Exception/InvalidArgumentException.php b/library/Zend/Code/Generator/Exception/InvalidArgumentException.php index 11a4b248..0b5cb4c2 100644 --- a/library/Zend/Code/Generator/Exception/InvalidArgumentException.php +++ b/library/Zend/Code/Generator/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/Exception/RuntimeException.php b/library/Zend/Code/Generator/Exception/RuntimeException.php index b1acd4f9..7b95186f 100644 --- a/library/Zend/Code/Generator/Exception/RuntimeException.php +++ b/library/Zend/Code/Generator/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/FileGenerator.php b/library/Zend/Code/Generator/FileGenerator.php index 5cb559c3..5fb91a1b 100644 --- a/library/Zend/Code/Generator/FileGenerator.php +++ b/library/Zend/Code/Generator/FileGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -90,8 +90,6 @@ class FileGenerator extends AbstractGenerator $file->setSourceContent($fileReflection->getContents()); $file->setSourceDirty(false); - $body = $fileReflection->getContents(); - $uses = $fileReflection->getUses(); foreach ($fileReflection->getClasses() as $class) { @@ -154,7 +152,7 @@ class FileGenerator extends AbstractGenerator } /** - * @param DocBlockGenerator|string $docBlock + * @param DocBlockGenerator|array|string $docBlock * @throws Exception\InvalidArgumentException * @return FileGenerator */ @@ -304,7 +302,7 @@ class FileGenerator extends AbstractGenerator */ public function getClass($name = null) { - if ($name == null) { + if ($name === null) { reset($this->classes); return current($this->classes); @@ -454,8 +452,12 @@ class FileGenerator extends AbstractGenerator if ($namespace) { $namespace = sprintf('namespace %s;%s', $namespace, str_repeat(self::LINE_FEED, 2)); if (preg_match('#/\* Zend_Code_Generator_FileGenerator-NamespaceMarker \*/#m', $output)) { - $output = preg_replace('#/\* Zend_Code_Generator_FileGenerator-NamespaceMarker \*/#m', $namespace, - $output, 1); + $output = preg_replace( + '#/\* Zend_Code_Generator_FileGenerator-NamespaceMarker \*/#m', + $namespace, + $output, + 1 + ); } else { $output .= $namespace; } @@ -505,8 +507,12 @@ class FileGenerator extends AbstractGenerator $useOutput .= self::LINE_FEED; if (preg_match('#/\* Zend_Code_Generator_FileGenerator-UseMarker \*/#m', $output)) { - $output = preg_replace('#/\* Zend_Code_Generator_FileGenerator-UseMarker \*/#m', $useOutput, - $output, 1); + $output = preg_replace( + '#/\* Zend_Code_Generator_FileGenerator-UseMarker \*/#m', + $useOutput, + $output, + 1 + ); } else { $output .= $useOutput; } diff --git a/library/Zend/Code/Generator/FileGeneratorRegistry.php b/library/Zend/Code/Generator/FileGeneratorRegistry.php index 164cc525..dfacb6b3 100644 --- a/library/Zend/Code/Generator/FileGeneratorRegistry.php +++ b/library/Zend/Code/Generator/FileGeneratorRegistry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ class FileGeneratorRegistry */ public static function registerFileCodeGenerator(FileGenerator $fileCodeGenerator, $fileName = null) { - if ($fileName == null) { + if ($fileName === null) { $fileName = $fileCodeGenerator->getFilename(); } diff --git a/library/Zend/Code/Generator/GeneratorInterface.php b/library/Zend/Code/Generator/GeneratorInterface.php index 77e1eb8c..59e9d3a0 100644 --- a/library/Zend/Code/Generator/GeneratorInterface.php +++ b/library/Zend/Code/Generator/GeneratorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/MethodGenerator.php b/library/Zend/Code/Generator/MethodGenerator.php index d98cbd80..1f405dbc 100644 --- a/library/Zend/Code/Generator/MethodGenerator.php +++ b/library/Zend/Code/Generator/MethodGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -61,11 +61,40 @@ class MethodGenerator extends AbstractMemberGenerator $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter)); } - $method->setBody($reflectionMethod->getBody()); + $method->setBody(static::clearBodyIndention($reflectionMethod->getBody())); return $method; } + /** + * Identify the space indention from the first line and remove this indention + * from all lines + * + * @param string $body + * + * @return string + */ + protected static function clearBodyIndention($body) + { + if (empty($body)) { + return $body; + } + + $lines = explode(PHP_EOL, $body); + + $indention = str_replace(trim($lines[1]), '', $lines[1]); + + foreach ($lines as $key => $line) { + if (substr($line, 0, strlen($indention)) == $indention) { + $lines[$key] = substr($line, strlen($indention)); + } + } + + $body = implode(PHP_EOL, $lines); + + return $body; + } + /** * Generate from array * @@ -171,7 +200,7 @@ class MethodGenerator extends AbstractMemberGenerator } /** - * @param ParameterGenerator|string $parameter + * @param ParameterGenerator|array|string $parameter * @throws Exception\InvalidArgumentException * @return MethodGenerator */ @@ -179,7 +208,13 @@ class MethodGenerator extends AbstractMemberGenerator { if (is_string($parameter)) { $parameter = new ParameterGenerator($parameter); - } elseif (!$parameter instanceof ParameterGenerator) { + } + + if (is_array($parameter)) { + $parameter = ParameterGenerator::fromArray($parameter); + } + + if (!$parameter instanceof ParameterGenerator) { throw new Exception\InvalidArgumentException(sprintf( '%s is expecting either a string, array or an instance of %s\ParameterGenerator', __METHOD__, @@ -187,9 +222,7 @@ class MethodGenerator extends AbstractMemberGenerator )); } - $parameterName = $parameter->getName(); - - $this->parameters[$parameterName] = $parameter; + $this->parameters[$parameter->getName()] = $parameter; return $this; } diff --git a/library/Zend/Code/Generator/ParameterGenerator.php b/library/Zend/Code/Generator/ParameterGenerator.php index 30fad22c..3714565c 100644 --- a/library/Zend/Code/Generator/ParameterGenerator.php +++ b/library/Zend/Code/Generator/ParameterGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/PropertyGenerator.php b/library/Zend/Code/Generator/PropertyGenerator.php index 36735ad3..159e415c 100644 --- a/library/Zend/Code/Generator/PropertyGenerator.php +++ b/library/Zend/Code/Generator/PropertyGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -204,7 +204,7 @@ class PropertyGenerator extends AbstractMemberGenerator } if ($this->isConst()) { - if ($defaultValue != null && !$defaultValue->isValidConstantType()) { + if ($defaultValue !== null && !$defaultValue->isValidConstantType()) { throw new Exception\RuntimeException(sprintf( 'The property %s is said to be ' . 'constant but does not have a valid constant value.', diff --git a/library/Zend/Code/Generator/PropertyValueGenerator.php b/library/Zend/Code/Generator/PropertyValueGenerator.php index f36fc8c1..bf4156cb 100644 --- a/library/Zend/Code/Generator/PropertyValueGenerator.php +++ b/library/Zend/Code/Generator/PropertyValueGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generator/TraitGenerator.php b/library/Zend/Code/Generator/TraitGenerator.php new file mode 100644 index 00000000..4bc28720 --- /dev/null +++ b/library/Zend/Code/Generator/TraitGenerator.php @@ -0,0 +1,173 @@ +getName()); + + $cg->setSourceContent($cg->getSourceContent()); + $cg->setSourceDirty(false); + + if ($classReflection->getDocComment() != '') { + $cg->setDocBlock(DocBlockGenerator::fromReflection($classReflection->getDocBlock())); + } + + // set the namespace + if ($classReflection->inNamespace()) { + $cg->setNamespaceName($classReflection->getNamespaceName()); + } + + $properties = array(); + foreach ($classReflection->getProperties() as $reflectionProperty) { + if ($reflectionProperty->getDeclaringClass()->getName() == $classReflection->getName()) { + $properties[] = PropertyGenerator::fromReflection($reflectionProperty); + } + } + $cg->addProperties($properties); + + $methods = array(); + foreach ($classReflection->getMethods() as $reflectionMethod) { + $className = ($cg->getNamespaceName()) + ? $cg->getNamespaceName() . '\\' . $cg->getName() + : $cg->getName(); + if ($reflectionMethod->getDeclaringClass()->getName() == $className) { + $methods[] = MethodGenerator::fromReflection($reflectionMethod); + } + } + $cg->addMethods($methods); + + return $cg; + } + + /** + * Generate from array + * + * @configkey name string [required] Class Name + * @configkey filegenerator FileGenerator File generator that holds this class + * @configkey namespacename string The namespace for this class + * @configkey docblock string The docblock information + * @configkey properties + * @configkey methods + * + * @throws Exception\InvalidArgumentException + * @param array $array + * @return TraitGenerator + */ + public static function fromArray(array $array) + { + if (! isset($array['name'])) { + throw new Exception\InvalidArgumentException( + 'Class generator requires that a name is provided for this object' + ); + } + + $cg = new static($array['name']); + foreach ($array as $name => $value) { + // normalize key + switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) { + case 'containingfile': + $cg->setContainingFileGenerator($value); + break; + case 'namespacename': + $cg->setNamespaceName($value); + break; + case 'docblock': + $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value); + $cg->setDocBlock($docBlock); + break; + case 'properties': + $cg->addProperties($value); + break; + case 'methods': + $cg->addMethods($value); + break; + } + } + + return $cg; + } + + /** + * @param array|string $flags + * @return self + */ + public function setFlags($flags) + { + return $this; + } + + /** + * @param string $flag + * @return self + */ + public function addFlag($flag) + { + return $this; + } + + /** + * @param string $flag + * @return self + */ + public function removeFlag($flag) + { + return $this; + } + + /** + * @param bool $isFinal + * @return self + */ + public function setFinal($isFinal) + { + return $this; + } + + /** + * @param string $extendedClass + * @return self + */ + public function setExtendedClass($extendedClass) + { + return $this; + } + + /** + * @param array $implementedInterfaces + * @return self + */ + public function setImplementedInterfaces(array $implementedInterfaces) + { + return $this; + } + + /** + * @param bool $isAbstract + * @return self + */ + public function setAbstract($isAbstract) + { + return $this; + } +} diff --git a/library/Zend/Code/Generator/TraitUsageGenerator.php b/library/Zend/Code/Generator/TraitUsageGenerator.php new file mode 100644 index 00000000..0cd2b582 --- /dev/null +++ b/library/Zend/Code/Generator/TraitUsageGenerator.php @@ -0,0 +1,353 @@ +classGenerator = $classGenerator; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addUse($use, $useAlias = null) + { + if (! empty($useAlias)) { + $use .= ' as ' . $useAlias; + } + + $this->uses[$use] = $use; + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getUses() + { + return array_values($this->uses); + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTrait($trait) + { + $traitName = $trait; + if (is_array($trait)) { + if (! array_key_exists('traitName', $trait)) { + throw new Exception\InvalidArgumentException('Missing required value for traitName'); + } + $traitName = $trait['traitName']; + + if (array_key_exists('aliases', $trait)) { + foreach ($trait['aliases'] as $alias) { + $this->addAlias($alias); + } + } + + if (array_key_exists('insteadof', $trait)) { + foreach ($trait['insteadof'] as $insteadof) { + $this->addTraitOverride($insteadof); + } + } + } + + if (! $this->hasTrait($traitName)) { + $this->traits[] = $traitName; + } + + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTraits(array $traits) + { + foreach ($traits as $trait) { + $this->addTrait($trait); + } + + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function hasTrait($traitName) + { + return in_array($traitName, $this->traits); + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getTraits() + { + return $this->traits; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function removeTrait($traitName) + { + $key = array_search($traitName, $this->traits); + if (false !== $key) { + unset($this->traits[$key]); + } + + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTraitAlias($method, $alias, $visibility = null) + { + $traitAndMethod = $method; + if (is_array($method)) { + if (! array_key_exists('traitName', $method)) { + throw new Exception\InvalidArgumentException('Missing required argument "traitName" for $method'); + } + + if (! array_key_exists('method', $method)) { + throw new Exception\InvalidArgumentException('Missing required argument "method" for $method'); + } + + $traitAndMethod = $method['traitName'] . '::' . $method['method']; + } + + // Validations + if (false === strpos($traitAndMethod, "::")) { + throw new Exception\InvalidArgumentException( + 'Invalid Format: $method must be in the format of trait::method' + ); + } + if (! is_string($alias)) { + throw new Exception\InvalidArgumentException('Invalid Alias: $alias must be a string or array.'); + } + if ($this->classGenerator->hasMethod($alias)) { + throw new Exception\InvalidArgumentException('Invalid Alias: Method name already exists on this class.'); + } + if (null !== $visibility + && $visibility !== ReflectionMethod::IS_PUBLIC + && $visibility !== ReflectionMethod::IS_PRIVATE + && $visibility !== ReflectionMethod::IS_PROTECTED + ) { + throw new Exception\InvalidArgumentException( + 'Invalid Type: $visibility must of ReflectionMethod::IS_PUBLIC,' + . ' ReflectionMethod::IS_PRIVATE or ReflectionMethod::IS_PROTECTED' + ); + } + + list($trait, $method) = explode('::', $traitAndMethod); + if (! $this->hasTrait($trait)) { + throw new Exception\InvalidArgumentException('Invalid trait: Trait does not exists on this class'); + } + + $this->traitAliases[$traitAndMethod] = array( + 'alias' => $alias, + 'visibility' => $visibility + ); + + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getTraitAliases() + { + return $this->traitAliases; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function addTraitOverride($method, $traitsToReplace) + { + if (false === is_array($traitsToReplace)) { + $traitsToReplace = array($traitsToReplace); + } + + $traitAndMethod = $method; + if (is_array($method)) { + if (! array_key_exists('traitName', $method)) { + throw new Exception\InvalidArgumentException('Missing required argument "traitName" for $method'); + } + + if (! array_key_exists('method', $method)) { + throw new Exception\InvalidArgumentException('Missing required argument "method" for $method'); + } + + $traitAndMethod = (string) $method['traitName'] . '::' . (string) $method['method']; + } + + // Validations + if (false === strpos($traitAndMethod, "::")) { + throw new Exception\InvalidArgumentException( + 'Invalid Format: $method must be in the format of trait::method' + ); + } + + list($trait, $method) = explode("::", $traitAndMethod); + if (! $this->hasTrait($trait)) { + throw new Exception\InvalidArgumentException('Invalid trait: Trait does not exists on this class'); + } + + if (! array_key_exists($traitAndMethod, $this->traitOverrides)) { + $this->traitOverrides[$traitAndMethod] = array(); + } + + foreach ($traitsToReplace as $traitToReplace) { + if (! is_string($traitToReplace)) { + throw new Exception\InvalidArgumentException( + 'Invalid Argument: $traitToReplace must be a string or array of strings' + ); + } + + if (! in_array($traitToReplace, $this->traitOverrides[$traitAndMethod])) { + $this->traitOverrides[$traitAndMethod][] = $traitToReplace; + } + } + + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function removeTraitOverride($method, $overridesToRemove = null) + { + if (! array_key_exists($method, $this->traitOverrides)) { + return $this; + } + + if (null === $overridesToRemove) { + unset($this->traitOverrides[$method]); + return $this; + } + + $overridesToRemove = (! is_array($overridesToRemove)) + ? array($overridesToRemove) + : $overridesToRemove; + foreach ($overridesToRemove as $traitToRemove) { + $key = array_search($traitToRemove, $this->traitOverrides[$method]); + if (false !== $key) { + unset($this->traitOverrides[$method][$key]); + } + } + return $this; + } + + /** + * @inherit Zend\Code\Generator\TraitUsageInterface + */ + public function getTraitOverrides() + { + return $this->traitOverrides; + } + + /** + * @inherit Zend\Code\Generator\GeneratorInterface + */ + public function generate() + { + $output = ''; + $indent = $this->getIndentation(); + $traits = $this->getTraits(); + + if (empty($traits)) { + return $output; + } + + $output .= $indent . 'use ' . implode(', ', $traits); + + $aliases = $this->getTraitAliases(); + $overrides = $this->getTraitOverrides(); + if (empty($aliases) && empty($overrides)) { + $output .= ";" . self::LINE_FEED . self::LINE_FEED; + return $output; + } + + $output .= ' {' . self::LINE_FEED; + foreach ($aliases as $method => $alias) { + $visibility = (null !== $alias['visibility']) + ? current(Reflection::getModifierNames($alias['visibility'])) . ' ' + : ''; + + // validation check + if ($this->classGenerator->hasMethod($alias['alias'])) { + throw new Exception\RuntimeException(sprintf( + 'Generation Error: Aliased method %s already exists on this class', + $alias['alias'] + )); + } + + $output .= + $indent + . $indent + . $method + . ' as ' + . $visibility + . $alias['alias'] + . ';' + . self::LINE_FEED; + } + + foreach ($overrides as $method => $insteadofTraits) { + foreach ($insteadofTraits as $insteadofTrait) { + $output .= + $indent + . $indent + . $method + . ' insteadof ' + . $insteadofTrait + . ';' + . self::LINE_FEED; + } + } + + $output .= self::LINE_FEED . $indent . '}' . self::LINE_FEED . self::LINE_FEED; + + return $output; + } +} diff --git a/library/Zend/Code/Generator/TraitUsageInterface.php b/library/Zend/Code/Generator/TraitUsageInterface.php new file mode 100644 index 00000000..e5c0bda7 --- /dev/null +++ b/library/Zend/Code/Generator/TraitUsageInterface.php @@ -0,0 +1,159 @@ +:: + * Option 2: Array + * key: traitName value: trait name + * key: method value: method name + * + * $traitToReplace: + * The name of the trait that you wish to supersede. + * + * This method provides 2 ways for defining the trait method. + * Option 1: String of trait to replace + * Option 2: Array of strings of traits to replace + + * @param mixed $method + * @param mixed $traitToReplace + */ + public function addTraitOverride($method, $traitsToReplace); + + /** + * Remove an override for a given trait::method + * + * $method: + * This method provides 2 ways for defining the trait method. + * Option 1: String Format: :: + * Option 2: Array + * key: traitName value: trait name + * key: method value: method name + * + * $overridesToRemove: + * The name of the trait that you wish to remove. + * + * This method provides 2 ways for defining the trait method. + * Option 1: String of trait to replace + * Option 2: Array of strings of traits to replace + * + * @param $traitAndMethod + * @param null $overridesToRemove + * @return $this + */ + public function removeTraitOverride($method, $overridesToRemove = null); + + /** + * Return trait overrides + * + * @return array + */ + public function getTraitOverrides(); +} diff --git a/library/Zend/Code/Generator/ValueGenerator.php b/library/Zend/Code/Generator/ValueGenerator.php index 69e110b7..50da8651 100644 --- a/library/Zend/Code/Generator/ValueGenerator.php +++ b/library/Zend/Code/Generator/ValueGenerator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -73,7 +73,8 @@ class ValueGenerator extends AbstractGenerator */ public function __construct($value = null, $type = self::TYPE_AUTO, $outputMode = self::OUTPUT_MULTIPLE_LINE, ArrayObject $constants = null) { - if ($value !== null) { // strict check is important here if $type = AUTO + // strict check is important here if $type = AUTO + if ($value !== null) { $this->setValue($value); } if ($type !== self::TYPE_AUTO) { @@ -373,6 +374,9 @@ class ValueGenerator extends AbstractGenerator : ' '; $output .= implode(',' . $padding, $outputParts); if ($this->outputMode == self::OUTPUT_MULTIPLE_LINE) { + if (count($outputParts) > 0) { + $output .= ','; + } $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth); } $output .= ')'; diff --git a/library/Zend/Code/Generic/Prototype/PrototypeClassFactory.php b/library/Zend/Code/Generic/Prototype/PrototypeClassFactory.php index 7c3a9bf1..2fcc5f77 100644 --- a/library/Zend/Code/Generic/Prototype/PrototypeClassFactory.php +++ b/library/Zend/Code/Generic/Prototype/PrototypeClassFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generic/Prototype/PrototypeGenericInterface.php b/library/Zend/Code/Generic/Prototype/PrototypeGenericInterface.php index 3a5e44a8..06a41dae 100644 --- a/library/Zend/Code/Generic/Prototype/PrototypeGenericInterface.php +++ b/library/Zend/Code/Generic/Prototype/PrototypeGenericInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Generic/Prototype/PrototypeInterface.php b/library/Zend/Code/Generic/Prototype/PrototypeInterface.php index 2815e54d..acbfb722 100644 --- a/library/Zend/Code/Generic/Prototype/PrototypeInterface.php +++ b/library/Zend/Code/Generic/Prototype/PrototypeInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/NameInformation.php b/library/Zend/Code/NameInformation.php index 819ebfb0..59bb6b0d 100644 --- a/library/Zend/Code/NameInformation.php +++ b/library/Zend/Code/NameInformation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -58,7 +58,7 @@ class NameInformation */ public function hasNamespace() { - return ($this->namespace != null); + return ($this->namespace !== null); } /** diff --git a/library/Zend/Code/Reflection/ClassReflection.php b/library/Zend/Code/Reflection/ClassReflection.php index 86d1f14c..25bcaf05 100644 --- a/library/Zend/Code/Reflection/ClassReflection.php +++ b/library/Zend/Code/Reflection/ClassReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -177,6 +177,26 @@ class ClassReflection extends ReflectionClass implements ReflectionInterface return $methods; } + /** + * Returns an array of reflection classes of traits used by this class. + * + * @return array|null + */ + public function getTraits() + { + $vals = array(); + $traits = parent::getTraits(); + if ($traits === null) { + return; + } + + foreach ($traits as $trait) { + $vals[] = new ClassReflection($trait->getName()); + } + + return $vals; + } + /** * Get parent reflection class of reflected class * @@ -230,11 +250,17 @@ class ClassReflection extends ReflectionClass implements ReflectionInterface return $zendReflections; } + /** + * @return string + */ public function toString() { return parent::__toString(); } + /** + * @return string + */ public function __toString() { return parent::__toString(); diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php index 9afdee08..8b48fbe0 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php index 9f348108..6cd1bb62 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php index d1148ef6..ee7ec145 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php index 50738bfe..86d409ce 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -80,7 +80,7 @@ class MethodTag implements TagInterface, PhpDocTypedTagInterface public function getReturnType() { if (empty($this->types)) { - return null; + return; } return $this->types[0]; diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php index b11a16e4..74b8a1d5 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php b/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php index 01bea4b9..19b1119a 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/PropertyTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/PropertyTag.php index a15ffd21..d8b3435c 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/PropertyTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/PropertyTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -66,7 +66,7 @@ class PropertyTag implements TagInterface, PhpDocTypedTagInterface public function getType() { if (empty($this->types)) { - return null; + return; } return $this->types[0]; diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php index f43d7e2e..c9294149 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php b/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php index f34e154f..653c8844 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/Tag/ThrowsTag.php b/library/Zend/Code/Reflection/DocBlock/Tag/ThrowsTag.php index 25453460..5b57dea5 100644 --- a/library/Zend/Code/Reflection/DocBlock/Tag/ThrowsTag.php +++ b/library/Zend/Code/Reflection/DocBlock/Tag/ThrowsTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlock/TagManager.php b/library/Zend/Code/Reflection/DocBlock/TagManager.php index 4d8f0da8..3a5474db 100644 --- a/library/Zend/Code/Reflection/DocBlock/TagManager.php +++ b/library/Zend/Code/Reflection/DocBlock/TagManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/DocBlockReflection.php b/library/Zend/Code/Reflection/DocBlockReflection.php index a4902136..a898ca84 100644 --- a/library/Zend/Code/Reflection/DocBlockReflection.php +++ b/library/Zend/Code/Reflection/DocBlockReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -247,7 +247,7 @@ class DocBlockReflection implements ReflectionInterface return; } - $docComment = $this->docComment; // localize variable + $docComment = preg_replace('#[ ]{0,1}\*/$#', '', $this->docComment); // create a clean docComment $this->cleanDocComment = preg_replace("#[ \t]*(?:/\*\*|\*/|\*)[ ]{0,1}(.*)?#", '$1', $docComment); @@ -264,6 +264,9 @@ class DocBlockReflection implements ReflectionInterface $this->isReflected = true; } + /** + * @return string + */ public function toString() { $str = "DocBlock [ /* DocBlock */ ] {" . PHP_EOL . PHP_EOL; diff --git a/library/Zend/Code/Reflection/Exception/BadMethodCallException.php b/library/Zend/Code/Reflection/Exception/BadMethodCallException.php index 6eeb226f..f40a1992 100644 --- a/library/Zend/Code/Reflection/Exception/BadMethodCallException.php +++ b/library/Zend/Code/Reflection/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/Exception/ExceptionInterface.php b/library/Zend/Code/Reflection/Exception/ExceptionInterface.php index dfb6736c..a3574f83 100644 --- a/library/Zend/Code/Reflection/Exception/ExceptionInterface.php +++ b/library/Zend/Code/Reflection/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/Exception/InvalidArgumentException.php b/library/Zend/Code/Reflection/Exception/InvalidArgumentException.php index 08679691..bc816819 100644 --- a/library/Zend/Code/Reflection/Exception/InvalidArgumentException.php +++ b/library/Zend/Code/Reflection/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/Exception/RuntimeException.php b/library/Zend/Code/Reflection/Exception/RuntimeException.php index 1965fb60..f538b65e 100644 --- a/library/Zend/Code/Reflection/Exception/RuntimeException.php +++ b/library/Zend/Code/Reflection/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Reflection/FileReflection.php b/library/Zend/Code/Reflection/FileReflection.php index dfd07a04..1ab3bc5c 100644 --- a/library/Zend/Code/Reflection/FileReflection.php +++ b/library/Zend/Code/Reflection/FileReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,17 +34,17 @@ class FileReflection implements ReflectionInterface protected $endLine = null; /** - * @var string + * @var string[] */ protected $namespaces = array(); /** - * @var array + * @var string[] */ protected $uses = array(); /** - * @var array + * @var string[] */ protected $requiredFiles = array(); @@ -105,7 +105,7 @@ class FileReflection implements ReflectionInterface */ public static function export() { - return null; + return; } /** @@ -115,8 +115,7 @@ class FileReflection implements ReflectionInterface */ public function getFileName() { - // @todo get file name from path - return $this->filePath; + return basename($this->filePath); } /** @@ -162,7 +161,7 @@ class FileReflection implements ReflectionInterface } /** - * @return array + * @return string[] */ public function getNamespaces() { @@ -175,7 +174,7 @@ class FileReflection implements ReflectionInterface public function getNamespace() { if (count($this->namespaces) == 0) { - return null; + return; } return $this->namespaces[0]; diff --git a/library/Zend/Code/Reflection/FunctionReflection.php b/library/Zend/Code/Reflection/FunctionReflection.php index c752f1ec..b7bb4235 100644 --- a/library/Zend/Code/Reflection/FunctionReflection.php +++ b/library/Zend/Code/Reflection/FunctionReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -203,7 +203,7 @@ class FunctionReflection extends ReflectionFunction implements ReflectionInterfa /** * Get method body * - * @return string|bool + * @return string|false */ public function getBody() { @@ -249,6 +249,9 @@ class FunctionReflection extends ReflectionFunction implements ReflectionInterfa return $body; } + /** + * @return string + */ public function toString() { return $this->__toString(); diff --git a/library/Zend/Code/Reflection/MethodReflection.php b/library/Zend/Code/Reflection/MethodReflection.php index 10a9b8ab..514505ea 100644 --- a/library/Zend/Code/Reflection/MethodReflection.php +++ b/library/Zend/Code/Reflection/MethodReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -184,7 +184,7 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac * Get method contents * * @param bool $includeDocBlock - * @return string|bool + * @return string */ public function getContents($includeDocBlock = true) { @@ -198,7 +198,7 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac /** * Get method body * - * @return string|bool + * @return string */ public function getBody() { @@ -211,9 +211,9 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac * @param bool $bodyOnly * @return string */ - protected function extractMethodContents($bodyOnly=false) + protected function extractMethodContents($bodyOnly = false) { - $fileName = $this->getDeclaringClass()->getFileName(); + $fileName = $this->getFileName(); if ((class_exists($this->class) && false === $fileName) || ! file_exists($fileName)) { return ''; @@ -331,8 +331,8 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac /** * Take current position and find any whitespace * - * @param $haystack - * @param $position + * @param array $haystack + * @param int $position * @return string */ protected function extractPrefixedWhitespace($haystack, $position) @@ -361,8 +361,8 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac /** * Test for ending brace * - * @param $haystack - * @param $position + * @param array $haystack + * @param int $position * @return bool */ protected function isEndingBrace($haystack, $position) @@ -430,15 +430,16 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac * Test to see if current position is valid function or * closure. Returns true if it's a function and NOT a closure * - * @param $haystack - * @param $position + * @param array $haystack + * @param int $position + * @param string $functionName * @return bool */ protected function isValidFunction($haystack, $position, $functionName = null) { $isValid = false; $count = count($haystack); - for ($i = $position+1;$i < $count; $i++) { + for ($i = $position+1; $i < $count; $i++) { $tokenType = (is_array($haystack[$i])) ? token_name($haystack[$i][0]) : $haystack[$i]; $tokenValue = (is_array($haystack[$i])) ? $haystack[$i][1] : $haystack[$i]; @@ -460,11 +461,17 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac return $isValid; } + /** + * @return string + */ public function toString() { return parent::__toString(); } + /** + * @return string + */ public function __toString() { return parent::__toString(); diff --git a/library/Zend/Code/Reflection/ParameterReflection.php b/library/Zend/Code/Reflection/ParameterReflection.php index e6239abc..ba095255 100644 --- a/library/Zend/Code/Reflection/ParameterReflection.php +++ b/library/Zend/Code/Reflection/ParameterReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -40,8 +40,8 @@ class ParameterReflection extends ReflectionParameter implements ReflectionInter public function getClass() { $phpReflection = parent::getClass(); - if ($phpReflection == null) { - return null; + if ($phpReflection === null) { + return; } $zendReflection = new ClassReflection($phpReflection->getName()); @@ -87,7 +87,7 @@ class ParameterReflection extends ReflectionParameter implements ReflectionInter $docBlock = $this->getDeclaringFunction()->getDocBlock(); if (!$docBlock instanceof DocBlockReflection) { - return null; + return; } $params = $docBlock->getTags('param'); @@ -95,14 +95,20 @@ class ParameterReflection extends ReflectionParameter implements ReflectionInter return $params[$this->getPosition()]->getType(); } - return null; + return; } + /** + * @return string + */ public function toString() { return parent::__toString(); } + /** + * @return string + */ public function __toString() { return parent::__toString(); diff --git a/library/Zend/Code/Reflection/PropertyReflection.php b/library/Zend/Code/Reflection/PropertyReflection.php index c9b5a8d2..d5d5a1bc 100644 --- a/library/Zend/Code/Reflection/PropertyReflection.php +++ b/library/Zend/Code/Reflection/PropertyReflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -89,6 +89,9 @@ class PropertyReflection extends PhpReflectionProperty implements ReflectionInte return $this->annotations; } + /** + * @return string + */ public function toString() { return $this->__toString(); diff --git a/library/Zend/Code/Reflection/ReflectionInterface.php b/library/Zend/Code/Reflection/ReflectionInterface.php index ed5ffd46..a081cf71 100644 --- a/library/Zend/Code/Reflection/ReflectionInterface.php +++ b/library/Zend/Code/Reflection/ReflectionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/AggregateDirectoryScanner.php b/library/Zend/Code/Scanner/AggregateDirectoryScanner.php index 63fd6752..629d7f90 100644 --- a/library/Zend/Code/Scanner/AggregateDirectoryScanner.php +++ b/library/Zend/Code/Scanner/AggregateDirectoryScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/AnnotationScanner.php b/library/Zend/Code/Scanner/AnnotationScanner.php index 76e8144c..7fb8e639 100644 --- a/library/Zend/Code/Scanner/AnnotationScanner.php +++ b/library/Zend/Code/Scanner/AnnotationScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -160,7 +160,7 @@ class AnnotationScanner extends AnnotationCollection implements ScannerInterface } $currentChar = $stream[$streamIndex]; $matches = array(); - $currentLine = (preg_match('#(.*)\n#', $stream, $matches, null, $streamIndex) === 1) ? $matches[1] : substr($stream, $streamIndex); + $currentLine = (preg_match('#(.*?)(?:\n|\r\n?)#', $stream, $matches, null, $streamIndex) === 1) ? $matches[1] : substr($stream, $streamIndex); if ($currentChar === ' ') { $currentWord = (preg_match('#( +)#', $currentLine, $matches) === 1) ? $matches[1] : $currentLine; } else { @@ -213,7 +213,7 @@ class AnnotationScanner extends AnnotationCollection implements ScannerInterface } if ($MACRO_HAS_CONTEXT($CONTEXT_CLASS)) { - if (in_array($currentChar, array(' ', '(', "\n"))) { + if (in_array($currentChar, array(' ', '(', "\n", "\r"))) { $context &= ~$CONTEXT_CLASS; $MACRO_TOKEN_ADVANCE(); } else { @@ -225,7 +225,22 @@ class AnnotationScanner extends AnnotationCollection implements ScannerInterface } } - if ($currentChar === "\n") { + // Since we don't know what line endings are used in the file, we check for all scenarios. If we find a + // cariage return (\r), we check the next character for a line feed (\n). If so we consume it and act as + // if the cariage return was a line feed. + $lineEnded = $currentChar === "\n"; + if ($currentChar === "\r") { + $lineEnded = true; + + $nextChar = $MACRO_STREAM_ADVANCE_CHAR(); + if ($nextChar !== "\n") { + $streamIndex--; + } + + $currentChar = "\n"; + } + + if ($lineEnded) { $MACRO_TOKEN_SET_TYPE('ANNOTATION_NEWLINE'); $MACRO_TOKEN_APPEND_CHAR(); $MACRO_TOKEN_ADVANCE(); diff --git a/library/Zend/Code/Scanner/CachingFileScanner.php b/library/Zend/Code/Scanner/CachingFileScanner.php index cb728670..deef2440 100644 --- a/library/Zend/Code/Scanner/CachingFileScanner.php +++ b/library/Zend/Code/Scanner/CachingFileScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/ClassScanner.php b/library/Zend/Code/Scanner/ClassScanner.php index 2efc5539..d7507a20 100644 --- a/library/Zend/Code/Scanner/ClassScanner.php +++ b/library/Zend/Code/Scanner/ClassScanner.php @@ -3,12 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Code\Scanner; +use ReflectionClass; use Zend\Code\Annotation; use Zend\Code\Exception; use Zend\Code\NameInformation; @@ -45,6 +46,11 @@ class ClassScanner implements ScannerInterface */ protected $lineEnd = null; + /** + * @var bool + */ + protected $isTrait = false; + /** * @var bool */ @@ -95,6 +101,16 @@ class ClassScanner implements ScannerInterface */ protected $infos = array(); + /** + * @var array + */ + protected $traits = array(); + + /** + * @var array + */ + protected $methods = array(); + /** * @param array $classTokens * @param NameInformation|null $nameInformation @@ -202,6 +218,16 @@ class ClassScanner implements ScannerInterface return $this->isFinal; } + /** + * Verify if class is a trait + * @return bool + */ + public function isTrait() + { + $this->scan(); + return $this->isTrait; + } + /** * Verify if class is instantiable * @@ -243,7 +269,7 @@ class ClassScanner implements ScannerInterface public function hasParentClass() { $this->scan(); - return ($this->parentClass != null); + return ($this->parentClass !== null); } /** @@ -344,7 +370,9 @@ class ClassScanner implements ScannerInterface return false; } } else { - throw new Exception\InvalidArgumentException('Invalid constant name of info index type. Must be of type int or string'); + throw new Exception\InvalidArgumentException( + 'Invalid constant name of info index type. Must be of type int or string' + ); } if (!isset($info)) { return false; @@ -401,7 +429,7 @@ class ClassScanner implements ScannerInterface /** * Return a list of properties * - * @return PropertyScanner + * @return PropertyScanner[] */ public function getProperties() { @@ -447,7 +475,9 @@ class ClassScanner implements ScannerInterface return false; } } else { - throw new Exception\InvalidArgumentException('Invalid property name of info index type. Must be of type int or string'); + throw new Exception\InvalidArgumentException( + 'Invalid property name of info index type. Must be of type int or string' + ); } if (!isset($info)) { return false; @@ -480,6 +510,170 @@ class ClassScanner implements ScannerInterface return false; } + /** + * Retrieve any traits used by the class. + * + * @return ClassScanner[] + */ + public function getTraits() + { + if (! empty($this->traits)) { + return $this->traits; + } + + // get list of trait names + $traitNames = $this->getTraitNames(); + foreach ($traitNames as $traitName) { + $r = new ReflectionClass($traitName); + if (! $r->isTrait()) { + throw new Exception\RuntimeException(sprintf( + 'Non-trait class detected as a trait: %s', + $traitName + )); + } + $fileName = $r->getFileName(); + + $file = new FileScanner($fileName); + $this->traits[] = $file->getClass($traitName); + } + + return $this->traits; + } + + /** + * Retrieve a list of trait names used by this class. + * + * @return array + */ + public function getTraitNames() + { + $return = array(); + foreach ($this->infos as $info) { + if ($info['type'] !== 'use') { + continue; + } + + if (is_array($info['use_statements'])) { + foreach ($info['use_statements'] as $trait) { + $traitName = $trait; + if ($this->nameInformation instanceof NameInformation) { + $traitName = $this->nameInformation->resolveName($traitName); + } + $return[] = $traitName; + } + } + break; + } + + return $return; + } + + /** + * Retrieve a list of aliased traits used by the class. + * + * @return array + */ + public function getTraitAliases() + { + $return = array(); + foreach ($this->infos as $info) { + if ($info['type'] !== 'use') { + continue; + } + + if (is_array($info['aliases'])) { + foreach ($info['aliases'] as $alias) { + if (null === $alias + || (! empty($alias['type']) && $alias['type'] !== 'as') + ) { + continue; + } + + // attempt to get fqcn + list($trait, $method) = explode('::', $alias['original']); + if ($this->nameInformation instanceof NameInformation) { + $trait = $this->nameInformation->resolveName($trait); + } + + $return[$alias['alias']] = $trait . '::' . $method; + } + } + break; + } + + return $return; + } + + /** + * Retrieve visibility for a given alias. + * + * @param mixed $aliasName + * @return string + */ + protected function getVisibilityForAlias($aliasName) + { + $return = null; + foreach ($this->infos as $info) { + if ($info['type'] !== 'use') { + continue; + } + + if (is_array($info['aliases'])) { + foreach ($info['aliases'] as $alias) { + if (null === $alias + && (! empty($alias['type']) && $alias['type'] !== 'as') + ) { + continue; + } + + if ($alias['alias'] === $aliasName) { + $return = $alias['visibility']; + break 2; + } + } + } + break; + } + + return $return; + } + + /** + * Return an array of key = trait to keep, value = trait::method to ignore + * + * @return array + */ + protected function getBlockedTraitMethods() + { + $return = array(); + foreach ($this->infos as $info) { + if ($info['type'] !== 'use') { + continue; + } + + if (is_array($info['aliases'])) { + foreach ($info['aliases'] as $alias) { + if (null === $alias + || (! empty($alias['type']) && $alias['type'] !== 'insteadof') + ) { + continue; + } + + // attempt to get fqcn + list($trait, $method) = explode('::', $alias['original']); + if ($this->nameInformation instanceof NameInformation) { + $trait = $this->nameInformation->resolveName($alias['alias']); + } + + $return[] = $trait . '::' . $method; + } + } + break; + } + + return $return; + } + /** * Return a list of method names * @@ -489,13 +683,10 @@ class ClassScanner implements ScannerInterface { $this->scan(); + $methods = $this->getMethods(); $return = array(); - foreach ($this->infos as $info) { - if ($info['type'] != 'method') { - continue; - } - - $return[] = $info['name']; + foreach ($methods as $method) { + $return[] = $method->getName(); } return $return; @@ -510,16 +701,82 @@ class ClassScanner implements ScannerInterface { $this->scan(); - $return = array(); + if (! empty($this->methods)) { + return $this->methods; + } + foreach ($this->infos as $info) { - if ($info['type'] != 'method') { + if ($info['type'] !== 'method' && $info['type'] !== 'use') { continue; } - $return[] = $this->getMethod($info['name']); + // Merge in trait methods + if ($info['type'] === "use") { + $traitMethods = array(); + $traits = $this->getTraits(); + $insteadof = $this->getBlockedTraitMethods(); + $aliases = $this->getTraitAliases(); + + foreach ($traits as $trait) { + $tempMethods = $trait->getMethods(); + foreach ($tempMethods as $tempMethod) { + $methodFullName = $trait->getName() . '::' . $tempMethod->getName(); + $methodAlias = array_search($methodFullName, $aliases); + + if (false !== $methodAlias) { + // trait::method is aliased + // clone the tempMethod as we need to change + // the name and possibly the visibility of the + // scanned method. + // + // @todo setName and setVisibility were added to + // MethodScanner to accomplish this, may not be the + // best option, could use ReflectionClass instead? + $newMethod = clone $tempMethod; + $newMethod->setName($methodAlias); + + // if visibility exists, change it on the MethodScanner + $visibility = $this->getVisibilityForAlias($methodAlias); + if (null !== $visibility) { + $newMethod->setVisibility($visibility); + } + $traitMethods[$methodAlias] = $newMethod; + } elseif (in_array($methodFullName, $insteadof)) { + // ignore overridden methods + continue; + } else { + if (array_key_exists($tempMethod->getName(), $traitMethods)) { + throw new Exception\RuntimeException(sprintf( + 'Trait method %s has not been applied because there are' + . ' collisions with other trait methods see: (insteadof OR as)', + $tempMethod->getName() + )); + } + + $traitMethods[$tempMethod->getName()] = $tempMethod; + } + } + } + + $this->methods = array_merge($this->methods, array_values($traitMethods)); + continue; + } + + $m = new MethodScanner( + array_slice( + $this->tokens, + $info['tokenStart'], + $info['tokenEnd'] - $info['tokenStart'] + 1 + ), + $this->nameInformation + ); + $m->setClass($this->name); + $m->setScannerClass($this); + + $this->methods[] = $m; } - return $return; + return $this->methods; } /** @@ -538,31 +795,19 @@ class ClassScanner implements ScannerInterface if ($info['type'] != 'method') { throw new Exception\InvalidArgumentException('Index of info offset is not about a method'); } - } elseif (is_string($methodNameOrInfoIndex)) { - $methodFound = false; - foreach ($this->infos as $info) { - if ($info['type'] === 'method' && $info['name'] === $methodNameOrInfoIndex) { - $methodFound = true; - break; - } - } - if (!$methodFound) { - return false; - } - } - if (!isset($info)) { - // @todo find a way to test this - die('Massive Failure, test this'); + $methodNameOrInfoIndex = $info['name']; } - $m = new MethodScanner( - array_slice($this->tokens, $info['tokenStart'], $info['tokenEnd'] - $info['tokenStart'] + 1), - $this->nameInformation - ); - $m->setClass($this->name); - $m->setScannerClass($this); + $returnMethod = false; + $methods = $this->getMethods(); + foreach ($methods as $method) { + if ($method->getName() === $methodNameOrInfoIndex) { + $returnMethod = $method; + break; + } + } - return $m; + return $returnMethod; } /** @@ -575,13 +820,7 @@ class ClassScanner implements ScannerInterface { $this->scan(); - foreach ($this->infos as $info) { - if ($info['type'] === 'method' && $info['name'] === $name) { - return true; - } - } - - return false; + return is_object($this->getMethod($name)); } public static function export() @@ -628,7 +867,14 @@ class ClassScanner implements ScannerInterface /* * MACRO creation */ - $MACRO_TOKEN_ADVANCE = function () use (&$tokens, &$tokenIndex, &$token, &$tokenType, &$tokenContent, &$tokenLine) { + $MACRO_TOKEN_ADVANCE = function () use ( + &$tokens, + &$tokenIndex, + &$token, + &$tokenType, + &$tokenContent, + &$tokenLine + ) { static $lastTokenArray = null; $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1; if (!isset($tokens[$tokenIndex])) { @@ -684,6 +930,7 @@ class ClassScanner implements ScannerInterface case T_ABSTRACT: case T_CLASS: case T_INTERFACE: + case T_TRAIT: // CLASS INFORMATION @@ -703,12 +950,22 @@ class ClassScanner implements ScannerInterface case T_FINAL: $this->isFinal = true; goto SCANNER_CLASS_INFO_CONTINUE; - //goto no break needed + // goto no break needed case T_ABSTRACT: $this->isAbstract = true; goto SCANNER_CLASS_INFO_CONTINUE; - //goto no break needed + // goto no break needed + + case T_TRAIT: + $this->isTrait = true; + $this->shortName = $tokens[$tokenIndex + 2][1]; + if ($this->nameInformation && $this->nameInformation->hasNamespace()) { + $this->name = $this->nameInformation->getNamespace() . '\\' . $this->shortName; + } else { + $this->name = $this->shortName; + } + goto SCANNER_CLASS_INFO_CONTINUE; case T_INTERFACE: $this->isInterface = true; @@ -815,7 +1072,121 @@ class ClassScanner implements ScannerInterface $MACRO_INFO_ADVANCE(); goto SCANNER_CLASS_BODY_CONTINUE; - //goto no break needed + // goto no break needed + + case T_USE: + // ensure php backwards compatibility + if (! defined('T_INSTEADOF')) { + define('T_INSTEADOF', 24000); + } + + $infos[$infoIndex] = array( + 'type' => 'use', + 'tokenStart' => $tokenIndex, + 'tokenEnd' => null, + 'lineStart' => $tokens[$tokenIndex][2], + 'lineEnd' => null, + 'name' => $namespace, + 'use_statements' => array(0 => null), + 'aliases' => array(0 => null), + ); + + $isOriginalName = array(T_STRING, T_DOUBLE_COLON); + $isAlias = array(T_STRING); + $isVisibility = array(T_PRIVATE, T_PROTECTED, T_PUBLIC, T_STATIC); + $isAliasType = array(T_AS, T_INSTEADOF); + $isValidAlias = array_merge($isOriginalName, $isAlias, $isVisibility, $isAliasType); + + $useStatementIndex = 0; + $aliasStatementIndex = 0; + $useAliasContext = false; + $useAsContext = false; + + // start processing with next token + if ($MACRO_TOKEN_ADVANCE() === false) { + goto SCANNER_END; + } + + SCANNER_USE_TOP: + + if ($tokenType === null) { + if ($tokenContent === "{") { + $useStatementIndex = 0; + $useAliasContext = true; + $infos[$infoIndex]['aliases'][$useStatementIndex] = array( + 'original' => null, + 'alias' => null, + 'visibility' => null, + 'type' => 'as' + ); + } elseif ($tokenContent === "}") { + $useAliasContext = false; + goto SCANNER_USE_END; + } elseif ($tokenContent === ';') { + if ($useAliasContext === true) { + $useStatementIndex++; + $useAsContext = false; + } + // only end if we aren't inside braces + if (false === $useAliasContext) { + goto SCANNER_USE_END; + } + } elseif ($tokenContent === ',') { + $useStatementIndex++; + $infos[$infoIndex]['use_statements'][$useStatementIndex] = ''; + } + } + + // ANALYZE + if ($tokenType !== null) { + // use context + if (false === $useAliasContext) { + if ($tokenType == T_NS_SEPARATOR || $tokenType == T_STRING) { + $infos[$infoIndex]['use_statements'][$useStatementIndex] .= $tokenContent; + } + } else { + if (in_array($tokenType, $isValidAlias) + && empty($infos[$infoIndex]['aliases'][$useStatementIndex]) + ) { + $infos[$infoIndex]['aliases'][$useStatementIndex] = array( + 'original' => null, + 'visibility' => null, + 'alias' => null, + 'type' => null + ); + } + + if ($tokenType == T_AS || $tokenType == T_INSTEADOF) { + $useAsContext = true; + $infos[$infoIndex]['aliases'][$useStatementIndex]['type'] = ($tokenType == T_INSTEADOF) + ? 'insteadof' + : 'as'; + goto SCANNER_USE_CONTINUE; + } + + // in alias context + if ($useAsContext === true && in_array($tokenType, $isAlias)) { + $infos[$infoIndex]['aliases'][$useStatementIndex]['alias'] = $tokenContent; + } elseif (in_array($tokenType, $isOriginalName)) { + $infos[$infoIndex]['aliases'][$useStatementIndex]['original'] .= $tokenContent; + } elseif (in_array($tokenType, $isVisibility)) { + //add whitespace (will trim later) + $infos[$infoIndex]['aliases'][$useStatementIndex]['visibility'] = $tokenType; + } + } + } + + SCANNER_USE_CONTINUE: + + if ($MACRO_TOKEN_ADVANCE() === false) { + goto SCANNER_END; + } + goto SCANNER_USE_TOP; + + SCANNER_USE_END: + + $MACRO_INFO_ADVANCE(); + goto SCANNER_CLASS_BODY_CONTINUE; case T_DOC_COMMENT: case T_PUBLIC: @@ -846,7 +1217,7 @@ class ClassScanner implements ScannerInterface $methodBodyStarted = true; $braceCount++; goto SCANNER_CLASS_BODY_MEMBER_CONTINUE; - //goto no break needed + // goto no break needed case '}': $braceCount--; goto SCANNER_CLASS_BODY_MEMBER_CONTINUE; @@ -882,20 +1253,20 @@ class ClassScanner implements ScannerInterface $infos[$infoIndex]['name'] = ltrim($tokenContent, '$'); } goto SCANNER_CLASS_BODY_MEMBER_CONTINUE; - //goto no break needed + // goto no break needed case T_FUNCTION: $memberContext = 'method'; $infos[$infoIndex]['type'] = 'method'; goto SCANNER_CLASS_BODY_MEMBER_CONTINUE; - //goto no break needed + // goto no break needed case T_STRING: if ($memberContext === 'method' && null === $infos[$infoIndex]['name']) { $infos[$infoIndex]['name'] = $tokenContent; } goto SCANNER_CLASS_BODY_MEMBER_CONTINUE; - //goto no break needed + // goto no break needed } SCANNER_CLASS_BODY_MEMBER_CONTINUE: @@ -910,7 +1281,7 @@ class ClassScanner implements ScannerInterface $memberContext = null; $MACRO_INFO_ADVANCE(); goto SCANNER_CLASS_BODY_CONTINUE; - //goto no break needed + // goto no break needed case null: // no type, is a string @@ -918,7 +1289,8 @@ class ClassScanner implements ScannerInterface case '{': $braceCount++; goto SCANNER_CLASS_BODY_CONTINUE; - //fall-through + // goto no break needed + case '}': $braceCount--; goto SCANNER_CLASS_BODY_CONTINUE; diff --git a/library/Zend/Code/Scanner/ConstantScanner.php b/library/Zend/Code/Scanner/ConstantScanner.php index c37c7a22..f2a81da5 100644 --- a/library/Zend/Code/Scanner/ConstantScanner.php +++ b/library/Zend/Code/Scanner/ConstantScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/DerivedClassScanner.php b/library/Zend/Code/Scanner/DerivedClassScanner.php index 6c8463ed..4790c738 100644 --- a/library/Zend/Code/Scanner/DerivedClassScanner.php +++ b/library/Zend/Code/Scanner/DerivedClassScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -123,7 +123,7 @@ class DerivedClassScanner extends ClassScanner */ public function hasParentClass() { - return ($this->classScanner->getParentClass() != null); + return ($this->classScanner->getParentClass() !== null); } /** diff --git a/library/Zend/Code/Scanner/DirectoryScanner.php b/library/Zend/Code/Scanner/DirectoryScanner.php index b1a0223d..33120ff7 100644 --- a/library/Zend/Code/Scanner/DirectoryScanner.php +++ b/library/Zend/Code/Scanner/DirectoryScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/DocBlockScanner.php b/library/Zend/Code/Scanner/DocBlockScanner.php index 3bb28ece..b367849b 100644 --- a/library/Zend/Code/Scanner/DocBlockScanner.php +++ b/library/Zend/Code/Scanner/DocBlockScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/FileScanner.php b/library/Zend/Code/Scanner/FileScanner.php index 64700f61..e462f727 100644 --- a/library/Zend/Code/Scanner/FileScanner.php +++ b/library/Zend/Code/Scanner/FileScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/FunctionScanner.php b/library/Zend/Code/Scanner/FunctionScanner.php index dbb082b2..d1fd2198 100644 --- a/library/Zend/Code/Scanner/FunctionScanner.php +++ b/library/Zend/Code/Scanner/FunctionScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/MethodScanner.php b/library/Zend/Code/Scanner/MethodScanner.php index e92b4d10..e2c299f6 100644 --- a/library/Zend/Code/Scanner/MethodScanner.php +++ b/library/Zend/Code/Scanner/MethodScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -251,6 +251,55 @@ class MethodScanner implements ScannerInterface return $this->isStatic; } + /** + * Override the given name for a method, this is necessary to + * support traits. + * + * @param $name + * @return self + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Visibility must be of T_PUBLIC, T_PRIVATE or T_PROTECTED + * Needed to support traits + * + * @param $visibility T_PUBLIC | T_PRIVATE | T_PROTECTED + * @return self + * @throws \Zend\Code\Exception + */ + public function setVisibility($visibility) + { + switch (strtolower($visibility)) { + case T_PUBLIC: + $this->isPublic = true; + $this->isPrivate = false; + $this->isProtected = false; + break; + + case T_PRIVATE: + $this->isPublic = false; + $this->isPrivate = true; + $this->isProtected = false; + break; + + case T_PROTECTED: + $this->isPublic = false; + $this->isPrivate = false; + $this->isProtected = true; + break; + + default: + throw new Exception("Invalid visibility argument passed to setVisibility."); + } + + return $this; + } + /** * @return int */ @@ -372,7 +421,14 @@ class MethodScanner implements ScannerInterface /* * MACRO creation */ - $MACRO_TOKEN_ADVANCE = function () use (&$tokens, &$tokenIndex, &$token, &$tokenType, &$tokenContent, &$tokenLine) { + $MACRO_TOKEN_ADVANCE = function () use ( + &$tokens, + &$tokenIndex, + &$token, + &$tokenType, + &$tokenContent, + &$tokenLine + ) { static $lastTokenArray = null; $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1; if (!isset($tokens[$tokenIndex])) { @@ -452,14 +508,12 @@ class MethodScanner implements ScannerInterface //goto (no break needed); case T_PROTECTED: - $this->isProtected = true; - $this->isPublic = false; + $this->setVisibility(T_PROTECTED); goto SCANNER_CONTINUE_SIGNATURE; //goto (no break needed); case T_PRIVATE: - $this->isPrivate = true; - $this->isPublic = false; + $this->setVisibility(T_PRIVATE); goto SCANNER_CONTINUE_SIGNATURE; //goto (no break needed); diff --git a/library/Zend/Code/Scanner/ParameterScanner.php b/library/Zend/Code/Scanner/ParameterScanner.php index ef15a16c..d6130060 100644 --- a/library/Zend/Code/Scanner/ParameterScanner.php +++ b/library/Zend/Code/Scanner/ParameterScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/PropertyScanner.php b/library/Zend/Code/Scanner/PropertyScanner.php index ce38b158..a5a08651 100644 --- a/library/Zend/Code/Scanner/PropertyScanner.php +++ b/library/Zend/Code/Scanner/PropertyScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/ScannerInterface.php b/library/Zend/Code/Scanner/ScannerInterface.php index 8acb04ec..f832edac 100644 --- a/library/Zend/Code/Scanner/ScannerInterface.php +++ b/library/Zend/Code/Scanner/ScannerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/TokenArrayScanner.php b/library/Zend/Code/Scanner/TokenArrayScanner.php index 72d27f6d..26c9d140 100644 --- a/library/Zend/Code/Scanner/TokenArrayScanner.php +++ b/library/Zend/Code/Scanner/TokenArrayScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -225,7 +225,7 @@ class TokenArrayScanner implements ScannerInterface } if (!isset($info)) { - return null; + return; } return new NameInformation($info['namespace'], $info['uses']); @@ -587,7 +587,7 @@ class TokenArrayScanner implements ScannerInterface || ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function')) ) { $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) { @@ -669,7 +669,7 @@ class TokenArrayScanner implements ScannerInterface } elseif (!is_string($namespace)) { throw new Exception\InvalidArgumentException('Invalid namespace provided'); } elseif (!in_array($namespace, $namespaces)) { - return null; + return; } $uses = array(); diff --git a/library/Zend/Code/Scanner/Util.php b/library/Zend/Code/Scanner/Util.php index e54ae0b8..dbd5bf7a 100644 --- a/library/Zend/Code/Scanner/Util.php +++ b/library/Zend/Code/Scanner/Util.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/Scanner/ValueScanner.php b/library/Zend/Code/Scanner/ValueScanner.php index d0826cc2..0a87cc01 100644 --- a/library/Zend/Code/Scanner/ValueScanner.php +++ b/library/Zend/Code/Scanner/ValueScanner.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Code/composer.json b/library/Zend/Code/composer.json index 5cc56413..8375dc74 100644 --- a/library/Zend/Code/composer.json +++ b/library/Zend/Code/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Code\\": "" } }, - "target-dir": "Zend/Code", "require": { "php": ">=5.3.23", "zendframework/zend-eventmanager": "self.version" @@ -27,8 +26,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Config/AbstractConfigFactory.php b/library/Zend/Config/AbstractConfigFactory.php index 20f04be0..b9c8766c 100644 --- a/library/Zend/Config/AbstractConfigFactory.php +++ b/library/Zend/Config/AbstractConfigFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -84,7 +84,7 @@ class AbstractConfigFactory implements ServiceManager\AbstractFactoryInterface $config = $serviceLocator->get('Config'); $this->configs[$requestedName] = $this->configs[$key] = $config[$key]; - return $config; + return $config[$key]; } /** @@ -167,6 +167,6 @@ class AbstractConfigFactory implements ServiceManager\AbstractFactoryInterface return $matches[1]; } } - return null; + return; } } diff --git a/library/Zend/Config/Config.php b/library/Zend/Config/Config.php index 17b67978..d2a0f000 100644 --- a/library/Zend/Config/Config.php +++ b/library/Zend/Config/Config.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,13 +30,6 @@ class Config implements Countable, Iterator, ArrayAccess */ protected $allowModifications; - /** - * Number of elements in configuration data. - * - * @var int - */ - protected $count; - /** * Data within the configuration. * @@ -71,8 +64,6 @@ class Config implements Countable, Iterator, ArrayAccess } else { $this->data[$key] = $value; } - - $this->count++; } } @@ -126,8 +117,6 @@ class Config implements Countable, Iterator, ArrayAccess } else { $this->data[$name] = $value; } - - $this->count++; } else { throw new Exception\RuntimeException('Config is read only'); } @@ -200,7 +189,6 @@ class Config implements Countable, Iterator, ArrayAccess throw new Exception\InvalidArgumentException('Config is read only'); } elseif (isset($this->data[$name])) { unset($this->data[$name]); - $this->count--; $this->skipNextIteration = true; } } @@ -213,7 +201,7 @@ class Config implements Countable, Iterator, ArrayAccess */ public function count() { - return $this->count; + return count($this->data); } /** @@ -360,8 +348,6 @@ class Config implements Countable, Iterator, ArrayAccess } else { $this->data[$key] = $value; } - - $this->count++; } } diff --git a/library/Zend/Config/Exception/ExceptionInterface.php b/library/Zend/Config/Exception/ExceptionInterface.php index d6e0240f..087bfe33 100644 --- a/library/Zend/Config/Exception/ExceptionInterface.php +++ b/library/Zend/Config/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Exception/InvalidArgumentException.php b/library/Zend/Config/Exception/InvalidArgumentException.php index 11e49110..0b9421eb 100644 --- a/library/Zend/Config/Exception/InvalidArgumentException.php +++ b/library/Zend/Config/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Exception/RuntimeException.php b/library/Zend/Config/Exception/RuntimeException.php index 6ed90a20..b9e145c9 100644 --- a/library/Zend/Config/Exception/RuntimeException.php +++ b/library/Zend/Config/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Factory.php b/library/Zend/Config/Factory.php index 9646bf0c..38256aca 100644 --- a/library/Zend/Config/Factory.php +++ b/library/Zend/Config/Factory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,10 +34,11 @@ class Factory * @var array */ protected static $extensions = array( - 'ini' => 'ini', - 'json' => 'json', - 'xml' => 'xml', - 'yaml' => 'yaml', + 'ini' => 'ini', + 'json' => 'json', + 'xml' => 'xml', + 'yaml' => 'yaml', + 'properties' => 'javaproperties', ); /** diff --git a/library/Zend/Config/Processor/Constant.php b/library/Zend/Config/Processor/Constant.php index 28f76b9a..069b8a8d 100644 --- a/library/Zend/Config/Processor/Constant.php +++ b/library/Zend/Config/Processor/Constant.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Processor/Filter.php b/library/Zend/Config/Processor/Filter.php index 99909f28..3a2b1cb9 100644 --- a/library/Zend/Config/Processor/Filter.php +++ b/library/Zend/Config/Processor/Filter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Processor/ProcessorInterface.php b/library/Zend/Config/Processor/ProcessorInterface.php index 6aa28e91..2ee94f20 100644 --- a/library/Zend/Config/Processor/ProcessorInterface.php +++ b/library/Zend/Config/Processor/ProcessorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Processor/Queue.php b/library/Zend/Config/Processor/Queue.php index 9a7905f2..2dddd42f 100644 --- a/library/Zend/Config/Processor/Queue.php +++ b/library/Zend/Config/Processor/Queue.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Processor/Token.php b/library/Zend/Config/Processor/Token.php index 2af2e1b3..096ad93f 100644 --- a/library/Zend/Config/Processor/Token.php +++ b/library/Zend/Config/Processor/Token.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -259,7 +259,7 @@ class Token implements ProcessorInterface if (!is_string($value) && (is_bool($value) || is_numeric($value))) { $stringVal = (string) $value; - $changedVal = strtr($value, $this->map); + $changedVal = strtr($stringVal, $this->map); // replace the value only if a string replacement occurred if ($changedVal !== $stringVal) { diff --git a/library/Zend/Config/Processor/Translator.php b/library/Zend/Config/Processor/Translator.php index 48c0985d..f33a891a 100644 --- a/library/Zend/Config/Processor/Translator.php +++ b/library/Zend/Config/Processor/Translator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Reader/Ini.php b/library/Zend/Config/Reader/Ini.php index 34366854..23e39703 100644 --- a/library/Zend/Config/Reader/Ini.php +++ b/library/Zend/Config/Reader/Ini.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -72,7 +72,7 @@ class Ini implements ReaderInterface $this->directory = dirname($filename); set_error_handler( - function ($error, $message = '', $file = '', $line = 0) use ($filename) { + function ($error, $message = '') use ($filename) { throw new Exception\RuntimeException( sprintf('Error reading INI file "%s": %s', $filename, $message), $error @@ -101,7 +101,7 @@ class Ini implements ReaderInterface $this->directory = null; set_error_handler( - function ($error, $message = '', $file = '', $line = 0) { + function ($error, $message = '') { throw new Exception\RuntimeException( sprintf('Error reading INI string: %s', $message), $error diff --git a/library/Zend/Config/Reader/JavaProperties.php b/library/Zend/Config/Reader/JavaProperties.php index 965bd3c8..24613d97 100644 --- a/library/Zend/Config/Reader/JavaProperties.php +++ b/library/Zend/Config/Reader/JavaProperties.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Reader/Json.php b/library/Zend/Config/Reader/Json.php index 407e2aaf..9e60d413 100644 --- a/library/Zend/Config/Reader/Json.php +++ b/library/Zend/Config/Reader/Json.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Reader/ReaderInterface.php b/library/Zend/Config/Reader/ReaderInterface.php index 0393fe05..1394943c 100644 --- a/library/Zend/Config/Reader/ReaderInterface.php +++ b/library/Zend/Config/Reader/ReaderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Reader/Xml.php b/library/Zend/Config/Reader/Xml.php index 348354fa..8ecb542c 100644 --- a/library/Zend/Config/Reader/Xml.php +++ b/library/Zend/Config/Reader/Xml.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -59,14 +59,13 @@ class Xml implements ReaderInterface $filename )); } - $this->reader = new XMLReader(); $this->reader->open($filename, null, LIBXML_XINCLUDE); $this->directory = dirname($filename); set_error_handler( - function ($error, $message = '', $file = '', $line = 0) use ($filename) { + function ($error, $message = '') use ($filename) { throw new Exception\RuntimeException( sprintf('Error reading XML file "%s": %s', $filename, $message), $error @@ -76,6 +75,7 @@ class Xml implements ReaderInterface ); $return = $this->process(); restore_error_handler(); + $this->reader->close(); return $return; } @@ -100,7 +100,7 @@ class Xml implements ReaderInterface $this->directory = null; set_error_handler( - function ($error, $message = '', $file = '', $line = 0) { + function ($error, $message = '') { throw new Exception\RuntimeException( sprintf('Error reading XML string: %s', $message), $error @@ -110,6 +110,7 @@ class Xml implements ReaderInterface ); $return = $this->process(); restore_error_handler(); + $this->reader->close(); return $return; } @@ -154,7 +155,7 @@ class Xml implements ReaderInterface $child = array('_' => $child); } - if (! is_array($child) ) { + if (! is_array($child)) { $child = array(); } diff --git a/library/Zend/Config/Reader/Yaml.php b/library/Zend/Config/Reader/Yaml.php index 709b8b8a..41f33946 100644 --- a/library/Zend/Config/Reader/Yaml.php +++ b/library/Zend/Config/Reader/Yaml.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/ReaderPluginManager.php b/library/Zend/Config/ReaderPluginManager.php index 3e74a564..4c350643 100644 --- a/library/Zend/Config/ReaderPluginManager.php +++ b/library/Zend/Config/ReaderPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,10 +19,11 @@ class ReaderPluginManager extends AbstractPluginManager * @var array */ protected $invokableClasses = array( - 'ini' => 'Zend\Config\Reader\Ini', - 'json' => 'Zend\Config\Reader\Json', - 'xml' => 'Zend\Config\Reader\Xml', - 'yaml' => 'Zend\Config\Reader\Yaml', + 'ini' => 'Zend\Config\Reader\Ini', + 'json' => 'Zend\Config\Reader\Json', + 'xml' => 'Zend\Config\Reader\Xml', + 'yaml' => 'Zend\Config\Reader\Yaml', + 'javaproperties' => 'Zend\Config\Reader\JavaProperties', ); /** diff --git a/library/Zend/Config/Writer/AbstractWriter.php b/library/Zend/Config/Writer/AbstractWriter.php index a02111f7..c9451ceb 100644 --- a/library/Zend/Config/Writer/AbstractWriter.php +++ b/library/Zend/Config/Writer/AbstractWriter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,7 +38,7 @@ abstract class AbstractWriter implements WriterInterface } set_error_handler( - function ($error, $message = '', $file = '', $line = 0) use ($filename) { + function ($error, $message = '') use ($filename) { throw new Exception\RuntimeException( sprintf('Error writing to "%s": %s', $filename, $message), $error diff --git a/library/Zend/Config/Writer/Ini.php b/library/Zend/Config/Writer/Ini.php index 9244f73e..0372d712 100644 --- a/library/Zend/Config/Writer/Ini.php +++ b/library/Zend/Config/Writer/Ini.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Writer/Json.php b/library/Zend/Config/Writer/Json.php index 04548495..78a68b3e 100644 --- a/library/Zend/Config/Writer/Json.php +++ b/library/Zend/Config/Writer/Json.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Writer/PhpArray.php b/library/Zend/Config/Writer/PhpArray.php index 352d1584..f7d72edc 100644 --- a/library/Zend/Config/Writer/PhpArray.php +++ b/library/Zend/Config/Writer/PhpArray.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -76,7 +76,7 @@ class PhpArray extends AbstractWriter } set_error_handler( - function ($error, $message = '', $file = '', $line = 0) use ($filename) { + function ($error, $message = '') use ($filename) { throw new Exception\RuntimeException( sprintf('Error writing to "%s": %s', $filename, $message), $error diff --git a/library/Zend/Config/Writer/WriterInterface.php b/library/Zend/Config/Writer/WriterInterface.php index afbecd10..92e821d4 100644 --- a/library/Zend/Config/Writer/WriterInterface.php +++ b/library/Zend/Config/Writer/WriterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/Writer/Xml.php b/library/Zend/Config/Writer/Xml.php index 0fd36b95..f388558f 100644 --- a/library/Zend/Config/Writer/Xml.php +++ b/library/Zend/Config/Writer/Xml.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -71,7 +71,7 @@ class Xml extends AbstractWriter if ($branchType === 'numeric') { if (is_array($value)) { - $this->addBranch($value, $value, $writer); + $this->addBranch($branchName, $value, $writer); } else { $writer->writeElement($branchName, (string) $value); } diff --git a/library/Zend/Config/Writer/Yaml.php b/library/Zend/Config/Writer/Yaml.php index f741ad67..e872d9b7 100644 --- a/library/Zend/Config/Writer/Yaml.php +++ b/library/Zend/Config/Writer/Yaml.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/WriterPluginManager.php b/library/Zend/Config/WriterPluginManager.php index c70e4415..9b031ffa 100644 --- a/library/Zend/Config/WriterPluginManager.php +++ b/library/Zend/Config/WriterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Config/composer.json b/library/Zend/Config/composer.json index 6ea7fa11..a2352582 100644 --- a/library/Zend/Config/composer.json +++ b/library/Zend/Config/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Config\\": "" } }, - "target-dir": "Zend/Config", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -31,8 +30,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Console/Adapter/AbstractAdapter.php b/library/Zend/Console/Adapter/AbstractAdapter.php index 49718034..bc73d91f 100644 --- a/library/Zend/Console/Adapter/AbstractAdapter.php +++ b/library/Zend/Console/Adapter/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -159,7 +159,6 @@ abstract class AbstractAdapter implements AdapterInterface // Determine charset and dimensions $charset = $this->getCharset(); $width = $x2 - $x1 + 1; - $height = $y2 - $y1 + 1; if ($width <= 2) { $lineStyle = static::LINE_NONE; diff --git a/library/Zend/Console/Adapter/AdapterInterface.php b/library/Zend/Console/Adapter/AdapterInterface.php index 45407b80..60f631ee 100644 --- a/library/Zend/Console/Adapter/AdapterInterface.php +++ b/library/Zend/Console/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Adapter/Posix.php b/library/Zend/Console/Adapter/Posix.php index 184e6ad9..5424892c 100644 --- a/library/Zend/Console/Adapter/Posix.php +++ b/library/Zend/Console/Adapter/Posix.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -402,6 +402,6 @@ class Posix extends AbstractAdapter return static::$ansiColorMap[$type][$color]; } - return null; + return; } } diff --git a/library/Zend/Console/Adapter/Virtual.php b/library/Zend/Console/Adapter/Virtual.php index f1b1eb95..752a26d2 100644 --- a/library/Zend/Console/Adapter/Virtual.php +++ b/library/Zend/Console/Adapter/Virtual.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Adapter/Windows.php b/library/Zend/Console/Adapter/Windows.php index c1bf8b73..83f5688d 100644 --- a/library/Zend/Console/Adapter/Windows.php +++ b/library/Zend/Console/Adapter/Windows.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -299,7 +299,7 @@ class Windows extends Virtual exec( 'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "' - . '[int[]] $mask = ' . join(',', $asciiMask) . ';' + . '[int[]] $mask = ' . implode(',', $asciiMask) . ';' . 'do {' . '$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\').VirtualKeyCode;' . '} while ( !($mask -contains $key) );' diff --git a/library/Zend/Console/Adapter/WindowsAnsicon.php b/library/Zend/Console/Adapter/WindowsAnsicon.php index 3519a9e2..1ffc728e 100644 --- a/library/Zend/Console/Adapter/WindowsAnsicon.php +++ b/library/Zend/Console/Adapter/WindowsAnsicon.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -165,7 +165,6 @@ class WindowsAnsicon extends Posix /** * Get charset currently in use by this adapter. * - * @return CharsetInterface $charset */ public function getCharset() @@ -259,7 +258,7 @@ class WindowsAnsicon extends Posix $result = $return = null; exec( 'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "' - . '[int[]] $mask = '.join(',', $asciiMask).';' + . '[int[]] $mask = '.implode(',', $asciiMask).';' . 'do {' . '$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\').VirtualKeyCode;' . '} while ( !($mask -contains $key) );' diff --git a/library/Zend/Console/Charset/Ascii.php b/library/Zend/Console/Charset/Ascii.php index 0cc32614..e6be409e 100644 --- a/library/Zend/Console/Charset/Ascii.php +++ b/library/Zend/Console/Charset/Ascii.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Charset/AsciiExtended.php b/library/Zend/Console/Charset/AsciiExtended.php index 2cdf07c2..7e4b6ac5 100644 --- a/library/Zend/Console/Charset/AsciiExtended.php +++ b/library/Zend/Console/Charset/AsciiExtended.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Charset/CharsetInterface.php b/library/Zend/Console/Charset/CharsetInterface.php index c64656c1..a34ccb44 100644 --- a/library/Zend/Console/Charset/CharsetInterface.php +++ b/library/Zend/Console/Charset/CharsetInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Charset/DECSG.php b/library/Zend/Console/Charset/DECSG.php index 958de421..2eada167 100644 --- a/library/Zend/Console/Charset/DECSG.php +++ b/library/Zend/Console/Charset/DECSG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Charset/Utf8.php b/library/Zend/Console/Charset/Utf8.php index 63ae157b..26a846b4 100644 --- a/library/Zend/Console/Charset/Utf8.php +++ b/library/Zend/Console/Charset/Utf8.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Charset/Utf8Heavy.php b/library/Zend/Console/Charset/Utf8Heavy.php index 6f968690..3f0b736a 100644 --- a/library/Zend/Console/Charset/Utf8Heavy.php +++ b/library/Zend/Console/Charset/Utf8Heavy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Color/Xterm256.php b/library/Zend/Console/Color/Xterm256.php index 8b367789..54870cd6 100644 --- a/library/Zend/Console/Color/Xterm256.php +++ b/library/Zend/Console/Color/Xterm256.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/ColorInterface.php b/library/Zend/Console/ColorInterface.php index b2cc770b..6fdc3a77 100644 --- a/library/Zend/Console/ColorInterface.php +++ b/library/Zend/Console/ColorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Console.php b/library/Zend/Console/Console.php index a3c70134..1c77b0b5 100644 --- a/library/Zend/Console/Console.php +++ b/library/Zend/Console/Console.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -170,7 +170,7 @@ abstract class Console { // Check if we are in a console environment if (!static::isConsole()) { - return null; + return; } // Check if we're on windows diff --git a/library/Zend/Console/Exception/BadMethodCallException.php b/library/Zend/Console/Exception/BadMethodCallException.php index aa650fc0..65daaf4b 100644 --- a/library/Zend/Console/Exception/BadMethodCallException.php +++ b/library/Zend/Console/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Exception/ExceptionInterface.php b/library/Zend/Console/Exception/ExceptionInterface.php index 70d8baf8..9830733a 100644 --- a/library/Zend/Console/Exception/ExceptionInterface.php +++ b/library/Zend/Console/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Exception/InvalidArgumentException.php b/library/Zend/Console/Exception/InvalidArgumentException.php index ad3b4e97..c930f223 100644 --- a/library/Zend/Console/Exception/InvalidArgumentException.php +++ b/library/Zend/Console/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Exception/RuntimeException.php b/library/Zend/Console/Exception/RuntimeException.php index 6551912c..de79db52 100644 --- a/library/Zend/Console/Exception/RuntimeException.php +++ b/library/Zend/Console/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Getopt.php b/library/Zend/Console/Getopt.php index 12493264..94ccac0e 100644 --- a/library/Zend/Console/Getopt.php +++ b/library/Zend/Console/Getopt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -514,7 +514,7 @@ class Getopt return $this->options[$flag]; } } - return null; + return; } /** diff --git a/library/Zend/Console/Prompt/AbstractPrompt.php b/library/Zend/Console/Prompt/AbstractPrompt.php index cd717cf3..225533ce 100644 --- a/library/Zend/Console/Prompt/AbstractPrompt.php +++ b/library/Zend/Console/Prompt/AbstractPrompt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Prompt/Char.php b/library/Zend/Console/Prompt/Char.php index b6c30514..a16e3fc6 100644 --- a/library/Zend/Console/Prompt/Char.php +++ b/library/Zend/Console/Prompt/Char.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Prompt/Checkbox.php b/library/Zend/Console/Prompt/Checkbox.php new file mode 100644 index 00000000..30bfabbb --- /dev/null +++ b/library/Zend/Console/Prompt/Checkbox.php @@ -0,0 +1,183 @@ +promptText = (string) $promptText; + + $this->setOptions($options); + + $this->echo = (bool) $echo; + + $this->ignoreCase = (bool) $ignoreCase; + } + + /** + * Show a list of options and prompt the user to select any number of them. + * + * @return array Checked options + */ + public function show() + { + $this->checkedOptions = array(); + $mask = $this->prepareMask(); + + do { + $this->showAvailableOptions(); + + $response = $this->readOption($mask); + + if ($this->echo) { + $this->showResponse($response); + } + + $this->checkOrUncheckOption($response); + } while ($response != "\r" && $response != "\n"); + + $this->lastResponse = $this->checkedOptions; + + return $this->checkedOptions; + } + + /** + * Shows the selected option to the screen + * @param string $response + */ + private function showResponse($response) + { + $console = $this->getConsole(); + if (isset($this->options[$response])) { + $console->writeLine($this->options[$response]); + } else { + $console->writeLine(); + } + } + + /** + * Check or uncheck an option + * + * @param string $response + */ + private function checkOrUncheckOption($response) + { + if ($response != "\r" && $response != "\n" && isset($this->options[$response])) { + $pos = array_search($this->options[$response], $this->checkedOptions); + if ($pos === false) { + $this->checkedOptions[] = $this->options[$response]; + } else { + array_splice($this->checkedOptions, $pos, 1); + } + } + } + + /** + * Generates a mask to to be used by the readChar method. + * + * @return string + */ + private function prepareMask() + { + $mask = implode("", array_keys($this->options)) . "\r\n"; + + /** + * Normalize the mask if case is irrelevant + */ + if (!$this->ignoreCase) { + return $mask; + } + + $mask = implode("", array_unique(str_split(strtolower($mask) . strtoupper($mask)))); + + return $mask; + } + + /** + * Reads a char from console. + * + * @param string $mask + * @return string + */ + private function readOption($mask) + { + /** + * Read char from console + */ + + return $this->getConsole()->readChar($mask); + } + + /** + * Shows the available options with checked and unchecked states + */ + private function showAvailableOptions() + { + $console = $this->getConsole(); + $console->writeLine($this->promptText); + foreach ($this->options as $k => $v) { + $console->writeLine(' ' . $k . ') ' . (in_array($v, $this->checkedOptions) ? '[X] ' : '[ ] ') . $v); + } + } + + /** + * Set allowed options + * + * @param array|\Traversable $options + * @throws Exception\InvalidArgumentException + */ + private function setOptions($options) + { + $options = ArrayUtils::iteratorToArray($options); + + if (empty($options)) { + throw new Exception\InvalidArgumentException('Please, specify at least one option'); + } + + $this->options = $options; + } +} diff --git a/library/Zend/Console/Prompt/Confirm.php b/library/Zend/Console/Prompt/Confirm.php index f660452b..67465790 100644 --- a/library/Zend/Console/Prompt/Confirm.php +++ b/library/Zend/Console/Prompt/Confirm.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Prompt/Line.php b/library/Zend/Console/Prompt/Line.php index 7a7427d7..3b2bb784 100644 --- a/library/Zend/Console/Prompt/Line.php +++ b/library/Zend/Console/Prompt/Line.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Prompt/Number.php b/library/Zend/Console/Prompt/Number.php index 8ce53300..7f096a7e 100644 --- a/library/Zend/Console/Prompt/Number.php +++ b/library/Zend/Console/Prompt/Number.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Prompt/Password.php b/library/Zend/Console/Prompt/Password.php new file mode 100644 index 00000000..ac96303e --- /dev/null +++ b/library/Zend/Console/Prompt/Password.php @@ -0,0 +1,70 @@ +promptText = (string) $promptText; + $this->echo = (bool) $echo; + } + + /** + * Show the prompt to user and return a string. + * + * @return string + */ + public function show() + { + $console = $this->getConsole(); + + $console->writeLine($this->promptText); + + $password = ''; + + /** + * Read characters from console + */ + while (true) { + $char = $console->readChar(); + + $console->clearLine(); + + if (PHP_EOL == $char) { + break; + } + + $password .= $char; + + if ($this->echo) { + $console->write(str_repeat('*', strlen($password))); + } + } + + return $password; + } +} diff --git a/library/Zend/Console/Prompt/PromptInterface.php b/library/Zend/Console/Prompt/PromptInterface.php index da1b6215..54e8615c 100644 --- a/library/Zend/Console/Prompt/PromptInterface.php +++ b/library/Zend/Console/Prompt/PromptInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Prompt/Select.php b/library/Zend/Console/Prompt/Select.php index 050a97d5..e31361cf 100644 --- a/library/Zend/Console/Prompt/Select.php +++ b/library/Zend/Console/Prompt/Select.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Request.php b/library/Zend/Console/Request.php index 57b48bb2..1c885c4f 100644 --- a/library/Zend/Console/Request.php +++ b/library/Zend/Console/Request.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/Response.php b/library/Zend/Console/Response.php index 75a06861..a96974d7 100644 --- a/library/Zend/Console/Response.php +++ b/library/Zend/Console/Response.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,6 +38,10 @@ class Response extends Message implements ResponseInterface */ public function setErrorLevel($errorLevel) { + if (is_string($errorLevel) && !ctype_digit($errorLevel)) { + return $this; + } + $this->setMetadata('errorLevel', $errorLevel); return $this; } diff --git a/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php b/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php index a5f8fae5..55a92e38 100644 --- a/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php +++ b/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -136,7 +136,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface * Optional literal param, i.e. * [something] */ - elseif (preg_match('/\G\[ *?(?P[a-zA-Z][a-zA-Z0-9\_\-]*?) *?\](?: +|$)/s', $def, $m, 0, $pos)) { + elseif (preg_match('/\G\[ *?(?P[a-zA-Z][a-zA-Z0-9\_\-\:]*?) *?\](?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'literal' => true, @@ -175,7 +175,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface * Mandatory literal param, i.e. * something */ - elseif (preg_match('/\G(?P[a-zA-Z][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { + elseif (preg_match('/\G(?P[a-zA-Z][a-zA-Z0-9\_\-\:]*?)(?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'literal' => true, @@ -372,7 +372,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface array_unique($options); // remove prefix - array_walk($options, function (&$val, $key) { + array_walk($options, function (&$val) { $val = ltrim($val, '-'); }); @@ -415,7 +415,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface array_unique($options); // remove prefix - array_walk($options, function (&$val, $key) { + array_walk($options, function (&$val) { $val = ltrim($val, '-'); }); @@ -510,7 +510,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface $alternativeAliases[] = '(?:' . implode('|', $this->getAliases($alternative)) . ')'; } - $regex .= join('|', $alternativeAliases); + $regex .= implode('|', $alternativeAliases); if ($part['hasValue']) { $regex .= ')(?:\=(?P.*?)$)?$/'; @@ -568,7 +568,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface * Drop out if that was a mandatory param */ if ($part['required']) { - return null; + return; } /* @@ -599,7 +599,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface array_splice($params, $x, 1); } else { // there are no more params available - return null; + return; } } @@ -611,7 +611,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface !preg_match($this->constraints[$part['name']], $value) ) { // constraint failed - return null; + return; } } @@ -653,7 +653,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface */ foreach ($params as $param) { if (preg_match('#^\-+#', $param)) { - return null; // there is an unrecognized flag + return; // there is an unrecognized flag } } @@ -668,7 +668,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface if (!isset($params[$argPos])) { if ($part['required']) { // cannot find required positional param - return null; + return; } else { // stop matching break; @@ -685,7 +685,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface (isset($part['alternatives']) && !in_array($value, $part['alternatives'])) || (!isset($part['alternatives']) && $value != $part['name']) ) { - return null; + return; } } @@ -697,7 +697,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface !preg_match($this->constraints[$part['name']], $value) ) { // constraint failed - return null; + return; } } @@ -734,7 +734,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface * Check if we have consumed all positional parameters */ if ($argPos < count($params)) { - return null; // there are extraneous params that were not consumed + return; // there are extraneous params that were not consumed } /* @@ -772,7 +772,7 @@ class DefaultRouteMatcher implements RouteMatcherInterface } if (!$valid) { - return null; + return; } return array_replace($this->defaults, $matches); diff --git a/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php b/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php index 62f463c3..b8d5bac7 100644 --- a/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php +++ b/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Console/composer.json b/library/Zend/Console/composer.json index 404a7c25..59cf8c38 100644 --- a/library/Zend/Console/composer.json +++ b/library/Zend/Console/composer.json @@ -8,19 +8,22 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Console\\": "" } }, - "target-dir": "Zend/Console", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, + "suggest": { + "zendframework/zend-validator": "To support DefaultRouteMatcher usage", + "zendframework/zend-filter": "To support DefaultRouteMatcher usage" + }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Crypt/BlockCipher.php b/library/Zend/Crypt/BlockCipher.php index 9b2a713e..1a6acb02 100644 --- a/library/Zend/Crypt/BlockCipher.php +++ b/library/Zend/Crypt/BlockCipher.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -461,7 +461,7 @@ class BlockCipher } $hmacSize = Hmac::getOutputSize($this->hash); $hmac = substr($data, 0, $hmacSize); - $ciphertext = substr($data, $hmacSize); + $ciphertext = substr($data, $hmacSize) ?: ''; if (!$this->binaryOutput) { $ciphertext = base64_decode($ciphertext); } diff --git a/library/Zend/Crypt/Exception/ExceptionInterface.php b/library/Zend/Crypt/Exception/ExceptionInterface.php index ef937436..0748e326 100644 --- a/library/Zend/Crypt/Exception/ExceptionInterface.php +++ b/library/Zend/Crypt/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Exception/InvalidArgumentException.php b/library/Zend/Crypt/Exception/InvalidArgumentException.php index 723593b3..2e64150b 100644 --- a/library/Zend/Crypt/Exception/InvalidArgumentException.php +++ b/library/Zend/Crypt/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Exception/RuntimeException.php b/library/Zend/Crypt/Exception/RuntimeException.php index 052566ff..037a448d 100644 --- a/library/Zend/Crypt/Exception/RuntimeException.php +++ b/library/Zend/Crypt/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/FileCipher.php b/library/Zend/Crypt/FileCipher.php new file mode 100644 index 00000000..da7dfca6 --- /dev/null +++ b/library/Zend/Crypt/FileCipher.php @@ -0,0 +1,374 @@ +cipher = new Mcrypt; + } + + /** + * Set the cipher object + * + * @param SymmetricInterface $cipher + */ + public function setCipher(SymmetricInterface $cipher) + { + $this->cipher = $cipher; + } + + /** + * Get the cipher object + * + * @return SymmetricInterface + */ + public function getCipher() + { + return $this->cipher; + } + + /** + * Set the number of iterations for Pbkdf2 + * + * @param int $num + */ + public function setKeyIteration($num) + { + $this->keyIteration = (int) $num; + } + + /** + * Get the number of iterations for Pbkdf2 + * + * @return int + */ + public function getKeyIteration() + { + return $this->keyIteration; + } + + /** + * Set the encryption/decryption key + * + * @param string $key + * @throws Exception\InvalidArgumentException + */ + public function setKey($key) + { + if (empty($key)) { + throw new Exception\InvalidArgumentException('The key cannot be empty'); + } + $this->key = (string) $key; + } + + /** + * Get the key + * + * @return string|null + */ + public function getKey() + { + return $this->key; + } + + /** + * Set algorithm of the symmetric cipher + * + * @param string $algo + */ + public function setCipherAlgorithm($algo) + { + $this->cipher->setAlgorithm($algo); + } + + /** + * Get the cipher algorithm + * + * @return string|bool + */ + public function getCipherAlgorithm() + { + return $this->cipher->getAlgorithm(); + } + + /** + * Get the supported algorithms of the symmetric cipher + * + * @return array + */ + public function getCipherSupportedAlgorithms() + { + return $this->cipher->getSupportedAlgorithms(); + } + + /** + * Set the hash algorithm for HMAC authentication + * + * @param string $hash + * @throws Exception\InvalidArgumentException + */ + public function setHashAlgorithm($hash) + { + if (!Hash::isSupported($hash)) { + throw new Exception\InvalidArgumentException( + "The specified hash algorithm '{$hash}' is not supported by Zend\Crypt\Hash" + ); + } + $this->hash = (string) $hash; + } + + /** + * Get the hash algorithm for HMAC authentication + * + * @return string + */ + public function getHashAlgorithm() + { + return $this->hash; + } + + /** + * Set the hash algorithm for the Pbkdf2 + * + * @param string $hash + * @throws Exception\InvalidArgumentException + */ + public function setPbkdf2HashAlgorithm($hash) + { + if (!Hash::isSupported($hash)) { + throw new Exception\InvalidArgumentException( + "The specified hash algorithm '{$hash}' is not supported by Zend\Crypt\Hash" + ); + } + $this->pbkdf2Hash = (string) $hash; + } + + /** + * Get the Pbkdf2 hash algorithm + * + * @return string + */ + public function getPbkdf2HashAlgorithm() + { + return $this->pbkdf2Hash; + } + + /** + * Encrypt then authenticate a file using HMAC + * + * @param string $fileIn + * @param string $fileOut + * @return bool + * @throws Exception\InvalidArgumentException + */ + public function encrypt($fileIn, $fileOut) + { + $this->checkFileInOut($fileIn, $fileOut); + if (empty($this->key)) { + throw new Exception\InvalidArgumentException('No key specified for encryption'); + } + + $read = fopen($fileIn, "r"); + $write = fopen($fileOut, "w"); + $iv = Rand::getBytes($this->cipher->getSaltSize(), true); + $keys = Pbkdf2::calc($this->getPbkdf2HashAlgorithm(), + $this->getKey(), + $iv, + $this->getKeyIteration(), + $this->cipher->getKeySize() * 2); + $hmac = ''; + $size = 0; + $tot = filesize($fileIn); + $padding = $this->cipher->getPadding(); + + $this->cipher->setKey(substr($keys, 0, $this->cipher->getKeySize())); + $this->cipher->setPadding(new Symmetric\Padding\NoPadding); + $this->cipher->setSalt($iv); + $this->cipher->setMode('cbc'); + + $hashAlgo = $this->getHashAlgorithm(); + $saltSize = $this->cipher->getSaltSize(); + $algorithm = $this->cipher->getAlgorithm(); + $keyHmac = substr($keys, $this->cipher->getKeySize()); + + while ($data = fread($read, self::BUFFER_SIZE)) { + $size += strlen($data); + // Padding if last block + if ($size == $tot) { + $this->cipher->setPadding($padding); + } + $result = $this->cipher->encrypt($data); + if ($size <= self::BUFFER_SIZE) { + // Write a placeholder for the HMAC and write the IV + fwrite($write, str_repeat(0, Hmac::getOutputSize($hashAlgo))); + } else { + $result = substr($result, $saltSize); + } + $hmac = Hmac::compute($keyHmac, + $hashAlgo, + $algorithm . $hmac . $result); + $this->cipher->setSalt(substr($result, -1 * $saltSize)); + if (fwrite($write, $result) !== strlen($result)) { + return false; + } + } + $result = true; + // write the HMAC at the beginning of the file + fseek($write, 0); + if (fwrite($write, $hmac) !== strlen($hmac)) { + $result = false; + } + fclose($write); + fclose($read); + + return $result; + } + + /** + * Decrypt a file + * + * @param string $fileIn + * @param string $fileOut + * @param bool $compress + * @return bool + * @throws Exception\InvalidArgumentException + */ + public function decrypt($fileIn, $fileOut) + { + $this->checkFileInOut($fileIn, $fileOut); + if (empty($this->key)) { + throw new Exception\InvalidArgumentException('No key specified for decryption'); + } + + $read = fopen($fileIn, "r"); + $write = fopen($fileOut, "w"); + $hmacRead = fread($read, Hmac::getOutputSize($this->getHashAlgorithm())); + $iv = fread($read, $this->cipher->getSaltSize()); + $tot = filesize($fileIn); + $hmac = $iv; + $size = strlen($iv) + strlen($hmacRead); + $keys = Pbkdf2::calc($this->getPbkdf2HashAlgorithm(), + $this->getKey(), + $iv, + $this->getKeyIteration(), + $this->cipher->getKeySize() * 2); + $padding = $this->cipher->getPadding(); + $this->cipher->setPadding(new Symmetric\Padding\NoPadding); + $this->cipher->setKey(substr($keys, 0, $this->cipher->getKeySize())); + $this->cipher->setMode('cbc'); + + $blockSize = $this->cipher->getBlockSize(); + $hashAlgo = $this->getHashAlgorithm(); + $algorithm = $this->cipher->getAlgorithm(); + $saltSize = $this->cipher->getSaltSize(); + $keyHmac = substr($keys, $this->cipher->getKeySize()); + + while ($data = fread($read, self::BUFFER_SIZE)) { + $size += strlen($data); + // Unpadding if last block + if ($size + $blockSize >= $tot) { + $this->cipher->setPadding($padding); + $data .= fread($read, $blockSize); + } + $result = $this->cipher->decrypt($iv . $data); + $hmac = Hmac::compute($keyHmac, + $hashAlgo, + $algorithm . $hmac . $data); + $iv = substr($data, -1 * $saltSize); + if (fwrite($write, $result) !== strlen($result)) { + return false; + } + } + fclose($write); + fclose($read); + + // check for data integrity + if (!Utils::compareStrings($hmac, $hmacRead)) { + unlink($fileOut); + return false; + } + + return true; + } + + /** + * Check that input file exists and output file dont + * + * @param string $fileIn + * @param string $fileOut + * @throws Exception\InvalidArgumentException + */ + protected function checkFileInOut($fileIn, $fileOut) + { + if (!file_exists($fileIn)) { + throw new Exception\InvalidArgumentException(sprintf( + "I cannot open the %s file", $fileIn + )); + } + if (file_exists($fileOut)) { + throw new Exception\InvalidArgumentException(sprintf( + "The file %s already exists", $fileOut + )); + } + } +} diff --git a/library/Zend/Crypt/Hash.php b/library/Zend/Crypt/Hash.php index ccbd15d3..826cc888 100644 --- a/library/Zend/Crypt/Hash.php +++ b/library/Zend/Crypt/Hash.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Hmac.php b/library/Zend/Crypt/Hmac.php index decde91b..5e3ee975 100644 --- a/library/Zend/Crypt/Hmac.php +++ b/library/Zend/Crypt/Hmac.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php b/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php index e87602e9..b513962a 100644 --- a/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php +++ b/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Key/Derivation/Exception/InvalidArgumentException.php b/library/Zend/Crypt/Key/Derivation/Exception/InvalidArgumentException.php index 02f3b5f5..a82f9e3b 100644 --- a/library/Zend/Crypt/Key/Derivation/Exception/InvalidArgumentException.php +++ b/library/Zend/Crypt/Key/Derivation/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Key/Derivation/Exception/RuntimeException.php b/library/Zend/Crypt/Key/Derivation/Exception/RuntimeException.php index e3590385..85b8c172 100644 --- a/library/Zend/Crypt/Key/Derivation/Exception/RuntimeException.php +++ b/library/Zend/Crypt/Key/Derivation/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Key/Derivation/Pbkdf2.php b/library/Zend/Crypt/Key/Derivation/Pbkdf2.php index 8d216d64..af3835a4 100644 --- a/library/Zend/Crypt/Key/Derivation/Pbkdf2.php +++ b/library/Zend/Crypt/Key/Derivation/Pbkdf2.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Key/Derivation/SaltedS2k.php b/library/Zend/Crypt/Key/Derivation/SaltedS2k.php index 763d2f53..c3a71e16 100644 --- a/library/Zend/Crypt/Key/Derivation/SaltedS2k.php +++ b/library/Zend/Crypt/Key/Derivation/SaltedS2k.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,8 @@ namespace Zend\Crypt\Key\Derivation; */ class SaltedS2k { - protected static $supportedMhashAlgos = array ( + protected static $supportedMhashAlgos = array( + 'adler32' => MHASH_ADLER32, 'md2' => MHASH_MD2, 'md4' => MHASH_MD4, 'md5' => MHASH_MD5, @@ -26,13 +27,21 @@ class SaltedS2k 'ripemd128' => MHASH_RIPEMD128, 'ripemd256' => MHASH_RIPEMD256, 'ripemd320' => MHASH_RIPEMD320, - 'haval128,3' => MHASH_HAVAL128, - 'haval160,3' => MHASH_HAVAL160, - 'haval192,3' => MHASH_HAVAL192, - 'haval224,3' => MHASH_HAVAL224, - 'haval256,3' => MHASH_HAVAL256, - 'tiger128,3' => MHASH_TIGER128, - 'riger160,3' => MHASH_TIGER160, + 'haval128,3' => MHASH_HAVAL128, // @deprecated use haval128 instead + 'haval128' => MHASH_HAVAL128, + 'haval160,3' => MHASH_HAVAL160, // @deprecated use haval160 instead + 'haval160' => MHASH_HAVAL160, + 'haval192,3' => MHASH_HAVAL192, // @deprecated use haval192 instead + 'haval192' => MHASH_HAVAL192, + 'haval224,3' => MHASH_HAVAL224, // @deprecated use haval224 instead + 'haval224' => MHASH_HAVAL224, + 'haval256,3' => MHASH_HAVAL256, // @deprecated use haval256 instead + 'haval256' => MHASH_HAVAL256, + 'tiger' => MHASH_TIGER, + 'tiger128,3' => MHASH_TIGER128, // @deprecated use tiger128 instead + 'tiger128' => MHASH_TIGER128, + 'tiger160,3' => MHASH_TIGER160, // @deprecated use tiger160 instead + 'tiger160' => MHASH_TIGER160, 'whirpool' => MHASH_WHIRLPOOL, 'snefru256' => MHASH_SNEFRU256, 'gost' => MHASH_GOST, diff --git a/library/Zend/Crypt/Key/Derivation/Scrypt.php b/library/Zend/Crypt/Key/Derivation/Scrypt.php index da2a7836..fe8a5397 100644 --- a/library/Zend/Crypt/Key/Derivation/Scrypt.php +++ b/library/Zend/Crypt/Key/Derivation/Scrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -315,7 +315,7 @@ abstract class Scrypt if (PHP_INT_SIZE === 8) { $v = 'V'; } - list(,$n) = unpack($v, substr($b, -64)); + list(, $n) = unpack($v, substr($b, -64)); return $n; } diff --git a/library/Zend/Crypt/Password/Apache.php b/library/Zend/Crypt/Password/Apache.php index d9359827..7a0cd12f 100644 --- a/library/Zend/Crypt/Password/Apache.php +++ b/library/Zend/Crypt/Password/Apache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,6 +11,7 @@ namespace Zend\Crypt\Password; use Traversable; use Zend\Math\Rand; +use Zend\Crypt\Utils; /** * Apache password authentication @@ -126,8 +127,9 @@ class Apache implements PasswordInterface { if (substr($hash, 0, 5) === '{SHA}') { $hash2 = '{SHA}' . base64_encode(sha1($password, true)); - return ($hash === $hash2); + return Utils::compareStrings($hash, $hash2); } + if (substr($hash, 0, 6) === '$apr1$') { $token = explode('$', $hash); if (empty($token[2])) { @@ -136,18 +138,22 @@ class Apache implements PasswordInterface ); } $hash2 = $this->apr1Md5($password, $token[2]); - return ($hash === $hash2); + return Utils::compareStrings($hash, $hash2); } - if (strlen($hash) > 13) { // digest + + $bcryptPattern = '/\$2[ay]?\$[0-9]{2}\$[' . addcslashes(static::BASE64, '+/') . '\.]{53}/'; + + if (strlen($hash) > 13 && ! preg_match($bcryptPattern, $hash)) { // digest if (empty($this->userName) || empty($this->authName)) { throw new Exception\RuntimeException( 'You must specify UserName and AuthName (realm) to verify the digest' ); } $hash2 = md5($this->userName . ':' . $this->authName . ':' .$password); - return ($hash === $hash2); + return Utils::compareStrings($hash, $hash2); } - return (crypt($password, $hash) === $hash); + + return Utils::compareStrings($hash, crypt($password, $hash)); } /** diff --git a/library/Zend/Crypt/Password/Bcrypt.php b/library/Zend/Crypt/Password/Bcrypt.php index b489ddd4..a5562744 100644 --- a/library/Zend/Crypt/Password/Bcrypt.php +++ b/library/Zend/Crypt/Password/Bcrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,6 +12,7 @@ namespace Zend\Crypt\Password; use Traversable; use Zend\Math\Rand; use Zend\Stdlib\ArrayUtils; +use Zend\Crypt\Utils; /** * Bcrypt algorithm using crypt() function of PHP @@ -34,11 +35,6 @@ class Bcrypt implements PasswordInterface */ protected $salt; - /** - * @var bool - */ - protected $backwardCompatibility = false; - /** * Constructor * @@ -87,19 +83,7 @@ class Bcrypt implements PasswordInterface * Check for security flaw in the bcrypt implementation used by crypt() * @see http://php.net/security/crypt_blowfish.php */ - if ((PHP_VERSION_ID >= 50307) && !$this->backwardCompatibility) { - $prefix = '$2y$'; - } else { - $prefix = '$2a$'; - // check if the password contains 8-bit character - if (preg_match('/[\x80-\xFF]/', $password)) { - throw new Exception\RuntimeException( - 'The bcrypt implementation used by PHP can contain a security flaw ' . - 'using password with 8-bit character. ' . - 'We suggest to upgrade to PHP 5.3.7+ or use passwords with only 7-bit characters' - ); - } - } + $prefix = '$2y$'; $hash = crypt($password, $prefix . $this->cost . '$' . $salt64); if (strlen($hash) < 13) { throw new Exception\RuntimeException('Error during the bcrypt generation'); @@ -118,10 +102,7 @@ class Bcrypt implements PasswordInterface public function verify($password, $hash) { $result = crypt($password, $hash); - if ($result === $hash) { - return true; - } - return false; + return Utils::compareStrings($hash, $result); } /** @@ -186,22 +167,23 @@ class Bcrypt implements PasswordInterface /** * Set the backward compatibility $2a$ instead of $2y$ for PHP 5.3.7+ * + * @deprecated since zf 2.3 requires PHP >= 5.3.23 * @param bool $value * @return Bcrypt */ public function setBackwardCompatibility($value) { - $this->backwardCompatibility = (bool) $value; return $this; } /** * Get the backward compatibility * + * @deprecated since zf 2.3 requires PHP >= 5.3.23 * @return bool */ public function getBackwardCompatibility() { - return $this->backwardCompatibility; + return false; } } diff --git a/library/Zend/Crypt/Password/BcryptSha.php b/library/Zend/Crypt/Password/BcryptSha.php new file mode 100644 index 00000000..b33a7be4 --- /dev/null +++ b/library/Zend/Crypt/Password/BcryptSha.php @@ -0,0 +1,45 @@ +72 characters. + */ +class BcryptSha extends Bcrypt +{ + + /** + * BcryptSha + * + * @param string $password + * @throws Exception\RuntimeException + * @return string + */ + public function create($password) + { + return parent::create(Hash::compute('sha256', $password)); + } + + /** + * Verify if a password is correct against a hash value + * + * @param string $password + * @param string $hash + * @throws Exception\RuntimeException when the hash is unable to be processed + * @return bool + */ + public function verify($password, $hash) + { + return parent::verify(Hash::compute('sha256', $password), $hash); + } +} diff --git a/library/Zend/Crypt/Password/Exception/ExceptionInterface.php b/library/Zend/Crypt/Password/Exception/ExceptionInterface.php index 5c65fb78..8a3f7229 100644 --- a/library/Zend/Crypt/Password/Exception/ExceptionInterface.php +++ b/library/Zend/Crypt/Password/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Password/Exception/InvalidArgumentException.php b/library/Zend/Crypt/Password/Exception/InvalidArgumentException.php index 97f1a9d1..3011eb38 100644 --- a/library/Zend/Crypt/Password/Exception/InvalidArgumentException.php +++ b/library/Zend/Crypt/Password/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Password/Exception/RuntimeException.php b/library/Zend/Crypt/Password/Exception/RuntimeException.php index 57f2976c..9adcf0d4 100644 --- a/library/Zend/Crypt/Password/Exception/RuntimeException.php +++ b/library/Zend/Crypt/Password/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Password/PasswordInterface.php b/library/Zend/Crypt/Password/PasswordInterface.php index 1f7683ea..ff106d93 100644 --- a/library/Zend/Crypt/Password/PasswordInterface.php +++ b/library/Zend/Crypt/Password/PasswordInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/PublicKey/DiffieHellman.php b/library/Zend/Crypt/PublicKey/DiffieHellman.php index 4d5615fc..deeb5bf2 100644 --- a/library/Zend/Crypt/PublicKey/DiffieHellman.php +++ b/library/Zend/Crypt/PublicKey/DiffieHellman.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -414,14 +414,11 @@ class DiffieHellman switch ($outputFormat) { case self::FORMAT_BINARY: return $this->math->intToBin($number); - break; case self::FORMAT_BTWOC: return $this->math->intToBin($number, true); - break; case self::FORMAT_NUMBER: default: return $number; - break; } } diff --git a/library/Zend/Crypt/PublicKey/Rsa.php b/library/Zend/Crypt/PublicKey/Rsa.php index 44faaa7d..1673b2fa 100644 --- a/library/Zend/Crypt/PublicKey/Rsa.php +++ b/library/Zend/Crypt/PublicKey/Rsa.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -246,10 +246,11 @@ class Rsa * * @param string $data * @param Rsa\AbstractKey $key + * @param null|int $padding An OPENSSL_*_PADDING constant value. * @return string * @throws Rsa\Exception\InvalidArgumentException */ - public function encrypt($data, Rsa\AbstractKey $key = null) + public function encrypt($data, Rsa\AbstractKey $key = null, $padding = null) { if (null === $key) { $key = $this->options->getPublicKey(); @@ -259,7 +260,11 @@ class Rsa throw new Exception\InvalidArgumentException('No key specified for the decryption'); } - $encrypted = $key->encrypt($data); + if (null === $padding) { + $encrypted = $key->encrypt($data); + } else { + $encrypted = $key->encrypt($data, $padding); + } if ($this->options->getBinaryOutput()) { return $encrypted; @@ -279,6 +284,7 @@ class Rsa * @param string $data * @param Rsa\AbstractKey $key * @param int $mode Input encoding + * @param null|int $padding An OPENSSL_*_PADDING constant value. * @return string * @throws Rsa\Exception\InvalidArgumentException * @see Rsa::MODE_AUTO @@ -288,7 +294,8 @@ class Rsa public function decrypt( $data, Rsa\AbstractKey $key = null, - $mode = self::MODE_AUTO + $mode = self::MODE_AUTO, + $padding = null ) { if (null === $key) { $key = $this->options->getPrivateKey(); @@ -314,7 +321,10 @@ class Rsa break; } - return $key->decrypt($data); + if (null === $padding) { + return $key->decrypt($data); + } + return $key->decrypt($data, $padding); } /** diff --git a/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php b/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php index 5051c771..b87e84b1 100644 --- a/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php +++ b/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php b/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php index ccaad1b3..7c8efca2 100644 --- a/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php +++ b/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/PublicKey/Rsa/Exception/InvalidArgumentException.php b/library/Zend/Crypt/PublicKey/Rsa/Exception/InvalidArgumentException.php index 857a1525..ede57788 100644 --- a/library/Zend/Crypt/PublicKey/Rsa/Exception/InvalidArgumentException.php +++ b/library/Zend/Crypt/PublicKey/Rsa/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/PublicKey/Rsa/Exception/RuntimeException.php b/library/Zend/Crypt/PublicKey/Rsa/Exception/RuntimeException.php index bdbf10bf..09497448 100644 --- a/library/Zend/Crypt/PublicKey/Rsa/Exception/RuntimeException.php +++ b/library/Zend/Crypt/PublicKey/Rsa/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/PublicKey/Rsa/PrivateKey.php b/library/Zend/Crypt/PublicKey/Rsa/PrivateKey.php index 54ebd5f5..df8f259b 100644 --- a/library/Zend/Crypt/PublicKey/Rsa/PrivateKey.php +++ b/library/Zend/Crypt/PublicKey/Rsa/PrivateKey.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -79,18 +79,19 @@ class PrivateKey extends AbstractKey * Encrypt using this key * * @param string $data + * @param integer $padding * @return string * @throws Exception\RuntimeException * @throws Exception\InvalidArgumentException */ - public function encrypt($data) + public function encrypt($data, $padding = OPENSSL_PKCS1_PADDING) { if (empty($data)) { throw new Exception\InvalidArgumentException('The data to encrypt cannot be empty'); } $encrypted = ''; - $result = openssl_private_encrypt($data, $encrypted, $this->getOpensslKeyResource()); + $result = openssl_private_encrypt($data, $encrypted, $this->getOpensslKeyResource(), $padding); if (false === $result) { throw new Exception\RuntimeException( 'Can not encrypt; openssl ' . openssl_error_string() @@ -102,13 +103,18 @@ class PrivateKey extends AbstractKey /** * Decrypt using this key + * Starting in 2.4.9/2.5.2, we changed the default padding to + * OPENSSL_PKCS1_OAEP_PADDING to prevent Bleichenbacher's chosen-ciphertext + * attack. * + * @see http://archiv.infsec.ethz.ch/education/fs08/secsem/bleichenbacher98.pdf * @param string $data + * @param integer $padding * @return string * @throws Exception\RuntimeException * @throws Exception\InvalidArgumentException */ - public function decrypt($data) + public function decrypt($data, $padding = OPENSSL_PKCS1_OAEP_PADDING) { if (!is_string($data)) { throw new Exception\InvalidArgumentException('The data to decrypt must be a string'); @@ -118,7 +124,7 @@ class PrivateKey extends AbstractKey } $decrypted = ''; - $result = openssl_private_decrypt($data, $decrypted, $this->getOpensslKeyResource()); + $result = openssl_private_decrypt($data, $decrypted, $this->getOpensslKeyResource(), $padding); if (false === $result) { throw new Exception\RuntimeException( 'Can not decrypt; openssl ' . openssl_error_string() diff --git a/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php b/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php index d73078d2..ca658c9f 100644 --- a/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php +++ b/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -68,19 +68,25 @@ class PublicKey extends AbstractKey /** * Encrypt using this key * + * Starting in 2.4.9/2.5.2, we changed the default padding to + * OPENSSL_PKCS1_OAEP_PADDING to prevent Bleichenbacher's chosen-ciphertext + * attack. + * + * @see http://archiv.infsec.ethz.ch/education/fs08/secsem/bleichenbacher98.pdf * @param string $data + * @param string $padding * @throws Exception\InvalidArgumentException * @throws Exception\RuntimeException * @return string */ - public function encrypt($data) + public function encrypt($data, $padding = OPENSSL_PKCS1_OAEP_PADDING) { if (empty($data)) { throw new Exception\InvalidArgumentException('The data to encrypt cannot be empty'); } $encrypted = ''; - $result = openssl_public_encrypt($data, $encrypted, $this->getOpensslKeyResource()); + $result = openssl_public_encrypt($data, $encrypted, $this->getOpensslKeyResource(), $padding); if (false === $result) { throw new Exception\RuntimeException( 'Can not encrypt; openssl ' . openssl_error_string() @@ -94,11 +100,12 @@ class PublicKey extends AbstractKey * Decrypt using this key * * @param string $data + * @param string $padding * @throws Exception\InvalidArgumentException * @throws Exception\RuntimeException * @return string */ - public function decrypt($data) + public function decrypt($data, $padding = OPENSSL_PKCS1_PADDING) { if (!is_string($data)) { throw new Exception\InvalidArgumentException('The data to decrypt must be a string'); @@ -108,7 +115,7 @@ class PublicKey extends AbstractKey } $decrypted = ''; - $result = openssl_public_decrypt($data, $decrypted, $this->getOpensslKeyResource()); + $result = openssl_public_decrypt($data, $decrypted, $this->getOpensslKeyResource(), $padding); if (false === $result) { throw new Exception\RuntimeException( 'Can not decrypt; openssl ' . openssl_error_string() diff --git a/library/Zend/Crypt/PublicKey/RsaOptions.php b/library/Zend/Crypt/PublicKey/RsaOptions.php index 54cd7c55..b8aca757 100644 --- a/library/Zend/Crypt/PublicKey/RsaOptions.php +++ b/library/Zend/Crypt/PublicKey/RsaOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php b/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php index 7e62c51b..e78ede75 100644 --- a/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php +++ b/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Symmetric/Exception/InvalidArgumentException.php b/library/Zend/Crypt/Symmetric/Exception/InvalidArgumentException.php index fa85f678..dcf71f99 100644 --- a/library/Zend/Crypt/Symmetric/Exception/InvalidArgumentException.php +++ b/library/Zend/Crypt/Symmetric/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Symmetric/Exception/RuntimeException.php b/library/Zend/Crypt/Symmetric/Exception/RuntimeException.php index 5dd9386a..1ce2b0c6 100644 --- a/library/Zend/Crypt/Symmetric/Exception/RuntimeException.php +++ b/library/Zend/Crypt/Symmetric/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Crypt/Symmetric/Mcrypt.php b/library/Zend/Crypt/Symmetric/Mcrypt.php index acdb26a1..44178afe 100644 --- a/library/Zend/Crypt/Symmetric/Mcrypt.php +++ b/library/Zend/Crypt/Symmetric/Mcrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -258,7 +258,7 @@ class Mcrypt implements SymmetricInterface public function getKey() { if (empty($this->key)) { - return null; + return; } return substr($this->key, 0, $this->getKeySize()); } @@ -433,7 +433,7 @@ class Mcrypt implements SymmetricInterface public function getSalt() { if (empty($this->iv)) { - return null; + return; } if (strlen($this->iv) < $this->getSaltSize()) { throw new Exception\RuntimeException( diff --git a/library/Zend/Crypt/Symmetric/Padding/NoPadding.php b/library/Zend/Crypt/Symmetric/Padding/NoPadding.php new file mode 100644 index 00000000..afbee052 --- /dev/null +++ b/library/Zend/Crypt/Symmetric/Padding/NoPadding.php @@ -0,0 +1,39 @@ +=5.3.23", "zendframework/zend-math": "self.version", @@ -24,8 +23,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Db/Adapter/Adapter.php b/library/Zend/Db/Adapter/Adapter.php index b4c7edff..3771b94c 100644 --- a/library/Zend/Db/Adapter/Adapter.php +++ b/library/Zend/Db/Adapter/Adapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -87,7 +87,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface $driver->checkEnvironment(); $this->driver = $driver; - if ($platform == null) { + if ($platform === null) { $platform = $this->createPlatform($parameters); } @@ -128,7 +128,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface */ 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.'); } return $this->driver; @@ -160,6 +160,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface * * @param string $sql * @param string|array|ParameterContainer $parametersOrQueryMode + * @param \Zend\Db\ResultSet\ResultSetInterface $resultPrototype * @throws Exception\InvalidArgumentException * @return Driver\StatementInterface|ResultSet\ResultSet */ @@ -208,7 +209,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface public function createStatement($initialSql = null, $initialParameters = null) { $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())); } $statement->setParameterContainer($initialParameters); diff --git a/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php b/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php index 42800a2c..b40865e7 100644 --- a/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php +++ b/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/AdapterAwareInterface.php b/library/Zend/Db/Adapter/AdapterAwareInterface.php index 95443a9a..3013fd4c 100644 --- a/library/Zend/Db/Adapter/AdapterAwareInterface.php +++ b/library/Zend/Db/Adapter/AdapterAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/AdapterAwareTrait.php b/library/Zend/Db/Adapter/AdapterAwareTrait.php index 3df7b36b..93e99856 100644 --- a/library/Zend/Db/Adapter/AdapterAwareTrait.php +++ b/library/Zend/Db/Adapter/AdapterAwareTrait.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter; - trait AdapterAwareTrait { /** diff --git a/library/Zend/Db/Adapter/AdapterInterface.php b/library/Zend/Db/Adapter/AdapterInterface.php index 57a6a737..a9310671 100644 --- a/library/Zend/Db/Adapter/AdapterInterface.php +++ b/library/Zend/Db/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/AdapterServiceFactory.php b/library/Zend/Db/Adapter/AdapterServiceFactory.php index f0619ad8..2f418ce6 100644 --- a/library/Zend/Db/Adapter/AdapterServiceFactory.php +++ b/library/Zend/Db/Adapter/AdapterServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/AbstractConnection.php b/library/Zend/Db/Adapter/Driver/AbstractConnection.php new file mode 100644 index 00000000..09cb075d --- /dev/null +++ b/library/Zend/Db/Adapter/Driver/AbstractConnection.php @@ -0,0 +1,135 @@ +isConnected()) { + $this->resource = null; + } + + return $this; + } + + /** + * Get connection parameters + * + * @return array + */ + public function getConnectionParameters() + { + return $this->connectionParameters; + } + + /** + * Get driver name + * + * @return null|string + */ + public function getDriverName() + { + return $this->driverName; + } + + /** + * @return null|ProfilerInterface + */ + public function getProfiler() + { + return $this->profiler; + } + + /** + * {@inheritDoc} + * + * @return resource + */ + public function getResource() + { + if (!$this->isConnected()) { + $this->connect(); + } + + return $this->resource; + } + + /** + * Checks whether the connection is in transaction state. + * + * @return boolean + */ + public function inTransaction() + { + return $this->inTransaction; + } + + /** + * @param array $connectionParameters + * @return self + */ + public function setConnectionParameters(array $connectionParameters) + { + $this->connectionParameters = $connectionParameters; + + return $this; + } + + /** + * {@inheritDoc} + * + * @return self + */ + public function setProfiler(ProfilerInterface $profiler) + { + $this->profiler = $profiler; + + return $this; + } +} diff --git a/library/Zend/Db/Adapter/Driver/ConnectionInterface.php b/library/Zend/Db/Adapter/Driver/ConnectionInterface.php index 2e27fd68..0ac8a399 100644 --- a/library/Zend/Db/Adapter/Driver/ConnectionInterface.php +++ b/library/Zend/Db/Adapter/Driver/ConnectionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/DriverInterface.php b/library/Zend/Db/Adapter/Driver/DriverInterface.php index 98bbc835..3bddb193 100644 --- a/library/Zend/Db/Adapter/Driver/DriverInterface.php +++ b/library/Zend/Db/Adapter/Driver/DriverInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Feature/AbstractFeature.php b/library/Zend/Db/Adapter/Driver/Feature/AbstractFeature.php index 22ba9547..b30eb8ea 100644 --- a/library/Zend/Db/Adapter/Driver/Feature/AbstractFeature.php +++ b/library/Zend/Db/Adapter/Driver/Feature/AbstractFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php b/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php index 10c96f77..405f2f71 100644 --- a/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php +++ b/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/IbmDb2/Connection.php b/library/Zend/Db/Adapter/Driver/IbmDb2/Connection.php index 53649741..3d474c9b 100644 --- a/library/Zend/Db/Adapter/Driver/IbmDb2/Connection.php +++ b/library/Zend/Db/Adapter/Driver/IbmDb2/Connection.php @@ -3,45 +3,22 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver\IbmDb2; -use Zend\Db\Adapter\Driver\ConnectionInterface; +use Zend\Db\Adapter\Driver\AbstractConnection; use Zend\Db\Adapter\Exception; -use Zend\Db\Adapter\Profiler; -class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface +class Connection extends AbstractConnection { /** - * @var IbmDb2 + * @var IbmDb2 */ protected $driver = null; - /** - * @var array - */ - protected $connectionParameters = null; - - /** - * @var resource - */ - protected $resource = null; - - /** - * @var Profiler\ProfilerInterface - */ - protected $profiler = null; - - /** - * In transaction - * - * @var bool - */ - protected $inTransaction = false; - /** * i5 OS * @@ -78,54 +55,19 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface /** * Set driver * - * @param IbmDb2 $driver - * @return Connection + * @param IbmDb2 $driver + * @return self */ public function setDriver(IbmDb2 $driver) { $this->driver = $driver; + return $this; } /** - * @param Profiler\ProfilerInterface $profiler - * @return Connection - */ - public function setProfiler(Profiler\ProfilerInterface $profiler) - { - $this->profiler = $profiler; - return $this; - } - - /** - * @return null|Profiler\ProfilerInterface - */ - public function getProfiler() - { - return $this->profiler; - } - - /** - * @param array $connectionParameters - * @return Connection - */ - public function setConnectionParameters(array $connectionParameters) - { - $this->connectionParameters = $connectionParameters; - return $this; - } - - /** - * @return array - */ - public function getConnectionParameters() - { - return $this->connectionParameters; - } - - /** - * @param resource $resource DB2 resource - * @return Connection + * @param resource $resource DB2 resource + * @return self */ public function setResource($resource) { @@ -133,13 +75,12 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface throw new Exception\InvalidArgumentException('The resource provided must be of type "DB2 Connection"'); } $this->resource = $resource; + return $this; } /** - * Get current schema - * - * @return string + * {@inheritDoc} */ public function getCurrentSchema() { @@ -148,23 +89,12 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $info = db2_server_info($this->resource); + return (isset($info->DB_NAME) ? $info->DB_NAME : ''); } /** - * Get resource - * - * @return mixed - */ - public function getResource() - { - return $this->resource; - } - - /** - * Connect - * - * @return self + * {@inheritDoc} */ public function connect() { @@ -183,7 +113,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } } - return null; + return; }; $database = $findParameterValue(array('database', 'db')); @@ -206,9 +136,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Is connected - * - * @return bool + * {@inheritDoc} */ public function isConnected() { @@ -216,9 +144,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Disconnect - * - * @return ConnectionInterface + * {@inheritDoc} */ public function disconnect() { @@ -231,9 +157,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Begin transaction - * - * @return ConnectionInterface + * {@inheritDoc} */ public function beginTransaction() { @@ -250,23 +174,12 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $this->prevAutocommit = db2_autocommit($this->resource); db2_autocommit($this->resource, DB2_AUTOCOMMIT_OFF); $this->inTransaction = true; + return $this; } /** - * In transaction - * - * @return bool - */ - public function inTransaction() - { - return $this->inTransaction; - } - - /** - * Commit - * - * @return ConnectionInterface + * {@inheritDoc} */ public function commit() { @@ -283,21 +196,22 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $this->inTransaction = false; + return $this; } /** * Rollback * - * @return ConnectionInterface + * @return Connection */ public function rollback() { - if (!$this->resource) { + if (!$this->isConnected()) { throw new Exception\RuntimeException('Must be connected before you can rollback.'); } - if (!$this->inTransaction) { + if (!$this->inTransaction()) { throw new Exception\RuntimeException('Must call beginTransaction() before you can rollback.'); } @@ -310,14 +224,12 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $this->inTransaction = false; + return $this; } /** - * Execute - * - * @param string $sql - * @return Result + * {@inheritDoc} */ public function execute($sql) { @@ -346,10 +258,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Get last generated id - * - * @param null $name Ignored - * @return int + * {@inheritDoc} */ public function getLastGeneratedValue($name = null) { @@ -367,7 +276,8 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface return $this->i5; } - $this->i5 = php_uname('s') == 'OS400' ? true : false; + $this->i5 = (php_uname('s') == 'OS400'); + return $this->i5; } } diff --git a/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php b/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php index d129b49b..783e0f40 100644 --- a/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php +++ b/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php b/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php index add4e1e3..5c9dc53b 100644 --- a/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php +++ b/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -119,7 +119,7 @@ class Result implements ResultInterface */ public function buffer() { - return null; + return; } /** @@ -187,6 +187,6 @@ class Result implements ResultInterface */ public function count() { - return null; + return; } } diff --git a/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php b/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php index 029a9ed2..97d25884 100644 --- a/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php +++ b/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -167,7 +167,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface throw new Exception\RuntimeException('This statement has been prepared already'); } - if ($sql == null) { + if ($sql === null) { $sql = $this->sql; } @@ -194,7 +194,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface /** * Execute * - * @param null $parameters + * @param null|array|ParameterContainer $parameters * @return Result */ public function execute($parameters = null) diff --git a/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php b/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php index d84db10f..b855ee12 100644 --- a/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php +++ b/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php @@ -3,51 +3,31 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver\Mysqli; -use Zend\Db\Adapter\Driver\ConnectionInterface; +use Zend\Db\Adapter\Driver\AbstractConnection; use Zend\Db\Adapter\Exception; -use Zend\Db\Adapter\Profiler; -class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface +class Connection extends AbstractConnection { /** * @var Mysqli */ protected $driver = null; - /** - * @var Profiler\ProfilerInterface - */ - protected $profiler = null; - - /** - * Connection parameters - * - * @var array - */ - protected $connectionParameters = array(); - /** * @var \mysqli */ protected $resource = null; - /** - * In transaction - * - * @var bool - */ - protected $inTransaction = false; - /** * Constructor * - * @param array|mysqli|null $connectionInfo + * @param array|mysqli|null $connectionInfo * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException */ public function __construct($connectionInfo = null) @@ -62,59 +42,18 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * @param Mysqli $driver - * @return Connection + * @param Mysqli $driver + * @return self */ public function setDriver(Mysqli $driver) { $this->driver = $driver; + return $this; } /** - * @param Profiler\ProfilerInterface $profiler - * @return Connection - */ - public function setProfiler(Profiler\ProfilerInterface $profiler) - { - $this->profiler = $profiler; - return $this; - } - - /** - * @return null|Profiler\ProfilerInterface - */ - public function getProfiler() - { - return $this->profiler; - } - - /** - * Set connection parameters - * - * @param array $connectionParameters - * @return Connection - */ - public function setConnectionParameters(array $connectionParameters) - { - $this->connectionParameters = $connectionParameters; - return $this; - } - - /** - * Get connection parameters - * - * @return array - */ - public function getConnectionParameters() - { - return $this->connectionParameters; - } - - /** - * Get current schema - * - * @return string + * {@inheritDoc} */ public function getCurrentSchema() { @@ -125,6 +64,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface /** @var $result \mysqli_result */ $result = $this->resource->query('SELECT DATABASE()'); $r = $result->fetch_row(); + return $r[0]; } @@ -132,30 +72,17 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface * Set resource * * @param \mysqli $resource - * @return Connection + * @return self */ public function setResource(\mysqli $resource) { $this->resource = $resource; + return $this; } /** - * Get resource - * - * @return \mysqli - */ - public function getResource() - { - $this->connect(); - return $this->resource; - } - - /** - * Connect - * - * @throws Exception\RuntimeException - * @return Connection + * {@inheritDoc} */ public function connect() { @@ -173,6 +100,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface return $p[$name]; } } + return; }; @@ -217,9 +145,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Is connected - * - * @return bool + * {@inheritDoc} */ public function isConnected() { @@ -227,9 +153,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Disconnect - * - * @return void + * {@inheritDoc} */ public function disconnect() { @@ -240,9 +164,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Begin transaction - * - * @return void + * {@inheritDoc} */ public function beginTransaction() { @@ -252,43 +174,32 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $this->resource->autocommit(false); $this->inTransaction = true; + + return $this; } /** - * In transaction - * - * @return bool - */ - public function inTransaction() - { - return $this->inTransaction; - } - - /** - * Commit - * - * @return void + * {@inheritDoc} */ public function commit() { - if (!$this->resource) { + if (!$this->isConnected()) { $this->connect(); } $this->resource->commit(); $this->inTransaction = false; $this->resource->autocommit(true); + + return $this; } /** - * Rollback - * - * @throws Exception\RuntimeException - * @return Connection + * {@inheritDoc} */ public function rollback() { - if (!$this->resource) { + if (!$this->isConnected()) { throw new Exception\RuntimeException('Must be connected before you can rollback.'); } @@ -298,15 +209,15 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $this->resource->rollback(); $this->resource->autocommit(true); + $this->inTransaction = false; + return $this; } /** - * Execute + * {@inheritDoc} * - * @param string $sql * @throws Exception\InvalidQueryException - * @return Result */ public function execute($sql) { @@ -330,14 +241,12 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $resultPrototype = $this->driver->createResult(($resultResource === true) ? $this->resource : $resultResource); + return $resultPrototype; } /** - * Get last generated id - * - * @param null $name Ignored - * @return int + * {@inheritDoc} */ public function getLastGeneratedValue($name = null) { diff --git a/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php b/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php index 443350ca..4fcc5584 100644 --- a/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php +++ b/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Mysqli/Result.php b/library/Zend/Db/Adapter/Driver/Mysqli/Result.php index 11622b15..d4af5c5c 100644 --- a/library/Zend/Db/Adapter/Driver/Mysqli/Result.php +++ b/library/Zend/Db/Adapter/Driver/Mysqli/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -187,7 +187,6 @@ class Result implements */ protected function loadDataFromMysqliStatement() { - $data = null; // build the default reference based bind structure, if it does not already exist if ($this->statementBindValues['keys'] === null) { $this->statementBindValues['keys'] = array(); diff --git a/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php b/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php index d462cd17..361ec3f5 100644 --- a/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php +++ b/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -219,7 +219,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface /** * Execute * - * @param ParameterContainer|array $parameters + * @param null|array|ParameterContainer $parameters * @throws Exception\RuntimeException * @return mixed */ diff --git a/library/Zend/Db/Adapter/Driver/Oci8/Connection.php b/library/Zend/Db/Adapter/Driver/Oci8/Connection.php index 73376521..4a231917 100644 --- a/library/Zend/Db/Adapter/Driver/Oci8/Connection.php +++ b/library/Zend/Db/Adapter/Driver/Oci8/Connection.php @@ -3,51 +3,26 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver\Oci8; -use Zend\Db\Adapter\Driver\ConnectionInterface; +use Zend\Db\Adapter\Driver\AbstractConnection; use Zend\Db\Adapter\Exception; -use Zend\Db\Adapter\Profiler; -class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface +class Connection extends AbstractConnection { /** * @var Oci8 */ protected $driver = null; - /** - * @var Profiler\ProfilerInterface - */ - protected $profiler = null; - - /** - * Connection parameters - * - * @var array - */ - protected $connectionParameters = array(); - - /** - * @var - */ - protected $resource = null; - - /** - * In transaction - * - * @var bool - */ - protected $inTransaction = false; - /** * Constructor * - * @param array|resource|null $connectionInfo + * @param array|resource|null $connectionInfo * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException */ public function __construct($connectionInfo = null) @@ -62,59 +37,18 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * @param Oci8 $driver - * @return Connection + * @param Oci8 $driver + * @return self */ public function setDriver(Oci8 $driver) { $this->driver = $driver; + return $this; } /** - * @param Profiler\ProfilerInterface $profiler - * @return Connection - */ - public function setProfiler(Profiler\ProfilerInterface $profiler) - { - $this->profiler = $profiler; - return $this; - } - - /** - * @return null|Profiler\ProfilerInterface - */ - public function getProfiler() - { - return $this->profiler; - } - - /** - * Set connection parameters - * - * @param array $connectionParameters - * @return Connection - */ - public function setConnectionParameters(array $connectionParameters) - { - $this->connectionParameters = $connectionParameters; - return $this; - } - - /** - * Get connection parameters - * - * @return array - */ - public function getConnectionParameters() - { - return $this->connectionParameters; - } - - /** - * Get current schema - * - * @return string + * {@inheritDoc} */ public function getCurrentSchema() { @@ -126,6 +60,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $stmt = oci_parse($this->resource, $query); oci_execute($stmt); $dbNameArray = oci_fetch_array($stmt, OCI_ASSOC); + return $dbNameArray['current_schema']; } @@ -133,7 +68,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface * Set resource * * @param resource $resource - * @return Connection + * @return self */ public function setResource($resource) { @@ -141,24 +76,12 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface throw new Exception\InvalidArgumentException('A resource of type "oci8 connection" was expected'); } $this->resource = $resource; + return $this; } /** - * Get resource - * - * @return \oci8 - */ - public function getResource() - { - $this->connect(); - return $this->resource; - } - - /** - * Connect - * - * @return Connection + * {@inheritDoc} */ public function connect() { @@ -176,7 +99,8 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface return $p[$name]; } } - return null; + + return; }; // http://www.php.net/manual/en/function.oci-connect.php @@ -211,9 +135,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Is connected - * - * @return bool + * {@inheritDoc} */ public function isConnected() { @@ -221,7 +143,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Disconnect + * {@inheritDoc} */ public function disconnect() { @@ -231,7 +153,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Begin transaction + * {@inheritDoc} */ public function beginTransaction() { @@ -241,48 +163,42 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface // A transaction begins when the first SQL statement that changes data is executed with oci_execute() using the OCI_NO_AUTO_COMMIT flag. $this->inTransaction = true; + + return $this; } /** - * In transaction - * - * @return bool - */ - public function inTransaction() - { - return $this->inTransaction; - } - - /** - * Commit + * {@inheritDoc} */ public function commit() { - if (!$this->resource) { + if (!$this->isConnected()) { $this->connect(); } - if ($this->inTransaction) { + if ($this->inTransaction()) { $valid = oci_commit($this->resource); if ($valid === false) { $e = oci_error($this->resource); throw new Exception\InvalidQueryException($e['message'], $e['code']); } + + $this->inTransaction = false; } + + return $this; } /** - * Rollback - * - * @return Connection + * {@inheritDoc} */ public function rollback() { - if (!$this->resource) { + if (!$this->isConnected()) { throw new Exception\RuntimeException('Must be connected before you can rollback.'); } - if (!$this->inTransaction) { + if (!$this->inTransaction()) { throw new Exception\RuntimeException('Must call commit() before you can rollback.'); } @@ -292,14 +208,13 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface throw new Exception\InvalidQueryException($e['message'], $e['code']); } + $this->inTransaction = false; + return $this; } /** - * Execute - * - * @param string $sql - * @return Result + * {@inheritDoc} */ public function execute($sql) { @@ -329,18 +244,16 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $resultPrototype = $this->driver->createResult($ociStmt); + return $resultPrototype; } /** - * Get last generated id - * - * @param null $name Ignored - * @return int + * {@inheritDoc} */ public function getLastGeneratedValue($name = null) { // @todo Get Last Generated Value in Connection (this might not apply) - return null; + return; } } diff --git a/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php b/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php index 9685f8c4..c846df72 100644 --- a/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php +++ b/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Oci8/Result.php b/library/Zend/Db/Adapter/Driver/Oci8/Result.php index f0ae96ab..03111b9d 100644 --- a/library/Zend/Db/Adapter/Driver/Oci8/Result.php +++ b/library/Zend/Db/Adapter/Driver/Oci8/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -82,7 +82,7 @@ class Result implements Iterator, ResultInterface */ public function buffer() { - return null; + return; } /** @@ -202,7 +202,7 @@ class Result implements Iterator, ResultInterface public function count() { // @todo OCI8 row count in Driver Result - return null; + return; } /** @@ -219,6 +219,6 @@ class Result implements Iterator, ResultInterface public function getGeneratedValue() { // @todo OCI8 generated value in Driver Result - return null; + return; } } diff --git a/library/Zend/Db/Adapter/Driver/Oci8/Statement.php b/library/Zend/Db/Adapter/Driver/Oci8/Statement.php index 707442fd..c14f8302 100644 --- a/library/Zend/Db/Adapter/Driver/Oci8/Statement.php +++ b/library/Zend/Db/Adapter/Driver/Oci8/Statement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -213,7 +213,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface /** * Execute * - * @param ParameterContainer $parameters + * @param null|array|ParameterContainer $parameters * @return mixed */ public function execute($parameters = null) @@ -305,7 +305,12 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface $type = SQLT_CHR; } - oci_bind_by_name($this->resource, $name, $value, -1, $type); + $maxLength = -1; + if ($this->parameterContainer->offsetHasMaxLength($name)) { + $maxLength = $this->parameterContainer->offsetGetMaxLength($name); + } + + oci_bind_by_name($this->resource, $name, $value, $maxLength, $type); } } } diff --git a/library/Zend/Db/Adapter/Driver/Pdo/Connection.php b/library/Zend/Db/Adapter/Driver/Pdo/Connection.php index 1cd2c666..6e5f22cf 100644 --- a/library/Zend/Db/Adapter/Driver/Pdo/Connection.php +++ b/library/Zend/Db/Adapter/Driver/Pdo/Connection.php @@ -3,48 +3,27 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver\Pdo; -use Zend\Db\Adapter\Driver\ConnectionInterface; +use Zend\Db\Adapter\Driver\AbstractConnection; use Zend\Db\Adapter\Exception; -use Zend\Db\Adapter\Profiler; -class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface +class Connection extends AbstractConnection { /** * @var Pdo */ protected $driver = null; - /** - * @var Profiler\ProfilerInterface - */ - protected $profiler = null; - - /** - * @var string - */ - protected $driverName = null; - - /** - * @var array - */ - protected $connectionParameters = array(); - /** * @var \PDO */ protected $resource = null; - /** - * @var bool - */ - protected $inTransaction = false; - /** * @var string */ @@ -53,7 +32,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface /** * Constructor * - * @param array|\PDO|null $connectionParameters + * @param array|\PDO|null $connectionParameters * @throws Exception\InvalidArgumentException */ public function __construct($connectionParameters = null) @@ -63,61 +42,35 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } elseif ($connectionParameters instanceof \PDO) { $this->setResource($connectionParameters); } elseif (null !== $connectionParameters) { - throw new Exception\InvalidArgumentException('$connection must be an array of parameters, a PDO object or null'); + throw new Exception\InvalidArgumentException( + '$connection must be an array of parameters, a PDO object or null' + ); } } /** * Set driver * - * @param Pdo $driver - * @return Connection + * @param Pdo $driver + * @return self */ public function setDriver(Pdo $driver) { $this->driver = $driver; + return $this; } /** - * @param Profiler\ProfilerInterface $profiler - * @return Connection - */ - public function setProfiler(Profiler\ProfilerInterface $profiler) - { - $this->profiler = $profiler; - return $this; - } - - /** - * @return null|Profiler\ProfilerInterface - */ - public function getProfiler() - { - return $this->profiler; - } - - /** - * Get driver name - * - * @return null|string - */ - public function getDriverName() - { - return $this->driverName; - } - - /** - * Set connection parameters - * - * @param array $connectionParameters - * @return void + * {@inheritDoc} */ public function setConnectionParameters(array $connectionParameters) { $this->connectionParameters = $connectionParameters; if (isset($connectionParameters['dsn'])) { - $this->driverName = substr($connectionParameters['dsn'], 0, + $this->driverName = substr( + $connectionParameters['dsn'], + 0, strpos($connectionParameters['dsn'], ':') ); } elseif (isset($connectionParameters['pdodriver'])) { @@ -130,16 +83,6 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } } - /** - * Get connection parameters - * - * @return array - */ - public function getConnectionParameters() - { - return $this->connectionParameters; - } - /** * Get the dsn string for this connection * @throws \Zend\Db\Adapter\Exception\RunTimeException @@ -148,16 +91,16 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface public function getDsn() { if (!$this->dsn) { - throw new Exception\RunTimeException("The DSN has not been set or constructed from parameters in connect() for this Connection"); + throw new Exception\RunTimeException( + 'The DSN has not been set or constructed from parameters in connect() for this Connection' + ); } return $this->dsn; } /** - * Get current schema - * - * @return string + * {@inheritDoc} */ public function getCurrentSchema() { @@ -186,6 +129,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface if ($result instanceof \PDOStatement) { return $result->fetchColumn(); } + return false; } @@ -193,32 +137,19 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface * Set resource * * @param \PDO $resource - * @return Connection + * @return self */ public function setResource(\PDO $resource) { $this->resource = $resource; $this->driverName = strtolower($this->resource->getAttribute(\PDO::ATTR_DRIVER_NAME)); + return $this; } /** - * Get resource + * {@inheritDoc} * - * @return \PDO - */ - public function getResource() - { - if (!$this->isConnected()) { - $this->connect(); - } - return $this->resource; - } - - /** - * Connect - * - * @return Connection * @throws Exception\InvalidConnectionParametersException * @throws Exception\RuntimeException */ @@ -236,9 +167,11 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $dsn = $value; break; case 'driver': - $value = strtolower($value); + $value = strtolower((string) $value); if (strpos($value, 'pdo') === 0) { - $pdoDriver = strtolower(substr(str_replace(array('-', '_', ' '), '', $value), 3)); + $pdoDriver = str_replace(array('-', '_', ' '), '', $value); + $pdoDriver = substr($pdoDriver, 3) ?: ''; + $pdoDriver = strtolower($pdoDriver); } break; case 'pdodriver': @@ -335,9 +268,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Is connected - * - * @return bool + * {@inheritDoc} */ public function isConnected() { @@ -345,47 +276,26 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Disconnect - * - * @return Connection - */ - public function disconnect() - { - if ($this->isConnected()) { - $this->resource = null; - } - return $this; - } - - /** - * Begin transaction - * - * @return Connection + * {@inheritDoc} */ public function beginTransaction() { if (!$this->isConnected()) { $this->connect(); } - $this->resource->beginTransaction(); - $this->inTransaction = true; + + if (0 === $this->nestedTransactionsCount) { + $this->resource->beginTransaction(); + $this->inTransaction = true; + } + + $this->nestedTransactionsCount ++; + return $this; } /** - * In transaction - * - * @return bool - */ - public function inTransaction() - { - return $this->inTransaction; - } - - /** - * Commit - * - * @return Connection + * {@inheritDoc} */ public function commit() { @@ -393,15 +303,25 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $this->connect(); } - $this->resource->commit(); - $this->inTransaction = false; + if ($this->inTransaction) { + $this->nestedTransactionsCount -= 1; + } + + /* + * This shouldn't check for being in a transaction since + * after issuing a SET autocommit=0; we have to commit too. + */ + if (0 === $this->nestedTransactionsCount) { + $this->resource->commit(); + $this->inTransaction = false; + } + return $this; } /** - * Rollback + * {@inheritDoc} * - * @return Connection * @throws Exception\RuntimeException */ public function rollback() @@ -410,19 +330,21 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface throw new Exception\RuntimeException('Must be connected before you can rollback'); } - if (!$this->inTransaction) { + if (!$this->inTransaction()) { throw new Exception\RuntimeException('Must call beginTransaction() before you can rollback'); } $this->resource->rollBack(); + + $this->inTransaction = false; + $this->nestedTransactionsCount = 0; + return $this; } /** - * Execute + * {@inheritDoc} * - * @param $sql - * @return Result * @throws Exception\InvalidQueryException */ public function execute($sql) @@ -447,13 +369,14 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $result = $this->driver->createResult($resultResource, $sql); + return $result; } /** * Prepare * - * @param string $sql + * @param string $sql * @return Statement */ public function prepare($sql) @@ -463,19 +386,20 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $statement = $this->driver->createStatement($sql); + return $statement; } /** - * Get last generated id + * {@inheritDoc} * - * @param string $name + * @param string $name * @return string|null|false */ public function getLastGeneratedValue($name = null) { if ($name === null && $this->driverName == 'pgsql') { - return null; + return; } try { @@ -483,6 +407,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } catch (\Exception $e) { // do nothing } + return false; } } diff --git a/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php b/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php index 2a25cdd6..199949a9 100644 --- a/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php +++ b/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ class OracleRowCounter extends AbstractFeature $countStmt = clone $statement; $sql = $statement->getSql(); if ($sql == '' || stripos($sql, 'select') === false) { - return null; + return; } $countSql = 'SELECT COUNT(*) as "count" FROM (' . $sql . ')'; $countStmt->prepare($countSql); @@ -51,7 +51,7 @@ class OracleRowCounter extends AbstractFeature public function getCountForSql($sql) { if (stripos($sql, 'select') === false) { - return null; + return; } $countSql = 'SELECT COUNT(*) as count FROM (' . $sql . ')'; /** @var $pdo \PDO */ diff --git a/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php b/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php index 13c8d66d..9f795fef 100644 --- a/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php +++ b/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ class SqliteRowCounter extends AbstractFeature $countStmt = clone $statement; $sql = $statement->getSql(); if ($sql == '' || stripos($sql, 'select') === false) { - return null; + return; } $countSql = 'SELECT COUNT(*) as "count" FROM (' . $sql . ')'; $countStmt->prepare($countSql); @@ -51,7 +51,7 @@ class SqliteRowCounter extends AbstractFeature public function getCountForSql($sql) { if (stripos($sql, 'select') === false) { - return null; + return; } $countSql = 'SELECT COUNT(*) as count FROM (' . $sql . ')'; /** @var $pdo \PDO */ diff --git a/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php b/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php index 3de7beb4..c70afa8d 100644 --- a/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php +++ b/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -297,7 +297,7 @@ class Pdo implements DriverInterface, DriverFeatureInterface, Profiler\ProfilerA */ 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; } diff --git a/library/Zend/Db/Adapter/Driver/Pdo/Result.php b/library/Zend/Db/Adapter/Driver/Pdo/Result.php index 9323282d..47836232 100644 --- a/library/Zend/Db/Adapter/Driver/Pdo/Result.php +++ b/library/Zend/Db/Adapter/Driver/Pdo/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,12 @@ class Result implements Iterator, ResultInterface protected $statementMode = self::STATEMENT_MODE_FORWARD; /** - * @var \PDOStatement + * @var int + */ + protected $fetchMode = \PDO::FETCH_ASSOC; + + /** + * @var PDOStatement */ protected $resource = null; @@ -85,7 +90,7 @@ class Result implements Iterator, ResultInterface */ public function buffer() { - return null; + return; } /** @@ -96,6 +101,29 @@ class Result implements Iterator, ResultInterface return false; } + /** + * @param int $fetchMode + * @throws Exception\InvalidArgumentException on invalid fetch mode + */ + public function setFetchMode($fetchMode) + { + if ($fetchMode < 1 || $fetchMode > 10) { + throw new Exception\InvalidArgumentException( + 'The fetch mode must be one of the PDO::FETCH_* constants.' + ); + } + + $this->fetchMode = (int) $fetchMode; + } + + /** + * @return int + */ + public function getFetchMode() + { + return $this->fetchMode; + } + /** * Get resource * @@ -116,7 +144,7 @@ class Result implements Iterator, ResultInterface return $this->currentData; } - $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC); + $this->currentData = $this->resource->fetch($this->fetchMode); $this->currentComplete = true; return $this->currentData; } @@ -128,7 +156,7 @@ class Result implements Iterator, ResultInterface */ public function next() { - $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC); + $this->currentData = $this->resource->fetch($this->fetchMode); $this->currentComplete = true; $this->position++; return $this->currentData; @@ -155,7 +183,7 @@ class Result implements Iterator, ResultInterface 'This result is a forward only result set, calling rewind() after moving forward is not supported' ); } - $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC); + $this->currentData = $this->resource->fetch($this->fetchMode); $this->currentComplete = true; $this->position = 0; } diff --git a/library/Zend/Db/Adapter/Driver/Pdo/Statement.php b/library/Zend/Db/Adapter/Driver/Pdo/Statement.php index 891bec9d..0180859d 100644 --- a/library/Zend/Db/Adapter/Driver/Pdo/Statement.php +++ b/library/Zend/Db/Adapter/Driver/Pdo/Statement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -179,7 +179,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface throw new Exception\RuntimeException('This statement has been prepared already'); } - if ($sql == null) { + if ($sql === null) { $sql = $this->sql; } @@ -202,7 +202,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface } /** - * @param mixed $parameters + * @param null|array|ParameterContainer $parameters * @throws Exception\InvalidQueryException * @return Result */ diff --git a/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php b/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php index fa91289a..ea2025a7 100644 --- a/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php +++ b/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php @@ -3,17 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver\Pgsql; -use Zend\Db\Adapter\Driver\ConnectionInterface; +use Zend\Db\Adapter\Driver\AbstractConnection; use Zend\Db\Adapter\Exception; -use Zend\Db\Adapter\Profiler; -class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface +class Connection extends AbstractConnection { /** * @var Pgsql @@ -21,28 +20,9 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface protected $driver = null; /** - * @var Profiler\ProfilerInterface + * @var null|int PostgreSQL connection type */ - protected $profiler = null; - - /** - * Connection parameters - * - * @var array - */ - protected $connectionParameters = array(); - - /** - * @var resource - */ - protected $resource = null; - - /** - * In transaction - * - * @var bool - */ - protected $inTransaction = false; + protected $type = null; /** * Constructor @@ -58,62 +38,41 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } } - /** - * Set connection parameters - * - * @param array $connectionParameters - * @return Connection - */ - public function setConnectionParameters(array $connectionParameters) - { - $this->connectionParameters = $connectionParameters; - return $this; - } - /** * Set driver * * @param Pgsql $driver - * @return Connection + * @return self */ public function setDriver(Pgsql $driver) { $this->driver = $driver; + return $this; } /** - * @param Profiler\ProfilerInterface $profiler - * @return Connection + * @param int|null $type + * @return self */ - public function setProfiler(Profiler\ProfilerInterface $profiler) + public function setType($type) { - $this->profiler = $profiler; + $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; } /** - * @return null|Profiler\ProfilerInterface - */ - public function getProfiler() - { - return $this->profiler; - } - - /** - * Set resource - * - * @param resource $resource - * @return Connection - */ - public function setResource($resource) - { - $this->resource = $resource; - return; - } - - /** - * Get current schema + * {@inheritDoc} * * @return null|string */ @@ -125,28 +84,15 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $result = pg_query($this->resource, 'SELECT CURRENT_SCHEMA AS "currentschema"'); if ($result == false) { - return null; + return; } + return pg_fetch_result($result, 0, 'currentschema'); } /** - * Get resource + * {@inheritDoc} * - * @return resource - */ - public function getResource() - { - if (!$this->isConnected()) { - $this->connect(); - } - return $this->resource; - } - - /** - * Connect to the database - * - * @return Connection * @throws Exception\RuntimeException on failure */ public function connect() @@ -155,30 +101,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface return $this; } - // localize - $p = $this->connectionParameters; - - // given a list of key names, test for existence in $p - $findParameterValue = function (array $names) use ($p) { - foreach ($names as $name) { - if (isset($p[$name])) { - return $p[$name]; - } - } - return null; - }; - - $connection = array(); - $connection['host'] = $findParameterValue(array('hostname', 'host')); - $connection['user'] = $findParameterValue(array('username', 'user')); - $connection['password'] = $findParameterValue(array('password', 'passwd', 'pw')); - $connection['dbname'] = $findParameterValue(array('database', 'dbname', 'db', 'schema')); - $connection['port'] = (isset($p['port'])) ? (int) $p['port'] : null; - $connection['socket'] = (isset($p['socket'])) ? $p['socket'] : null; - - $connection = array_filter($connection); // remove nulls - $connection = http_build_query($connection, null, ' '); // @link http://php.net/pg_connect - + $connection = $this->getConnectionString(); set_error_handler(function ($number, $string) { throw new Exception\RuntimeException( __METHOD__ . ': Unable to connect to database', null, new Exception\ErrorException($string, $number) @@ -198,7 +121,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * @return bool + * {@inheritDoc} */ public function isConnected() { @@ -206,19 +129,20 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * @return void + * {@inheritDoc} */ public function disconnect() { pg_close($this->resource); + return $this; } /** - * @return void + * {@inheritDoc} */ public function beginTransaction() { - if ($this->inTransaction) { + if ($this->inTransaction()) { throw new Exception\RuntimeException('Nested transactions are not supported'); } @@ -228,46 +152,51 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface pg_query($this->resource, 'BEGIN'); $this->inTransaction = true; + + return $this; } /** - * In transaction - * - * @return bool - */ - public function inTransaction() - { - return $this->inTransaction; - } - - /** - * @return void + * {@inheritDoc} */ public function commit() { - if (!$this->inTransaction) { + if (!$this->isConnected()) { + $this->connect(); + } + + if (!$this->inTransaction()) { return; // We ignore attempts to commit non-existing transaction } pg_query($this->resource, 'COMMIT'); $this->inTransaction = false; + + return $this; } /** - * @return void + * {@inheritDoc} */ public function rollback() { - if (!$this->inTransaction) { - return; + if (!$this->isConnected()) { + throw new Exception\RuntimeException('Must be connected before you can rollback'); + } + + if (!$this->inTransaction()) { + throw new Exception\RuntimeException('Must call beginTransaction() before you can rollback'); } pg_query($this->resource, 'ROLLBACK'); $this->inTransaction = false; + + return $this; } /** - * @param string $sql + * {@inheritDoc} + * * @throws Exception\InvalidQueryException * @return resource|\Zend\Db\ResultSet\ResultSetInterface */ @@ -293,19 +222,54 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $resultPrototype = $this->driver->createResult(($resultResource === true) ? $this->resource : $resultResource); + return $resultPrototype; } /** - * @param null $name Ignored + * {@inheritDoc} + * * @return string */ public function getLastGeneratedValue($name = null) { - if ($name == null) { - return null; + if ($name === null) { + return; } $result = pg_query($this->resource, 'SELECT CURRVAL(\'' . str_replace('\'', '\\\'', $name) . '\') as "currval"'); + return pg_fetch_result($result, 0, 'currval'); } + + /** + * Get Connection String + * + * @return string + */ + private function getConnectionString() + { + // localize + $p = $this->connectionParameters; + + // given a list of key names, test for existence in $p + $findParameterValue = function (array $names) use ($p) { + foreach ($names as $name) { + if (isset($p[$name])) { + return $p[$name]; + } + } + return; + }; + + $connectionParameters = array( + 'host' => $findParameterValue(array('hostname', 'host')), + 'user' => $findParameterValue(array('username', 'user')), + 'password' => $findParameterValue(array('password', 'passwd', 'pw')), + 'dbname' => $findParameterValue(array('database', 'dbname', 'db', 'schema')), + 'port' => isset($p['port']) ? (int) $p['port'] : null, + 'socket' => isset($p['socket']) ? $p['socket'] : null, + ); + + return urldecode(http_build_query(array_filter($connectionParameters), null, ' ')); + } } diff --git a/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php b/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php index 36e5e0f2..b186fe82 100644 --- a/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php +++ b/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Pgsql/Result.php b/library/Zend/Db/Adapter/Driver/Pgsql/Result.php index 6c2410da..a19f226e 100644 --- a/library/Zend/Db/Adapter/Driver/Pgsql/Result.php +++ b/library/Zend/Db/Adapter/Driver/Pgsql/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -113,7 +113,7 @@ class Result implements ResultInterface */ public function buffer() { - return null; + return; } /** diff --git a/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php b/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php index c105a664..a0dc26f7 100644 --- a/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php +++ b/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -168,7 +168,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface $pCount = 1; $sql = preg_replace_callback( - '#\$\##', function ($foo) use (&$pCount) { + '#\$\##', function () use (&$pCount) { return '$' . $pCount++; }, $sql @@ -192,7 +192,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface /** * Execute * - * @param ParameterContainer|null $parameters + * @param null|array|ParameterContainer $parameters * @throws Exception\InvalidQueryException * @return Result */ diff --git a/library/Zend/Db/Adapter/Driver/ResultInterface.php b/library/Zend/Db/Adapter/Driver/ResultInterface.php index cb1f4078..fd83b9d7 100644 --- a/library/Zend/Db/Adapter/Driver/ResultInterface.php +++ b/library/Zend/Db/Adapter/Driver/ResultInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Sqlsrv/Connection.php b/library/Zend/Db/Adapter/Driver/Sqlsrv/Connection.php index f0d859a4..7ce54d90 100644 --- a/library/Zend/Db/Adapter/Driver/Sqlsrv/Connection.php +++ b/library/Zend/Db/Adapter/Driver/Sqlsrv/Connection.php @@ -3,48 +3,27 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver\Sqlsrv; -use Zend\Db\Adapter\Driver\ConnectionInterface; +use Zend\Db\Adapter\Driver\AbstractConnection; use Zend\Db\Adapter\Driver\Sqlsrv\Exception\ErrorException; use Zend\Db\Adapter\Exception; -use Zend\Db\Adapter\Profiler; -class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface +class Connection extends AbstractConnection { /** * @var Sqlsrv */ protected $driver = null; - /** - * @var Profiler\ProfilerInterface - */ - protected $profiler = null; - - /** - * @var array - */ - protected $connectionParameters = array(); - - /** - * @var resource - */ - protected $resource = null; - - /** - * @var bool - */ - protected $inTransaction = false; - /** * Constructor * - * @param array|resource $connectionInfo + * @param array|resource $connectionInfo * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException */ public function __construct($connectionInfo) @@ -62,58 +41,17 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface * Set driver * * @param Sqlsrv $driver - * @return Connection + * @return self */ public function setDriver(Sqlsrv $driver) { $this->driver = $driver; + return $this; } /** - * @param Profiler\ProfilerInterface $profiler - * @return Connection - */ - public function setProfiler(Profiler\ProfilerInterface $profiler) - { - $this->profiler = $profiler; - return $this; - } - - /** - * @return null|Profiler\ProfilerInterface - */ - public function getProfiler() - { - return $this->profiler; - } - - /** - * Set connection parameters - * - * @param array $connectionParameters - * @return Connection - */ - public function setConnectionParameters(array $connectionParameters) - { - $this->connectionParameters = $connectionParameters; - return $this; - } - - /** - * Get connection parameters - * - * @return array - */ - public function getConnectionParameters() - { - return $this->connectionParameters; - } - - /** - * Get current schema - * - * @return string + * {@inheritDoc} */ public function getCurrentSchema() { @@ -123,15 +61,16 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $result = sqlsrv_query($this->resource, 'SELECT SCHEMA_NAME()'); $r = sqlsrv_fetch_array($result); + return $r[0]; } /** * Set resource * - * @param resource $resource + * @param resource $resource * @throws Exception\InvalidArgumentException - * @return Connection + * @return self */ public function setResource($resource) { @@ -139,25 +78,14 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface throw new Exception\InvalidArgumentException('Resource provided was not of type SQL Server Connection'); } $this->resource = $resource; + return $this; } /** - * @return resource - */ - public function getResource() - { - if (!$this->isConnected()) { - $this->connect(); - } - return $this->resource; - } - - /** - * Connect + * {@inheritDoc} * * @throws Exception\RuntimeException - * @return Connection */ public function connect() { @@ -212,8 +140,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Is connected - * @return bool + * {@inheritDoc} */ public function isConnected() { @@ -221,7 +148,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Disconnect + * {@inheritDoc} */ public function disconnect() { @@ -230,70 +157,64 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } /** - * Begin transaction + * {@inheritDoc} */ public function beginTransaction() { - if (!$this->resource) { + if (!$this->isConnected()) { $this->connect(); } + if (sqlsrv_begin_transaction($this->resource) === false) { throw new Exception\RuntimeException( - 'Begin transaction failed', - null, new ErrorException(sqlsrv_errors()) ); } $this->inTransaction = true; + + return $this; } /** - * In transaction - * - * @return bool - */ - public function inTransaction() - { - return $this->inTransaction; - } - - /** - * Commit + * {@inheritDoc} */ public function commit() { // http://msdn.microsoft.com/en-us/library/cc296194.aspx - if (!$this->resource) { + if (!$this->isConnected()) { $this->connect(); } + sqlsrv_commit($this->resource); + $this->inTransaction = false; - return sqlsrv_commit($this->resource); + return $this; } /** - * Rollback + * {@inheritDoc} */ public function rollback() { // http://msdn.microsoft.com/en-us/library/cc296176.aspx - if (!$this->resource) { + if (!$this->isConnected()) { throw new Exception\RuntimeException('Must be connected before you can rollback.'); } - return sqlsrv_rollback($this->resource); + sqlsrv_rollback($this->resource); + $this->inTransaction = false; + + return $this; } /** - * Execute + * {@inheritDoc} * - * @param string $sql * @throws Exception\RuntimeException - * @return mixed */ public function execute($sql) { @@ -329,6 +250,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $result = $this->driver->createResult($returnValue); + return $result; } @@ -345,13 +267,13 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface } $statement = $this->driver->createStatement($sql); + return $statement; } /** - * Get last generated id + * {@inheritDoc} * - * @param string $name * @return mixed */ public function getLastGeneratedValue($name = null) @@ -362,6 +284,7 @@ class Connection implements ConnectionInterface, Profiler\ProfilerAwareInterface $sql = 'SELECT @@IDENTITY as Current_Identity'; $result = sqlsrv_query($this->resource, $sql); $row = sqlsrv_fetch_array($result); + return $row['Current_Identity']; } } diff --git a/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php b/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php index 9976eee6..40b15abe 100644 --- a/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php +++ b/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php b/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php index a7168e8d..2a039d96 100644 --- a/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php +++ b/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Driver/Sqlsrv/Result.php b/library/Zend/Db/Adapter/Driver/Sqlsrv/Result.php index cc7f9beb..4edef486 100644 --- a/library/Zend/Db/Adapter/Driver/Sqlsrv/Result.php +++ b/library/Zend/Db/Adapter/Driver/Sqlsrv/Result.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -60,7 +60,7 @@ class Result implements Iterator, ResultInterface */ public function buffer() { - return null; + return; } /** diff --git a/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php b/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php index 0cb8b243..652874a2 100644 --- a/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php +++ b/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -165,7 +165,7 @@ class Sqlsrv implements DriverInterface, Profiler\ProfilerAwareInterface $statement->initialize($this->connection->getResource()); if (is_string($sqlOrResource)) { $statement->setSql($sqlOrResource); - } elseif ($sqlOrResource != null) { + } elseif ($sqlOrResource !== null) { throw new Exception\InvalidArgumentException('createStatement() only accepts an SQL string or a Sqlsrv resource'); } } diff --git a/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php b/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php index 4aefa9ff..0a40bc58 100644 --- a/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php +++ b/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -231,7 +231,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface /** * Execute * - * @param array|ParameterContainer $parameters + * @param null|array|ParameterContainer $parameters * @throws Exception\RuntimeException * @return Result */ diff --git a/library/Zend/Db/Adapter/Driver/StatementInterface.php b/library/Zend/Db/Adapter/Driver/StatementInterface.php index a1ba5670..e18c364a 100644 --- a/library/Zend/Db/Adapter/Driver/StatementInterface.php +++ b/library/Zend/Db/Adapter/Driver/StatementInterface.php @@ -3,12 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Driver; +use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\StatementContainerInterface; interface StatementInterface extends StatementContainerInterface @@ -37,7 +38,7 @@ interface StatementInterface extends StatementContainerInterface /** * Execute * - * @param null $parameters + * @param null|array|ParameterContainer $parameters * @return ResultInterface */ public function execute($parameters = null); diff --git a/library/Zend/Db/Adapter/Exception/ErrorException.php b/library/Zend/Db/Adapter/Exception/ErrorException.php index 125550a2..5704ad1a 100644 --- a/library/Zend/Db/Adapter/Exception/ErrorException.php +++ b/library/Zend/Db/Adapter/Exception/ErrorException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Exception/ExceptionInterface.php b/library/Zend/Db/Adapter/Exception/ExceptionInterface.php index 3f3660d9..afd43b6a 100644 --- a/library/Zend/Db/Adapter/Exception/ExceptionInterface.php +++ b/library/Zend/Db/Adapter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Exception/InvalidArgumentException.php b/library/Zend/Db/Adapter/Exception/InvalidArgumentException.php index 5cf7a4bf..392677d7 100644 --- a/library/Zend/Db/Adapter/Exception/InvalidArgumentException.php +++ b/library/Zend/Db/Adapter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Exception/InvalidConnectionParametersException.php b/library/Zend/Db/Adapter/Exception/InvalidConnectionParametersException.php index d1c035af..bb75d0c0 100644 --- a/library/Zend/Db/Adapter/Exception/InvalidConnectionParametersException.php +++ b/library/Zend/Db/Adapter/Exception/InvalidConnectionParametersException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Exception/InvalidQueryException.php b/library/Zend/Db/Adapter/Exception/InvalidQueryException.php index 1372237f..f24c84c4 100644 --- a/library/Zend/Db/Adapter/Exception/InvalidQueryException.php +++ b/library/Zend/Db/Adapter/Exception/InvalidQueryException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Exception/RuntimeException.php b/library/Zend/Db/Adapter/Exception/RuntimeException.php index e1ff7859..81b4fcd5 100644 --- a/library/Zend/Db/Adapter/Exception/RuntimeException.php +++ b/library/Zend/Db/Adapter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Exception/UnexpectedValueException.php b/library/Zend/Db/Adapter/Exception/UnexpectedValueException.php index 46859f26..1e73c668 100644 --- a/library/Zend/Db/Adapter/Exception/UnexpectedValueException.php +++ b/library/Zend/Db/Adapter/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/ParameterContainer.php b/library/Zend/Db/Adapter/ParameterContainer.php index 429a6542..9c180b8f 100644 --- a/library/Zend/Db/Adapter/ParameterContainer.php +++ b/library/Zend/Db/Adapter/ParameterContainer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -42,6 +42,13 @@ class ParameterContainer implements Iterator, ArrayAccess, Countable */ protected $errata = array(); + /** + * Max length + * + * @var array + */ + protected $maxLength = array(); + /** * Constructor * @@ -91,8 +98,10 @@ class ParameterContainer implements Iterator, ArrayAccess, Countable * @param string|int $name * @param mixed $value * @param mixed $errata + * @param mixed $maxLength + * @throws Exception\InvalidArgumentException */ - public function offsetSet($name, $value, $errata = null) + public function offsetSet($name, $value, $errata = null, $maxLength = null) { $position = false; @@ -122,6 +131,10 @@ class ParameterContainer implements Iterator, ArrayAccess, Countable if ($errata) { $this->offsetSetErrata($name, $errata); } + + if ($maxLength) { + $this->offsetSetMaxLength($name, $maxLength); + } } /** @@ -153,6 +166,79 @@ class ParameterContainer implements Iterator, ArrayAccess, Countable return $this; } + /** + * Offset set max length + * + * @param string|int $name + * @param mixed $maxLength + */ + public function offsetSetMaxLength($name, $maxLength) + { + if (is_int($name)) { + $name = $this->positions[$name]; + } + $this->maxLength[$name] = $maxLength; + } + + /** + * Offset get max length + * + * @param string|int $name + * @throws Exception\InvalidArgumentException + * @return mixed + */ + public function offsetGetMaxLength($name) + { + if (is_int($name)) { + $name = $this->positions[$name]; + } + if (!array_key_exists($name, $this->data)) { + throw new Exception\InvalidArgumentException('Data does not exist for this name/position'); + } + return $this->maxLength[$name]; + } + + /** + * Offset has max length + * + * @param string|int $name + * @return bool + */ + public function offsetHasMaxLength($name) + { + if (is_int($name)) { + $name = $this->positions[$name]; + } + return (isset($this->maxLength[$name])); + } + + /** + * Offset unset max length + * + * @param string|int $name + * @throws Exception\InvalidArgumentException + */ + public function offsetUnsetMaxLength($name) + { + if (is_int($name)) { + $name = $this->positions[$name]; + } + if (!array_key_exists($name, $this->maxLength)) { + throw new Exception\InvalidArgumentException('Data does not exist for this name/position'); + } + $this->maxLength[$name] = null; + } + + /** + * Get max length iterator + * + * @return \ArrayIterator + */ + public function getMaxLengthIterator() + { + return new \ArrayIterator($this->maxLength); + } + /** * Offset set errata * diff --git a/library/Zend/Db/Adapter/Platform/AbstractPlatform.php b/library/Zend/Db/Adapter/Platform/AbstractPlatform.php new file mode 100644 index 00000000..44d0d5c7 --- /dev/null +++ b/library/Zend/Db/Adapter/Platform/AbstractPlatform.php @@ -0,0 +1,137 @@ +quoteIdentifiers) { + return $identifier; + } + + $safeWordsInt = array('*' => true, ' ' => true, '.' => true, 'as' => true); + + foreach ($safeWords as $sWord) { + $safeWordsInt[strtolower($sWord)] = true; + } + + $parts = preg_split( + '/([^0-9,a-z,A-Z$_:])/i', + $identifier, + -1, + PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY + ); + + $identifier = ''; + + foreach ($parts as $part) { + $identifier .= isset($safeWordsInt[strtolower($part)]) + ? $part + : $this->quoteIdentifier[0] + . str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $part) + . $this->quoteIdentifier[1]; + } + + return $identifier; + } + + /** + * {@inheritDoc} + */ + public function quoteIdentifier($identifier) + { + if (! $this->quoteIdentifiers) { + return $identifier; + } + + return $this->quoteIdentifier[0] + . str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $identifier) + . $this->quoteIdentifier[1]; + } + + /** + * {@inheritDoc} + */ + public function quoteIdentifierChain($identifierChain) + { + return '"' . implode('"."', (array) str_replace('"', '\\"', $identifierChain)) . '"'; + } + + /** + * {@inheritDoc} + */ + public function getQuoteIdentifierSymbol() + { + return $this->quoteIdentifier[0]; + } + + /** + * {@inheritDoc} + */ + public function getQuoteValueSymbol() + { + return '\''; + } + + /** + * {@inheritDoc} + */ + public function quoteValue($value) + { + trigger_error( + 'Attempting to quote a value in ' . get_class($this) . + ' without extension/driver support can introduce security vulnerabilities in a production environment' + ); + return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\''; + } + + /** + * {@inheritDoc} + */ + public function quoteTrustedValue($value) + { + return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\''; + } + + /** + * {@inheritDoc} + */ + public function quoteValueList($valueList) + { + return implode(', ', array_map(array($this, 'quoteValue'), (array) $valueList)); + } + + /** + * {@inheritDoc} + */ + public function getIdentifierSeparator() + { + return '.'; + } +} diff --git a/library/Zend/Db/Adapter/Platform/IbmDb2.php b/library/Zend/Db/Adapter/Platform/IbmDb2.php index 693b647e..4f6ea19e 100644 --- a/library/Zend/Db/Adapter/Platform/IbmDb2.php +++ b/library/Zend/Db/Adapter/Platform/IbmDb2.php @@ -3,21 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Platform; -class IbmDb2 implements PlatformInterface +class IbmDb2 extends AbstractPlatform { - protected $quoteValueAllowed = false; - - /** - * @var bool - */ - protected $quoteIdentifiers = true; - /** * @var string */ @@ -41,9 +34,7 @@ class IbmDb2 implements PlatformInterface } /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -51,34 +42,7 @@ class IbmDb2 implements PlatformInterface } /** - * Get quote indentifier symbol - * - * @return string - */ - public function getQuoteIdentifierSymbol() - { - return '"'; - } - - /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - if ($this->quoteIdentifiers === false) { - return $identifier; - } - return '"' . str_replace('"', '\\' . '"', $identifier) . '"'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string + * {@inheritDoc} */ public function quoteIdentifierChain($identifierChain) { @@ -93,20 +57,7 @@ class IbmDb2 implements PlatformInterface } /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { @@ -121,12 +72,7 @@ class IbmDb2 implements PlatformInterface } /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed + * {@inheritDoc} */ public function quoteTrustedValue($value) { @@ -137,71 +83,10 @@ class IbmDb2 implements PlatformInterface } /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string + * {@inheritDoc} */ public function getIdentifierSeparator() { return $this->identifierSeparator; } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - if ($this->quoteIdentifiers === false) { - return $identifier; - } - $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"'; - } - } - - return implode('', $parts); - } } diff --git a/library/Zend/Db/Adapter/Platform/Mysql.php b/library/Zend/Db/Adapter/Platform/Mysql.php index 6e02f083..42fc769b 100644 --- a/library/Zend/Db/Adapter/Platform/Mysql.php +++ b/library/Zend/Db/Adapter/Platform/Mysql.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,11 +14,26 @@ use Zend\Db\Adapter\Driver\Mysqli; use Zend\Db\Adapter\Driver\Pdo; use Zend\Db\Adapter\Exception; -class Mysql implements PlatformInterface +class Mysql extends AbstractPlatform { - /** @var \mysqli|\PDO */ + /** + * {@inheritDoc} + */ + protected $quoteIdentifier = array('`', '`'); + + /** + * {@inheritDoc} + */ + protected $quoteIdentifierTo = '``'; + + /** + * @var \mysqli|\PDO + */ protected $resource = null; + /** + * @param null|\Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo|\mysqli|\PDO $driver + */ public function __construct($driver = null) { if ($driver) { @@ -27,9 +42,10 @@ class Mysql implements PlatformInterface } /** - * @param \Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo||\mysqli|\PDO $driver + * @param \Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo|\mysqli|\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException - * @return $this + * + * @return self */ public function setDriver($driver) { @@ -47,9 +63,7 @@ class Mysql implements PlatformInterface } /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -57,56 +71,15 @@ class Mysql implements PlatformInterface } /** - * Get quote identifier symbol - * - * @return string - */ - public function getQuoteIdentifierSymbol() - { - return '`'; - } - - /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - return '`' . str_replace('`', '``', $identifier) . '`'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string + * {@inheritDoc} */ public function quoteIdentifierChain($identifierChain) { - $identifierChain = str_replace('`', '``', $identifierChain); - if (is_array($identifierChain)) { - $identifierChain = implode('`.`', $identifierChain); - } - return '`' . $identifierChain . '`'; + return '`' . implode('`.`', (array) str_replace('`', '``', $identifierChain)) . '`'; } /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { @@ -119,20 +92,11 @@ class Mysql implements PlatformInterface if ($this->resource instanceof \PDO) { return $this->resource->quote($value); } - trigger_error( - 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support ' - . 'can introduce security vulnerabilities in a production environment.' - ); - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; + return parent::quoteValue($value); } /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed + * {@inheritDoc} */ public function quoteTrustedValue($value) { @@ -145,70 +109,6 @@ class Mysql implements PlatformInterface if ($this->resource instanceof \PDO) { return $this->resource->quote($value); } - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; - } - - /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string - */ - public function getIdentifierSeparator() - { - return '.'; - } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - // regex taken from @link http://dev.mysql.com/doc/refman/5.0/en/identifiers.html - $parts = preg_split('#([^0-9,a-z,A-Z$_])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '`' . str_replace('`', '``', $part) . '`'; - } - } - return implode('', $parts); + return parent::quoteTrustedValue($value); } } diff --git a/library/Zend/Db/Adapter/Platform/Oracle.php b/library/Zend/Db/Adapter/Platform/Oracle.php index 61f700a4..cb64ab34 100644 --- a/library/Zend/Db/Adapter/Platform/Oracle.php +++ b/library/Zend/Db/Adapter/Platform/Oracle.php @@ -3,19 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Platform; -class Oracle implements PlatformInterface +class Oracle extends AbstractPlatform { - /** - * @var bool - */ - protected $quoteIdentifiers = true; - /** * @param array $options */ @@ -30,9 +25,7 @@ class Oracle implements PlatformInterface } /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -40,62 +33,19 @@ class Oracle implements PlatformInterface } /** - * Get quote identifier symbol - * - * @return string - */ - public function getQuoteIdentifierSymbol() - { - return '"'; - } - - /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - if ($this->quoteIdentifiers === false) { - return $identifier; - } - return '"' . str_replace('"', '\\' . '"', $identifier) . '"'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string + * {@inheritDoc} */ public function quoteIdentifierChain($identifierChain) { if ($this->quoteIdentifiers === false) { - return (is_array($identifierChain)) ? implode('.', $identifierChain) : $identifierChain; + return implode('.', (array) $identifierChain); } - $identifierChain = str_replace('"', '\\"', $identifierChain); - if (is_array($identifierChain)) { - $identifierChain = implode('"."', $identifierChain); - } - return '"' . $identifierChain . '"'; + + return '"' . implode('"."', (array) str_replace('"', '\\"', $identifierChain)) . '"'; } /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { @@ -103,85 +53,14 @@ class Oracle implements PlatformInterface 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support ' . 'can introduce security vulnerabilities in a production environment.' ); - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; + return '\'' . addcslashes(str_replace('\'', '\'\'', $value), "\x00\n\r\"\x1a") . '\''; } /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed + * {@inheritDoc} */ public function quoteTrustedValue($value) { - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; - } - - /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string - */ - public function getIdentifierSeparator() - { - return '.'; - } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - if ($this->quoteIdentifiers === false) { - return $identifier; - } - $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"'; - } - } - return implode('', $parts); + return '\'' . addcslashes(str_replace('\'', '\'\'', $value), "\x00\n\r\"\x1a") . '\''; } } diff --git a/library/Zend/Db/Adapter/Platform/PlatformInterface.php b/library/Zend/Db/Adapter/Platform/PlatformInterface.php index d8ec05b2..f0f39f98 100644 --- a/library/Zend/Db/Adapter/Platform/PlatformInterface.php +++ b/library/Zend/Db/Adapter/Platform/PlatformInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Platform/Postgresql.php b/library/Zend/Db/Adapter/Platform/Postgresql.php index 197aa453..440e9a78 100644 --- a/library/Zend/Db/Adapter/Platform/Postgresql.php +++ b/library/Zend/Db/Adapter/Platform/Postgresql.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,11 +14,23 @@ use Zend\Db\Adapter\Driver\Pdo; use Zend\Db\Adapter\Driver\Pgsql; use Zend\Db\Adapter\Exception; -class Postgresql implements PlatformInterface +class Postgresql extends AbstractPlatform { - /** @var resource|\PDO */ + /** + * Overrides value from AbstractPlatform to use proper escaping for Postgres + * + * @var string + */ + protected $quoteIdentifierTo = '""'; + + /** + * @var resource|\PDO + */ protected $resource = null; + /** + * @param null|\Zend\Db\Adapter\Driver\Pgsql\Pgsql|\Zend\Db\Adapter\Driver\Pdo\Pdo|resource|\PDO $driver + */ public function __construct($driver = null) { if ($driver) { @@ -46,9 +58,7 @@ class Postgresql implements PlatformInterface } /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -56,56 +66,15 @@ class Postgresql implements PlatformInterface } /** - * Get quote indentifier symbol - * - * @return string - */ - public function getQuoteIdentifierSymbol() - { - return '"'; - } - - /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - return '"' . str_replace('"', '\\' . '"', $identifier) . '"'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string + * {@inheritDoc} */ public function quoteIdentifierChain($identifierChain) { - $identifierChain = str_replace('"', '\\"', $identifierChain); - if (is_array($identifierChain)) { - $identifierChain = implode('"."', $identifierChain); - } - return '"' . $identifierChain . '"'; + return '"' . implode('"."', (array) str_replace('"', '""', $identifierChain)) . '"'; } /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { @@ -118,20 +87,11 @@ class Postgresql implements PlatformInterface if ($this->resource instanceof \PDO) { return $this->resource->quote($value); } - trigger_error( - 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support ' - . 'can introduce security vulnerabilities in a production environment.' - ); - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; + return 'E' . parent::quoteValue($value); } /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed + * {@inheritDoc} */ public function quoteTrustedValue($value) { @@ -144,69 +104,6 @@ class Postgresql implements PlatformInterface if ($this->resource instanceof \PDO) { return $this->resource->quote($value); } - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; - } - - /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string - */ - public function getIdentifierSeparator() - { - return '.'; - } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"'; - } - } - return implode('', $parts); + return 'E' . parent::quoteTrustedValue($value); } } diff --git a/library/Zend/Db/Adapter/Platform/Sql92.php b/library/Zend/Db/Adapter/Platform/Sql92.php index bbeda46d..afbe90d2 100644 --- a/library/Zend/Db/Adapter/Platform/Sql92.php +++ b/library/Zend/Db/Adapter/Platform/Sql92.php @@ -3,18 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Adapter\Platform; -class Sql92 implements PlatformInterface +class Sql92 extends AbstractPlatform { /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -22,140 +20,14 @@ class Sql92 implements PlatformInterface } /** - * Get quote indentifier symbol - * - * @return string - */ - public function getQuoteIdentifierSymbol() - { - return '"'; - } - - /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - return '"' . str_replace('"', '\\' . '"', $identifier) . '"'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string - */ - public function quoteIdentifierChain($identifierChain) - { - $identifierChain = str_replace('"', '\\"', $identifierChain); - if (is_array($identifierChain)) { - $identifierChain = implode('"."', $identifierChain); - } - return '"' . $identifierChain . '"'; - } - - /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { trigger_error( - 'Attempting to quote a value without specific driver level support can introduce security vulnerabilities in a production environment.' + 'Attempting to quote a value without specific driver level support' + . ' can introduce security vulnerabilities in a production environment.' ); return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; } - - /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed - */ - public function quoteTrustedValue($value) - { - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; - } - - /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string - */ - public function getIdentifierSeparator() - { - return '.'; - } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"'; - } - } - - return implode('', $parts); - } } diff --git a/library/Zend/Db/Adapter/Platform/SqlServer.php b/library/Zend/Db/Adapter/Platform/SqlServer.php index 74a9acb9..5716c06b 100644 --- a/library/Zend/Db/Adapter/Platform/SqlServer.php +++ b/library/Zend/Db/Adapter/Platform/SqlServer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,11 +13,26 @@ use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\Driver\Pdo; use Zend\Db\Adapter\Exception; -class SqlServer implements PlatformInterface +class SqlServer extends AbstractPlatform { - /** @var resource|\PDO */ + /** + * {@inheritDoc} + */ + protected $quoteIdentifier = array('[',']'); + + /** + * {@inheritDoc} + */ + protected $quoteIdentifierTo = '\\'; + + /** + * @var resource|\PDO + */ protected $resource = null; + /** + * @param null|\Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv|\Zend\Db\Adapter\Driver\Pdo\Pdo|resource|\PDO $driver + */ public function __construct($driver = null) { if ($driver) { @@ -26,9 +41,10 @@ class SqlServer implements PlatformInterface } /** - * @param \Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv|\Zend\Db\Adapter\Driver\Pdo\Pdo||resource|\PDO $driver + * @param \Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv|\Zend\Db\Adapter\Driver\Pdo\Pdo|resource|\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException - * @return $this + * + * @return self */ public function setDriver($driver) { @@ -44,9 +60,7 @@ class SqlServer implements PlatformInterface } /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -54,55 +68,23 @@ class SqlServer implements PlatformInterface } /** - * Get quote identifier symbol - * - * @return string + * {@inheritDoc} */ public function getQuoteIdentifierSymbol() { - return array('[', ']'); + return $this->quoteIdentifier; } /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - return '[' . $identifier . ']'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string + * {@inheritDoc} */ public function quoteIdentifierChain($identifierChain) { - if (is_array($identifierChain)) { - $identifierChain = implode('].[', $identifierChain); - } - return '[' . $identifierChain . ']'; + return '[' . implode('].[', (array) $identifierChain) . ']'; } /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { @@ -116,17 +98,12 @@ class SqlServer implements PlatformInterface 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support ' . 'can introduce security vulnerabilities in a production environment.' ); - $value = addcslashes($value, "\000\032"); - return '\'' . str_replace('\'', '\'\'', $value) . '\''; + + return '\'' . str_replace('\'', '\'\'', addcslashes($value, "\000\032")) . '\''; } /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed + * {@inheritDoc} */ public function quoteTrustedValue($value) { @@ -138,66 +115,4 @@ class SqlServer implements PlatformInterface } return '\'' . str_replace('\'', '\'\'', $value) . '\''; } - - /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string - */ - public function getIdentifierSeparator() - { - return '.'; - } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '[' . $part . ']'; - } - } - return implode('', $parts); - } } diff --git a/library/Zend/Db/Adapter/Platform/Sqlite.php b/library/Zend/Db/Adapter/Platform/Sqlite.php index 340c247e..46fece87 100644 --- a/library/Zend/Db/Adapter/Platform/Sqlite.php +++ b/library/Zend/Db/Adapter/Platform/Sqlite.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,11 +13,26 @@ use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\Driver\Pdo; use Zend\Db\Adapter\Exception; -class Sqlite implements PlatformInterface +class Sqlite extends AbstractPlatform { - /** @var \PDO */ + /** + * {@inheritDoc} + */ + protected $quoteIdentifier = array('"','"'); + + /** + * {@inheritDoc} + */ + protected $quoteIdentifierTo = '\''; + + /** + * @var \PDO + */ protected $resource = null; + /** + * @param null|\Zend\Db\Adapter\Driver\Pdo\Pdo||\PDO $driver + */ public function __construct($driver = null) { if ($driver) { @@ -26,9 +41,10 @@ class Sqlite implements PlatformInterface } /** - * @param \Zend\Db\Adapter\Driver\Pdo\Pdo||\PDO $driver + * @param \Zend\Db\Adapter\Driver\Pdo\Pdo|\PDO $driver * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException - * @return $this + * + * @return self */ public function setDriver($driver) { @@ -43,9 +59,7 @@ class Sqlite implements PlatformInterface } /** - * Get name - * - * @return string + * {@inheritDoc} */ public function getName() { @@ -53,56 +67,7 @@ class Sqlite implements PlatformInterface } /** - * Get quote identifier symbol - * - * @return string - */ - public function getQuoteIdentifierSymbol() - { - return '"'; - } - - /** - * Quote identifier - * - * @param string $identifier - * @return string - */ - public function quoteIdentifier($identifier) - { - return '"' . str_replace('"', '\\' . '"', $identifier) . '"'; - } - - /** - * Quote identifier chain - * - * @param string|string[] $identifierChain - * @return string - */ - public function quoteIdentifierChain($identifierChain) - { - $identifierChain = str_replace('"', '\\"', $identifierChain); - if (is_array($identifierChain)) { - $identifierChain = implode('"."', $identifierChain); - } - return '"' . $identifierChain . '"'; - } - - /** - * Get quote value symbol - * - * @return string - */ - public function getQuoteValueSymbol() - { - return '\''; - } - - /** - * Quote value - * - * @param string $value - * @return string + * {@inheritDoc} */ public function quoteValue($value) { @@ -116,20 +81,11 @@ class Sqlite implements PlatformInterface return $resource->quote($value); } - trigger_error( - 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support ' - . 'can introduce security vulnerabilities in a production environment.' - ); - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; + return parent::quoteValue($value); } /** - * Quote Trusted Value - * - * The ability to quote values without notices - * - * @param $value - * @return mixed + * {@inheritDoc} */ public function quoteTrustedValue($value) { @@ -143,68 +99,6 @@ class Sqlite implements PlatformInterface return $resource->quote($value); } - return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\''; - } - - /** - * Quote value list - * - * @param string|string[] $valueList - * @return string - */ - public function quoteValueList($valueList) - { - if (!is_array($valueList)) { - return $this->quoteValue($valueList); - } - $value = reset($valueList); - do { - $valueList[key($valueList)] = $this->quoteValue($value); - } while ($value = next($valueList)); - return implode(', ', $valueList); - } - - /** - * Get identifier separator - * - * @return string - */ - public function getIdentifierSeparator() - { - return '.'; - } - - /** - * Quote identifier in fragment - * - * @param string $identifier - * @param array $safeWords - * @return string - */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) - { - $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if ($safeWords) { - $safeWords = array_flip($safeWords); - $safeWords = array_change_key_case($safeWords, CASE_LOWER); - } - foreach ($parts as $i => $part) { - if ($safeWords && isset($safeWords[strtolower($part)])) { - continue; - } - switch ($part) { - case ' ': - case '.': - case '*': - case 'AS': - case 'As': - case 'aS': - case 'as': - break; - default: - $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"'; - } - } - return implode('', $parts); + return parent::quoteTrustedValue($value); } } diff --git a/library/Zend/Db/Adapter/Profiler/Profiler.php b/library/Zend/Db/Adapter/Profiler/Profiler.php index 5115e3f3..ca0cad05 100644 --- a/library/Zend/Db/Adapter/Profiler/Profiler.php +++ b/library/Zend/Db/Adapter/Profiler/Profiler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php b/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php index a0b631d9..a45e6fb7 100644 --- a/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php +++ b/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,5 +11,8 @@ namespace Zend\Db\Adapter\Profiler; interface ProfilerAwareInterface { + /** + * @param ProfilerInterface $profiler + */ public function setProfiler(ProfilerInterface $profiler); } diff --git a/library/Zend/Db/Adapter/Profiler/ProfilerInterface.php b/library/Zend/Db/Adapter/Profiler/ProfilerInterface.php index 5f8ee90e..ed0c6396 100644 --- a/library/Zend/Db/Adapter/Profiler/ProfilerInterface.php +++ b/library/Zend/Db/Adapter/Profiler/ProfilerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/StatementContainer.php b/library/Zend/Db/Adapter/StatementContainer.php index 51dff646..59b7d506 100644 --- a/library/Zend/Db/Adapter/StatementContainer.php +++ b/library/Zend/Db/Adapter/StatementContainer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Adapter/StatementContainerInterface.php b/library/Zend/Db/Adapter/StatementContainerInterface.php index 098d6a6f..fc8964d1 100644 --- a/library/Zend/Db/Adapter/StatementContainerInterface.php +++ b/library/Zend/Db/Adapter/StatementContainerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Exception/ErrorException.php b/library/Zend/Db/Exception/ErrorException.php index f6915a8c..6a3d5a29 100644 --- a/library/Zend/Db/Exception/ErrorException.php +++ b/library/Zend/Db/Exception/ErrorException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Exception/ExceptionInterface.php b/library/Zend/Db/Exception/ExceptionInterface.php index 9f480dd4..f8d23d23 100644 --- a/library/Zend/Db/Exception/ExceptionInterface.php +++ b/library/Zend/Db/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Exception/InvalidArgumentException.php b/library/Zend/Db/Exception/InvalidArgumentException.php index efeba3a7..52a6f6c0 100644 --- a/library/Zend/Db/Exception/InvalidArgumentException.php +++ b/library/Zend/Db/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Exception/RuntimeException.php b/library/Zend/Db/Exception/RuntimeException.php index 57ed5847..a95db657 100644 --- a/library/Zend/Db/Exception/RuntimeException.php +++ b/library/Zend/Db/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Exception/UnexpectedValueException.php b/library/Zend/Db/Exception/UnexpectedValueException.php index 9671d8a4..febcd330 100644 --- a/library/Zend/Db/Exception/UnexpectedValueException.php +++ b/library/Zend/Db/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Metadata.php b/library/Zend/Db/Metadata/Metadata.php index 3db73d85..1c4bc0cc 100644 --- a/library/Zend/Db/Metadata/Metadata.php +++ b/library/Zend/Db/Metadata/Metadata.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/MetadataInterface.php b/library/Zend/Db/Metadata/MetadataInterface.php index f0f58eb3..1a3772dc 100644 --- a/library/Zend/Db/Metadata/MetadataInterface.php +++ b/library/Zend/Db/Metadata/MetadataInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Object/AbstractTableObject.php b/library/Zend/Db/Metadata/Object/AbstractTableObject.php index e315e891..d51859e6 100644 --- a/library/Zend/Db/Metadata/Object/AbstractTableObject.php +++ b/library/Zend/Db/Metadata/Object/AbstractTableObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Object/ColumnObject.php b/library/Zend/Db/Metadata/Object/ColumnObject.php index e76a91a9..a9b1288c 100644 --- a/library/Zend/Db/Metadata/Object/ColumnObject.php +++ b/library/Zend/Db/Metadata/Object/ColumnObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -372,7 +372,7 @@ class ColumnObject if (array_key_exists($errataName, $this->errata)) { return $this->errata[$errataName]; } - return null; + return; } /** diff --git a/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php b/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php index 56836880..81147bf6 100644 --- a/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php +++ b/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Object/ConstraintObject.php b/library/Zend/Db/Metadata/Object/ConstraintObject.php index 089c5ea1..4c10c296 100644 --- a/library/Zend/Db/Metadata/Object/ConstraintObject.php +++ b/library/Zend/Db/Metadata/Object/ConstraintObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Object/TableObject.php b/library/Zend/Db/Metadata/Object/TableObject.php index 8735fbfc..1a3ea409 100644 --- a/library/Zend/Db/Metadata/Object/TableObject.php +++ b/library/Zend/Db/Metadata/Object/TableObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Object/TriggerObject.php b/library/Zend/Db/Metadata/Object/TriggerObject.php index eece8c4f..d0e424ac 100644 --- a/library/Zend/Db/Metadata/Object/TriggerObject.php +++ b/library/Zend/Db/Metadata/Object/TriggerObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Object/ViewObject.php b/library/Zend/Db/Metadata/Object/ViewObject.php index 5130e9ec..a580d480 100644 --- a/library/Zend/Db/Metadata/Object/ViewObject.php +++ b/library/Zend/Db/Metadata/Object/ViewObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Source/AbstractSource.php b/library/Zend/Db/Metadata/Source/AbstractSource.php index 63d63a92..7b57dc29 100644 --- a/library/Zend/Db/Metadata/Source/AbstractSource.php +++ b/library/Zend/Db/Metadata/Source/AbstractSource.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Source/MysqlMetadata.php b/library/Zend/Db/Metadata/Source/MysqlMetadata.php index ac9642f9..4c28f3f2 100644 --- a/library/Zend/Db/Metadata/Source/MysqlMetadata.php +++ b/library/Zend/Db/Metadata/Source/MysqlMetadata.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Source/OracleMetadata.php b/library/Zend/Db/Metadata/Source/OracleMetadata.php index 44deac13..3207dc6c 100644 --- a/library/Zend/Db/Metadata/Source/OracleMetadata.php +++ b/library/Zend/Db/Metadata/Source/OracleMetadata.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php b/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php index bb274487..ca58ce8d 100644 --- a/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php +++ b/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Source/SqlServerMetadata.php b/library/Zend/Db/Metadata/Source/SqlServerMetadata.php index b2b3e76f..8c1fe7ef 100644 --- a/library/Zend/Db/Metadata/Source/SqlServerMetadata.php +++ b/library/Zend/Db/Metadata/Source/SqlServerMetadata.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Metadata/Source/SqliteMetadata.php b/library/Zend/Db/Metadata/Source/SqliteMetadata.php index f3869af8..8006133d 100644 --- a/library/Zend/Db/Metadata/Source/SqliteMetadata.php +++ b/library/Zend/Db/Metadata/Source/SqliteMetadata.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -78,9 +78,6 @@ class SqliteMetadata extends AbstractSource $this->prepareDataHierarchy('columns', $schema, $table); $this->prepareDataHierarchy('sqlite_columns', $schema, $table); - $p = $this->adapter->getPlatform(); - - $results = $this->fetchPragma('table_info', $table, $schema); $columns = array(); @@ -274,7 +271,7 @@ class SqliteMetadata extends AbstractSource } if (!preg_match($re, $sql, $matches)) { - return null; + return; } return array( 'view_definition' => $matches['view_definition'], @@ -294,7 +291,7 @@ class SqliteMetadata extends AbstractSource 'TRIGGER', array('IF', 'NOT', 'EXISTS'), $identifierChain, - array('(?BEFORE|AFTER|INSTEAD\\s+OF)',), + array('(?BEFORE|AFTER|INSTEAD\\s+OF)', ), '(?DELETE|INSERT|UPDATE)', array('OF', '(?' . $identifierList . ')'), 'ON', @@ -309,7 +306,7 @@ class SqliteMetadata extends AbstractSource } if (!preg_match($re, $sql, $matches)) { - return null; + return; } $data = array(); diff --git a/library/Zend/Db/ResultSet/AbstractResultSet.php b/library/Zend/Db/ResultSet/AbstractResultSet.php index 0db4c2d3..f1f904d9 100644 --- a/library/Zend/Db/ResultSet/AbstractResultSet.php +++ b/library/Zend/Db/ResultSet/AbstractResultSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -50,7 +50,7 @@ abstract class AbstractResultSet implements Iterator, ResultSetInterface /** * Set the data source for the result set * - * @param Iterator|IteratorAggregate|ResultInterface $dataSource + * @param array|Iterator|IteratorAggregate|ResultInterface $dataSource * @return ResultSet * @throws Exception\InvalidArgumentException */ @@ -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'); } - if ($this->count == null && $this->dataSource instanceof Countable) { + if ($this->count === null && $this->dataSource instanceof Countable) { $this->count = $this->dataSource->count(); } @@ -171,7 +171,9 @@ abstract class AbstractResultSet implements Iterator, ResultSetInterface if ($this->buffer === null) { $this->buffer = -2; // implicitly disable buffering from here on } - $this->dataSource->next(); + if (!is_array($this->buffer) || $this->position == $this->dataSource->key()) { + $this->dataSource->next(); + } $this->position++; } diff --git a/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php b/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php index 7f7648b3..c4aa1aa8 100644 --- a/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php +++ b/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/ResultSet/Exception/InvalidArgumentException.php b/library/Zend/Db/ResultSet/Exception/InvalidArgumentException.php index 42f3c93a..32b62677 100644 --- a/library/Zend/Db/ResultSet/Exception/InvalidArgumentException.php +++ b/library/Zend/Db/ResultSet/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/ResultSet/Exception/RuntimeException.php b/library/Zend/Db/ResultSet/Exception/RuntimeException.php index f201ac10..244c1d97 100644 --- a/library/Zend/Db/ResultSet/Exception/RuntimeException.php +++ b/library/Zend/Db/ResultSet/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/ResultSet/HydratingResultSet.php b/library/Zend/Db/ResultSet/HydratingResultSet.php index a4bd9162..74b9c0b8 100644 --- a/library/Zend/Db/ResultSet/HydratingResultSet.php +++ b/library/Zend/Db/ResultSet/HydratingResultSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -55,6 +55,16 @@ class HydratingResultSet extends AbstractResultSet return $this; } + /** + * Get the row object prototype + * + * @return object + */ + public function getObjectPrototype() + { + return $this->objectPrototype; + } + /** * Set the hydrator to use for each row object * diff --git a/library/Zend/Db/ResultSet/ResultSet.php b/library/Zend/Db/ResultSet/ResultSet.php index 2286410c..59bfac9d 100644 --- a/library/Zend/Db/ResultSet/ResultSet.php +++ b/library/Zend/Db/ResultSet/ResultSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/ResultSet/ResultSetInterface.php b/library/Zend/Db/ResultSet/ResultSetInterface.php index c2bbd73b..63de3691 100644 --- a/library/Zend/Db/ResultSet/ResultSetInterface.php +++ b/library/Zend/Db/ResultSet/ResultSetInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/AbstractRowGateway.php b/library/Zend/Db/RowGateway/AbstractRowGateway.php index 4e1ee461..662fb226 100644 --- a/library/Zend/Db/RowGateway/AbstractRowGateway.php +++ b/library/Zend/Db/RowGateway/AbstractRowGateway.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -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.'); } - if ($this->primaryKeyColumn == null) { + if ($this->primaryKeyColumn === null) { throw new Exception\RuntimeException('This row object does not have a primary key column set.'); } elseif (is_string($this->primaryKeyColumn)) { $this->primaryKeyColumn = (array) $this->primaryKeyColumn; diff --git a/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php b/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php index 7bb37fc9..54004999 100644 --- a/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php +++ b/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/Exception/InvalidArgumentException.php b/library/Zend/Db/RowGateway/Exception/InvalidArgumentException.php index 7db3117d..1f820341 100644 --- a/library/Zend/Db/RowGateway/Exception/InvalidArgumentException.php +++ b/library/Zend/Db/RowGateway/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/Exception/RuntimeException.php b/library/Zend/Db/RowGateway/Exception/RuntimeException.php index 0b698c64..acfa6b24 100644 --- a/library/Zend/Db/RowGateway/Exception/RuntimeException.php +++ b/library/Zend/Db/RowGateway/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/Feature/AbstractFeature.php b/library/Zend/Db/RowGateway/Feature/AbstractFeature.php index ead00679..d53a0ccb 100644 --- a/library/Zend/Db/RowGateway/Feature/AbstractFeature.php +++ b/library/Zend/Db/RowGateway/Feature/AbstractFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/Feature/FeatureSet.php b/library/Zend/Db/RowGateway/Feature/FeatureSet.php index de3b2344..424251c6 100644 --- a/library/Zend/Db/RowGateway/Feature/FeatureSet.php +++ b/library/Zend/Db/RowGateway/Feature/FeatureSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/RowGateway.php b/library/Zend/Db/RowGateway/RowGateway.php index df2295c1..97e7fdab 100644 --- a/library/Zend/Db/RowGateway/RowGateway.php +++ b/library/Zend/Db/RowGateway/RowGateway.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/RowGateway/RowGatewayInterface.php b/library/Zend/Db/RowGateway/RowGatewayInterface.php index e0a20b55..7683e94b 100644 --- a/library/Zend/Db/RowGateway/RowGatewayInterface.php +++ b/library/Zend/Db/RowGateway/RowGatewayInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/AbstractExpression.php b/library/Zend/Db/Sql/AbstractExpression.php new file mode 100644 index 00000000..de207ed5 --- /dev/null +++ b/library/Zend/Db/Sql/AbstractExpression.php @@ -0,0 +1,93 @@ +buildNormalizedArgument($argument, self::TYPE_VALUE); + } + + if (is_scalar($argument) || $argument === null) { + return $this->buildNormalizedArgument($argument, $defaultType); + } + + if (is_array($argument)) { + $value = current($argument); + + if ($value instanceof ExpressionInterface || $value instanceof SqlInterface) { + return $this->buildNormalizedArgument($value, self::TYPE_VALUE); + } + + $key = key($argument); + + if (is_integer($key) && ! in_array($value, $this->allowedTypes)) { + return $this->buildNormalizedArgument($value, $defaultType); + } + + return $this->buildNormalizedArgument($key, $value); + } + + throw new Exception\InvalidArgumentException(sprintf( + '$argument should be %s or %s or %s or %s or %s, "%s" given', + 'null', + 'scalar', + 'array', + 'Zend\Db\Sql\ExpressionInterface', + 'Zend\Db\Sql\SqlInterface', + is_object($argument) ? get_class($argument) : gettype($argument) + )); + } + + /** + * @param mixed $argument + * @param string $argumentType + * + * @return array + * + * @throws Exception\InvalidArgumentException + */ + private function buildNormalizedArgument($argument, $argumentType) + { + if (! in_array($argumentType, $this->allowedTypes)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Argument type should be in array(%s)', + implode(',', $this->allowedTypes) + )); + } + + return array( + $argument, + $argumentType, + ); + } +} diff --git a/library/Zend/Db/Sql/AbstractPreparableSql.php b/library/Zend/Db/Sql/AbstractPreparableSql.php new file mode 100644 index 00000000..0741f38f --- /dev/null +++ b/library/Zend/Db/Sql/AbstractPreparableSql.php @@ -0,0 +1,39 @@ +getParameterContainer(); + + if (! $parameterContainer instanceof ParameterContainer) { + $parameterContainer = new ParameterContainer(); + + $statementContainer->setParameterContainer($parameterContainer); + } + + $statementContainer->setSql( + $this->buildSqlString($adapter->getPlatform(), $adapter->getDriver(), $parameterContainer) + ); + + return $statementContainer; + } +} diff --git a/library/Zend/Db/Sql/AbstractSql.php b/library/Zend/Db/Sql/AbstractSql.php index 80cd7318..f99b3b9c 100644 --- a/library/Zend/Db/Sql/AbstractSql.php +++ b/library/Zend/Db/Sql/AbstractSql.php @@ -3,23 +3,24 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql; -use Zend\Db\Adapter\Adapter; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\StatementContainer; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; +use Zend\Db\Adapter\Platform\Sql92 as DefaultAdapterPlatform; -abstract class AbstractSql +abstract class AbstractSql implements SqlInterface { /** - * @var array + * Specifications for Sql String generation + * + * @var string[]|array[] */ protected $specifications = array(); @@ -33,63 +34,143 @@ abstract class AbstractSql */ protected $instanceParameterIndex = array(); - protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, DriverInterface $driver = null, $namedParameterPrefix = null) + /** + * {@inheritDoc} + */ + public function getSqlString(PlatformInterface $adapterPlatform = null) { + $adapterPlatform = ($adapterPlatform) ?: new DefaultAdapterPlatform; + return $this->buildSqlString($adapterPlatform); + } + + /** + * @param PlatformInterface $platform + * @param null|DriverInterface $driver + * @param null|ParameterContainer $parameterContainer + * @return string + */ + protected function buildSqlString( + PlatformInterface $platform, + DriverInterface $driver = null, + ParameterContainer $parameterContainer = null + ) { + $this->localizeVariables(); + + $sqls = array(); + $parameters = array(); + + foreach ($this->specifications as $name => $specification) { + $parameters[$name] = $this->{'process' . $name}( + $platform, + $driver, + $parameterContainer, + $sqls, + $parameters + ); + + if ($specification && is_array($parameters[$name])) { + $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]); + + continue; + } + + if (is_string($parameters[$name])) { + $sqls[$name] = $parameters[$name]; + } + } + return rtrim(implode(' ', $sqls), "\n ,"); + } + + /** + * @staticvar int $runtimeExpressionPrefix + * @param ExpressionInterface $expression + * @param PlatformInterface $platform + * @param null|DriverInterface $driver + * @param null|ParameterContainer $parameterContainer + * @param null|string $namedParameterPrefix + * @return string + * @throws Exception\RuntimeException + */ + protected function processExpression( + ExpressionInterface $expression, + 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 $runtimeExpressionPrefix = 0; - if ($driver && ((!is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) { + if ($parameterContainer && ((!is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) { $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix); + } else { + $namedParameterPrefix = preg_replace('/\s/', '__', $namedParameterPrefix); } $sql = ''; - $statementContainer = new StatementContainer; - $parameterContainer = $statementContainer->getParameterContainer(); // initialize variables $parts = $expression->getExpressionData(); - if (!isset($this->instanceParameterIndex[$namedParameterPrefix])) { + if (! isset($this->instanceParameterIndex[$namedParameterPrefix])) { $this->instanceParameterIndex[$namedParameterPrefix] = 1; } $expressionParamIndex = &$this->instanceParameterIndex[$namedParameterPrefix]; 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)) { $sql .= $part; continue; } - if (!is_array($part)) { - throw new Exception\RuntimeException('Elements returned from getExpressionData() array must be a string or array.'); + if (! is_array($part)) { + throw new Exception\RuntimeException( + 'Elements returned from getExpressionData() array must be a string or array.' + ); } - // 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]; - $types = (isset($part[2])) ? $part[2] : array(); + $types = isset($part[2]) ? $part[2] : array(); foreach ($values as $vIndex => $value) { - if (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_IDENTIFIER) { - $values[$vIndex] = $platform->quoteIdentifierInFragment($value); - } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE && $value instanceof Select) { + if (!isset($types[$vIndex])) { + continue; + } + $type = $types[$vIndex]; + if ($value instanceof Select) { // process sub-select - if ($driver) { - $values[$vIndex] = '(' . $this->processSubSelect($value, $platform, $driver, $parameterContainer) . ')'; - } else { - $values[$vIndex] = '(' . $this->processSubSelect($value, $platform) . ')'; - } - } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE && $value instanceof ExpressionInterface) { + $values[$vIndex] = '(' + . $this->processSubSelect($value, $platform, $driver, $parameterContainer) + . ')'; + } elseif ($value instanceof ExpressionInterface) { // recursive call to satisfy nested expressions - $innerStatementContainer = $this->processExpression($value, $platform, $driver, $namedParameterPrefix . $vIndex . 'subpart'); - $values[$vIndex] = $innerStatementContainer->getSql(); - if ($driver) { - $parameterContainer->merge($innerStatementContainer->getParameterContainer()); - } - } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE) { + $values[$vIndex] = $this->processExpression( + $value, + $platform, + $driver, + $parameterContainer, + $namedParameterPrefix . $vIndex . 'subpart' + ); + } elseif ($type == ExpressionInterface::TYPE_IDENTIFIER) { + $values[$vIndex] = $platform->quoteIdentifierInFragment($value); + } elseif ($type == ExpressionInterface::TYPE_VALUE) { // if prepareType is set, it means that this particular value must be // passed back to the statement in a way it can be used as a placeholder value - if ($driver) { + if ($parameterContainer) { $name = $namedParameterPrefix . $expressionParamIndex++; $parameterContainer->offsetSet($name, $value); $values[$vIndex] = $driver->formatParameterName($name); @@ -98,23 +179,25 @@ abstract class AbstractSql // if not a preparable statement, simply quote the value and move on $values[$vIndex] = $platform->quoteValue($value); - } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_LITERAL) { + } elseif ($type == ExpressionInterface::TYPE_LITERAL) { $values[$vIndex] = $value; } } - // 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); } - $statementContainer->setSql($sql); - return $statementContainer; + return $sql; } /** - * @param $specifications - * @param $parameters + * @param string|array $specifications + * @param string|array $parameters + * * @return string + * * @throws Exception\RuntimeException */ protected function createSqlFromSpecificationAndParameters($specifications, $parameters) @@ -124,10 +207,12 @@ abstract class AbstractSql } $parametersCount = count($parameters); + foreach ($specifications as $specificationString => $paramSpecs) { if ($parametersCount == count($paramSpecs)) { break; } + unset($specificationString, $paramSpecs); } @@ -144,7 +229,10 @@ abstract class AbstractSql foreach ($paramsForPosition as $multiParamsForPosition) { $ppCount = count($multiParamsForPosition); 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); } @@ -152,7 +240,10 @@ abstract class AbstractSql } elseif ($paramSpecs[$position] !== null) { $ppCount = count($paramsForPosition); 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); } else { @@ -162,40 +253,129 @@ abstract class AbstractSql return vsprintf($specificationString, $topParameters); } - protected function processSubSelect(Select $subselect, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) - { - if ($driver) { - $stmtContainer = new StatementContainer; + /** + * @param Select $subselect + * @param PlatformInterface $platform + * @param null|DriverInterface $driver + * @param null|ParameterContainer $parameterContainer + * @return string + */ + protected function processSubSelect( + Select $subselect, + PlatformInterface $platform, + DriverInterface $driver = null, + ParameterContainer $parameterContainer = null + ) { + if ($this instanceof PlatformDecoratorInterface) { + $decorator = clone $this; + $decorator->setSubject($subselect); + } else { + $decorator = $subselect; + } + if ($parameterContainer) { // Track subselect prefix and count for parameters + $processInfoContext = ($decorator instanceof PlatformDecoratorInterface) ? $subselect : $decorator; $this->processInfo['subselectCount']++; - $subselect->processInfo['subselectCount'] = $this->processInfo['subselectCount']; - $subselect->processInfo['paramPrefix'] = 'subselect' . $subselect->processInfo['subselectCount']; + $processInfoContext->processInfo['subselectCount'] = $this->processInfo['subselectCount']; + $processInfoContext->processInfo['paramPrefix'] = 'subselect' + . $processInfoContext->processInfo['subselectCount']; - // call subselect - if ($this instanceof PlatformDecoratorInterface) { - /** @var Select|PlatformDecoratorInterface $subselectDecorator */ - $subselectDecorator = clone $this; - $subselectDecorator->setSubject($subselect); - $subselectDecorator->prepareStatement(new Adapter($driver, $platform), $stmtContainer); - } else { - $subselect->prepareStatement(new Adapter($driver, $platform), $stmtContainer); - } + $sql = $decorator->buildSqlString($platform, $driver, $parameterContainer); // copy count - $this->processInfo['subselectCount'] = $subselect->processInfo['subselectCount']; - - $parameterContainer->merge($stmtContainer->getParameterContainer()->getNamedArray()); - $sql = $stmtContainer->getSql(); - } else { - if ($this instanceof PlatformDecoratorInterface) { - $subselectDecorator = clone $this; - $subselectDecorator->setSubject($subselect); - $sql = $subselectDecorator->getSqlString($platform); - } else { - $sql = $subselect->getSqlString($platform); - } + $this->processInfo['subselectCount'] = $decorator->processInfo['subselectCount']; + return $sql; + } + + return $decorator->buildSqlString($platform, $driver, $parameterContainer); + } + + /** + * @param null|array|ExpressionInterface|Select $column + * @param PlatformInterface $platform + * @param null|DriverInterface $driver + * @param null|string $namedParameterPrefix + * @param null|ParameterContainer $parameterContainer + * @return string + */ + protected function resolveColumnValue( + $column, + PlatformInterface $platform, + DriverInterface $driver = null, + ParameterContainer $parameterContainer = null, + $namedParameterPrefix = null + ) { + $namedParameterPrefix = ! $namedParameterPrefix + ? $namedParameterPrefix + : $this->processInfo['paramPrefix'] . $namedParameterPrefix; + $isIdentifier = false; + $fromTable = ''; + if (is_array($column)) { + if (isset($column['isIdentifier'])) { + $isIdentifier = (bool) $column['isIdentifier']; + } + if (isset($column['fromTable']) && $column['fromTable'] !== null) { + $fromTable = $column['fromTable']; + } + $column = $column['column']; + } + + if ($column instanceof ExpressionInterface) { + return $this->processExpression($column, $platform, $driver, $parameterContainer, $namedParameterPrefix); + } + if ($column instanceof Select) { + return '(' . $this->processSubSelect($column, $platform, $driver, $parameterContainer) . ')'; + } + if ($column === null) { + return 'NULL'; + } + return $isIdentifier + ? $fromTable . $platform->quoteIdentifierInFragment($column) + : $platform->quoteValue($column); + } + + /** + * @param string|TableIdentifier|Select $table + * @param PlatformInterface $platform + * @param DriverInterface $driver + * @param ParameterContainer $parameterContainer + * @return string + */ + protected function resolveTable( + $table, + PlatformInterface $platform, + DriverInterface $driver = null, + ParameterContainer $parameterContainer = null + ) { + $schema = null; + if ($table instanceof TableIdentifier) { + list($table, $schema) = $table->getTableAndSchema(); + } + + if ($table instanceof Select) { + $table = '(' . $this->processSubselect($table, $platform, $driver, $parameterContainer) . ')'; + } elseif ($table) { + $table = $platform->quoteIdentifier($table); + } + + if ($schema && $table) { + $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; + } + return $table; + } + + /** + * Copy variables from the subject into the local properties + */ + protected function localizeVariables() + { + if (! $this instanceof PlatformDecoratorInterface) { + return; + } + + foreach (get_object_vars($this->subject) as $name => $value) { + $this->{$name} = $value; } - return $sql; } } diff --git a/library/Zend/Db/Sql/Combine.php b/library/Zend/Db/Sql/Combine.php new file mode 100644 index 00000000..1b0ed0f4 --- /dev/null +++ b/library/Zend/Db/Sql/Combine.php @@ -0,0 +1,207 @@ + '%1$s (%2$s) ', + ); + + /** + * @var Select[][] + */ + private $combine = array(); + + /** + * @param Select|array|null $select + * @param string $type + * @param string $modifier + */ + public function __construct($select = null, $type = self::COMBINE_UNION, $modifier = '') + { + if ($select) { + $this->combine($select, $type, $modifier); + } + } + + /** + * Create combine clause + * + * @param Select|array $select + * @param string $type + * @param string $modifier + * + * @return self + */ + public function combine($select, $type = self::COMBINE_UNION, $modifier = '') + { + if (is_array($select)) { + foreach ($select as $combine) { + if ($combine instanceof Select) { + $combine = array($combine); + } + + $this->combine( + $combine[0], + isset($combine[1]) ? $combine[1] : $type, + isset($combine[2]) ? $combine[2] : $modifier + ); + } + return $this; + } + + if (! $select instanceof Select) { + throw new Exception\InvalidArgumentException(sprintf( + '$select must be a array or instance of Select, "%s" given', + is_object($select) ? get_class($select) : gettype($select) + )); + } + + $this->combine[] = array( + 'select' => $select, + 'type' => $type, + 'modifier' => $modifier + ); + return $this; + } + + /** + * Create union clause + * + * @param Select|array $select + * @param string $modifier + * + * @return self + */ + public function union($select, $modifier = '') + { + return $this->combine($select, self::COMBINE_UNION, $modifier); + } + + /** + * Create except clause + * + * @param Select|array $select + * @param string $modifier + * + * @return self + */ + public function except($select, $modifier = '') + { + return $this->combine($select, self::COMBINE_EXCEPT, $modifier); + } + + /** + * Create intersect clause + * + * @param Select|array $select + * @param string $modifier + * @return self + */ + public function intersect($select, $modifier = '') + { + return $this->combine($select, self::COMBINE_INTERSECT, $modifier); + } + + /** + * Build sql string + * + * @param PlatformInterface $platform + * @param DriverInterface $driver + * @param ParameterContainer $parameterContainer + * + * @return string + */ + protected function buildSqlString(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) + { + if (!$this->combine) { + return; + } + + $sql = ''; + foreach ($this->combine as $i => $combine) { + $type = $i == 0 + ? '' + : strtoupper($combine['type'] . ($combine['modifier'] ? ' ' . $combine['modifier'] : '')); + $select = $this->processSubSelect($combine['select'], $platform, $driver, $parameterContainer); + $sql .= sprintf( + $this->specifications[self::COMBINE], + $type, + $select + ); + } + return trim($sql, ' '); + } + + /** + * @return $this + */ + public function alignColumns() + { + if (!$this->combine) { + return $this; + } + + $allColumns = array(); + foreach ($this->combine as $combine) { + $allColumns = array_merge( + $allColumns, + $combine['select']->getRawState(self::COLUMNS) + ); + } + + foreach ($this->combine as $combine) { + $combineColumns = $combine['select']->getRawState(self::COLUMNS); + $aligned = array(); + foreach ($allColumns as $alias => $column) { + $aligned[$alias] = isset($combineColumns[$alias]) + ? $combineColumns[$alias] + : new Predicate\Expression('NULL'); + } + $combine['select']->columns($aligned, false); + } + return $this; + } + + /** + * Get raw state + * + * @param string $key + * + * @return array + */ + public function getRawState($key = null) + { + $rawState = array( + self::COMBINE => $this->combine, + self::COLUMNS => $this->combine + ? $this->combine[0]['select']->getRawState(self::COLUMNS) + : array(), + ); + return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; + } +} diff --git a/library/Zend/Db/Sql/Ddl/AlterTable.php b/library/Zend/Db/Sql/Ddl/AlterTable.php index 2721db5a..467bc2e2 100644 --- a/library/Zend/Db/Sql/Ddl/AlterTable.php +++ b/library/Zend/Db/Sql/Ddl/AlterTable.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92 as AdapterSql92Platform; use Zend\Db\Sql\AbstractSql; class AlterTable extends AbstractSql implements SqlInterface @@ -55,27 +54,27 @@ class AlterTable extends AbstractSql implements SqlInterface self::TABLE => "ALTER TABLE %1\$s\n", self::ADD_COLUMNS => array( "%1\$s" => array( - array(1 => 'ADD COLUMN %1$s', 'combinedby' => ",\n") + array(1 => "ADD COLUMN %1\$s,\n", 'combinedby' => "") ) ), self::CHANGE_COLUMNS => array( "%1\$s" => array( - array(2 => 'CHANGE COLUMN %1$s %2$s', 'combinedby' => ",\n"), + array(2 => "CHANGE COLUMN %1\$s %2\$s,\n", 'combinedby' => ""), ) ), self::DROP_COLUMNS => array( "%1\$s" => array( - array(1 => 'DROP COLUMN %1$s', 'combinedby' => ",\n"), + array(1 => "DROP COLUMN %1\$s,\n", 'combinedby' => ""), ) ), self::ADD_CONSTRAINTS => array( "%1\$s" => array( - array(1 => 'ADD %1$s', 'combinedby' => ",\n"), + array(1 => "ADD %1\$s,\n", 'combinedby' => ""), ) ), self::DROP_CONSTRAINTS => array( "%1\$s" => array( - array(1 => 'DROP CONSTRAINT %1$s', 'combinedby' => ",\n"), + array(1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ""), ) ) ); @@ -178,36 +177,6 @@ class AlterTable extends AbstractSql implements SqlInterface return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - /** - * @param PlatformInterface $adapterPlatform - * @return string - */ - public function getSqlString(PlatformInterface $adapterPlatform = null) - { - // get platform, or create default - $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform; - - $sqls = array(); - $parameters = array(); - - foreach ($this->specifications as $name => $specification) { - $parameters[$name] = $this->{'process' . $name}($adapterPlatform, null, null, $sqls, $parameters); - if ($specification && is_array($parameters[$name]) && ($parameters[$name] != array(array()))) { - $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]); - } - if (stripos($name, 'table') === false && $parameters[$name] !== array(array())) { - $sqls[] = ",\n"; - } - } - - // remove last ,\n - array_pop($sqls); - - $sql = implode('', $sqls); - - return $sql; - } - protected function processTable(PlatformInterface $adapterPlatform = null) { return array($adapterPlatform->quoteIdentifier($this->table)); @@ -217,7 +186,7 @@ class AlterTable extends AbstractSql implements SqlInterface { $sqls = array(); foreach ($this->addColumns as $column) { - $sqls[] = $this->processExpression($column, $adapterPlatform)->getSql(); + $sqls[] = $this->processExpression($column, $adapterPlatform); } return array($sqls); @@ -229,7 +198,7 @@ class AlterTable extends AbstractSql implements SqlInterface foreach ($this->changeColumns as $name => $column) { $sqls[] = array( $adapterPlatform->quoteIdentifier($name), - $this->processExpression($column, $adapterPlatform)->getSql() + $this->processExpression($column, $adapterPlatform) ); } diff --git a/library/Zend/Db/Sql/Ddl/Column/AbstractLengthColumn.php b/library/Zend/Db/Sql/Ddl/Column/AbstractLengthColumn.php new file mode 100644 index 00000000..8bc50740 --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/AbstractLengthColumn.php @@ -0,0 +1,72 @@ +setLength($length); + + parent::__construct($name, $nullable, $default, $options); + } + + /** + * @param int $length + * + * @return self + */ + public function setLength($length) + { + $this->length = (int) $length; + + return $this; + } + + /** + * @return int + */ + public function getLength() + { + return $this->length; + } + + /** + * @return string + */ + protected function getLengthExpression() + { + return (string) $this->length; + } + + /** + * @return array + */ + public function getExpressionData() + { + $data = parent::getExpressionData(); + + if ($this->getLengthExpression()) { + $data[0][1][1] .= '(' . $this->getLengthExpression() . ')'; + } + + return $data; + } +} diff --git a/library/Zend/Db/Sql/Ddl/Column/AbstractPrecisionColumn.php b/library/Zend/Db/Sql/Ddl/Column/AbstractPrecisionColumn.php new file mode 100644 index 00000000..d148367d --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -0,0 +1,80 @@ +setDecimal($decimal); + + parent::__construct($name, $digits, $nullable, $default, $options); + } + + /** + * @param int $digits + * + * @return self + */ + public function setDigits($digits) + { + return $this->setLength($digits); + } + + /** + * @return int + */ + public function getDigits() + { + return $this->getLength(); + } + + /** + * @param int|null $decimal + * @return self + */ + public function setDecimal($decimal) + { + $this->decimal = null === $decimal ? null : (int) $decimal; + + return $this; + } + + /** + * @return int|null + */ + public function getDecimal() + { + return $this->decimal; + } + + /** + * {@inheritDoc} + */ + protected function getLengthExpression() + { + if ($this->decimal !== null) { + return $this->length . ',' . $this->decimal; + } + + return $this->length; + } +} diff --git a/library/Zend/Db/Sql/Ddl/Column/AbstractTimestampColumn.php b/library/Zend/Db/Sql/Ddl/Column/AbstractTimestampColumn.php new file mode 100644 index 00000000..933c8455 --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/AbstractTimestampColumn.php @@ -0,0 +1,63 @@ +specification; + + $params = array(); + $params[] = $this->name; + $params[] = $this->type; + + $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); + + if (!$this->isNullable) { + $spec .= ' NOT NULL'; + } + + if ($this->default !== null) { + $spec .= ' DEFAULT %s'; + $params[] = $this->default; + $types[] = self::TYPE_VALUE; + } + + $options = $this->getOptions(); + + if (isset($options['on_update'])) { + $spec .= ' %s'; + $params[] = 'ON UPDATE CURRENT_TIMESTAMP'; + $types[] = self::TYPE_LITERAL; + } + + $data = array(array( + $spec, + $params, + $types, + )); + + foreach ($this->constraints as $constraint) { + $data[] = ' '; + $data = array_merge($data, $constraint->getExpressionData()); + } + + return $data; + } +} diff --git a/library/Zend/Db/Sql/Ddl/Column/BigInteger.php b/library/Zend/Db/Sql/Ddl/Column/BigInteger.php index d915a948..75ce21cc 100644 --- a/library/Zend/Db/Sql/Ddl/Column/BigInteger.php +++ b/library/Zend/Db/Sql/Ddl/Column/BigInteger.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Ddl/Column/Binary.php b/library/Zend/Db/Sql/Ddl/Column/Binary.php new file mode 100644 index 00000000..d56a2833 --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/Binary.php @@ -0,0 +1,18 @@ +setName($name); - $this->setLength($length); - $this->setNullable($nullable); - $this->setDefault($default); - $this->setOptions($options); - } - - /** - * @param int $length - * @return self - */ - public function setLength($length) - { - $this->length = $length; - return $this; - } - - /** - * @return int - */ - public function getLength() - { - return $this->length; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - - $params = array(); - $params[] = $this->name; - $params[] = $this->type; - - if ($this->length) { - $params[1] .= ' ' . $this->length; - } - - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); - - if (!$this->isNullable) { - $params[1] .= ' NOT NULL'; - } - - if ($this->default !== null) { - $spec .= ' DEFAULT %s'; - $params[] = $this->default; - $types[] = self::TYPE_VALUE; - } - - return array(array( - $spec, - $params, - $types, - )); - } } diff --git a/library/Zend/Db/Sql/Ddl/Column/Boolean.php b/library/Zend/Db/Sql/Ddl/Column/Boolean.php index 36c07187..61008dc5 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Boolean.php +++ b/library/Zend/Db/Sql/Ddl/Column/Boolean.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,31 +12,20 @@ namespace Zend\Db\Sql\Ddl\Column; class Boolean extends Column { /** - * @var string specification + * @var string */ - protected $specification = '%s TINYINT NOT NULL'; + protected $type = 'BOOLEAN'; /** - * @param string $name + * {@inheritDoc} */ - public function __construct($name) - { - $this->name = $name; - } + protected $isNullable = false; /** - * @return array + * {@inheritDoc} */ - public function getExpressionData() + public function setNullable($nullable) { - $spec = $this->specification; - $params = array($this->name); - $types = array(self::TYPE_IDENTIFIER); - - return array(array( - $spec, - $params, - $types, - )); + return parent::setNullable(false); } } diff --git a/library/Zend/Db/Sql/Ddl/Column/Char.php b/library/Zend/Db/Sql/Ddl/Column/Char.php index 507cfe2c..c1b2a78d 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Char.php +++ b/library/Zend/Db/Sql/Ddl/Column/Char.php @@ -3,56 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl\Column; -class Char extends Column +class Char extends AbstractLengthColumn { /** * @var string */ - protected $specification = '%s CHAR(%s) %s %s'; - - /** - * @var int - */ - protected $length; - - /** - * @param string $name - * @param int $length - */ - public function __construct($name, $length) - { - $this->name = $name; - $this->length = $length; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); - $params[] = $this->name; - $params[] = $this->length; - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); - } + protected $type = 'CHAR'; } diff --git a/library/Zend/Db/Sql/Ddl/Column/Column.php b/library/Zend/Db/Sql/Ddl/Column/Column.php index de2f852b..32366fa3 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Column.php +++ b/library/Zend/Db/Sql/Ddl/Column/Column.php @@ -3,18 +3,20 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl\Column; +use Zend\Db\Sql\Ddl\Constraint\ConstraintInterface; + class Column implements ColumnInterface { /** * @var null|string|int */ - protected $default = null; + protected $default; /** * @var bool @@ -24,13 +26,18 @@ class Column implements ColumnInterface /** * @var string */ - protected $name = null; + protected $name = ''; /** * @var array */ protected $options = array(); + /** + * @var ConstraintInterface[] + */ + protected $constraints = array(); + /** * @var string */ @@ -43,10 +50,16 @@ class Column implements ColumnInterface /** * @param null|string $name + * @param bool $nullable + * @param mixed|null $default + * @param mixed[] $options */ - public function __construct($name = null) + public function __construct($name = null, $nullable = false, $default = null, array $options = array()) { - (!$name) ?: $this->setName($name); + $this->setName($name); + $this->setNullable($nullable); + $this->setDefault($default); + $this->setOptions($options); } /** @@ -55,7 +68,7 @@ class Column implements ColumnInterface */ public function setName($name) { - $this->name = $name; + $this->name = (string) $name; return $this; } @@ -132,6 +145,18 @@ class Column implements ColumnInterface return $this->options; } + /** + * @param ConstraintInterface $constraint + * + * @return self + */ + public function addConstraint(ConstraintInterface $constraint) + { + $this->constraints[] = $constraint; + + return $this; + } + /** * @return array */ @@ -146,7 +171,7 @@ class Column implements ColumnInterface $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); if (!$this->isNullable) { - $params[1] .= ' NOT NULL'; + $spec .= ' NOT NULL'; } if ($this->default !== null) { @@ -155,10 +180,17 @@ class Column implements ColumnInterface $types[] = self::TYPE_VALUE; } - return array(array( + $data = array(array( $spec, $params, $types, )); + + foreach ($this->constraints as $constraint) { + $data[] = ' '; + $data = array_merge($data, $constraint->getExpressionData()); + } + + return $data; } } diff --git a/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php b/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php index 331e5254..f21e11d9 100644 --- a/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php +++ b/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,10 +11,30 @@ namespace Zend\Db\Sql\Ddl\Column; use Zend\Db\Sql\ExpressionInterface; +/** + * Interface ColumnInterface describes the protocol on how Column objects interact + * + * @package Zend\Db\Sql\Ddl\Column + */ interface ColumnInterface extends ExpressionInterface { + /** + * @return string + */ public function getName(); + + /** + * @return bool + */ public function isNullable(); + + /** + * @return null|string|int + */ public function getDefault(); + + /** + * @return array + */ public function getOptions(); } diff --git a/library/Zend/Db/Sql/Ddl/Column/Date.php b/library/Zend/Db/Sql/Ddl/Column/Date.php index 489a1143..527b64c5 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Date.php +++ b/library/Zend/Db/Sql/Ddl/Column/Date.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,37 +14,5 @@ class Date extends Column /** * @var string */ - protected $specification = '%s DATE %s %s'; - - /** - * @param string $name - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER); - $params[] = $this->name; - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); - } + protected $type = 'DATE'; } diff --git a/library/Zend/Db/Sql/Ddl/Column/Datetime.php b/library/Zend/Db/Sql/Ddl/Column/Datetime.php new file mode 100644 index 00000000..5b320738 --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/Datetime.php @@ -0,0 +1,18 @@ +name = $name; - $this->precision = $precision; - $this->scale = $scale; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); - $params[] = $this->name; - $params[] = $this->precision; - - if ($this->scale !== null) { - $params[1] .= ', ' . $this->scale; - } - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); - } + protected $type = 'DECIMAL'; } diff --git a/library/Zend/Db/Sql/Ddl/Column/Float.php b/library/Zend/Db/Sql/Ddl/Column/Float.php index e866abcf..c04e7007 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Float.php +++ b/library/Zend/Db/Sql/Ddl/Column/Float.php @@ -3,64 +3,46 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl\Column; -class Float extends Column +/** + * Stub class for backwards compatibility. + * + * Since PHP 7 adds "float" as a reserved keyword, we can no longer have a class + * named that and retain PHP 7 compatibility. The original class has been + * renamed to "Floating", and this class is now an extension of it. It raises an + * E_USER_DEPRECATED to warn users to migrate. + * + * @deprecated + */ +class Float extends Floating { /** - * @var int + * {@inheritDoc} + * + * Raises a deprecation notice. */ - protected $decimal; + public function __construct( + $name, + $digits = null, + $decimal = null, + $nullable = false, + $default = null, + array $options = array() + ) { + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\Floating', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); - /** - * @var int - */ - protected $digits; - - /** - * @var string - */ - protected $specification = '%s DECIMAL(%s) %s %s'; - - /** - * @param null|string $name - * @param int $digits - * @param int $decimal - */ - public function __construct($name, $digits, $decimal) - { - $this->name = $name; - $this->digits = $digits; - $this->decimal = $decimal; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); - $params[] = $this->name; - $params[] = $this->digits; - $params[1] .= ', ' . $this->decimal; - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); + parent::__construct($name, $digits, $decimal, $nullable, $default, $options); } } diff --git a/library/Zend/Db/Sql/Ddl/Column/Floating.php b/library/Zend/Db/Sql/Ddl/Column/Floating.php new file mode 100644 index 00000000..85343cef --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/Floating.php @@ -0,0 +1,24 @@ +setName($name); - $this->setNullable($nullable); - $this->setDefault($default); - $this->setOptions($options); + $data = parent::getExpressionData(); + $options = $this->getOptions(); + + if (isset($options['length'])) { + $data[0][1][1] .= '(' . $options['length'] . ')'; + } + + return $data; } } diff --git a/library/Zend/Db/Sql/Ddl/Column/Text.php b/library/Zend/Db/Sql/Ddl/Column/Text.php index 3e407090..60e059e0 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Text.php +++ b/library/Zend/Db/Sql/Ddl/Column/Text.php @@ -3,49 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl\Column; - -class Text extends Column +class Text extends AbstractLengthColumn { /** * @var string */ - protected $specification = '%s TEXT %s %s'; - - /** - * @param null|string $name - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); - $params[] = $this->name; - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); - } + protected $type = 'TEXT'; } diff --git a/library/Zend/Db/Sql/Ddl/Column/Time.php b/library/Zend/Db/Sql/Ddl/Column/Time.php index 68d3c664..03008e31 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Time.php +++ b/library/Zend/Db/Sql/Ddl/Column/Time.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,37 +14,5 @@ class Time extends Column /** * @var string */ - protected $specification = '%s TIME %s %s'; - - /** - * @param string $name - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER); - $params[] = $this->name; - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); - } + protected $type = 'TIME'; } diff --git a/library/Zend/Db/Sql/Ddl/Column/Timestamp.php b/library/Zend/Db/Sql/Ddl/Column/Timestamp.php new file mode 100644 index 00000000..ae98a262 --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Column/Timestamp.php @@ -0,0 +1,18 @@ +name = $name; - $this->length = $length; - } - - /** - * @return array - */ - public function getExpressionData() - { - $spec = $this->specification; - $params = array(); - - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); - $params[] = $this->name; - $params[] = $this->length; - - $types[] = self::TYPE_LITERAL; - $params[] = (!$this->isNullable) ? 'NOT NULL' : ''; - - $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL; - $params[] = ($this->default !== null) ? $this->default : ''; - - return array(array( - $spec, - $params, - $types, - )); - } + protected $type = 'VARCHAR'; } diff --git a/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php b/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php index 19909fad..57c00fc1 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,6 +11,26 @@ namespace Zend\Db\Sql\Ddl\Constraint; abstract class AbstractConstraint implements ConstraintInterface { + /** + * @var string + */ + protected $columnSpecification = ' (%s)'; + + /** + * @var string + */ + protected $namedSpecification = 'CONSTRAINT %s '; + + /** + * @var string + */ + protected $specification = ''; + + /** + * @var string + */ + protected $name = ''; + /** * @var array */ @@ -18,10 +38,33 @@ abstract class AbstractConstraint implements ConstraintInterface /** * @param null|string|array $columns + * @param null|string $name */ - public function __construct($columns = null) + public function __construct($columns = null, $name = null) { - (!$columns) ?: $this->setColumns($columns); + if ($columns) { + $this->setColumns($columns); + } + + $this->setName($name); + } + + /** + * @param string $name + * @return self + */ + public function setName($name) + { + $this->name = (string) $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; } /** @@ -30,11 +73,8 @@ abstract class AbstractConstraint implements ConstraintInterface */ public function setColumns($columns) { - if (!is_array($columns)) { - $columns = array($columns); - } + $this->columns = (array) $columns; - $this->columns = $columns; return $this; } @@ -49,10 +89,42 @@ abstract class AbstractConstraint implements ConstraintInterface } /** - * @return array + * {@inheritDoc} */ public function getColumns() { return $this->columns; } + + /** + * {@inheritDoc} + */ + public function getExpressionData() + { + $colCount = count($this->columns); + $newSpecTypes = array(); + $values = array(); + $newSpec = ''; + + if ($this->name) { + $newSpec .= $this->namedSpecification; + $values[] = $this->name; + $newSpecTypes[] = self::TYPE_IDENTIFIER; + } + + $newSpec .= $this->specification; + + if ($colCount) { + $values = array_merge($values, $this->columns); + $newSpecParts = array_fill(0, $colCount, '%s'); + $newSpecTypes = array_merge($newSpecTypes, array_fill(0, $colCount, self::TYPE_IDENTIFIER)); + $newSpec .= sprintf($this->columnSpecification, implode(', ', $newSpecParts)); + } + + return array(array( + $newSpec, + $values, + $newSpecTypes, + )); + } } diff --git a/library/Zend/Db/Sql/Ddl/Constraint/Check.php b/library/Zend/Db/Sql/Ddl/Constraint/Check.php index 1afbeb39..cc4e2a81 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/Check.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/Check.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,9 +17,9 @@ class Check extends AbstractConstraint protected $expression; /** - * @var string + * {@inheritDoc} */ - protected $specification = 'CONSTRAINT %s CHECK (%s)'; + protected $specification = 'CHECK (%s)'; /** * @param string|\Zend\Db\Sql\ExpressionInterface $expression @@ -32,14 +32,25 @@ class Check extends AbstractConstraint } /** - * @return array + * {@inheritDoc} */ public function getExpressionData() { + $newSpecTypes = array(self::TYPE_LITERAL); + $values = array($this->expression); + $newSpec = ''; + + if ($this->name) { + $newSpec .= $this->namedSpecification; + + array_unshift($values, $this->name); + array_unshift($newSpecTypes, self::TYPE_IDENTIFIER); + } + return array(array( - $this->specification, - array($this->name, $this->expression), - array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL), + $newSpec . $this->specification, + $values, + $newSpecTypes, )); } } diff --git a/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php b/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php index bcb96439..667e5601 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Ddl/Constraint/ForeignKey.php b/library/Zend/Db/Sql/Ddl/Constraint/ForeignKey.php index 1d0c0cad..c8189aaa 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/ForeignKey.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/ForeignKey.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,11 +11,6 @@ namespace Zend\Db\Sql\Ddl\Constraint; class ForeignKey extends AbstractConstraint { - /** - * @var string - */ - protected $name; - /** * @var string */ @@ -27,54 +22,50 @@ class ForeignKey extends AbstractConstraint protected $onUpdateRule = 'NO ACTION'; /** - * @var string + * @var string[] */ - protected $referenceColumn; + protected $referenceColumn = array(); /** * @var string */ - protected $referenceTable; + protected $referenceTable = ''; /** - * @var string + * {@inheritDoc} */ - protected $specification = 'CONSTRAINT %1$s FOREIGN KEY (%2$s) REFERENCES %3$s (%4$s) ON DELETE %5$s ON UPDATE %6$s'; + protected $columnSpecification = 'FOREIGN KEY (%s) '; /** - * @param array|null|string $name - * @param string $column + * @var string[] + */ + protected $referenceSpecification = array( + 'REFERENCES %s ', + 'ON DELETE %s ON UPDATE %s' + ); + + /** + * @param null|string $name + * @param null|string|array $columns * @param string $referenceTable - * @param string $referenceColumn + * @param null|string|array $referenceColumn * @param null|string $onDeleteRule * @param null|string $onUpdateRule */ - public function __construct($name, $column, $referenceTable, $referenceColumn, $onDeleteRule = null, $onUpdateRule = null) + public function __construct($name, $columns, $referenceTable, $referenceColumn, $onDeleteRule = null, $onUpdateRule = null) { $this->setName($name); - $this->setColumns($column); + $this->setColumns($columns); $this->setReferenceTable($referenceTable); $this->setReferenceColumn($referenceColumn); - (!$onDeleteRule) ?: $this->setOnDeleteRule($onDeleteRule); - (!$onUpdateRule) ?: $this->setOnUpdateRule($onUpdateRule); - } - /** - * @param string $name - * @return self - */ - public function setName($name) - { - $this->name = $name; - return $this; - } + if ($onDeleteRule) { + $this->setOnDeleteRule($onDeleteRule); + } - /** - * @return string - */ - public function getName() - { - return $this->name; + if ($onUpdateRule) { + $this->setOnUpdateRule($onUpdateRule); + } } /** @@ -83,7 +74,7 @@ class ForeignKey extends AbstractConstraint */ public function setReferenceTable($referenceTable) { - $this->referenceTable = $referenceTable; + $this->referenceTable = (string) $referenceTable; return $this; } @@ -96,17 +87,18 @@ class ForeignKey extends AbstractConstraint } /** - * @param string $referenceColumn + * @param null|string|array $referenceColumn * @return self */ public function setReferenceColumn($referenceColumn) { - $this->referenceColumn = $referenceColumn; + $this->referenceColumn = (array) $referenceColumn; + return $this; } /** - * @return string + * @return array */ public function getReferenceColumn() { @@ -119,7 +111,8 @@ class ForeignKey extends AbstractConstraint */ public function setOnDeleteRule($onDeleteRule) { - $this->onDeleteRule = $onDeleteRule; + $this->onDeleteRule = (string) $onDeleteRule; + return $this; } @@ -137,7 +130,8 @@ class ForeignKey extends AbstractConstraint */ public function setOnUpdateRule($onUpdateRule) { - $this->onUpdateRule = $onUpdateRule; + $this->onUpdateRule = (string) $onUpdateRule; + return $this; } @@ -154,24 +148,31 @@ class ForeignKey extends AbstractConstraint */ public function getExpressionData() { - return array(array( - $this->specification, - array( - $this->name, - $this->columns[0], - $this->referenceTable, - $this->referenceColumn, - $this->onDeleteRule, - $this->onUpdateRule, - ), - array( - self::TYPE_IDENTIFIER, - self::TYPE_IDENTIFIER, - self::TYPE_IDENTIFIER, - self::TYPE_IDENTIFIER, - self::TYPE_LITERAL, - self::TYPE_LITERAL, - ), - )); + $data = parent::getExpressionData(); + $colCount = count($this->referenceColumn); + $newSpecTypes = array(self::TYPE_IDENTIFIER); + $values = array($this->referenceTable); + + $data[0][0] .= $this->referenceSpecification[0]; + + if ($colCount) { + $values = array_merge($values, $this->referenceColumn); + $newSpecParts = array_fill(0, $colCount, '%s'); + $newSpecTypes = array_merge($newSpecTypes, array_fill(0, $colCount, self::TYPE_IDENTIFIER)); + + $data[0][0] .= sprintf('(%s) ', implode(', ', $newSpecParts)); + } + + $data[0][0] .= $this->referenceSpecification[1]; + + $values[] = $this->onDeleteRule; + $values[] = $this->onUpdateRule; + $newSpecTypes[] = self::TYPE_LITERAL; + $newSpecTypes[] = self::TYPE_LITERAL; + + $data[0][1] = array_merge($data[0][1], $values); + $data[0][2] = array_merge($data[0][2], $newSpecTypes); + + return $data; } } diff --git a/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php b/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php index 84124a4d..064b1e04 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,23 +14,5 @@ class PrimaryKey extends AbstractConstraint /** * @var string */ - protected $specification = 'PRIMARY KEY (%s)'; - - /** - * @return array - */ - public function getExpressionData() - { - $colCount = count($this->columns); - $newSpecParts = array_fill(0, $colCount, '%s'); - $newSpecTypes = array_fill(0, $colCount, self::TYPE_IDENTIFIER); - - $newSpec = sprintf($this->specification, implode(', ', $newSpecParts)); - - return array(array( - $newSpec, - $this->columns, - $newSpecTypes, - )); - } + protected $specification = 'PRIMARY KEY'; } diff --git a/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php b/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php index 8d871054..ffca8156 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,42 +14,5 @@ class UniqueKey extends AbstractConstraint /** * @var string */ - protected $specification = 'CONSTRAINT UNIQUE KEY %s(...)'; - - /** - * @param string $column - * @param null|string $name - */ - public function __construct($column, $name = null) - { - $this->setColumns($column); - $this->name = $name; - } - - /** - * @return array - */ - public function getExpressionData() - { - $colCount = count($this->columns); - - $values = array(); - $values[] = ($this->name) ? $this->name : ''; - - $newSpecTypes = array(self::TYPE_IDENTIFIER); - $newSpecParts = array(); - - for ($i = 0; $i < $colCount; $i++) { - $newSpecParts[] = '%s'; - $newSpecTypes[] = self::TYPE_IDENTIFIER; - } - - $newSpec = str_replace('...', implode(', ', $newSpecParts), $this->specification); - - return array(array( - $newSpec, - array_merge($values, $this->columns), - $newSpecTypes, - )); - } + protected $specification = 'UNIQUE'; } diff --git a/library/Zend/Db/Sql/Ddl/CreateTable.php b/library/Zend/Db/Sql/Ddl/CreateTable.php index 45bfd982..31aa4cc2 100644 --- a/library/Zend/Db/Sql/Ddl/CreateTable.php +++ b/library/Zend/Db/Sql/Ddl/CreateTable.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92 as AdapterSql92Platform; use Zend\Db\Sql\AbstractSql; class CreateTable extends AbstractSql implements SqlInterface @@ -20,12 +19,12 @@ class CreateTable extends AbstractSql implements SqlInterface const TABLE = 'table'; /** - * @var array + * @var Column\ColumnInterface[] */ protected $columns = array(); /** - * @var array + * @var string[] */ protected $constraints = array(); @@ -35,8 +34,7 @@ class CreateTable extends AbstractSql implements SqlInterface protected $isTemporary = false; /** - * Specifications for Sql String generation - * @var array + * {@inheritDoc} */ protected $specifications = array( self::TABLE => 'CREATE %1$sTABLE %2$s (', @@ -45,11 +43,13 @@ class CreateTable extends AbstractSql implements SqlInterface array(1 => '%1$s', 'combinedby' => ",\n ") ) ), + 'combinedBy' => ",", self::CONSTRAINTS => array( "\n %1\$s" => array( array(1 => '%1$s', 'combinedby' => ",\n ") ) ), + 'statementEnd' => '%1$s', ); /** @@ -131,88 +131,77 @@ class CreateTable extends AbstractSql implements SqlInterface } /** - * @param PlatformInterface $adapterPlatform - * @return string + * @param PlatformInterface $adapterPlatform + * + * @return string[] */ - public function getSqlString(PlatformInterface $adapterPlatform = null) - { - // get platform, or create default - $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform; - - $sqls = array(); - $parameters = array(); - - foreach ($this->specifications as $name => $specification) { - if (is_int($name)) { - $sqls[] = $specification; - continue; - } - - $parameters[$name] = $this->{'process' . $name}( - $adapterPlatform, - null, - null, - $sqls, - $parameters - ); - - - if ($specification - && is_array($parameters[$name]) - && ($parameters[$name] != array(array())) - ) { - $sqls[$name] = $this->createSqlFromSpecificationAndParameters( - $specification, - $parameters[$name] - ); - } - - if (stripos($name, 'table') === false - && $parameters[$name] !== array(array()) - ) { - $sqls[] = ",\n"; - } - } - - - // remove last , - if (count($sqls) > 2) { - array_pop($sqls); - } - - $sql = implode('', $sqls) . "\n)"; - - return $sql; - } - protected function processTable(PlatformInterface $adapterPlatform = null) { - $ret = array(); - if ($this->isTemporary) { - $ret[] = 'TEMPORARY '; - } else { - $ret[] = ''; - } - - $ret[] = $adapterPlatform->quoteIdentifier($this->table); - return $ret; + return array( + $this->isTemporary ? 'TEMPORARY ' : '', + $adapterPlatform->quoteIdentifier($this->table), + ); } + /** + * @param PlatformInterface $adapterPlatform + * + * @return string[][]|null + */ protected function processColumns(PlatformInterface $adapterPlatform = null) { - $sqls = array(); - foreach ($this->columns as $column) { - $sqls[] = $this->processExpression($column, $adapterPlatform)->getSql(); + if (! $this->columns) { + return; } + + $sqls = array(); + + foreach ($this->columns as $column) { + $sqls[] = $this->processExpression($column, $adapterPlatform); + } + return array($sqls); } + /** + * @param PlatformInterface $adapterPlatform + * + * @return array|string + */ + protected function processCombinedby(PlatformInterface $adapterPlatform = null) + { + if ($this->constraints && $this->columns) { + return $this->specifications['combinedBy']; + } + } + + /** + * @param PlatformInterface $adapterPlatform + * + * @return string[][]|null + */ protected function processConstraints(PlatformInterface $adapterPlatform = null) { - $sqls = array(); - foreach ($this->constraints as $constraint) { - $sqls[] = $this->processExpression($constraint, $adapterPlatform)->getSql(); + if (!$this->constraints) { + return; } + + $sqls = array(); + + foreach ($this->constraints as $constraint) { + $sqls[] = $this->processExpression($constraint, $adapterPlatform); + } + return array($sqls); } + + /** + * @param PlatformInterface $adapterPlatform + * + * @return string[] + */ + protected function processStatementEnd(PlatformInterface $adapterPlatform = null) + { + return array("\n)"); + } } diff --git a/library/Zend/Db/Sql/Ddl/DropTable.php b/library/Zend/Db/Sql/Ddl/DropTable.php index e38425c6..6f5646ef 100644 --- a/library/Zend/Db/Sql/Ddl/DropTable.php +++ b/library/Zend/Db/Sql/Ddl/DropTable.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Ddl; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92 as AdapterSql92Platform; use Zend\Db\Sql\AbstractSql; class DropTable extends AbstractSql implements SqlInterface @@ -37,39 +36,6 @@ class DropTable extends AbstractSql implements SqlInterface $this->table = $table; } - /** - * @param null|PlatformInterface $adapterPlatform - * @return string - */ - public function getSqlString(PlatformInterface $adapterPlatform = null) - { - // get platform, or create default - $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform; - - $sqls = array(); - $parameters = array(); - - foreach ($this->specifications as $name => $specification) { - $parameters[$name] = $this->{'process' . $name}( - $adapterPlatform, - null, - null, - $sqls, - $parameters - ); - - if ($specification && is_array($parameters[$name])) { - $sqls[$name] = $this->createSqlFromSpecificationAndParameters( - $specification, - $parameters[$name] - ); - } - } - - $sql = implode(' ', $sqls); - return $sql; - } - protected function processTable(PlatformInterface $adapterPlatform = null) { return array($adapterPlatform->quoteIdentifier($this->table)); diff --git a/library/Zend/Db/Sql/Ddl/Index/AbstractIndex.php b/library/Zend/Db/Sql/Ddl/Index/AbstractIndex.php new file mode 100644 index 00000000..a9e1e4cf --- /dev/null +++ b/library/Zend/Db/Sql/Ddl/Index/AbstractIndex.php @@ -0,0 +1,16 @@ +setColumns($column); + + $this->name = null === $name ? null : (string) $name; + $this->lengths = $lengths; + } + + /** + * + * @return array of array|string should return an array in the format: + * + * array ( + * // a sprintf formatted string + * string $specification, + * + * // the values for the above sprintf formatted string + * array $values, + * + * // an array of equal length of the $values array, with either TYPE_IDENTIFIER or TYPE_VALUE for each value + * array $types, + * ) + * + */ + public function getExpressionData() + { + $colCount = count($this->columns); + $values = array(); + $values[] = $this->name ?: ''; + $newSpecTypes = array(self::TYPE_IDENTIFIER); + $newSpecParts = array(); + + for ($i = 0; $i < $colCount; $i++) { + $specPart = '%s'; + + if (isset($this->lengths[$i])) { + $specPart .= "({$this->lengths[$i]})"; + } + + $newSpecParts[] = $specPart; + $newSpecTypes[] = self::TYPE_IDENTIFIER; + } + + $newSpec = str_replace('...', implode(', ', $newSpecParts), $this->specification); + + return array(array( + $newSpec, + array_merge($values, $this->columns), + $newSpecTypes, + )); + } +} diff --git a/library/Zend/Db/Sql/Ddl/SqlInterface.php b/library/Zend/Db/Sql/Ddl/SqlInterface.php index 76131245..fb4dab05 100644 --- a/library/Zend/Db/Sql/Ddl/SqlInterface.php +++ b/library/Zend/Db/Sql/Ddl/SqlInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Delete.php b/library/Zend/Db/Sql/Delete.php index 1187277d..10ada94a 100644 --- a/library/Zend/Db/Sql/Delete.php +++ b/library/Zend/Db/Sql/Delete.php @@ -3,23 +3,21 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92; -use Zend\Db\Adapter\StatementContainerInterface; +use Zend\Db\Adapter\Driver\DriverInterface; /** * * @property Where $where */ -class Delete extends AbstractSql implements SqlInterface, PreparableSqlInterface +class Delete extends AbstractPreparableSql { /**@#+ * @const @@ -29,7 +27,7 @@ class Delete extends AbstractSql implements SqlInterface, PreparableSqlInterface /**@#-*/ /** - * @var array Specifications + * {@inheritDoc} */ protected $specifications = array( self::SPECIFICATION_DELETE => 'DELETE FROM %1$s', @@ -81,6 +79,11 @@ class Delete extends AbstractSql implements SqlInterface, PreparableSqlInterface return $this; } + /** + * @param null $key + * + * @return mixed + */ public function getRawState($key = null) { $rawState = array( @@ -97,6 +100,7 @@ class Delete extends AbstractSql implements SqlInterface, PreparableSqlInterface * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * * @return Delete */ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) @@ -110,81 +114,37 @@ class Delete extends AbstractSql implements SqlInterface, PreparableSqlInterface } /** - * Prepare the delete statement + * @param PlatformInterface $platform + * @param DriverInterface|null $driver + * @param ParameterContainer|null $parameterContainer * - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - * @return void + * @return string */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function processDelete(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $driver = $adapter->getDriver(); - $platform = $adapter->getPlatform(); - $parameterContainer = $statementContainer->getParameterContainer(); - - if (!$parameterContainer instanceof ParameterContainer) { - $parameterContainer = new ParameterContainer(); - $statementContainer->setParameterContainer($parameterContainer); - } - - $table = $this->table; - $schema = null; - - // create quoted table name to use in delete processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); - } - - $table = $platform->quoteIdentifier($table); - - if ($schema) { - $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; - } - - $sql = sprintf($this->specifications[static::SPECIFICATION_DELETE], $table); - - // process where - if ($this->where->count() > 0) { - $whereParts = $this->processExpression($this->where, $platform, $driver, 'where'); - $parameterContainer->merge($whereParts->getParameterContainer()); - $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql()); - } - $statementContainer->setSql($sql); + return sprintf( + $this->specifications[static::SPECIFICATION_DELETE], + $this->resolveTable($this->table, $platform, $driver, $parameterContainer) + ); } /** - * Get the SQL string, based on the platform + * @param PlatformInterface $platform + * @param DriverInterface|null $driver + * @param ParameterContainer|null $parameterContainer * - * Platform defaults to Sql92 if none provided - * - * @param null|PlatformInterface $adapterPlatform - * @return string + * @return null|string */ - public function getSqlString(PlatformInterface $adapterPlatform = null) + protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $adapterPlatform = ($adapterPlatform) ?: new Sql92; - $table = $this->table; - $schema = null; - - // create quoted table name to use in delete processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); + if ($this->where->count() == 0) { + return; } - $table = $adapterPlatform->quoteIdentifier($table); - - if ($schema) { - $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table; - } - - $sql = sprintf($this->specifications[static::SPECIFICATION_DELETE], $table); - - if ($this->where->count() > 0) { - $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where'); - $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql()); - } - - return $sql; + return sprintf( + $this->specifications[static::SPECIFICATION_WHERE], + $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where') + ); } /** @@ -193,7 +153,8 @@ class Delete extends AbstractSql implements SqlInterface, PreparableSqlInterface * Overloads "where" only. * * @param string $name - * @return mixed + * + * @return Where|null */ public function __get($name) { diff --git a/library/Zend/Db/Sql/Exception/ExceptionInterface.php b/library/Zend/Db/Sql/Exception/ExceptionInterface.php index 337266de..9e18dba2 100644 --- a/library/Zend/Db/Sql/Exception/ExceptionInterface.php +++ b/library/Zend/Db/Sql/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Exception/InvalidArgumentException.php b/library/Zend/Db/Sql/Exception/InvalidArgumentException.php index 0892d68b..19aef601 100644 --- a/library/Zend/Db/Sql/Exception/InvalidArgumentException.php +++ b/library/Zend/Db/Sql/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Exception/RuntimeException.php b/library/Zend/Db/Sql/Exception/RuntimeException.php index b6546b09..5a7dea34 100644 --- a/library/Zend/Db/Sql/Exception/RuntimeException.php +++ b/library/Zend/Db/Sql/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Expression.php b/library/Zend/Db/Sql/Expression.php index b9f935b4..04fb789e 100644 --- a/library/Zend/Db/Sql/Expression.php +++ b/library/Zend/Db/Sql/Expression.php @@ -3,13 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql; -class Expression implements ExpressionInterface +class Expression extends AbstractExpression { /** * @const @@ -34,19 +34,31 @@ class Expression implements ExpressionInterface /** * @param string $expression * @param string|array $parameters - * @param array $types + * @param array $types @deprecated will be dropped in version 3.0.0 */ public function __construct($expression = '', $parameters = null, array $types = array()) { - if ($expression) { + if ($expression !== '') { $this->setExpression($expression); } + + if ($types) { // should be deprecated and removed version 3.0.0 + if (is_array($parameters)) { + foreach ($parameters as $i=>$parameter) { + $parameters[$i] = array( + $parameter => isset($types[$i]) ? $types[$i] : self::TYPE_VALUE, + ); + } + } elseif (is_scalar($parameters)) { + $parameters = array( + $parameters => $types[0], + ); + } + } + if ($parameters) { $this->setParameters($parameters); } - if ($types) { - $this->setTypes($types); - } } /** @@ -94,6 +106,7 @@ class Expression implements ExpressionInterface } /** + * @deprecated * @param array $types * @return Expression */ @@ -104,6 +117,7 @@ class Expression implements ExpressionInterface } /** + * @deprecated * @return array */ public function getTypes() @@ -118,35 +132,26 @@ class Expression implements ExpressionInterface public function getExpressionData() { $parameters = (is_scalar($this->parameters)) ? array($this->parameters) : $this->parameters; - - $types = array(); $parametersCount = count($parameters); + $expression = str_replace('%', '%%', $this->expression); - if ($parametersCount == 0 && strpos($this->expression, self::PLACEHOLDER) !== false) { - // if there are no parameters, but there is a placeholder - $parametersCount = substr_count($this->expression, self::PLACEHOLDER); - $parameters = array_fill(0, $parametersCount, null); - } - - for ($i = 0; $i < $parametersCount; $i++) { - $types[$i] = (isset($this->types[$i]) && ($this->types[$i] == self::TYPE_IDENTIFIER || $this->types[$i] == self::TYPE_LITERAL)) - ? $this->types[$i] : self::TYPE_VALUE; + if ($parametersCount == 0) { + return array( + str_ireplace(self::PLACEHOLDER, '', $expression) + ); } // assign locally, escaping % signs - $expression = str_replace('%', '%%', $this->expression); - - if ($parametersCount > 0) { - $count = 0; - $expression = str_replace(self::PLACEHOLDER, '%s', $expression, $count); - if ($count !== $parametersCount) { - throw new Exception\RuntimeException('The number of replacements in the expression does not match the number of parameters'); - } + $expression = str_replace(self::PLACEHOLDER, '%s', $expression, $count); + if ($count !== $parametersCount) { + throw new Exception\RuntimeException('The number of replacements in the expression does not match the number of parameters'); + } + foreach ($parameters as $parameter) { + list($values[], $types[]) = $this->normalizeArgument($parameter, self::TYPE_VALUE); } - return array(array( $expression, - $parameters, + $values, $types )); } diff --git a/library/Zend/Db/Sql/ExpressionInterface.php b/library/Zend/Db/Sql/ExpressionInterface.php index 99c92993..71286e49 100644 --- a/library/Zend/Db/Sql/ExpressionInterface.php +++ b/library/Zend/Db/Sql/ExpressionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,6 +14,7 @@ interface ExpressionInterface const TYPE_IDENTIFIER = 'identifier'; const TYPE_VALUE = 'value'; const TYPE_LITERAL = 'literal'; + const TYPE_SELECT = 'select'; /** * @abstract diff --git a/library/Zend/Db/Sql/Having.php b/library/Zend/Db/Sql/Having.php index abbbd4c8..024f9d0f 100644 --- a/library/Zend/Db/Sql/Having.php +++ b/library/Zend/Db/Sql/Having.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Insert.php b/library/Zend/Db/Sql/Insert.php index 8704678f..b319616d 100644 --- a/library/Zend/Db/Sql/Insert.php +++ b/library/Zend/Db/Sql/Insert.php @@ -3,19 +3,17 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92; -use Zend\Db\Adapter\StatementContainerInterface; +use Zend\Db\Adapter\Driver\DriverInterface; -class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface +class Insert extends AbstractPreparableSql { /**#@+ * Constants @@ -45,7 +43,7 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface /** * @var array|Select */ - protected $values = null; + protected $select = null; /** * Constructor @@ -79,7 +77,7 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function columns(array $columns) { - $this->columns = $columns; + $this->columns = array_flip($columns); return $this; } @@ -93,48 +91,34 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function values($values, $flag = self::VALUES_SET) { - if (!is_array($values) && !$values instanceof Select) { - throw new Exception\InvalidArgumentException('values() expects an array of values or Zend\Db\Sql\Select instance'); - } - if ($values instanceof Select) { - if ($flag == self::VALUES_MERGE && (is_array($this->values) && !empty($this->values))) { + if ($flag == self::VALUES_MERGE) { throw new Exception\InvalidArgumentException( - 'A Zend\Db\Sql\Select instance cannot be provided with the merge flag when values already exist.' + 'A Zend\Db\Sql\Select instance cannot be provided with the merge flag' ); } - $this->values = $values; + $this->select = $values; return $this; } - // determine if this is assoc or a set of values - $keys = array_keys($values); - $firstKey = current($keys); - - if ($flag == self::VALUES_SET) { - $this->columns = array(); - $this->values = array(); - } elseif ($this->values instanceof Select) { + if (!is_array($values)) { throw new Exception\InvalidArgumentException( - 'An array of values cannot be provided with the merge flag when a Zend\Db\Sql\Select' - . ' instance already exists as the value source.' + 'values() expects an array of values or Zend\Db\Sql\Select instance' + ); + } + if ($this->select && $flag == self::VALUES_MERGE) { + throw new Exception\InvalidArgumentException( + 'An array of values cannot be provided with the merge flag when a Zend\Db\Sql\Select instance already exists as the value source' ); } - if (is_string($firstKey)) { - foreach ($keys as $key) { - if (($index = array_search($key, $this->columns)) !== false) { - $this->values[$index] = $values[$key]; - } else { - $this->columns[] = $key; - $this->values[] = $values[$key]; - } + if ($flag == self::VALUES_SET) { + $this->columns = $values; + } else { + foreach ($values as $column=>$value) { + $this->columns[$column] = $value; } - } elseif (is_int($firstKey)) { - // determine if count of columns should match count of values - $this->values = array_merge($this->values, array_values($values)); } - return $this; } @@ -159,145 +143,61 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface { $rawState = array( 'table' => $this->table, - 'columns' => $this->columns, - 'values' => $this->values + 'columns' => array_keys($this->columns), + 'values' => array_values($this->columns) ); return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - /** - * Prepare statement - * - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - * @return void - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function processInsert(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $driver = $adapter->getDriver(); - $platform = $adapter->getPlatform(); - $parameterContainer = $statementContainer->getParameterContainer(); - - if (!$parameterContainer instanceof ParameterContainer) { - $parameterContainer = new ParameterContainer(); - $statementContainer->setParameterContainer($parameterContainer); + if ($this->select) { + return; } - - $table = $this->table; - $schema = null; - - // create quoted table name to use in insert processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); - } - - $table = $platform->quoteIdentifier($table); - - if ($schema) { - $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; + if (!$this->columns) { + throw new Exception\InvalidArgumentException('values or select should be present'); } $columns = array(); $values = array(); - - if (is_array($this->values)) { - foreach ($this->columns as $cIndex => $column) { - $columns[$cIndex] = $platform->quoteIdentifier($column); - if (isset($this->values[$cIndex]) && $this->values[$cIndex] instanceof Expression) { - $exprData = $this->processExpression($this->values[$cIndex], $platform, $driver); - $values[$cIndex] = $exprData->getSql(); - $parameterContainer->merge($exprData->getParameterContainer()); - } else { - $values[$cIndex] = $driver->formatParameterName($column); - if (isset($this->values[$cIndex])) { - $parameterContainer->offsetSet($column, $this->values[$cIndex]); - } else { - $parameterContainer->offsetSet($column, null); - } - } + foreach ($this->columns as $column=>$value) { + $columns[] = $platform->quoteIdentifier($column); + if (is_scalar($value) && $parameterContainer) { + $values[] = $driver->formatParameterName($column); + $parameterContainer->offsetSet($column, $value); + } else { + $values[] = $this->resolveColumnValue( + $value, + $platform, + $driver, + $parameterContainer + ); } - $sql = sprintf( - $this->specifications[static::SPECIFICATION_INSERT], - $table, - implode(', ', $columns), - implode(', ', $values) - ); - } elseif ($this->values instanceof Select) { - $this->values->prepareStatement($adapter, $statementContainer); - - $columns = array_map(array($platform, 'quoteIdentifier'), $this->columns); - $columns = implode(', ', $columns); - - $sql = sprintf( - $this->specifications[static::SPECIFICATION_SELECT], - $table, - $columns ? "($columns)" : "", - $statementContainer->getSql() - ); - } else { - throw new Exception\InvalidArgumentException('values or select should be present'); } - $statementContainer->setSql($sql); + return sprintf( + $this->specifications[static::SPECIFICATION_INSERT], + $this->resolveTable($this->table, $platform, $driver, $parameterContainer), + implode(', ', $columns), + implode(', ', $values) + ); } - /** - * Get SQL string for this statement - * - * @param null|PlatformInterface $adapterPlatform Defaults to Sql92 if none provided - * @return string - */ - public function getSqlString(PlatformInterface $adapterPlatform = null) + protected function processSelect(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $adapterPlatform = ($adapterPlatform) ?: new Sql92; - $table = $this->table; - $schema = null; - - // create quoted table name to use in insert processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); + if (!$this->select) { + return; } + $selectSql = $this->processSubSelect($this->select, $platform, $driver, $parameterContainer); - $table = $adapterPlatform->quoteIdentifier($table); - - if ($schema) { - $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table; - } - - $columns = array_map(array($adapterPlatform, 'quoteIdentifier'), $this->columns); + $columns = array_map(array($platform, 'quoteIdentifier'), array_keys($this->columns)); $columns = implode(', ', $columns); - if (is_array($this->values)) { - $values = array(); - foreach ($this->values as $value) { - if ($value instanceof Expression) { - $exprData = $this->processExpression($value, $adapterPlatform); - $values[] = $exprData->getSql(); - } elseif ($value === null) { - $values[] = 'NULL'; - } else { - $values[] = $adapterPlatform->quoteValue($value); - } - } - return sprintf( - $this->specifications[static::SPECIFICATION_INSERT], - $table, - $columns, - implode(', ', $values) - ); - } elseif ($this->values instanceof Select) { - $selectString = $this->values->getSqlString($adapterPlatform); - if ($columns) { - $columns = "($columns)"; - } - return sprintf( - $this->specifications[static::SPECIFICATION_SELECT], - $table, - $columns, - $selectString - ); - } else { - throw new Exception\InvalidArgumentException('values or select should be present'); - } + return sprintf( + $this->specifications[static::SPECIFICATION_SELECT], + $this->resolveTable($this->table, $platform, $driver, $parameterContainer), + $columns ? "($columns)" : "", + $selectSql + ); } /** @@ -311,8 +211,7 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function __set($name, $value) { - $values = array($name => $value); - $this->values($values, self::VALUES_MERGE); + $this->columns[$name] = $value; return $this; } @@ -327,14 +226,11 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function __unset($name) { - if (($position = array_search($name, $this->columns)) === false) { + if (!isset($this->columns[$name])) { throw new Exception\InvalidArgumentException('The key ' . $name . ' was not found in this objects column list'); } - unset($this->columns[$position]); - if (is_array($this->values)) { - unset($this->values[$position]); - } + unset($this->columns[$name]); } /** @@ -347,7 +243,7 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function __isset($name) { - return in_array($name, $this->columns); + return isset($this->columns[$name]); } /** @@ -361,12 +257,9 @@ class Insert extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function __get($name) { - if (!is_array($this->values)) { - return null; - } - if (($position = array_search($name, $this->columns)) === false) { + if (!isset($this->columns[$name])) { throw new Exception\InvalidArgumentException('The key ' . $name . ' was not found in this objects column list'); } - return $this->values[$position]; + return $this->columns[$name]; } } diff --git a/library/Zend/Db/Sql/Literal.php b/library/Zend/Db/Sql/Literal.php index ba67415a..1da41028 100644 --- a/library/Zend/Db/Sql/Literal.php +++ b/library/Zend/Db/Sql/Literal.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Platform/AbstractPlatform.php b/library/Zend/Db/Sql/Platform/AbstractPlatform.php index c5ddd6ce..32d5bd1f 100644 --- a/library/Zend/Db/Sql/Platform/AbstractPlatform.php +++ b/library/Zend/Db/Sql/Platform/AbstractPlatform.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,9 +19,9 @@ use Zend\Db\Sql\SqlInterface; class AbstractPlatform implements PlatformDecoratorInterface, PreparableSqlInterface, SqlInterface { /** - * @var object + * @var object|null */ - protected $subject = null; + protected $subject; /** * @var PlatformDecoratorInterface[] @@ -29,22 +29,43 @@ class AbstractPlatform implements PlatformDecoratorInterface, PreparableSqlInter protected $decorators = array(); /** - * @param $subject + * {@inheritDoc} */ public function setSubject($subject) { $this->subject = $subject; + + return $this; } /** - * @param $type + * @param string $type * @param PlatformDecoratorInterface $decorator + * + * @return void */ public function setTypeDecorator($type, PlatformDecoratorInterface $decorator) { $this->decorators[$type] = $decorator; } + /** + * @param PreparableSqlInterface|SqlInterface $subject + * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface + */ + public function getTypeDecorator($subject) + { + foreach ($this->decorators as $type => $decorator) { + if ($subject instanceof $type) { + $decorator->setSubject($subject); + + return $decorator; + } + } + + return $subject; + } + /** * @return array|PlatformDecoratorInterface[] */ @@ -54,57 +75,32 @@ class AbstractPlatform implements PlatformDecoratorInterface, PreparableSqlInter } /** - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer + * {@inheritDoc} + * * @throws Exception\RuntimeException - * @return void */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) { - if (!$this->subject instanceof PreparableSqlInterface) { + if (! $this->subject instanceof PreparableSqlInterface) { throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling prepareStatement() has no effect'); } - $decoratorForType = false; - foreach ($this->decorators as $type => $decorator) { - if ($this->subject instanceof $type && $decorator instanceof PreparableSqlInterface) { - /** @var $decoratorForType PreparableSqlInterface|PlatformDecoratorInterface */ - $decoratorForType = $decorator; - break; - } - } - if ($decoratorForType) { - $decoratorForType->setSubject($this->subject); - $decoratorForType->prepareStatement($adapter, $statementContainer); - } else { - $this->subject->prepareStatement($adapter, $statementContainer); - } + $this->getTypeDecorator($this->subject)->prepareStatement($adapter, $statementContainer); + + return $statementContainer; } /** - * @param null|\Zend\Db\Adapter\Platform\PlatformInterface $adapterPlatform - * @return mixed + * {@inheritDoc} + * * @throws Exception\RuntimeException */ public function getSqlString(PlatformInterface $adapterPlatform = null) { - if (!$this->subject instanceof SqlInterface) { - throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling prepareStatement() has no effect'); + if (! $this->subject instanceof SqlInterface) { + throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\SqlInterface, thus calling prepareStatement() has no effect'); } - $decoratorForType = false; - foreach ($this->decorators as $type => $decorator) { - if ($this->subject instanceof $type && $decorator instanceof SqlInterface) { - /** @var $decoratorForType SqlInterface|PlatformDecoratorInterface */ - $decoratorForType = $decorator; - break; - } - } - if ($decoratorForType) { - $decoratorForType->setSubject($this->subject); - return $decoratorForType->getSqlString($adapterPlatform); - } - - return $this->subject->getSqlString($adapterPlatform); + return $this->getTypeDecorator($this->subject)->getSqlString($adapterPlatform); } } diff --git a/library/Zend/Db/Sql/Platform/IbmDb2/IbmDb2.php b/library/Zend/Db/Sql/Platform/IbmDb2/IbmDb2.php index f744bb47..0effa78f 100644 --- a/library/Zend/Db/Sql/Platform/IbmDb2/IbmDb2.php +++ b/library/Zend/Db/Sql/Platform/IbmDb2/IbmDb2.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Platform/IbmDb2/SelectDecorator.php b/library/Zend/Db/Sql/Platform/IbmDb2/SelectDecorator.php index 4ad32369..9df9398c 100644 --- a/library/Zend/Db/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/library/Zend/Db/Sql/Platform/IbmDb2/SelectDecorator.php @@ -3,17 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Platform\IbmDb2; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\StatementContainerInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; @@ -27,7 +25,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $select = null; + protected $subject = null; /** * @return bool @@ -50,7 +48,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface */ public function setSubject($select) { - $this->select = $select; + $this->subject = $select; } /** @@ -61,40 +59,14 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface return $table . ' ' . $alias; } - /** - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function localizeVariables() { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } + parent::localizeVariables(); // set specifications unset($this->specifications[self::LIMIT]); unset($this->specifications[self::OFFSET]); $this->specifications['LIMITOFFSET'] = null; - parent::prepareStatement($adapter, $statementContainer); - } - - /** - * @param PlatformInterface $platform - * @return string - */ - public function getSqlString(PlatformInterface $platform = null) - { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } - - unset($this->specifications[self::LIMIT]); - unset($this->specifications[self::OFFSET]); - $this->specifications['LIMITOFFSET'] = null; - - return parent::getSqlString($platform); } /** diff --git a/library/Zend/Db/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/library/Zend/Db/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php new file mode 100644 index 00000000..c6390e34 --- /dev/null +++ b/library/Zend/Db/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -0,0 +1,248 @@ + 0, + 'zerofill' => 1, + 'identity' => 2, + 'serial' => 2, + 'autoincrement' => 2, + 'comment' => 3, + 'columnformat' => 4, + 'format' => 4, + 'storage' => 5, + ); + + /** + * @param AlterTable $subject + * @return \Zend\Db\Sql\Platform\PlatformDecoratorInterface + */ + public function setSubject($subject) + { + $this->subject = $subject; + + return $this; + } + + /** + * @param string $sql + * @return array + */ + protected function getSqlInsertOffsets($sql) + { + $sqlLength = strlen($sql); + $insertStart = array(); + + foreach (array('NOT NULL', 'NULL', 'DEFAULT', 'UNIQUE', 'PRIMARY', 'REFERENCES') as $needle) { + $insertPos = strpos($sql, ' ' . $needle); + + if ($insertPos !== false) { + switch ($needle) { + case 'REFERENCES': + $insertStart[2] = !isset($insertStart[2]) ? $insertPos : $insertStart[2]; + // no break + case 'PRIMARY': + case 'UNIQUE': + $insertStart[1] = !isset($insertStart[1]) ? $insertPos : $insertStart[1]; + // no break + default: + $insertStart[0] = !isset($insertStart[0]) ? $insertPos : $insertStart[0]; + } + } + } + + foreach (range(0, 3) as $i) { + $insertStart[$i] = isset($insertStart[$i]) ? $insertStart[$i] : $sqlLength; + } + + return $insertStart; + } + + /** + * @param PlatformInterface $adapterPlatform + * @return array + */ + protected function processAddColumns(PlatformInterface $adapterPlatform = null) + { + $sqls = array(); + + foreach ($this->addColumns as $i => $column) { + $sql = $this->processExpression($column, $adapterPlatform); + $insertStart = $this->getSqlInsertOffsets($sql); + $columnOptions = $column->getOptions(); + + uksort($columnOptions, array($this, 'compareColumnOptions')); + + foreach ($columnOptions as $coName => $coValue) { + $insert = ''; + + if (! $coValue) { + continue; + } + + switch ($this->normalizeColumnOption($coName)) { + case 'unsigned': + $insert = ' UNSIGNED'; + $j = 0; + break; + case 'zerofill': + $insert = ' ZEROFILL'; + $j = 0; + break; + case 'identity': + case 'serial': + case 'autoincrement': + $insert = ' AUTO_INCREMENT'; + $j = 1; + break; + case 'comment': + $insert = ' COMMENT ' . $adapterPlatform->quoteValue($coValue); + $j = 2; + break; + case 'columnformat': + case 'format': + $insert = ' COLUMN_FORMAT ' . strtoupper($coValue); + $j = 2; + break; + case 'storage': + $insert = ' STORAGE ' . strtoupper($coValue); + $j = 2; + break; + } + + if ($insert) { + $j = isset($j) ? $j : 0; + $sql = substr_replace($sql, $insert, $insertStart[$j], 0); + $insertStartCount = count($insertStart); + for (; $j < $insertStartCount; ++$j) { + $insertStart[$j] += strlen($insert); + } + } + } + $sqls[$i] = $sql; + } + return array($sqls); + } + + /** + * @param PlatformInterface $adapterPlatform + * @return array + */ + protected function processChangeColumns(PlatformInterface $adapterPlatform = null) + { + $sqls = array(); + foreach ($this->changeColumns as $name => $column) { + $sql = $this->processExpression($column, $adapterPlatform); + $insertStart = $this->getSqlInsertOffsets($sql); + $columnOptions = $column->getOptions(); + + uksort($columnOptions, array($this, 'compareColumnOptions')); + + foreach ($columnOptions as $coName => $coValue) { + $insert = ''; + + if (! $coValue) { + continue; + } + + switch ($this->normalizeColumnOption($coName)) { + case 'unsigned': + $insert = ' UNSIGNED'; + $j = 0; + break; + case 'zerofill': + $insert = ' ZEROFILL'; + $j = 0; + break; + case 'identity': + case 'serial': + case 'autoincrement': + $insert = ' AUTO_INCREMENT'; + $j = 1; + break; + case 'comment': + $insert = ' COMMENT ' . $adapterPlatform->quoteValue($coValue); + $j = 2; + break; + case 'columnformat': + case 'format': + $insert = ' COLUMN_FORMAT ' . strtoupper($coValue); + $j = 2; + break; + case 'storage': + $insert = ' STORAGE ' . strtoupper($coValue); + $j = 2; + break; + } + + if ($insert) { + $j = isset($j) ? $j : 0; + $sql = substr_replace($sql, $insert, $insertStart[$j], 0); + $insertStartCount = count($insertStart); + for (; $j < $insertStartCount; ++$j) { + $insertStart[$j] += strlen($insert); + } + } + } + $sqls[] = array( + $adapterPlatform->quoteIdentifier($name), + $sql + ); + } + + return array($sqls); + } + + /** + * @param string $name + * + * @return string + */ + private function normalizeColumnOption($name) + { + return strtolower(str_replace(array('-', '_', ' '), '', $name)); + } + + /** + * @internal @private this method is only public for PHP 5.3 compatibility purposes. + * + * @param string $columnA + * @param string $columnB + * + * @return int + */ + public function compareColumnOptions($columnA, $columnB) + { + $columnA = $this->normalizeColumnOption($columnA); + $columnA = isset($this->columnOptionSortOrder[$columnA]) + ? $this->columnOptionSortOrder[$columnA] : count($this->columnOptionSortOrder); + + $columnB = $this->normalizeColumnOption($columnB); + $columnB = isset($this->columnOptionSortOrder[$columnB]) + ? $this->columnOptionSortOrder[$columnB] : count($this->columnOptionSortOrder); + + return $columnA - $columnB; + } +} diff --git a/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index d9cfa155..34ea4adf 100644 --- a/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -18,69 +18,168 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @var CreateTable */ - protected $createTable; + protected $subject; + + /** + * @var int[] + */ + protected $columnOptionSortOrder = array( + 'unsigned' => 0, + 'zerofill' => 1, + 'identity' => 2, + 'serial' => 2, + 'autoincrement' => 2, + 'comment' => 3, + 'columnformat' => 4, + 'format' => 4, + 'storage' => 5, + ); /** * @param CreateTable $subject + * + * @return self */ public function setSubject($subject) { - $this->createTable = $subject; + $this->subject = $subject; + + return $this; } /** - * @param null|PlatformInterface $platform - * @return string + * @param string $sql + * @return array */ - public function getSqlString(PlatformInterface $platform = null) + protected function getSqlInsertOffsets($sql) { - // localize variables - foreach (get_object_vars($this->createTable) as $name => $value) { - $this->{$name} = $value; + $sqlLength = strlen($sql); + $insertStart = array(); + + foreach (array('NOT NULL', 'NULL', 'DEFAULT', 'UNIQUE', 'PRIMARY', 'REFERENCES') as $needle) { + $insertPos = strpos($sql, ' ' . $needle); + + if ($insertPos !== false) { + switch ($needle) { + case 'REFERENCES': + $insertStart[2] = !isset($insertStart[2]) ? $insertPos : $insertStart[2]; + // no break + case 'PRIMARY': + case 'UNIQUE': + $insertStart[1] = !isset($insertStart[1]) ? $insertPos : $insertStart[1]; + // no break + default: + $insertStart[0] = !isset($insertStart[0]) ? $insertPos : $insertStart[0]; + } + } } - return parent::getSqlString($platform); + + foreach (range(0, 3) as $i) { + $insertStart[$i] = isset($insertStart[$i]) ? $insertStart[$i] : $sqlLength; + } + + return $insertStart; } + /** + * {@inheritDoc} + */ protected function processColumns(PlatformInterface $platform = null) { + if (! $this->columns) { + return; + } + $sqls = array(); + foreach ($this->columns as $i => $column) { - $stmtContainer = $this->processExpression($column, $platform); - $sql = $stmtContainer->getSql(); + $sql = $this->processExpression($column, $platform); + $insertStart = $this->getSqlInsertOffsets($sql); $columnOptions = $column->getOptions(); + uksort($columnOptions, array($this, 'compareColumnOptions')); + foreach ($columnOptions as $coName => $coValue) { - switch (strtolower(str_replace(array('-', '_', ' '), '', $coName))) { + $insert = ''; + + if (! $coValue) { + continue; + } + + switch ($this->normalizeColumnOption($coName)) { + case 'unsigned': + $insert = ' UNSIGNED'; + $j = 0; + break; + case 'zerofill': + $insert = ' ZEROFILL'; + $j = 0; + break; case 'identity': case 'serial': case 'autoincrement': - $sql .= ' AUTO_INCREMENT'; + $insert = ' AUTO_INCREMENT'; + $j = 1; break; - /* - case 'primary': - case 'primarykey': - $sql .= ' PRIMARY KEY'; - break; - case 'unique': - case 'uniquekey': - $sql .= ' UNIQUE KEY'; - break; - */ case 'comment': - $sql .= ' COMMENT \'' . $coValue . '\''; + $insert = ' COMMENT ' . $platform->quoteValue($coValue); + $j = 2; break; case 'columnformat': case 'format': - $sql .= ' COLUMN_FORMAT ' . strtoupper($coValue); + $insert = ' COLUMN_FORMAT ' . strtoupper($coValue); + $j = 2; break; case 'storage': - $sql .= ' STORAGE ' . strtoupper($coValue); + $insert = ' STORAGE ' . strtoupper($coValue); + $j = 2; break; } + + if ($insert) { + $j = isset($j) ? $j : 0; + $sql = substr_replace($sql, $insert, $insertStart[$j], 0); + $insertStartCount = count($insertStart); + for (; $j < $insertStartCount; ++$j) { + $insertStart[$j] += strlen($insert); + } + } } - $stmtContainer->setSql($sql); - $sqls[$i] = $stmtContainer; + + $sqls[$i] = $sql; } + return array($sqls); } + + /** + * @param string $name + * + * @return string + */ + private function normalizeColumnOption($name) + { + return strtolower(str_replace(array('-', '_', ' '), '', $name)); + } + + /** + * @internal @private this method is only public for PHP 5.3 compatibility purposes. + * + * @param string $columnA + * @param string $columnB + * + * @return int + */ + public function compareColumnOptions($columnA, $columnB) + { + $columnA = $this->normalizeColumnOption($columnA); + $columnA = isset($this->columnOptionSortOrder[$columnA]) + ? $this->columnOptionSortOrder[$columnA] : count($this->columnOptionSortOrder); + + $columnB = $this->normalizeColumnOption($columnB); + $columnB = isset($this->columnOptionSortOrder[$columnB]) + ? $this->columnOptionSortOrder[$columnB] : count($this->columnOptionSortOrder); + + return $columnA - $columnB; + } } diff --git a/library/Zend/Db/Sql/Platform/Mysql/Mysql.php b/library/Zend/Db/Sql/Platform/Mysql/Mysql.php index 80455869..43873257 100644 --- a/library/Zend/Db/Sql/Platform/Mysql/Mysql.php +++ b/library/Zend/Db/Sql/Platform/Mysql/Mysql.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,5 +17,6 @@ class Mysql extends AbstractPlatform { $this->setTypeDecorator('Zend\Db\Sql\Select', new SelectDecorator()); $this->setTypeDecorator('Zend\Db\Sql\Ddl\CreateTable', new Ddl\CreateTableDecorator()); + $this->setTypeDecorator('Zend\Db\Sql\Ddl\AlterTable', new Ddl\AlterTableDecorator()); } } diff --git a/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php b/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php index 5c4678a7..decf9091 100644 --- a/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php +++ b/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php @@ -3,17 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Platform\Mysql; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\StatementContainerInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; @@ -22,46 +20,22 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $select = null; + protected $subject = null; /** * @param Select $select */ public function setSubject($select) { - $this->select = $select; + $this->subject = $select; } - /** - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function localizeVariables() { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } + parent::localizeVariables(); if ($this->limit === null && $this->offset !== null) { $this->specifications[self::LIMIT] = 'LIMIT 18446744073709551615'; } - parent::prepareStatement($adapter, $statementContainer); - } - - /** - * @param PlatformInterface $platform - * @return string - */ - public function getSqlString(PlatformInterface $platform = null) - { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } - if ($this->limit === null && $this->offset !== null) { - $this->specifications[self::LIMIT] = 'LIMIT 18446744073709551615'; - } - return parent::getSqlString($platform); } protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -70,24 +44,22 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface return array(''); } if ($this->limit === null) { - return null; + return; } - if ($driver) { - $sql = $driver->formatParameterName('limit'); + if ($parameterContainer) { $parameterContainer->offsetSet('limit', $this->limit, ParameterContainer::TYPE_INTEGER); - } else { - $sql = $this->limit; + return array($driver->formatParameterName('limit')); } - return array($sql); + return array($this->limit); } protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->offset === null) { - return null; + return; } - if ($driver) { + if ($parameterContainer) { $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER); return array($driver->formatParameterName('offset')); } diff --git a/library/Zend/Db/Sql/Platform/Oracle/Oracle.php b/library/Zend/Db/Sql/Platform/Oracle/Oracle.php index e5af22fa..e2f3f176 100644 --- a/library/Zend/Db/Sql/Platform/Oracle/Oracle.php +++ b/library/Zend/Db/Sql/Platform/Oracle/Oracle.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php b/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php index 457c696b..389d3b2a 100644 --- a/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php +++ b/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php @@ -3,18 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Platform\Oracle; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\StatementContainerInterface; -use Zend\Db\Sql\ExpressionInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; @@ -23,14 +20,14 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $select = null; + protected $subject = null; /** * @param Select $select */ public function setSubject($select) { - $this->select = $select; + $this->subject = $select; } /** @@ -38,44 +35,16 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface */ protected function renderTable($table, $alias = null) { - return $table . ' ' . $alias; + return $table . ($alias ? ' ' . $alias : ''); } - /** - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function localizeVariables() { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } - // set specifications + parent::localizeVariables(); unset($this->specifications[self::LIMIT]); unset($this->specifications[self::OFFSET]); $this->specifications['LIMITOFFSET'] = null; - parent::prepareStatement($adapter, $statementContainer); - } - - /** - * @param PlatformInterface $platform - * @return string - */ - public function getSqlString(PlatformInterface $platform = null) - { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } - - // set specifications - unset($this->specifications[self::LIMIT]); - unset($this->specifications[self::OFFSET]); - - $this->specifications['LIMITOFFSET'] = null; - return parent::getSqlString($platform); } /** @@ -89,7 +58,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters) { if ($this->limit === null && $this->offset === null) { - return null; + return; } $selectParameters = $parameters[self::SELECT]; @@ -145,36 +114,4 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface $this->specifications[self::SELECT], $parameters[self::SELECT] ); } - - - protected function processJoins(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) - { - if (!$this->joins) { - return null; - } - - // process joins - $joinSpecArgArray = array(); - foreach ($this->joins as $j => $join) { - $joinSpecArgArray[$j] = array(); - // type - $joinSpecArgArray[$j][] = strtoupper($join['type']); - // table name - $joinSpecArgArray[$j][] = (is_array($join['name'])) - ? $platform->quoteIdentifier(current($join['name'])) . ' ' . $platform->quoteIdentifier(key($join['name'])) - : $platform->quoteIdentifier($join['name']); - // on expression - $joinSpecArgArray[$j][] = ($join['on'] instanceof ExpressionInterface) - ? $this->processExpression($join['on'], $platform, $driver, $this->processInfo['paramPrefix'] . 'join') - : $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN')); // on - if ($joinSpecArgArray[$j][2] instanceof StatementContainerInterface) { - if ($parameterContainer) { - $parameterContainer->merge($joinSpecArgArray[$j][2]->getParameterContainer()); - } - $joinSpecArgArray[$j][2] = $joinSpecArgArray[$j][2]->getSql(); - } - } - - return array($joinSpecArgArray); - } } diff --git a/library/Zend/Db/Sql/Platform/Platform.php b/library/Zend/Db/Sql/Platform/Platform.php index 4a6fc2e9..886ed193 100644 --- a/library/Zend/Db/Sql/Platform/Platform.php +++ b/library/Zend/Db/Sql/Platform/Platform.php @@ -3,13 +3,18 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Platform; use Zend\Db\Adapter\AdapterInterface; +use Zend\Db\Adapter\Platform\PlatformInterface; +use Zend\Db\Adapter\StatementContainerInterface; +use Zend\Db\Sql\Exception; +use Zend\Db\Sql\PreparableSqlInterface; +use Zend\Db\Sql\SqlInterface; class Platform extends AbstractPlatform { @@ -18,29 +23,143 @@ class Platform extends AbstractPlatform */ protected $adapter = null; + /** + * @var PlatformInterface|null + */ + protected $defaultPlatform; + public function __construct(AdapterInterface $adapter) { - $this->adapter = $adapter; - $platform = $adapter->getPlatform(); - switch (strtolower($platform->getName())) { - case 'mysql': - $platform = new Mysql\Mysql(); - $this->decorators = $platform->decorators; - break; - case 'sqlserver': - $platform = new SqlServer\SqlServer(); - $this->decorators = $platform->decorators; - break; - case 'oracle': - $platform = new Oracle\Oracle(); - $this->decorators = $platform->decorators; - break; - case 'ibm db2': - case 'ibm_db2': - case 'ibmdb2': - $platform = new IbmDb2\IbmDb2(); - $this->decorators = $platform->decorators; - default: + $this->defaultPlatform = $adapter->getPlatform(); + + $mySqlPlatform = new Mysql\Mysql(); + $sqlServerPlatform = new SqlServer\SqlServer(); + $oraclePlatform = new Oracle\Oracle(); + $ibmDb2Platform = new IbmDb2\IbmDb2(); + + $this->decorators['mysql'] = $mySqlPlatform->getDecorators(); + $this->decorators['sqlserver'] = $sqlServerPlatform->getDecorators(); + $this->decorators['oracle'] = $oraclePlatform->getDecorators(); + $this->decorators['ibmdb2'] = $ibmDb2Platform->getDecorators(); + } + + /** + * @param string $type + * @param PlatformDecoratorInterface $decorator + * @param AdapterInterface|PlatformInterface $adapterOrPlatform + */ + public function setTypeDecorator($type, PlatformDecoratorInterface $decorator, $adapterOrPlatform = null) + { + $platformName = $this->resolvePlatformName($adapterOrPlatform); + $this->decorators[$platformName][$type] = $decorator; + } + + /** + * @param PreparableSqlInterface|SqlInterface $subject + * @param AdapterInterface|PlatformInterface|null $adapterOrPlatform + * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface + */ + public function getTypeDecorator($subject, $adapterOrPlatform = null) + { + $platformName = $this->resolvePlatformName($adapterOrPlatform); + + if (isset($this->decorators[$platformName])) { + foreach ($this->decorators[$platformName] as $type => $decorator) { + if ($subject instanceof $type && is_a($decorator, $type, true)) { + $decorator->setSubject($subject); + return $decorator; + } + } } + + return $subject; + } + + /** + * @return array|PlatformDecoratorInterface[] + */ + public function getDecorators() + { + $platformName = $this->resolvePlatformName($this->getDefaultPlatform()); + return $this->decorators[$platformName]; + } + + /** + * {@inheritDoc} + * + * @throws Exception\RuntimeException + */ + public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + { + if (! $this->subject instanceof PreparableSqlInterface) { + throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling prepareStatement() has no effect'); + } + + $this->getTypeDecorator($this->subject, $adapter)->prepareStatement($adapter, $statementContainer); + + return $statementContainer; + } + + /** + * {@inheritDoc} + * + * @throws Exception\RuntimeException + */ + public function getSqlString(PlatformInterface $adapterPlatform = null) + { + if (! $this->subject instanceof SqlInterface) { + throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\SqlInterface, thus calling prepareStatement() has no effect'); + } + + $adapterPlatform = $this->resolvePlatform($adapterPlatform); + + return $this->getTypeDecorator($this->subject, $adapterPlatform)->getSqlString($adapterPlatform); + } + + protected function resolvePlatformName($adapterOrPlatform) + { + $platformName = $this->resolvePlatform($adapterOrPlatform)->getName(); + return str_replace(array(' ', '_'), '', strtolower($platformName)); + } + /** + * @param null|PlatformInterface|AdapterInterface $adapterOrPlatform + * + * @return PlatformInterface + * + * @throws Exception\InvalidArgumentException + */ + protected function resolvePlatform($adapterOrPlatform) + { + if (! $adapterOrPlatform) { + return $this->getDefaultPlatform(); + } + + if ($adapterOrPlatform instanceof AdapterInterface) { + return $adapterOrPlatform->getPlatform(); + } + + if ($adapterOrPlatform instanceof PlatformInterface) { + return $adapterOrPlatform; + } + + throw new Exception\InvalidArgumentException(sprintf( + '$adapterOrPlatform should be null, %s, or %s', + 'Zend\Db\Adapter\AdapterInterface', + 'Zend\Db\Adapter\Platform\PlatformInterface' + )); + } + + /** + * @return PlatformInterface + * + * @throws Exception\RuntimeException + */ + protected function getDefaultPlatform() + { + if (! $this->defaultPlatform) { + throw new Exception\RuntimeException('$this->defaultPlatform was not set'); + } + + return $this->defaultPlatform; } } diff --git a/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php b/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php index 2ff7c97c..6cda120d 100644 --- a/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php +++ b/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,5 +11,10 @@ namespace Zend\Db\Sql\Platform; interface PlatformDecoratorInterface { + /** + * @param $subject + * + * @return self + */ public function setSubject($subject); } diff --git a/library/Zend/Db/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/library/Zend/Db/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index c84742df..0a8ea8c3 100644 --- a/library/Zend/Db/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/library/Zend/Db/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -18,7 +18,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @var CreateTable */ - protected $createTable; + protected $subject; /** * @param CreateTable $subject @@ -26,36 +26,20 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter */ public function setSubject($subject) { - $this->createTable = $subject; + $this->subject = $subject; return $this; } - /** - * @param null|PlatformInterface $platform - * @return string - */ - public function getSqlString(PlatformInterface $platform = null) - { - // localize variables - foreach (get_object_vars($this->createTable) as $name => $value) { - $this->{$name} = $value; - } - return parent::getSqlString($platform); - } - /** * @param PlatformInterface $adapterPlatform * @return array */ protected function processTable(PlatformInterface $adapterPlatform = null) { - $ret = array(''); - if ($this->isTemporary) { - $table = '#'; - } else { - $table = ''; - } - $ret[] = $adapterPlatform->quoteIdentifier($table . ltrim($this->table, '#')); - return $ret; + $table = ($this->isTemporary ? '#' : '') . ltrim($this->table, '#'); + return array( + '', + $adapterPlatform->quoteIdentifier($table), + ); } } diff --git a/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php b/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php index 7667ebcb..e1da3f22 100644 --- a/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php +++ b/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php @@ -3,18 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Platform\SqlServer; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Driver\Sqlsrv\Statement; -use Zend\Db\Adapter\StatementContainerInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; @@ -23,57 +20,24 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $select = null; + protected $subject = null; /** * @param Select $select */ public function setSubject($select) { - $this->select = $select; + $this->subject = $select; } - /** - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function localizeVariables() { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } - + parent::localizeVariables(); // set specifications unset($this->specifications[self::LIMIT]); unset($this->specifications[self::OFFSET]); $this->specifications['LIMITOFFSET'] = null; - parent::prepareStatement($adapter, $statementContainer); - - //set statement cursor type - if ($statementContainer instanceof Statement) { - $statementContainer->setPrepareOptions(array('Scrollable'=>\SQLSRV_CURSOR_STATIC)); - } - } - - /** - * @param PlatformInterface $platform - * @return string - */ - public function getSqlString(PlatformInterface $platform = null) - { - // localize variables - foreach (get_object_vars($this->select) as $name => $value) { - $this->{$name} = $value; - } - - // set specifications - unset($this->specifications[self::LIMIT]); - unset($this->specifications[self::OFFSET]); - - $this->specifications['LIMITOFFSET'] = null; - return parent::getSqlString($platform); } /** @@ -87,7 +51,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters) { if ($this->limit === null && $this->offset === null) { - return null; + return; } $selectParameters = $parameters[self::SELECT]; diff --git a/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php b/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php index ed72b77a..1bb500d4 100644 --- a/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php +++ b/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Predicate/Between.php b/library/Zend/Db/Sql/Predicate/Between.php index 686b65db..b927cdf4 100644 --- a/library/Zend/Db/Sql/Predicate/Between.php +++ b/library/Zend/Db/Sql/Predicate/Between.php @@ -3,13 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Predicate; -class Between implements PredicateInterface +use Zend\Db\Sql\AbstractExpression; + +class Between extends AbstractExpression implements PredicateInterface { protected $specification = '%1$s BETWEEN %2$s AND %3$s'; protected $identifier = null; @@ -131,11 +133,14 @@ class Between implements PredicateInterface */ public function getExpressionData() { + list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); + list($values[], $types[]) = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); + list($values[], $types[]) = $this->normalizeArgument($this->maxValue, self::TYPE_VALUE); return array( array( $this->getSpecification(), - array($this->identifier, $this->minValue, $this->maxValue), - array(self::TYPE_IDENTIFIER, self::TYPE_VALUE, self::TYPE_VALUE), + $values, + $types, ), ); } diff --git a/library/Zend/Db/Sql/Predicate/Expression.php b/library/Zend/Db/Sql/Predicate/Expression.php index 4822dd08..ee54dd29 100644 --- a/library/Zend/Db/Sql/Predicate/Expression.php +++ b/library/Zend/Db/Sql/Predicate/Expression.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,17 +25,6 @@ class Expression extends BaseExpression implements PredicateInterface $this->setExpression($expression); } - if (is_array($valueParameter)) { - $this->setParameters($valueParameter); - } else { - $argNum = func_num_args(); - if ($argNum > 2 || is_scalar($valueParameter)) { - $parameters = array(); - for ($i = 1; $i < $argNum; $i++) { - $parameters[] = func_get_arg($i); - } - $this->setParameters($parameters); - } - } + $this->setParameters(is_array($valueParameter) ? $valueParameter : array_slice(func_get_args(), 1)); } } diff --git a/library/Zend/Db/Sql/Predicate/In.php b/library/Zend/Db/Sql/Predicate/In.php index eb7ccc36..7fcefcde 100644 --- a/library/Zend/Db/Sql/Predicate/In.php +++ b/library/Zend/Db/Sql/Predicate/In.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,14 +11,17 @@ namespace Zend\Db\Sql\Predicate; use Zend\Db\Sql\Exception; use Zend\Db\Sql\Select; +use Zend\Db\Sql\AbstractExpression; -class In implements PredicateInterface +class In extends AbstractExpression implements PredicateInterface { protected $identifier; protected $valueSet; protected $specification = '%s IN %s'; + protected $valueSpecSpecification = '%%s IN (%s)'; + /** * Constructor * @@ -116,12 +119,13 @@ class In implements PredicateInterface $replacements[] = $values; $types[] = self::TYPE_VALUE; } else { + foreach ($values as $argument) { + list($replacements[], $types[]) = $this->normalizeArgument($argument, self::TYPE_VALUE); + } $specification = vsprintf( $this->specification, array($identifierSpecFragment, '(' . implode(', ', array_fill(0, count($values), '%s')) . ')') ); - $replacements = array_merge($replacements, $values); - $types = array_merge($types, array_fill(0, count($values), self::TYPE_VALUE)); } return array(array( diff --git a/library/Zend/Db/Sql/Predicate/IsNotNull.php b/library/Zend/Db/Sql/Predicate/IsNotNull.php index e09f3491..13dfa319 100644 --- a/library/Zend/Db/Sql/Predicate/IsNotNull.php +++ b/library/Zend/Db/Sql/Predicate/IsNotNull.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Predicate/IsNull.php b/library/Zend/Db/Sql/Predicate/IsNull.php index c184a020..3ae953e5 100644 --- a/library/Zend/Db/Sql/Predicate/IsNull.php +++ b/library/Zend/Db/Sql/Predicate/IsNull.php @@ -3,13 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Predicate; -class IsNull implements PredicateInterface +use Zend\Db\Sql\AbstractExpression; + +class IsNull extends AbstractExpression implements PredicateInterface { /** * @var string @@ -84,10 +86,11 @@ class IsNull implements PredicateInterface */ public function getExpressionData() { + $identifier = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); return array(array( $this->getSpecification(), - array($this->identifier), - array(self::TYPE_IDENTIFIER), + array($identifier[0]), + array($identifier[1]), )); } } diff --git a/library/Zend/Db/Sql/Predicate/Like.php b/library/Zend/Db/Sql/Predicate/Like.php index b5d6676f..301340c6 100644 --- a/library/Zend/Db/Sql/Predicate/Like.php +++ b/library/Zend/Db/Sql/Predicate/Like.php @@ -3,13 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Predicate; -class Like implements PredicateInterface +use Zend\Db\Sql\AbstractExpression; + +class Like extends AbstractExpression implements PredicateInterface { /** * @var string @@ -99,8 +101,14 @@ class Like implements PredicateInterface */ public function getExpressionData() { + list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); + list($values[], $types[]) = $this->normalizeArgument($this->like, self::TYPE_VALUE); return array( - array($this->specification, array($this->identifier, $this->like), array(self::TYPE_IDENTIFIER, self::TYPE_VALUE)) + array( + $this->specification, + $values, + $types, + ) ); } } diff --git a/library/Zend/Db/Sql/Predicate/Literal.php b/library/Zend/Db/Sql/Predicate/Literal.php index 5ee68c99..8d88cf33 100644 --- a/library/Zend/Db/Sql/Predicate/Literal.php +++ b/library/Zend/Db/Sql/Predicate/Literal.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Predicate/NotIn.php b/library/Zend/Db/Sql/Predicate/NotIn.php index 09555590..de32d23c 100644 --- a/library/Zend/Db/Sql/Predicate/NotIn.php +++ b/library/Zend/Db/Sql/Predicate/NotIn.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Predicate/NotLike.php b/library/Zend/Db/Sql/Predicate/NotLike.php index 329de23e..0cd1afaf 100644 --- a/library/Zend/Db/Sql/Predicate/NotLike.php +++ b/library/Zend/Db/Sql/Predicate/NotLike.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Predicate; - class NotLike extends Like { protected $specification = '%1$s NOT LIKE %2$s'; diff --git a/library/Zend/Db/Sql/Predicate/Operator.php b/library/Zend/Db/Sql/Predicate/Operator.php index acd94140..2de5dfd3 100644 --- a/library/Zend/Db/Sql/Predicate/Operator.php +++ b/library/Zend/Db/Sql/Predicate/Operator.php @@ -3,15 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql\Predicate; use Zend\Db\Sql\Exception; +use Zend\Db\Sql\AbstractExpression; -class Operator implements PredicateInterface +class Operator extends AbstractExpression implements PredicateInterface { const OPERATOR_EQUAL_TO = '='; const OP_EQ = '='; @@ -31,28 +32,55 @@ class Operator implements PredicateInterface const OPERATOR_GREATER_THAN_OR_EQUAL_TO = '>='; const OP_GTE = '>='; + /** + * {@inheritDoc} + */ protected $allowedTypes = array( self::TYPE_IDENTIFIER, self::TYPE_VALUE, ); - protected $left = null; - protected $leftType = self::TYPE_IDENTIFIER; - protected $operator = self::OPERATOR_EQUAL_TO; - protected $right = null; - protected $rightType = self::TYPE_VALUE; + /** + * @var int|float|bool|string + */ + protected $left; + + /** + * @var int|float|bool|string + */ + protected $right; + + /** + * @var string + */ + protected $leftType = self::TYPE_IDENTIFIER; + + /** + * @var string + */ + protected $rightType = self::TYPE_VALUE; + + /** + * @var string + */ + protected $operator = self::OPERATOR_EQUAL_TO; /** * Constructor * - * @param int|float|bool|string $left - * @param string $operator - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param string $operator + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} */ - public function __construct($left = null, $operator = self::OPERATOR_EQUAL_TO, $right = null, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE) - { + public function __construct( + $left = null, + $operator = self::OPERATOR_EQUAL_TO, + $right = null, + $leftType = self::TYPE_IDENTIFIER, + $rightType = self::TYPE_VALUE + ) { if ($left !== null) { $this->setLeft($left); } @@ -78,11 +106,18 @@ class Operator implements PredicateInterface * Set left side of operator * * @param int|float|bool|string $left + * * @return Operator */ public function setLeft($left) { $this->left = $left; + + if (is_array($left)) { + $left = $this->normalizeArgument($left, $this->leftType); + $this->leftType = $left[1]; + } + return $this; } @@ -100,8 +135,10 @@ class Operator implements PredicateInterface * Set parameter type for left side of operator * * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} - * @throws Exception\InvalidArgumentException + * * @return Operator + * + * @throws Exception\InvalidArgumentException */ public function setLeftType($type) { @@ -113,7 +150,9 @@ class Operator implements PredicateInterface __CLASS__ . '::TYPE_VALUE' )); } + $this->leftType = $type; + return $this; } @@ -136,6 +175,7 @@ class Operator implements PredicateInterface public function setOperator($operator) { $this->operator = $operator; + return $this; } @@ -152,12 +192,19 @@ class Operator implements PredicateInterface /** * Set right side of operator * - * @param int|float|bool|string $value + * @param int|float|bool|string $right + * * @return Operator */ - public function setRight($value) + public function setRight($right) { - $this->right = $value; + $this->right = $right; + + if (is_array($right)) { + $right = $this->normalizeArgument($right, $this->rightType); + $this->rightType = $right[1]; + } + return $this; } @@ -188,7 +235,9 @@ class Operator implements PredicateInterface __CLASS__ . '::TYPE_VALUE' )); } + $this->rightType = $type; + return $this; } @@ -209,10 +258,13 @@ class Operator implements PredicateInterface */ public function getExpressionData() { + list($values[], $types[]) = $this->normalizeArgument($this->left, $this->leftType); + list($values[], $types[]) = $this->normalizeArgument($this->right, $this->rightType); + return array(array( '%s ' . $this->operator . ' %s', - array($this->left, $this->right), - array($this->leftType, $this->rightType) + $values, + $types )); } } diff --git a/library/Zend/Db/Sql/Predicate/Predicate.php b/library/Zend/Db/Sql/Predicate/Predicate.php index e9ef5757..c928100e 100644 --- a/library/Zend/Db/Sql/Predicate/Predicate.php +++ b/library/Zend/Db/Sql/Predicate/Predicate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -57,12 +57,12 @@ class Predicate extends PredicateSet */ public function unnest() { - if ($this->unnest == null) { + if ($this->unnest === null) { throw new RuntimeException('Not nested'); } - $unnset = $this->unnest; + $unnest = $this->unnest; $this->unnest = null; - return $unnset; + return $unnest; } /** @@ -382,6 +382,27 @@ class Predicate extends PredicateSet return $this; } + /** + * Use given predicate directly + * + * Contrary to {@link addPredicate()} this method respects formerly set + * AND / OR combination operator, thus allowing generic predicates to be + * used fluently within where chains as any other concrete predicate. + * + * @param PredicateInterface $predicate + * @return Predicate + */ + public function predicate(PredicateInterface $predicate) + { + $this->addPredicate( + $predicate, + $this->nextPredicateCombineOperator ?: $this->defaultCombination + ); + $this->nextPredicateCombineOperator = null; + + return $this; + } + /** * Overloading * diff --git a/library/Zend/Db/Sql/Predicate/PredicateInterface.php b/library/Zend/Db/Sql/Predicate/PredicateInterface.php index 68b197f8..32b99c54 100644 --- a/library/Zend/Db/Sql/Predicate/PredicateInterface.php +++ b/library/Zend/Db/Sql/Predicate/PredicateInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/Sql/Predicate/PredicateSet.php b/library/Zend/Db/Sql/Predicate/PredicateSet.php index c616425b..921d8fcb 100644 --- a/library/Zend/Db/Sql/Predicate/PredicateSet.php +++ b/library/Zend/Db/Sql/Predicate/PredicateSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -61,6 +61,13 @@ class PredicateSet implements PredicateInterface, Countable return $this; } + /** + * Add predicates to set + * + * @param PredicateInterface|\Closure|string|array $predicates + * @param string $combination + * @return PredicateSet + */ public function addPredicates($predicates, $combination = self::OP_AND) { if ($predicates === null) { @@ -91,7 +98,7 @@ class PredicateSet implements PredicateInterface, Countable $predicates = new Expression($pkey, $pvalue); } elseif ($pvalue === null) { // Otherwise, if still a string, do something intelligent with the PHP type provided // map PHP null to SQL IS NULL expression - $predicates = new IsNull($pkey, $pvalue); + $predicates = new IsNull($pkey); } elseif (is_array($pvalue)) { // if the value is an array, assume IN() is desired $predicates = new In($pkey, $pvalue); diff --git a/library/Zend/Db/Sql/PreparableSqlInterface.php b/library/Zend/Db/Sql/PreparableSqlInterface.php index ea32cd65..f5dc2851 100644 --- a/library/Zend/Db/Sql/PreparableSqlInterface.php +++ b/library/Zend/Db/Sql/PreparableSqlInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,8 +15,9 @@ use Zend\Db\Adapter\StatementContainerInterface; interface PreparableSqlInterface { /** - * @param AdapterInterface $adapter + * @param AdapterInterface $adapter * @param StatementContainerInterface $statementContainer + * * @return void */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer); diff --git a/library/Zend/Db/Sql/Select.php b/library/Zend/Db/Sql/Select.php index d63ed299..2596eb2c 100644 --- a/library/Zend/Db/Sql/Select.php +++ b/library/Zend/Db/Sql/Select.php @@ -3,25 +3,22 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\Driver\DriverInterface; -use Zend\Db\Adapter\StatementContainerInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92 as AdapterSql92Platform; /** * * @property Where $where * @property Having $having */ -class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface +class Select extends AbstractPreparableSql { /**#@+ * Constant @@ -44,6 +41,8 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface const JOIN_OUTER = 'outer'; const JOIN_LEFT = 'left'; const JOIN_RIGHT = 'right'; + const JOIN_OUTER_RIGHT = 'outer right'; + const JOIN_OUTER_LEFT = 'outer left'; const SQL_STAR = '*'; const ORDER_ASCENDING = 'ASC'; const ORDER_DESCENDING = 'DESC'; @@ -207,9 +206,9 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function quantifier($quantifier) { - if (!is_string($quantifier) && !$quantifier instanceof Expression) { + if (!is_string($quantifier) && !$quantifier instanceof ExpressionInterface) { throw new Exception\InvalidArgumentException( - 'Quantifier must be one of DISTINCT, ALL, or some platform specific Expression object' + 'Quantifier must be one of DISTINCT, ALL, or some platform specific object implementing ExpressionInterface' ); } $this->quantifier = $quantifier; @@ -475,65 +474,6 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - /** - * Prepare statement - * - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - * @return void - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) - { - // ensure statement has a ParameterContainer - $parameterContainer = $statementContainer->getParameterContainer(); - if (!$parameterContainer instanceof ParameterContainer) { - $parameterContainer = new ParameterContainer(); - $statementContainer->setParameterContainer($parameterContainer); - } - - $sqls = array(); - $parameters = array(); - $platform = $adapter->getPlatform(); - $driver = $adapter->getDriver(); - - foreach ($this->specifications as $name => $specification) { - $parameters[$name] = $this->{'process' . $name}($platform, $driver, $parameterContainer, $sqls, $parameters); - if ($specification && is_array($parameters[$name])) { - $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]); - } - } - - $sql = implode(' ', $sqls); - - $statementContainer->setSql($sql); - return; - } - - /** - * Get SQL string for statement - * - * @param null|PlatformInterface $adapterPlatform If null, defaults to Sql92 - * @return string - */ - public function getSqlString(PlatformInterface $adapterPlatform = null) - { - // get platform, or create default - $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform; - - $sqls = array(); - $parameters = array(); - - foreach ($this->specifications as $name => $specification) { - $parameters[$name] = $this->{'process' . $name}($adapterPlatform, null, null, $sqls, $parameters); - if ($specification && is_array($parameters[$name])) { - $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]); - } - } - - $sql = implode(' ', $sqls); - return $sql; - } - /** * Returns whether the table is read only or not. * @@ -554,11 +494,7 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface */ protected function renderTable($table, $alias = null) { - $sql = $table; - if ($alias) { - $sql .= ' AS ' . $alias; - } - return $sql; + return $table . ($alias ? ' AS ' . $alias : ''); } protected function processStatementStart(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -587,70 +523,26 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface { $expr = 1; - if ($this->table) { - $table = $this->table; - $schema = $alias = null; - - if (is_array($table)) { - $alias = key($this->table); - $table = current($this->table); - } - - // create quoted table name to use in columns processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); - } - - if ($table instanceof Select) { - $table = '(' . $this->processSubselect($table, $platform, $driver, $parameterContainer) . ')'; - } else { - $table = $platform->quoteIdentifier($table); - } - - if ($schema) { - $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; - } - - if ($alias) { - $fromTable = $platform->quoteIdentifier($alias); - $table = $this->renderTable($table, $fromTable); - } else { - $fromTable = $table; - } - } else { - $fromTable = ''; - } - - if ($this->prefixColumnsWithTable) { - $fromTable .= $platform->getIdentifierSeparator(); - } else { - $fromTable = ''; - } - + list($table, $fromTable) = $this->resolveTable($this->table, $platform, $driver, $parameterContainer); // process table columns $columns = array(); foreach ($this->columns as $columnIndexOrAs => $column) { - $columnName = ''; if ($column === self::SQL_STAR) { $columns[] = array($fromTable . self::SQL_STAR); continue; } - if ($column instanceof ExpressionInterface) { - $columnParts = $this->processExpression( - $column, - $platform, - $driver, - $this->processInfo['paramPrefix'] . ((is_string($columnIndexOrAs)) ? $columnIndexOrAs : 'column') - ); - if ($parameterContainer) { - $parameterContainer->merge($columnParts->getParameterContainer()); - } - $columnName .= $columnParts->getSql(); - } else { - $columnName .= $fromTable . $platform->quoteIdentifier($column); - } - + $columnName = $this->resolveColumnValue( + array( + 'column' => $column, + 'fromTable' => $fromTable, + 'isIdentifier' => true, + ), + $platform, + $driver, + $parameterContainer, + (is_string($columnIndexOrAs) ? $columnIndexOrAs : 'column') + ); // process As portion if (is_string($columnIndexOrAs)) { $columnAs = $platform->quoteIdentifier($columnIndexOrAs); @@ -660,32 +552,27 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface $columns[] = (isset($columnAs)) ? array($columnName, $columnAs) : array($columnName); } - $separator = $platform->getIdentifierSeparator(); - // process join columns foreach ($this->joins as $join) { + $joinName = (is_array($join['name'])) ? key($join['name']) : $join['name']; + $joinName = parent::resolveTable($joinName, $platform, $driver, $parameterContainer); + foreach ($join['columns'] as $jKey => $jColumn) { $jColumns = array(); - if ($jColumn instanceof ExpressionInterface) { - $jColumnParts = $this->processExpression( - $jColumn, - $platform, - $driver, - $this->processInfo['paramPrefix'] . ((is_string($jKey)) ? $jKey : 'column') - ); - if ($parameterContainer) { - $parameterContainer->merge($jColumnParts->getParameterContainer()); - } - $jColumns[] = $jColumnParts->getSql(); - } else { - $name = (is_array($join['name'])) ? key($join['name']) : $name = $join['name']; - if ($name instanceof TableIdentifier) { - $name = ($name->hasSchema() ? $platform->quoteIdentifier($name->getSchema()) . $separator : '') . $platform->quoteIdentifier($name->getTable()); - } else { - $name = $platform->quoteIdentifier($name); - } - $jColumns[] = $name . $separator . $platform->quoteIdentifierInFragment($jColumn); - } + $jFromTable = is_scalar($jColumn) + ? $joinName . $platform->getIdentifierSeparator() + : ''; + $jColumns[] = $this->resolveColumnValue( + array( + 'column' => $jColumn, + 'fromTable' => $jFromTable, + 'isIdentifier' => true, + ), + $platform, + $driver, + $parameterContainer, + (is_string($jKey) ? $jKey : 'column') + ); if (is_string($jKey)) { $jColumns[] = $platform->quoteIdentifier($jKey); } elseif ($jColumn !== self::SQL_STAR) { @@ -696,15 +583,9 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface } if ($this->quantifier) { - if ($this->quantifier instanceof ExpressionInterface) { - $quantifierParts = $this->processExpression($this->quantifier, $platform, $driver, 'quantifier'); - if ($parameterContainer) { - $parameterContainer->merge($quantifierParts->getParameterContainer()); - } - $quantifier = $quantifierParts->getSql(); - } else { - $quantifier = $this->quantifier; - } + $quantifier = ($this->quantifier instanceof ExpressionInterface) + ? $this->processExpression($this->quantifier, $platform, $driver, $parameterContainer, 'quantifier') + : $this->quantifier; } if (!isset($table)) { @@ -719,19 +600,15 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface protected function processJoins(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if (!$this->joins) { - return null; + return; } // process joins $joinSpecArgArray = array(); foreach ($this->joins as $j => $join) { - $joinSpecArgArray[$j] = array(); $joinName = null; $joinAs = null; - // type - $joinSpecArgArray[$j][] = strtoupper($join['type']); - // table name if (is_array($join['name'])) { $joinName = current($join['name']); @@ -739,31 +616,30 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface } else { $joinName = $join['name']; } - if ($joinName instanceof ExpressionInterface) { + + if ($joinName instanceof Expression) { $joinName = $joinName->getExpression(); } elseif ($joinName instanceof TableIdentifier) { $joinName = $joinName->getTableAndSchema(); $joinName = ($joinName[1] ? $platform->quoteIdentifier($joinName[1]) . $platform->getIdentifierSeparator() : '') . $platform->quoteIdentifier($joinName[0]); + } elseif ($joinName instanceof Select) { + $joinName = '(' . $this->processSubSelect($joinName, $platform, $driver, $parameterContainer) . ')'; + } elseif (is_string($joinName) || (is_object($joinName) && is_callable(array($joinName, '__toString')))) { + $joinName = $platform->quoteIdentifier($joinName); } else { - if ($joinName instanceof Select) { - $joinName = '(' . $this->processSubSelect($joinName, $platform, $driver, $parameterContainer) . ')'; - } else { - $joinName = $platform->quoteIdentifier($joinName); - } + throw new Exception\InvalidArgumentException(sprintf('Join name expected to be Expression|TableIdentifier|Select|string, "%s" given', gettype($joinName))); } - $joinSpecArgArray[$j][] = (isset($joinAs)) ? $joinName . ' AS ' . $joinAs : $joinName; + + $joinSpecArgArray[$j] = array( + strtoupper($join['type']), + $this->renderTable($joinName, $joinAs), + ); // on expression // note: for Expression objects, pass them to processExpression with a prefix specific to each join (used for named parameters) $joinSpecArgArray[$j][] = ($join['on'] instanceof ExpressionInterface) - ? $this->processExpression($join['on'], $platform, $driver, $this->processInfo['paramPrefix'] . 'join' . ($j+1) . 'part') + ? $this->processExpression($join['on'], $platform, $driver, $parameterContainer, 'join' . ($j+1) . 'part') : $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN', '<', '>')); // on - if ($joinSpecArgArray[$j][2] instanceof StatementContainerInterface) { - if ($parameterContainer) { - $parameterContainer->merge($joinSpecArgArray[$j][2]->getParameterContainer()); - } - $joinSpecArgArray[$j][2] = $joinSpecArgArray[$j][2]->getSql(); - } } return array($joinSpecArgArray); @@ -772,34 +648,31 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->where->count() == 0) { - return null; + return; } - $whereParts = $this->processExpression($this->where, $platform, $driver, $this->processInfo['paramPrefix'] . 'where'); - if ($parameterContainer) { - $parameterContainer->merge($whereParts->getParameterContainer()); - } - return array($whereParts->getSql()); + return array( + $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where') + ); } protected function processGroup(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->group === null) { - return null; + return; } // process table columns $groups = array(); foreach ($this->group as $column) { - $columnSql = ''; - if ($column instanceof Expression) { - $columnParts = $this->processExpression($column, $platform, $driver, $this->processInfo['paramPrefix'] . 'group'); - if ($parameterContainer) { - $parameterContainer->merge($columnParts->getParameterContainer()); - } - $columnSql .= $columnParts->getSql(); - } else { - $columnSql .= $platform->quoteIdentifierInFragment($column); - } - $groups[] = $columnSql; + $groups[] = $this->resolveColumnValue( + array( + 'column' => $column, + 'isIdentifier' => true, + ), + $platform, + $driver, + $parameterContainer, + 'group' + ); } return array($groups); } @@ -807,29 +680,24 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface protected function processHaving(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->having->count() == 0) { - return null; + return; } - $whereParts = $this->processExpression($this->having, $platform, $driver, $this->processInfo['paramPrefix'] . 'having'); - if ($parameterContainer) { - $parameterContainer->merge($whereParts->getParameterContainer()); - } - return array($whereParts->getSql()); + return array( + $this->processExpression($this->having, $platform, $driver, $parameterContainer, 'having') + ); } protected function processOrder(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if (empty($this->order)) { - return null; + return; } $orders = array(); foreach ($this->order as $k => $v) { - if ($v instanceof Expression) { - /** @var $orderParts \Zend\Db\Adapter\StatementContainer */ - $orderParts = $this->processExpression($v, $platform, $driver); - if ($parameterContainer) { - $parameterContainer->merge($orderParts->getParameterContainer()); - } - $orders[] = array($orderParts->getSql()); + if ($v instanceof ExpressionInterface) { + $orders[] = array( + $this->processExpression($v, $platform, $driver, $parameterContainer) + ); continue; } if (is_int($k)) { @@ -852,56 +720,42 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->limit === null) { - return null; + return; } - - $limit = $this->limit; - - if ($driver) { - $sql = $driver->formatParameterName('limit'); - $parameterContainer->offsetSet('limit', $limit, ParameterContainer::TYPE_INTEGER); - } else { - $sql = $platform->quoteValue($limit); + if ($parameterContainer) { + $parameterContainer->offsetSet('limit', $this->limit, ParameterContainer::TYPE_INTEGER); + return array($driver->formatParameterName('limit')); } - - return array($sql); + return array($platform->quoteValue($this->limit)); } protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->offset === null) { - return null; + return; } - - $offset = $this->offset; - - if ($driver) { - $parameterContainer->offsetSet('offset', $offset, ParameterContainer::TYPE_INTEGER); + if ($parameterContainer) { + $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER); return array($driver->formatParameterName('offset')); } - return array($platform->quoteValue($offset)); + return array($platform->quoteValue($this->offset)); } protected function processCombine(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->combine == array()) { - return null; + return; } $type = $this->combine['type']; if ($this->combine['modifier']) { $type .= ' ' . $this->combine['modifier']; } - $type = strtoupper($type); - if ($driver) { - $sql = $this->processSubSelect($this->combine['select'], $platform, $driver, $parameterContainer); - return array($type, $sql); - } return array( - $type, - $this->processSubSelect($this->combine['select'], $platform) + strtoupper($type), + $this->processSubSelect($this->combine['select'], $platform, $driver, $parameterContainer), ); } @@ -936,4 +790,41 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface $this->where = clone $this->where; $this->having = clone $this->having; } + + /** + * @param string|TableIdentifier|Select $table + * @param PlatformInterface $platform + * @param DriverInterface $driver + * @param ParameterContainer $parameterContainer + * @return string + */ + protected function resolveTable($table, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) + { + $alias = null; + + if (is_array($table)) { + $alias = key($table); + $table = current($table); + } + + $table = parent::resolveTable($table, $platform, $driver, $parameterContainer); + + if ($alias) { + $fromTable = $platform->quoteIdentifier($alias); + $table = $this->renderTable($table, $fromTable); + } else { + $fromTable = $table; + } + + if ($this->prefixColumnsWithTable && $fromTable) { + $fromTable .= $platform->getIdentifierSeparator(); + } else { + $fromTable = ''; + } + + return array( + $table, + $fromTable + ); + } } diff --git a/library/Zend/Db/Sql/Sql.php b/library/Zend/Db/Sql/Sql.php index 17a697e2..4f5b1514 100644 --- a/library/Zend/Db/Sql/Sql.php +++ b/library/Zend/Db/Sql/Sql.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,13 +24,18 @@ class Sql /** @var Platform\Platform */ protected $sqlPlatform = null; + /** + * @param AdapterInterface $adapter + * @param null|string|array|TableIdentifier $table + * @param null|Platform\AbstractPlatform $sqlPlatform @deprecated since version 3.0 + */ public function __construct(AdapterInterface $adapter, $table = null, Platform\AbstractPlatform $sqlPlatform = null) { $this->adapter = $adapter; if ($table) { $this->setTable($table); } - $this->sqlPlatform = ($sqlPlatform) ?: new Platform\Platform($adapter); + $this->sqlPlatform = $sqlPlatform ?: new Platform\Platform($adapter); } /** @@ -43,7 +48,7 @@ class Sql public function hasTable() { - return ($this->table != null); + return ($this->table !== null); } public function setTable($table) @@ -112,40 +117,48 @@ class Sql /** * @param PreparableSqlInterface $sqlObject - * @param StatementInterface|null $statement + * @param StatementInterface $statement + * @param AdapterInterface $adapter + * * @return StatementInterface */ - public function prepareStatementForSqlObject(PreparableSqlInterface $sqlObject, StatementInterface $statement = null) + public function prepareStatementForSqlObject(PreparableSqlInterface $sqlObject, StatementInterface $statement = null, AdapterInterface $adapter = null) { - $statement = ($statement) ?: $this->adapter->getDriver()->createStatement(); + $adapter = $adapter ?: $this->adapter; + $statement = $statement ?: $adapter->getDriver()->createStatement(); - if ($this->sqlPlatform) { - $this->sqlPlatform->setSubject($sqlObject); - $this->sqlPlatform->prepareStatement($this->adapter, $statement); - } else { - $sqlObject->prepareStatement($this->adapter, $statement); - } - - return $statement; + return $this->sqlPlatform->setSubject($sqlObject)->prepareStatement($adapter, $statement); } /** * Get sql string using platform or sql object * - * @param SqlInterface $sqlObject - * @param PlatformInterface $platform + * @param SqlInterface $sqlObject + * @param PlatformInterface|null $platform * * @return string + * + * @deprecated Deprecated in 2.4. Use buildSqlString() instead */ public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null) { $platform = ($platform) ?: $this->adapter->getPlatform(); + return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($platform); + } - if ($this->sqlPlatform) { - $this->sqlPlatform->setSubject($sqlObject); - return $this->sqlPlatform->getSqlString($platform); - } - - return $sqlObject->getSqlString($platform); + /** + * @param SqlInterface $sqlObject + * @param AdapterInterface $adapter + * + * @return string + * + * @throws Exception\InvalidArgumentException + */ + public function buildSqlString(SqlInterface $sqlObject, AdapterInterface $adapter = null) + { + return $this + ->sqlPlatform + ->setSubject($sqlObject) + ->getSqlString($adapter ? $adapter->getPlatform() : $this->adapter->getPlatform()); } } diff --git a/library/Zend/Db/Sql/SqlInterface.php b/library/Zend/Db/Sql/SqlInterface.php index f7db64c1..81c1d03b 100644 --- a/library/Zend/Db/Sql/SqlInterface.php +++ b/library/Zend/Db/Sql/SqlInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,9 @@ use Zend\Db\Adapter\Platform\PlatformInterface; interface SqlInterface { /** - * @param PlatformInterface $adapterPlatform + * Get SQL string for statement + * + * @param null|PlatformInterface $adapterPlatform * * @return string */ diff --git a/library/Zend/Db/Sql/TableIdentifier.php b/library/Zend/Db/Sql/TableIdentifier.php index 2c31b930..315e5243 100644 --- a/library/Zend/Db/Sql/TableIdentifier.php +++ b/library/Zend/Db/Sql/TableIdentifier.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,22 +19,53 @@ class TableIdentifier protected $table; /** - * @var string + * @var null|string */ protected $schema; /** - * @param string $table - * @param string $schema + * @param string $table + * @param null|string $schema */ public function __construct($table, $schema = null) { - $this->table = $table; - $this->schema = $schema; + if (! (is_string($table) || is_callable(array($table, '__toString')))) { + throw new Exception\InvalidArgumentException(sprintf( + '$table must be a valid table name, parameter of type %s given', + is_object($table) ? get_class($table) : gettype($table) + )); + } + + $this->table = (string) $table; + + if ('' === $this->table) { + throw new Exception\InvalidArgumentException('$table must be a valid table name, empty string given'); + } + + if (null === $schema) { + $this->schema = null; + } else { + if (! (is_string($schema) || is_callable(array($schema, '__toString')))) { + throw new Exception\InvalidArgumentException(sprintf( + '$schema must be a valid schema name, parameter of type %s given', + is_object($schema) ? get_class($schema) : gettype($schema) + )); + } + + $this->schema = (string) $schema; + + if ('' === $this->schema) { + throw new Exception\InvalidArgumentException( + '$schema must be a valid schema name or null, empty string given' + ); + } + } } /** * @param string $table + * + * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ public function setTable($table) { @@ -54,11 +85,13 @@ class TableIdentifier */ public function hasSchema() { - return ($this->schema != null); + return ($this->schema !== null); } /** * @param $schema + * + * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ public function setSchema($schema) { diff --git a/library/Zend/Db/Sql/Update.php b/library/Zend/Db/Sql/Update.php index 11e44e83..75dd4ea8 100644 --- a/library/Zend/Db/Sql/Update.php +++ b/library/Zend/Db/Sql/Update.php @@ -3,24 +3,22 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Db\Sql; -use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Platform\Sql92; -use Zend\Db\Adapter\StatementContainerInterface; +use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Stdlib\PriorityList; /** * * @property Where $where */ -class Update extends AbstractSql implements SqlInterface, PreparableSqlInterface +class Update extends AbstractPreparableSql { /**@#++ * @const @@ -94,7 +92,7 @@ class Update extends AbstractSql implements SqlInterface, PreparableSqlInterface */ 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'); } @@ -117,7 +115,7 @@ class Update extends AbstractSql implements SqlInterface, PreparableSqlInterface * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @throws Exception\InvalidArgumentException - * @return Select + * @return Update */ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) { @@ -140,104 +138,40 @@ class Update extends AbstractSql implements SqlInterface, PreparableSqlInterface return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - /** - * Prepare statement - * - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - * @return void - */ - public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) + protected function processUpdate(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $driver = $adapter->getDriver(); - $platform = $adapter->getPlatform(); - $parameterContainer = $statementContainer->getParameterContainer(); - - if (!$parameterContainer instanceof ParameterContainer) { - $parameterContainer = new ParameterContainer(); - $statementContainer->setParameterContainer($parameterContainer); - } - - $table = $this->table; - $schema = null; - - // create quoted table name to use in update processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); - } - - $table = $platform->quoteIdentifier($table); - - if ($schema) { - $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; - } - $setSql = array(); foreach ($this->set as $column => $value) { - if ($value instanceof Expression) { - $exprData = $this->processExpression($value, $platform, $driver); - $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $exprData->getSql(); - $parameterContainer->merge($exprData->getParameterContainer()); - } else { - $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $driver->formatParameterName($column); + $prefix = $platform->quoteIdentifier($column) . ' = '; + if (is_scalar($value) && $parameterContainer) { + $setSql[] = $prefix . $driver->formatParameterName($column); $parameterContainer->offsetSet($column, $value); + } else { + $setSql[] = $prefix . $this->resolveColumnValue( + $value, + $platform, + $driver, + $parameterContainer + ); } } - $set = implode(', ', $setSql); - $sql = sprintf($this->specifications[static::SPECIFICATION_UPDATE], $table, $set); - - // process where - if ($this->where->count() > 0) { - $whereParts = $this->processExpression($this->where, $platform, $driver, 'where'); - $parameterContainer->merge($whereParts->getParameterContainer()); - $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql()); - } - $statementContainer->setSql($sql); + return sprintf( + $this->specifications[static::SPECIFICATION_UPDATE], + $this->resolveTable($this->table, $platform, $driver, $parameterContainer), + implode(', ', $setSql) + ); } - /** - * Get SQL string for statement - * - * @param null|PlatformInterface $adapterPlatform If null, defaults to Sql92 - * @return string - */ - public function getSqlString(PlatformInterface $adapterPlatform = null) + protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $adapterPlatform = ($adapterPlatform) ?: new Sql92; - $table = $this->table; - $schema = null; - - // create quoted table name to use in update processing - if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); + if ($this->where->count() == 0) { + return; } - - $table = $adapterPlatform->quoteIdentifier($table); - - if ($schema) { - $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table; - } - - $setSql = array(); - foreach ($this->set as $column => $value) { - if ($value instanceof ExpressionInterface) { - $exprData = $this->processExpression($value, $adapterPlatform); - $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $exprData->getSql(); - } elseif ($value === null) { - $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = NULL'; - } else { - $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $adapterPlatform->quoteValue($value); - } - } - $set = implode(', ', $setSql); - - $sql = sprintf($this->specifications[static::SPECIFICATION_UPDATE], $table, $set); - if ($this->where->count() > 0) { - $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where'); - $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql()); - } - return $sql; + return sprintf( + $this->specifications[static::SPECIFICATION_WHERE], + $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where') + ); } /** @@ -250,9 +184,8 @@ class Update extends AbstractSql implements SqlInterface, PreparableSqlInterface */ public function __get($name) { - switch (strtolower($name)) { - case 'where': - return $this->where; + if (strtolower($name) == 'where') { + return $this->where; } } diff --git a/library/Zend/Db/Sql/Where.php b/library/Zend/Db/Sql/Where.php index f50efb46..22c9d386 100644 --- a/library/Zend/Db/Sql/Where.php +++ b/library/Zend/Db/Sql/Where.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/AbstractTableGateway.php b/library/Zend/Db/TableGateway/AbstractTableGateway.php index 08e88e5b..43037259 100644 --- a/library/Zend/Db/TableGateway/AbstractTableGateway.php +++ b/library/Zend/Db/TableGateway/AbstractTableGateway.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,6 +19,7 @@ use Zend\Db\Sql\Sql; use Zend\Db\Sql\TableIdentifier; use Zend\Db\Sql\Update; use Zend\Db\Sql\Where; +use Zend\Db\TableGateway\Feature\EventFeature; /** * @@ -39,7 +40,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface protected $adapter = null; /** - * @var string + * @var string|array|TableIdentifier */ protected $table = null; @@ -94,13 +95,13 @@ abstract class AbstractTableGateway implements TableGatewayInterface } $this->featureSet->setTableGateway($this); - $this->featureSet->apply('preInitialize', array()); + $this->featureSet->apply(EventFeature::EVENT_PRE_INITIALIZE, array()); if (!$this->adapter instanceof AdapterInterface) { throw new Exception\RuntimeException('This table does not have an Adapter setup'); } - if (!is_string($this->table) && !$this->table instanceof TableIdentifier) { + if (!is_string($this->table) && !$this->table instanceof TableIdentifier && !is_array($this->table)) { throw new Exception\RuntimeException('This table object does not have a valid table set.'); } @@ -112,7 +113,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface $this->sql = new Sql($this->adapter, $this->table); } - $this->featureSet->apply('postInitialize', array()); + $this->featureSet->apply(EventFeature::EVENT_POST_INITIALIZE, array()); $this->isInitialized = true; } @@ -215,8 +216,13 @@ abstract class AbstractTableGateway implements TableGatewayInterface protected function executeSelect(Select $select) { $selectState = $select->getRawState(); - if ($selectState['table'] != $this->table && (is_array($selectState['table']) && end($selectState['table']) != $this->table)) { - throw new Exception\RuntimeException('The table name of the provided select object must match that of the table'); + if ($selectState['table'] != $this->table + && (is_array($selectState['table']) + && end($selectState['table']) != $this->table) + ) { + throw new Exception\RuntimeException( + 'The table name of the provided select object must match that of the table' + ); } if ($selectState['columns'] == array(Select::SQL_STAR) @@ -225,7 +231,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface } // apply preSelect features - $this->featureSet->apply('preSelect', array($select)); + $this->featureSet->apply(EventFeature::EVENT_PRE_SELECT, array($select)); // prepare and execute $statement = $this->sql->prepareStatementForSqlObject($select); @@ -236,7 +242,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface $resultSet->initialize($result); // apply postSelect features - $this->featureSet->apply('postSelect', array($statement, $result, $resultSet)); + $this->featureSet->apply(EventFeature::EVENT_POST_SELECT, array($statement, $result, $resultSet)); return $resultSet; } @@ -280,20 +286,37 @@ abstract class AbstractTableGateway implements TableGatewayInterface { $insertState = $insert->getRawState(); if ($insertState['table'] != $this->table) { - throw new Exception\RuntimeException('The table name of the provided Insert object must match that of the table'); + throw new Exception\RuntimeException( + 'The table name of the provided Insert object must match that of the table' + ); } // apply preInsert features - $this->featureSet->apply('preInsert', array($insert)); + $this->featureSet->apply(EventFeature::EVENT_PRE_INSERT, array($insert)); + + // Most RDBMS solutions do not allow using table aliases in INSERTs + // See https://github.com/zendframework/zf2/issues/7311 + $unaliasedTable = false; + if (is_array($insertState['table'])) { + $tableData = array_values($insertState['table']); + $unaliasedTable = array_shift($tableData); + $insert->into($unaliasedTable); + } $statement = $this->sql->prepareStatementForSqlObject($insert); $result = $statement->execute(); $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue(); // apply postInsert features - $this->featureSet->apply('postInsert', array($statement, $result)); + $this->featureSet->apply(EventFeature::EVENT_POST_INSERT, array($statement, $result)); - return $result->getAffectedRows(); + // Reset original table information in Insert instance, if necessary + if ($unaliasedTable) { + $insert->into($insertState['table']); + } + + $return = $result->getAffectedRows(); + return $return; } /** @@ -340,17 +363,19 @@ abstract class AbstractTableGateway implements TableGatewayInterface { $updateState = $update->getRawState(); if ($updateState['table'] != $this->table) { - throw new Exception\RuntimeException('The table name of the provided Update object must match that of the table'); + throw new Exception\RuntimeException( + 'The table name of the provided Update object must match that of the table' + ); } // apply preUpdate features - $this->featureSet->apply('preUpdate', array($update)); + $this->featureSet->apply(EventFeature::EVENT_PRE_UPDATE, array($update)); $statement = $this->sql->prepareStatementForSqlObject($update); $result = $statement->execute(); // apply postUpdate features - $this->featureSet->apply('postUpdate', array($statement, $result)); + $this->featureSet->apply(EventFeature::EVENT_POST_UPDATE, array($statement, $result)); return $result->getAffectedRows(); } @@ -396,17 +421,19 @@ abstract class AbstractTableGateway implements TableGatewayInterface { $deleteState = $delete->getRawState(); if ($deleteState['table'] != $this->table) { - throw new Exception\RuntimeException('The table name of the provided Update object must match that of the table'); + throw new Exception\RuntimeException( + 'The table name of the provided Update object must match that of the table' + ); } // pre delete update - $this->featureSet->apply('preDelete', array($delete)); + $this->featureSet->apply(EventFeature::EVENT_PRE_DELETE, array($delete)); $statement = $this->sql->prepareStatementForSqlObject($delete); $result = $statement->execute(); // apply postDelete features - $this->featureSet->apply('postDelete', array($statement, $result)); + $this->featureSet->apply(EventFeature::EVENT_POST_DELETE, array($statement, $result)); return $result->getAffectedRows(); } @@ -469,7 +496,11 @@ abstract class AbstractTableGateway implements TableGatewayInterface if ($this->featureSet->canCallMagicCall($method)) { return $this->featureSet->callMagicCall($method, $arguments); } - throw new Exception\InvalidArgumentException('Invalid method (' . $method . ') called, caught by ' . __CLASS__ . '::__call()'); + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid method (%s) called, caught by %s::__call()', + $method, + __CLASS__ + )); } /** @@ -481,6 +512,14 @@ abstract class AbstractTableGateway implements TableGatewayInterface $this->sql = clone $this->sql; if (is_object($this->table)) { $this->table = clone $this->table; + } elseif ( + is_array($this->table) + && count($this->table) == 1 + && is_object(reset($this->table)) + ) { + foreach ($this->table as $alias => &$tableObject) { + $tableObject = clone $tableObject; + } } } } diff --git a/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php b/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php index ecd3085a..857e9a20 100644 --- a/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php +++ b/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Exception/InvalidArgumentException.php b/library/Zend/Db/TableGateway/Exception/InvalidArgumentException.php index 1f967a59..828cd308 100644 --- a/library/Zend/Db/TableGateway/Exception/InvalidArgumentException.php +++ b/library/Zend/Db/TableGateway/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Exception/RuntimeException.php b/library/Zend/Db/TableGateway/Exception/RuntimeException.php index 3c79b9f0..4b4d9287 100644 --- a/library/Zend/Db/TableGateway/Exception/RuntimeException.php +++ b/library/Zend/Db/TableGateway/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Feature/AbstractFeature.php b/library/Zend/Db/TableGateway/Feature/AbstractFeature.php index 5028078e..ddbf3328 100644 --- a/library/Zend/Db/TableGateway/Feature/AbstractFeature.php +++ b/library/Zend/Db/TableGateway/Feature/AbstractFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Feature/EventFeature.php b/library/Zend/Db/TableGateway/Feature/EventFeature.php index 08e3cffb..73de610f 100644 --- a/library/Zend/Db/TableGateway/Feature/EventFeature.php +++ b/library/Zend/Db/TableGateway/Feature/EventFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -22,6 +22,21 @@ use Zend\EventManager\EventsCapableInterface; class EventFeature extends AbstractFeature implements EventsCapableInterface { + const EVENT_PRE_INITIALIZE = 'preInitialize'; + const EVENT_POST_INITIALIZE = 'postInitialize'; + + const EVENT_PRE_SELECT = 'preSelect'; + const EVENT_POST_SELECT = 'postSelect'; + + const EVENT_PRE_INSERT = 'preInsert'; + const EVENT_POST_INSERT = 'postInsert'; + + const EVENT_PRE_DELETE = 'preDelete'; + const EVENT_POST_DELETE = 'postDelete'; + + const EVENT_PRE_UPDATE = 'preUpdate'; + const EVENT_POST_UPDATE = 'postUpdate'; + /** * @var EventManagerInterface */ @@ -87,7 +102,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface } $this->event->setTarget($this->tableGateway); - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_PRE_INITIALIZE); $this->eventManager->trigger($this->event); } @@ -98,7 +113,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function postInitialize() { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_POST_INITIALIZE); $this->eventManager->trigger($this->event); } @@ -113,7 +128,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function preSelect(Select $select) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_PRE_SELECT); $this->event->setParams(array('select' => $select)); $this->eventManager->trigger($this->event); } @@ -133,7 +148,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_POST_SELECT); $this->event->setParams(array( 'statement' => $statement, 'result' => $result, @@ -153,7 +168,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function preInsert(Insert $insert) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_PRE_INSERT); $this->event->setParams(array('insert' => $insert)); $this->eventManager->trigger($this->event); } @@ -171,7 +186,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function postInsert(StatementInterface $statement, ResultInterface $result) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_POST_INSERT); $this->event->setParams(array( 'statement' => $statement, 'result' => $result, @@ -190,7 +205,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function preUpdate(Update $update) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_PRE_UPDATE); $this->event->setParams(array('update' => $update)); $this->eventManager->trigger($this->event); } @@ -208,7 +223,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function postUpdate(StatementInterface $statement, ResultInterface $result) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_POST_UPDATE); $this->event->setParams(array( 'statement' => $statement, 'result' => $result, @@ -227,7 +242,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function preDelete(Delete $delete) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_PRE_DELETE); $this->event->setParams(array('delete' => $delete)); $this->eventManager->trigger($this->event); } @@ -245,7 +260,7 @@ class EventFeature extends AbstractFeature implements EventsCapableInterface */ public function postDelete(StatementInterface $statement, ResultInterface $result) { - $this->event->setName(__FUNCTION__); + $this->event->setName(static::EVENT_POST_DELETE); $this->event->setParams(array( 'statement' => $statement, 'result' => $result, diff --git a/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php index 1097a86f..af46132d 100644 --- a/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Feature/FeatureSet.php b/library/Zend/Db/TableGateway/Feature/FeatureSet.php index 498db1ad..939444e0 100644 --- a/library/Zend/Db/TableGateway/Feature/FeatureSet.php +++ b/library/Zend/Db/TableGateway/Feature/FeatureSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php b/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php index bb8c6d60..bdcd97dc 100644 --- a/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php +++ b/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php b/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php index 255735de..4e551015 100644 --- a/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php +++ b/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -62,7 +62,7 @@ class MasterSlaveFeature extends AbstractFeature public function postInitialize() { $this->masterSql = $this->tableGateway->sql; - if ($this->slaveSql == null) { + if ($this->slaveSql === null) { $this->slaveSql = new Sql( $this->slaveAdapter, $this->tableGateway->sql->getTable(), diff --git a/library/Zend/Db/TableGateway/Feature/MetadataFeature.php b/library/Zend/Db/TableGateway/Feature/MetadataFeature.php index 59393bec..a1cc39e5 100644 --- a/library/Zend/Db/TableGateway/Feature/MetadataFeature.php +++ b/library/Zend/Db/TableGateway/Feature/MetadataFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -39,7 +39,7 @@ class MetadataFeature extends AbstractFeature public function postInitialize() { - if ($this->metadata == null) { + if ($this->metadata === null) { $this->metadata = new Metadata($this->tableGateway->adapter); } diff --git a/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php b/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php index 18c4fd9d..88f07097 100644 --- a/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php +++ b/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -45,7 +45,7 @@ class RowGatewayFeature extends AbstractFeature if (isset($args[0])) { if (is_string($args[0])) { $primaryKey = $args[0]; - $rowGatewayPrototype = new RowGateway($primaryKey, $this->tableGateway->table, $this->tableGateway->adapter, $this->tableGateway->sql); + $rowGatewayPrototype = new RowGateway($primaryKey, $this->tableGateway->table, $this->tableGateway->adapter); $resultSetPrototype->setArrayObjectPrototype($rowGatewayPrototype); } elseif ($args[0] instanceof RowGatewayInterface) { $rowGatewayPrototype = $args[0]; @@ -60,7 +60,7 @@ class RowGatewayFeature extends AbstractFeature ); } $primaryKey = $metadata->sharedData['metadata']['primaryKey']; - $rowGatewayPrototype = new RowGateway($primaryKey, $this->tableGateway->table, $this->tableGateway->adapter, $this->tableGateway->sql); + $rowGatewayPrototype = new RowGateway($primaryKey, $this->tableGateway->table, $this->tableGateway->adapter); $resultSetPrototype->setArrayObjectPrototype($rowGatewayPrototype); } } diff --git a/library/Zend/Db/TableGateway/Feature/SequenceFeature.php b/library/Zend/Db/TableGateway/Feature/SequenceFeature.php index 9f58d1a5..fa34068a 100644 --- a/library/Zend/Db/TableGateway/Feature/SequenceFeature.php +++ b/library/Zend/Db/TableGateway/Feature/SequenceFeature.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -92,7 +92,7 @@ class SequenceFeature extends AbstractFeature $sql = 'SELECT NEXTVAL(\'"' . $this->sequenceName . '"\')'; break; default : - return null; + return; } $statement = $this->tableGateway->adapter->createStatement(); @@ -120,7 +120,7 @@ class SequenceFeature extends AbstractFeature $sql = 'SELECT CURRVAL(\'' . $this->sequenceName . '\')'; break; default : - return null; + return; } $statement = $this->tableGateway->adapter->createStatement(); diff --git a/library/Zend/Db/TableGateway/TableGateway.php b/library/Zend/Db/TableGateway/TableGateway.php index 0defd8a4..62604f6a 100644 --- a/library/Zend/Db/TableGateway/TableGateway.php +++ b/library/Zend/Db/TableGateway/TableGateway.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,17 +20,18 @@ class TableGateway extends AbstractTableGateway /** * Constructor * - * @param string $table - * @param AdapterInterface $adapter - * @param Feature\AbstractFeature|Feature\FeatureSet|Feature\AbstractFeature[] $features - * @param ResultSetInterface $resultSetPrototype - * @param Sql $sql + * @param string|TableIdentifier|array $table + * @param AdapterInterface $adapter + * @param Feature\AbstractFeature|Feature\FeatureSet|Feature\AbstractFeature[]|null $features + * @param ResultSetInterface|null $resultSetPrototype + * @param Sql|null $sql + * * @throws Exception\InvalidArgumentException */ public function __construct($table, AdapterInterface $adapter, $features = null, ResultSetInterface $resultSetPrototype = null, Sql $sql = null) { // table - if (!(is_string($table) || $table instanceof TableIdentifier)) { + if (!(is_string($table) || $table instanceof TableIdentifier || is_array($table))) { throw new Exception\InvalidArgumentException('Table name must be a string or an instance of Zend\Db\Sql\TableIdentifier'); } $this->table = $table; diff --git a/library/Zend/Db/TableGateway/TableGatewayInterface.php b/library/Zend/Db/TableGateway/TableGatewayInterface.php index 0a77e0f1..a48fec2e 100644 --- a/library/Zend/Db/TableGateway/TableGatewayInterface.php +++ b/library/Zend/Db/TableGateway/TableGatewayInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Db/composer.json b/library/Zend/Db/composer.json index 6eee3ae0..08be381f 100644 --- a/library/Zend/Db/composer.json +++ b/library/Zend/Db/composer.json @@ -8,13 +8,13 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Db\\": "" } }, - "target-dir": "Zend/Db", "require": { - "php": ">=5.3.23" + "php": ">=5.3.23", + "zendframework/zend-stdlib": "self.version" }, "require-dev": { "zendframework/zend-eventmanager": "self.version", @@ -23,13 +23,12 @@ }, "suggest": { "zendframework/zend-eventmanager": "Zend\\EventManager component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-stdlib": "Zend\\Stdlib component" + "zendframework/zend-servicemanager": "Zend\\ServiceManager component" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Debug/Debug.php b/library/Zend/Debug/Debug.php index f240935c..a53091db 100644 --- a/library/Zend/Debug/Debug.php +++ b/library/Zend/Debug/Debug.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Debug/composer.json b/library/Zend/Debug/composer.json index b6c18c7b..1ec06988 100644 --- a/library/Zend/Debug/composer.json +++ b/library/Zend/Debug/composer.json @@ -8,16 +8,15 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Debug\\": "" } }, - "target-dir": "Zend/Debug", "require": { "php": ">=5.3.23" }, "require-dev": { - "zendframework/zend-escaper": "*" + "zendframework/zend-escaper": "2.*" }, "suggest": { "ext/xdebug": "XDebug, for better backtrace output", @@ -25,8 +24,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Di/Config.php b/library/Zend/Di/Config.php index b1773050..3dd6fcbd 100644 --- a/library/Zend/Di/Config.php +++ b/library/Zend/Di/Config.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/Annotation/Inject.php b/library/Zend/Di/Definition/Annotation/Inject.php index 8534c021..9544502c 100644 --- a/library/Zend/Di/Definition/Annotation/Inject.php +++ b/library/Zend/Di/Definition/Annotation/Inject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/Annotation/Instantiator.php b/library/Zend/Di/Definition/Annotation/Instantiator.php index d0aed531..cc55d5d4 100644 --- a/library/Zend/Di/Definition/Annotation/Instantiator.php +++ b/library/Zend/Di/Definition/Annotation/Instantiator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/ArrayDefinition.php b/library/Zend/Di/Definition/ArrayDefinition.php index 5e64f5b3..6415f8a3 100644 --- a/library/Zend/Di/Definition/ArrayDefinition.php +++ b/library/Zend/Di/Definition/ArrayDefinition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -80,7 +80,7 @@ class ArrayDefinition implements DefinitionInterface public function getInstantiator($class) { if (!isset($this->dataArray[$class])) { - return null; + return; } if (!isset($this->dataArray[$class]['instantiator'])) { diff --git a/library/Zend/Di/Definition/Builder/InjectionMethod.php b/library/Zend/Di/Definition/Builder/InjectionMethod.php index a27f7b19..b411504d 100644 --- a/library/Zend/Di/Definition/Builder/InjectionMethod.php +++ b/library/Zend/Di/Definition/Builder/InjectionMethod.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -98,22 +98,16 @@ class InjectionMethod case "require": case "required": return Di::METHOD_IS_REQUIRED; - break; case "aware": return Di::METHOD_IS_AWARE; - break; case "optional": return Di::METHOD_IS_OPTIONAL; - break; case "constructor": return Di::METHOD_IS_CONSTRUCTOR; - break; case "instantiator": return Di::METHOD_IS_INSTANTIATOR; - break; case "eager": return Di::METHOD_IS_EAGER; - break; } } return 0; diff --git a/library/Zend/Di/Definition/Builder/PhpClass.php b/library/Zend/Di/Definition/Builder/PhpClass.php index 80d4197a..2b9c0664 100644 --- a/library/Zend/Di/Definition/Builder/PhpClass.php +++ b/library/Zend/Di/Definition/Builder/PhpClass.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/BuilderDefinition.php b/library/Zend/Di/Definition/BuilderDefinition.php index 6ad935a0..e013b2e2 100644 --- a/library/Zend/Di/Definition/BuilderDefinition.php +++ b/library/Zend/Di/Definition/BuilderDefinition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/ClassDefinition.php b/library/Zend/Di/Definition/ClassDefinition.php index 2b110659..764cfff8 100644 --- a/library/Zend/Di/Definition/ClassDefinition.php +++ b/library/Zend/Di/Definition/ClassDefinition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -162,7 +162,7 @@ class ClassDefinition implements DefinitionInterface, PartialMarker public function getInstantiator($class) { if ($this->class !== $class) { - return null; + return; } return $this->instantiator; } @@ -192,14 +192,14 @@ class ClassDefinition implements DefinitionInterface, PartialMarker public function hasMethod($class, $method) { if ($this->class !== $class) { - return null; + return; } if (is_array($this->methods)) { return array_key_exists($method, $this->methods); } - return null; + return; } /** @@ -219,13 +219,13 @@ class ClassDefinition implements DefinitionInterface, PartialMarker public function getMethodParameters($class, $method) { if ($this->class !== $class) { - return null; + return; } if (array_key_exists($method, $this->methodParameters)) { return $this->methodParameters[$method]; } - return null; + return; } } diff --git a/library/Zend/Di/Definition/CompilerDefinition.php b/library/Zend/Di/Definition/CompilerDefinition.php index dcecde10..1553cf3f 100644 --- a/library/Zend/Di/Definition/CompilerDefinition.php +++ b/library/Zend/Di/Definition/CompilerDefinition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -100,7 +100,7 @@ class CompilerDefinition implements DefinitionInterface */ public function addCodeScannerFile(FileScanner $fileScanner) { - if ($this->directoryScanner == null) { + if ($this->directoryScanner === null) { $this->directoryScanner = new DirectoryScanner(); } @@ -185,7 +185,7 @@ class CompilerDefinition implements DefinitionInterface $def['supertypes'] = $supertypes; - if ($def['instantiator'] == null) { + if ($def['instantiator'] === null) { if ($rClass->isInstantiable()) { $def['instantiator'] = '__construct'; } diff --git a/library/Zend/Di/Definition/DefinitionInterface.php b/library/Zend/Di/Definition/DefinitionInterface.php index 420bb459..e9d3d13f 100644 --- a/library/Zend/Di/Definition/DefinitionInterface.php +++ b/library/Zend/Di/Definition/DefinitionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/IntrospectionStrategy.php b/library/Zend/Di/Definition/IntrospectionStrategy.php index c34fbbb9..0a432967 100644 --- a/library/Zend/Di/Definition/IntrospectionStrategy.php +++ b/library/Zend/Di/Definition/IntrospectionStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/PartialMarker.php b/library/Zend/Di/Definition/PartialMarker.php index 4a40728f..c37e4579 100644 --- a/library/Zend/Di/Definition/PartialMarker.php +++ b/library/Zend/Di/Definition/PartialMarker.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Definition/RuntimeDefinition.php b/library/Zend/Di/Definition/RuntimeDefinition.php index 7e735093..0b94e6a7 100644 --- a/library/Zend/Di/Definition/RuntimeDefinition.php +++ b/library/Zend/Di/Definition/RuntimeDefinition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,6 +38,11 @@ class RuntimeDefinition implements DefinitionInterface */ protected $injectionMethods = array(); + /** + * @var array + */ + protected $processedClass = array(); + /** * Constructor * @@ -174,25 +179,20 @@ class RuntimeDefinition implements DefinitionInterface return $this->classes[$class]['parameters'][$method]; } - /** - * @param string $class - * - * @return bool - */ - protected function hasProcessedClass($class) - { - return array_key_exists($class, $this->classes) && is_array($this->classes[$class]); - } - /** * @param string $class * @param bool $forceLoad */ protected function processClass($class, $forceLoad = false) { - if (!$forceLoad && $this->hasProcessedClass($class)) { + if (!isset($this->processedClass[$class]) || $this->processedClass[$class] === false) { + $this->processedClass[$class] = (array_key_exists($class, $this->classes) && is_array($this->classes[$class])); + } + + if (!$forceLoad && $this->processedClass[$class]) { return; } + $strategy = $this->introspectionStrategy; // localize for readability /** @var $rClass \Zend\Code\Reflection\ClassReflection */ @@ -231,9 +231,9 @@ class RuntimeDefinition implements DefinitionInterface $rTarget = $rTargetParent; } while (true); - $def['supertypes'] = $supertypes; + $def['supertypes'] = array_keys(array_flip($supertypes)); - if ($def['instantiator'] == null) { + if ($def['instantiator'] === null) { if ($rClass->isInstantiable()) { $def['instantiator'] = '__construct'; } diff --git a/library/Zend/Di/DefinitionList.php b/library/Zend/Di/DefinitionList.php index efe190e5..43f03717 100644 --- a/library/Zend/Di/DefinitionList.php +++ b/library/Zend/Di/DefinitionList.php @@ -3,29 +3,34 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Di; use SplDoublyLinkedList; +use Zend\Di\Definition\RuntimeDefinition; /** * Class definition based on multiple definitions */ class DefinitionList extends SplDoublyLinkedList implements Definition\DefinitionInterface { + protected $classes = array(); + protected $runtimeDefinitions; + /** * @param Definition\DefinitionInterface|Definition\DefinitionInterface[] $definitions */ public function __construct($definitions) { + $this->runtimeDefinitions = new SplDoublyLinkedList(); if (!is_array($definitions)) { $definitions = array($definitions); } foreach ($definitions as $definition) { - $this->push($definition); + $this->addDefinition($definition, true); } } @@ -45,6 +50,35 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio } } + protected function getDefinitionClassMap(Definition\DefinitionInterface $definition) + { + $definitionClasses = $definition->getClasses(); + if (empty($definitionClasses)) { + return array(); + } + return array_combine(array_values($definitionClasses), array_fill(0, count($definitionClasses), $definition)); + } + + public function unshift($definition) + { + $result = parent::unshift($definition); + if ($definition instanceof RuntimeDefinition) { + $this->runtimeDefinitions->unshift($definition); + } + $this->classes = array_merge($this->classes, $this->getDefinitionClassMap($definition)); + return $result; + } + + public function push($definition) + { + $result = parent::push($definition); + if ($definition instanceof RuntimeDefinition) { + $this->runtimeDefinitions->push($definition); + } + $this->classes = array_merge($this->getDefinitionClassMap($definition), $this->classes); + return $result; + } + /** * @param string $type * @return Definition\DefinitionInterface[] @@ -84,8 +118,11 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function getDefinitionForClass($class) { + if (array_key_exists($class, $this->classes)) { + return $this->classes[$class]; + } /** @var $definition Definition\DefinitionInterface */ - foreach ($this as $definition) { + foreach ($this->runtimeDefinitions as $definition) { if ($definition->hasClass($class)) { return $definition; } @@ -108,13 +145,7 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function getClasses() { - $classes = array(); - /** @var $definition Definition\DefinitionInterface */ - foreach ($this as $definition) { - $classes = array_merge($classes, $definition->getClasses()); - } - - return $classes; + return array_keys($this->classes); } /** @@ -122,8 +153,11 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function hasClass($class) { + if (array_key_exists($class, $this->classes)) { + return true; + } /** @var $definition Definition\DefinitionInterface */ - foreach ($this as $definition) { + foreach ($this->runtimeDefinitions as $definition) { if ($definition->hasClass($class)) { return true; } @@ -137,9 +171,18 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function getClassSupertypes($class) { - $supertypes = array(); + if (false === ($classDefinition = $this->getDefinitionForClass($class))) { + return array(); + } + $supertypes = $classDefinition->getClassSupertypes($class); + if (! $classDefinition instanceof Definition\PartialMarker) { + return $supertypes; + } /** @var $definition Definition\DefinitionInterface */ foreach ($this as $definition) { + if ($definition === $classDefinition) { + continue; + } if ($definition->hasClass($class)) { $supertypes = array_merge($supertypes, $definition->getClassSupertypes($class)); if ($definition instanceof Definition\PartialMarker) { @@ -157,8 +200,21 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function getInstantiator($class) { + if (! $classDefinition = $this->getDefinitionForClass($class)) { + return false; + } + $value = $classDefinition->getInstantiator($class); + if (!is_null($value)) { + return $value; + } + if (! $classDefinition instanceof Definition\PartialMarker) { + return false; + } /** @var $definition Definition\DefinitionInterface */ foreach ($this as $definition) { + if ($definition === $classDefinition) { + continue; + } if ($definition->hasClass($class)) { $value = $definition->getInstantiator($class); if ($value === null && $definition instanceof Definition\PartialMarker) { @@ -177,8 +233,20 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function hasMethods($class) { + if (! $classDefinition = $this->getDefinitionForClass($class)) { + return false; + } + if (false !== ($methods = $classDefinition->hasMethods($class))) { + return $methods; + } + if (! $classDefinition instanceof Definition\PartialMarker) { + return false; + } /** @var $definition Definition\DefinitionInterface */ foreach ($this as $definition) { + if ($definition === $classDefinition) { + continue; + } if ($definition->hasClass($class)) { if ($definition->hasMethods($class) === false && $definition instanceof Definition\PartialMarker) { continue; @@ -199,9 +267,15 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio if (!$this->hasMethods($class)) { return false; } - + $classDefinition = $this->getDefinitionForClass($class); + if ($classDefinition->hasMethod($class, $method)) { + return true; + } /** @var $definition Definition\DefinitionInterface */ - foreach ($this as $definition) { + foreach ($this->runtimeDefinitions as $definition) { + if ($definition === $classDefinition) { + continue; + } if ($definition->hasClass($class) && $definition->hasMethod($class, $method)) { return true; } @@ -215,9 +289,18 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function getMethods($class) { + if (false === ($classDefinition = $this->getDefinitionForClass($class))) { + return array(); + } + $methods = $classDefinition->getMethods($class); + if (! $classDefinition instanceof Definition\PartialMarker) { + return $methods; + } /** @var $definition Definition\DefinitionInterface */ - $methods = array(); foreach ($this as $definition) { + if ($definition === $classDefinition) { + continue; + } if ($definition->hasClass($class)) { if (!$definition instanceof Definition\PartialMarker) { return array_merge($definition->getMethods($class), $methods); @@ -245,9 +328,21 @@ class DefinitionList extends SplDoublyLinkedList implements Definition\Definitio */ public function getMethodParameters($class, $method) { + if (false === ($classDefinition = $this->getDefinitionForClass($class))) { + return array(); + } + if ($classDefinition->hasMethod($class, $method) && $classDefinition->hasMethodParameters($class, $method)) { + return $classDefinition->getMethodParameters($class, $method); + } /** @var $definition Definition\DefinitionInterface */ foreach ($this as $definition) { - if ($definition->hasClass($class) && $definition->hasMethod($class, $method) && $definition->hasMethodParameters($class, $method)) { + if ($definition === $classDefinition) { + continue; + } + if ($definition->hasClass($class) + && $definition->hasMethod($class, $method) + && $definition->hasMethodParameters($class, $method) + ) { return $definition->getMethodParameters($class, $method); } } diff --git a/library/Zend/Di/DependencyInjectionInterface.php b/library/Zend/Di/DependencyInjectionInterface.php index b8218761..4acc8dfb 100644 --- a/library/Zend/Di/DependencyInjectionInterface.php +++ b/library/Zend/Di/DependencyInjectionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Di.php b/library/Zend/Di/Di.php index 14c2aa99..5293410c 100644 --- a/library/Zend/Di/Di.php +++ b/library/Zend/Di/Di.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Di; use Closure; -use ReflectionClass; use Zend\Di\Exception\RuntimeException as DiRuntimeException; use Zend\ServiceManager\Exception\ExceptionInterface as ServiceManagerException; @@ -244,7 +243,6 @@ class Di implements DependencyInjectionInterface return $im->getSharedInstance($name, $callParameters); } - $config = $im->getConfig($name); $instance = $this->newInstance($name, $params, $config['shared']); array_pop($this->instanceContext); @@ -412,7 +410,7 @@ class Di implements DependencyInjectionInterface } elseif (is_int($injectName) && is_array($injectValue)) { throw new Exception\RuntimeException( 'An injection was provided with a keyed index and an array of data, try using' - . ' the name of a particular method as a key for your injection data.' + . ' the name of a particular method as a key for your injection data.' ); } } @@ -426,7 +424,7 @@ class Di implements DependencyInjectionInterface if ($methodParams) { foreach ($methodParams as $methodParam) { $objectToInjectClass = $this->getClass($objectToInject); - if ($objectToInjectClass == $methodParam[1] || self::isSubclassOf($objectToInjectClass, $methodParam[1])) { + if ($objectToInjectClass == $methodParam[1] || is_subclass_of($objectToInjectClass, $methodParam[1])) { if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, array($methodParam[0] => $objectToInject), $instanceAlias, self::METHOD_IS_REQUIRED, $type)) { $calledMethods[$typeInjectionMethod] = true; } @@ -441,7 +439,7 @@ class Di implements DependencyInjectionInterface } if ($methodsToCall) { foreach ($methodsToCall as $methodInfo) { - $this->resolveAndCallInjectionMethodForInstance($instance, $methodInfo['method'], $methodInfo['args'], $instanceAlias, self::METHOD_IS_REQUIRED, $instanceClass); + $this->resolveAndCallInjectionMethodForInstance($instance, $methodInfo['method'], $methodInfo['args'], $instanceAlias, self::METHOD_IS_REQUIRED, $instanceClass); } } } @@ -626,7 +624,7 @@ class Di implements DependencyInjectionInterface if (array_key_exists('parameters', $iConfig['requestedClass'])) { $newParameters = array(); - foreach ($iConfig['requestedClass']['parameters'] as $name=>$parameter) { + foreach ($iConfig['requestedClass']['parameters'] as $name => $parameter) { $newParameters[$requestedClass.'::'.$method.'::'.$name] = $parameter; } @@ -743,7 +741,7 @@ class Di implements DependencyInjectionInterface } $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; - if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) { + if ($pInstanceClass === $type || is_subclass_of($pInstanceClass, $type)) { $computedParams['retrieval'][$fqParamPos] = array($pInstance, $pInstanceClass); continue 2; } @@ -760,7 +758,7 @@ class Di implements DependencyInjectionInterface } $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; - if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) { + if ($pInstanceClass === $type || is_subclass_of($pInstanceClass, $type)) { $computedParams['retrieval'][$fqParamPos] = array($pInstance, $pInstanceClass); continue 2; } @@ -817,12 +815,14 @@ class Di implements DependencyInjectionInterface } // if this item was marked strict, // plus it cannot be resolve, and no value exist, bail out - throw new Exception\MissingPropertyException(sprintf( - 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, - (($value[0] === null) ? 'value' : 'instance/object' ) - ), - $e->getCode(), - $e); + throw new Exception\MissingPropertyException( + sprintf( + 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, + (($value[0] === null) ? 'value' : 'instance/object') + ), + $e->getCode(), + $e + ); } else { //finally ( be aware to do at the end of flow) array_pop($this->currentDependencies); @@ -841,12 +841,14 @@ class Di implements DependencyInjectionInterface } // if this item was marked strict, // plus it cannot be resolve, and no value exist, bail out - throw new Exception\MissingPropertyException(sprintf( - 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, - (($value[0] === null) ? 'value' : 'instance/object' ) - ), - $e->getCode(), - $e); + throw new Exception\MissingPropertyException( + sprintf( + 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, + (($value[0] === null) ? 'value' : 'instance/object') + ), + $e->getCode(), + $e + ); } else { //finally ( be aware to do at the end of flow) array_pop($this->currentDependencies); @@ -866,7 +868,7 @@ class Di implements DependencyInjectionInterface // plus it cannot be resolve, and no value exist, bail out throw new Exception\MissingPropertyException(sprintf( 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, - (($value[0] === null) ? 'value' : 'instance/object' ) + (($value[0] === null) ? 'value' : 'instance/object') )); } else { return false; @@ -887,23 +889,14 @@ class Di implements DependencyInjectionInterface * @see https://bugs.php.net/bug.php?id=53727 * @see https://github.com/zendframework/zf2/pull/1807 * + * @deprecated since zf 2.3 requires PHP >= 5.3.23 + * * @param string $className * @param $type * @return bool */ protected static function isSubclassOf($className, $type) { - if (is_subclass_of($className, $type)) { - return true; - } - if (PHP_VERSION_ID >= 50307) { - return false; - } - if (!interface_exists($type)) { - return false; - } - $r = new ReflectionClass($className); - - return $r->implementsInterface($type); + return is_subclass_of($className, $type); } } diff --git a/library/Zend/Di/Display/Console.php b/library/Zend/Di/Display/Console.php index 31b861e6..a0e2fcd0 100644 --- a/library/Zend/Di/Display/Console.php +++ b/library/Zend/Di/Display/Console.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -164,8 +164,8 @@ class Console foreach ($definition->getMethods($class) as $methodName => $methodIsRequired) { foreach ($definition->getMethodParameters($class, $methodName) as $fqName => $pData) { echo ' ' . $pData[0] . ' [type: '; - echo ($pData[1]) ? $pData[1] : 'scalar'; - echo ($pData[2] === true && $methodIsRequired) ? ', required' : ', not required'; + echo($pData[1]) ? $pData[1] : 'scalar'; + echo($pData[2] === true && $methodIsRequired) ? ', required' : ', not required'; echo ', injection-method: ' . $methodName; echo ' fq-name: ' . $fqName; echo ']' . PHP_EOL; diff --git a/library/Zend/Di/Exception/CircularDependencyException.php b/library/Zend/Di/Exception/CircularDependencyException.php index 8cb9eae3..ed064adc 100644 --- a/library/Zend/Di/Exception/CircularDependencyException.php +++ b/library/Zend/Di/Exception/CircularDependencyException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/ClassNotFoundException.php b/library/Zend/Di/Exception/ClassNotFoundException.php index 6ba93ba6..90db4a2d 100644 --- a/library/Zend/Di/Exception/ClassNotFoundException.php +++ b/library/Zend/Di/Exception/ClassNotFoundException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/ExceptionInterface.php b/library/Zend/Di/Exception/ExceptionInterface.php index ae0ba771..dc1a3942 100644 --- a/library/Zend/Di/Exception/ExceptionInterface.php +++ b/library/Zend/Di/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/InvalidArgumentException.php b/library/Zend/Di/Exception/InvalidArgumentException.php index 435cab35..9b6257c5 100644 --- a/library/Zend/Di/Exception/InvalidArgumentException.php +++ b/library/Zend/Di/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/InvalidCallbackException.php b/library/Zend/Di/Exception/InvalidCallbackException.php index ccd958bf..bd216c12 100644 --- a/library/Zend/Di/Exception/InvalidCallbackException.php +++ b/library/Zend/Di/Exception/InvalidCallbackException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/InvalidParamNameException.php b/library/Zend/Di/Exception/InvalidParamNameException.php index dc0f3ba9..dcf6f9c8 100644 --- a/library/Zend/Di/Exception/InvalidParamNameException.php +++ b/library/Zend/Di/Exception/InvalidParamNameException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/InvalidPositionException.php b/library/Zend/Di/Exception/InvalidPositionException.php index abfecd58..352caa70 100644 --- a/library/Zend/Di/Exception/InvalidPositionException.php +++ b/library/Zend/Di/Exception/InvalidPositionException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/MissingPropertyException.php b/library/Zend/Di/Exception/MissingPropertyException.php index 76ce99af..dc987cfe 100644 --- a/library/Zend/Di/Exception/MissingPropertyException.php +++ b/library/Zend/Di/Exception/MissingPropertyException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/RuntimeException.php b/library/Zend/Di/Exception/RuntimeException.php index 1097cae7..a8236a79 100644 --- a/library/Zend/Di/Exception/RuntimeException.php +++ b/library/Zend/Di/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/Exception/UndefinedReferenceException.php b/library/Zend/Di/Exception/UndefinedReferenceException.php index e7aa43a2..5e87bfde 100644 --- a/library/Zend/Di/Exception/UndefinedReferenceException.php +++ b/library/Zend/Di/Exception/UndefinedReferenceException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/InstanceManager.php b/library/Zend/Di/InstanceManager.php index 609fe390..13c19a36 100644 --- a/library/Zend/Di/InstanceManager.php +++ b/library/Zend/Di/InstanceManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -318,6 +318,7 @@ class InstanceManager /* implements InstanceManagerInterface */ if (strpos($name, 'alias') === 0) { continue; } + $classes[] = $name; } diff --git a/library/Zend/Di/LocatorInterface.php b/library/Zend/Di/LocatorInterface.php index 88a12f6c..4368ed78 100644 --- a/library/Zend/Di/LocatorInterface.php +++ b/library/Zend/Di/LocatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/ServiceLocator.php b/library/Zend/Di/ServiceLocator.php index aa93a3df..5c011a8f 100644 --- a/library/Zend/Di/ServiceLocator.php +++ b/library/Zend/Di/ServiceLocator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -74,7 +74,7 @@ class ServiceLocator implements ServiceLocatorInterface { if (!isset($this->services[$name])) { if (!isset($this->map[$name])) { - return null; + return; } $method = $this->map[$name]; diff --git a/library/Zend/Di/ServiceLocator/DependencyInjectorProxy.php b/library/Zend/Di/ServiceLocator/DependencyInjectorProxy.php index be0c3cb1..81418936 100644 --- a/library/Zend/Di/ServiceLocator/DependencyInjectorProxy.php +++ b/library/Zend/Di/ServiceLocator/DependencyInjectorProxy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/ServiceLocator/Generator.php b/library/Zend/Di/ServiceLocator/Generator.php index 82e8ca19..73bf96f4 100644 --- a/library/Zend/Di/ServiceLocator/Generator.php +++ b/library/Zend/Di/ServiceLocator/Generator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/ServiceLocator/GeneratorInstance.php b/library/Zend/Di/ServiceLocator/GeneratorInstance.php index aeb5f93a..f7af4698 100644 --- a/library/Zend/Di/ServiceLocator/GeneratorInstance.php +++ b/library/Zend/Di/ServiceLocator/GeneratorInstance.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/ServiceLocatorInterface.php b/library/Zend/Di/ServiceLocatorInterface.php index fe5e1257..08f893d0 100644 --- a/library/Zend/Di/ServiceLocatorInterface.php +++ b/library/Zend/Di/ServiceLocatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Di/composer.json b/library/Zend/Di/composer.json index 81f6cb78..1312aa84 100644 --- a/library/Zend/Di/composer.json +++ b/library/Zend/Di/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Di\\": "" } }, - "target-dir": "Zend/Di", "require": { "php": ">=5.3.23", "zendframework/zend-code": "self.version", @@ -26,8 +25,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Dom/Css2Xpath.php b/library/Zend/Dom/Css2Xpath.php index 7aa7d506..55b60c37 100644 --- a/library/Zend/Dom/Css2Xpath.php +++ b/library/Zend/Dom/Css2Xpath.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/DOMXPath.php b/library/Zend/Dom/DOMXPath.php index 37a016ae..f46d5504 100644 --- a/library/Zend/Dom/DOMXPath.php +++ b/library/Zend/Dom/DOMXPath.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Dom; diff --git a/library/Zend/Dom/Document.php b/library/Zend/Dom/Document.php index 456e17f8..5d389430 100644 --- a/library/Zend/Dom/Document.php +++ b/library/Zend/Dom/Document.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/Document/NodeList.php b/library/Zend/Dom/Document/NodeList.php index 352326fe..3c1c8478 100644 --- a/library/Zend/Dom/Document/NodeList.php +++ b/library/Zend/Dom/Document/NodeList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/Document/Query.php b/library/Zend/Dom/Document/Query.php index bea59032..947e6afd 100644 --- a/library/Zend/Dom/Document/Query.php +++ b/library/Zend/Dom/Document/Query.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/Exception/BadMethodCallException.php b/library/Zend/Dom/Exception/BadMethodCallException.php index df3eb1fd..993c26d9 100644 --- a/library/Zend/Dom/Exception/BadMethodCallException.php +++ b/library/Zend/Dom/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/Exception/ExceptionInterface.php b/library/Zend/Dom/Exception/ExceptionInterface.php index f342f8fe..19251584 100644 --- a/library/Zend/Dom/Exception/ExceptionInterface.php +++ b/library/Zend/Dom/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/Exception/RuntimeException.php b/library/Zend/Dom/Exception/RuntimeException.php index 6cd15e22..e96886a4 100644 --- a/library/Zend/Dom/Exception/RuntimeException.php +++ b/library/Zend/Dom/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/NodeList.php b/library/Zend/Dom/NodeList.php index f9d4a1dc..82447c43 100644 --- a/library/Zend/Dom/NodeList.php +++ b/library/Zend/Dom/NodeList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Dom/Query.php b/library/Zend/Dom/Query.php index 55142991..7e65b602 100644 --- a/library/Zend/Dom/Query.php +++ b/library/Zend/Dom/Query.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -297,7 +297,7 @@ class Query * * @param DOMDocument $document * @param string|array $xpathQuery - * @return array + * @return \DOMNodeList * @throws \ErrorException If query cannot be executed */ protected function getNodeList($document, $xpathQuery) diff --git a/library/Zend/Dom/composer.json b/library/Zend/Dom/composer.json index 94433c52..9d94841f 100644 --- a/library/Zend/Dom/composer.json +++ b/library/Zend/Dom/composer.json @@ -8,18 +8,17 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Dom\\": "" } }, - "target-dir": "Zend/Dom", "require": { "php": ">=5.3.23" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Escaper/Escaper.php b/library/Zend/Escaper/Escaper.php index 3a3d30eb..072d543f 100644 --- a/library/Zend/Escaper/Escaper.php +++ b/library/Zend/Escaper/Escaper.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Escaper; - /** * Context specific methods for use in secure output escaping */ @@ -321,9 +320,9 @@ class Escaper } if (!$this->isUtf8($result)) { - throw new Exception\RuntimeException(sprintf( - 'String to be escaped was not valid UTF-8 or could not be converted: %s', $result - )); + throw new Exception\RuntimeException( + sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) + ); } return $result; diff --git a/library/Zend/Escaper/Exception/ExceptionInterface.php b/library/Zend/Escaper/Exception/ExceptionInterface.php index 3a7c8a3f..7174796a 100644 --- a/library/Zend/Escaper/Exception/ExceptionInterface.php +++ b/library/Zend/Escaper/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Escaper/Exception/InvalidArgumentException.php b/library/Zend/Escaper/Exception/InvalidArgumentException.php index c7958b96..0ad3f731 100644 --- a/library/Zend/Escaper/Exception/InvalidArgumentException.php +++ b/library/Zend/Escaper/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Escaper/Exception/RuntimeException.php b/library/Zend/Escaper/Exception/RuntimeException.php index b4217562..d626123a 100644 --- a/library/Zend/Escaper/Exception/RuntimeException.php +++ b/library/Zend/Escaper/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Escaper/composer.json b/library/Zend/Escaper/composer.json index 5f81793f..a81c8700 100644 --- a/library/Zend/Escaper/composer.json +++ b/library/Zend/Escaper/composer.json @@ -8,18 +8,17 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Escaper\\": "" } }, - "target-dir": "Zend/Escaper", "require": { "php": ">=5.3.23" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/EventManager/AbstractListenerAggregate.php b/library/Zend/EventManager/AbstractListenerAggregate.php index 3f4df278..a8b887d6 100644 --- a/library/Zend/EventManager/AbstractListenerAggregate.php +++ b/library/Zend/EventManager/AbstractListenerAggregate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Event.php b/library/Zend/EventManager/Event.php index abc34e74..bc4ed442 100644 --- a/library/Zend/EventManager/Event.php +++ b/library/Zend/EventManager/Event.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/EventInterface.php b/library/Zend/EventManager/EventInterface.php index c1d0de70..3a6274e9 100644 --- a/library/Zend/EventManager/EventInterface.php +++ b/library/Zend/EventManager/EventInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/EventManager.php b/library/Zend/EventManager/EventManager.php index 64a25724..aab67eef 100644 --- a/library/Zend/EventManager/EventManager.php +++ b/library/Zend/EventManager/EventManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -167,12 +167,10 @@ class EventManager implements EventManagerInterface /** * Trigger all listeners for a given event * - * Can emulate triggerUntil() if the last argument provided is a callback. - * - * @param string $event - * @param string|object $target Object calling emit, or symbol describing target (such as static method name) - * @param array|ArrayAccess $argv Array of arguments; typically, should be associative - * @param null|callable $callback + * @param string|EventInterface $event + * @param string|object $target Object calling emit, or symbol describing target (such as static method name) + * @param array|ArrayAccess $argv Array of arguments; typically, should be associative + * @param null|callable $callback Trigger listeners until return value of this callback evaluate to true * @return ResponseCollection All listener return values * @throws Exception\InvalidCallbackException */ @@ -214,42 +212,21 @@ class EventManager implements EventManagerInterface * Triggers listeners until the provided callback evaluates the return * value of one as true, or until all listeners have been executed. * - * @param string $event + * @param string|EventInterface $event * @param string|object $target Object calling emit, or symbol describing target (such as static method name) * @param array|ArrayAccess $argv Array of arguments; typically, should be associative * @param callable $callback * @return ResponseCollection + * @deprecated Please use trigger() * @throws Exception\InvalidCallbackException if invalid callable provided */ public function triggerUntil($event, $target, $argv = null, $callback = null) { - if ($event instanceof EventInterface) { - $e = $event; - $event = $e->getName(); - $callback = $target; - } elseif ($target instanceof EventInterface) { - $e = $target; - $e->setName($event); - $callback = $argv; - } elseif ($argv instanceof EventInterface) { - $e = $argv; - $e->setName($event); - $e->setTarget($target); - } else { - $e = new $this->eventClass(); - $e->setName($event); - $e->setTarget($target); - $e->setParams($argv); - } - - if (!is_callable($callback)) { - throw new Exception\InvalidCallbackException('Invalid callback provided'); - } - - // Initial value of stop propagation flag should be false - $e->stopPropagation(false); - - return $this->triggerListeners($event, $e, $callback); + trigger_error( + 'This method is deprecated and will be removed in the future. Please use trigger() instead.', + E_USER_DEPRECATED + ); + return $this->trigger($event, $target, $argv, $callback); } /** @@ -416,7 +393,7 @@ class EventManager implements EventManagerInterface * * Use this method if you want to be able to modify arguments from within a * listener. It returns an ArrayObject of the arguments, which may then be - * passed to trigger() or triggerUntil(). + * passed to trigger(). * * @param array $args * @return ArrayObject @@ -429,8 +406,7 @@ class EventManager implements EventManagerInterface /** * Trigger listeners * - * Actual functionality for triggering listeners, to which both trigger() and triggerUntil() - * delegate. + * Actual functionality for triggering listeners, to which trigger() delegate. * * @param string $event Event name * @param EventInterface $e @@ -530,7 +506,7 @@ class EventManager implements EventManagerInterface * Used to inject shared listeners and wildcard listeners. * * @param PriorityQueue $masterListeners - * @param PriorityQueue $listeners + * @param array|Traversable $listeners * @return void */ protected function insertListeners($masterListeners, $listeners) diff --git a/library/Zend/EventManager/EventManagerAwareInterface.php b/library/Zend/EventManager/EventManagerAwareInterface.php index a5c25f25..77ea5334 100644 --- a/library/Zend/EventManager/EventManagerAwareInterface.php +++ b/library/Zend/EventManager/EventManagerAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/EventManagerAwareTrait.php b/library/Zend/EventManager/EventManagerAwareTrait.php index 31e47a4b..1b87b58f 100644 --- a/library/Zend/EventManager/EventManagerAwareTrait.php +++ b/library/Zend/EventManager/EventManagerAwareTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/EventManagerInterface.php b/library/Zend/EventManager/EventManagerInterface.php index 6a2129f9..c33bfb69 100644 --- a/library/Zend/EventManager/EventManagerInterface.php +++ b/library/Zend/EventManager/EventManagerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,10 +25,9 @@ interface EventManagerInterface extends SharedEventManagerAwareInterface * - Passing event name and Event object only * - Passing event name, target, and Event object * - Passing event name, target, and array|ArrayAccess of arguments + * - Passing event name, target, array|ArrayAccess of arguments, and callback * - * Can emulate triggerUntil() if the last argument provided is a callback. - * - * @param string $event + * @param string|EventInterface $event * @param object|string $target * @param array|object $argv * @param null|callable $callback @@ -45,11 +44,12 @@ interface EventManagerInterface extends SharedEventManagerAwareInterface * - Passing event name, target, Event object, and callback * - Passing event name, target, array|ArrayAccess of arguments, and callback * - * @param string $event + * @param string|EventInterface $event * @param object|string $target * @param array|object $argv * @param callable $callback * @return ResponseCollection + * @deprecated Please use trigger() */ public function triggerUntil($event, $target, $argv = null, $callback = null); diff --git a/library/Zend/EventManager/EventsCapableInterface.php b/library/Zend/EventManager/EventsCapableInterface.php index d94b8d0f..e4b99b3f 100644 --- a/library/Zend/EventManager/EventsCapableInterface.php +++ b/library/Zend/EventManager/EventsCapableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Exception/DomainException.php b/library/Zend/EventManager/Exception/DomainException.php index 180f481b..6b247ad9 100644 --- a/library/Zend/EventManager/Exception/DomainException.php +++ b/library/Zend/EventManager/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Exception/ExceptionInterface.php b/library/Zend/EventManager/Exception/ExceptionInterface.php index 68cd6c36..61382cfc 100644 --- a/library/Zend/EventManager/Exception/ExceptionInterface.php +++ b/library/Zend/EventManager/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Exception/InvalidArgumentException.php b/library/Zend/EventManager/Exception/InvalidArgumentException.php index 2a4a6b53..2b277514 100644 --- a/library/Zend/EventManager/Exception/InvalidArgumentException.php +++ b/library/Zend/EventManager/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Exception/InvalidCallbackException.php b/library/Zend/EventManager/Exception/InvalidCallbackException.php index e7665942..3afda0cb 100644 --- a/library/Zend/EventManager/Exception/InvalidCallbackException.php +++ b/library/Zend/EventManager/Exception/InvalidCallbackException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Filter/FilterInterface.php b/library/Zend/EventManager/Filter/FilterInterface.php index b69fc2cb..71d0c1dc 100644 --- a/library/Zend/EventManager/Filter/FilterInterface.php +++ b/library/Zend/EventManager/Filter/FilterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/Filter/FilterIterator.php b/library/Zend/EventManager/Filter/FilterIterator.php index 60f811fb..d15274ba 100644 --- a/library/Zend/EventManager/Filter/FilterIterator.php +++ b/library/Zend/EventManager/Filter/FilterIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/FilterChain.php b/library/Zend/EventManager/FilterChain.php index d79a5de9..f657a35d 100644 --- a/library/Zend/EventManager/FilterChain.php +++ b/library/Zend/EventManager/FilterChain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -115,6 +115,6 @@ class FilterChain implements Filter\FilterInterface */ public function getResponses() { - return null; + return; } } diff --git a/library/Zend/EventManager/GlobalEventManager.php b/library/Zend/EventManager/GlobalEventManager.php index 4bac5b57..336b69cd 100644 --- a/library/Zend/EventManager/GlobalEventManager.php +++ b/library/Zend/EventManager/GlobalEventManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -52,14 +52,15 @@ class GlobalEventManager /** * Trigger an event * - * @param string $event + * @param string $event * @param object|string $context - * @param array|object $argv + * @param array|object $argv + * @param null|callable $callback * @return ResponseCollection */ - public static function trigger($event, $context, $argv = array()) + public static function trigger($event, $context, $argv = array(), $callback = null) { - return static::getEventCollection()->trigger($event, $context, $argv); + return static::getEventCollection()->trigger($event, $context, $argv, $callback); } /** @@ -71,10 +72,15 @@ class GlobalEventManager * @param array|object $argv * @param callable $callback * @return ResponseCollection + * @deprecated Please use trigger() */ public static function triggerUntil($event, $context, $argv, $callback) { - return static::getEventCollection()->triggerUntil($event, $context, $argv, $callback); + trigger_error( + 'This method is deprecated and will be removed in the future. Please use trigger() instead.', + E_USER_DEPRECATED + ); + return static::trigger($event, $context, $argv, $callback); } /** diff --git a/library/Zend/EventManager/ListenerAggregateInterface.php b/library/Zend/EventManager/ListenerAggregateInterface.php index cd0eef4c..df76708d 100644 --- a/library/Zend/EventManager/ListenerAggregateInterface.php +++ b/library/Zend/EventManager/ListenerAggregateInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/ListenerAggregateTrait.php b/library/Zend/EventManager/ListenerAggregateTrait.php index bd287e49..17ae0b04 100644 --- a/library/Zend/EventManager/ListenerAggregateTrait.php +++ b/library/Zend/EventManager/ListenerAggregateTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/ProvidesEvents.php b/library/Zend/EventManager/ProvidesEvents.php index 0cfeb197..edb19c1d 100644 --- a/library/Zend/EventManager/ProvidesEvents.php +++ b/library/Zend/EventManager/ProvidesEvents.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/ResponseCollection.php b/library/Zend/EventManager/ResponseCollection.php index b9fb7353..62e584ed 100644 --- a/library/Zend/EventManager/ResponseCollection.php +++ b/library/Zend/EventManager/ResponseCollection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -61,7 +61,7 @@ class ResponseCollection extends SplStack public function last() { if (count($this) === 0) { - return null; + return; } return parent::top(); } diff --git a/library/Zend/EventManager/SharedEventAggregateAwareInterface.php b/library/Zend/EventManager/SharedEventAggregateAwareInterface.php index 4cda8bc1..73b849c3 100644 --- a/library/Zend/EventManager/SharedEventAggregateAwareInterface.php +++ b/library/Zend/EventManager/SharedEventAggregateAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/SharedEventManager.php b/library/Zend/EventManager/SharedEventManager.php index 05424311..40fae74a 100644 --- a/library/Zend/EventManager/SharedEventManager.php +++ b/library/Zend/EventManager/SharedEventManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/SharedEventManagerAwareInterface.php b/library/Zend/EventManager/SharedEventManagerAwareInterface.php index 09e5c98c..f6c05ec6 100644 --- a/library/Zend/EventManager/SharedEventManagerAwareInterface.php +++ b/library/Zend/EventManager/SharedEventManagerAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/SharedEventManagerInterface.php b/library/Zend/EventManager/SharedEventManagerInterface.php index f6705880..1e26c570 100644 --- a/library/Zend/EventManager/SharedEventManagerInterface.php +++ b/library/Zend/EventManager/SharedEventManagerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/SharedListenerAggregateInterface.php b/library/Zend/EventManager/SharedListenerAggregateInterface.php index 0c592f71..e1190407 100644 --- a/library/Zend/EventManager/SharedListenerAggregateInterface.php +++ b/library/Zend/EventManager/SharedListenerAggregateInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/EventManager/StaticEventManager.php b/library/Zend/EventManager/StaticEventManager.php index 28e6921b..3b571362 100644 --- a/library/Zend/EventManager/StaticEventManager.php +++ b/library/Zend/EventManager/StaticEventManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,7 @@ namespace Zend\EventManager; class StaticEventManager extends SharedEventManager { /** - * @var StaticEventManager + * @var SharedEventManagerInterface */ protected static $instance; diff --git a/library/Zend/EventManager/composer.json b/library/Zend/EventManager/composer.json index cdb67a0e..559df993 100644 --- a/library/Zend/EventManager/composer.json +++ b/library/Zend/EventManager/composer.json @@ -8,19 +8,18 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\EventManager\\": "" } }, - "target-dir": "Zend/EventManager", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Feed/Exception/BadMethodCallException.php b/library/Zend/Feed/Exception/BadMethodCallException.php index 107c3e64..3e994f2e 100644 --- a/library/Zend/Feed/Exception/BadMethodCallException.php +++ b/library/Zend/Feed/Exception/BadMethodCallException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Feed\Exception; -class BadMethodCallException - extends \BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Exception/ExceptionInterface.php b/library/Zend/Feed/Exception/ExceptionInterface.php index 82619590..0f752962 100644 --- a/library/Zend/Feed/Exception/ExceptionInterface.php +++ b/library/Zend/Feed/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Exception/InvalidArgumentException.php b/library/Zend/Feed/Exception/InvalidArgumentException.php index 56647bc8..29b64828 100644 --- a/library/Zend/Feed/Exception/InvalidArgumentException.php +++ b/library/Zend/Feed/Exception/InvalidArgumentException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Feed\Exception; -class InvalidArgumentException - extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Exception/RuntimeException.php b/library/Zend/Feed/Exception/RuntimeException.php index ece11e05..43167a1e 100644 --- a/library/Zend/Feed/Exception/RuntimeException.php +++ b/library/Zend/Feed/Exception/RuntimeException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Feed\Exception; -class RuntimeException - extends \RuntimeException - implements ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Feed/PubSubHubbub/AbstractCallback.php b/library/Zend/Feed/PubSubHubbub/AbstractCallback.php index 7645cb90..7321c962 100644 --- a/library/Zend/Feed/PubSubHubbub/AbstractCallback.php +++ b/library/Zend/Feed/PubSubHubbub/AbstractCallback.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/CallbackInterface.php b/library/Zend/Feed/PubSubHubbub/CallbackInterface.php index 8873c3db..c6b7412f 100644 --- a/library/Zend/Feed/PubSubHubbub/CallbackInterface.php +++ b/library/Zend/Feed/PubSubHubbub/CallbackInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Exception/ExceptionInterface.php b/library/Zend/Feed/PubSubHubbub/Exception/ExceptionInterface.php index e9286a0b..f32bc1c3 100644 --- a/library/Zend/Feed/PubSubHubbub/Exception/ExceptionInterface.php +++ b/library/Zend/Feed/PubSubHubbub/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Exception/InvalidArgumentException.php b/library/Zend/Feed/PubSubHubbub/Exception/InvalidArgumentException.php index 95125314..cad1e01b 100644 --- a/library/Zend/Feed/PubSubHubbub/Exception/InvalidArgumentException.php +++ b/library/Zend/Feed/PubSubHubbub/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Feed\PubSubHubbub\Exception; use Zend\Feed\Exception; -class InvalidArgumentException - extends Exception\InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Feed/PubSubHubbub/Exception/RuntimeException.php b/library/Zend/Feed/PubSubHubbub/Exception/RuntimeException.php index f4a49c79..cc954a51 100644 --- a/library/Zend/Feed/PubSubHubbub/Exception/RuntimeException.php +++ b/library/Zend/Feed/PubSubHubbub/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Feed\PubSubHubbub\Exception; use Zend\Feed\Exception; -class RuntimeException - extends Exception\RuntimeException - implements ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Feed/PubSubHubbub/HttpResponse.php b/library/Zend/Feed/PubSubHubbub/HttpResponse.php index 0c4c7417..0c1adf2e 100644 --- a/library/Zend/Feed/PubSubHubbub/HttpResponse.php +++ b/library/Zend/Feed/PubSubHubbub/HttpResponse.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Model/AbstractModel.php b/library/Zend/Feed/PubSubHubbub/Model/AbstractModel.php index 92e68813..3ebd07f5 100644 --- a/library/Zend/Feed/PubSubHubbub/Model/AbstractModel.php +++ b/library/Zend/Feed/PubSubHubbub/Model/AbstractModel.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Model/Subscription.php b/library/Zend/Feed/PubSubHubbub/Model/Subscription.php index 9571106a..46a5d82c 100644 --- a/library/Zend/Feed/PubSubHubbub/Model/Subscription.php +++ b/library/Zend/Feed/PubSubHubbub/Model/Subscription.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Model/SubscriptionPersistenceInterface.php b/library/Zend/Feed/PubSubHubbub/Model/SubscriptionPersistenceInterface.php index ccd27232..09e7d755 100644 --- a/library/Zend/Feed/PubSubHubbub/Model/SubscriptionPersistenceInterface.php +++ b/library/Zend/Feed/PubSubHubbub/Model/SubscriptionPersistenceInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/PubSubHubbub.php b/library/Zend/Feed/PubSubHubbub/PubSubHubbub.php index 585be54d..a930a70b 100644 --- a/library/Zend/Feed/PubSubHubbub/PubSubHubbub.php +++ b/library/Zend/Feed/PubSubHubbub/PubSubHubbub.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Publisher.php b/library/Zend/Feed/PubSubHubbub/Publisher.php index 916ffcad..6130992b 100644 --- a/library/Zend/Feed/PubSubHubbub/Publisher.php +++ b/library/Zend/Feed/PubSubHubbub/Publisher.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Subscriber.php b/library/Zend/Feed/PubSubHubbub/Subscriber.php index 265fe776..d5db9085 100644 --- a/library/Zend/Feed/PubSubHubbub/Subscriber.php +++ b/library/Zend/Feed/PubSubHubbub/Subscriber.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Subscriber/Callback.php b/library/Zend/Feed/PubSubHubbub/Subscriber/Callback.php index 5ec8af2f..51602590 100644 --- a/library/Zend/Feed/PubSubHubbub/Subscriber/Callback.php +++ b/library/Zend/Feed/PubSubHubbub/Subscriber/Callback.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/PubSubHubbub/Version.php b/library/Zend/Feed/PubSubHubbub/Version.php index edee6953..9ac7fb4b 100644 --- a/library/Zend/Feed/PubSubHubbub/Version.php +++ b/library/Zend/Feed/PubSubHubbub/Version.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/AbstractEntry.php b/library/Zend/Feed/Reader/AbstractEntry.php index cf8a9361..a5bcd428 100644 --- a/library/Zend/Feed/Reader/AbstractEntry.php +++ b/library/Zend/Feed/Reader/AbstractEntry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -180,7 +180,7 @@ abstract class AbstractEntry if (array_key_exists($name . '\Entry', $this->extensions)) { return $this->extensions[$name . '\Entry']; } - return null; + return; } /** diff --git a/library/Zend/Feed/Reader/AbstractFeed.php b/library/Zend/Feed/Reader/AbstractFeed.php index f8aa49d8..1ded7441 100644 --- a/library/Zend/Feed/Reader/AbstractFeed.php +++ b/library/Zend/Feed/Reader/AbstractFeed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -266,7 +266,7 @@ abstract class AbstractFeed implements Feed\FeedInterface if (array_key_exists($name . '\Feed', $this->extensions)) { return $this->extensions[$name . '\Feed']; } - return null; + return; } protected function loadExtensions() diff --git a/library/Zend/Feed/Reader/Collection.php b/library/Zend/Feed/Reader/Collection.php index ac1c9638..f50c1bc2 100644 --- a/library/Zend/Feed/Reader/Collection.php +++ b/library/Zend/Feed/Reader/Collection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Collection/AbstractCollection.php b/library/Zend/Feed/Reader/Collection/AbstractCollection.php index 62580248..749ff5c8 100644 --- a/library/Zend/Feed/Reader/Collection/AbstractCollection.php +++ b/library/Zend/Feed/Reader/Collection/AbstractCollection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Collection/Author.php b/library/Zend/Feed/Reader/Collection/Author.php index 9e0996e1..82716db2 100644 --- a/library/Zend/Feed/Reader/Collection/Author.php +++ b/library/Zend/Feed/Reader/Collection/Author.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Collection/Category.php b/library/Zend/Feed/Reader/Collection/Category.php index 34b8fded..57d05604 100644 --- a/library/Zend/Feed/Reader/Collection/Category.php +++ b/library/Zend/Feed/Reader/Collection/Category.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Collection/Collection.php b/library/Zend/Feed/Reader/Collection/Collection.php index 86a29276..cf791c2e 100644 --- a/library/Zend/Feed/Reader/Collection/Collection.php +++ b/library/Zend/Feed/Reader/Collection/Collection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Entry/AbstractEntry.php b/library/Zend/Feed/Reader/Entry/AbstractEntry.php index 241a8cdb..7b006875 100644 --- a/library/Zend/Feed/Reader/Entry/AbstractEntry.php +++ b/library/Zend/Feed/Reader/Entry/AbstractEntry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -122,8 +122,9 @@ abstract class AbstractEntry */ public function saveXml() { - $dom = new DOMDocument('1.0', $this->getEncoding()); - $entry = $dom->importNode($this->getElement(), true); + $dom = new DOMDocument('1.0', $this->getEncoding()); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $entry = $dom->importNode($this->getElement(), $deep); $dom->appendChild($entry); return $dom->saveXml(); } @@ -184,7 +185,7 @@ abstract class AbstractEntry if (array_key_exists($name . '\\Entry', $this->extensions)) { return $this->extensions[$name . '\\Entry']; } - return null; + return; } /** @@ -202,8 +203,10 @@ abstract class AbstractEntry return call_user_func_array(array($extension, $method), $args); } } - throw new Exception\RuntimeException('Method: ' . $method - . ' does not exist and could not be located on a registered Extension'); + throw new Exception\RuntimeException(sprintf( + 'Method: %s does not exist and could not be located on a registered Extension', + $method + )); } /** diff --git a/library/Zend/Feed/Reader/Entry/Atom.php b/library/Zend/Feed/Reader/Entry/Atom.php index ed61a21e..543f4566 100644 --- a/library/Zend/Feed/Reader/Entry/Atom.php +++ b/library/Zend/Feed/Reader/Entry/Atom.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -62,7 +62,7 @@ class Atom extends AbstractEntry implements EntryInterface return $authors[$index]; } - return null; + return; } /** @@ -207,7 +207,7 @@ class Atom extends AbstractEntry implements EntryInterface return $this->data['links'][$index]; } - return null; + return; } /** diff --git a/library/Zend/Feed/Reader/Entry/EntryInterface.php b/library/Zend/Feed/Reader/Entry/EntryInterface.php index 86fea3ec..c5e5fb22 100644 --- a/library/Zend/Feed/Reader/Entry/EntryInterface.php +++ b/library/Zend/Feed/Reader/Entry/EntryInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Entry/Rss.php b/library/Zend/Feed/Reader/Entry/Rss.php index a59c85fd..79678a53 100644 --- a/library/Zend/Feed/Reader/Entry/Rss.php +++ b/library/Zend/Feed/Reader/Entry/Rss.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -76,7 +76,7 @@ class Rss extends AbstractEntry implements EntryInterface return $authors[$index]; } - return null; + return; } /** @@ -109,8 +109,6 @@ class Rss extends AbstractEntry implements EntryInterface if ($list->length) { foreach ($list as $author) { $string = trim($author->nodeValue); - $email = null; - $name = null; $data = array(); // Pretty rough parsing - but it's a catchall if (preg_match("/^.*@[^ ]*/", $string, $matches)) { @@ -188,7 +186,6 @@ class Rss extends AbstractEntry implements EntryInterface return $this->data['datemodified']; } - $dateModified = null; $date = null; if ($this->getType() !== Reader\Reader::TYPE_RSS_10 @@ -207,7 +204,7 @@ class Rss extends AbstractEntry implements EntryInterface $date = date_create_from_format($standard, $dateModified); break; } catch (\Exception $e) { - if ($standard == null) { + if ($standard === null) { throw new Exception\RuntimeException( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' @@ -366,7 +363,7 @@ class Rss extends AbstractEntry implements EntryInterface return $this->data['links'][$index]; } - return null; + return; } /** diff --git a/library/Zend/Feed/Reader/Exception/BadMethodCallException.php b/library/Zend/Feed/Reader/Exception/BadMethodCallException.php index 3e265088..008c57ec 100644 --- a/library/Zend/Feed/Reader/Exception/BadMethodCallException.php +++ b/library/Zend/Feed/Reader/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Feed\Reader\Exception; use Zend\Feed\Exception; -class BadMethodCallException - extends Exception\BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends Exception\BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Reader/Exception/ExceptionInterface.php b/library/Zend/Feed/Reader/Exception/ExceptionInterface.php index 148e5b2d..e5e664af 100644 --- a/library/Zend/Feed/Reader/Exception/ExceptionInterface.php +++ b/library/Zend/Feed/Reader/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Exception/InvalidArgumentException.php b/library/Zend/Feed/Reader/Exception/InvalidArgumentException.php index 9f795c68..646b767b 100644 --- a/library/Zend/Feed/Reader/Exception/InvalidArgumentException.php +++ b/library/Zend/Feed/Reader/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Feed\Reader\Exception; use Zend\Feed\Exception; -class InvalidArgumentException - extends Exception\InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Reader/Exception/RuntimeException.php b/library/Zend/Feed/Reader/Exception/RuntimeException.php index e9ffc9e7..d876e7f0 100644 --- a/library/Zend/Feed/Reader/Exception/RuntimeException.php +++ b/library/Zend/Feed/Reader/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Feed\Reader\Exception; use Zend\Feed\Exception; -class RuntimeException - extends Exception\RuntimeException - implements ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Reader/Extension/AbstractEntry.php b/library/Zend/Feed/Reader/Extension/AbstractEntry.php index 15e7574d..72bd62ea 100644 --- a/library/Zend/Feed/Reader/Extension/AbstractEntry.php +++ b/library/Zend/Feed/Reader/Extension/AbstractEntry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Extension/AbstractFeed.php b/library/Zend/Feed/Reader/Extension/AbstractFeed.php index 1bea2e49..94acea6e 100644 --- a/library/Zend/Feed/Reader/Extension/AbstractFeed.php +++ b/library/Zend/Feed/Reader/Extension/AbstractFeed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -105,7 +105,6 @@ abstract class AbstractFeed return $type; } - /** * Return the feed as an array * diff --git a/library/Zend/Feed/Reader/Extension/Atom/Entry.php b/library/Zend/Feed/Reader/Extension/Atom/Entry.php index 9e20321c..06e94a27 100644 --- a/library/Zend/Feed/Reader/Extension/Atom/Entry.php +++ b/library/Zend/Feed/Reader/Extension/Atom/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ class Entry extends Extension\AbstractEntry return $authors[$index]; } - return null; + return; } /** @@ -103,20 +103,21 @@ class Entry extends Extension\AbstractEntry case 'html': case 'text/html': $content = $el->nodeValue; - break; + break; case 'xhtml': $this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml'); $xhtml = $this->getXpath()->query( $this->getXpathPrefix() . '/atom:content/xhtml:div' )->item(0); $d = new DOMDocument('1.0', $this->getEncoding()); - $xhtmls = $d->importNode($xhtml, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $xhtmls = $d->importNode($xhtml, $deep); $d->appendChild($xhtmls); $content = $this->collectXhtml( $d->saveXML(), $d->lookupPrefix('http://www.w3.org/1999/xhtml') ); - break; + break; } } @@ -296,9 +297,12 @@ class Entry extends Extension\AbstractEntry return $this->data['baseUrl']; } - $baseUrl = $this->getXpath()->evaluate('string(' - . $this->getXpathPrefix() . '/@xml:base[1]' - . ')'); + $baseUrl = $this->getXpath()->evaluate( + 'string(' + . $this->getXpathPrefix() + . '/@xml:base[1]' + . ')' + ); if (!$baseUrl) { $baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])'); @@ -329,7 +333,7 @@ class Entry extends Extension\AbstractEntry return $this->data['links'][$index]; } - return null; + return; } /** @@ -588,7 +592,7 @@ class Entry extends Extension\AbstractEntry } if (empty($author)) { - return null; + return; } return $author; } diff --git a/library/Zend/Feed/Reader/Extension/Atom/Feed.php b/library/Zend/Feed/Reader/Extension/Atom/Feed.php index 986d23fd..19dbf5a5 100644 --- a/library/Zend/Feed/Reader/Extension/Atom/Feed.php +++ b/library/Zend/Feed/Reader/Extension/Atom/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ class Feed extends Extension\AbstractFeed return $authors[$index]; } - return null; + return; } /** @@ -471,7 +471,7 @@ class Feed extends Extension\AbstractFeed } if (empty($author)) { - return null; + return; } return $author; } diff --git a/library/Zend/Feed/Reader/Extension/Content/Entry.php b/library/Zend/Feed/Reader/Extension/Content/Entry.php index 9b5f7cb3..539848f2 100644 --- a/library/Zend/Feed/Reader/Extension/Content/Entry.php +++ b/library/Zend/Feed/Reader/Extension/Content/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php b/library/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php index 1883dc6b..9194682f 100644 --- a/library/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php +++ b/library/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ class Entry extends Extension\AbstractEntry return $licenses[$index]; } - return null; + return; } /** diff --git a/library/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php b/library/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php index 99977fd4..c833bbda 100644 --- a/library/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php +++ b/library/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ class Feed extends Extension\AbstractFeed return $licenses[$index]; } - return null; + return; } /** diff --git a/library/Zend/Feed/Reader/Extension/DublinCore/Entry.php b/library/Zend/Feed/Reader/Extension/DublinCore/Entry.php index 2713353c..e23de810 100644 --- a/library/Zend/Feed/Reader/Extension/DublinCore/Entry.php +++ b/library/Zend/Feed/Reader/Extension/DublinCore/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ class Entry extends Extension\AbstractEntry return $authors[$index]; } - return null; + return; } /** @@ -110,7 +110,6 @@ class Entry extends Extension\AbstractEntry return $this->data['categories']; } - /** * Get the entry content * @@ -132,7 +131,6 @@ class Entry extends Extension\AbstractEntry return $this->data['description']; } - $description = null; $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)'); if (!$description) { @@ -159,7 +157,6 @@ class Entry extends Extension\AbstractEntry return $this->data['id']; } - $id = null; $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)'); if (!$id) { @@ -182,7 +179,6 @@ class Entry extends Extension\AbstractEntry return $this->data['title']; } - $title = null; $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)'); if (!$title) { diff --git a/library/Zend/Feed/Reader/Extension/DublinCore/Feed.php b/library/Zend/Feed/Reader/Extension/DublinCore/Feed.php index 2738ac73..6b54b081 100644 --- a/library/Zend/Feed/Reader/Extension/DublinCore/Feed.php +++ b/library/Zend/Feed/Reader/Extension/DublinCore/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ class Feed extends Extension\AbstractFeed return $authors[$index]; } - return null; + return; } /** @@ -87,7 +87,6 @@ class Feed extends Extension\AbstractFeed return $this->data['copyright']; } - $copyright = null; $copyright = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:rights)'); if (!$copyright) { @@ -114,7 +113,6 @@ class Feed extends Extension\AbstractFeed return $this->data['description']; } - $description = null; $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)'); if (!$description) { @@ -141,7 +139,6 @@ class Feed extends Extension\AbstractFeed return $this->data['id']; } - $id = null; $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)'); if (!$id) { @@ -164,7 +161,6 @@ class Feed extends Extension\AbstractFeed return $this->data['language']; } - $language = null; $language = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:language)'); if (!$language) { @@ -191,7 +187,6 @@ class Feed extends Extension\AbstractFeed return $this->data['title']; } - $title = null; $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)'); if (!$title) { diff --git a/library/Zend/Feed/Reader/Extension/Podcast/Entry.php b/library/Zend/Feed/Reader/Extension/Podcast/Entry.php index c97e64ff..5aec2fd9 100644 --- a/library/Zend/Feed/Reader/Extension/Podcast/Entry.php +++ b/library/Zend/Feed/Reader/Extension/Podcast/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Extension/Podcast/Feed.php b/library/Zend/Feed/Reader/Extension/Podcast/Feed.php index 66b13a48..9fb80de5 100644 --- a/library/Zend/Feed/Reader/Extension/Podcast/Feed.php +++ b/library/Zend/Feed/Reader/Extension/Podcast/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -63,7 +63,7 @@ class Feed extends Extension\AbstractFeed /** * Get the entry category * - * @return string + * @return array|null */ public function getItunesCategories() { @@ -93,7 +93,6 @@ class Feed extends Extension\AbstractFeed } } - if (!$categories) { $categories = null; } diff --git a/library/Zend/Feed/Reader/Extension/Slash/Entry.php b/library/Zend/Feed/Reader/Extension/Slash/Entry.php index 9ddb862e..786d894e 100644 --- a/library/Zend/Feed/Reader/Extension/Slash/Entry.php +++ b/library/Zend/Feed/Reader/Extension/Slash/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Extension/Syndication/Feed.php b/library/Zend/Feed/Reader/Extension/Syndication/Feed.php index db1724c1..09f12dde 100644 --- a/library/Zend/Feed/Reader/Extension/Syndication/Feed.php +++ b/library/Zend/Feed/Reader/Extension/Syndication/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Extension/Thread/Entry.php b/library/Zend/Feed/Reader/Extension/Thread/Entry.php index d3bc3158..e5de5bb1 100644 --- a/library/Zend/Feed/Reader/Extension/Thread/Entry.php +++ b/library/Zend/Feed/Reader/Extension/Thread/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php b/library/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php index 6d5a9770..42fafb4a 100644 --- a/library/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php +++ b/library/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/ExtensionManager.php b/library/Zend/Feed/Reader/ExtensionManager.php index 9103643a..bf694c8e 100644 --- a/library/Zend/Feed/Reader/ExtensionManager.php +++ b/library/Zend/Feed/Reader/ExtensionManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/ExtensionManagerInterface.php b/library/Zend/Feed/Reader/ExtensionManagerInterface.php index 4bbb91d9..70ec37d4 100644 --- a/library/Zend/Feed/Reader/ExtensionManagerInterface.php +++ b/library/Zend/Feed/Reader/ExtensionManagerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/ExtensionPluginManager.php b/library/Zend/Feed/Reader/ExtensionPluginManager.php index 45d3b26b..3e3308c2 100644 --- a/library/Zend/Feed/Reader/ExtensionPluginManager.php +++ b/library/Zend/Feed/Reader/ExtensionPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Feed/AbstractFeed.php b/library/Zend/Feed/Reader/Feed/AbstractFeed.php index dd616bef..9814967a 100644 --- a/library/Zend/Feed/Reader/Feed/AbstractFeed.php +++ b/library/Zend/Feed/Reader/Feed/AbstractFeed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -270,7 +270,7 @@ abstract class AbstractFeed implements FeedInterface if (array_key_exists($name . '\\Feed', $this->extensions)) { return $this->extensions[$name . '\\Feed']; } - return null; + return; } protected function loadExtensions() diff --git a/library/Zend/Feed/Reader/Feed/Atom.php b/library/Zend/Feed/Reader/Feed/Atom.php index 72efcf76..37064701 100644 --- a/library/Zend/Feed/Reader/Feed/Atom.php +++ b/library/Zend/Feed/Reader/Feed/Atom.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -58,7 +58,7 @@ class Atom extends AbstractFeed return $authors[$index]; } - return null; + return; } /** @@ -152,7 +152,7 @@ class Atom extends AbstractFeed */ public function getLastBuildDate() { - return null; + return; } /** diff --git a/library/Zend/Feed/Reader/Feed/Atom/Source.php b/library/Zend/Feed/Reader/Feed/Atom/Source.php index 5eabd974..2590de65 100644 --- a/library/Zend/Feed/Reader/Feed/Atom/Source.php +++ b/library/Zend/Feed/Reader/Feed/Atom/Source.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Feed/FeedInterface.php b/library/Zend/Feed/Reader/Feed/FeedInterface.php index c98a1b33..441ba926 100644 --- a/library/Zend/Feed/Reader/Feed/FeedInterface.php +++ b/library/Zend/Feed/Reader/Feed/FeedInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Feed/Rss.php b/library/Zend/Feed/Reader/Feed/Rss.php index bc930901..9e045d7b 100644 --- a/library/Zend/Feed/Reader/Feed/Rss.php +++ b/library/Zend/Feed/Reader/Feed/Rss.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -69,7 +69,7 @@ class Rss extends AbstractFeed return $authors[$index]; } - return null; + return; } /** @@ -106,8 +106,6 @@ class Rss extends AbstractFeed if ($list->length) { foreach ($list as $author) { $string = trim($author->nodeValue); - $email = null; - $name = null; $data = array(); // Pretty rough parsing - but it's a catchall if (preg_match("/^.*@[^ ]*/", $string, $matches)) { @@ -194,7 +192,6 @@ class Rss extends AbstractFeed return $this->data['datemodified']; } - $dateModified = null; $date = null; if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && @@ -215,7 +212,7 @@ class Rss extends AbstractFeed $date = DateTime::createFromFormat($standard, $dateModified); break; } catch (\Exception $e) { - if ($standard == null) { + if ($standard === null) { throw new Exception\RuntimeException( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' @@ -258,7 +255,6 @@ class Rss extends AbstractFeed return $this->data['lastBuildDate']; } - $lastBuildDate = null; $date = null; if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && @@ -276,7 +272,7 @@ class Rss extends AbstractFeed $date = DateTime::createFromFormat($standard, $lastBuildDateParsed); break; } catch (\Exception $e) { - if ($standard == null) { + if ($standard === null) { throw new Exception\RuntimeException( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' @@ -310,8 +306,6 @@ class Rss extends AbstractFeed return $this->data['description']; } - $description = null; - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) { $description = $this->xpath->evaluate('string(/rss/channel/description)'); @@ -481,8 +475,6 @@ class Rss extends AbstractFeed return $this->data['link']; } - $link = null; - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) { $link = $this->xpath->evaluate('string(/rss/channel/link)'); @@ -514,8 +506,6 @@ class Rss extends AbstractFeed return $this->data['feedlink']; } - $link = null; - $link = $this->getExtension('Atom')->getFeedLink(); if ($link === null || empty($link)) { @@ -578,8 +568,6 @@ class Rss extends AbstractFeed return $this->data['title']; } - $title = null; - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) { $title = $this->xpath->evaluate('string(/rss/channel/title)'); diff --git a/library/Zend/Feed/Reader/FeedSet.php b/library/Zend/Feed/Reader/FeedSet.php index e487bc8f..8fab2cba 100644 --- a/library/Zend/Feed/Reader/FeedSet.php +++ b/library/Zend/Feed/Reader/FeedSet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -115,7 +115,7 @@ class FeedSet extends ArrayObject { if ($offset == 'feed' && !$this->offsetExists('feed')) { if (!$this->offsetExists('href')) { - return null; + return; } $feed = Reader::import($this->offsetGet('href')); $this->offsetSet('feed', $feed); diff --git a/library/Zend/Feed/Reader/Http/ClientInterface.php b/library/Zend/Feed/Reader/Http/ClientInterface.php index 43932f76..13879818 100644 --- a/library/Zend/Feed/Reader/Http/ClientInterface.php +++ b/library/Zend/Feed/Reader/Http/ClientInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Http/ResponseInterface.php b/library/Zend/Feed/Reader/Http/ResponseInterface.php index 39c51724..96b422e1 100644 --- a/library/Zend/Feed/Reader/Http/ResponseInterface.php +++ b/library/Zend/Feed/Reader/Http/ResponseInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Reader/Reader.php b/library/Zend/Feed/Reader/Reader.php index bcd387ad..c5eb3d45 100644 --- a/library/Zend/Feed/Reader/Reader.php +++ b/library/Zend/Feed/Reader/Reader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,7 +17,7 @@ use Zend\Stdlib\ErrorHandler; /** */ -class Reader +class Reader implements ReaderImportInterface { /** * Namespace constants @@ -125,7 +125,6 @@ class Reader static::$httpClient = $httpClient; } - /** * Gets the HTTP client object. If none is set, a new ZendHttp\Client will be used. * @@ -191,7 +190,6 @@ class Reader public static function import($uri, $etag = null, $lastModified = null) { $cache = self::getCache(); - $feed = null; $client = self::getHttpClient(); $client->resetParameters(); $headers = new ZendHttp\Headers(); @@ -546,7 +544,7 @@ class Reader public static function getExtensionManager() { if (!isset(static::$extensionManager)) { - static::setExtensionManager(new ExtensionManager()); + static::setExtensionManager(new StandaloneExtensionManager()); } return static::$extensionManager; } diff --git a/library/Zend/Feed/Reader/ReaderImportInterface.php b/library/Zend/Feed/Reader/ReaderImportInterface.php new file mode 100644 index 00000000..0a2edd14 --- /dev/null +++ b/library/Zend/Feed/Reader/ReaderImportInterface.php @@ -0,0 +1,62 @@ + 'Zend\Feed\Reader\Extension\Atom\Entry', + 'Atom\Feed' => 'Zend\Feed\Reader\Extension\Atom\Feed', + 'Content\Entry' => 'Zend\Feed\Reader\Extension\Content\Entry', + 'CreativeCommons\Entry' => 'Zend\Feed\Reader\Extension\CreativeCommons\Entry', + 'CreativeCommons\Feed' => 'Zend\Feed\Reader\Extension\CreativeCommons\Feed', + 'DublinCore\Entry' => 'Zend\Feed\Reader\Extension\DublinCore\Entry', + 'DublinCore\Feed' => 'Zend\Feed\Reader\Extension\DublinCore\Feed', + 'Podcast\Entry' => 'Zend\Feed\Reader\Extension\Podcast\Entry', + 'Podcast\Feed' => 'Zend\Feed\Reader\Extension\Podcast\Feed', + 'Slash\Entry' => 'Zend\Feed\Reader\Extension\Slash\Entry', + 'Syndication\Feed' => 'Zend\Feed\Reader\Extension\Syndication\Feed', + 'Thread\Entry' => 'Zend\Feed\Reader\Extension\Thread\Entry', + 'WellFormedWeb\Entry' => 'Zend\Feed\Reader\Extension\WellFormedWeb\Entry', + ); + + /** + * Do we have the extension? + * + * @param string $extension + * @return bool + */ + public function has($extension) + { + return array_key_exists($extension, $this->extensions); + } + + /** + * Retrieve the extension + * + * @param string $extension + * @return Extension\AbstractEntry|Extension\AbstractFeed + */ + public function get($extension) + { + $class = $this->extensions[$extension]; + return new $class(); + } +} diff --git a/library/Zend/Feed/Uri.php b/library/Zend/Feed/Uri.php index 940bce11..9a4565e3 100644 --- a/library/Zend/Feed/Uri.php +++ b/library/Zend/Feed/Uri.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/AbstractFeed.php b/library/Zend/Feed/Writer/AbstractFeed.php index 1dd6fe54..26616b06 100644 --- a/library/Zend/Feed/Writer/AbstractFeed.php +++ b/library/Zend/Feed/Writer/AbstractFeed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -531,7 +531,7 @@ class AbstractFeed return $this->data['authors'][$index]; } - return null; + return; } /** @@ -542,7 +542,7 @@ class AbstractFeed public function getAuthors() { if (!array_key_exists('authors', $this->data)) { - return null; + return; } return $this->data['authors']; } @@ -555,7 +555,7 @@ class AbstractFeed public function getCopyright() { if (!array_key_exists('copyright', $this->data)) { - return null; + return; } return $this->data['copyright']; } @@ -568,7 +568,7 @@ class AbstractFeed public function getDateCreated() { if (!array_key_exists('dateCreated', $this->data)) { - return null; + return; } return $this->data['dateCreated']; } @@ -581,7 +581,7 @@ class AbstractFeed public function getDateModified() { if (!array_key_exists('dateModified', $this->data)) { - return null; + return; } return $this->data['dateModified']; } @@ -594,7 +594,7 @@ class AbstractFeed public function getLastBuildDate() { if (!array_key_exists('lastBuildDate', $this->data)) { - return null; + return; } return $this->data['lastBuildDate']; } @@ -607,7 +607,7 @@ class AbstractFeed public function getDescription() { if (!array_key_exists('description', $this->data)) { - return null; + return; } return $this->data['description']; } @@ -620,7 +620,7 @@ class AbstractFeed public function getGenerator() { if (!array_key_exists('generator', $this->data)) { - return null; + return; } return $this->data['generator']; } @@ -633,7 +633,7 @@ class AbstractFeed public function getId() { if (!array_key_exists('id', $this->data)) { - return null; + return; } return $this->data['id']; } @@ -646,7 +646,7 @@ class AbstractFeed public function getImage() { if (!array_key_exists('image', $this->data)) { - return null; + return; } return $this->data['image']; } @@ -659,7 +659,7 @@ class AbstractFeed public function getLanguage() { if (!array_key_exists('language', $this->data)) { - return null; + return; } return $this->data['language']; } @@ -672,7 +672,7 @@ class AbstractFeed public function getLink() { if (!array_key_exists('link', $this->data)) { - return null; + return; } return $this->data['link']; } @@ -685,7 +685,7 @@ class AbstractFeed public function getFeedLinks() { if (!array_key_exists('feedLinks', $this->data)) { - return null; + return; } return $this->data['feedLinks']; } @@ -698,7 +698,7 @@ class AbstractFeed public function getTitle() { if (!array_key_exists('title', $this->data)) { - return null; + return; } return $this->data['title']; } @@ -724,7 +724,7 @@ class AbstractFeed public function getBaseUrl() { if (!array_key_exists('baseUrl', $this->data)) { - return null; + return; } return $this->data['baseUrl']; } @@ -737,7 +737,7 @@ class AbstractFeed public function getHubs() { if (!array_key_exists('hubs', $this->data)) { - return null; + return; } return $this->data['hubs']; } @@ -750,7 +750,7 @@ class AbstractFeed public function getCategories() { if (!array_key_exists('categories', $this->data)) { - return null; + return; } return $this->data['categories']; } diff --git a/library/Zend/Feed/Writer/Deleted.php b/library/Zend/Feed/Writer/Deleted.php index b91ee094..1d72fc92 100644 --- a/library/Zend/Feed/Writer/Deleted.php +++ b/library/Zend/Feed/Writer/Deleted.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -124,7 +124,7 @@ class Deleted public function getReference() { if (!array_key_exists('reference', $this->data)) { - return null; + return; } return $this->data['reference']; } @@ -157,7 +157,7 @@ class Deleted public function getWhen() { if (!array_key_exists('when', $this->data)) { - return null; + return; } return $this->data['when']; } @@ -208,7 +208,7 @@ class Deleted public function getBy() { if (!array_key_exists('by', $this->data)) { - return null; + return; } return $this->data['by']; } @@ -229,7 +229,7 @@ class Deleted public function getComment() { if (!array_key_exists('comment', $this->data)) { - return null; + return; } return $this->data['comment']; } diff --git a/library/Zend/Feed/Writer/Entry.php b/library/Zend/Feed/Writer/Entry.php index c5b1085a..78b968dc 100644 --- a/library/Zend/Feed/Writer/Entry.php +++ b/library/Zend/Feed/Writer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -365,7 +365,7 @@ class Entry public function getAuthors() { if (!array_key_exists('authors', $this->data)) { - return null; + return; } return $this->data['authors']; } @@ -378,7 +378,7 @@ class Entry public function getContent() { if (!array_key_exists('content', $this->data)) { - return null; + return; } return $this->data['content']; } @@ -391,7 +391,7 @@ class Entry public function getCopyright() { if (!array_key_exists('copyright', $this->data)) { - return null; + return; } return $this->data['copyright']; } @@ -404,7 +404,7 @@ class Entry public function getDateCreated() { if (!array_key_exists('dateCreated', $this->data)) { - return null; + return; } return $this->data['dateCreated']; } @@ -417,7 +417,7 @@ class Entry public function getDateModified() { if (!array_key_exists('dateModified', $this->data)) { - return null; + return; } return $this->data['dateModified']; } @@ -430,7 +430,7 @@ class Entry public function getDescription() { if (!array_key_exists('description', $this->data)) { - return null; + return; } return $this->data['description']; } @@ -443,7 +443,7 @@ class Entry public function getId() { if (!array_key_exists('id', $this->data)) { - return null; + return; } return $this->data['id']; } @@ -456,7 +456,7 @@ class Entry public function getLink() { if (!array_key_exists('link', $this->data)) { - return null; + return; } return $this->data['link']; } @@ -470,7 +470,7 @@ class Entry public function getLinks() { if (!array_key_exists('links', $this->data)) { - return null; + return; } return $this->data['links']; } @@ -483,7 +483,7 @@ class Entry public function getTitle() { if (!array_key_exists('title', $this->data)) { - return null; + return; } return $this->data['title']; } @@ -496,7 +496,7 @@ class Entry public function getCommentCount() { if (!array_key_exists('commentCount', $this->data)) { - return null; + return; } return $this->data['commentCount']; } @@ -509,7 +509,7 @@ class Entry public function getCommentLink() { if (!array_key_exists('commentLink', $this->data)) { - return null; + return; } return $this->data['commentLink']; } @@ -523,7 +523,7 @@ class Entry public function getCommentFeedLinks() { if (!array_key_exists('commentFeedLinks', $this->data)) { - return null; + return; } return $this->data['commentFeedLinks']; } @@ -582,7 +582,7 @@ class Entry public function getCategories() { if (!array_key_exists('categories', $this->data)) { - return null; + return; } return $this->data['categories']; } @@ -618,7 +618,7 @@ class Entry public function getEnclosure() { if (!array_key_exists('enclosure', $this->data)) { - return null; + return; } return $this->data['enclosure']; } @@ -659,7 +659,7 @@ class Entry if (array_key_exists($name . '\\Entry', $this->extensions)) { return $this->extensions[$name . '\\Entry']; } - return null; + return; } /** @@ -744,7 +744,7 @@ class Entry if (isset($this->data['source'])) { return $this->data['source']; } - return null; + return; } /** diff --git a/library/Zend/Feed/Writer/Exception/BadMethodCallException.php b/library/Zend/Feed/Writer/Exception/BadMethodCallException.php index 79d1c82c..b2ea2bef 100644 --- a/library/Zend/Feed/Writer/Exception/BadMethodCallException.php +++ b/library/Zend/Feed/Writer/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -16,8 +16,6 @@ use Zend\Feed\Exception; * * Class to represent exceptions that occur during Feed operations. */ -class BadMethodCallException - extends Exception\BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends Exception\BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Writer/Exception/ExceptionInterface.php b/library/Zend/Feed/Writer/Exception/ExceptionInterface.php index c2ed59be..ee8bdaf6 100644 --- a/library/Zend/Feed/Writer/Exception/ExceptionInterface.php +++ b/library/Zend/Feed/Writer/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Exception/InvalidArgumentException.php b/library/Zend/Feed/Writer/Exception/InvalidArgumentException.php index 838a01bb..d8c4a8b8 100644 --- a/library/Zend/Feed/Writer/Exception/InvalidArgumentException.php +++ b/library/Zend/Feed/Writer/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -16,8 +16,6 @@ use Zend\Feed\Exception; * * Class to represent exceptions that occur during Feed operations. */ -class InvalidArgumentException - extends Exception\InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Writer/Exception/RuntimeException.php b/library/Zend/Feed/Writer/Exception/RuntimeException.php index 0bab4b8f..ae8ee361 100644 --- a/library/Zend/Feed/Writer/Exception/RuntimeException.php +++ b/library/Zend/Feed/Writer/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Feed\Writer\Exception; use Zend\Feed\Exception; -class RuntimeException - extends Exception\RuntimeException - implements ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Feed/Writer/Extension/AbstractRenderer.php b/library/Zend/Feed/Writer/Extension/AbstractRenderer.php index 5e4eb8c8..1a32b475 100644 --- a/library/Zend/Feed/Writer/Extension/AbstractRenderer.php +++ b/library/Zend/Feed/Writer/Extension/AbstractRenderer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php b/library/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php index 6b24ec01..25571c0e 100644 --- a/library/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php +++ b/library/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php b/library/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php index b9031516..939b2492 100644 --- a/library/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php +++ b/library/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php b/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php index 8f9465c7..5cc86cd6 100644 --- a/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php +++ b/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php b/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php index 6e68f98e..160b5a48 100644 --- a/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php +++ b/library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/ITunes/Entry.php b/library/Zend/Feed/Writer/Extension/ITunes/Entry.php index 1b7b64aa..c06e8a97 100644 --- a/library/Zend/Feed/Writer/Extension/ITunes/Entry.php +++ b/library/Zend/Feed/Writer/Extension/ITunes/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -239,7 +239,7 @@ class Entry if (!array_key_exists($point, $this->data) || empty($this->data[$point]) ) { - return null; + return; } return $this->data[$point]; } diff --git a/library/Zend/Feed/Writer/Extension/ITunes/Feed.php b/library/Zend/Feed/Writer/Extension/ITunes/Feed.php index 22c54db6..08a6b13f 100644 --- a/library/Zend/Feed/Writer/Extension/ITunes/Feed.php +++ b/library/Zend/Feed/Writer/Extension/ITunes/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -355,7 +355,7 @@ class Feed ); } if (!array_key_exists($point, $this->data) || empty($this->data[$point])) { - return null; + return; } return $this->data[$point]; } diff --git a/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php b/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php index bc57d1da..ed8f732e 100644 --- a/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php +++ b/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php b/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php index e6113a22..d978f032 100644 --- a/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php +++ b/library/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/RendererInterface.php b/library/Zend/Feed/Writer/Extension/RendererInterface.php index e72346c2..9afe88b2 100644 --- a/library/Zend/Feed/Writer/Extension/RendererInterface.php +++ b/library/Zend/Feed/Writer/Extension/RendererInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php b/library/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php index 077caa6e..c74cb020 100644 --- a/library/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php +++ b/library/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php b/library/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php index a0ea739d..6f19641b 100644 --- a/library/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php +++ b/library/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php b/library/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php index d661360a..48c0d8f2 100644 --- a/library/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php +++ b/library/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/ExtensionManager.php b/library/Zend/Feed/Writer/ExtensionManager.php index 77d49a0d..89be41d8 100644 --- a/library/Zend/Feed/Writer/ExtensionManager.php +++ b/library/Zend/Feed/Writer/ExtensionManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/ExtensionManagerInterface.php b/library/Zend/Feed/Writer/ExtensionManagerInterface.php index 0f7e023f..b0e28a08 100644 --- a/library/Zend/Feed/Writer/ExtensionManagerInterface.php +++ b/library/Zend/Feed/Writer/ExtensionManagerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/ExtensionPluginManager.php b/library/Zend/Feed/Writer/ExtensionPluginManager.php index 1155c84d..6763374c 100644 --- a/library/Zend/Feed/Writer/ExtensionPluginManager.php +++ b/library/Zend/Feed/Writer/ExtensionPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Feed.php b/library/Zend/Feed/Writer/Feed.php index 36b2b3ba..d402bb8f 100644 --- a/library/Zend/Feed/Writer/Feed.php +++ b/library/Zend/Feed/Writer/Feed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/FeedFactory.php b/library/Zend/Feed/Writer/FeedFactory.php index 15e7a346..99b528c7 100644 --- a/library/Zend/Feed/Writer/FeedFactory.php +++ b/library/Zend/Feed/Writer/FeedFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Renderer/AbstractRenderer.php b/library/Zend/Feed/Writer/Renderer/AbstractRenderer.php index e1045019..76b9a685 100644 --- a/library/Zend/Feed/Writer/Renderer/AbstractRenderer.php +++ b/library/Zend/Feed/Writer/Renderer/AbstractRenderer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Renderer/Entry/Atom.php b/library/Zend/Feed/Writer/Renderer/Entry/Atom.php index 975aa726..31b0a9ac 100644 --- a/library/Zend/Feed/Writer/Renderer/Entry/Atom.php +++ b/library/Zend/Feed/Writer/Renderer/Entry/Atom.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -137,7 +137,7 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa $updated = $dom->createElement('updated'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->format(DateTime::ISO8601) + $this->getDataContainer()->getDateModified()->format(DateTime::ATOM) ); $updated->appendChild($text); } @@ -157,7 +157,7 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa $el = $dom->createElement('published'); $root->appendChild($el); $text = $dom->createTextNode( - $this->getDataContainer()->getDateCreated()->format(DateTime::ISO8601) + $this->getDataContainer()->getDateCreated()->format(DateTime::ATOM) ); $el->appendChild($text); } @@ -265,12 +265,14 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa if (!$this->getDataContainer()->getId()) { $this->getDataContainer()->setId( - $this->getDataContainer()->getLink()); + $this->getDataContainer()->getLink() + ); } if (!Uri::factory($this->getDataContainer()->getId())->isValid() && !preg_match( "#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", - $this->getDataContainer()->getId()) + $this->getDataContainer()->getId() + ) && !$this->_validateTagUri($this->getDataContainer()->getId()) ) { throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI'); @@ -289,7 +291,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa */ protected function _validateTagUri($id) { - if (preg_match('/^tag:(?P.*),(?P\d{4}-?\d{0,2}-?\d{0,2}):(?P.*)(.*:)*$/', $id, $matches)) { + if (preg_match( + '/^tag:(?P.*),(?P\d{4}-?\d{0,2}-?\d{0,2}):(?P.*)(.*:)*$/', + $id, + $matches + )) { $dvalid = false; $date = $matches['date']; $d6 = strtotime($date); @@ -341,7 +347,8 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa $element = $dom->createElement('content'); $element->setAttribute('type', 'xhtml'); $xhtmlElement = $this->_loadXhtml($content); - $xhtml = $dom->importNode($xhtmlElement, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $xhtml = $dom->importNode($xhtmlElement, $deep); $element->appendChild($xhtml); $root->appendChild($element); } @@ -369,8 +376,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa "/(<[\/]?)([a-zA-Z]+)/" ), '$1xhtml:$2', $xhtml); $dom = new DOMDocument('1.0', $this->getEncoding()); - $dom->loadXML('' - . $xhtml . ''); + $dom->loadXML( + '' + . $xhtml + . '' + ); return $dom->documentElement; } diff --git a/library/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php b/library/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php index 65ace00b..8519bd9d 100644 --- a/library/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php +++ b/library/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -40,7 +40,7 @@ class Deleted extends Renderer\AbstractRenderer implements Renderer\RendererInte $this->dom->appendChild($entry); $entry->setAttribute('ref', $this->container->getReference()); - $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ISO8601)); + $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ATOM)); $this->_setBy($this->dom, $entry); $this->_setComment($this->dom, $entry); diff --git a/library/Zend/Feed/Writer/Renderer/Entry/AtomDeleted.php b/library/Zend/Feed/Writer/Renderer/Entry/AtomDeleted.php index 1ed4aa3d..f0db3e93 100644 --- a/library/Zend/Feed/Writer/Renderer/Entry/AtomDeleted.php +++ b/library/Zend/Feed/Writer/Renderer/Entry/AtomDeleted.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -42,7 +42,7 @@ class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\Renderer $this->dom->appendChild($entry); $entry->setAttribute('ref', $this->container->getReference()); - $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ISO8601)); + $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ATOM)); $this->_setBy($this->dom, $entry); $this->_setComment($this->dom, $entry); diff --git a/library/Zend/Feed/Writer/Renderer/Entry/Rss.php b/library/Zend/Feed/Writer/Renderer/Entry/Rss.php index 2338cdc2..aae2f46e 100644 --- a/library/Zend/Feed/Writer/Renderer/Entry/Rss.php +++ b/library/Zend/Feed/Writer/Renderer/Entry/Rss.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Renderer/Feed/AbstractAtom.php b/library/Zend/Feed/Writer/Renderer/Feed/AbstractAtom.php index e7ad9f56..a5400a60 100644 --- a/library/Zend/Feed/Writer/Renderer/Feed/AbstractAtom.php +++ b/library/Zend/Feed/Writer/Renderer/Feed/AbstractAtom.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -118,7 +118,7 @@ class AbstractAtom extends Renderer\AbstractRenderer $updated = $dom->createElement('updated'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->format(DateTime::ISO8601) + $this->getDataContainer()->getDateModified()->format(DateTime::ATOM) ); $updated->appendChild($text); } diff --git a/library/Zend/Feed/Writer/Renderer/Feed/Atom.php b/library/Zend/Feed/Writer/Renderer/Feed/Atom.php index 87b6b94a..939babc0 100644 --- a/library/Zend/Feed/Writer/Renderer/Feed/Atom.php +++ b/library/Zend/Feed/Writer/Renderer/Feed/Atom.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -40,7 +40,8 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface $this->dom = new DOMDocument('1.0', $this->container->getEncoding()); $this->dom->formatOutput = true; $root = $this->dom->createElementNS( - Writer\Writer::NAMESPACE_ATOM_10, 'feed' + Writer\Writer::NAMESPACE_ATOM_10, + 'feed' ); $this->setRootElement($root); $this->dom->appendChild($root); @@ -76,7 +77,8 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface } else { if (!$this->dom->documentElement->hasAttribute('xmlns:at')) { $this->dom->documentElement->setAttribute( - 'xmlns:at', 'http://purl.org/atompub/tombstones/1.0' + 'xmlns:at', + 'http://purl.org/atompub/tombstones/1.0' ); } $renderer = new Renderer\Entry\AtomDeleted($entry); @@ -88,7 +90,8 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface $renderer->setRootElement($this->dom->documentElement); $renderer->render(); $element = $renderer->getElement(); - $imported = $this->dom->importNode($element, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $imported = $this->dom->importNode($element, $deep); $root->appendChild($imported); } return $this; diff --git a/library/Zend/Feed/Writer/Renderer/Feed/Atom/AbstractAtom.php b/library/Zend/Feed/Writer/Renderer/Feed/Atom/AbstractAtom.php index 379cd5c9..20fc8df8 100644 --- a/library/Zend/Feed/Writer/Renderer/Feed/Atom/AbstractAtom.php +++ b/library/Zend/Feed/Writer/Renderer/Feed/Atom/AbstractAtom.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -115,7 +115,7 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer $updated = $dom->createElement('updated'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->format(DateTime::ISO8601) + $this->getDataContainer()->getDateModified()->format(DateTime::ATOM) ); $updated->appendChild($text); } @@ -313,7 +313,6 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer $img->appendChild($text); } - /** * Set date feed was created * diff --git a/library/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php b/library/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php index 30f576a1..3793db0c 100644 --- a/library/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php +++ b/library/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Renderer/Feed/AtomSource.php b/library/Zend/Feed/Writer/Renderer/Feed/AtomSource.php index bdadd4db..d552b808 100644 --- a/library/Zend/Feed/Writer/Renderer/Feed/AtomSource.php +++ b/library/Zend/Feed/Writer/Renderer/Feed/AtomSource.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Renderer/Feed/Rss.php b/library/Zend/Feed/Writer/Renderer/Feed/Rss.php index 75c502e3..be902b8a 100644 --- a/library/Zend/Feed/Writer/Renderer/Feed/Rss.php +++ b/library/Zend/Feed/Writer/Renderer/Feed/Rss.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -85,7 +85,8 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac $renderer->setRootElement($this->dom->documentElement); $renderer->render(); $element = $renderer->getElement(); - $imported = $this->dom->importNode($element, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $imported = $this->dom->importNode($element, $deep); $channel->appendChild($imported); } return $this; @@ -195,8 +196,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac protected function _setGenerator(DOMDocument $dom, DOMElement $root) { if (!$this->getDataContainer()->getGenerator()) { - $this->getDataContainer()->setGenerator('Zend_Feed_Writer', - Version::VERSION, 'http://framework.zend.com'); + $this->getDataContainer()->setGenerator( + 'Zend_Feed_Writer', + Version::VERSION, + 'http://framework.zend.com' + ); } $gdata = $this->getDataContainer()->getGenerator(); diff --git a/library/Zend/Feed/Writer/Renderer/RendererInterface.php b/library/Zend/Feed/Writer/Renderer/RendererInterface.php index b2e0e00a..24738efc 100644 --- a/library/Zend/Feed/Writer/Renderer/RendererInterface.php +++ b/library/Zend/Feed/Writer/Renderer/RendererInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Source.php b/library/Zend/Feed/Writer/Source.php index f0b4dcac..23affa7a 100644 --- a/library/Zend/Feed/Writer/Source.php +++ b/library/Zend/Feed/Writer/Source.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Version.php b/library/Zend/Feed/Writer/Version.php index 8dd20df9..08351ca3 100644 --- a/library/Zend/Feed/Writer/Version.php +++ b/library/Zend/Feed/Writer/Version.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/Writer/Writer.php b/library/Zend/Feed/Writer/Writer.php index ae8e1536..8c539789 100644 --- a/library/Zend/Feed/Writer/Writer.php +++ b/library/Zend/Feed/Writer/Writer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Feed/composer.json b/library/Zend/Feed/composer.json index 0c4d7dc1..134ef322 100644 --- a/library/Zend/Feed/composer.json +++ b/library/Zend/Feed/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Feed\\": "" } }, - "target-dir": "Zend/Feed", "require": { "php": ">=5.3.23", "zendframework/zend-escaper": "self.version", @@ -34,8 +33,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/File/ClassFileLocator.php b/library/Zend/File/ClassFileLocator.php index 9ef7821a..f8c28e86 100644 --- a/library/Zend/File/ClassFileLocator.php +++ b/library/Zend/File/ClassFileLocator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -116,6 +116,10 @@ class ClassFileLocator extends FilterIterator break; case $t_trait: case T_CLASS: + // ignore T_CLASS after T_DOUBLE_COLON to allow PHP >=5.5 FQCN scalar resolution + if ($i > 0 && is_array($tokens[$i-1]) && $tokens[$i-1][0] === T_DOUBLE_COLON) { + break; + } case T_INTERFACE: // Abstract class, class, interface or trait found diff --git a/library/Zend/File/Exception/BadMethodCallException.php b/library/Zend/File/Exception/BadMethodCallException.php index 04be8693..0e6ac034 100644 --- a/library/Zend/File/Exception/BadMethodCallException.php +++ b/library/Zend/File/Exception/BadMethodCallException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\File\Exception; -class BadMethodCallException extends \BadMethodCallException implements - ExceptionInterface +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/File/Exception/ExceptionInterface.php b/library/Zend/File/Exception/ExceptionInterface.php index 851724f2..984da8b6 100644 --- a/library/Zend/File/Exception/ExceptionInterface.php +++ b/library/Zend/File/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/Exception/InvalidArgumentException.php b/library/Zend/File/Exception/InvalidArgumentException.php index 83ae6a93..c9132efd 100644 --- a/library/Zend/File/Exception/InvalidArgumentException.php +++ b/library/Zend/File/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,8 +12,6 @@ namespace Zend\File\Exception; /** * Exception class raised when invalid arguments are discovered */ -class InvalidArgumentException - extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/File/Exception/RuntimeException.php b/library/Zend/File/Exception/RuntimeException.php index 530821bf..bd9ae27b 100644 --- a/library/Zend/File/Exception/RuntimeException.php +++ b/library/Zend/File/Exception/RuntimeException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\File\Exception; -class RuntimeException - extends \RuntimeException - implements ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/File/PhpClassFile.php b/library/Zend/File/PhpClassFile.php index 82503cf3..800c859c 100644 --- a/library/Zend/File/PhpClassFile.php +++ b/library/Zend/File/PhpClassFile.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/Transfer/Adapter/AbstractAdapter.php b/library/Zend/File/Transfer/Adapter/AbstractAdapter.php index a46935f6..7be8c58d 100644 --- a/library/Zend/File/Transfer/Adapter/AbstractAdapter.php +++ b/library/Zend/File/Transfer/Adapter/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -369,14 +369,18 @@ abstract class AbstractAdapter implements TranslatorAwareInterface break; case (1 <= $argc): $validator = array_shift($validatorInfo); + // fall-through case (2 <= $argc): $breakChainOnFailure = array_shift($validatorInfo); + // fall-through case (3 <= $argc): $options = array_shift($validatorInfo); + // fall-through case (4 <= $argc): if (!empty($validatorInfo)) { $file = array_shift($validatorInfo); } + // fall-through default: $this->addValidator($validator, $breakChainOnFailure, $options, $file); break; @@ -424,7 +428,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface public function getValidator($name) { if (false === ($identifier = $this->getValidatorIdentifier($name))) { - return null; + return; } return $this->validators[$identifier]; } @@ -437,7 +441,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface */ public function getValidators($files = null) { - if ($files == null) { + if ($files === null) { return $this->validators; } @@ -523,13 +527,13 @@ abstract class AbstractAdapter implements TranslatorAwareInterface foreach ($options as $name => $value) { foreach ($file as $key => $content) { switch ($name) { - case 'magicFile' : + case 'magicFile': $this->files[$key]['options'][$name] = (string) $value; break; - case 'ignoreNoFile' : - case 'useByteString' : - case 'detectInfos' : + case 'ignoreNoFile': + case 'useByteString': + case 'detectInfos': $this->files[$key]['options'][$name] = (bool) $value; break; @@ -800,7 +804,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface public function getFilter($name) { if (false === ($identifier = $this->getFilterIdentifier($name))) { - return null; + return; } return $this->filters[$identifier]; @@ -1027,7 +1031,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface public function getTranslator() { if ($this->isTranslatorEnabled()) { - return null; + return; } return $this->translator; @@ -1165,7 +1169,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface } elseif (file_exists($value['tmp_name'])) { $filename = $value['tmp_name']; } else { - return null; + return; } ErrorHandler::start(); @@ -1220,7 +1224,7 @@ abstract class AbstractAdapter implements TranslatorAwareInterface } elseif (file_exists($value['tmp_name'])) { $file = $value['tmp_name']; } else { - return null; + return; } if (class_exists('finfo', false)) { diff --git a/library/Zend/File/Transfer/Adapter/FilterPluginManager.php b/library/Zend/File/Transfer/Adapter/FilterPluginManager.php index 28da7ee4..8179eef1 100644 --- a/library/Zend/File/Transfer/Adapter/FilterPluginManager.php +++ b/library/Zend/File/Transfer/Adapter/FilterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/Transfer/Adapter/Http.php b/library/Zend/File/Transfer/Adapter/Http.php index 3cba2184..b7c2908b 100644 --- a/library/Zend/File/Transfer/Adapter/Http.php +++ b/library/Zend/File/Transfer/Adapter/Http.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/Transfer/Adapter/ValidatorPluginManager.php b/library/Zend/File/Transfer/Adapter/ValidatorPluginManager.php index f24f5d45..c6912c01 100644 --- a/library/Zend/File/Transfer/Adapter/ValidatorPluginManager.php +++ b/library/Zend/File/Transfer/Adapter/ValidatorPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/Transfer/Exception/BadMethodCallException.php b/library/Zend/File/Transfer/Exception/BadMethodCallException.php index 0d47a905..ed9d0170 100644 --- a/library/Zend/File/Transfer/Exception/BadMethodCallException.php +++ b/library/Zend/File/Transfer/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\File\Transfer\Exception; use Zend\File\Exception; -class BadMethodCallException extends Exception\BadMethodCallException implements - ExceptionInterface +class BadMethodCallException extends Exception\BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/File/Transfer/Exception/ExceptionInterface.php b/library/Zend/File/Transfer/Exception/ExceptionInterface.php index a20e99fd..827196bf 100644 --- a/library/Zend/File/Transfer/Exception/ExceptionInterface.php +++ b/library/Zend/File/Transfer/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,6 @@ use Zend\File\Exception\ExceptionInterface as FileException; * Exception class for Zend\File\Transfer * */ -interface ExceptionInterface - extends FileException +interface ExceptionInterface extends FileException { } diff --git a/library/Zend/File/Transfer/Exception/InvalidArgumentException.php b/library/Zend/File/Transfer/Exception/InvalidArgumentException.php index f99187ef..63999e30 100644 --- a/library/Zend/File/Transfer/Exception/InvalidArgumentException.php +++ b/library/Zend/File/Transfer/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\File\Transfer\Exception; use Zend\File\Exception; -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/File/Transfer/Exception/PhpEnvironmentException.php b/library/Zend/File/Transfer/Exception/PhpEnvironmentException.php index ae29a3c8..8a358463 100644 --- a/library/Zend/File/Transfer/Exception/PhpEnvironmentException.php +++ b/library/Zend/File/Transfer/Exception/PhpEnvironmentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/Transfer/Exception/RuntimeException.php b/library/Zend/File/Transfer/Exception/RuntimeException.php index 215a38ab..29dcc843 100644 --- a/library/Zend/File/Transfer/Exception/RuntimeException.php +++ b/library/Zend/File/Transfer/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\File\Transfer\Exception; use Zend\File\Exception; -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/File/Transfer/Transfer.php b/library/Zend/File/Transfer/Transfer.php index bdd44c37..28350019 100644 --- a/library/Zend/File/Transfer/Transfer.php +++ b/library/Zend/File/Transfer/Transfer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/File/composer.json b/library/Zend/File/composer.json index d3d86cea..af48a8a2 100644 --- a/library/Zend/File/composer.json +++ b/library/Zend/File/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\File\\": "" } }, - "target-dir": "Zend/File", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -29,8 +28,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Filter/AbstractDateDropdown.php b/library/Zend/Filter/AbstractDateDropdown.php new file mode 100644 index 00000000..076b8137 --- /dev/null +++ b/library/Zend/Filter/AbstractDateDropdown.php @@ -0,0 +1,155 @@ +setOptions($options); + } + } + + /** + * @param bool $nullOnAllEmpty + * @return self + */ + public function setNullOnAllEmpty($nullOnAllEmpty) + { + $this->nullOnAllEmpty = $nullOnAllEmpty; + return $this; + } + + /** + * @return bool + */ + public function isNullOnAllEmpty() + { + return $this->nullOnAllEmpty; + } + + /** + * @param bool $nullOnEmpty + * @return self + */ + public function setNullOnEmpty($nullOnEmpty) + { + $this->nullOnEmpty = $nullOnEmpty; + return $this; + } + + /** + * @return bool + */ + public function isNullOnEmpty() + { + return $this->nullOnEmpty; + } + + /** + * Attempts to filter an array of date/time information to a formatted + * string. + * + * @param mixed $value + * @return mixed + * @throws Exception\RuntimeException If filtering $value is impossible + */ + public function filter($value) + { + if (! is_array($value)) { + // nothing to do + return $value; + } + + // Convert the date to a specific format + if ($this->isNullOnEmpty() + && array_reduce($value, __CLASS__ . '::reduce', false) + ) { + return; + } + + if ($this->isNullOnAllEmpty() + && array_reduce($value, __CLASS__ . '::reduce', true) + ) { + return; + } + + $this->filterable($value); + + ksort($value); + $value = vsprintf($this->format, $value); + + return $value; + } + + /** + * Ensures there are enough inputs in the array to properly format the date. + * + * @param $value + * @throws Exception\RuntimeException + */ + protected function filterable($value) + { + if (count($value) !== $this->expectedInputs) { + throw new Exception\RuntimeException( + sprintf( + 'There are not enough values in the array to filter this date (Required: %d, Received: %d)', + $this->expectedInputs, + count($value) + ) + ); + } + } + + /** + * Reduce to a single value + * + * @param string $soFar + * @param string $value + * @return bool + */ + public static function reduce($soFar, $value) + { + return $soFar || empty($value); + } +} diff --git a/library/Zend/Filter/AbstractFilter.php b/library/Zend/Filter/AbstractFilter.php index a52bcfa7..138a74e8 100644 --- a/library/Zend/Filter/AbstractFilter.php +++ b/library/Zend/Filter/AbstractFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -52,10 +52,14 @@ abstract class AbstractFilter implements FilterInterface } elseif (array_key_exists($key, $this->options)) { $this->options[$key] = $value; } else { - throw new Exception\InvalidArgumentException(sprintf( - 'The option "%s" does not have a matching %s setter method or options[%s] array key', - $key, $setter, $key - )); + throw new Exception\InvalidArgumentException( + sprintf( + 'The option "%s" does not have a matching %s setter method or options[%s] array key', + $key, + $setter, + $key + ) + ); } } return $this; diff --git a/library/Zend/Filter/AbstractUnicode.php b/library/Zend/Filter/AbstractUnicode.php index 685608f7..b67c8fda 100644 --- a/library/Zend/Filter/AbstractUnicode.php +++ b/library/Zend/Filter/AbstractUnicode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/BaseName.php b/library/Zend/Filter/BaseName.php index 48807ca4..bdbb0b0d 100644 --- a/library/Zend/Filter/BaseName.php +++ b/library/Zend/Filter/BaseName.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Blacklist.php b/library/Zend/Filter/Blacklist.php new file mode 100644 index 00000000..c8e8ed6c --- /dev/null +++ b/library/Zend/Filter/Blacklist.php @@ -0,0 +1,90 @@ +setOptions($options); + } + } + + /** + * Determine whether the in_array() call should be "strict" or not. See in_array docs. + * + * @param bool $strict + */ + public function setStrict($strict = true) + { + $this->strict = (bool) $strict; + } + + /** + * Returns whether the in_array() call should be "strict" or not. See in_array docs. + * + * @return boolean + */ + public function getStrict() + { + return $this->strict; + } + + /** + * Set the list of items to black-list. + * + * @param array|Traversable $list + */ + public function setList($list = array()) + { + if (!is_array($list)) { + $list = ArrayUtils::iteratorToArray($list); + } + + $this->list = $list; + } + + /** + * Get the list of items to black-list + * + * @return array + */ + public function getList() + { + return $this->list; + } + + /** + * {@inheritDoc} + * + * Will return null if $value is present in the black-list. If $value is NOT present then it will return $value. + */ + public function filter($value) + { + return in_array($value, $this->getList(), $this->getStrict()) ? null : $value; + } +} diff --git a/library/Zend/Filter/Boolean.php b/library/Zend/Filter/Boolean.php index 505842f6..87dc04a6 100644 --- a/library/Zend/Filter/Boolean.php +++ b/library/Zend/Filter/Boolean.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -67,10 +67,7 @@ class Boolean extends AbstractFilter } if (is_array($typeOrOptions)) { - if (isset($typeOrOptions['type']) - || isset($typeOrOptions['casting']) - || isset($typeOrOptions['translations']) - ) { + if (isset($typeOrOptions['type']) || isset($typeOrOptions['casting']) || isset($typeOrOptions['translations'])) { $this->setOptions($typeOrOptions); } else { $this->setType($typeOrOptions); diff --git a/library/Zend/Filter/Callback.php b/library/Zend/Filter/Callback.php index 51392e16..fea37c49 100644 --- a/library/Zend/Filter/Callback.php +++ b/library/Zend/Filter/Callback.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress.php b/library/Zend/Filter/Compress.php index f6a49e77..d33de12a 100644 --- a/library/Zend/Filter/Compress.php +++ b/library/Zend/Filter/Compress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/AbstractCompressionAlgorithm.php b/library/Zend/Filter/Compress/AbstractCompressionAlgorithm.php index b97e68cf..4893181e 100644 --- a/library/Zend/Filter/Compress/AbstractCompressionAlgorithm.php +++ b/library/Zend/Filter/Compress/AbstractCompressionAlgorithm.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -51,7 +51,7 @@ abstract class AbstractCompressionAlgorithm implements CompressionAlgorithmInter } if (!array_key_exists($option, $this->options)) { - return null; + return; } return $this->options[$option]; diff --git a/library/Zend/Filter/Compress/Bz2.php b/library/Zend/Filter/Compress/Bz2.php index 79716118..f0f4341c 100644 --- a/library/Zend/Filter/Compress/Bz2.php +++ b/library/Zend/Filter/Compress/Bz2.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/CompressionAlgorithmInterface.php b/library/Zend/Filter/Compress/CompressionAlgorithmInterface.php index cf4e5f3c..6947ffd3 100644 --- a/library/Zend/Filter/Compress/CompressionAlgorithmInterface.php +++ b/library/Zend/Filter/Compress/CompressionAlgorithmInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/Gz.php b/library/Zend/Filter/Compress/Gz.php index aa0721af..6663c3e1 100644 --- a/library/Zend/Filter/Compress/Gz.php +++ b/library/Zend/Filter/Compress/Gz.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/Lzf.php b/library/Zend/Filter/Compress/Lzf.php index ea4fd0c6..5e6b16ef 100644 --- a/library/Zend/Filter/Compress/Lzf.php +++ b/library/Zend/Filter/Compress/Lzf.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/Rar.php b/library/Zend/Filter/Compress/Rar.php index f8fb8458..39eb36c9 100644 --- a/library/Zend/Filter/Compress/Rar.php +++ b/library/Zend/Filter/Compress/Rar.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/Snappy.php b/library/Zend/Filter/Compress/Snappy.php index 33a9c616..d6214e94 100644 --- a/library/Zend/Filter/Compress/Snappy.php +++ b/library/Zend/Filter/Compress/Snappy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Compress/Tar.php b/library/Zend/Filter/Compress/Tar.php index f8a3d312..0addc7db 100644 --- a/library/Zend/Filter/Compress/Tar.php +++ b/library/Zend/Filter/Compress/Tar.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -45,7 +45,8 @@ class Tar extends AbstractCompressionAlgorithm if (!class_exists('Archive_Tar')) { throw new Exception\ExtensionNotLoadedException( 'This filter needs PEAR\'s Archive_Tar component. ' - . 'Ensure loading Archive_Tar (registering autoload or require_once)'); + . 'Ensure loading Archive_Tar (registering autoload or require_once)' + ); } parent::__construct($options); @@ -171,10 +172,9 @@ class Tar extends AbstractCompressionAlgorithm if (is_dir($content)) { // collect all file infos foreach (new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME), - RecursiveIteratorIterator::SELF_FIRST - ) as $directory => $info - ) { + new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME), + RecursiveIteratorIterator::SELF_FIRST + ) as $directory => $info) { if ($info->isFile()) { $file[] = $directory; } diff --git a/library/Zend/Filter/Compress/Zip.php b/library/Zend/Filter/Compress/Zip.php index 5a6f01a0..27781d2c 100644 --- a/library/Zend/Filter/Compress/Zip.php +++ b/library/Zend/Filter/Compress/Zip.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -228,76 +228,76 @@ class Zip extends AbstractCompressionAlgorithm public function errorString($error) { switch ($error) { - case ZipArchive::ER_MULTIDISK : + case ZipArchive::ER_MULTIDISK: return 'Multidisk ZIP Archives not supported'; - case ZipArchive::ER_RENAME : + case ZipArchive::ER_RENAME: return 'Failed to rename the temporary file for ZIP'; - case ZipArchive::ER_CLOSE : + case ZipArchive::ER_CLOSE: return 'Failed to close the ZIP Archive'; - case ZipArchive::ER_SEEK : + case ZipArchive::ER_SEEK: return 'Failure while seeking the ZIP Archive'; - case ZipArchive::ER_READ : + case ZipArchive::ER_READ: return 'Failure while reading the ZIP Archive'; - case ZipArchive::ER_WRITE : + case ZipArchive::ER_WRITE: return 'Failure while writing the ZIP Archive'; - case ZipArchive::ER_CRC : + case ZipArchive::ER_CRC: return 'CRC failure within the ZIP Archive'; - case ZipArchive::ER_ZIPCLOSED : + case ZipArchive::ER_ZIPCLOSED: return 'ZIP Archive already closed'; - case ZipArchive::ER_NOENT : + case ZipArchive::ER_NOENT: return 'No such file within the ZIP Archive'; - case ZipArchive::ER_EXISTS : + case ZipArchive::ER_EXISTS: return 'ZIP Archive already exists'; - case ZipArchive::ER_OPEN : + case ZipArchive::ER_OPEN: return 'Can not open ZIP Archive'; - case ZipArchive::ER_TMPOPEN : + case ZipArchive::ER_TMPOPEN: return 'Failure creating temporary ZIP Archive'; - case ZipArchive::ER_ZLIB : + case ZipArchive::ER_ZLIB: return 'ZLib Problem'; - case ZipArchive::ER_MEMORY : + case ZipArchive::ER_MEMORY: return 'Memory allocation problem while working on a ZIP Archive'; - case ZipArchive::ER_CHANGED : + case ZipArchive::ER_CHANGED: return 'ZIP Entry has been changed'; - case ZipArchive::ER_COMPNOTSUPP : + case ZipArchive::ER_COMPNOTSUPP: return 'Compression method not supported within ZLib'; - case ZipArchive::ER_EOF : + case ZipArchive::ER_EOF: return 'Premature EOF within ZIP Archive'; - case ZipArchive::ER_INVAL : + case ZipArchive::ER_INVAL: return 'Invalid argument for ZLIB'; - case ZipArchive::ER_NOZIP : + case ZipArchive::ER_NOZIP: return 'Given file is no zip archive'; - case ZipArchive::ER_INTERNAL : + case ZipArchive::ER_INTERNAL: return 'Internal error while working on a ZIP Archive'; - case ZipArchive::ER_INCONS : + case ZipArchive::ER_INCONS: return 'Inconsistent ZIP archive'; - case ZipArchive::ER_REMOVE : + case ZipArchive::ER_REMOVE: return 'Can not remove ZIP Archive'; - case ZipArchive::ER_DELETED : + case ZipArchive::ER_DELETED: return 'ZIP Entry has been deleted'; - default : + default: return 'Unknown error within ZIP Archive'; } } diff --git a/library/Zend/Filter/DataUnitFormatter.php b/library/Zend/Filter/DataUnitFormatter.php new file mode 100644 index 00000000..b8ca41b8 --- /dev/null +++ b/library/Zend/Filter/DataUnitFormatter.php @@ -0,0 +1,245 @@ + array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'), + // decimal SI units: + self::MODE_DECIMAL => array('', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'), + ); + + /** + * Default options: + * + * @var array + */ + protected $options = array( + 'mode' => self::MODE_DECIMAL, + 'unit' => '', + 'precision' => 2, + 'prefixes' => array(), + ); + + /** + * @param array $options + */ + public function __construct($options = array()) + { + if (!static::isOptions($options)) { + throw new InvalidArgumentException('The unit filter needs options to work.'); + } + + if (!isset($options['unit'])) { + throw new InvalidArgumentException('The unit filter needs a unit to work with.'); + } + + $this->setOptions($options); + } + + /** + * Define the mode of the filter. Possible values can be fount at self::$modes. + * + * @param string $mode + * + * @throws InvalidArgumentException + */ + protected function setMode($mode) + { + $mode = strtolower($mode); + if (!in_array($mode, self::$modes)) { + throw new InvalidArgumentException(sprintf('Invalid binary mode: %s', $mode)); + } + $this->options['mode'] = $mode; + } + + /** + * Get current filter mode + * + * @return string + */ + protected function getMode() + { + return $this->options['mode']; + } + + /** + * Find out if the filter is in decimal mode. + * + * @return bool + */ + protected function isDecimalMode() + { + return $this->getMode() == self::MODE_DECIMAL; + } + + /** + * Find out if the filter is in binary mode. + * + * @return bool + */ + protected function isBinaryMode() + { + return $this->getMode() == self::MODE_BINARY; + } + + /** + * Define the unit of the filter. Possible values can be fount at self::$types. + * + * @param string $unit + */ + protected function setUnit($unit) + { + $this->options['unit'] = (string) $unit; + } + + /** + * Get current filter type + * + * @return string + */ + protected function getUnit() + { + return $this->options['unit']; + } + + /** + * Set the precision of the filtered result. + * + * @param $precision + */ + protected function setPrecision($precision) + { + $this->options['precision'] = (int) $precision; + } + + /** + * Get the precision of the filtered result. + * + * @return int + */ + protected function getPrecision() + { + return $this->options['precision']; + } + + /** + * Set the precision of the result. + * + * @param array $prefixes + */ + protected function setPrefixes(array $prefixes) + { + $this->options['prefixes'] = $prefixes; + } + + /** + * Get the predefined prefixes or use the build-in standardized lists of prefixes. + * + * @return array + */ + protected function getPrefixes() + { + $prefixes = $this->options['prefixes']; + if ($prefixes) { + return $prefixes; + } + + return self::$standardizedPrefixes[$this->getMode()]; + } + + /** + * Find the prefix at a specific location in the prefixes array. + * + * @param $index + * + * @return string|null + */ + protected function getPrefixAt($index) + { + $prefixes = $this->getPrefixes(); + return isset($prefixes[$index]) ? $prefixes[$index] : null; + } + + /** + * Defined by Zend\Filter\FilterInterface + * + * Returns a human readable format of the amount of bits or bytes. + * + * If the value provided is not numeric, the value will remain unfiltered + * + * @param string $value + * @return string|mixed + */ + public function filter($value) + { + if (!is_numeric($value)) { + return $value; + } + + // Parse to float and check if value is not zero + $amount = (float) $value; + if ($amount == 0) { + return $this->formatAmount($amount); + } + + // Calculate the correct size and prefix: + $base = $this->isBinaryMode() ? self::BASE_BINARY : self::BASE_DECIMAL; + $power = floor(log($amount, $base)); + $prefix = $this->getPrefixAt((int)$power); + + // When the amount is too big, no prefix can be found: + if (is_null($prefix)) { + return $this->formatAmount($amount); + } + + // return formatted value: + $result = ($amount / pow($base, $power)); + $formatted = number_format($result, $this->getPrecision()); + return $this->formatAmount($formatted, $prefix); + } + + /** + * @param $amount + * @param null $prefix + * + * @return string + */ + protected function formatAmount($amount, $prefix = null) + { + return sprintf('%s %s%s', $amount, $prefix, $this->getUnit()); + } +} diff --git a/library/Zend/Filter/DateSelect.php b/library/Zend/Filter/DateSelect.php new file mode 100644 index 00000000..8d16217f --- /dev/null +++ b/library/Zend/Filter/DateSelect.php @@ -0,0 +1,25 @@ +isNullOnEmpty() + && ( + empty($value['year']) + || empty($value['month']) + || empty($value['day']) + || empty($value['hour']) + || empty($value['minute']) + || (isset($value['second']) && empty($value['second'])) + ) + ) { + return; + } + + if ($this->isNullOnAllEmpty() + && ( + empty($value['year']) + && empty($value['month']) + && empty($value['day']) + && empty($value['hour']) + && empty($value['minute']) + && (!isset($value['second']) || empty($value['second'])) + ) + ) { + // Cannot handle this value + return; + } + + if (! isset($value['second'])) { + $value['second'] = '00'; + } + + $this->filterable($value); + + ksort($value); + + $value = vsprintf($this->format, $value); + + return $value; + } +} diff --git a/library/Zend/Filter/Decompress.php b/library/Zend/Filter/Decompress.php index 3489c70c..44070009 100644 --- a/library/Zend/Filter/Decompress.php +++ b/library/Zend/Filter/Decompress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Decrypt.php b/library/Zend/Filter/Decrypt.php index 9c8e8492..aa2b7b66 100644 --- a/library/Zend/Filter/Decrypt.php +++ b/library/Zend/Filter/Decrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Digits.php b/library/Zend/Filter/Digits.php index c5e856fb..cb68407b 100644 --- a/library/Zend/Filter/Digits.php +++ b/library/Zend/Filter/Digits.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Dir.php b/library/Zend/Filter/Dir.php index 58bdb77d..c0ba268b 100644 --- a/library/Zend/Filter/Dir.php +++ b/library/Zend/Filter/Dir.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Encrypt.php b/library/Zend/Filter/Encrypt.php index adb13843..7a5152a7 100644 --- a/library/Zend/Filter/Encrypt.php +++ b/library/Zend/Filter/Encrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,9 +38,45 @@ class Encrypt extends AbstractFilter $this->setAdapter($options); } + /** + * Returns the adapter instance + * + * @throws Exception\RuntimeException + * @throws Exception\InvalidArgumentException + * @return Encrypt\EncryptionAlgorithmInterface + */ + public function getAdapterInstance() + { + if ($this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) { + return $this->adapter; + } + + $adapter = $this->adapter; + $options = $this->getOptions(); + if (! class_exists($adapter)) { + $adapter = __CLASS__ . '\\' . ucfirst($adapter); + if (! class_exists($adapter)) { + throw new Exception\RuntimeException(sprintf( + '%s unable to load adapter; class "%s" not found', + __METHOD__, + $this->adapter + )); + } + } + + $this->adapter = new $adapter($options); + if (! $this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) { + throw new Exception\InvalidArgumentException(sprintf( + 'Encryption adapter "%s" does not implement %s\\EncryptionAlgorithmInterface', + $adapter, + __CLASS__ + )); + } + return $this->adapter; + } + /** * Returns the name of the set adapter - * @todo inconsitent: get adapter should return the adapter and not the name * * @return string */ @@ -76,17 +112,20 @@ class Encrypt extends AbstractFilter $adapter = 'Zend\Filter\Encrypt\\' . ucfirst($adapter); } elseif (!class_exists($adapter)) { throw new Exception\DomainException( - sprintf('%s expects a valid registry class name; received "%s", which did not resolve', + sprintf( + '%s expects a valid registry class name; received "%s", which did not resolve', __METHOD__, $adapter - )); + ) + ); } $this->adapter = new $adapter($options); if (!$this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) { throw new Exception\InvalidArgumentException( "Encoding adapter '" . $adapter - . "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithmInterface"); + . "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithmInterface" + ); } return $this; @@ -120,7 +159,7 @@ class Encrypt extends AbstractFilter */ public function filter($value) { - if (!is_string($value)) { + if (!is_string($value) && !is_numeric($value)) { return $value; } diff --git a/library/Zend/Filter/Encrypt/BlockCipher.php b/library/Zend/Filter/Encrypt/BlockCipher.php index 5b7c1366..b51a608b 100644 --- a/library/Zend/Filter/Encrypt/BlockCipher.php +++ b/library/Zend/Filter/Encrypt/BlockCipher.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Encrypt/EncryptionAlgorithmInterface.php b/library/Zend/Filter/Encrypt/EncryptionAlgorithmInterface.php index faf0c518..31257bc3 100644 --- a/library/Zend/Filter/Encrypt/EncryptionAlgorithmInterface.php +++ b/library/Zend/Filter/Encrypt/EncryptionAlgorithmInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Encrypt/Openssl.php b/library/Zend/Filter/Encrypt/Openssl.php index 571f58cd..141e4a39 100644 --- a/library/Zend/Filter/Encrypt/Openssl.php +++ b/library/Zend/Filter/Encrypt/Openssl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Exception/BadMethodCallException.php b/library/Zend/Filter/Exception/BadMethodCallException.php index ae0d3f84..54bf4841 100644 --- a/library/Zend/Filter/Exception/BadMethodCallException.php +++ b/library/Zend/Filter/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Exception/DomainException.php b/library/Zend/Filter/Exception/DomainException.php index 4a37739b..8457b938 100644 --- a/library/Zend/Filter/Exception/DomainException.php +++ b/library/Zend/Filter/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Exception/ExceptionInterface.php b/library/Zend/Filter/Exception/ExceptionInterface.php index dd0be926..01392556 100644 --- a/library/Zend/Filter/Exception/ExceptionInterface.php +++ b/library/Zend/Filter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Exception/ExtensionNotLoadedException.php b/library/Zend/Filter/Exception/ExtensionNotLoadedException.php index 7a24b86c..ef383df4 100644 --- a/library/Zend/Filter/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Filter/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Exception/InvalidArgumentException.php b/library/Zend/Filter/Exception/InvalidArgumentException.php index 52b1c8ab..25d34607 100644 --- a/library/Zend/Filter/Exception/InvalidArgumentException.php +++ b/library/Zend/Filter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Exception/RuntimeException.php b/library/Zend/Filter/Exception/RuntimeException.php index d8b160be..7131d94c 100644 --- a/library/Zend/Filter/Exception/RuntimeException.php +++ b/library/Zend/Filter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/File/Decrypt.php b/library/Zend/Filter/File/Decrypt.php index 4d84fc3b..95f12bc8 100644 --- a/library/Zend/Filter/File/Decrypt.php +++ b/library/Zend/Filter/File/Decrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -74,7 +74,6 @@ class Decrypt extends Filter\Decrypt $value = $value['tmp_name']; } - if (!file_exists($value)) { throw new Exception\InvalidArgumentException("File '$value' not found"); } diff --git a/library/Zend/Filter/File/Encrypt.php b/library/Zend/Filter/File/Encrypt.php index 9e32b4ce..5638291a 100644 --- a/library/Zend/Filter/File/Encrypt.php +++ b/library/Zend/Filter/File/Encrypt.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/File/LowerCase.php b/library/Zend/Filter/File/LowerCase.php index 15d31482..b730355d 100644 --- a/library/Zend/Filter/File/LowerCase.php +++ b/library/Zend/Filter/File/LowerCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/File/Rename.php b/library/Zend/Filter/File/Rename.php index 4ea75c6b..8b04a429 100644 --- a/library/Zend/Filter/File/Rename.php +++ b/library/Zend/Filter/File/Rename.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -225,15 +225,15 @@ class Rename extends Filter\AbstractFilter $files['source'] = (string) $value; break; - case 'target' : + case 'target': $files['target'] = (string) $value; break; - case 'overwrite' : + case 'overwrite': $files['overwrite'] = (bool) $value; break; - case 'randomize' : + case 'randomize': $files['randomize'] = (bool) $value; break; diff --git a/library/Zend/Filter/File/RenameUpload.php b/library/Zend/Filter/File/RenameUpload.php index e0b5d0b5..52aacce3 100644 --- a/library/Zend/Filter/File/RenameUpload.php +++ b/library/Zend/Filter/File/RenameUpload.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -218,7 +218,8 @@ class RenameUpload extends AbstractFilter if (!$result || null !== $warningException) { throw new Exception\RuntimeException( sprintf("File '%s' could not be renamed. An error occurred while processing the file.", $sourceFile), - 0, $warningException + 0, + $warningException ); } diff --git a/library/Zend/Filter/File/UpperCase.php b/library/Zend/Filter/File/UpperCase.php index 22bf0927..fe2af6df 100644 --- a/library/Zend/Filter/File/UpperCase.php +++ b/library/Zend/Filter/File/UpperCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/FilterChain.php b/library/Zend/Filter/FilterChain.php index 5809b2eb..17ed93c5 100644 --- a/library/Zend/Filter/FilterChain.php +++ b/library/Zend/Filter/FilterChain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/FilterInterface.php b/library/Zend/Filter/FilterInterface.php index 2b3c1635..a3a0c410 100644 --- a/library/Zend/Filter/FilterInterface.php +++ b/library/Zend/Filter/FilterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/FilterPluginManager.php b/library/Zend/Filter/FilterPluginManager.php index 3cff6b46..7a3b24f7 100644 --- a/library/Zend/Filter/FilterPluginManager.php +++ b/library/Zend/Filter/FilterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,65 +20,87 @@ use Zend\ServiceManager\AbstractPluginManager; */ class FilterPluginManager extends AbstractPluginManager { + protected $aliases = array( + 'Zend\Filter\Int' => 'Zend\Filter\ToInt', + 'Zend\Filter\Null' => 'Zend\Filter\ToNull', + ); + + /** + * Default set of plugins factories + * + * @var array + */ + protected $factories = array( + 'wordseparatortoseparator' => 'Zend\Filter\Word\Service\SeparatorToSeparatorFactory', + ); + /** * Default set of filters * * @var array */ protected $invokableClasses = array( - 'alnum' => 'Zend\I18n\Filter\Alnum', - 'alpha' => 'Zend\I18n\Filter\Alpha', - 'basename' => 'Zend\Filter\BaseName', - 'boolean' => 'Zend\Filter\Boolean', - 'callback' => 'Zend\Filter\Callback', - 'compress' => 'Zend\Filter\Compress', - 'compressbz2' => 'Zend\Filter\Compress\Bz2', - 'compressgz' => 'Zend\Filter\Compress\Gz', - 'compresslzf' => 'Zend\Filter\Compress\Lzf', - 'compressrar' => 'Zend\Filter\Compress\Rar', - 'compresssnappy' => 'Zend\Filter\Compress\Snappy', - 'compresstar' => 'Zend\Filter\Compress\Tar', - 'compresszip' => 'Zend\Filter\Compress\Zip', - 'datetimeformatter' => 'Zend\Filter\DateTimeFormatter', - 'decompress' => 'Zend\Filter\Decompress', - 'decrypt' => 'Zend\Filter\Decrypt', - 'digits' => 'Zend\Filter\Digits', - 'dir' => 'Zend\Filter\Dir', - 'encrypt' => 'Zend\Filter\Encrypt', - 'encryptblockcipher' => 'Zend\Filter\Encrypt\BlockCipher', - 'encryptopenssl' => 'Zend\Filter\Encrypt\Openssl', - 'filedecrypt' => 'Zend\Filter\File\Decrypt', - 'fileencrypt' => 'Zend\Filter\File\Encrypt', - 'filelowercase' => 'Zend\Filter\File\LowerCase', - 'filerename' => 'Zend\Filter\File\Rename', - 'filerenameupload' => 'Zend\Filter\File\RenameUpload', - 'fileuppercase' => 'Zend\Filter\File\UpperCase', - 'htmlentities' => 'Zend\Filter\HtmlEntities', - 'inflector' => 'Zend\Filter\Inflector', - 'int' => 'Zend\Filter\Int', - 'null' => 'Zend\Filter\Null', - 'numberformat' => 'Zend\I18n\Filter\NumberFormat', - 'numberparse' => 'Zend\I18n\Filter\NumberParse', - 'pregreplace' => 'Zend\Filter\PregReplace', - 'realpath' => 'Zend\Filter\RealPath', - 'stringtolower' => 'Zend\Filter\StringToLower', - 'stringtoupper' => 'Zend\Filter\StringToUpper', - 'stringtrim' => 'Zend\Filter\StringTrim', - 'stripnewlines' => 'Zend\Filter\StripNewlines', - 'striptags' => 'Zend\Filter\StripTags', - 'urinormalize' => 'Zend\Filter\UriNormalize', - 'wordcamelcasetodash' => 'Zend\Filter\Word\CamelCaseToDash', - 'wordcamelcasetoseparator' => 'Zend\Filter\Word\CamelCaseToSeparator', - 'wordcamelcasetounderscore' => 'Zend\Filter\Word\CamelCaseToUnderscore', - 'worddashtocamelcase' => 'Zend\Filter\Word\DashToCamelCase', - 'worddashtoseparator' => 'Zend\Filter\Word\DashToSeparator', - 'worddashtounderscore' => 'Zend\Filter\Word\DashToUnderscore', - 'wordseparatortocamelcase' => 'Zend\Filter\Word\SeparatorToCamelCase', - 'wordseparatortodash' => 'Zend\Filter\Word\SeparatorToDash', - 'wordseparatortoseparator' => 'Zend\Filter\Word\SeparatorToSeparator', - 'wordunderscoretocamelcase' => 'Zend\Filter\Word\UnderscoreToCamelCase', - 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', - 'wordunderscoretoseparator' => 'Zend\Filter\Word\UnderscoreToSeparator', + 'alnum' => 'Zend\I18n\Filter\Alnum', + 'alpha' => 'Zend\I18n\Filter\Alpha', + 'basename' => 'Zend\Filter\BaseName', + 'blacklist' => 'Zend\Filter\Blacklist', + 'boolean' => 'Zend\Filter\Boolean', + 'callback' => 'Zend\Filter\Callback', + 'compress' => 'Zend\Filter\Compress', + 'compressbz2' => 'Zend\Filter\Compress\Bz2', + 'compressgz' => 'Zend\Filter\Compress\Gz', + 'compresslzf' => 'Zend\Filter\Compress\Lzf', + 'compressrar' => 'Zend\Filter\Compress\Rar', + 'compresssnappy' => 'Zend\Filter\Compress\Snappy', + 'compresstar' => 'Zend\Filter\Compress\Tar', + 'compresszip' => 'Zend\Filter\Compress\Zip', + 'dataunitformatter' => 'Zend\Filter\DataUnitFormatter', + 'dateselect' => 'Zend\Filter\DateSelect', + 'datetimeformatter' => 'Zend\Filter\DateTimeFormatter', + 'datetimeselect' => 'Zend\Filter\DateTimeSelect', + 'decompress' => 'Zend\Filter\Decompress', + 'decrypt' => 'Zend\Filter\Decrypt', + 'digits' => 'Zend\Filter\Digits', + 'dir' => 'Zend\Filter\Dir', + 'encrypt' => 'Zend\Filter\Encrypt', + 'encryptblockcipher' => 'Zend\Filter\Encrypt\BlockCipher', + 'encryptopenssl' => 'Zend\Filter\Encrypt\Openssl', + 'filedecrypt' => 'Zend\Filter\File\Decrypt', + 'fileencrypt' => 'Zend\Filter\File\Encrypt', + 'filelowercase' => 'Zend\Filter\File\LowerCase', + 'filerename' => 'Zend\Filter\File\Rename', + 'filerenameupload' => 'Zend\Filter\File\RenameUpload', + 'fileuppercase' => 'Zend\Filter\File\UpperCase', + 'htmlentities' => 'Zend\Filter\HtmlEntities', + 'inflector' => 'Zend\Filter\Inflector', + 'int' => 'Zend\Filter\ToInt', + 'monthselect' => 'Zend\Filter\MonthSelect', + 'null' => 'Zend\Filter\ToNull', + 'numberformat' => 'Zend\I18n\Filter\NumberFormat', + 'numberparse' => 'Zend\I18n\Filter\NumberParse', + 'pregreplace' => 'Zend\Filter\PregReplace', + 'realpath' => 'Zend\Filter\RealPath', + 'stringtolower' => 'Zend\Filter\StringToLower', + 'stringtoupper' => 'Zend\Filter\StringToUpper', + 'stringtrim' => 'Zend\Filter\StringTrim', + 'stripnewlines' => 'Zend\Filter\StripNewlines', + 'striptags' => 'Zend\Filter\StripTags', + 'toint' => 'Zend\Filter\ToInt', + 'tonull' => 'Zend\Filter\ToNull', + 'urinormalize' => 'Zend\Filter\UriNormalize', + 'whitelist' => 'Zend\Filter\Whitelist', + 'wordcamelcasetodash' => 'Zend\Filter\Word\CamelCaseToDash', + 'wordcamelcasetoseparator' => 'Zend\Filter\Word\CamelCaseToSeparator', + 'wordcamelcasetounderscore' => 'Zend\Filter\Word\CamelCaseToUnderscore', + 'worddashtocamelcase' => 'Zend\Filter\Word\DashToCamelCase', + 'worddashtoseparator' => 'Zend\Filter\Word\DashToSeparator', + 'worddashtounderscore' => 'Zend\Filter\Word\DashToUnderscore', + 'wordseparatortocamelcase' => 'Zend\Filter\Word\SeparatorToCamelCase', + 'wordseparatortodash' => 'Zend\Filter\Word\SeparatorToDash', + 'wordunderscoretocamelcase' => 'Zend\Filter\Word\UnderscoreToCamelCase', + 'wordunderscoretostudlycase' => 'Zend\Filter\Word\UnderscoreToStudlyCase', + 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', + 'wordunderscoretoseparator' => 'Zend\Filter\Word\UnderscoreToSeparator', ); /** diff --git a/library/Zend/Filter/HtmlEntities.php b/library/Zend/Filter/HtmlEntities.php index 2abff010..a77ba6ed 100644 --- a/library/Zend/Filter/HtmlEntities.php +++ b/library/Zend/Filter/HtmlEntities.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -97,7 +97,6 @@ class HtmlEntities extends AbstractFilter return $this; } - /** * Get encoding * diff --git a/library/Zend/Filter/Inflector.php b/library/Zend/Filter/Inflector.php index 4120a68f..a6bffdaa 100644 --- a/library/Zend/Filter/Inflector.php +++ b/library/Zend/Filter/Inflector.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -152,7 +152,7 @@ class Inflector extends AbstractFilter */ public function setThrowTargetExceptionsOn($throwTargetExceptionsOn) { - $this->throwTargetExceptionsOn = ($throwTargetExceptionsOn == true) ? true : false; + $this->throwTargetExceptionsOn = (bool) $throwTargetExceptionsOn; return $this; } diff --git a/library/Zend/Filter/Int.php b/library/Zend/Filter/Int.php index 0f2b80db..a65b8d14 100644 --- a/library/Zend/Filter/Int.php +++ b/library/Zend/Filter/Int.php @@ -3,31 +3,33 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Filter; -class Int extends AbstractFilter +/** + * Stub class for backwards compatibility. + * + * Since PHP 7 adds "int" as a reserved keyword, we can no longer have a class + * named that and retain PHP 7 compatibility. The original class has been + * renamed to "ToInt", and this class is now an extension of it. It raises an + * E_USER_DEPRECATED to warn users to migrate. + * + * @deprecated + */ +class Int extends ToInt { - /** - * Defined by Zend\Filter\FilterInterface - * - * Returns (int) $value - * - * If the value provided is non-scalar, the value will remain unfiltered - * - * @param string $value - * @return int|mixed - */ - public function filter($value) + public function __construct() { - if (!is_scalar($value)) { - return $value; - } - $value = (string) $value; - - return (int) $value; + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\ToInt', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); } } diff --git a/library/Zend/Filter/MonthSelect.php b/library/Zend/Filter/MonthSelect.php new file mode 100644 index 00000000..450aafbd --- /dev/null +++ b/library/Zend/Filter/MonthSelect.php @@ -0,0 +1,25 @@ + 'boolean', - self::TYPE_INTEGER => 'integer', - self::TYPE_EMPTY_ARRAY => 'array', - self::TYPE_STRING => 'string', - self::TYPE_ZERO_STRING => 'zero', - self::TYPE_FLOAT => 'float', - self::TYPE_ALL => 'all', - ); - - /** - * @var array - */ - protected $options = array( - 'type' => self::TYPE_ALL, - ); - - /** - * Constructor - * - * @param string|array|Traversable $typeOrOptions OPTIONAL + * {@inheritdoc} */ public function __construct($typeOrOptions = null) { - if ($typeOrOptions !== null) { - if ($typeOrOptions instanceof Traversable) { - $typeOrOptions = iterator_to_array($typeOrOptions); - } + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\ToNull', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); - if (is_array($typeOrOptions)) { - if (isset($typeOrOptions['type'])) { - $this->setOptions($typeOrOptions); - } else { - $this->setType($typeOrOptions); - } - } else { - $this->setType($typeOrOptions); - } - } - } - - /** - * Set boolean types - * - * @param int|array $type - * @throws Exception\InvalidArgumentException - * @return self - */ - public function setType($type = null) - { - if (is_array($type)) { - $detected = 0; - foreach ($type as $value) { - if (is_int($value)) { - $detected += $value; - } elseif (in_array($value, $this->constants)) { - $detected += array_search($value, $this->constants); - } - } - - $type = $detected; - } elseif (is_string($type) && in_array($type, $this->constants)) { - $type = array_search($type, $this->constants); - } - - if (!is_int($type) || ($type < 0) || ($type > self::TYPE_ALL)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Unknown type value "%s" (%s)', - $type, - gettype($type) - )); - } - - $this->options['type'] = $type; - return $this; - } - - /** - * Returns defined boolean types - * - * @return int - */ - public function getType() - { - return $this->options['type']; - } - - /** - * Defined by Zend\Filter\FilterInterface - * - * Returns null representation of $value, if value is empty and matches - * types that should be considered null. - * - * @param string $value - * @return string - */ - public function filter($value) - { - $type = $this->getType(); - - // FLOAT (0.0) - if ($type >= self::TYPE_FLOAT) { - $type -= self::TYPE_FLOAT; - if (is_float($value) && ($value == 0.0)) { - return null; - } - } - - // STRING ZERO ('0') - if ($type >= self::TYPE_ZERO_STRING) { - $type -= self::TYPE_ZERO_STRING; - if (is_string($value) && ($value == '0')) { - return null; - } - } - - // STRING ('') - if ($type >= self::TYPE_STRING) { - $type -= self::TYPE_STRING; - if (is_string($value) && ($value == '')) { - return null; - } - } - - // EMPTY_ARRAY (array()) - if ($type >= self::TYPE_EMPTY_ARRAY) { - $type -= self::TYPE_EMPTY_ARRAY; - if (is_array($value) && ($value == array())) { - return null; - } - } - - // INTEGER (0) - if ($type >= self::TYPE_INTEGER) { - $type -= self::TYPE_INTEGER; - if (is_int($value) && ($value == 0)) { - return null; - } - } - - // BOOLEAN (false) - if ($type >= self::TYPE_BOOLEAN) { - $type -= self::TYPE_BOOLEAN; - if (is_bool($value) && ($value == false)) { - return null; - } - } - - return $value; + parent::__construct($typeOrOptions); } } diff --git a/library/Zend/Filter/PregReplace.php b/library/Zend/Filter/PregReplace.php index 9a7e3f3a..5eeb9476 100644 --- a/library/Zend/Filter/PregReplace.php +++ b/library/Zend/Filter/PregReplace.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,9 +32,7 @@ class PregReplace extends AbstractFilter $options = iterator_to_array($options); } - if (!is_array($options) - || (!isset($options['pattern']) && !isset($options['replacement'])) - ) { + if (!is_array($options) || (!isset($options['pattern']) && !isset($options['replacement']))) { $args = func_get_args(); if (isset($args[0])) { $this->setPattern($args[0]); diff --git a/library/Zend/Filter/RealPath.php b/library/Zend/Filter/RealPath.php index 00633d5c..9a205327 100644 --- a/library/Zend/Filter/RealPath.php +++ b/library/Zend/Filter/RealPath.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/StaticFilter.php b/library/Zend/Filter/StaticFilter.php index 2847137b..aeb5c104 100644 --- a/library/Zend/Filter/StaticFilter.php +++ b/library/Zend/Filter/StaticFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/StringToLower.php b/library/Zend/Filter/StringToLower.php index 3d6f66a4..0a5042da 100644 --- a/library/Zend/Filter/StringToLower.php +++ b/library/Zend/Filter/StringToLower.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -53,8 +53,8 @@ class StringToLower extends AbstractUnicode } $value = (string) $value; - if ($this->options['encoding'] !== null) { - return mb_strtolower($value, $this->options['encoding']); + if (null !== $this->getEncoding()) { + return mb_strtolower($value, $this->options['encoding']); } return strtolower($value); diff --git a/library/Zend/Filter/StringToUpper.php b/library/Zend/Filter/StringToUpper.php index 7f4c78e1..33be1d54 100644 --- a/library/Zend/Filter/StringToUpper.php +++ b/library/Zend/Filter/StringToUpper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -53,8 +53,8 @@ class StringToUpper extends AbstractUnicode } $value = (string) $value; - if ($this->options['encoding'] !== null) { - return mb_strtoupper($value, $this->options['encoding']); + if (null !== $this->getEncoding()) { + return mb_strtoupper($value, $this->options['encoding']); } return strtoupper($value); diff --git a/library/Zend/Filter/StringTrim.php b/library/Zend/Filter/StringTrim.php index 2eae7fa3..4ec0e6ce 100644 --- a/library/Zend/Filter/StringTrim.php +++ b/library/Zend/Filter/StringTrim.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,9 +28,7 @@ class StringTrim extends AbstractFilter public function __construct($charlistOrOptions = null) { if ($charlistOrOptions !== null) { - if (!is_array($charlistOrOptions) - && !$charlistOrOptions instanceof Traversable - ) { + if (!is_array($charlistOrOptions) && !$charlistOrOptions instanceof Traversable) { $this->setCharList($charlistOrOptions); } else { $this->setOptions($charlistOrOptions); diff --git a/library/Zend/Filter/StripNewlines.php b/library/Zend/Filter/StripNewlines.php index 481facaa..dcf4a1ea 100644 --- a/library/Zend/Filter/StripNewlines.php +++ b/library/Zend/Filter/StripNewlines.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/StripTags.php b/library/Zend/Filter/StripTags.php index 7caf4605..24cc346f 100644 --- a/library/Zend/Filter/StripTags.php +++ b/library/Zend/Filter/StripTags.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -105,9 +105,8 @@ class StripTags extends AbstractFilter $tagName = strtolower($element); // Store the tag as allowed with no attributes $this->tagsAllowed[$tagName] = array(); - } - // Otherwise, if a tag was provided with attributes - elseif (is_string($index) && (is_array($element) || is_string($element))) { + } elseif (is_string($index) && (is_array($element) || is_string($element))) { + // Otherwise, if a tag was provided with attributes // Canonicalize the tag name $tagName = strtolower($index); // Canonicalize the attributes @@ -189,7 +188,7 @@ class StripTags extends AbstractFilter if (!preg_match('/--\s*>/s', $value)) { $value = ''; } else { - $value = preg_replace('/<(?:!(?:--[\s\S]*?--\s*)?(>))/s', '', $value); + $value = preg_replace('/<(?:!(?:--[\s\S]*?--\s*)?(>))/s', '', $value); } $value = $start . $value; diff --git a/library/Zend/Filter/ToInt.php b/library/Zend/Filter/ToInt.php new file mode 100644 index 00000000..8d9b79a9 --- /dev/null +++ b/library/Zend/Filter/ToInt.php @@ -0,0 +1,33 @@ + 'boolean', + self::TYPE_INTEGER => 'integer', + self::TYPE_EMPTY_ARRAY => 'array', + self::TYPE_STRING => 'string', + self::TYPE_ZERO_STRING => 'zero', + self::TYPE_FLOAT => 'float', + self::TYPE_ALL => 'all', + ); + + /** + * @var array + */ + protected $options = array( + 'type' => self::TYPE_ALL, + ); + + /** + * Constructor + * + * @param string|array|Traversable $typeOrOptions OPTIONAL + */ + public function __construct($typeOrOptions = null) + { + if ($typeOrOptions !== null) { + if ($typeOrOptions instanceof Traversable) { + $typeOrOptions = iterator_to_array($typeOrOptions); + } + + if (is_array($typeOrOptions)) { + if (isset($typeOrOptions['type'])) { + $this->setOptions($typeOrOptions); + } else { + $this->setType($typeOrOptions); + } + } else { + $this->setType($typeOrOptions); + } + } + } + + /** + * Set boolean types + * + * @param int|array $type + * @throws Exception\InvalidArgumentException + * @return self + */ + public function setType($type = null) + { + if (is_array($type)) { + $detected = 0; + foreach ($type as $value) { + if (is_int($value)) { + $detected += $value; + } elseif (in_array($value, $this->constants)) { + $detected += array_search($value, $this->constants); + } + } + + $type = $detected; + } elseif (is_string($type) && in_array($type, $this->constants)) { + $type = array_search($type, $this->constants); + } + + if (!is_int($type) || ($type < 0) || ($type > self::TYPE_ALL)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Unknown type value "%s" (%s)', + $type, + gettype($type) + )); + } + + $this->options['type'] = $type; + return $this; + } + + /** + * Returns defined boolean types + * + * @return int + */ + public function getType() + { + return $this->options['type']; + } + + /** + * Defined by Zend\Filter\FilterInterface + * + * Returns null representation of $value, if value is empty and matches + * types that should be considered null. + * + * @param string $value + * @return string + */ + public function filter($value) + { + $type = $this->getType(); + + // FLOAT (0.0) + if ($type >= self::TYPE_FLOAT) { + $type -= self::TYPE_FLOAT; + if (is_float($value) && ($value == 0.0)) { + return; + } + } + + // STRING ZERO ('0') + if ($type >= self::TYPE_ZERO_STRING) { + $type -= self::TYPE_ZERO_STRING; + if (is_string($value) && ($value == '0')) { + return; + } + } + + // STRING ('') + if ($type >= self::TYPE_STRING) { + $type -= self::TYPE_STRING; + if (is_string($value) && ($value == '')) { + return; + } + } + + // EMPTY_ARRAY (array()) + if ($type >= self::TYPE_EMPTY_ARRAY) { + $type -= self::TYPE_EMPTY_ARRAY; + if (is_array($value) && ($value == array())) { + return; + } + } + + // INTEGER (0) + if ($type >= self::TYPE_INTEGER) { + $type -= self::TYPE_INTEGER; + if (is_int($value) && ($value == 0)) { + return; + } + } + + // BOOLEAN (false) + if ($type >= self::TYPE_BOOLEAN) { + $type -= self::TYPE_BOOLEAN; + if (is_bool($value) && ($value == false)) { + return; + } + } + + return $value; + } +} diff --git a/library/Zend/Filter/UpperCaseWords.php b/library/Zend/Filter/UpperCaseWords.php new file mode 100644 index 00000000..0bcdeee4 --- /dev/null +++ b/library/Zend/Filter/UpperCaseWords.php @@ -0,0 +1,61 @@ + null + ); + + /** + * Constructor + * + * @param string|array|\Traversable $encodingOrOptions OPTIONAL + */ + public function __construct($encodingOrOptions = null) + { + if ($encodingOrOptions !== null) { + if (static::isOptions($encodingOrOptions)) { + $this->setOptions($encodingOrOptions); + } else { + $this->setEncoding($encodingOrOptions); + } + } + } + + /** + * {@inheritDoc} + * + * Returns the string $value, converting words to have an uppercase first character as necessary + * + * If the value provided is not a string, the value will remain unfiltered + * + * @param string|mixed $value + * @return string|mixed + */ + public function filter($value) + { + if (! is_string($value)) { + return $value; + } + + $value = (string) $value; + + if ($this->options['encoding'] !== null) { + return mb_convert_case($value, MB_CASE_TITLE, $this->options['encoding']); + } + + return ucwords(strtolower($value)); + } +} diff --git a/library/Zend/Filter/UriNormalize.php b/library/Zend/Filter/UriNormalize.php index 0ab20152..894f673f 100644 --- a/library/Zend/Filter/UriNormalize.php +++ b/library/Zend/Filter/UriNormalize.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Whitelist.php b/library/Zend/Filter/Whitelist.php new file mode 100644 index 00000000..fafb6eb7 --- /dev/null +++ b/library/Zend/Filter/Whitelist.php @@ -0,0 +1,91 @@ +setOptions($options); + } + } + + /** + * Determine whether the in_array() call should be "strict" or not. See in_array docs. + * + * @param bool $strict + */ + public function setStrict($strict = true) + { + $this->strict = (bool) $strict; + } + + /** + * Returns whether the in_array() call should be "strict" or not. See in_array docs. + * + * @return boolean + */ + public function getStrict() + { + return $this->strict; + } + + /** + * Set the list of items to white-list. + * + * @param array|Traversable $list + */ + public function setList($list = array()) + { + if (!is_array($list)) { + $list = ArrayUtils::iteratorToArray($list); + } + + $this->list = $list; + } + + + /** + * Get the list of items to white-list + * + * @return array + */ + public function getList() + { + return $this->list; + } + + /** + * {@inheritDoc} + * + * Will return $value if its present in the white-list. If $value is rejected then it will return null. + */ + public function filter($value) + { + return in_array($value, $this->getList(), $this->getStrict()) ? $value : null; + } +} diff --git a/library/Zend/Filter/Word/AbstractSeparator.php b/library/Zend/Filter/Word/AbstractSeparator.php index 598b0a0b..9c2e71c0 100644 --- a/library/Zend/Filter/Word/AbstractSeparator.php +++ b/library/Zend/Filter/Word/AbstractSeparator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/CamelCaseToDash.php b/library/Zend/Filter/Word/CamelCaseToDash.php index f2d1c346..ce31683b 100644 --- a/library/Zend/Filter/Word/CamelCaseToDash.php +++ b/library/Zend/Filter/Word/CamelCaseToDash.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/CamelCaseToSeparator.php b/library/Zend/Filter/Word/CamelCaseToSeparator.php index 0a06586b..e6addca6 100644 --- a/library/Zend/Filter/Word/CamelCaseToSeparator.php +++ b/library/Zend/Filter/Word/CamelCaseToSeparator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/CamelCaseToUnderscore.php b/library/Zend/Filter/Word/CamelCaseToUnderscore.php index fb28b6c5..82507847 100644 --- a/library/Zend/Filter/Word/CamelCaseToUnderscore.php +++ b/library/Zend/Filter/Word/CamelCaseToUnderscore.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/DashToCamelCase.php b/library/Zend/Filter/Word/DashToCamelCase.php index 4d211a01..6bf36f87 100644 --- a/library/Zend/Filter/Word/DashToCamelCase.php +++ b/library/Zend/Filter/Word/DashToCamelCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/DashToSeparator.php b/library/Zend/Filter/Word/DashToSeparator.php index 086aaa2b..856d3c2d 100644 --- a/library/Zend/Filter/Word/DashToSeparator.php +++ b/library/Zend/Filter/Word/DashToSeparator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/DashToUnderscore.php b/library/Zend/Filter/Word/DashToUnderscore.php index b7d56941..104dedc3 100644 --- a/library/Zend/Filter/Word/DashToUnderscore.php +++ b/library/Zend/Filter/Word/DashToUnderscore.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/SeparatorToCamelCase.php b/library/Zend/Filter/Word/SeparatorToCamelCase.php index 2804570b..931997b0 100644 --- a/library/Zend/Filter/Word/SeparatorToCamelCase.php +++ b/library/Zend/Filter/Word/SeparatorToCamelCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,8 +30,8 @@ class SeparatorToCamelCase extends AbstractSeparator if (StringUtils::hasPcreUnicodeSupport()) { $patterns = array( - '#(' . $pregQuotedSeparator.')(\p{L}{1})#u', - '#(^\p{Ll}{1})#u', + '#(' . $pregQuotedSeparator.')(\P{Z}{1})#u', + '#(^\P{Z}{1})#u', ); if (!extension_loaded('mbstring')) { $replacements = array( @@ -54,8 +54,8 @@ class SeparatorToCamelCase extends AbstractSeparator } } else { $patterns = array( - '#(' . $pregQuotedSeparator.')([A-Za-z]{1})#', - '#(^[A-Za-z]{1})#', + '#(' . $pregQuotedSeparator.')([\S]{1})#', + '#(^[\S]{1})#', ); $replacements = array( function ($matches) { diff --git a/library/Zend/Filter/Word/SeparatorToDash.php b/library/Zend/Filter/Word/SeparatorToDash.php index 3558a75b..d9da74d3 100644 --- a/library/Zend/Filter/Word/SeparatorToDash.php +++ b/library/Zend/Filter/Word/SeparatorToDash.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/SeparatorToSeparator.php b/library/Zend/Filter/Word/SeparatorToSeparator.php index ed5b50f7..5f0ffd13 100644 --- a/library/Zend/Filter/Word/SeparatorToSeparator.php +++ b/library/Zend/Filter/Word/SeparatorToSeparator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -87,7 +87,7 @@ class SeparatorToSeparator extends AbstractFilter 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.'); } diff --git a/library/Zend/Filter/Word/Service/SeparatorToSeparatorFactory.php b/library/Zend/Filter/Word/Service/SeparatorToSeparatorFactory.php new file mode 100644 index 00000000..148ac3b0 --- /dev/null +++ b/library/Zend/Filter/Word/Service/SeparatorToSeparatorFactory.php @@ -0,0 +1,53 @@ +creationOptions = $creationOptions; + } + + /** + * Get creation options + * + * @return array + */ + public function getCreationOptions() + { + return $this->creationOptions; + } + + /** + * {@inheritDoc} + * + * @return SeparatorToSeparator + * @throws ServiceNotCreatedException if Controllermanager service is not found in application service locator + */ + public function createService(ServiceLocatorInterface $plugins) + { + return new SeparatorToSeparator( + isset($this->creationOptions['search_separator']) ? $this->creationOptions['search_separator'] : ' ', + isset($this->creationOptions['replacement_separator']) ? $this->creationOptions['replacement_separator'] : '-' + ); + } +} diff --git a/library/Zend/Filter/Word/UnderscoreToCamelCase.php b/library/Zend/Filter/Word/UnderscoreToCamelCase.php index fc9c5138..0c6c5be6 100644 --- a/library/Zend/Filter/Word/UnderscoreToCamelCase.php +++ b/library/Zend/Filter/Word/UnderscoreToCamelCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/UnderscoreToDash.php b/library/Zend/Filter/Word/UnderscoreToDash.php index 1a39ebec..816d3557 100644 --- a/library/Zend/Filter/Word/UnderscoreToDash.php +++ b/library/Zend/Filter/Word/UnderscoreToDash.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/UnderscoreToSeparator.php b/library/Zend/Filter/Word/UnderscoreToSeparator.php index 86d35a28..0d55ca4e 100644 --- a/library/Zend/Filter/Word/UnderscoreToSeparator.php +++ b/library/Zend/Filter/Word/UnderscoreToSeparator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Filter/Word/UnderscoreToStudlyCase.php b/library/Zend/Filter/Word/UnderscoreToStudlyCase.php new file mode 100644 index 00000000..21a9ec1a --- /dev/null +++ b/library/Zend/Filter/Word/UnderscoreToStudlyCase.php @@ -0,0 +1,36 @@ +=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -30,8 +29,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Form/Annotation/AbstractAnnotationsListener.php b/library/Zend/Form/Annotation/AbstractAnnotationsListener.php index 62685edc..acdae220 100644 --- a/library/Zend/Form/Annotation/AbstractAnnotationsListener.php +++ b/library/Zend/Form/Annotation/AbstractAnnotationsListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/AbstractArrayAnnotation.php b/library/Zend/Form/Annotation/AbstractArrayAnnotation.php index d6d8b315..87c28971 100644 --- a/library/Zend/Form/Annotation/AbstractArrayAnnotation.php +++ b/library/Zend/Form/Annotation/AbstractArrayAnnotation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/AbstractArrayOrStringAnnotation.php b/library/Zend/Form/Annotation/AbstractArrayOrStringAnnotation.php index 04e3733a..221f57be 100644 --- a/library/Zend/Form/Annotation/AbstractArrayOrStringAnnotation.php +++ b/library/Zend/Form/Annotation/AbstractArrayOrStringAnnotation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/AbstractStringAnnotation.php b/library/Zend/Form/Annotation/AbstractStringAnnotation.php index a327ae5c..b8e8c897 100644 --- a/library/Zend/Form/Annotation/AbstractStringAnnotation.php +++ b/library/Zend/Form/Annotation/AbstractStringAnnotation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/AllowEmpty.php b/library/Zend/Form/Annotation/AllowEmpty.php index eb3a0b70..be58287c 100644 --- a/library/Zend/Form/Annotation/AllowEmpty.php +++ b/library/Zend/Form/Annotation/AllowEmpty.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -18,6 +18,7 @@ use Zend\Filter\Boolean as BooleanFilter; * \Zend\InputFilter\Input should enable the allowEmpty flag. * * @Annotation + * @deprecated 2.4.8 Use `@Validator({"name":"NotEmpty"})` instead. */ class AllowEmpty { diff --git a/library/Zend/Form/Annotation/AnnotationBuilder.php b/library/Zend/Form/Annotation/AnnotationBuilder.php index a7e09521..01406074 100644 --- a/library/Zend/Form/Annotation/AnnotationBuilder.php +++ b/library/Zend/Form/Annotation/AnnotationBuilder.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Form\Annotation; use ArrayObject; -use ReflectionClass; use Zend\Code\Annotation\AnnotationCollection; use Zend\Code\Annotation\AnnotationManager; use Zend\Code\Annotation\Parser; @@ -25,11 +24,16 @@ use Zend\Form\FormFactoryAwareInterface; use Zend\Stdlib\ArrayUtils; /** - * Parses a class' properties for annotations in order to create a form and - * input filter definition. + * Parses the properties of a class for annotations in order to create a form + * and input filter definition. */ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareInterface { + /** + * @var Parser\DoctrineAnnotationParser + */ + protected $annotationParser; + /** * @var AnnotationManager */ @@ -57,6 +61,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI 'AllowEmpty', 'Attributes', 'ComposedObject', + 'ContinueIfEmpty', 'ErrorMessage', 'Exclude', 'Filter', @@ -64,6 +69,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI 'Hydrator', 'Input', 'InputFilter', + 'Instance', 'Name', 'Object', 'Options', @@ -73,6 +79,11 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI 'Validator' ); + /** + * @var bool + */ + protected $preserveDefinedOrder = false; + /** * Set form factory to use when building form from annotations * @@ -93,7 +104,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI */ public function setAnnotationManager(AnnotationManager $annotationManager) { - $parser = new Parser\DoctrineAnnotationParser(); + $parser = $this->getAnnotationParser(); foreach ($this->defaultAnnotations as $annotationName) { $class = __NAMESPACE__ . '\\' . $annotationName; $parser->registerAnnotation($class); @@ -215,6 +226,8 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI if (!isset($formSpec['input_filter'])) { $formSpec['input_filter'] = $filterSpec; + } elseif (is_array($formSpec['input_filter'])) { + $formSpec['input_filter'] = ArrayUtils::merge($filterSpec->getArrayCopy(), $formSpec['input_filter']); } return $formSpec; @@ -334,8 +347,9 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI ? $elementSpec['spec']['type'] : 'Zend\Form\Element'; - // Compose as a fieldset or an element, based on specification type - if (static::isSubclassOf($type, 'Zend\Form\FieldsetInterface')) { + // Compose as a fieldset or an element, based on specification type. + // If preserve defined order is true, all elements are composed as elements to keep their ordering + if (!$this->preserveDefinedOrder() && is_subclass_of($type, 'Zend\Form\FieldsetInterface')) { if (!isset($formSpec['fieldsets'])) { $formSpec['fieldsets'] = array(); } @@ -348,6 +362,24 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI } } + /** + * @param bool $preserveDefinedOrder + * @return $this + */ + public function setPreserveDefinedOrder($preserveDefinedOrder) + { + $this->preserveDefinedOrder = (bool) $preserveDefinedOrder; + return $this; + } + + /** + * @return bool + */ + public function preserveDefinedOrder() + { + return $this->preserveDefinedOrder; + } + /** * Discover the name of the given form or element * @@ -382,28 +414,32 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI return (bool) $results->last(); } + /** + * @return \Zend\Code\Annotation\Parser\DoctrineAnnotationParser + */ + public function getAnnotationParser() + { + if (null === $this->annotationParser) { + $this->annotationParser = new Parser\DoctrineAnnotationParser(); + } + + return $this->annotationParser; + } + /** * Checks if the object has this class as one of its parents * * @see https://bugs.php.net/bug.php?id=53727 * @see https://github.com/zendframework/zf2/pull/1807 * + * @deprecated since zf 2.3 requires PHP >= 5.3.23 + * * @param string $className * @param string $type * @return bool */ protected static function isSubclassOf($className, $type) { - if (is_subclass_of($className, $type)) { - return true; - } - if (PHP_VERSION_ID >= 50307) { - return false; - } - if (!interface_exists($type)) { - return false; - } - $r = new ReflectionClass($className); - return $r->implementsInterface($type); + return is_subclass_of($className, $type); } } diff --git a/library/Zend/Form/Annotation/Attributes.php b/library/Zend/Form/Annotation/Attributes.php index 2a6398f5..db4c5bc5 100644 --- a/library/Zend/Form/Annotation/Attributes.php +++ b/library/Zend/Form/Annotation/Attributes.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/ComposedObject.php b/library/Zend/Form/Annotation/ComposedObject.php index 5aa73642..b8649f99 100644 --- a/library/Zend/Form/Annotation/ComposedObject.php +++ b/library/Zend/Form/Annotation/ComposedObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/ContinueIfEmpty.php b/library/Zend/Form/Annotation/ContinueIfEmpty.php new file mode 100644 index 00000000..031f5844 --- /dev/null +++ b/library/Zend/Form/Annotation/ContinueIfEmpty.php @@ -0,0 +1,58 @@ +filter($continueIfEmpty); + } + + $this->continueIfEmpty = $continueIfEmpty; + } + + /** + * Get value of required flag + * + * @return bool + */ + public function getContinueIfEmpty() + { + return $this->continueIfEmpty; + } +} diff --git a/library/Zend/Form/Annotation/ElementAnnotationsListener.php b/library/Zend/Form/Annotation/ElementAnnotationsListener.php index e751f6db..93e1f2fe 100644 --- a/library/Zend/Form/Annotation/ElementAnnotationsListener.php +++ b/library/Zend/Form/Annotation/ElementAnnotationsListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,7 +25,7 @@ use Zend\Stdlib\ArrayObject; * - Flags * - Input * - Hydrator - * - Object + * - Object and Instance (the latter is preferred starting in 2.4) * - Required * - Type * - Validator @@ -44,6 +44,7 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener $this->listeners[] = $events->attach('configureElement', array($this, 'handleAllowEmptyAnnotation')); $this->listeners[] = $events->attach('configureElement', array($this, 'handleAttributesAnnotation')); $this->listeners[] = $events->attach('configureElement', array($this, 'handleComposedObjectAnnotation')); + $this->listeners[] = $events->attach('configureElement', array($this, 'handleContinueIfEmptyAnnotation')); $this->listeners[] = $events->attach('configureElement', array($this, 'handleErrorMessageAnnotation')); $this->listeners[] = $events->attach('configureElement', array($this, 'handleFilterAnnotation')); $this->listeners[] = $events->attach('configureElement', array($this, 'handleFlagsAnnotation')); @@ -97,7 +98,10 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener $elementSpec = $e->getParam('elementSpec'); if (isset($elementSpec['spec']['attributes'])) { - $elementSpec['spec']['attributes'] = array_merge($elementSpec['spec']['attributes'], $annotation->getAttributes()); + $elementSpec['spec']['attributes'] = array_merge( + $elementSpec['spec']['attributes'], + $annotation->getAttributes() + ); return; } @@ -123,7 +127,6 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener $name = $e->getParam('name'); $elementSpec = $e->getParam('elementSpec'); - $filterSpec = $e->getParam('filterSpec'); if ($annotation->isCollection()) { // Compose specification as a fieldset into parent form/fieldset @@ -142,7 +145,7 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener $elementSpec['spec']['type'] = 'Zend\Form\Element\Collection'; $elementSpec['spec']['name'] = $name; - $elementSpec['spec']['options'] = new ArrayObject($annotation->getOptions()); + $elementSpec['spec']['options'] = new ArrayObject($this->mergeOptions($elementSpec, $annotation)); $elementSpec['spec']['options']['target_element'] = $specification; $elementSpec['spec']['options']['target_element']['options']['input_filter_spec'] = $inputFilter; @@ -163,17 +166,37 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener $specification['type'] = 'Zend\Form\Fieldset'; } - // Merge options of composed object with the ones of the target object: - $options = (isset($elementSpec['spec']['options']) && is_array($elementSpec['spec']['options'])) ? $elementSpec['spec']['options'] : array(); - $options = array_merge($options, $annotation->getOptions()); + if (isset($elementSpec['spec']['options'])) { + $specification['options'] = isset($specification['options']) ? $specification['options'] : array(); + $specification['options'] = array_merge($elementSpec['spec']['options'], $specification['options']); + } // Add element spec: $elementSpec['spec'] = $specification; $elementSpec['spec']['name'] = $name; - $elementSpec['spec']['options'] = new ArrayObject($options); + $elementSpec['spec']['options'] = new ArrayObject($this->mergeOptions($elementSpec, $annotation)); } } + /** + * Handle the ContinueIfEmpty annotation + * + * Sets the continue_if_empty flag on the input specification array. + * + * @param \Zend\EventManager\EventInterface $e + * @return void + */ + public function handleContinueIfEmptyAnnotation($e) + { + $annotation = $e->getParam('annotation'); + if (!$annotation instanceof ContinueIfEmpty) { + return; + } + + $inputSpec = $e->getParam('inputSpec'); + $inputSpec['continue_if_empty'] = true; + } + /** * Handle the ErrorMessage annotation * @@ -290,7 +313,7 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener } /** - * Handle the Object annotation + * Handle the Object and Instance annotations * * Sets the object to bind to the form or fieldset * @@ -300,7 +323,9 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener public function handleObjectAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Object) { + + // Only need to typehint on Instance, as Object extends it + if (! $annotation instanceof Instance) { return; } @@ -324,7 +349,7 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener } $elementSpec = $e->getParam('elementSpec'); - $elementSpec['spec']['options'] = $annotation->getOptions(); + $elementSpec['spec']['options'] = $this->mergeOptions($elementSpec, $annotation); } /** @@ -396,4 +421,25 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener } $inputSpec['validators'][] = $annotation->getValidator(); } + + /** + * @param array|\ArrayAccess $elementSpec + * @param ComposedObject|Options $annotation + * + * @return array + */ + private function mergeOptions($elementSpec, $annotation) + { + if (isset($elementSpec['spec']['options'])) { + if (is_array($elementSpec['spec']['options'])) { + return array_merge($elementSpec['spec']['options'], $annotation->getOptions()); + } + + if ($elementSpec['spec']['options'] instanceof ArrayObject) { + return array_merge($elementSpec['spec']['options']->getArrayCopy(), $annotation->getOptions()); + } + } + + return $annotation->getOptions(); + } } diff --git a/library/Zend/Form/Annotation/ErrorMessage.php b/library/Zend/Form/Annotation/ErrorMessage.php index e9ae743c..28c334b6 100644 --- a/library/Zend/Form/Annotation/ErrorMessage.php +++ b/library/Zend/Form/Annotation/ErrorMessage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Exclude.php b/library/Zend/Form/Annotation/Exclude.php index 317d976b..d2ba94ca 100644 --- a/library/Zend/Form/Annotation/Exclude.php +++ b/library/Zend/Form/Annotation/Exclude.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Filter.php b/library/Zend/Form/Annotation/Filter.php index e43b88dd..ffe43eac 100644 --- a/library/Zend/Form/Annotation/Filter.php +++ b/library/Zend/Form/Annotation/Filter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Flags.php b/library/Zend/Form/Annotation/Flags.php index d7573f7e..35fafb75 100644 --- a/library/Zend/Form/Annotation/Flags.php +++ b/library/Zend/Form/Annotation/Flags.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/FormAnnotationsListener.php b/library/Zend/Form/Annotation/FormAnnotationsListener.php index 4adf5786..1701391a 100644 --- a/library/Zend/Form/Annotation/FormAnnotationsListener.php +++ b/library/Zend/Form/Annotation/FormAnnotationsListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,7 +20,7 @@ use Zend\EventManager\EventManagerInterface; * - Attributes * - Flags * - Hydrator - * - Object + * - Object and Instance (the latter is preferred starting in 2.4) * - InputFilter * - Type * - ValidationGroup @@ -129,7 +129,7 @@ class FormAnnotationsListener extends AbstractAnnotationsListener } /** - * Handle the Object annotation + * Handle the Object and Instance annotations * * Sets the object to bind to the form or fieldset * @@ -139,7 +139,9 @@ class FormAnnotationsListener extends AbstractAnnotationsListener public function handleObjectAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Object) { + + // Only need to typehint on Instance, as Object extends it + if (! $annotation instanceof Instance) { return; } diff --git a/library/Zend/Form/Annotation/Hydrator.php b/library/Zend/Form/Annotation/Hydrator.php index c7f5e45d..d8aa0d9f 100644 --- a/library/Zend/Form/Annotation/Hydrator.php +++ b/library/Zend/Form/Annotation/Hydrator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Input.php b/library/Zend/Form/Annotation/Input.php index c01e29e1..70221598 100644 --- a/library/Zend/Form/Annotation/Input.php +++ b/library/Zend/Form/Annotation/Input.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/InputFilter.php b/library/Zend/Form/Annotation/InputFilter.php index 0ba09013..f35738f8 100644 --- a/library/Zend/Form/Annotation/InputFilter.php +++ b/library/Zend/Form/Annotation/InputFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -18,7 +18,7 @@ namespace Zend\Form\Annotation; * * @Annotation */ -class InputFilter extends AbstractStringAnnotation +class InputFilter extends AbstractArrayOrStringAnnotation { /** * Retrieve the input filter class diff --git a/library/Zend/Form/Annotation/Instance.php b/library/Zend/Form/Annotation/Instance.php new file mode 100644 index 00000000..39507781 --- /dev/null +++ b/library/Zend/Form/Annotation/Instance.php @@ -0,0 +1,33 @@ +value; + } +} diff --git a/library/Zend/Form/Annotation/Name.php b/library/Zend/Form/Annotation/Name.php index 63927832..47b7ee56 100644 --- a/library/Zend/Form/Annotation/Name.php +++ b/library/Zend/Form/Annotation/Name.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Object.php b/library/Zend/Form/Annotation/Object.php index 19cfb154..ed569f18 100644 --- a/library/Zend/Form/Annotation/Object.php +++ b/library/Zend/Form/Annotation/Object.php @@ -3,31 +3,40 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Form\Annotation; - /** - * Object annotation + * Stub class for backwards compatibility. * - * Use this annotation to specify an object to use as the bound object of a form or fieldset + * Since PHP 7 adds "object" as a reserved keyword, we can no longer have a class + * named that and retain PHP 7 compatibility. The original class has been + * renamed to "Instance", and this class is now an extension of it. It raises an + * E_USER_DEPRECATED to warn users to migrate. * + * @deprecated * @Annotation - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Object extends AbstractStringAnnotation +class Object extends Instance { /** - * Retrieve the object - * - * @return null|string + * {@inheritdoc} */ - public function getObject() + public function __construct(array $data) { - return $this->value; + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\Instance,' + . ' and the annotation @Instance or @Annotation\Instance', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); + + parent::__construct($data); } } diff --git a/library/Zend/Form/Annotation/Options.php b/library/Zend/Form/Annotation/Options.php index 26743b84..6638d593 100644 --- a/library/Zend/Form/Annotation/Options.php +++ b/library/Zend/Form/Annotation/Options.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Required.php b/library/Zend/Form/Annotation/Required.php index 666370ab..b3f1fe9e 100644 --- a/library/Zend/Form/Annotation/Required.php +++ b/library/Zend/Form/Annotation/Required.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/Type.php b/library/Zend/Form/Annotation/Type.php index 9fd0f5dd..9acee1f1 100644 --- a/library/Zend/Form/Annotation/Type.php +++ b/library/Zend/Form/Annotation/Type.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Annotation/ValidationGroup.php b/library/Zend/Form/Annotation/ValidationGroup.php index 85e5c7b1..4bac8da0 100644 --- a/library/Zend/Form/Annotation/ValidationGroup.php +++ b/library/Zend/Form/Annotation/ValidationGroup.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,7 +17,7 @@ namespace Zend\Form\Annotation; * The value should be an associative array. * * @Annotation - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ValidationGroup extends AbstractArrayAnnotation diff --git a/library/Zend/Form/Annotation/Validator.php b/library/Zend/Form/Annotation/Validator.php index 61cb6632..7c8349d0 100644 --- a/library/Zend/Form/Annotation/Validator.php +++ b/library/Zend/Form/Annotation/Validator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element.php b/library/Zend/Form/Element.php index cfe6880d..decdadeb 100644 --- a/library/Zend/Form/Element.php +++ b/library/Zend/Form/Element.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -160,7 +160,7 @@ class Element implements public function getOption($option) { if (!isset($this->options[$option])) { - return null; + return; } return $this->options[$option]; @@ -206,7 +206,7 @@ class Element implements public function getAttribute($key) { if (!isset($this->attributes[$key])) { - return null; + return; } return $this->attributes[$key]; @@ -446,7 +446,7 @@ class Element implements public function getLabelOption($key) { if (!isset($this->labelOptions[$key])) { - return null; + return; } return $this->labelOptions[$key]; diff --git a/library/Zend/Form/Element/Button.php b/library/Zend/Form/Element/Button.php index 93b9360b..22e6f62f 100644 --- a/library/Zend/Form/Element/Button.php +++ b/library/Zend/Form/Element/Button.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Captcha.php b/library/Zend/Form/Element/Captcha.php index 92f43158..2d0d45b3 100644 --- a/library/Zend/Form/Element/Captcha.php +++ b/library/Zend/Form/Element/Captcha.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Checkbox.php b/library/Zend/Form/Element/Checkbox.php index a7fe6fc8..9d60cdd9 100644 --- a/library/Zend/Form/Element/Checkbox.php +++ b/library/Zend/Form/Element/Checkbox.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Collection.php b/library/Zend/Form/Element/Collection.php index f8abf9a1..88cbd8c8 100644 --- a/library/Zend/Form/Element/Collection.php +++ b/library/Zend/Form/Element/Collection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -209,7 +209,8 @@ class Collection extends Fieldset } // Check to see if elements have been replaced or removed - foreach ($this->byName as $name => $elementOrFieldset) { + $toRemove = array(); + foreach ($this as $name => $elementOrFieldset) { if (isset($data[$name])) { continue; } @@ -221,6 +222,10 @@ class Collection extends Fieldset )); } + $toRemove[] = $name; + } + + foreach ($toRemove as $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 * @return Collection @@ -485,7 +491,8 @@ class Collection extends Fieldset 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) { $this->remove($this->templatePlaceholder); } @@ -516,11 +523,11 @@ class Collection extends Fieldset $values[$key] = $this->hydrator->extract($value); continue; } - + // If the target element is a fieldset that can accept the provided value // we should clone it, inject the value and extract the data - if ( $this->targetElement instanceof FieldsetInterface ) { - if ( ! $this->targetElement->allowObjectBinding($value) ) { + if ($this->targetElement instanceof FieldsetInterface) { + if (! $this->targetElement->allowObjectBinding($value)) { continue; } $targetElement = clone $this->targetElement; @@ -531,9 +538,9 @@ class Collection extends Fieldset } continue; } - + // If the target element is a non-fieldset element, just use the value - if ( $this->targetElement instanceof ElementInterface ) { + if ($this->targetElement instanceof ElementInterface) { $values[$key] = $value; if (!$this->createNewObjects() && $this->has($key)) { $this->get($key)->setValue($value); @@ -590,7 +597,7 @@ class Collection extends Fieldset protected function createTemplateElement() { if (!$this->shouldCreateTemplate) { - return null; + return; } if ($this->templateElement) { diff --git a/library/Zend/Form/Element/Color.php b/library/Zend/Form/Element/Color.php index 17d42b77..7de8ee97 100644 --- a/library/Zend/Form/Element/Color.php +++ b/library/Zend/Form/Element/Color.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Csrf.php b/library/Zend/Form/Element/Csrf.php index 1ff15aec..8c8bfa03 100644 --- a/library/Zend/Form/Element/Csrf.php +++ b/library/Zend/Form/Element/Csrf.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Date.php b/library/Zend/Form/Element/Date.php index 581824f5..209060f3 100644 --- a/library/Zend/Form/Element/Date.php +++ b/library/Zend/Form/Element/Date.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/DateSelect.php b/library/Zend/Form/Element/DateSelect.php index 490f6013..5376cc81 100644 --- a/library/Zend/Form/Element/DateSelect.php +++ b/library/Zend/Form/Element/DateSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -43,7 +43,7 @@ class DateSelect extends MonthSelect * - day_attributes: HTML attributes to be rendered with the day element * * @param array|\Traversable $options - * @return DateSelect + * @return self */ public function setOptions($options) { @@ -64,11 +64,21 @@ class DateSelect extends MonthSelect return $this->dayElement; } + /** + * Get both the year and month elements + * + * @return array + */ + public function getElements() + { + return array_merge(array($this->dayElement), parent::getElements()); + } + /** * Set the day attributes * * @param array $dayAttributes - * @return DateSelect + * @return self */ public function setDayAttributes(array $dayAttributes) { @@ -89,7 +99,7 @@ class DateSelect extends MonthSelect /** * @param string|array|\ArrayAccess|PhpDateTime $value * @throws \Zend\Form\Exception\InvalidArgumentException - * @return void|\Zend\Form\Element + * @return self Provides a fluent interface */ public function setValue($value) { @@ -105,13 +115,15 @@ class DateSelect extends MonthSelect $value = array( 'year' => $value->format('Y'), 'month' => $value->format('m'), - 'day' => $value->format('d') + 'day' => $value->format('d'), ); } $this->yearElement->setValue($value['year']); $this->monthElement->setValue($value['month']); $this->dayElement->setValue($value['day']); + + return $this; } /** @@ -119,7 +131,8 @@ class DateSelect extends MonthSelect */ public function getValue() { - return sprintf('%s-%s-%s', + return sprintf( + '%s-%s-%s', $this->getYearElement()->getValue(), $this->getMonthElement()->getValue(), $this->getDayElement()->getValue() @@ -166,19 +179,7 @@ class DateSelect extends MonthSelect 'name' => $this->getName(), 'required' => false, 'filters' => array( - array( - 'name' => 'Callback', - 'options' => array( - 'callback' => function ($date) { - // Convert the date to a specific format - if (is_array($date)) { - $date = $date['year'] . '-' . $date['month'] . '-' . $date['day']; - } - - return $date; - } - ) - ) + array('name' => 'DateSelect') ), 'validators' => array( $this->getValidator(), diff --git a/library/Zend/Form/Element/DateTime.php b/library/Zend/Form/Element/DateTime.php index 1a7ff598..3ec892ed 100644 --- a/library/Zend/Form/Element/DateTime.php +++ b/library/Zend/Form/Element/DateTime.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/DateTimeLocal.php b/library/Zend/Form/Element/DateTimeLocal.php index f27cdb80..5e602a49 100644 --- a/library/Zend/Form/Element/DateTimeLocal.php +++ b/library/Zend/Form/Element/DateTimeLocal.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/DateTimeSelect.php b/library/Zend/Form/Element/DateTimeSelect.php index 26e88833..c82c7d94 100644 --- a/library/Zend/Form/Element/DateTimeSelect.php +++ b/library/Zend/Form/Element/DateTimeSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,10 @@ namespace Zend\Form\Element; use DateTime as PhpDateTime; use Exception; +use Traversable; use Zend\Form\FormInterface; use Zend\Form\Exception\InvalidArgumentException; +use Zend\Stdlib\ArrayUtils; use Zend\Validator\ValidatorInterface; use Zend\Validator\Date as DateValidator; @@ -62,19 +64,26 @@ class DateTimeSelect extends DateSelect } /** - * Accepted options for DateTimeSelect (plus the ones from DateSelect) : + * Set options for DateTimeSelect element. + * + * Accepted options for DateTimeSelect (plus the ones from DateSelect): + * * - hour_attributes: HTML attributes to be rendered with the hour element * - minute_attributes: HTML attributes to be rendered with the minute element * - second_attributes: HTML attributes to be rendered with the second element * - should_show_seconds: if set to true, the seconds select is shown * - * @param array|\Traversable $options - * @return DateSelect + * @param array|Traversable $options + * @return self */ public function setOptions($options) { parent::setOptions($options); + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); + } + if (isset($options['hour_attributes'])) { $this->setHourAttributes($options['hour_attributes']); } @@ -122,7 +131,7 @@ class DateTimeSelect extends DateSelect * Set the hour attributes * * @param array $hourAttributes - * @return DateSelect + * @return self */ public function setHourAttributes(array $hourAttributes) { @@ -144,7 +153,7 @@ class DateTimeSelect extends DateSelect * Set the minute attributes * * @param array $minuteAttributes - * @return DateSelect + * @return self */ public function setMinuteAttributes(array $minuteAttributes) { @@ -166,7 +175,7 @@ class DateTimeSelect extends DateSelect * Set the second attributes * * @param array $secondAttributes - * @return DateSelect + * @return self */ public function setSecondAttributes(array $secondAttributes) { @@ -189,7 +198,7 @@ class DateTimeSelect extends DateSelect * assumed to always be 00 * * @param bool $shouldShowSeconds - * @return DateTimeSelect + * @return self */ public function setShouldShowSeconds($shouldShowSeconds) { @@ -207,8 +216,8 @@ class DateTimeSelect extends DateSelect /** * @param mixed $value - * @throws \Zend\Form\Exception\InvalidArgumentException - * @return void|\Zend\Form\Element + * @return self + * @throws InvalidArgumentException */ public function setValue($value) { @@ -235,7 +244,7 @@ class DateTimeSelect extends DateSelect ); } - if (!isset($value['second'])) { + if (! isset($value['second'])) { $value['second'] = '00'; } @@ -245,14 +254,17 @@ class DateTimeSelect extends DateSelect $this->hourElement->setValue($value['hour']); $this->minuteElement->setValue($value['minute']); $this->secondElement->setValue($value['second']); + + return $this; } /** - * @return String + * @return string */ public function getValue() { - return sprintf('%s-%s-%s %s:%s:%s', + return sprintf( + '%s-%s-%s %s:%s:%s', $this->getYearElement()->getValue(), $this->getMonthElement()->getValue(), $this->getDayElement()->getValue(), @@ -266,7 +278,7 @@ class DateTimeSelect extends DateSelect * Prepare the form element (mostly used for rendering purposes) * * @param FormInterface $form - * @return mixed + * @return void */ public function prepareElement(FormInterface $form) { @@ -304,29 +316,11 @@ class DateTimeSelect extends DateSelect 'name' => $this->getName(), 'required' => false, 'filters' => array( - array( - 'name' => 'Callback', - 'options' => array( - 'callback' => function ($date) { - // Convert the date to a specific format - if (is_array($date)) { - if (!isset($date['second'])) { - $date['second'] = '00'; - } - $date = sprintf('%s-%s-%s %s:%s:%s', - $date['year'], $date['month'], $date['day'], - $date['hour'], $date['minute'], $date['second'] - ); - } - - return $date; - } - ) - ) + array('name' => 'DateTimeSelect') ), 'validators' => array( $this->getValidator(), - ) + ), ); } diff --git a/library/Zend/Form/Element/Email.php b/library/Zend/Form/Element/Email.php index 69d36fb6..a16eb4a8 100644 --- a/library/Zend/Form/Element/Email.php +++ b/library/Zend/Form/Element/Email.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -116,7 +116,6 @@ class Email extends Element implements InputProviderInterface return $this; } - /** * Provide default input rules for this element * diff --git a/library/Zend/Form/Element/File.php b/library/Zend/Form/Element/File.php index ecfaa7e5..68577826 100644 --- a/library/Zend/Form/Element/File.php +++ b/library/Zend/Form/Element/File.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Hidden.php b/library/Zend/Form/Element/Hidden.php index 6d950db0..9216c0ba 100644 --- a/library/Zend/Form/Element/Hidden.php +++ b/library/Zend/Form/Element/Hidden.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Image.php b/library/Zend/Form/Element/Image.php index 96e50fc0..11f57042 100644 --- a/library/Zend/Form/Element/Image.php +++ b/library/Zend/Form/Element/Image.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Month.php b/library/Zend/Form/Element/Month.php index 7a57678a..e831df08 100644 --- a/library/Zend/Form/Element/Month.php +++ b/library/Zend/Form/Element/Month.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/MonthSelect.php b/library/Zend/Form/Element/MonthSelect.php index 8f8a461c..69eaf615 100644 --- a/library/Zend/Form/Element/MonthSelect.php +++ b/library/Zend/Form/Element/MonthSelect.php @@ -3,17 +3,19 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Form\Element; use DateTime as PhpDateTime; +use Traversable; use Zend\Form\Element; use Zend\Form\ElementPrepareAwareInterface; use Zend\Form\FormInterface; use Zend\InputFilter\InputProviderInterface; +use Zend\Stdlib\ArrayUtils; use Zend\Validator\Regex as RegexValidator; use Zend\Validator\ValidatorInterface; @@ -68,7 +70,6 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep */ protected $validator; - /** * Constructor. Add two selects elements * @@ -87,19 +88,26 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep } /** - * Accepted options for DateSelect: + * Set element options. + * + * Accepted options for MonthSelect: + * * - month_attributes: HTML attributes to be rendered with the month element * - year_attributes: HTML attributes to be rendered with the month element * - min_year: min year to use in the year select * - max_year: max year to use in the year select * - * @param array|\Traversable $options - * @return MonthSelect + * @param array|Traversable $options + * @return self */ public function setOptions($options) { parent::setOptions($options); + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); + } + if (isset($options['month_attributes'])) { $this->setMonthAttributes($options['month_attributes']); } @@ -143,11 +151,21 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep return $this->yearElement; } + /** + * Get both the year and month elements + * + * @return array + */ + public function getElements() + { + return array($this->monthElement, $this->yearElement); + } + /** * Set the month attributes * * @param array $monthAttributes - * @return MonthSelect + * @return self */ public function setMonthAttributes(array $monthAttributes) { @@ -169,7 +187,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep * Set the year attributes * * @param array $yearAttributes - * @return MonthSelect + * @return self */ public function setYearAttributes(array $yearAttributes) { @@ -189,7 +207,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep /** * @param int $minYear - * @return MonthSelect + * @return self */ public function setMinYear($minYear) { @@ -207,7 +225,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep /** * @param int $maxYear - * @return MonthSelect + * @return self */ public function setMaxYear($maxYear) { @@ -225,7 +243,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep /** * @param bool $createEmptyOption - * @return MonthSelect + * @return self */ public function setShouldCreateEmptyOption($createEmptyOption) { @@ -243,7 +261,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep /** * @param bool $renderDelimiters - * @return MonthSelect + * @return self */ public function setShouldRenderDelimiters($renderDelimiters) { @@ -261,7 +279,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep /** * @param mixed $value - * @return void|\Zend\Form\Element + * @return self */ public function setValue($value) { @@ -274,14 +292,16 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep $this->yearElement->setValue($value['year']); $this->monthElement->setValue($value['month']); + return $this; } /** - * @return String + * @return string */ public function getValue() { - return sprintf('%s-%s', + return sprintf( + '%s-%s', $this->getYearElement()->getValue(), $this->getMonthElement()->getValue() ); @@ -291,7 +311,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep * Prepare the form element (mostly used for rendering purposes) * * @param FormInterface $form - * @return mixed + * @return void */ public function prepareElement(FormInterface $form) { @@ -322,23 +342,11 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep 'name' => $this->getName(), 'required' => false, 'filters' => array( - array( - 'name' => 'Callback', - 'options' => array( - 'callback' => function ($date) { - // Convert the date to a specific format - if (is_array($date)) { - $date = $date['year'] . '-' . $date['month']; - } - - return $date; - } - ) - ) + array('name' => 'MonthSelect'), ), 'validators' => array( $this->getValidator(), - ) + ), ); } diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index 6e053be4..c98ac3a8 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Number.php b/library/Zend/Form/Element/Number.php index 45427292..a56255a8 100644 --- a/library/Zend/Form/Element/Number.php +++ b/library/Zend/Form/Element/Number.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Password.php b/library/Zend/Form/Element/Password.php index 0bea1c50..47b44947 100644 --- a/library/Zend/Form/Element/Password.php +++ b/library/Zend/Form/Element/Password.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Radio.php b/library/Zend/Form/Element/Radio.php index 86d77726..e0b1de55 100644 --- a/library/Zend/Form/Element/Radio.php +++ b/library/Zend/Form/Element/Radio.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Range.php b/library/Zend/Form/Element/Range.php index 05fb5f98..a4611cf5 100644 --- a/library/Zend/Form/Element/Range.php +++ b/library/Zend/Form/Element/Range.php @@ -3,14 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Form\Element; use Zend\Form\Element\Number as NumberElement; -use Zend\I18n\Validator\Float as NumberValidator; +use Zend\I18n\Validator\IsFloat as NumberValidator; use Zend\Validator\GreaterThan as GreaterThanValidator; use Zend\Validator\LessThan as LessThanValidator; use Zend\Validator\Step as StepValidator; @@ -55,7 +55,6 @@ class Range extends NumberElement 'inclusive' => $inclusive )); - if (!isset($this->attributes['step']) || 'any' !== $this->attributes['step'] ) { diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index 94d863ae..7417f645 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Submit.php b/library/Zend/Form/Element/Submit.php index 3f1507e8..b4360721 100644 --- a/library/Zend/Form/Element/Submit.php +++ b/library/Zend/Form/Element/Submit.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Text.php b/library/Zend/Form/Element/Text.php index aff28762..a1aeb2f9 100644 --- a/library/Zend/Form/Element/Text.php +++ b/library/Zend/Form/Element/Text.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Textarea.php b/library/Zend/Form/Element/Textarea.php index a2fe2d3c..82b63702 100644 --- a/library/Zend/Form/Element/Textarea.php +++ b/library/Zend/Form/Element/Textarea.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Time.php b/library/Zend/Form/Element/Time.php index eca9d300..26b1d5ed 100644 --- a/library/Zend/Form/Element/Time.php +++ b/library/Zend/Form/Element/Time.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Element/Url.php b/library/Zend/Form/Element/Url.php index d9517614..f03b1713 100644 --- a/library/Zend/Form/Element/Url.php +++ b/library/Zend/Form/Element/Url.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -48,7 +48,7 @@ class Url extends Element implements InputProviderInterface /** * Provide default input rules for this element * - * Attaches an email validator. + * Attaches an uri validator. * * @return array */ diff --git a/library/Zend/Form/Element/Week.php b/library/Zend/Form/Element/Week.php index b5549c0d..0fec5593 100644 --- a/library/Zend/Form/Element/Week.php +++ b/library/Zend/Form/Element/Week.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/ElementAttributeRemovalInterface.php b/library/Zend/Form/ElementAttributeRemovalInterface.php index 768a48b4..975ee4e0 100644 --- a/library/Zend/Form/ElementAttributeRemovalInterface.php +++ b/library/Zend/Form/ElementAttributeRemovalInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/ElementInterface.php b/library/Zend/Form/ElementInterface.php index 8081649d..4fcd995e 100644 --- a/library/Zend/Form/ElementInterface.php +++ b/library/Zend/Form/ElementInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/ElementPrepareAwareInterface.php b/library/Zend/Form/ElementPrepareAwareInterface.php index 1e62addd..ee339057 100644 --- a/library/Zend/Form/ElementPrepareAwareInterface.php +++ b/library/Zend/Form/ElementPrepareAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Exception/BadMethodCallException.php b/library/Zend/Form/Exception/BadMethodCallException.php index 8209503e..943b2dc4 100644 --- a/library/Zend/Form/Exception/BadMethodCallException.php +++ b/library/Zend/Form/Exception/BadMethodCallException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Form\Exception; -class BadMethodCallException - extends \BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Form/Exception/DomainException.php b/library/Zend/Form/Exception/DomainException.php index 0f5bb488..1399d8cf 100644 --- a/library/Zend/Form/Exception/DomainException.php +++ b/library/Zend/Form/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Exception/ExceptionInterface.php b/library/Zend/Form/Exception/ExceptionInterface.php index 9ab0609b..5fc745d6 100644 --- a/library/Zend/Form/Exception/ExceptionInterface.php +++ b/library/Zend/Form/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Exception/ExtensionNotLoadedException.php b/library/Zend/Form/Exception/ExtensionNotLoadedException.php index cc81df43..02ba3fbb 100644 --- a/library/Zend/Form/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Form/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Exception/InvalidArgumentException.php b/library/Zend/Form/Exception/InvalidArgumentException.php index 7081cea9..8710b8fe 100644 --- a/library/Zend/Form/Exception/InvalidArgumentException.php +++ b/library/Zend/Form/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Exception/InvalidElementException.php b/library/Zend/Form/Exception/InvalidElementException.php index b91090b5..981c0e54 100644 --- a/library/Zend/Form/Exception/InvalidElementException.php +++ b/library/Zend/Form/Exception/InvalidElementException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Exception/UnexpectedValueException.php b/library/Zend/Form/Exception/UnexpectedValueException.php index bcff1ac7..05d47cc9 100644 --- a/library/Zend/Form/Exception/UnexpectedValueException.php +++ b/library/Zend/Form/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Factory.php b/library/Zend/Form/Factory.php index 832f4a12..56834f9d 100644 --- a/library/Zend/Form/Factory.php +++ b/library/Zend/Form/Factory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -442,7 +442,7 @@ class Factory $hydrator = $this->getHydratorFromName($hydratorOrName); } - if (!$hydrator instanceof Hydrator\HydratorInterface) { + if (! isset($hydrator) || !$hydrator instanceof Hydrator\HydratorInterface) { throw new Exception\DomainException(sprintf( '%s expects a valid implementation of Zend\Stdlib\Hydrator\HydratorInterface; received "%s"', $method, diff --git a/library/Zend/Form/Fieldset.php b/library/Zend/Form/Fieldset.php index 5b0f45e5..5074b59a 100644 --- a/library/Zend/Form/Fieldset.php +++ b/library/Zend/Form/Fieldset.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,7 @@ use Zend\Code\Reflection\ClassReflection; use Zend\Stdlib\Hydrator; use Zend\Stdlib\Hydrator\HydratorAwareInterface; use Zend\Stdlib\Hydrator\HydratorInterface; -use Zend\Stdlib\PriorityQueue; +use Zend\Stdlib\PriorityList; class Fieldset extends Element implements FieldsetInterface { @@ -23,11 +23,6 @@ class Fieldset extends Element implements FieldsetInterface */ protected $factory; - /** - * @var ElementInterface[] - */ - protected $byName = array(); - /** * @var array */ @@ -44,7 +39,7 @@ class Fieldset extends Element implements FieldsetInterface protected $messages = array(); /** - * @var PriorityQueue + * @var PriorityList */ protected $iterator; @@ -82,7 +77,8 @@ class Fieldset extends Element implements FieldsetInterface */ public function __construct($name = null, $options = array()) { - $this->iterator = new PriorityQueue(); + $this->iterator = new PriorityList(); + $this->iterator->isLIFO(false); parent::__construct($name, $options); } @@ -188,8 +184,7 @@ class Fieldset extends Element implements FieldsetInterface $order = $flags['priority']; } - $this->iterator->insert($elementOrFieldset, $order); - $this->byName[$name] = $elementOrFieldset; + $this->iterator->insert($name, $elementOrFieldset, $order); if ($elementOrFieldset instanceof FieldsetInterface) { $this->fieldsets[$name] = $elementOrFieldset; @@ -208,7 +203,7 @@ class Fieldset extends Element implements FieldsetInterface */ public function has($elementOrFieldset) { - return array_key_exists($elementOrFieldset, $this->byName); + return $this->iterator->get($elementOrFieldset) !== null; } /** @@ -225,7 +220,7 @@ class Fieldset extends Element implements FieldsetInterface $elementOrFieldset )); } - return $this->byName[$elementOrFieldset]; + return $this->iterator->get($elementOrFieldset); } /** @@ -240,12 +235,9 @@ class Fieldset extends Element implements FieldsetInterface return $this; } - $entry = $this->byName[$elementOrFieldset]; - unset($this->byName[$elementOrFieldset]); + $this->iterator->remove($elementOrFieldset); - $this->iterator->remove($entry); - - if ($entry instanceof FieldsetInterface) { + if (isset($this->fieldsets[$elementOrFieldset])) { unset($this->fieldsets[$elementOrFieldset]); return $this; } @@ -263,9 +255,7 @@ class Fieldset extends Element implements FieldsetInterface */ public function setPriority($elementOrFieldset, $priority) { - $element = $this->get($elementOrFieldset); - $this->remove($elementOrFieldset); - $this->add($element, array('priority' => $priority)); + $this->iterator->setPriority($elementOrFieldset, $priority); return $this; } @@ -336,7 +326,7 @@ class Fieldset extends Element implements FieldsetInterface { if (null === $elementName) { $messages = array(); - foreach ($this->byName as $name => $element) { + foreach ($this->iterator as $name => $element) { $messageSet = $element->getMessages(); if (!is_array($messageSet) && !$messageSet instanceof Traversable @@ -371,7 +361,7 @@ class Fieldset extends Element implements FieldsetInterface { $name = $this->getName(); - foreach ($this->byName as $elementOrFieldset) { + foreach ($this->iterator as $elementOrFieldset) { $elementOrFieldset->setName($name . '[' . $elementOrFieldset->getName() . ']'); // Recursively prepare elements @@ -398,7 +388,7 @@ class Fieldset extends Element implements FieldsetInterface )); } - foreach ($this->byName as $name => $elementOrFieldset) { + foreach ($this->iterator as $name => $elementOrFieldset) { $valueExists = array_key_exists($name, $data); if ($elementOrFieldset instanceof FieldsetInterface) { @@ -439,7 +429,7 @@ class Fieldset extends Element implements FieldsetInterface /** * IteratorAggregate: return internal iterator * - * @return PriorityQueue + * @return PriorityList */ public function getIterator() { @@ -579,14 +569,14 @@ class Fieldset extends Element implements FieldsetInterface continue; } - $element = $this->byName[$name]; + $element = $this->iterator->get($name); if ($element instanceof FieldsetInterface && $element->allowValueBinding()) { $value = $element->bindValues($value); } // skip post values for disabled elements, get old value from object - if (!$element->hasAttribute('disabled')) { + if (!$element->getAttribute('disabled')) { $hydratableData[$name] = $value; } elseif (array_key_exists($name, $objectData)) { $hydratableData[$name] = $objectData[$name]; @@ -669,19 +659,17 @@ class Fieldset extends Element implements FieldsetInterface */ public function __clone() { - $items = $this->iterator->toArray(PriorityQueue::EXTR_BOTH); + $items = $this->iterator->toArray(PriorityList::EXTR_BOTH); - $this->byName = array(); $this->elements = array(); $this->fieldsets = array(); - $this->iterator = new PriorityQueue(); + $this->iterator = new PriorityList(); + $this->iterator->isLIFO(false); - foreach ($items as $item) { + foreach ($items as $name => $item) { $elementOrFieldset = clone $item['data']; - $name = $elementOrFieldset->getName(); - $this->iterator->insert($elementOrFieldset, $item['priority']); - $this->byName[$name] = $elementOrFieldset; + $this->iterator->insert($name, $elementOrFieldset, $item['priority']); if ($elementOrFieldset instanceof FieldsetInterface) { $this->fieldsets[$name] = $elementOrFieldset; @@ -689,7 +677,7 @@ class Fieldset extends Element implements FieldsetInterface $this->elements[$name] = $elementOrFieldset; } } - + $this->iterator->rewind(); // Also make a deep copy of the object in case it's used within a collection if (is_object($this->object)) { $this->object = clone $this->object; diff --git a/library/Zend/Form/FieldsetInterface.php b/library/Zend/Form/FieldsetInterface.php index f2e16b90..f4adab4f 100644 --- a/library/Zend/Form/FieldsetInterface.php +++ b/library/Zend/Form/FieldsetInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/FieldsetPrepareAwareInterface.php b/library/Zend/Form/FieldsetPrepareAwareInterface.php index b1584c81..00008f54 100644 --- a/library/Zend/Form/FieldsetPrepareAwareInterface.php +++ b/library/Zend/Form/FieldsetPrepareAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/Form.php b/library/Zend/Form/Form.php index 7d4ecae9..886f94ed 100644 --- a/library/Zend/Form/Form.php +++ b/library/Zend/Form/Form.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -129,7 +129,6 @@ class Form extends Fieldset implements FormInterface */ protected $validationGroup; - /** * Set options for a form. Accepted options are: * - prefer_form_input_filter: is form input filter is preferred? @@ -231,7 +230,7 @@ class Form extends Fieldset implements FormInterface { $name = $this->getName(); - foreach ($this->byName as $elementOrFieldset) { + foreach ($this->iterator as $elementOrFieldset) { if ($form->wrapElements()) { $elementOrFieldset->setName($name . '[' . $elementOrFieldset->getName() . ']'); } @@ -300,7 +299,10 @@ class Form extends Fieldset implements FormInterface $this->bindAs = $flags; $this->setObject($object); - $this->extract(); + + $data = $this->extract(); + + $this->populateValues($data, true); return $this; } @@ -480,6 +482,7 @@ class Form extends Fieldset implements FormInterface if (!is_array($this->data)) { $data = $this->extract(); + $this->populateValues($data, true); if (!is_array($data)) { throw new Exception\DomainException(sprintf( '%s is unable to validate as there is no data currently set', @@ -617,11 +620,11 @@ class Form extends Fieldset implements FormInterface continue; } - $fieldset = $formOrFieldset->byName[$key]; + $fieldset = $formOrFieldset->iterator->get($key); if ($fieldset instanceof Collection) { if (!isset($data[$key]) && $fieldset->getCount() == 0) { - unset ($validationGroup[$key]); + unset($validationGroup[$key]); continue; } @@ -761,9 +764,7 @@ class Form extends Fieldset implements FormInterface } if (!$fieldset instanceof Collection || !$fieldset->getTargetElement() instanceof FieldsetInterface || $inputFilter instanceof CollectionInputFilter) { - foreach ($elements as $element) { - $name = $element->getName(); - + foreach ($elements as $name => $element) { if ($this->preferFormInputFilter && $inputFilter->has($name)) { continue; } @@ -787,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) { @@ -798,9 +804,7 @@ class Form extends Fieldset implements FormInterface } } - foreach ($fieldset->getFieldsets() as $childFieldset) { - $name = $childFieldset->getName(); - + foreach ($fieldset->getFieldsets() as $name => $childFieldset) { if (!$childFieldset instanceof InputFilterProviderInterface) { if (!$inputFilter->has($name)) { // Add a new empty input filter if it does not exist (or the fieldset's object input filter), @@ -808,8 +812,27 @@ class Form extends Fieldset implements FormInterface if ($childFieldset->getObject() instanceof InputFilterAwareInterface) { $inputFilter->add($childFieldset->getObject()->getInputFilter(), $name); } else { - if ($fieldset instanceof Collection && $inputFilter instanceof CollectionInputFilter) { - continue; + // Add input filter for collections via getInputFilterSpecification() + 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 { $inputFilter->add(new InputFilter(), $name); } @@ -841,9 +864,31 @@ class Form extends Fieldset implements FormInterface // Recursively attach sub filters $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 ? * @@ -867,7 +912,24 @@ class Form extends Fieldset implements FormInterface } /** - * Recursively extract values for elements and sub-fieldsets, and populate form values + * {@inheritDoc} + * + * @param bool $onlyBase + */ + public function populateValues($data, $onlyBase = false) + { + if ($onlyBase && $this->baseFieldset !== null) { + $name = $this->baseFieldset->getName(); + if (array_key_exists($name, $data)) { + $this->baseFieldset->populateValues($data[$name]); + } + } else { + parent::populateValues($data); + } + } + + /** + * Recursively extract values for elements and sub-fieldsets * * @return array */ @@ -876,10 +938,8 @@ class Form extends Fieldset implements FormInterface if (null !== $this->baseFieldset) { $name = $this->baseFieldset->getName(); $values[$name] = $this->baseFieldset->extract(); - $this->baseFieldset->populateValues($values[$name]); } else { $values = parent::extract(); - $this->populateValues($values); } return $values; diff --git a/library/Zend/Form/FormAbstractServiceFactory.php b/library/Zend/Form/FormAbstractServiceFactory.php index c7c90164..cc66abf8 100644 --- a/library/Zend/Form/FormAbstractServiceFactory.php +++ b/library/Zend/Form/FormAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/FormElementManager.php b/library/Zend/Form/FormElementManager.php index bdea8f74..34244da4 100644 --- a/library/Zend/Form/FormElementManager.php +++ b/library/Zend/Form/FormElementManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/FormFactoryAwareInterface.php b/library/Zend/Form/FormFactoryAwareInterface.php index e5e6f501..3000204f 100644 --- a/library/Zend/Form/FormFactoryAwareInterface.php +++ b/library/Zend/Form/FormFactoryAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/FormFactoryAwareTrait.php b/library/Zend/Form/FormFactoryAwareTrait.php index 1684ca1f..a5cfeb12 100644 --- a/library/Zend/Form/FormFactoryAwareTrait.php +++ b/library/Zend/Form/FormFactoryAwareTrait.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Form; - trait FormFactoryAwareTrait { /** diff --git a/library/Zend/Form/FormInterface.php b/library/Zend/Form/FormInterface.php index 25acfdb1..42337f0f 100644 --- a/library/Zend/Form/FormInterface.php +++ b/library/Zend/Form/FormInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/InputFilterProviderFieldset.php b/library/Zend/Form/InputFilterProviderFieldset.php index 6c34f14f..74b291b1 100644 --- a/library/Zend/Form/InputFilterProviderFieldset.php +++ b/library/Zend/Form/InputFilterProviderFieldset.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/LabelAwareInterface.php b/library/Zend/Form/LabelAwareInterface.php index 57096d06..9e3ba861 100644 --- a/library/Zend/Form/LabelAwareInterface.php +++ b/library/Zend/Form/LabelAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/LabelAwareTrait.php b/library/Zend/Form/LabelAwareTrait.php index 450603c6..545065d6 100644 --- a/library/Zend/Form/LabelAwareTrait.php +++ b/library/Zend/Form/LabelAwareTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -131,7 +131,7 @@ trait LabelAwareTrait public function getLabelOption($key) { if (!array_key_exists($key, $this->labelOptions)) { - return null; + return; } return $this->labelOptions[$key]; } diff --git a/library/Zend/Form/View/Helper/AbstractHelper.php b/library/Zend/Form/View/Helper/AbstractHelper.php index c77a99b8..60ac8533 100644 --- a/library/Zend/Form/View/Helper/AbstractHelper.php +++ b/library/Zend/Form/View/Helper/AbstractHelper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,6 @@ abstract class AbstractHelper extends BaseAbstractHelper * @var array */ protected $booleanAttributes = array( - 'autocomplete' => array('on' => 'on', 'off' => 'off'), 'autofocus' => array('on' => 'autofocus', 'off' => ''), 'checked' => array('on' => 'checked', 'off' => ''), 'disabled' => array('on' => 'disabled', 'off' => ''), @@ -131,8 +130,8 @@ abstract class AbstractHelper extends BaseAbstractHelper 'onvolumechange' => true, 'onwaiting' => true, 'role' => true, - 'aria-labelled-by' => true, - 'aria-described-by' => true, + 'aria-labelledby' => true, + 'aria-describedby' => true, 'spellcheck' => true, 'style' => true, 'tabindex' => true, @@ -183,6 +182,7 @@ abstract class AbstractHelper extends BaseAbstractHelper public function setEncoding($encoding) { $this->getEscapeHtmlHelper()->setEncoding($encoding); + $this->getEscapeHtmlAttrHelper()->setEncoding($encoding); return $this; } diff --git a/library/Zend/Form/View/Helper/Captcha/AbstractWord.php b/library/Zend/Form/View/Helper/Captcha/AbstractWord.php index b27e641f..10d9032f 100644 --- a/library/Zend/Form/View/Helper/Captcha/AbstractWord.php +++ b/library/Zend/Form/View/Helper/Captcha/AbstractWord.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/Captcha/Dumb.php b/library/Zend/Form/View/Helper/Captcha/Dumb.php index 1f49fe21..d6acd1b3 100644 --- a/library/Zend/Form/View/Helper/Captcha/Dumb.php +++ b/library/Zend/Form/View/Helper/Captcha/Dumb.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/Captcha/Figlet.php b/library/Zend/Form/View/Helper/Captcha/Figlet.php index d8273111..a0497575 100644 --- a/library/Zend/Form/View/Helper/Captcha/Figlet.php +++ b/library/Zend/Form/View/Helper/Captcha/Figlet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/Captcha/Image.php b/library/Zend/Form/View/Helper/Captcha/Image.php index d848fb0e..f2e6fd05 100644 --- a/library/Zend/Form/View/Helper/Captcha/Image.php +++ b/library/Zend/Form/View/Helper/Captcha/Image.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/Captcha/ReCaptcha.php b/library/Zend/Form/View/Helper/Captcha/ReCaptcha.php index 7106dbe0..eb7aaa5f 100644 --- a/library/Zend/Form/View/Helper/Captcha/ReCaptcha.php +++ b/library/Zend/Form/View/Helper/Captcha/ReCaptcha.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/File/FormFileApcProgress.php b/library/Zend/Form/View/Helper/File/FormFileApcProgress.php index c2f56074..737b6053 100644 --- a/library/Zend/Form/View/Helper/File/FormFileApcProgress.php +++ b/library/Zend/Form/View/Helper/File/FormFileApcProgress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/File/FormFileSessionProgress.php b/library/Zend/Form/View/Helper/File/FormFileSessionProgress.php index 3eb1d487..2a02859b 100644 --- a/library/Zend/Form/View/Helper/File/FormFileSessionProgress.php +++ b/library/Zend/Form/View/Helper/File/FormFileSessionProgress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/File/FormFileUploadProgress.php b/library/Zend/Form/View/Helper/File/FormFileUploadProgress.php index cc2107bf..515d9721 100644 --- a/library/Zend/Form/View/Helper/File/FormFileUploadProgress.php +++ b/library/Zend/Form/View/Helper/File/FormFileUploadProgress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,11 +38,12 @@ class FormFileUploadProgress extends FormInput */ public function renderHiddenId() { - $attributes = array(); - $attributes['id'] = 'progress_key'; - $attributes['name'] = $this->getName(); - $attributes['type'] = 'hidden'; - $attributes['value'] = $this->getValue(); + $attributes = array( + 'id' => 'progress_key', + 'name' => $this->getName(), + 'type' => 'hidden', + 'value' => $this->getValue() + ); return sprintf( ' '', - 'method' => 'get', - ); + $doctype = $this->getDoctype(); + $attributes = array(); + + if (! (Doctype::HTML5 === $doctype || Doctype::XHTML5 === $doctype)) { + $attributes = array( + 'action' => '', + 'method' => 'get', + ); + } if ($form instanceof FormInterface) { $formAttributes = $form->getAttributes(); @@ -94,9 +100,11 @@ class Form extends AbstractHelper $attributes = array_merge($attributes, $formAttributes); } - $tag = sprintf('
', $this->createAttributesString($attributes)); + if ($attributes) { + return sprintf('', $this->createAttributesString($attributes)); + } - return $tag; + return ''; } /** diff --git a/library/Zend/Form/View/Helper/FormButton.php b/library/Zend/Form/View/Helper/FormButton.php index 743c416a..74de9f93 100644 --- a/library/Zend/Form/View/Helper/FormButton.php +++ b/library/Zend/Form/View/Helper/FormButton.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -79,20 +79,23 @@ class FormButton extends FormInput if (null === $buttonContent) { $buttonContent = $element->getLabel(); if (null === $buttonContent) { - throw new Exception\DomainException(sprintf( - '%s expects either button content as the second argument, ' . + throw new Exception\DomainException( + sprintf( + '%s expects either button content as the second argument, ' . 'or that the element provided has a label value; neither found', - __METHOD__ - )); - } - - if (null !== ($translator = $this->getTranslator())) { - $buttonContent = $translator->translate( - $buttonContent, $this->getTranslatorTextDomain() + __METHOD__ + ) ); } } + if (null !== ($translator = $this->getTranslator())) { + $buttonContent = $translator->translate( + $buttonContent, $this->getTranslatorTextDomain() + ); + } + + if (! $element instanceof LabelAwareInterface || ! $element->getLabelOption('disable_html_escape')) { $escapeHtmlHelper = $this->getEscapeHtmlHelper(); $buttonContent = $escapeHtmlHelper($buttonContent); diff --git a/library/Zend/Form/View/Helper/FormCaptcha.php b/library/Zend/Form/View/Helper/FormCaptcha.php index 0ffb6e6d..7796ebef 100644 --- a/library/Zend/Form/View/Helper/FormCaptcha.php +++ b/library/Zend/Form/View/Helper/FormCaptcha.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormCheckbox.php b/library/Zend/Form/View/Helper/FormCheckbox.php index 97a1023c..aee31bff 100644 --- a/library/Zend/Form/View/Helper/FormCheckbox.php +++ b/library/Zend/Form/View/Helper/FormCheckbox.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -58,8 +58,9 @@ class FormCheckbox extends FormInput if ($element->useHiddenElement()) { $hiddenAttributes = array( - 'name' => $attributes['name'], - 'value' => $element->getUncheckedValue(), + 'disabled' => isset($attributes['disabled']) ? $attributes['disabled'] : false, + 'name' => $attributes['name'], + 'value' => $element->getUncheckedValue(), ); $rendered = sprintf( diff --git a/library/Zend/Form/View/Helper/FormCollection.php b/library/Zend/Form/View/Helper/FormCollection.php index 4a79e8c4..1e0b30d0 100644 --- a/library/Zend/Form/View/Helper/FormCollection.php +++ b/library/Zend/Form/View/Helper/FormCollection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -113,7 +113,7 @@ class FormCollection extends AbstractHelper foreach ($element->getIterator() as $elementOrFieldset) { if ($elementOrFieldset instanceof FieldsetInterface) { - $markup .= $fieldsetHelper($elementOrFieldset); + $markup .= $fieldsetHelper($elementOrFieldset, $this->shouldWrap()); } elseif ($elementOrFieldset instanceof ElementInterface) { $markup .= $elementHelper($elementOrFieldset); } @@ -178,13 +178,13 @@ class FormCollection extends AbstractHelper $elementOrFieldset = $collection->getTemplateElement(); if ($elementOrFieldset instanceof FieldsetInterface) { - $templateMarkup .= $fieldsetHelper($elementOrFieldset); + $templateMarkup .= $fieldsetHelper($elementOrFieldset, $this->shouldWrap()); } elseif ($elementOrFieldset instanceof ElementInterface) { $templateMarkup .= $elementHelper($elementOrFieldset); } return sprintf( - $this->templateWrapper, + $this->getTemplateWrapper(), $escapeHtmlAttribHelper($templateMarkup) ); } diff --git a/library/Zend/Form/View/Helper/FormColor.php b/library/Zend/Form/View/Helper/FormColor.php index ebf955fa..d83dda78 100644 --- a/library/Zend/Form/View/Helper/FormColor.php +++ b/library/Zend/Form/View/Helper/FormColor.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormDate.php b/library/Zend/Form/View/Helper/FormDate.php index 6e21eb62..8fda4399 100644 --- a/library/Zend/Form/View/Helper/FormDate.php +++ b/library/Zend/Form/View/Helper/FormDate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormDateSelect.php b/library/Zend/Form/View/Helper/FormDateSelect.php index bd9e5e34..be21bbc0 100644 --- a/library/Zend/Form/View/Helper/FormDateSelect.php +++ b/library/Zend/Form/View/Helper/FormDateSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormDateTime.php b/library/Zend/Form/View/Helper/FormDateTime.php index 4c2b615c..3bc62e4e 100644 --- a/library/Zend/Form/View/Helper/FormDateTime.php +++ b/library/Zend/Form/View/Helper/FormDateTime.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormDateTimeLocal.php b/library/Zend/Form/View/Helper/FormDateTimeLocal.php index d072e809..520ca1b1 100644 --- a/library/Zend/Form/View/Helper/FormDateTimeLocal.php +++ b/library/Zend/Form/View/Helper/FormDateTimeLocal.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormDateTimeSelect.php b/library/Zend/Form/View/Helper/FormDateTimeSelect.php index c5c4042c..31048b92 100644 --- a/library/Zend/Form/View/Helper/FormDateTimeSelect.php +++ b/library/Zend/Form/View/Helper/FormDateTimeSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -144,9 +144,8 @@ class FormDateTimeSelect extends FormDateSelectHelper $markup .= $data[$value]; } } - $markup = trim($markup); - return $markup; + return trim($markup); } /** diff --git a/library/Zend/Form/View/Helper/FormElement.php b/library/Zend/Form/View/Helper/FormElement.php index acd5484e..8327d18f 100644 --- a/library/Zend/Form/View/Helper/FormElement.php +++ b/library/Zend/Form/View/Helper/FormElement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -187,7 +187,7 @@ class FormElement extends BaseAbstractHelper return $this->renderHelper($pluginName, $element); } } - return null; + return; } /** @@ -203,6 +203,6 @@ class FormElement extends BaseAbstractHelper if (isset($this->typeMap[$type])) { return $this->renderHelper($this->typeMap[$type], $element); } - return null; + return; } } diff --git a/library/Zend/Form/View/Helper/FormElementErrors.php b/library/Zend/Form/View/Helper/FormElementErrors.php index 2e927923..15fe08ff 100644 --- a/library/Zend/Form/View/Helper/FormElementErrors.php +++ b/library/Zend/Form/View/Helper/FormElementErrors.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormEmail.php b/library/Zend/Form/View/Helper/FormEmail.php index e03930eb..2ffb3142 100644 --- a/library/Zend/Form/View/Helper/FormEmail.php +++ b/library/Zend/Form/View/Helper/FormEmail.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormFile.php b/library/Zend/Form/View/Helper/FormFile.php index e75b34d8..6fbdfab6 100644 --- a/library/Zend/Form/View/Helper/FormFile.php +++ b/library/Zend/Form/View/Helper/FormFile.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormHidden.php b/library/Zend/Form/View/Helper/FormHidden.php index f478b2a6..c041ad97 100644 --- a/library/Zend/Form/View/Helper/FormHidden.php +++ b/library/Zend/Form/View/Helper/FormHidden.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormImage.php b/library/Zend/Form/View/Helper/FormImage.php index e5bc26ce..7a0577b5 100644 --- a/library/Zend/Form/View/Helper/FormImage.php +++ b/library/Zend/Form/View/Helper/FormImage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormInput.php b/library/Zend/Form/View/Helper/FormInput.php index 5a2f5adc..e7346159 100644 --- a/library/Zend/Form/View/Helper/FormInput.php +++ b/library/Zend/Form/View/Helper/FormInput.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -120,8 +120,12 @@ class FormInput extends AbstractHelper $attributes = $element->getAttributes(); $attributes['name'] = $name; - $attributes['type'] = $this->getType($element); + $type = $this->getType($element); + $attributes['type'] = $type; $attributes['value'] = $element->getValue(); + if ('password' == $type) { + $attributes['value'] = ''; + } return sprintf( 'getLabel(); if (empty($label)) { - throw new Exception\DomainException(sprintf( - '%s expects either label content as the second argument, ' . + throw new Exception\DomainException( + sprintf( + '%s expects either label content as the second argument, ' . 'or that the element provided has a label attribute; neither found', - __METHOD__ - )); + __METHOD__ + ) + ); } if (null !== ($translator = $this->getTranslator())) { - $label = $translator->translate( - $label, $this->getTranslatorTextDomain() - ); + $label = $translator->translate($label, $this->getTranslatorTextDomain()); } if (! $element instanceof LabelAwareInterface || ! $element->getLabelOption('disable_html_escape')) { diff --git a/library/Zend/Form/View/Helper/FormMonth.php b/library/Zend/Form/View/Helper/FormMonth.php index a0881b40..9d6955bf 100644 --- a/library/Zend/Form/View/Helper/FormMonth.php +++ b/library/Zend/Form/View/Helper/FormMonth.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormMonthSelect.php b/library/Zend/Form/View/Helper/FormMonthSelect.php index f3cfa213..dc0fe3dd 100644 --- a/library/Zend/Form/View/Helper/FormMonthSelect.php +++ b/library/Zend/Form/View/Helper/FormMonthSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormMultiCheckbox.php b/library/Zend/Form/View/Helper/FormMultiCheckbox.php index 927071c8..2fd1d80b 100644 --- a/library/Zend/Form/View/Helper/FormMultiCheckbox.php +++ b/library/Zend/Form/View/Helper/FormMultiCheckbox.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -95,7 +95,6 @@ class FormMultiCheckbox extends FormInput * * @param ElementInterface $element * @throws Exception\InvalidArgumentException - * @throws Exception\DomainException * @return string */ public function render(ElementInterface $element) @@ -110,12 +109,6 @@ class FormMultiCheckbox extends FormInput $name = static::getName($element); $options = $element->getValueOptions(); - if (empty($options)) { - throw new Exception\DomainException(sprintf( - '%s requires that the element has "value_options"; none found', - __METHOD__ - )); - } $attributes = $element->getAttributes(); $attributes['name'] = $name; @@ -145,8 +138,7 @@ class FormMultiCheckbox extends FormInput * @param array $attributes * @return string */ - protected function renderOptions(MultiCheckboxElement $element, array $options, array $selectedOptions, - array $attributes) + protected function renderOptions(MultiCheckboxElement $element, array $options, array $selectedOptions, array $attributes) { $escapeHtmlHelper = $this->getEscapeHtmlHelper(); $labelHelper = $this->getLabelHelper(); @@ -176,8 +168,8 @@ class FormMultiCheckbox extends FormInput $label = ''; $inputAttributes = $attributes; $labelAttributes = $globalLabelAttributes; - $selected = isset($inputAttributes['selected']) && $inputAttributes['type'] != 'radio' && $inputAttributes['selected'] != false ? true : false; - $disabled = isset($inputAttributes['disabled']) && $inputAttributes['disabled'] != false ? true : false; + $selected = (isset($inputAttributes['selected']) && $inputAttributes['type'] != 'radio' && $inputAttributes['selected']); + $disabled = (isset($inputAttributes['disabled']) && $inputAttributes['disabled']); if (is_scalar($optionSpec)) { $optionSpec = array( @@ -223,7 +215,8 @@ class FormMultiCheckbox extends FormInput if (null !== ($translator = $this->getTranslator())) { $label = $translator->translate( - $label, $this->getTranslatorTextDomain() + $label, + $this->getTranslatorTextDomain() ); } diff --git a/library/Zend/Form/View/Helper/FormNumber.php b/library/Zend/Form/View/Helper/FormNumber.php index a19c89af..ba2f5370 100644 --- a/library/Zend/Form/View/Helper/FormNumber.php +++ b/library/Zend/Form/View/Helper/FormNumber.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormPassword.php b/library/Zend/Form/View/Helper/FormPassword.php index a2683f69..cbd78228 100644 --- a/library/Zend/Form/View/Helper/FormPassword.php +++ b/library/Zend/Form/View/Helper/FormPassword.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormRadio.php b/library/Zend/Form/View/Helper/FormRadio.php index 97405006..5cb5bb11 100644 --- a/library/Zend/Form/View/Helper/FormRadio.php +++ b/library/Zend/Form/View/Helper/FormRadio.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormRange.php b/library/Zend/Form/View/Helper/FormRange.php index e2d7cf68..b1cbd9dd 100644 --- a/library/Zend/Form/View/Helper/FormRange.php +++ b/library/Zend/Form/View/Helper/FormRange.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormReset.php b/library/Zend/Form/View/Helper/FormReset.php index 53e2988b..22aed0b6 100644 --- a/library/Zend/Form/View/Helper/FormReset.php +++ b/library/Zend/Form/View/Helper/FormReset.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormRow.php b/library/Zend/Form/View/Helper/FormRow.php index 0a8eb464..715b8b00 100644 --- a/library/Zend/Form/View/Helper/FormRow.php +++ b/library/Zend/Form/View/Helper/FormRow.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,6 +11,7 @@ namespace Zend\Form\View\Helper; use Zend\Form\Element\Button; use Zend\Form\Element\MonthSelect; +use Zend\Form\Element\Captcha; use Zend\Form\ElementInterface; use Zend\Form\Exception; use Zend\Form\LabelAwareInterface; @@ -91,10 +92,8 @@ class FormRow extends AbstractHelper return $this; } - if ($labelPosition !== null) { - $this->setLabelPosition($labelPosition); - } elseif ($this->labelPosition === null) { - $this->setLabelPosition(self::LABEL_PREPEND); + if (is_null($labelPosition)) { + $labelPosition = $this->getLabelPosition(); } if ($renderErrors !== null) { @@ -105,17 +104,18 @@ class FormRow extends AbstractHelper $this->setPartial($partial); } - return $this->render($element); + return $this->render($element, $labelPosition); } /** * Utility form helper that renders a label (if it exists), an element and errors * * @param ElementInterface $element + * @param null|string $labelPosition * @throws \Zend\Form\Exception\DomainException * @return string */ - public function render(ElementInterface $element) + public function render(ElementInterface $element, $labelPosition = null) { $escapeHtmlHelper = $this->getEscapeHtmlHelper(); $labelHelper = $this->getLabelHelper(); @@ -125,12 +125,14 @@ class FormRow extends AbstractHelper $label = $element->getLabel(); $inputErrorClass = $this->getInputErrorClass(); + if (is_null($labelPosition)) { + $labelPosition = $this->labelPosition; + } + if (isset($label) && '' !== $label) { // Translate the label if (null !== ($translator = $this->getTranslator())) { - $label = $translator->translate( - $label, $this->getTranslatorTextDomain() - ); + $label = $translator->translate($label, $this->getTranslatorTextDomain()); } } @@ -147,7 +149,7 @@ class FormRow extends AbstractHelper 'element' => $element, 'label' => $label, 'labelAttributes' => $this->labelAttributes, - 'labelPosition' => $this->labelPosition, + 'labelPosition' => $labelPosition, 'renderErrors' => $this->renderErrors, ); @@ -182,11 +184,13 @@ class FormRow extends AbstractHelper if ($type === 'multi_checkbox' || $type === 'radio' || $element instanceof MonthSelect + || $element instanceof Captcha ) { $markup = sprintf( '
%s%s
', $label, - $elementString); + $elementString + ); } else { // Ensure element and label will be separated if element has an `id`-attribute. // If element has label option `always_wrap` it will be nested in any case. @@ -212,7 +216,11 @@ class FormRow extends AbstractHelper $labelOpen = $labelClose = $label = ''; } - switch ($this->labelPosition) { + if ($element instanceof LabelAwareInterface && $element->getLabelOption('label_position')) { + $labelPosition = $element->getLabelOption('label_position'); + } + + switch ($labelPosition) { case self::LABEL_PREPEND: $markup = $labelOpen . $label . $elementString . $labelClose; break; diff --git a/library/Zend/Form/View/Helper/FormSearch.php b/library/Zend/Form/View/Helper/FormSearch.php index 80e08620..1a824c69 100644 --- a/library/Zend/Form/View/Helper/FormSearch.php +++ b/library/Zend/Form/View/Helper/FormSearch.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormSelect.php b/library/Zend/Form/View/Helper/FormSelect.php index 7e1dc411..e2d99762 100644 --- a/library/Zend/Form/View/Helper/FormSelect.php +++ b/library/Zend/Form/View/Helper/FormSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,13 +32,14 @@ class FormSelect extends AbstractHelper * @var array */ protected $validSelectAttributes = array( - 'name' => true, - 'autofocus' => true, - 'disabled' => true, - 'form' => true, - 'multiple' => true, - 'required' => true, - 'size' => true + 'name' => true, + 'autocomplete' => true, + 'autofocus' => true, + 'disabled' => true, + 'form' => true, + 'multiple' => true, + 'required' => true, + 'size' => true ); /** @@ -68,7 +69,7 @@ class FormSelect extends AbstractHelper ); /** - * @var FromHidden|null + * @var FormHidden|null */ protected $formHiddenHelper; @@ -208,7 +209,8 @@ class FormSelect extends AbstractHelper if (null !== ($translator = $this->getTranslator())) { $label = $translator->translate( - $label, $this->getTranslatorTextDomain() + $label, + $this->getTranslatorTextDomain() ); } diff --git a/library/Zend/Form/View/Helper/FormSubmit.php b/library/Zend/Form/View/Helper/FormSubmit.php index 926028d8..2dbd4347 100644 --- a/library/Zend/Form/View/Helper/FormSubmit.php +++ b/library/Zend/Form/View/Helper/FormSubmit.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormTel.php b/library/Zend/Form/View/Helper/FormTel.php index 746f0e15..de1fc356 100644 --- a/library/Zend/Form/View/Helper/FormTel.php +++ b/library/Zend/Form/View/Helper/FormTel.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormText.php b/library/Zend/Form/View/Helper/FormText.php index 0e57c051..2f39a471 100644 --- a/library/Zend/Form/View/Helper/FormText.php +++ b/library/Zend/Form/View/Helper/FormText.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormTextarea.php b/library/Zend/Form/View/Helper/FormTextarea.php index 32011b2c..114a408c 100644 --- a/library/Zend/Form/View/Helper/FormTextarea.php +++ b/library/Zend/Form/View/Helper/FormTextarea.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,18 +20,19 @@ class FormTextarea extends AbstractHelper * @var array */ protected $validTagAttributes = array( - 'autofocus' => true, - 'cols' => true, - 'dirname' => true, - 'disabled' => true, - 'form' => true, - 'maxlength' => true, - 'name' => true, - 'placeholder' => true, - 'readonly' => true, - 'required' => true, - 'rows' => true, - 'wrap' => true, + 'autocomplete' => true, + 'autofocus' => true, + 'cols' => true, + 'dirname' => true, + 'disabled' => true, + 'form' => true, + 'maxlength' => true, + 'name' => true, + 'placeholder' => true, + 'readonly' => true, + 'required' => true, + 'rows' => true, + 'wrap' => true, ); /** diff --git a/library/Zend/Form/View/Helper/FormTime.php b/library/Zend/Form/View/Helper/FormTime.php index cf8fbc32..9f8ce6c9 100644 --- a/library/Zend/Form/View/Helper/FormTime.php +++ b/library/Zend/Form/View/Helper/FormTime.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormUrl.php b/library/Zend/Form/View/Helper/FormUrl.php index 90df9965..a386debb 100644 --- a/library/Zend/Form/View/Helper/FormUrl.php +++ b/library/Zend/Form/View/Helper/FormUrl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/Helper/FormWeek.php b/library/Zend/Form/View/Helper/FormWeek.php index 4fe6758c..3704d9a0 100644 --- a/library/Zend/Form/View/Helper/FormWeek.php +++ b/library/Zend/Form/View/Helper/FormWeek.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/View/HelperConfig.php b/library/Zend/Form/View/HelperConfig.php index c9b6f56a..4a425e2f 100644 --- a/library/Zend/Form/View/HelperConfig.php +++ b/library/Zend/Form/View/HelperConfig.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Form/composer.json b/library/Zend/Form/composer.json index 9d2cad0f..95dea087 100644 --- a/library/Zend/Form/composer.json +++ b/library/Zend/Form/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Form\\": "" } }, - "target-dir": "Zend/Form", "require": { "php": ">=5.3.23", "zendframework/zend-inputfilter": "self.version", @@ -43,8 +42,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Http/AbstractMessage.php b/library/Zend/Http/AbstractMessage.php index 0c607e8a..0f4f3047 100644 --- a/library/Zend/Http/AbstractMessage.php +++ b/library/Zend/Http/AbstractMessage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client.php b/library/Zend/Http/Client.php index 71ff2d49..71c670e5 100644 --- a/library/Zend/Http/Client.php +++ b/library/Zend/Http/Client.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,7 +25,7 @@ class Client implements Stdlib\DispatchableInterface * @const string Supported HTTP Authentication methods */ const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; // not implemented yet + const AUTH_DIGEST = 'digest'; /** * @const string POST data encoding methods @@ -54,7 +54,7 @@ class Client implements Stdlib\DispatchableInterface protected $request; /** - * @var Client/Adapter + * @var Client\Adapter\AdapterInterface */ protected $adapter; @@ -233,6 +233,7 @@ class Client implements Stdlib\DispatchableInterface { if (empty($this->request)) { $this->request = new Request(); + $this->request->setAllowCustomMethods(false); } return $this->request; } @@ -262,7 +263,6 @@ class Client implements Stdlib\DispatchableInterface return $this->response; } - /** * Get the last request (as a string) * @@ -412,13 +412,16 @@ class Client implements Stdlib\DispatchableInterface */ public function setEncType($encType, $boundary = null) { - if (!empty($encType)) { - if (!empty($boundary)) { - $this->encType = $encType . "; boundary={$boundary}"; - } else { - $this->encType = $encType; - } + if (null === $encType || empty($encType)) { + $this->encType = null; + return $this; } + + if (! empty($boundary)) { + $encType .= sprintf('; boundary=%s', $boundary); + } + + $this->encType = $encType; return $this; } @@ -716,18 +719,18 @@ class Client implements Stdlib\DispatchableInterface */ public function setAuth($user, $password, $type = self::AUTH_BASIC) { - if (!defined('self::AUTH_' . strtoupper($type))) { + if (!defined('static::AUTH_' . strtoupper($type))) { throw new Exception\InvalidArgumentException("Invalid or not supported authentication type: '$type'"); } + if (empty($user)) { throw new Exception\InvalidArgumentException("The username cannot be empty"); } - $this->auth = array ( + $this->auth = array( 'user' => $user, 'password' => $password, 'type' => $type - ); return $this; @@ -824,7 +827,6 @@ class Client implements Stdlib\DispatchableInterface } $this->redirectCounter = 0; - $response = null; $adapter = $this->getAdapter(); @@ -864,6 +866,9 @@ class Client implements Stdlib\DispatchableInterface // method $method = $this->getRequest()->getMethod(); + // this is so the correct Encoding Type is set + $this->setMethod($method); + // body $body = $this->prepareBody(); @@ -939,7 +944,6 @@ class Client implements Stdlib\DispatchableInterface $this->setMethod(Request::METHOD_GET); } - // If we got a well formed absolute URI if (($scheme = substr($location, 0, 6)) && ($scheme == 'http:/' || $scheme == 'https:')) { @@ -1139,7 +1143,12 @@ class Client implements Stdlib\DispatchableInterface } break; case self::AUTH_DIGEST : - throw new Exception\RuntimeException("The digest authentication is not implemented yet"); + if (!$this->adapter instanceof Client\Adapter\Curl) { + throw new Exception\RuntimeException("The digest authentication is only available for curl adapters (Zend\\Http\\Client\\Adapter\\Curl)"); + } + + $this->adapter->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + $this->adapter->setCurlOption(CURLOPT_USERPWD, $this->auth['user'] . ':' . $this->auth['password']); } } @@ -1369,8 +1378,13 @@ class Client implements Stdlib\DispatchableInterface } } // HTTP connection - $this->lastRawRequest = $this->adapter->write($method, - $uri, $this->config['httpversion'], $headers, $body); + $this->lastRawRequest = $this->adapter->write( + $method, + $uri, + $this->config['httpversion'], + $headers, + $body + ); return $this->adapter->read(); } @@ -1388,8 +1402,6 @@ class Client implements Stdlib\DispatchableInterface */ public static function encodeAuthHeader($user, $password, $type = self::AUTH_BASIC) { - $authHeader = null; - switch ($type) { case self::AUTH_BASIC: // In basic authentication, the user name cannot contain ":" @@ -1397,8 +1409,7 @@ class Client implements Stdlib\DispatchableInterface throw new Client\Exception\InvalidArgumentException("The user name cannot contain ':' in 'Basic' HTTP authentication"); } - $authHeader = 'Basic ' . base64_encode($user . ':' . $password); - break; + return 'Basic ' . base64_encode($user . ':' . $password); //case self::AUTH_DIGEST: /** @@ -1410,6 +1421,7 @@ class Client implements Stdlib\DispatchableInterface throw new Client\Exception\InvalidArgumentException("Not a supported HTTP authentication type: '$type'"); } - return $authHeader; + + return; } } diff --git a/library/Zend/Http/Client/Adapter/AdapterInterface.php b/library/Zend/Http/Client/Adapter/AdapterInterface.php index 9e423ebb..f6fe0cfb 100644 --- a/library/Zend/Http/Client/Adapter/AdapterInterface.php +++ b/library/Zend/Http/Client/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Curl.php b/library/Zend/Http/Client/Adapter/Curl.php index f6421440..cdc406f6 100644 --- a/library/Zend/Http/Client/Adapter/Curl.php +++ b/library/Zend/Http/Client/Adapter/Curl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -72,7 +72,9 @@ class Curl implements HttpAdapter, StreamInterface public function __construct() { if (!extension_loaded('curl')) { - throw new AdapterException\InitializationException('cURL extension has to be loaded to use this Zend\Http\Client adapter'); + throw new AdapterException\InitializationException( + 'cURL extension has to be loaded to use this Zend\Http\Client adapter' + ); } $this->invalidOverwritableCurlOptions = array( CURLOPT_HTTPGET, @@ -82,14 +84,11 @@ class Curl implements HttpAdapter, StreamInterface CURLOPT_HEADER, CURLOPT_RETURNTRANSFER, CURLOPT_HTTPHEADER, - CURLOPT_POSTFIELDS, CURLOPT_INFILE, CURLOPT_INFILESIZE, CURLOPT_PORT, CURLOPT_MAXREDIRS, CURLOPT_CONNECTTIMEOUT, - CURL_HTTP_VERSION_1_1, - CURL_HTTP_VERSION_1_0, ); } @@ -122,6 +121,11 @@ class Curl implements HttpAdapter, StreamInterface unset($options['proxyuser'], $options['proxypass']); } + if (isset($options['sslverifypeer'])) { + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $options['sslverifypeer']); + unset($options['sslverifypeer']); + } + foreach ($options as $k => $v) { $option = strtolower($k); switch ($option) { @@ -144,14 +148,14 @@ class Curl implements HttpAdapter, StreamInterface } /** - * Retrieve the array of all configuration options - * - * @return array - */ - public function getConfig() - { - return $this->config; - } + * Retrieve the array of all configuration options + * + * @return array + */ + public function getConfig() + { + return $this->config; + } /** * Direct setter for cURL adapter related options. @@ -185,15 +189,6 @@ class Curl implements HttpAdapter, StreamInterface $this->close(); } - // If we are connected to a different server or port, disconnect first - if ($this->curl - && is_array($this->connectedTo) - && ($this->connectedTo[0] != $host - || $this->connectedTo[1] != $port) - ) { - $this->close(); - } - // Do the actual connection $this->curl = curl_init(); if ($port != 80) { @@ -248,7 +243,9 @@ class Curl implements HttpAdapter, StreamInterface * @param array $headers * @param string $body * @return string $request - * @throws AdapterException\RuntimeException If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option + * @throws AdapterException\RuntimeException If connection fails, connected + * to wrong host, no PUT file defined, unsupported method, or unsupported + * cURL option. * @throws AdapterException\InvalidArgumentException if $method is currently not supported */ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '') @@ -268,15 +265,15 @@ class Curl implements HttpAdapter, StreamInterface // ensure correct curl call $curlValue = true; switch ($method) { - case 'GET' : + case 'GET': $curlMethod = CURLOPT_HTTPGET; break; - case 'POST' : + case 'POST': $curlMethod = CURLOPT_POST; break; - case 'PUT' : + case 'PUT': // There are two different types of PUT request, either a Raw Data string has been set // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used. if (is_resource($body)) { @@ -288,7 +285,10 @@ class Curl implements HttpAdapter, StreamInterface if (!isset($headers['Content-Length']) && !isset($this->config['curloptions'][CURLOPT_INFILESIZE]) ) { - throw new AdapterException\RuntimeException("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE."); + throw new AdapterException\RuntimeException( + 'Cannot set a file-handle for cURL option CURLOPT_INFILE' + . ' without also setting its size in CURLOPT_INFILESIZE.' + ); } if (isset($headers['Content-Length'])) { @@ -307,27 +307,27 @@ class Curl implements HttpAdapter, StreamInterface } break; - case 'PATCH' : + case 'PATCH': $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "PATCH"; break; - case 'DELETE' : + case 'DELETE': $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "DELETE"; break; - case 'OPTIONS' : + case 'OPTIONS': $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "OPTIONS"; break; - case 'TRACE' : + case 'TRACE': $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "TRACE"; break; - case 'HEAD' : + case 'HEAD': $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "HEAD"; break; @@ -401,7 +401,10 @@ class Curl implements HttpAdapter, StreamInterface foreach ((array) $this->config['curloptions'] as $k => $v) { if (!in_array($k, $this->invalidOverwritableCurlOptions)) { if (curl_setopt($this->curl, $k, $v) == false) { - throw new AdapterException\RuntimeException(sprintf("Unknown or erroreous cURL option '%s' set", $k)); + throw new AdapterException\RuntimeException(sprintf( + 'Unknown or erroreous cURL option "%s" set', + $k + )); } } } @@ -422,35 +425,42 @@ class Curl implements HttpAdapter, StreamInterface throw new AdapterException\RuntimeException("Error in cURL request: " . curl_error($this->curl)); } - // cURL automatically decodes chunked-messages, this means we have to disallow the Zend\Http\Response to do it again - if (stripos($this->response, "Transfer-Encoding: chunked\r\n")) { - $this->response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->response); - } + // separating header from body because it is dangerous to accidentially replace strings in the body + $responseHeaderSize = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE); + $responseHeaders = substr($this->response, 0, $responseHeaderSize); + + // cURL automatically decodes chunked-messages, this means we have to + // disallow the Zend\Http\Response to do it again. + $responseHeaders = preg_replace("/Transfer-Encoding:\s*chunked\\r\\n/", "", $responseHeaders); // cURL can automatically handle content encoding; prevent double-decoding from occurring if (isset($this->config['curloptions'][CURLOPT_ENCODING]) && '' == $this->config['curloptions'][CURLOPT_ENCODING] - && stripos($this->response, "Content-Encoding: gzip\r\n") ) { - $this->response = str_ireplace("Content-Encoding: gzip\r\n", '', $this->response); + $responseHeaders = preg_replace("/Content-Encoding:\s*gzip\\r\\n/", '', $responseHeaders); } + // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string: + $responseHeaders = preg_replace( + "/HTTP\/1.0\s*200\s*Connection\s*established\\r\\n\\r\\n/", + '', + $responseHeaders + ); + + // replace old header with new, cleaned up, header + $this->response = substr_replace($this->response, $responseHeaders, 0, $responseHeaderSize); + // Eliminate multiple HTTP responses. do { - $parts = preg_split('|(?:\r?\n){2}|m', $this->response, 2); - $again = false; + $parts = preg_split('|(?:\r?\n){2}|m', $this->response, 2); + $again = false; if (isset($parts[1]) && preg_match("|^HTTP/1\.[01](.*?)\r\n|mi", $parts[1])) { - $this->response = $parts[1]; - $again = true; + $this->response = $parts[1]; + $again = true; } } while ($again); - // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string: - if (stripos($this->response, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) { - $this->response = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $this->response); - } - return $request; } diff --git a/library/Zend/Http/Client/Adapter/Exception/ExceptionInterface.php b/library/Zend/Http/Client/Adapter/Exception/ExceptionInterface.php index cedd1380..bf53840d 100644 --- a/library/Zend/Http/Client/Adapter/Exception/ExceptionInterface.php +++ b/library/Zend/Http/Client/Adapter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Exception/InitializationException.php b/library/Zend/Http/Client/Adapter/Exception/InitializationException.php index 3b0d3e80..c0c9e037 100644 --- a/library/Zend/Http/Client/Adapter/Exception/InitializationException.php +++ b/library/Zend/Http/Client/Adapter/Exception/InitializationException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Exception/InvalidArgumentException.php b/library/Zend/Http/Client/Adapter/Exception/InvalidArgumentException.php index f8c13481..5ba54691 100644 --- a/library/Zend/Http/Client/Adapter/Exception/InvalidArgumentException.php +++ b/library/Zend/Http/Client/Adapter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Exception/OutOfRangeException.php b/library/Zend/Http/Client/Adapter/Exception/OutOfRangeException.php index b9f97fb8..4fd0cbd0 100644 --- a/library/Zend/Http/Client/Adapter/Exception/OutOfRangeException.php +++ b/library/Zend/Http/Client/Adapter/Exception/OutOfRangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Exception/RuntimeException.php b/library/Zend/Http/Client/Adapter/Exception/RuntimeException.php index cc8396df..e6a9d4f3 100644 --- a/library/Zend/Http/Client/Adapter/Exception/RuntimeException.php +++ b/library/Zend/Http/Client/Adapter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Exception/TimeoutException.php b/library/Zend/Http/Client/Adapter/Exception/TimeoutException.php index f205246a..eb8a8e1f 100644 --- a/library/Zend/Http/Client/Adapter/Exception/TimeoutException.php +++ b/library/Zend/Http/Client/Adapter/Exception/TimeoutException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Proxy.php b/library/Zend/Http/Client/Adapter/Proxy.php index f66155a5..e4875dac 100644 --- a/library/Zend/Http/Client/Adapter/Proxy.php +++ b/library/Zend/Http/Client/Adapter/Proxy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -204,7 +204,7 @@ class Proxy extends Socket protected function connectHandshake($host, $port = 443, $httpVer = '1.1', array &$headers = array()) { $request = "CONNECT $host:$port HTTP/$httpVer\r\n" . - "Host: " . $this->config['proxy_host'] . "\r\n"; + "Host: " . $host . "\r\n"; // Add the user-agent header if (isset($this->config['useragent'])) { diff --git a/library/Zend/Http/Client/Adapter/Socket.php b/library/Zend/Http/Client/Adapter/Socket.php index 010a766c..aceb54dc 100644 --- a/library/Zend/Http/Client/Adapter/Socket.php +++ b/library/Zend/Http/Client/Adapter/Socket.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/StreamInterface.php b/library/Zend/Http/Client/Adapter/StreamInterface.php index 6dd1a504..63ca174d 100644 --- a/library/Zend/Http/Client/Adapter/StreamInterface.php +++ b/library/Zend/Http/Client/Adapter/StreamInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Adapter/Test.php b/library/Zend/Http/Client/Adapter/Test.php index 0d9b0234..23c6be0d 100644 --- a/library/Zend/Http/Client/Adapter/Test.php +++ b/library/Zend/Http/Client/Adapter/Test.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -124,9 +124,6 @@ class Test implements AdapterInterface */ public function write($method, $uri, $httpVer = '1.1', $headers = array(), $body = '') { - $host = $uri->getHost(); - $host = (strtolower($uri->getScheme()) == 'https' ? 'sslv2://' . $host : $host); - // Build request headers $path = $uri->getPath(); if (empty($path)) { diff --git a/library/Zend/Http/Client/Exception/ExceptionInterface.php b/library/Zend/Http/Client/Exception/ExceptionInterface.php index eeb74f29..aba1a69a 100644 --- a/library/Zend/Http/Client/Exception/ExceptionInterface.php +++ b/library/Zend/Http/Client/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Exception/InvalidArgumentException.php b/library/Zend/Http/Client/Exception/InvalidArgumentException.php index 1e30969b..bac8ed32 100644 --- a/library/Zend/Http/Client/Exception/InvalidArgumentException.php +++ b/library/Zend/Http/Client/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Exception/OutOfRangeException.php b/library/Zend/Http/Client/Exception/OutOfRangeException.php index 21f1730f..2de55df6 100644 --- a/library/Zend/Http/Client/Exception/OutOfRangeException.php +++ b/library/Zend/Http/Client/Exception/OutOfRangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Client/Exception/RuntimeException.php b/library/Zend/Http/Client/Exception/RuntimeException.php index 430e0500..39010f06 100644 --- a/library/Zend/Http/Client/Exception/RuntimeException.php +++ b/library/Zend/Http/Client/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/ClientStatic.php b/library/Zend/Http/ClientStatic.php index 020fa07e..4695a56c 100644 --- a/library/Zend/Http/ClientStatic.php +++ b/library/Zend/Http/ClientStatic.php @@ -3,29 +3,32 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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; - /** * Http static client */ class ClientStatic { + /** + * @var Client + */ protected static $client; /** * Get the static HTTP client * + * @param array|Traversable $options * @return Client */ - protected static function getStaticClient() + protected static function getStaticClient($options = null) { - if (!isset(static::$client)) { - static::$client = new Client(); + if (!isset(static::$client) || $options !== null) { + static::$client = new Client(null, $options); } return static::$client; } @@ -37,9 +40,10 @@ class ClientStatic * @param array $query * @param array $headers * @param mixed $body + * @param array|Traversable $clientOptions * @return Response|bool */ - public static function get($url, $query = array(), $headers = array(), $body = null) + public static function get($url, $query = array(), $headers = array(), $body = null, $clientOptions = null) { if (empty($url)) { return false; @@ -61,7 +65,7 @@ class ClientStatic $request->setContent($body); } - return static::getStaticClient()->send($request); + return static::getStaticClient($clientOptions)->send($request); } /** @@ -71,10 +75,11 @@ class ClientStatic * @param array $params * @param array $headers * @param mixed $body + * @param array|Traversable $clientOptions * @throws Exception\InvalidArgumentException * @return Response|bool */ - public static function post($url, $params, $headers = array(), $body = null) + public static function post($url, $params, $headers = array(), $body = null, $clientOptions = null) { if (empty($url)) { return false; @@ -91,7 +96,7 @@ class ClientStatic } if (!isset($headers['Content-Type'])) { - $headers['Content-Type']= Client::ENC_URLENCODED; + $headers['Content-Type'] = Client::ENC_URLENCODED; } if (!empty($headers) && is_array($headers)) { @@ -102,6 +107,6 @@ class ClientStatic $request->setContent($body); } - return static::getStaticClient()->send($request); + return static::getStaticClient($clientOptions)->send($request); } } diff --git a/library/Zend/Http/Cookies.php b/library/Zend/Http/Cookies.php index 7d4ac275..725c0621 100644 --- a/library/Zend/Http/Cookies.php +++ b/library/Zend/Http/Cookies.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,7 +13,6 @@ use ArrayIterator; use Zend\Http\Header\SetCookie; use Zend\Uri; - /** * A Zend\Http\Cookies object is designed to contain and maintain HTTP cookies, and should * be used along with Zend\Http\Client in order to manage cookies across HTTP requests and @@ -60,7 +59,7 @@ class Cookies extends Headers const COOKIE_STRING_CONCAT_STRICT = 3; /** - * @var \Zend\Http\Cookies + * @var array */ protected $cookies = array(); @@ -161,9 +160,12 @@ class Cookies extends Headers * @throws Exception\InvalidArgumentException if invalid URI specified * @return array|string */ - public function getMatchingCookies($uri, $matchSessionCookies = true, - $retAs = self::COOKIE_OBJECT, $now = null) - { + public function getMatchingCookies( + $uri, + $matchSessionCookies = true, + $retAs = self::COOKIE_OBJECT, + $now = null + ) { if (is_string($uri)) { $uri = Uri\UriFactory::factory($uri, 'http'); } elseif (!$uri instanceof Uri\Uri) { @@ -217,7 +219,8 @@ class Cookies extends Headers // Get correct cookie path $path = $uri->getPath(); - $path = substr($path, 0, strrpos($path, '/')); + $lastSlashPos = strrpos($path, '/') ?: 0; + $path = substr($path, 0, $lastSlashPos); if (! $path) { $path = '/'; } @@ -228,16 +231,13 @@ class Cookies extends Headers switch ($retAs) { case self::COOKIE_OBJECT: return $cookie; - break; case self::COOKIE_STRING_ARRAY: case self::COOKIE_STRING_CONCAT: return $cookie->__toString(); - break; default: throw new Exception\InvalidArgumentException("Invalid value passed for \$retAs: {$retAs}"); - break; } } @@ -268,20 +268,17 @@ class Cookies extends Headers switch ($retAs) { case self::COOKIE_STRING_ARRAY: return array($ptr->__toString()); - break; case self::COOKIE_STRING_CONCAT: return $ptr->__toString(); - break; case self::COOKIE_OBJECT: default: return array($ptr); - break; } } - return null; + return; } /** diff --git a/library/Zend/Http/Exception/ExceptionInterface.php b/library/Zend/Http/Exception/ExceptionInterface.php index b58caddf..365c90aa 100644 --- a/library/Zend/Http/Exception/ExceptionInterface.php +++ b/library/Zend/Http/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Exception/InvalidArgumentException.php b/library/Zend/Http/Exception/InvalidArgumentException.php index fb20cde7..92671693 100644 --- a/library/Zend/Http/Exception/InvalidArgumentException.php +++ b/library/Zend/Http/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Exception/OutOfRangeException.php b/library/Zend/Http/Exception/OutOfRangeException.php index 5d1b20e3..e3e0fd15 100644 --- a/library/Zend/Http/Exception/OutOfRangeException.php +++ b/library/Zend/Http/Exception/OutOfRangeException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Exception; -class OutOfRangeException extends \OutOfRangeException implements - ExceptionInterface +class OutOfRangeException extends \OutOfRangeException implements ExceptionInterface { } diff --git a/library/Zend/Http/Exception/RuntimeException.php b/library/Zend/Http/Exception/RuntimeException.php index 9f1ed68e..6b924eb7 100644 --- a/library/Zend/Http/Exception/RuntimeException.php +++ b/library/Zend/Http/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/AbstractAccept.php b/library/Zend/Http/Header/AbstractAccept.php index ec11a906..e8f09728 100644 --- a/library/Zend/Http/Header/AbstractAccept.php +++ b/library/Zend/Http/Header/AbstractAccept.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -53,7 +53,6 @@ abstract class AbstractAccept implements HeaderInterface */ protected $sorted = false; - /** * Parse a full header line or just the field value part. * @@ -70,6 +69,8 @@ abstract class AbstractAccept implements HeaderInterface $value = $headerLine; } + HeaderValue::assertValid($value); + foreach ($this->getFieldValuePartsFromHeaderLine($value) as $value) { $this->addFieldValuePartToQueue($value); } @@ -102,14 +103,13 @@ abstract class AbstractAccept implements HeaderInterface || !isset($values[0]) ) { throw new Exception\InvalidArgumentException( - 'Invalid header line for ' . $this->getFieldName() . ' header string' + 'Invalid header line for ' . $this->getFieldName() . ' header string' ); } $out = array(); foreach ($values[0] as $value) { $value = trim($value); - $out[] = $this->parseFieldValuePart($value); } @@ -182,7 +182,6 @@ abstract class AbstractAccept implements HeaderInterface return $params; } - /** * Get field value * @@ -205,7 +204,6 @@ abstract class AbstractAccept implements HeaderInterface return implode(', ', $strings); } - /** * Assemble and escape the field value parameters based on RFC 2616 section 2.1 * @@ -219,7 +217,8 @@ abstract class AbstractAccept implements HeaderInterface $separators = array('(', ')', '<', '>', '@', ',', ';', ':', '/', '[', ']', '?', '=', '{', '}', ' ', "\t"); - $escaped = preg_replace_callback('/[[:cntrl:]"\\\\]/', // escape cntrl, ", \ + $escaped = preg_replace_callback( + '/[[:cntrl:]"\\\\]/', // escape cntrl, ", \ function ($v) { return '\\' . $v[0]; }, @@ -269,15 +268,14 @@ abstract class AbstractAccept implements HeaderInterface } $assembledString = $this->getFieldValue( - array((object) array('typeString' => $type, 'params' => $params)) - ); + array((object) array('typeString' => $type, 'params' => $params)) + ); $value = $this->parseFieldValuePart($assembledString); $this->addFieldValuePartToQueue($value); return $this; } - /** * Does the header have the requested type? * @@ -375,7 +373,6 @@ abstract class AbstractAccept implements HeaderInterface return $match1; } - /** * Add a key/value combination to the internal queue * diff --git a/library/Zend/Http/Header/AbstractDate.php b/library/Zend/Http/Header/AbstractDate.php index 5990dc4f..e0283547 100644 --- a/library/Zend/Http/Header/AbstractDate.php +++ b/library/Zend/Http/Header/AbstractDate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -88,6 +88,44 @@ abstract class AbstractDate implements HeaderInterface return $dateHeader; } + /** + * Create date-based header from strtotime()-compatible string + * + * @param int|string $time + * + * @return self + * + * @throws Exception\InvalidArgumentException + */ + public static function fromTimeString($time) + { + return static::fromTimestamp(strtotime($time)); + } + + /** + * Create date-based header from Unix timestamp + * + * @param int $time + * + * @return self + * + * @throws Exception\InvalidArgumentException + */ + public static function fromTimestamp($time) + { + $dateHeader = new static(); + + if (! $time || ! is_numeric($time)) { + throw new Exception\InvalidArgumentException( + 'Invalid time for "' . $dateHeader->getFieldName() . '" header string' + ); + } + + $dateHeader->setDate(new DateTime('@' . $time)); + + return $dateHeader; + } + /** * Set date output format * diff --git a/library/Zend/Http/Header/AbstractLocation.php b/library/Zend/Http/Header/AbstractLocation.php index 12088cc9..d493be3b 100644 --- a/library/Zend/Http/Header/AbstractLocation.php +++ b/library/Zend/Http/Header/AbstractLocation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,7 +13,6 @@ use Zend\Uri\Exception as UriException; use Zend\Uri\UriFactory; use Zend\Uri\UriInterface; - /** * Abstract Location Header * Supports headers that have URI as value @@ -55,6 +54,7 @@ abstract class AbstractLocation implements HeaderInterface ); } + HeaderValue::assertValid($uri); $locationHeader->setUri(trim($uri)); return $locationHeader; @@ -74,9 +74,9 @@ abstract class AbstractLocation implements HeaderInterface $uri = UriFactory::factory($uri); } catch (UriException\InvalidUriPartException $e) { throw new Exception\InvalidArgumentException( - sprintf('Invalid URI passed as string (%s)', (string) $uri), - $e->getCode(), - $e + sprintf('Invalid URI passed as string (%s)', (string) $uri), + $e->getCode(), + $e ); } } elseif (!($uri instanceof UriInterface)) { diff --git a/library/Zend/Http/Header/Accept.php b/library/Zend/Http/Header/Accept.php index 2c344d35..6f2fe1de 100644 --- a/library/Zend/Http/Header/Accept.php +++ b/library/Zend/Http/Header/Accept.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -80,7 +80,7 @@ class Accept extends AbstractAccept if ($pos = strpos($fieldValuePart, '/')) { $type = trim(substr($fieldValuePart, 0, $pos)); } else { - $type = trim(substr($fieldValuePart, 0)); + $type = trim($fieldValuePart); } $params = $this->getParametersFromFieldValuePart($fieldValuePart); @@ -89,7 +89,7 @@ class Accept extends AbstractAccept $fieldValuePart = trim(substr($fieldValuePart, 0, $pos)); } - if ($pos = strpos($fieldValuePart, '/')) { + if (strpos($fieldValuePart, '/')) { $subtypeWhole = $format = $subtype = trim(substr($fieldValuePart, strpos($fieldValuePart, '/') + 1)); } else { $subtypeWhole = ''; diff --git a/library/Zend/Http/Header/Accept/FieldValuePart/AbstractFieldValuePart.php b/library/Zend/Http/Header/Accept/FieldValuePart/AbstractFieldValuePart.php index 1dd1b7ae..2c1c1096 100644 --- a/library/Zend/Http/Header/Accept/FieldValuePart/AbstractFieldValuePart.php +++ b/library/Zend/Http/Header/Accept/FieldValuePart/AbstractFieldValuePart.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Accept/FieldValuePart/AcceptFieldValuePart.php b/library/Zend/Http/Header/Accept/FieldValuePart/AcceptFieldValuePart.php index 15e2de99..e8e2ef1c 100644 --- a/library/Zend/Http/Header/Accept/FieldValuePart/AcceptFieldValuePart.php +++ b/library/Zend/Http/Header/Accept/FieldValuePart/AcceptFieldValuePart.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Accept/FieldValuePart/CharsetFieldValuePart.php b/library/Zend/Http/Header/Accept/FieldValuePart/CharsetFieldValuePart.php index 38fb0178..9956d795 100644 --- a/library/Zend/Http/Header/Accept/FieldValuePart/CharsetFieldValuePart.php +++ b/library/Zend/Http/Header/Accept/FieldValuePart/CharsetFieldValuePart.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Accept/FieldValuePart/EncodingFieldValuePart.php b/library/Zend/Http/Header/Accept/FieldValuePart/EncodingFieldValuePart.php index 06e0b76a..af73becd 100644 --- a/library/Zend/Http/Header/Accept/FieldValuePart/EncodingFieldValuePart.php +++ b/library/Zend/Http/Header/Accept/FieldValuePart/EncodingFieldValuePart.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Accept/FieldValuePart/LanguageFieldValuePart.php b/library/Zend/Http/Header/Accept/FieldValuePart/LanguageFieldValuePart.php index a58b232a..a5b34512 100644 --- a/library/Zend/Http/Header/Accept/FieldValuePart/LanguageFieldValuePart.php +++ b/library/Zend/Http/Header/Accept/FieldValuePart/LanguageFieldValuePart.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/AcceptCharset.php b/library/Zend/Http/Header/AcceptCharset.php index 5c49c93d..cd80e752 100644 --- a/library/Zend/Http/Header/AcceptCharset.php +++ b/library/Zend/Http/Header/AcceptCharset.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/AcceptEncoding.php b/library/Zend/Http/Header/AcceptEncoding.php index 2b9ee519..d5bea1ef 100644 --- a/library/Zend/Http/Header/AcceptEncoding.php +++ b/library/Zend/Http/Header/AcceptEncoding.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/AcceptLanguage.php b/library/Zend/Http/Header/AcceptLanguage.php index 256c9562..5b25271a 100644 --- a/library/Zend/Http/Header/AcceptLanguage.php +++ b/library/Zend/Http/Header/AcceptLanguage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -85,7 +85,7 @@ class AcceptLanguage extends AbstractAccept $fieldValuePart = $type = trim(substr($fieldValuePart, 0, $pos)); } - if ($pos = strpos($fieldValuePart, '-')) { + if (strpos($fieldValuePart, '-')) { $subtypeWhole = $format = $subtype = trim(substr($fieldValuePart, strpos($fieldValuePart, '-')+1)); } else { $subtypeWhole = ''; diff --git a/library/Zend/Http/Header/AcceptRanges.php b/library/Zend/Http/Header/AcceptRanges.php index f1827c17..2f1c73ad 100644 --- a/library/Zend/Http/Header/AcceptRanges.php +++ b/library/Zend/Http/Header/AcceptRanges.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,7 +24,9 @@ class AcceptRanges implements HeaderInterface // check to ensure proper header type for this factory 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); @@ -34,7 +36,9 @@ class AcceptRanges implements HeaderInterface public function __construct($rangeUnit = null) { - $this->rangeUnit = $rangeUnit; + if ($rangeUnit) { + $this->setRangeUnit($rangeUnit); + } } public function getFieldName() @@ -49,6 +53,7 @@ class AcceptRanges implements HeaderInterface public function setRangeUnit($rangeUnit) { + HeaderValue::assertValid($rangeUnit); $this->rangeUnit = $rangeUnit; return $this; } diff --git a/library/Zend/Http/Header/Age.php b/library/Zend/Http/Header/Age.php index 633614b0..a1197466 100644 --- a/library/Zend/Http/Header/Age.php +++ b/library/Zend/Http/Header/Age.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -79,6 +79,9 @@ class Age implements HeaderInterface */ public function setDeltaSeconds($delta) { + if (! is_int($delta) && ! is_numeric($delta)) { + throw new Exception\InvalidArgumentException('Invalid delta provided'); + } $this->deltaSeconds = (int) $delta; return $this; } diff --git a/library/Zend/Http/Header/Allow.php b/library/Zend/Http/Header/Allow.php index e1f4e75b..42401798 100644 --- a/library/Zend/Http/Header/Allow.php +++ b/library/Zend/Http/Header/Allow.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -110,6 +110,12 @@ class Allow implements HeaderInterface { foreach ((array) $allowedMethods as $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; } @@ -126,6 +132,12 @@ class Allow implements HeaderInterface { foreach ((array) $disallowedMethods as $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; } diff --git a/library/Zend/Http/Header/AuthenticationInfo.php b/library/Zend/Http/Header/AuthenticationInfo.php index a35cebc6..c9df1f4a 100644 --- a/library/Zend/Http/Header/AuthenticationInfo.php +++ b/library/Zend/Http/Header/AuthenticationInfo.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class AuthenticationInfo implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class AuthenticationInfo implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class AuthenticationInfo implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Authorization.php b/library/Zend/Http/Header/Authorization.php index 98ee0307..4a5bcfd6 100644 --- a/library/Zend/Http/Header/Authorization.php +++ b/library/Zend/Http/Header/Authorization.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Authorization implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class Authorization implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class Authorization implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/CacheControl.php b/library/Zend/Http/Header/CacheControl.php index ef92ecfd..05e63af9 100644 --- a/library/Zend/Http/Header/CacheControl.php +++ b/library/Zend/Http/Header/CacheControl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class CacheControl implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; /** @@ -38,9 +40,13 @@ class CacheControl implements HeaderInterface // check to ensure proper header type for this factory if (strtolower($name) !== 'cache-control') { - throw new Exception\InvalidArgumentException('Invalid header line for Cache-Control string: "' . $name . '"'); + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid header line for Cache-Control string: ""', + $name + )); } + HeaderValue::assertValid($value); $directives = static::parseValue($value); // @todo implementation details @@ -83,6 +89,10 @@ class CacheControl implements HeaderInterface */ public function addDirective($key, $value = true) { + HeaderValue::assertValid($key); + if (! is_bool($value)) { + HeaderValue::assertValid($value); + } $this->directives[$key] = $value; return $this; } @@ -179,11 +189,10 @@ class CacheControl implements HeaderInterface case 0: $directive = $lastMatch; goto state_value; - break; + // intentional fall-through default: throw new Exception\InvalidArgumentException('expected DIRECTIVE'); - break; } state_value: @@ -191,32 +200,29 @@ class CacheControl implements HeaderInterface case 0: $directives[$directive] = substr($lastMatch, 2, -1); goto state_separator; - break; + // intentional fall-through case 1: $directives[$directive] = rtrim(substr($lastMatch, 1)); goto state_separator; - break; + // intentional fall-through default: $directives[$directive] = true; goto state_separator; - break; } state_separator: switch (static::match(array('\s*,\s*', '$'), $value, $lastMatch)) { case 0: goto state_directive; - break; + // intentional fall-through case 1: return $directives; - break; default: throw new Exception\InvalidArgumentException('expected SEPARATOR or END'); - break; } } @@ -231,10 +237,13 @@ class CacheControl implements HeaderInterface */ protected static function match($tokens, &$string, &$lastMatch) { + // Ensure we have a string + $value = (string) $string; + foreach ($tokens as $i => $token) { - if (preg_match('/^' . $token . '/', $string, $matches)) { + if (preg_match('/^' . $token . '/', $value, $matches)) { $lastMatch = $matches[0]; - $string = substr($string, strlen($matches[0])); + $string = substr($value, strlen($matches[0])); return $i; } } diff --git a/library/Zend/Http/Header/Connection.php b/library/Zend/Http/Header/Connection.php index 16cb1258..739fb13a 100644 --- a/library/Zend/Http/Header/Connection.php +++ b/library/Zend/Http/Header/Connection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -47,7 +47,6 @@ class Connection implements HeaderInterface return $header; } - /** * Set Connection header to define persistent connection * @@ -56,11 +55,9 @@ class Connection implements HeaderInterface */ public function setPersistent($flag) { - if ((bool) $flag === true) { - $this->value = self::CONNECTION_KEEP_ALIVE; - } else { - $this->value = self::CONNECTION_CLOSE; - } + $this->value = (bool) $flag + ? self::CONNECTION_KEEP_ALIVE + : self::CONNECTION_CLOSE; return $this; } @@ -83,11 +80,11 @@ class Connection implements HeaderInterface */ public function setValue($value) { + HeaderValue::assertValid($value); $this->value = strtolower($value); return $this; } - /** * Connection header name * diff --git a/library/Zend/Http/Header/ContentDisposition.php b/library/Zend/Http/Header/ContentDisposition.php index 60b1f7a5..508fbfcd 100644 --- a/library/Zend/Http/Header/ContentDisposition.php +++ b/library/Zend/Http/Header/ContentDisposition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentDisposition implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ContentDisposition implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class ContentDisposition implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentEncoding.php b/library/Zend/Http/Header/ContentEncoding.php index b3a99478..a6c64287 100644 --- a/library/Zend/Http/Header/ContentEncoding.php +++ b/library/Zend/Http/Header/ContentEncoding.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentEncoding implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,9 @@ class ContentEncoding implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +39,10 @@ class ContentEncoding implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentLanguage.php b/library/Zend/Http/Header/ContentLanguage.php index d0250ccd..58d320b5 100644 --- a/library/Zend/Http/Header/ContentLanguage.php +++ b/library/Zend/Http/Header/ContentLanguage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentLanguage implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ContentLanguage implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class ContentLanguage implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentLength.php b/library/Zend/Http/Header/ContentLength.php index e4c89862..7b89798a 100644 --- a/library/Zend/Http/Header/ContentLength.php +++ b/library/Zend/Http/Header/ContentLength.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentLength implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ContentLength implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class ContentLength implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentLocation.php b/library/Zend/Http/Header/ContentLocation.php index 018761d2..5238e36d 100644 --- a/library/Zend/Http/Header/ContentLocation.php +++ b/library/Zend/Http/Header/ContentLocation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/ContentMD5.php b/library/Zend/Http/Header/ContentMD5.php index a120319a..7cd6006e 100644 --- a/library/Zend/Http/Header/ContentMD5.php +++ b/library/Zend/Http/Header/ContentMD5.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentMD5 implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class ContentMD5 implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentRange.php b/library/Zend/Http/Header/ContentRange.php index 4c3f473d..c23f921e 100644 --- a/library/Zend/Http/Header/ContentRange.php +++ b/library/Zend/Http/Header/ContentRange.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentRange implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ContentRange implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class ContentRange implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentSecurityPolicy.php b/library/Zend/Http/Header/ContentSecurityPolicy.php index 5ddb5335..e149db2b 100644 --- a/library/Zend/Http/Header/ContentSecurityPolicy.php +++ b/library/Zend/Http/Header/ContentSecurityPolicy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -65,7 +65,7 @@ class ContentSecurityPolicy implements HeaderInterface */ 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( '%s expects a valid directive name; received "%s"', __METHOD__, @@ -74,9 +74,12 @@ class ContentSecurityPolicy implements HeaderInterface } if (empty($sources)) { $this->directives[$name] = "'none'"; - } else { - $this->directives[$name] = implode(' ', $sources); + return $this; } + + array_walk($sources, array(__NAMESPACE__ . '\HeaderValue', 'assertValid')); + + $this->directives[$name] = implode(' ', $sources); return $this; } @@ -107,7 +110,7 @@ class ContentSecurityPolicy implements HeaderInterface if ($token) { list($directiveName, $directiveValue) = explode(' ', $token, 2); if (!isset($header->directives[$directiveName])) { - $header->directives[$directiveName] = $directiveValue; + $header->setDirective($directiveName, array($directiveValue)); } } } diff --git a/library/Zend/Http/Header/ContentTransferEncoding.php b/library/Zend/Http/Header/ContentTransferEncoding.php index 6e44a9ad..480fb44c 100644 --- a/library/Zend/Http/Header/ContentTransferEncoding.php +++ b/library/Zend/Http/Header/ContentTransferEncoding.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ContentTransferEncoding implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ContentTransferEncoding implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class ContentTransferEncoding implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ContentType.php b/library/Zend/Http/Header/ContentType.php index df679549..c7d0c28c 100644 --- a/library/Zend/Http/Header/ContentType.php +++ b/library/Zend/Http/Header/ContentType.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -44,7 +44,10 @@ class ContentType implements HeaderInterface // check to ensure proper header type for this factory 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); @@ -55,7 +58,7 @@ class ContentType implements HeaderInterface $parameters = array(); foreach ($parts as $parameter) { $parameter = trim($parameter); - if (!preg_match('/^(?P[^\s\=]+)\=(?P[^\s\=]*)$/', $parameter, $matches)) { + if (!preg_match('/^(?P[^\s\=]+)\="?(?P[^\s\"]*)"?$/', $parameter, $matches)) { continue; } $parameters[$matches['key']] = $matches['value']; @@ -68,7 +71,10 @@ class ContentType implements HeaderInterface public function __construct($value = null, $mediaType = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } $this->mediaType = $mediaType; } @@ -155,6 +161,7 @@ class ContentType implements HeaderInterface */ public function setMediaType($mediaType) { + HeaderValue::assertValid($mediaType); $this->mediaType = strtolower($mediaType); $this->value = null; return $this; @@ -178,6 +185,10 @@ class ContentType implements HeaderInterface */ public function setParameters(array $parameters) { + foreach ($parameters as $key => $value) { + HeaderValue::assertValid($key); + HeaderValue::assertValid($value); + } $this->parameters = array_merge($this->parameters, $parameters); $this->value = null; return $this; @@ -201,6 +212,7 @@ class ContentType implements HeaderInterface */ public function setCharset($charset) { + HeaderValue::assertValid($charset); $this->parameters['charset'] = $charset; $this->value = null; return $this; @@ -216,7 +228,7 @@ class ContentType implements HeaderInterface if (isset($this->parameters['charset'])) { return $this->parameters['charset']; } - return null; + return; } /** diff --git a/library/Zend/Http/Header/Cookie.php b/library/Zend/Http/Header/Cookie.php index d26ae004..5cbac5e5 100644 --- a/library/Zend/Http/Header/Cookie.php +++ b/library/Zend/Http/Header/Cookie.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -22,17 +22,25 @@ class Cookie extends ArrayObject implements HeaderInterface public static function fromSetCookieArray(array $setCookies) { $nvPairs = array(); - /* @var $setCookie SetCookie */ + foreach ($setCookies as $setCookie) { - if (!$setCookie instanceof SetCookie) { - throw new Exception\InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . ' requires an array of SetCookie objects'); + if (! $setCookie instanceof SetCookie) { + throw new Exception\InvalidArgumentException(sprintf( + '%s requires an array of SetCookie objects', + __METHOD__ + )); } + 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(); } + return new static($nvPairs); } diff --git a/library/Zend/Http/Header/Date.php b/library/Zend/Http/Header/Date.php index f310da10..7b260664 100644 --- a/library/Zend/Http/Header/Date.php +++ b/library/Zend/Http/Header/Date.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Etag.php b/library/Zend/Http/Header/Etag.php index 94acb8e4..8f23d7f9 100644 --- a/library/Zend/Http/Header/Etag.php +++ b/library/Zend/Http/Header/Etag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Etag implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Etag implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Exception/DomainException.php b/library/Zend/Http/Header/Exception/DomainException.php index dc3f03f8..c826e642 100644 --- a/library/Zend/Http/Header/Exception/DomainException.php +++ b/library/Zend/Http/Header/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Exception/ExceptionInterface.php b/library/Zend/Http/Header/Exception/ExceptionInterface.php index c106c2d2..c4d10698 100644 --- a/library/Zend/Http/Header/Exception/ExceptionInterface.php +++ b/library/Zend/Http/Header/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Exception/InvalidArgumentException.php b/library/Zend/Http/Header/Exception/InvalidArgumentException.php index aaf366e3..06aa79fd 100644 --- a/library/Zend/Http/Header/Exception/InvalidArgumentException.php +++ b/library/Zend/Http/Header/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Exception/RuntimeException.php b/library/Zend/Http/Header/Exception/RuntimeException.php index 097b3819..467d626d 100644 --- a/library/Zend/Http/Header/Exception/RuntimeException.php +++ b/library/Zend/Http/Header/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Expect.php b/library/Zend/Http/Header/Expect.php index 4e2bc54e..d6eb7433 100644 --- a/library/Zend/Http/Header/Expect.php +++ b/library/Zend/Http/Header/Expect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Expect implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Expect implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Expires.php b/library/Zend/Http/Header/Expires.php index 82e8d89c..ff2de5c8 100644 --- a/library/Zend/Http/Header/Expires.php +++ b/library/Zend/Http/Header/Expires.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/From.php b/library/Zend/Http/Header/From.php index 95a007b9..505080d4 100644 --- a/library/Zend/Http/Header/From.php +++ b/library/Zend/Http/Header/From.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class From implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class From implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/GenericHeader.php b/library/Zend/Http/Header/GenericHeader.php index 81fa5217..d17c8e16 100644 --- a/library/Zend/Http/Header/GenericHeader.php +++ b/library/Zend/Http/Header/GenericHeader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -53,6 +53,10 @@ class GenericHeader implements HeaderInterface 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]); return $parts; @@ -88,20 +92,18 @@ class GenericHeader implements HeaderInterface throw new Exception\InvalidArgumentException('Header name must be a string'); } - // Pre-filter to normalize valid characters, change underscore to dash - $fieldName = str_replace('_', '-', $fieldName); - /* - * Following RFC 2616 section 4.2 + * Following RFC 7230 section 3.2 * - * message-header = field-name ":" [ field-value ] - * field-name = token - * - * @see http://tools.ietf.org/html/rfc2616#section-2.2 for token definition. + * header-field = field-name ":" [ field-value ] + * field-name = token + * token = 1*tchar + * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / + * "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA */ - if (!preg_match('/^[!#-\'*+\-\.0-9A-Z\^-z|~]+$/', $fieldName)) { + if (!preg_match('/^[!#$%&\'*+\-\.\^_`|~0-9a-zA-Z]+$/', $fieldName)) { throw new Exception\InvalidArgumentException( - 'Header name must be a valid RFC 2616 (section 4.2) field-name.' + 'Header name must be a valid RFC 7230 (section 3.2) field-name.' ); } @@ -128,6 +130,7 @@ class GenericHeader implements HeaderInterface public function setFieldValue($fieldValue) { $fieldValue = (string) $fieldValue; + HeaderValue::assertValid($fieldValue); if (preg_match('/^\s+$/', $fieldValue)) { $fieldValue = ''; diff --git a/library/Zend/Http/Header/GenericMultiHeader.php b/library/Zend/Http/Header/GenericMultiHeader.php index 62e1c271..90c1f966 100644 --- a/library/Zend/Http/Header/GenericMultiHeader.php +++ b/library/Zend/Http/Header/GenericMultiHeader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/HeaderInterface.php b/library/Zend/Http/Header/HeaderInterface.php index 1cd2e465..ba285f37 100644 --- a/library/Zend/Http/Header/HeaderInterface.php +++ b/library/Zend/Http/Header/HeaderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/HeaderValue.php b/library/Zend/Http/Header/HeaderValue.php new file mode 100644 index 00000000..a16e22e4 --- /dev/null +++ b/library/Zend/Http/Header/HeaderValue.php @@ -0,0 +1,107 @@ + 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'); + } + } +} diff --git a/library/Zend/Http/Header/Host.php b/library/Zend/Http/Header/Host.php index 904579df..ada179ac 100644 --- a/library/Zend/Http/Header/Host.php +++ b/library/Zend/Http/Header/Host.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Host implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Host implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/IfMatch.php b/library/Zend/Http/Header/IfMatch.php index a190ea77..e4e40b25 100644 --- a/library/Zend/Http/Header/IfMatch.php +++ b/library/Zend/Http/Header/IfMatch.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class IfMatch implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class IfMatch implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/IfModifiedSince.php b/library/Zend/Http/Header/IfModifiedSince.php index d8d9f9a6..329fbc52 100644 --- a/library/Zend/Http/Header/IfModifiedSince.php +++ b/library/Zend/Http/Header/IfModifiedSince.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/IfNoneMatch.php b/library/Zend/Http/Header/IfNoneMatch.php index 06f63276..f7e8605a 100644 --- a/library/Zend/Http/Header/IfNoneMatch.php +++ b/library/Zend/Http/Header/IfNoneMatch.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class IfNoneMatch implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class IfNoneMatch implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class IfNoneMatch implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/IfRange.php b/library/Zend/Http/Header/IfRange.php index ed7f78b8..59231583 100644 --- a/library/Zend/Http/Header/IfRange.php +++ b/library/Zend/Http/Header/IfRange.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class IfRange implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class IfRange implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/IfUnmodifiedSince.php b/library/Zend/Http/Header/IfUnmodifiedSince.php index 2615596a..4a1b35c8 100644 --- a/library/Zend/Http/Header/IfUnmodifiedSince.php +++ b/library/Zend/Http/Header/IfUnmodifiedSince.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/KeepAlive.php b/library/Zend/Http/Header/KeepAlive.php index 5178f84b..10486bd2 100644 --- a/library/Zend/Http/Header/KeepAlive.php +++ b/library/Zend/Http/Header/KeepAlive.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class KeepAlive implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class KeepAlive implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/LastModified.php b/library/Zend/Http/Header/LastModified.php index d9ea8bdb..8f30f57b 100644 --- a/library/Zend/Http/Header/LastModified.php +++ b/library/Zend/Http/Header/LastModified.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Location.php b/library/Zend/Http/Header/Location.php index 8d391ebf..5fa93f1e 100644 --- a/library/Zend/Http/Header/Location.php +++ b/library/Zend/Http/Header/Location.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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; - /** * Location Header * diff --git a/library/Zend/Http/Header/MaxForwards.php b/library/Zend/Http/Header/MaxForwards.php index 99e5a895..4d4b1620 100644 --- a/library/Zend/Http/Header/MaxForwards.php +++ b/library/Zend/Http/Header/MaxForwards.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class MaxForwards implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class MaxForwards implements HeaderInterface // check to ensure proper header type for this factory 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 @@ -35,7 +40,10 @@ class MaxForwards implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/MultipleHeaderInterface.php b/library/Zend/Http/Header/MultipleHeaderInterface.php index 3034f7b4..b6b5246c 100644 --- a/library/Zend/Http/Header/MultipleHeaderInterface.php +++ b/library/Zend/Http/Header/MultipleHeaderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Origin.php b/library/Zend/Http/Header/Origin.php index 5f88a334..01b95b94 100644 --- a/library/Zend/Http/Header/Origin.php +++ b/library/Zend/Http/Header/Origin.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,7 +20,7 @@ class Origin implements HeaderInterface /** * @var string */ - protected $value; + protected $value = ''; public static function fromString($headerLine) { @@ -44,7 +44,10 @@ class Origin implements HeaderInterface */ public function __construct($value = null) { - $this->value = (string) $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Pragma.php b/library/Zend/Http/Header/Pragma.php index e193b98c..a9b68d91 100644 --- a/library/Zend/Http/Header/Pragma.php +++ b/library/Zend/Http/Header/Pragma.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Pragma implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Pragma implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/ProxyAuthenticate.php b/library/Zend/Http/Header/ProxyAuthenticate.php index c233e7ad..7b4a0923 100644 --- a/library/Zend/Http/Header/ProxyAuthenticate.php +++ b/library/Zend/Http/Header/ProxyAuthenticate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ProxyAuthenticate implements MultipleHeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ProxyAuthenticate implements MultipleHeaderInterface // check to ensure proper header type for this factory if (strtolower($name) !== 'proxy-authenticate') { - throw new Exception\InvalidArgumentException('Invalid header line for Proxy-Authenticate string: "' . $name . '"'); + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid header line for Proxy-Authenticate string: "%s"', + $name + )); } // @todo implementation details @@ -35,7 +40,10 @@ class ProxyAuthenticate implements MultipleHeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() @@ -59,7 +67,8 @@ class ProxyAuthenticate implements MultipleHeaderInterface foreach ($headers as $header) { if (!$header instanceof ProxyAuthenticate) { throw new Exception\RuntimeException( - 'The ProxyAuthenticate multiple header implementation can only accept an array of ProxyAuthenticate headers' + 'The ProxyAuthenticate multiple header implementation can only accept' + . ' an array of ProxyAuthenticate headers' ); } $strings[] = $header->toString(); diff --git a/library/Zend/Http/Header/ProxyAuthorization.php b/library/Zend/Http/Header/ProxyAuthorization.php index 321411a5..1d7c7dc8 100644 --- a/library/Zend/Http/Header/ProxyAuthorization.php +++ b/library/Zend/Http/Header/ProxyAuthorization.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class ProxyAuthorization implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class ProxyAuthorization implements HeaderInterface // check to ensure proper header type for this factory if (strtolower($name) !== 'proxy-authorization') { - throw new Exception\InvalidArgumentException('Invalid header line for Proxy-Authorization string: "' . $name . '"'); + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid header line for Proxy-Authorization string: "%s"', + $name + )); } // @todo implementation details @@ -35,7 +40,10 @@ class ProxyAuthorization implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Range.php b/library/Zend/Http/Header/Range.php index b18cea4e..bfeb7ed7 100644 --- a/library/Zend/Http/Header/Range.php +++ b/library/Zend/Http/Header/Range.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Range implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Range implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Referer.php b/library/Zend/Http/Header/Referer.php index cde2f861..8b89cf4b 100644 --- a/library/Zend/Http/Header/Referer.php +++ b/library/Zend/Http/Header/Referer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Refresh.php b/library/Zend/Http/Header/Refresh.php index 557924c1..20913930 100644 --- a/library/Zend/Http/Header/Refresh.php +++ b/library/Zend/Http/Header/Refresh.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Refresh implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Refresh implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/RetryAfter.php b/library/Zend/Http/Header/RetryAfter.php index cdd239aa..6f526b3b 100644 --- a/library/Zend/Http/Header/RetryAfter.php +++ b/library/Zend/Http/Header/RetryAfter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Header/Server.php b/library/Zend/Http/Header/Server.php index 1cf38b19..e3343178 100644 --- a/library/Zend/Http/Header/Server.php +++ b/library/Zend/Http/Header/Server.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Server implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Server implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/SetCookie.php b/library/Zend/Http/Header/SetCookie.php index 6b2514ea..bb0cc306 100644 --- a/library/Zend/Http/Header/SetCookie.php +++ b/library/Zend/Http/Header/SetCookie.php @@ -3,12 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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; +use DateTime; use Zend\Uri\UriFactory; /** @@ -113,7 +114,7 @@ class SetCookie implements MultipleHeaderInterface } // First K=V pair is always the cookie name and value - if ($header->getName() === NULL) { + if ($header->getName() === null) { $header->setName($headerKey); $header->setValue(urldecode($headerValue)); continue; @@ -121,13 +122,27 @@ class SetCookie implements MultipleHeaderInterface // Process the remaining elements switch (str_replace(array('-', '_'), '', strtolower($headerKey))) { - case 'expires' : $header->setExpires($headerValue); break; - case 'domain' : $header->setDomain($headerValue); break; - case 'path' : $header->setPath($headerValue); break; - case 'secure' : $header->setSecure(true); break; - case 'httponly': $header->setHttponly(true); break; - case 'version' : $header->setVersion((int) $headerValue); break; - case 'maxage' : $header->setMaxAge((int) $headerValue); break; + case 'expires': + $header->setExpires($headerValue); + break; + case 'domain': + $header->setDomain($headerValue); + break; + case 'path': + $header->setPath($headerValue); + break; + case 'secure': + $header->setSecure(true); + break; + case 'httponly': + $header->setHttponly(true); + break; + case 'version': + $header->setVersion((int) $headerValue); + break; + case 'maxage': + $header->setMaxAge((int) $headerValue); + break; default: // Intentionally omitted } @@ -138,6 +153,7 @@ class SetCookie implements MultipleHeaderInterface } list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + HeaderValue::assertValid($value); // some sites return set-cookie::value, this is to get rid of the second : $name = (strtolower($name) =='set-cookie:') ? 'set-cookie' : $name; @@ -165,19 +181,27 @@ class SetCookie implements MultipleHeaderInterface * * @todo Add validation of each one of the parameters (legal domain, etc.) * - * @param string $name - * @param string $value - * @param int|string $expires - * @param string $path - * @param string $domain - * @param bool $secure - * @param bool $httponly - * @param string $maxAge - * @param int $version - * @return SetCookie + * @param string $name + * @param string $value + * @param int|string|DateTime $expires + * @param string $path + * @param string $domain + * @param bool $secure + * @param bool $httponly + * @param string $maxAge + * @param int $version */ - public function __construct($name = null, $value = null, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false, $maxAge = null, $version = null) - { + public function __construct( + $name = null, + $value = null, + $expires = null, + $path = null, + $domain = null, + $secure = false, + $httponly = false, + $maxAge = null, + $version = null + ) { $this->type = 'Cookie'; $this->setName($name) @@ -210,14 +234,14 @@ class SetCookie implements MultipleHeaderInterface } $value = urlencode($this->getValue()); - if ( $this->hasQuoteFieldValue() ) { + if ($this->hasQuoteFieldValue()) { $value = '"'. $value . '"'; } $fieldValue = $this->getName() . '=' . $value; $version = $this->getVersion(); - if ($version!==null) { + if ($version !== null) { $fieldValue .= '; Version=' . $version; } @@ -259,6 +283,7 @@ class SetCookie implements MultipleHeaderInterface */ public function setName($name) { + HeaderValue::assertValid($name); $this->name = $name; return $this; } @@ -342,9 +367,13 @@ class SetCookie implements MultipleHeaderInterface } /** - * @param int|string $expires + * Set Expires + * + * @param int|string|DateTime $expires + * + * @return self + * * @throws Exception\InvalidArgumentException - * @return SetCookie */ public function setExpires($expires) { @@ -353,14 +382,19 @@ class SetCookie implements MultipleHeaderInterface return $this; } + if ($expires instanceof DateTime) { + $expires = $expires->format(DateTime::COOKIE); + } + $tsExpires = $expires; + if (is_string($expires)) { $tsExpires = strtotime($expires); // if $tsExpires is invalid and PHP is compiled as 32bit. Check if it fail reason is the 2038 bug if (!is_int($tsExpires) && PHP_INT_SIZE === 4) { - $dateTime = new \DateTime($expires); - if ( $dateTime->format('Y') > 2038) { + $dateTime = new DateTime($expires); + if ($dateTime->format('Y') > 2038) { $tsExpires = PHP_INT_MAX; } } @@ -371,6 +405,7 @@ class SetCookie implements MultipleHeaderInterface } $this->expires = $tsExpires; + return $this; } @@ -395,6 +430,7 @@ class SetCookie implements MultipleHeaderInterface */ public function setDomain($domain) { + HeaderValue::assertValid($domain); $this->domain = $domain; return $this; } @@ -413,6 +449,7 @@ class SetCookie implements MultipleHeaderInterface */ public function setPath($path) { + HeaderValue::assertValid($path); $this->path = $path; return $this; } @@ -431,6 +468,9 @@ class SetCookie implements MultipleHeaderInterface */ public function setSecure($secure) { + if (null !== $secure) { + $secure = (bool) $secure; + } $this->secure = $secure; return $this; } @@ -461,6 +501,9 @@ class SetCookie implements MultipleHeaderInterface */ public function setHttponly($httponly) { + if (null !== $httponly) { + $httponly = (bool) $httponly; + } $this->httponly = $httponly; return $this; } @@ -542,7 +585,7 @@ class SetCookie implements MultipleHeaderInterface */ public function match($uri, $matchSessionCookies = true, $now = null) { - if (is_string ($uri)) { + if (is_string($uri)) { $uri = UriFactory::factory($uri); } diff --git a/library/Zend/Http/Header/TE.php b/library/Zend/Http/Header/TE.php index baf8175c..b9a1eefd 100644 --- a/library/Zend/Http/Header/TE.php +++ b/library/Zend/Http/Header/TE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class TE implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class TE implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Trailer.php b/library/Zend/Http/Header/Trailer.php index 6e032b33..6caf7eb5 100644 --- a/library/Zend/Http/Header/Trailer.php +++ b/library/Zend/Http/Header/Trailer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Trailer implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Trailer implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/TransferEncoding.php b/library/Zend/Http/Header/TransferEncoding.php index 8f4380d8..526253d2 100644 --- a/library/Zend/Http/Header/TransferEncoding.php +++ b/library/Zend/Http/Header/TransferEncoding.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class TransferEncoding implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,9 @@ class TransferEncoding implements HeaderInterface // check to ensure proper header type for this factory if (strtolower($name) !== 'transfer-encoding') { - throw new Exception\InvalidArgumentException('Invalid header line for Transfer-Encoding string: "' . $name . '"'); + throw new Exception\InvalidArgumentException( + 'Invalid header line for Transfer-Encoding string: "' . $name . '"' + ); } // @todo implementation details @@ -35,7 +39,10 @@ class TransferEncoding implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Upgrade.php b/library/Zend/Http/Header/Upgrade.php index b133c659..909a3f01 100644 --- a/library/Zend/Http/Header/Upgrade.php +++ b/library/Zend/Http/Header/Upgrade.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Upgrade implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Upgrade implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/UserAgent.php b/library/Zend/Http/Header/UserAgent.php index 16a02087..6fdbec64 100644 --- a/library/Zend/Http/Header/UserAgent.php +++ b/library/Zend/Http/Header/UserAgent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class UserAgent implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class UserAgent implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Vary.php b/library/Zend/Http/Header/Vary.php index 86c944c7..3e41b6b7 100644 --- a/library/Zend/Http/Header/Vary.php +++ b/library/Zend/Http/Header/Vary.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Vary implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Vary implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/Via.php b/library/Zend/Http/Header/Via.php index aba2a00d..a387be16 100644 --- a/library/Zend/Http/Header/Via.php +++ b/library/Zend/Http/Header/Via.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Via implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Via implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/Header/WWWAuthenticate.php b/library/Zend/Http/Header/WWWAuthenticate.php index bec6574d..d1b8bd17 100644 --- a/library/Zend/Http/Header/WWWAuthenticate.php +++ b/library/Zend/Http/Header/WWWAuthenticate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class WWWAuthenticate implements MultipleHeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -24,7 +26,10 @@ class WWWAuthenticate implements MultipleHeaderInterface // check to ensure proper header type for this factory if (strtolower($name) !== 'www-authenticate') { - throw new Exception\InvalidArgumentException('Invalid header line for WWW-Authenticate string: "' . $name . '"'); + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid header line for WWW-Authenticate string: "%s"', + $name + )); } // @todo implementation details @@ -35,7 +40,10 @@ class WWWAuthenticate implements MultipleHeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() @@ -59,7 +67,8 @@ class WWWAuthenticate implements MultipleHeaderInterface foreach ($headers as $header) { if (!$header instanceof WWWAuthenticate) { throw new Exception\RuntimeException( - 'The WWWAuthenticate multiple header implementation can only accept an array of WWWAuthenticate headers' + 'The WWWAuthenticate multiple header implementation can only' + . ' accept an array of WWWAuthenticate headers' ); } $strings[] = $header->toString(); diff --git a/library/Zend/Http/Header/Warning.php b/library/Zend/Http/Header/Warning.php index e0b86997..4b36e194 100644 --- a/library/Zend/Http/Header/Warning.php +++ b/library/Zend/Http/Header/Warning.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,9 @@ namespace Zend\Http\Header; */ class Warning implements HeaderInterface { - /** @var string */ + /** + * @var string + */ protected $value; public static function fromString($headerLine) @@ -35,7 +37,10 @@ class Warning implements HeaderInterface public function __construct($value = null) { - $this->value = $value; + if ($value) { + HeaderValue::assertValid($value); + $this->value = $value; + } } public function getFieldName() diff --git a/library/Zend/Http/HeaderLoader.php b/library/Zend/Http/HeaderLoader.php index af617d67..ffca6362 100644 --- a/library/Zend/Http/HeaderLoader.php +++ b/library/Zend/Http/HeaderLoader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Headers.php b/library/Zend/Http/Headers.php index 348b437e..85aa555e 100644 --- a/library/Zend/Http/Headers.php +++ b/library/Zend/Http/Headers.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -51,13 +51,29 @@ class Headers implements Countable, Iterator */ public static function fromString($string) { - $headers = new static(); - $current = array(); + $headers = new static(); + $current = array(); + $emptyLine = 0; // iterate the header lines, some might be continuations foreach (explode("\r\n", $string) as $line) { + // CRLF*2 is end of headers; an empty line by itself or between header lines + // is an attempt at CRLF injection. + if (preg_match('/^\s*$/', $line)) { + // empty line indicates end of headers + $emptyLine += 1; + if ($emptyLine > 2) { + throw new Exception\RuntimeException('Malformed header detected'); + } + continue; + } + + if ($emptyLine) { + throw new Exception\RuntimeException('Malformed header detected'); + } + // check if a header name is present - if (preg_match('/^(?P[^()><@,;:\"\\/\[\]?=}{ \t]+):.*$/', $line, $matches)) { + if (preg_match('/^(?P[^()><@,;:\"\\/\[\]?={} \t]+):.*$/', $line, $matches)) { if ($current) { // a header name was present, then store the current complete line $headers->headersKeys[] = static::createKey($current['name']); @@ -67,19 +83,21 @@ class Headers implements Countable, Iterator 'name' => $matches['name'], 'line' => trim($line) ); - } elseif (preg_match('/^(?P\s+).*$/', $line, $matches)) { - // continuation: append to current line - $current['line'] .= "\r\n" . $matches['ws'] . trim($line); - } elseif (preg_match('/^\s*$/', $line)) { - // empty line indicates end of headers - break; - } else { - // Line does not match header format! - throw new Exception\RuntimeException(sprintf( - 'Line "%s" does not match header format!', - $line - )); + + continue; } + + if (preg_match("/^[ \t][^\r\n]*$/", $line, $matches)) { + // continuation: append to current line + $current['line'] .= trim($line); + continue; + } + + // Line does not match header format! + throw new Exception\RuntimeException(sprintf( + 'Line "%s" does not match header format!', + $line + )); } if ($current) { $headers->headersKeys[] = static::createKey($current['name']); diff --git a/library/Zend/Http/PhpEnvironment/RemoteAddress.php b/library/Zend/Http/PhpEnvironment/RemoteAddress.php index 077768ab..4406ece4 100644 --- a/library/Zend/Http/PhpEnvironment/RemoteAddress.php +++ b/library/Zend/Http/PhpEnvironment/RemoteAddress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -150,7 +150,6 @@ class RemoteAddress return $ip; } - /** * Normalize a header string * diff --git a/library/Zend/Http/PhpEnvironment/Request.php b/library/Zend/Http/PhpEnvironment/Request.php index 4ed9f05f..10abf598 100644 --- a/library/Zend/Http/PhpEnvironment/Request.php +++ b/library/Zend/Http/PhpEnvironment/Request.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -59,9 +59,13 @@ class Request extends HttpRequest /** * Construct * Instantiates request. + * + * @param bool $allowCustomMethods */ - public function __construct() + public function __construct($allowCustomMethods = true) { + $this->setAllowCustomMethods($allowCustomMethods); + $this->setEnv(new Parameters($_ENV)); if ($_GET) { @@ -216,21 +220,19 @@ class Request extends HttpRequest $headers = array(); foreach ($server as $key => $value) { - if ($value && strpos($key, 'HTTP_') === 0) { - if (strpos($key, 'HTTP_COOKIE') === 0) { - // Cookies are handled using the $_COOKIE superglobal - continue; - } - $name = strtr(substr($key, 5), '_', ' '); - $name = strtr(ucwords(strtolower($name)), ' ', '-'); - } elseif ($value && strpos($key, 'CONTENT_') === 0) { - $name = substr($key, 8); // Content- - $name = 'Content-' . (($name == 'MD5') ? $name : ucfirst(strtolower($name))); - } else { - continue; - } + if ($value || (!is_array($value) && strlen($value))) { + if (strpos($key, 'HTTP_') === 0) { + if (strpos($key, 'HTTP_COOKIE') === 0) { + // Cookies are handled using the $_COOKIE superglobal + continue; + } - $headers[$name] = $value; + $headers[strtr(ucwords(strtolower(strtr(substr($key, 5), '_', ' '))), ' ', '-')] = $value; + } elseif (strpos($key, 'CONTENT_') === 0) { + $name = substr($key, 8); // Remove "Content-" + $headers['Content-' . (($name == 'MD5') ? $name : ucfirst(strtolower($name)))] = $value; + } + } } $this->getHeaders()->addHeaders($headers); @@ -251,8 +253,9 @@ class Request extends HttpRequest $uri = new HttpUri(); // URI scheme - if ((!empty($this->serverParams['HTTPS']) && $this->serverParams['HTTPS'] !== 'off') - || (!empty($this->serverParams['HTTP_X_FORWARDED_PROTO']) && $this->serverParams['HTTP_X_FORWARDED_PROTO'] == 'https') + if ((!empty($this->serverParams['HTTPS']) && strtolower($this->serverParams['HTTPS']) !== 'off') + || (!empty($this->serverParams['HTTP_X_FORWARDED_PROTO']) + && $this->serverParams['HTTP_X_FORWARDED_PROTO'] == 'https') ) { $scheme = 'https'; } else { @@ -362,7 +365,7 @@ class Request extends HttpRequest * Return the parameter container responsible for env parameters or a single parameter value. * * @param string|null $name Parameter name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the parameter is missing. * @return \Zend\Stdlib\ParametersInterface + * @param mixed|null $default Default value to use when the parameter is missing. * @return \Zend\Stdlib\ParametersInterface|mixed */ public function getEnv($name = null, $default = null) @@ -507,7 +510,8 @@ class Request extends HttpRequest $basename = basename($filename); if ($basename) { $path = ($phpSelf ? trim($phpSelf, '/') : ''); - $baseUrl .= substr($path, 0, strpos($path, $basename)) . $basename; + $basePos = strpos($path, $basename) ?: 0; + $baseUrl .= substr($path, 0, $basePos) . $basename; } } diff --git a/library/Zend/Http/PhpEnvironment/Response.php b/library/Zend/Http/PhpEnvironment/Response.php index 1ffbdb1e..1a3dc5ab 100644 --- a/library/Zend/Http/PhpEnvironment/Response.php +++ b/library/Zend/Http/PhpEnvironment/Response.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Http/Request.php b/library/Zend/Http/Request.php index 71d36805..9cac0778 100644 --- a/library/Zend/Http/Request.php +++ b/library/Zend/Http/Request.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -42,6 +42,11 @@ class Request extends AbstractMessage implements RequestInterface */ protected $method = self::METHOD_GET; + /** + * @var bool + */ + protected $allowCustomMethods = true; + /** * @var string|HttpUri */ @@ -66,22 +71,36 @@ class Request extends AbstractMessage implements RequestInterface * A factory that produces a Request object from a well-formed Http Request string * * @param string $string - * @return Request + * @param bool $allowCustomMethods * @throws Exception\InvalidArgumentException + * @return Request */ - public static function fromString($string) + public static function fromString($string, $allowCustomMethods = true) { $request = new static(); + $request->setAllowCustomMethods($allowCustomMethods); $lines = explode("\r\n", $string); // first line must be Method/Uri/Version string - $matches = null; - $methods = implode('|', array( - self::METHOD_OPTIONS, self::METHOD_GET, self::METHOD_HEAD, self::METHOD_POST, - self::METHOD_PUT, self::METHOD_DELETE, self::METHOD_TRACE, self::METHOD_CONNECT, - self::METHOD_PATCH - )); + $matches = null; + $methods = $allowCustomMethods + ? '[\w-]+' + : implode( + '|', + array( + self::METHOD_OPTIONS, + self::METHOD_GET, + self::METHOD_HEAD, + self::METHOD_POST, + self::METHOD_PUT, + self::METHOD_DELETE, + self::METHOD_TRACE, + self::METHOD_CONNECT, + self::METHOD_PATCH + ) + ); + $regex = '#^(?P' . $methods . ')\s(?P[^ ]*)(?:\sHTTP\/(?P\d+\.\d+)){0,1}#'; $firstLine = array_shift($lines); if (!preg_match($regex, $firstLine, $matches)) { @@ -93,6 +112,13 @@ class Request extends AbstractMessage implements RequestInterface $request->setMethod($matches['method']); $request->setUri($matches['uri']); + $parsedUri = parse_url($matches['uri']); + if (array_key_exists('query', $parsedUri)) { + $parsedQuery = array(); + parse_str($parsedUri['query'], $parsedQuery); + $request->setQuery(new Parameters($parsedQuery)); + } + if (isset($matches['version'])) { $request->setVersion($matches['version']); } @@ -109,11 +135,23 @@ class Request extends AbstractMessage implements RequestInterface $isHeader = false; continue; } + if ($isHeader) { + if (preg_match("/[\r\n]/", $nextLine)) { + throw new Exception\RuntimeException('CRLF injection detected'); + } $headers[] = $nextLine; - } else { - $rawBody[] = $nextLine; + continue; } + + + if (empty($rawBody) + && preg_match('/^[a-z0-9!#$%&\'*+.^_`|~-]+:$/i', $nextLine) + ) { + throw new Exception\RuntimeException('CRLF injection detected'); + } + + $rawBody[] = $nextLine; } if ($headers) { @@ -137,7 +175,7 @@ class Request extends AbstractMessage implements RequestInterface public function setMethod($method) { $method = strtoupper($method); - if (!defined('static::METHOD_' . $method)) { + if (!defined('static::METHOD_' . $method) && ! $this->getAllowCustomMethods()) { throw new Exception\InvalidArgumentException('Invalid HTTP method passed'); } $this->method = $method; @@ -279,7 +317,7 @@ class Request extends AbstractMessage implements RequestInterface * Return the Cookie header, this is the same as calling $request->getHeaders()->get('Cookie'); * * @convenience $request->getHeaders()->get('Cookie'); - * @return Header\Cookie + * @return Header\Cookie|bool */ public function getCookie() { @@ -503,4 +541,20 @@ class Request extends AbstractMessage implements RequestInterface $str .= $this->getContent(); return $str; } + + /** + * @return boolean + */ + public function getAllowCustomMethods() + { + return $this->allowCustomMethods; + } + + /** + * @param boolean $strictMethods + */ + public function setAllowCustomMethods($strictMethods) + { + $this->allowCustomMethods = (bool) $strictMethods; + } } diff --git a/library/Zend/Http/Response.php b/library/Zend/Http/Response.php index e485ff64..2d5c1a45 100644 --- a/library/Zend/Http/Response.php +++ b/library/Zend/Http/Response.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -124,7 +124,7 @@ class Response extends AbstractMessage implements ResponseInterface 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Large', + 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', @@ -202,11 +202,22 @@ class Response extends AbstractMessage implements ResponseInterface $isHeader = false; continue; } + if ($isHeader) { + if (preg_match("/[\r\n]/", $line)) { + throw new Exception\RuntimeException('CRLF injection detected'); + } $headers[] = $line; - } else { - $content[] = $line; + continue; } + + if (empty($content) + && preg_match('/^[a-z0-9!#$%&\'*+.^_`|~-]+:$/i', $line) + ) { + throw new Exception\RuntimeException('CRLF injection detected'); + } + + $content[] = $line; } if ($headers) { @@ -245,8 +256,8 @@ class Response extends AbstractMessage implements ResponseInterface $code )); } - $this->statusCode = (int) $code; - return $this; + + return $this->saveStatusCode($code); } /** @@ -276,6 +287,18 @@ class Response extends AbstractMessage implements ResponseInterface )); } + return $this->saveStatusCode($code); + } + + /** + * Assign status code + * + * @param int $code + * @return self + */ + protected function saveStatusCode($code) + { + $this->reasonPhrase = null; $this->statusCode = (int) $code; return $this; } @@ -298,7 +321,7 @@ class Response extends AbstractMessage implements ResponseInterface public function getReasonPhrase() { if (null == $this->reasonPhrase and isset($this->recommendedReasonPhrases[$this->statusCode])) { - return $this->recommendedReasonPhrases[$this->statusCode]; + $this->reasonPhrase = $this->recommendedReasonPhrases[$this->statusCode]; } return $this->reasonPhrase; } diff --git a/library/Zend/Http/Response/Stream.php b/library/Zend/Http/Response/Stream.php index bb2c310f..dbb1ea76 100644 --- a/library/Zend/Http/Response/Stream.php +++ b/library/Zend/Http/Response/Stream.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -174,7 +174,6 @@ class Stream extends Response if (!$headerComplete) { while (false !== ($nextLine = fgets($stream))) { - $headersString .= trim($nextLine)."\r\n"; if ($nextLine == "\r\n" || $nextLine == "\n") { $headerComplete = true; @@ -231,7 +230,7 @@ class Stream extends Response */ public function getBody() { - if ($this->stream != null) { + if ($this->stream !== null) { $this->readStream(); } return parent::getBody(); diff --git a/library/Zend/Http/composer.json b/library/Zend/Http/composer.json index d459e554..2f3e6575 100644 --- a/library/Zend/Http/composer.json +++ b/library/Zend/Http/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Http\\": "" } }, - "target-dir": "Zend/Http", "require": { "php": ">=5.3.23", "zendframework/zend-loader": "self.version", @@ -22,8 +21,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/I18n/Exception/ExceptionInterface.php b/library/Zend/I18n/Exception/ExceptionInterface.php index f6a7a0fb..6c6cfcdf 100644 --- a/library/Zend/I18n/Exception/ExceptionInterface.php +++ b/library/Zend/I18n/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Exception/ExtensionNotLoadedException.php b/library/Zend/I18n/Exception/ExtensionNotLoadedException.php index 1b5f8b67..735116f9 100644 --- a/library/Zend/I18n/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/I18n/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\I18n\Exception; use DomainException; -class ExtensionNotLoadedException extends DomainException implements - ExceptionInterface +class ExtensionNotLoadedException extends DomainException implements ExceptionInterface { } diff --git a/library/Zend/I18n/Exception/InvalidArgumentException.php b/library/Zend/I18n/Exception/InvalidArgumentException.php index 229ccc28..22c68475 100644 --- a/library/Zend/I18n/Exception/InvalidArgumentException.php +++ b/library/Zend/I18n/Exception/InvalidArgumentException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\I18n\Exception; -class InvalidArgumentException extends \InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/I18n/Exception/OutOfBoundsException.php b/library/Zend/I18n/Exception/OutOfBoundsException.php index fe696ffa..46f5b245 100644 --- a/library/Zend/I18n/Exception/OutOfBoundsException.php +++ b/library/Zend/I18n/Exception/OutOfBoundsException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\I18n\Exception; -class OutOfBoundsException extends \OutOfBoundsException implements - ExceptionInterface +class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface { } diff --git a/library/Zend/I18n/Exception/ParseException.php b/library/Zend/I18n/Exception/ParseException.php index 7f82ace0..e97878d9 100644 --- a/library/Zend/I18n/Exception/ParseException.php +++ b/library/Zend/I18n/Exception/ParseException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Exception/RangeException.php b/library/Zend/I18n/Exception/RangeException.php index 021673f2..e7e8c457 100644 --- a/library/Zend/I18n/Exception/RangeException.php +++ b/library/Zend/I18n/Exception/RangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Exception/RuntimeException.php b/library/Zend/I18n/Exception/RuntimeException.php index f7f37366..b420a51c 100644 --- a/library/Zend/I18n/Exception/RuntimeException.php +++ b/library/Zend/I18n/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Filter/AbstractLocale.php b/library/Zend/I18n/Filter/AbstractLocale.php index 14b3c11f..ffff1b1d 100644 --- a/library/Zend/I18n/Filter/AbstractLocale.php +++ b/library/Zend/I18n/Filter/AbstractLocale.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Filter/Alnum.php b/library/Zend/I18n/Filter/Alnum.php index 563b30f9..15085c97 100644 --- a/library/Zend/I18n/Filter/Alnum.php +++ b/library/Zend/I18n/Filter/Alnum.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Filter/Alpha.php b/library/Zend/I18n/Filter/Alpha.php index d7b0f951..ad468f53 100644 --- a/library/Zend/I18n/Filter/Alpha.php +++ b/library/Zend/I18n/Filter/Alpha.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Filter/NumberFormat.php b/library/Zend/I18n/Filter/NumberFormat.php index c6b31956..9c53c752 100644 --- a/library/Zend/I18n/Filter/NumberFormat.php +++ b/library/Zend/I18n/Filter/NumberFormat.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Filter/NumberParse.php b/library/Zend/I18n/Filter/NumberParse.php index 5f4775a0..6f1328e4 100644 --- a/library/Zend/I18n/Filter/NumberParse.php +++ b/library/Zend/I18n/Filter/NumberParse.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -131,7 +131,6 @@ class NumberParse extends AbstractLocale return $this->formatter; } - /** * Defined by Zend\Filter\FilterInterface * diff --git a/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php b/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php index 69872515..28527326 100644 --- a/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php +++ b/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/Loader/FileLoaderInterface.php b/library/Zend/I18n/Translator/Loader/FileLoaderInterface.php index f21125e9..e387aaea 100644 --- a/library/Zend/I18n/Translator/Loader/FileLoaderInterface.php +++ b/library/Zend/I18n/Translator/Loader/FileLoaderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/Loader/Gettext.php b/library/Zend/I18n/Translator/Loader/Gettext.php index 764fe005..d64827a5 100644 --- a/library/Zend/I18n/Translator/Loader/Gettext.php +++ b/library/Zend/I18n/Translator/Loader/Gettext.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -128,7 +128,9 @@ class Gettext extends AbstractFileLoader array_shift($originalString); foreach ($originalString as $string) { - $textDomain[$string] = ''; + if (! isset($textDomain[$string])) { + $textDomain[$string] = ''; + } } } else { $textDomain[$originalString[0]] = $translationString[0]; diff --git a/library/Zend/I18n/Translator/Loader/Ini.php b/library/Zend/I18n/Translator/Loader/Ini.php index 49ff0d9e..fcbd058c 100644 --- a/library/Zend/I18n/Translator/Loader/Ini.php +++ b/library/Zend/I18n/Translator/Loader/Ini.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/Loader/PhpArray.php b/library/Zend/I18n/Translator/Loader/PhpArray.php index f46061b5..10fdab87 100644 --- a/library/Zend/I18n/Translator/Loader/PhpArray.php +++ b/library/Zend/I18n/Translator/Loader/PhpArray.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/Loader/PhpMemoryArray.php b/library/Zend/I18n/Translator/Loader/PhpMemoryArray.php index f38ab30c..dc9b9e38 100644 --- a/library/Zend/I18n/Translator/Loader/PhpMemoryArray.php +++ b/library/Zend/I18n/Translator/Loader/PhpMemoryArray.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -40,23 +40,20 @@ class PhpMemoryArray implements RemoteLoaderInterface public function load($locale, $textDomain) { if (!is_array($this->messages)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected an array, but received %s', - gettype($this->messages) - )); + throw new Exception\InvalidArgumentException( + sprintf('Expected an array, but received %s', gettype($this->messages)) + ); } if (!isset($this->messages[$textDomain])) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected textdomain "%s" to be an array, but it is not set', - $textDomain) + throw new Exception\InvalidArgumentException( + sprintf('Expected textdomain "%s" to be an array, but it is not set', $textDomain) ); } if (!isset($this->messages[$textDomain][$locale])) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected locale "%s" to be an array, but it is not set', - $locale) + throw new Exception\InvalidArgumentException( + sprintf('Expected locale "%s" to be an array, but it is not set', $locale) ); } diff --git a/library/Zend/I18n/Translator/Loader/RemoteLoaderInterface.php b/library/Zend/I18n/Translator/Loader/RemoteLoaderInterface.php index 59b0046d..8ed1d8fb 100644 --- a/library/Zend/I18n/Translator/Loader/RemoteLoaderInterface.php +++ b/library/Zend/I18n/Translator/Loader/RemoteLoaderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/LoaderPluginManager.php b/library/Zend/I18n/Translator/LoaderPluginManager.php index 4ce79663..9ecdbb10 100644 --- a/library/Zend/I18n/Translator/LoaderPluginManager.php +++ b/library/Zend/I18n/Translator/LoaderPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/Plural/Parser.php b/library/Zend/I18n/Translator/Plural/Parser.php index d3e872e3..ffcf8f21 100644 --- a/library/Zend/I18n/Translator/Plural/Parser.php +++ b/library/Zend/I18n/Translator/Plural/Parser.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -222,7 +222,7 @@ class Parser * Parse a string. * * @param string $string - * @return array + * @return Symbol */ public function parse($string) { @@ -264,10 +264,9 @@ class Parser public function advance($id = null) { if ($id !== null && $this->currentToken->id !== $id) { - throw new Exception\ParseException(sprintf( - 'Expected token with id %s but received %s', - $id, $this->currentToken->id - )); + throw new Exception\ParseException( + sprintf('Expected token with id %s but received %s', $id, $this->currentToken->id) + ); } $this->currentToken = $this->getNextToken(); @@ -354,7 +353,6 @@ class Parser 'Found invalid character "%s" in input stream', $result )); - break; } $token = $this->getSymbol($id); diff --git a/library/Zend/I18n/Translator/Plural/Rule.php b/library/Zend/I18n/Translator/Plural/Rule.php index 98e29cf6..5427fce8 100644 --- a/library/Zend/I18n/Translator/Plural/Rule.php +++ b/library/Zend/I18n/Translator/Plural/Rule.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -62,10 +62,9 @@ class Rule $result = $this->evaluateAstPart($this->ast, abs((int) $number)); if ($result < 0 || $result >= $this->numPlurals) { - throw new Exception\RangeException(sprintf( - 'Calculated result %s is between 0 and %d', - $result, ($this->numPlurals - 1) - )); + throw new Exception\RangeException( + sprintf('Calculated result %s is between 0 and %d', $result, ($this->numPlurals - 1)) + ); } return $result; diff --git a/library/Zend/I18n/Translator/Plural/Symbol.php b/library/Zend/I18n/Translator/Plural/Symbol.php index 31d6606c..7b33419e 100644 --- a/library/Zend/I18n/Translator/Plural/Symbol.php +++ b/library/Zend/I18n/Translator/Plural/Symbol.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -132,9 +132,7 @@ class Symbol public function getNullDenotation() { if ($this->nullDenotationGetter === null) { - throw new Exception\ParseException(sprintf( - 'Syntax error: %s', $this->id - )); + throw new Exception\ParseException(sprintf('Syntax error: %s', $this->id)); } /** @var callable $function */ @@ -152,9 +150,7 @@ class Symbol public function getLeftDenotation($left) { if ($this->leftDenotationGetter === null) { - throw new Exception\ParseException(sprintf( - 'Unknown operator: %s', $this->id - )); + throw new Exception\ParseException(sprintf('Unknown operator: %s', $this->id)); } /** @var callable $function */ diff --git a/library/Zend/I18n/Translator/TextDomain.php b/library/Zend/I18n/Translator/TextDomain.php index 5c9607e8..ee746ba1 100644 --- a/library/Zend/I18n/Translator/TextDomain.php +++ b/library/Zend/I18n/Translator/TextDomain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/Translator.php b/library/Zend/I18n/Translator/Translator.php index 2bfb5422..727c61ba 100644 --- a/library/Zend/I18n/Translator/Translator.php +++ b/library/Zend/I18n/Translator/Translator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -401,6 +401,8 @@ class Translator implements TranslatorInterface } return ($number == 1 ? $singular : $plural); + } elseif (is_string($translation)) { + $translation = array($translation); } $index = $this->messages[$textDomain][$locale] @@ -408,9 +410,9 @@ class Translator implements TranslatorInterface ->evaluate($number); if (!isset($translation[$index])) { - throw new Exception\OutOfBoundsException(sprintf( - 'Provided index %d does not exist in plural array', $index - )); + throw new Exception\OutOfBoundsException( + sprintf('Provided index %d does not exist in plural array', $index) + ); } return $translation[$index]; @@ -461,7 +463,7 @@ class Translator implements TranslatorInterface } } - return null; + return; } /** diff --git a/library/Zend/I18n/Translator/TranslatorAwareInterface.php b/library/Zend/I18n/Translator/TranslatorAwareInterface.php index 1b4cbce7..aaebf616 100644 --- a/library/Zend/I18n/Translator/TranslatorAwareInterface.php +++ b/library/Zend/I18n/Translator/TranslatorAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/TranslatorAwareTrait.php b/library/Zend/I18n/Translator/TranslatorAwareTrait.php index f223e4a6..d4d4e753 100644 --- a/library/Zend/I18n/Translator/TranslatorAwareTrait.php +++ b/library/Zend/I18n/Translator/TranslatorAwareTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/TranslatorInterface.php b/library/Zend/I18n/Translator/TranslatorInterface.php index b7f1bb56..43986b6b 100644 --- a/library/Zend/I18n/Translator/TranslatorInterface.php +++ b/library/Zend/I18n/Translator/TranslatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Translator/TranslatorServiceFactory.php b/library/Zend/I18n/Translator/TranslatorServiceFactory.php index 8a14ffed..427df424 100644 --- a/library/Zend/I18n/Translator/TranslatorServiceFactory.php +++ b/library/Zend/I18n/Translator/TranslatorServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/Alnum.php b/library/Zend/I18n/Validator/Alnum.php index f983a642..162fd86b 100644 --- a/library/Zend/I18n/Validator/Alnum.php +++ b/library/Zend/I18n/Validator/Alnum.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/Alpha.php b/library/Zend/I18n/Validator/Alpha.php index c7972993..2e136cd3 100644 --- a/library/Zend/I18n/Validator/Alpha.php +++ b/library/Zend/I18n/Validator/Alpha.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/DateTime.php b/library/Zend/I18n/Validator/DateTime.php index 73f00981..ad8eb480 100644 --- a/library/Zend/I18n/Validator/DateTime.php +++ b/library/Zend/I18n/Validator/DateTime.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,6 +12,7 @@ namespace Zend\I18n\Validator; use Locale; use IntlDateFormatter; use Traversable; +use IntlException; use Zend\I18n\Exception as I18nException; use Zend\Validator\AbstractValidator; use Zend\Validator\Exception as ValidatorException; @@ -263,15 +264,26 @@ class DateTime extends AbstractValidator } $this->setValue($value); - $formatter = $this->getIntlDateFormatter(); - if (intl_is_failure($formatter->getErrorCode())) { - throw new ValidatorException\InvalidArgumentException($formatter->getErrorMessage()); + try { + $formatter = $this->getIntlDateFormatter(); + + if (intl_is_failure($formatter->getErrorCode())) { + throw new ValidatorException\InvalidArgumentException($formatter->getErrorMessage()); + } + } catch (IntlException $intlException) { + throw new ValidatorException\InvalidArgumentException($intlException->getMessage(), 0, $intlException); } - $timestamp = $formatter->parse($value); - if (intl_is_failure($formatter->getErrorCode()) || $timestamp === false) { + try { + $timestamp = $formatter->parse($value); + + if (intl_is_failure($formatter->getErrorCode()) || $timestamp === false) { + $this->error(self::INVALID_DATETIME); + return false; + } + } catch (IntlException $intlException) { $this->error(self::INVALID_DATETIME); return false; } @@ -286,7 +298,7 @@ class DateTime extends AbstractValidator */ protected function getIntlDateFormatter() { - if ($this->formatter == null || $this->invalidateFormatter) { + if ($this->formatter === null || $this->invalidateFormatter) { $this->formatter = new IntlDateFormatter( $this->getLocale(), $this->getDateType(), diff --git a/library/Zend/I18n/Validator/Float.php b/library/Zend/I18n/Validator/Float.php index af146089..afa491a1 100644 --- a/library/Zend/I18n/Validator/Float.php +++ b/library/Zend/I18n/Validator/Float.php @@ -3,49 +3,24 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\I18n\Validator; -use Locale; -use NumberFormatter; -use Traversable; -use Zend\I18n\Exception as I18nException; -use Zend\Stdlib\ArrayUtils; -use Zend\Stdlib\StringUtils; -use Zend\Stdlib\StringWrapper\StringWrapperInterface; -use Zend\Validator\AbstractValidator; -use Zend\Validator\Exception; - -class Float extends AbstractValidator +/** + * Stub class for backwards compatibility. + * + * Since PHP 7 adds "float" as a reserved keyword, we can no longer have a class + * named that and retain PHP 7 compatibility. The original class has been + * renamed to "IsFloat", and this class is now an extension of it. It raises an + * E_USER_DEPRECATED to warn users to migrate. + * + * @deprecated + */ +class Float extends IsFloat { - const INVALID = 'floatInvalid'; - const NOT_FLOAT = 'notFloat'; - - /** - * @var array - */ - protected $messageTemplates = array( - self::INVALID => "Invalid type given. String, integer or float expected", - self::NOT_FLOAT => "The input does not appear to be a float", - ); - - /** - * Optional locale - * - * @var string|null - */ - protected $locale; - - /** - * UTF-8 compatable wrapper for string functions - * - * @var StringWrapperInterface - */ - protected $wrapper; - /** * Constructor for the integer validator * @@ -54,189 +29,15 @@ class Float extends AbstractValidator */ public function __construct($options = array()) { - if (!extension_loaded('intl')) { - throw new I18nException\ExtensionNotLoadedException( - sprintf('%s component requires the intl PHP extension', __NAMESPACE__) - ); - } - - $this->wrapper = StringUtils::getWrapper(); - - if ($options instanceof Traversable) { - $options = ArrayUtils::iteratorToArray($options); - } - - if (array_key_exists('locale', $options)) { - $this->setLocale($options['locale']); - } + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\IsFloat', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); parent::__construct($options); } - - /** - * Returns the set locale - * - * @return string - */ - public function getLocale() - { - if (null === $this->locale) { - $this->locale = Locale::getDefault(); - } - return $this->locale; - } - - /** - * Sets the locale to use - * - * @param string|null $locale - * @return Float - */ - public function setLocale($locale) - { - $this->locale = $locale; - return $this; - } - - /** - * Returns true if and only if $value is a floating-point value. Uses the formal definition of a float as described - * in the PHP manual: {@link http://www.php.net/float} - * - * @param string $value - * @return bool - * @throws Exception\InvalidArgumentException - */ - public function isValid($value) - { - if (!is_scalar($value) || is_bool($value)) { - $this->error(self::INVALID); - return false; - } - - $this->setValue($value); - - if (is_float($value) || is_int($value)) { - return true; - } - - // Need to check if this is scientific formatted string. If not, switch to decimal. - $formatter = new NumberFormatter($this->getLocale(), NumberFormatter::SCIENTIFIC); - - if (intl_is_failure($formatter->getErrorCode())) { - throw new Exception\InvalidArgumentException($formatter->getErrorMessage()); - } - - if (StringUtils::hasPcreUnicodeSupport()) { - $exponentialSymbols = '[Ee' . $formatter->getSymbol(NumberFormatter::EXPONENTIAL_SYMBOL) . ']+'; - $search = '/' . $exponentialSymbols . '/u'; - } else { - $exponentialSymbols = '[Ee]'; - $search = '/' . $exponentialSymbols . '/'; - } - - if (!preg_match($search, $value)) { - $formatter = new NumberFormatter($this->getLocale(), NumberFormatter::DECIMAL); - } - - /** - * @desc There are seperator "look-alikes" for decimal and group seperators that are more commonly used than the - * official unicode chracter. We need to replace those with the real thing - or remove it. - */ - $groupSeparator = $formatter->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL); - $decSeparator = $formatter->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); - - //NO-BREAK SPACE and ARABIC THOUSANDS SEPARATOR - if ($groupSeparator == "\xC2\xA0") { - $value = str_replace(' ', $groupSeparator, $value); - } elseif ($groupSeparator == "\xD9\xAC") { //NumberFormatter doesn't have grouping at all for Arabic-Indic - $value = str_replace(array('\'', $groupSeparator), '', $value); - } - - //ARABIC DECIMAL SEPARATOR - if ($decSeparator == "\xD9\xAB") { - $value = str_replace(',', $decSeparator, $value); - } - - $groupSeparatorPosition = $this->wrapper->strpos($value, $groupSeparator); - $decSeparatorPosition = $this->wrapper->strpos($value, $decSeparator); - - //We have seperators, and they are flipped. i.e. 2.000,000 for en-US - if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) { - return false; - } - - //If we have Unicode support, we can use the real graphemes, otherwise, just the ASCII characters - $decimal = '['. preg_quote($decSeparator, '/') . ']'; - $prefix = '[+-]'; - $exp = $exponentialSymbols; - $numberRange = '0-9'; - $useUnicode = ''; - $suffix = ''; - - if (StringUtils::hasPcreUnicodeSupport()) { - $prefix = '[' - . preg_quote( - $formatter->getTextAttribute(NumberFormatter::POSITIVE_PREFIX) - . $formatter->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX) - . $formatter->getSymbol(NumberFormatter::PLUS_SIGN_SYMBOL) - . $formatter->getSymbol(NumberFormatter::MINUS_SIGN_SYMBOL), - '/' - ) - . ']{0,3}'; - $suffix = ($formatter->getTextAttribute(NumberFormatter::NEGATIVE_SUFFIX)) - ? '[' - . preg_quote( - $formatter->getTextAttribute(NumberFormatter::POSITIVE_SUFFIX) - . $formatter->getTextAttribute(NumberFormatter::NEGATIVE_SUFFIX) - . $formatter->getSymbol(NumberFormatter::PLUS_SIGN_SYMBOL) - . $formatter->getSymbol(NumberFormatter::MINUS_SIGN_SYMBOL), - '/' - ) - . ']{0,3}' - : ''; - $numberRange = '\p{N}'; - $useUnicode = 'u'; - } - - /** - * @desc Match against the formal definition of a float. The - * exponential number check is modified for RTL non-Latin number - * systems (Arabic-Indic numbering). I'm also switching out the period - * for the decimal separator. The formal definition leaves out +- from - * the integer and decimal notations so add that. This also checks - * that a grouping sperator is not in the last GROUPING_SIZE graphemes - * of the string - i.e. 10,6 is not valid for en-US. - * @see http://www.php.net/float - */ - - $lnum = '[' . $numberRange . ']+'; - $dnum = '(([' . $numberRange . ']*' . $decimal . $lnum . ')|(' . $lnum . $decimal . '[' . $numberRange . ']*))'; - $expDnum = '((' . $prefix . '((' . $lnum . '|' . $dnum . ')' . $exp . $prefix . $lnum . ')' . $suffix . ')|' - . '(' . $suffix . '(' . $lnum . $prefix . $exp . '(' . $dnum . '|' . $lnum . '))' . $prefix . '))'; - - // LEFT-TO-RIGHT MARK (U+200E) is messing up everything for the handful - // of locales that have it - $lnumSearch = str_replace("\xE2\x80\x8E", '', '/^' .$prefix . $lnum . $suffix . '$/' . $useUnicode); - $dnumSearch = str_replace("\xE2\x80\x8E", '', '/^' .$prefix . $dnum . $suffix . '$/' . $useUnicode); - $expDnumSearch = str_replace("\xE2\x80\x8E", '', '/^' . $expDnum . '$/' . $useUnicode); - $value = str_replace("\xE2\x80\x8E", '', $value); - $unGroupedValue = str_replace($groupSeparator, '', $value); - - // No strrpos() in wrappers yet. ICU 4.x doesn't have grouping size for - // everything. ICU 52 has 3 for ALL locales. - $groupSize = ($formatter->getAttribute(NumberFormatter::GROUPING_SIZE)) - ? $formatter->getAttribute(NumberFormatter::GROUPING_SIZE) - : 3; - $lastStringGroup = $this->wrapper->substr($value, -$groupSize); - - if ((preg_match($lnumSearch, $unGroupedValue) - || preg_match($dnumSearch, $unGroupedValue) - || preg_match($expDnumSearch, $unGroupedValue)) - && false === $this->wrapper->strpos($lastStringGroup, $groupSeparator) - ) { - return true; - } - - return false; - } } diff --git a/library/Zend/I18n/Validator/Int.php b/library/Zend/I18n/Validator/Int.php index c6f90ca8..b244a228 100644 --- a/library/Zend/I18n/Validator/Int.php +++ b/library/Zend/I18n/Validator/Int.php @@ -3,40 +3,24 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\I18n\Validator; -use Locale; -use NumberFormatter; -use Traversable; -use Zend\I18n\Exception as I18nException; -use Zend\Stdlib\ArrayUtils; -use Zend\Validator\AbstractValidator; -use Zend\Validator\Exception; - -class Int extends AbstractValidator +/** + * Stub class for backwards compatibility. + * + * Since PHP 7 adds "int" as a reserved keyword, we can no longer have a class + * named that and retain PHP 7 compatibility. The original class has been + * renamed to "IsInt", and this class is now an extension of it. It raises an + * E_USER_DEPRECATED to warn users to migrate. + * + * @deprecated + */ +class Int extends IsInt { - const INVALID = 'intInvalid'; - const NOT_INT = 'notInt'; - - /** - * @var array - */ - protected $messageTemplates = array( - self::INVALID => "Invalid type given. String or integer expected", - self::NOT_INT => "The input does not appear to be an integer", - ); - - /** - * Optional locale - * - * @var string|null - */ - protected $locale; - /** * Constructor for the integer validator * @@ -45,90 +29,15 @@ class Int extends AbstractValidator */ public function __construct($options = array()) { - if (!extension_loaded('intl')) { - throw new I18nException\ExtensionNotLoadedException(sprintf( - '%s component requires the intl PHP extension', + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\IsInt', + __CLASS__, __NAMESPACE__ - )); - } - - if ($options instanceof Traversable) { - $options = ArrayUtils::iteratorToArray($options); - } - - if (array_key_exists('locale', $options)) { - $this->setLocale($options['locale']); - } + ), + E_USER_DEPRECATED + ); parent::__construct($options); } - - /** - * Returns the set locale - */ - public function getLocale() - { - if (null === $this->locale) { - $this->locale = Locale::getDefault(); - } - return $this->locale; - } - - /** - * Sets the locale to use - * - * @param string $locale - * @return Int - */ - public function setLocale($locale) - { - $this->locale = $locale; - return $this; - } - - /** - * Returns true if and only if $value is a valid integer - * - * @param string|int $value - * @return bool - * @throws Exception\InvalidArgumentException - */ - public function isValid($value) - { - if (!is_string($value) && !is_int($value) && !is_float($value)) { - $this->error(self::INVALID); - return false; - } - - if (is_int($value)) { - return true; - } - - $this->setValue($value); - - $locale = $this->getLocale(); - $format = new NumberFormatter($locale, NumberFormatter::DECIMAL); - if (intl_is_failure($format->getErrorCode())) { - throw new Exception\InvalidArgumentException("Invalid locale string given"); - } - - $parsedInt = $format->parse($value, NumberFormatter::TYPE_INT64); - if (intl_is_failure($format->getErrorCode())) { - $this->error(self::NOT_INT); - return false; - } - - $decimalSep = $format->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); - $groupingSep = $format->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL); - - $valueFiltered = str_replace($groupingSep, '', $value); - $valueFiltered = str_replace($decimalSep, '.', $valueFiltered); - - if (strval($parsedInt) !== $valueFiltered) { - $this->error(self::NOT_INT); - return false; - } - - return true; - } } diff --git a/library/Zend/I18n/Validator/IsFloat.php b/library/Zend/I18n/Validator/IsFloat.php new file mode 100644 index 00000000..9a985eb2 --- /dev/null +++ b/library/Zend/I18n/Validator/IsFloat.php @@ -0,0 +1,253 @@ + "Invalid type given. String, integer or float expected", + self::NOT_FLOAT => "The input does not appear to be a float", + ); + + /** + * Optional locale + * + * @var string|null + */ + protected $locale; + + /** + * UTF-8 compatable wrapper for string functions + * + * @var StringWrapperInterface + */ + protected $wrapper; + + /** + * Constructor for the integer validator + * + * @param array|Traversable $options + * @throws Exception\ExtensionNotLoadedException if ext/intl is not present + */ + public function __construct($options = array()) + { + if (!extension_loaded('intl')) { + throw new I18nException\ExtensionNotLoadedException( + sprintf('%s component requires the intl PHP extension', __NAMESPACE__) + ); + } + + $this->wrapper = StringUtils::getWrapper(); + + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); + } + + if (array_key_exists('locale', $options)) { + $this->setLocale($options['locale']); + } + + parent::__construct($options); + } + + /** + * Returns the set locale + * + * @return string + */ + public function getLocale() + { + if (null === $this->locale) { + $this->locale = Locale::getDefault(); + } + return $this->locale; + } + + /** + * Sets the locale to use + * + * @param string|null $locale + * @return Float + */ + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + /** + * Returns true if and only if $value is a floating-point value. Uses the formal definition of a float as described + * in the PHP manual: {@link http://www.php.net/float} + * + * @param string $value + * @return bool + * @throws Exception\InvalidArgumentException + */ + public function isValid($value) + { + if (!is_scalar($value) || is_bool($value)) { + $this->error(self::INVALID); + return false; + } + + $this->setValue($value); + + if (is_float($value) || is_int($value)) { + return true; + } + + // Need to check if this is scientific formatted string. If not, switch to decimal. + $formatter = new NumberFormatter($this->getLocale(), NumberFormatter::SCIENTIFIC); + + try { + if (intl_is_failure($formatter->getErrorCode())) { + throw new Exception\InvalidArgumentException($formatter->getErrorMessage()); + } + } catch (IntlException $intlException) { + throw new Exception\InvalidArgumentException($intlException->getMessage(), 0, $intlException); + } + + if (StringUtils::hasPcreUnicodeSupport()) { + $exponentialSymbols = '[Ee' . $formatter->getSymbol(NumberFormatter::EXPONENTIAL_SYMBOL) . ']+'; + $search = '/' . $exponentialSymbols . '/u'; + } else { + $exponentialSymbols = '[Ee]'; + $search = '/' . $exponentialSymbols . '/'; + } + + if (!preg_match($search, $value)) { + $formatter = new NumberFormatter($this->getLocale(), NumberFormatter::DECIMAL); + } + + /** + * @desc There are seperator "look-alikes" for decimal and group seperators that are more commonly used than the + * official unicode chracter. We need to replace those with the real thing - or remove it. + */ + $groupSeparator = $formatter->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL); + $decSeparator = $formatter->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); + + //NO-BREAK SPACE and ARABIC THOUSANDS SEPARATOR + if ($groupSeparator == "\xC2\xA0") { + $value = str_replace(' ', $groupSeparator, $value); + } elseif ($groupSeparator == "\xD9\xAC") { + //NumberFormatter doesn't have grouping at all for Arabic-Indic + $value = str_replace(array('\'', $groupSeparator), '', $value); + } + + //ARABIC DECIMAL SEPARATOR + if ($decSeparator == "\xD9\xAB") { + $value = str_replace(',', $decSeparator, $value); + } + + $groupSeparatorPosition = $this->wrapper->strpos($value, $groupSeparator); + $decSeparatorPosition = $this->wrapper->strpos($value, $decSeparator); + + //We have seperators, and they are flipped. i.e. 2.000,000 for en-US + if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) { + $this->error(self::NOT_FLOAT); + + return false; + } + + //If we have Unicode support, we can use the real graphemes, otherwise, just the ASCII characters + $decimal = '['. preg_quote($decSeparator, '/') . ']'; + $prefix = '[+-]'; + $exp = $exponentialSymbols; + $numberRange = '0-9'; + $useUnicode = ''; + $suffix = ''; + + if (StringUtils::hasPcreUnicodeSupport()) { + $prefix = '[' + . preg_quote( + $formatter->getTextAttribute(NumberFormatter::POSITIVE_PREFIX) + . $formatter->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX) + . $formatter->getSymbol(NumberFormatter::PLUS_SIGN_SYMBOL) + . $formatter->getSymbol(NumberFormatter::MINUS_SIGN_SYMBOL), + '/' + ) + . ']{0,3}'; + $suffix = ($formatter->getTextAttribute(NumberFormatter::NEGATIVE_SUFFIX)) + ? '[' + . preg_quote( + $formatter->getTextAttribute(NumberFormatter::POSITIVE_SUFFIX) + . $formatter->getTextAttribute(NumberFormatter::NEGATIVE_SUFFIX) + . $formatter->getSymbol(NumberFormatter::PLUS_SIGN_SYMBOL) + . $formatter->getSymbol(NumberFormatter::MINUS_SIGN_SYMBOL), + '/' + ) + . ']{0,3}' + : ''; + $numberRange = '\p{N}'; + $useUnicode = 'u'; + } + + /** + * @desc Match against the formal definition of a float. The + * exponential number check is modified for RTL non-Latin number + * systems (Arabic-Indic numbering). I'm also switching out the period + * for the decimal separator. The formal definition leaves out +- from + * the integer and decimal notations so add that. This also checks + * that a grouping sperator is not in the last GROUPING_SIZE graphemes + * of the string - i.e. 10,6 is not valid for en-US. + * @see http://www.php.net/float + */ + + $lnum = '[' . $numberRange . ']+'; + $dnum = '(([' . $numberRange . ']*' . $decimal . $lnum . ')|(' + . $lnum . $decimal . '[' . $numberRange . ']*))'; + $expDnum = '((' . $prefix . '((' . $lnum . '|' . $dnum . ')' . $exp . $prefix . $lnum . ')' . $suffix . ')|' + . '(' . $suffix . '(' . $lnum . $prefix . $exp . '(' . $dnum . '|' . $lnum . '))' . $prefix . '))'; + + // LEFT-TO-RIGHT MARK (U+200E) is messing up everything for the handful + // of locales that have it + $lnumSearch = str_replace("\xE2\x80\x8E", '', '/^' .$prefix . $lnum . $suffix . '$/' . $useUnicode); + $dnumSearch = str_replace("\xE2\x80\x8E", '', '/^' .$prefix . $dnum . $suffix . '$/' . $useUnicode); + $expDnumSearch = str_replace("\xE2\x80\x8E", '', '/^' . $expDnum . '$/' . $useUnicode); + $value = str_replace("\xE2\x80\x8E", '', $value); + $unGroupedValue = str_replace($groupSeparator, '', $value); + + // No strrpos() in wrappers yet. ICU 4.x doesn't have grouping size for + // everything. ICU 52 has 3 for ALL locales. + $groupSize = ($formatter->getAttribute(NumberFormatter::GROUPING_SIZE)) + ? $formatter->getAttribute(NumberFormatter::GROUPING_SIZE) + : 3; + $lastStringGroup = $this->wrapper->substr($value, -$groupSize); + + if ((preg_match($lnumSearch, $unGroupedValue) + || preg_match($dnumSearch, $unGroupedValue) + || preg_match($expDnumSearch, $unGroupedValue)) + && false === $this->wrapper->strpos($lastStringGroup, $groupSeparator) + ) { + return true; + } + + $this->error(self::NOT_FLOAT); + + return false; + } +} diff --git a/library/Zend/I18n/Validator/IsInt.php b/library/Zend/I18n/Validator/IsInt.php new file mode 100644 index 00000000..e4a815f0 --- /dev/null +++ b/library/Zend/I18n/Validator/IsInt.php @@ -0,0 +1,144 @@ + "Invalid type given. String or integer expected", + self::NOT_INT => "The input does not appear to be an integer", + ); + + /** + * Optional locale + * + * @var string|null + */ + protected $locale; + + /** + * Constructor for the integer validator + * + * @param array|Traversable $options + * @throws Exception\ExtensionNotLoadedException if ext/intl is not present + */ + public function __construct($options = array()) + { + if (!extension_loaded('intl')) { + throw new I18nException\ExtensionNotLoadedException(sprintf( + '%s component requires the intl PHP extension', + __NAMESPACE__ + )); + } + + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); + } + + if (array_key_exists('locale', $options)) { + $this->setLocale($options['locale']); + } + + parent::__construct($options); + } + + /** + * Returns the set locale + */ + public function getLocale() + { + if (null === $this->locale) { + $this->locale = Locale::getDefault(); + } + return $this->locale; + } + + /** + * Sets the locale to use + * + * @param string $locale + * @return Int + */ + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + /** + * Returns true if and only if $value is a valid integer + * + * @param string|int $value + * @return bool + * @throws Exception\InvalidArgumentException + */ + public function isValid($value) + { + if (!is_string($value) && !is_int($value) && !is_float($value)) { + $this->error(self::INVALID); + return false; + } + + if (is_int($value)) { + return true; + } + + $this->setValue($value); + + $locale = $this->getLocale(); + try { + $format = new NumberFormatter($locale, NumberFormatter::DECIMAL); + if (intl_is_failure($format->getErrorCode())) { + throw new Exception\InvalidArgumentException("Invalid locale string given"); + } + } catch (IntlException $intlException) { + throw new Exception\InvalidArgumentException("Invalid locale string given", 0, $intlException); + } + + try { + $parsedInt = $format->parse($value, NumberFormatter::TYPE_INT64); + if (intl_is_failure($format->getErrorCode())) { + $this->error(self::NOT_INT); + return false; + } + } catch (IntlException $intlException) { + $this->error(self::NOT_INT); + return false; + } + + $decimalSep = $format->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); + $groupingSep = $format->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL); + + $valueFiltered = str_replace($groupingSep, '', $value); + $valueFiltered = str_replace($decimalSep, '.', $valueFiltered); + + if (strval($parsedInt) !== $valueFiltered) { + $this->error(self::NOT_INT); + return false; + } + + return true; + } +} diff --git a/library/Zend/I18n/Validator/PhoneNumber.php b/library/Zend/I18n/Validator/PhoneNumber.php index 37fe6d40..3af31a2b 100644 --- a/library/Zend/I18n/Validator/PhoneNumber.php +++ b/library/Zend/I18n/Validator/PhoneNumber.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AC.php b/library/Zend/I18n/Validator/PhoneNumber/AC.php index a8e32bfa..d1356fee 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AD.php b/library/Zend/I18n/Validator/PhoneNumber/AD.php index 54ccdbb0..e9369ba7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AE.php b/library/Zend/I18n/Validator/PhoneNumber/AE.php index 8cacd8c0..45f8ea3c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AF.php b/library/Zend/I18n/Validator/PhoneNumber/AF.php index c4a25e33..bbbdb2da 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AG.php b/library/Zend/I18n/Validator/PhoneNumber/AG.php index f3f62c88..99c074cf 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AI.php b/library/Zend/I18n/Validator/PhoneNumber/AI.php index 4d5c2f2d..e086c43e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AL.php b/library/Zend/I18n/Validator/PhoneNumber/AL.php index 765acf2e..a80de5f2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AM.php b/library/Zend/I18n/Validator/PhoneNumber/AM.php index af34426b..03b04fb8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AO.php b/library/Zend/I18n/Validator/PhoneNumber/AO.php index a9c8632e..6817767c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AR.php b/library/Zend/I18n/Validator/PhoneNumber/AR.php index 2cdb5efb..b61e9476 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AS.php b/library/Zend/I18n/Validator/PhoneNumber/AS.php index 21686cba..da5300b9 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AT.php b/library/Zend/I18n/Validator/PhoneNumber/AT.php index e79f2b23..9bdcd3fa 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AU.php b/library/Zend/I18n/Validator/PhoneNumber/AU.php index 129c543a..5e5c46d2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AW.php b/library/Zend/I18n/Validator/PhoneNumber/AW.php index a5493c5f..f1b927fc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AX.php b/library/Zend/I18n/Validator/PhoneNumber/AX.php index 36b90a0a..2223a7fb 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AX.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AX.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/AZ.php b/library/Zend/I18n/Validator/PhoneNumber/AZ.php index f62ef58e..ad8e8239 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/AZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/AZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BA.php b/library/Zend/I18n/Validator/PhoneNumber/BA.php index aacdbc9e..e7908dd3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BB.php b/library/Zend/I18n/Validator/PhoneNumber/BB.php index eff89300..961750c2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BB.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BB.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BD.php b/library/Zend/I18n/Validator/PhoneNumber/BD.php index 9924303c..9a6b8a18 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BE.php b/library/Zend/I18n/Validator/PhoneNumber/BE.php index ae0020a4..72022bc9 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BF.php b/library/Zend/I18n/Validator/PhoneNumber/BF.php index 2d9d9a58..9b287fcd 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BG.php b/library/Zend/I18n/Validator/PhoneNumber/BG.php index 4e8c4fcb..70cdc86a 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BH.php b/library/Zend/I18n/Validator/PhoneNumber/BH.php index 755ff41e..86dd502a 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BI.php b/library/Zend/I18n/Validator/PhoneNumber/BI.php index d71589d0..7a29f820 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BJ.php b/library/Zend/I18n/Validator/PhoneNumber/BJ.php index d45f8629..0b6b7f60 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BJ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BJ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BL.php b/library/Zend/I18n/Validator/PhoneNumber/BL.php index 7a65486c..fa7d83ad 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BM.php b/library/Zend/I18n/Validator/PhoneNumber/BM.php index 9db45422..c5212876 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BN.php b/library/Zend/I18n/Validator/PhoneNumber/BN.php index 0dabeae0..b49f67d0 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BO.php b/library/Zend/I18n/Validator/PhoneNumber/BO.php index a81a711b..b7eddf86 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BQ.php b/library/Zend/I18n/Validator/PhoneNumber/BQ.php index ec247393..5b91802d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BQ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BQ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BR.php b/library/Zend/I18n/Validator/PhoneNumber/BR.php index 00d334c1..7d623e6b 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BS.php b/library/Zend/I18n/Validator/PhoneNumber/BS.php index 55a9d552..238c7d16 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BT.php b/library/Zend/I18n/Validator/PhoneNumber/BT.php index f6e49d4a..19022abc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BW.php b/library/Zend/I18n/Validator/PhoneNumber/BW.php index 1cac6f55..208ea9cf 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BY.php b/library/Zend/I18n/Validator/PhoneNumber/BY.php index 288b0d00..6c06aa36 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/BZ.php b/library/Zend/I18n/Validator/PhoneNumber/BZ.php index 713e28fd..047562aa 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/BZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/BZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CA.php b/library/Zend/I18n/Validator/PhoneNumber/CA.php index 0d7388e4..e184b713 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CC.php b/library/Zend/I18n/Validator/PhoneNumber/CC.php index d5565fcc..c37dac8c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CD.php b/library/Zend/I18n/Validator/PhoneNumber/CD.php index f0589c91..cc3278e1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CF.php b/library/Zend/I18n/Validator/PhoneNumber/CF.php index 2ccb05cf..29c28e45 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CG.php b/library/Zend/I18n/Validator/PhoneNumber/CG.php index dadad9ff..f036b813 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CH.php b/library/Zend/I18n/Validator/PhoneNumber/CH.php index a16c372a..c3e34cbc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CI.php b/library/Zend/I18n/Validator/PhoneNumber/CI.php index c688aa2b..2dc7092e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CK.php b/library/Zend/I18n/Validator/PhoneNumber/CK.php index 932f83fc..1c2871ed 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CL.php b/library/Zend/I18n/Validator/PhoneNumber/CL.php index 8cccec24..0c2362fd 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CM.php b/library/Zend/I18n/Validator/PhoneNumber/CM.php index b3249d9a..1c2e0188 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CN.php b/library/Zend/I18n/Validator/PhoneNumber/CN.php index 28ed30d0..e936fab2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CO.php b/library/Zend/I18n/Validator/PhoneNumber/CO.php index bb37839a..2f67c08c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CR.php b/library/Zend/I18n/Validator/PhoneNumber/CR.php index dd31fc8c..354bbbb2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CU.php b/library/Zend/I18n/Validator/PhoneNumber/CU.php index 8b57518f..9686c1a5 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CV.php b/library/Zend/I18n/Validator/PhoneNumber/CV.php index e0fbd208..eb4574b2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CV.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CV.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CW.php b/library/Zend/I18n/Validator/PhoneNumber/CW.php index f98f6124..83722658 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CX.php b/library/Zend/I18n/Validator/PhoneNumber/CX.php index f8b783d1..c0780f48 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CX.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CX.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CY.php b/library/Zend/I18n/Validator/PhoneNumber/CY.php index d31c642c..3a62a9e2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/CZ.php b/library/Zend/I18n/Validator/PhoneNumber/CZ.php index 0522f3a2..a4752b3e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/CZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/CZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/DE.php b/library/Zend/I18n/Validator/PhoneNumber/DE.php index c2e33cfe..9e385832 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/DE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/DE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/DJ.php b/library/Zend/I18n/Validator/PhoneNumber/DJ.php index 4d67877a..2f1c7df0 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/DJ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/DJ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/DK.php b/library/Zend/I18n/Validator/PhoneNumber/DK.php index 7ca1c02a..a3493b25 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/DK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/DK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/DM.php b/library/Zend/I18n/Validator/PhoneNumber/DM.php index 46fb12cb..74cca0ab 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/DM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/DM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/DO.php b/library/Zend/I18n/Validator/PhoneNumber/DO.php index 8ad41576..412ad19c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/DO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/DO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/DZ.php b/library/Zend/I18n/Validator/PhoneNumber/DZ.php index dc76f783..46e941d5 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/DZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/DZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/EC.php b/library/Zend/I18n/Validator/PhoneNumber/EC.php index e059b3e8..2e929bd6 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/EC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/EC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/EE.php b/library/Zend/I18n/Validator/PhoneNumber/EE.php index 43184e26..d09f3081 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/EE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/EE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/EG.php b/library/Zend/I18n/Validator/PhoneNumber/EG.php index 51370045..d26829a7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/EG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/EG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/EH.php b/library/Zend/I18n/Validator/PhoneNumber/EH.php index 61fa0254..a328ffcc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/EH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/EH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ER.php b/library/Zend/I18n/Validator/PhoneNumber/ER.php index 561f303a..919acf5d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ER.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ER.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ES.php b/library/Zend/I18n/Validator/PhoneNumber/ES.php index c9640759..5387b25f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ES.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ES.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ET.php b/library/Zend/I18n/Validator/PhoneNumber/ET.php index 8601f009..f87979b5 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ET.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ET.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/FI.php b/library/Zend/I18n/Validator/PhoneNumber/FI.php index 3450c5ae..ecfa89b6 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/FI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/FI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/FJ.php b/library/Zend/I18n/Validator/PhoneNumber/FJ.php index 4d6cf27c..da6105a0 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/FJ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/FJ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/FK.php b/library/Zend/I18n/Validator/PhoneNumber/FK.php index fb92b5b3..b826575e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/FK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/FK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/FM.php b/library/Zend/I18n/Validator/PhoneNumber/FM.php index 05b987ff..f16972bc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/FM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/FM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/FO.php b/library/Zend/I18n/Validator/PhoneNumber/FO.php index 175587aa..8f402e42 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/FO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/FO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/FR.php b/library/Zend/I18n/Validator/PhoneNumber/FR.php index fdbadcd3..d12baba1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/FR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/FR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,9 +13,9 @@ return array( 'national' => array( 'general' => '/^[124-9]\\d{8}|3\\d{3}(?:\\d{5})?$/', 'fixed' => '/^[1-5]\\d{8}$/', - 'mobile' => '/^[6-7]\\d{8}|7[5-9]\\d{7}$/', + 'mobile' => '/^(?:[6-7]\\d{8}|7[5-9]\\d{7})$/', 'tollfree' => '/^80\\d{7}$/', - 'premium' => '/^3\\d{3}|89[1-37-9]\\d{6}$/', + 'premium' => '/^(?:3\\d{3}|89[1-37-9])\\d{6}$/', 'shared' => '/^8(?:1[019]|2[0156]|84|90)\\d{6}$/', 'voip' => '/^9\\d{8}$/', 'emergency' => '/^1(?:[578]|12)$/', diff --git a/library/Zend/I18n/Validator/PhoneNumber/GA.php b/library/Zend/I18n/Validator/PhoneNumber/GA.php index 89efc1a7..46ad3fe6 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GB.php b/library/Zend/I18n/Validator/PhoneNumber/GB.php index c79d084c..ccebd249 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GB.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GB.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GD.php b/library/Zend/I18n/Validator/PhoneNumber/GD.php index 5402120e..79d8b665 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GE.php b/library/Zend/I18n/Validator/PhoneNumber/GE.php index 8574f7fe..fac5a770 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GF.php b/library/Zend/I18n/Validator/PhoneNumber/GF.php index 2cf36618..8a2d790d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GG.php b/library/Zend/I18n/Validator/PhoneNumber/GG.php index ed541475..067acc37 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GH.php b/library/Zend/I18n/Validator/PhoneNumber/GH.php index cd575022..7f7e363d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GI.php b/library/Zend/I18n/Validator/PhoneNumber/GI.php index 6847168b..561620e9 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GL.php b/library/Zend/I18n/Validator/PhoneNumber/GL.php index 074467e1..c429cd4e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GM.php b/library/Zend/I18n/Validator/PhoneNumber/GM.php index d4b834bd..637a496c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GN.php b/library/Zend/I18n/Validator/PhoneNumber/GN.php index d1df586c..df126258 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GP.php b/library/Zend/I18n/Validator/PhoneNumber/GP.php index 75ab3436..2efcda49 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GP.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GP.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GQ.php b/library/Zend/I18n/Validator/PhoneNumber/GQ.php index df5d2531..77fe07cc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GQ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GQ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GR.php b/library/Zend/I18n/Validator/PhoneNumber/GR.php index f279291a..ecb5dafd 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GT.php b/library/Zend/I18n/Validator/PhoneNumber/GT.php index f417e17a..25010c61 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GU.php b/library/Zend/I18n/Validator/PhoneNumber/GU.php index f897375f..466d7bc1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GW.php b/library/Zend/I18n/Validator/PhoneNumber/GW.php index 661a13e0..7f251ad9 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/GY.php b/library/Zend/I18n/Validator/PhoneNumber/GY.php index 1d97f513..d485d2e0 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/GY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/GY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/HK.php b/library/Zend/I18n/Validator/PhoneNumber/HK.php index 4d8ad36b..66acea94 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/HK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/HK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/HN.php b/library/Zend/I18n/Validator/PhoneNumber/HN.php index d6737460..2645c73c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/HN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/HN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/HR.php b/library/Zend/I18n/Validator/PhoneNumber/HR.php index a4c032f8..1dfe30cf 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/HR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/HR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/HT.php b/library/Zend/I18n/Validator/PhoneNumber/HT.php index 90abff57..e9371388 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/HT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/HT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/HU.php b/library/Zend/I18n/Validator/PhoneNumber/HU.php index c1d26615..400a29db 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/HU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/HU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ID.php b/library/Zend/I18n/Validator/PhoneNumber/ID.php index 05f70715..b22157f6 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ID.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ID.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IE.php b/library/Zend/I18n/Validator/PhoneNumber/IE.php index 416da054..75a9ddf7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IL.php b/library/Zend/I18n/Validator/PhoneNumber/IL.php index 293a3fa6..286fca8c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IM.php b/library/Zend/I18n/Validator/PhoneNumber/IM.php index d36f15a2..910d465c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IN.php b/library/Zend/I18n/Validator/PhoneNumber/IN.php index 1968e8f9..440addf0 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IO.php b/library/Zend/I18n/Validator/PhoneNumber/IO.php index 1b1d63bd..6375b337 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IQ.php b/library/Zend/I18n/Validator/PhoneNumber/IQ.php index e660e274..912c3194 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IQ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IQ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IR.php b/library/Zend/I18n/Validator/PhoneNumber/IR.php index 6ca5e96a..7743e69e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IS.php b/library/Zend/I18n/Validator/PhoneNumber/IS.php index 517e49fa..0f1874d4 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/IT.php b/library/Zend/I18n/Validator/PhoneNumber/IT.php index 9274de6a..b6f16be6 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/IT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/IT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/JE.php b/library/Zend/I18n/Validator/PhoneNumber/JE.php index 71f2f698..fb4d5604 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/JE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/JE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/JM.php b/library/Zend/I18n/Validator/PhoneNumber/JM.php index d70e08eb..b602a498 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/JM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/JM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/JO.php b/library/Zend/I18n/Validator/PhoneNumber/JO.php index efd7f97e..c1bd3b98 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/JO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/JO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/JP.php b/library/Zend/I18n/Validator/PhoneNumber/JP.php index 31d8ab5a..85619eba 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/JP.php +++ b/library/Zend/I18n/Validator/PhoneNumber/JP.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KE.php b/library/Zend/I18n/Validator/PhoneNumber/KE.php index 49f198d6..704fab02 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KG.php b/library/Zend/I18n/Validator/PhoneNumber/KG.php index 25820b21..6f08e533 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KH.php b/library/Zend/I18n/Validator/PhoneNumber/KH.php index ebd1b0c9..aba42b4c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KI.php b/library/Zend/I18n/Validator/PhoneNumber/KI.php index 3b9b43fb..2fde2e2e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KM.php b/library/Zend/I18n/Validator/PhoneNumber/KM.php index 97c0af26..7c2fe27c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KN.php b/library/Zend/I18n/Validator/PhoneNumber/KN.php index 6f54c236..0ca61108 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KP.php b/library/Zend/I18n/Validator/PhoneNumber/KP.php index c005ef8e..f9964671 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KP.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KP.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KR.php b/library/Zend/I18n/Validator/PhoneNumber/KR.php index 3c336339..d94c4e0d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KW.php b/library/Zend/I18n/Validator/PhoneNumber/KW.php index ad19cafc..68b8a6f1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KY.php b/library/Zend/I18n/Validator/PhoneNumber/KY.php index ea8b6fe1..1dd83798 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/KZ.php b/library/Zend/I18n/Validator/PhoneNumber/KZ.php index 0ba5df16..30e98e9d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/KZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/KZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LA.php b/library/Zend/I18n/Validator/PhoneNumber/LA.php index 618b55d5..b861bd13 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LB.php b/library/Zend/I18n/Validator/PhoneNumber/LB.php index 52a08199..25c0e803 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LB.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LB.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LC.php b/library/Zend/I18n/Validator/PhoneNumber/LC.php index 8bd033c6..f943a618 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LI.php b/library/Zend/I18n/Validator/PhoneNumber/LI.php index bf27ab78..1342dea8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LK.php b/library/Zend/I18n/Validator/PhoneNumber/LK.php index 739737f5..7f7bfaac 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LR.php b/library/Zend/I18n/Validator/PhoneNumber/LR.php index 6547a6c7..16bc19e3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LS.php b/library/Zend/I18n/Validator/PhoneNumber/LS.php index f5073759..1951870a 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LT.php b/library/Zend/I18n/Validator/PhoneNumber/LT.php index b054f55e..9f7fca06 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LU.php b/library/Zend/I18n/Validator/PhoneNumber/LU.php index aee8dc9f..a41eec60 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LV.php b/library/Zend/I18n/Validator/PhoneNumber/LV.php index 9d73e515..02596f67 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LV.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LV.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/LY.php b/library/Zend/I18n/Validator/PhoneNumber/LY.php index 0855a57a..3afc6a38 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/LY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/LY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MA.php b/library/Zend/I18n/Validator/PhoneNumber/MA.php index 7e887cfa..d1bf3da5 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MC.php b/library/Zend/I18n/Validator/PhoneNumber/MC.php index c2212dcd..11f305b1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MD.php b/library/Zend/I18n/Validator/PhoneNumber/MD.php index 7c490dee..d1a257bd 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ME.php b/library/Zend/I18n/Validator/PhoneNumber/ME.php index fbc80ff7..bae5d575 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ME.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ME.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MF.php b/library/Zend/I18n/Validator/PhoneNumber/MF.php index 55dd233e..c72d36db 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MG.php b/library/Zend/I18n/Validator/PhoneNumber/MG.php index 5a26015b..8b16a3a1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MH.php b/library/Zend/I18n/Validator/PhoneNumber/MH.php index b4a462cb..d42cade3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MK.php b/library/Zend/I18n/Validator/PhoneNumber/MK.php index 5fe3a4f9..f3509851 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ML.php b/library/Zend/I18n/Validator/PhoneNumber/ML.php index fef63884..36f11729 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ML.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ML.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MM.php b/library/Zend/I18n/Validator/PhoneNumber/MM.php index 282bccb1..41182b1b 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MN.php b/library/Zend/I18n/Validator/PhoneNumber/MN.php index 33e5258a..2c947a86 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MO.php b/library/Zend/I18n/Validator/PhoneNumber/MO.php index 1dbd32af..66a033d9 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MP.php b/library/Zend/I18n/Validator/PhoneNumber/MP.php index aa93d456..9125a20a 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MP.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MP.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MQ.php b/library/Zend/I18n/Validator/PhoneNumber/MQ.php index 1224eb1d..873de070 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MQ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MQ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MR.php b/library/Zend/I18n/Validator/PhoneNumber/MR.php index 1a8e84c2..fb1b5294 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MS.php b/library/Zend/I18n/Validator/PhoneNumber/MS.php index 1587038d..ab3bf7c4 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MT.php b/library/Zend/I18n/Validator/PhoneNumber/MT.php index 320a3015..ced6e51e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MU.php b/library/Zend/I18n/Validator/PhoneNumber/MU.php index 1884219d..4fc5cade 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MV.php b/library/Zend/I18n/Validator/PhoneNumber/MV.php index fd58c0a6..0203235f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MV.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MV.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MW.php b/library/Zend/I18n/Validator/PhoneNumber/MW.php index 193fcec4..ce7afec0 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MX.php b/library/Zend/I18n/Validator/PhoneNumber/MX.php index fe04bb4b..30ccaa30 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MX.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MX.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MY.php b/library/Zend/I18n/Validator/PhoneNumber/MY.php index 09a5cc4c..4c8a13e7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/MZ.php b/library/Zend/I18n/Validator/PhoneNumber/MZ.php index dc3c66d1..7322f5d8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/MZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/MZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NA.php b/library/Zend/I18n/Validator/PhoneNumber/NA.php index ca55c4d8..cf590936 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NC.php b/library/Zend/I18n/Validator/PhoneNumber/NC.php index 000d5de2..2f0f9d8f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NE.php b/library/Zend/I18n/Validator/PhoneNumber/NE.php index 447ceaf9..fe593e95 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NF.php b/library/Zend/I18n/Validator/PhoneNumber/NF.php index 5cc97acb..9d174161 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NG.php b/library/Zend/I18n/Validator/PhoneNumber/NG.php index 2e892aff..30dad559 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NI.php b/library/Zend/I18n/Validator/PhoneNumber/NI.php index 4d0ea370..1a6dc26b 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NL.php b/library/Zend/I18n/Validator/PhoneNumber/NL.php index 770efefc..2d1c32a1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NO.php b/library/Zend/I18n/Validator/PhoneNumber/NO.php index 9a35d2cb..16e727d3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NP.php b/library/Zend/I18n/Validator/PhoneNumber/NP.php index 3e50c534..167eb5cf 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NP.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NP.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NR.php b/library/Zend/I18n/Validator/PhoneNumber/NR.php index 584755f4..20a8f665 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NU.php b/library/Zend/I18n/Validator/PhoneNumber/NU.php index d215c2e7..0f1a7587 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/NZ.php b/library/Zend/I18n/Validator/PhoneNumber/NZ.php index 35b2dfbf..d1694483 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/NZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/NZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/OM.php b/library/Zend/I18n/Validator/PhoneNumber/OM.php index 079f9128..67e16524 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/OM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/OM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PA.php b/library/Zend/I18n/Validator/PhoneNumber/PA.php index e12308bb..23736a5b 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PE.php b/library/Zend/I18n/Validator/PhoneNumber/PE.php index 677e9e77..55952bdc 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PF.php b/library/Zend/I18n/Validator/PhoneNumber/PF.php index b145f73e..16eafa34 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PG.php b/library/Zend/I18n/Validator/PhoneNumber/PG.php index 9b670bca..83827132 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PH.php b/library/Zend/I18n/Validator/PhoneNumber/PH.php index 63c83e67..017f1a8c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PK.php b/library/Zend/I18n/Validator/PhoneNumber/PK.php index 8bc537dd..9f3de733 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PL.php b/library/Zend/I18n/Validator/PhoneNumber/PL.php index 727adf86..8c635783 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PM.php b/library/Zend/I18n/Validator/PhoneNumber/PM.php index c47eae2b..25602651 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PR.php b/library/Zend/I18n/Validator/PhoneNumber/PR.php index f0cb29d0..c13d9e13 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PS.php b/library/Zend/I18n/Validator/PhoneNumber/PS.php index 7e98744f..2897f820 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PT.php b/library/Zend/I18n/Validator/PhoneNumber/PT.php index 01ca6734..ee18cfb4 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PW.php b/library/Zend/I18n/Validator/PhoneNumber/PW.php index dbb7e2a3..d1fc4987 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/PY.php b/library/Zend/I18n/Validator/PhoneNumber/PY.php index 7fd69d0f..99aec619 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/PY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/PY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/QA.php b/library/Zend/I18n/Validator/PhoneNumber/QA.php index 3d139c1b..7ffff430 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/QA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/QA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/RE.php b/library/Zend/I18n/Validator/PhoneNumber/RE.php index 5281602b..45022369 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/RE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/RE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/RO.php b/library/Zend/I18n/Validator/PhoneNumber/RO.php index b51f28fc..b0fcd0d1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/RO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/RO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/RS.php b/library/Zend/I18n/Validator/PhoneNumber/RS.php index 35c2eeff..f37422d2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/RS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/RS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/RU.php b/library/Zend/I18n/Validator/PhoneNumber/RU.php index 6a4e91ca..c90aaf6c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/RU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/RU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/RW.php b/library/Zend/I18n/Validator/PhoneNumber/RW.php index c75e3e2a..8dc2b389 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/RW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/RW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SA.php b/library/Zend/I18n/Validator/PhoneNumber/SA.php index 375f84be..2bc0b9c8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SB.php b/library/Zend/I18n/Validator/PhoneNumber/SB.php index ea109869..909f49b8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SB.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SB.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SC.php b/library/Zend/I18n/Validator/PhoneNumber/SC.php index 3127bc4c..7d347da3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SD.php b/library/Zend/I18n/Validator/PhoneNumber/SD.php index ac125809..264e9940 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SE.php b/library/Zend/I18n/Validator/PhoneNumber/SE.php index 1019aa41..b5dc73a9 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SG.php b/library/Zend/I18n/Validator/PhoneNumber/SG.php index 8bfd363e..e729579d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SH.php b/library/Zend/I18n/Validator/PhoneNumber/SH.php index 789f0d80..970c2071 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SI.php b/library/Zend/I18n/Validator/PhoneNumber/SI.php index ff155eba..e291c0c6 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SJ.php b/library/Zend/I18n/Validator/PhoneNumber/SJ.php index 32ebd5cc..8b298fba 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SJ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SJ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SK.php b/library/Zend/I18n/Validator/PhoneNumber/SK.php index 0f5ac7d5..40d6f0ce 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SL.php b/library/Zend/I18n/Validator/PhoneNumber/SL.php index 021a8c31..7ca542ca 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SM.php b/library/Zend/I18n/Validator/PhoneNumber/SM.php index 31ecb9a3..372f0b80 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SN.php b/library/Zend/I18n/Validator/PhoneNumber/SN.php index b1cb398e..896ce54b 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SO.php b/library/Zend/I18n/Validator/PhoneNumber/SO.php index a8400a35..1d442519 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SR.php b/library/Zend/I18n/Validator/PhoneNumber/SR.php index 73468fc8..f7f3f13e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SS.php b/library/Zend/I18n/Validator/PhoneNumber/SS.php index e1055dbf..8e8eb691 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ST.php b/library/Zend/I18n/Validator/PhoneNumber/ST.php index e6204120..332f980f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ST.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ST.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SV.php b/library/Zend/I18n/Validator/PhoneNumber/SV.php index 2f0e5f18..9fac3525 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SV.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SV.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SX.php b/library/Zend/I18n/Validator/PhoneNumber/SX.php index 1a58b86a..122b7f38 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SX.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SX.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SY.php b/library/Zend/I18n/Validator/PhoneNumber/SY.php index 2036019c..cfb7af6f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/SZ.php b/library/Zend/I18n/Validator/PhoneNumber/SZ.php index 1200fe57..2fa26726 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/SZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/SZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TC.php b/library/Zend/I18n/Validator/PhoneNumber/TC.php index a111f2e1..3cd78dc1 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TD.php b/library/Zend/I18n/Validator/PhoneNumber/TD.php index 832f9f83..ffa54afd 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TD.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TD.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TG.php b/library/Zend/I18n/Validator/PhoneNumber/TG.php index efbff3a5..ebf28dd7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TH.php b/library/Zend/I18n/Validator/PhoneNumber/TH.php index 2b546e31..b3d50d63 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TH.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TH.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TJ.php b/library/Zend/I18n/Validator/PhoneNumber/TJ.php index 1542a109..c95bcc50 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TJ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TJ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TK.php b/library/Zend/I18n/Validator/PhoneNumber/TK.php index ffbac87c..93387430 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TK.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TK.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TL.php b/library/Zend/I18n/Validator/PhoneNumber/TL.php index b316d81b..00980a84 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TL.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TL.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TM.php b/library/Zend/I18n/Validator/PhoneNumber/TM.php index 94f7f38c..a57bf6ad 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TN.php b/library/Zend/I18n/Validator/PhoneNumber/TN.php index a974e155..858c6763 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TO.php b/library/Zend/I18n/Validator/PhoneNumber/TO.php index 4c76aa71..e60e0c7c 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TO.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TO.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TR.php b/library/Zend/I18n/Validator/PhoneNumber/TR.php index d0b4bf79..196a3852 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TR.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TR.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TT.php b/library/Zend/I18n/Validator/PhoneNumber/TT.php index 663c946e..6ad19f14 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TV.php b/library/Zend/I18n/Validator/PhoneNumber/TV.php index aa34f107..153a6981 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TV.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TV.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TW.php b/library/Zend/I18n/Validator/PhoneNumber/TW.php index 1bdc2282..fa69626f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/TZ.php b/library/Zend/I18n/Validator/PhoneNumber/TZ.php index 9f11578c..d03db84e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/TZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/TZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/UA.php b/library/Zend/I18n/Validator/PhoneNumber/UA.php index 3c4ea482..4dc1de69 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/UA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/UA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/UG.php b/library/Zend/I18n/Validator/PhoneNumber/UG.php index 30ae376a..7780758e 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/UG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/UG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/US.php b/library/Zend/I18n/Validator/PhoneNumber/US.php index ef0f7b5d..b4bcbc95 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/US.php +++ b/library/Zend/I18n/Validator/PhoneNumber/US.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/UY.php b/library/Zend/I18n/Validator/PhoneNumber/UY.php index 991caec3..1cc5cee5 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/UY.php +++ b/library/Zend/I18n/Validator/PhoneNumber/UY.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/UZ.php b/library/Zend/I18n/Validator/PhoneNumber/UZ.php index 6e3a5c7d..d4de7063 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/UZ.php +++ b/library/Zend/I18n/Validator/PhoneNumber/UZ.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VA.php b/library/Zend/I18n/Validator/PhoneNumber/VA.php index 365826d1..8811f5c3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VC.php b/library/Zend/I18n/Validator/PhoneNumber/VC.php index fc911554..3ff352e2 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VC.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VC.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VE.php b/library/Zend/I18n/Validator/PhoneNumber/VE.php index 6a064f8a..3a155ef7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VG.php b/library/Zend/I18n/Validator/PhoneNumber/VG.php index 604e063a..e5c44aa3 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VG.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VG.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VI.php b/library/Zend/I18n/Validator/PhoneNumber/VI.php index a1f8010d..6a23bdb7 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VI.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VI.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VN.php b/library/Zend/I18n/Validator/PhoneNumber/VN.php index ea46f114..00577091 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VN.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VN.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/VU.php b/library/Zend/I18n/Validator/PhoneNumber/VU.php index 7ba438b8..9dc42aaa 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/VU.php +++ b/library/Zend/I18n/Validator/PhoneNumber/VU.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/WF.php b/library/Zend/I18n/Validator/PhoneNumber/WF.php index 8dd7c1a4..63981b80 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/WF.php +++ b/library/Zend/I18n/Validator/PhoneNumber/WF.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/WS.php b/library/Zend/I18n/Validator/PhoneNumber/WS.php index 3d0a9de3..a4ffd0a8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/WS.php +++ b/library/Zend/I18n/Validator/PhoneNumber/WS.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/XK.php b/library/Zend/I18n/Validator/PhoneNumber/XK.php new file mode 100644 index 00000000..e0da04df --- /dev/null +++ b/library/Zend/I18n/Validator/PhoneNumber/XK.php @@ -0,0 +1,34 @@ + '383', + 'patterns' => array( + 'national' => array( + 'general' => '/^[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})$/', + 'fixed' => '/^(?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8}$/', + 'mobile' => '/^6(?:[0-689]|7\\d)\\d{6,7}$/', + 'tollfree' => '/^800\\d{3,9}$/', + 'premium' => '/^(?:90[0169]|78\\d)\\d{3,7}$/', + 'uan' => '/^7[06]\\d{4,10}$/', + 'shortcode' => '/^1(?:1(?:[013-9]|\\d(2,4))|[89]\\d{1,4})$/', + 'emergency' => '/^112|9[234]$/', + ), + 'possible' => array( + 'general' => '/^\\d{5,12}$/', + 'fixed' => '/^\\d{5,12}$/', + 'mobile' => '/^\\d{8,10}$/', + 'tollfree' => '/^\\d{6,12}$/', + 'premium' => '/^\\d{6,12}$/', + 'uan' => '/^\\d{6,12}$/', + 'shortcode' => '/^\\d{3,6}$/', + 'emergency' => '/^\\d{2,3}$/', + ), + ), +); diff --git a/library/Zend/I18n/Validator/PhoneNumber/YE.php b/library/Zend/I18n/Validator/PhoneNumber/YE.php index a09d92f0..6a37c42d 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/YE.php +++ b/library/Zend/I18n/Validator/PhoneNumber/YE.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/YT.php b/library/Zend/I18n/Validator/PhoneNumber/YT.php index 416090e9..43e0bf41 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/YT.php +++ b/library/Zend/I18n/Validator/PhoneNumber/YT.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ZA.php b/library/Zend/I18n/Validator/PhoneNumber/ZA.php index e53ffcf3..be812ec8 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ZA.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ZA.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ZM.php b/library/Zend/I18n/Validator/PhoneNumber/ZM.php index 149d8549..39f95170 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ZM.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ZM.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PhoneNumber/ZW.php b/library/Zend/I18n/Validator/PhoneNumber/ZW.php index 6818e722..332cf55f 100644 --- a/library/Zend/I18n/Validator/PhoneNumber/ZW.php +++ b/library/Zend/I18n/Validator/PhoneNumber/ZW.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/Validator/PostCode.php b/library/Zend/I18n/Validator/PostCode.php index a1ab059c..eafc3905 100644 --- a/library/Zend/I18n/Validator/PostCode.php +++ b/library/Zend/I18n/Validator/PostCode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -61,7 +61,7 @@ class PostCode extends AbstractValidator * @var array */ protected static $postCodeRegex = array( - 'GB' => 'GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}', + 'GB' => 'GIR[ ]?0AA|^((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))$|^BFPO[ ]?\d{1,4}', 'JE' => 'JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}', 'GG' => 'GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}', 'IM' => 'IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}', @@ -69,7 +69,7 @@ class PostCode extends AbstractValidator 'CA' => '[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d', 'DE' => '\d{5}', 'JP' => '\d{3}-\d{4}', - 'FR' => '\d{2}[ ]?\d{3}', + 'FR' => '(?!(0{2})|(9(6|9))[ ]?\d{3})(\d{2}[ ]?\d{3})', 'AU' => '\d{4}', 'IT' => '\d{5}', 'CH' => '\d{4}', @@ -79,7 +79,7 @@ class PostCode extends AbstractValidator 'BE' => '\d{4}', 'DK' => '\d{4}', 'SE' => '\d{3}[ ]?\d{2}', - 'NO' => '\d{4}', + 'NO' => '(?!0000)\d{4}', 'BR' => '\d{5}[\-]?\d{3}', 'PT' => '\d{4}([\-]\d{3})?', 'FI' => '\d{5}', diff --git a/library/Zend/I18n/View/Helper/AbstractTranslatorHelper.php b/library/Zend/I18n/View/Helper/AbstractTranslatorHelper.php index 87639702..5e7cacd6 100644 --- a/library/Zend/I18n/View/Helper/AbstractTranslatorHelper.php +++ b/library/Zend/I18n/View/Helper/AbstractTranslatorHelper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -64,7 +64,7 @@ abstract class AbstractTranslatorHelper extends AbstractHelper implements public function getTranslator() { if (! $this->isTranslatorEnabled()) { - return null; + return; } return $this->translator; diff --git a/library/Zend/I18n/View/Helper/CurrencyFormat.php b/library/Zend/I18n/View/Helper/CurrencyFormat.php index e2c7d83c..ddad245d 100644 --- a/library/Zend/I18n/View/Helper/CurrencyFormat.php +++ b/library/Zend/I18n/View/Helper/CurrencyFormat.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -81,8 +81,8 @@ class CurrencyFormat extends AbstractHelper $number, $currencyCode = null, $showDecimals = null, - $locale = null, - $pattern = null + $locale = null, + $pattern = null ) { if (null === $locale) { $locale = $this->getLocale(); @@ -136,9 +136,7 @@ class CurrencyFormat extends AbstractHelper $this->formatters[$formatterId]->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); } - return $this->formatters[$formatterId]->formatCurrency( - $number, $currencyCode - ); + return $this->formatters[$formatterId]->formatCurrency($number, $currencyCode); } /** @@ -163,7 +161,6 @@ class CurrencyFormat extends AbstractHelper return $this->currencyCode; } - /** * Set the currency pattern * diff --git a/library/Zend/I18n/View/Helper/DateFormat.php b/library/Zend/I18n/View/Helper/DateFormat.php index 0323435b..026cdd9a 100644 --- a/library/Zend/I18n/View/Helper/DateFormat.php +++ b/library/Zend/I18n/View/Helper/DateFormat.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -68,8 +68,8 @@ class DateFormat extends AbstractHelper $date, $dateType = IntlDateFormatter::NONE, $timeType = IntlDateFormatter::NONE, - $locale = null, - $pattern = null + $locale = null, + $pattern = null ) { if ($locale === null) { $locale = $this->getLocale(); diff --git a/library/Zend/I18n/View/Helper/NumberFormat.php b/library/Zend/I18n/View/Helper/NumberFormat.php index eb6301a8..b944b1ae 100644 --- a/library/Zend/I18n/View/Helper/NumberFormat.php +++ b/library/Zend/I18n/View/Helper/NumberFormat.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -80,9 +80,9 @@ class NumberFormat extends AbstractHelper public function __invoke( $number, $formatStyle = null, - $formatType = null, - $locale = null, - $decimals = null + $formatType = null, + $locale = null, + $decimals = null ) { if (null === $locale) { $locale = $this->getLocale(); diff --git a/library/Zend/I18n/View/Helper/Plural.php b/library/Zend/I18n/View/Helper/Plural.php index f550101a..3bb31ba7 100644 --- a/library/Zend/I18n/View/Helper/Plural.php +++ b/library/Zend/I18n/View/Helper/Plural.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/View/Helper/Translate.php b/library/Zend/I18n/View/Helper/Translate.php index 5b7a5083..bfd9d20a 100644 --- a/library/Zend/I18n/View/Helper/Translate.php +++ b/library/Zend/I18n/View/Helper/Translate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/View/Helper/TranslatePlural.php b/library/Zend/I18n/View/Helper/TranslatePlural.php index 9c46853f..eee3efea 100644 --- a/library/Zend/I18n/View/Helper/TranslatePlural.php +++ b/library/Zend/I18n/View/Helper/TranslatePlural.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/View/HelperConfig.php b/library/Zend/I18n/View/HelperConfig.php index e7ac22df..714b1315 100644 --- a/library/Zend/I18n/View/HelperConfig.php +++ b/library/Zend/I18n/View/HelperConfig.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/I18n/composer.json b/library/Zend/I18n/composer.json index 6eec5a6a..a2091f44 100644 --- a/library/Zend/I18n/composer.json +++ b/library/Zend/I18n/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\I18n\\": "" } }, - "target-dir": "Zend/I18n", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -39,8 +38,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/InputFilter/ArrayInput.php b/library/Zend/InputFilter/ArrayInput.php index 2036c63f..102d6fb1 100644 --- a/library/Zend/InputFilter/ArrayInput.php +++ b/library/Zend/InputFilter/ArrayInput.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,6 +31,16 @@ class ArrayInput extends Input return parent::setValue($value); } + /** + * {@inheritdoc} + */ + public function resetValue() + { + $this->value = array(); + $this->hasValue = false; + return $this; + } + /** * @return array */ @@ -50,16 +60,43 @@ class ArrayInput extends Input */ public function isValid($context = null) { - $this->injectNotEmptyValidator(); + $hasValue = $this->hasValue(); + $required = $this->isRequired(); + $hasFallback = $this->hasFallback(); + + if (! $hasValue && $hasFallback) { + $this->setValue($this->getFallbackValue()); + return true; + } + + if (! $hasValue && $required) { + if ($this->errorMessage === null) { + $this->errorMessage = $this->prepareRequiredValidationFailureMessage(); + } + return false; + } + + if (!$this->continueIfEmpty() && !$this->allowEmpty()) { + $this->injectNotEmptyValidator(); + } $validator = $this->getValidatorChain(); $values = $this->getValue(); $result = true; foreach ($values as $value) { + $empty = ($value === null || $value === '' || $value === array()); + if ($empty && !$this->isRequired() && !$this->continueIfEmpty()) { + $result = true; + continue; + } + if ($empty && $this->allowEmpty() && !$this->continueIfEmpty()) { + $result = true; + continue; + } $result = $validator->isValid($value, $context); if (!$result) { - if ($this->hasFallback()) { + if ($hasFallback) { $this->setValue($this->getFallbackValue()); - $result = true; + return true; } break; } diff --git a/library/Zend/InputFilter/BaseInputFilter.php b/library/Zend/InputFilter/BaseInputFilter.php index 5dd4320b..0b2d1bd8 100644 --- a/library/Zend/InputFilter/BaseInputFilter.php +++ b/library/Zend/InputFilter/BaseInputFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,20 +14,35 @@ use Traversable; use Zend\Stdlib\ArrayUtils; use Zend\Stdlib\InitializableInterface; -/** - * @todo How should we deal with required input when data is missing? - * should a message be returned? if so, what message? - */ class BaseInputFilter implements InputFilterInterface, UnknownInputsCapableInterface, InitializableInterface, ReplaceableInputInterface { + /** + * @var null|array + */ protected $data; + + /** + * @var InputInterface[]|InputFilterInterface[] + */ protected $inputs = array(); + + /** + * @var InputInterface[]|InputFilterInterface[] + */ protected $invalidInputs; + + /** + * @var null|string[] Input names + */ protected $validationGroup; + + /** + * @var InputInterface[]|InputFilterInterface[] + */ protected $validInputs; /** @@ -91,23 +106,13 @@ class BaseInputFilter implements /** * Replace a named input * - * @param InputInterface|InputFilterInterface $input + * @param mixed $input Any of the input types allowed on add() method. * @param string $name Name of the input to replace - * @throws Exception\InvalidArgumentException + * @throws Exception\InvalidArgumentException If input to replace not exists. * @return self */ public function replace($input, $name) { - if (!$input instanceof InputInterface && !$input instanceof InputFilterInterface) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects an instance of %s or %s as its first argument; received "%s"', - __METHOD__, - 'Zend\InputFilter\InputInterface', - 'Zend\InputFilter\InputFilterInterface', - (is_object($input) ? get_class($input) : gettype($input)) - )); - } - if (!array_key_exists($name, $this->inputs)) { throw new Exception\InvalidArgumentException(sprintf( '%s: no input found matching "%s"', @@ -116,7 +121,9 @@ class BaseInputFilter implements )); } - $this->inputs[$name] = $input; + $this->remove($name); + $this->add($input, $name); + return $this; } @@ -171,16 +178,16 @@ class BaseInputFilter implements */ public function setData($data) { - if (!is_array($data) && !$data instanceof Traversable) { + if ($data instanceof Traversable) { + $data = ArrayUtils::iteratorToArray($data); + } + if (!is_array($data)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received %s', __METHOD__, (is_object($data) ? get_class($data) : gettype($data)) )); } - if (is_object($data) && !$data instanceof ArrayAccess) { - $data = ArrayUtils::iteratorToArray($data); - } $this->data = $data; $this->populate(); return $this; @@ -189,13 +196,13 @@ class BaseInputFilter implements /** * Is the data set valid? * + * @param mixed|null $context * @throws Exception\RuntimeException * @return bool */ - public function isValid() + public function isValid($context = null) { - $data = $this->getRawValues(); - if (null === $data) { + if (null === $this->data) { throw new Exception\RuntimeException(sprintf( '%s: no data present to validate!', __METHOD__ @@ -203,132 +210,31 @@ class BaseInputFilter implements } $inputs = $this->validationGroup ?: array_keys($this->inputs); - return $this->validateInputs($inputs, $data); + return $this->validateInputs($inputs, $this->data, $context); } /** * Validate a set of inputs against the current data * - * @param array $inputs - * @param array $data + * @param string[] $inputs Array of input names. + * @param array|ArrayAccess $data + * @param mixed|null $context * @return bool */ - protected function validateInputs(array $inputs, array $data = array()) + protected function validateInputs(array $inputs, $data = array(), $context = null) { - // backwards compatibility - if (empty($data)) { - $data = $this->getRawValues(); - } + $inputContext = $context ?: (array_merge($this->getRawValues(), (array) $data)); $this->validInputs = array(); $this->invalidInputs = array(); $valid = true; foreach ($inputs as $name) { - $input = $this->inputs[$name]; - $dataExists = array_key_exists($name, $data); - - // key doesn't exist, but input is not required; valid - if (!$dataExists - && $input instanceof InputInterface - && !$input->isRequired() - ) { - $this->validInputs[$name] = $input; - continue; - } - - // key doesn't exist, input is required, allows empty; valid if - // continueIfEmpty is false or input doesn't implement - // that interface; otherwise validation chain continues - if (!$dataExists - && $input instanceof InputInterface - && $input->isRequired() - && $input->allowEmpty() - ) { - if (!($input instanceOf EmptyContextInterface && $input->continueIfEmpty())) { - $this->validInputs[$name] = $input; - continue; - } - } - - // key exists, is null, input is not required; valid - if ($dataExists - && null === $data[$name] - && $input instanceof InputInterface - && !$input->isRequired() - ) { - $this->validInputs[$name] = $input; - continue; - } - - // key exists, is null, input is required, allows empty; valid if - // continueIfEmpty is false or input doesn't implement - // that interface; otherwise validation chain continues - if ($dataExists - && null === $data[$name] - && $input instanceof InputInterface - && $input->isRequired() - && $input->allowEmpty() - ) { - if (!($input instanceof EmptyContextInterface && $input->continueIfEmpty())) { - $this->validInputs[$name] = $input; - continue; - } - } - - // key exists, empty string, input is not required, allows empty; valid - if ($dataExists - && '' === $data[$name] - && $input instanceof InputInterface - && !$input->isRequired() - && $input->allowEmpty() - ) { - $this->validInputs[$name] = $input; - continue; - } - - // key exists, empty string, input is required, allows empty; valid - // if continueIfEmpty is false, otherwise validation continues - if ($dataExists - && '' === $data[$name] - && $input instanceof InputInterface - && $input->isRequired() - && $input->allowEmpty() - ) { - if (!($input instanceof EmptyContextInterface && $input->continueIfEmpty())) { - $this->validInputs[$name] = $input; - continue; - } - } - - // key exists, is array representing file, no file present, input not - // required or allows empty; valid - if ($dataExists - && is_array($data[$name]) - && ( - (isset($data[$name]['error']) - && $data[$name]['error'] === UPLOAD_ERR_NO_FILE) - || (count($data[$name]) === 1 - && isset($data[$name][0]) - && is_array($data[$name][0]) - && isset($data[$name][0]['error']) - && $data[$name][0]['error'] === UPLOAD_ERR_NO_FILE) - ) - && $input instanceof InputInterface - && (!$input->isRequired() || $input->allowEmpty()) - ) { - $this->validInputs[$name] = $input; - continue; - } - - // make sure we have a value (empty) for validation - if (!$dataExists) { - $data[$name] = null; - } + $input = $this->inputs[$name]; // Validate an input filter if ($input instanceof InputFilterInterface) { - if (!$input->isValid()) { + if (!$input->isValid($context)) { $this->invalidInputs[$name] = $input; $valid = false; continue; @@ -337,21 +243,30 @@ class BaseInputFilter implements continue; } + // If input is not InputInterface then silently continue (BC safe) + if (!$input instanceof InputInterface) { + continue; + } + + // If input is optional (not required), and value is not set, then ignore. + if (!array_key_exists($name, $data) + && !$input->isRequired() + ) { + continue; + } + // Validate an input - if ($input instanceof InputInterface) { - if (!$input->isValid($data)) { - // Validation failure - $this->invalidInputs[$name] = $input; - $valid = false; + if (!$input->isValid($inputContext)) { + // Validation failure + $this->invalidInputs[$name] = $input; + $valid = false; - if ($input->breakOnFailure()) { - return false; - } - continue; + if ($input->breakOnFailure()) { + return false; } - $this->validInputs[$name] = $input; continue; } + $this->validInputs[$name] = $input; } return $valid; @@ -387,35 +302,33 @@ class BaseInputFilter implements if (is_array($name)) { $inputs = array(); foreach ($name as $key => $value) { - if (!$this->has($key)) { + if (! $this->has($key)) { $inputs[] = $value; - } else { - $inputs[] = $key; - - if (!$this->inputs[$key] instanceof InputFilterInterface) { - throw new Exception\InvalidArgumentException( - sprintf( - 'Input "%s" must implement InputFilterInterface', - $key - ) - ); - } - // Recursively populate validation groups for sub input filters - $this->inputs[$key]->setValidationGroup($value); + continue; } - } - if (!empty($inputs)) { - $this->validateValidationGroup($inputs); - $this->validationGroup = $inputs; - } + $inputs[] = $key; - return $this; + if (! $this->inputs[$key] instanceof InputFilterInterface) { + throw new Exception\InvalidArgumentException( + sprintf( + 'Input "%s" must implement InputFilterInterface', + $key + ) + ); + } + + // Recursively populate validation groups for sub input filters + $this->inputs[$key]->setValidationGroup($value); + } + } else { + $inputs = func_get_args(); } - $inputs = func_get_args(); - $this->validateValidationGroup($inputs); - $this->validationGroup = $inputs; + if (! empty($inputs)) { + $this->validateValidationGroup($inputs); + $this->validationGroup = $inputs; + } return $this; } @@ -512,6 +425,9 @@ class BaseInputFilter implements )); } $input = $this->inputs[$name]; + if ($input instanceof InputFilterInterface) { + return $input->getRawValues(); + } return $input->getRawValue(); } @@ -531,6 +447,7 @@ class BaseInputFilter implements $values[$name] = $input->getRawValues(); continue; } + $values[$name] = $input->getRawValue(); } return $values; @@ -557,7 +474,7 @@ class BaseInputFilter implements /** * Ensure all names of a validation group exist as input in the filter * - * @param array $inputs + * @param string[] $inputs Input names * @return void * @throws Exception\InvalidArgumentException */ @@ -588,7 +505,7 @@ class BaseInputFilter implements $input->clearRawValues(); } - if (!isset($this->data[$name])) { + if (!array_key_exists($name, $this->data)) { // No value; clear value in this input if ($input instanceof InputFilterInterface) { $input->setData(array()); @@ -600,6 +517,11 @@ class BaseInputFilter implements continue; } + if ($input instanceof Input) { + $input->resetValue(); + continue; + } + $input->setValue(null); continue; } @@ -673,10 +595,26 @@ class BaseInputFilter implements /** * Get an array of all inputs * - * @return array + * @return InputInterface[]|InputFilterInterface[] */ public function getInputs() { return $this->inputs; } + + /** + * Merges the inputs from an InputFilter into the current one + * + * @param BaseInputFilter $inputFilter + * + * @return self + */ + public function merge(BaseInputFilter $inputFilter) + { + foreach ($inputFilter->getInputs() as $name => $input) { + $this->add($input, $name); + } + + return $this; + } } diff --git a/library/Zend/InputFilter/CollectionInputFilter.php b/library/Zend/InputFilter/CollectionInputFilter.php index 9775d1c1..6d34c7c1 100644 --- a/library/Zend/InputFilter/CollectionInputFilter.php +++ b/library/Zend/InputFilter/CollectionInputFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,27 +13,27 @@ use Traversable; class CollectionInputFilter extends InputFilter { - /* + /** * @var bool */ protected $isRequired = false; - /* + /** * @var int */ protected $count = null; - /* - * @var array + /** + * @var array[] */ protected $collectionValues = array(); - /* - * @var array + /** + * @var array[] */ protected $collectionRawValues = array(); - /* + /** * @var array */ protected $collectionMessages = array(); @@ -140,6 +140,8 @@ class CollectionInputFilter extends InputFilter public function setData($data) { $this->data = $data; + + return $this; } /** @@ -200,11 +202,8 @@ class CollectionInputFilter extends InputFilter public function setValidationGroup($name) { if ($name === self::VALIDATE_ALL) { - $this->validationGroup = null; - - return $this; + $name = null; } - $this->validationGroup = $name; return $this; @@ -229,7 +228,7 @@ class CollectionInputFilter extends InputFilter /** * Clear collectionValues * - * @access public + * @return array[] */ public function clearValues() { @@ -239,7 +238,7 @@ class CollectionInputFilter extends InputFilter /** * Clear collectionRawValues * - * @access public + * @return array[] */ public function clearRawValues() { diff --git a/library/Zend/InputFilter/EmptyContextInterface.php b/library/Zend/InputFilter/EmptyContextInterface.php index 0a2270d7..fd049db1 100644 --- a/library/Zend/InputFilter/EmptyContextInterface.php +++ b/library/Zend/InputFilter/EmptyContextInterface.php @@ -3,15 +3,29 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\InputFilter; +/** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + */ interface EmptyContextInterface { + /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain and set this to `true`. + * + * @param bool $continueIfEmpty + * @return self + */ public function setContinueIfEmpty($continueIfEmpty); + /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. Should always return `true`. + * + * @return bool + */ public function continueIfEmpty(); } diff --git a/library/Zend/InputFilter/Exception/ExceptionInterface.php b/library/Zend/InputFilter/Exception/ExceptionInterface.php index cca907e4..25dc0f93 100644 --- a/library/Zend/InputFilter/Exception/ExceptionInterface.php +++ b/library/Zend/InputFilter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/InputFilter/Exception/InvalidArgumentException.php b/library/Zend/InputFilter/Exception/InvalidArgumentException.php index 7677836b..2be90530 100644 --- a/library/Zend/InputFilter/Exception/InvalidArgumentException.php +++ b/library/Zend/InputFilter/Exception/InvalidArgumentException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\InputFilter\Exception; -class InvalidArgumentException extends \InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/InputFilter/Exception/RuntimeException.php b/library/Zend/InputFilter/Exception/RuntimeException.php index edfdf80f..b882163d 100644 --- a/library/Zend/InputFilter/Exception/RuntimeException.php +++ b/library/Zend/InputFilter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/InputFilter/Factory.php b/library/Zend/InputFilter/Factory.php index 8b66af22..d07ecc6b 100644 --- a/library/Zend/InputFilter/Factory.php +++ b/library/Zend/InputFilter/Factory.php @@ -3,19 +3,18 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\InputFilter; use Traversable; -use Zend\Filter\Exception; use Zend\Filter\FilterChain; -use Zend\Stdlib\ArrayUtils; -use Zend\Validator\ValidatorInterface; -use Zend\Validator\ValidatorChain; use Zend\ServiceManager\ServiceLocatorInterface; +use Zend\Stdlib\ArrayUtils; +use Zend\Validator\ValidatorChain; +use Zend\Validator\ValidatorInterface; class Factory { @@ -145,13 +144,17 @@ class Factory /** * Factory for input objects * - * @param array|Traversable $inputSpecification + * @param array|Traversable|InputProviderInterface $inputSpecification * @throws Exception\InvalidArgumentException * @throws Exception\RuntimeException * @return InputInterface|InputFilterInterface */ public function createInput($inputSpecification) { + if ($inputSpecification instanceof InputProviderInterface) { + $inputSpecification = $inputSpecification->getInputSpecification(); + } + if (!is_array($inputSpecification) && !$inputSpecification instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable; received "%s"', @@ -167,19 +170,20 @@ class Factory if (isset($inputSpecification['type'])) { $class = $inputSpecification['type']; - - if ($this->getInputFilterManager()->has($class)) { - return $this->createInputFilter($inputSpecification); - } - - if (!class_exists($class)) { - throw new Exception\RuntimeException(sprintf( - 'Input factory expects the "type" to be a valid class; received "%s"', - $class - )); - } } - $input = new $class(); + + $managerInstance = null; + if ($this->getInputFilterManager()->has($class)) { + $managerInstance = $this->getInputFilterManager()->get($class); + } + if (! $managerInstance && ! class_exists($class)) { + throw new Exception\RuntimeException(sprintf( + 'Input factory expects the "type" to be a valid class or a plugin name; received "%s"', + $class + )); + } + + $input = $managerInstance ?: new $class; if ($input instanceof InputFilterInterface) { return $this->createInputFilter($inputSpecification); @@ -207,9 +211,6 @@ class Factory break; case 'required': $input->setRequired($value); - if (isset($inputSpecification['allow_empty'])) { - $input->setAllowEmpty($inputSpecification['allow_empty']); - } break; case 'allow_empty': $input->setAllowEmpty($value); @@ -218,12 +219,26 @@ class Factory } break; case 'continue_if_empty': + if (!$input instanceof Input) { + throw new Exception\RuntimeException(sprintf( + '%s "continue_if_empty" can only set to inputs of type "%s"', + __METHOD__, + 'Zend\InputFilter\Input' + )); + } $input->setContinueIfEmpty($inputSpecification['continue_if_empty']); break; case 'error_message': $input->setErrorMessage($value); break; case 'fallback_value': + if (!$input instanceof Input) { + throw new Exception\RuntimeException(sprintf( + '%s "fallback_value" can only set to inputs of type "%s"', + __METHOD__, + 'Zend\InputFilter\Input' + )); + } $input->setFallbackValue($value); break; case 'break_on_failure': @@ -269,13 +284,17 @@ class Factory /** * Factory for input filters * - * @param array|Traversable $inputFilterSpecification + * @param array|Traversable|InputFilterProviderInterface $inputFilterSpecification * @throws Exception\InvalidArgumentException * @throws Exception\RuntimeException * @return InputFilterInterface */ public function createInputFilter($inputFilterSpecification) { + if ($inputFilterSpecification instanceof InputFilterProviderInterface) { + $inputFilterSpecification = $inputFilterSpecification->getInputFilterSpecification(); + } + if (!is_array($inputFilterSpecification) && !$inputFilterSpecification instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable; received "%s"', @@ -367,7 +386,7 @@ class Factory /** * @param ValidatorChain $chain - * @param array|Traversable $validators + * @param string[]|ValidatorInterface[] $validators * @throws Exception\RuntimeException * @return void */ diff --git a/library/Zend/InputFilter/FileInput.php b/library/Zend/InputFilter/FileInput.php index 41d2e493..ed59091a 100644 --- a/library/Zend/InputFilter/FileInput.php +++ b/library/Zend/InputFilter/FileInput.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -83,16 +83,65 @@ class FileInput extends Input return $value; } + /** + * Checks if the raw input value is an empty file input eg: no file was uploaded + * + * @param $rawValue + * @return bool + */ + public function isEmptyFile($rawValue) + { + if (!is_array($rawValue)) { + return true; + } + + if (isset($rawValue['error']) && $rawValue['error'] === UPLOAD_ERR_NO_FILE) { + return true; + } + + if (count($rawValue) === 1 && isset($rawValue[0])) { + return $this->isEmptyFile($rawValue[0]); + } + + return false; + } + /** * @param mixed $context Extra "context" to provide the validator * @return bool */ public function isValid($context = null) { + $rawValue = $this->getRawValue(); + $hasValue = $this->hasValue(); + $empty = $this->isEmptyFile($rawValue); + $required = $this->isRequired(); + $allowEmpty = $this->allowEmpty(); + $continueIfEmpty = $this->continueIfEmpty(); + + if (! $hasValue && ! $required) { + return true; + } + + if (! $hasValue && $required && ! $this->hasFallback()) { + if ($this->errorMessage === null) { + $this->errorMessage = $this->prepareRequiredValidationFailureMessage(); + } + return false; + } + + if ($empty && ! $required && ! $continueIfEmpty) { + return true; + } + + if ($empty && $allowEmpty && ! $continueIfEmpty) { + return true; + } + $this->injectUploadValidator(); $validator = $this->getValidatorChain(); //$value = $this->getValue(); // Do not run the filters yet for File uploads (see getValue()) - $rawValue = $this->getRawValue(); + if (!is_array($rawValue)) { // This can happen in an AJAX POST, where the input comes across as a string $rawValue = array( @@ -144,6 +193,8 @@ class FileInput extends Input } /** + * @deprecated 2.4.8 See note on parent class. Removal does not affect this class. + * * No-op, NotEmpty validator does not apply for FileInputs. * See also: BaseInputFilter::isValid() * diff --git a/library/Zend/InputFilter/Input.php b/library/Zend/InputFilter/Input.php index a5da2ab2..cf51ba02 100644 --- a/library/Zend/InputFilter/Input.php +++ b/library/Zend/InputFilter/Input.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,14 +13,20 @@ use Zend\Filter\FilterChain; use Zend\Validator\NotEmpty; use Zend\Validator\ValidatorChain; -class Input implements InputInterface, EmptyContextInterface +class Input implements + InputInterface, + EmptyContextInterface { /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + * * @var bool */ protected $allowEmpty = false; /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + * * @var bool */ protected $continueIfEmpty = false; @@ -46,6 +52,8 @@ class Input implements InputInterface, EmptyContextInterface protected $name; /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + * * @var bool */ protected $notEmptyValidator = false; @@ -65,6 +73,13 @@ class Input implements InputInterface, EmptyContextInterface */ protected $value; + /** + * Flag for distinguish when $value contains the value previously set or the default one. + * + * @var bool + */ + protected $hasValue = false; + /** * @var mixed */ @@ -81,6 +96,8 @@ class Input implements InputInterface, EmptyContextInterface } /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain and set this to `true`. + * * @param bool $allowEmpty * @return Input */ @@ -101,8 +118,10 @@ class Input implements InputInterface, EmptyContextInterface } /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain and set this to `true`. + * * @param bool $continueIfEmpty - * @return \Zend\InputFilter\Input + * @return Input */ public function setContinueIfEmpty($continueIfEmpty) { @@ -147,7 +166,6 @@ class Input implements InputInterface, EmptyContextInterface public function setRequired($required) { $this->required = (bool) $required; - $this->setAllowEmpty(!$required); return $this; } @@ -162,12 +180,36 @@ class Input implements InputInterface, EmptyContextInterface } /** + * Set the input value. + * + * If you want to remove/unset the current value use {@link Input::resetValue()}. + * + * @see Input::getValue() For retrieve the input value. + * @see Input::hasValue() For to know if input value was set. + * @see Input::resetValue() For reset the input value to the default state. + * * @param mixed $value * @return Input */ public function setValue($value) { $this->value = $value; + $this->hasValue = true; + return $this; + } + + /** + * Reset input value to the default state. + * + * @see Input::hasValue() For to know if input value was set. + * @see Input::setValue() For set a new value. + * + * @return Input + */ + public function resetValue() + { + $this->value = null; + $this->hasValue = false; return $this; } @@ -183,6 +225,8 @@ class Input implements InputInterface, EmptyContextInterface } /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + * * @return bool */ public function allowEmpty() @@ -199,6 +243,8 @@ class Input implements InputInterface, EmptyContextInterface } /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. Should always return `true`. + * * @return bool */ public function continueIfEmpty() @@ -269,6 +315,22 @@ class Input implements InputInterface, EmptyContextInterface return $filter->filter($this->value); } + /** + * Flag for inform if input value was set. + * + * This flag used for distinguish when {@link Input::getValue()} will return the value previously set or the default. + * + * @see Input::getValue() For retrieve the input value. + * @see Input::setValue() For set a new value. + * @see Input::resetValue() For reset the input value to the default state. + * + * @return bool + */ + public function hasValue() + { + return $this->hasValue; + } + /** * @return mixed */ @@ -298,12 +360,16 @@ class Input implements InputInterface, EmptyContextInterface public function merge(InputInterface $input) { $this->setBreakOnFailure($input->breakOnFailure()); - $this->setContinueIfEmpty($input->continueIfEmpty()); + if ($input instanceof Input) { + $this->setContinueIfEmpty($input->continueIfEmpty()); + } $this->setErrorMessage($input->getErrorMessage()); $this->setName($input->getName()); $this->setRequired($input->isRequired()); $this->setAllowEmpty($input->allowEmpty()); - $this->setValue($input->getRawValue()); + if (!($input instanceof Input) || $input->hasValue()) { + $this->setValue($input->getRawValue()); + } $filterChain = $input->getFilterChain(); $this->getFilterChain()->merge($filterChain); @@ -319,16 +385,48 @@ class Input implements InputInterface, EmptyContextInterface */ public function isValid($context = null) { - // Empty value needs further validation if continueIfEmpty is set - // so don't inject NotEmpty validator which would always - // mark that as false - if (!$this->continueIfEmpty()) { + $value = $this->getValue(); + $hasValue = $this->hasValue(); + $empty = ($value === null || $value === '' || $value === array()); + $required = $this->isRequired(); + $allowEmpty = $this->allowEmpty(); + $continueIfEmpty = $this->continueIfEmpty(); + + if (! $hasValue && $this->hasFallback()) { + $this->setValue($this->getFallbackValue()); + return true; + } + + if (! $hasValue && ! $required) { + return true; + } + + if (! $hasValue && $required) { + if ($this->errorMessage === null) { + $this->errorMessage = $this->prepareRequiredValidationFailureMessage(); + } + return false; + } + + if ($empty && ! $required && ! $continueIfEmpty) { + return true; + } + + if ($empty && $allowEmpty && ! $continueIfEmpty) { + return true; + } + + // At this point, we need to run validators. + // If we do not allow empty and the "continue if empty" flag are + // BOTH false, we inject the "not empty" validator into the chain, + // which adds that logic into the validation routine. + if (! $allowEmpty && ! $continueIfEmpty) { $this->injectNotEmptyValidator(); } + $validator = $this->getValidatorChain(); - $value = $this->getValue(); $result = $validator->isValid($value, $context); - if (!$result && $this->hasFallback()) { + if (! $result && $this->hasFallback()) { $this->setValue($this->getFallbackValue()); $result = true; } @@ -337,7 +435,7 @@ class Input implements InputInterface, EmptyContextInterface } /** - * @return array + * @return string[] */ public function getMessages() { @@ -354,6 +452,8 @@ class Input implements InputInterface, EmptyContextInterface } /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + * * @return void */ protected function injectNotEmptyValidator() @@ -372,7 +472,28 @@ class Input implements InputInterface, EmptyContextInterface } } - $chain->prependByName('NotEmpty', array(), true); $this->notEmptyValidator = true; + + if (class_exists('Zend\ServiceManager\AbstractPluginManager')) { + $chain->prependByName('NotEmpty', array(), true); + + return; + } + + $chain->prependValidator(new NotEmpty(), true); + } + + /** + * Create and return the validation failure message for required input. + * + * @return string[] + */ + protected function prepareRequiredValidationFailureMessage() + { + $notEmpty = new NotEmpty(); + $templates = $notEmpty->getOption('messageTemplates'); + return array( + NotEmpty::IS_EMPTY => $templates[NotEmpty::IS_EMPTY], + ); } } diff --git a/library/Zend/InputFilter/InputFilter.php b/library/Zend/InputFilter/InputFilter.php index 29073e91..93131640 100644 --- a/library/Zend/InputFilter/InputFilter.php +++ b/library/Zend/InputFilter/InputFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/InputFilter/InputFilterAbstractServiceFactory.php b/library/Zend/InputFilter/InputFilterAbstractServiceFactory.php new file mode 100644 index 00000000..5d8c5506 --- /dev/null +++ b/library/Zend/InputFilter/InputFilterAbstractServiceFactory.php @@ -0,0 +1,112 @@ +getServiceLocator(); + if (! $services instanceof ServiceLocatorInterface + || ! $services->has('Config') + ) { + return false; + } + + $config = $services->get('Config'); + if (!isset($config['input_filter_specs'][$rName]) + || !is_array($config['input_filter_specs'][$rName]) + ) { + return false; + } + + return true; + } + + /** + * @param ServiceLocatorInterface $inputFilters + * @param string $cName + * @param string $rName + * @return InputFilterInterface + */ + public function createServiceWithName(ServiceLocatorInterface $inputFilters, $cName, $rName) + { + $services = $inputFilters->getServiceLocator(); + $allConfig = $services->get('Config'); + $config = $allConfig['input_filter_specs'][$rName]; + + $factory = $this->getInputFilterFactory($services); + + return $factory->createInputFilter($config); + } + + /** + * @param ServiceLocatorInterface $services + * @return Factory + */ + protected function getInputFilterFactory(ServiceLocatorInterface $services) + { + if ($this->factory instanceof Factory) { + return $this->factory; + } + + $this->factory = new Factory(); + $this->factory + ->getDefaultFilterChain() + ->setPluginManager($this->getFilterPluginManager($services)); + $this->factory + ->getDefaultValidatorChain() + ->setPluginManager($this->getValidatorPluginManager($services)); + + return $this->factory; + } + + /** + * @param ServiceLocatorInterface $services + * @return FilterPluginManager + */ + protected function getFilterPluginManager(ServiceLocatorInterface $services) + { + if ($services->has('FilterManager')) { + return $services->get('FilterManager'); + } + + return new FilterPluginManager(); + } + + /** + * @param ServiceLocatorInterface $services + * @return ValidatorPluginManager + */ + protected function getValidatorPluginManager(ServiceLocatorInterface $services) + { + if ($services->has('ValidatorManager')) { + return $services->get('ValidatorManager'); + } + + return new ValidatorPluginManager(); + } +} diff --git a/library/Zend/InputFilter/InputFilterAwareInterface.php b/library/Zend/InputFilter/InputFilterAwareInterface.php index bf4f2011..fcbf887e 100644 --- a/library/Zend/InputFilter/InputFilterAwareInterface.php +++ b/library/Zend/InputFilter/InputFilterAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/InputFilter/InputFilterAwareTrait.php b/library/Zend/InputFilter/InputFilterAwareTrait.php index cab399e4..a7670f74 100644 --- a/library/Zend/InputFilter/InputFilterAwareTrait.php +++ b/library/Zend/InputFilter/InputFilterAwareTrait.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\InputFilter; - trait InputFilterAwareTrait { /** diff --git a/library/Zend/InputFilter/InputFilterInterface.php b/library/Zend/InputFilter/InputFilterInterface.php index 41bbfcfb..40550169 100644 --- a/library/Zend/InputFilter/InputFilterInterface.php +++ b/library/Zend/InputFilter/InputFilterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,9 +19,12 @@ interface InputFilterInterface extends Countable /** * Add an input to the input filter * - * @param InputInterface|InputFilterInterface|array $input + * @param InputInterface|InputFilterInterface|array|Traversable $input + * Implementations MUST handle at least one of the specified types, and + * raise an exception for any they cannot process. * @param null|string $name Name used to retrieve this input * @return InputFilterInterface + * @throws Exception\InvalidArgumentException if unable to handle the input type. */ public function add($input, $name = null); @@ -142,7 +145,7 @@ interface InputFilterInterface extends Countable * Should return an associative array of named input/message list pairs. * Pairs should only be returned for inputs that failed validation. * - * @return array + * @return string[] */ public function getMessages(); } diff --git a/library/Zend/InputFilter/InputFilterPluginManager.php b/library/Zend/InputFilter/InputFilterPluginManager.php index bd1e7dad..c7460588 100644 --- a/library/Zend/InputFilter/InputFilterPluginManager.php +++ b/library/Zend/InputFilter/InputFilterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,7 +24,7 @@ class InputFilterPluginManager extends AbstractPluginManager /** * Default set of plugins * - * @var array + * @var string[] */ protected $invokableClasses = array( 'inputfilter' => 'Zend\InputFilter\InputFilter', @@ -51,12 +51,12 @@ class InputFilterPluginManager extends AbstractPluginManager /** * Inject this and populate the factory with filter chain and validator chain * - * @param $inputfilter + * @param $inputFilter */ - public function populateFactory($inputfilter) + public function populateFactory($inputFilter) { - if ($inputfilter instanceof InputFilter) { - $factory = $inputfilter->getFactory(); + if ($inputFilter instanceof InputFilter) { + $factory = $inputFilter->getFactory(); $factory->setInputFilterManager($this); @@ -73,7 +73,7 @@ class InputFilterPluginManager extends AbstractPluginManager public function validatePlugin($plugin) { if ($plugin instanceof InputFilterInterface || $plugin instanceof InputInterface) { - // Hook to perform various initialization, when the inputfilter is not created through the factory + // Hook to perform various initialization, when the inputFilter is not created through the factory if ($plugin instanceof InitializableInterface) { $plugin->init(); } @@ -83,8 +83,10 @@ class InputFilterPluginManager extends AbstractPluginManager } throw new Exception\RuntimeException(sprintf( - 'Plugin of type %s is invalid; must implement Zend\InputFilter\InputFilterInterface', - (is_object($plugin) ? get_class($plugin) : gettype($plugin)) + 'Plugin of type %s is invalid; must implement %s or %s', + (is_object($plugin) ? get_class($plugin) : gettype($plugin)), + 'Zend\InputFilter\InputFilterInterface', + 'Zend\InputFilter\InputInterface' )); } } diff --git a/library/Zend/InputFilter/InputFilterProviderInterface.php b/library/Zend/InputFilter/InputFilterProviderInterface.php index 3b57cc8b..f6073faf 100644 --- a/library/Zend/InputFilter/InputFilterProviderInterface.php +++ b/library/Zend/InputFilter/InputFilterProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/InputFilter/InputInterface.php b/library/Zend/InputFilter/InputInterface.php index 85637654..cde375fa 100644 --- a/library/Zend/InputFilter/InputInterface.php +++ b/library/Zend/InputFilter/InputInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,26 +14,116 @@ use Zend\Validator\ValidatorChain; interface InputInterface { + /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain and set this to `true`. + * + * @param bool $allowEmpty + * @return self + */ public function setAllowEmpty($allowEmpty); + + /** + * @param bool $breakOnFailure + * @return self + */ public function setBreakOnFailure($breakOnFailure); + + /** + * @param string|null $errorMessage + * @return self + */ public function setErrorMessage($errorMessage); + + /** + * @param FilterChain $filterChain + * @return self + */ public function setFilterChain(FilterChain $filterChain); + + /** + * @param string $name + * @return self + */ public function setName($name); + + /** + * @param bool $required + * @return self + */ public function setRequired($required); + + /** + * @param ValidatorChain $validatorChain + * @return self + */ public function setValidatorChain(ValidatorChain $validatorChain); + + /** + * @param mixed $value + * @return self + */ public function setValue($value); + + /** + * @param InputInterface $input + * @return self + */ public function merge(InputInterface $input); + /** + * @deprecated 2.4.8 Add Zend\Validator\NotEmpty validator to the ValidatorChain. + * + * @return bool + */ public function allowEmpty(); + + /** + * @return bool + */ public function breakOnFailure(); + + /** + * @return string|null + */ public function getErrorMessage(); + + /** + * @return FilterChain + */ public function getFilterChain(); + + /** + * @return string + */ public function getName(); + + /** + * @return mixed + */ public function getRawValue(); + + /** + * @return bool + */ public function isRequired(); + + /** + * @return ValidatorChain + */ public function getValidatorChain(); + + /** + * @return mixed + */ public function getValue(); + /** + * @return bool + */ public function isValid(); + + /** + * @return string[] + */ public function getMessages(); } diff --git a/library/Zend/InputFilter/InputProviderInterface.php b/library/Zend/InputFilter/InputProviderInterface.php index f5298a19..79aca565 100644 --- a/library/Zend/InputFilter/InputProviderInterface.php +++ b/library/Zend/InputFilter/InputProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/InputFilter/ReplaceableInputInterface.php b/library/Zend/InputFilter/ReplaceableInputInterface.php index ecaf46ab..9bf55190 100644 --- a/library/Zend/InputFilter/ReplaceableInputInterface.php +++ b/library/Zend/InputFilter/ReplaceableInputInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,5 +15,10 @@ namespace Zend\InputFilter; */ interface ReplaceableInputInterface { + /** + * @param $input + * @param $name + * @return self + */ public function replace($input, $name); } diff --git a/library/Zend/InputFilter/UnknownInputsCapableInterface.php b/library/Zend/InputFilter/UnknownInputsCapableInterface.php index 1890307b..58156fe5 100644 --- a/library/Zend/InputFilter/UnknownInputsCapableInterface.php +++ b/library/Zend/InputFilter/UnknownInputsCapableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,6 +15,19 @@ namespace Zend\InputFilter; */ interface UnknownInputsCapableInterface { + /** + * Is the data set has unknown input ? + * + * @throws Exception\RuntimeException + * @return bool + */ public function hasUnknown(); + + /** + * Return the unknown input + * + * @throws Exception\RuntimeException + * @return array + */ public function getUnknown(); } diff --git a/library/Zend/InputFilter/composer.json b/library/Zend/InputFilter/composer.json index 886d7310..0615067e 100644 --- a/library/Zend/InputFilter/composer.json +++ b/library/Zend/InputFilter/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\InputFilter\\": "" } }, - "target-dir": "Zend/InputFilter", "require": { "php": ">=5.3.23", "zendframework/zend-filter": "self.version", @@ -27,8 +26,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Json/Decoder.php b/library/Zend/Json/Decoder.php index e064e6fa..fc4779bb 100644 --- a/library/Zend/Json/Decoder.php +++ b/library/Zend/Json/Decoder.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -220,16 +220,12 @@ class Decoder $result = $this->tokenValue; $this->_getNextToken(); return($result); - break; case self::LBRACE: return($this->_decodeObject()); - break; case self::LBRACKET: return($this->_decodeArray()); - break; default: - return null; - break; + return; } } @@ -265,7 +261,7 @@ class Decoder throw new RuntimeException('Missing ":" in object encoding: ' . $this->source); } - $tok = $this->_getNextToken(); + $this->_getNextToken(); $members[$key] = $this->_decodeValue(); $tok = $this->token; @@ -334,24 +330,17 @@ class Decoder return $result; } - /** * Removes whitespace characters from the source input */ protected function _eatWhitespace() { - if (preg_match( - '/([\t\b\f\n\r ])*/s', - $this->source, - $matches, - PREG_OFFSET_CAPTURE, - $this->offset) + if (preg_match('/([\t\b\f\n\r ])*/s', $this->source, $matches, PREG_OFFSET_CAPTURE, $this->offset) && $matches[0][1] == $this->offset) { $this->offset += strlen($matches[0][0]); } } - /** * Retrieves the next token from the source stream * @@ -375,8 +364,8 @@ class Decoder switch ($str{$i}) { case '{': - $this->token = self::LBRACE; - break; + $this->token = self::LBRACE; + break; case '}': $this->token = self::RBRACE; break; @@ -392,7 +381,7 @@ class Decoder case ':': $this->token = self::COLON; break; - case '"': + case '"': $result = ''; do { $i++; @@ -409,31 +398,31 @@ class Decoder } $chr = $str{$i}; switch ($chr) { - case '"' : + case '"': $result .= '"'; break; case '\\': $result .= '\\'; break; - case '/' : + case '/': $result .= '/'; break; - case 'b' : + case 'b': $result .= "\x08"; break; - case 'f' : + case 'f': $result .= "\x0c"; break; - case 'n' : + case 'n': $result .= "\x0a"; break; - case 'r' : + case 'r': $result .= "\x0d"; break; - case 't' : + case 't': $result .= "\x09"; break; - case '\'' : + case '\'': $result .= '\''; break; default: @@ -468,7 +457,7 @@ class Decoder if (($i+ 3) < $strLength && substr($str, $start, 4) == "null") { $this->token = self::DATUM; } - $this->tokenValue = NULL; + $this->tokenValue = null; $i += 3; break; } @@ -480,8 +469,7 @@ class Decoder $chr = $str{$i}; if ($chr == '-' || $chr == '.' || ($chr >= '0' && $chr <= '9')) { - if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s', - $str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) { + if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s', $str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) { $datum = $matches[0][0]; if (is_numeric($datum)) { diff --git a/library/Zend/Json/Encoder.php b/library/Zend/Json/Encoder.php index 0d8d3552..5c02f1af 100644 --- a/library/Zend/Json/Encoder.php +++ b/library/Zend/Json/Encoder.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -65,7 +65,7 @@ class Encoder */ public static function encode($value, $cycleCheck = false, $options = array()) { - $encoder = new static(($cycleCheck) ? true : false, $options); + $encoder = new static($cycleCheck, $options); if ($value instanceof JsonSerializable) { $value = $value->jsonSerialize(); @@ -95,7 +95,6 @@ class Encoder return $this->_encodeDatum($value); } - /** * Encode an object to JSON by encoding each of the public properties * @@ -129,7 +128,7 @@ class Encoder $props = ''; if (method_exists($value, 'toJson')) { - $props =',' . preg_replace("/^\{(.*)\}$/","\\1", $value->toJson()); + $props = ',' . preg_replace("/^\{(.*)\}$/", "\\1", $value->toJson()); } else { if ($value instanceof IteratorAggregate) { $propCollection = $value->getIterator(); @@ -155,7 +154,6 @@ class Encoder . $props . '}'; } - /** * Determine if an object has been serialized already * @@ -171,7 +169,6 @@ class Encoder return false; } - /** * JSON encode an array value * @@ -215,7 +212,6 @@ class Encoder return $result; } - /** * JSON encode a basic data type (string, number, boolean, null) * @@ -241,7 +237,6 @@ class Encoder return $result; } - /** * JSON encode a string value by escaping characters as necessary * @@ -265,7 +260,6 @@ class Encoder return '"' . $string . '"'; } - /** * Encode the constants associated with the ReflectionClass * parameter. The encoding format is based on the class2 format @@ -290,7 +284,6 @@ class Encoder return $result . "}"; } - /** * Encode the public methods of the ReflectionClass in the * class2 format @@ -353,7 +346,6 @@ class Encoder return $result . "}"; } - /** * Encode the public properties of the ReflectionClass in the class2 * format. @@ -367,7 +359,6 @@ class Encoder $properties = $cls->getProperties(); $propValues = get_class_vars($cls->getName()); $result = "variables:{"; - $cnt = 0; $tmpArray = array(); foreach ($properties as $prop) { @@ -410,7 +401,6 @@ class Encoder . self::_encodeVariables($cls) .'});'; } - /** * Encode several classes at once * @@ -471,9 +461,12 @@ class Encoder case (($ordVarC & 0xF0) == 0xE0): // characters U-00000800 - U-0000FFFF, mask 1110XXXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ordVarC, - ord($value[$i + 1]), - ord($value[$i + 2])); + $char = pack( + 'C*', + $ordVarC, + ord($value[$i + 1]), + ord($value[$i + 2]) + ); $i += 2; $utf16 = self::_utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -482,10 +475,13 @@ class Encoder case (($ordVarC & 0xF8) == 0xF0): // characters U-00010000 - U-001FFFFF, mask 11110XXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ordVarC, - ord($value[$i + 1]), - ord($value[$i + 2]), - ord($value[$i + 3])); + $char = pack( + 'C*', + $ordVarC, + ord($value[$i + 1]), + ord($value[$i + 2]), + ord($value[$i + 3]) + ); $i += 3; $utf16 = self::_utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -494,11 +490,14 @@ class Encoder case (($ordVarC & 0xFC) == 0xF8): // characters U-00200000 - U-03FFFFFF, mask 111110XX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ordVarC, - ord($value[$i + 1]), - ord($value[$i + 2]), - ord($value[$i + 3]), - ord($value[$i + 4])); + $char = pack( + 'C*', + $ordVarC, + ord($value[$i + 1]), + ord($value[$i + 2]), + ord($value[$i + 3]), + ord($value[$i + 4]) + ); $i += 4; $utf16 = self::_utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -507,12 +506,15 @@ class Encoder case (($ordVarC & 0xFE) == 0xFC): // characters U-04000000 - U-7FFFFFFF, mask 1111110X // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ordVarC, - ord($value[$i + 1]), - ord($value[$i + 2]), - ord($value[$i + 3]), - ord($value[$i + 4]), - ord($value[$i + 5])); + $char = pack( + 'C*', + $ordVarC, + ord($value[$i + 1]), + ord($value[$i + 2]), + ord($value[$i + 3]), + ord($value[$i + 4]), + ord($value[$i + 5]) + ); $i += 5; $utf16 = self::_utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -552,17 +554,12 @@ class Encoder case 2: // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); + return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); + return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); } // ignoring UTF-32 for now, sorry diff --git a/library/Zend/Json/Exception/BadMethodCallException.php b/library/Zend/Json/Exception/BadMethodCallException.php index 6f2ace0d..ef32d84d 100644 --- a/library/Zend/Json/Exception/BadMethodCallException.php +++ b/library/Zend/Json/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Exception/ExceptionInterface.php b/library/Zend/Json/Exception/ExceptionInterface.php index e087d9b2..2e5ee94f 100644 --- a/library/Zend/Json/Exception/ExceptionInterface.php +++ b/library/Zend/Json/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Exception/InvalidArgumentException.php b/library/Zend/Json/Exception/InvalidArgumentException.php index e7e8b5ae..3863261d 100644 --- a/library/Zend/Json/Exception/InvalidArgumentException.php +++ b/library/Zend/Json/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Exception/RecursionException.php b/library/Zend/Json/Exception/RecursionException.php index c40ec571..e6fd545b 100644 --- a/library/Zend/Json/Exception/RecursionException.php +++ b/library/Zend/Json/Exception/RecursionException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Exception/RuntimeException.php b/library/Zend/Json/Exception/RuntimeException.php index 65381497..a74268ee 100644 --- a/library/Zend/Json/Exception/RuntimeException.php +++ b/library/Zend/Json/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Expr.php b/library/Zend/Json/Expr.php index c112de7f..683127c3 100644 --- a/library/Zend/Json/Expr.php +++ b/library/Zend/Json/Expr.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Json.php b/library/Zend/Json/Json.php index ec74d199..03159557 100644 --- a/library/Zend/Json/Json.php +++ b/library/Zend/Json/Json.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -114,16 +114,29 @@ class Json $valueToEncode = static::_recursiveJsonExprFinder($valueToEncode, $javascriptExpressions); } + $prettyPrint = (isset($options['prettyPrint']) && ($options['prettyPrint'] == true)); + // Encoding if (function_exists('json_encode') && static::$useBuiltinEncoderDecoder !== true) { + $encodeOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP; + + if ($prettyPrint && defined('JSON_PRETTY_PRINT')) { + $encodeOptions |= JSON_PRETTY_PRINT; + $prettyPrint = false; + } + $encodedResult = json_encode( $valueToEncode, - JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP + $encodeOptions ); } else { $encodedResult = Encoder::encode($valueToEncode, $cycleCheck, $options); } + if ($prettyPrint) { + $encodedResult = self::prettyPrint($encodedResult, array("intent" => " ")); + } + //only do post-processing to revert back the Zend\Json\Expr if any. if (count($javascriptExpressions) > 0) { $count = count($javascriptExpressions); @@ -160,7 +173,9 @@ class Json * @return mixed */ protected static function _recursiveJsonExprFinder( - &$value, array &$javascriptExpressions, $currentKey = null + &$value, + array &$javascriptExpressions, + $currentKey = null ) { if ($value instanceof Expr) { // TODO: Optimize with ascii keys, if performance is bad @@ -318,9 +333,7 @@ class Json // If it is not a valid XML content, throw an exception. if (!$simpleXmlElementObject) { throw new RuntimeException('Function fromXml was called with an invalid XML formatted string.'); - } // End of if ($simpleXmlElementObject == null) - - $resultArray = null; + } // End of if ($simpleXmlElementObject === null) // Call the recursive function to convert the XML into a PHP array. $resultArray = static::_processXml($simpleXmlElementObject, $ignoreXmlAttributes); @@ -346,17 +359,22 @@ class Json $result = ""; $indent = 0; - $ind = "\t"; + $ind = " "; if (isset($options['indent'])) { $ind = $options['indent']; } $inLiteral = false; foreach ($tokens as $token) { + $token = trim($token); if ($token == "") { continue; } + if (preg_match('/^("(?:.*)"):[ ]?(.*)$/', $token, $matches)) { + $token = $matches[1] . ': ' . $matches[2]; + } + $prefix = str_repeat($ind, $indent); if (!$inLiteral && ($token == "{" || $token == "[")) { $indent++; diff --git a/library/Zend/Json/Server/Cache.php b/library/Zend/Json/Server/Cache.php index 720c2d32..7f86331a 100644 --- a/library/Zend/Json/Server/Cache.php +++ b/library/Zend/Json/Server/Cache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Client.php b/library/Zend/Json/Server/Client.php index 2b35be0e..174cdc7b 100644 --- a/library/Zend/Json/Server/Client.php +++ b/library/Zend/Json/Server/Client.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Error.php b/library/Zend/Json/Server/Error.php index 34a7e53d..ed1bbca7 100644 --- a/library/Zend/Json/Server/Error.php +++ b/library/Zend/Json/Server/Error.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Exception/ErrorException.php b/library/Zend/Json/Server/Exception/ErrorException.php index 39bb6c74..d6676d42 100644 --- a/library/Zend/Json/Server/Exception/ErrorException.php +++ b/library/Zend/Json/Server/Exception/ErrorException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Exception/ExceptionInterface.php b/library/Zend/Json/Server/Exception/ExceptionInterface.php index b8e777e5..5efc62e8 100644 --- a/library/Zend/Json/Server/Exception/ExceptionInterface.php +++ b/library/Zend/Json/Server/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Exception/HttpException.php b/library/Zend/Json/Server/Exception/HttpException.php index 193c51c8..2b794dbf 100644 --- a/library/Zend/Json/Server/Exception/HttpException.php +++ b/library/Zend/Json/Server/Exception/HttpException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Exception/InvalidArgumentException.php b/library/Zend/Json/Server/Exception/InvalidArgumentException.php index 3ccd8fd4..199eb1ee 100644 --- a/library/Zend/Json/Server/Exception/InvalidArgumentException.php +++ b/library/Zend/Json/Server/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Exception/RuntimeException.php b/library/Zend/Json/Server/Exception/RuntimeException.php index d3ed4651..68ded927 100644 --- a/library/Zend/Json/Server/Exception/RuntimeException.php +++ b/library/Zend/Json/Server/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Request.php b/library/Zend/Json/Server/Request.php index e9d31ec5..d27e10a9 100644 --- a/library/Zend/Json/Server/Request.php +++ b/library/Zend/Json/Server/Request.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -135,7 +135,7 @@ class Request return $this->params[$index]; } - return null; + return; } /** diff --git a/library/Zend/Json/Server/Request/Http.php b/library/Zend/Json/Server/Request/Http.php index 1cc43efb..b1b864d5 100644 --- a/library/Zend/Json/Server/Request/Http.php +++ b/library/Zend/Json/Server/Request/Http.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Response.php b/library/Zend/Json/Server/Response.php index 074f39a1..c53cac96 100644 --- a/library/Zend/Json/Server/Response.php +++ b/library/Zend/Json/Server/Response.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Response/Http.php b/library/Zend/Json/Server/Response/Http.php index 71b2d1a0..de21723f 100644 --- a/library/Zend/Json/Server/Response/Http.php +++ b/library/Zend/Json/Server/Response/Http.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Server.php b/library/Zend/Json/Server/Server.php index cef0ef71..531ccf36 100644 --- a/library/Zend/Json/Server/Server.php +++ b/library/Zend/Json/Server/Server.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -269,7 +269,7 @@ class Server extends AbstractServer */ public function setReturnResponse($flag = true) { - $this->returnResponse = ($flag) ? true : false; + $this->returnResponse = (bool) $flag; return $this; } @@ -304,7 +304,7 @@ class Server extends AbstractServer } } } - return null; + return; } /** diff --git a/library/Zend/Json/Server/Smd.php b/library/Zend/Json/Server/Smd.php index c04c4406..5abd8ac6 100644 --- a/library/Zend/Json/Server/Smd.php +++ b/library/Zend/Json/Server/Smd.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/Server/Smd/Service.php b/library/Zend/Json/Server/Smd/Service.php index fa78393c..bea17c21 100644 --- a/library/Zend/Json/Server/Smd/Service.php +++ b/library/Zend/Json/Server/Smd/Service.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Json/composer.json b/library/Zend/Json/composer.json index 0ca65aa4..a2e2e250 100644 --- a/library/Zend/Json/composer.json +++ b/library/Zend/Json/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Json\\": "" } }, - "target-dir": "Zend/Json", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -28,8 +27,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Ldap/Attribute.php b/library/Zend/Ldap/Attribute.php index e49b628a..6ee974c2 100644 --- a/library/Zend/Ldap/Attribute.php +++ b/library/Zend/Ldap/Attribute.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -81,15 +81,15 @@ class Attribute return $retArray; } elseif (is_int($index)) { if (!isset($data[$attribName])) { - return null; + return; } elseif ($index >= 0 && $index < count($data[$attribName])) { return self::valueFromLdap($data[$attribName][$index]); } else { - return null; + return; } } - return null; + return; } /** @@ -197,7 +197,7 @@ class Attribute } else { return $return; } - } catch (Exception\InvalidArgumentException $e) { + } catch (Converter\Exception\InvalidArgumentException $e) { return $value; } } @@ -318,7 +318,7 @@ class Attribute return Converter\Converter::toLdapDateTime($value, $utc); } - return null; + return; } /** @@ -361,10 +361,10 @@ class Attribute try { return Converter\Converter::fromLdapDateTime($value, false)->format('U'); } catch (Converter\Exception\InvalidArgumentException $e) { - return null; + return; } } - return null; + return; } } diff --git a/library/Zend/Ldap/Collection.php b/library/Zend/Ldap/Collection.php index a460d269..2204c6a8 100644 --- a/library/Zend/Ldap/Collection.php +++ b/library/Zend/Ldap/Collection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -88,7 +88,7 @@ class Collection implements Iterator, Countable $this->rewind(); return $this->current(); } - return null; + return; } /** @@ -128,13 +128,13 @@ class Collection implements Iterator, Countable if (!array_key_exists($this->current, $this->cache)) { $current = $this->iterator->current(); if ($current === null) { - return null; + return; } $this->cache[$this->current] = $this->createEntry($current); } return $this->cache[$this->current]; } - return null; + return; } /** @@ -161,7 +161,7 @@ class Collection implements Iterator, Countable } return $this->iterator->key(); } - return null; + return; } /** @@ -178,7 +178,7 @@ class Collection implements Iterator, Countable } return $this->current; } - return null; + return; } /** diff --git a/library/Zend/Ldap/Collection/DefaultIterator.php b/library/Zend/Ldap/Collection/DefaultIterator.php index 1a30db54..9c71ed33 100644 --- a/library/Zend/Ldap/Collection/DefaultIterator.php +++ b/library/Zend/Ldap/Collection/DefaultIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -192,7 +192,7 @@ class DefaultIterator implements Iterator, Countable $this->rewind(); } if (!is_resource($this->current)) { - return null; + return; } $entry = array('dn' => $this->key()); @@ -270,7 +270,7 @@ class DefaultIterator implements Iterator, Countable return $currentDn; } else { - return null; + return; } } diff --git a/library/Zend/Ldap/Converter/Converter.php b/library/Zend/Ldap/Converter/Converter.php index 8932343b..5bf4a035 100644 --- a/library/Zend/Ldap/Converter/Converter.php +++ b/library/Zend/Ldap/Converter/Converter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -66,14 +66,12 @@ class Converter return $string; } - /** * Convert any value to an LDAP-compatible value. * * By setting the $type-parameter the conversion of a certain * type can be forced * - * @todo write more tests * * @param mixed $value The value to convert * @param int $type The conversion type to use @@ -86,10 +84,8 @@ class Converter switch ($type) { case self::BOOLEAN: return static::toldapBoolean($value); - break; case self::GENERALIZED_TIME: return static::toLdapDatetime($value); - break; default: if (is_string($value)) { return $value; @@ -107,10 +103,9 @@ class Converter return static::toLdapSerialize($value); } elseif (is_resource($value) && get_resource_type($value) === 'stream') { return stream_get_contents($value); - } else { - return null; } - break; + + return; } } catch (\Exception $e) { throw new Exception\ConverterException($e->getMessage(), $e->getCode(), $e); @@ -167,7 +162,7 @@ class Converter if (!is_scalar($value)) { return $return; } - if (true === $value || 'true' === strtolower($value) || 1 === $value) { + if (true === $value || (is_string($value) && 'true' === strtolower($value)) || 1 === $value) { $return = 'TRUE'; } return $return; @@ -203,10 +198,8 @@ class Converter switch ($type) { case self::BOOLEAN: return static::fromldapBoolean($value); - break; case self::GENERALIZED_TIME: return static::fromLdapDateTime($value); - break; default: if (is_numeric($value)) { // prevent numeric values to be treated as date/time @@ -327,7 +320,9 @@ class Converter if (isset($off[3])) { $offsetMinutes = substr($off[3], 0, 2); if ($offsetMinutes < 0 || $offsetMinutes > 59) { - throw new Exception\InvalidArgumentException('Invalid date format found (invalid offset minute)'); + throw new Exception\InvalidArgumentException( + 'Invalid date format found (invalid offset minute)' + ); } $time['offsetminutes'] = $offsetMinutes; } @@ -335,9 +330,6 @@ class Converter } // Raw-Data is present, so lets create a DateTime-Object from it. - $offset = $time['offdir'] - . str_pad($time['offsethours'], 2, '0', STR_PAD_LEFT) - . str_pad($time['offsetminutes'], 2, '0', STR_PAD_LEFT); $timestring = $time['year'] . '-' . str_pad($time['month'], 2, '0', STR_PAD_LEFT) . '-' . str_pad($time['day'], 2, '0', STR_PAD_LEFT) . ' ' @@ -347,7 +339,15 @@ class Converter . $time['offdir'] . str_pad($time['offsethours'], 2, '0', STR_PAD_LEFT) . str_pad($time['offsetminutes'], 2, '0', STR_PAD_LEFT); - $date = new DateTime($timestring); + try { + $date = new DateTime($timestring); + } catch (\Exception $e) { + throw new Exception\InvalidArgumentException( + 'Invalid date format found', + 0, + $e + ); + } if ($asUtc) { $date->setTimezone(new DateTimeZone('UTC')); } diff --git a/library/Zend/Ldap/Converter/Exception/ConverterException.php b/library/Zend/Ldap/Converter/Exception/ConverterException.php index eae8f5df..6226da94 100644 --- a/library/Zend/Ldap/Converter/Exception/ConverterException.php +++ b/library/Zend/Ldap/Converter/Exception/ConverterException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Converter/Exception/ExceptionInterface.php b/library/Zend/Ldap/Converter/Exception/ExceptionInterface.php index 39d9cdff..a1587474 100644 --- a/library/Zend/Ldap/Converter/Exception/ExceptionInterface.php +++ b/library/Zend/Ldap/Converter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Converter/Exception/InvalidArgumentException.php b/library/Zend/Ldap/Converter/Exception/InvalidArgumentException.php index f54cc47d..a1cd3560 100644 --- a/library/Zend/Ldap/Converter/Exception/InvalidArgumentException.php +++ b/library/Zend/Ldap/Converter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Converter/Exception/UnexpectedValueException.php b/library/Zend/Ldap/Converter/Exception/UnexpectedValueException.php index 9a13f451..78456f49 100644 --- a/library/Zend/Ldap/Converter/Exception/UnexpectedValueException.php +++ b/library/Zend/Ldap/Converter/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Dn.php b/library/Zend/Ldap/Dn.php index 0ca0721f..1b10e5a8 100644 --- a/library/Zend/Ldap/Dn.php +++ b/library/Zend/Ldap/Dn.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -445,10 +445,8 @@ class Dn implements ArrayAccess case self::ATTR_CASEFOLD_UPPER: case self::ATTR_CASEFOLD_LOWER: return $caseFold; - break; default: return $default; - break; } } @@ -474,7 +472,7 @@ class Dn implements ArrayAccess foreach ($values as $key => $val) { // Escaping of filter meta characters $val = str_replace( - array('\\', ',', '+', '"', '<', '>', ';', '#', '=',), + array('\\', ',', '+', '"', '<', '>', ';', '#', '='), array('\\\\', '\,', '\+', '\"', '\<', '\>', '\;', '\#', '\='), $val ); $val = Converter\Converter::ascToHex32($val); @@ -518,7 +516,7 @@ class Dn implements ArrayAccess // strip slashes from special chars $val = str_replace( array('\\\\', '\,', '\+', '\"', '\<', '\>', '\;', '\#', '\='), - array('\\', ',', '+', '"', '<', '>', ';', '#', '=',), $val + array('\\', ',', '+', '"', '<', '>', ';', '#', '=', ), $val ); $values[$key] = Converter\Converter::hex32ToAsc($val); } @@ -555,9 +553,9 @@ class Dn implements ArrayAccess } $ret = array(); for ($i = 0, $count = count($k); $i < $count; $i++) { - if (is_array($k[$i]) && is_array($v[$i]) && (count($k[$i]) === count($v[$i]))) { + if (is_array($k[$i]) && is_array($v[$i]) && (($keyCount = count($k[$i])) === count($v[$i]))) { $multi = array(); - for ($j = 0; $j < count($k[$i]); $j++) { + for ($j = 0; $j < $keyCount; $j++) { $key = $k[$i][$j]; $val = $v[$i][$j]; $multi[$key] = $val; @@ -594,8 +592,6 @@ class Dn implements ArrayAccess * to state 1. If a backslash (\) is encountered, state 3 is used to collect the * following character without engaging the logic of other states. */ - $key = null; - $value = null; $slen = strlen($dn); $state = 1; $ko = $vo = 0; diff --git a/library/Zend/Ldap/Exception/BadMethodCallException.php b/library/Zend/Ldap/Exception/BadMethodCallException.php index c028787f..74ac7243 100644 --- a/library/Zend/Ldap/Exception/BadMethodCallException.php +++ b/library/Zend/Ldap/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Exception/ExceptionInterface.php b/library/Zend/Ldap/Exception/ExceptionInterface.php index 8d5ed4b4..9c03b13e 100644 --- a/library/Zend/Ldap/Exception/ExceptionInterface.php +++ b/library/Zend/Ldap/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Exception/InvalidArgumentException.php b/library/Zend/Ldap/Exception/InvalidArgumentException.php index e1b7f306..cf8e371a 100644 --- a/library/Zend/Ldap/Exception/InvalidArgumentException.php +++ b/library/Zend/Ldap/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Exception/LdapException.php b/library/Zend/Ldap/Exception/LdapException.php index 84800795..48838bdc 100644 --- a/library/Zend/Ldap/Exception/LdapException.php +++ b/library/Zend/Ldap/Exception/LdapException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter.php b/library/Zend/Ldap/Filter.php index ac79bd49..98c67446 100644 --- a/library/Zend/Ldap/Filter.php +++ b/library/Zend/Ldap/Filter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/AbstractFilter.php b/library/Zend/Ldap/Filter/AbstractFilter.php index 89f063e0..5a079c87 100644 --- a/library/Zend/Ldap/Filter/AbstractFilter.php +++ b/library/Zend/Ldap/Filter/AbstractFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/AbstractLogicalFilter.php b/library/Zend/Ldap/Filter/AbstractLogicalFilter.php index f04cd641..b83200d9 100644 --- a/library/Zend/Ldap/Filter/AbstractLogicalFilter.php +++ b/library/Zend/Ldap/Filter/AbstractLogicalFilter.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Ldap\Filter; - /** * Zend\Ldap\Filter\AbstractLogicalFilter provides a base implementation for a grouping filter. */ diff --git a/library/Zend/Ldap/Filter/AndFilter.php b/library/Zend/Ldap/Filter/AndFilter.php index beeb4ce2..af859395 100644 --- a/library/Zend/Ldap/Filter/AndFilter.php +++ b/library/Zend/Ldap/Filter/AndFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/Exception/ExceptionInterface.php b/library/Zend/Ldap/Filter/Exception/ExceptionInterface.php index f5ff231f..42413306 100644 --- a/library/Zend/Ldap/Filter/Exception/ExceptionInterface.php +++ b/library/Zend/Ldap/Filter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/Exception/FilterException.php b/library/Zend/Ldap/Filter/Exception/FilterException.php index 0ed11421..81398e5e 100644 --- a/library/Zend/Ldap/Filter/Exception/FilterException.php +++ b/library/Zend/Ldap/Filter/Exception/FilterException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/MaskFilter.php b/library/Zend/Ldap/Filter/MaskFilter.php index 89b5059c..64566ab8 100644 --- a/library/Zend/Ldap/Filter/MaskFilter.php +++ b/library/Zend/Ldap/Filter/MaskFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/NotFilter.php b/library/Zend/Ldap/Filter/NotFilter.php index b2a23601..77593374 100644 --- a/library/Zend/Ldap/Filter/NotFilter.php +++ b/library/Zend/Ldap/Filter/NotFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/OrFilter.php b/library/Zend/Ldap/Filter/OrFilter.php index 215a51f4..d7727815 100644 --- a/library/Zend/Ldap/Filter/OrFilter.php +++ b/library/Zend/Ldap/Filter/OrFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Filter/StringFilter.php b/library/Zend/Ldap/Filter/StringFilter.php index 9f98cf8e..3d6bbcd6 100644 --- a/library/Zend/Ldap/Filter/StringFilter.php +++ b/library/Zend/Ldap/Filter/StringFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Ldap.php b/library/Zend/Ldap/Ldap.php index e935481a..cd7cff5a 100644 --- a/library/Zend/Ldap/Ldap.php +++ b/library/Zend/Ldap/Ldap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -1083,7 +1083,7 @@ class Ldap } } - return null; + return; } /** diff --git a/library/Zend/Ldap/Ldif/Encoder.php b/library/Zend/Ldap/Ldif/Encoder.php index 02fa92b2..6d6ae877 100644 --- a/library/Zend/Ldap/Ldif/Encoder.php +++ b/library/Zend/Ldap/Ldif/Encoder.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -87,7 +87,6 @@ class Encoder } elseif (count($item) > 0 && $name === 'dn') { $items[] = $item; $item = array(); - $last = null; } $last = array($name, $type, $value); } elseif (trim($line) === '') { @@ -156,7 +155,7 @@ class Encoder return $value->toLdif($this->options); } - return null; + return; } /** diff --git a/library/Zend/Ldap/Node.php b/library/Zend/Ldap/Node.php index 01e9dc82..cea73801 100644 --- a/library/Zend/Ldap/Node.php +++ b/library/Zend/Ldap/Node.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -221,7 +221,7 @@ class Node extends Node\AbstractNode implements Iterator, RecursiveIterator $this->originalData = array(); } $this->children = null; - $this->markAsNew(($fromDataSource === true) ? false : true); + $this->markAsNew($fromDataSource !== true); $this->markAsToBeDeleted(false); } @@ -268,7 +268,7 @@ class Node extends Node\AbstractNode implements Iterator, RecursiveIterator } $data = $ldap->getEntry($dn, array('*', '+'), true); if ($data === null) { - return null; + return; } $entry = new static($dn, $data, true, $ldap); @@ -295,7 +295,7 @@ class Node extends Node\AbstractNode implements Iterator, RecursiveIterator } else { throw new Exception\LdapException(null, '\'dn\' key is of a wrong data type.'); } - $fromDataSource = ($fromDataSource === true) ? true : false; + $fromDataSource = ($fromDataSource === true); $new = new static($dn, $data, $fromDataSource, null); $new->ensureRdnAttributeValues(); @@ -328,7 +328,7 @@ class Node extends Node\AbstractNode implements Iterator, RecursiveIterator */ protected function markAsNew($new) { - $this->new = ($new === false) ? false : true; + $this->new = (bool) $new; } /** @@ -353,7 +353,7 @@ class Node extends Node\AbstractNode implements Iterator, RecursiveIterator */ protected function markAsToBeDeleted($delete) { - $this->delete = ($delete === true) ? true : false; + $this->delete = (bool) $delete; } diff --git a/library/Zend/Ldap/Node/AbstractNode.php b/library/Zend/Ldap/Node/AbstractNode.php index 5e14c97f..322c89b0 100644 --- a/library/Zend/Ldap/Node/AbstractNode.php +++ b/library/Zend/Ldap/Node/AbstractNode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/ChildrenIterator.php b/library/Zend/Ldap/Node/ChildrenIterator.php index 1b6a361d..6296e46e 100644 --- a/library/Zend/Ldap/Node/ChildrenIterator.php +++ b/library/Zend/Ldap/Node/ChildrenIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -127,7 +127,7 @@ class ChildrenIterator implements Iterator, Countable, RecursiveIterator, ArrayA return $this->current()->getChildren(); } - return null; + return; } /** @@ -143,7 +143,7 @@ class ChildrenIterator implements Iterator, Countable, RecursiveIterator, ArrayA return $this->data[$rdn]; } - return null; + return; } /** diff --git a/library/Zend/Ldap/Node/Collection.php b/library/Zend/Ldap/Node/Collection.php index 5185a636..42f1712a 100644 --- a/library/Zend/Ldap/Node/Collection.php +++ b/library/Zend/Ldap/Node/Collection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/RootDse.php b/library/Zend/Ldap/Node/RootDse.php index 213df1dd..255f2878 100644 --- a/library/Zend/Ldap/Node/RootDse.php +++ b/library/Zend/Ldap/Node/RootDse.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/RootDse/ActiveDirectory.php b/library/Zend/Ldap/Node/RootDse/ActiveDirectory.php index b786b09e..52d13f81 100644 --- a/library/Zend/Ldap/Node/RootDse/ActiveDirectory.php +++ b/library/Zend/Ldap/Node/RootDse/ActiveDirectory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/RootDse/OpenLdap.php b/library/Zend/Ldap/Node/RootDse/OpenLdap.php index 2c765fc6..67128817 100644 --- a/library/Zend/Ldap/Node/RootDse/OpenLdap.php +++ b/library/Zend/Ldap/Node/RootDse/OpenLdap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/RootDse/eDirectory.php b/library/Zend/Ldap/Node/RootDse/eDirectory.php index eb96ac2b..9855f781 100644 --- a/library/Zend/Ldap/Node/RootDse/eDirectory.php +++ b/library/Zend/Ldap/Node/RootDse/eDirectory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema.php b/library/Zend/Ldap/Node/Schema.php index 20d2b0cc..32943224 100644 --- a/library/Zend/Ldap/Node/Schema.php +++ b/library/Zend/Ldap/Node/Schema.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema/AbstractItem.php b/library/Zend/Ldap/Node/Schema/AbstractItem.php index 5f5e1648..3de4bfd7 100644 --- a/library/Zend/Ldap/Node/Schema/AbstractItem.php +++ b/library/Zend/Ldap/Node/Schema/AbstractItem.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -70,7 +70,7 @@ abstract class AbstractItem implements ArrayAccess, Countable return $this->data[$name]; } - return null; + return; } /** diff --git a/library/Zend/Ldap/Node/Schema/ActiveDirectory.php b/library/Zend/Ldap/Node/Schema/ActiveDirectory.php index 946ab513..a3a4ab8a 100644 --- a/library/Zend/Ldap/Node/Schema/ActiveDirectory.php +++ b/library/Zend/Ldap/Node/Schema/ActiveDirectory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema/AttributeType/ActiveDirectory.php b/library/Zend/Ldap/Node/Schema/AttributeType/ActiveDirectory.php index 859adcce..770a9782 100644 --- a/library/Zend/Ldap/Node/Schema/AttributeType/ActiveDirectory.php +++ b/library/Zend/Ldap/Node/Schema/AttributeType/ActiveDirectory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema/AttributeType/AttributeTypeInterface.php b/library/Zend/Ldap/Node/Schema/AttributeType/AttributeTypeInterface.php index 83ad8f2f..6bc49164 100644 --- a/library/Zend/Ldap/Node/Schema/AttributeType/AttributeTypeInterface.php +++ b/library/Zend/Ldap/Node/Schema/AttributeType/AttributeTypeInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema/AttributeType/OpenLdap.php b/library/Zend/Ldap/Node/Schema/AttributeType/OpenLdap.php index d71924b1..65af6af4 100644 --- a/library/Zend/Ldap/Node/Schema/AttributeType/OpenLdap.php +++ b/library/Zend/Ldap/Node/Schema/AttributeType/OpenLdap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -47,7 +47,7 @@ class OpenLdap extends Schema\AbstractItem implements AttributeTypeInterface if ($this->syntax === null) { $parent = $this->getParent(); if ($parent === null) { - return null; + return; } else { return $parent->getSyntax(); } @@ -67,7 +67,7 @@ class OpenLdap extends Schema\AbstractItem implements AttributeTypeInterface if ($maxLength === null) { $parent = $this->getParent(); if ($parent === null) { - return null; + return; } else { return $parent->getMaxLength(); } @@ -107,6 +107,6 @@ class OpenLdap extends Schema\AbstractItem implements AttributeTypeInterface return $this->_parents[0]; } - return null; + return; } } diff --git a/library/Zend/Ldap/Node/Schema/ObjectClass/ActiveDirectory.php b/library/Zend/Ldap/Node/Schema/ObjectClass/ActiveDirectory.php index 6327942f..95e0dcc0 100644 --- a/library/Zend/Ldap/Node/Schema/ObjectClass/ActiveDirectory.php +++ b/library/Zend/Ldap/Node/Schema/ObjectClass/ActiveDirectory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema/ObjectClass/ObjectClassInterface.php b/library/Zend/Ldap/Node/Schema/ObjectClass/ObjectClassInterface.php index 0a317f26..fd5e08a2 100644 --- a/library/Zend/Ldap/Node/Schema/ObjectClass/ObjectClassInterface.php +++ b/library/Zend/Ldap/Node/Schema/ObjectClass/ObjectClassInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php b/library/Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php index 0f5a88ef..a39f3d36 100644 --- a/library/Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php +++ b/library/Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,7 +31,6 @@ class OpenLdap extends Schema\AbstractItem implements ObjectClassInterface */ protected $inheritedMay = null; - /** * Gets the objectClass name * diff --git a/library/Zend/Ldap/Node/Schema/OpenLdap.php b/library/Zend/Ldap/Node/Schema/OpenLdap.php index a22fdcf0..6fc2b810 100644 --- a/library/Zend/Ldap/Node/Schema/OpenLdap.php +++ b/library/Zend/Ldap/Node/Schema/OpenLdap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Ldap/composer.json b/library/Zend/Ldap/composer.json index 512d8903..ef753a78 100644 --- a/library/Zend/Ldap/composer.json +++ b/library/Zend/Ldap/composer.json @@ -8,13 +8,13 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Ldap\\": "" } }, - "target-dir": "Zend/Ldap", "require": { "php": ">=5.3.23", + "ext-ldap": "*", "zendframework/zend-stdlib": "self.version" }, "require-dev": { @@ -25,8 +25,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Loader/AutoloaderFactory.php b/library/Zend/Loader/AutoloaderFactory.php index be282072..a786c494 100644 --- a/library/Zend/Loader/AutoloaderFactory.php +++ b/library/Zend/Loader/AutoloaderFactory.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Loader; -use ReflectionClass; use Traversable; if (class_exists('Zend\Loader\AutoloaderFactory')) { @@ -87,7 +86,7 @@ abstract class AutoloaderFactory ); } - if (!static::isSubclassOf($class, 'Zend\Loader\SplAutoloader')) { + if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) { require_once 'Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class) @@ -199,22 +198,14 @@ abstract class AutoloaderFactory * @see https://bugs.php.net/bug.php?id=53727 * @see https://github.com/zendframework/zf2/pull/1807 * + * @deprecated since zf 2.3 requires PHP >= 5.3.23 + * * @param string $className * @param string $type * @return bool */ protected static function isSubclassOf($className, $type) { - if (is_subclass_of($className, $type)) { - return true; - } - if (PHP_VERSION_ID >= 50307) { - return false; - } - if (!interface_exists($type)) { - return false; - } - $r = new ReflectionClass($className); - return $r->implementsInterface($type); + return is_subclass_of($className, $type); } } diff --git a/library/Zend/Loader/ClassMapAutoloader.php b/library/Zend/Loader/ClassMapAutoloader.php index 58b6378d..a50e1fc0 100644 --- a/library/Zend/Loader/ClassMapAutoloader.php +++ b/library/Zend/Loader/ClassMapAutoloader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -91,7 +91,7 @@ class ClassMapAutoloader implements SplAutoloader )); } - $this->map = array_merge($this->map, $map); + $this->map = $map + $this->map; if (isset($location)) { $this->mapsLoaded[] = $location; @@ -197,7 +197,7 @@ class ClassMapAutoloader implements SplAutoloader */ public static function realPharPath($path) { - if (!preg_match('|^phar:(/{2,3})|',$path, $match)) { + if (!preg_match('|^phar:(/{2,3})|', $path, $match)) { return; } diff --git a/library/Zend/Loader/Exception/BadMethodCallException.php b/library/Zend/Loader/Exception/BadMethodCallException.php index 3ae44881..9d939115 100644 --- a/library/Zend/Loader/Exception/BadMethodCallException.php +++ b/library/Zend/Loader/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/Exception/DomainException.php b/library/Zend/Loader/Exception/DomainException.php index 4f888e84..33835571 100644 --- a/library/Zend/Loader/Exception/DomainException.php +++ b/library/Zend/Loader/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/Exception/ExceptionInterface.php b/library/Zend/Loader/Exception/ExceptionInterface.php index 5c68d37f..5c621826 100644 --- a/library/Zend/Loader/Exception/ExceptionInterface.php +++ b/library/Zend/Loader/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/Exception/InvalidArgumentException.php b/library/Zend/Loader/Exception/InvalidArgumentException.php index 5018380c..beb5c087 100644 --- a/library/Zend/Loader/Exception/InvalidArgumentException.php +++ b/library/Zend/Loader/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\Loader\Exception; require_once __DIR__ . '/ExceptionInterface.php'; -class InvalidArgumentException extends \InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Loader/Exception/InvalidPathException.php b/library/Zend/Loader/Exception/InvalidPathException.php index dcbbcc0a..3c93cec4 100644 --- a/library/Zend/Loader/Exception/InvalidPathException.php +++ b/library/Zend/Loader/Exception/InvalidPathException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/Exception/MissingResourceNamespaceException.php b/library/Zend/Loader/Exception/MissingResourceNamespaceException.php index 58cda79c..bef0a295 100644 --- a/library/Zend/Loader/Exception/MissingResourceNamespaceException.php +++ b/library/Zend/Loader/Exception/MissingResourceNamespaceException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\Loader\Exception; require_once __DIR__ . '/ExceptionInterface.php'; -class MissingResourceNamespaceException extends \Exception implements - ExceptionInterface +class MissingResourceNamespaceException extends \Exception implements ExceptionInterface { } diff --git a/library/Zend/Loader/Exception/PluginLoaderException.php b/library/Zend/Loader/Exception/PluginLoaderException.php index 49f393a7..e7603f73 100644 --- a/library/Zend/Loader/Exception/PluginLoaderException.php +++ b/library/Zend/Loader/Exception/PluginLoaderException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/Exception/RuntimeException.php b/library/Zend/Loader/Exception/RuntimeException.php index 2bb4e1bc..6476cad0 100644 --- a/library/Zend/Loader/Exception/RuntimeException.php +++ b/library/Zend/Loader/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/Exception/SecurityException.php b/library/Zend/Loader/Exception/SecurityException.php index dbbaecbd..7ea1ad46 100644 --- a/library/Zend/Loader/Exception/SecurityException.php +++ b/library/Zend/Loader/Exception/SecurityException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/ModuleAutoloader.php b/library/Zend/Loader/ModuleAutoloader.php index 2aa6938b..e867aae8 100644 --- a/library/Zend/Loader/ModuleAutoloader.php +++ b/library/Zend/Loader/ModuleAutoloader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,6 +13,8 @@ namespace Zend\Loader; require_once __DIR__ . '/SplAutoloader.php'; use GlobIterator; +use Phar; +use PharFileInfo; use SplFileInfo; use Traversable; @@ -33,6 +35,11 @@ class ModuleAutoloader implements SplAutoloader */ protected $namespacedPaths = array(); + /** + * @var string Will contain the absolute phar:// path to the executable when packaged as phar file + */ + protected $pharBasePath = ""; + /** * @var array An array of supported phar extensions (filled on constructor) */ @@ -53,6 +60,7 @@ class ModuleAutoloader implements SplAutoloader public function __construct($options = null) { if (extension_loaded('phar')) { + $this->pharBasePath = Phar::running(true); $this->pharExtensions = array( 'phar', 'phar.tar', @@ -159,7 +167,7 @@ class ModuleAutoloader implements SplAutoloader continue; } - $moduleNameBuffer = str_replace($namespace . "\\", "", $moduleName ); + $moduleNameBuffer = str_replace($namespace . "\\", "", $moduleName); $path .= DIRECTORY_SEPARATOR . $moduleNameBuffer . DIRECTORY_SEPARATOR; $classLoaded = $this->loadModuleFromDir($path, $class); @@ -174,7 +182,6 @@ class ModuleAutoloader implements SplAutoloader } } - $moduleClassPath = str_replace('\\', DIRECTORY_SEPARATOR, $moduleName); $pharSuffixPattern = null; @@ -186,7 +193,9 @@ class ModuleAutoloader implements SplAutoloader $path = $path . $moduleClassPath; if ($path == '.' || substr($path, 0, 2) == './' || substr($path, 0, 2) == '.\\') { - $basePath = realpath('.'); + if (!$basePath = $this->pharBasePath) { + $basePath = realpath('.'); + } if (false === $basePath) { $basePath = getcwd(); @@ -233,12 +242,19 @@ class ModuleAutoloader implements SplAutoloader */ protected function loadModuleFromDir($dirPath, $class) { - $file = new SplFileInfo($dirPath . '/Module.php'); - if ($file->isReadable() && $file->isFile()) { + $modulePath = $dirPath . '/Module.php'; + if (substr($modulePath, 0, 7) === 'phar://') { + $file = new PharFileInfo($modulePath); + } else { + $file = new SplFileInfo($modulePath); + } + + if (($file->isReadable() && $file->isFile())) { // Found directory with Module.php in it - require_once $file->getRealPath(); + $absModulePath = $this->pharBasePath ? (string) $file : $file->getRealPath(); + require_once $absModulePath; if (class_exists($class)) { - $this->moduleClassMap[$class] = $file->getRealPath(); + $this->moduleClassMap[$class] = $absModulePath; return $class; } } @@ -369,7 +385,7 @@ class ModuleAutoloader implements SplAutoloader )); } if ($moduleName) { - if (in_array( substr($moduleName, -2), array('\\*', '\\%'))) { + if (in_array(substr($moduleName, -2), array('\\*', '\\%'))) { $this->namespacedPaths[substr($moduleName, 0, -2)] = static::normalizePath($path); } else { $this->explicitPaths[$moduleName] = static::normalizePath($path); diff --git a/library/Zend/Loader/PluginClassLoader.php b/library/Zend/Loader/PluginClassLoader.php index 63701444..0fbf2111 100644 --- a/library/Zend/Loader/PluginClassLoader.php +++ b/library/Zend/Loader/PluginClassLoader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/PluginClassLocator.php b/library/Zend/Loader/PluginClassLocator.php index e141586c..91ed0dde 100644 --- a/library/Zend/Loader/PluginClassLocator.php +++ b/library/Zend/Loader/PluginClassLocator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/ShortNameLocator.php b/library/Zend/Loader/ShortNameLocator.php index f0ee23c7..dfa020c7 100644 --- a/library/Zend/Loader/ShortNameLocator.php +++ b/library/Zend/Loader/ShortNameLocator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/SplAutoloader.php b/library/Zend/Loader/SplAutoloader.php index 87cfebd2..47d6b6c5 100644 --- a/library/Zend/Loader/SplAutoloader.php +++ b/library/Zend/Loader/SplAutoloader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Loader/StandardAutoloader.php b/library/Zend/Loader/StandardAutoloader.php index cddcf26e..2d744a88 100644 --- a/library/Zend/Loader/StandardAutoloader.php +++ b/library/Zend/Loader/StandardAutoloader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -89,7 +89,7 @@ class StandardAutoloader implements SplAutoloader case self::AUTOREGISTER_ZF: if ($pairs) { $this->registerNamespace('Zend', dirname(__DIR__)); - $this->registerNamespace('ZendXml', dirname(dirname((__DIR__))) . '/ZendXml'); + $this->registerNamespace('ZendXml', dirname(dirname((__DIR__))) . DIRECTORY_SEPARATOR . 'ZendXml'); } break; case self::LOAD_NS: diff --git a/library/Zend/Loader/composer.json b/library/Zend/Loader/composer.json index c2cab634..53ab6b54 100644 --- a/library/Zend/Loader/composer.json +++ b/library/Zend/Loader/composer.json @@ -8,18 +8,17 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Loader\\": "" } }, - "target-dir": "Zend/Loader", "require": { "php": ">=5.3.23" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Log/Exception/ExceptionInterface.php b/library/Zend/Log/Exception/ExceptionInterface.php index fe163f81..39bf0b1c 100644 --- a/library/Zend/Log/Exception/ExceptionInterface.php +++ b/library/Zend/Log/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Exception/InvalidArgumentException.php b/library/Zend/Log/Exception/InvalidArgumentException.php index cd34a99e..ba0be8f3 100644 --- a/library/Zend/Log/Exception/InvalidArgumentException.php +++ b/library/Zend/Log/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,8 +12,6 @@ namespace Zend\Log\Exception; /** * Invalid argument exception */ -class InvalidArgumentException - extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Log/Exception/RuntimeException.php b/library/Zend/Log/Exception/RuntimeException.php index b339c6df..85493afc 100644 --- a/library/Zend/Log/Exception/RuntimeException.php +++ b/library/Zend/Log/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,8 +12,6 @@ namespace Zend\Log\Exception; /** * Runtime argument exception */ -class RuntimeException - extends \RuntimeException - implements ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Log/Filter/FilterInterface.php b/library/Zend/Log/Filter/FilterInterface.php index dc72777d..561550ed 100644 --- a/library/Zend/Log/Filter/FilterInterface.php +++ b/library/Zend/Log/Filter/FilterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Filter/Mock.php b/library/Zend/Log/Filter/Mock.php index f35c6231..5e6f5b1c 100644 --- a/library/Zend/Log/Filter/Mock.php +++ b/library/Zend/Log/Filter/Mock.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Filter/Priority.php b/library/Zend/Log/Filter/Priority.php index 01f00dae..7df5586e 100644 --- a/library/Zend/Log/Filter/Priority.php +++ b/library/Zend/Log/Filter/Priority.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Filter/Regex.php b/library/Zend/Log/Filter/Regex.php index 6d055bd1..24451b10 100644 --- a/library/Zend/Log/Filter/Regex.php +++ b/library/Zend/Log/Filter/Regex.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -59,7 +59,7 @@ class Regex implements FilterInterface { $message = $event['message']; if (is_array($event['message'])) { - $message = var_export($message, TRUE); + $message = var_export($message, true); } return preg_match($this->regex, $message) > 0; } diff --git a/library/Zend/Log/Filter/Sample.php b/library/Zend/Log/Filter/Sample.php index 459130fb..504837c9 100644 --- a/library/Zend/Log/Filter/Sample.php +++ b/library/Zend/Log/Filter/Sample.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Filter/SuppressFilter.php b/library/Zend/Log/Filter/SuppressFilter.php index 646ccad7..cc34fef6 100644 --- a/library/Zend/Log/Filter/SuppressFilter.php +++ b/library/Zend/Log/Filter/SuppressFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,9 +34,9 @@ class SuppressFilter implements FilterInterface $suppress = isset($suppress['suppress']) ? $suppress['suppress'] : false; } if (!is_bool($suppress)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Suppress must be a boolean; received "%s"', gettype($suppress) - )); + throw new Exception\InvalidArgumentException( + sprintf('Suppress must be a boolean; received "%s"', gettype($suppress)) + ); } $this->suppress($suppress); diff --git a/library/Zend/Log/Filter/Timestamp.php b/library/Zend/Log/Filter/Timestamp.php new file mode 100644 index 00000000..f611dd6b --- /dev/null +++ b/library/Zend/Log/Filter/Timestamp.php @@ -0,0 +1,126 @@ + + */ +class Timestamp implements FilterInterface +{ + /** + * DateTime instance or desired value based on $dateFormatChar. + * + * @var int|DateTime + */ + protected $value; + + /** + * PHP idate()-compliant format character. + * + * @var string|null + */ + protected $dateFormatChar; + + /** + * @var string + */ + protected $operator; + + /** + * @param int|DateTime|array|Traversable $value DateTime instance or desired value based on $dateFormatChar + * @param string $dateFormatChar PHP idate()-compliant format character + * @param string $operator Comparison operator + * @return Timestamp + * @throws Exception\InvalidArgumentException + */ + public function __construct($value, $dateFormatChar = null, $operator = '<=') + { + if ($value instanceof Traversable) { + $value = ArrayUtils::iteratorToArray($value); + } + + if (is_array($value)) { + $dateFormatChar = isset($value['dateFormatChar']) ? $value['dateFormatChar'] : null; + $operator = isset($value['operator']) ? $value['operator'] : null; + $value = isset($value['value']) ? $value['value'] : null; + } + + if ($value instanceof DateTime) { + $this->value = $value; + } else { + if (!is_int($value)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Value must be either DateTime instance or integer; received "%s"', + gettype($value) + )); + } + if (!is_string($dateFormatChar)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Date format character must be supplied as string; received "%s"', + gettype($dateFormatChar) + )); + } + + $this->value = $value; + $this->dateFormatChar = $dateFormatChar; + } + + if ($operator === null) { + $operator = '<='; + } elseif (!in_array( + $operator, + array('<', 'lt', '<=', 'le', '>', 'gt', '>=', 'ge', '==', '=', 'eq', '!=', '<>') + )) { + throw new Exception\InvalidArgumentException( + "Unsupported comparison operator: '$operator'" + ); + } + + $this->operator = $operator; + } + + /** + * Returns TRUE if timestamp is accepted, otherwise FALSE is returned. + * + * @param array $event event data + * @return bool + */ + public function filter(array $event) + { + if (! isset($event['timestamp'])) { + return false; + } + + $datetime = $event['timestamp']; + + if (! ($datetime instanceof DateTime || is_int($datetime) || is_string($datetime))) { + return false; + } + + $timestamp = $datetime instanceof DateTime ? $datetime->getTimestamp() : (int) $datetime; + + if ($this->value instanceof DateTime) { + return version_compare($timestamp, $this->value->getTimestamp(), $this->operator); + } + + return version_compare( + idate($this->dateFormatChar, $timestamp), + $this->value, + $this->operator + ); + } +} diff --git a/library/Zend/Log/Filter/Validator.php b/library/Zend/Log/Filter/Validator.php index 651ea882..33a0a0c4 100644 --- a/library/Zend/Log/Filter/Validator.php +++ b/library/Zend/Log/Filter/Validator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/Base.php b/library/Zend/Log/Formatter/Base.php index 54e0cd83..e150418b 100644 --- a/library/Zend/Log/Formatter/Base.php +++ b/library/Zend/Log/Formatter/Base.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/ChromePhp.php b/library/Zend/Log/Formatter/ChromePhp.php index 671429b0..0670faa0 100644 --- a/library/Zend/Log/Formatter/ChromePhp.php +++ b/library/Zend/Log/Formatter/ChromePhp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/Db.php b/library/Zend/Log/Formatter/Db.php index 256bb1c0..45bb60df 100644 --- a/library/Zend/Log/Formatter/Db.php +++ b/library/Zend/Log/Formatter/Db.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/ErrorHandler.php b/library/Zend/Log/Formatter/ErrorHandler.php index 287d6977..a6a12da1 100644 --- a/library/Zend/Log/Formatter/ErrorHandler.php +++ b/library/Zend/Log/Formatter/ErrorHandler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/ExceptionHandler.php b/library/Zend/Log/Formatter/ExceptionHandler.php index 28d82118..e3f5a7d2 100644 --- a/library/Zend/Log/Formatter/ExceptionHandler.php +++ b/library/Zend/Log/Formatter/ExceptionHandler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -79,11 +79,11 @@ class ExceptionHandler implements FormatterInterface protected function getType($type) { switch ($type) { - case "::" : + case "::": return "static"; - case "->" : + case "->": return "method"; - default : + default: return $type; } } diff --git a/library/Zend/Log/Formatter/FirePhp.php b/library/Zend/Log/Formatter/FirePhp.php index 4e15a982..84465621 100644 --- a/library/Zend/Log/Formatter/FirePhp.php +++ b/library/Zend/Log/Formatter/FirePhp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/FormatterInterface.php b/library/Zend/Log/Formatter/FormatterInterface.php index 975c3ec4..8962e592 100644 --- a/library/Zend/Log/Formatter/FormatterInterface.php +++ b/library/Zend/Log/Formatter/FormatterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/Simple.php b/library/Zend/Log/Formatter/Simple.php index 531ea764..8ba52008 100644 --- a/library/Zend/Log/Formatter/Simple.php +++ b/library/Zend/Log/Formatter/Simple.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Formatter/Xml.php b/library/Zend/Log/Formatter/Xml.php index ae4abf73..4e894bba 100644 --- a/library/Zend/Log/Formatter/Xml.php +++ b/library/Zend/Log/Formatter/Xml.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -160,10 +160,11 @@ class Xml implements FormatterInterface $event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat()); } - if ($this->elementMap === null) { - $dataToInsert = $event; - } else { + $dataToInsert = $event; + + if (null !== $this->elementMap) { $dataToInsert = array(); + foreach ($this->elementMap as $elementName => $fieldKey) { $dataToInsert[$elementName] = $event[$fieldKey]; } @@ -177,21 +178,78 @@ class Xml implements FormatterInterface foreach ($dataToInsert as $key => $value) { if (empty($value) || is_scalar($value) + || ((is_array($value) || $value instanceof Traversable) && $key == "extra") || (is_object($value) && method_exists($value, '__toString')) ) { if ($key == "message") { $value = $escaper->escapeHtml($value); - } elseif ($key == "extra" && empty($value)) { + } + + if ($key == "extra" && empty($value)) { continue; } + + if ($key == "extra" && (is_array($value) || $value instanceof Traversable)) { + $elt->appendChild($this->buildElementTree($dom, $dom->createElement('extra'), $value)); + + continue; + } + $elt->appendChild(new DOMElement($key, (string) $value)); } } - $xml = $dom->saveXML(); - $xml = preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $xml); + return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $dom->saveXML()) . PHP_EOL; + } - return $xml . PHP_EOL; + /** + * Recursion function to create an xml tree structure out of array structure + * @param DomDocument $doc - DomDocument where the current nodes will be generated + * @param DomElement $rootElement - root element the tree will be attached to + * @param $mixedData array|Traversable - mixedData + * @return DomElement $domElement - DOM Element with appended child nodes + */ + protected function buildElementTree(DOMDocument $doc, DOMElement $rootElement, $mixedData) + { + if (! (is_array($mixedData) || $mixedData instanceof Traversable)) { + return $rootElement; + } + + foreach ($mixedData as $key => $value) { + // key is numeric and switch is not possible, numeric values are not valid node names + if ((empty($value) || is_numeric($value)) && is_numeric($key)) { + continue; + } + + if ($value instanceof Traversable || is_array($value)) { + // current value is an array, start recursion + $rootElement->appendChild($this->buildElementTree($doc, $doc->createElement($key), $value)); + + continue; + } + + if (is_object($value) && ! method_exists($value, '__toString')) { + // object does not support __toString() method, manually convert the value + $value = $this->getEscaper()->escapeHtml( + '"Object" of type ' . get_class($value) . " does not support __toString() method" + ); + } + + if (is_numeric($key)) { + // xml does not allow numeric values, try to switch the value and the key + $key = (string) $value; + $value = null; + } + + try { + $rootElement->appendChild(new DOMElement($key, empty($value) ? null : (string) $value)); + } catch (\DOMException $e) { + // the input name is not valid, go one. + continue; + } + } + + return $rootElement; } /** diff --git a/library/Zend/Log/Logger.php b/library/Zend/Log/Logger.php index 676ced6d..21c09e6e 100644 --- a/library/Zend/Log/Logger.php +++ b/library/Zend/Log/Logger.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -49,6 +49,9 @@ class Logger implements LoggerInterface E_USER_ERROR => self::ERR, E_CORE_ERROR => self::ERR, E_RECOVERABLE_ERROR => self::ERR, + E_PARSE => self::ERR, + E_COMPILE_ERROR => self::ERR, + E_COMPILE_WARNING => self::ERR, E_STRICT => self::DEBUG, E_DEPRECATED => self::DEBUG, E_USER_DEPRECATED => self::DEBUG, @@ -416,7 +419,7 @@ class Logger implements LoggerInterface { if (!is_int($priority) || ($priority<0) || ($priority>=count($this->priorities))) { throw new Exception\InvalidArgumentException(sprintf( - '$priority must be an integer > 0 and < %d; received %s', + '$priority must be an integer >= 0 and < %d; received %s', count($this->priorities), var_export($priority, 1) )); @@ -613,18 +616,35 @@ class Logger implements LoggerInterface register_shutdown_function(function () use ($logger, $errorPriorityMap) { $error = error_get_last(); - if (null !== $error && $error['type'] === E_ERROR) { - $logger->log($errorPriorityMap[E_ERROR], - $error['message'], + + if (null === $error + || ! in_array( + $error['type'], array( - 'file' => $error['file'], - 'line' => $error['line'], - ) - ); + E_ERROR, + E_PARSE, + E_CORE_ERROR, + E_CORE_WARNING, + E_COMPILE_ERROR, + E_COMPILE_WARNING + ), + true + ) + ) { + return; } + + $logger->log($errorPriorityMap[$error['type']], + $error['message'], + array( + 'file' => $error['file'], + 'line' => $error['line'], + ) + ); }); static::$registeredFatalErrorShutdownFunction = true; + return true; } diff --git a/library/Zend/Log/LoggerAbstractServiceFactory.php b/library/Zend/Log/LoggerAbstractServiceFactory.php index b4611e15..b280dd04 100644 --- a/library/Zend/Log/LoggerAbstractServiceFactory.php +++ b/library/Zend/Log/LoggerAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/LoggerAwareInterface.php b/library/Zend/Log/LoggerAwareInterface.php index a65aff10..ad6d979b 100644 --- a/library/Zend/Log/LoggerAwareInterface.php +++ b/library/Zend/Log/LoggerAwareInterface.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Log; - /** * Logger aware interface */ diff --git a/library/Zend/Log/LoggerAwareTrait.php b/library/Zend/Log/LoggerAwareTrait.php index 6f5748dd..2da20dee 100644 --- a/library/Zend/Log/LoggerAwareTrait.php +++ b/library/Zend/Log/LoggerAwareTrait.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Log; - trait LoggerAwareTrait { /** diff --git a/library/Zend/Log/LoggerInterface.php b/library/Zend/Log/LoggerInterface.php index a2fc6eb5..b82a5fbd 100644 --- a/library/Zend/Log/LoggerInterface.php +++ b/library/Zend/Log/LoggerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/LoggerServiceFactory.php b/library/Zend/Log/LoggerServiceFactory.php index 0fc47c05..afa75c15 100644 --- a/library/Zend/Log/LoggerServiceFactory.php +++ b/library/Zend/Log/LoggerServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Processor/Backtrace.php b/library/Zend/Log/Processor/Backtrace.php index 2355a90b..01b19ade 100644 --- a/library/Zend/Log/Processor/Backtrace.php +++ b/library/Zend/Log/Processor/Backtrace.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository -* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) +* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -70,10 +70,6 @@ class Backtrace implements ProcessorInterface return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->traceLimit); } - if (PHP_VERSION_ID >= 50306) { - return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - } - - return debug_backtrace(); + return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } } diff --git a/library/Zend/Log/Processor/ProcessorInterface.php b/library/Zend/Log/Processor/ProcessorInterface.php index f0a32163..ea1b2eff 100644 --- a/library/Zend/Log/Processor/ProcessorInterface.php +++ b/library/Zend/Log/Processor/ProcessorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Processor/ReferenceId.php b/library/Zend/Log/Processor/ReferenceId.php new file mode 100644 index 00000000..3507c8f4 --- /dev/null +++ b/library/Zend/Log/Processor/ReferenceId.php @@ -0,0 +1,59 @@ +getIdentifier(); + + return $event; + } + + /** + * Sets identifier. + * + * @param string $identifier + * @return self + */ + public function setReferenceId($identifier) + { + $this->identifier = $identifier; + + return $this; + } + + /** + * Returns identifier. + * + * @return string + */ + public function getReferenceId() + { + return $this->getIdentifier(); + } +} diff --git a/library/Zend/Log/Processor/RequestId.php b/library/Zend/Log/Processor/RequestId.php index eb66f8fb..55f13211 100644 --- a/library/Zend/Log/Processor/RequestId.php +++ b/library/Zend/Log/Processor/RequestId.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository -* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) +* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -21,7 +21,7 @@ class RequestId implements ProcessorInterface protected $identifier; /** - * Adds an identifier for the request to the log. + * Adds an identifier for the request to the log, unless one has already been set. * * This enables to filter the log for messages belonging to a specific request * @@ -30,6 +30,10 @@ class RequestId implements ProcessorInterface */ public function process(array $event) { + if (isset($event['extra']['requestId'])) { + return $event; + } + if (!isset($event['extra'])) { $event['extra'] = array(); } diff --git a/library/Zend/Log/ProcessorPluginManager.php b/library/Zend/Log/ProcessorPluginManager.php index 319040f5..0e2cae2b 100644 --- a/library/Zend/Log/ProcessorPluginManager.php +++ b/library/Zend/Log/ProcessorPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,6 +20,7 @@ class ProcessorPluginManager extends AbstractPluginManager */ protected $invokableClasses = array( 'backtrace' => 'Zend\Log\Processor\Backtrace', + 'referenceid' => 'Zend\Log\Processor\ReferenceId', 'requestid' => 'Zend\Log\Processor\RequestId', ); diff --git a/library/Zend/Log/Writer/AbstractWriter.php b/library/Zend/Log/Writer/AbstractWriter.php index 39f5d1e9..f3ee13fc 100644 --- a/library/Zend/Log/Writer/AbstractWriter.php +++ b/library/Zend/Log/Writer/AbstractWriter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -215,18 +215,19 @@ abstract class AbstractWriter implements WriterInterface $plugins = new $plugins; } if (!$plugins instanceof FormatterPluginManager) { - throw new Exception\InvalidArgumentException(sprintf( + throw new Exception\InvalidArgumentException( + sprintf( 'Writer plugin manager must extend %s\FormatterPluginManager; received %s', __NAMESPACE__, is_object($plugins) ? get_class($plugins) : gettype($plugins) - )); + ) + ); } $this->formatterPlugins = $plugins; return $this; } - /** * Get formatter instance * @@ -265,14 +266,12 @@ abstract class AbstractWriter implements WriterInterface } catch (\Exception $e) { if ($errorHandlerStarted) { ErrorHandler::stop(); - $errorHandlerStarted = false; } throw $e; } if ($errorHandlerStarted) { $error = ErrorHandler::stop(); - $errorHandlerStarted = false; if ($error) { throw new Exception\RuntimeException("Unable to write", 0, $error); } diff --git a/library/Zend/Log/Writer/ChromePhp.php b/library/Zend/Log/Writer/ChromePhp.php index aa536314..6483cc29 100644 --- a/library/Zend/Log/Writer/ChromePhp.php +++ b/library/Zend/Log/Writer/ChromePhp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/ChromePhp/ChromePhpBridge.php b/library/Zend/Log/Writer/ChromePhp/ChromePhpBridge.php index 05de1de8..ac263cb3 100644 --- a/library/Zend/Log/Writer/ChromePhp/ChromePhpBridge.php +++ b/library/Zend/Log/Writer/ChromePhp/ChromePhpBridge.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/ChromePhp/ChromePhpInterface.php b/library/Zend/Log/Writer/ChromePhp/ChromePhpInterface.php index 772fe0b7..569b6def 100644 --- a/library/Zend/Log/Writer/ChromePhp/ChromePhpInterface.php +++ b/library/Zend/Log/Writer/ChromePhp/ChromePhpInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/Db.php b/library/Zend/Log/Writer/Db.php index 2eb54f29..675708aa 100644 --- a/library/Zend/Log/Writer/Db.php +++ b/library/Zend/Log/Writer/Db.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -139,8 +139,8 @@ class Db extends AbstractWriter { $keys = array_keys($fields); $sql = 'INSERT INTO ' . $db->platform->quoteIdentifier($tableName) . ' (' . - implode(",",array_map(array($db->platform, 'quoteIdentifier'), $keys)) . ') VALUES (' . - implode(",",array_map(array($db->driver, 'formatParameterName'), $keys)) . ')'; + implode(",", array_map(array($db->platform, 'quoteIdentifier'), $keys)) . ') VALUES (' . + implode(",", array_map(array($db->driver, 'formatParameterName'), $keys)) . ')'; return $sql; } @@ -163,7 +163,12 @@ class Db extends AbstractWriter if (is_array($value)) { foreach ($value as $key => $subvalue) { if (isset($columnMap[$name][$key])) { - $data[$columnMap[$name][$key]] = $subvalue; + if (is_scalar($subvalue)) { + $data[$columnMap[$name][$key]] = $subvalue; + continue; + } + + $data[$columnMap[$name][$key]] = var_export($subvalue, true); } } } elseif (isset($columnMap[$name])) { @@ -189,7 +194,12 @@ class Db extends AbstractWriter foreach ($event as $name => $value) { if (is_array($value)) { foreach ($value as $key => $subvalue) { - $data[$name . $this->separator . $key] = $subvalue; + if (is_scalar($subvalue)) { + $data[$name . $this->separator . $key] = $subvalue; + continue; + } + + $data[$name . $this->separator . $key] = var_export($subvalue, true); } } else { $data[$name] = $value; diff --git a/library/Zend/Log/Writer/FilterPluginManager.php b/library/Zend/Log/Writer/FilterPluginManager.php index d2c569b8..456d84e6 100644 --- a/library/Zend/Log/Writer/FilterPluginManager.php +++ b/library/Zend/Log/Writer/FilterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/FingersCrossed.php b/library/Zend/Log/Writer/FingersCrossed.php index d7720e84..26316b19 100644 --- a/library/Zend/Log/Writer/FingersCrossed.php +++ b/library/Zend/Log/Writer/FingersCrossed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Log\Writer; diff --git a/library/Zend/Log/Writer/FirePhp.php b/library/Zend/Log/Writer/FirePhp.php index 3a6b7664..b57b343d 100644 --- a/library/Zend/Log/Writer/FirePhp.php +++ b/library/Zend/Log/Writer/FirePhp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use FirePHP as FirePHPService; use Zend\Log\Exception; use Zend\Log\Formatter\FirePhp as FirePhpFormatter; use Zend\Log\Logger; -use FirePhp\FirePhpInterface; class FirePhp extends AbstractWriter { @@ -42,11 +41,10 @@ class FirePhp extends AbstractWriter $instance = isset($instance['instance']) ? $instance['instance'] : null; } - if ($instance instanceof FirePhpInterface) { + if ($instance !== null && !($instance instanceof FirePhp\FirePhpInterface)) { throw new Exception\InvalidArgumentException('You must pass a valid FirePhp\FirePhpInterface'); } - $this->firephp = $instance; $this->formatter = new FirePhpFormatter(); } diff --git a/library/Zend/Log/Writer/FirePhp/FirePhpBridge.php b/library/Zend/Log/Writer/FirePhp/FirePhpBridge.php index 0b8dc81c..d5527484 100644 --- a/library/Zend/Log/Writer/FirePhp/FirePhpBridge.php +++ b/library/Zend/Log/Writer/FirePhp/FirePhpBridge.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -53,34 +53,37 @@ class FirePhpBridge implements FirePhpInterface /** * Log an error message * - * @param string $line + * @param string $line + * @param string|null $label * @return void */ - public function error($line) + public function error($line, $label = null) { - return $this->firephp->error($line); + return $this->firephp->error($line, $label); } /** * Log a warning * - * @param string $line + * @param string $line + * @param string|null $label * @return void */ - public function warn($line) + public function warn($line, $label = null) { - return $this->firephp->warn($line); + return $this->firephp->warn($line, $label); } /** * Log informational message * - * @param string $line + * @param string $line + * @param string|null $label * @return void */ - public function info($line) + public function info($line, $label = null) { - return $this->firephp->info($line); + return $this->firephp->info($line, $label); } /** @@ -97,11 +100,12 @@ class FirePhpBridge implements FirePhpInterface /** * Log a message * - * @param string $line + * @param string $line + * @param string|null $label * @return void */ - public function log($line) + public function log($line, $label = null) { - return $this->firephp->trace($line); + return $this->firephp->trace($line, $label); } } diff --git a/library/Zend/Log/Writer/FirePhp/FirePhpInterface.php b/library/Zend/Log/Writer/FirePhp/FirePhpInterface.php index 523c5b92..ddecf109 100644 --- a/library/Zend/Log/Writer/FirePhp/FirePhpInterface.php +++ b/library/Zend/Log/Writer/FirePhp/FirePhpInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/FormatterPluginManager.php b/library/Zend/Log/Writer/FormatterPluginManager.php index 374f1e5b..c06faf41 100644 --- a/library/Zend/Log/Writer/FormatterPluginManager.php +++ b/library/Zend/Log/Writer/FormatterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/Mail.php b/library/Zend/Log/Writer/Mail.php index 4ceca29a..f27a5bf2 100644 --- a/library/Zend/Log/Writer/Mail.php +++ b/library/Zend/Log/Writer/Mail.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,6 +13,7 @@ use Traversable; use Zend\Log\Exception; use Zend\Log\Formatter\Simple as SimpleFormatter; use Zend\Mail\Message as MailMessage; +use Zend\Mail\MessageFactory as MailMessageFactory; use Zend\Mail\Transport; use Zend\Mail\Transport\Exception as TransportException; @@ -86,6 +87,9 @@ class Mail extends AbstractWriter } $transport = isset($mail['transport']) ? $mail['transport'] : null; $mail = isset($mail['mail']) ? $mail['mail'] : null; + if (is_array($mail)) { + $mail = MailMessageFactory::getInstance($mail); + } } // Ensure we have a valid mail message @@ -192,10 +196,11 @@ class Mail extends AbstractWriter } catch (TransportException\ExceptionInterface $e) { trigger_error( "unable to send log entries via email; " . - "message = {$e->getMessage()}; " . - "code = {$e->getCode()}; " . - "exception class = " . get_class($e), - E_USER_WARNING); + "message = {$e->getMessage()}; " . + "code = {$e->getCode()}; " . + "exception class = " . get_class($e), + E_USER_WARNING + ); } } diff --git a/library/Zend/Log/Writer/Mock.php b/library/Zend/Log/Writer/Mock.php index 2059c535..a7c15432 100644 --- a/library/Zend/Log/Writer/Mock.php +++ b/library/Zend/Log/Writer/Mock.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/MongoDB.php b/library/Zend/Log/Writer/MongoDB.php index bb2a7544..4179f965 100644 --- a/library/Zend/Log/Writer/MongoDB.php +++ b/library/Zend/Log/Writer/MongoDB.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Log/Writer/Noop.php b/library/Zend/Log/Writer/Noop.php new file mode 100644 index 00000000..6a456baa --- /dev/null +++ b/library/Zend/Log/Writer/Noop.php @@ -0,0 +1,23 @@ + 'noop', + 'Zend\Log\Writer\Null' => 'noop', + ); + /** * Default set of writers * @@ -25,7 +30,7 @@ class WriterPluginManager extends AbstractPluginManager 'firephp' => 'Zend\Log\Writer\FirePhp', 'mail' => 'Zend\Log\Writer\Mail', 'mock' => 'Zend\Log\Writer\Mock', - 'null' => 'Zend\Log\Writer\Null', + 'noop' => 'Zend\Log\Writer\Noop', 'stream' => 'Zend\Log\Writer\Stream', 'syslog' => 'Zend\Log\Writer\Syslog', 'zendmonitor' => 'Zend\Log\Writer\ZendMonitor', diff --git a/library/Zend/Log/composer.json b/library/Zend/Log/composer.json index af642194..87f3c25f 100644 --- a/library/Zend/Log/composer.json +++ b/library/Zend/Log/composer.json @@ -9,11 +9,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Log\\": "" } }, - "target-dir": "Zend/Log", "require": { "php": ">=5.3.23", "zendframework/zend-servicemanager": "self.version", @@ -37,8 +36,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Mail/Address.php b/library/Zend/Mail/Address.php index 526826a9..e97878d5 100644 --- a/library/Zend/Mail/Address.php +++ b/library/Zend/Mail/Address.php @@ -3,12 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail; +use Zend\Validator\EmailAddress as EmailAddressValidator; +use Zend\Validator\Hostname; + class Address implements Address\AddressInterface { protected $email; @@ -24,15 +27,33 @@ class Address implements Address\AddressInterface */ public function __construct($email, $name = null) { - if (!is_string($email)) { - throw new Exception\InvalidArgumentException('Email must be a string'); + $emailAddressValidator = new EmailAddressValidator(Hostname::ALLOW_LOCAL); + if (! is_string($email) || empty($email)) { + throw new Exception\InvalidArgumentException('Email must be a valid email address'); } - if (null !== $name && !is_string($name)) { - throw new Exception\InvalidArgumentException('Name must be a string'); + + if (preg_match("/[\r\n]/", $email)) { + throw new Exception\InvalidArgumentException('CRLF injection detected'); + } + + if (! $emailAddressValidator->isValid($email)) { + $invalidMessages = $emailAddressValidator->getMessages(); + throw new Exception\InvalidArgumentException(array_shift($invalidMessages)); + } + + if (null !== $name) { + if (! is_string($name)) { + throw new Exception\InvalidArgumentException('Name must be a string'); + } + + if (preg_match("/[\r\n]/", $name)) { + throw new Exception\InvalidArgumentException('CRLF injection detected'); + } + + $this->name = $name; } $this->email = $email; - $this->name = $name; } /** @@ -68,7 +89,6 @@ class Address implements Address\AddressInterface return $string; } - $string = $name . ' ' . $string; - return $string; + return $name . ' ' . $string; } } diff --git a/library/Zend/Mail/Address/AddressInterface.php b/library/Zend/Mail/Address/AddressInterface.php index 4f23c5f8..bcdf92ad 100644 --- a/library/Zend/Mail/Address/AddressInterface.php +++ b/library/Zend/Mail/Address/AddressInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/AddressList.php b/library/Zend/Mail/AddressList.php index acf5bde8..60a34d61 100644 --- a/library/Zend/Mail/AddressList.php +++ b/library/Zend/Mail/AddressList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -79,6 +79,40 @@ class AddressList implements Countable, Iterator return $this; } + /** + * Add an address to the list from any valid string format, such as + * - "ZF Dev" + * - dev@zf.com + * + * @param string $address + * @throws Exception\InvalidArgumentException + * @return AddressList + */ + public function addFromString($address) + { + if (!preg_match('/^((?P.*?)<(?P[^>]+)>|(?P.+))$/', $address, $matches)) { + throw new Exception\InvalidArgumentException('Invalid address format'); + } + + $name = null; + if (isset($matches['name'])) { + $name = trim($matches['name']); + } + if (empty($name)) { + $name = null; + } + + if (isset($matches['namedEmail'])) { + $email = $matches['namedEmail']; + } + if (isset($matches['email'])) { + $email = $matches['email']; + } + $email = trim($email); + + return $this->add($email, $name); + } + /** * Merge another address list into this one * diff --git a/library/Zend/Mail/Exception/BadMethodCallException.php b/library/Zend/Mail/Exception/BadMethodCallException.php index 6a11063b..05f15e00 100644 --- a/library/Zend/Mail/Exception/BadMethodCallException.php +++ b/library/Zend/Mail/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Exception/DomainException.php b/library/Zend/Mail/Exception/DomainException.php index a3b14dd6..921d1d87 100644 --- a/library/Zend/Mail/Exception/DomainException.php +++ b/library/Zend/Mail/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Exception/ExceptionInterface.php b/library/Zend/Mail/Exception/ExceptionInterface.php index e1ebc990..4d9f7783 100644 --- a/library/Zend/Mail/Exception/ExceptionInterface.php +++ b/library/Zend/Mail/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Exception/InvalidArgumentException.php b/library/Zend/Mail/Exception/InvalidArgumentException.php index 30c58a5b..b25b5108 100644 --- a/library/Zend/Mail/Exception/InvalidArgumentException.php +++ b/library/Zend/Mail/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Exception/OutOfBoundsException.php b/library/Zend/Mail/Exception/OutOfBoundsException.php index 1e94c8e4..dd832995 100644 --- a/library/Zend/Mail/Exception/OutOfBoundsException.php +++ b/library/Zend/Mail/Exception/OutOfBoundsException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Exception/RuntimeException.php b/library/Zend/Mail/Exception/RuntimeException.php index 339d3a40..7b437460 100644 --- a/library/Zend/Mail/Exception/RuntimeException.php +++ b/library/Zend/Mail/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/AbstractAddressList.php b/library/Zend/Mail/Header/AbstractAddressList.php index 87f76c77..e7db7240 100644 --- a/library/Zend/Mail/Header/AbstractAddressList.php +++ b/library/Zend/Mail/Header/AbstractAddressList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -41,9 +41,10 @@ abstract class AbstractAddressList implements HeaderInterface public static function fromString($headerLine) { - $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); - // split into name/value - list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($decodedLine); + list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine); + $decodedValue = HeaderWrap::mimeDecodeValue($fieldValue); + $wasEncoded = ($decodedValue !== $fieldValue); + $fieldValue = $decodedValue; if (strtolower($fieldName) !== static::$type) { throw new Exception\InvalidArgumentException(sprintf( @@ -52,12 +53,12 @@ abstract class AbstractAddressList implements HeaderInterface )); } $header = new static(); - if ($decodedLine != $headerLine) { + if ($wasEncoded) { $header->setEncoding('UTF-8'); } // split value on "," $fieldValue = str_replace(Headers::FOLDING, ' ', $fieldValue); - $values = explode(',', $fieldValue); + $values = str_getcsv($fieldValue, ','); array_walk( $values, function (&$value) { @@ -67,29 +68,7 @@ abstract class AbstractAddressList implements HeaderInterface $addressList = $header->getAddressList(); foreach ($values as $address) { - // split values into name/email - if (!preg_match('/^((?P.*?)<(?P[^>]+)>|(?P.+))$/', $address, $matches)) { - // Should we raise an exception here? - continue; - } - $name = null; - if (isset($matches['name'])) { - $name = trim($matches['name']); - } - if (empty($name)) { - $name = null; - } - - if (isset($matches['namedEmail'])) { - $email = $matches['namedEmail']; - } - if (isset($matches['email'])) { - $email = $matches['email']; - } - $email = trim($email); // we may have leading whitespace - - // populate address list - $addressList->add($email, $name); + $addressList->addFromString($address); } return $header; } @@ -103,22 +82,33 @@ abstract class AbstractAddressList implements HeaderInterface { $emails = array(); $encoding = $this->getEncoding(); + foreach ($this->getAddressList() as $address) { $email = $address->getEmail(); $name = $address->getName(); + if (empty($name)) { $emails[] = $email; - } else { - if (false !== strstr($name, ',')) { - $name = sprintf('"%s"', $name); - } + continue; + } - if ($format == HeaderInterface::FORMAT_ENCODED - && 'ASCII' !== $encoding - ) { - $name = HeaderWrap::mimeEncodeValue($name, $encoding); - } - $emails[] = sprintf('%s <%s>', $name, $email); + if (false !== strstr($name, ',')) { + $name = sprintf('"%s"', $name); + } + + if ($format === HeaderInterface::FORMAT_ENCODED + && 'ASCII' !== $encoding + ) { + $name = HeaderWrap::mimeEncodeValue($name, $encoding); + } + + $emails[] = sprintf('%s <%s>', $name, $email); + } + + // Ensure the values are valid before sending them. + if ($format !== HeaderInterface::FORMAT_RAW) { + foreach ($emails as $email) { + HeaderValue::assertValid($email); } } diff --git a/library/Zend/Mail/Header/Bcc.php b/library/Zend/Mail/Header/Bcc.php index b03611fe..418b3bd7 100644 --- a/library/Zend/Mail/Header/Bcc.php +++ b/library/Zend/Mail/Header/Bcc.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/Cc.php b/library/Zend/Mail/Header/Cc.php index 07c6668c..f4ee5709 100644 --- a/library/Zend/Mail/Header/Cc.php +++ b/library/Zend/Mail/Header/Cc.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/ContentTransferEncoding.php b/library/Zend/Mail/Header/ContentTransferEncoding.php index 3d72e706..86233a45 100644 --- a/library/Zend/Mail/Header/ContentTransferEncoding.php +++ b/library/Zend/Mail/Header/ContentTransferEncoding.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Header; - class ContentTransferEncoding implements HeaderInterface { /** @@ -22,14 +21,13 @@ class ContentTransferEncoding implements HeaderInterface '8bit', 'quoted-printable', 'base64', + 'binary', /* * not implemented: - * 'binary', * x-token: 'X-' */ ); - /** * @var string */ @@ -42,8 +40,8 @@ class ContentTransferEncoding implements HeaderInterface public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'content-transfer-encoding') { diff --git a/library/Zend/Mail/Header/ContentType.php b/library/Zend/Mail/Header/ContentType.php index f3fd16ed..e2efa919 100644 --- a/library/Zend/Mail/Header/ContentType.php +++ b/library/Zend/Mail/Header/ContentType.php @@ -3,21 +3,29 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Header; use Zend\Mail\Headers; +use Zend\Mime\Mime; -class ContentType implements HeaderInterface +class ContentType implements UnstructuredInterface { /** * @var string */ protected $type; + /** + * Header encoding + * + * @var string + */ + protected $encoding = 'ASCII'; + /** * @var array */ @@ -25,30 +33,28 @@ class ContentType implements HeaderInterface public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'content-type') { throw new Exception\InvalidArgumentException('Invalid header line for Content-Type string'); } - $value = str_replace(Headers::FOLDING, " ", $value); + $value = str_replace(Headers::FOLDING, ' ', $value); $values = preg_split('#\s*;\s*#', $value); + $type = array_shift($values); - - //Remove empty values - $values = array_filter($values); - $header = new static(); $header->setType($type); - if (count($values)) { - foreach ($values as $keyValuePair) { - list($key, $value) = explode('=', $keyValuePair, 2); - $value = trim($value, "'\" \t\n\r\0\x0B"); - $header->addParameter($key, $value); - } + // Remove empty values + $values = array_filter($values); + + foreach ($values as $keyValuePair) { + list($key, $value) = explode('=', $keyValuePair, 2); + $value = trim($value, "'\" \t\n\r\0\x0B"); + $header->addParameter($key, $value); } return $header; @@ -68,6 +74,12 @@ class ContentType implements HeaderInterface $values = array($prepared); foreach ($this->parameters as $attribute => $value) { + if (HeaderInterface::FORMAT_ENCODED === $format && !Mime::isPrintable($value)) { + $this->encoding = 'UTF-8'; + $value = HeaderWrap::wrap($value, $this); + $this->encoding = 'ASCII'; + } + $values[] = sprintf('%s="%s"', $attribute, $value); } @@ -76,18 +88,18 @@ class ContentType implements HeaderInterface public function setEncoding($encoding) { - // This header must be always in US-ASCII + $this->encoding = $encoding; return $this; } public function getEncoding() { - return 'ASCII'; + return $this->encoding; } public function toString() { - return 'Content-Type: ' . $this->getFieldValue(); + return 'Content-Type: ' . $this->getFieldValue(HeaderInterface::FORMAT_ENCODED); } /** @@ -126,11 +138,24 @@ class ContentType implements HeaderInterface * @param string $name * @param string $value * @return ContentType + * @throws Exception\InvalidArgumentException for parameter names that do not follow RFC 2822 + * @throws Exception\InvalidArgumentException for parameter values that do not follow RFC 2822 */ public function addParameter($name, $value) { - $name = strtolower($name); - $this->parameters[$name] = (string) $value; + $name = strtolower($name); + $value = (string) $value; + + if (! HeaderValue::isValid($name)) { + throw new Exception\InvalidArgumentException('Invalid content-type parameter name detected'); + } + if (! HeaderWrap::canBeEncoded($value)) { + throw new Exception\InvalidArgumentException( + 'Parameter value must be composed of printable US-ASCII or UTF-8 characters.' + ); + } + + $this->parameters[$name] = $value; return $this; } @@ -156,7 +181,7 @@ class ContentType implements HeaderInterface if (isset($this->parameters[$name])) { return $this->parameters[$name]; } - return null; + return; } /** diff --git a/library/Zend/Mail/Header/Date.php b/library/Zend/Mail/Header/Date.php index 4c62da8d..9b659546 100644 --- a/library/Zend/Mail/Header/Date.php +++ b/library/Zend/Mail/Header/Date.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -22,6 +22,7 @@ class Date implements HeaderInterface public static function fromString($headerLine) { list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'date') { @@ -35,6 +36,9 @@ class Date implements HeaderInterface public function __construct($value) { + if (! HeaderValue::isValid($value)) { + throw new Exception\InvalidArgumentException('Invalid Date header value detected'); + } $this->value = $value; } diff --git a/library/Zend/Mail/Header/Exception/BadMethodCallException.php b/library/Zend/Mail/Header/Exception/BadMethodCallException.php index ebd63ca6..c58f5bb0 100644 --- a/library/Zend/Mail/Header/Exception/BadMethodCallException.php +++ b/library/Zend/Mail/Header/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\Mail\Header\Exception; use Zend\Mail\Exception; -class BadMethodCallException extends Exception\BadMethodCallException implements - ExceptionInterface +class BadMethodCallException extends Exception\BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Header/Exception/ExceptionInterface.php b/library/Zend/Mail/Header/Exception/ExceptionInterface.php index a6333e03..8ac63324 100644 --- a/library/Zend/Mail/Header/Exception/ExceptionInterface.php +++ b/library/Zend/Mail/Header/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/Exception/InvalidArgumentException.php b/library/Zend/Mail/Header/Exception/InvalidArgumentException.php index 0c784420..af8fd91c 100644 --- a/library/Zend/Mail/Header/Exception/InvalidArgumentException.php +++ b/library/Zend/Mail/Header/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\Mail\Header\Exception; use Zend\Mail\Exception; -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Header/Exception/RuntimeException.php b/library/Zend/Mail/Header/Exception/RuntimeException.php index 2d9d5937..98354eb9 100644 --- a/library/Zend/Mail/Header/Exception/RuntimeException.php +++ b/library/Zend/Mail/Header/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ namespace Zend\Mail\Header\Exception; use Zend\Mail\Exception; -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Header/From.php b/library/Zend/Mail/Header/From.php index 463f1c6d..4d10dfec 100644 --- a/library/Zend/Mail/Header/From.php +++ b/library/Zend/Mail/Header/From.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/GenericHeader.php b/library/Zend/Mail/Header/GenericHeader.php index 3824604a..20619a83 100644 --- a/library/Zend/Mail/Header/GenericHeader.php +++ b/library/Zend/Mail/Header/GenericHeader.php @@ -3,12 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Header; +use Zend\Mime\Mime; + class GenericHeader implements HeaderInterface, UnstructuredInterface { /** @@ -24,18 +26,16 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface /** * Header encoding * - * @var string + * @var null|string */ - protected $encoding = 'ASCII'; + protected $encoding; public static function fromString($headerLine) { - $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); - list($name, $value) = GenericHeader::splitHeaderLine($decodedLine); + list($name, $value) = self::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); $header = new static($name, $value); - if ($decodedLine != $headerLine) { - $header->setEncoding('UTF-8'); - } + return $header; } @@ -53,6 +53,15 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface throw new Exception\InvalidArgumentException('Header must match with the format "name:value"'); } + if (! HeaderName::isValid($parts[0])) { + throw new Exception\InvalidArgumentException('Invalid header name detected'); + } + + if (! HeaderValue::isValid($parts[1])) { + throw new Exception\InvalidArgumentException('Invalid header value detected'); + } + + $parts[0] = $parts[0]; $parts[1] = ltrim($parts[1]); return $parts; @@ -79,8 +88,8 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface * Set header name * * @param string $fieldName - * @throws Exception\InvalidArgumentException * @return GenericHeader + * @throws Exception\InvalidArgumentException; */ public function setFieldName($fieldName) { @@ -91,8 +100,7 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface // Pre-filter to normalize valid characters, change underscore to dash $fieldName = str_replace(' ', '-', ucwords(str_replace(array('_', '-'), ' ', $fieldName))); - // Validate what we have - if (!preg_match('/^[\x21-\x39\x3B-\x7E]*$/', $fieldName)) { + if (! HeaderName::isValid($fieldName)) { throw new Exception\InvalidArgumentException( 'Header name must be composed of printable US-ASCII characters, except colon.' ); @@ -112,16 +120,21 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface * * @param string $fieldValue * @return GenericHeader + * @throws Exception\InvalidArgumentException; */ public function setFieldValue($fieldValue) { $fieldValue = (string) $fieldValue; - if (empty($fieldValue) || preg_match('/^\s+$/', $fieldValue)) { - $fieldValue = ''; + if (! HeaderWrap::canBeEncoded($fieldValue)) { + throw new Exception\InvalidArgumentException( + 'Header value must be composed of printable US-ASCII characters and valid folding sequences.' + ); } $this->fieldValue = $fieldValue; + $this->encoding = null; + return $this; } @@ -142,12 +155,19 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface public function getEncoding() { + if (! $this->encoding) { + $this->encoding = Mime::isPrintable($this->fieldValue) ? 'ASCII' : 'UTF-8'; + } + return $this->encoding; } public function toString() { - $name = $this->getFieldName(); + $name = $this->getFieldName(); + if (empty($name)) { + throw new Exception\RuntimeException('Header name is not set, use setFieldName()'); + } $value = $this->getFieldValue(HeaderInterface::FORMAT_ENCODED); return $name . ': ' . $value; diff --git a/library/Zend/Mail/Header/GenericMultiHeader.php b/library/Zend/Mail/Header/GenericMultiHeader.php index a5f2fb29..122c4c18 100644 --- a/library/Zend/Mail/Header/GenericMultiHeader.php +++ b/library/Zend/Mail/Header/GenericMultiHeader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -16,24 +16,18 @@ class GenericMultiHeader extends GenericHeader implements MultipleHeadersInterfa { public static function fromString($headerLine) { - $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); - list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($decodedLine); + list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine); + $fieldValue = HeaderWrap::mimeDecodeValue($fieldValue); if (strpos($fieldValue, ',')) { $headers = array(); - $encoding = ($decodedLine != $headerLine) ? 'UTF-8' : 'ASCII'; foreach (explode(',', $fieldValue) as $multiValue) { - $header = new static($fieldName, $multiValue); - $headers[] = $header->setEncoding($encoding); + $headers[] = new static($fieldName, $multiValue); } return $headers; - } else { - $header = new static($fieldName, $fieldValue); - if ($decodedLine != $headerLine) { - $header->setEncoding('UTF-8'); - } - return $header; } + + return new static($fieldName, $fieldValue); } /** @@ -45,16 +39,18 @@ class GenericMultiHeader extends GenericHeader implements MultipleHeadersInterfa */ public function toStringMultipleHeaders(array $headers) { - $name = $this->getFieldName(); + $name = $this->getFieldName(); $values = array($this->getFieldValue(HeaderInterface::FORMAT_ENCODED)); + foreach ($headers as $header) { - if (!$header instanceof static) { + if (! $header instanceof static) { throw new Exception\InvalidArgumentException( 'This method toStringMultipleHeaders was expecting an array of headers of the same type' ); } $values[] = $header->getFieldValue(HeaderInterface::FORMAT_ENCODED); } + return $name . ': ' . implode(',', $values); } } diff --git a/library/Zend/Mail/Header/HeaderInterface.php b/library/Zend/Mail/Header/HeaderInterface.php index 37919eca..8b304b3d 100644 --- a/library/Zend/Mail/Header/HeaderInterface.php +++ b/library/Zend/Mail/Header/HeaderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,7 +25,6 @@ interface HeaderInterface */ const FORMAT_RAW = false; - /** * Factory to generate a header object from a string * diff --git a/library/Zend/Mail/Header/HeaderLoader.php b/library/Zend/Mail/Header/HeaderLoader.php index aa33fc0d..2711ac85 100644 --- a/library/Zend/Mail/Header/HeaderLoader.php +++ b/library/Zend/Mail/Header/HeaderLoader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/HeaderName.php b/library/Zend/Mail/Header/HeaderName.php new file mode 100644 index 00000000..46eefdd5 --- /dev/null +++ b/library/Zend/Mail/Header/HeaderName.php @@ -0,0 +1,74 @@ + 32 && $ord < 127 && $ord !== 58) { + $result .= $name[$i]; + } + } + return $result; + } + + /** + * Determine if the header name contains any invalid characters. + * + * @param string $name + * @return bool + */ + public static function isValid($name) + { + $tot = strlen($name); + for ($i = 0; $i < $tot; $i += 1) { + $ord = ord($name[$i]); + if ($ord < 33 || $ord > 126 || $ord === 58) { + return false; + } + } + return true; + } + + /** + * Assert that the header name is valid. + * + * Raises an exception if invalid. + * + * @param string $name + * @throws Exception\RuntimeException + * @return void + */ + public static function assertValid($name) + { + if (! self::isValid($name)) { + throw new Exception\RuntimeException('Invalid header name detected'); + } + } +} diff --git a/library/Zend/Mail/Header/HeaderValue.php b/library/Zend/Mail/Header/HeaderValue.php new file mode 100644 index 00000000..5104a512 --- /dev/null +++ b/library/Zend/Mail/Header/HeaderValue.php @@ -0,0 +1,117 @@ + 127) { + continue; + } + + if ($ord === 13) { + if ($i + 2 >= $total) { + continue; + } + + $lf = ord($value[$i + 1]); + $sp = ord($value[$i + 2]); + + if ($lf !== 10 || $sp !== 32) { + continue; + } + + $result .= "\r\n "; + $i += 2; + continue; + } + + $result .= $value[$i]; + } + + return $result; + } + + /** + * Determine if the header value contains any invalid characters. + * + * @see http://www.rfc-base.org/txt/rfc-2822.txt (section 2.2) + * @param string $value + * @return bool + */ + public static function isValid($value) + { + $total = strlen($value); + for ($i = 0; $i < $total; $i += 1) { + $ord = ord($value[$i]); + + // bare LF means we aren't valid + if ($ord === 10 || $ord > 127) { + return false; + } + + if ($ord === 13) { + if ($i + 2 >= $total) { + return false; + } + + $lf = ord($value[$i + 1]); + $sp = ord($value[$i + 2]); + + if ($lf !== 10 || ! in_array($sp, array(9, 32), true)) { + return false; + } + + // skip over the LF following this + $i += 2; + } + } + + return true; + } + + /** + * Assert that the header value is valid. + * + * Raises an exception if invalid. + * + * @param string $value + * @throws Exception\RuntimeException + * @return void + */ + public static function assertValid($value) + { + if (! self::isValid($value)) { + throw new Exception\RuntimeException('Invalid header value detected'); + } + } +} diff --git a/library/Zend/Mail/Header/HeaderWrap.php b/library/Zend/Mail/Header/HeaderWrap.php index 30c223f2..df532edc 100644 --- a/library/Zend/Mail/Header/HeaderWrap.php +++ b/library/Zend/Mail/Header/HeaderWrap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -92,4 +92,32 @@ abstract class HeaderWrap { return Mime::encodeQuotedPrintableHeader($value, $encoding, $lineLength, Headers::EOL); } + + /** + * MIME-decode a value + * + * Performs quoted-printable decoding on a value. + * + * @param string $value + * @return string Returns the mime encode value without the last line ending + */ + public static function mimeDecodeValue($value) + { + $decodedValue = iconv_mime_decode($value, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); + + return $decodedValue; + } + + /** + * Test if is possible apply MIME-encoding + * + * @param string $value + * @return bool + */ + public static function canBeEncoded($value) + { + $encoded = iconv_mime_encode('x-test', $value, array('scheme' => 'Q')); + + return (false !== $encoded); + } } diff --git a/library/Zend/Mail/Header/MessageId.php b/library/Zend/Mail/Header/MessageId.php index fbb7cd5a..850757ea 100644 --- a/library/Zend/Mail/Header/MessageId.php +++ b/library/Zend/Mail/Header/MessageId.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Header; - class MessageId implements HeaderInterface { /** @@ -17,10 +16,10 @@ class MessageId implements HeaderInterface */ protected $messageId; - public static function fromString($headerLine) { list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'message-id') { @@ -71,8 +70,13 @@ class MessageId implements HeaderInterface $id = $this->createMessageId(); } - $id = sprintf('<%s>', $id); - $this->messageId = $id; + if (! HeaderValue::isValid($id) + || preg_match("/[\r\n]/", $id) + ) { + throw new Exception\InvalidArgumentException('Invalid ID detected'); + } + + $this->messageId = sprintf('<%s>', $id); return $this; } diff --git a/library/Zend/Mail/Header/MimeVersion.php b/library/Zend/Mail/Header/MimeVersion.php index c6b34e50..41c5996e 100644 --- a/library/Zend/Mail/Header/MimeVersion.php +++ b/library/Zend/Mail/Header/MimeVersion.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,6 +19,7 @@ class MimeVersion implements HeaderInterface public static function fromString($headerLine) { list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'mime-version') { @@ -68,6 +69,9 @@ class MimeVersion implements HeaderInterface */ public function setVersion($version) { + if (! preg_match('/^[1-9]\d*\.\d+$/', $version)) { + throw new Exception\InvalidArgumentException('Invalid MIME-Version value detected'); + } $this->version = $version; return $this; } diff --git a/library/Zend/Mail/Header/MultipleHeadersInterface.php b/library/Zend/Mail/Header/MultipleHeadersInterface.php index dae4c7eb..66e8b06d 100644 --- a/library/Zend/Mail/Header/MultipleHeadersInterface.php +++ b/library/Zend/Mail/Header/MultipleHeadersInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/Received.php b/library/Zend/Mail/Header/Received.php index 3efbe42e..b0a54197 100644 --- a/library/Zend/Mail/Header/Received.php +++ b/library/Zend/Mail/Header/Received.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,6 +24,7 @@ class Received implements HeaderInterface, MultipleHeadersInterface public static function fromString($headerLine) { list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'received') { @@ -37,6 +38,9 @@ class Received implements HeaderInterface, MultipleHeadersInterface public function __construct($value = '') { + if (! HeaderValue::isValid($value)) { + throw new Exception\InvalidArgumentException('Invalid Received value provided'); + } $this->value = $value; } @@ -77,7 +81,7 @@ class Received implements HeaderInterface, MultipleHeadersInterface { $strings = array($this->toString()); foreach ($headers as $header) { - if (!$header instanceof Received) { + if (! $header instanceof Received) { throw new Exception\RuntimeException( 'The Received multiple header implementation can only accept an array of Received headers' ); diff --git a/library/Zend/Mail/Header/ReplyTo.php b/library/Zend/Mail/Header/ReplyTo.php index ca977b29..8d2c8929 100644 --- a/library/Zend/Mail/Header/ReplyTo.php +++ b/library/Zend/Mail/Header/ReplyTo.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/Sender.php b/library/Zend/Mail/Header/Sender.php index c8840baa..2efc23bf 100644 --- a/library/Zend/Mail/Header/Sender.php +++ b/library/Zend/Mail/Header/Sender.php @@ -3,14 +3,21 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Header; use Zend\Mail; +use Zend\Mime\Mime; +/** + * Sender header class methods. + * + * @see https://tools.ietf.org/html/rfc2822 RFC 2822 + * @see https://tools.ietf.org/html/rfc2047 RFC 2047 + */ class Sender implements HeaderInterface { /** @@ -21,36 +28,37 @@ class Sender implements HeaderInterface /** * Header encoding * - * @var string + * @var null|string */ - protected $encoding = 'ASCII'; + protected $encoding; public static function fromString($headerLine) { - $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); - list($name, $value) = GenericHeader::splitHeaderLine($decodedLine); + list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'sender') { throw new Exception\InvalidArgumentException('Invalid header line for Sender string'); } - $header = new static(); - if ($decodedLine != $headerLine) { - $header->setEncoding('UTF-8'); - } + $header = new static(); + $senderName = ''; + $senderEmail = ''; // Check for address, and set if found if (preg_match('/^(?P.*?)<(?P[^>]+)>$/', $value, $matches)) { - $name = $matches['name']; - if (empty($name)) { - $name = null; - } else { - $name = iconv_mime_decode($name, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); + $senderName = trim($matches['name']); + if (empty($senderName)) { + $senderName = null; } - $header->setAddress($matches['email'], $name); + $senderEmail = $matches['email']; + } else { + $senderEmail = $value; } + $header->setAddress($senderEmail, $senderName); + return $header; } @@ -61,21 +69,23 @@ class Sender implements HeaderInterface public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { - if (!$this->address instanceof Mail\Address\AddressInterface) { + if (! $this->address instanceof Mail\Address\AddressInterface) { return ''; } $email = sprintf('<%s>', $this->address->getEmail()); $name = $this->address->getName(); + if (!empty($name)) { - $encoding = $this->getEncoding(); - if ($format == HeaderInterface::FORMAT_ENCODED - && 'ASCII' !== $encoding - ) { - $name = HeaderWrap::mimeEncodeValue($name, $encoding); + if ($format == HeaderInterface::FORMAT_ENCODED) { + $encoding = $this->getEncoding(); + if ('ASCII' !== $encoding) { + $name = HeaderWrap::mimeEncodeValue($name, $encoding); + } } $email = sprintf('%s %s', $name, $email); } + return $email; } @@ -87,6 +97,12 @@ class Sender implements HeaderInterface public function getEncoding() { + if (! $this->encoding) { + $this->encoding = Mime::isPrintable($this->getFieldValue(HeaderInterface::FORMAT_RAW)) + ? 'ASCII' + : 'UTF-8'; + } + return $this->encoding; } diff --git a/library/Zend/Mail/Header/StructuredInterface.php b/library/Zend/Mail/Header/StructuredInterface.php index 475cee3b..8d3825d3 100644 --- a/library/Zend/Mail/Header/StructuredInterface.php +++ b/library/Zend/Mail/Header/StructuredInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/Subject.php b/library/Zend/Mail/Header/Subject.php index 50daa82f..4eb44434 100644 --- a/library/Zend/Mail/Header/Subject.php +++ b/library/Zend/Mail/Header/Subject.php @@ -3,12 +3,20 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Header; +use Zend\Mime\Mime; + +/** + * Subject header class methods. + * + * @see https://tools.ietf.org/html/rfc2822 RFC 2822 + * @see https://tools.ietf.org/html/rfc2047 RFC 2047 + */ class Subject implements UnstructuredInterface { /** @@ -19,14 +27,14 @@ class Subject implements UnstructuredInterface /** * Header encoding * - * @var string + * @var null|string */ - protected $encoding = 'ASCII'; + protected $encoding; public static function fromString($headerLine) { - $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); - list($name, $value) = GenericHeader::splitHeaderLine($decodedLine); + list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $value = HeaderWrap::mimeDecodeValue($value); // check to ensure proper header type for this factory if (strtolower($name) !== 'subject') { @@ -34,9 +42,6 @@ class Subject implements UnstructuredInterface } $header = new static(); - if ($decodedLine != $headerLine) { - $header->setEncoding('UTF-8'); - } $header->setSubject($value); return $header; @@ -64,12 +69,26 @@ class Subject implements UnstructuredInterface public function getEncoding() { + if (! $this->encoding) { + $this->encoding = Mime::isPrintable($this->subject) ? 'ASCII' : 'UTF-8'; + } + return $this->encoding; } public function setSubject($subject) { - $this->subject = (string) $subject; + $subject = (string) $subject; + + if (! HeaderWrap::canBeEncoded($subject)) { + throw new Exception\InvalidArgumentException( + 'Subject value must be composed of printable US-ASCII or UTF-8 characters.' + ); + } + + $this->subject = $subject; + $this->encoding = null; + return $this; } diff --git a/library/Zend/Mail/Header/To.php b/library/Zend/Mail/Header/To.php index 78f69a4a..26d41ae3 100644 --- a/library/Zend/Mail/Header/To.php +++ b/library/Zend/Mail/Header/To.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Header/UnstructuredInterface.php b/library/Zend/Mail/Header/UnstructuredInterface.php index 1b60c1d0..c14dbc2c 100644 --- a/library/Zend/Mail/Header/UnstructuredInterface.php +++ b/library/Zend/Mail/Header/UnstructuredInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Headers.php b/library/Zend/Mail/Headers.php index 7822a01b..3ceb10be 100644 --- a/library/Zend/Mail/Headers.php +++ b/library/Zend/Mail/Headers.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -66,29 +66,50 @@ class Headers implements Countable, Iterator { $headers = new static(); $currentLine = ''; + $emptyLine = 0; // iterate the header lines, some might be continuations - foreach (explode($EOL, $string) as $line) { + $lines = explode($EOL, $string); + $total = count($lines); + for ($i = 0; $i < $total; $i += 1) { + $line = $lines[$i]; + + // Empty line indicates end of headers + // EXCEPT if there are more lines, in which case, there's a possible error condition + if (preg_match('/^\s*$/', $line)) { + $emptyLine += 1; + if ($emptyLine > 2) { + throw new Exception\RuntimeException('Malformed header detected'); + } + continue; + } + + if ($emptyLine > 0) { + throw new Exception\RuntimeException('Malformed header detected'); + } + // check if a header name is present - if (preg_match('/^(?P[\x21-\x39\x3B-\x7E]+):.*$/', $line, $matches)) { + if (preg_match('/^[\x21-\x39\x3B-\x7E]+:.*$/', $line)) { if ($currentLine) { // a header name was present, then store the current complete line $headers->addHeaderLine($currentLine); } $currentLine = trim($line); - } elseif (preg_match('/^\s+.*$/', $line, $matches)) { - // continuation: append to current line - $currentLine .= trim($line); - } elseif (preg_match('/^\s*$/', $line)) { - // empty line indicates end of headers - break; - } else { - // Line does not match header format! - throw new Exception\RuntimeException(sprintf( - 'Line "%s"does not match header format!', - $line - )); + continue; } + + // continuation: append to current line + // recover the whitespace that break the line (unfolding, rfc2822#section-2.2.3) + if (preg_match('/^\s+.*$/', $line)) { + $currentLine .= ' ' . trim($line); + continue; + } + + // Line does not match header format! + throw new Exception\RuntimeException(sprintf( + 'Line "%s"does not match header format!', + $line + )); } if ($currentLine) { $headers->addHeaderLine($currentLine); @@ -199,7 +220,9 @@ class Headers implements Countable, Iterator if (!is_string($headerFieldNameOrLine)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects its first argument to be a string; received "%s"', - (is_object($headerFieldNameOrLine) ? get_class($headerFieldNameOrLine) : gettype($headerFieldNameOrLine)) + (is_object($headerFieldNameOrLine) + ? get_class($headerFieldNameOrLine) + : gettype($headerFieldNameOrLine)) )); } @@ -207,10 +230,10 @@ class Headers implements Countable, Iterator $this->addHeader(Header\GenericHeader::fromString($headerFieldNameOrLine)); } elseif (is_array($fieldValue)) { foreach ($fieldValue as $i) { - $this->addHeader(new Header\GenericMultiHeader($headerFieldNameOrLine, $i)); + $this->addHeader(Header\GenericMultiHeader::fromString($headerFieldNameOrLine . ':' . $i)); } } else { - $this->addHeader(new Header\GenericHeader($headerFieldNameOrLine, $fieldValue)); + $this->addHeader(Header\GenericHeader::fromString($headerFieldNameOrLine . ':' . $fieldValue)); } return $this; @@ -250,8 +273,8 @@ class Headers implements Countable, Iterator if (!empty($indexes)) { foreach ($indexes as $index) { - unset ($this->headersKeys[$index]); - unset ($this->headers[$index]); + unset($this->headersKeys[$index]); + unset($this->headers[$index]); } return true; } @@ -302,6 +325,7 @@ class Headers implements Countable, Iterator } else { return $results[0]; } + //fall-trough default: return new ArrayIterator($results); } @@ -447,8 +471,7 @@ class Headers implements Countable, Iterator { $current = $this->headers[$index]; - $key = $this->headersKeys[$index]; - /* @var $class Header\HeaderInterface */ + $key = $this->headersKeys[$index]; $class = ($this->getPluginClassLoader()->load($key)) ?: 'Zend\Mail\Header\GenericHeader'; $encoding = $current->getEncoding(); diff --git a/library/Zend/Mail/Message.php b/library/Zend/Mail/Message.php index a820bc8a..e16c2438 100644 --- a/library/Zend/Mail/Message.php +++ b/library/Zend/Mail/Message.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -346,7 +346,7 @@ class Message { $headers = $this->getHeaders(); if (!$headers->has('subject')) { - return null; + return; } $header = $headers->get('subject'); return $header->getFieldValue(); @@ -372,7 +372,8 @@ class Message if (!$body instanceof Mime\Message) { if (!method_exists($body, '__toString')) { throw new Exception\InvalidArgumentException(sprintf( - '%s expects object arguments of type Zend\Mime\Message or implementing __toString(); object of type "%s" received', + '%s expects object arguments of type Zend\Mime\Message or implementing __toString();' + . ' object of type "%s" received', __METHOD__, get_class($body) )); @@ -402,7 +403,7 @@ class Message $parts = $this->body->getParts(); if (!empty($parts)) { $part = array_shift($parts); - $headers->addHeaders($part->getHeadersArray()); + $headers->addHeaders($part->getHeadersArray("\r\n")); } return $this; } @@ -510,11 +511,18 @@ class Message } if (!is_string($emailOrAddressOrList) && !$emailOrAddressOrList instanceof Address\AddressInterface) { throw new Exception\InvalidArgumentException(sprintf( - '%s expects a string, AddressInterface, array, AddressList, or Traversable as its first argument; received "%s"', + '%s expects a string, AddressInterface, array, AddressList, or Traversable as its first argument;' + . ' received "%s"', $callingMethod, (is_object($emailOrAddressOrList) ? get_class($emailOrAddressOrList) : gettype($emailOrAddressOrList)) )); } + + if (is_string($emailOrAddressOrList) && $name === null) { + $addressList->addFromString($emailOrAddressOrList); + return; + } + $addressList->add($emailOrAddressOrList, $name); } diff --git a/library/Zend/Mail/MessageFactory.php b/library/Zend/Mail/MessageFactory.php new file mode 100644 index 00000000..9a9af88a --- /dev/null +++ b/library/Zend/Mail/MessageFactory.php @@ -0,0 +1,65 @@ + $value) { + $setter = self::getSetterMethod($key); + if (method_exists($message, $setter)) { + $message->{$setter}($value); + } + } + + return $message; + } + + /** + * Generate a setter method name based on a provided key. + * + * @param string $key + * @return string + */ + private static function getSetterMethod($key) + { + return 'set' + . str_replace( + ' ', + '', + ucwords( + strtr( + $key, + array( + '-' => ' ', + '_' => ' ', + ) + ) + ) + ); + } +} diff --git a/library/Zend/Mail/Protocol/AbstractProtocol.php b/library/Zend/Mail/Protocol/AbstractProtocol.php index 3f8d4c1c..af472078 100644 --- a/library/Zend/Mail/Protocol/AbstractProtocol.php +++ b/library/Zend/Mail/Protocol/AbstractProtocol.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,6 @@ abstract class AbstractProtocol */ const EOL = "\r\n"; - /** * Default timeout in seconds for initiating session */ @@ -35,56 +34,48 @@ abstract class AbstractProtocol */ protected $maximumLog = 64; - /** * Hostname or IP address of remote server * @var string */ protected $host; - /** * Port number of connection * @var int */ protected $port; - /** * Instance of Zend\Validator\ValidatorChain to check hostnames * @var \Zend\Validator\ValidatorChain */ protected $validHost; - /** * Socket connection resource * @var resource */ protected $socket; - /** * Last request sent to server * @var string */ protected $request; - /** * Array of server responses to last request * @var array */ protected $response; - /** * Log of mail requests and server responses for a session * @var array */ private $log = array(); - /** * Constructor. * @@ -105,7 +96,6 @@ abstract class AbstractProtocol $this->port = $port; } - /** * Class destructor to cleanup open resources * @@ -125,7 +115,6 @@ abstract class AbstractProtocol $this->maximumLog = (int) $maximumLog; } - /** * Get the maximum log size * @@ -136,7 +125,6 @@ abstract class AbstractProtocol return $this->maximumLog; } - /** * Create a connection to the remote host * @@ -144,7 +132,6 @@ abstract class AbstractProtocol */ abstract public function connect(); - /** * Retrieve the last client request * @@ -155,7 +142,6 @@ abstract class AbstractProtocol return $this->request; } - /** * Retrieve the last server response * @@ -166,7 +152,6 @@ abstract class AbstractProtocol return $this->response; } - /** * Retrieve the transaction log * @@ -177,7 +162,6 @@ abstract class AbstractProtocol return implode('', $this->log); } - /** * Reset the transaction log * @@ -232,7 +216,6 @@ abstract class AbstractProtocol return $result; } - /** * Disconnect from remote host and free resource * @@ -244,7 +227,6 @@ abstract class AbstractProtocol } } - /** * Send the given request followed by a LINEEND to the server. * @@ -272,7 +254,6 @@ abstract class AbstractProtocol return $result; } - /** * Get a line from the stream. * @@ -311,7 +292,6 @@ abstract class AbstractProtocol return $response; } - /** * Parse server response for successful codes * diff --git a/library/Zend/Mail/Protocol/Exception/ExceptionInterface.php b/library/Zend/Mail/Protocol/Exception/ExceptionInterface.php index a19ba3a3..3ec5ce25 100644 --- a/library/Zend/Mail/Protocol/Exception/ExceptionInterface.php +++ b/library/Zend/Mail/Protocol/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Protocol/Exception/InvalidArgumentException.php b/library/Zend/Mail/Protocol/Exception/InvalidArgumentException.php index a93b3a9b..f49618df 100644 --- a/library/Zend/Mail/Protocol/Exception/InvalidArgumentException.php +++ b/library/Zend/Mail/Protocol/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Protocol/Exception/RuntimeException.php b/library/Zend/Mail/Protocol/Exception/RuntimeException.php index db1d48d4..1b9e1923 100644 --- a/library/Zend/Mail/Protocol/Exception/RuntimeException.php +++ b/library/Zend/Mail/Protocol/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Protocol/Imap.php b/library/Zend/Mail/Protocol/Imap.php index df9365a1..53eb3baf 100644 --- a/library/Zend/Mail/Protocol/Imap.php +++ b/library/Zend/Mail/Protocol/Imap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -299,7 +299,7 @@ class Imap } elseif ($tokens[0] == 'NO') { return false; } - return null; + return; } /** @@ -429,7 +429,6 @@ class Imap return $result; } - /** * Get capabilities from IMAP server * @@ -586,7 +585,8 @@ class Imap // if we want only one message we can ignore everything else and just return if ($to === null && !is_array($from) && $tokens[0] == $from) { // we still need to read all lines - while (!$this->readLine($tokens, $tag)); + while (!$this->readLine($tokens, $tag)) { + } return $data; } $result[$tokens[0]] = $data; @@ -651,14 +651,14 @@ class Imap $flags = $this->escapeList($flags); $set = (int) $from; - if ($to != null) { + if ($to !== null) { $set .= ':' . ($to == INF ? '*' : (int) $to); } $result = $this->requestAndResponse('STORE', array($set, $item, $flags), $silent); if ($silent) { - return $result ? true : false; + return (bool) $result; } $tokens = $result; @@ -710,7 +710,7 @@ class Imap public function copy($folder, $from, $to = null) { $set = (int) $from; - if ($to != null) { + if ($to !== null) { $set .= ':' . ($to == INF ? '*' : (int) $to); } @@ -751,6 +751,17 @@ class Imap return $this->requestAndResponse('DELETE', array($this->escapeString($folder)), true); } + /** + * subscribe to a folder + * + * @param string $folder folder name + * @return bool success + */ + public function subscribe($folder) + { + return $this->requestAndResponse('SUBSCRIBE', array($this->escapeString($folder)), true); + } + /** * permanently remove messages * diff --git a/library/Zend/Mail/Protocol/Pop3.php b/library/Zend/Mail/Protocol/Pop3.php index 2722a128..6a9eb141 100644 --- a/library/Zend/Mail/Protocol/Pop3.php +++ b/library/Zend/Mail/Protocol/Pop3.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -36,7 +36,6 @@ class Pop3 */ protected $timestamp; - /** * Public constructor * @@ -51,7 +50,6 @@ class Pop3 } } - /** * Public destructor */ @@ -60,7 +58,6 @@ class Pop3 $this->logout(); } - /** * Open connection to POP3 server * @@ -125,7 +122,6 @@ class Pop3 return $welcome; } - /** * Send a request * @@ -142,7 +138,6 @@ class Pop3 } } - /** * read a response * @@ -186,7 +181,6 @@ class Pop3 return $message; } - /** * Send request and get response * @@ -202,7 +196,6 @@ class Pop3 return $this->readResponse($multiline); } - /** * End communication with POP3 server (also closes socket) */ @@ -372,7 +365,6 @@ class Pop3 return $result; } - /** * Make a RETR call for retrieving a full message with headers and body * @@ -393,7 +385,6 @@ class Pop3 $this->request('NOOP'); } - /** * Make a DELE count to remove a message * @@ -404,7 +395,6 @@ class Pop3 $this->request("DELE $msgno"); } - /** * Make RSET call, which rollbacks delete requests */ diff --git a/library/Zend/Mail/Protocol/Smtp.php b/library/Zend/Mail/Protocol/Smtp.php index 21506530..d542c79a 100644 --- a/library/Zend/Mail/Protocol/Smtp.php +++ b/library/Zend/Mail/Protocol/Smtp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,6 @@ class Smtp extends AbstractProtocol */ protected $transport = 'tcp'; - /** * Indicates that a session is requested to be secure * @@ -31,7 +30,6 @@ class Smtp extends AbstractProtocol */ protected $secure; - /** * Indicates an smtp session has been started by the HELO command * @@ -39,7 +37,6 @@ class Smtp extends AbstractProtocol */ protected $sess = false; - /** * Indicates an smtp AUTH has been issued and authenticated * @@ -47,7 +44,6 @@ class Smtp extends AbstractProtocol */ protected $auth = false; - /** * Indicates a MAIL command has been issued * @@ -55,7 +51,6 @@ class Smtp extends AbstractProtocol */ protected $mail = false; - /** * Indicates one or more RCTP commands have been issued * @@ -63,7 +58,6 @@ class Smtp extends AbstractProtocol */ protected $rcpt = false; - /** * Indicates that DATA has been issued and sent * @@ -71,7 +65,6 @@ class Smtp extends AbstractProtocol */ protected $data = null; - /** * Constructor. * @@ -124,19 +117,18 @@ class Smtp extends AbstractProtocol case 'ssl': $this->transport = 'ssl'; $this->secure = 'ssl'; - if ($port == null) { + if ($port === null) { $port = 465; } break; default: throw new Exception\InvalidArgumentException($config['ssl'] . ' is unsupported SSL type'); - break; } } // If no port has been specified then check the master PHP ini file. Defaults to 25 if the ini setting is null. - if ($port == null) { + if ($port === null) { if (($port = ini_get('smtp_port')) == '') { $port = 25; } @@ -282,9 +274,7 @@ class Smtp extends AbstractProtocol $this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2 // Ensure newlines are CRLF (\r\n) - if (PHP_EOL === "\n") { - $data = str_replace("\n", "\r\n", str_replace("\r", '', $data)); - } + $data = str_replace("\n", "\r\n", str_replace("\r", '', $data)); foreach (explode(self::EOL, $data) as $line) { if (strpos($line, '.') === 0) { @@ -317,7 +307,6 @@ class Smtp extends AbstractProtocol $this->data = false; } - /** * Issues the NOOP command end validates answer * @@ -330,7 +319,6 @@ class Smtp extends AbstractProtocol $this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 } - /** * Issues the VRFY command end validates answer * @@ -344,7 +332,6 @@ class Smtp extends AbstractProtocol $this->_expect(array(250, 251, 252), 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 } - /** * Issues the QUIT command and clears the current session * @@ -359,7 +346,6 @@ class Smtp extends AbstractProtocol } } - /** * Default authentication method * @@ -374,7 +360,6 @@ class Smtp extends AbstractProtocol } } - /** * Closes connection * @@ -403,7 +388,6 @@ class Smtp extends AbstractProtocol $this->sess = true; } - /** * Stop mail session * diff --git a/library/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php b/library/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php index 9666df10..c3bd3a0c 100644 --- a/library/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php +++ b/library/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -22,13 +22,11 @@ class Crammd5 extends Smtp */ protected $username; - /** * @var string */ protected $password; - /** * Constructor. * @@ -65,7 +63,6 @@ class Crammd5 extends Smtp parent::__construct($host, $port, $origConfig); } - /** * Performs CRAM-MD5 authentication with supplied credentials */ diff --git a/library/Zend/Mail/Protocol/Smtp/Auth/Login.php b/library/Zend/Mail/Protocol/Smtp/Auth/Login.php index 79158e67..b5dba8fc 100644 --- a/library/Zend/Mail/Protocol/Smtp/Auth/Login.php +++ b/library/Zend/Mail/Protocol/Smtp/Auth/Login.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,6 @@ class Login extends Smtp */ protected $username; - /** * LOGIN password * @@ -31,7 +30,6 @@ class Login extends Smtp */ protected $password; - /** * Constructor. * @@ -65,7 +63,6 @@ class Login extends Smtp parent::__construct($host, $port, $origConfig); } - /** * Perform LOGIN authentication with supplied credentials * diff --git a/library/Zend/Mail/Protocol/Smtp/Auth/Plain.php b/library/Zend/Mail/Protocol/Smtp/Auth/Plain.php index 335ba407..7011aeff 100644 --- a/library/Zend/Mail/Protocol/Smtp/Auth/Plain.php +++ b/library/Zend/Mail/Protocol/Smtp/Auth/Plain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,6 @@ class Plain extends Smtp */ protected $username; - /** * PLAIN password * @@ -31,7 +30,6 @@ class Plain extends Smtp */ protected $password; - /** * Constructor. * @@ -65,7 +63,6 @@ class Plain extends Smtp parent::__construct($host, $port, $origConfig); } - /** * Perform PLAIN authentication with supplied credentials * diff --git a/library/Zend/Mail/Protocol/SmtpPluginManager.php b/library/Zend/Mail/Protocol/SmtpPluginManager.php index b84272b2..898fd47b 100644 --- a/library/Zend/Mail/Protocol/SmtpPluginManager.php +++ b/library/Zend/Mail/Protocol/SmtpPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Storage.php b/library/Zend/Mail/Storage.php index bcad4e36..934589c5 100644 --- a/library/Zend/Mail/Storage.php +++ b/library/Zend/Mail/Storage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,6 +15,7 @@ class Storage // system flags and other flags const FLAG_PASSED = 'Passed'; const FLAG_SEEN = '\Seen'; + const FLAG_UNSEEN = '\Unseen'; const FLAG_ANSWERED = '\Answered'; const FLAG_FLAGGED = '\Flagged'; const FLAG_DELETED = '\Deleted'; diff --git a/library/Zend/Mail/Storage/AbstractStorage.php b/library/Zend/Mail/Storage/AbstractStorage.php index 7ebf74c2..36bec3c6 100644 --- a/library/Zend/Mail/Storage/AbstractStorage.php +++ b/library/Zend/Mail/Storage/AbstractStorage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -70,7 +70,6 @@ abstract class AbstractStorage implements throw new Exception\InvalidArgumentException($var . ' not found'); } - /** * Get a full list of features supported by the specific mail lib and the server * @@ -81,7 +80,6 @@ abstract class AbstractStorage implements return $this->has; } - /** * Count messages messages in current box/folder * @@ -90,7 +88,6 @@ abstract class AbstractStorage implements */ abstract public function countMessages(); - /** * Get a list of messages with number and size * @@ -99,7 +96,6 @@ abstract class AbstractStorage implements */ abstract public function getSize($id = 0); - /** * Get a message with headers and body * @@ -108,7 +104,6 @@ abstract class AbstractStorage implements */ abstract public function getMessage($id); - /** * Get raw header of message or part * @@ -136,7 +131,6 @@ abstract class AbstractStorage implements */ abstract public function __construct($params); - /** * Destructor calls close() and therefore closes the resource. */ @@ -145,14 +139,12 @@ abstract class AbstractStorage implements $this->close(); } - /** * Close resource for mail lib. If you need to control, when the resource * is closed. Otherwise the destructor would call this. */ abstract public function close(); - /** * Keep the resource alive. */ @@ -195,42 +187,39 @@ abstract class AbstractStorage implements * * @return int */ - public function count() - { - return $this->countMessages(); - } + public function count() + { + return $this->countMessages(); + } + /** + * ArrayAccess::offsetExists() + * + * @param int $id + * @return bool + */ + public function offsetExists($id) + { + try { + if ($this->getMessage($id)) { + return true; + } + } catch (Exception\ExceptionInterface $e) { + } - /** - * ArrayAccess::offsetExists() - * - * @param int $id - * @return bool - */ - public function offsetExists($id) - { - try { - if ($this->getMessage($id)) { - return true; - } - } catch (Exception\ExceptionInterface $e) { - } - - return false; - } - - - /** - * ArrayAccess::offsetGet() - * - * @param int $id - * @return \Zend\Mail\Storage\Message message object - */ - public function offsetGet($id) - { - return $this->getMessage($id); - } + return false; + } + /** + * ArrayAccess::offsetGet() + * + * @param int $id + * @return \Zend\Mail\Storage\Message message object + */ + public function offsetGet($id) + { + return $this->getMessage($id); + } /** * ArrayAccess::offsetSet() @@ -239,98 +228,91 @@ abstract class AbstractStorage implements * @param mixed $value * @throws Exception\RuntimeException */ - public function offsetSet($id, $value) - { - throw new Exception\RuntimeException('cannot write mail messages via array access'); - } + public function offsetSet($id, $value) + { + throw new Exception\RuntimeException('cannot write mail messages via array access'); + } + /** + * ArrayAccess::offsetUnset() + * + * @param int $id + * @return bool success + */ + public function offsetUnset($id) + { + return $this->removeMessage($id); + } - /** - * ArrayAccess::offsetUnset() - * - * @param int $id - * @return bool success - */ - public function offsetUnset($id) - { - return $this->removeMessage($id); - } + /** + * Iterator::rewind() + * + * Rewind always gets the new count from the storage. Thus if you use + * the interfaces and your scripts take long you should use reset() + * from time to time. + */ + public function rewind() + { + $this->iterationMax = $this->countMessages(); + $this->iterationPos = 1; + } + /** + * Iterator::current() + * + * @return Message current message + */ + public function current() + { + return $this->getMessage($this->iterationPos); + } - /** - * Iterator::rewind() - * - * Rewind always gets the new count from the storage. Thus if you use - * the interfaces and your scripts take long you should use reset() - * from time to time. - */ - public function rewind() - { - $this->iterationMax = $this->countMessages(); - $this->iterationPos = 1; - } + /** + * Iterator::key() + * + * @return int id of current position + */ + public function key() + { + return $this->iterationPos; + } + /** + * Iterator::next() + */ + public function next() + { + ++$this->iterationPos; + } - /** - * Iterator::current() - * - * @return Message current message - */ - public function current() - { - return $this->getMessage($this->iterationPos); - } + /** + * Iterator::valid() + * + * @return bool + */ + public function valid() + { + if ($this->iterationMax === null) { + $this->iterationMax = $this->countMessages(); + } + return $this->iterationPos && $this->iterationPos <= $this->iterationMax; + } + /** + * SeekableIterator::seek() + * + * @param int $pos + * @throws Exception\OutOfBoundsException + */ + public function seek($pos) + { + if ($this->iterationMax === null) { + $this->iterationMax = $this->countMessages(); + } - /** - * Iterator::key() - * - * @return int id of current position - */ - public function key() - { - return $this->iterationPos; - } - - - /** - * Iterator::next() - */ - public function next() - { - ++$this->iterationPos; - } - - - /** - * Iterator::valid() - * - * @return bool - */ - public function valid() - { - if ($this->iterationMax === null) { - $this->iterationMax = $this->countMessages(); - } - return $this->iterationPos && $this->iterationPos <= $this->iterationMax; - } - - - /** - * SeekableIterator::seek() - * - * @param int $pos - * @throws Exception\OutOfBoundsException - */ - public function seek($pos) - { - if ($this->iterationMax === null) { - $this->iterationMax = $this->countMessages(); - } - - if ($pos > $this->iterationMax) { - throw new Exception\OutOfBoundsException('this position does not exist'); - } - $this->iterationPos = $pos; - } + if ($pos > $this->iterationMax) { + throw new Exception\OutOfBoundsException('this position does not exist'); + } + $this->iterationPos = $pos; + } } diff --git a/library/Zend/Mail/Storage/Exception/ExceptionInterface.php b/library/Zend/Mail/Storage/Exception/ExceptionInterface.php index 630637c3..923dd1b8 100644 --- a/library/Zend/Mail/Storage/Exception/ExceptionInterface.php +++ b/library/Zend/Mail/Storage/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Storage/Exception/InvalidArgumentException.php b/library/Zend/Mail/Storage/Exception/InvalidArgumentException.php index 768de067..64c8dc94 100644 --- a/library/Zend/Mail/Storage/Exception/InvalidArgumentException.php +++ b/library/Zend/Mail/Storage/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Storage/Exception/OutOfBoundsException.php b/library/Zend/Mail/Storage/Exception/OutOfBoundsException.php index fae5f1e8..d86c16ac 100644 --- a/library/Zend/Mail/Storage/Exception/OutOfBoundsException.php +++ b/library/Zend/Mail/Storage/Exception/OutOfBoundsException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class OutOfBoundsException extends Exception\OutOfBoundsException implements - ExceptionInterface +class OutOfBoundsException extends Exception\OutOfBoundsException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Storage/Exception/RuntimeException.php b/library/Zend/Mail/Storage/Exception/RuntimeException.php index d44af131..281ae1b9 100644 --- a/library/Zend/Mail/Storage/Exception/RuntimeException.php +++ b/library/Zend/Mail/Storage/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Storage/Folder.php b/library/Zend/Mail/Storage/Folder.php index 4d5c316e..6ccb5d65 100644 --- a/library/Zend/Mail/Storage/Folder.php +++ b/library/Zend/Mail/Storage/Folder.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Storage/Folder/FolderInterface.php b/library/Zend/Mail/Storage/Folder/FolderInterface.php index d334f45c..a3d05f1b 100644 --- a/library/Zend/Mail/Storage/Folder/FolderInterface.php +++ b/library/Zend/Mail/Storage/Folder/FolderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,6 @@ interface FolderInterface */ public function selectFolder($globalName); - /** * get Zend\Mail\Storage\Folder instance for current folder * diff --git a/library/Zend/Mail/Storage/Folder/Maildir.php b/library/Zend/Mail/Storage/Folder/Maildir.php index 2c7996c2..876bccb3 100644 --- a/library/Zend/Mail/Storage/Folder/Maildir.php +++ b/library/Zend/Mail/Storage/Folder/Maildir.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -193,8 +193,11 @@ class Maildir extends Storage\Maildir implements FolderInterface } // seems like file has vanished; rebuilding folder tree - but it's still an exception $this->_buildFolderTree(); - throw new Exception\RuntimeException('seems like the maildir has vanished, I\'ve rebuild the ' . - 'folder tree, search for an other folder and try again', 0, $e); + throw new Exception\RuntimeException( + 'seems like the maildir has vanished, I\'ve rebuild the folder tree, search for an other folder and try again', + 0, + $e + ); } } diff --git a/library/Zend/Mail/Storage/Folder/Mbox.php b/library/Zend/Mail/Storage/Folder/Mbox.php index ffc536dc..29445d71 100644 --- a/library/Zend/Mail/Storage/Folder/Mbox.php +++ b/library/Zend/Mail/Storage/Folder/Mbox.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -168,8 +168,11 @@ class Mbox extends Storage\Mbox implements FolderInterface } // seems like file has vanished; rebuilding folder tree - but it's still an exception $this->_buildFolderTree($this->rootdir); - throw new Exception\RuntimeException('seems like the mbox file has vanished, I\'ve rebuild the ' . - 'folder tree, search for an other folder and try again', 0, $e); + throw new Exception\RuntimeException( + 'seems like the mbox file has vanished, I\'ve rebuild the folder tree, search for an other folder and try again', + 0, + $e + ); } } diff --git a/library/Zend/Mail/Storage/Imap.php b/library/Zend/Mail/Storage/Imap.php index 93a3cfef..142f8624 100644 --- a/library/Zend/Mail/Storage/Imap.php +++ b/library/Zend/Mail/Storage/Imap.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -36,6 +36,7 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W protected static $knownFlags = array('\Passed' => Mail\Storage::FLAG_PASSED, '\Answered' => Mail\Storage::FLAG_ANSWERED, '\Seen' => Mail\Storage::FLAG_SEEN, + '\Unseen' => Mail\Storage::FLAG_UNSEEN, '\Deleted' => Mail\Storage::FLAG_DELETED, '\Draft' => Mail\Storage::FLAG_DRAFT, '\Flagged' => Mail\Storage::FLAG_FLAGGED); @@ -47,6 +48,7 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W protected static $searchFlags = array('\Recent' => 'RECENT', '\Answered' => 'ANSWERED', '\Seen' => 'SEEN', + '\Unseen' => 'UNSEEN', '\Deleted' => 'DELETED', '\Draft' => 'DRAFT', '\Flagged' => 'FLAGGED'); @@ -289,7 +291,6 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W throw new Exception\InvalidArgumentException('unique id not found'); } - /** * get root folder or given folder * @@ -362,7 +363,6 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W } } - /** * get \Zend\Mail\Storage\Folder instance for current folder * @@ -388,7 +388,7 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W // TODO: we assume / as the hierarchy delim - need to get that from the folder class! if ($parentFolder instanceof Folder) { $folder = $parentFolder->getGlobalName() . '/' . $name; - } elseif ($parentFolder != null) { + } elseif ($parentFolder !== null) { $folder = $parentFolder . '/' . $name; } else { $folder = $name; @@ -444,7 +444,6 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W * @param null|array $flags set flags for new message, else a default set is used * @throws Exception\RuntimeException */ - // not yet * @param string|\Zend\Mail\Message|\Zend\Mime\Message $message message as string or instance of message class public function appendMessage($message, $folder = null, $flags = null) { if ($folder === null) { diff --git a/library/Zend/Mail/Storage/Maildir.php b/library/Zend/Mail/Storage/Maildir.php index ad995229..02f81e92 100644 --- a/library/Zend/Mail/Storage/Maildir.php +++ b/library/Zend/Mail/Storage/Maildir.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -122,8 +122,6 @@ class Maildir extends AbstractStorage return $result; } - - /** * Fetch a message * @@ -330,7 +328,6 @@ class Maildir extends AbstractStorage } } - /** * Close resource for mail lib. If you need to control, when the resource * is closed. Otherwise the destructor would call this. @@ -341,7 +338,6 @@ class Maildir extends AbstractStorage $this->files = array(); } - /** * Waste some CPU cycles doing nothing. * @@ -352,7 +348,6 @@ class Maildir extends AbstractStorage return true; } - /** * stub for not supported message deletion * diff --git a/library/Zend/Mail/Storage/Mbox.php b/library/Zend/Mail/Storage/Mbox.php index 847c3c0e..e542b84d 100644 --- a/library/Zend/Mail/Storage/Mbox.php +++ b/library/Zend/Mail/Storage/Mbox.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -43,6 +43,13 @@ class Mbox extends AbstractStorage */ protected $messageClass = '\Zend\Mail\Storage\Message\File'; + /** + * end of Line for messages + * + * @var string|null + */ + protected $messageEOL; + /** * Count messages all messages in current box * @@ -54,7 +61,6 @@ class Mbox extends AbstractStorage return count($this->positions); } - /** * Get a list of messages with number and size * @@ -76,7 +82,6 @@ class Mbox extends AbstractStorage return $result; } - /** * Get positions for mail message or throw exception if id is invalid * @@ -93,7 +98,6 @@ class Mbox extends AbstractStorage return $this->positions[$id - 1]; } - /** * Fetch a message * @@ -108,8 +112,18 @@ class Mbox extends AbstractStorage || is_subclass_of($this->messageClass, '\Zend\Mail\Storage\Message\File')) { // TODO top/body lines $messagePos = $this->getPos($id); - return new $this->messageClass(array('file' => $this->fh, 'startPos' => $messagePos['start'], - 'endPos' => $messagePos['end'])); + + $messageClassParams = array( + 'file' => $this->fh, + 'startPos' => $messagePos['start'], + 'endPos' => $messagePos['end'] + ); + + if (isset($this->messageEOL)) { + $messageClassParams['EOL'] = $this->messageEOL; + } + + return new $this->messageClass($messageClassParams); } $bodyLines = 0; // TODO: need a way to change that @@ -184,6 +198,10 @@ class Mbox extends AbstractStorage throw new Exception\InvalidArgumentException('no valid filename given in params'); } + if (isset($params->messageEOL)) { + $this->messageEOL = (string) $params->messageEOL; + } + $this->openMboxFile($params->filename); $this->has['top'] = true; $this->has['uniqueid'] = false; @@ -213,7 +231,7 @@ class Mbox extends AbstractStorage $result = false; - $line = fgets($file); + $line = fgets($file) ?: ''; if (strpos($line, 'From ') === 0) { $result = true; } diff --git a/library/Zend/Mail/Storage/Message.php b/library/Zend/Mail/Storage/Message.php index 53c858f7..a7eb3d38 100644 --- a/library/Zend/Mail/Storage/Message.php +++ b/library/Zend/Mail/Storage/Message.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -42,6 +42,8 @@ class Message extends Part implements Message\MessageInterface } else { $params['raw'] = stream_get_contents($params['file']); } + + $params['raw'] = ltrim($params['raw']); } if (!empty($params['flags'])) { diff --git a/library/Zend/Mail/Storage/Message/File.php b/library/Zend/Mail/Storage/Message/File.php index 98933dfe..cd9a501f 100644 --- a/library/Zend/Mail/Storage/Message/File.php +++ b/library/Zend/Mail/Storage/Message/File.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Storage/Message/MessageInterface.php b/library/Zend/Mail/Storage/Message/MessageInterface.php index 7dd7067d..80a1bf74 100644 --- a/library/Zend/Mail/Storage/Message/MessageInterface.php +++ b/library/Zend/Mail/Storage/Message/MessageInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Storage/Part.php b/library/Zend/Mail/Storage/Part.php index d46d7d14..26a51127 100644 --- a/library/Zend/Mail/Storage/Part.php +++ b/library/Zend/Mail/Storage/Part.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -349,7 +349,6 @@ class Part implements RecursiveIterator, Part\PartInterface return Mime\Decode::splitHeaderField(current($this->getHeader($name, 'array')), $wantedPart, $firstName); } - /** * Getter for mail headers - name is matched in lowercase * diff --git a/library/Zend/Mail/Storage/Part/Exception/ExceptionInterface.php b/library/Zend/Mail/Storage/Part/Exception/ExceptionInterface.php index d0cfeefb..851d0080 100644 --- a/library/Zend/Mail/Storage/Part/Exception/ExceptionInterface.php +++ b/library/Zend/Mail/Storage/Part/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Storage/Part/Exception/InvalidArgumentException.php b/library/Zend/Mail/Storage/Part/Exception/InvalidArgumentException.php index f918809b..f904c032 100644 --- a/library/Zend/Mail/Storage/Part/Exception/InvalidArgumentException.php +++ b/library/Zend/Mail/Storage/Part/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Storage\Exception; /** * Exception for Zend\Mail component. */ -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Storage/Part/Exception/RuntimeException.php b/library/Zend/Mail/Storage/Part/Exception/RuntimeException.php index 5d1fc5fb..e27d09e4 100644 --- a/library/Zend/Mail/Storage/Part/Exception/RuntimeException.php +++ b/library/Zend/Mail/Storage/Part/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Storage\Exception; /** * Exception for Zend\Mail component. */ -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Storage/Part/File.php b/library/Zend/Mail/Storage/Part/File.php index 154491bf..110205e0 100644 --- a/library/Zend/Mail/Storage/Part/File.php +++ b/library/Zend/Mail/Storage/Part/File.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,6 +25,7 @@ class File extends Part * - file filename or open file handler with message content (required) * - startPos start position of message or part in file (default: current position) * - endPos end position of message or part in file (default: end of file) + * - EOL end of Line for messages * * @param array $params full message with or without headers * @throws Exception\RuntimeException @@ -53,7 +54,11 @@ class File extends Part $header .= $line; } - $this->headers = Headers::fromString($header); + if (isset($params['EOL'])) { + $this->headers = Headers::fromString($header, $params['EOL']); + } else { + $this->headers = Headers::fromString($header); + } $this->contentPos[0] = ftell($this->fh); if ($endPos !== null) { @@ -103,7 +108,6 @@ class File extends Part $this->countParts = count($this->partPos); } - /** * Body of part * diff --git a/library/Zend/Mail/Storage/Part/PartInterface.php b/library/Zend/Mail/Storage/Part/PartInterface.php index d0cd78ef..88224bed 100644 --- a/library/Zend/Mail/Storage/Part/PartInterface.php +++ b/library/Zend/Mail/Storage/Part/PartInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,7 +20,6 @@ interface PartInterface extends RecursiveIterator */ public function isMultipart(); - /** * Body of part * @@ -54,7 +53,6 @@ interface PartInterface extends RecursiveIterator */ public function countParts(); - /** * Get all headers * @@ -95,7 +93,6 @@ interface PartInterface extends RecursiveIterator */ public function getHeaderField($name, $wantedPart = '0', $firstName = '0'); - /** * Getter for mail headers - name is matched in lowercase * diff --git a/library/Zend/Mail/Storage/Pop3.php b/library/Zend/Mail/Storage/Pop3.php index 4e5b698f..53393bdf 100644 --- a/library/Zend/Mail/Storage/Pop3.php +++ b/library/Zend/Mail/Storage/Pop3.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -21,7 +21,6 @@ class Pop3 extends AbstractStorage */ protected $protocol; - /** * Count messages all messages in current box * @@ -271,7 +270,7 @@ class Pop3 extends AbstractStorage } catch (MailException\ExceptionInterface $e) { // ignoring error } - $this->has['uniqueid'] = $id ? true : false; + $this->has['uniqueid'] = (bool) $id; return $this->has['uniqueid']; } diff --git a/library/Zend/Mail/Storage/Writable/Maildir.php b/library/Zend/Mail/Storage/Writable/Maildir.php index e930ea04..c96a9f4a 100644 --- a/library/Zend/Mail/Storage/Writable/Maildir.php +++ b/library/Zend/Mail/Storage/Writable/Maildir.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -107,7 +107,7 @@ class Maildir extends Folder\Maildir implements WritableInterface { if ($parentFolder instanceof Folder) { $folder = $parentFolder->getGlobalName() . $this->delim . $name; - } elseif ($parentFolder != null) { + } elseif ($parentFolder !== null) { $folder = rtrim($parentFolder, $this->delim) . $this->delim . $name; } else { $folder = $name; @@ -379,8 +379,9 @@ class Maildir extends Folder\Maildir implements WritableInterface } if (!$fh) { - throw new StorageException\RuntimeException("tried $maxTries unique ids for a temp file, but all were taken" - . ' - giving up'); + throw new StorageException\RuntimeException( + "tried {$maxTries} unique ids for a temp file, but all were taken - giving up" + ); } return array('dirname' => $this->rootdir . '.' . $folder, @@ -625,7 +626,6 @@ class Maildir extends Folder\Maildir implements WritableInterface $this->files = array_values($this->files); } - /** * set flags for message * @@ -656,7 +656,6 @@ class Maildir extends Folder\Maildir implements WritableInterface $this->files[$id - 1] = $filedata; } - /** * stub for not supported message deletion * @@ -783,7 +782,6 @@ class Maildir extends Folder\Maildir implements WritableInterface continue; } - while (($entry = readdir()) !== false) { if ($entry[0] == '.' || !is_file($dirname . $entry)) { continue; diff --git a/library/Zend/Mail/Storage/Writable/WritableInterface.php b/library/Zend/Mail/Storage/Writable/WritableInterface.php index de00e8b4..2fbbffbb 100644 --- a/library/Zend/Mail/Storage/Writable/WritableInterface.php +++ b/library/Zend/Mail/Storage/Writable/WritableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Transport/Envelope.php b/library/Zend/Mail/Transport/Envelope.php new file mode 100644 index 00000000..eb6d917d --- /dev/null +++ b/library/Zend/Mail/Transport/Envelope.php @@ -0,0 +1,65 @@ +from; + } + + /** + * Set MAIL FROM + * + * @param string $from + */ + public function setFrom($from) + { + $this->from = (string) $from; + } + + /** + * Get RCPT TO + * + * @return string|null + */ + public function getTo() + { + return $this->to; + } + + /** + * Set RCPT TO + * + * @param string $to + */ + public function setTo($to) + { + $this->to = $to; + } +} diff --git a/library/Zend/Mail/Transport/Exception/DomainException.php b/library/Zend/Mail/Transport/Exception/DomainException.php index 908234eb..7ecec702 100644 --- a/library/Zend/Mail/Transport/Exception/DomainException.php +++ b/library/Zend/Mail/Transport/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Transport/Exception/ExceptionInterface.php b/library/Zend/Mail/Transport/Exception/ExceptionInterface.php index db249c65..3b1a56cb 100644 --- a/library/Zend/Mail/Transport/Exception/ExceptionInterface.php +++ b/library/Zend/Mail/Transport/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Transport/Exception/InvalidArgumentException.php b/library/Zend/Mail/Transport/Exception/InvalidArgumentException.php index 8f67c238..40dd3551 100644 --- a/library/Zend/Mail/Transport/Exception/InvalidArgumentException.php +++ b/library/Zend/Mail/Transport/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Transport/Exception/RuntimeException.php b/library/Zend/Mail/Transport/Exception/RuntimeException.php index 258fb628..a14e41b7 100644 --- a/library/Zend/Mail/Transport/Exception/RuntimeException.php +++ b/library/Zend/Mail/Transport/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\Mail\Exception; /** * Exception for Zend\Mail component. */ -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Mail/Transport/Factory.php b/library/Zend/Mail/Transport/Factory.php index b0add594..8840de72 100644 --- a/library/Zend/Mail/Transport/Factory.php +++ b/library/Zend/Mail/Transport/Factory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,7 +19,9 @@ abstract class Factory */ protected static $classMap = array( 'file' => 'Zend\Mail\Transport\File', - 'null' => 'Zend\Mail\Transport\Null', + 'inmemory' => 'Zend\Mail\Transport\InMemory', + 'memory' => 'Zend\Mail\Transport\InMemory', + 'null' => 'Zend\Mail\Transport\InMemory', 'sendmail' => 'Zend\Mail\Transport\Sendmail', 'smtp' => 'Zend\Mail\Transport\Smtp', ); @@ -64,7 +66,8 @@ abstract class Factory if (! $transport instanceof TransportInterface) { throw new Exception\DomainException(sprintf( - '%s expects the "type" attribute to resolve to a valid Zend\Mail\Transport\TransportInterface instance; received "%s"', + '%s expects the "type" attribute to resolve to a valid' + . ' Zend\Mail\Transport\TransportInterface instance; received "%s"', __METHOD__, $type )); diff --git a/library/Zend/Mail/Transport/File.php b/library/Zend/Mail/Transport/File.php index 89143b27..8efd6c88 100644 --- a/library/Zend/Mail/Transport/File.php +++ b/library/Zend/Mail/Transport/File.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Transport/FileOptions.php b/library/Zend/Mail/Transport/FileOptions.php index c58601fc..8ed86296 100644 --- a/library/Zend/Mail/Transport/FileOptions.php +++ b/library/Zend/Mail/Transport/FileOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,7 +15,7 @@ use Zend\Stdlib\AbstractOptions; class FileOptions extends AbstractOptions { /** - * @var string Local client hostname + * @var string Path to stored mail files */ protected $path; @@ -87,7 +87,7 @@ class FileOptions extends AbstractOptions public function getCallback() { if (null === $this->callback) { - $this->setCallback(function ($transport) { + $this->setCallback(function () { return 'ZendMail_' . time() . '_' . mt_rand() . '.eml'; }); } diff --git a/library/Zend/Mail/Transport/InMemory.php b/library/Zend/Mail/Transport/InMemory.php new file mode 100644 index 00000000..de088911 --- /dev/null +++ b/library/Zend/Mail/Transport/InMemory.php @@ -0,0 +1,47 @@ +lastMessage = $message; + } + + /** + * Get the last message sent. + * + * @return Message + */ + public function getLastMessage() + { + return $this->lastMessage; + } +} diff --git a/library/Zend/Mail/Transport/Null.php b/library/Zend/Mail/Transport/Null.php index af0b4097..29f47472 100644 --- a/library/Zend/Mail/Transport/Null.php +++ b/library/Zend/Mail/Transport/Null.php @@ -3,44 +3,33 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mail\Transport; -use Zend\Mail\Message; - /** - * File transport + * Stub class for backwards compatibility. * - * The null transport will just store the message in memory. It is helpful - * when unit testing. + * Since PHP 7 adds "null" as a reserved keyword, we can no longer have a class + * named that and retain PHP 7 compatibility. The original class has been + * renamed to "InMemory", and this class is now an extension of it. It raises an + * E_USER_DEPRECATED to warn users to migrate. + * + * @deprecated */ -class Null implements TransportInterface +class Null extends InMemory { - /** - * @var Message - */ - protected $lastMessage; - - /** - * Takes the last message and Saves it for testing - * - * @param Message $message - */ - public function send(Message $message) + public function __construct() { - $this->lastMessage = $message; - } - - /** - * Get the last message sent - * - * @return Message - */ - public function getLastMessage() - { - return $this->lastMessage; + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\InMemory', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); } } diff --git a/library/Zend/Mail/Transport/Sendmail.php b/library/Zend/Mail/Transport/Sendmail.php index 4905ffc8..6040a211 100644 --- a/library/Zend/Mail/Transport/Sendmail.php +++ b/library/Zend/Mail/Transport/Sendmail.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,6 +14,7 @@ use Zend\Mail; use Zend\Mail\Address\AddressInterface; use Zend\Mail\Exception; use Zend\Mail\Header\HeaderInterface; +use Zend\Mail\Transport\Exception\RuntimeException; /** * Class for sending email via the PHP internal mail() function @@ -184,7 +185,7 @@ class Sendmail implements TransportInterface { $headers = $message->getHeaders(); if (!$headers->has('subject')) { - return null; + return; } $header = $headers->get('subject'); return $header->getFieldValue(HeaderInterface::FORMAT_ENCODED); @@ -226,6 +227,16 @@ class Sendmail implements TransportInterface $headers = clone $message->getHeaders(); $headers->removeHeader('To'); $headers->removeHeader('Subject'); + + // Sanitize the From header + $from = $headers->get('From'); + if ($from) { + foreach ($from->getAddressList() as $address) { + if (preg_match('/\\\"/', $address->getEmail())) { + throw new RuntimeException('Potential code injection in From header'); + } + } + } return $headers->toString(); } @@ -241,7 +252,7 @@ class Sendmail implements TransportInterface protected function prepareParameters(Mail\Message $message) { if ($this->isWindowsOs()) { - return null; + return; } $parameters = (string) $this->parameters; diff --git a/library/Zend/Mail/Transport/Smtp.php b/library/Zend/Mail/Transport/Smtp.php index 62277ef4..30acad58 100644 --- a/library/Zend/Mail/Transport/Smtp.php +++ b/library/Zend/Mail/Transport/Smtp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,6 +27,11 @@ class Smtp implements TransportInterface */ protected $options; + /** + * @var Envelope|null + */ + protected $envelope; + /** * @var Protocol\Smtp */ @@ -77,6 +82,26 @@ class Smtp implements TransportInterface return $this->options; } + /** + * Set options + * + * @param Envelope $envelope + */ + public function setEnvelope(Envelope $envelope) + { + $this->envelope = $envelope; + } + + /** + * Get envelope + * + * @return Envelope|null + */ + public function getEnvelope() + { + return $this->envelope; + } + /** * Set plugin manager for obtaining SMTP protocol connection * @@ -164,7 +189,6 @@ class Smtp implements TransportInterface $this->connection = $connection; } - /** * Gets the connection protocol instance * @@ -215,11 +239,13 @@ class Smtp implements TransportInterface $body = $this->prepareBody($message); if ((count($recipients) == 0) && (!empty($headers) || !empty($body))) { - throw new Exception\RuntimeException( // Per RFC 2821 3.3 (page 18) + // Per RFC 2821 3.3 (page 18) + throw new Exception\RuntimeException( sprintf( '%s transport expects at least one recipient if the message has at least one header or body', __CLASS__ - )); + ) + ); } // Set sender email address @@ -243,13 +269,18 @@ class Smtp implements TransportInterface */ protected function prepareFromAddress(Message $message) { + if ($this->getEnvelope() && $this->getEnvelope()->getFrom()) { + return $this->getEnvelope()->getFrom(); + } + $sender = $message->getSender(); if ($sender instanceof Address\AddressInterface) { return $sender->getEmail(); } $from = $message->getFrom(); - if (!count($from)) { // Per RFC 2822 3.6 + if (!count($from)) { + // Per RFC 2822 3.6 throw new Exception\RuntimeException(sprintf( '%s transport expects either a Sender or at least one From address in the Message; none provided', __CLASS__ @@ -269,6 +300,10 @@ class Smtp implements TransportInterface */ protected function prepareRecipients(Message $message) { + if ($this->getEnvelope() && $this->getEnvelope()->getTo()) { + return (array) $this->getEnvelope()->getTo(); + } + $recipients = array(); foreach ($message->getTo() as $address) { $recipients[] = $address->getEmail(); @@ -279,6 +314,7 @@ class Smtp implements TransportInterface foreach ($message->getBcc() as $address) { $recipients[] = $address->getEmail(); } + $recipients = array_unique($recipients); return $recipients; } diff --git a/library/Zend/Mail/Transport/SmtpOptions.php b/library/Zend/Mail/Transport/SmtpOptions.php index a3039c34..2ce262a6 100644 --- a/library/Zend/Mail/Transport/SmtpOptions.php +++ b/library/Zend/Mail/Transport/SmtpOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/Transport/TransportInterface.php b/library/Zend/Mail/Transport/TransportInterface.php index cded3c6d..6d9fe7d8 100644 --- a/library/Zend/Mail/Transport/TransportInterface.php +++ b/library/Zend/Mail/Transport/TransportInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mail/composer.json b/library/Zend/Mail/composer.json index 57b7f083..a259247e 100644 --- a/library/Zend/Mail/composer.json +++ b/library/Zend/Mail/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Mail\\": "" } }, - "target-dir": "Zend/Mail", "require": { "php": ">=5.3.23", "zendframework/zend-crypt": "self.version", @@ -29,8 +28,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Math/BigInteger/Adapter/AdapterInterface.php b/library/Zend/Math/BigInteger/Adapter/AdapterInterface.php index 6a0eb120..6db40ff1 100644 --- a/library/Zend/Math/BigInteger/Adapter/AdapterInterface.php +++ b/library/Zend/Math/BigInteger/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/BigInteger/Adapter/Bcmath.php b/library/Zend/Math/BigInteger/Adapter/Bcmath.php index d3bc289a..62b68699 100644 --- a/library/Zend/Math/BigInteger/Adapter/Bcmath.php +++ b/library/Zend/Math/BigInteger/Adapter/Bcmath.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -212,7 +212,7 @@ class Bcmath implements AdapterInterface public function intToBin($operand, $twoc = false) { $nb = chr(0); - $isNegative = (strpos($operand, '-') === 0) ? true : false; + $isNegative = (strpos($operand, '-') === 0); $operand = ltrim($operand, '+-0'); if (empty($operand)) { diff --git a/library/Zend/Math/BigInteger/Adapter/Gmp.php b/library/Zend/Math/BigInteger/Adapter/Gmp.php index 830d5071..e29dc9c0 100644 --- a/library/Zend/Math/BigInteger/Adapter/Gmp.php +++ b/library/Zend/Math/BigInteger/Adapter/Gmp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -203,7 +203,7 @@ class Gmp implements AdapterInterface public function intToBin($int, $twoc = false) { $nb = chr(0); - $isNegative = (strpos($int, '-') === 0) ? true : false; + $isNegative = (strpos($int, '-') === 0); $int = ltrim($int, '+-0'); if (empty($int)) { diff --git a/library/Zend/Math/BigInteger/AdapterPluginManager.php b/library/Zend/Math/BigInteger/AdapterPluginManager.php index f86bdb24..4f84e108 100644 --- a/library/Zend/Math/BigInteger/AdapterPluginManager.php +++ b/library/Zend/Math/BigInteger/AdapterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/BigInteger/BigInteger.php b/library/Zend/Math/BigInteger/BigInteger.php index f633b821..7e0c16b8 100644 --- a/library/Zend/Math/BigInteger/BigInteger.php +++ b/library/Zend/Math/BigInteger/BigInteger.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/BigInteger/Exception/DivisionByZeroException.php b/library/Zend/Math/BigInteger/Exception/DivisionByZeroException.php index 878ac7fa..d3323257 100644 --- a/library/Zend/Math/BigInteger/Exception/DivisionByZeroException.php +++ b/library/Zend/Math/BigInteger/Exception/DivisionByZeroException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/BigInteger/Exception/ExceptionInterface.php b/library/Zend/Math/BigInteger/Exception/ExceptionInterface.php index 03e685d9..ea758242 100644 --- a/library/Zend/Math/BigInteger/Exception/ExceptionInterface.php +++ b/library/Zend/Math/BigInteger/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/BigInteger/Exception/InvalidArgumentException.php b/library/Zend/Math/BigInteger/Exception/InvalidArgumentException.php index 03b89202..fc9f3352 100644 --- a/library/Zend/Math/BigInteger/Exception/InvalidArgumentException.php +++ b/library/Zend/Math/BigInteger/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/BigInteger/Exception/RuntimeException.php b/library/Zend/Math/BigInteger/Exception/RuntimeException.php index a8dd99bf..954d3734 100644 --- a/library/Zend/Math/BigInteger/Exception/RuntimeException.php +++ b/library/Zend/Math/BigInteger/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/Exception/DomainException.php b/library/Zend/Math/Exception/DomainException.php index 86f2a215..881bb60e 100644 --- a/library/Zend/Math/Exception/DomainException.php +++ b/library/Zend/Math/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/Exception/ExceptionInterface.php b/library/Zend/Math/Exception/ExceptionInterface.php index ce7c7fa4..d6372640 100644 --- a/library/Zend/Math/Exception/ExceptionInterface.php +++ b/library/Zend/Math/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/Exception/InvalidArgumentException.php b/library/Zend/Math/Exception/InvalidArgumentException.php index fc8ad48a..2c6d7603 100644 --- a/library/Zend/Math/Exception/InvalidArgumentException.php +++ b/library/Zend/Math/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/Exception/RuntimeException.php b/library/Zend/Math/Exception/RuntimeException.php index 27c0d040..d1aca8d9 100644 --- a/library/Zend/Math/Exception/RuntimeException.php +++ b/library/Zend/Math/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Math/Rand.php b/library/Zend/Math/Rand.php index 7ca5523e..7a2095c6 100644 --- a/library/Zend/Math/Rand.php +++ b/library/Zend/Math/Rand.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -39,19 +39,13 @@ abstract class Rand return false; } - if (function_exists('openssl_random_pseudo_bytes') - && ((PHP_VERSION_ID >= 50304) - || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - ) { + if (function_exists('openssl_random_pseudo_bytes')) { $bytes = openssl_random_pseudo_bytes($length, $usable); if (true === $usable) { return $bytes; } } - if (function_exists('mcrypt_create_iv') - && ((PHP_VERSION_ID >= 50307) - || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - ) { + if (function_exists('mcrypt_create_iv')) { $bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); if ($bytes !== false && strlen($bytes) === $length) { return $bytes; @@ -60,7 +54,7 @@ abstract class Rand $checkAlternatives = (file_exists('/dev/urandom') && is_readable('/dev/urandom')) || class_exists('\\COM', false); if (true === $strong && false === $checkAlternatives) { - throw new Exception\RuntimeException ( + throw new Exception\RuntimeException( 'This PHP environment doesn\'t support secure random number generation. ' . 'Please consider installing the OpenSSL and/or Mcrypt extensions' ); diff --git a/library/Zend/Math/Source/HashTiming.php b/library/Zend/Math/Source/HashTiming.php index 22e93bba..a50ce43d 100644 --- a/library/Zend/Math/Source/HashTiming.php +++ b/library/Zend/Math/Source/HashTiming.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Math\Source; diff --git a/library/Zend/Math/composer.json b/library/Zend/Math/composer.json index d818427e..4af34e2a 100644 --- a/library/Zend/Math/composer.json +++ b/library/Zend/Math/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Math\\": "" } }, - "target-dir": "Zend/Math", "require": { "php": ">=5.3.23" }, @@ -24,8 +23,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Memory/Container/AbstractContainer.php b/library/Zend/Memory/Container/AbstractContainer.php index 079bda81..e2a7b081 100644 --- a/library/Zend/Memory/Container/AbstractContainer.php +++ b/library/Zend/Memory/Container/AbstractContainer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Memory/Container/AccessController.php b/library/Zend/Memory/Container/AccessController.php index 47055611..08e4095e 100644 --- a/library/Zend/Memory/Container/AccessController.php +++ b/library/Zend/Memory/Container/AccessController.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,6 @@ class AccessController implements ContainerInterface */ private $memContainer; - /** * Object constructor * @@ -49,7 +48,6 @@ class AccessController implements ContainerInterface $this->memContainer->destroy(); } - /** * Get string value reference * @@ -81,7 +79,6 @@ class AccessController implements ContainerInterface $this->memContainer->lock(); } - /** * Unlock object */ diff --git a/library/Zend/Memory/Container/ContainerInterface.php b/library/Zend/Memory/Container/ContainerInterface.php index fd78a581..4b8311b4 100644 --- a/library/Zend/Memory/Container/ContainerInterface.php +++ b/library/Zend/Memory/Container/ContainerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Memory/Container/Locked.php b/library/Zend/Memory/Container/Locked.php index 12cf62c7..a903139d 100644 --- a/library/Zend/Memory/Container/Locked.php +++ b/library/Zend/Memory/Container/Locked.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,6 @@ class Locked extends AbstractContainer */ public $value; - /** * Object constructor * diff --git a/library/Zend/Memory/Container/Movable.php b/library/Zend/Memory/Container/Movable.php index a45e096a..68ec50ac 100644 --- a/library/Zend/Memory/Container/Movable.php +++ b/library/Zend/Memory/Container/Movable.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -102,7 +102,7 @@ class Movable extends AbstractContainer */ public function isLocked() { - return $this->state & self::LOCKED; + return (bool) ($this->state & self::LOCKED); } /** diff --git a/library/Zend/Memory/Exception/ExceptionInterface.php b/library/Zend/Memory/Exception/ExceptionInterface.php index 775395a2..ad87a42d 100644 --- a/library/Zend/Memory/Exception/ExceptionInterface.php +++ b/library/Zend/Memory/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Memory/Exception/InvalidArgumentException.php b/library/Zend/Memory/Exception/InvalidArgumentException.php index c35534b0..9f9a7675 100644 --- a/library/Zend/Memory/Exception/InvalidArgumentException.php +++ b/library/Zend/Memory/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Memory/Exception/RuntimeException.php b/library/Zend/Memory/Exception/RuntimeException.php index ecf52c07..72e202cc 100644 --- a/library/Zend/Memory/Exception/RuntimeException.php +++ b/library/Zend/Memory/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Memory/MemoryManager.php b/library/Zend/Memory/MemoryManager.php index e4c3df69..d1d5a077 100644 --- a/library/Zend/Memory/MemoryManager.php +++ b/library/Zend/Memory/MemoryManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -222,7 +222,7 @@ class MemoryManager */ public function create($value = '') { - return $this->_create($value, false); + return $this->_create($value, false); } /** diff --git a/library/Zend/Memory/Value.php b/library/Zend/Memory/Value.php index 5615891f..0c5f1837 100644 --- a/library/Zend/Memory/Value.php +++ b/library/Zend/Memory/Value.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -132,7 +132,6 @@ class Value implements ArrayAccess, Countable } } - /** * To string conversion * @@ -143,7 +142,6 @@ class Value implements ArrayAccess, Countable return $this->value; } - /** * Get string value reference * diff --git a/library/Zend/Memory/composer.json b/library/Zend/Memory/composer.json index 1dd9b832..4e6e5284 100644 --- a/library/Zend/Memory/composer.json +++ b/library/Zend/Memory/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Memory\\": "" } }, - "target-dir": "Zend/Memory", "require": { "php": ">=5.3.23" }, @@ -24,8 +23,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Mime/Decode.php b/library/Zend/Mime/Decode.php index 738b877a..db6d2107 100644 --- a/library/Zend/Mime/Decode.php +++ b/library/Zend/Mime/Decode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -73,7 +73,7 @@ class Decode { $parts = static::splitMime($message, $boundary); if (count($parts) <= 0) { - return null; + return; } $result = array(); $headers = null; // "Declare" variable before the first usage "for reading" @@ -188,7 +188,7 @@ class Decode } return substr($matches[2][$key], 1, -1); } - return null; + return; } $split = array(); diff --git a/library/Zend/Mime/Exception/ExceptionInterface.php b/library/Zend/Mime/Exception/ExceptionInterface.php index bee99530..f5ff3c8e 100644 --- a/library/Zend/Mime/Exception/ExceptionInterface.php +++ b/library/Zend/Mime/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mime/Exception/InvalidArgumentException.php b/library/Zend/Mime/Exception/InvalidArgumentException.php new file mode 100644 index 00000000..4da62c8d --- /dev/null +++ b/library/Zend/Mime/Exception/InvalidArgumentException.php @@ -0,0 +1,15 @@ +'); + $properties['id'] = trim($fieldValue, '<>'); break; case 'content-disposition': $properties['disposition'] = $fieldValue; diff --git a/library/Zend/Mime/Mime.php b/library/Zend/Mime/Mime.php index 4223aa61..c7b9f297 100644 --- a/library/Zend/Mime/Mime.php +++ b/library/Zend/Mime/Mime.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -181,28 +181,29 @@ class Mime $str = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $str); // initialize first line, we need it anyways - $lines = array(0 => ""); + $lines = array(0 => ''); // Split encoded text into separate lines - $tmp = ""; + $tmp = ''; while (strlen($str) > 0) { - $currentLine = max(count($lines)-1, 0); + $currentLine = max(count($lines) - 1, 0); $token = static::getNextQuotedPrintableToken($str); - $str = substr($str, strlen($token)); + $substr = substr($str, strlen($token)); + $str = (false === $substr) ? '' : $substr; $tmp .= $token; - if ($token == '=20') { + if ($token === '=20') { // only if we have a single char token or space, we can append the // tempstring it to the current line or start a new line if necessary. if (strlen($lines[$currentLine] . $tmp) > $lineLength) { - $lines[$currentLine+1] = $tmp; + $lines[$currentLine + 1] = $tmp; } else { $lines[$currentLine] .= $tmp; } - $tmp = ""; + $tmp = ''; } // don't forget to append the rest to the last line - if (strlen($str) == 0) { + if (strlen($str) === 0) { $lines[$currentLine] .= $tmp; } } @@ -223,7 +224,7 @@ class Mime */ private static function getNextQuotedPrintableToken($str) { - if (substr($str, 0, 1) == "=") { + if (substr($str, 0, 1) === "=") { $token = substr($str, 0, 3); } else { $token = substr($str, 0, 1); diff --git a/library/Zend/Mime/Part.php b/library/Zend/Mime/Part.php index d4895696..e15381ac 100644 --- a/library/Zend/Mime/Part.php +++ b/library/Zend/Mime/Part.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,16 +28,23 @@ class Part protected $isStream = false; protected $filters = array(); - /** * create a new Mime Part. * The (unencoded) content of the Part as passed * as a string or stream * * @param mixed $content String or Stream containing the content + * @throws Exception\InvalidArgumentException */ - public function __construct($content) + public function __construct($content = '') { + if (! is_string($content) && ! is_resource($content)) { + throw new Exception\InvalidArgumentException(sprintf( + "'%s' must be string or resource", + $content + )); + } + $this->content = $content; if (is_resource($content)) { $this->isStream = true; @@ -45,11 +52,272 @@ class Part } /** - * @todo setters/getters * @todo error checking for setting $type * @todo error checking for setting $encoding */ + /** + * Set type + * @param string $type + * @return self + */ + public function setType($type = Mime::TYPE_OCTETSTREAM) + { + $this->type = $type; + return $this; + } + + /** + * Get type + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set encoding + * @param string $encoding + * @return self + */ + public function setEncoding($encoding = Mime::ENCODING_8BIT) + { + $this->encoding = $encoding; + return $this; + } + + /** + * Get encoding + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * Set id + * @param string $id + * @return self + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * Get id + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Set disposition + * @param string $disposition + * @return self + */ + public function setDisposition($disposition) + { + $this->disposition = $disposition; + return $this; + } + + /** + * Get disposition + * @return string + */ + public function getDisposition() + { + return $this->disposition; + } + + /** + * Set description + * @param string $description + * @return self + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Get description + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set filename + * @param string $fileName + * @return self + */ + public function setFileName($fileName) + { + $this->filename = $fileName; + return $this; + } + + /** + * Get filename + * @return string + */ + public function getFileName() + { + return $this->filename; + } + + /** + * Set charset + * @param string $type + * @return self + */ + public function setCharset($charset) + { + $this->charset = $charset; + return $this; + } + + /** + * Get charset + * @return string + */ + public function getCharset() + { + return $this->charset; + } + + /** + * Set boundary + * @param string $boundary + * @return self + */ + public function setBoundary($boundary) + { + $this->boundary = $boundary; + return $this; + } + + /** + * Get boundary + * @return string + */ + public function getBoundary() + { + return $this->boundary; + } + + /** + * Set location + * @param string $location + * @return self + */ + public function setLocation($location) + { + $this->location = $location; + return $this; + } + + /** + * Get location + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * Set language + * @param string $language + * @return self + */ + public function setLanguage($language) + { + $this->language = $language; + return $this; + } + + /** + * Get language + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Set content + * @param mixed $content String or Stream containing the content + * @throws Exception\InvalidArgumentException + * @return self + */ + public function setContent($content) + { + if (! is_string($content) && ! is_resource($content)) { + throw new Exception\InvalidArgumentException( + "'%s' must be string or resource", + $content + ); + } + $this->content = $content; + if (is_resource($content)) { + $this->isStream = true; + } + + return $this; + } + + /** + * Set isStream + * @param bool $isStream + * @return self + */ + public function setIsStream($isStream = false) + { + $this->isStream = (bool) $isStream; + return $this; + } + + /** + * Get isStream + * @return bool + */ + public function getIsStream() + { + return $this->isStream; + } + + /** + * Set filters + * @param array $filters + * @return self + */ + public function setFilters($filters = array()) + { + $this->filters = $filters; + return $this; + } + + /** + * Get Filters + * @return array + */ + public function getFilters() + { + return $this->filters; + } + /** * check if this part can be read as a stream. * if true, getEncodedStream can be called, otherwise @@ -73,7 +341,7 @@ class Part */ public function getEncodedStream($EOL = Mime::LINEEND) { - if (!$this->isStream) { + if (! $this->isStream) { throw new Exception\RuntimeException('Attempt to get a stream from a string part'); } @@ -93,12 +361,12 @@ class Part ) ); $this->filters[Mime::ENCODING_QUOTEDPRINTABLE] = $filter; - if (!is_resource($filter)) { + if (! is_resource($filter)) { throw new Exception\RuntimeException('Failed to append quoted-printable filter'); } break; case Mime::ENCODING_BASE64: - if (array_key_exists(Mime::ENCODING_BASE64,$this->filters)) { + if (array_key_exists(Mime::ENCODING_BASE64, $this->filters)) { stream_filter_remove($this->filters[Mime::ENCODING_BASE64]); } $filter = stream_filter_append( @@ -111,7 +379,7 @@ class Part ) ); $this->filters[Mime::ENCODING_BASE64] = $filter; - if (!is_resource($filter)) { + if (! is_resource($filter)) { throw new Exception\RuntimeException('Failed to append base64 filter'); } break; diff --git a/library/Zend/Mime/composer.json b/library/Zend/Mime/composer.json index bbbe5fea..315b5359 100644 --- a/library/Zend/Mime/composer.json +++ b/library/Zend/Mime/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Mime\\": "" } }, - "target-dir": "Zend/Mime", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -25,8 +24,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/ModuleManager/Exception/ExceptionInterface.php b/library/Zend/ModuleManager/Exception/ExceptionInterface.php index f673f166..3e784eed 100644 --- a/library/Zend/ModuleManager/Exception/ExceptionInterface.php +++ b/library/Zend/ModuleManager/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Exception/InvalidArgumentException.php b/library/Zend/ModuleManager/Exception/InvalidArgumentException.php index 2616bdcc..0c2752dd 100644 --- a/library/Zend/ModuleManager/Exception/InvalidArgumentException.php +++ b/library/Zend/ModuleManager/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Exception/MissingDependencyModuleException.php b/library/Zend/ModuleManager/Exception/MissingDependencyModuleException.php index add17e8c..a28373b9 100644 --- a/library/Zend/ModuleManager/Exception/MissingDependencyModuleException.php +++ b/library/Zend/ModuleManager/Exception/MissingDependencyModuleException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Exception/RuntimeException.php b/library/Zend/ModuleManager/Exception/RuntimeException.php index 358f5553..d01e905e 100644 --- a/library/Zend/ModuleManager/Exception/RuntimeException.php +++ b/library/Zend/ModuleManager/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/AutoloaderProviderInterface.php b/library/Zend/ModuleManager/Feature/AutoloaderProviderInterface.php index 894ebd40..bb72b389 100644 --- a/library/Zend/ModuleManager/Feature/AutoloaderProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/AutoloaderProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/BootstrapListenerInterface.php b/library/Zend/ModuleManager/Feature/BootstrapListenerInterface.php index e898d61e..5e2ee294 100644 --- a/library/Zend/ModuleManager/Feature/BootstrapListenerInterface.php +++ b/library/Zend/ModuleManager/Feature/BootstrapListenerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/ConfigProviderInterface.php b/library/Zend/ModuleManager/Feature/ConfigProviderInterface.php index 259cb639..0829e652 100644 --- a/library/Zend/ModuleManager/Feature/ConfigProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/ConfigProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/ConsoleBannerProviderInterface.php b/library/Zend/ModuleManager/Feature/ConsoleBannerProviderInterface.php index f1989ab1..3ec2ebd6 100644 --- a/library/Zend/ModuleManager/Feature/ConsoleBannerProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/ConsoleBannerProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/ConsoleUsageProviderInterface.php b/library/Zend/ModuleManager/Feature/ConsoleUsageProviderInterface.php index 610c7580..ebc43344 100644 --- a/library/Zend/ModuleManager/Feature/ConsoleUsageProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/ConsoleUsageProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/ControllerPluginProviderInterface.php b/library/Zend/ModuleManager/Feature/ControllerPluginProviderInterface.php index 1202d10b..e1270ae0 100644 --- a/library/Zend/ModuleManager/Feature/ControllerPluginProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/ControllerPluginProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/ControllerProviderInterface.php b/library/Zend/ModuleManager/Feature/ControllerProviderInterface.php index ccb18c6b..1ff1bd3d 100644 --- a/library/Zend/ModuleManager/Feature/ControllerProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/ControllerProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/DependencyIndicatorInterface.php b/library/Zend/ModuleManager/Feature/DependencyIndicatorInterface.php index 0f851887..c68d1e68 100644 --- a/library/Zend/ModuleManager/Feature/DependencyIndicatorInterface.php +++ b/library/Zend/ModuleManager/Feature/DependencyIndicatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/FilterProviderInterface.php b/library/Zend/ModuleManager/Feature/FilterProviderInterface.php index be1305ee..5b4639a6 100644 --- a/library/Zend/ModuleManager/Feature/FilterProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/FilterProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/FormElementProviderInterface.php b/library/Zend/ModuleManager/Feature/FormElementProviderInterface.php index 364b228d..6f97818a 100644 --- a/library/Zend/ModuleManager/Feature/FormElementProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/FormElementProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/HydratorProviderInterface.php b/library/Zend/ModuleManager/Feature/HydratorProviderInterface.php index 628e5f23..935e1a5d 100644 --- a/library/Zend/ModuleManager/Feature/HydratorProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/HydratorProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/InitProviderInterface.php b/library/Zend/ModuleManager/Feature/InitProviderInterface.php index 61c8da6a..f04c3eb1 100644 --- a/library/Zend/ModuleManager/Feature/InitProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/InitProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/InputFilterProviderInterface.php b/library/Zend/ModuleManager/Feature/InputFilterProviderInterface.php index 5074829f..d84caee6 100644 --- a/library/Zend/ModuleManager/Feature/InputFilterProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/InputFilterProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/LocatorRegisteredInterface.php b/library/Zend/ModuleManager/Feature/LocatorRegisteredInterface.php index 5a85affc..d4578b67 100644 --- a/library/Zend/ModuleManager/Feature/LocatorRegisteredInterface.php +++ b/library/Zend/ModuleManager/Feature/LocatorRegisteredInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/LogProcessorProviderInterface.php b/library/Zend/ModuleManager/Feature/LogProcessorProviderInterface.php index c5561139..4e15d81c 100644 --- a/library/Zend/ModuleManager/Feature/LogProcessorProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/LogProcessorProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/LogWriterProviderInterface.php b/library/Zend/ModuleManager/Feature/LogWriterProviderInterface.php index 251edad1..a81ad545 100644 --- a/library/Zend/ModuleManager/Feature/LogWriterProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/LogWriterProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/RouteProviderInterface.php b/library/Zend/ModuleManager/Feature/RouteProviderInterface.php index 95dbaf9a..af5bcf8e 100644 --- a/library/Zend/ModuleManager/Feature/RouteProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/RouteProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/SerializerProviderInterface.php b/library/Zend/ModuleManager/Feature/SerializerProviderInterface.php index 94e78853..481c28b3 100644 --- a/library/Zend/ModuleManager/Feature/SerializerProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/SerializerProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/ServiceProviderInterface.php b/library/Zend/ModuleManager/Feature/ServiceProviderInterface.php index 91f1f9b4..7fcf922d 100644 --- a/library/Zend/ModuleManager/Feature/ServiceProviderInterface.php +++ b/library/Zend/ModuleManager/Feature/ServiceProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Feature/TranslatorPluginProviderInterface.php b/library/Zend/ModuleManager/Feature/TranslatorPluginProviderInterface.php new file mode 100644 index 00000000..eaca5186 --- /dev/null +++ b/library/Zend/ModuleManager/Feature/TranslatorPluginProviderInterface.php @@ -0,0 +1,21 @@ +paths[] = array('type' => $type, 'path' => $path); @@ -332,9 +340,12 @@ class ConfigListener extends AbstractListener implements if (!is_array($config)) { throw new Exception\InvalidArgumentException( - sprintf('Config being merged must be an array, ' - . 'implement the Traversable interface, or be an ' - . 'instance of Zend\Config\Config. %s given.', gettype($config)) + sprintf( + 'Config being merged must be an array, ' + . 'implement the Traversable interface, or be an ' + . 'instance of Zend\Config\Config. %s given.', + gettype($config) + ) ); } diff --git a/library/Zend/ModuleManager/Listener/ConfigMergerInterface.php b/library/Zend/ModuleManager/Listener/ConfigMergerInterface.php index 9b86a4f9..1b6eb766 100644 --- a/library/Zend/ModuleManager/Listener/ConfigMergerInterface.php +++ b/library/Zend/ModuleManager/Listener/ConfigMergerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/DefaultListenerAggregate.php b/library/Zend/ModuleManager/Listener/DefaultListenerAggregate.php index dae7d5ea..3eaedca5 100644 --- a/library/Zend/ModuleManager/Listener/DefaultListenerAggregate.php +++ b/library/Zend/ModuleManager/Listener/DefaultListenerAggregate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/Exception/ExceptionInterface.php b/library/Zend/ModuleManager/Listener/Exception/ExceptionInterface.php index f52be43d..e988e4f3 100644 --- a/library/Zend/ModuleManager/Listener/Exception/ExceptionInterface.php +++ b/library/Zend/ModuleManager/Listener/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/Exception/InvalidArgumentException.php b/library/Zend/ModuleManager/Listener/Exception/InvalidArgumentException.php index 94d597eb..e8c82cd0 100644 --- a/library/Zend/ModuleManager/Listener/Exception/InvalidArgumentException.php +++ b/library/Zend/ModuleManager/Listener/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/Exception/RuntimeException.php b/library/Zend/ModuleManager/Listener/Exception/RuntimeException.php index b5a2710e..9234a3cc 100644 --- a/library/Zend/ModuleManager/Listener/Exception/RuntimeException.php +++ b/library/Zend/ModuleManager/Listener/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/InitTrigger.php b/library/Zend/ModuleManager/Listener/InitTrigger.php index 884961f8..4487b2e5 100644 --- a/library/Zend/ModuleManager/Listener/InitTrigger.php +++ b/library/Zend/ModuleManager/Listener/InitTrigger.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/ListenerOptions.php b/library/Zend/ModuleManager/Listener/ListenerOptions.php index a32206cd..d6b91607 100644 --- a/library/Zend/ModuleManager/Listener/ListenerOptions.php +++ b/library/Zend/ModuleManager/Listener/ListenerOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -88,10 +88,14 @@ class ListenerOptions extends AbstractOptions { if (!is_array($modulePaths) && !$modulePaths instanceof Traversable) { throw new Exception\InvalidArgumentException( - sprintf('Argument passed to %s::%s() must be an array, ' - . 'implement the Traversable interface, or be an ' - . 'instance of Zend\Config\Config. %s given.', - __CLASS__, __METHOD__, gettype($modulePaths)) + sprintf( + 'Argument passed to %s::%s() must be an array, ' + . 'implement the Traversable interface, or be an ' + . 'instance of Zend\Config\Config. %s given.', + __CLASS__, + __METHOD__, + gettype($modulePaths) + ) ); } @@ -130,10 +134,14 @@ class ListenerOptions extends AbstractOptions { if (!is_array($configGlobPaths) && !$configGlobPaths instanceof Traversable) { throw new Exception\InvalidArgumentException( - sprintf('Argument passed to %s::%s() must be an array, ' - . 'implement the Traversable interface, or be an ' - . 'instance of Zend\Config\Config. %s given.', - __CLASS__, __METHOD__, gettype($configGlobPaths)) + sprintf( + 'Argument passed to %s::%s() must be an array, ' + . 'implement the Traversable interface, or be an ' + . 'instance of Zend\Config\Config. %s given.', + __CLASS__, + __METHOD__, + gettype($configGlobPaths) + ) ); } @@ -152,10 +160,14 @@ class ListenerOptions extends AbstractOptions { if (!is_array($configStaticPaths) && !$configStaticPaths instanceof Traversable) { throw new Exception\InvalidArgumentException( - sprintf('Argument passed to %s::%s() must be an array, ' - . 'implement the Traversable interface, or be an ' - . 'instance of Zend\Config\Config. %s given.', - __CLASS__, __METHOD__, gettype($configStaticPaths)) + sprintf( + 'Argument passed to %s::%s() must be an array, ' + . 'implement the Traversable interface, or be an ' + . 'instance of Zend\Config\Config. %s given.', + __CLASS__, + __METHOD__, + gettype($configStaticPaths) + ) ); } @@ -185,10 +197,14 @@ class ListenerOptions extends AbstractOptions { if (!is_array($extraConfig) && !$extraConfig instanceof Traversable) { throw new Exception\InvalidArgumentException( - sprintf('Argument passed to %s::%s() must be an array, ' - . 'implement the Traversable interface, or be an ' - . 'instance of Zend\Config\Config. %s given.', - __CLASS__, __METHOD__, gettype($extraConfig)) + sprintf( + 'Argument passed to %s::%s() must be an array, ' + . 'implement the Traversable interface, or be an ' + . 'instance of Zend\Config\Config. %s given.', + __CLASS__, + __METHOD__, + gettype($extraConfig) + ) ); } @@ -250,7 +266,11 @@ class ListenerOptions extends AbstractOptions */ public function getConfigCacheFile() { - return $this->getCacheDir() . '/module-config-cache.' . $this->getConfigCacheKey().'.php'; + if ($this->getConfigCacheKey()) { + return $this->getCacheDir() . '/module-config-cache.' . $this->getConfigCacheKey().'.php'; + } + + return $this->getCacheDir() . '/module-config-cache.php'; } /** @@ -330,7 +350,11 @@ class ListenerOptions extends AbstractOptions */ public function getModuleMapCacheFile() { - return $this->getCacheDir() . '/module-classmap-cache.'.$this->getModuleMapCacheKey().'.php'; + if ($this->getModuleMapCacheKey()) { + return $this->getCacheDir() . '/module-classmap-cache.' . $this->getModuleMapCacheKey() . '.php'; + } + + return $this->getCacheDir() . '/module-classmap-cache.php'; } /** diff --git a/library/Zend/ModuleManager/Listener/LocatorRegistrationListener.php b/library/Zend/ModuleManager/Listener/LocatorRegistrationListener.php index b3bc1410..19fac011 100644 --- a/library/Zend/ModuleManager/Listener/LocatorRegistrationListener.php +++ b/library/Zend/ModuleManager/Listener/LocatorRegistrationListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,7 @@ use Zend\EventManager\EventManagerInterface; use Zend\EventManager\ListenerAggregateInterface; use Zend\ModuleManager\Feature\LocatorRegisteredInterface; use Zend\ModuleManager\ModuleEvent; -use Zend\Mvc\MvcEvent; +use Zend\ModuleManager\ModuleManager; /** * Locator registration listener @@ -67,7 +67,7 @@ class LocatorRegistrationListener extends AbstractListener implements } // Shared instance for module manager - $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, function ($e) use ($moduleManager) { + $events->attach('Zend\Mvc\Application', ModuleManager::EVENT_BOOTSTRAP, function ($e) use ($moduleManager) { $moduleClassName = get_class($moduleManager); $moduleClassNameArray = explode('\\', $moduleClassName); $moduleClassNameAlias = end($moduleClassNameArray); @@ -83,7 +83,7 @@ class LocatorRegistrationListener extends AbstractListener implements } // Attach to the bootstrap event if there are modules we need to process - $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, array($this, 'onBootstrap'), 1000); + $events->attach('Zend\Mvc\Application', ModuleManager::EVENT_BOOTSTRAP, array($this, 'onBootstrap'), 1000); } /** diff --git a/library/Zend/ModuleManager/Listener/ModuleDependencyCheckerListener.php b/library/Zend/ModuleManager/Listener/ModuleDependencyCheckerListener.php index 636ba92d..fcb76644 100644 --- a/library/Zend/ModuleManager/Listener/ModuleDependencyCheckerListener.php +++ b/library/Zend/ModuleManager/Listener/ModuleDependencyCheckerListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/ModuleLoaderListener.php b/library/Zend/ModuleManager/Listener/ModuleLoaderListener.php index 9e8bdf56..b4ea9509 100644 --- a/library/Zend/ModuleManager/Listener/ModuleLoaderListener.php +++ b/library/Zend/ModuleManager/Listener/ModuleLoaderListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/ModuleResolverListener.php b/library/Zend/ModuleManager/Listener/ModuleResolverListener.php index 6e841155..b058796b 100644 --- a/library/Zend/ModuleManager/Listener/ModuleResolverListener.php +++ b/library/Zend/ModuleManager/Listener/ModuleResolverListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,6 @@ class ModuleResolverListener extends AbstractListener return false; } - $module = new $class; - return $module; + return new $class; } } diff --git a/library/Zend/ModuleManager/Listener/OnBootstrapListener.php b/library/Zend/ModuleManager/Listener/OnBootstrapListener.php index 5b0e1392..434792c7 100644 --- a/library/Zend/ModuleManager/Listener/OnBootstrapListener.php +++ b/library/Zend/ModuleManager/Listener/OnBootstrapListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,7 @@ namespace Zend\ModuleManager\Listener; use Zend\ModuleManager\Feature\BootstrapListenerInterface; use Zend\ModuleManager\ModuleEvent; -use Zend\Mvc\MvcEvent; +use Zend\ModuleManager\ModuleManager; /** * Autoloader listener @@ -34,6 +34,6 @@ class OnBootstrapListener extends AbstractListener $moduleManager = $e->getTarget(); $events = $moduleManager->getEventManager(); $sharedEvents = $events->getSharedManager(); - $sharedEvents->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, array($module, 'onBootstrap')); + $sharedEvents->attach('Zend\Mvc\Application', ModuleManager::EVENT_BOOTSTRAP, array($module, 'onBootstrap')); } } diff --git a/library/Zend/ModuleManager/Listener/ServiceListener.php b/library/Zend/ModuleManager/Listener/ServiceListener.php index 7907d6f9..252d84c0 100644 --- a/library/Zend/ModuleManager/Listener/ServiceListener.php +++ b/library/Zend/ModuleManager/Listener/ServiceListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/Listener/ServiceListenerInterface.php b/library/Zend/ModuleManager/Listener/ServiceListenerInterface.php index 3de7660f..9cfe4018 100644 --- a/library/Zend/ModuleManager/Listener/ServiceListenerInterface.php +++ b/library/Zend/ModuleManager/Listener/ServiceListenerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/ModuleEvent.php b/library/Zend/ModuleManager/ModuleEvent.php index ccc39f3e..a4b2783b 100644 --- a/library/Zend/ModuleManager/ModuleEvent.php +++ b/library/Zend/ModuleManager/ModuleEvent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -61,10 +61,13 @@ class ModuleEvent extends Event public function setModuleName($moduleName) { if (!is_string($moduleName)) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects a string as an argument; %s provided' - ,__METHOD__, gettype($moduleName) - )); + throw new Exception\InvalidArgumentException( + sprintf( + '%s expects a string as an argument; %s provided', + __METHOD__, + gettype($moduleName) + ) + ); } // Performance tweak, don't add it as param. $this->moduleName = $moduleName; @@ -92,10 +95,13 @@ class ModuleEvent extends Event public function setModule($module) { if (!is_object($module)) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects a module object as an argument; %s provided' - ,__METHOD__, gettype($module) - )); + throw new Exception\InvalidArgumentException( + sprintf( + '%s expects a module object as an argument; %s provided', + __METHOD__, + gettype($module) + ) + ); } // Performance tweak, don't add it as param. $this->module = $module; diff --git a/library/Zend/ModuleManager/ModuleManager.php b/library/Zend/ModuleManager/ModuleManager.php index a1207e02..4a4143fc 100644 --- a/library/Zend/ModuleManager/ModuleManager.php +++ b/library/Zend/ModuleManager/ModuleManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -18,6 +18,12 @@ use Zend\EventManager\EventManagerInterface; */ class ModuleManager implements ModuleManagerInterface { + /**#@+ + * Reference to Zend\Mvc\MvcEvent::EVENT_BOOTSTRAP + */ + const EVENT_BOOTSTRAP = 'bootstrap'; + /**#@-*/ + /** * @var array An array of Module classes of loaded modules */ @@ -219,7 +225,7 @@ class ModuleManager implements ModuleManagerInterface public function getModule($moduleName) { if (!isset($this->loadedModules[$moduleName])) { - return null; + return; } return $this->loadedModules[$moduleName]; } @@ -246,10 +252,13 @@ class ModuleManager implements ModuleManagerInterface if (is_array($modules) || $modules instanceof Traversable) { $this->modules = $modules; } else { - throw new Exception\InvalidArgumentException(sprintf( - 'Parameter to %s\'s %s method must be an array or implement the Traversable interface', - __CLASS__, __METHOD__ - )); + throw new Exception\InvalidArgumentException( + sprintf( + 'Parameter to %s\'s %s method must be an array or implement the Traversable interface', + __CLASS__, + __METHOD__ + ) + ); } return $this; } diff --git a/library/Zend/ModuleManager/ModuleManagerInterface.php b/library/Zend/ModuleManager/ModuleManagerInterface.php index 8d381872..92454c03 100644 --- a/library/Zend/ModuleManager/ModuleManagerInterface.php +++ b/library/Zend/ModuleManager/ModuleManagerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ModuleManager/composer.json b/library/Zend/ModuleManager/composer.json index db1d6388..43b57cc6 100644 --- a/library/Zend/ModuleManager/composer.json +++ b/library/Zend/ModuleManager/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\ModuleManager\\": "" } }, - "target-dir": "Zend/ModuleManager", "require": { "php": ">=5.3.23", "zendframework/zend-eventmanager": "self.version", @@ -22,7 +21,6 @@ "zendframework/zend-config": "self.version", "zendframework/zend-console": "self.version", "zendframework/zend-loader": "self.version", - "zendframework/zend-mvc": "self.version", "zendframework/zend-servicemanager": "self.version" }, "suggest": { @@ -34,8 +32,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Mvc/Application.php b/library/Zend/Mvc/Application.php index 0dce2db3..096b9cf8 100644 --- a/library/Zend/Mvc/Application.php +++ b/library/Zend/Mvc/Application.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -66,6 +66,7 @@ class Application implements protected $defaultListeners = array( 'RouteListener', 'DispatchListener', + 'HttpMethodListener', 'ViewManager', 'SendResponseListener', ); diff --git a/library/Zend/Mvc/ApplicationInterface.php b/library/Zend/Mvc/ApplicationInterface.php index c6bc23f3..51bd7eec 100644 --- a/library/Zend/Mvc/ApplicationInterface.php +++ b/library/Zend/Mvc/ApplicationInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/AbstractActionController.php b/library/Zend/Mvc/Controller/AbstractActionController.php index f933b83e..e604e308 100644 --- a/library/Zend/Mvc/Controller/AbstractActionController.php +++ b/library/Zend/Mvc/Controller/AbstractActionController.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,7 +12,6 @@ namespace Zend\Mvc\Controller; use Zend\Http\Response as HttpResponse; use Zend\Mvc\Exception; use Zend\Mvc\MvcEvent; -use Zend\View\Model\ConsoleModel; use Zend\View\Model\ViewModel; /** @@ -21,7 +20,7 @@ use Zend\View\Model\ViewModel; abstract class AbstractActionController extends AbstractController { /** - * @var string + * {@inheritDoc} */ protected $eventIdentifier = __CLASS__; @@ -88,30 +87,24 @@ abstract class AbstractActionController extends AbstractController } /** - * Create an HTTP view model representing a "not found" page + * @deprecated please use the {@see \Zend\Mvc\Controller\Plugin\CreateHttpNotFoundModel} plugin instead: this + * method will be removed in release 2.5 or later. * - * @param HttpResponse $response - * @return ViewModel + * {@inheritDoc} */ protected function createHttpNotFoundModel(HttpResponse $response) { - $response->setStatusCode(404); - return new ViewModel(array( - 'content' => 'Page not found', - )); + return $this->__call('createHttpNotFoundModel', array($response)); } /** - * Create a console view model representing a "not found" action + * @deprecated please use the {@see \Zend\Mvc\Controller\Plugin\CreateConsoleNotFoundModel} plugin instead: this + * method will be removed in release 2.5 or later. * - * @param \Zend\Stdlib\ResponseInterface $response - * @return ConsoleModel + * {@inheritDoc} */ protected function createConsoleNotFoundModel($response) { - $viewModel = new ConsoleModel(); - $viewModel->setErrorLevel(1); - $viewModel->setResult('Page not found'); - return $viewModel; + return $this->__call('createConsoleNotFoundModel', array($response)); } } diff --git a/library/Zend/Mvc/Controller/AbstractConsoleController.php b/library/Zend/Mvc/Controller/AbstractConsoleController.php index 8f0a5962..42eb361a 100644 --- a/library/Zend/Mvc/Controller/AbstractConsoleController.php +++ b/library/Zend/Mvc/Controller/AbstractConsoleController.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/AbstractController.php b/library/Zend/Mvc/Controller/AbstractController.php index d29ee7dc..0a2cc03a 100644 --- a/library/Zend/Mvc/Controller/AbstractController.php +++ b/library/Zend/Mvc/Controller/AbstractController.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,8 +29,8 @@ use Zend\Stdlib\ResponseInterface as Response; * Convenience methods for pre-built plugins (@see __call): * * @method \Zend\View\Model\ModelInterface acceptableViewModelSelector(array $matchAgainst = null, bool $returnDefault = true, \Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart $resultReference = null) - * @method bool|array|\Zend\Http\Response fileprg(\Zend\Form\Form $form, $redirect = null, $redirectToUrl = false) - * @method bool|array|\Zend\Http\Response filePostRedirectGet(\Zend\Form\Form $form, $redirect = null, $redirectToUrl = false) + * @method bool|array|\Zend\Http\Response fileprg(\Zend\Form\FormInterface $form, $redirect = null, $redirectToUrl = false) + * @method bool|array|\Zend\Http\Response filePostRedirectGet(\Zend\Form\FormInterface $form, $redirect = null, $redirectToUrl = false) * @method \Zend\Mvc\Controller\Plugin\FlashMessenger flashMessenger() * @method \Zend\Mvc\Controller\Plugin\Forward forward() * @method mixed|null identity() @@ -40,6 +40,8 @@ use Zend\Stdlib\ResponseInterface as Response; * @method \Zend\Http\Response|array postRedirectGet(string $redirect = null, bool $redirectToUrl = false) * @method \Zend\Mvc\Controller\Plugin\Redirect redirect() * @method \Zend\Mvc\Controller\Plugin\Url url() + * @method \Zend\View\Model\ConsoleModel createConsoleNotFoundModel() + * @method \Zend\View\Model\ViewModel createHttpNotFoundModel() */ abstract class AbstractController implements Dispatchable, @@ -78,7 +80,7 @@ abstract class AbstractController implements protected $serviceLocator; /** - * @var string + * @var null|string|string[] */ protected $eventIdentifier; @@ -90,7 +92,6 @@ abstract class AbstractController implements */ abstract public function onDispatch(MvcEvent $e); - /** * Dispatch a request * @@ -159,13 +160,19 @@ abstract class AbstractController implements */ public function setEventManager(EventManagerInterface $events) { - $events->setIdentifiers(array( - 'Zend\Stdlib\DispatchableInterface', - __CLASS__, - get_class($this), - $this->eventIdentifier, - substr(get_class($this), 0, strpos(get_class($this), '\\')) + $className = get_class($this); + + $nsPos = strpos($className, '\\') ?: 0; + $events->setIdentifiers(array_merge( + array( + __CLASS__, + $className, + substr($className, 0, $nsPos) + ), + array_values(class_implements($className)), + (array) $this->eventIdentifier )); + $this->events = $events; $this->attachDefaultListeners(); diff --git a/library/Zend/Mvc/Controller/AbstractRestfulController.php b/library/Zend/Mvc/Controller/AbstractRestfulController.php index 142185c7..f763294b 100644 --- a/library/Zend/Mvc/Controller/AbstractRestfulController.php +++ b/library/Zend/Mvc/Controller/AbstractRestfulController.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Controller; @@ -23,7 +23,7 @@ abstract class AbstractRestfulController extends AbstractController const CONTENT_TYPE_JSON = 'json'; /** - * @var string + * {@inheritDoc} */ protected $eventIdentifier = __CLASS__; @@ -116,7 +116,7 @@ abstract class AbstractRestfulController extends AbstractController * * @return mixed */ - public function deleteList() + public function deleteList($data) { $this->response->setStatusCode(405); @@ -200,6 +200,7 @@ abstract class AbstractRestfulController extends AbstractController * * @param $id * @param $data + * @return array */ public function patch($id, $data) { @@ -346,6 +347,8 @@ abstract class AbstractRestfulController extends AbstractController // DELETE case 'delete': $id = $this->getIdentifier($routeMatch, $request); + $data = $this->processBodyContent($request); + if ($id !== false) { $action = 'delete'; $return = $this->delete($id); @@ -353,7 +356,7 @@ abstract class AbstractRestfulController extends AbstractController } $action = 'deleteList'; - $return = $this->deleteList(); + $return = $this->deleteList($data); break; // GET case 'get': @@ -373,8 +376,8 @@ abstract class AbstractRestfulController extends AbstractController $id = null; } $action = 'head'; - $this->head($id); - $response = $e->getResponse(); + $headResult = $this->head($id); + $response = ($headResult instanceof Response) ? clone $headResult : $e->getResponse(); $response->setContent(''); $return = $response; break; diff --git a/library/Zend/Mvc/Controller/ControllerManager.php b/library/Zend/Mvc/Controller/ControllerManager.php index c64de268..97f428db 100644 --- a/library/Zend/Mvc/Controller/ControllerManager.php +++ b/library/Zend/Mvc/Controller/ControllerManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/AbstractPlugin.php b/library/Zend/Mvc/Controller/Plugin/AbstractPlugin.php index 6c6e3ae4..7f74dfb3 100644 --- a/library/Zend/Mvc/Controller/Plugin/AbstractPlugin.php +++ b/library/Zend/Mvc/Controller/Plugin/AbstractPlugin.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/AcceptableViewModelSelector.php b/library/Zend/Mvc/Controller/Plugin/AcceptableViewModelSelector.php index fffab0ed..2049d8f0 100644 --- a/library/Zend/Mvc/Controller/Plugin/AcceptableViewModelSelector.php +++ b/library/Zend/Mvc/Controller/Plugin/AcceptableViewModelSelector.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -134,7 +134,7 @@ class AcceptableViewModelSelector extends AbstractPlugin $headers = $request->getHeaders(); if ((!$matchAgainst && !$this->defaultMatchAgainst) || !$headers->has('accept')) { - return null; + return; } if (!$matchAgainst) { @@ -151,7 +151,7 @@ class AcceptableViewModelSelector extends AbstractPlugin /** @var $accept \Zend\Http\Header\Accept */ $accept = $headers->get('Accept'); if (($res = $accept->match($matchAgainstString)) === false) { - return null; + return; } return $res; diff --git a/library/Zend/Mvc/Controller/Plugin/CreateConsoleNotFoundModel.php b/library/Zend/Mvc/Controller/Plugin/CreateConsoleNotFoundModel.php new file mode 100644 index 00000000..9cc02a26 --- /dev/null +++ b/library/Zend/Mvc/Controller/Plugin/CreateConsoleNotFoundModel.php @@ -0,0 +1,30 @@ +setErrorLevel(1); + $viewModel->setResult('Page not found'); + + return $viewModel; + } +} diff --git a/library/Zend/Mvc/Controller/Plugin/CreateHttpNotFoundModel.php b/library/Zend/Mvc/Controller/Plugin/CreateHttpNotFoundModel.php new file mode 100644 index 00000000..c87b5c14 --- /dev/null +++ b/library/Zend/Mvc/Controller/Plugin/CreateHttpNotFoundModel.php @@ -0,0 +1,30 @@ +setStatusCode(404); + + return new ViewModel(array('content' => 'Page not found')); + } +} diff --git a/library/Zend/Mvc/Controller/Plugin/FilePostRedirectGet.php b/library/Zend/Mvc/Controller/Plugin/FilePostRedirectGet.php index 9250ad78..48822b60 100644 --- a/library/Zend/Mvc/Controller/Plugin/FilePostRedirectGet.php +++ b/library/Zend/Mvc/Controller/Plugin/FilePostRedirectGet.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -126,7 +126,6 @@ class FilePostRedirectGet extends AbstractPlugin $post = $container->post; $errors = $container->errors; $isValid = $container->isValid; - $previousFiles = ($container->files) ?: array(); unset($container->post); unset($container->errors); unset($container->isValid); @@ -257,7 +256,7 @@ class FilePostRedirectGet extends AbstractPlugin return $value; } } - return null; + return; } ); } @@ -278,13 +277,13 @@ class FilePostRedirectGet extends AbstractPlugin $messages = $input->getMessages(); if (is_array($value) && $input instanceof FileInput && empty($messages)) { $rawValue = $input->getRawValue(); - if ( (isset($rawValue['error']) && $rawValue['error'] === UPLOAD_ERR_NO_FILE) + if ((isset($rawValue['error']) && $rawValue['error'] === UPLOAD_ERR_NO_FILE) || (isset($rawValue[0]['error']) && $rawValue[0]['error'] === UPLOAD_ERR_NO_FILE) ) { return $value; } } - return null; + return; } ); } diff --git a/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php b/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php index a7b2d309..02908123 100644 --- a/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php +++ b/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -151,20 +151,25 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta * Add a message * * @param string $message + * @param null|string $namespace + * @param null|int $hops * @return FlashMessenger Provides a fluent interface */ - public function addMessage($message) + public function addMessage($message, $namespace = null, $hops = 1) { $container = $this->getContainer(); - $namespace = $this->getNamespace(); - if (!$this->messageAdded) { - $this->getMessagesFromContainer(); - $container->setExpirationHops(1, null); + if (null === $namespace) { + $namespace = $this->getNamespace(); } - if (!isset($container->{$namespace}) - || !($container->{$namespace} instanceof SplQueue) + if (! $this->messageAdded) { + $this->getMessagesFromContainer(); + $container->setExpirationHops($hops, null); + } + + if (! isset($container->{$namespace}) + || ! $container->{$namespace} instanceof SplQueue ) { $container->{$namespace} = new SplQueue(); } @@ -184,10 +189,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function addInfoMessage($message) { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_INFO); - $this->addMessage($message); - $this->setNamespace($namespace); + $this->addMessage($message, self::NAMESPACE_INFO); return $this; } @@ -200,10 +202,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function addSuccessMessage($message) { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_SUCCESS); - $this->addMessage($message); - $this->setNamespace($namespace); + $this->addMessage($message, self::NAMESPACE_SUCCESS); return $this; } @@ -216,10 +215,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function addWarningMessage($message) { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $this->addMessage($message); - $this->setNamespace($namespace); + $this->addMessage($message, self::NAMESPACE_WARNING); return $this; } @@ -232,10 +228,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function addErrorMessage($message) { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_ERROR); - $this->addMessage($message); - $this->setNamespace($namespace); + $this->addMessage($message, self::NAMESPACE_ERROR); return $this; } @@ -243,13 +236,18 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta /** * Whether a specific namespace has messages * + * @param string $namespace * @return bool */ - public function hasMessages() + public function hasMessages($namespace = null) { + if (null === $namespace) { + $namespace = $this->getNamespace(); + } + $this->getMessagesFromContainer(); - return isset($this->messages[$this->getNamespace()]); + return isset($this->messages[$namespace]); } /** @@ -259,12 +257,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasInfoMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_INFO); - $hasMessages = $this->hasMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasMessages(self::NAMESPACE_INFO); } /** @@ -274,12 +267,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasSuccessMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_SUCCESS); - $hasMessages = $this->hasMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasMessages(self::NAMESPACE_SUCCESS); } /** @@ -289,12 +277,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasWarningMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $hasMessages = $this->hasMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasMessages(self::NAMESPACE_WARNING); } /** @@ -304,23 +287,23 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasErrorMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_ERROR); - $hasMessages = $this->hasMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasMessages(self::NAMESPACE_ERROR); } /** * Get messages from a specific namespace * + * @param string $namespace * @return array */ - public function getMessages() + public function getMessages($namespace = null) { - if ($this->hasMessages()) { - return $this->messages[$this->getNamespace()]->toArray(); + if (null === $namespace) { + $namespace = $this->getNamespace(); + } + + if ($this->hasMessages($namespace)) { + return $this->messages[$namespace]->toArray(); } return array(); @@ -333,12 +316,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getInfoMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_INFO); - $messages = $this->getMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getMessages(self::NAMESPACE_INFO); } /** @@ -348,12 +326,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getSuccessMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_SUCCESS); - $messages = $this->getMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getMessages(self::NAMESPACE_SUCCESS); } /** @@ -363,12 +336,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getWarningMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $messages = $this->getMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getMessages(self::NAMESPACE_WARNING); } /** @@ -378,23 +346,23 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getErrorMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_ERROR); - $messages = $this->getMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getMessages(self::NAMESPACE_ERROR); } /** * Clear all messages from the previous request & current namespace * + * @param string $namespace * @return bool True if messages were cleared, false if none existed */ - public function clearMessages() + public function clearMessages($namespace = null) { - if ($this->hasMessages()) { - unset($this->messages[$this->getNamespace()]); + if (null === $namespace) { + $namespace = $this->getNamespace(); + } + + if ($this->hasMessages($namespace)) { + unset($this->messages[$namespace]); return true; } @@ -410,12 +378,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function clearMessagesFromNamespace($namespaceToClear) { - $namespace = $this->getNamespace(); - $this->setNamespace($namespaceToClear); - $cleared = $this->clearMessages(); - $this->setNamespace($namespace); - - return $cleared; + return $this->clearMessages($namespaceToClear); } /** @@ -439,12 +402,15 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta * Check to see if messages have been added to the current * namespace within this request * + * @param string $namespace * @return bool */ - public function hasCurrentMessages() + public function hasCurrentMessages($namespace = null) { $container = $this->getContainer(); - $namespace = $this->getNamespace(); + if (null === $namespace) { + $namespace = $this->getNamespace(); + } return isset($container->{$namespace}); } @@ -457,12 +423,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasCurrentInfoMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_INFO); - $hasMessages = $this->hasCurrentMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasCurrentMessages(self::NAMESPACE_INFO); } /** @@ -473,12 +434,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasCurrentSuccessMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_SUCCESS); - $hasMessages = $this->hasCurrentMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasCurrentMessages(self::NAMESPACE_SUCCESS); } /** @@ -489,12 +445,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasCurrentWarningMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $hasMessages = $this->hasCurrentMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasCurrentMessages(self::NAMESPACE_WARNING); } /** @@ -505,25 +456,24 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function hasCurrentErrorMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_ERROR); - $hasMessages = $this->hasCurrentMessages(); - $this->setNamespace($namespace); - - return $hasMessages; + return $this->hasCurrentMessages(self::NAMESPACE_ERROR); } /** * Get messages that have been added to the current * namespace within this request * + * @param string $namespace * @return array */ - public function getCurrentMessages() + public function getCurrentMessages($namespace = null) { - if ($this->hasCurrentMessages()) { - $container = $this->getContainer(); + if (null === $namespace) { $namespace = $this->getNamespace(); + } + + if ($this->hasCurrentMessages($namespace)) { + $container = $this->getContainer(); return $container->{$namespace}->toArray(); } @@ -539,12 +489,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getCurrentInfoMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_INFO); - $messages = $this->getCurrentMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getCurrentMessages(self::NAMESPACE_INFO); } /** @@ -555,12 +500,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getCurrentSuccessMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_SUCCESS); - $messages = $this->getCurrentMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getCurrentMessages(self::NAMESPACE_SUCCESS); } /** @@ -571,12 +511,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getCurrentWarningMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $messages = $this->getCurrentMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getCurrentMessages(self::NAMESPACE_WARNING); } /** @@ -587,12 +522,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getCurrentErrorMessages() { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_ERROR); - $messages = $this->getCurrentMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getCurrentMessages(self::NAMESPACE_ERROR); } /** @@ -604,24 +534,23 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getCurrentMessagesFromNamespace($namespaceToGet) { - $namespace = $this->getNamespace(); - $this->setNamespace($namespaceToGet); - $messages = $this->getCurrentMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getCurrentMessages($namespaceToGet); } /** * Clear messages from the current request and current namespace * + * @param string $namespace * @return bool True if current messages were cleared, false if none existed. */ - public function clearCurrentMessages() + public function clearCurrentMessages($namespace = null) { - if ($this->hasCurrentMessages()) { - $container = $this->getContainer(); + if (null === $namespace) { $namespace = $this->getNamespace(); + } + + if ($this->hasCurrentMessages($namespace)) { + $container = $this->getContainer(); unset($container->{$namespace}); return true; @@ -638,12 +567,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function clearCurrentMessagesFromNamespace($namespaceToClear) { - $namespace = $this->getNamespace(); - $this->setNamespace($namespaceToClear); - $cleared = $this->clearCurrentMessages(); - $this->setNamespace($namespace); - - return $cleared; + return $this->clearCurrentMessages($namespaceToClear); } /** @@ -707,12 +631,7 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ public function getMessagesFromNamespace($namespaceToGet) { - $namespace = $this->getNamespace(); - $this->setNamespace($namespaceToGet); - $messages = $this->getMessages(); - $this->setNamespace($namespace); - - return $messages; + return $this->getMessages($namespaceToGet); } /** diff --git a/library/Zend/Mvc/Controller/Plugin/Forward.php b/library/Zend/Mvc/Controller/Plugin/Forward.php index 19389f79..ec793b8f 100644 --- a/library/Zend/Mvc/Controller/Plugin/Forward.php +++ b/library/Zend/Mvc/Controller/Plugin/Forward.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -192,7 +192,7 @@ class Forward extends AbstractPlugin } foreach ($classArray as $class) { - if (is_a($currentCallback, $class)) { + if ($currentCallback instanceof $class) { $sharedEvents->detach($id, $currentEvent); $results[$id][$eventName][] = $currentEvent; } diff --git a/library/Zend/Mvc/Controller/Plugin/Identity.php b/library/Zend/Mvc/Controller/Plugin/Identity.php index 5c30d699..a420b191 100644 --- a/library/Zend/Mvc/Controller/Plugin/Identity.php +++ b/library/Zend/Mvc/Controller/Plugin/Identity.php @@ -3,13 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Controller\Plugin; -use Zend\Authentication\AuthenticationService; +use Zend\Authentication\AuthenticationServiceInterface; use Zend\Mvc\Exception; /** @@ -18,12 +18,12 @@ use Zend\Mvc\Exception; class Identity extends AbstractPlugin { /** - * @var AuthenticationService + * @var AuthenticationServiceInterface */ protected $authenticationService; /** - * @return AuthenticationService + * @return AuthenticationServiceInterface */ public function getAuthenticationService() { @@ -31,9 +31,9 @@ class Identity extends AbstractPlugin } /** - * @param AuthenticationService $authenticationService + * @param AuthenticationServiceInterface $authenticationService */ - public function setAuthenticationService(AuthenticationService $authenticationService) + public function setAuthenticationService(AuthenticationServiceInterface $authenticationService) { $this->authenticationService = $authenticationService; } @@ -48,11 +48,11 @@ class Identity extends AbstractPlugin */ public function __invoke() { - if (!$this->authenticationService instanceof AuthenticationService) { - throw new Exception\RuntimeException('No AuthenticationService instance provided'); + if (!$this->authenticationService instanceof AuthenticationServiceInterface) { + throw new Exception\RuntimeException('No AuthenticationServiceInterface instance provided'); } if (!$this->authenticationService->hasIdentity()) { - return null; + return; } return $this->authenticationService->getIdentity(); } diff --git a/library/Zend/Mvc/Controller/Plugin/Layout.php b/library/Zend/Mvc/Controller/Plugin/Layout.php index ccdd2f21..14963098 100644 --- a/library/Zend/Mvc/Controller/Plugin/Layout.php +++ b/library/Zend/Mvc/Controller/Plugin/Layout.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/Params.php b/library/Zend/Mvc/Controller/Plugin/Params.php index 7642b05f..7f281880 100644 --- a/library/Zend/Mvc/Controller/Plugin/Params.php +++ b/library/Zend/Mvc/Controller/Plugin/Params.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/PluginInterface.php b/library/Zend/Mvc/Controller/Plugin/PluginInterface.php index ba4d7378..f4b28d00 100644 --- a/library/Zend/Mvc/Controller/Plugin/PluginInterface.php +++ b/library/Zend/Mvc/Controller/Plugin/PluginInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php b/library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php index a2b67efa..de74783c 100644 --- a/library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php +++ b/library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -52,7 +52,7 @@ class PostRedirectGet extends AbstractPlugin $container->post = $request->getPost()->toArray(); return $this->redirect($redirect, $redirectToUrl); } else { - if ($container->post !== null) { + if (null !== $container->post) { $post = $container->post; unset($container->post); return $post; @@ -114,14 +114,14 @@ class PostRedirectGet extends AbstractPlugin * If the user wants to redirect to a route, the redirector has to come * from the plugin manager -- otherwise no router will be injected */ - if ($redirectToUrl === false) { + if (false === $redirectToUrl) { throw new RuntimeException('Could not redirect to a route without a router'); } $redirector = new Redirect(); } - if ($redirectToUrl === false) { + if (false === $redirectToUrl) { $response = $redirector->toRoute($redirect, $params, $options, $reuseMatchedParams); $response->setStatusCode(303); return $response; diff --git a/library/Zend/Mvc/Controller/Plugin/Redirect.php b/library/Zend/Mvc/Controller/Plugin/Redirect.php index 10eb029f..471f5b56 100644 --- a/library/Zend/Mvc/Controller/Plugin/Redirect.php +++ b/library/Zend/Mvc/Controller/Plugin/Redirect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.php b/library/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.php index 8f5025ce..1f114ac5 100644 --- a/library/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.php +++ b/library/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/Service/IdentityFactory.php b/library/Zend/Mvc/Controller/Plugin/Service/IdentityFactory.php index a59c6a62..701b3ddd 100644 --- a/library/Zend/Mvc/Controller/Plugin/Service/IdentityFactory.php +++ b/library/Zend/Mvc/Controller/Plugin/Service/IdentityFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/Plugin/Url.php b/library/Zend/Mvc/Controller/Plugin/Url.php index 4eb31351..583023e2 100644 --- a/library/Zend/Mvc/Controller/Plugin/Url.php +++ b/library/Zend/Mvc/Controller/Plugin/Url.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Controller/PluginManager.php b/library/Zend/Mvc/Controller/PluginManager.php index ec53bb0c..35d101ca 100644 --- a/library/Zend/Mvc/Controller/PluginManager.php +++ b/library/Zend/Mvc/Controller/PluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -45,6 +45,8 @@ class PluginManager extends AbstractPluginManager 'postredirectget' => 'Zend\Mvc\Controller\Plugin\PostRedirectGet', 'redirect' => 'Zend\Mvc\Controller\Plugin\Redirect', 'url' => 'Zend\Mvc\Controller\Plugin\Url', + 'createhttpnotfoundmodel' => 'Zend\Mvc\Controller\Plugin\CreateHttpNotFoundModel', + 'createconsolenotfoundmodel' => 'Zend\Mvc\Controller\Plugin\CreateConsoleNotFoundModel', ); /** diff --git a/library/Zend/Mvc/DispatchListener.php b/library/Zend/Mvc/DispatchListener.php index 6a78aa98..63b1a39f 100644 --- a/library/Zend/Mvc/DispatchListener.php +++ b/library/Zend/Mvc/DispatchListener.php @@ -3,19 +3,18 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc; use ArrayObject; +use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManagerInterface; -use Zend\EventManager\ListenerAggregateInterface; use Zend\Mvc\Exception\InvalidControllerException; use Zend\Stdlib\ArrayUtils; - /** * Default dispatch listener * @@ -38,13 +37,8 @@ use Zend\Stdlib\ArrayUtils; * The return value of dispatching the controller is placed into the result * property of the MvcEvent, and returned. */ -class DispatchListener implements ListenerAggregateInterface +class DispatchListener extends AbstractListenerAggregate { - /** - * @var \Zend\Stdlib\CallbackHandler[] - */ - protected $listeners = array(); - /** * Attach listeners to an event manager * @@ -59,21 +53,6 @@ class DispatchListener implements ListenerAggregateInterface } } - /** - * Detach listeners from an event manager - * - * @param EventManagerInterface $events - * @return void - */ - public function detach(EventManagerInterface $events) - { - foreach ($this->listeners as $index => $listener) { - if ($events->detach($listener)) { - unset($this->listeners[$index]); - } - } - } - /** * Listen to the "dispatch" event * diff --git a/library/Zend/Mvc/Exception/BadMethodCallException.php b/library/Zend/Mvc/Exception/BadMethodCallException.php index 11ecc40a..cb01a8a5 100644 --- a/library/Zend/Mvc/Exception/BadMethodCallException.php +++ b/library/Zend/Mvc/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/DomainException.php b/library/Zend/Mvc/Exception/DomainException.php index fdf8dbf1..7490b646 100644 --- a/library/Zend/Mvc/Exception/DomainException.php +++ b/library/Zend/Mvc/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/ExceptionInterface.php b/library/Zend/Mvc/Exception/ExceptionInterface.php index 8fd5cd55..abdd7a32 100644 --- a/library/Zend/Mvc/Exception/ExceptionInterface.php +++ b/library/Zend/Mvc/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/InvalidArgumentException.php b/library/Zend/Mvc/Exception/InvalidArgumentException.php index cc81ee99..fbd05f59 100644 --- a/library/Zend/Mvc/Exception/InvalidArgumentException.php +++ b/library/Zend/Mvc/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/InvalidControllerException.php b/library/Zend/Mvc/Exception/InvalidControllerException.php index 83e484b8..166f1fcd 100644 --- a/library/Zend/Mvc/Exception/InvalidControllerException.php +++ b/library/Zend/Mvc/Exception/InvalidControllerException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/InvalidPluginException.php b/library/Zend/Mvc/Exception/InvalidPluginException.php index 4961c9ce..05abc5da 100644 --- a/library/Zend/Mvc/Exception/InvalidPluginException.php +++ b/library/Zend/Mvc/Exception/InvalidPluginException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/MissingLocatorException.php b/library/Zend/Mvc/Exception/MissingLocatorException.php index e741a16a..220c01e4 100644 --- a/library/Zend/Mvc/Exception/MissingLocatorException.php +++ b/library/Zend/Mvc/Exception/MissingLocatorException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Exception/RuntimeException.php b/library/Zend/Mvc/Exception/RuntimeException.php index cabf55da..a959ed7f 100644 --- a/library/Zend/Mvc/Exception/RuntimeException.php +++ b/library/Zend/Mvc/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/HttpMethodListener.php b/library/Zend/Mvc/HttpMethodListener.php new file mode 100644 index 00000000..0ba69843 --- /dev/null +++ b/library/Zend/Mvc/HttpMethodListener.php @@ -0,0 +1,127 @@ +setEnabled($enabled); + + if (! empty($allowedMethods)) { + $this->setAllowedMethods($allowedMethods); + } + } + + /** + * {@inheritdoc} + */ + public function attach(EventManagerInterface $events) + { + if (! $this->isEnabled()) { + return; + } + + $this->listeners[] = $events->attach( + MvcEvent::EVENT_ROUTE, + array($this, 'onRoute'), + 10000 + ); + } + + /** + * @param MvcEvent $e + * @return void|HttpResponse + */ + public function onRoute(MvcEvent $e) + { + $request = $e->getRequest(); + $response = $e->getResponse(); + + if (! $request instanceof HttpRequest || ! $response instanceof HttpResponse) { + return; + } + + $method = $request->getMethod(); + + if (in_array($method, $this->getAllowedMethods())) { + return; + } + + $response->setStatusCode(405); + + return $response; + } + + /** + * @return array + */ + public function getAllowedMethods() + { + return $this->allowedMethods; + } + + /** + * @param array $allowedMethods + */ + public function setAllowedMethods(array $allowedMethods) + { + foreach ($allowedMethods as &$value) { + $value = strtoupper($value); + } + $this->allowedMethods = $allowedMethods; + } + + /** + * @return bool + */ + public function isEnabled() + { + return $this->enabled; + } + + /** + * @param bool $enabled + */ + public function setEnabled($enabled) + { + $this->enabled = (bool) $enabled; + } +} diff --git a/library/Zend/Mvc/I18n/DummyTranslator.php b/library/Zend/Mvc/I18n/DummyTranslator.php index 657379f7..62019817 100644 --- a/library/Zend/Mvc/I18n/DummyTranslator.php +++ b/library/Zend/Mvc/I18n/DummyTranslator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/I18n/Translator.php b/library/Zend/Mvc/I18n/Translator.php index 71caf83c..032dbed1 100644 --- a/library/Zend/Mvc/I18n/Translator.php +++ b/library/Zend/Mvc/I18n/Translator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/InjectApplicationEventInterface.php b/library/Zend/Mvc/InjectApplicationEventInterface.php index ba3be137..506b6e2f 100644 --- a/library/Zend/Mvc/InjectApplicationEventInterface.php +++ b/library/Zend/Mvc/InjectApplicationEventInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/ModuleRouteListener.php b/library/Zend/Mvc/ModuleRouteListener.php index f9c4dc6a..e55a85a4 100644 --- a/library/Zend/Mvc/ModuleRouteListener.php +++ b/library/Zend/Mvc/ModuleRouteListener.php @@ -3,25 +3,20 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc; +use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManagerInterface; -use Zend\EventManager\ListenerAggregateInterface; -class ModuleRouteListener implements ListenerAggregateInterface +class ModuleRouteListener extends AbstractListenerAggregate { const MODULE_NAMESPACE = '__NAMESPACE__'; const ORIGINAL_CONTROLLER = '__CONTROLLER__'; - /** - * @var \Zend\Stdlib\CallbackHandler[] - */ - protected $listeners = array(); - /** * Attach to an event manager * @@ -33,21 +28,6 @@ class ModuleRouteListener implements ListenerAggregateInterface $this->listeners[] = $events->attach(MvcEvent::EVENT_ROUTE, array($this, 'onRoute'), $priority); } - /** - * Detach all our listeners from the event manager - * - * @param EventManagerInterface $events - * @return void - */ - public function detach(EventManagerInterface $events) - { - foreach ($this->listeners as $index => $listener) { - if ($events->detach($listener)) { - unset($this->listeners[$index]); - } - } - } - /** * Listen to the "route" event and determine if the module namespace should * be prepended to the controller name. diff --git a/library/Zend/Mvc/MvcEvent.php b/library/Zend/Mvc/MvcEvent.php index 896cdbf4..824b27e3 100644 --- a/library/Zend/Mvc/MvcEvent.php +++ b/library/Zend/Mvc/MvcEvent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/ResponseSender/AbstractResponseSender.php b/library/Zend/Mvc/ResponseSender/AbstractResponseSender.php index edfbd4f8..09a42567 100644 --- a/library/Zend/Mvc/ResponseSender/AbstractResponseSender.php +++ b/library/Zend/Mvc/ResponseSender/AbstractResponseSender.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/ResponseSender/ConsoleResponseSender.php b/library/Zend/Mvc/ResponseSender/ConsoleResponseSender.php index c921dfa9..4aaa3984 100644 --- a/library/Zend/Mvc/ResponseSender/ConsoleResponseSender.php +++ b/library/Zend/Mvc/ResponseSender/ConsoleResponseSender.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -43,7 +43,7 @@ class ConsoleResponseSender implements ResponseSenderInterface } $this->sendContent($event); - $errorLevel = (int) $response->getMetadata('errorLevel',0); + $errorLevel = (int) $response->getMetadata('errorLevel', 0); $event->stopPropagation(true); exit($errorLevel); } diff --git a/library/Zend/Mvc/ResponseSender/HttpResponseSender.php b/library/Zend/Mvc/ResponseSender/HttpResponseSender.php index 2f07bbd1..5c129e63 100644 --- a/library/Zend/Mvc/ResponseSender/HttpResponseSender.php +++ b/library/Zend/Mvc/ResponseSender/HttpResponseSender.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/ResponseSender/PhpEnvironmentResponseSender.php b/library/Zend/Mvc/ResponseSender/PhpEnvironmentResponseSender.php index 94833d23..3fe5efb4 100644 --- a/library/Zend/Mvc/ResponseSender/PhpEnvironmentResponseSender.php +++ b/library/Zend/Mvc/ResponseSender/PhpEnvironmentResponseSender.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/ResponseSender/ResponseSenderInterface.php b/library/Zend/Mvc/ResponseSender/ResponseSenderInterface.php index b1a76dd3..de42f9a6 100644 --- a/library/Zend/Mvc/ResponseSender/ResponseSenderInterface.php +++ b/library/Zend/Mvc/ResponseSender/ResponseSenderInterface.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\ResponseSender; - interface ResponseSenderInterface { /** diff --git a/library/Zend/Mvc/ResponseSender/SendResponseEvent.php b/library/Zend/Mvc/ResponseSender/SendResponseEvent.php index 696c22a0..34c2d3b7 100644 --- a/library/Zend/Mvc/ResponseSender/SendResponseEvent.php +++ b/library/Zend/Mvc/ResponseSender/SendResponseEvent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/ResponseSender/SimpleStreamResponseSender.php b/library/Zend/Mvc/ResponseSender/SimpleStreamResponseSender.php index 2cd90c50..d238232a 100644 --- a/library/Zend/Mvc/ResponseSender/SimpleStreamResponseSender.php +++ b/library/Zend/Mvc/ResponseSender/SimpleStreamResponseSender.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/RouteListener.php b/library/Zend/Mvc/RouteListener.php index bc1d0714..e86878ec 100644 --- a/library/Zend/Mvc/RouteListener.php +++ b/library/Zend/Mvc/RouteListener.php @@ -3,22 +3,17 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc; +use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManagerInterface; -use Zend\EventManager\ListenerAggregateInterface; -class RouteListener implements ListenerAggregateInterface +class RouteListener extends AbstractListenerAggregate { - /** - * @var \Zend\Stdlib\CallbackHandler[] - */ - protected $listeners = array(); - /** * Attach to an event manager * @@ -30,21 +25,6 @@ class RouteListener implements ListenerAggregateInterface $this->listeners[] = $events->attach(MvcEvent::EVENT_ROUTE, array($this, 'onRoute')); } - /** - * Detach all our listeners from the event manager - * - * @param EventManagerInterface $events - * @return void - */ - public function detach(EventManagerInterface $events) - { - foreach ($this->listeners as $index => $listener) { - if ($events->detach($listener)) { - unset($this->listeners[$index]); - } - } - } - /** * Listen to the "route" event and attempt to route the request * diff --git a/library/Zend/Mvc/Router/Console/Catchall.php b/library/Zend/Mvc/Router/Console/Catchall.php index 8f796c46..def9e0ee 100644 --- a/library/Zend/Mvc/Router/Console/Catchall.php +++ b/library/Zend/Mvc/Router/Console/Catchall.php @@ -98,7 +98,7 @@ class Catchall implements RouteInterface public function match(Request $request) { if (!$request instanceof ConsoleRequest) { - return null; + return; } return new RouteMatch($this->defaults); diff --git a/library/Zend/Mvc/Router/Console/RouteInterface.php b/library/Zend/Mvc/Router/Console/RouteInterface.php index b35be0a9..2a3c8c6d 100644 --- a/library/Zend/Mvc/Router/Console/RouteInterface.php +++ b/library/Zend/Mvc/Router/Console/RouteInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,7 +17,7 @@ use Zend\Mvc\Router\RouteInterface as BaseRoute; /** * Tree specific route interface. * - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface RouteInterface extends BaseRoute diff --git a/library/Zend/Mvc/Router/Console/RouteMatch.php b/library/Zend/Mvc/Router/Console/RouteMatch.php index b5af6a8b..5de4746a 100644 --- a/library/Zend/Mvc/Router/Console/RouteMatch.php +++ b/library/Zend/Mvc/Router/Console/RouteMatch.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -17,7 +17,7 @@ use Zend\Mvc\Router\RouteMatch as BaseRouteMatch; /** * Part route match. * - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class RouteMatch extends BaseRouteMatch diff --git a/library/Zend/Mvc/Router/Console/Simple.php b/library/Zend/Mvc/Router/Console/Simple.php index 7be034b8..7367bc22 100644 --- a/library/Zend/Mvc/Router/Console/Simple.php +++ b/library/Zend/Mvc/Router/Console/Simple.php @@ -52,7 +52,7 @@ class Simple implements RouteInterface * @param array $aliases * @param null|array|Traversable|FilterChain $filters * @param null|array|Traversable|ValidatorChain $validators - * @throws InvalidArgumentException + * @throws Exception\InvalidArgumentException */ public function __construct( $routeOrRouteMatcher, @@ -79,7 +79,7 @@ class Simple implements RouteInterface * * @see \Zend\Mvc\Router\RouteInterface::factory() * @param array|Traversable $options - * @throws InvalidArgumentException + * @throws Exception\InvalidArgumentException * @return self */ public static function factory($options = array()) @@ -112,7 +112,6 @@ class Simple implements RouteInterface $options['filters'] = null; } - return new static( $options['route'], $options['constraints'], @@ -134,7 +133,7 @@ class Simple implements RouteInterface public function match(Request $request, $pathOffset = null) { if (!$request instanceof ConsoleRequest) { - return null; + return; } $params = $request->getParams()->toArray(); @@ -143,7 +142,7 @@ class Simple implements RouteInterface if (null !== $matches) { return new RouteMatch($matches); } - return null; + return; } /** diff --git a/library/Zend/Mvc/Router/Console/SimpleRouteStack.php b/library/Zend/Mvc/Router/Console/SimpleRouteStack.php index a16c03de..acdb93e2 100644 --- a/library/Zend/Mvc/Router/Console/SimpleRouteStack.php +++ b/library/Zend/Mvc/Router/Console/SimpleRouteStack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Exception/ExceptionInterface.php b/library/Zend/Mvc/Router/Exception/ExceptionInterface.php index d2eda183..42e2fad8 100644 --- a/library/Zend/Mvc/Router/Exception/ExceptionInterface.php +++ b/library/Zend/Mvc/Router/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Exception/InvalidArgumentException.php b/library/Zend/Mvc/Router/Exception/InvalidArgumentException.php index ab3432c0..c0a72729 100644 --- a/library/Zend/Mvc/Router/Exception/InvalidArgumentException.php +++ b/library/Zend/Mvc/Router/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Exception/RuntimeException.php b/library/Zend/Mvc/Router/Exception/RuntimeException.php index 243a4bb6..d722b958 100644 --- a/library/Zend/Mvc/Router/Exception/RuntimeException.php +++ b/library/Zend/Mvc/Router/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Http/Chain.php b/library/Zend/Mvc/Router/Http/Chain.php index 909ca2a1..32e20613 100644 --- a/library/Zend/Mvc/Router/Http/Chain.php +++ b/library/Zend/Mvc/Router/Http/Chain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -102,7 +102,7 @@ class Chain extends TreeRouteStack implements RouteInterface public function match(Request $request, $pathOffset = null, array $options = array()) { if (!method_exists($request, 'getUri')) { - return null; + return; } if ($pathOffset === null) { @@ -125,7 +125,7 @@ class Chain extends TreeRouteStack implements RouteInterface $subMatch = $route->match($request, $pathOffset, $options); if ($subMatch === null) { - return null; + return; } $match->merge($subMatch); @@ -133,7 +133,7 @@ class Chain extends TreeRouteStack implements RouteInterface } if ($mustTerminate && $pathOffset !== $pathLength) { - return null; + return; } return $match; @@ -156,11 +156,13 @@ class Chain extends TreeRouteStack implements RouteInterface $this->assembledParams = array(); - end($this->routes); - $lastRouteKey = key($this->routes); + $routes = ArrayUtils::iteratorToArray($this->routes); + + end($routes); + $lastRouteKey = key($routes); $path = ''; - foreach ($this->routes as $key => $route) { + foreach ($routes as $key => $route) { $chainOptions = $options; $hasChild = isset($options['has_child']) ? $options['has_child'] : false; diff --git a/library/Zend/Mvc/Router/Http/Hostname.php b/library/Zend/Mvc/Router/Http/Hostname.php index 0b4de2ce..03b24baf 100644 --- a/library/Zend/Mvc/Router/Http/Hostname.php +++ b/library/Zend/Mvc/Router/Http/Hostname.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -115,7 +115,9 @@ class Hostname implements RouteInterface $level = 0; while ($currentPos < $length) { - preg_match('(\G(?P[a-z0-9-.]*)(?P[:{\[\]]|$))', $def, $matches, 0, $currentPos); + if (!preg_match('(\G(?P[a-z0-9-.]*)(?P[:{\[\]]|$))', $def, $matches, 0, $currentPos)) { + throw new Exception\RuntimeException('Matched hostname literal contains a disallowed character'); + } $currentPos += strlen($matches[0]); @@ -266,7 +268,7 @@ class Hostname implements RouteInterface public function match(Request $request) { if (!method_exists($request, 'getUri')) { - return null; + return; } $uri = $request->getUri(); @@ -275,7 +277,7 @@ class Hostname implements RouteInterface $result = preg_match('(^' . $this->regex . '$)', $host, $matches); if (!$result) { - return null; + return; } $params = array(); diff --git a/library/Zend/Mvc/Router/Http/Literal.php b/library/Zend/Mvc/Router/Http/Literal.php index 528536a0..83087f16 100644 --- a/library/Zend/Mvc/Router/Http/Literal.php +++ b/library/Zend/Mvc/Router/Http/Literal.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -83,7 +83,7 @@ class Literal implements RouteInterface public function match(Request $request, $pathOffset = null) { if (!method_exists($request, 'getUri')) { - return null; + return; } $uri = $request->getUri(); @@ -96,14 +96,14 @@ class Literal implements RouteInterface } } - return null; + return; } if ($path === $this->route) { return new RouteMatch($this->defaults, strlen($this->route)); } - return null; + return; } /** diff --git a/library/Zend/Mvc/Router/Http/Method.php b/library/Zend/Mvc/Router/Http/Method.php index 27b3b642..c3b04cf9 100644 --- a/library/Zend/Mvc/Router/Http/Method.php +++ b/library/Zend/Mvc/Router/Http/Method.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -82,7 +82,7 @@ class Method implements RouteInterface public function match(Request $request) { if (!method_exists($request, 'getMethod')) { - return null; + return; } $requestVerb = strtoupper($request->getMethod()); @@ -93,7 +93,7 @@ class Method implements RouteInterface return new RouteMatch($this->defaults); } - return null; + return; } /** diff --git a/library/Zend/Mvc/Router/Http/Part.php b/library/Zend/Mvc/Router/Http/Part.php index 1c7e4b0b..21ddef6d 100644 --- a/library/Zend/Mvc/Router/Http/Part.php +++ b/library/Zend/Mvc/Router/Http/Part.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -169,7 +169,7 @@ class Part extends TreeRouteStack implements RouteInterface } } - return null; + return; } /** diff --git a/library/Zend/Mvc/Router/Http/Query.php b/library/Zend/Mvc/Router/Http/Query.php index c25964f2..c17ef0cd 100644 --- a/library/Zend/Mvc/Router/Http/Query.php +++ b/library/Zend/Mvc/Router/Http/Query.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Http/Regex.php b/library/Zend/Mvc/Router/Http/Regex.php index d2f70370..c7ce161c 100644 --- a/library/Zend/Mvc/Router/Http/Regex.php +++ b/library/Zend/Mvc/Router/Http/Regex.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -104,7 +104,7 @@ class Regex implements RouteInterface public function match(Request $request, $pathOffset = null) { if (!method_exists($request, 'getUri')) { - return null; + return; } $uri = $request->getUri(); @@ -117,7 +117,7 @@ class Regex implements RouteInterface } if (!$result) { - return null; + return; } $matchedLength = strlen($matches[0]); diff --git a/library/Zend/Mvc/Router/Http/RouteInterface.php b/library/Zend/Mvc/Router/Http/RouteInterface.php index a9987758..50d5f3f4 100644 --- a/library/Zend/Mvc/Router/Http/RouteInterface.php +++ b/library/Zend/Mvc/Router/Http/RouteInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Http/RouteMatch.php b/library/Zend/Mvc/Router/Http/RouteMatch.php index 39c88235..f1864f25 100644 --- a/library/Zend/Mvc/Router/Http/RouteMatch.php +++ b/library/Zend/Mvc/Router/Http/RouteMatch.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Http/Scheme.php b/library/Zend/Mvc/Router/Http/Scheme.php index 707f8ea1..aefd3b0b 100644 --- a/library/Zend/Mvc/Router/Http/Scheme.php +++ b/library/Zend/Mvc/Router/Http/Scheme.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -82,14 +82,14 @@ class Scheme implements RouteInterface public function match(Request $request) { if (!method_exists($request, 'getUri')) { - return null; + return; } $uri = $request->getUri(); $scheme = $uri->getScheme(); if ($scheme !== $this->scheme) { - return null; + return; } return new RouteMatch($this->defaults); diff --git a/library/Zend/Mvc/Router/Http/Segment.php b/library/Zend/Mvc/Router/Http/Segment.php index 540e6cf2..cd152ac7 100644 --- a/library/Zend/Mvc/Router/Http/Segment.php +++ b/library/Zend/Mvc/Router/Http/Segment.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -344,7 +344,7 @@ class Segment implements RouteInterface public function match(Request $request, $pathOffset = null, array $options = array()) { if (!method_exists($request, 'getUri')) { - return null; + return; } $uri = $request->getUri(); @@ -373,7 +373,7 @@ class Segment implements RouteInterface } if (!$result) { - return null; + return; } $matchedLength = strlen($matches[0]); diff --git a/library/Zend/Mvc/Router/Http/TranslatorAwareTreeRouteStack.php b/library/Zend/Mvc/Router/Http/TranslatorAwareTreeRouteStack.php index 4caa4e7a..7b2884cf 100644 --- a/library/Zend/Mvc/Router/Http/TranslatorAwareTreeRouteStack.php +++ b/library/Zend/Mvc/Router/Http/TranslatorAwareTreeRouteStack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/Http/TreeRouteStack.php b/library/Zend/Mvc/Router/Http/TreeRouteStack.php index da18421d..1742210d 100644 --- a/library/Zend/Mvc/Router/Http/TreeRouteStack.php +++ b/library/Zend/Mvc/Router/Http/TreeRouteStack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -235,7 +235,7 @@ class TreeRouteStack extends SimpleRouteStack return $this->prototypes[$name]; } - return null; + return; } /** @@ -250,7 +250,7 @@ class TreeRouteStack extends SimpleRouteStack public function match(Request $request, $pathOffset = null, array $options = array()) { if (!method_exists($request, 'getUri')) { - return null; + return; } if ($this->baseUrl === null && method_exists($request, 'getBaseUrl')) { @@ -291,7 +291,7 @@ class TreeRouteStack extends SimpleRouteStack } } - return null; + return; } /** @@ -371,9 +371,21 @@ class TreeRouteStack extends SimpleRouteStack $uri->setScheme($this->requestUri->getScheme()); } - return $uri->setPath($path)->normalize()->toString(); + $uri->setPath($path); + + if (!isset($options['normalize_path']) || $options['normalize_path']) { + $uri->normalize(); + } + + return $uri->toString(); } elseif (!$uri->isAbsolute() && $uri->isValidRelative()) { - return $uri->setPath($path)->normalize()->toString(); + $uri->setPath($path); + + if (!isset($options['normalize_path']) || $options['normalize_path']) { + $uri->normalize(); + } + + return $uri->toString(); } return $path; diff --git a/library/Zend/Mvc/Router/Http/Wildcard.php b/library/Zend/Mvc/Router/Http/Wildcard.php index ce8f6251..5580dfd4 100644 --- a/library/Zend/Mvc/Router/Http/Wildcard.php +++ b/library/Zend/Mvc/Router/Http/Wildcard.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -74,7 +74,10 @@ class Wildcard implements RouteInterface if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { - throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); + throw new Exception\InvalidArgumentException(sprintf( + '%s expects an array or Traversable set of options', + __METHOD__ + )); } if (!isset($options['key_value_delimiter'])) { @@ -103,25 +106,25 @@ class Wildcard implements RouteInterface public function match(Request $request, $pathOffset = null) { if (!method_exists($request, 'getUri')) { - return null; + return; } $uri = $request->getUri(); - $path = $uri->getPath(); + $path = $uri->getPath() ?: ''; if ($path === '/') { $path = ''; } if ($pathOffset !== null) { - $path = substr($path, $pathOffset); + $path = substr($path, $pathOffset) ?: ''; } $matches = array(); $params = explode($this->paramDelimiter, $path); if (count($params) > 1 && ($params[0] !== '' || end($params) === '')) { - return null; + return; } if ($this->keyValueDelimiter === $this->paramDelimiter) { diff --git a/library/Zend/Mvc/Router/PriorityList.php b/library/Zend/Mvc/Router/PriorityList.php index 889a0a6e..3fcf8ad7 100644 --- a/library/Zend/Mvc/Router/PriorityList.php +++ b/library/Zend/Mvc/Router/PriorityList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/RouteInterface.php b/library/Zend/Mvc/Router/RouteInterface.php index a5374bc3..c5977bde 100644 --- a/library/Zend/Mvc/Router/RouteInterface.php +++ b/library/Zend/Mvc/Router/RouteInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/RouteMatch.php b/library/Zend/Mvc/Router/RouteMatch.php index 94cf57dd..a78dd454 100644 --- a/library/Zend/Mvc/Router/RouteMatch.php +++ b/library/Zend/Mvc/Router/RouteMatch.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/RoutePluginManager.php b/library/Zend/Mvc/Router/RoutePluginManager.php index b3fbca3a..641c128c 100644 --- a/library/Zend/Mvc/Router/RoutePluginManager.php +++ b/library/Zend/Mvc/Router/RoutePluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/RouteStackInterface.php b/library/Zend/Mvc/Router/RouteStackInterface.php index 4eb5b10c..2470da0b 100644 --- a/library/Zend/Mvc/Router/RouteStackInterface.php +++ b/library/Zend/Mvc/Router/RouteStackInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Router/SimpleRouteStack.php b/library/Zend/Mvc/Router/SimpleRouteStack.php index 798bbf53..36138604 100644 --- a/library/Zend/Mvc/Router/SimpleRouteStack.php +++ b/library/Zend/Mvc/Router/SimpleRouteStack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -303,7 +303,7 @@ class SimpleRouteStack implements RouteStackInterface } } - return null; + return; } /** diff --git a/library/Zend/Mvc/SendResponseListener.php b/library/Zend/Mvc/SendResponseListener.php index ea95d490..14726140 100644 --- a/library/Zend/Mvc/SendResponseListener.php +++ b/library/Zend/Mvc/SendResponseListener.php @@ -3,16 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc; +use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManager; use Zend\EventManager\EventManagerAwareInterface; use Zend\EventManager\EventManagerInterface; -use Zend\EventManager\ListenerAggregateInterface; use Zend\Mvc\ResponseSender\ConsoleResponseSender; use Zend\Mvc\ResponseSender\HttpResponseSender; use Zend\Mvc\ResponseSender\PhpEnvironmentResponseSender; @@ -20,15 +20,9 @@ use Zend\Mvc\ResponseSender\SendResponseEvent; use Zend\Mvc\ResponseSender\SimpleStreamResponseSender; use Zend\Stdlib\ResponseInterface as Response; -class SendResponseListener implements - EventManagerAwareInterface, - ListenerAggregateInterface +class SendResponseListener extends AbstractListenerAggregate implements + EventManagerAwareInterface { - /** - * @var \Zend\Stdlib\CallbackHandler[] - */ - protected $listeners = array(); - /** * @var SendResponseEvent */ @@ -71,7 +65,6 @@ class SendResponseListener implements return $this->eventManager; } - /** * Attach the aggregate to the specified event manager * @@ -83,21 +76,6 @@ class SendResponseListener implements $this->listeners[] = $events->attach(MvcEvent::EVENT_FINISH, array($this, 'sendResponse'), -10000); } - /** - * Detach aggregate listeners from the specified event manager - * - * @param EventManagerInterface $events - * @return void - */ - public function detach(EventManagerInterface $events) - { - foreach ($this->listeners as $index => $listener) { - if ($events->detach($listener)) { - unset($this->listeners[$index]); - } - } - } - /** * Send the response * diff --git a/library/Zend/Mvc/Service/AbstractPluginManagerFactory.php b/library/Zend/Mvc/Service/AbstractPluginManagerFactory.php index 8974d4c3..1463fd5d 100644 --- a/library/Zend/Mvc/Service/AbstractPluginManagerFactory.php +++ b/library/Zend/Mvc/Service/AbstractPluginManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ApplicationFactory.php b/library/Zend/Mvc/Service/ApplicationFactory.php index 6bb3c584..3b6cb8ee 100644 --- a/library/Zend/Mvc/Service/ApplicationFactory.php +++ b/library/Zend/Mvc/Service/ApplicationFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ConfigFactory.php b/library/Zend/Mvc/Service/ConfigFactory.php index 4fbc2bf3..a3683994 100644 --- a/library/Zend/Mvc/Service/ConfigFactory.php +++ b/library/Zend/Mvc/Service/ConfigFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ConsoleAdapterFactory.php b/library/Zend/Mvc/Service/ConsoleAdapterFactory.php index 79ffa399..0258653d 100644 --- a/library/Zend/Mvc/Service/ConsoleAdapterFactory.php +++ b/library/Zend/Mvc/Service/ConsoleAdapterFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ConsoleViewManagerFactory.php b/library/Zend/Mvc/Service/ConsoleViewManagerFactory.php index 1bd8c939..e3dfc665 100644 --- a/library/Zend/Mvc/Service/ConsoleViewManagerFactory.php +++ b/library/Zend/Mvc/Service/ConsoleViewManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ControllerLoaderFactory.php b/library/Zend/Mvc/Service/ControllerLoaderFactory.php index b5572907..cf5cda2d 100644 --- a/library/Zend/Mvc/Service/ControllerLoaderFactory.php +++ b/library/Zend/Mvc/Service/ControllerLoaderFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ControllerPluginManagerFactory.php b/library/Zend/Mvc/Service/ControllerPluginManagerFactory.php index 048f9a35..adcfac72 100644 --- a/library/Zend/Mvc/Service/ControllerPluginManagerFactory.php +++ b/library/Zend/Mvc/Service/ControllerPluginManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/DiAbstractServiceFactoryFactory.php b/library/Zend/Mvc/Service/DiAbstractServiceFactoryFactory.php index 75bf207d..625468f6 100644 --- a/library/Zend/Mvc/Service/DiAbstractServiceFactoryFactory.php +++ b/library/Zend/Mvc/Service/DiAbstractServiceFactoryFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/DiFactory.php b/library/Zend/Mvc/Service/DiFactory.php index 4bc11566..9ea5ceab 100644 --- a/library/Zend/Mvc/Service/DiFactory.php +++ b/library/Zend/Mvc/Service/DiFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/DiServiceInitializerFactory.php b/library/Zend/Mvc/Service/DiServiceInitializerFactory.php index 190e6737..2a2fb190 100644 --- a/library/Zend/Mvc/Service/DiServiceInitializerFactory.php +++ b/library/Zend/Mvc/Service/DiServiceInitializerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/DiStrictAbstractServiceFactory.php b/library/Zend/Mvc/Service/DiStrictAbstractServiceFactory.php index eb6df3d5..38eaa897 100644 --- a/library/Zend/Mvc/Service/DiStrictAbstractServiceFactory.php +++ b/library/Zend/Mvc/Service/DiStrictAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -87,7 +87,6 @@ class DiStrictAbstractServiceFactory extends Di implements AbstractFactoryInterf throw new Exception\InvalidServiceNameException('Service "' . $requestedName . '" is not whitelisted'); } - if ($serviceLocator instanceof AbstractPluginManager) { /* @var $serviceLocator AbstractPluginManager */ $this->serviceLocator = $serviceLocator->getServiceLocator(); diff --git a/library/Zend/Mvc/Service/DiStrictAbstractServiceFactoryFactory.php b/library/Zend/Mvc/Service/DiStrictAbstractServiceFactoryFactory.php index 70100c29..54dd3335 100644 --- a/library/Zend/Mvc/Service/DiStrictAbstractServiceFactoryFactory.php +++ b/library/Zend/Mvc/Service/DiStrictAbstractServiceFactoryFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/EventManagerFactory.php b/library/Zend/Mvc/Service/EventManagerFactory.php index 7941cb76..a806e104 100644 --- a/library/Zend/Mvc/Service/EventManagerFactory.php +++ b/library/Zend/Mvc/Service/EventManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/FilterManagerFactory.php b/library/Zend/Mvc/Service/FilterManagerFactory.php index a6a53603..d9a9e172 100644 --- a/library/Zend/Mvc/Service/FilterManagerFactory.php +++ b/library/Zend/Mvc/Service/FilterManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/FormAnnotationBuilderFactory.php b/library/Zend/Mvc/Service/FormAnnotationBuilderFactory.php new file mode 100644 index 00000000..873b68a3 --- /dev/null +++ b/library/Zend/Mvc/Service/FormAnnotationBuilderFactory.php @@ -0,0 +1,61 @@ +get('FormElementManager'); + $formElementManager->injectFactory($annotationBuilder); + + $config = $serviceLocator->get('Config'); + if (isset($config['form_annotation_builder'])) { + $config = $config['form_annotation_builder']; + + if (isset($config['annotations'])) { + foreach ((array) $config['annotations'] as $fullyQualifiedClassName) { + $annotationBuilder->getAnnotationParser()->registerAnnotation($fullyQualifiedClassName); + } + } + + if (isset($config['listeners'])) { + foreach ((array) $config['listeners'] as $listenerName) { + $listener = $serviceLocator->get($listenerName); + if (!($listener instanceof ListenerAggregateInterface)) { + throw new RuntimeException(sprintf('Invalid event listener (%s) provided', $listenerName)); + } + $listener->attach($annotationBuilder->getEventManager()); + } + } + + if (isset($config['preserve_defined_order'])) { + $annotationBuilder->setPreserveDefinedOrder($config['preserve_defined_order']); + } + } + + return $annotationBuilder; + } +} diff --git a/library/Zend/Mvc/Service/FormElementManagerFactory.php b/library/Zend/Mvc/Service/FormElementManagerFactory.php index fd5400f3..e33dd87e 100644 --- a/library/Zend/Mvc/Service/FormElementManagerFactory.php +++ b/library/Zend/Mvc/Service/FormElementManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/HttpMethodListenerFactory.php b/library/Zend/Mvc/Service/HttpMethodListenerFactory.php new file mode 100644 index 00000000..46ea25ee --- /dev/null +++ b/library/Zend/Mvc/Service/HttpMethodListenerFactory.php @@ -0,0 +1,40 @@ +get('config'); + + if (! isset($config['http_methods_listener'])) { + return new HttpMethodListener(); + } + + $listenerConfig = $config['http_methods_listener']; + $enabled = array_key_exists('enabled', $listenerConfig) + ? $listenerConfig['enabled'] + : true; + $allowedMethods = (isset($listenerConfig['allowed_methods']) && is_array($listenerConfig['allowed_methods'])) + ? $listenerConfig['allowed_methods'] + : null; + + return new HttpMethodListener($enabled, $allowedMethods); + } +} diff --git a/library/Zend/Mvc/Service/HttpViewManagerFactory.php b/library/Zend/Mvc/Service/HttpViewManagerFactory.php index 928c3da5..5c61bad9 100644 --- a/library/Zend/Mvc/Service/HttpViewManagerFactory.php +++ b/library/Zend/Mvc/Service/HttpViewManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/HydratorManagerFactory.php b/library/Zend/Mvc/Service/HydratorManagerFactory.php index 561d00c7..76c6da07 100644 --- a/library/Zend/Mvc/Service/HydratorManagerFactory.php +++ b/library/Zend/Mvc/Service/HydratorManagerFactory.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Service; - class HydratorManagerFactory extends AbstractPluginManagerFactory { const PLUGIN_MANAGER_CLASS = 'Zend\Stdlib\Hydrator\HydratorPluginManager'; diff --git a/library/Zend/Mvc/Service/InjectTemplateListenerFactory.php b/library/Zend/Mvc/Service/InjectTemplateListenerFactory.php new file mode 100644 index 00000000..e0bac2e1 --- /dev/null +++ b/library/Zend/Mvc/Service/InjectTemplateListenerFactory.php @@ -0,0 +1,38 @@ +get('Config'); + + if (isset($config['view_manager']['controller_map']) + && (is_array($config['view_manager']['controller_map'])) + ) { + $listener->setControllerMap($config['view_manager']['controller_map']); + } + + return $listener; + } +} diff --git a/library/Zend/Mvc/Service/InputFilterManagerFactory.php b/library/Zend/Mvc/Service/InputFilterManagerFactory.php index 61cf6888..14806f7f 100644 --- a/library/Zend/Mvc/Service/InputFilterManagerFactory.php +++ b/library/Zend/Mvc/Service/InputFilterManagerFactory.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Service; - class InputFilterManagerFactory extends AbstractPluginManagerFactory { const PLUGIN_MANAGER_CLASS = 'Zend\InputFilter\InputFilterPluginManager'; diff --git a/library/Zend/Mvc/Service/LogProcessorManagerFactory.php b/library/Zend/Mvc/Service/LogProcessorManagerFactory.php index 83390686..fa3f884e 100644 --- a/library/Zend/Mvc/Service/LogProcessorManagerFactory.php +++ b/library/Zend/Mvc/Service/LogProcessorManagerFactory.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Service; - class LogProcessorManagerFactory extends AbstractPluginManagerFactory { const PLUGIN_MANAGER_CLASS = 'Zend\Log\ProcessorPluginManager'; diff --git a/library/Zend/Mvc/Service/LogWriterManagerFactory.php b/library/Zend/Mvc/Service/LogWriterManagerFactory.php index a9e39a28..b858dbe3 100644 --- a/library/Zend/Mvc/Service/LogWriterManagerFactory.php +++ b/library/Zend/Mvc/Service/LogWriterManagerFactory.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Service; - class LogWriterManagerFactory extends AbstractPluginManagerFactory { const PLUGIN_MANAGER_CLASS = 'Zend\Log\WriterPluginManager'; diff --git a/library/Zend/Mvc/Service/ModuleManagerFactory.php b/library/Zend/Mvc/Service/ModuleManagerFactory.php index a47b89e4..ae2bd4d5 100644 --- a/library/Zend/Mvc/Service/ModuleManagerFactory.php +++ b/library/Zend/Mvc/Service/ModuleManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -121,6 +121,12 @@ class ModuleManagerFactory implements FactoryInterface 'Zend\ModuleManager\Feature\LogWriterProviderInterface', 'getLogWriterConfig' ); + $serviceListener->addServiceManager( + 'TranslatorPluginManager', + 'translator_plugins', + 'Zend\ModuleManager\Feature\TranslatorPluginProviderInterface', + 'getTranslatorPluginConfig' + ); $events = $serviceLocator->get('EventManager'); $events->attach($defaultListeners); diff --git a/library/Zend/Mvc/Service/PaginatorPluginManagerFactory.php b/library/Zend/Mvc/Service/PaginatorPluginManagerFactory.php index 2f8db4c9..182a53a4 100644 --- a/library/Zend/Mvc/Service/PaginatorPluginManagerFactory.php +++ b/library/Zend/Mvc/Service/PaginatorPluginManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/RequestFactory.php b/library/Zend/Mvc/Service/RequestFactory.php index 84201bd5..3c5d4a5c 100644 --- a/library/Zend/Mvc/Service/RequestFactory.php +++ b/library/Zend/Mvc/Service/RequestFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ResponseFactory.php b/library/Zend/Mvc/Service/ResponseFactory.php index 9f7b74a5..707e6c9d 100644 --- a/library/Zend/Mvc/Service/ResponseFactory.php +++ b/library/Zend/Mvc/Service/ResponseFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/RoutePluginManagerFactory.php b/library/Zend/Mvc/Service/RoutePluginManagerFactory.php index c37f606f..2f24b858 100644 --- a/library/Zend/Mvc/Service/RoutePluginManagerFactory.php +++ b/library/Zend/Mvc/Service/RoutePluginManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/RouterFactory.php b/library/Zend/Mvc/Service/RouterFactory.php index 18f2bcb9..462ec210 100644 --- a/library/Zend/Mvc/Service/RouterFactory.php +++ b/library/Zend/Mvc/Service/RouterFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/SerializerAdapterPluginManagerFactory.php b/library/Zend/Mvc/Service/SerializerAdapterPluginManagerFactory.php index aee001c5..11d1653c 100644 --- a/library/Zend/Mvc/Service/SerializerAdapterPluginManagerFactory.php +++ b/library/Zend/Mvc/Service/SerializerAdapterPluginManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ServiceListenerFactory.php b/library/Zend/Mvc/Service/ServiceListenerFactory.php index 6686a4dc..0bf1ea09 100644 --- a/library/Zend/Mvc/Service/ServiceListenerFactory.php +++ b/library/Zend/Mvc/Service/ServiceListenerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -37,7 +37,9 @@ class ServiceListenerFactory implements FactoryInterface 'invokables' => array( 'DispatchListener' => 'Zend\Mvc\DispatchListener', 'RouteListener' => 'Zend\Mvc\RouteListener', - 'SendResponseListener' => 'Zend\Mvc\SendResponseListener' + 'SendResponseListener' => 'Zend\Mvc\SendResponseListener', + 'ViewJsonRenderer' => 'Zend\View\Renderer\JsonRenderer', + 'ViewFeedRenderer' => 'Zend\View\Renderer\FeedRenderer', ), 'factories' => array( 'Application' => 'Zend\Mvc\Service\ApplicationFactory', @@ -52,10 +54,13 @@ class ServiceListenerFactory implements FactoryInterface 'DiServiceInitializer' => 'Zend\Mvc\Service\DiServiceInitializerFactory', 'DiStrictAbstractServiceFactory' => 'Zend\Mvc\Service\DiStrictAbstractServiceFactoryFactory', 'FilterManager' => 'Zend\Mvc\Service\FilterManagerFactory', + 'FormAnnotationBuilder' => 'Zend\Mvc\Service\FormAnnotationBuilderFactory', 'FormElementManager' => 'Zend\Mvc\Service\FormElementManagerFactory', 'HttpRouter' => 'Zend\Mvc\Service\RouterFactory', + 'HttpMethodListener' => 'Zend\Mvc\Service\HttpMethodListenerFactory', 'HttpViewManager' => 'Zend\Mvc\Service\HttpViewManagerFactory', 'HydratorManager' => 'Zend\Mvc\Service\HydratorManagerFactory', + 'InjectTemplateListener' => 'Zend\Mvc\Service\InjectTemplateListenerFactory', 'InputFilterManager' => 'Zend\Mvc\Service\InputFilterManagerFactory', 'LogProcessorManager' => 'Zend\Mvc\Service\LogProcessorManagerFactory', 'LogWriterManager' => 'Zend\Mvc\Service\LogWriterManagerFactory', @@ -66,28 +71,30 @@ class ServiceListenerFactory implements FactoryInterface 'Router' => 'Zend\Mvc\Service\RouterFactory', 'RoutePluginManager' => 'Zend\Mvc\Service\RoutePluginManagerFactory', 'SerializerAdapterManager' => 'Zend\Mvc\Service\SerializerAdapterPluginManagerFactory', + 'TranslatorPluginManager' => 'Zend\Mvc\Service\TranslatorPluginManagerFactory', 'ValidatorManager' => 'Zend\Mvc\Service\ValidatorManagerFactory', 'ViewHelperManager' => 'Zend\Mvc\Service\ViewHelperManagerFactory', - 'ViewFeedRenderer' => 'Zend\Mvc\Service\ViewFeedRendererFactory', 'ViewFeedStrategy' => 'Zend\Mvc\Service\ViewFeedStrategyFactory', - 'ViewJsonRenderer' => 'Zend\Mvc\Service\ViewJsonRendererFactory', 'ViewJsonStrategy' => 'Zend\Mvc\Service\ViewJsonStrategyFactory', 'ViewManager' => 'Zend\Mvc\Service\ViewManagerFactory', 'ViewResolver' => 'Zend\Mvc\Service\ViewResolverFactory', 'ViewTemplateMapResolver' => 'Zend\Mvc\Service\ViewTemplateMapResolverFactory', 'ViewTemplatePathStack' => 'Zend\Mvc\Service\ViewTemplatePathStackFactory', + 'ViewPrefixPathStackResolver' => 'Zend\Mvc\Service\ViewPrefixPathStackResolverFactory', ), 'aliases' => array( - 'Configuration' => 'Config', - 'Console' => 'ConsoleAdapter', - 'Di' => 'DependencyInjector', - 'Zend\Di\LocatorInterface' => 'DependencyInjector', - 'Zend\Mvc\Controller\PluginManager' => 'ControllerPluginManager', - 'Zend\View\Resolver\TemplateMapResolver' => 'ViewTemplateMapResolver', - 'Zend\View\Resolver\TemplatePathStack' => 'ViewTemplatePathStack', - 'Zend\View\Resolver\AggregateResolver' => 'ViewResolver', - 'Zend\View\Resolver\ResolverInterface' => 'ViewResolver', - 'ControllerManager' => 'ControllerLoader' + 'Configuration' => 'Config', + 'Console' => 'ConsoleAdapter', + 'Di' => 'DependencyInjector', + 'Zend\Di\LocatorInterface' => 'DependencyInjector', + 'Zend\Form\Annotation\FormAnnotationBuilder' => 'FormAnnotationBuilder', + 'Zend\Mvc\Controller\PluginManager' => 'ControllerPluginManager', + 'Zend\Mvc\View\Http\InjectTemplateListener' => 'InjectTemplateListener', + 'Zend\View\Resolver\TemplateMapResolver' => 'ViewTemplateMapResolver', + 'Zend\View\Resolver\TemplatePathStack' => 'ViewTemplatePathStack', + 'Zend\View\Resolver\AggregateResolver' => 'ViewResolver', + 'Zend\View\Resolver\ResolverInterface' => 'ViewResolver', + 'ControllerManager' => 'ControllerLoader', ), 'abstract_factories' => array( 'Zend\Form\FormAbstractServiceFactory', diff --git a/library/Zend/Mvc/Service/ServiceManagerConfig.php b/library/Zend/Mvc/Service/ServiceManagerConfig.php index dc724027..921d4f74 100644 --- a/library/Zend/Mvc/Service/ServiceManagerConfig.php +++ b/library/Zend/Mvc/Service/ServiceManagerConfig.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/TranslatorPluginManagerFactory.php b/library/Zend/Mvc/Service/TranslatorPluginManagerFactory.php new file mode 100644 index 00000000..2dee23cb --- /dev/null +++ b/library/Zend/Mvc/Service/TranslatorPluginManagerFactory.php @@ -0,0 +1,15 @@ +setPluginManager($serviceLocator->get('TranslatorPluginManager')); $serviceLocator->setService('Zend\I18n\Translator\TranslatorInterface', $i18nTranslator); return new MvcTranslator($i18nTranslator); } diff --git a/library/Zend/Mvc/Service/ValidatorManagerFactory.php b/library/Zend/Mvc/Service/ValidatorManagerFactory.php index 0fe09f0c..a270f8fc 100644 --- a/library/Zend/Mvc/Service/ValidatorManagerFactory.php +++ b/library/Zend/Mvc/Service/ValidatorManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ViewFeedStrategyFactory.php b/library/Zend/Mvc/Service/ViewFeedStrategyFactory.php index 56ab2556..2e7c8d20 100644 --- a/library/Zend/Mvc/Service/ViewFeedStrategyFactory.php +++ b/library/Zend/Mvc/Service/ViewFeedStrategyFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ViewHelperManagerFactory.php b/library/Zend/Mvc/Service/ViewHelperManagerFactory.php index 30757df1..cb205411 100644 --- a/library/Zend/Mvc/Service/ViewHelperManagerFactory.php +++ b/library/Zend/Mvc/Service/ViewHelperManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -80,13 +80,26 @@ class ViewHelperManagerFactory extends AbstractPluginManagerFactory $plugins->setFactory('basepath', function () use ($serviceLocator) { $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array(); $basePathHelper = new ViewHelper\BasePath; + + if (Console::isConsole() + && isset($config['view_manager']) + && isset($config['view_manager']['base_path_console']) + ) { + $basePathHelper->setBasePath($config['view_manager']['base_path_console']); + + return $basePathHelper; + } + if (isset($config['view_manager']) && isset($config['view_manager']['base_path'])) { $basePathHelper->setBasePath($config['view_manager']['base_path']); - } else { - $request = $serviceLocator->get('Request'); - if (is_callable(array($request, 'getBasePath'))) { - $basePathHelper->setBasePath($request->getBasePath()); - } + + return $basePathHelper; + } + + $request = $serviceLocator->get('Request'); + + if (is_callable(array($request, 'getBasePath'))) { + $basePathHelper->setBasePath($request->getBasePath()); } return $basePathHelper; diff --git a/library/Zend/Mvc/Service/ViewJsonRendererFactory.php b/library/Zend/Mvc/Service/ViewJsonRendererFactory.php deleted file mode 100644 index d1c4ee44..00000000 --- a/library/Zend/Mvc/Service/ViewJsonRendererFactory.php +++ /dev/null @@ -1,29 +0,0 @@ -get('Config'); + $prefixes = array(); + + if (isset($config['view_manager']['prefix_template_path_stack'])) { + $prefixes = $config['view_manager']['prefix_template_path_stack']; + } + + return new PrefixPathStackResolver($prefixes); + } +} diff --git a/library/Zend/Mvc/Service/ViewResolverFactory.php b/library/Zend/Mvc/Service/ViewResolverFactory.php index 166ce1a2..e57e6c39 100644 --- a/library/Zend/Mvc/Service/ViewResolverFactory.php +++ b/library/Zend/Mvc/Service/ViewResolverFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -21,14 +21,28 @@ class ViewResolverFactory implements FactoryInterface * Creates a Zend\View\Resolver\AggregateResolver and attaches the template * map resolver and path stack resolver * - * @param ServiceLocatorInterface $serviceLocator + * @param ServiceLocatorInterface $serviceLocator * @return ViewResolver\AggregateResolver */ public function createService(ServiceLocatorInterface $serviceLocator) { $resolver = new ViewResolver\AggregateResolver(); - $resolver->attach($serviceLocator->get('ViewTemplateMapResolver')); - $resolver->attach($serviceLocator->get('ViewTemplatePathStack')); + + /* @var $mapResolver \Zend\View\Resolver\ResolverInterface */ + $mapResolver = $serviceLocator->get('ViewTemplateMapResolver'); + /* @var $pathResolver \Zend\View\Resolver\ResolverInterface */ + $pathResolver = $serviceLocator->get('ViewTemplatePathStack'); + /* @var $prefixPathStackResolver \Zend\View\Resolver\ResolverInterface */ + $prefixPathStackResolver = $serviceLocator->get('ViewPrefixPathStackResolver'); + + $resolver + ->attach($mapResolver) + ->attach($pathResolver) + ->attach($prefixPathStackResolver) + ->attach(new ViewResolver\RelativeFallbackResolver($mapResolver)) + ->attach(new ViewResolver\RelativeFallbackResolver($pathResolver)) + ->attach(new ViewResolver\RelativeFallbackResolver($prefixPathStackResolver)); + return $resolver; } } diff --git a/library/Zend/Mvc/Service/ViewTemplateMapResolverFactory.php b/library/Zend/Mvc/Service/ViewTemplateMapResolverFactory.php index 1df38dbd..ca49219a 100644 --- a/library/Zend/Mvc/Service/ViewTemplateMapResolverFactory.php +++ b/library/Zend/Mvc/Service/ViewTemplateMapResolverFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/Service/ViewTemplatePathStackFactory.php b/library/Zend/Mvc/Service/ViewTemplatePathStackFactory.php index 8c028f76..dcf6ddd4 100644 --- a/library/Zend/Mvc/Service/ViewTemplatePathStackFactory.php +++ b/library/Zend/Mvc/Service/ViewTemplatePathStackFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Console/CreateViewModelListener.php b/library/Zend/Mvc/View/Console/CreateViewModelListener.php index 91eaf6d6..0403d3a4 100644 --- a/library/Zend/Mvc/View/Console/CreateViewModelListener.php +++ b/library/Zend/Mvc/View/Console/CreateViewModelListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php b/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php index dd7d6000..9bc5e2bd 100644 --- a/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php +++ b/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -15,6 +15,7 @@ use Zend\EventManager\EventManagerInterface; use Zend\Mvc\MvcEvent; use Zend\Stdlib\ResponseInterface as Response; use Zend\View\Model\ConsoleModel as ConsoleViewModel; +use Zend\View\Model\ModelInterface; class DefaultRenderingStrategy extends AbstractListenerAggregate { @@ -42,7 +43,7 @@ class DefaultRenderingStrategy extends AbstractListenerAggregate // marshal arguments $response = $e->getResponse(); - if (empty($result)) { + if (!$result instanceof ModelInterface) { // There is absolutely no result, so there's nothing to display. // We will return an empty response object return $response; @@ -51,6 +52,7 @@ class DefaultRenderingStrategy extends AbstractListenerAggregate // Collect results from child models $responseText = ''; if ($result->hasChildren()) { + /* @var ModelInterface $child */ foreach ($result->getChildren() as $child) { // Do not use ::getResult() method here as we cannot be sure if // children are also console models. diff --git a/library/Zend/Mvc/View/Console/ExceptionStrategy.php b/library/Zend/Mvc/View/Console/ExceptionStrategy.php index 380e6143..360684a3 100644 --- a/library/Zend/Mvc/View/Console/ExceptionStrategy.php +++ b/library/Zend/Mvc/View/Console/ExceptionStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -196,7 +196,8 @@ EOT; ':file', ':line', ':stack', - ),array( + ), + array( get_class($previousException), $previousException->getMessage(), $previousException->getCode(), @@ -219,7 +220,7 @@ EOT; ':line', ':stack', ':previous', - ),array( + ), array( get_class($exception), $exception->getMessage(), $exception->getCode(), @@ -240,7 +241,7 @@ EOT; ':line', ':stack', ':previous', - ),array( + ), array( '', '', '', diff --git a/library/Zend/Mvc/View/Console/InjectNamedConsoleParamsListener.php b/library/Zend/Mvc/View/Console/InjectNamedConsoleParamsListener.php index 18919365..5631105a 100644 --- a/library/Zend/Mvc/View/Console/InjectNamedConsoleParamsListener.php +++ b/library/Zend/Mvc/View/Console/InjectNamedConsoleParamsListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Console/InjectViewModelListener.php b/library/Zend/Mvc/View/Console/InjectViewModelListener.php index 985a1010..30895cb8 100644 --- a/library/Zend/Mvc/View/Console/InjectViewModelListener.php +++ b/library/Zend/Mvc/View/Console/InjectViewModelListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php b/library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php index af64e134..f30c80f0 100644 --- a/library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php +++ b/library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Console/ViewManager.php b/library/Zend/Mvc/View/Console/ViewManager.php index 2ca26438..0d0b2310 100644 --- a/library/Zend/Mvc/View/Console/ViewManager.php +++ b/library/Zend/Mvc/View/Console/ViewManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,20 +25,16 @@ class ViewManager extends BaseViewManager * algorithms, as well as to ensure we pick up the Console variants * of several listeners and strategies. * - * @param $event + * @param \Zend\Mvc\MvcEvent $event * @return void */ public function onBootstrap($event) { - $application = $event->getApplication(); - $services = $application->getServiceManager(); - $config = $services->get('Config'); - $events = $application->getEventManager(); - $sharedEvents = $events->getSharedManager(); - - $this->config = isset($config['view_manager']) && (is_array($config['view_manager']) || $config['view_manager'] instanceof ArrayAccess) - ? $config['view_manager'] - : array(); + $application = $event->getApplication(); + $services = $application->getServiceManager(); + $events = $application->getEventManager(); + $sharedEvents = $events->getSharedManager(); + $this->config = $this->loadConfig($services->get('Config')); $this->services = $services; $this->event = $event; @@ -148,4 +144,27 @@ class ViewManager extends BaseViewManager return $this->routeNotFoundStrategy; } + + /** + * Extract view manager configuration from the application's configuration + * + * @param array|ArrayAccess $configService + * + * @return array + */ + private function loadConfig($configService) + { + $config = array(); + + // override when console config is provided, otherwise use the standard definition + if (isset($configService['console']['view_manager'])) { + $config = $configService['console']['view_manager']; + } elseif (isset($configService['view_manager'])) { + $config = $configService['view_manager']; + } + + return ($config instanceof ArrayAccess || is_array($config)) + ? $config + : array(); + } } diff --git a/library/Zend/Mvc/View/Http/CreateViewModelListener.php b/library/Zend/Mvc/View/Http/CreateViewModelListener.php index d2282eb2..77b2029e 100644 --- a/library/Zend/Mvc/View/Http/CreateViewModelListener.php +++ b/library/Zend/Mvc/View/Http/CreateViewModelListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php b/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php index 0407d1a6..e3db51ed 100644 --- a/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php +++ b/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -77,7 +77,8 @@ class DefaultRenderingStrategy extends AbstractListenerAggregate * Render the view * * @param MvcEvent $e - * @return Response + * @return Response|null + * @throws \Exception */ public function render(MvcEvent $e) { diff --git a/library/Zend/Mvc/View/Http/ExceptionStrategy.php b/library/Zend/Mvc/View/Http/ExceptionStrategy.php index 1f888cd6..dc99f5e8 100644 --- a/library/Zend/Mvc/View/Http/ExceptionStrategy.php +++ b/library/Zend/Mvc/View/Http/ExceptionStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Http/InjectRoutematchParamsListener.php b/library/Zend/Mvc/View/Http/InjectRoutematchParamsListener.php index f68f0308..79228930 100644 --- a/library/Zend/Mvc/View/Http/InjectRoutematchParamsListener.php +++ b/library/Zend/Mvc/View/Http/InjectRoutematchParamsListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Http/InjectTemplateListener.php b/library/Zend/Mvc/View/Http/InjectTemplateListener.php index abb16ac8..644a0741 100644 --- a/library/Zend/Mvc/View/Http/InjectTemplateListener.php +++ b/library/Zend/Mvc/View/Http/InjectTemplateListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,6 +32,13 @@ class InjectTemplateListener extends AbstractListenerAggregate */ protected $controllerMap = array(); + /** + * Flag to force the use of the route match controller param + * + * @var boolean + */ + protected $preferRouteMatchController = false; + /** * {@inheritDoc} */ @@ -66,8 +73,10 @@ class InjectTemplateListener extends AbstractListenerAggregate if (is_object($controller)) { $controller = get_class($controller); } - if (!$controller) { - $controller = $routeMatch->getParam('controller', ''); + + $routeMatchController = $routeMatch->getParam('controller', ''); + if (!$controller || ($this->preferRouteMatchController && $routeMatchController)) { + $controller = $routeMatchController; } $template = $this->mapController($controller); @@ -122,6 +131,10 @@ class InjectTemplateListener extends AbstractListenerAggregate */ public function mapController($controller) { + if (! is_string($controller)) { + return false; + } + foreach ($this->controllerMap as $namespace => $replacement) { if ( // Allow disabling rule by setting value to false since config @@ -137,7 +150,7 @@ class InjectTemplateListener extends AbstractListenerAggregate // Map namespace to $replacement if its value is string if (is_string($replacement)) { $map = rtrim($replacement, '/') . '/'; - $controller = substr($controller, strlen($namespace) + 1); + $controller = substr($controller, strlen($namespace) + 1) ?: ''; } //strip Controller namespace(s) (but not classname) @@ -227,4 +240,23 @@ class InjectTemplateListener extends AbstractListenerAggregate return $controller; } + + /** + * Sets the flag to instruct the listener to prefer the route match controller param + * over the class name + * + * @param boolean $preferRouteMatchController + */ + public function setPreferRouteMatchController($preferRouteMatchController) + { + $this->preferRouteMatchController = (bool) $preferRouteMatchController; + } + + /** + * @return boolean + */ + public function isPreferRouteMatchController() + { + return $this->preferRouteMatchController; + } } diff --git a/library/Zend/Mvc/View/Http/InjectViewModelListener.php b/library/Zend/Mvc/View/Http/InjectViewModelListener.php index 2115984a..dc9bd7c5 100644 --- a/library/Zend/Mvc/View/Http/InjectViewModelListener.php +++ b/library/Zend/Mvc/View/Http/InjectViewModelListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php b/library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php index 718e774d..951d4f75 100644 --- a/library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php +++ b/library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/View/Http/ViewManager.php b/library/Zend/Mvc/View/Http/ViewManager.php index 168962fa..d6c85583 100644 --- a/library/Zend/Mvc/View/Http/ViewManager.php +++ b/library/Zend/Mvc/View/Http/ViewManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -332,11 +332,7 @@ class ViewManager extends AbstractListenerAggregate public function getInjectTemplateListener() { - $listener = new InjectTemplateListener(); - if (isset($this->config['controller_map'])) { - $listener->setControllerMap($this->config['controller_map']); - } - return $listener; + return $this->services->get('Zend\Mvc\View\Http\InjectTemplateListener'); } /** @@ -364,6 +360,9 @@ class ViewManager extends AbstractListenerAggregate * is a ListenerAggregate, attach it to the view, at priority 100. This * latter allows each to trigger before the default mvc rendering strategy, * and for them to trigger in the order they are registered. + * + * @param EventManagerInterface $events + * @return void */ protected function registerMvcRenderingStrategies(EventManagerInterface $events) { diff --git a/library/Zend/Mvc/View/SendResponseListener.php b/library/Zend/Mvc/View/SendResponseListener.php index 275fb8c5..0e1ebb84 100644 --- a/library/Zend/Mvc/View/SendResponseListener.php +++ b/library/Zend/Mvc/View/SendResponseListener.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Mvc/composer.json b/library/Zend/Mvc/composer.json index 68483df1..fc18b2a6 100644 --- a/library/Zend/Mvc/composer.json +++ b/library/Zend/Mvc/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Mvc\\": "" } }, - "target-dir": "Zend/Mvc", "require": { "php": ">=5.3.23", "zendframework/zend-eventmanager": "self.version", @@ -63,8 +62,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Navigation/AbstractContainer.php b/library/Zend/Navigation/AbstractContainer.php index 1308803f..596ee22b 100644 --- a/library/Zend/Navigation/AbstractContainer.php +++ b/library/Zend/Navigation/AbstractContainer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -303,7 +303,7 @@ abstract class AbstractContainer implements Countable, RecursiveIterator } } - return null; + return; } /** @@ -502,7 +502,7 @@ abstract class AbstractContainer implements Countable, RecursiveIterator return $this->pages[$hash]; } - return null; + return; } // Countable interface: diff --git a/library/Zend/Navigation/Exception/BadMethodCallException.php b/library/Zend/Navigation/Exception/BadMethodCallException.php index 3e5f6600..af2be268 100644 --- a/library/Zend/Navigation/Exception/BadMethodCallException.php +++ b/library/Zend/Navigation/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Exception/DomainException.php b/library/Zend/Navigation/Exception/DomainException.php index ce106f67..11dafd28 100644 --- a/library/Zend/Navigation/Exception/DomainException.php +++ b/library/Zend/Navigation/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Exception/ExceptionInterface.php b/library/Zend/Navigation/Exception/ExceptionInterface.php index f921eb48..dc841acf 100644 --- a/library/Zend/Navigation/Exception/ExceptionInterface.php +++ b/library/Zend/Navigation/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Exception/InvalidArgumentException.php b/library/Zend/Navigation/Exception/InvalidArgumentException.php index 45715b4e..5e36fa5b 100644 --- a/library/Zend/Navigation/Exception/InvalidArgumentException.php +++ b/library/Zend/Navigation/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Exception/OutOfBoundsException.php b/library/Zend/Navigation/Exception/OutOfBoundsException.php index 97854a49..edfd5c79 100644 --- a/library/Zend/Navigation/Exception/OutOfBoundsException.php +++ b/library/Zend/Navigation/Exception/OutOfBoundsException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Navigation.php b/library/Zend/Navigation/Navigation.php index dede898e..2c2dd5b5 100644 --- a/library/Zend/Navigation/Navigation.php +++ b/library/Zend/Navigation/Navigation.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Page/AbstractPage.php b/library/Zend/Navigation/Page/AbstractPage.php index d64a6d53..ca784d6f 100644 --- a/library/Zend/Navigation/Page/AbstractPage.php +++ b/library/Zend/Navigation/Page/AbstractPage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -1001,7 +1001,7 @@ abstract class AbstractPage extends AbstractContainer return $this->properties[$property]; } - return null; + return; } // Magic overloads: diff --git a/library/Zend/Navigation/Page/Mvc.php b/library/Zend/Navigation/Page/Mvc.php index 449b301f..324d2ed9 100644 --- a/library/Zend/Navigation/Page/Mvc.php +++ b/library/Zend/Navigation/Page/Mvc.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -130,18 +130,18 @@ class Mvc extends AbstractPage $reqParams['controller'] = $reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER]; } - $myParams = $this->params; + $pageParams = $this->params; if (null !== $this->controller) { - $myParams['controller'] = $this->controller; + $pageParams['controller'] = $this->controller; } if (null !== $this->action) { - $myParams['action'] = $this->action; + $pageParams['action'] = $this->action; } if (null !== $this->getRoute()) { if ( $this->routeMatch->getMatchedRouteName() === $this->getRoute() - && (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) + && (count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)) ) { $this->active = true; return $this->active; @@ -151,27 +151,27 @@ class Mvc extends AbstractPage } } - $myParams = $this->params; + $pageParams = $this->params; if (null !== $this->controller) { - $myParams['controller'] = $this->controller; + $pageParams['controller'] = $this->controller; } else { /** * @todo In ZF1, this was configurable and pulled from the front controller */ - $myParams['controller'] = 'index'; + $pageParams['controller'] = 'index'; } if (null !== $this->action) { - $myParams['action'] = $this->action; + $pageParams['action'] = $this->action; } else { /** * @todo In ZF1, this was configurable and pulled from the front controller */ - $myParams['action'] = 'index'; + $pageParams['action'] = 'index'; } - if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) { + if (count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)) { $this->active = true; return true; } @@ -226,11 +226,11 @@ class Mvc extends AbstractPage } - if (($param = $this->getController()) != null) { + if (($param = $this->getController()) !== null) { $params['controller'] = $param; } - if (($param = $this->getAction()) != null) { + if (($param = $this->getAction()) !== null) { $params['action'] = $param; } diff --git a/library/Zend/Navigation/Page/Uri.php b/library/Zend/Navigation/Page/Uri.php index ebdc0f4e..e07c886d 100644 --- a/library/Zend/Navigation/Page/Uri.php +++ b/library/Zend/Navigation/Page/Uri.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Service/AbstractNavigationFactory.php b/library/Zend/Navigation/Service/AbstractNavigationFactory.php index d25678d4..08fc8aec 100644 --- a/library/Zend/Navigation/Service/AbstractNavigationFactory.php +++ b/library/Zend/Navigation/Service/AbstractNavigationFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -73,6 +73,7 @@ abstract class AbstractNavigationFactory implements FactoryInterface /** * @param ServiceLocatorInterface $serviceLocator * @param array|\Zend\Config\Config $pages + * @return null|array * @throws \Zend\Navigation\Exception\InvalidArgumentException */ protected function preparePages(ServiceLocatorInterface $serviceLocator, $pages) @@ -122,10 +123,14 @@ abstract class AbstractNavigationFactory implements FactoryInterface * @param RouteMatch $routeMatch * @param Router $router * @param null|Request $request - * @return mixed + * @return array */ - protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null, $request = null) - { + protected function injectComponents( + array $pages, + RouteMatch $routeMatch = null, + Router $router = null, + $request = null + ) { foreach ($pages as &$page) { $hasUri = isset($page['uri']); $hasMvc = isset($page['action']) || isset($page['controller']) || isset($page['route']); diff --git a/library/Zend/Navigation/Service/ConstructedNavigationFactory.php b/library/Zend/Navigation/Service/ConstructedNavigationFactory.php index 363c2b2e..7c3e281c 100644 --- a/library/Zend/Navigation/Service/ConstructedNavigationFactory.php +++ b/library/Zend/Navigation/Service/ConstructedNavigationFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Service/DefaultNavigationFactory.php b/library/Zend/Navigation/Service/DefaultNavigationFactory.php index 771666d7..3e06179c 100644 --- a/library/Zend/Navigation/Service/DefaultNavigationFactory.php +++ b/library/Zend/Navigation/Service/DefaultNavigationFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/Service/NavigationAbstractServiceFactory.php b/library/Zend/Navigation/Service/NavigationAbstractServiceFactory.php new file mode 100644 index 00000000..23849f26 --- /dev/null +++ b/library/Zend/Navigation/Service/NavigationAbstractServiceFactory.php @@ -0,0 +1,122 @@ +get('Zend\Navigation\Special') to retrieve a navigation instance with this configuration. + */ +final class NavigationAbstractServiceFactory implements AbstractFactoryInterface +{ + /** + * Top-level configuration key indicating navigation configuration + * + * @var string + */ + const CONFIG_KEY = 'navigation'; + + /** + * Service manager factory prefix + * + * @var string + */ + const SERVICE_PREFIX = 'Zend\Navigation\\'; + + /** + * Normalized name prefix + */ + const NAME_PREFIX = 'zendnavigation'; + + /** + * Navigation configuration + * + * @var array + */ + protected $config; + + /** + * Can we create a navigation by the requested name? + * + * @param ServiceLocatorInterface $serviceLocator + * @param string $name Service name (as resolved by ServiceManager) + * @param string $requestedName Name by which service was requested, must start with Zend\Navigation\ + * @return bool + */ + public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + { + if (0 !== strpos($name, self::NAME_PREFIX)) { + return false; + } + $config = $this->getConfig($serviceLocator); + + return (!empty($config[$this->getConfigName($name)])); + } + + /** + * Create a navigation container + * + * @param ServiceLocatorInterface $serviceLocator + * @param string $name Service name (as resolved by ServiceManager) + * @param string $requestedName Name by which service was requested + * @return Navigation + */ + public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + { + $config = $this->getConfig($serviceLocator); + $factory = new ConstructedNavigationFactory($config[$this->getConfigName($name)]); + return $factory->createService($serviceLocator); + } + + /** + * Get navigation configuration, if any + * + * @param ServiceLocatorInterface $services + * @return array + */ + protected function getConfig(ServiceLocatorInterface $services) + { + if ($this->config !== null) { + return $this->config; + } + + if (!$services->has('Config')) { + $this->config = array(); + return $this->config; + } + + $config = $services->get('Config'); + if (!isset($config[self::CONFIG_KEY]) + || !is_array($config[self::CONFIG_KEY]) + ) { + $this->config = array(); + return $this->config; + } + + $this->config = $config[self::CONFIG_KEY]; + return $this->config; + } + + /** + * Extract config name from service name + * + * @param string $name + * @return string + */ + protected function getConfigName($name) + { + return substr($name, strlen(self::NAME_PREFIX)); + } +} diff --git a/library/Zend/Navigation/View/HelperConfig.php b/library/Zend/Navigation/View/HelperConfig.php index af3c2d61..f831691f 100644 --- a/library/Zend/Navigation/View/HelperConfig.php +++ b/library/Zend/Navigation/View/HelperConfig.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Navigation/composer.json b/library/Zend/Navigation/composer.json index 8c0ec78f..67ad7c46 100644 --- a/library/Zend/Navigation/composer.json +++ b/library/Zend/Navigation/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Navigation\\": "" } }, - "target-dir": "Zend/Navigation", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -33,8 +32,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Paginator/Adapter/AdapterInterface.php b/library/Zend/Paginator/Adapter/AdapterInterface.php index faf74e26..513517e9 100644 --- a/library/Zend/Paginator/Adapter/AdapterInterface.php +++ b/library/Zend/Paginator/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/ArrayAdapter.php b/library/Zend/Paginator/Adapter/ArrayAdapter.php index a713b19d..90a5dc16 100644 --- a/library/Zend/Paginator/Adapter/ArrayAdapter.php +++ b/library/Zend/Paginator/Adapter/ArrayAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Callback.php b/library/Zend/Paginator/Adapter/Callback.php index 2bf1a0cb..412736b9 100644 --- a/library/Zend/Paginator/Adapter/Callback.php +++ b/library/Zend/Paginator/Adapter/Callback.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/DbSelect.php b/library/Zend/Paginator/Adapter/DbSelect.php index 29f7317b..baae5856 100644 --- a/library/Zend/Paginator/Adapter/DbSelect.php +++ b/library/Zend/Paginator/Adapter/DbSelect.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -18,29 +18,38 @@ use Zend\Db\ResultSet\ResultSetInterface; class DbSelect implements AdapterInterface { + const ROW_COUNT_COLUMN_NAME = 'C'; + /** * @var Sql */ - protected $sql = null; + protected $sql; /** * Database query * * @var Select */ - protected $select = null; + protected $select; + + /** + * Database count query + * + * @var Select|null + */ + protected $countSelect; /** * @var ResultSet */ - protected $resultSetPrototype = null; + protected $resultSetPrototype; /** * Total item count * * @var int */ - protected $rowCount = null; + protected $rowCount; /** * Constructor. @@ -48,11 +57,18 @@ class DbSelect implements AdapterInterface * @param Select $select The select query * @param Adapter|Sql $adapterOrSqlObject DB adapter or Sql object * @param null|ResultSetInterface $resultSetPrototype + * @param null|Select $countSelect + * * @throws Exception\InvalidArgumentException */ - public function __construct(Select $select, $adapterOrSqlObject, ResultSetInterface $resultSetPrototype = null) - { + public function __construct( + Select $select, + $adapterOrSqlObject, + ResultSetInterface $resultSetPrototype = null, + Select $countSelect = null + ) { $this->select = $select; + $this->countSelect = $countSelect; if ($adapterOrSqlObject instanceof Adapter) { $adapterOrSqlObject = new Sql($adapterOrSqlObject); @@ -87,7 +103,7 @@ class DbSelect implements AdapterInterface $resultSet = clone $this->resultSetPrototype; $resultSet->initialize($result); - return $resultSet; + return iterator_to_array($resultSet); } /** @@ -101,21 +117,38 @@ class DbSelect implements AdapterInterface return $this->rowCount; } + $select = $this->getSelectCount(); + + $statement = $this->sql->prepareStatementForSqlObject($select); + $result = $statement->execute(); + $row = $result->current(); + + $this->rowCount = (int) $row[self::ROW_COUNT_COLUMN_NAME]; + + return $this->rowCount; + } + + /** + * Returns select query for count + * + * @return Select + */ + protected function getSelectCount() + { + if ($this->countSelect) { + return $this->countSelect; + } + $select = clone $this->select; $select->reset(Select::LIMIT); $select->reset(Select::OFFSET); $select->reset(Select::ORDER); $countSelect = new Select; - $countSelect->columns(array('c' => new Expression('COUNT(1)'))); + + $countSelect->columns(array(self::ROW_COUNT_COLUMN_NAME => new Expression('COUNT(1)'))); $countSelect->from(array('original_select' => $select)); - $statement = $this->sql->prepareStatementForSqlObject($countSelect); - $result = $statement->execute(); - $row = $result->current(); - - $this->rowCount = $row['c']; - - return $this->rowCount; + return $countSelect; } } diff --git a/library/Zend/Paginator/Adapter/DbTableGateway.php b/library/Zend/Paginator/Adapter/DbTableGateway.php index 447f7726..8f2b30f7 100644 --- a/library/Zend/Paginator/Adapter/DbTableGateway.php +++ b/library/Zend/Paginator/Adapter/DbTableGateway.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Exception/ExceptionInterface.php b/library/Zend/Paginator/Adapter/Exception/ExceptionInterface.php index 492a1fda..71d02ea0 100644 --- a/library/Zend/Paginator/Adapter/Exception/ExceptionInterface.php +++ b/library/Zend/Paginator/Adapter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Exception/InvalidArgumentException.php b/library/Zend/Paginator/Adapter/Exception/InvalidArgumentException.php index ed1ade69..f8b76a87 100644 --- a/library/Zend/Paginator/Adapter/Exception/InvalidArgumentException.php +++ b/library/Zend/Paginator/Adapter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Exception/RuntimeException.php b/library/Zend/Paginator/Adapter/Exception/RuntimeException.php index 43b0c1de..85868d2c 100644 --- a/library/Zend/Paginator/Adapter/Exception/RuntimeException.php +++ b/library/Zend/Paginator/Adapter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Exception/UnexpectedValueException.php b/library/Zend/Paginator/Adapter/Exception/UnexpectedValueException.php index c7d4c030..bf956f58 100644 --- a/library/Zend/Paginator/Adapter/Exception/UnexpectedValueException.php +++ b/library/Zend/Paginator/Adapter/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Iterator.php b/library/Zend/Paginator/Adapter/Iterator.php index 8b2e760a..ebbc1d7f 100644 --- a/library/Zend/Paginator/Adapter/Iterator.php +++ b/library/Zend/Paginator/Adapter/Iterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -16,7 +16,7 @@ class Iterator implements AdapterInterface /** * Iterator which implements Countable * - * @var Iterator + * @var \Iterator */ protected $iterator = null; diff --git a/library/Zend/Paginator/Adapter/Null.php b/library/Zend/Paginator/Adapter/Null.php index 557c03c8..3ea9e564 100644 --- a/library/Zend/Paginator/Adapter/Null.php +++ b/library/Zend/Paginator/Adapter/Null.php @@ -3,57 +3,28 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Paginator\Adapter; -class Null implements AdapterInterface +class Null extends NullFill { /** - * Item count - * - * @var int - */ - protected $count = null; - - /** - * Constructor. - * - * @param int $count Total item count (Optional) + * {@inheritdoc} */ public function __construct($count = 0) { - $this->count = $count; - } + trigger_error( + sprintf( + 'The class %s has been deprecated; please use %s\\NullFill', + __CLASS__, + __NAMESPACE__ + ), + E_USER_DEPRECATED + ); - /** - * Returns an array of items for a page. - * - * @param int $offset Page offset - * @param int $itemCountPerPage Number of items per page - * @return array - */ - public function getItems($offset, $itemCountPerPage) - { - if ($offset >= $this->count()) { - return array(); - } - - $remainItemCount = $this->count() - $offset; - $currentItemCount = $remainItemCount > $itemCountPerPage ? $itemCountPerPage : $remainItemCount; - - return array_fill(0, $currentItemCount, null); - } - - /** - * Returns the total number of rows in the array. - * - * @return int - */ - public function count() - { - return $this->count; + parent::__construct($count); } } diff --git a/library/Zend/Paginator/Adapter/NullFill.php b/library/Zend/Paginator/Adapter/NullFill.php new file mode 100644 index 00000000..9786964c --- /dev/null +++ b/library/Zend/Paginator/Adapter/NullFill.php @@ -0,0 +1,59 @@ +count = $count; + } + + /** + * Returns an array of items for a page. + * + * @param int $offset Page offset + * @param int $itemCountPerPage Number of items per page + * @return array + */ + public function getItems($offset, $itemCountPerPage) + { + if ($offset >= $this->count()) { + return array(); + } + + $remainItemCount = $this->count() - $offset; + $currentItemCount = $remainItemCount > $itemCountPerPage ? $itemCountPerPage : $remainItemCount; + + return array_fill(0, $currentItemCount, null); + } + + /** + * Returns the total number of rows in the array. + * + * @return int + */ + public function count() + { + return $this->count; + } +} diff --git a/library/Zend/Paginator/Adapter/Service/CallbackFactory.php b/library/Zend/Paginator/Adapter/Service/CallbackFactory.php index 97fdb747..e59d6509 100644 --- a/library/Zend/Paginator/Adapter/Service/CallbackFactory.php +++ b/library/Zend/Paginator/Adapter/Service/CallbackFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Adapter/Service/DbSelectFactory.php b/library/Zend/Paginator/Adapter/Service/DbSelectFactory.php index dea2dc37..662881c5 100644 --- a/library/Zend/Paginator/Adapter/Service/DbSelectFactory.php +++ b/library/Zend/Paginator/Adapter/Service/DbSelectFactory.php @@ -3,39 +3,47 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Paginator\Adapter\Service; +use Zend\Paginator\Adapter\DbSelect; use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\MutableCreationOptionsInterface; use Zend\ServiceManager\ServiceLocatorInterface; -class DbSelectFactory implements FactoryInterface +class DbSelectFactory implements + FactoryInterface, + MutableCreationOptionsInterface { /** * Adapter options + * * @var array */ protected $creationOptions; /** - * Construct with adapter options - * @param array $creationOptions + * {@inheritDoc} */ - public function __construct(array $creationOptions) + public function setCreationOptions(array $creationOptions) { $this->creationOptions = $creationOptions; } /** - * @param ServiceLocatorInterface $serviceLocator + * {@inheritDoc} + * * @return \Zend\Paginator\Adapter\DbSelect */ public function createService(ServiceLocatorInterface $serviceLocator) { - $class = new \ReflectionClass('Zend\Paginator\Adapter\DbSelect'); - return $class->newInstanceArgs($this->creationOptions); + return new DbSelect( + $this->creationOptions[0], + $this->creationOptions[1], + isset($this->creationOptions[2]) ? $this->creationOptions[2] : null + ); } } diff --git a/library/Zend/Paginator/Adapter/Service/DbTableGatewayFactory.php b/library/Zend/Paginator/Adapter/Service/DbTableGatewayFactory.php index 7c8f60f5..e849fec5 100644 --- a/library/Zend/Paginator/Adapter/Service/DbTableGatewayFactory.php +++ b/library/Zend/Paginator/Adapter/Service/DbTableGatewayFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/AdapterAggregateInterface.php b/library/Zend/Paginator/AdapterAggregateInterface.php index 4b50b458..da00a86e 100644 --- a/library/Zend/Paginator/AdapterAggregateInterface.php +++ b/library/Zend/Paginator/AdapterAggregateInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/AdapterPluginManager.php b/library/Zend/Paginator/AdapterPluginManager.php index df9405d9..ad5e7a38 100644 --- a/library/Zend/Paginator/AdapterPluginManager.php +++ b/library/Zend/Paginator/AdapterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,6 +20,19 @@ use Zend\ServiceManager\AbstractPluginManager; */ class AdapterPluginManager extends AbstractPluginManager { + /** + * Default aliases + * + * Primarily for ensuring previously defined adapters select their + * current counterparts. + * + * @var array + */ + protected $aliases = array( + 'null' => 'nullfill', + 'Zend\Paginator\Adapter\Null' => 'nullfill', + ); + /** * Default set of adapters * @@ -28,7 +41,7 @@ class AdapterPluginManager extends AbstractPluginManager protected $invokableClasses = array( 'array' => 'Zend\Paginator\Adapter\ArrayAdapter', 'iterator' => 'Zend\Paginator\Adapter\Iterator', - 'null' => 'Zend\Paginator\Adapter\Null', + 'nullfill' => 'Zend\Paginator\Adapter\NullFill', ); /** diff --git a/library/Zend/Paginator/Exception/ExceptionInterface.php b/library/Zend/Paginator/Exception/ExceptionInterface.php index ccf56213..25f5a3bb 100644 --- a/library/Zend/Paginator/Exception/ExceptionInterface.php +++ b/library/Zend/Paginator/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Exception/InvalidArgumentException.php b/library/Zend/Paginator/Exception/InvalidArgumentException.php index d5b62aaf..1e158e98 100644 --- a/library/Zend/Paginator/Exception/InvalidArgumentException.php +++ b/library/Zend/Paginator/Exception/InvalidArgumentException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Paginator\Exception; -class InvalidArgumentException - extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Paginator/Exception/RuntimeException.php b/library/Zend/Paginator/Exception/RuntimeException.php index 00bb7f74..06401f0f 100644 --- a/library/Zend/Paginator/Exception/RuntimeException.php +++ b/library/Zend/Paginator/Exception/RuntimeException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Paginator\Exception; -class RuntimeException - extends \RuntimeException - implements ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Paginator/Exception/UnexpectedValueException.php b/library/Zend/Paginator/Exception/UnexpectedValueException.php index d655f29b..42d1736d 100644 --- a/library/Zend/Paginator/Exception/UnexpectedValueException.php +++ b/library/Zend/Paginator/Exception/UnexpectedValueException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Paginator\Exception; -class UnexpectedValueException - extends \UnexpectedValueException - implements ExceptionInterface +class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface { } diff --git a/library/Zend/Paginator/Factory.php b/library/Zend/Paginator/Factory.php index 790f51b7..afba3da7 100644 --- a/library/Zend/Paginator/Factory.php +++ b/library/Zend/Paginator/Factory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/Paginator.php b/library/Zend/Paginator/Paginator.php index 93dcc423..e524f44b 100644 --- a/library/Zend/Paginator/Paginator.php +++ b/library/Zend/Paginator/Paginator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -140,7 +140,7 @@ class Paginator implements Countable, IteratorAggregate /** * Pages * - * @var array + * @var \stdClass */ protected $pages = null; @@ -176,7 +176,7 @@ class Paginator implements Countable, IteratorAggregate $scrollingStyle = isset($config['scrolling_style']) ? $config['scrolling_style'] : null; - if ($scrollingStyle != null) { + if ($scrollingStyle !== null) { static::setDefaultScrollingStyle($scrollingStyle); } } @@ -294,7 +294,7 @@ class Paginator implements Countable, IteratorAggregate $key = strtolower($setupMethod); $value = isset($config[$key]) ? $config[$key] : null; - if ($value != null) { + if ($value !== null) { $setupMethod = 'set' . $setupMethod; $this->$setupMethod($value); } @@ -372,11 +372,8 @@ class Paginator implements Countable, IteratorAggregate $cacheIterator = static::$cache->getIterator(); $cacheIterator->setMode(CacheIterator::CURRENT_AS_KEY); foreach ($cacheIterator as $key) { - $tags = static::$cache->getTags($key); - if ($tags && in_array($this->_getCacheInternalId(), $tags)) { - if (substr($key, 0, $prefixLength) == self::CACHE_TAG_PREFIX) { - static::$cache->removeItem($this->_getCacheId((int)substr($key, $prefixLength))); - } + if (substr($key, 0, $prefixLength) == self::CACHE_TAG_PREFIX) { + static::$cache->removeItem($this->_getCacheId((int)substr($key, $prefixLength))); } } } else { @@ -397,7 +394,7 @@ class Paginator implements Countable, IteratorAggregate { $relativeItemNumber = $this->normalizeItemNumber($relativeItemNumber); - if ($pageNumber == null) { + if ($pageNumber === null) { $pageNumber = $this->getCurrentPageNumber(); } @@ -503,7 +500,7 @@ class Paginator implements Countable, IteratorAggregate */ public function getItem($itemNumber, $pageNumber = null) { - if ($pageNumber == null) { + if ($pageNumber === null) { $pageNumber = $this->getCurrentPageNumber(); } elseif ($pageNumber < 0) { $pageNumber = ($this->count() + 1) + $pageNumber; @@ -523,8 +520,9 @@ class Paginator implements Countable, IteratorAggregate $itemNumber = $this->normalizeItemNumber($itemNumber); if ($itemNumber > $itemCount) { - throw new Exception\InvalidArgumentException('Page ' . $pageNumber . ' does not' - . ' contain item number ' . $itemNumber); + throw new Exception\InvalidArgumentException( + "Page {$pageNumber} does not contain item number {$itemNumber}" + ); } return $page[$itemNumber - 1]; @@ -616,7 +614,6 @@ class Paginator implements Countable, IteratorAggregate if ($this->cacheEnabled()) { $cacheId = $this->_getCacheId($pageNumber); static::$cache->setItem($cacheId, $items); - static::$cache->setTags($cacheId, array($this->_getCacheInternalId())); } return $items; @@ -664,7 +661,7 @@ class Paginator implements Countable, IteratorAggregate * Returns the page collection. * * @param string $scrollingStyle Scrolling style - * @return array + * @return \stdClass */ public function getPages($scrollingStyle = null) { @@ -709,11 +706,8 @@ class Paginator implements Countable, IteratorAggregate $cacheIterator = static::$cache->getIterator(); $cacheIterator->setMode(CacheIterator::CURRENT_AS_VALUE); foreach ($cacheIterator as $key => $value) { - $tags = static::$cache->getTags($key); - if ($tags && in_array($this->_getCacheInternalId(), $tags)) { - if (substr($key, 0, $prefixLength) == self::CACHE_TAG_PREFIX) { - $data[(int) substr($key, $prefixLength)] = $value; - } + if (substr($key, 0, $prefixLength) == self::CACHE_TAG_PREFIX) { + $data[(int) substr($key, $prefixLength)] = $value; } } } @@ -916,10 +910,13 @@ class Paginator implements Countable, IteratorAggregate // Item numbers if ($this->getCurrentItems() !== null) { $pages->currentItemCount = $this->getCurrentItemCount(); - $pages->itemCountPerPage = $this->getItemCountPerPage(); $pages->totalItemCount = $this->getTotalItemCount(); - $pages->firstItemNumber = (($currentPageNumber - 1) * $this->getItemCountPerPage()) + 1; - $pages->lastItemNumber = $pages->firstItemNumber + $pages->currentItemCount - 1; + $pages->firstItemNumber = $pages->totalItemCount + ? (($currentPageNumber - 1) * $pages->itemCountPerPage) + 1 + : 0; + $pages->lastItemNumber = $pages->totalItemCount + ? $pages->firstItemNumber + $pages->currentItemCount - 1 + : 0; } return $pages; diff --git a/library/Zend/Paginator/PaginatorIterator.php b/library/Zend/Paginator/PaginatorIterator.php new file mode 100644 index 00000000..1c8b1eae --- /dev/null +++ b/library/Zend/Paginator/PaginatorIterator.php @@ -0,0 +1,124 @@ +paginator = $paginator; + } + + /** + * Return the current element + * @link http://php.net/manual/en/iterator.current.php + * @return mixed Can return any type. + */ + public function current() + { + return $this->getInnerIterator()->current(); + } + + /** + * Move forward to next element + * @link http://php.net/manual/en/iterator.next.php + * @return void Any returned value is ignored. + */ + public function next() + { + $innerIterator = $this->getInnerIterator(); + $innerIterator->next(); + + if ($innerIterator->valid()) { + return; + } + + $page = $this->paginator->getCurrentPageNumber(); + $nextPage = $page + 1; + $this->paginator->setCurrentPageNumber($nextPage); + + $page = $this->paginator->getCurrentPageNumber(); + if ($page !== $nextPage) { + $this->valid = false; + } + } + + /** + * Return the key of the current element + * @link http://php.net/manual/en/iterator.key.php + * @return mixed scalar on success, or null on failure. + */ + public function key() + { + $innerKey = $this->getInnerIterator()->key(); + $innerKey += 1; //Zend\Paginator\Paginator normalizes 0 to 1 + + $page = $this->paginator->getCurrentPageNumber(); + return ($this->paginator->getAbsoluteItemNumber( + $innerKey, + $this->paginator->getCurrentPageNumber() + )) - 1; + } + + /** + * Checks if current position is valid + * @link http://php.net/manual/en/iterator.valid.php + * @return boolean The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. + */ + public function valid() + { + if (count($this->paginator) < 1) { + $this->valid = false; + } + return $this->valid; + } + + /** + * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. + */ + public function rewind() + { + $this->paginator->setCurrentPageNumber(1); + $this->valid = true; + } + + /** + * Returns the inner iterator for the current entry. + * @link http://php.net/manual/en/outeriterator.getinneriterator.php + * @return \Iterator The inner iterator for the current entry. + */ + public function getInnerIterator() + { + return $this->paginator->getCurrentItems(); + } +} diff --git a/library/Zend/Paginator/ScrollingStyle/All.php b/library/Zend/Paginator/ScrollingStyle/All.php index c22d807a..c7f44b82 100644 --- a/library/Zend/Paginator/ScrollingStyle/All.php +++ b/library/Zend/Paginator/ScrollingStyle/All.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/ScrollingStyle/Elastic.php b/library/Zend/Paginator/ScrollingStyle/Elastic.php index 07d0e344..8183ae2e 100644 --- a/library/Zend/Paginator/ScrollingStyle/Elastic.php +++ b/library/Zend/Paginator/ScrollingStyle/Elastic.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/ScrollingStyle/Jumping.php b/library/Zend/Paginator/ScrollingStyle/Jumping.php index 705d2e9e..f560c9b7 100644 --- a/library/Zend/Paginator/ScrollingStyle/Jumping.php +++ b/library/Zend/Paginator/ScrollingStyle/Jumping.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/ScrollingStyle/ScrollingStyleInterface.php b/library/Zend/Paginator/ScrollingStyle/ScrollingStyleInterface.php index eeb92c92..3bf7c979 100644 --- a/library/Zend/Paginator/ScrollingStyle/ScrollingStyleInterface.php +++ b/library/Zend/Paginator/ScrollingStyle/ScrollingStyleInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/ScrollingStyle/Sliding.php b/library/Zend/Paginator/ScrollingStyle/Sliding.php index 57fed038..00ecf508 100644 --- a/library/Zend/Paginator/ScrollingStyle/Sliding.php +++ b/library/Zend/Paginator/ScrollingStyle/Sliding.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/ScrollingStylePluginManager.php b/library/Zend/Paginator/ScrollingStylePluginManager.php index 09e78335..8c6b4bed 100644 --- a/library/Zend/Paginator/ScrollingStylePluginManager.php +++ b/library/Zend/Paginator/ScrollingStylePluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Paginator/SerializableLimitIterator.php b/library/Zend/Paginator/SerializableLimitIterator.php index 46755a15..c67b2f8f 100644 --- a/library/Zend/Paginator/SerializableLimitIterator.php +++ b/library/Zend/Paginator/SerializableLimitIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,7 +38,7 @@ class SerializableLimitIterator extends LimitIterator implements Serializable, A * @param int $count Maximum number of elements to show or -1 for all * @see LimitIterator::__construct */ - public function __construct(Iterator $it, $offset=0, $count=-1) + public function __construct(Iterator $it, $offset = 0, $count = -1) { parent::__construct($it, $offset, $count); $this->offset = $offset; diff --git a/library/Zend/Paginator/composer.json b/library/Zend/Paginator/composer.json index a9425751..3a304077 100644 --- a/library/Zend/Paginator/composer.json +++ b/library/Zend/Paginator/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Paginator\\": "" } }, - "target-dir": "Zend/Paginator", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -35,8 +34,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Permissions/Acl/Acl.php b/library/Zend/Permissions/Acl/Acl.php index b0365ec8..1b7887b0 100644 --- a/library/Zend/Permissions/Acl/Acl.php +++ b/library/Zend/Permissions/Acl/Acl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -108,7 +108,6 @@ class Acl implements AclInterface ); } - $this->getRoleRegistry()->add($role, $parents); return $this; @@ -522,8 +521,13 @@ class Acl implements AclInterface * @throws Exception\InvalidArgumentException * @return Acl Provides a fluent interface */ - public function setRule($operation, $type, $roles = null, $resources = null, - $privileges = null, Assertion\AssertionInterface $assert = null + public function setRule( + $operation, + $type, + $roles = null, + $resources = null, + $privileges = null, + Assertion\AssertionInterface $assert = null ) { // ensure that the rule type is valid; normalize input to uppercase $type = strtoupper($type); @@ -632,16 +636,12 @@ class Acl implements AclInterface continue; } - if (isset($rules['allPrivileges']['type']) && - $type === $rules['allPrivileges']['type'] - ) { + if (isset($rules['allPrivileges']['type']) && $type === $rules['allPrivileges']['type']) { unset($rules['allPrivileges']); } } else { foreach ($privileges as $privilege) { - if (isset($rules['byPrivilegeId'][$privilege]) && - $type === $rules['byPrivilegeId'][$privilege]['type'] - ) { + if (isset($rules['byPrivilegeId'][$privilege]) && $type === $rules['byPrivilegeId'][$privilege]['type']) { unset($rules['byPrivilegeId'][$privilege]); } } @@ -829,7 +829,7 @@ class Acl implements AclInterface } } - return null; + return; } /** @@ -868,7 +868,7 @@ class Acl implements AclInterface $dfs['stack'][] = $roleParent; } - return null; + return; } /** @@ -908,7 +908,7 @@ class Acl implements AclInterface } } - return null; + return; } /** @@ -926,8 +926,11 @@ class Acl implements AclInterface * @return bool|null * @throws Exception\RuntimeException */ - protected function roleDFSVisitOnePrivilege(Role\RoleInterface $role, Resource\ResourceInterface $resource = null, - $privilege = null, &$dfs = null + protected function roleDFSVisitOnePrivilege( + Role\RoleInterface $role, + Resource\ResourceInterface $resource = null, + $privilege = null, + &$dfs = null ) { if (null === $privilege) { /** @@ -954,7 +957,7 @@ class Acl implements AclInterface $dfs['stack'][] = $roleParent; } - return null; + return; } /** @@ -982,7 +985,7 @@ class Acl implements AclInterface { // get the rules for the $resource and $role if (null === ($rules = $this->getRules($resource, $role))) { - return null; + return; } // follow $privilege @@ -990,10 +993,10 @@ class Acl implements AclInterface if (isset($rules['allPrivileges'])) { $rule = $rules['allPrivileges']; } else { - return null; + return; } } elseif (!isset($rules['byPrivilegeId'][$privilege])) { - return null; + return; } else { $rule = $rules['byPrivilegeId'][$privilege]; } @@ -1012,7 +1015,7 @@ class Acl implements AclInterface if (null === $rule['assert'] || $assertionValue) { return $rule['type']; } elseif (null !== $resource || null !== $role || null !== $privilege) { - return null; + return; } elseif (self::TYPE_ALLOW === $rule['type']) { return self::TYPE_DENY; } @@ -1055,7 +1058,6 @@ class Acl implements AclInterface $visitor =& $this->rules['byResourceId'][$resourceId]; } while (false); - // follow $role if (null === $role) { if (!isset($visitor['allRoles'])) { diff --git a/library/Zend/Permissions/Acl/AclInterface.php b/library/Zend/Permissions/Acl/AclInterface.php index 2f730d19..6e0b9f2c 100644 --- a/library/Zend/Permissions/Acl/AclInterface.php +++ b/library/Zend/Permissions/Acl/AclInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Assertion/AssertionAggregate.php b/library/Zend/Permissions/Acl/Assertion/AssertionAggregate.php index 9bd24793..4821e56a 100644 --- a/library/Zend/Permissions/Acl/Assertion/AssertionAggregate.php +++ b/library/Zend/Permissions/Acl/Assertion/AssertionAggregate.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Permissions\Acl\Assertion; diff --git a/library/Zend/Permissions/Acl/Assertion/AssertionInterface.php b/library/Zend/Permissions/Acl/Assertion/AssertionInterface.php index f43823a2..f963c93d 100644 --- a/library/Zend/Permissions/Acl/Assertion/AssertionInterface.php +++ b/library/Zend/Permissions/Acl/Assertion/AssertionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Assertion/AssertionManager.php b/library/Zend/Permissions/Acl/Assertion/AssertionManager.php index 606ab265..69e35e8f 100644 --- a/library/Zend/Permissions/Acl/Assertion/AssertionManager.php +++ b/library/Zend/Permissions/Acl/Assertion/AssertionManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Permissions\Acl\Assertion; @@ -28,9 +28,12 @@ class AssertionManager extends AbstractPluginManager public function validatePlugin($plugin) { if (! $plugin instanceof AssertionInterface) { - throw new InvalidArgumentException(sprintf('Plugin of type %s is invalid; must implement - Zend\Permissions\Acl\Assertion\AssertionInterface', - (is_object($plugin) ? get_class($plugin) : gettype($plugin)))); + throw new InvalidArgumentException( + sprintf( + 'Plugin of type %s is invalid; must implement Zend\Permissions\Acl\Assertion\AssertionInterface', + (is_object($plugin) ? get_class($plugin) : gettype($plugin)) + ) + ); } return true; diff --git a/library/Zend/Permissions/Acl/Assertion/CallbackAssertion.php b/library/Zend/Permissions/Acl/Assertion/CallbackAssertion.php new file mode 100644 index 00000000..df30528e --- /dev/null +++ b/library/Zend/Permissions/Acl/Assertion/CallbackAssertion.php @@ -0,0 +1,59 @@ +callback = $callback; + } + + /** + * Returns true if and only if the assertion conditions are met. + * + * This method is passed the ACL, Role, Resource, and privilege to which the + * authorization query applies. + * + * If the $role, $resource, or $privilege parameters are null, it means + * that the query applies to all Roles, Resources, or privileges, + * respectively. + * + * @param Acl $acl + * @param RoleInterface $role + * @param ResourceInterface $resource + * @param string $privilege + * + * @return bool + */ + public function assert( + Acl $acl, + RoleInterface $role = null, + ResourceInterface $resource = null, + $privilege = null + ) { + return (bool) call_user_func($this->callback, $acl, $role, $resource, $privilege); + } +} diff --git a/library/Zend/Permissions/Acl/Exception/ExceptionInterface.php b/library/Zend/Permissions/Acl/Exception/ExceptionInterface.php index 1fc28d8b..78c92c63 100644 --- a/library/Zend/Permissions/Acl/Exception/ExceptionInterface.php +++ b/library/Zend/Permissions/Acl/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Exception/InvalidArgumentException.php b/library/Zend/Permissions/Acl/Exception/InvalidArgumentException.php index 89b37780..0ca63111 100644 --- a/library/Zend/Permissions/Acl/Exception/InvalidArgumentException.php +++ b/library/Zend/Permissions/Acl/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Exception/RuntimeException.php b/library/Zend/Permissions/Acl/Exception/RuntimeException.php index 0def073a..db23864b 100644 --- a/library/Zend/Permissions/Acl/Exception/RuntimeException.php +++ b/library/Zend/Permissions/Acl/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Resource/GenericResource.php b/library/Zend/Permissions/Acl/Resource/GenericResource.php index 019e2871..2b45d6bd 100644 --- a/library/Zend/Permissions/Acl/Resource/GenericResource.php +++ b/library/Zend/Permissions/Acl/Resource/GenericResource.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Resource/ResourceInterface.php b/library/Zend/Permissions/Acl/Resource/ResourceInterface.php index f761c2ed..4ae5b40a 100644 --- a/library/Zend/Permissions/Acl/Resource/ResourceInterface.php +++ b/library/Zend/Permissions/Acl/Resource/ResourceInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Role/GenericRole.php b/library/Zend/Permissions/Acl/Role/GenericRole.php index 2f7463f8..a913393d 100644 --- a/library/Zend/Permissions/Acl/Role/GenericRole.php +++ b/library/Zend/Permissions/Acl/Role/GenericRole.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Role/Registry.php b/library/Zend/Permissions/Acl/Role/Registry.php index 3c38ec07..b575759a 100644 --- a/library/Zend/Permissions/Acl/Role/Registry.php +++ b/library/Zend/Permissions/Acl/Role/Registry.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/Role/RoleInterface.php b/library/Zend/Permissions/Acl/Role/RoleInterface.php index 55c83759..104de047 100644 --- a/library/Zend/Permissions/Acl/Role/RoleInterface.php +++ b/library/Zend/Permissions/Acl/Role/RoleInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Acl/composer.json b/library/Zend/Permissions/Acl/composer.json index 4276a5a7..ae51d363 100644 --- a/library/Zend/Permissions/Acl/composer.json +++ b/library/Zend/Permissions/Acl/composer.json @@ -8,18 +8,20 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Permissions\\Acl\\": "" } }, - "target-dir": "Zend/Permissions/Acl", "require": { "php": ">=5.3.23" }, + "suggest": { + "zendframework/zend-servicemanager": "To support Zend\\Permissions\\Acl\\Assertion\\AssertionManager plugin manager usage" + }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Permissions/Rbac/AbstractIterator.php b/library/Zend/Permissions/Rbac/AbstractIterator.php index 5b28a922..dc8a6834 100644 --- a/library/Zend/Permissions/Rbac/AbstractIterator.php +++ b/library/Zend/Permissions/Rbac/AbstractIterator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/AbstractRole.php b/library/Zend/Permissions/Rbac/AbstractRole.php index d3d6ea76..0f69b089 100644 --- a/library/Zend/Permissions/Rbac/AbstractRole.php +++ b/library/Zend/Permissions/Rbac/AbstractRole.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/Assertion/CallbackAssertion.php b/library/Zend/Permissions/Rbac/Assertion/CallbackAssertion.php new file mode 100644 index 00000000..b3a64a1e --- /dev/null +++ b/library/Zend/Permissions/Rbac/Assertion/CallbackAssertion.php @@ -0,0 +1,45 @@ +callback = $callback; + } + + /** + * Assertion method - must return a boolean. + * + * Returns the result of the composed callback. + * + * @param Rbac $rbac + * @return bool + */ + public function assert(Rbac $rbac) + { + return (bool) call_user_func($this->callback, $rbac); + } +} diff --git a/library/Zend/Permissions/Rbac/AssertionInterface.php b/library/Zend/Permissions/Rbac/AssertionInterface.php index 0a01addc..cddff258 100644 --- a/library/Zend/Permissions/Rbac/AssertionInterface.php +++ b/library/Zend/Permissions/Rbac/AssertionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/Exception/ExceptionInterface.php b/library/Zend/Permissions/Rbac/Exception/ExceptionInterface.php index 63e89be6..431c4d5e 100644 --- a/library/Zend/Permissions/Rbac/Exception/ExceptionInterface.php +++ b/library/Zend/Permissions/Rbac/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/Exception/InvalidArgumentException.php b/library/Zend/Permissions/Rbac/Exception/InvalidArgumentException.php index 170e078d..c2708ae4 100644 --- a/library/Zend/Permissions/Rbac/Exception/InvalidArgumentException.php +++ b/library/Zend/Permissions/Rbac/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/Rbac.php b/library/Zend/Permissions/Rbac/Rbac.php index 3ce66aa2..aa550e42 100644 --- a/library/Zend/Permissions/Rbac/Rbac.php +++ b/library/Zend/Permissions/Rbac/Rbac.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -141,24 +141,18 @@ class Rbac extends AbstractIterator { if ($assert) { if ($assert instanceof AssertionInterface) { - if (!$assert->assert($this)) { - return false; - } - } elseif (is_callable($assert)) { - if (!$assert($this)) { - return false; - } - } else { - throw new Exception\InvalidArgumentException( - 'Assertions must be a Callable or an instance of Zend\Permissions\Rbac\AssertionInterface' - ); + return (bool) $assert->assert($this); } + + if (is_callable($assert)) { + return (bool) $assert($this); + } + + throw new Exception\InvalidArgumentException( + 'Assertions must be a Callable or an instance of Zend\Permissions\Rbac\AssertionInterface' + ); } - if ($this->getRole($role)->hasPermission($permission)) { - return true; - } - - return false; + return $this->getRole($role)->hasPermission($permission); } } diff --git a/library/Zend/Permissions/Rbac/Role.php b/library/Zend/Permissions/Rbac/Role.php index 9daa1d74..18114a41 100644 --- a/library/Zend/Permissions/Rbac/Role.php +++ b/library/Zend/Permissions/Rbac/Role.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/RoleInterface.php b/library/Zend/Permissions/Rbac/RoleInterface.php index fd8a65c5..f7a78279 100644 --- a/library/Zend/Permissions/Rbac/RoleInterface.php +++ b/library/Zend/Permissions/Rbac/RoleInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Permissions/Rbac/composer.json b/library/Zend/Permissions/Rbac/composer.json index e70e6c13..3b93d9ee 100644 --- a/library/Zend/Permissions/Rbac/composer.json +++ b/library/Zend/Permissions/Rbac/composer.json @@ -8,18 +8,17 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Permissions\\Rbac\\": "" } }, - "target-dir": "Zend/Permissions/Rbac", "require": { "php": ">=5.3.23" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/ProgressBar/Adapter/AbstractAdapter.php b/library/Zend/ProgressBar/Adapter/AbstractAdapter.php index 53f9d289..446a6334 100644 --- a/library/Zend/ProgressBar/Adapter/AbstractAdapter.php +++ b/library/Zend/ProgressBar/Adapter/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Adapter/Console.php b/library/Zend/ProgressBar/Adapter/Console.php index 8de843c8..3d9b8ff3 100644 --- a/library/Zend/ProgressBar/Adapter/Console.php +++ b/library/Zend/ProgressBar/Adapter/Console.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Adapter/Exception/ExceptionInterface.php b/library/Zend/ProgressBar/Adapter/Exception/ExceptionInterface.php index e64d3afd..7f9c7ca9 100644 --- a/library/Zend/ProgressBar/Adapter/Exception/ExceptionInterface.php +++ b/library/Zend/ProgressBar/Adapter/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Adapter/Exception/InvalidArgumentException.php b/library/Zend/ProgressBar/Adapter/Exception/InvalidArgumentException.php index a1b18f2d..a7bafe45 100644 --- a/library/Zend/ProgressBar/Adapter/Exception/InvalidArgumentException.php +++ b/library/Zend/ProgressBar/Adapter/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\ProgressBar\Exception; /** * Exception for Zend\Progressbar component. */ -class InvalidArgumentException extends Exception\InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/ProgressBar/Adapter/Exception/RuntimeException.php b/library/Zend/ProgressBar/Adapter/Exception/RuntimeException.php index f7024862..43faa3cc 100644 --- a/library/Zend/ProgressBar/Adapter/Exception/RuntimeException.php +++ b/library/Zend/ProgressBar/Adapter/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,7 +14,6 @@ use Zend\ProgressBar\Exception; /** * Exception for Zend\Progressbar component. */ -class RuntimeException extends Exception\RuntimeException implements - ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/ProgressBar/Adapter/JsPull.php b/library/Zend/ProgressBar/Adapter/JsPull.php index f5f63f07..66940e96 100644 --- a/library/Zend/ProgressBar/Adapter/JsPull.php +++ b/library/Zend/ProgressBar/Adapter/JsPull.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Adapter/JsPush.php b/library/Zend/ProgressBar/Adapter/JsPush.php index cf417468..25796bd4 100644 --- a/library/Zend/ProgressBar/Adapter/JsPush.php +++ b/library/Zend/ProgressBar/Adapter/JsPush.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Exception/ExceptionInterface.php b/library/Zend/ProgressBar/Exception/ExceptionInterface.php index d89fbc01..a2ca184b 100644 --- a/library/Zend/ProgressBar/Exception/ExceptionInterface.php +++ b/library/Zend/ProgressBar/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Exception/InvalidArgumentException.php b/library/Zend/ProgressBar/Exception/InvalidArgumentException.php index 1734096b..122fc78d 100644 --- a/library/Zend/ProgressBar/Exception/InvalidArgumentException.php +++ b/library/Zend/ProgressBar/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,7 +12,6 @@ namespace Zend\ProgressBar\Exception; /** * Exception for Zend\Progressbar component. */ -class InvalidArgumentException extends \InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/ProgressBar/Exception/OutOfRangeException.php b/library/Zend/ProgressBar/Exception/OutOfRangeException.php index 72a7543e..9a477e31 100644 --- a/library/Zend/ProgressBar/Exception/OutOfRangeException.php +++ b/library/Zend/ProgressBar/Exception/OutOfRangeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Exception/PhpEnvironmentException.php b/library/Zend/ProgressBar/Exception/PhpEnvironmentException.php index 7eb63ed1..2893bcdb 100644 --- a/library/Zend/ProgressBar/Exception/PhpEnvironmentException.php +++ b/library/Zend/ProgressBar/Exception/PhpEnvironmentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Exception/RuntimeException.php b/library/Zend/ProgressBar/Exception/RuntimeException.php index 874dcd3f..6b8a51a4 100644 --- a/library/Zend/ProgressBar/Exception/RuntimeException.php +++ b/library/Zend/ProgressBar/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/ProgressBar.php b/library/Zend/ProgressBar/ProgressBar.php index 424a0d3c..c811ecd0 100644 --- a/library/Zend/ProgressBar/ProgressBar.php +++ b/library/Zend/ProgressBar/ProgressBar.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Upload/AbstractUploadHandler.php b/library/Zend/ProgressBar/Upload/AbstractUploadHandler.php index 1474c4c2..82b42a35 100644 --- a/library/Zend/ProgressBar/Upload/AbstractUploadHandler.php +++ b/library/Zend/ProgressBar/Upload/AbstractUploadHandler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -137,9 +137,7 @@ abstract class AbstractUploadHandler implements UploadHandlerInterface $adapter = $this->getProgressAdapter(); if (isset($adapter)) { if ($adapter instanceof AbstractProgressAdapter) { - $adapter = new ProgressBar( - $adapter, 0, $status['total'], $this->getSessionNamespace() - ); + $adapter = new ProgressBar($adapter, 0, $status['total'], $this->getSessionNamespace()); $this->setProgressAdapter($adapter); } diff --git a/library/Zend/ProgressBar/Upload/ApcProgress.php b/library/Zend/ProgressBar/Upload/ApcProgress.php index 236e3767..2fa561f4 100644 --- a/library/Zend/ProgressBar/Upload/ApcProgress.php +++ b/library/Zend/ProgressBar/Upload/ApcProgress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Upload/SessionProgress.php b/library/Zend/ProgressBar/Upload/SessionProgress.php index 3c8cfbed..8560a610 100644 --- a/library/Zend/ProgressBar/Upload/SessionProgress.php +++ b/library/Zend/ProgressBar/Upload/SessionProgress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/Upload/UploadHandlerInterface.php b/library/Zend/ProgressBar/Upload/UploadHandlerInterface.php index 9c974693..234759ed 100644 --- a/library/Zend/ProgressBar/Upload/UploadHandlerInterface.php +++ b/library/Zend/ProgressBar/Upload/UploadHandlerInterface.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ProgressBar\Upload; - /** * Interface for Upload Progress Handlers */ diff --git a/library/Zend/ProgressBar/Upload/UploadProgress.php b/library/Zend/ProgressBar/Upload/UploadProgress.php index 871de58d..8dd65aac 100644 --- a/library/Zend/ProgressBar/Upload/UploadProgress.php +++ b/library/Zend/ProgressBar/Upload/UploadProgress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ProgressBar/composer.json b/library/Zend/ProgressBar/composer.json index c0cefdc8..a1708c2e 100644 --- a/library/Zend/ProgressBar/composer.json +++ b/library/Zend/ProgressBar/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\ProgressBar\\": "" } }, - "target-dir": "Zend/ProgressBar", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" @@ -27,8 +26,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Serializer/Adapter/AbstractAdapter.php b/library/Zend/Serializer/Adapter/AbstractAdapter.php index de5ae4a3..1b6c8b43 100644 --- a/library/Zend/Serializer/Adapter/AbstractAdapter.php +++ b/library/Zend/Serializer/Adapter/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/AdapterInterface.php b/library/Zend/Serializer/Adapter/AdapterInterface.php index 132304f4..44c0c4fc 100644 --- a/library/Zend/Serializer/Adapter/AdapterInterface.php +++ b/library/Zend/Serializer/Adapter/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/AdapterOptions.php b/library/Zend/Serializer/Adapter/AdapterOptions.php index 4054c30d..800eb9f8 100644 --- a/library/Zend/Serializer/Adapter/AdapterOptions.php +++ b/library/Zend/Serializer/Adapter/AdapterOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/IgBinary.php b/library/Zend/Serializer/Adapter/IgBinary.php index 391cb3eb..ddc56126 100644 --- a/library/Zend/Serializer/Adapter/IgBinary.php +++ b/library/Zend/Serializer/Adapter/IgBinary.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -69,7 +69,7 @@ class IgBinary extends AbstractAdapter public function unserialize($serialized) { if ($serialized === static::$serializedNull) { - return null; + return; } ErrorHandler::start(); diff --git a/library/Zend/Serializer/Adapter/Json.php b/library/Zend/Serializer/Adapter/Json.php index 025c19ef..03bde65d 100644 --- a/library/Zend/Serializer/Adapter/Json.php +++ b/library/Zend/Serializer/Adapter/Json.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/JsonOptions.php b/library/Zend/Serializer/Adapter/JsonOptions.php index e6bc3c91..4b2e3e00 100644 --- a/library/Zend/Serializer/Adapter/JsonOptions.php +++ b/library/Zend/Serializer/Adapter/JsonOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/MsgPack.php b/library/Zend/Serializer/Adapter/MsgPack.php index 01734e39..e8537d6b 100644 --- a/library/Zend/Serializer/Adapter/MsgPack.php +++ b/library/Zend/Serializer/Adapter/MsgPack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/PhpCode.php b/library/Zend/Serializer/Adapter/PhpCode.php index 74437739..9b2cee95 100644 --- a/library/Zend/Serializer/Adapter/PhpCode.php +++ b/library/Zend/Serializer/Adapter/PhpCode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/PhpSerialize.php b/library/Zend/Serializer/Adapter/PhpSerialize.php index 3fef17e4..5dbd92f5 100644 --- a/library/Zend/Serializer/Adapter/PhpSerialize.php +++ b/library/Zend/Serializer/Adapter/PhpSerialize.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -48,9 +48,7 @@ class PhpSerialize extends AbstractAdapter $ret = serialize($value); $err = ErrorHandler::stop(); if ($err) { - throw new Exception\RuntimeException( - 'Serialization failed', 0, $err - ); + throw new Exception\RuntimeException('Serialization failed', 0, $err); } return $ret; diff --git a/library/Zend/Serializer/Adapter/PythonPickle.php b/library/Zend/Serializer/Adapter/PythonPickle.php index daa1ac5c..25ea9cd2 100644 --- a/library/Zend/Serializer/Adapter/PythonPickle.php +++ b/library/Zend/Serializer/Adapter/PythonPickle.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -1048,9 +1048,9 @@ class PythonPickle extends AbstractAdapter . chr(0x80 | $uniCode >> 6 & 0x3F) . chr(0x80 | $uniCode & 0x3F); } else { - throw new Exception\RuntimeException(sprintf( - 'Unsupported unicode character found "%s"', dechex($uniCode) - )); + throw new Exception\RuntimeException( + sprintf('Unsupported unicode character found "%s"', dechex($uniCode)) + ); } return $utf8Char; diff --git a/library/Zend/Serializer/Adapter/PythonPickleOptions.php b/library/Zend/Serializer/Adapter/PythonPickleOptions.php index b43f2ab7..bdf55117 100644 --- a/library/Zend/Serializer/Adapter/PythonPickleOptions.php +++ b/library/Zend/Serializer/Adapter/PythonPickleOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Adapter/Wddx.php b/library/Zend/Serializer/Adapter/Wddx.php index b848cee1..907d30e9 100644 --- a/library/Zend/Serializer/Adapter/Wddx.php +++ b/library/Zend/Serializer/Adapter/Wddx.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -125,7 +125,7 @@ class Wddx extends AbstractAdapter //$simpleXml = new \SimpleXMLElement($wddx); libxml_disable_entity_loader($oldLibxmlDisableEntityLoader); if (isset($simpleXml->data[0]->null[0])) { - return null; // valid null + return; // valid null } throw new Exception\RuntimeException('Unserialization failed: Invalid wddx packet'); } catch (\Exception $e) { diff --git a/library/Zend/Serializer/Adapter/WddxOptions.php b/library/Zend/Serializer/Adapter/WddxOptions.php index e403731a..a06276a6 100644 --- a/library/Zend/Serializer/Adapter/WddxOptions.php +++ b/library/Zend/Serializer/Adapter/WddxOptions.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Serializer\Adapter; - class WddxOptions extends AdapterOptions { /** diff --git a/library/Zend/Serializer/AdapterPluginManager.php b/library/Zend/Serializer/AdapterPluginManager.php index 5be62ce6..56d2f729 100644 --- a/library/Zend/Serializer/AdapterPluginManager.php +++ b/library/Zend/Serializer/AdapterPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Exception/ExceptionInterface.php b/library/Zend/Serializer/Exception/ExceptionInterface.php index bf31d9f1..c58b17ad 100644 --- a/library/Zend/Serializer/Exception/ExceptionInterface.php +++ b/library/Zend/Serializer/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Exception/ExtensionNotLoadedException.php b/library/Zend/Serializer/Exception/ExtensionNotLoadedException.php index 5d389dbf..d502a3d3 100644 --- a/library/Zend/Serializer/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Serializer/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Exception/InvalidArgumentException.php b/library/Zend/Serializer/Exception/InvalidArgumentException.php index 91d20326..f0b38532 100644 --- a/library/Zend/Serializer/Exception/InvalidArgumentException.php +++ b/library/Zend/Serializer/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Exception/RuntimeException.php b/library/Zend/Serializer/Exception/RuntimeException.php index d09f5969..3d8486aa 100644 --- a/library/Zend/Serializer/Exception/RuntimeException.php +++ b/library/Zend/Serializer/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/Serializer.php b/library/Zend/Serializer/Serializer.php index adcea15c..ec3b63b4 100644 --- a/library/Zend/Serializer/Serializer.php +++ b/library/Zend/Serializer/Serializer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Serializer/composer.json b/library/Zend/Serializer/composer.json index c36b3ab5..c4d9d293 100644 --- a/library/Zend/Serializer/composer.json +++ b/library/Zend/Serializer/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Serializer\\": "" } }, - "target-dir": "Zend/Serializer", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version", @@ -27,8 +26,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Server/AbstractServer.php b/library/Zend/Server/AbstractServer.php index e52deefd..47e4ca67 100644 --- a/library/Zend/Server/AbstractServer.php +++ b/library/Zend/Server/AbstractServer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Cache.php b/library/Zend/Server/Cache.php index c45f3940..c23ea8f3 100644 --- a/library/Zend/Server/Cache.php +++ b/library/Zend/Server/Cache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -36,9 +36,7 @@ class Cache */ public static function save($filename, Server $server) { - if (!is_string($filename) - || (!file_exists($filename) && !is_writable(dirname($filename))) - ) { + if (!is_string($filename) || (!file_exists($filename) && !is_writable(dirname($filename)))) { return false; } @@ -98,9 +96,7 @@ class Cache */ public static function get($filename, Server $server) { - if (!is_string($filename) - || !file_exists($filename) - || !is_readable($filename)) { + if (!is_string($filename) || !file_exists($filename) || !is_readable($filename)) { return false; } diff --git a/library/Zend/Server/Client.php b/library/Zend/Server/Client.php index 203b9c01..b84ed4db 100644 --- a/library/Zend/Server/Client.php +++ b/library/Zend/Server/Client.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Definition.php b/library/Zend/Server/Definition.php index 1cf6e09d..442a0370 100644 --- a/library/Zend/Server/Definition.php +++ b/library/Zend/Server/Definition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Exception/BadMethodCallException.php b/library/Zend/Server/Exception/BadMethodCallException.php index 2ea3d550..8ba9c2da 100644 --- a/library/Zend/Server/Exception/BadMethodCallException.php +++ b/library/Zend/Server/Exception/BadMethodCallException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Server\Exception; -class BadMethodCallException - extends \BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Server/Exception/ExceptionInterface.php b/library/Zend/Server/Exception/ExceptionInterface.php index 65974b9d..8b19f6c8 100644 --- a/library/Zend/Server/Exception/ExceptionInterface.php +++ b/library/Zend/Server/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Exception/InvalidArgumentException.php b/library/Zend/Server/Exception/InvalidArgumentException.php index c3c0a0a9..bbddd095 100644 --- a/library/Zend/Server/Exception/InvalidArgumentException.php +++ b/library/Zend/Server/Exception/InvalidArgumentException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Server\Exception; -class InvalidArgumentException - extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Server/Exception/RuntimeException.php b/library/Zend/Server/Exception/RuntimeException.php index cc53b7ec..f2f213e2 100644 --- a/library/Zend/Server/Exception/RuntimeException.php +++ b/library/Zend/Server/Exception/RuntimeException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Server\Exception; -class RuntimeException - extends \RuntimeException - implements ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Server/Method/Callback.php b/library/Zend/Server/Method/Callback.php index 472dc1c5..7e73b349 100644 --- a/library/Zend/Server/Method/Callback.php +++ b/library/Zend/Server/Method/Callback.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Method/Definition.php b/library/Zend/Server/Method/Definition.php index 66125977..3df08b53 100644 --- a/library/Zend/Server/Method/Definition.php +++ b/library/Zend/Server/Method/Definition.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Method/Parameter.php b/library/Zend/Server/Method/Parameter.php index a867ec97..9d6ea917 100644 --- a/library/Zend/Server/Method/Parameter.php +++ b/library/Zend/Server/Method/Parameter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Method/Prototype.php b/library/Zend/Server/Method/Prototype.php index 61380b98..3b36b729 100644 --- a/library/Zend/Server/Method/Prototype.php +++ b/library/Zend/Server/Method/Prototype.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -146,7 +146,7 @@ class Prototype public function getParameter($index) { if (!is_string($index) && !is_numeric($index)) { - return null; + return; } if (array_key_exists($index, $this->parameterNameMap)) { $index = $this->parameterNameMap[$index]; @@ -154,7 +154,7 @@ class Prototype if (array_key_exists($index, $this->parameters)) { return $this->parameters[$index]; } - return null; + return; } /** diff --git a/library/Zend/Server/Reflection.php b/library/Zend/Server/Reflection.php index 729efbf7..ab9332af 100644 --- a/library/Zend/Server/Reflection.php +++ b/library/Zend/Server/Reflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -38,7 +38,7 @@ class Reflection { if (is_object($class)) { $reflection = new \ReflectionObject($class); - } elseif (class_exists($class)) { + } elseif (is_string($class) && class_exists($class)) { $reflection = new \ReflectionClass($class); } else { throw new Reflection\Exception\InvalidArgumentException('Invalid class or object passed to attachClass()'); @@ -71,7 +71,10 @@ class Reflection public static function reflectFunction($function, $argv = false, $namespace = '') { if (!is_string($function) || !function_exists($function)) { - throw new Reflection\Exception\InvalidArgumentException('Invalid function "' . $function . '" passed to reflectFunction'); + throw new Reflection\Exception\InvalidArgumentException(sprintf( + 'Invalid function "%s" passed to reflectFunction', + $function + )); } if ($argv && !is_array($argv)) { diff --git a/library/Zend/Server/Reflection/AbstractFunction.php b/library/Zend/Server/Reflection/AbstractFunction.php index 1f288316..9ba6abd6 100644 --- a/library/Zend/Server/Reflection/AbstractFunction.php +++ b/library/Zend/Server/Reflection/AbstractFunction.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -282,8 +282,9 @@ abstract class AbstractFunction } } elseif ($nParamTypesTmp != $paramCount) { throw new Exception\RuntimeException( - 'Variable number of arguments is not supported for services (except optional parameters). ' - . 'Number of function arguments must correspond to actual number of arguments described in a docblock.'); + 'Variable number of arguments is not supported for services (except optional parameters). ' + . 'Number of function arguments must correspond to actual number of arguments described in a docblock.' + ); } $paramTypes = array(); @@ -297,7 +298,6 @@ abstract class AbstractFunction $this->buildSignatures($return, $returnDesc, $paramTypes, $paramDesc); } - /** * Proxy reflection calls * @@ -330,7 +330,7 @@ abstract class AbstractFunction return $this->config[$key]; } - return null; + return; } /** diff --git a/library/Zend/Server/Reflection/Exception/BadMethodCallException.php b/library/Zend/Server/Reflection/Exception/BadMethodCallException.php index eb4c152e..613fdde0 100644 --- a/library/Zend/Server/Reflection/Exception/BadMethodCallException.php +++ b/library/Zend/Server/Reflection/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Server\Reflection\Exception; use Zend\Server\Exception; -class BadMethodCallException - extends Exception\BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends Exception\BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Server/Reflection/Exception/ExceptionInterface.php b/library/Zend/Server/Reflection/Exception/ExceptionInterface.php index 6e527671..e44c798d 100644 --- a/library/Zend/Server/Reflection/Exception/ExceptionInterface.php +++ b/library/Zend/Server/Reflection/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Reflection/Exception/InvalidArgumentException.php b/library/Zend/Server/Reflection/Exception/InvalidArgumentException.php index 2803eb24..4fc4e271 100644 --- a/library/Zend/Server/Reflection/Exception/InvalidArgumentException.php +++ b/library/Zend/Server/Reflection/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Server\Reflection\Exception; use Zend\Server\Exception; -class InvalidArgumentException - extends Exception\InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Server/Reflection/Exception/RuntimeException.php b/library/Zend/Server/Reflection/Exception/RuntimeException.php index be51f236..6ddfdf95 100644 --- a/library/Zend/Server/Reflection/Exception/RuntimeException.php +++ b/library/Zend/Server/Reflection/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,8 +11,6 @@ namespace Zend\Server\Reflection\Exception; use Zend\Server\Exception; -class RuntimeException - extends Exception\RuntimeException - implements ExceptionInterface +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Server/Reflection/Node.php b/library/Zend/Server/Reflection/Node.php index e0f4268e..6f49044a 100644 --- a/library/Zend/Server/Reflection/Node.php +++ b/library/Zend/Server/Reflection/Node.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -168,9 +168,7 @@ class Node if (null === $value) { $endPoints[] = $this; - } elseif ((null !== $value) - && $child->hasChildren() - ) { + } elseif ((null !== $value) && $child->hasChildren()) { $childEndPoints = $child->getEndPoints(); if (!empty($childEndPoints)) { $endPoints = array_merge($endPoints, $childEndPoints); diff --git a/library/Zend/Server/Reflection/Prototype.php b/library/Zend/Server/Reflection/Prototype.php index 416995bf..35c53ddd 100644 --- a/library/Zend/Server/Reflection/Prototype.php +++ b/library/Zend/Server/Reflection/Prototype.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Reflection/ReflectionClass.php b/library/Zend/Server/Reflection/ReflectionClass.php index 7c047989..aa76e482 100644 --- a/library/Zend/Server/Reflection/ReflectionClass.php +++ b/library/Zend/Server/Reflection/ReflectionClass.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -104,7 +104,7 @@ class ReflectionClass return $this->config[$key]; } - return null; + return; } /** diff --git a/library/Zend/Server/Reflection/ReflectionFunction.php b/library/Zend/Server/Reflection/ReflectionFunction.php index 2595ce56..f06fc68f 100644 --- a/library/Zend/Server/Reflection/ReflectionFunction.php +++ b/library/Zend/Server/Reflection/ReflectionFunction.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Reflection/ReflectionMethod.php b/library/Zend/Server/Reflection/ReflectionMethod.php index af63f506..3e8865d0 100644 --- a/library/Zend/Server/Reflection/ReflectionMethod.php +++ b/library/Zend/Server/Reflection/ReflectionMethod.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Reflection/ReflectionParameter.php b/library/Zend/Server/Reflection/ReflectionParameter.php index e076e93b..af6b661f 100644 --- a/library/Zend/Server/Reflection/ReflectionParameter.php +++ b/library/Zend/Server/Reflection/ReflectionParameter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Reflection/ReflectionReturnValue.php b/library/Zend/Server/Reflection/ReflectionReturnValue.php index 64f0fb95..3b7e1839 100644 --- a/library/Zend/Server/Reflection/ReflectionReturnValue.php +++ b/library/Zend/Server/Reflection/ReflectionReturnValue.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/Server.php b/library/Zend/Server/Server.php index 56e5269b..3cf0756d 100644 --- a/library/Zend/Server/Server.php +++ b/library/Zend/Server/Server.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Server/composer.json b/library/Zend/Server/composer.json index 5391d38a..21d9ad52 100644 --- a/library/Zend/Server/composer.json +++ b/library/Zend/Server/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Server\\": "" } }, - "target-dir": "Zend/Server", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version", @@ -20,8 +19,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/ServiceManager/AbstractFactoryInterface.php b/library/Zend/ServiceManager/AbstractFactoryInterface.php index f54205b2..96bffea8 100644 --- a/library/Zend/ServiceManager/AbstractFactoryInterface.php +++ b/library/Zend/ServiceManager/AbstractFactoryInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/AbstractPluginManager.php b/library/Zend/ServiceManager/AbstractPluginManager.php index f82c1b35..4f134145 100644 --- a/library/Zend/ServiceManager/AbstractPluginManager.php +++ b/library/Zend/ServiceManager/AbstractPluginManager.php @@ -3,12 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ServiceManager; +use Exception as BaseException; + /** * ServiceManager implementation for managing plugins * @@ -55,7 +57,7 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo * Add a default initializer to ensure the plugin is valid after instance * creation. * - * @param null|ConfigInterface $configuration + * @param null|ConfigInterface $configuration */ public function __construct(ConfigInterface $configuration = null) { @@ -74,7 +76,7 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo * Checks that the filter loaded is either a valid callback or an instance * of FilterInterface. * - * @param mixed $plugin + * @param mixed $plugin * @return void * @throws Exception\RuntimeException if invalid */ @@ -88,21 +90,44 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo * constructor if not null and a non-empty array. * * @param string $name - * @param array $options - * @param bool $usePeeringServiceManagers + * @param array $options + * @param bool $usePeeringServiceManagers + * * @return object + * + * @throws Exception\ServiceNotFoundException + * @throws Exception\ServiceNotCreatedException + * @throws Exception\RuntimeException */ public function get($name, $options = array(), $usePeeringServiceManagers = true) { + $isAutoInvokable = false; + // Allow specifying a class name directly; registers as an invokable class if (!$this->has($name) && $this->autoAddInvokableClass && class_exists($name)) { + $isAutoInvokable = true; + $this->setInvokableClass($name, $name); } $this->creationOptions = $options; - $instance = parent::get($name, $usePeeringServiceManagers); + + try { + $instance = parent::get($name, $usePeeringServiceManagers); + } catch (Exception\ServiceNotFoundException $exception) { + $this->tryThrowingServiceLocatorUsageException($name, $isAutoInvokable, $exception); + } catch (Exception\ServiceNotCreatedException $exception) { + $this->tryThrowingServiceLocatorUsageException($name, $isAutoInvokable, $exception); + } + $this->creationOptions = null; - $this->validatePlugin($instance); + + try { + $this->validatePlugin($instance); + } catch (Exception\RuntimeException $exception) { + $this->tryThrowingServiceLocatorUsageException($name, $isAutoInvokable, $exception); + } + return $instance; } @@ -112,9 +137,9 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo * Validates that the service object via validatePlugin() prior to * attempting to register it. * - * @param string $name - * @param mixed $service - * @param bool $shared + * @param string $name + * @param mixed $service + * @param bool $shared * @return AbstractPluginManager * @throws Exception\InvalidServiceNameException */ @@ -124,18 +149,20 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo $this->validatePlugin($service); } parent::setService($name, $service, $shared); + return $this; } /** * Set the main service locator so factories can have access to it to pull deps * - * @param ServiceLocatorInterface $serviceLocator + * @param ServiceLocatorInterface $serviceLocator * @return AbstractPluginManager */ public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; + return $this; } @@ -155,8 +182,8 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo * Overrides parent implementation by passing $creationOptions to the * constructor, if non-null. * - * @param string $canonicalName - * @param string $requestedName + * @param string $canonicalName + * @param string $requestedName * @return null|\stdClass * @throws Exception\ServiceNotCreatedException If resolved class does not exist */ @@ -191,8 +218,8 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo * Overrides parent implementation by passing $creationOptions to the * constructor, if non-null. * - * @param string $canonicalName - * @param string $requestedName + * @param string $canonicalName + * @param string $requestedName * @return mixed * @throws Exception\ServiceNotCreatedException If factory is not callable */ @@ -217,7 +244,9 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo $instance = $this->createServiceViaCallback($factory, $canonicalName, $requestedName); } else { throw new Exception\ServiceNotCreatedException(sprintf( - 'While attempting to create %s%s an invalid factory was registered for this instance type.', $canonicalName, ($requestedName ? '(alias: ' . $requestedName . ')' : '') + 'While attempting to create %s%s an invalid factory was registered for this instance type.', + $canonicalName, + ($requestedName ? '(alias: ' . $requestedName . ')' : '') )); } @@ -227,9 +256,9 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo /** * Create service via callback * - * @param callable $callable - * @param string $cName - * @param string $rName + * @param callable $callable + * @param string $cName + * @param string $rName * @throws Exception\ServiceNotCreatedException * @throws Exception\ServiceNotFoundException * @throws Exception\CircularDependencyFoundException @@ -254,4 +283,35 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo return parent::createServiceViaCallback($callable, $cName, $rName); } + + /** + * @param string $serviceName + * @param bool $isAutoInvokable + * @param BaseException $exception + * + * @throws BaseException + * @throws Exception\ServiceLocatorUsageException + */ + private function tryThrowingServiceLocatorUsageException( + $serviceName, + $isAutoInvokable, + BaseException $exception + ) { + if ($isAutoInvokable) { + $this->unregisterService($this->canonicalizeName($serviceName)); + } + + $serviceLocator = $this->getServiceLocator(); + + if ($serviceLocator && $serviceLocator->has($serviceName)) { + throw Exception\ServiceLocatorUsageException::fromInvalidPluginManagerRequestedServiceName( + $this, + $serviceLocator, + $serviceName, + $exception + ); + } + + throw $exception; + } } diff --git a/library/Zend/ServiceManager/Config.php b/library/Zend/ServiceManager/Config.php index c64bb0e7..0551ee02 100644 --- a/library/Zend/ServiceManager/Config.php +++ b/library/Zend/ServiceManager/Config.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/ConfigInterface.php b/library/Zend/ServiceManager/ConfigInterface.php index 1593312a..d55bc0e5 100644 --- a/library/Zend/ServiceManager/ConfigInterface.php +++ b/library/Zend/ServiceManager/ConfigInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/DelegatorFactoryInterface.php b/library/Zend/ServiceManager/DelegatorFactoryInterface.php index 27ad5f1f..fc8a47a9 100644 --- a/library/Zend/ServiceManager/DelegatorFactoryInterface.php +++ b/library/Zend/ServiceManager/DelegatorFactoryInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php b/library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php index 9f030e18..7b4b257d 100644 --- a/library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php +++ b/library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Di/DiInstanceManagerProxy.php b/library/Zend/ServiceManager/Di/DiInstanceManagerProxy.php index cdd4bf9f..87b10a39 100644 --- a/library/Zend/ServiceManager/Di/DiInstanceManagerProxy.php +++ b/library/Zend/ServiceManager/Di/DiInstanceManagerProxy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Di/DiServiceFactory.php b/library/Zend/ServiceManager/Di/DiServiceFactory.php index 27d3a31a..97bcb02c 100644 --- a/library/Zend/ServiceManager/Di/DiServiceFactory.php +++ b/library/Zend/ServiceManager/Di/DiServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Di/DiServiceInitializer.php b/library/Zend/ServiceManager/Di/DiServiceInitializer.php index 6bfe8d2e..66760f06 100644 --- a/library/Zend/ServiceManager/Di/DiServiceInitializer.php +++ b/library/Zend/ServiceManager/Di/DiServiceInitializer.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ServiceManager\Di; use Zend\Di\Di; -use Zend\ServiceManager\Exception; use Zend\ServiceManager\InitializerInterface; use Zend\ServiceManager\ServiceLocatorInterface; diff --git a/library/Zend/ServiceManager/Exception/CircularDependencyFoundException.php b/library/Zend/ServiceManager/Exception/CircularDependencyFoundException.php index d50ef311..280ff9d1 100644 --- a/library/Zend/ServiceManager/Exception/CircularDependencyFoundException.php +++ b/library/Zend/ServiceManager/Exception/CircularDependencyFoundException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/CircularReferenceException.php b/library/Zend/ServiceManager/Exception/CircularReferenceException.php index f5451f80..0472cdf2 100644 --- a/library/Zend/ServiceManager/Exception/CircularReferenceException.php +++ b/library/Zend/ServiceManager/Exception/CircularReferenceException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/ExceptionInterface.php b/library/Zend/ServiceManager/Exception/ExceptionInterface.php index d72a170d..ca59fbf3 100644 --- a/library/Zend/ServiceManager/Exception/ExceptionInterface.php +++ b/library/Zend/ServiceManager/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/InvalidArgumentException.php b/library/Zend/ServiceManager/Exception/InvalidArgumentException.php index d997c62e..174c7eb0 100644 --- a/library/Zend/ServiceManager/Exception/InvalidArgumentException.php +++ b/library/Zend/ServiceManager/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/InvalidServiceNameException.php b/library/Zend/ServiceManager/Exception/InvalidServiceNameException.php index 8958b631..a7065c4d 100644 --- a/library/Zend/ServiceManager/Exception/InvalidServiceNameException.php +++ b/library/Zend/ServiceManager/Exception/InvalidServiceNameException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/RuntimeException.php b/library/Zend/ServiceManager/Exception/RuntimeException.php index 1ce28f1f..d1916537 100644 --- a/library/Zend/ServiceManager/Exception/RuntimeException.php +++ b/library/Zend/ServiceManager/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/ServiceLocatorUsageException.php b/library/Zend/ServiceManager/Exception/ServiceLocatorUsageException.php new file mode 100644 index 00000000..d248047e --- /dev/null +++ b/library/Zend/ServiceManager/Exception/ServiceLocatorUsageException.php @@ -0,0 +1,50 @@ +getServiceLocator() in your factory code?', + $serviceName, + get_class($pluginManager), + get_class($previousException), + $serviceName, + get_class($parentLocator) + ), + 0, + $previousException + ); + } +} diff --git a/library/Zend/ServiceManager/Exception/ServiceNotCreatedException.php b/library/Zend/ServiceManager/Exception/ServiceNotCreatedException.php index caf843d7..a8b08e0f 100644 --- a/library/Zend/ServiceManager/Exception/ServiceNotCreatedException.php +++ b/library/Zend/ServiceManager/Exception/ServiceNotCreatedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/Exception/ServiceNotFoundException.php b/library/Zend/ServiceManager/Exception/ServiceNotFoundException.php index e02b2409..478f4ee0 100644 --- a/library/Zend/ServiceManager/Exception/ServiceNotFoundException.php +++ b/library/Zend/ServiceManager/Exception/ServiceNotFoundException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/FactoryInterface.php b/library/Zend/ServiceManager/FactoryInterface.php index 8fd7dc44..0a65d655 100644 --- a/library/Zend/ServiceManager/FactoryInterface.php +++ b/library/Zend/ServiceManager/FactoryInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/InitializerInterface.php b/library/Zend/ServiceManager/InitializerInterface.php index b12061b5..7e7f793f 100644 --- a/library/Zend/ServiceManager/InitializerInterface.php +++ b/library/Zend/ServiceManager/InitializerInterface.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ServiceManager; - interface InitializerInterface { /** diff --git a/library/Zend/ServiceManager/MutableCreationOptionsInterface.php b/library/Zend/ServiceManager/MutableCreationOptionsInterface.php index 785e6e84..3464155e 100644 --- a/library/Zend/ServiceManager/MutableCreationOptionsInterface.php +++ b/library/Zend/ServiceManager/MutableCreationOptionsInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/MutableCreationOptionsTrait.php b/library/Zend/ServiceManager/MutableCreationOptionsTrait.php new file mode 100644 index 00000000..5f8af8a0 --- /dev/null +++ b/library/Zend/ServiceManager/MutableCreationOptionsTrait.php @@ -0,0 +1,42 @@ +creationOptions = $creationOptions; + } + + /** + * Get creation options + * + * @return array + */ + public function getCreationOptions() + { + return $this->creationOptions; + } +} diff --git a/library/Zend/ServiceManager/Proxy/LazyServiceFactory.php b/library/Zend/ServiceManager/Proxy/LazyServiceFactory.php index 3be5506b..806d008d 100644 --- a/library/Zend/ServiceManager/Proxy/LazyServiceFactory.php +++ b/library/Zend/ServiceManager/Proxy/LazyServiceFactory.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ServiceManager\Proxy; use ProxyManager\Factory\LazyLoadingValueHolderFactory; - use ProxyManager\Proxy\LazyLoadingInterface; use Zend\ServiceManager\DelegatorFactoryInterface; use Zend\ServiceManager\Exception; diff --git a/library/Zend/ServiceManager/Proxy/LazyServiceFactoryFactory.php b/library/Zend/ServiceManager/Proxy/LazyServiceFactoryFactory.php index 2f363a0b..9c94e75a 100644 --- a/library/Zend/ServiceManager/Proxy/LazyServiceFactoryFactory.php +++ b/library/Zend/ServiceManager/Proxy/LazyServiceFactoryFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/ServiceLocatorAwareInterface.php b/library/Zend/ServiceManager/ServiceLocatorAwareInterface.php index 7f53ada0..1058042c 100644 --- a/library/Zend/ServiceManager/ServiceLocatorAwareInterface.php +++ b/library/Zend/ServiceManager/ServiceLocatorAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/ServiceLocatorAwareTrait.php b/library/Zend/ServiceManager/ServiceLocatorAwareTrait.php index 17f6069d..94ceb56e 100644 --- a/library/Zend/ServiceManager/ServiceLocatorAwareTrait.php +++ b/library/Zend/ServiceManager/ServiceLocatorAwareTrait.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ServiceManager; - trait ServiceLocatorAwareTrait { /** diff --git a/library/Zend/ServiceManager/ServiceLocatorInterface.php b/library/Zend/ServiceManager/ServiceLocatorInterface.php index b9a04e5d..4df3c5fc 100644 --- a/library/Zend/ServiceManager/ServiceLocatorInterface.php +++ b/library/Zend/ServiceManager/ServiceLocatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/ServiceManager.php b/library/Zend/ServiceManager/ServiceManager.php index 74129fdd..4411343e 100644 --- a/library/Zend/ServiceManager/ServiceManager.php +++ b/library/Zend/ServiceManager/ServiceManager.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\ServiceManager; -use ReflectionClass; - class ServiceManager implements ServiceLocatorInterface { /**@#+ @@ -116,6 +114,11 @@ class ServiceManager implements ServiceLocatorInterface */ protected $canonicalNamesReplacements = array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''); + /** + * @var ServiceLocatorInterface + */ + protected $serviceManagerCaller; + /** * Constructor * @@ -448,7 +451,7 @@ class ServiceManager implements ServiceLocatorInterface if (!isset($this->shared[$cName])) { return $this->shareByDefault(); } - + return $this->shared[$cName]; } @@ -720,10 +723,21 @@ class ServiceManager implements ServiceLocatorInterface } if ($usePeeringServiceManagers) { + $caller = $this->serviceManagerCaller; foreach ($this->peeringServiceManagers as $peeringServiceManager) { + // ignore peering service manager if they are the same instance + if ($caller === $peeringServiceManager) { + continue; + } + + $peeringServiceManager->serviceManagerCaller = $this; + if ($peeringServiceManager->has($name)) { + $peeringServiceManager->serviceManagerCaller = null; return true; } + + $peeringServiceManager->serviceManagerCaller = null; } } @@ -989,11 +1003,8 @@ class ServiceManager implements ServiceLocatorInterface */ protected function retrieveFromPeeringManager($name) { - foreach ($this->peeringServiceManagers as $peeringServiceManager) { - if ($peeringServiceManager->has($name)) { - $this->shared[$name] = $peeringServiceManager->isShared($name); - return $peeringServiceManager->get($name); - } + if (null !== ($service = $this->loopPeeringServiceManagers($name))) { + return $service; } $name = $this->canonicalizeName($name); @@ -1004,14 +1015,43 @@ class ServiceManager implements ServiceLocatorInterface } while ($this->hasAlias($name)); } - foreach ($this->peeringServiceManagers as $peeringServiceManager) { - if ($peeringServiceManager->has($name)) { - $this->shared[$name] = $peeringServiceManager->isShared($name); - return $peeringServiceManager->get($name); - } + if (null !== ($service = $this->loopPeeringServiceManagers($name))) { + return $service; } - return null; + return; + } + + /** + * Loop over peering service managers. + * + * @param string $name + * @return mixed + */ + protected function loopPeeringServiceManagers($name) + { + $caller = $this->serviceManagerCaller; + + foreach ($this->peeringServiceManagers as $peeringServiceManager) { + // ignore peering service manager if they are the same instance + if ($caller === $peeringServiceManager) { + continue; + } + + // pass this instance to peering service manager + $peeringServiceManager->serviceManagerCaller = $this; + + if ($peeringServiceManager->has($name)) { + $this->shared[$name] = $peeringServiceManager->isShared($name); + $instance = $peeringServiceManager->get($name); + $peeringServiceManager->serviceManagerCaller = null; + return $instance; + } + + $peeringServiceManager->serviceManagerCaller = null; + } + + return; } /** @@ -1103,7 +1143,7 @@ class ServiceManager implements ServiceLocatorInterface ); } } - return null; + return; } /** @@ -1189,6 +1229,8 @@ class ServiceManager implements ServiceLocatorInterface * @see https://bugs.php.net/bug.php?id=53727 * @see https://github.com/zendframework/zf2/pull/1807 * + * @deprecated since zf 2.3 requires PHP >= 5.3.23 + * * @param string $className * @param string $type * @return bool @@ -1197,17 +1239,7 @@ class ServiceManager implements ServiceLocatorInterface */ protected static function isSubclassOf($className, $type) { - if (is_subclass_of($className, $type)) { - return true; - } - if (PHP_VERSION_ID >= 50307) { - return false; - } - if (!interface_exists($type)) { - return false; - } - $r = new ReflectionClass($className); - return $r->implementsInterface($type); + return is_subclass_of($className, $type); } /** diff --git a/library/Zend/ServiceManager/ServiceManagerAwareInterface.php b/library/Zend/ServiceManager/ServiceManagerAwareInterface.php index 320f6bc6..2519bbaf 100644 --- a/library/Zend/ServiceManager/ServiceManagerAwareInterface.php +++ b/library/Zend/ServiceManager/ServiceManagerAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/ServiceManager/composer.json b/library/Zend/ServiceManager/composer.json index bc54dd6e..efde3f7c 100644 --- a/library/Zend/ServiceManager/composer.json +++ b/library/Zend/ServiceManager/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\ServiceManager\\": "" } }, - "target-dir": "Zend/ServiceManager", "require": { "php": ">=5.3.23" }, @@ -20,12 +19,13 @@ "zendframework/zend-di": "self.version" }, "suggest": { + "ocramius/proxy-manager": "ProxyManager 0.5.* to handle lazy initialization of services", "zendframework/zend-di": "Zend\\Di component" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Session/AbstractContainer.php b/library/Zend/Session/AbstractContainer.php index 92ab8ea1..c6d68c6d 100644 --- a/library/Zend/Session/AbstractContainer.php +++ b/library/Zend/Session/AbstractContainer.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -63,7 +63,7 @@ abstract class AbstractContainer extends ArrayObject */ public function __construct($name = 'Default', Manager $manager = null) { - if (!preg_match('/^[a-z][a-z0-9_\\\]+$/i', $name)) { + if (!preg_match('/^[a-z0-9][a-z0-9_\\\\]+$/i', $name)) { throw new Exception\InvalidArgumentException( 'Name passed to container is invalid; must consist of alphanumerics, backslashes and underscores only' ); @@ -422,10 +422,10 @@ abstract class AbstractContainer extends ArrayObject * @param string $key * @return mixed */ - public function offsetGet($key) + public function &offsetGet($key) { if (!$this->offsetExists($key)) { - return null; + return; } $storage = $this->getStorage(); $name = $this->getName(); @@ -528,7 +528,7 @@ abstract class AbstractContainer extends ArrayObject // Map item keys => timestamp $expires = array_flip($expires); - $expires = array_map(function ($value) use ($ts) { + $expires = array_map(function () use ($ts) { return $ts; }, $expires); @@ -579,7 +579,7 @@ abstract class AbstractContainer extends ArrayObject // Map item keys => timestamp $expires = array_flip($expires); - $expires = array_map(function ($value) use ($hops, $ts) { + $expires = array_map(function () use ($hops, $ts) { return array('hops' => $hops, 'ts' => $ts); }, $expires); diff --git a/library/Zend/Session/AbstractManager.php b/library/Zend/Session/AbstractManager.php index 7f94be15..51eda67d 100644 --- a/library/Zend/Session/AbstractManager.php +++ b/library/Zend/Session/AbstractManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -48,16 +48,26 @@ abstract class AbstractManager implements Manager */ protected $saveHandler; + /** + * @var array + */ + protected $validators; + /** * Constructor * - * @param Config|null $config - * @param Storage|null $storage + * @param Config|null $config + * @param Storage|null $storage * @param SaveHandler|null $saveHandler + * @param array $validators * @throws Exception\RuntimeException */ - public function __construct(Config $config = null, Storage $storage = null, SaveHandler $saveHandler = null) - { + public function __construct( + Config $config = null, + Storage $storage = null, + SaveHandler $saveHandler = null, + array $validators = array() + ) { // init config if ($config === null) { if (!class_exists($this->defaultConfigClass)) { @@ -106,6 +116,8 @@ abstract class AbstractManager implements Manager if ($saveHandler !== null) { $this->saveHandler = $saveHandler; } + + $this->validators = $validators; } /** diff --git a/library/Zend/Session/Config/ConfigInterface.php b/library/Zend/Session/Config/ConfigInterface.php index a71b891e..97b062d7 100644 --- a/library/Zend/Session/Config/ConfigInterface.php +++ b/library/Zend/Session/Config/ConfigInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Config/SessionConfig.php b/library/Zend/Session/Config/SessionConfig.php index 0abf8892..3c96268e 100644 --- a/library/Zend/Session/Config/SessionConfig.php +++ b/library/Zend/Session/Config/SessionConfig.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -85,10 +85,11 @@ class SessionConfig extends StandardConfig break; } - $result = ini_set($key, $storageValue); - if (FALSE === $result) { - throw new Exception\InvalidArgumentException("'" . $key . - "' is not a valid sessions-related ini setting."); + $result = ini_set($key, (string) $storageValue); + if (false === $result) { + throw new Exception\InvalidArgumentException( + "'{$key}' is not a valid sessions-related ini setting." + ); } return $this; } @@ -161,7 +162,6 @@ class SessionConfig extends StandardConfig return $this; } - /** * Set session.serialize_handler * diff --git a/library/Zend/Session/Config/StandardConfig.php b/library/Zend/Session/Config/StandardConfig.php index 805691fd..a5dd2f16 100644 --- a/library/Zend/Session/Config/StandardConfig.php +++ b/library/Zend/Session/Config/StandardConfig.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -88,7 +88,6 @@ class StandardConfig implements ConfigInterface */ protected $options = array(); - /** * Set many options at once * @@ -174,7 +173,7 @@ class StandardConfig implements ConfigInterface return $value; } - return null; + return; } /** @@ -214,7 +213,7 @@ class StandardConfig implements ConfigInterface */ public function getStorageOption($storageOption) { - return null; + return; } /** @@ -251,8 +250,6 @@ class StandardConfig implements ConfigInterface return $this->savePath; } - - /** * Set session.name * diff --git a/library/Zend/Session/Container.php b/library/Zend/Session/Container.php index 7c116290..9957ae72 100644 --- a/library/Zend/Session/Container.php +++ b/library/Zend/Session/Container.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Exception/BadMethodCallException.php b/library/Zend/Session/Exception/BadMethodCallException.php index 518b6414..273372d7 100644 --- a/library/Zend/Session/Exception/BadMethodCallException.php +++ b/library/Zend/Session/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Exception/ExceptionInterface.php b/library/Zend/Session/Exception/ExceptionInterface.php index 2534a709..457ecc7b 100644 --- a/library/Zend/Session/Exception/ExceptionInterface.php +++ b/library/Zend/Session/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Exception/InvalidArgumentException.php b/library/Zend/Session/Exception/InvalidArgumentException.php index ca813627..85e698da 100644 --- a/library/Zend/Session/Exception/InvalidArgumentException.php +++ b/library/Zend/Session/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Exception/RuntimeException.php b/library/Zend/Session/Exception/RuntimeException.php index 0590cf2b..48446ecb 100644 --- a/library/Zend/Session/Exception/RuntimeException.php +++ b/library/Zend/Session/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/ManagerInterface.php b/library/Zend/Session/ManagerInterface.php index 2038c692..f5e34681 100644 --- a/library/Zend/Session/ManagerInterface.php +++ b/library/Zend/Session/ManagerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/SaveHandler/Cache.php b/library/Zend/Session/SaveHandler/Cache.php index c5ad2707..be3b4d75 100644 --- a/library/Zend/Session/SaveHandler/Cache.php +++ b/library/Zend/Session/SaveHandler/Cache.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/SaveHandler/DbTableGateway.php b/library/Zend/Session/SaveHandler/DbTableGateway.php index 1d8487cc..e568fc73 100644 --- a/library/Zend/Session/SaveHandler/DbTableGateway.php +++ b/library/Zend/Session/SaveHandler/DbTableGateway.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -128,7 +128,7 @@ class DbTableGateway implements SaveHandlerInterface $this->options->getNameColumn() => $this->sessionName, )); - if ($row = $rows->current()) { + if ($rows->current()) { return (bool) $this->tableGateway->update($data, array( $this->options->getIdColumn() => $id, $this->options->getNameColumn() => $this->sessionName, @@ -164,9 +164,12 @@ class DbTableGateway implements SaveHandlerInterface public function gc($maxlifetime) { $platform = $this->tableGateway->getAdapter()->getPlatform(); - return (bool) $this->tableGateway->delete(sprintf('%s < %d', - $platform->quoteIdentifier($this->options->getModifiedColumn()), - (time() - $this->lifetime) - )); + return (bool) $this->tableGateway->delete( + sprintf( + '%s < %d', + $platform->quoteIdentifier($this->options->getModifiedColumn()), + (time() - $this->lifetime) + ) + ); } } diff --git a/library/Zend/Session/SaveHandler/DbTableGatewayOptions.php b/library/Zend/Session/SaveHandler/DbTableGatewayOptions.php index ad55c73c..6553863a 100644 --- a/library/Zend/Session/SaveHandler/DbTableGatewayOptions.php +++ b/library/Zend/Session/SaveHandler/DbTableGatewayOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -47,7 +47,6 @@ class DbTableGatewayOptions extends AbstractOptions */ protected $modifiedColumn = 'modified'; - /** * Set Id Column * diff --git a/library/Zend/Session/SaveHandler/MongoDB.php b/library/Zend/Session/SaveHandler/MongoDB.php index 9780b310..2965ab49 100644 --- a/library/Zend/Session/SaveHandler/MongoDB.php +++ b/library/Zend/Session/SaveHandler/MongoDB.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/SaveHandler/MongoDBOptions.php b/library/Zend/Session/SaveHandler/MongoDBOptions.php index 5616337c..9e9a9970 100644 --- a/library/Zend/Session/SaveHandler/MongoDBOptions.php +++ b/library/Zend/Session/SaveHandler/MongoDBOptions.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -76,11 +76,32 @@ class MongoDBOptions extends AbstractOptions { parent::__construct($options); - if ($this->saveOptions === array('w' => 1) && version_compare(phpversion('mongo'), '1.3.0', '<')) { + $mongoVersion = phpversion('mongo') ?: '0.0.0'; + if ($this->saveOptions === array('w' => 1) && version_compare($mongoVersion, '1.3.0', '<')) { $this->saveOptions = array('safe' => true); } } + /** + * Override AbstractOptions::__set + * + * Validates value if save options are being set. + * + * @param string $key + * @param mixed $value + */ + public function __set($key, $value) + { + if (strtolower($key) !== 'saveoptions') { + return parent::__set($key, $value); + } + + if (! is_array($value)) { + throw new InvalidArgumentException('Expected array for save options'); + } + $this->setSaveOptions($value); + } + /** * Set database name * diff --git a/library/Zend/Session/SaveHandler/SaveHandlerInterface.php b/library/Zend/Session/SaveHandler/SaveHandlerInterface.php index 5ee7dd49..8ed3bcf2 100644 --- a/library/Zend/Session/SaveHandler/SaveHandlerInterface.php +++ b/library/Zend/Session/SaveHandler/SaveHandlerInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Service/ContainerAbstractServiceFactory.php b/library/Zend/Session/Service/ContainerAbstractServiceFactory.php index cb4ecd7e..0d099dc6 100644 --- a/library/Zend/Session/Service/ContainerAbstractServiceFactory.php +++ b/library/Zend/Session/Service/ContainerAbstractServiceFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Service/SessionConfigFactory.php b/library/Zend/Session/Service/SessionConfigFactory.php index 389b53d2..35f1d889 100644 --- a/library/Zend/Session/Service/SessionConfigFactory.php +++ b/library/Zend/Session/Service/SessionConfigFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Service/SessionManagerFactory.php b/library/Zend/Session/Service/SessionManagerFactory.php index 5efe3194..712990d1 100644 --- a/library/Zend/Session/Service/SessionManagerFactory.php +++ b/library/Zend/Session/Service/SessionManagerFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -65,6 +65,7 @@ class SessionManagerFactory implements FactoryInterface $config = null; $storage = null; $saveHandler = null; + $validators = array(); $managerConfig = $this->defaultManagerConfig; if ($services->has('Zend\Session\Config\ConfigInterface')) { @@ -103,8 +104,6 @@ class SessionManagerFactory implements FactoryInterface } } - $manager = new SessionManager($config, $storage, $saveHandler); - // Get session manager configuration, if any, and merge with default configuration if ($services->has('Config')) { $configService = $services->get('Config'); @@ -113,16 +112,14 @@ class SessionManagerFactory implements FactoryInterface ) { $managerConfig = array_merge($managerConfig, $configService['session_manager']); } - // Attach validators to session manager, if any + if (isset($managerConfig['validators'])) { - $chain = $manager->getValidatorChain(); - foreach ($managerConfig['validators'] as $validator) { - $validator = new $validator(); - $chain->attach('session.validate', array($validator, 'isValid')); - } + $validators = $managerConfig['validators']; } } + $manager = new SessionManager($config, $storage, $saveHandler, $validators); + // If configuration enables the session manager as the default manager for container // instances, do so. if (isset($managerConfig['enable_default_container_manager']) diff --git a/library/Zend/Session/Service/StorageFactory.php b/library/Zend/Session/Service/StorageFactory.php index 66414268..7dfc827b 100644 --- a/library/Zend/Session/Service/StorageFactory.php +++ b/library/Zend/Session/Service/StorageFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/SessionManager.php b/library/Zend/Session/SessionManager.php index e013e0e7..e2d9dff4 100644 --- a/library/Zend/Session/SessionManager.php +++ b/library/Zend/Session/SessionManager.php @@ -3,13 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Session; use Zend\EventManager\EventManagerInterface; +use Zend\Stdlib\ArrayUtils; /** * Session ManagerInterface implementation utilizing ext/session @@ -40,14 +41,19 @@ class SessionManager extends AbstractManager /** * Constructor * - * @param Config\ConfigInterface|null $config - * @param Storage\StorageInterface|null $storage + * @param Config\ConfigInterface|null $config + * @param Storage\StorageInterface|null $storage * @param SaveHandler\SaveHandlerInterface|null $saveHandler + * @param array $validators * @throws Exception\RuntimeException */ - public function __construct(Config\ConfigInterface $config = null, Storage\StorageInterface $storage = null, SaveHandler\SaveHandlerInterface $saveHandler = null) - { - parent::__construct($config, $storage, $saveHandler); + public function __construct( + Config\ConfigInterface $config = null, + Storage\StorageInterface $storage = null, + SaveHandler\SaveHandlerInterface $saveHandler = null, + array $validators = array() + ) { + parent::__construct($config, $storage, $saveHandler, $validators); register_shutdown_function(array($this, 'writeClose')); } @@ -92,8 +98,19 @@ class SessionManager extends AbstractManager $this->registerSaveHandler($saveHandler); } + $oldSessionData = array(); + if (isset($_SESSION)) { + $oldSessionData = $_SESSION; + } + session_start(); + if ($oldSessionData instanceof \Traversable + || (! empty($oldSessionData) && is_array($oldSessionData)) + ) { + $_SESSION = ArrayUtils::merge($oldSessionData, $_SESSION, true); + } + $storage = $this->getStorage(); // Since session is starting, we need to potentially repopulate our @@ -107,11 +124,32 @@ class SessionManager extends AbstractManager $storage->init($_SESSION); } + $this->initializeValidatorChain(); + if (!$this->isValid()) { throw new Exception\RuntimeException('Session validation failed'); } } + /** + * Create validators, insert reference value and add them to the validator chain + */ + protected function initializeValidatorChain() + { + $validatorChain = $this->getValidatorChain(); + $validatorValues = $this->getStorage()->getMetadata('_VALID'); + + foreach ($this->validators as $validator) { + // Ignore validators which are already present in Storage + if (is_array($validatorValues) && array_key_exists($validator, $validatorValues)) { + continue; + } + + $validator = new $validator(null); + $validatorChain->attach('session.validate', array($validator, 'isValid')); + } + } + /** * Destroy/end a session * @@ -331,7 +369,7 @@ class SessionManager extends AbstractManager public function isValid() { $validator = $this->getValidatorChain(); - $responses = $validator->triggerUntil('session.validate', $this, array($this), function ($test) { + $responses = $validator->trigger('session.validate', $this, array($this), function ($test) { return false === $test; }); if ($responses->stopped()) { @@ -356,8 +394,8 @@ class SessionManager extends AbstractManager return; } setcookie( - $this->getName(), // session name - '', // value + $this->getName(), // session name + '', // value $_SERVER['REQUEST_TIME'] - 42000, // TTL for cookie $config->getCookiePath(), $config->getCookieDomain(), diff --git a/library/Zend/Session/Storage/AbstractSessionArrayStorage.php b/library/Zend/Session/Storage/AbstractSessionArrayStorage.php index 604954ae..bdfbf9a9 100644 --- a/library/Zend/Session/Storage/AbstractSessionArrayStorage.php +++ b/library/Zend/Session/Storage/AbstractSessionArrayStorage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,6 @@ abstract class AbstractSessionArrayStorage implements $this->init($input); } - /** * Initialize Storage * @@ -134,7 +133,7 @@ abstract class AbstractSessionArrayStorage implements return $_SESSION[$key]; } - return null; + return; } /** @@ -351,9 +350,9 @@ abstract class AbstractSessionArrayStorage implements public function setMetadata($key, $value, $overwriteArray = false) { if ($this->isImmutable()) { - throw new Exception\RuntimeException(sprintf( - 'Cannot set key "%s" as storage is marked isImmutable', $key - )); + throw new Exception\RuntimeException( + sprintf('Cannot set key "%s" as storage is marked isImmutable', $key) + ); } if (!isset($_SESSION['__ZF'])) { diff --git a/library/Zend/Session/Storage/ArrayStorage.php b/library/Zend/Session/Storage/ArrayStorage.php index f0d70647..ed54a31a 100644 --- a/library/Zend/Session/Storage/ArrayStorage.php +++ b/library/Zend/Session/Storage/ArrayStorage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -87,14 +87,14 @@ class ArrayStorage extends ArrayObject implements StorageInterface public function offsetSet($key, $value) { if ($this->isImmutable()) { - throw new Exception\RuntimeException(sprintf( - 'Cannot set key "%s" as storage is marked isImmutable', $key - )); + throw new Exception\RuntimeException( + sprintf('Cannot set key "%s" as storage is marked isImmutable', $key) + ); } if ($this->isLocked($key)) { - throw new Exception\RuntimeException(sprintf( - 'Cannot set key "%s" due to locking', $key - )); + throw new Exception\RuntimeException( + sprintf('Cannot set key "%s" due to locking', $key) + ); } parent::offsetSet($key, $value); @@ -232,9 +232,9 @@ class ArrayStorage extends ArrayObject implements StorageInterface public function setMetadata($key, $value, $overwriteArray = false) { if ($this->isImmutable) { - throw new Exception\RuntimeException(sprintf( - 'Cannot set key "%s" as storage is marked isImmutable', $key - )); + throw new Exception\RuntimeException( + sprintf('Cannot set key "%s" as storage is marked isImmutable', $key) + ); } if (!isset($this['__ZF'])) { diff --git a/library/Zend/Session/Storage/Factory.php b/library/Zend/Session/Storage/Factory.php index 0e6c4ea3..0d7bf36e 100644 --- a/library/Zend/Session/Storage/Factory.php +++ b/library/Zend/Session/Storage/Factory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -60,14 +60,11 @@ abstract class Factory switch (true) { case (in_array('Zend\Session\Storage\AbstractSessionArrayStorage', class_parents($type))): return static::createSessionArrayStorage($type, $options); - break; case ($type === 'Zend\Session\Storage\ArrayStorage'): case (in_array('Zend\Session\Storage\ArrayStorage', class_parents($type))): return static::createArrayStorage($type, $options); - break; case (in_array('Zend\Session\Storage\StorageInterface', class_implements($type))): return new $type($options); - break; default: throw new Exception\InvalidArgumentException(sprintf( 'Unrecognized type "%s" provided; expects a class implementing %s\StorageInterface', diff --git a/library/Zend/Session/Storage/SessionArrayStorage.php b/library/Zend/Session/Storage/SessionArrayStorage.php index a8da9292..f000a589 100644 --- a/library/Zend/Session/Storage/SessionArrayStorage.php +++ b/library/Zend/Session/Storage/SessionArrayStorage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Storage/SessionStorage.php b/library/Zend/Session/Storage/SessionStorage.php index 231fb7ff..ec7e2954 100644 --- a/library/Zend/Session/Storage/SessionStorage.php +++ b/library/Zend/Session/Storage/SessionStorage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Storage/StorageInitializationInterface.php b/library/Zend/Session/Storage/StorageInitializationInterface.php index 8323eed4..afb2f7d7 100644 --- a/library/Zend/Session/Storage/StorageInitializationInterface.php +++ b/library/Zend/Session/Storage/StorageInitializationInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Storage/StorageInterface.php b/library/Zend/Session/Storage/StorageInterface.php index 4070bc5f..74a26e39 100644 --- a/library/Zend/Session/Storage/StorageInterface.php +++ b/library/Zend/Session/Storage/StorageInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Validator/HttpUserAgent.php b/library/Zend/Session/Validator/HttpUserAgent.php index 5b1bf92e..f8129bfc 100644 --- a/library/Zend/Session/Validator/HttpUserAgent.php +++ b/library/Zend/Session/Validator/HttpUserAgent.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/Validator/RemoteAddr.php b/library/Zend/Session/Validator/RemoteAddr.php index d8870059..ba7626f1 100644 --- a/library/Zend/Session/Validator/RemoteAddr.php +++ b/library/Zend/Session/Validator/RemoteAddr.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -50,6 +50,8 @@ class RemoteAddr implements SessionValidator /** * Constructor * get the current user IP and store it in the session as 'valid data' + * + * @param null|string $data */ public function __construct($data = null) { diff --git a/library/Zend/Session/Validator/ValidatorInterface.php b/library/Zend/Session/Validator/ValidatorInterface.php index fcbe9bca..6f1c8b77 100644 --- a/library/Zend/Session/Validator/ValidatorInterface.php +++ b/library/Zend/Session/Validator/ValidatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Session/ValidatorChain.php b/library/Zend/Session/ValidatorChain.php index 5774c98f..333797d0 100644 --- a/library/Zend/Session/ValidatorChain.php +++ b/library/Zend/Session/ValidatorChain.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Session; diff --git a/library/Zend/Session/compatibility/autoload.php b/library/Zend/Session/compatibility/autoload.php index 3ecffe7f..287c6ba0 100644 --- a/library/Zend/Session/compatibility/autoload.php +++ b/library/Zend/Session/compatibility/autoload.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @deprecated */ diff --git a/library/Zend/Session/composer.json b/library/Zend/Session/composer.json index c3541e78..42a67e8f 100644 --- a/library/Zend/Session/composer.json +++ b/library/Zend/Session/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Session\\": "" } }, - "target-dir": "Zend/Session", "require": { "php": ">=5.3.23", "zendframework/zend-eventmanager": "self.version", @@ -35,8 +34,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Soap/AutoDiscover.php b/library/Zend/Soap/AutoDiscover.php index 92f79c5f..c4ca0f53 100644 --- a/library/Zend/Soap/AutoDiscover.php +++ b/library/Zend/Soap/AutoDiscover.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -150,7 +150,7 @@ class AutoDiscover /** * Set the class map of php to wsdl mappings. * - * @param array $classmap + * @param array $classMap * @return self * @throws Exception\InvalidArgumentException */ @@ -207,7 +207,6 @@ class AutoDiscover return $this->serviceName; } - /** * Set the location at which the WSDL file will be available. * diff --git a/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php b/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php index fccbd95d..126b1e3f 100644 --- a/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php +++ b/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php b/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php index abc7688b..b5ab91a3 100644 --- a/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php +++ b/library/Zend/Soap/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Client.php b/library/Zend/Soap/Client.php index 6bb794b2..381e6d71 100644 --- a/library/Zend/Soap/Client.php +++ b/library/Zend/Soap/Client.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -270,14 +270,13 @@ class Client implements ServerClient $this->setTypemap($value); break; - // Not used now - // case 'connection_timeout': - // $this->connectionTimeout = $value; - // break; + case 'connectiontimeout': + case 'connection_timeout': + $this->connectionTimeout = $value; + break; default: throw new Exception\InvalidArgumentException('Unknown SOAP client option'); - break; } } @@ -311,7 +310,7 @@ class Client implements ServerClient $options['local_cert'] = $this->getHttpsCertificate(); $options['passphrase'] = $this->getHttpsCertPassphrase(); $options['compression'] = $this->getCompressionOptions(); - //$options['connection_timeout'] = $this->connectionTimeout; + $options['connection_timeout'] = $this->connectionTimeout; $options['stream_context'] = $this->getStreamContext(); $options['cache_wsdl'] = $this->getWSDLCache(); $options['features'] = $this->getSoapFeatures(); @@ -327,7 +326,7 @@ class Client implements ServerClient unset($options[$key]); } } else { - if ($value == null) { + if ($value === null) { unset($options[$key]); } } @@ -985,7 +984,7 @@ class Client implements ServerClient * @param int $oneWay * @return mixed */ - public function _doRequest(Client\Common $client, $request, $location,$action, $version, $oneWay = null) + public function _doRequest(Client\Common $client, $request, $location, $action, $version, $oneWay = null) { // Perform request as is if ($oneWay === null) { @@ -1004,7 +1003,7 @@ class Client implements ServerClient $wsdl = $this->getWSDL(); $options = array_merge($this->getOptions(), array('trace' => true)); - if ($wsdl == null) { + if ($wsdl === null) { if (!isset($options['location'])) { throw new Exception\UnexpectedValueException('"location" parameter is required in non-WSDL mode.'); } @@ -1143,7 +1142,7 @@ class Client implements ServerClient */ public function getFunctions() { - if ($this->getWSDL() == null) { + if ($this->getWSDL() === null) { throw new Exception\UnexpectedValueException(sprintf( '%s method is available only in WSDL mode.', __METHOD__ @@ -1162,7 +1161,7 @@ class Client implements ServerClient */ public function getTypes() { - if ($this->getWSDL() == null) { + if ($this->getWSDL() === null) { throw new Exception\UnexpectedValueException(sprintf( '%s method is available only in WSDL mode.', __METHOD__ @@ -1192,7 +1191,7 @@ class Client implements ServerClient */ public function getSoapClient() { - if ($this->soapClient == null) { + if ($this->soapClient === null) { $this->_initSoapClientObject(); } return $this->soapClient; diff --git a/library/Zend/Soap/Client/Common.php b/library/Zend/Soap/Client/Common.php index a252f0b2..5b1c2fb4 100644 --- a/library/Zend/Soap/Client/Common.php +++ b/library/Zend/Soap/Client/Common.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Client/DotNet.php b/library/Zend/Soap/Client/DotNet.php index 0910dd13..84393d87 100644 --- a/library/Zend/Soap/Client/DotNet.php +++ b/library/Zend/Soap/Client/DotNet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Client/Local.php b/library/Zend/Soap/Client/Local.php index 61c11cfa..fc9868c0 100644 --- a/library/Zend/Soap/Client/Local.php +++ b/library/Zend/Soap/Client/Local.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Exception/BadMethodCallException.php b/library/Zend/Soap/Exception/BadMethodCallException.php index 970baa36..6cc54650 100644 --- a/library/Zend/Soap/Exception/BadMethodCallException.php +++ b/library/Zend/Soap/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Exception/ExceptionInterface.php b/library/Zend/Soap/Exception/ExceptionInterface.php index ceb6da94..1aae25f6 100644 --- a/library/Zend/Soap/Exception/ExceptionInterface.php +++ b/library/Zend/Soap/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Exception/ExtensionNotLoadedException.php b/library/Zend/Soap/Exception/ExtensionNotLoadedException.php index 536cde40..03e346bd 100644 --- a/library/Zend/Soap/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Soap/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Exception/InvalidArgumentException.php b/library/Zend/Soap/Exception/InvalidArgumentException.php index 0b0899ee..8b9ec023 100644 --- a/library/Zend/Soap/Exception/InvalidArgumentException.php +++ b/library/Zend/Soap/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Exception/RuntimeException.php b/library/Zend/Soap/Exception/RuntimeException.php index 40214d58..9a36a5ab 100644 --- a/library/Zend/Soap/Exception/RuntimeException.php +++ b/library/Zend/Soap/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Exception/UnexpectedValueException.php b/library/Zend/Soap/Exception/UnexpectedValueException.php index 062c1deb..b18e0108 100644 --- a/library/Zend/Soap/Exception/UnexpectedValueException.php +++ b/library/Zend/Soap/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Server.php b/library/Zend/Soap/Server.php index 3c563b44..d5e22fb2 100644 --- a/library/Zend/Soap/Server.php +++ b/library/Zend/Soap/Server.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -448,7 +448,10 @@ class Server implements ZendServerServer foreach ($typeMap as $type) { if (!is_callable($type['from_xml'])) { - throw new Exception\InvalidArgumentException('Invalid from_xml callback for type: ' . $type['type_name']); + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid from_xml callback for type: %s', + $type['type_name'] + )); } if (!is_callable($type['to_xml'])) { throw new Exception\InvalidArgumentException('Invalid to_xml callback for type: ' . $type['type_name']); @@ -590,7 +593,9 @@ class Server implements ZendServerServer public function setClass($class, $namespace = '', $argv = null) { if (isset($this->class)) { - throw new Exception\InvalidArgumentException('A class has already been registered with this soap server instance'); + throw new Exception\InvalidArgumentException( + 'A class has already been registered with this soap server instance' + ); } if (is_object($class)) { @@ -785,7 +790,7 @@ class Server implements ZendServerServer */ public function setReturnResponse($flag = true) { - $this->returnResponse = ($flag) ? true : false; + $this->returnResponse = (bool) $flag; return $this; } @@ -914,7 +919,7 @@ class Server implements ZendServerServer // Restore original error handler restore_error_handler(); - ini_set('display_errors', $displayErrorsOriginalState); + ini_set('display_errors', (string) $displayErrorsOriginalState); // Send a fault, if we have one if ($fault instanceof SoapFault && !$this->returnResponse) { @@ -947,7 +952,7 @@ class Server implements ZendServerServer protected function _initializeSoapErrorContext() { $displayErrorsOriginalState = ini_get('display_errors'); - ini_set('display_errors', false); + ini_set('display_errors', '0'); set_error_handler(array($this, 'handlePhpErrors'), E_USER_ERROR); return $displayErrorsOriginalState; } @@ -955,7 +960,9 @@ class Server implements ZendServerServer /** * Set the debug mode. * In debug mode, all exceptions are send to the client. - * @param bool $debug + * + * @param bool $debug + * @return self */ public function setDebugMode($debug) { @@ -976,14 +983,18 @@ class Server implements ZendServerServer foreach ($class as $row) { $this->registerFaultException($row); } - } elseif (is_string($class) && class_exists($class) && (is_subclass_of($class, 'Exception') || 'Exception' === $class)) { + } elseif (is_string($class) + && class_exists($class) + && (is_subclass_of($class, 'Exception') || 'Exception' === $class) + ) { $ref = new ReflectionClass($class); $this->faultExceptions[] = $ref->getName(); $this->faultExceptions = array_unique($this->faultExceptions); } else { throw new Exception\InvalidArgumentException( - 'Argument for Zend\Soap\Server::registerFaultException should be string or array of strings with valid exception names' + 'Argument for Zend\Soap\Server::registerFaultException should be' + . ' string or array of strings with valid exception names' ); } @@ -1075,7 +1086,14 @@ class Server implements ZendServerServer $message = 'Unknown error'; } - $allowedFaultModes = array('VersionMismatch', 'MustUnderstand', 'DataEncodingUnknown', 'Sender', 'Receiver', 'Server'); + $allowedFaultModes = array( + 'VersionMismatch', + 'MustUnderstand', + 'DataEncodingUnknown', + 'Sender', + 'Receiver', + 'Server' + ); if (!in_array($code, $allowedFaultModes)) { $code = 'Receiver'; } diff --git a/library/Zend/Soap/Server/DocumentLiteralWrapper.php b/library/Zend/Soap/Server/DocumentLiteralWrapper.php index fcf4c20a..b3f7222c 100644 --- a/library/Zend/Soap/Server/DocumentLiteralWrapper.php +++ b/library/Zend/Soap/Server/DocumentLiteralWrapper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Wsdl.php b/library/Zend/Soap/Wsdl.php index 33def53c..5cac9b2b 100644 --- a/library/Zend/Soap/Wsdl.php +++ b/library/Zend/Soap/Wsdl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -165,9 +165,10 @@ class Wsdl /** * Set the class map of php to wsdl mappings.. * + * @param array $classMap * @return self */ - public function setClassMap($classMap) + public function setClassMap(array $classMap) { $this->classMap = $classMap; return $this; @@ -190,7 +191,7 @@ class Wsdl $oldUri = $this->uri; $this->uri = $uri; - if ($this->dom instanceof DOMDocument ) { + if ($this->dom instanceof DOMDocument) { // namespace declarations are NOT true attributes so one must explicitly set on root element // xmlns:tns = $uri $this->dom->documentElement->setAttributeNS(self::XML_NS_URI, self::XML_NS . ':' . self::TYPES_NS, $uri); @@ -549,7 +550,7 @@ class Wsdl if ($types instanceof DOMDocument) { $dom = $this->dom->importNode($types->documentElement); $this->wsdl->appendChild($dom); - } elseif ($types instanceof DOMNode || $types instanceof DOMElement || $types instanceof DOMDocumentFragment ) { + } elseif ($types instanceof DOMNode || $types instanceof DOMElement || $types instanceof DOMDocumentFragment) { $dom = $this->dom->importNode($types); $this->wsdl->appendChild($dom); } @@ -587,7 +588,7 @@ class Wsdl */ public function getSchema() { - if ($this->schema == null) { + if ($this->schema === null) { $this->addSchemaTypeSection(); } return $this->schema; @@ -713,7 +714,7 @@ class Wsdl return $this->classMap[$type]; } - $type = trim($type,'\\'); + $type = trim($type, '\\'); // remove namespace, $pos = strrpos($type, '\\'); @@ -795,11 +796,9 @@ class Wsdl case 'soapaction': case 'location': return $this->sanitizeUri($value); - break; default: return $value; - break; } } @@ -859,7 +858,7 @@ class Wsdl */ protected function getSoapNamespaceUriByVersion($soapVersion) { - if ($soapVersion != SOAP_1_1 AND $soapVersion != SOAP_1_2) { + if ($soapVersion != SOAP_1_1 and $soapVersion != SOAP_1_2) { throw new Exception\InvalidArgumentException('Invalid SOAP version, use constants: SOAP_1_1 or SOAP_1_2'); } diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AbstractComplexTypeStrategy.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AbstractComplexTypeStrategy.php index b8c3b04c..5babaeaf 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AbstractComplexTypeStrategy.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AbstractComplexTypeStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -54,6 +54,6 @@ abstract class AbstractComplexTypeStrategy implements ComplexTypeStrategyInterfa $soapTypes = $this->getContext()->getTypes(); return $soapTypes[$phpType]; } - return null; + return; } } diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AnyType.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AnyType.php index 17774147..c1594df8 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AnyType.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AnyType.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php index 487a9699..16f9eee5 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -69,7 +69,6 @@ class ArrayOfTypeComplex extends DefaultComplexType // Process singular type using DefaultComplexType strategy parent::addComplexType($singularType); - // Add array type structure to WSDL document $dom = $this->getContext()->toDomDocument(); diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php index c9248e2a..9085f089 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -104,7 +104,6 @@ class ArrayOfTypeSequence extends DefaultComplexType // Register type here to avoid recursion $this->getContext()->addType($phpArrayType, $arrayType); - $dom = $this->getContext()->toDomDocument(); $arrayTypeName = substr($arrayType, strpos($arrayType, ':') + 1); diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ComplexTypeStrategyInterface.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ComplexTypeStrategyInterface.php index 47aece37..69128a17 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ComplexTypeStrategyInterface.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/ComplexTypeStrategyInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/Composite.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/Composite.php index 784e73f6..8f1b9f0b 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/Composite.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/Composite.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index 59e74e56..b3fe27c3 100644 --- a/library/Zend/Soap/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/library/Zend/Soap/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Soap/composer.json b/library/Zend/Soap/composer.json index 53b0a87d..828aed14 100644 --- a/library/Zend/Soap/composer.json +++ b/library/Zend/Soap/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Soap\\": "" } }, - "target-dir": "Zend/Soap", "require": { "php": ">=5.3.23", "zendframework/zend-server": "self.version", @@ -27,8 +26,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Stdlib/AbstractOptions.php b/library/Zend/Stdlib/AbstractOptions.php index 6bb4c12a..aaa1dd29 100644 --- a/library/Zend/Stdlib/AbstractOptions.php +++ b/library/Zend/Stdlib/AbstractOptions.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -47,10 +47,15 @@ abstract class AbstractOptions implements ParameterObjectInterface } if (!is_array($options) && !$options instanceof Traversable) { - throw new Exception\InvalidArgumentException(sprintf( - 'Parameter provided to %s must be an %s, %s or %s', - __METHOD__, 'array', 'Traversable', 'Zend\Stdlib\AbstractOptions' - )); + throw new Exception\InvalidArgumentException( + sprintf( + 'Parameter provided to %s must be an %s, %s or %s', + __METHOD__, + 'array', + 'Traversable', + 'Zend\Stdlib\AbstractOptions' + ) + ); } foreach ($options as $key => $value) { @@ -93,17 +98,22 @@ abstract class AbstractOptions implements ParameterObjectInterface */ public function __set($key, $value) { - $setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); - if ($this->__strictMode__ && !method_exists($this, $setter)) { - throw new Exception\BadMethodCallException( - 'The option "' . $key . '" does not ' - . 'have a matching ' . $setter . ' setter method ' - . 'which must be defined' - ); - } elseif (!$this->__strictMode__ && !method_exists($this, $setter)) { + $setter = 'set' . str_replace('_', '', $key); + + if (is_callable(array($this, $setter))) { + $this->{$setter}($value); + return; } - $this->{$setter}($value); + + if ($this->__strictMode__) { + throw new Exception\BadMethodCallException(sprintf( + 'The option "%s" does not have a callable "%s" ("%s") setter method which must be defined', + $key, + 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))), + $setter + )); + } } /** @@ -116,16 +126,17 @@ abstract class AbstractOptions implements ParameterObjectInterface */ public function __get($key) { - $getter = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); - if (!method_exists($this, $getter)) { - throw new Exception\BadMethodCallException( - 'The option "' . $key . '" does not ' - . 'have a matching ' . $getter . ' getter method ' - . 'which must be defined' - ); + $getter = 'get' . str_replace('_', '', $key); + + if (is_callable(array($this, $getter))) { + return $this->{$getter}(); } - return $this->{$getter}(); + throw new Exception\BadMethodCallException(sprintf( + 'The option "%s" does not have a callable "%s" getter method which must be defined', + $key, + 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))) + )); } /** @@ -136,7 +147,9 @@ abstract class AbstractOptions implements ParameterObjectInterface */ public function __isset($key) { - return null !== $this->__get($key); + $getter = 'get' . str_replace('_', '', $key); + + return method_exists($this, $getter) && null !== $this->__get($key); } /** @@ -154,7 +167,7 @@ abstract class AbstractOptions implements ParameterObjectInterface } catch (Exception\BadMethodCallException $e) { throw new Exception\InvalidArgumentException( 'The class property $' . $key . ' cannot be unset as' - . ' NULL is an invalid value for it', + . ' NULL is an invalid value for it', 0, $e ); diff --git a/library/Zend/Stdlib/ArrayObject.php b/library/Zend/Stdlib/ArrayObject.php index b4d9eb79..44145c85 100644 --- a/library/Zend/Stdlib/ArrayObject.php +++ b/library/Zend/Stdlib/ArrayObject.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/ArraySerializableInterface.php b/library/Zend/Stdlib/ArraySerializableInterface.php index 222f57b0..dcf84719 100644 --- a/library/Zend/Stdlib/ArraySerializableInterface.php +++ b/library/Zend/Stdlib/ArraySerializableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/ArrayStack.php b/library/Zend/Stdlib/ArrayStack.php index 0fcceb95..39d02aac 100644 --- a/library/Zend/Stdlib/ArrayStack.php +++ b/library/Zend/Stdlib/ArrayStack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/ArrayUtils.php b/library/Zend/Stdlib/ArrayUtils.php index a9ece65f..3545054e 100644 --- a/library/Zend/Stdlib/ArrayUtils.php +++ b/library/Zend/Stdlib/ArrayUtils.php @@ -3,13 +3,15 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib; use Traversable; +use Zend\Stdlib\ArrayUtils\MergeRemoveKey; +use Zend\Stdlib\ArrayUtils\MergeReplaceKeyInterface; /** * Utility class for testing and manipulation of PHP arrays. @@ -18,6 +20,16 @@ use Traversable; */ abstract class ArrayUtils { + /** + * Compatibility Flag for ArrayUtils::filter + */ + const ARRAY_FILTER_USE_BOTH = 1; + + /** + * Compatibility Flag for ArrayUtils::filter + */ + const ARRAY_FILTER_USE_KEY = 2; + /** * Test whether an array contains one or more string keys * @@ -257,8 +269,12 @@ abstract class ArrayUtils public static function merge(array $a, array $b, $preserveNumericKeys = false) { foreach ($b as $key => $value) { - if (isset($a[$key]) || array_key_exists($key, $a)) { - if (!$preserveNumericKeys && is_int($key)) { + if ($value instanceof MergeReplaceKeyInterface) { + $a[$key] = $value->getData(); + } elseif (isset($a[$key]) || array_key_exists($key, $a)) { + if ($value instanceof MergeRemoveKey) { + unset($a[$key]); + } elseif (!$preserveNumericKeys && is_int($key)) { $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { $a[$key] = static::merge($a[$key], $value, $preserveNumericKeys); @@ -266,10 +282,54 @@ abstract class ArrayUtils $a[$key] = $value; } } else { - $a[$key] = $value; + if (!$value instanceof MergeRemoveKey) { + $a[$key] = $value; + } } } return $a; } + + /** + * Compatibility Method for array_filter on <5.6 systems + * + * @param array $data + * @param callable $callback + * @param null|int $flag + * @return array + */ + public static function filter(array $data, $callback, $flag = null) + { + if (! is_callable($callback)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Second parameter of %s must be callable', + __METHOD__ + )); + } + + if (version_compare(PHP_VERSION, '5.6.0') >= 0) { + return array_filter($data, $callback, $flag); + } + + $output = array(); + foreach ($data as $key => $value) { + $params = array($value); + + if ($flag === static::ARRAY_FILTER_USE_BOTH) { + $params[] = $key; + } + + if ($flag === static::ARRAY_FILTER_USE_KEY) { + $params = array($key); + } + + $response = call_user_func_array($callback, $params); + if ($response) { + $output[$key] = $value; + } + } + + return $output; + } } diff --git a/library/Zend/Stdlib/ArrayUtils/MergeRemoveKey.php b/library/Zend/Stdlib/ArrayUtils/MergeRemoveKey.php new file mode 100644 index 00000000..7c4d097d --- /dev/null +++ b/library/Zend/Stdlib/ArrayUtils/MergeRemoveKey.php @@ -0,0 +1,14 @@ +data = $data; + } + + /** + * {@inheritDoc} + */ + public function getData() + { + return $this->data; + } +} diff --git a/library/Zend/Stdlib/ArrayUtils/MergeReplaceKeyInterface.php b/library/Zend/Stdlib/ArrayUtils/MergeReplaceKeyInterface.php new file mode 100644 index 00000000..725cf11b --- /dev/null +++ b/library/Zend/Stdlib/ArrayUtils/MergeReplaceKeyInterface.php @@ -0,0 +1,21 @@ +metadata)) { return $this->metadata[$name]; } - return null; + return; } /** diff --git a/library/Zend/Stdlib/DateTime.php b/library/Zend/Stdlib/DateTime.php index 64a39f62..cdab67d6 100644 --- a/library/Zend/Stdlib/DateTime.php +++ b/library/Zend/Stdlib/DateTime.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/DispatchableInterface.php b/library/Zend/Stdlib/DispatchableInterface.php index b8bfdac1..4f74d1e8 100644 --- a/library/Zend/Stdlib/DispatchableInterface.php +++ b/library/Zend/Stdlib/DispatchableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/ErrorHandler.php b/library/Zend/Stdlib/ErrorHandler.php index d3255843..01949d1e 100644 --- a/library/Zend/Stdlib/ErrorHandler.php +++ b/library/Zend/Stdlib/ErrorHandler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/BadMethodCallException.php b/library/Zend/Stdlib/Exception/BadMethodCallException.php index 4b06b388..0254e45b 100644 --- a/library/Zend/Stdlib/Exception/BadMethodCallException.php +++ b/library/Zend/Stdlib/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/DomainException.php b/library/Zend/Stdlib/Exception/DomainException.php index 3178c153..6d2ac714 100644 --- a/library/Zend/Stdlib/Exception/DomainException.php +++ b/library/Zend/Stdlib/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/ExceptionInterface.php b/library/Zend/Stdlib/Exception/ExceptionInterface.php index d43eb307..60b795f8 100644 --- a/library/Zend/Stdlib/Exception/ExceptionInterface.php +++ b/library/Zend/Stdlib/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/ExtensionNotLoadedException.php b/library/Zend/Stdlib/Exception/ExtensionNotLoadedException.php index 3955952f..4b51475f 100644 --- a/library/Zend/Stdlib/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Stdlib/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/InvalidArgumentException.php b/library/Zend/Stdlib/Exception/InvalidArgumentException.php index 534d1906..8028c471 100644 --- a/library/Zend/Stdlib/Exception/InvalidArgumentException.php +++ b/library/Zend/Stdlib/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/InvalidCallbackException.php b/library/Zend/Stdlib/Exception/InvalidCallbackException.php index bfc1070a..aa36f986 100644 --- a/library/Zend/Stdlib/Exception/InvalidCallbackException.php +++ b/library/Zend/Stdlib/Exception/InvalidCallbackException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/LogicException.php b/library/Zend/Stdlib/Exception/LogicException.php index 8becb252..087ac0e8 100644 --- a/library/Zend/Stdlib/Exception/LogicException.php +++ b/library/Zend/Stdlib/Exception/LogicException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Exception/RuntimeException.php b/library/Zend/Stdlib/Exception/RuntimeException.php index bb52eb87..f3891d64 100644 --- a/library/Zend/Stdlib/Exception/RuntimeException.php +++ b/library/Zend/Stdlib/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Extractor/ExtractionInterface.php b/library/Zend/Stdlib/Extractor/ExtractionInterface.php index 8913b099..297d5577 100644 --- a/library/Zend/Stdlib/Extractor/ExtractionInterface.php +++ b/library/Zend/Stdlib/Extractor/ExtractionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Glob.php b/library/Zend/Stdlib/Glob.php index 5a821be9..a4d0068a 100644 --- a/library/Zend/Stdlib/Glob.php +++ b/library/Zend/Stdlib/Glob.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib; - /** * Wrapper for glob with fallback if GLOB_BRACE is not available. */ diff --git a/library/Zend/Stdlib/Guard/AllGuardsTrait.php b/library/Zend/Stdlib/Guard/AllGuardsTrait.php index 60b34128..95bc5162 100644 --- a/library/Zend/Stdlib/Guard/AllGuardsTrait.php +++ b/library/Zend/Stdlib/Guard/AllGuardsTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Guard/ArrayOrTraversableGuardTrait.php b/library/Zend/Stdlib/Guard/ArrayOrTraversableGuardTrait.php index 84e846ea..e6959a5e 100644 --- a/library/Zend/Stdlib/Guard/ArrayOrTraversableGuardTrait.php +++ b/library/Zend/Stdlib/Guard/ArrayOrTraversableGuardTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Guard/EmptyGuardTrait.php b/library/Zend/Stdlib/Guard/EmptyGuardTrait.php index 72f5b345..c6751cc3 100644 --- a/library/Zend/Stdlib/Guard/EmptyGuardTrait.php +++ b/library/Zend/Stdlib/Guard/EmptyGuardTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Guard/GuardUtils.php b/library/Zend/Stdlib/Guard/GuardUtils.php index 31c44641..4fe4ccac 100644 --- a/library/Zend/Stdlib/Guard/GuardUtils.php +++ b/library/Zend/Stdlib/Guard/GuardUtils.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Guard/NullGuardTrait.php b/library/Zend/Stdlib/Guard/NullGuardTrait.php index e7aadb15..eac71628 100644 --- a/library/Zend/Stdlib/Guard/NullGuardTrait.php +++ b/library/Zend/Stdlib/Guard/NullGuardTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/AbstractHydrator.php b/library/Zend/Stdlib/Hydrator/AbstractHydrator.php index fc07ae4d..338ed804 100644 --- a/library/Zend/Stdlib/Hydrator/AbstractHydrator.php +++ b/library/Zend/Stdlib/Hydrator/AbstractHydrator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/Aggregate/AggregateHydrator.php b/library/Zend/Stdlib/Hydrator/Aggregate/AggregateHydrator.php index 335f5648..38a868e0 100644 --- a/library/Zend/Stdlib/Hydrator/Aggregate/AggregateHydrator.php +++ b/library/Zend/Stdlib/Hydrator/Aggregate/AggregateHydrator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/Aggregate/ExtractEvent.php b/library/Zend/Stdlib/Hydrator/Aggregate/ExtractEvent.php index 7e199397..b13bc5c7 100644 --- a/library/Zend/Stdlib/Hydrator/Aggregate/ExtractEvent.php +++ b/library/Zend/Stdlib/Hydrator/Aggregate/ExtractEvent.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Aggregate; - use Zend\EventManager\Event; /** diff --git a/library/Zend/Stdlib/Hydrator/Aggregate/HydrateEvent.php b/library/Zend/Stdlib/Hydrator/Aggregate/HydrateEvent.php index 0cc48abe..a7c91eec 100644 --- a/library/Zend/Stdlib/Hydrator/Aggregate/HydrateEvent.php +++ b/library/Zend/Stdlib/Hydrator/Aggregate/HydrateEvent.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Aggregate; - use Zend\EventManager\Event; /** diff --git a/library/Zend/Stdlib/Hydrator/Aggregate/HydratorListener.php b/library/Zend/Stdlib/Hydrator/Aggregate/HydratorListener.php index d2d8ff46..1c25ff3c 100644 --- a/library/Zend/Stdlib/Hydrator/Aggregate/HydratorListener.php +++ b/library/Zend/Stdlib/Hydrator/Aggregate/HydratorListener.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Aggregate; - use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManagerInterface; use Zend\Stdlib\Hydrator\HydratorInterface; diff --git a/library/Zend/Stdlib/Hydrator/ArraySerializable.php b/library/Zend/Stdlib/Hydrator/ArraySerializable.php index 7b8a48ba..4f4ab2a1 100644 --- a/library/Zend/Stdlib/Hydrator/ArraySerializable.php +++ b/library/Zend/Stdlib/Hydrator/ArraySerializable.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,9 +25,9 @@ class ArraySerializable extends AbstractHydrator public function extract($object) { if (!is_callable(array($object, 'getArrayCopy'))) { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided object to implement getArrayCopy()', __METHOD__ - )); + throw new Exception\BadMethodCallException( + sprintf('%s expects the provided object to implement getArrayCopy()', __METHOD__) + ); } $data = $object->getArrayCopy(); @@ -74,9 +74,9 @@ class ArraySerializable extends AbstractHydrator } elseif (is_callable(array($object, 'populate'))) { $object->populate($replacement); } else { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided object to implement exchangeArray() or populate()', __METHOD__ - )); + throw new Exception\BadMethodCallException( + sprintf('%s expects the provided object to implement exchangeArray() or populate()', __METHOD__) + ); } return $object; } diff --git a/library/Zend/Stdlib/Hydrator/ClassMethods.php b/library/Zend/Stdlib/Hydrator/ClassMethods.php index 07376d95..4edb1f4d 100644 --- a/library/Zend/Stdlib/Hydrator/ClassMethods.php +++ b/library/Zend/Stdlib/Hydrator/ClassMethods.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -19,12 +19,30 @@ use Zend\Stdlib\Hydrator\Filter\HasFilter; use Zend\Stdlib\Hydrator\Filter\IsFilter; use Zend\Stdlib\Hydrator\Filter\MethodMatchFilter; use Zend\Stdlib\Hydrator\Filter\OptionalParametersFilter; +use Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface; use Zend\Stdlib\Hydrator\NamingStrategy\UnderscoreNamingStrategy; class ClassMethods extends AbstractHydrator implements HydratorOptionsInterface { + /** + * Holds the names of the methods used for hydration, indexed by class::property name, + * false if the hydration method is not callable/usable for hydration purposes + * + * @var string[]|bool[] + */ + private $hydrationMethodsCache = array(); + + /** + * A map of extraction methods to property name to be used during extraction, indexed + * by class name and method name + * + * @var string[][] + */ + private $extractionMethodsCache = array(); + /** * Flag defining whether array keys are underscore-separated (true) or camel case (false) + * * @var bool */ protected $underscoreSeparatedKeys = true; @@ -110,49 +128,60 @@ class ClassMethods extends AbstractHydrator implements HydratorOptionsInterface { if (!is_object($object)) { throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided $object to be a PHP object)', __METHOD__ + '%s expects the provided $object to be a PHP object)', + __METHOD__ )); } - $filter = null; + $objectClass = get_class($object); + + // reset the hydrator's hydrator's cache for this object, as the filter may be per-instance if ($object instanceof FilterProviderInterface) { - $filter = new FilterComposite( - array($object->getFilter()), - array(new MethodMatchFilter('getFilter')) - ); - } else { - $filter = $this->filterComposite; + $this->extractionMethodsCache[$objectClass] = null; } - $attributes = array(); - $methods = get_class_methods($object); + // pass 1 - finding out which properties can be extracted, with which methods (populate hydration cache) + if (! isset($this->extractionMethodsCache[$objectClass])) { + $this->extractionMethodsCache[$objectClass] = array(); + $filter = $this->filterComposite; + $methods = get_class_methods($object); - foreach ($methods as $method) { - if ( - !$filter->filter( - get_class($object) . '::' . $method - ) - ) { - continue; + if ($object instanceof FilterProviderInterface) { + $filter = new FilterComposite( + array($object->getFilter()), + array(new MethodMatchFilter('getFilter')) + ); } - if (!$this->callableMethodFilter->filter(get_class($object) . '::' . $method)) { - continue; - } + foreach ($methods as $method) { + $methodFqn = $objectClass . '::' . $method; - $attribute = $method; - if (preg_match('/^get/', $method)) { - $attribute = substr($method, 3); - if (!property_exists($object, $attribute)) { - $attribute = lcfirst($attribute); + if (! ($filter->filter($methodFqn) && $this->callableMethodFilter->filter($methodFqn))) { + continue; } - } - $attribute = $this->extractName($attribute, $object); - $attributes[$attribute] = $this->extractValue($attribute, $object->$method(), $object); + $attribute = $method; + + if (strpos($method, 'get') === 0) { + $attribute = substr($method, 3); + if (!property_exists($object, $attribute)) { + $attribute = lcfirst($attribute); + } + } + + $this->extractionMethodsCache[$objectClass][$method] = $attribute; + } } - return $attributes; + $values = array(); + + // pass 2 - actually extract data + foreach ($this->extractionMethodsCache[$objectClass] as $methodName => $attributeName) { + $realAttributeName = $this->extractName($attributeName, $object); + $values[$realAttributeName] = $this->extractValue($realAttributeName, $object->$methodName(), $object); + } + + return $values; } /** @@ -169,18 +198,77 @@ class ClassMethods extends AbstractHydrator implements HydratorOptionsInterface { if (!is_object($object)) { throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided $object to be a PHP object)', __METHOD__ + '%s expects the provided $object to be a PHP object)', + __METHOD__ )); } + $objectClass = get_class($object); + foreach ($data as $property => $value) { - $method = 'set' . ucfirst($this->hydrateName($property, $data)); - if (is_callable(array($object, $method))) { - $value = $this->hydrateValue($property, $value, $data); - $object->$method($value); + $propertyFqn = $objectClass . '::$' . $property; + + if (! isset($this->hydrationMethodsCache[$propertyFqn])) { + $setterName = 'set' . ucfirst($this->hydrateName($property, $data)); + + $this->hydrationMethodsCache[$propertyFqn] = is_callable(array($object, $setterName)) + ? $setterName + : false; + } + + if ($this->hydrationMethodsCache[$propertyFqn]) { + $object->{$this->hydrationMethodsCache[$propertyFqn]}($this->hydrateValue($property, $value, $data)); } } return $object; } + + /** + * {@inheritDoc} + */ + public function addFilter($name, $filter, $condition = FilterComposite::CONDITION_OR) + { + $this->resetCaches(); + + return parent::addFilter($name, $filter, $condition); + } + + /** + * {@inheritDoc} + */ + public function removeFilter($name) + { + $this->resetCaches(); + + return parent::removeFilter($name); + } + + /** + * {@inheritDoc} + */ + public function setNamingStrategy(NamingStrategyInterface $strategy) + { + $this->resetCaches(); + + return parent::setNamingStrategy($strategy); + } + + /** + * {@inheritDoc} + */ + public function removeNamingStrategy() + { + $this->resetCaches(); + + return parent::removeNamingStrategy(); + } + + /** + * Reset all local hydration/extraction caches + */ + private function resetCaches() + { + $this->hydrationMethodsCache = $this->extractionMethodsCache = array(); + } } diff --git a/library/Zend/Stdlib/Hydrator/DelegatingHydrator.php b/library/Zend/Stdlib/Hydrator/DelegatingHydrator.php new file mode 100644 index 00000000..db234d38 --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/DelegatingHydrator.php @@ -0,0 +1,57 @@ +hydrators = $hydrators; + } + + /** + * {@inheritdoc} + */ + public function hydrate(array $data, $object) + { + return $this->getHydrator($object)->hydrate($data, $object); + } + + /** + * {@inheritdoc} + */ + public function extract($object) + { + return $this->getHydrator($object)->extract($object); + } + + /** + * Gets hydrator of an object + * + * @param object $object + * @return HydratorInterface + */ + protected function getHydrator($object) + { + return $this->hydrators->get(get_class($object)); + } +} diff --git a/library/Zend/Mvc/Service/ViewFeedRendererFactory.php b/library/Zend/Stdlib/Hydrator/DelegatingHydratorFactory.php similarity index 56% rename from library/Zend/Mvc/Service/ViewFeedRendererFactory.php rename to library/Zend/Stdlib/Hydrator/DelegatingHydratorFactory.php index 94047892..c3a0da25 100644 --- a/library/Zend/Mvc/Service/ViewFeedRendererFactory.php +++ b/library/Zend/Stdlib/Hydrator/DelegatingHydratorFactory.php @@ -3,27 +3,27 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Mvc\Service; +namespace Zend\Stdlib\Hydrator; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\View\Renderer\FeedRenderer; -class ViewFeedRendererFactory implements FactoryInterface +class DelegatingHydratorFactory implements FactoryInterface { /** - * Create and return the feed view renderer + * Creates DelegatingHydrator * * @param ServiceLocatorInterface $serviceLocator - * @return FeedRenderer + * @return DelegatingHydrator */ public function createService(ServiceLocatorInterface $serviceLocator) { - $feedRenderer = new FeedRenderer(); - return $feedRenderer; + // Assume that this factory is registered with the HydratorManager, + // and just pass it directly on. + return new DelegatingHydrator($serviceLocator); } } diff --git a/library/Zend/Stdlib/Hydrator/Filter/FilterComposite.php b/library/Zend/Stdlib/Hydrator/Filter/FilterComposite.php index 49cd785d..060034bb 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/FilterComposite.php +++ b/library/Zend/Stdlib/Hydrator/Filter/FilterComposite.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; @@ -36,16 +36,16 @@ class FilterComposite implements FilterInterface /** * Define default Filter * + * @param array $orFilter + * @param array $andFilter * @throws InvalidArgumentException */ public function __construct($orFilter = array(), $andFilter = array()) { - array_walk($orFilter, + array_walk( + $orFilter, function ($value, $key) { - if ( - !is_callable($value) - && !$value instanceof FilterInterface - ) { + if (!is_callable($value) && !$value instanceof FilterInterface) { throw new InvalidArgumentException( 'The value of ' . $key . ' should be either a callable or ' . 'an instance of Zend\Stdlib\Hydrator\Filter\FilterInterface' @@ -54,12 +54,10 @@ class FilterComposite implements FilterInterface } ); - array_walk($andFilter, + array_walk( + $andFilter, function ($value, $key) { - if ( - !is_callable($value) - && !$value instanceof FilterInterface - ) { + if (!is_callable($value) && !$value instanceof FilterInterface) { throw new InvalidArgumentException( 'The value of ' . $key . ' should be either a callable or ' . 'an instance of Zend\Stdlib\Hydrator\Filter\FilterInterface' diff --git a/library/Zend/Stdlib/Hydrator/Filter/FilterInterface.php b/library/Zend/Stdlib/Hydrator/Filter/FilterInterface.php index 7e2ebaae..16df098f 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/FilterInterface.php +++ b/library/Zend/Stdlib/Hydrator/Filter/FilterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; diff --git a/library/Zend/Stdlib/Hydrator/Filter/FilterProviderInterface.php b/library/Zend/Stdlib/Hydrator/Filter/FilterProviderInterface.php index e3fbc8c0..c2e97887 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/FilterProviderInterface.php +++ b/library/Zend/Stdlib/Hydrator/Filter/FilterProviderInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; diff --git a/library/Zend/Stdlib/Hydrator/Filter/GetFilter.php b/library/Zend/Stdlib/Hydrator/Filter/GetFilter.php index 8a303f8f..b4d898dc 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/GetFilter.php +++ b/library/Zend/Stdlib/Hydrator/Filter/GetFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; diff --git a/library/Zend/Stdlib/Hydrator/Filter/HasFilter.php b/library/Zend/Stdlib/Hydrator/Filter/HasFilter.php index 48011fe0..0cf57f95 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/HasFilter.php +++ b/library/Zend/Stdlib/Hydrator/Filter/HasFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; diff --git a/library/Zend/Stdlib/Hydrator/Filter/IsFilter.php b/library/Zend/Stdlib/Hydrator/Filter/IsFilter.php index 736212b5..3b6e3763 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/IsFilter.php +++ b/library/Zend/Stdlib/Hydrator/Filter/IsFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; diff --git a/library/Zend/Stdlib/Hydrator/Filter/MethodMatchFilter.php b/library/Zend/Stdlib/Hydrator/Filter/MethodMatchFilter.php index 0f8db071..2601a6fb 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/MethodMatchFilter.php +++ b/library/Zend/Stdlib/Hydrator/Filter/MethodMatchFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; @@ -41,8 +41,8 @@ class MethodMatchFilter implements FilterInterface $pos = 0; } if (substr($property, $pos) === $this->method) { - return $this->exclude ? false : true; + return !$this->exclude; } - return $this->exclude ? true : false; + return $this->exclude; } } diff --git a/library/Zend/Stdlib/Hydrator/Filter/NumberOfParameterFilter.php b/library/Zend/Stdlib/Hydrator/Filter/NumberOfParameterFilter.php index 3d153e3a..1254b63b 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/NumberOfParameterFilter.php +++ b/library/Zend/Stdlib/Hydrator/Filter/NumberOfParameterFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/Filter/OptionalParametersFilter.php b/library/Zend/Stdlib/Hydrator/Filter/OptionalParametersFilter.php index 46401590..ccd67ca5 100644 --- a/library/Zend/Stdlib/Hydrator/Filter/OptionalParametersFilter.php +++ b/library/Zend/Stdlib/Hydrator/Filter/OptionalParametersFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator\Filter; diff --git a/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php b/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php index 04505bb2..380aade0 100644 --- a/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php +++ b/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/HydrationInterface.php b/library/Zend/Stdlib/Hydrator/HydrationInterface.php index 340a7663..e7deff49 100644 --- a/library/Zend/Stdlib/Hydrator/HydrationInterface.php +++ b/library/Zend/Stdlib/Hydrator/HydrationInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/HydratorAwareInterface.php b/library/Zend/Stdlib/Hydrator/HydratorAwareInterface.php index 598af9f1..d64782ea 100644 --- a/library/Zend/Stdlib/Hydrator/HydratorAwareInterface.php +++ b/library/Zend/Stdlib/Hydrator/HydratorAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php b/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php index 94df7307..9c772c27 100644 --- a/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php +++ b/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/HydratorInterface.php b/library/Zend/Stdlib/Hydrator/HydratorInterface.php index 1c735538..bc9983d9 100644 --- a/library/Zend/Stdlib/Hydrator/HydratorInterface.php +++ b/library/Zend/Stdlib/Hydrator/HydratorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/HydratorOptionsInterface.php b/library/Zend/Stdlib/Hydrator/HydratorOptionsInterface.php index 0830b758..44610f7c 100644 --- a/library/Zend/Stdlib/Hydrator/HydratorOptionsInterface.php +++ b/library/Zend/Stdlib/Hydrator/HydratorOptionsInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/HydratorPluginManager.php b/library/Zend/Stdlib/Hydrator/HydratorPluginManager.php index 3b01f0c9..1b238e7c 100644 --- a/library/Zend/Stdlib/Hydrator/HydratorPluginManager.php +++ b/library/Zend/Stdlib/Hydrator/HydratorPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,6 +26,15 @@ class HydratorPluginManager extends AbstractPluginManager */ protected $shareByDefault = false; + /** + * Default aliases + * + * @var array + */ + protected $aliases = array( + 'delegatinghydrator' => 'Zend\Stdlib\Hydrator\DelegatingHydrator', + ); + /** * Default set of adapters * @@ -38,6 +47,15 @@ class HydratorPluginManager extends AbstractPluginManager 'reflection' => 'Zend\Stdlib\Hydrator\Reflection' ); + /** + * Default factory-based adapters + * + * @var array + */ + protected $factories = array( + 'Zend\Stdlib\Hydrator\DelegatingHydrator' => 'Zend\Stdlib\Hydrator\DelegatingHydratorFactory', + ); + /** * {@inheritDoc} */ diff --git a/library/Zend/Stdlib/Hydrator/NamingStrategy/ArrayMapNamingStrategy.php b/library/Zend/Stdlib/Hydrator/NamingStrategy/ArrayMapNamingStrategy.php new file mode 100644 index 00000000..962303ae --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/NamingStrategy/ArrayMapNamingStrategy.php @@ -0,0 +1,51 @@ +extractionMap = $extractionMap; + $this->hydrationMap = array_flip($extractionMap); + } + + /** + * {@inheritDoc} + */ + public function hydrate($name) + { + return isset($this->hydrationMap[$name]) ? $this->hydrationMap[$name] : $name; + } + + /** + * {@inheritDoc} + */ + public function extract($name) + { + return isset($this->extractionMap[$name]) ? $this->extractionMap[$name] : $name; + } +} diff --git a/library/Zend/Stdlib/Hydrator/NamingStrategy/CompositeNamingStrategy.php b/library/Zend/Stdlib/Hydrator/NamingStrategy/CompositeNamingStrategy.php new file mode 100644 index 00000000..0887e928 --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/NamingStrategy/CompositeNamingStrategy.php @@ -0,0 +1,64 @@ +namingStrategies = array_map( + function (NamingStrategyInterface $strategy) { + // this callback is here only to ensure type-safety + return $strategy; + }, + $strategies + ); + + $this->defaultNamingStrategy = $defaultNamingStrategy ?: new IdentityNamingStrategy(); + } + + /** + * {@inheritDoc} + */ + public function extract($name) + { + $strategy = isset($this->namingStrategies[$name]) + ? $this->namingStrategies[$name] + : $this->defaultNamingStrategy; + + return $strategy->extract($name); + } + + /** + * {@inheritDoc} + */ + public function hydrate($name) + { + $strategy = isset($this->namingStrategies[$name]) + ? $this->namingStrategies[$name] + : $this->defaultNamingStrategy; + + return $strategy->hydrate($name); + } +} diff --git a/library/Zend/Stdlib/Hydrator/NamingStrategy/IdentityNamingStrategy.php b/library/Zend/Stdlib/Hydrator/NamingStrategy/IdentityNamingStrategy.php new file mode 100644 index 00000000..ee4b328d --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/NamingStrategy/IdentityNamingStrategy.php @@ -0,0 +1,29 @@ +mapping = $mapping; + $this->reverse = $reverse ?: $this->flipMapping($mapping); + } + + /** + * Safelly flip mapping array. + * + * @param array $array Array to flip + * @return array Flipped array + * @throws InvalidArgumentException + */ + protected function flipMapping(array $array) + { + array_walk($array, function ($value) { + if (!is_string($value) && !is_int($value)) { + throw new InvalidArgumentException('Mapping array can\'t be flipped because of invalid value'); + } + }); + + return array_flip($array); + } + + /** + * Converts the given name so that it can be extracted by the hydrator. + * + * @param string $name The original name + * @return mixed The hydrated name + */ + public function hydrate($name) + { + if (array_key_exists($name, $this->mapping)) { + return $this->mapping[$name]; + } + + return $name; + } + + /** + * Converts the given name so that it can be hydrated by the hydrator. + * + * @param string $name The original name + * @return mixed The extracted name + */ + public function extract($name) + { + if (array_key_exists($name, $this->reverse)) { + return $this->reverse[$name]; + } + + return $name; + } +} diff --git a/library/Zend/Stdlib/Hydrator/NamingStrategy/NamingStrategyInterface.php b/library/Zend/Stdlib/Hydrator/NamingStrategy/NamingStrategyInterface.php index dacca119..ff99385c 100644 --- a/library/Zend/Stdlib/Hydrator/NamingStrategy/NamingStrategyInterface.php +++ b/library/Zend/Stdlib/Hydrator/NamingStrategy/NamingStrategyInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php b/library/Zend/Stdlib/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php index c6eceb53..023b4eec 100644 --- a/library/Zend/Stdlib/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php +++ b/library/Zend/Stdlib/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,9 +13,15 @@ use Zend\Filter\FilterChain; class UnderscoreNamingStrategy implements NamingStrategyInterface { + /** + * @var FilterChain|null + */ protected static $camelCaseToUnderscoreFilter; - protected static $underscoreToCamelCaseFilter; + /** + * @var FilterChain|null + */ + protected static $underscoreToStudlyCaseFilter; /** * Remove underscores and capitalize letters @@ -25,7 +31,7 @@ class UnderscoreNamingStrategy implements NamingStrategyInterface */ public function hydrate($name) { - return lcfirst($this->getUnderscoreToCamelCaseFilter()->filter($name)); + return $this->getUnderscoreToStudlyCaseFilter()->filter($name); } /** @@ -42,16 +48,17 @@ class UnderscoreNamingStrategy implements NamingStrategyInterface /** * @return FilterChain */ - protected function getUnderscoreToCamelCaseFilter() + protected function getUnderscoreToStudlyCaseFilter() { - if (static::$underscoreToCamelCaseFilter instanceof FilterChain) { - return static::$underscoreToCamelCaseFilter; + if (static::$underscoreToStudlyCaseFilter instanceof FilterChain) { + return static::$underscoreToStudlyCaseFilter; } $filter = new FilterChain(); - $filter->attachByName('WordUnderscoreToCamelCase'); - static::$underscoreToCamelCaseFilter = $filter; - return $filter; + + $filter->attachByName('WordUnderscoreToStudlyCase'); + + return static::$underscoreToStudlyCaseFilter = $filter; } /** @@ -64,9 +71,10 @@ class UnderscoreNamingStrategy implements NamingStrategyInterface } $filter = new FilterChain(); + $filter->attachByName('WordCamelCaseToUnderscore'); $filter->attachByName('StringToLower'); - static::$camelCaseToUnderscoreFilter = $filter; - return $filter; + + return static::$camelCaseToUnderscoreFilter = $filter; } } diff --git a/library/Zend/Stdlib/Hydrator/NamingStrategyEnabledInterface.php b/library/Zend/Stdlib/Hydrator/NamingStrategyEnabledInterface.php index ab1ce7f1..f9c6288a 100644 --- a/library/Zend/Stdlib/Hydrator/NamingStrategyEnabledInterface.php +++ b/library/Zend/Stdlib/Hydrator/NamingStrategyEnabledInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/ObjectProperty.php b/library/Zend/Stdlib/Hydrator/ObjectProperty.php index 20c97c4a..c9f5260a 100644 --- a/library/Zend/Stdlib/Hydrator/ObjectProperty.php +++ b/library/Zend/Stdlib/Hydrator/ObjectProperty.php @@ -3,48 +3,56 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Stdlib\Hydrator; use Zend\Stdlib\Exception; +use ReflectionClass; +use ReflectionProperty; class ObjectProperty extends AbstractHydrator { /** - * Extract values from an object + * @var array[] indexed by class name and then property name + */ + private static $skippedPropertiesCache = array(); + + /** + * {@inheritDoc} * * Extracts the accessible non-static properties of the given $object. * - * @param object $object - * @return array * @throws Exception\BadMethodCallException for a non-object $object */ public function extract($object) { if (!is_object($object)) { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided $object to be a PHP object)', __METHOD__ - )); + throw new Exception\BadMethodCallException( + sprintf('%s expects the provided $object to be a PHP object)', __METHOD__) + ); } - $data = get_object_vars($object); - + $data = get_object_vars($object); $filter = $this->getFilter(); + foreach ($data as $name => $value) { // Filter keys, removing any we don't want - if (!$filter->filter($name)) { + if (! $filter->filter($name)) { unset($data[$name]); continue; } + // Replace name if extracted differ $extracted = $this->extractName($name, $object); + if ($extracted !== $name) { unset($data[$name]); $name = $extracted; } + $data[$name] = $this->extractValue($name, $value, $object); } @@ -52,26 +60,51 @@ class ObjectProperty extends AbstractHydrator } /** + * {@inheritDoc} + * * Hydrate an object by populating public properties * * Hydrates an object by setting public properties of the object. * - * @param array $data - * @param object $object - * @return object * @throws Exception\BadMethodCallException for a non-object $object */ public function hydrate(array $data, $object) { if (!is_object($object)) { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided $object to be a PHP object)', __METHOD__ - )); + throw new Exception\BadMethodCallException( + sprintf('%s expects the provided $object to be a PHP object)', __METHOD__) + ); } + + $properties = & self::$skippedPropertiesCache[get_class($object)]; + + if (! isset($properties)) { + $reflection = new ReflectionClass($object); + $properties = array_fill_keys( + array_map( + function (ReflectionProperty $property) { + return $property->getName(); + }, + $reflection->getProperties( + ReflectionProperty::IS_PRIVATE + + ReflectionProperty::IS_PROTECTED + + ReflectionProperty::IS_STATIC + ) + ), + true + ); + } + foreach ($data as $name => $value) { $property = $this->hydrateName($name, $data); + + if (isset($properties[$property])) { + continue; + } + $object->$property = $this->hydrateValue($property, $value, $data); } + return $object; } } diff --git a/library/Zend/Stdlib/Hydrator/Reflection.php b/library/Zend/Stdlib/Hydrator/Reflection.php index 3c066e96..ea8e2d21 100644 --- a/library/Zend/Stdlib/Hydrator/Reflection.php +++ b/library/Zend/Stdlib/Hydrator/Reflection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -16,7 +16,7 @@ class Reflection extends AbstractHydrator { /** * Simple in-memory array cache of ReflectionProperties used. - * @var array + * @var \ReflectionProperty[] */ protected static $reflProperties = array(); @@ -67,7 +67,7 @@ class Reflection extends AbstractHydrator * * @param string|object $input * @throws Exception\InvalidArgumentException - * @return array + * @return \ReflectionProperty[] */ protected static function getReflProperties($input) { diff --git a/library/Zend/Stdlib/Hydrator/Strategy/BooleanStrategy.php b/library/Zend/Stdlib/Hydrator/Strategy/BooleanStrategy.php new file mode 100644 index 00000000..3c29231f --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/Strategy/BooleanStrategy.php @@ -0,0 +1,106 @@ +trueValue = $trueValue; + $this->falseValue = $falseValue; + } + + /** + * Converts the given value so that it can be extracted by the hydrator. + * + * @param bool $value The original value. + * @throws InvalidArgumentException + * @return int|string Returns the value that should be extracted. + */ + public function extract($value) + { + if (!is_bool($value)) { + throw new InvalidArgumentException(sprintf( + 'Unable to extract. Expected bool. %s was given.', + is_object($value) ? get_class($value) : gettype($value) + )); + } + + return $value === true ? $this->trueValue : $this->falseValue; + } + + /** + * Converts the given value so that it can be hydrated by the hydrator. + * + * @param int|string $value The original value. + * @throws InvalidArgumentException + * @return bool Returns the value that should be hydrated. + */ + public function hydrate($value) + { + if (!is_string($value) && !is_int($value)) { + throw new InvalidArgumentException(sprintf( + 'Unable to hydrate. Expected string or int. %s was given.', + is_object($value) ? get_class($value) : gettype($value) + )); + } + + if ($value === $this->trueValue) { + return true; + } + + if ($value === $this->falseValue) { + return false; + } + + throw new InvalidArgumentException(sprintf( + 'Unexpected value %s can\'t be hydrated. Expect %s or %s as Value.', + $value, + $this->trueValue, + $this->falseValue + )); + } +} diff --git a/library/Zend/Stdlib/Hydrator/Strategy/ClosureStrategy.php b/library/Zend/Stdlib/Hydrator/Strategy/ClosureStrategy.php index 6360c868..bf456a7f 100644 --- a/library/Zend/Stdlib/Hydrator/Strategy/ClosureStrategy.php +++ b/library/Zend/Stdlib/Hydrator/Strategy/ClosureStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/Strategy/DateTimeFormatterStrategy.php b/library/Zend/Stdlib/Hydrator/Strategy/DateTimeFormatterStrategy.php new file mode 100644 index 00000000..62d92c58 --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/Strategy/DateTimeFormatterStrategy.php @@ -0,0 +1,80 @@ +format = (string) $format; + $this->timezone = $timezone; + } + + /** + * {@inheritDoc} + * + * Converts to date time string + * + * @param mixed|DateTime $value + * + * @return mixed|string + */ + public function extract($value) + { + if ($value instanceof DateTime) { + return $value->format($this->format); + } + + return $value; + } + + /** + * Converts date time string to DateTime instance for injecting to object + * + * {@inheritDoc} + * + * @param mixed|string $value + * + * @return mixed|DateTime + */ + public function hydrate($value) + { + if ($value === '' || $value === null) { + return; + } + + if ($this->timezone) { + $hydrated = DateTime::createFromFormat($this->format, $value, $this->timezone); + } else { + $hydrated = DateTime::createFromFormat($this->format, $value); + } + + return $hydrated ?: $value; + } +} diff --git a/library/Zend/Stdlib/Hydrator/Strategy/DefaultStrategy.php b/library/Zend/Stdlib/Hydrator/Strategy/DefaultStrategy.php index d455f177..b2c5c29b 100644 --- a/library/Zend/Stdlib/Hydrator/Strategy/DefaultStrategy.php +++ b/library/Zend/Stdlib/Hydrator/Strategy/DefaultStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/Strategy/Exception/ExceptionInterface.php b/library/Zend/Stdlib/Hydrator/Strategy/Exception/ExceptionInterface.php new file mode 100644 index 00000000..c7b576ce --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/Strategy/Exception/ExceptionInterface.php @@ -0,0 +1,14 @@ +setValueDelimiter($delimiter); + + $this->explodeLimit = ($explodeLimit === null) ? null : (int) $explodeLimit; + } + + /** + * Sets the delimiter string that the values will be split upon + * + * @param string $delimiter + * @return self + */ + private function setValueDelimiter($delimiter) + { + if (!is_string($delimiter)) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects Delimiter to be string, %s provided instead', + __METHOD__, + is_object($delimiter) ? get_class($delimiter) : gettype($delimiter) + )); + } + + if (empty($delimiter)) { + throw new Exception\InvalidArgumentException('Delimiter cannot be empty.'); + } + + $this->valueDelimiter = $delimiter; + } + + /** + * {@inheritDoc} + * + * Split a string by delimiter + * + * @param string|null $value + * + * @return string[] + * + * @throws Exception\InvalidArgumentException + */ + public function hydrate($value) + { + if (null === $value) { + return array(); + } + + if (!(is_string($value) || is_numeric($value))) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects argument 1 to be string, %s provided instead', + __METHOD__, + is_object($value) ? get_class($value) : gettype($value) + )); + } + + if ($this->explodeLimit !== null) { + return explode($this->valueDelimiter, $value, $this->explodeLimit); + } + + return explode($this->valueDelimiter, $value); + } + + /** + * {@inheritDoc} + * + * Join array elements with delimiter + * + * @param string[] $value The original value. + * + * @return string|null + */ + public function extract($value) + { + if (!is_array($value)) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects argument 1 to be array, %s provided instead', + __METHOD__, + is_object($value) ? get_class($value) : gettype($value) + )); + } + + return empty($value) ? null : implode($this->valueDelimiter, $value); + } +} diff --git a/library/Zend/Stdlib/Hydrator/Strategy/SerializableStrategy.php b/library/Zend/Stdlib/Hydrator/Strategy/SerializableStrategy.php index 71375bb9..260efa30 100644 --- a/library/Zend/Stdlib/Hydrator/Strategy/SerializableStrategy.php +++ b/library/Zend/Stdlib/Hydrator/Strategy/SerializableStrategy.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/Strategy/StrategyChain.php b/library/Zend/Stdlib/Hydrator/Strategy/StrategyChain.php new file mode 100644 index 00000000..a9316bbd --- /dev/null +++ b/library/Zend/Stdlib/Hydrator/Strategy/StrategyChain.php @@ -0,0 +1,73 @@ +extractionStrategies = array_map( + function (StrategyInterface $strategy) { + // this callback is here only to ensure type-safety + return $strategy; + }, + $extractionStrategies + ); + + $this->hydrationStrategies = array_reverse($extractionStrategies); + } + + /** + * {@inheritDoc} + */ + public function extract($value) + { + foreach ($this->extractionStrategies as $strategy) { + $value = $strategy->extract($value); + } + + return $value; + } + + /** + * {@inheritDoc} + */ + public function hydrate($value) + { + foreach ($this->hydrationStrategies as $strategy) { + $value = $strategy->hydrate($value); + } + + return $value; + } +} diff --git a/library/Zend/Stdlib/Hydrator/Strategy/StrategyInterface.php b/library/Zend/Stdlib/Hydrator/Strategy/StrategyInterface.php index 03208b3e..562ec4bd 100644 --- a/library/Zend/Stdlib/Hydrator/Strategy/StrategyInterface.php +++ b/library/Zend/Stdlib/Hydrator/Strategy/StrategyInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Hydrator/StrategyEnabledInterface.php b/library/Zend/Stdlib/Hydrator/StrategyEnabledInterface.php index 9cb0f4ab..6f29b16a 100644 --- a/library/Zend/Stdlib/Hydrator/StrategyEnabledInterface.php +++ b/library/Zend/Stdlib/Hydrator/StrategyEnabledInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/InitializableInterface.php b/library/Zend/Stdlib/InitializableInterface.php index f50343c2..f78bedef 100644 --- a/library/Zend/Stdlib/InitializableInterface.php +++ b/library/Zend/Stdlib/InitializableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/JsonSerializable.php b/library/Zend/Stdlib/JsonSerializable.php index 9d00b356..6d6c2abe 100644 --- a/library/Zend/Stdlib/JsonSerializable.php +++ b/library/Zend/Stdlib/JsonSerializable.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/JsonSerializable/PhpLegacyCompatibility.php b/library/Zend/Stdlib/JsonSerializable/PhpLegacyCompatibility.php index a590cab6..ecc7525d 100644 --- a/library/Zend/Stdlib/JsonSerializable/PhpLegacyCompatibility.php +++ b/library/Zend/Stdlib/JsonSerializable/PhpLegacyCompatibility.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Message.php b/library/Zend/Stdlib/Message.php index c6c1c825..63ba7c73 100644 --- a/library/Zend/Stdlib/Message.php +++ b/library/Zend/Stdlib/Message.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/MessageInterface.php b/library/Zend/Stdlib/MessageInterface.php index 990ed9c8..28d8857f 100644 --- a/library/Zend/Stdlib/MessageInterface.php +++ b/library/Zend/Stdlib/MessageInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/ParameterObjectInterface.php b/library/Zend/Stdlib/ParameterObjectInterface.php index e03f4e6c..676a6e2b 100644 --- a/library/Zend/Stdlib/ParameterObjectInterface.php +++ b/library/Zend/Stdlib/ParameterObjectInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Parameters.php b/library/Zend/Stdlib/Parameters.php index 484dde25..bef834a8 100644 --- a/library/Zend/Stdlib/Parameters.php +++ b/library/Zend/Stdlib/Parameters.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -86,7 +86,7 @@ class Parameters extends PhpArrayObject implements ParametersInterface if ($this->offsetExists($name)) { return parent::offsetGet($name); } - return null; + return; } /** diff --git a/library/Zend/Stdlib/ParametersInterface.php b/library/Zend/Stdlib/ParametersInterface.php index 7dcd6677..feeda580 100644 --- a/library/Zend/Stdlib/ParametersInterface.php +++ b/library/Zend/Stdlib/ParametersInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/PriorityList.php b/library/Zend/Stdlib/PriorityList.php index e9cc56a2..45aa2d8f 100644 --- a/library/Zend/Stdlib/PriorityList.php +++ b/library/Zend/Stdlib/PriorityList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -62,8 +62,11 @@ class PriorityList implements Iterator, Countable */ public function insert($name, $value, $priority = 0) { + if (!isset($this->items[$name])) { + $this->count++; + } + $this->sorted = false; - $this->count++; $this->items[$name] = array( 'data' => $value, @@ -129,7 +132,7 @@ class PriorityList implements Iterator, Countable public function get($name) { if (!isset($this->items[$name])) { - return null; + return; } return $this->items[$name]['data']; @@ -197,6 +200,7 @@ class PriorityList implements Iterator, Countable */ public function current() { + $this->sorted || $this->sort(); $node = current($this->items); return $node ? $node['data'] : false; @@ -207,6 +211,7 @@ class PriorityList implements Iterator, Countable */ public function key() { + $this->sorted || $this->sort(); return key($this->items); } @@ -228,6 +233,14 @@ class PriorityList implements Iterator, Countable return current($this->items) !== false; } + /** + * @return self + */ + public function getIterator() + { + return clone $this; + } + /** * {@inheritDoc} */ @@ -252,9 +265,9 @@ class PriorityList implements Iterator, Countable } return array_map( - self::EXTR_PRIORITY === $flag - ? function ($item) { return $item['priority']; } - : function ($item) { return $item['data']; }, + function ($item) use ($flag) { + return ($flag == PriorityList::EXTR_PRIORITY) ? $item['priority'] : $item['data']; + }, $this->items ); } diff --git a/library/Zend/Stdlib/PriorityQueue.php b/library/Zend/Stdlib/PriorityQueue.php index 869af132..1baf44e8 100644 --- a/library/Zend/Stdlib/PriorityQueue.php +++ b/library/Zend/Stdlib/PriorityQueue.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -208,7 +208,6 @@ class PriorityQueue implements Countable, IteratorAggregate, Serializable switch ($flag) { case self::EXTR_BOTH: return $this->items; - break; case self::EXTR_PRIORITY: return array_map(function ($item) { return $item['priority']; diff --git a/library/Zend/Stdlib/Request.php b/library/Zend/Stdlib/Request.php index 674111e3..7c084039 100644 --- a/library/Zend/Stdlib/Request.php +++ b/library/Zend/Stdlib/Request.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/RequestInterface.php b/library/Zend/Stdlib/RequestInterface.php index 210e4869..c2bac316 100644 --- a/library/Zend/Stdlib/RequestInterface.php +++ b/library/Zend/Stdlib/RequestInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/Response.php b/library/Zend/Stdlib/Response.php index 69b8818a..f3074bad 100644 --- a/library/Zend/Stdlib/Response.php +++ b/library/Zend/Stdlib/Response.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/ResponseInterface.php b/library/Zend/Stdlib/ResponseInterface.php index 894986aa..fe94d304 100644 --- a/library/Zend/Stdlib/ResponseInterface.php +++ b/library/Zend/Stdlib/ResponseInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/SplPriorityQueue.php b/library/Zend/Stdlib/SplPriorityQueue.php index 404e4c24..029d8e9f 100644 --- a/library/Zend/Stdlib/SplPriorityQueue.php +++ b/library/Zend/Stdlib/SplPriorityQueue.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -42,7 +42,6 @@ class SplPriorityQueue extends \SplPriorityQueue implements Serializable parent::insert($datum, $priority); } - /** * Serialize to an array * @@ -59,7 +58,6 @@ class SplPriorityQueue extends \SplPriorityQueue implements Serializable return $array; } - /** * Serialize * diff --git a/library/Zend/Stdlib/SplQueue.php b/library/Zend/Stdlib/SplQueue.php index fe06b884..029bc9f1 100644 --- a/library/Zend/Stdlib/SplQueue.php +++ b/library/Zend/Stdlib/SplQueue.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/SplStack.php b/library/Zend/Stdlib/SplStack.php index 1b17acc7..fac77a5d 100644 --- a/library/Zend/Stdlib/SplStack.php +++ b/library/Zend/Stdlib/SplStack.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/StringUtils.php b/library/Zend/Stdlib/StringUtils.php index eed15d00..9bbb4a46 100644 --- a/library/Zend/Stdlib/StringUtils.php +++ b/library/Zend/Stdlib/StringUtils.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/StringWrapper/AbstractStringWrapper.php b/library/Zend/Stdlib/StringWrapper/AbstractStringWrapper.php index 74d0c55f..3e395ccc 100644 --- a/library/Zend/Stdlib/StringWrapper/AbstractStringWrapper.php +++ b/library/Zend/Stdlib/StringWrapper/AbstractStringWrapper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -67,7 +67,6 @@ abstract class AbstractStringWrapper implements StringWrapperInterface ); } - if ($convertEncoding !== null) { $convertEncodingUpper = strtoupper($convertEncoding); if (!in_array($convertEncodingUpper, $supportedEncodings)) { diff --git a/library/Zend/Stdlib/StringWrapper/Iconv.php b/library/Zend/Stdlib/StringWrapper/Iconv.php index d240eaad..04930ff4 100644 --- a/library/Zend/Stdlib/StringWrapper/Iconv.php +++ b/library/Zend/Stdlib/StringWrapper/Iconv.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/StringWrapper/Intl.php b/library/Zend/Stdlib/StringWrapper/Intl.php index 77596c84..1b012773 100644 --- a/library/Zend/Stdlib/StringWrapper/Intl.php +++ b/library/Zend/Stdlib/StringWrapper/Intl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/StringWrapper/MbString.php b/library/Zend/Stdlib/StringWrapper/MbString.php index fad66295..d6db1856 100644 --- a/library/Zend/Stdlib/StringWrapper/MbString.php +++ b/library/Zend/Stdlib/StringWrapper/MbString.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/StringWrapper/Native.php b/library/Zend/Stdlib/StringWrapper/Native.php index d6e55b10..38b3c10a 100644 --- a/library/Zend/Stdlib/StringWrapper/Native.php +++ b/library/Zend/Stdlib/StringWrapper/Native.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/StringWrapper/StringWrapperInterface.php b/library/Zend/Stdlib/StringWrapper/StringWrapperInterface.php index a22c4e55..f25b3253 100644 --- a/library/Zend/Stdlib/StringWrapper/StringWrapperInterface.php +++ b/library/Zend/Stdlib/StringWrapper/StringWrapperInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Stdlib/compatibility/autoload.php b/library/Zend/Stdlib/compatibility/autoload.php index 1a237d22..f8670cc1 100644 --- a/library/Zend/Stdlib/compatibility/autoload.php +++ b/library/Zend/Stdlib/compatibility/autoload.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @deprecated */ diff --git a/library/Zend/Stdlib/composer.json b/library/Zend/Stdlib/composer.json index cc7492ed..a3aeb47d 100644 --- a/library/Zend/Stdlib/composer.json +++ b/library/Zend/Stdlib/composer.json @@ -8,28 +8,29 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Stdlib\\": "" } }, - "target-dir": "Zend/Stdlib", "require": { "php": ">=5.3.23" }, "require-dev": { "zendframework/zend-eventmanager": "self.version", "zendframework/zend-serializer": "self.version", - "zendframework/zend-servicemanager": "self.version" + "zendframework/zend-servicemanager": "self.version", + "zendframework/zend-filter": "self.version" }, "suggest": { "zendframework/zend-eventmanager": "To support aggregate hydrator usage", "zendframework/zend-serializer": "Zend\\Serializer component", - "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" + "zendframework/zend-servicemanager": "To support hydrator plugin manager usage", + "zendframework/zend-filter": "To support naming strategy hydrator usage" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Tag/Cloud.php b/library/Zend/Tag/Cloud.php index af108c5d..3d6e2277 100644 --- a/library/Zend/Tag/Cloud.php +++ b/library/Zend/Tag/Cloud.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/AbstractCloud.php b/library/Zend/Tag/Cloud/Decorator/AbstractCloud.php index 3510b28b..2b001638 100644 --- a/library/Zend/Tag/Cloud/Decorator/AbstractCloud.php +++ b/library/Zend/Tag/Cloud/Decorator/AbstractCloud.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/AbstractDecorator.php b/library/Zend/Tag/Cloud/Decorator/AbstractDecorator.php index d33db3c2..eab89940 100644 --- a/library/Zend/Tag/Cloud/Decorator/AbstractDecorator.php +++ b/library/Zend/Tag/Cloud/Decorator/AbstractDecorator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -160,6 +160,12 @@ abstract class AbstractDecorator implements Decorator } } + /** + * Wrap html with tag + * + * @param string $html + * @return string + */ protected function wrapTag($html) { $escaper = $this->getEscaper(); diff --git a/library/Zend/Tag/Cloud/Decorator/AbstractTag.php b/library/Zend/Tag/Cloud/Decorator/AbstractTag.php index b2e61d76..c4fcaacf 100644 --- a/library/Zend/Tag/Cloud/Decorator/AbstractTag.php +++ b/library/Zend/Tag/Cloud/Decorator/AbstractTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/DecoratorInterface.php b/library/Zend/Tag/Cloud/Decorator/DecoratorInterface.php index 312e8aee..18bc5e38 100644 --- a/library/Zend/Tag/Cloud/Decorator/DecoratorInterface.php +++ b/library/Zend/Tag/Cloud/Decorator/DecoratorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/Exception/ExceptionInterface.php b/library/Zend/Tag/Cloud/Decorator/Exception/ExceptionInterface.php index 70dfaadc..1526b625 100644 --- a/library/Zend/Tag/Cloud/Decorator/Exception/ExceptionInterface.php +++ b/library/Zend/Tag/Cloud/Decorator/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/Exception/InvalidArgumentException.php b/library/Zend/Tag/Cloud/Decorator/Exception/InvalidArgumentException.php index 7dca916d..8d4d2cf4 100644 --- a/library/Zend/Tag/Cloud/Decorator/Exception/InvalidArgumentException.php +++ b/library/Zend/Tag/Cloud/Decorator/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php b/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php index 1e2d8487..625d51ca 100644 --- a/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php +++ b/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/Decorator/HtmlTag.php b/library/Zend/Tag/Cloud/Decorator/HtmlTag.php index ebbe8dad..b7ecf349 100644 --- a/library/Zend/Tag/Cloud/Decorator/HtmlTag.php +++ b/library/Zend/Tag/Cloud/Decorator/HtmlTag.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Cloud/DecoratorPluginManager.php b/library/Zend/Tag/Cloud/DecoratorPluginManager.php index acb74a9c..1a951846 100644 --- a/library/Zend/Tag/Cloud/DecoratorPluginManager.php +++ b/library/Zend/Tag/Cloud/DecoratorPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Exception/ExceptionInterface.php b/library/Zend/Tag/Exception/ExceptionInterface.php index cd99c4e5..3a8e882a 100644 --- a/library/Zend/Tag/Exception/ExceptionInterface.php +++ b/library/Zend/Tag/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Exception/InvalidArgumentException.php b/library/Zend/Tag/Exception/InvalidArgumentException.php index 54b8c834..88a8db56 100644 --- a/library/Zend/Tag/Exception/InvalidArgumentException.php +++ b/library/Zend/Tag/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Exception/InvalidAttributeNameException.php b/library/Zend/Tag/Exception/InvalidAttributeNameException.php index afe351d0..44700c85 100644 --- a/library/Zend/Tag/Exception/InvalidAttributeNameException.php +++ b/library/Zend/Tag/Exception/InvalidAttributeNameException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Exception/InvalidElementNameException.php b/library/Zend/Tag/Exception/InvalidElementNameException.php index e5a0ea48..02f15376 100644 --- a/library/Zend/Tag/Exception/InvalidElementNameException.php +++ b/library/Zend/Tag/Exception/InvalidElementNameException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Exception/OutOfBoundsException.php b/library/Zend/Tag/Exception/OutOfBoundsException.php index d93d199c..6db45d52 100644 --- a/library/Zend/Tag/Exception/OutOfBoundsException.php +++ b/library/Zend/Tag/Exception/OutOfBoundsException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/Item.php b/library/Zend/Tag/Item.php index 35effba9..479d5d47 100644 --- a/library/Zend/Tag/Item.php +++ b/library/Zend/Tag/Item.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -189,6 +189,6 @@ class Item implements TaggableInterface if (isset($this->params[$name])) { return $this->params[$name]; } - return null; + return; } } diff --git a/library/Zend/Tag/ItemList.php b/library/Zend/Tag/ItemList.php index 75852601..c85a8586 100644 --- a/library/Zend/Tag/ItemList.php +++ b/library/Zend/Tag/ItemList.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/TaggableInterface.php b/library/Zend/Tag/TaggableInterface.php index 3a475ac9..6489a039 100644 --- a/library/Zend/Tag/TaggableInterface.php +++ b/library/Zend/Tag/TaggableInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Tag/composer.json b/library/Zend/Tag/composer.json index baaa1e73..4e0e47b1 100644 --- a/library/Zend/Tag/composer.json +++ b/library/Zend/Tag/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Tag\\": "" } }, - "target-dir": "Zend/Tag", "require": { "php": ">=5.3.23", "zendframework/zend-escaper": "self.version", @@ -26,8 +25,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Test/PHPUnit/Controller/AbstractConsoleControllerTestCase.php b/library/Zend/Test/PHPUnit/Controller/AbstractConsoleControllerTestCase.php index d1f1ea21..e30d948a 100644 --- a/library/Zend/Test/PHPUnit/Controller/AbstractConsoleControllerTestCase.php +++ b/library/Zend/Test/PHPUnit/Controller/AbstractConsoleControllerTestCase.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Test\PHPUnit\Controller; @@ -29,10 +29,13 @@ abstract class AbstractConsoleControllerTestCase extends AbstractControllerTestC { $response = $this->getResponse(); if (false === stripos($response->getContent(), $match)) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting output CONTAINS content "%s", actual content is "%s"', - $match, $response->getContent() - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + 'Failed asserting output CONTAINS content "%s", actual content is "%s"', + $match, + $response->getContent() + ) + ); } $this->assertNotSame(false, stripos($response->getContent(), $match)); } diff --git a/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php b/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php index 71a356a2..a47e1dab 100644 --- a/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php +++ b/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Test\PHPUnit\Controller; @@ -48,7 +48,7 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase * Trace error when exception is throwed in application * @var bool */ - protected $traceError = false; + protected $traceError = true; /** * Reset the application for isolation @@ -230,20 +230,14 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase } } elseif ($method == HttpRequest::METHOD_GET) { $query = array_merge($query, $params); - } elseif ($method == HttpRequest::METHOD_PUT) { + } elseif ($method == HttpRequest::METHOD_PUT || $method == HttpRequest::METHOD_PATCH) { if (count($params) != 0) { - array_walk( - $params, - function (&$item, $key) { - $item = $key . '=' . $item; - } - ); - $content = implode('&', $params); + $content = http_build_query($params); $request->setContent($content); } } elseif ($params) { trigger_error( - 'Additional params is only supported by GET, POST and PUT HTTP method', + 'Additional params is only supported by GET, POST, PUT and PATCH HTTP method', E_USER_NOTICE ); } @@ -270,9 +264,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase */ public function dispatch($url, $method = null, $params = array(), $isXmlHttpRequest = false) { - if ( !isset($method) && - $this->getRequest() instanceof HttpRequest && - $requestMethod = $this->getRequest()->getMethod() + if (!isset($method) + && $this->getRequest() instanceof HttpRequest + && $requestMethod = $this->getRequest()->getMethod() ) { $method = $requestMethod; } elseif (!isset($method)) { @@ -354,9 +348,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $modulesLoaded = $moduleManager->getModules(); $list = array_diff($modules, $modulesLoaded); if ($list) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Several modules are not loaded "%s"', implode(', ', $list) - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Several modules are not loaded "%s"', implode(', ', $list)) + ); } $this->assertEquals(count($list), 0); } @@ -372,9 +366,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $modulesLoaded = $moduleManager->getModules(); $list = array_intersect($modules, $modulesLoaded); if ($list) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Several modules WAS not loaded "%s"', implode(', ', $list) - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Several modules WAS not loaded "%s"', implode(', ', $list)) + ); } $this->assertEquals(count($list), 0); } @@ -415,10 +409,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase } $match = $this->getResponseStatusCode(); if ($code != $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting response code "%s", actual status code is "%s"', - $code, $match - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting response code "%s", actual status code is "%s"', $code, $match) + ); } $this->assertEquals($code, $match); } @@ -439,10 +432,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase } $match = $this->getResponseStatusCode(); if ($code == $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting response code was NOT "%s"', - $code - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting response code was NOT "%s"', $code) + ); } $this->assertNotEquals($code, $match); } @@ -496,10 +488,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $module = strtolower($module); if ($module != $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting module name "%s", actual module name is "%s"', - $module, $match - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting module name "%s", actual module name is "%s"', $module, $match) + ); } $this->assertEquals($module, $match); } @@ -516,10 +507,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $module = strtolower($module); if ($module == $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting module was NOT "%s"', - $module - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting module was NOT "%s"', $module) + ); } $this->assertNotEquals($module, $match); } @@ -536,10 +526,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $controller = strtolower($controller); if ($controller != $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting controller class "%s", actual controller class is "%s"', - $controller, $match - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting controller class "%s", actual controller class is "%s"', $controller, $match) + ); } $this->assertEquals($controller, $match); } @@ -556,10 +545,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $controller = strtolower($controller); if ($controller == $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting controller class was NOT "%s"', - $controller - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting controller class was NOT "%s"', $controller) + ); } $this->assertNotEquals($controller, $match); } @@ -576,10 +564,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $controller = strtolower($controller); if ($controller != $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting controller name "%s", actual controller name is "%s"', - $controller, $match - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting controller name "%s", actual controller name is "%s"', $controller, $match) + ); } $this->assertEquals($controller, $match); } @@ -596,10 +583,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $controller = strtolower($controller); if ($controller == $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting controller name was NOT "%s"', - $controller - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting controller name was NOT "%s"', $controller) + ); } $this->assertNotEquals($controller, $match); } @@ -616,10 +602,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $action = strtolower($action); if ($action != $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting action name "%s", actual action name is "%s"', - $action, $match - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting action name "%s", actual action name is "%s"', $action, $match) + ); } $this->assertEquals($action, $match); } @@ -636,10 +621,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $action = strtolower($action); if ($action == $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting action name was NOT "%s"', - $action - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting action name was NOT "%s"', $action) + ); } $this->assertNotEquals($action, $match); } @@ -656,10 +640,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $route = strtolower($route); if ($route != $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting matched route name was "%s", actual matched route name is "%s"', - $route, $match - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting matched route name was "%s", actual matched route name is "%s"', $route, $match) + ); } $this->assertEquals($route, $match); } @@ -676,9 +659,9 @@ abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase $match = strtolower($match); $route = strtolower($route); if ($route == $match) { - throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting route matched was NOT "%s"', $route - )); + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf('Failed asserting route matched was NOT "%s"', $route) + ); } $this->assertNotEquals($route, $match); } diff --git a/library/Zend/Test/PHPUnit/Controller/AbstractHttpControllerTestCase.php b/library/Zend/Test/PHPUnit/Controller/AbstractHttpControllerTestCase.php index a09f4ca9..2120ce87 100644 --- a/library/Zend/Test/PHPUnit/Controller/AbstractHttpControllerTestCase.php +++ b/library/Zend/Test/PHPUnit/Controller/AbstractHttpControllerTestCase.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Test\PHPUnit\Controller; @@ -381,7 +381,11 @@ abstract class AbstractHttpControllerTestCase extends AbstractControllerTestCase $document->registerXpathNamespaces($this->xpathNamespaces); } - $result = Document\Query::execute($path, $document, $useXpath ? Document\Query::TYPE_XPATH : Document\Query::TYPE_CSS); + $result = Document\Query::execute( + $path, + $document, + $useXpath ? Document\Query::TYPE_XPATH : Document\Query::TYPE_CSS + ); return $result; } @@ -682,22 +686,30 @@ abstract class AbstractHttpControllerTestCase extends AbstractControllerTestCase private function queryContentContainsAssertion($path, $match, $useXpath = false) { $result = $this->query($path, $useXpath); + if ($result->count() == 0) { throw new PHPUnit_Framework_ExpectationFailedException(sprintf( 'Failed asserting node DENOTED BY %s EXISTS', $path )); } + + $nodeValues = array(); + foreach ($result as $node) { if ($node->nodeValue == $match) { $this->assertEquals($match, $node->nodeValue); return; } + + $nodeValues[] = $node->nodeValue; } + throw new PHPUnit_Framework_ExpectationFailedException(sprintf( - 'Failed asserting node denoted by %s CONTAINS content "%s"', + 'Failed asserting node denoted by %s CONTAINS content "%s", Contents: [%s]', $path, - $match + $match, + implode(',', $nodeValues) )); } diff --git a/library/Zend/Test/Util/ModuleLoader.php b/library/Zend/Test/Util/ModuleLoader.php index 3b802cd6..671dfa2d 100644 --- a/library/Zend/Test/Util/ModuleLoader.php +++ b/library/Zend/Test/Util/ModuleLoader.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Test\Util; diff --git a/library/Zend/Test/composer.json b/library/Zend/Test/composer.json index f107cefb..f04ccc58 100644 --- a/library/Zend/Test/composer.json +++ b/library/Zend/Test/composer.json @@ -8,14 +8,13 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Test\\": "" } }, - "target-dir": "Zend/Test", "require": { "php": ">=5.3.23", - "phpunit/PHPUnit": "3.7.*", + "phpunit/PHPUnit": "~4.0", "zendframework/zend-console": "self.version", "zendframework/zend-dom": "self.version", "zendframework/zend-eventmanager": "self.version", @@ -34,8 +33,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Text/Exception/ExceptionInterface.php b/library/Zend/Text/Exception/ExceptionInterface.php index dd72d9f8..efce79a6 100644 --- a/library/Zend/Text/Exception/ExceptionInterface.php +++ b/library/Zend/Text/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Exception/InvalidArgumentException.php b/library/Zend/Text/Exception/InvalidArgumentException.php index 3ae73c86..68b980bc 100644 --- a/library/Zend/Text/Exception/InvalidArgumentException.php +++ b/library/Zend/Text/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Exception/OutOfBoundsException.php b/library/Zend/Text/Exception/OutOfBoundsException.php index 062ca856..59e71299 100644 --- a/library/Zend/Text/Exception/OutOfBoundsException.php +++ b/library/Zend/Text/Exception/OutOfBoundsException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Exception/OverflowException.php b/library/Zend/Text/Exception/OverflowException.php index 600a3668..de9c1fda 100644 --- a/library/Zend/Text/Exception/OverflowException.php +++ b/library/Zend/Text/Exception/OverflowException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Exception/RuntimeException.php b/library/Zend/Text/Exception/RuntimeException.php index 8b9268db..35493d0f 100644 --- a/library/Zend/Text/Exception/RuntimeException.php +++ b/library/Zend/Text/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Exception/UnexpectedValueException.php b/library/Zend/Text/Exception/UnexpectedValueException.php index c8f28c25..fbe71b04 100644 --- a/library/Zend/Text/Exception/UnexpectedValueException.php +++ b/library/Zend/Text/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Figlet/Exception/ExceptionInterface.php b/library/Zend/Text/Figlet/Exception/ExceptionInterface.php index f42fa230..5803b7e3 100644 --- a/library/Zend/Text/Figlet/Exception/ExceptionInterface.php +++ b/library/Zend/Text/Figlet/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Figlet/Exception/InvalidArgumentException.php b/library/Zend/Text/Figlet/Exception/InvalidArgumentException.php index d207be5e..de981c98 100644 --- a/library/Zend/Text/Figlet/Exception/InvalidArgumentException.php +++ b/library/Zend/Text/Figlet/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Figlet/Exception/RuntimeException.php b/library/Zend/Text/Figlet/Exception/RuntimeException.php index d8a73769..961bf59a 100644 --- a/library/Zend/Text/Figlet/Exception/RuntimeException.php +++ b/library/Zend/Text/Figlet/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Figlet/Exception/UnexpectedValueException.php b/library/Zend/Text/Figlet/Exception/UnexpectedValueException.php index 6c1ba165..45c60fe7 100644 --- a/library/Zend/Text/Figlet/Exception/UnexpectedValueException.php +++ b/library/Zend/Text/Figlet/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Figlet/Figlet.php b/library/Zend/Text/Figlet/Figlet.php index b1e70cf3..5bf9b54f 100644 --- a/library/Zend/Text/Figlet/Figlet.php +++ b/library/Zend/Text/Figlet/Figlet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -831,12 +831,12 @@ class Figlet if ($this->previousCharWidth < 2 || $this->currentCharWidth < 2) { // Disallows overlapping if the previous character or the current // character has a width of one or zero. - return null; + return; } if (($this->smushMode & self::SM_SMUSH) === 0) { // Kerning - return null; + return; } if (($this->smushMode & 63) === 0) { @@ -864,7 +864,7 @@ class Figlet } if ($leftChar === $this->hardBlank && $rightChar === $this->hardBlank) { - return null; + return; } if (($this->smushMode & self::SM_EQUAL) > 0) { @@ -931,7 +931,7 @@ class Figlet } } - return null; + return; } /** @@ -954,8 +954,7 @@ class Figlet // Check if gzip support is required if (substr($fontFile, -3) === '.gz') { if (!function_exists('gzcompress')) { - throw new Exception\RuntimeException('GZIP library is required for ' - . 'gzip compressed font files'); + throw new Exception\RuntimeException('GZIP library is required for gzip compressed font files'); } $fontFile = 'compress.zlib://' . $fontFile; @@ -979,15 +978,18 @@ class Figlet $magic = $this->_readMagic($fp); // Get the header - $numsRead = sscanf(fgets($fp, 1000), - '%*c%c %d %*d %d %d %d %d %d', - $this->hardBlank, - $this->charHeight, - $this->maxLength, - $smush, - $cmtLines, - $rightToLeft, - $this->fontSmush); + $line = fgets($fp, 1000) ?: ''; + $numsRead = sscanf( + $line, + '%*c%c %d %*d %d %d %d %d %d', + $this->hardBlank, + $this->charHeight, + $this->maxLength, + $smush, + $cmtLines, + $rightToLeft, + $this->fontSmush + ); if ($magic !== self::FONTFILE_MAGIC_NUMBER || $numsRead < 5) { throw new Exception\UnexpectedValueException($fontFile . ': Not a FIGlet 2 font file'); @@ -1056,7 +1058,13 @@ class Figlet // At the end fetch all extended characters while (!feof($fp)) { // Get the Unicode - list($uniCode) = explode(' ', fgets($fp, 2048)); + $uniCode = fgets($fp, 2048); + + if (false === $uniCode) { + continue; + } + + list($uniCode) = explode(' ', $uniCode); if (empty($uniCode)) { continue; diff --git a/library/Zend/Text/Figlet/zend-framework.flf b/library/Zend/Text/Figlet/zend-framework.flf index 5d7445cf..8b4ddc8b 100644 --- a/library/Zend/Text/Figlet/zend-framework.flf +++ b/library/Zend/Text/Figlet/zend-framework.flf @@ -17,7 +17,7 @@ Version: 1.0 obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately. - Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) ------------------------------------------------------------------------------- diff --git a/library/Zend/Text/MultiByte.php b/library/Zend/Text/MultiByte.php index 04bc869d..dba732a1 100644 --- a/library/Zend/Text/MultiByte.php +++ b/library/Zend/Text/MultiByte.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Column.php b/library/Zend/Text/Table/Column.php index 8c41981f..b51b8e5f 100644 --- a/library/Zend/Text/Table/Column.php +++ b/library/Zend/Text/Table/Column.php @@ -3,14 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Text\Table; use Zend\Stdlib\StringUtils; -use Zend\Text; /** * Column class for Zend\Text\Table\Row diff --git a/library/Zend/Text/Table/Decorator/Ascii.php b/library/Zend/Text/Table/Decorator/Ascii.php index 6d049ae8..159820d1 100644 --- a/library/Zend/Text/Table/Decorator/Ascii.php +++ b/library/Zend/Text/Table/Decorator/Ascii.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Decorator/Blank.php b/library/Zend/Text/Table/Decorator/Blank.php index 0b4bf087..81b058b9 100644 --- a/library/Zend/Text/Table/Decorator/Blank.php +++ b/library/Zend/Text/Table/Decorator/Blank.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Decorator/DecoratorInterface.php b/library/Zend/Text/Table/Decorator/DecoratorInterface.php index 31d0b5e3..9e9ec76d 100644 --- a/library/Zend/Text/Table/Decorator/DecoratorInterface.php +++ b/library/Zend/Text/Table/Decorator/DecoratorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Decorator/Unicode.php b/library/Zend/Text/Table/Decorator/Unicode.php index cb12a9d6..9d2748bb 100644 --- a/library/Zend/Text/Table/Decorator/Unicode.php +++ b/library/Zend/Text/Table/Decorator/Unicode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/DecoratorManager.php b/library/Zend/Text/Table/DecoratorManager.php index e936230e..10a5f00f 100644 --- a/library/Zend/Text/Table/DecoratorManager.php +++ b/library/Zend/Text/Table/DecoratorManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Exception/ExceptionInterface.php b/library/Zend/Text/Table/Exception/ExceptionInterface.php index eb2c70ef..8330046d 100644 --- a/library/Zend/Text/Table/Exception/ExceptionInterface.php +++ b/library/Zend/Text/Table/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Exception/InvalidArgumentException.php b/library/Zend/Text/Table/Exception/InvalidArgumentException.php index 2cb5570b..6e99a829 100644 --- a/library/Zend/Text/Table/Exception/InvalidArgumentException.php +++ b/library/Zend/Text/Table/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Exception/InvalidDecoratorException.php b/library/Zend/Text/Table/Exception/InvalidDecoratorException.php index 44817bbe..cc39ab33 100644 --- a/library/Zend/Text/Table/Exception/InvalidDecoratorException.php +++ b/library/Zend/Text/Table/Exception/InvalidDecoratorException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Exception/OutOfBoundsException.php b/library/Zend/Text/Table/Exception/OutOfBoundsException.php index 17e90026..1d07b24e 100644 --- a/library/Zend/Text/Table/Exception/OutOfBoundsException.php +++ b/library/Zend/Text/Table/Exception/OutOfBoundsException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Exception/OverflowException.php b/library/Zend/Text/Table/Exception/OverflowException.php index 3644d3b8..199c7e4b 100644 --- a/library/Zend/Text/Table/Exception/OverflowException.php +++ b/library/Zend/Text/Table/Exception/OverflowException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Exception/UnexpectedValueException.php b/library/Zend/Text/Table/Exception/UnexpectedValueException.php index 1f0a3490..71a76254 100644 --- a/library/Zend/Text/Table/Exception/UnexpectedValueException.php +++ b/library/Zend/Text/Table/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Text/Table/Row.php b/library/Zend/Text/Table/Row.php index 7af59288..b0c0936f 100644 --- a/library/Zend/Text/Table/Row.php +++ b/library/Zend/Text/Table/Row.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -78,7 +78,7 @@ class Row public function getColumn($index) { if (!isset($this->columns[$index])) { - return null; + return; } return $this->columns[$index]; @@ -103,7 +103,9 @@ class Row public function getColumnWidths() { if ($this->columnWidths === null) { - throw new Exception\UnexpectedValueException('render() must be called before columnWidths can be populated'); + throw new Exception\UnexpectedValueException( + 'render() must be called before columnWidths can be populated' + ); } return $this->columnWidths; @@ -143,9 +145,7 @@ class Row } // Calculate the column width - $columnWidth = ($colSpan - 1 + array_sum(array_slice($columnWidths, - $colNum, - $colSpan))); + $columnWidth = ($colSpan - 1 + array_sum(array_slice($columnWidths, $colNum, $colSpan))); // Render the column and split it's lines into an array $result = explode("\n", $column->render($columnWidth, $padding)); @@ -165,8 +165,7 @@ class Row // it with an empty column if ($colNum < count($columnWidths)) { $remainingWidth = (count($columnWidths) - $colNum - 1) + - array_sum(array_slice($columnWidths, - $colNum)); + array_sum(array_slice($columnWidths, $colNum)); $renderedColumns[] = array(str_repeat(' ', $remainingWidth)); $this->columnWidths[] = $remainingWidth; diff --git a/library/Zend/Text/Table/Table.php b/library/Zend/Text/Table/Table.php index 681db1b1..6077673e 100644 --- a/library/Zend/Text/Table/Table.php +++ b/library/Zend/Text/Table/Table.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -164,8 +164,7 @@ class Table foreach ($columnWidths as $columnNum => $columnWidth) { if (is_int($columnWidth) === false or $columnWidth < 1) { - throw new Exception\InvalidArgumentException('Column ' . $columnNum . ' has an invalid' - . ' column width'); + throw new Exception\InvalidArgumentException('Column ' . $columnNum . ' has an invalid column width'); } } @@ -375,8 +374,7 @@ class Table $result .= $this->decorator->getTopLeft(); foreach ($columnWidths as $columnNum => $columnWidth) { - $result .= str_repeat($this->decorator->getHorizontal(), - $columnWidth); + $result .= str_repeat($this->decorator->getHorizontal(), $columnWidth); if (($columnNum + 1) === $numColumns) { $result .= $this->decorator->getTopRight(); @@ -412,8 +410,7 @@ class Table // Loop through all column widths foreach ($this->columnWidths as $columnNum => $columnWidth) { // Add the horizontal line - $result .= str_repeat($this->decorator->getHorizontal(), - $columnWidth); + $result .= str_repeat($this->decorator->getHorizontal(), $columnWidth); // If this is the last line, break out if (($columnNum + 1) === $totalNumColumns) { @@ -476,8 +473,7 @@ class Table $result .= $this->decorator->getBottomLeft(); foreach ($columnWidths as $columnNum => $columnWidth) { - $result .= str_repeat($this->decorator->getHorizontal(), - $columnWidth); + $result .= str_repeat($this->decorator->getHorizontal(), $columnWidth); if (($columnNum + 1) === $numColumns) { $result .= $this->decorator->getBottomRight(); diff --git a/library/Zend/Text/composer.json b/library/Zend/Text/composer.json index 7f7cafb7..ff1df4ae 100644 --- a/library/Zend/Text/composer.json +++ b/library/Zend/Text/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Text\\": "" } }, - "target-dir": "Zend/Text", "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version", @@ -20,8 +19,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Uri/Exception/ExceptionInterface.php b/library/Zend/Uri/Exception/ExceptionInterface.php index f40e4239..de4a547e 100644 --- a/library/Zend/Uri/Exception/ExceptionInterface.php +++ b/library/Zend/Uri/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Uri/Exception/InvalidArgumentException.php b/library/Zend/Uri/Exception/InvalidArgumentException.php index 2c5772d5..dae1bec1 100644 --- a/library/Zend/Uri/Exception/InvalidArgumentException.php +++ b/library/Zend/Uri/Exception/InvalidArgumentException.php @@ -3,14 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Uri\Exception; -class InvalidArgumentException - extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Uri/Exception/InvalidUriException.php b/library/Zend/Uri/Exception/InvalidUriException.php index 9b466e41..d68dbfff 100644 --- a/library/Zend/Uri/Exception/InvalidUriException.php +++ b/library/Zend/Uri/Exception/InvalidUriException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Uri/Exception/InvalidUriPartException.php b/library/Zend/Uri/Exception/InvalidUriPartException.php index 0daf5b08..6f5a52a9 100644 --- a/library/Zend/Uri/Exception/InvalidUriPartException.php +++ b/library/Zend/Uri/Exception/InvalidUriPartException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Uri/File.php b/library/Zend/Uri/File.php index 71c21875..f95b7392 100644 --- a/library/Zend/Uri/File.php +++ b/library/Zend/Uri/File.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Uri/Http.php b/library/Zend/Uri/Http.php index a24851b1..6095e497 100644 --- a/library/Zend/Uri/Http.php +++ b/library/Zend/Uri/Http.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -47,59 +47,49 @@ class Http extends Uri */ protected $password; - /** - * Check if the URI is a valid HTTP URI - * - * This applies additional HTTP specific validation rules beyond the ones - * required by the generic URI syntax - * - * @return bool - * @see Uri::isValid() - */ - public function isValid() - { - return parent::isValid(); - } - /** * Get the username part (before the ':') of the userInfo URI part * - * @return null|string + * @return string|null */ public function getUser() { - if (null !== $this->user) { - return $this->user; - } - - $this->parseUserInfo(); return $this->user; } /** * Get the password part (after the ':') of the userInfo URI part * - * @return string + * @return string|null */ public function getPassword() { - if (null !== $this->password) { - return $this->password; - } - - $this->parseUserInfo(); return $this->password; } + /** + * Get the User-info (usually user:password) part + * + * @return string|null + */ + public function getUserInfo() + { + return $this->userInfo; + } + /** * Set the username part (before the ':') of the userInfo URI part * - * @param string $user - * @return Http + * @param string|null $user + * + * @return self */ public function setUser($user) { - $this->user = $user; + $this->user = null === $user ? null : (string) $user; + + $this->buildUserInfo(); + return $this; } @@ -107,11 +97,33 @@ class Http extends Uri * Set the password part (after the ':') of the userInfo URI part * * @param string $password - * @return Http + * + * @return self */ public function setPassword($password) { - $this->password = $password; + $this->password = null === $password ? null : (string) $password; + + $this->buildUserInfo(); + + return $this; + } + + /** + * Set the URI User-info part (usually user:password) + * + * @param string|null $userInfo + * + * @return self + * + * @throws Exception\InvalidUriPartException If the schema definition does not have this part + */ + public function setUserInfo($userInfo) + { + $this->userInfo = null === $userInfo ? null : (string) $userInfo; + + $this->parseUserInfo(); + return $this; } @@ -142,19 +154,37 @@ class Http extends Uri { // No user information? we're done if (null === $this->userInfo) { + $this->setUser(null); + $this->setPassword(null); + return; } // If no ':' separator, we only have a username if (false === strpos($this->userInfo, ':')) { $this->setUser($this->userInfo); + $this->setPassword(null); return; } // Split on the ':', and set both user and password - list($user, $password) = explode(':', $this->userInfo, 2); - $this->setUser($user); - $this->setPassword($password); + list($this->user, $this->password) = explode(':', $this->userInfo, 2); + } + + /** + * Build the user info based on user and password + * + * Builds the user info based on the given user and password values + * + * @return void + */ + protected function buildUserInfo() + { + if (null !== $this->password) { + $this->userInfo = $this->user . ':' . $this->password; + } else { + $this->userInfo = $this->user; + } } /** diff --git a/library/Zend/Uri/Mailto.php b/library/Zend/Uri/Mailto.php index 8463f995..afe61c8e 100644 --- a/library/Zend/Uri/Mailto.php +++ b/library/Zend/Uri/Mailto.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Uri/Uri.php b/library/Zend/Uri/Uri.php index cf8a1b18..bbb7eb5c 100644 --- a/library/Zend/Uri/Uri.php +++ b/library/Zend/Uri/Uri.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -36,18 +36,18 @@ class Uri implements UriInterface * Place 1 or 0 in the different positions for enable or disable the part. * Finally use a hexadecimal representation. */ - const HOST_IPV4 = 0x01; //00001 - const HOST_IPV6 = 0x02; //00010 - const HOST_IPVFUTURE = 0x04; //00100 - const HOST_IPVANY = 0x07; //00111 - const HOST_DNS = 0x08; //01000 - const HOST_DNS_OR_IPV4 = 0x09; //01001 - const HOST_DNS_OR_IPV6 = 0x0A; //01010 - const HOST_DNS_OR_IPV4_OR_IPV6 = 0x0B; //01011 - const HOST_DNS_OR_IPVANY = 0x0F; //01111 - const HOST_REGNAME = 0x10; //10000 - const HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME = 0x13; //10011 - const HOST_ALL = 0x1F; //11111 + const HOST_IPV4 = 0x01; //00001 + const HOST_IPV6 = 0x02; //00010 + const HOST_IPVFUTURE = 0x04; //00100 + const HOST_IPVANY = 0x07; //00111 + const HOST_DNS = 0x08; //01000 + const HOST_DNS_OR_IPV4 = 0x09; //01001 + const HOST_DNS_OR_IPV6 = 0x0A; //01010 + const HOST_DNS_OR_IPV4_OR_IPV6 = 0x0B; //01011 + const HOST_DNS_OR_IPVANY = 0x0F; //01111 + const HOST_REGNAME = 0x10; //10000 + const HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME = 0x1B; //11011 + const HOST_ALL = 0x1F; //11111 /** * URI scheme @@ -284,7 +284,7 @@ class Uri implements UriInterface // Capture scheme if (($scheme = self::parseScheme($uri)) !== null) { $this->setScheme($scheme); - $uri = substr($uri, strlen($scheme) + 1); + $uri = substr($uri, strlen($scheme) + 1) ?: ''; } // Capture authority part @@ -507,7 +507,6 @@ class Uri implements UriInterface return $this; } - /** * Convert the link to a relative link by substracting a base URI * @@ -560,10 +559,8 @@ class Uri implements UriInterface return $this; } - $pathParts = preg_split('|(/)|', $this->getPath(), null, - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - $baseParts = preg_split('|(/)|', $baseUri->getPath(), null, - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $pathParts = preg_split('|(/)|', $this->getPath(), null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $baseParts = preg_split('|(/)|', $baseUri->getPath(), null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); // Get the intersection of existing path parts and those from the // provided URI @@ -1075,7 +1072,7 @@ class Uri implements UriInterface return $match[1]; } - return null; + return; } /** @@ -1104,11 +1101,19 @@ class Uri implements UriInterface break; case ($path == '/..'): $path = '/'; - $output = substr($output, 0, strrpos($output, '/', -1)); + $lastSlashPos = strrpos($output, '/', -1); + if (false === $lastSlashPos) { + break; + } + $output = substr($output, 0, $lastSlashPos); break; case (substr($path, 0, 4) == '/../'): $path = '/' . substr($path, 4); - $output = substr($output, 0, strrpos($output, '/', -1)); + $lastSlashPos = strrpos($output, '/', -1); + if (false === $lastSlashPos) { + break; + } + $output = substr($output, 0, $lastSlashPos); break; case (substr($path, 0, 3) == '/./'): $path = substr($path, 2); @@ -1267,7 +1272,7 @@ class Uri implements UriInterface && isset(static::$defaultPorts[$scheme]) && ($port == static::$defaultPorts[$scheme]) ) { - return null; + return; } return $port; diff --git a/library/Zend/Uri/UriFactory.php b/library/Zend/Uri/UriFactory.php index d6b65a12..3641cdb2 100644 --- a/library/Zend/Uri/UriFactory.php +++ b/library/Zend/Uri/UriFactory.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Uri; - /** * URI Factory Class * @@ -73,9 +72,9 @@ abstract class UriFactory { if (isset(static::$schemeClasses[$scheme])) { return static::$schemeClasses[$scheme]; - } else { - return null; } + + return; } /** @@ -103,19 +102,21 @@ abstract class UriFactory if ($scheme && ! isset(static::$schemeClasses[$scheme])) { throw new Exception\InvalidArgumentException(sprintf( - 'no class registered for scheme "%s"', - $scheme - )); + 'no class registered for scheme "%s"', + $scheme + )); } if ($scheme && isset(static::$schemeClasses[$scheme])) { $class = static::$schemeClasses[$scheme]; $uri = new $class($uri); if (! $uri instanceof UriInterface) { - throw new Exception\InvalidArgumentException(sprintf( - 'class "%s" registered for scheme "%s" does not implement Zend\Uri\UriInterface', - $class, - $scheme - )); + throw new Exception\InvalidArgumentException( + sprintf( + 'class "%s" registered for scheme "%s" does not implement Zend\Uri\UriInterface', + $class, + $scheme + ) + ); } } diff --git a/library/Zend/Uri/UriInterface.php b/library/Zend/Uri/UriInterface.php index 7799f65d..6f13f678 100644 --- a/library/Zend/Uri/UriInterface.php +++ b/library/Zend/Uri/UriInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -76,8 +76,6 @@ interface UriInterface */ public function normalize(); - - /** * Convert the link to a relative link by substracting a base URI * diff --git a/library/Zend/Uri/composer.json b/library/Zend/Uri/composer.json index 536ae1b5..c6bd852c 100644 --- a/library/Zend/Uri/composer.json +++ b/library/Zend/Uri/composer.json @@ -8,11 +8,10 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Uri\\": "" } }, - "target-dir": "Zend/Uri", "require": { "php": ">=5.3.23", "zendframework/zend-escaper": "self.version", @@ -20,8 +19,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Validator/AbstractValidator.php b/library/Zend/Validator/AbstractValidator.php index 3852e391..93af2cab 100644 --- a/library/Zend/Validator/AbstractValidator.php +++ b/library/Zend/Validator/AbstractValidator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -279,7 +279,7 @@ abstract class AbstractValidator implements protected function createMessage($messageKey, $value) { if (!isset($this->abstractOptions['messageTemplates'][$messageKey])) { - return null; + return; } $message = $this->abstractOptions['messageTemplates'][$messageKey]; @@ -410,7 +410,7 @@ abstract class AbstractValidator implements public function getTranslator() { if (! $this->isTranslatorEnabled()) { - return null; + return; } if (null === $this->abstractOptions['translator']) { @@ -464,9 +464,8 @@ abstract class AbstractValidator implements * @return void * @throws Exception\InvalidArgumentException */ - public static function setDefaultTranslator( - Translator\TranslatorInterface $translator = null, $textDomain = null - ) { + public static function setDefaultTranslator(Translator\TranslatorInterface $translator = null, $textDomain = null) + { static::$defaultTranslator = $translator; if (null !== $textDomain) { self::setDefaultTranslatorTextDomain($textDomain); @@ -570,8 +569,6 @@ abstract class AbstractValidator implements return $message; } - return $translator->translate( - $message, $this->getTranslatorTextDomain() - ); + return $translator->translate($message, $this->getTranslatorTextDomain()); } } diff --git a/library/Zend/Validator/Barcode.php b/library/Zend/Validator/Barcode.php index ee39865c..cfa6cdc0 100644 --- a/library/Zend/Validator/Barcode.php +++ b/library/Zend/Validator/Barcode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/AbstractAdapter.php b/library/Zend/Validator/Barcode/AbstractAdapter.php index 1222d87e..a2842d84 100644 --- a/library/Zend/Validator/Barcode/AbstractAdapter.php +++ b/library/Zend/Validator/Barcode/AbstractAdapter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -53,10 +53,10 @@ abstract class AbstractAdapter implements AdapterInterface $found = true; } elseif ($length == 'even') { $count = $fixum % 2; - $found = ($count == 0) ? true : false; + $found = (0 == $count); } elseif ($length == 'odd') { $count = $fixum % 2; - $found = ($count == 1) ? true : false; + $found = (1 == $count); } return $found; diff --git a/library/Zend/Validator/Barcode/AdapterInterface.php b/library/Zend/Validator/Barcode/AdapterInterface.php index 33d24496..f30fe93e 100644 --- a/library/Zend/Validator/Barcode/AdapterInterface.php +++ b/library/Zend/Validator/Barcode/AdapterInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Codabar.php b/library/Zend/Validator/Barcode/Codabar.php index 1a3011c1..eca14e21 100644 --- a/library/Zend/Validator/Barcode/Codabar.php +++ b/library/Zend/Validator/Barcode/Codabar.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Code128.php b/library/Zend/Validator/Barcode/Code128.php index 0bcbb627..06a0b5e6 100644 --- a/library/Zend/Validator/Barcode/Code128.php +++ b/library/Zend/Validator/Barcode/Code128.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,51 +29,52 @@ class Code128 extends AbstractAdapter { $this->setLength(-1); $this->setCharacters(array( - 'A' => array( - 0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'", - 8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/', - 16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7', - 24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?', - 32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G', - 40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O', - 48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W', - 56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\',61 => ']', 62 => '^', 63 => '_', - 64 =>0x00, 65 =>0x01, 66 =>0x02, 67 =>0x03, 68 =>0x04, 69 =>0x05, 70 =>0x06, 71 =>0x07, - 72 =>0x08, 73 =>0x09, 74 =>0x0A, 75 =>0x0B, 76 =>0x0C, 77 =>0x0D, 78 =>0x0E, 79 =>0x0F, - 80 =>0x10, 81 =>0x11, 82 =>0x12, 83 =>0x13, 84 =>0x14, 85 =>0x15, 86 =>0x16, 87 =>0x17, - 88 =>0x18, 89 =>0x19, 90 =>0x1A, 91 =>0x1B, 92 =>0x1C, 93 =>0x1D, 94 =>0x1E, 95 =>0x1F, - 96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â',100 => 'ä',101 => 'à',102 => 'å',103 => '‡', - 104 => 'ˆ',105 => '‰',106 => 'Š'), - 'B' => array( - 0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'", - 8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/', - 16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7', - 24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?', - 32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G', - 40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O', - 48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W', - 56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\',61 => ']', 62 => '^', 63 => '_', - 64 => '`', 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', 69 => 'e', 70 => 'f', 71 => 'g', - 72 => 'h', 73 => 'i', 74 => 'j', 75 => 'k', 76 => 'l', 77 => 'm', 78 => 'n', 79 => 'o', - 80 => 'p', 81 => 'q', 82 => 'r', 83 => 's', 84 => 't', 85 => 'u', 86 => 'v', 87 => 'w', - 88 => 'x', 89 => 'y', 90 => 'z', 91 => '{', 92 => '|', 93 => '}', 94 => '~', 95 =>0x7F, - 96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â',100 => 'ä',101 => 'à',102 => 'å',103 => '‡', - 104 => 'ˆ',105 => '‰',106 => 'Š'), - 'C' => array( - 0 => '00', 1 => '01', 2 => '02', 3 => '03', 4 => '04', 5 => '05', 6 => '06', 7 => '07', - 8 => '08', 9 => '09', 10 => '10', 11 => '11', 12 => '12', 13 => '13', 14 => '14', 15 => '15', - 16 => '16', 17 => '17', 18 => '18', 19 => '19', 20 => '20', 21 => '21', 22 => '22', 23 => '23', - 24 => '24', 25 => '25', 26 => '26', 27 => '27', 28 => '28', 29 => '29', 30 => '30', 31 => '31', - 32 => '32', 33 => '33', 34 => '34', 35 => '35', 36 => '36', 37 => '37', 38 => '38', 39 => '39', - 40 => '40', 41 => '41', 42 => '42', 43 => '43', 44 => '44', 45 => '45', 46 => '46', 47 => '47', - 48 => '48', 49 => '49', 50 => '50', 51 => '51', 52 => '52', 53 => '53', 54 => '54', 55 => '55', - 56 => '56', 57 => '57', 58 => '58', 59 => '59', 60 => '60', 61 => '61', 62 => '62', 63 => '63', - 64 => '64', 65 => '65', 66 => '66', 67 => '67', 68 => '68', 69 => '69', 70 => '70', 71 => '71', - 72 => '72', 73 => '73', 74 => '74', 75 => '75', 76 => '76', 77 => '77', 78 => '78', 79 => '79', - 80 => '80', 81 => '81', 82 => '82', 83 => '83', 84 => '84', 85 => '85', 86 => '86', 87 => '87', - 88 => '88', 89 => '89', 90 => '90', 91 => '91', 92 => '92', 93 => '93', 94 => '94', 95 => '95', - 96 => '96', 97 => '97', 98 => '98', 99 => '99',100 => 'ä', 101 => 'à', 102 => 'å', 103 => '‡', - 104 => 'ˆ', 105 => '‰', 106 => 'Š'))); + 'A' => array( + 0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'", + 8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/', + 16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7', + 24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?', + 32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G', + 40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O', + 48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W', + 56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\', 61 => ']', 62 => '^', 63 => '_', + 64 =>0x00, 65 =>0x01, 66 =>0x02, 67 =>0x03, 68 =>0x04, 69 =>0x05, 70 =>0x06, 71 =>0x07, + 72 =>0x08, 73 =>0x09, 74 =>0x0A, 75 =>0x0B, 76 =>0x0C, 77 =>0x0D, 78 =>0x0E, 79 =>0x0F, + 80 =>0x10, 81 =>0x11, 82 =>0x12, 83 =>0x13, 84 =>0x14, 85 =>0x15, 86 =>0x16, 87 =>0x17, + 88 =>0x18, 89 =>0x19, 90 =>0x1A, 91 =>0x1B, 92 =>0x1C, 93 =>0x1D, 94 =>0x1E, 95 =>0x1F, + 96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â', 100 => 'ä', 101 => 'à', 102 => 'å', 103 => '‡', + 104 => 'ˆ', 105 => '‰', 106 => 'Š'), + 'B' => array( + 0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'", + 8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/', + 16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7', + 24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?', + 32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G', + 40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O', + 48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W', + 56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\', 61 => ']', 62 => '^', 63 => '_', + 64 => '`', 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', 69 => 'e', 70 => 'f', 71 => 'g', + 72 => 'h', 73 => 'i', 74 => 'j', 75 => 'k', 76 => 'l', 77 => 'm', 78 => 'n', 79 => 'o', + 80 => 'p', 81 => 'q', 82 => 'r', 83 => 's', 84 => 't', 85 => 'u', 86 => 'v', 87 => 'w', + 88 => 'x', 89 => 'y', 90 => 'z', 91 => '{', 92 => '|', 93 => '}', 94 => '~', 95 =>0x7F, + 96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â', 100 => 'ä', 101 => 'à', 102 => 'å', 103 => '‡', + 104 => 'ˆ', 105 => '‰', 106 => 'Š'), + 'C' => array( + 0 => '00', 1 => '01', 2 => '02', 3 => '03', 4 => '04', 5 => '05', 6 => '06', 7 => '07', + 8 => '08', 9 => '09', 10 => '10', 11 => '11', 12 => '12', 13 => '13', 14 => '14', 15 => '15', + 16 => '16', 17 => '17', 18 => '18', 19 => '19', 20 => '20', 21 => '21', 22 => '22', 23 => '23', + 24 => '24', 25 => '25', 26 => '26', 27 => '27', 28 => '28', 29 => '29', 30 => '30', 31 => '31', + 32 => '32', 33 => '33', 34 => '34', 35 => '35', 36 => '36', 37 => '37', 38 => '38', 39 => '39', + 40 => '40', 41 => '41', 42 => '42', 43 => '43', 44 => '44', 45 => '45', 46 => '46', 47 => '47', + 48 => '48', 49 => '49', 50 => '50', 51 => '51', 52 => '52', 53 => '53', 54 => '54', 55 => '55', + 56 => '56', 57 => '57', 58 => '58', 59 => '59', 60 => '60', 61 => '61', 62 => '62', 63 => '63', + 64 => '64', 65 => '65', 66 => '66', 67 => '67', 68 => '68', 69 => '69', 70 => '70', 71 => '71', + 72 => '72', 73 => '73', 74 => '74', 75 => '75', 76 => '76', 77 => '77', 78 => '78', 79 => '79', + 80 => '80', 81 => '81', 82 => '82', 83 => '83', 84 => '84', 85 => '85', 86 => '86', 87 => '87', + 88 => '88', 89 => '89', 90 => '90', 91 => '91', 92 => '92', 93 => '93', 94 => '94', 95 => '95', + 96 => '96', 97 => '97', 98 => '98', 99 => '99', 100 => 'ä', 101 => 'à', 102 => 'å', 103 => '‡', + 104 => 'ˆ', 105 => '‰', 106 => 'Š') + )); $this->setChecksum('code128'); } @@ -128,13 +129,13 @@ class Code128 extends AbstractAdapter switch ($char) { // Function definition - case 'Ç' : - case 'ü' : - case 'å' : + case 'Ç': + case 'ü': + case 'å': break; // Switch 1 char between A and B - case 'é' : + case 'é': if ($set == 'A') { $read = 'B'; } elseif ($set == 'B') { @@ -143,32 +144,31 @@ class Code128 extends AbstractAdapter break; // Switch to C - case 'â' : + case 'â': $set = 'C'; $read = 'C'; break; // Switch to B - case 'ä' : + case 'ä': $set = 'B'; $read = 'B'; break; // Switch to A - case 'à' : + case 'à': $set = 'A'; $read = 'A'; break; // Doubled start character - case '‡' : - case 'ˆ' : - case '‰' : + case '‡': + case 'ˆ': + case '‰': return false; - break; // Chars after the stop character - case 'Š' : + case 'Š': break 2; default: @@ -226,45 +226,45 @@ class Code128 extends AbstractAdapter switch ($char) { // Function definition - case 'Ç' : - case 'ü' : - case 'å' : + case 'Ç': + case 'ü': + case 'å': $sum += ($pos * $this->ord128($char, $set)); break; - case 'é' : + case 'é': $sum += ($pos * $this->ord128($char, $set)); - if ($set == 'A') { - $read = 'B'; - } elseif ($set == 'B') { - $read = 'A'; - } + if ($set == 'A') { + $read = 'B'; + } elseif ($set == 'B') { + $read = 'A'; + } break; // Switch to C - case 'â' : + case 'â': $sum += ($pos * $this->ord128($char, $set)); $set = 'C'; $read = 'C'; break; // Switch to B - case 'ä' : + case 'ä': $sum += ($pos * $this->ord128($char, $set)); $set = 'B'; $read = 'B'; break; // Switch to A - case 'à' : + case 'à': $sum += ($pos * $this->ord128($char, $set)); $set = 'A'; $read = 'A'; break; - case '‡' : - case 'ˆ' : - case '‰' : + case '‡': + case 'ˆ': + case '‰': return false; break; @@ -310,13 +310,13 @@ class Code128 extends AbstractAdapter { $value = $this->getUtf8StringWrapper()->substr($value, 0, 1); switch ($value) { - case '‡' : + case '‡': return 'A'; break; - case 'ˆ' : + case 'ˆ': return 'B'; break; - case '‰' : + case '‰': return 'C'; break; } diff --git a/library/Zend/Validator/Barcode/Code25.php b/library/Zend/Validator/Barcode/Code25.php index 3619f528..8235c437 100644 --- a/library/Zend/Validator/Barcode/Code25.php +++ b/library/Zend/Validator/Barcode/Code25.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Code25interleaved.php b/library/Zend/Validator/Barcode/Code25interleaved.php index 77bc027d..cb41c76e 100644 --- a/library/Zend/Validator/Barcode/Code25interleaved.php +++ b/library/Zend/Validator/Barcode/Code25interleaved.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Code39.php b/library/Zend/Validator/Barcode/Code39.php index 9a368c5d..01208ce2 100644 --- a/library/Zend/Validator/Barcode/Code39.php +++ b/library/Zend/Validator/Barcode/Code39.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Code39ext.php b/library/Zend/Validator/Barcode/Code39ext.php index b9b14a59..e65d491c 100644 --- a/library/Zend/Validator/Barcode/Code39ext.php +++ b/library/Zend/Validator/Barcode/Code39ext.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Code93.php b/library/Zend/Validator/Barcode/Code93.php index 35739a11..f312a138 100644 --- a/library/Zend/Validator/Barcode/Code93.php +++ b/library/Zend/Validator/Barcode/Code93.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Code93ext.php b/library/Zend/Validator/Barcode/Code93ext.php index aa8fc07b..99503a14 100644 --- a/library/Zend/Validator/Barcode/Code93ext.php +++ b/library/Zend/Validator/Barcode/Code93ext.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean12.php b/library/Zend/Validator/Barcode/Ean12.php index ee45ebb6..4805145a 100644 --- a/library/Zend/Validator/Barcode/Ean12.php +++ b/library/Zend/Validator/Barcode/Ean12.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean13.php b/library/Zend/Validator/Barcode/Ean13.php index b1dc05e1..e271cbea 100644 --- a/library/Zend/Validator/Barcode/Ean13.php +++ b/library/Zend/Validator/Barcode/Ean13.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean14.php b/library/Zend/Validator/Barcode/Ean14.php index fe20366a..9d8168bb 100644 --- a/library/Zend/Validator/Barcode/Ean14.php +++ b/library/Zend/Validator/Barcode/Ean14.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean18.php b/library/Zend/Validator/Barcode/Ean18.php index 774df712..7388b732 100644 --- a/library/Zend/Validator/Barcode/Ean18.php +++ b/library/Zend/Validator/Barcode/Ean18.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean2.php b/library/Zend/Validator/Barcode/Ean2.php index 9d8a527a..99a87bfe 100644 --- a/library/Zend/Validator/Barcode/Ean2.php +++ b/library/Zend/Validator/Barcode/Ean2.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean5.php b/library/Zend/Validator/Barcode/Ean5.php index 01f597d1..8ef2d519 100644 --- a/library/Zend/Validator/Barcode/Ean5.php +++ b/library/Zend/Validator/Barcode/Ean5.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Ean8.php b/library/Zend/Validator/Barcode/Ean8.php index 6af4cccf..a34c8b45 100644 --- a/library/Zend/Validator/Barcode/Ean8.php +++ b/library/Zend/Validator/Barcode/Ean8.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Gtin12.php b/library/Zend/Validator/Barcode/Gtin12.php index b3c97d3d..44464445 100644 --- a/library/Zend/Validator/Barcode/Gtin12.php +++ b/library/Zend/Validator/Barcode/Gtin12.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Gtin13.php b/library/Zend/Validator/Barcode/Gtin13.php index 04984979..b8dcd095 100644 --- a/library/Zend/Validator/Barcode/Gtin13.php +++ b/library/Zend/Validator/Barcode/Gtin13.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Gtin14.php b/library/Zend/Validator/Barcode/Gtin14.php index 70e3cc5b..862d3e14 100644 --- a/library/Zend/Validator/Barcode/Gtin14.php +++ b/library/Zend/Validator/Barcode/Gtin14.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Identcode.php b/library/Zend/Validator/Barcode/Identcode.php index 08c398dd..5b392715 100644 --- a/library/Zend/Validator/Barcode/Identcode.php +++ b/library/Zend/Validator/Barcode/Identcode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Intelligentmail.php b/library/Zend/Validator/Barcode/Intelligentmail.php index 665d2035..d26cce68 100644 --- a/library/Zend/Validator/Barcode/Intelligentmail.php +++ b/library/Zend/Validator/Barcode/Intelligentmail.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Issn.php b/library/Zend/Validator/Barcode/Issn.php index 52434ed1..e66451a1 100644 --- a/library/Zend/Validator/Barcode/Issn.php +++ b/library/Zend/Validator/Barcode/Issn.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Itf14.php b/library/Zend/Validator/Barcode/Itf14.php index 195d84dd..b17eb705 100644 --- a/library/Zend/Validator/Barcode/Itf14.php +++ b/library/Zend/Validator/Barcode/Itf14.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Leitcode.php b/library/Zend/Validator/Barcode/Leitcode.php index 29503a92..c1b82c3c 100644 --- a/library/Zend/Validator/Barcode/Leitcode.php +++ b/library/Zend/Validator/Barcode/Leitcode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Planet.php b/library/Zend/Validator/Barcode/Planet.php index ecdff2db..0708b7c8 100644 --- a/library/Zend/Validator/Barcode/Planet.php +++ b/library/Zend/Validator/Barcode/Planet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Postnet.php b/library/Zend/Validator/Barcode/Postnet.php index acc84da5..2942d4ca 100644 --- a/library/Zend/Validator/Barcode/Postnet.php +++ b/library/Zend/Validator/Barcode/Postnet.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Royalmail.php b/library/Zend/Validator/Barcode/Royalmail.php index 538efa61..77555ed5 100644 --- a/library/Zend/Validator/Barcode/Royalmail.php +++ b/library/Zend/Validator/Barcode/Royalmail.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Sscc.php b/library/Zend/Validator/Barcode/Sscc.php index d3b33637..57f9c8a3 100644 --- a/library/Zend/Validator/Barcode/Sscc.php +++ b/library/Zend/Validator/Barcode/Sscc.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Upca.php b/library/Zend/Validator/Barcode/Upca.php index 4c5f623f..afb2a7a4 100644 --- a/library/Zend/Validator/Barcode/Upca.php +++ b/library/Zend/Validator/Barcode/Upca.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Barcode/Upce.php b/library/Zend/Validator/Barcode/Upce.php index 646c739a..32a573f1 100644 --- a/library/Zend/Validator/Barcode/Upce.php +++ b/library/Zend/Validator/Barcode/Upce.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Between.php b/library/Zend/Validator/Between.php index 327115ee..28101538 100644 --- a/library/Zend/Validator/Between.php +++ b/library/Zend/Validator/Between.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -56,6 +56,8 @@ class Between extends AbstractValidator * 'inclusive' => boolean, inclusive border values * * @param array|Traversable $options + * + * @throws Exception\InvalidArgumentException */ public function __construct($options = null) { @@ -76,8 +78,10 @@ class Between extends AbstractValidator $options = $temp; } - if (!array_key_exists('min', $options) || !array_key_exists('max', $options)) { - // throw new Exception\InvalidArgumentException("Missing option. 'min' and 'max' has to be given"); + if (count($options) !== 2 + && (!array_key_exists('min', $options) || !array_key_exists('max', $options)) + ) { + throw new Exception\InvalidArgumentException("Missing option. 'min' and 'max' have to be given"); } parent::__construct($options); diff --git a/library/Zend/Validator/Bitwise.php b/library/Zend/Validator/Bitwise.php index 8abbffb3..7f676cff 100644 --- a/library/Zend/Validator/Bitwise.php +++ b/library/Zend/Validator/Bitwise.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Callback.php b/library/Zend/Validator/Callback.php index e4b389de..7a5005bb 100644 --- a/library/Zend/Validator/Callback.php +++ b/library/Zend/Validator/Callback.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/CreditCard.php b/library/Zend/Validator/CreditCard.php index e54a17c2..0f637f37 100644 --- a/library/Zend/Validator/CreditCard.php +++ b/library/Zend/Validator/CreditCard.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -84,7 +84,7 @@ class CreditCard extends AbstractValidator self::DINERS_CLUB => array(14), self::DINERS_CLUB_US => array(16), self::DISCOVER => array(16), - self::JCB => array(16), + self::JCB => array(15, 16), self::LASER => array(16, 17, 18, 19), self::MAESTRO => array(12, 13, 14, 15, 16, 17, 18, 19), self::MASTERCARD => array(16), @@ -108,7 +108,7 @@ class CreditCard extends AbstractValidator '62290', '62291', '622920', '622921', '622922', '622923', '622924', '622925', '644', '645', '646', '647', '648', '649', '65'), - self::JCB => array('3528', '3529', '353', '354', '355', '356', '357', '358'), + self::JCB => array('1800', '2131', '3528', '3529', '353', '354', '355', '356', '357', '358'), self::LASER => array('6304', '6706', '6771', '6709'), self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766'), diff --git a/library/Zend/Validator/Csrf.php b/library/Zend/Validator/Csrf.php index 6272c0be..ef64ee3c 100644 --- a/library/Zend/Validator/Csrf.php +++ b/library/Zend/Validator/Csrf.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -121,7 +121,10 @@ class Csrf extends AbstractValidator $tokenId = $this->getTokenIdFromHash($value); $hash = $this->getValidationToken($tokenId); - if ($this->getTokenFromHash($value) !== $this->getTokenFromHash($hash)) { + $tokenFromValue = $this->getTokenFromHash($value); + $tokenFromHash = $this->getTokenFromHash($hash); + + if (!$tokenFromValue || !$tokenFromHash || ($tokenFromValue !== $tokenFromHash)) { $this->error(self::NOT_SAME); return false; } @@ -331,7 +334,7 @@ class Csrf extends AbstractValidator return $this->formatHash($session->tokenList[$tokenId], $tokenId); } - return null; + return; } /** @@ -363,7 +366,7 @@ class Csrf extends AbstractValidator $data = explode('-', $hash); if (! isset($data[1])) { - return null; + return; } return $data[1]; diff --git a/library/Zend/Validator/Date.php b/library/Zend/Validator/Date.php index 044a6ce3..c3a3ab74 100644 --- a/library/Zend/Validator/Date.php +++ b/library/Zend/Validator/Date.php @@ -3,13 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator; use DateTime; +use DateTimeImmutable; use Traversable; /** @@ -55,7 +56,6 @@ class Date extends AbstractValidator */ protected $format = self::FORMAT_DEFAULT; - /** * Sets validator options * @@ -127,12 +127,12 @@ class Date extends AbstractValidator */ protected function convertToDateTime($param, $addErrors = true) { - if ($param instanceof DateTime) { + if ($param instanceof DateTime || $param instanceof DateTimeImmutable) { return $param; } $type = gettype($param); - if (!in_array($type, array('string', 'integer', 'array'))) { + if (!in_array($type, array('string', 'integer', 'double', 'array'))) { if ($addErrors) { $this->error(self::INVALID); } @@ -154,6 +154,17 @@ class Date extends AbstractValidator return date_create("@$value"); } + /** + * Attempts to convert an double into a DateTime object + * + * @param double $value + * @return bool|DateTime + */ + protected function convertDouble($value) + { + return DateTime::createFromFormat('U', $value); + } + /** * Attempts to convert a string into a DateTime object * diff --git a/library/Zend/Validator/DateStep.php b/library/Zend/Validator/DateStep.php index e1ff846a..67465d34 100644 --- a/library/Zend/Validator/DateStep.php +++ b/library/Zend/Validator/DateStep.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -211,11 +211,19 @@ class DateStep extends Date // Handle intervals of just one date or time unit. $intervalParts = explode('|', $step->format('%y|%m|%d|%h|%i|%s')); $partCounts = array_count_values($intervalParts); + + $unitKeys = array('years', 'months', 'days', 'hours', 'minutes', 'seconds'); + $intervalParts = array_combine($unitKeys, $intervalParts); + + // Get absolute time difference to avoid special cases of missing/added time + $absoluteValueDate = new DateTime($valueDate->format('Y-m-d H:i:s'), new DateTimeZone('UTC')); + $absoluteBaseDate = new DateTime($baseDate->format('Y-m-d H:i:s'), new DateTimeZone('UTC')); + + $timeDiff = $absoluteValueDate->diff($absoluteBaseDate, 1); + $diffParts = array_combine($unitKeys, explode('|', $timeDiff->format('%y|%m|%d|%h|%i|%s'))); + if (5 === $partCounts["0"]) { // Find the unit with the non-zero interval - $unitKeys = array('years', 'months', 'days', 'hours', 'minutes', 'seconds'); - $intervalParts = array_combine($unitKeys, $intervalParts); - $intervalUnit = null; $stepValue = null; foreach ($intervalParts as $key => $value) { @@ -226,17 +234,12 @@ class DateStep extends Date } } - // Get absolute time difference - $timeDiff = $valueDate->diff($baseDate, true); - $diffParts = explode('|', $timeDiff->format('%y|%m|%d|%h|%i|%s')); - $diffParts = array_combine($unitKeys, $diffParts); - // Check date units if (in_array($intervalUnit, array('years', 'months', 'days'))) { switch ($intervalUnit) { case 'years': - if ( 0 == $diffParts['months'] && 0 == $diffParts['days'] - && 0 == $diffParts['hours'] && 0 == $diffParts['minutes'] + if (0 == $diffParts['months'] && 0 == $diffParts['days'] + && 0 == $diffParts['hours'] && 0 == $diffParts['minutes'] && 0 == $diffParts['seconds'] ) { if (($diffParts['years'] % $stepValue) === 0) { @@ -245,7 +248,7 @@ class DateStep extends Date } break; case 'months': - if ( 0 == $diffParts['days'] && 0 == $diffParts['hours'] + if (0 == $diffParts['days'] && 0 == $diffParts['hours'] && 0 == $diffParts['minutes'] && 0 == $diffParts['seconds'] ) { $months = ($diffParts['years'] * 12) + $diffParts['months']; @@ -255,7 +258,7 @@ class DateStep extends Date } break; case 'days': - if ( 0 == $diffParts['hours'] && 0 == $diffParts['minutes'] + if (0 == $diffParts['hours'] && 0 == $diffParts['minutes'] && 0 == $diffParts['seconds'] ) { $days = $timeDiff->format('%a'); // Total days @@ -282,6 +285,10 @@ class DateStep extends Date } elseif ('seconds' === $intervalUnit) { return true; } + + $this->error(self::NOT_STEP); + + return false; } // Simple test for same day, when using default baseDate @@ -305,7 +312,7 @@ class DateStep extends Date } break; case 'seconds': - $seconds = ($diffParts['hours'] * 60) + $seconds = ($diffParts['hours'] * 60 * 60) + ($diffParts['minutes'] * 60) + $diffParts['seconds']; if (($seconds % $stepValue) === 0) { @@ -319,26 +326,154 @@ class DateStep extends Date } } - // Fall back to slower (but accurate) method for complex intervals. - // Keep adding steps to the base date until a match is found - // or until the value is exceeded. - if ($baseDate < $valueDate) { - while ($baseDate < $valueDate) { - $baseDate->add($step); - if ($baseDate == $valueDate) { - return true; - } - } - } else { - while ($baseDate > $valueDate) { - $baseDate->sub($step); - if ($baseDate == $valueDate) { - return true; - } + return $this->fallbackIncrementalIterationLogic($baseDate, $valueDate, $intervalParts, $diffParts, $step); + } + + /** + * Fall back to slower (but accurate) method for complex intervals. + * Keep adding steps to the base date until a match is found + * or until the value is exceeded. + * + * This is really slow if the interval is small, especially if the + * default base date of 1/1/1970 is used. We can skip a chunk of + * iterations by starting at the lower bound of steps needed to reach + * the target + * + * @param DateTime $baseDate + * @param DateTime $valueDate + * @param int[] $intervalParts + * @param int[] $diffParts + * @param DateInterval $step + * + * @return bool + */ + private function fallbackIncrementalIterationLogic( + DateTime $baseDate, + DateTime $valueDate, + array $intervalParts, + array $diffParts, + DateInterval $step + ) { + list($minSteps, $requiredIterations) = $this->computeMinStepAndRequiredIterations($intervalParts, $diffParts); + $minimumInterval = $this->computeMinimumInterval($intervalParts, $minSteps); + $isIncrementalStepping = $baseDate < $valueDate; + $dateModificationOperation = $isIncrementalStepping ? 'add' : 'sub'; + + for ($offsetIterations = 0; $offsetIterations < $requiredIterations; $offsetIterations += 1) { + $baseDate->{$dateModificationOperation}($minimumInterval); + } + + while (($isIncrementalStepping && $baseDate < $valueDate) + || (! $isIncrementalStepping && $baseDate > $valueDate) + ) { + $baseDate->{$dateModificationOperation}($step); + + if ($baseDate == $valueDate) { + return true; } } $this->error(self::NOT_STEP); + return false; } + + /** + * Computes minimum interval to use for iterations while checking steps + * + * @param int[] $intervalParts + * @param int $minSteps + * + * @return DateInterval + */ + private function computeMinimumInterval(array $intervalParts, $minSteps) + { + return new DateInterval(sprintf( + 'P%dY%dM%dDT%dH%dM%dS', + $intervalParts['years'] * $minSteps, + $intervalParts['months'] * $minSteps, + $intervalParts['days'] * $minSteps, + $intervalParts['hours'] * $minSteps, + $intervalParts['minutes'] * $minSteps, + $intervalParts['seconds'] * $minSteps + )); + } + + /** + * @param int[] $intervalParts + * @param int[] $diffParts + * + * @return int[] (ordered tuple containing minimum steps and required step iterations + */ + private function computeMinStepAndRequiredIterations(array $intervalParts, array $diffParts) + { + $minSteps = $this->computeMinSteps($intervalParts, $diffParts); + + // If we use PHP_INT_MAX DateInterval::__construct falls over with a bad format error + // before we reach the max on 64 bit machines + $maxInteger = min(pow(2, 31), PHP_INT_MAX); + // check for integer overflow and split $minimum interval if needed + $maximumInterval = max($intervalParts); + $requiredStepIterations = 1; + + if (($minSteps * $maximumInterval) > $maxInteger) { + $requiredStepIterations = ceil(($minSteps * $maximumInterval) / $maxInteger); + $minSteps = floor($minSteps / $requiredStepIterations); + } + + return array($minSteps, $minSteps ? $requiredStepIterations : 0); + } + + /** + * Multiply the step interval by the lower bound of steps to reach the target + * + * @param int[] $intervalParts + * @param int[] $diffParts + * + * @return int + */ + private function computeMinSteps(array $intervalParts, array $diffParts) + { + $intervalMaxSeconds = $this->computeIntervalMaxSeconds($intervalParts); + + return (0 == $intervalMaxSeconds) + ? 0 + : max(floor($this->computeDiffMinSeconds($diffParts) / $intervalMaxSeconds) - 1, 0); + } + + /** + * Get upper bound of the given interval in seconds + * Converts a given `$intervalParts` array into seconds + * + * @param int[] $intervalParts + * + * @return int + */ + private function computeIntervalMaxSeconds(array $intervalParts) + { + return ($intervalParts['years'] * 60 * 60 * 24 * 366) + + ($intervalParts['months'] * 60 * 60 * 24 * 31) + + ($intervalParts['days'] * 60 * 60 * 24) + + ($intervalParts['hours'] * 60 * 60) + + ($intervalParts['minutes'] * 60) + + $intervalParts['seconds']; + } + + /** + * Get lower bound of difference in secondss + * Converts a given `$diffParts` array into seconds + * + * @param int[] $diffParts + * + * @return int + */ + private function computeDiffMinSeconds(array $diffParts) + { + return ($diffParts['years'] * 60 * 60 * 24 * 365) + + ($diffParts['months'] * 60 * 60 * 24 * 28) + + ($diffParts['days'] * 60 * 60 * 24) + + ($diffParts['hours'] * 60 * 60) + + ($diffParts['minutes'] * 60) + + $diffParts['seconds']; + } } diff --git a/library/Zend/Validator/Db/AbstractDb.php b/library/Zend/Validator/Db/AbstractDb.php index 4214910b..9dac8885 100644 --- a/library/Zend/Validator/Db/AbstractDb.php +++ b/library/Zend/Validator/Db/AbstractDb.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Db/NoRecordExists.php b/library/Zend/Validator/Db/NoRecordExists.php index 8a5dd727..e87fdd68 100644 --- a/library/Zend/Validator/Db/NoRecordExists.php +++ b/library/Zend/Validator/Db/NoRecordExists.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Db/RecordExists.php b/library/Zend/Validator/Db/RecordExists.php index dfae6b2d..a7d06d33 100644 --- a/library/Zend/Validator/Db/RecordExists.php +++ b/library/Zend/Validator/Db/RecordExists.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Digits.php b/library/Zend/Validator/Digits.php index a4afe833..94210c91 100644 --- a/library/Zend/Validator/Digits.php +++ b/library/Zend/Validator/Digits.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/EmailAddress.php b/library/Zend/Validator/EmailAddress.php index 1c9d0b00..c1236866 100644 --- a/library/Zend/Validator/EmailAddress.php +++ b/library/Zend/Validator/EmailAddress.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -334,7 +334,7 @@ class EmailAddress extends AbstractValidator // atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*", // "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~" $atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e'; - if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->localPart)) { + if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->idnToAscii($this->localPart))) { $result = true; } else { // Try quoted string format (RFC 5321 Chapter 4.1.2) @@ -373,7 +373,7 @@ class EmailAddress extends AbstractValidator { $mxHosts = array(); $weight = array(); - $result = getmxrr($this->hostname, $mxHosts, $weight); + $result = getmxrr($this->idnToAscii($this->hostname), $mxHosts, $weight); if (!empty($mxHosts) && !empty($weight)) { $this->mxRecord = array_combine($mxHosts, $weight); } else { @@ -457,9 +457,12 @@ class EmailAddress extends AbstractValidator */ protected function splitEmailParts($value) { + $value = is_string($value) ? $value : ''; + // Split email address up and disallow '..' - if ((strpos($value, '..') !== false) or - (!preg_match('/^(.+)@([^@]+)$/', $value, $matches))) { + if (strpos($value, '..') !== false + || ! preg_match('/^(.+)@([^@]+)$/', $value, $matches) + ) { return false; } @@ -488,10 +491,10 @@ class EmailAddress extends AbstractValidator } $length = true; - $this->setValue($value); + $this->setValue($this->idnToUtf8($value)); // Split email address up and disallow '..' - if (!$this->splitEmailParts($value)) { + if (!$this->splitEmailParts($this->getValue())) { $this->error(self::INVALID_FORMAT); return false; } @@ -517,4 +520,30 @@ class EmailAddress extends AbstractValidator return false; } + + /** + * Safely convert UTF-8 encoded domain name to ASCII + * @param string $email the UTF-8 encoded email + * @return string + */ + protected function idnToAscii($email) + { + if (extension_loaded('intl')) { + return (idn_to_ascii($email) ?: $email); + } + return $email; + } + + /** + * Safely convert ASCII encoded domain name to UTF-8 + * @param string $email the ASCII encoded email + * @return string + */ + protected function idnToUtf8($email) + { + if (extension_loaded('intl')) { + return idn_to_utf8($email); + } + return $email; + } } diff --git a/library/Zend/Validator/Exception/BadMethodCallException.php b/library/Zend/Validator/Exception/BadMethodCallException.php index 8293c5ee..a4aa15f4 100644 --- a/library/Zend/Validator/Exception/BadMethodCallException.php +++ b/library/Zend/Validator/Exception/BadMethodCallException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator\Exception; -class BadMethodCallException extends \BadMethodCallException - implements ExceptionInterface +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { } diff --git a/library/Zend/Validator/Exception/ExceptionInterface.php b/library/Zend/Validator/Exception/ExceptionInterface.php index 6fb223fb..7f4f0b1a 100644 --- a/library/Zend/Validator/Exception/ExceptionInterface.php +++ b/library/Zend/Validator/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Exception/ExtensionNotLoadedException.php b/library/Zend/Validator/Exception/ExtensionNotLoadedException.php index 02b2c3c8..4a6b7c03 100644 --- a/library/Zend/Validator/Exception/ExtensionNotLoadedException.php +++ b/library/Zend/Validator/Exception/ExtensionNotLoadedException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Exception/InvalidArgumentException.php b/library/Zend/Validator/Exception/InvalidArgumentException.php index 94f49393..b6518b03 100644 --- a/library/Zend/Validator/Exception/InvalidArgumentException.php +++ b/library/Zend/Validator/Exception/InvalidArgumentException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator\Exception; -class InvalidArgumentException extends \InvalidArgumentException - implements ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/library/Zend/Validator/Exception/InvalidMagicMimeFileException.php b/library/Zend/Validator/Exception/InvalidMagicMimeFileException.php index 41baecc7..4e65bd86 100644 --- a/library/Zend/Validator/Exception/InvalidMagicMimeFileException.php +++ b/library/Zend/Validator/Exception/InvalidMagicMimeFileException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Exception/RuntimeException.php b/library/Zend/Validator/Exception/RuntimeException.php index c52d2cdf..a6319e05 100644 --- a/library/Zend/Validator/Exception/RuntimeException.php +++ b/library/Zend/Validator/Exception/RuntimeException.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator\Exception; -class RuntimeException extends \RuntimeException - implements ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/library/Zend/Validator/Explode.php b/library/Zend/Validator/Explode.php index 9a26f7f4..54177ec2 100644 --- a/library/Zend/Validator/Explode.php +++ b/library/Zend/Validator/Explode.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -159,10 +159,11 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn * Returns true if all values validate true * * @param mixed $value + * @param mixed $context Extra "context" to provide the composed validator * @return bool * @throws Exception\RuntimeException */ - public function isValid($value) + public function isValid($value, $context = null) { $this->setValue($value); @@ -195,7 +196,7 @@ class Explode extends AbstractValidator implements ValidatorPluginManagerAwareIn } foreach ($values as $value) { - if (!$validator->isValid($value)) { + if (!$validator->isValid($value, $context)) { $this->abstractOptions['messages'][] = $validator->getMessages(); if ($this->isBreakOnFirstFailure()) { diff --git a/library/Zend/Validator/File/Count.php b/library/Zend/Validator/File/Count.php index 0bbf6be6..6a6ba376 100644 --- a/library/Zend/Validator/File/Count.php +++ b/library/Zend/Validator/File/Count.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -121,8 +121,9 @@ class Count extends AbstractValidator $min = (int) $min; if (($this->getMax() !== null) && ($min > $this->getMax())) { - throw new Exception\InvalidArgumentException("The minimum must be less than or equal to the maximum file count, but $min >" - . " {$this->getMax()}"); + throw new Exception\InvalidArgumentException( + "The minimum must be less than or equal to the maximum file count, but {$min} > {$this->getMax()}" + ); } $this->options['min'] = $min; @@ -158,8 +159,9 @@ class Count extends AbstractValidator $max = (int) $max; if (($this->getMin() !== null) && ($max < $this->getMin())) { - throw new Exception\InvalidArgumentException("The maximum must be greater than or equal to the minimum file count, but " - . "$max < {$this->getMin()}"); + throw new Exception\InvalidArgumentException( + "The maximum must be greater than or equal to the minimum file count, but {$max} < {$this->getMin()}" + ); } $this->options['max'] = $max; diff --git a/library/Zend/Validator/File/Crc32.php b/library/Zend/Validator/File/Crc32.php index 737521c2..a5f3de87 100644 --- a/library/Zend/Validator/File/Crc32.php +++ b/library/Zend/Validator/File/Crc32.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/ExcludeExtension.php b/library/Zend/Validator/File/ExcludeExtension.php index 0d24b185..e73d25bd 100644 --- a/library/Zend/Validator/File/ExcludeExtension.php +++ b/library/Zend/Validator/File/ExcludeExtension.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/ExcludeMimeType.php b/library/Zend/Validator/File/ExcludeMimeType.php index dedcee9f..f0bd4f8c 100644 --- a/library/Zend/Validator/File/ExcludeMimeType.php +++ b/library/Zend/Validator/File/ExcludeMimeType.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/Exists.php b/library/Zend/Validator/File/Exists.php index c868aefc..f141b824 100644 --- a/library/Zend/Validator/File/Exists.php +++ b/library/Zend/Validator/File/Exists.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/Extension.php b/library/Zend/Validator/File/Extension.php index 2ceeebc7..a779832f 100644 --- a/library/Zend/Validator/File/Extension.php +++ b/library/Zend/Validator/File/Extension.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -13,6 +13,7 @@ use Traversable; use Zend\Stdlib\ArrayUtils; use Zend\Validator\AbstractValidator; use Zend\Validator\Exception; + /** * Validator for the file extension of a file */ diff --git a/library/Zend/Validator/File/FilesSize.php b/library/Zend/Validator/File/FilesSize.php index f2d2afd0..c1ea7644 100644 --- a/library/Zend/Validator/File/FilesSize.php +++ b/library/Zend/Validator/File/FilesSize.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -89,12 +89,24 @@ class FilesSize extends Size { if (is_string($value)) { $value = array($value); + } elseif (is_array($value) && isset($value['tmp_name'])) { + $value = array($value); } $min = $this->getMin(true); $max = $this->getMax(true); $size = $this->getSize(); foreach ($value as $files) { + if (is_array($files)) { + if (!isset($files['tmp_name']) || !isset($files['name'])) { + throw new Exception\InvalidArgumentException( + 'Value array must be in $_FILES format' + ); + } + $file = $files; + $files = $files['tmp_name']; + } + // Is file readable ? if (empty($files) || false === stream_resolve_include_path($files)) { $this->throwError($file, self::NOT_READABLE); diff --git a/library/Zend/Validator/File/Hash.php b/library/Zend/Validator/File/Hash.php index b77b1e19..99b9bca0 100644 --- a/library/Zend/Validator/File/Hash.php +++ b/library/Zend/Validator/File/Hash.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/ImageSize.php b/library/Zend/Validator/File/ImageSize.php index 921abfb1..018e5f90 100644 --- a/library/Zend/Validator/File/ImageSize.php +++ b/library/Zend/Validator/File/ImageSize.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -130,8 +130,10 @@ class ImageSize extends AbstractValidator public function setMinWidth($minWidth) { if (($this->getMaxWidth() !== null) && ($minWidth > $this->getMaxWidth())) { - throw new Exception\InvalidArgumentException("The minimum image width must be less than or equal to the " - . " maximum image width, but {$minWidth} > {$this->getMaxWidth()}"); + throw new Exception\InvalidArgumentException( + "The minimum image width must be less than or equal to the " + . " maximum image width, but {$minWidth} > {$this->getMaxWidth()}" + ); } $this->options['minWidth'] = (int) $minWidth; @@ -158,8 +160,10 @@ class ImageSize extends AbstractValidator public function setMaxWidth($maxWidth) { if (($this->getMinWidth() !== null) && ($maxWidth < $this->getMinWidth())) { - throw new Exception\InvalidArgumentException("The maximum image width must be greater than or equal to the " - . "minimum image width, but {$maxWidth} < {$this->getMinWidth()}"); + throw new Exception\InvalidArgumentException( + "The maximum image width must be greater than or equal to the " + . "minimum image width, but {$maxWidth} < {$this->getMinWidth()}" + ); } $this->options['maxWidth'] = (int) $maxWidth; @@ -186,8 +190,10 @@ class ImageSize extends AbstractValidator public function setMinHeight($minHeight) { if (($this->getMaxHeight() !== null) && ($minHeight > $this->getMaxHeight())) { - throw new Exception\InvalidArgumentException("The minimum image height must be less than or equal to the " - . " maximum image height, but {$minHeight} > {$this->getMaxHeight()}"); + throw new Exception\InvalidArgumentException( + "The minimum image height must be less than or equal to the " + . " maximum image height, but {$minHeight} > {$this->getMaxHeight()}" + ); } $this->options['minHeight'] = (int) $minHeight; @@ -214,8 +220,10 @@ class ImageSize extends AbstractValidator public function setMaxHeight($maxHeight) { if (($this->getMinHeight() !== null) && ($maxHeight < $this->getMinHeight())) { - throw new Exception\InvalidArgumentException("The maximum image height must be greater than or equal to the " - . "minimum image height, but {$maxHeight} < {$this->getMinHeight()}"); + throw new Exception\InvalidArgumentException( + "The maximum image height must be greater than or equal to the " + . "minimum image height, but {$maxHeight} < {$this->getMinHeight()}" + ); } $this->options['maxHeight'] = (int) $maxHeight; diff --git a/library/Zend/Validator/File/IsCompressed.php b/library/Zend/Validator/File/IsCompressed.php index 34bdf669..ebd2e77d 100644 --- a/library/Zend/Validator/File/IsCompressed.php +++ b/library/Zend/Validator/File/IsCompressed.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/IsImage.php b/library/Zend/Validator/File/IsImage.php index 20fa6c80..a13bc043 100644 --- a/library/Zend/Validator/File/IsImage.php +++ b/library/Zend/Validator/File/IsImage.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/Md5.php b/library/Zend/Validator/File/Md5.php index 5d9fc34b..e1d1e973 100644 --- a/library/Zend/Validator/File/Md5.php +++ b/library/Zend/Validator/File/Md5.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/MimeType.php b/library/Zend/Validator/File/MimeType.php index 53fb948d..a91c4dda 100644 --- a/library/Zend/Validator/File/MimeType.php +++ b/library/Zend/Validator/File/MimeType.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/NotExists.php b/library/Zend/Validator/File/NotExists.php index 17aa7da7..e50adef6 100644 --- a/library/Zend/Validator/File/NotExists.php +++ b/library/Zend/Validator/File/NotExists.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/Sha1.php b/library/Zend/Validator/File/Sha1.php index 98413945..7d172da4 100644 --- a/library/Zend/Validator/File/Sha1.php +++ b/library/Zend/Validator/File/Sha1.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/Size.php b/library/Zend/Validator/File/Size.php index 2c00f06e..e709fb5a 100644 --- a/library/Zend/Validator/File/Size.php +++ b/library/Zend/Validator/File/Size.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -149,8 +149,8 @@ class Size extends AbstractValidator $max = $this->getMax(true); if (($max !== null) && ($min > $max)) { throw new Exception\InvalidArgumentException( - 'The minimum must be less than or equal to the maximum file' - ." size, but $min > $max"); + "The minimum must be less than or equal to the maximum file size, but $min > $max" + ); } $this->options['min'] = $min; @@ -194,8 +194,8 @@ class Size extends AbstractValidator $min = $this->getMin(true); if (($min !== null) && ($max < $min)) { throw new Exception\InvalidArgumentException( - 'The maximum must be greater than or equal to the minimum file' - ." size, but $max < $min"); + "The maximum must be greater than or equal to the minimum file size, but $max < $min" + ); } $this->options['max'] = $max; diff --git a/library/Zend/Validator/File/Upload.php b/library/Zend/Validator/File/Upload.php index 748b482e..1524e4ca 100644 --- a/library/Zend/Validator/File/Upload.php +++ b/library/Zend/Validator/File/Upload.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -115,7 +115,7 @@ class Upload extends AbstractValidator $this->options['files'] = $files; } - if ($this->options['files'] === NULL) { + if ($this->options['files'] === null) { $this->options['files'] = array(); } diff --git a/library/Zend/Validator/File/UploadFile.php b/library/Zend/Validator/File/UploadFile.php index 4371c12b..f34958fc 100644 --- a/library/Zend/Validator/File/UploadFile.php +++ b/library/Zend/Validator/File/UploadFile.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/File/WordCount.php b/library/Zend/Validator/File/WordCount.php index f3d58016..460b06a6 100644 --- a/library/Zend/Validator/File/WordCount.php +++ b/library/Zend/Validator/File/WordCount.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -116,8 +116,8 @@ class WordCount extends AbstractValidator $min = (int) $min; if (($this->getMax() !== null) && ($min > $this->getMax())) { throw new Exception\InvalidArgumentException( - "The minimum must be less than or equal to the maximum word count, but $min >" - . " {$this->getMax()}"); + "The minimum must be less than or equal to the maximum word count, but $min > {$this->getMax()}" + ); } $this->options['min'] = $min; @@ -154,8 +154,8 @@ class WordCount extends AbstractValidator $max = (int) $max; if (($this->getMin() !== null) && ($max < $this->getMin())) { throw new Exception\InvalidArgumentException( - "The maximum must be greater than or equal to the minimum word count, but " - . "$max < {$this->getMin()}"); + "The maximum must be greater than or equal to the minimum word count, but $max < {$this->getMin()}" + ); } $this->options['max'] = $max; diff --git a/library/Zend/Validator/GreaterThan.php b/library/Zend/Validator/GreaterThan.php index 6a06ae8d..7f106e8c 100644 --- a/library/Zend/Validator/GreaterThan.php +++ b/library/Zend/Validator/GreaterThan.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Hex.php b/library/Zend/Validator/Hex.php index e7b591c8..64ae8930 100644 --- a/library/Zend/Validator/Hex.php +++ b/library/Zend/Validator/Hex.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Hostname.php b/library/Zend/Validator/Hostname.php index cdc98104..3306fb87 100644 --- a/library/Zend/Validator/Hostname.php +++ b/library/Zend/Validator/Hostname.php @@ -3,13 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator; -use Zend\Stdlib\ErrorHandler; use Zend\Stdlib\StringUtils; /** @@ -74,41 +73,863 @@ class Hostname extends AbstractValidator * @var array */ protected $validTlds = array( - 'ac', 'academy', 'actor', 'ad', 'ae', 'aero', 'af', 'ag', 'agency', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', - 'arpa', 'as', 'asia', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bar', 'bargains', 'bb', 'bd', 'be', 'berlin', 'best', - 'bf', 'bg', 'bh', 'bi', 'bike', 'biz', 'bj', 'bl', 'blue', 'bm', 'bn', 'bo', 'boutique', 'bq', 'br', 'bs', 'bt', - 'build', 'builders', 'buzz', 'bv', 'bw', 'by', 'bz', 'ca', 'cab', 'camera', 'camp', 'cards', 'careers', 'cat', - 'catering', 'cc', 'cd', 'center', 'ceo', 'cf', 'cg', 'ch', 'cheap', 'christmas', 'ci', 'ck', 'cl', 'cleaning', - 'clothing', 'club', 'cm', 'cn', 'co', 'codes', 'coffee', 'com', 'community', 'company', 'computer', - 'construction', 'contractors', 'cool', 'coop', 'cr', 'cruises', 'cu', 'cv', 'cw', 'cx', 'cy', 'cz', 'dance', - 'dating', 'de', 'democrat', 'diamonds', 'directory', 'dj', 'dk', 'dm', 'do', 'domains', 'dz', 'ec', 'edu', - 'education', 'ee', 'eg', 'eh', 'email', 'enterprises', 'equipment', 'er', 'es', 'estate', 'et', 'eu', 'events', - 'expert', 'exposed', 'farm', 'fi', 'fish', 'fj', 'fk', 'flights', 'florist', 'fm', 'fo', 'foundation', 'fr', - 'futbol', 'ga', 'gallery', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gift', 'gl', 'glass', 'gm', 'gn', 'gov', - 'gp', 'gq', 'gr', 'graphics', 'gs', 'gt', 'gu', 'guitars', 'guru', 'gw', 'gy', 'hk', 'hm', 'hn', 'holdings', - 'holiday', 'house', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'immobilien', 'in', 'industries', 'info', - 'institute', 'int', 'international', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jobs', 'jp', 'kaufen', - 'ke', 'kg', 'kh', 'ki', 'kim', 'kitchen', 'kiwi', 'km', 'kn', 'kp', 'kr', 'kred', 'kw', 'ky', 'kz', 'la', - 'land', 'lb', 'lc', 'li', 'lighting', 'limo', 'link', 'lk', 'lr', 'ls', 'lt', 'lu', 'luxury', 'lv', 'ly', 'ma', - 'management', 'mango', 'marketing', 'mc', 'md', 'me', 'menu', 'mf', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm', 'mn', - 'mo', 'mobi', 'moda', 'monash', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv', 'mw', 'mx', 'my', 'mz', - 'na', 'nagoya', 'name', 'nc', 'ne', 'net', 'neustar', 'nf', 'ng', 'ni', 'ninja', 'nl', 'no', 'np', 'nr', 'nu', - 'nz', 'om', 'onl', 'org', 'pa', 'partners', 'parts', 'pe', 'pf', 'pg', 'ph', 'photo', 'photography', 'photos', - 'pics', 'pink', 'pk', 'pl', 'plumbing', 'pm', 'pn', 'post', 'pr', 'pro', 'productions', 'properties', 'ps', - 'pt', 'pub', 'pw', 'py', 'qa', 'qpon', 're', 'recipes', 'red', 'rentals', 'repair', 'report', 'reviews', 'rich', - 'ro', 'rs', 'ru', 'ruhr', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sexy', 'sg', 'sh', 'shiksha', 'shoes', 'si', - 'singles', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'social', 'solar', 'solutions', 'sr', 'ss', 'st', 'su', - 'supplies', 'supply', 'support', 'sv', 'sx', 'sy', 'systems', 'sz', 'tattoo', 'tc', 'td', 'technology', 'tel', - 'tf', 'tg', 'th', 'tienda', 'tips', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'today', 'tokyo', 'tools', 'tp', 'tr', - 'training', 'travel', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'uno', 'us', 'uy', 'uz', 'va', - 'vacations', 'vc', 've', 'ventures', 'vg', 'vi', 'viajes', 'villas', 'vision', 'vn', 'voting', 'voyage', 'vu', - 'wang', 'watch', 'wed', 'wf', 'wien', 'wiki', 'works', 'ws', '测试', 'परीक्षा', '集团', '在线', '한국', 'ভারত', - 'বাংলা', '公益', '公司', '移动', '我爱你', 'испытание', 'қаз', 'онлайн', 'сайт', 'срб', '테스트', '삼성', - 'சிங்கப்பூர்', 'дети', 'טעסט', '中文网', '中信', '中国', '中國', 'భారత్', 'ලංකා', '測試', 'ભારત', 'भारत', - 'آزمایشی', 'பரிட்சை', '网络', 'укр', '香港', 'δοκιμή', 'إختبار', '台湾', '台灣', 'мон', - 'الجزائر', 'عمان', 'ایران', 'امارات', 'بازار', 'پاکستان', 'الاردن', 'بھارت', 'المغرب', 'السعودية', 'سودان', 'مليسيا', 'شبكة', 'გე', - 'ไทย', 'سورية', 'рф', 'تونس', 'みんな', 'ਭਾਰਤ', '游戏', 'مصر', 'قطر', 'இலங்கை', 'இந்தியா', '新加坡', 'فلسطين', - 'テスト', '政务', 'xxx', 'xyz', 'ye', 'yt', 'za', 'zm', 'zone', 'zw' + 'abbott', + 'abogado', + 'ac', + 'academy', + 'accountants', + 'active', + 'actor', + 'ad', + 'adult', + 'ae', + 'aero', + 'af', + 'ag', + 'agency', + 'ai', + 'airforce', + 'al', + 'allfinanz', + 'alsace', + 'am', + 'amsterdam', + 'an', + 'android', + 'ao', + 'apartments', + 'aq', + 'aquarelle', + 'ar', + 'archi', + 'army', + 'arpa', + 'as', + 'asia', + 'associates', + 'at', + 'attorney', + 'au', + 'auction', + 'audio', + 'autos', + 'aw', + 'ax', + 'axa', + 'az', + 'ba', + 'band', + 'bank', + 'bar', + 'barclaycard', + 'barclays', + 'bargains', + 'bayern', + 'bb', + 'bd', + 'be', + 'beer', + 'berlin', + 'best', + 'bf', + 'bg', + 'bh', + 'bi', + 'bid', + 'bike', + 'bingo', + 'bio', + 'biz', + 'bj', + 'black', + 'blackfriday', + 'bloomberg', + 'blue', + 'bm', + 'bmw', + 'bn', + 'bnpparibas', + 'bo', + 'boats', + 'boo', + 'boutique', + 'br', + 'brussels', + 'bs', + 'bt', + 'budapest', + 'build', + 'builders', + 'business', + 'buzz', + 'bv', + 'bw', + 'by', + 'bz', + 'bzh', + 'ca', + 'cab', + 'cal', + 'camera', + 'camp', + 'cancerresearch', + 'canon', + 'capetown', + 'capital', + 'caravan', + 'cards', + 'care', + 'career', + 'careers', + 'cartier', + 'casa', + 'cash', + 'casino', + 'cat', + 'catering', + 'cbn', + 'cc', + 'cd', + 'center', + 'ceo', + 'cern', + 'cf', + 'cfd', + 'cg', + 'ch', + 'channel', + 'chat', + 'cheap', + 'chloe', + 'christmas', + 'chrome', + 'church', + 'ci', + 'citic', + 'city', + 'ck', + 'cl', + 'claims', + 'cleaning', + 'click', + 'clinic', + 'clothing', + 'club', + 'cm', + 'cn', + 'co', + 'coach', + 'codes', + 'coffee', + 'college', + 'cologne', + 'com', + 'community', + 'company', + 'computer', + 'condos', + 'construction', + 'consulting', + 'contractors', + 'cooking', + 'cool', + 'coop', + 'country', + 'courses', + 'cr', + 'credit', + 'creditcard', + 'cricket', + 'crs', + 'cruises', + 'cu', + 'cuisinella', + 'cv', + 'cw', + 'cx', + 'cy', + 'cymru', + 'cz', + 'dabur', + 'dad', + 'dance', + 'dating', + 'datsun', + 'day', + 'dclk', + 'de', + 'deals', + 'degree', + 'delivery', + 'democrat', + 'dental', + 'dentist', + 'desi', + 'design', + 'dev', + 'diamonds', + 'diet', + 'digital', + 'direct', + 'directory', + 'discount', + 'dj', + 'dk', + 'dm', + 'dnp', + 'do', + 'docs', + 'domains', + 'doosan', + 'durban', + 'dvag', + 'dz', + 'eat', + 'ec', + 'edu', + 'education', + 'ee', + 'eg', + 'email', + 'emerck', + 'energy', + 'engineer', + 'engineering', + 'enterprises', + 'epson', + 'equipment', + 'er', + 'erni', + 'es', + 'esq', + 'estate', + 'et', + 'eu', + 'eurovision', + 'eus', + 'events', + 'everbank', + 'exchange', + 'expert', + 'exposed', + 'fail', + 'fan', + 'fans', + 'farm', + 'fashion', + 'feedback', + 'fi', + 'finance', + 'financial', + 'firmdale', + 'fish', + 'fishing', + 'fit', + 'fitness', + 'fj', + 'fk', + 'flights', + 'florist', + 'flowers', + 'flsmidth', + 'fly', + 'fm', + 'fo', + 'foo', + 'football', + 'forex', + 'forsale', + 'foundation', + 'fr', + 'frl', + 'frogans', + 'fund', + 'furniture', + 'futbol', + 'ga', + 'gal', + 'gallery', + 'garden', + 'gb', + 'gbiz', + 'gd', + 'gdn', + 'ge', + 'gent', + 'gf', + 'gg', + 'ggee', + 'gh', + 'gi', + 'gift', + 'gifts', + 'gives', + 'gl', + 'glass', + 'gle', + 'global', + 'globo', + 'gm', + 'gmail', + 'gmo', + 'gmx', + 'gn', + 'goldpoint', + 'goo', + 'goog', + 'google', + 'gop', + 'gov', + 'gp', + 'gq', + 'gr', + 'graphics', + 'gratis', + 'green', + 'gripe', + 'gs', + 'gt', + 'gu', + 'guide', + 'guitars', + 'guru', + 'gw', + 'gy', + 'hamburg', + 'hangout', + 'haus', + 'healthcare', + 'help', + 'here', + 'hermes', + 'hiphop', + 'hiv', + 'hk', + 'hm', + 'hn', + 'holdings', + 'holiday', + 'homes', + 'horse', + 'host', + 'hosting', + 'house', + 'how', + 'hr', + 'ht', + 'hu', + 'ibm', + 'id', + 'ie', + 'ifm', + 'il', + 'im', + 'immo', + 'immobilien', + 'in', + 'industries', + 'infiniti', + 'info', + 'ing', + 'ink', + 'institute', + 'insure', + 'int', + 'international', + 'investments', + 'io', + 'iq', + 'ir', + 'irish', + 'is', + 'it', + 'iwc', + 'java', + 'jcb', + 'je', + 'jetzt', + 'jm', + 'jo', + 'jobs', + 'joburg', + 'jp', + 'juegos', + 'kaufen', + 'kddi', + 'ke', + 'kg', + 'kh', + 'ki', + 'kim', + 'kitchen', + 'kiwi', + 'km', + 'kn', + 'koeln', + 'kp', + 'kr', + 'krd', + 'kred', + 'kw', + 'ky', + 'kyoto', + 'kz', + 'la', + 'lacaixa', + 'land', + 'lat', + 'latrobe', + 'lawyer', + 'lb', + 'lc', + 'lds', + 'lease', + 'leclerc', + 'legal', + 'lgbt', + 'li', + 'lidl', + 'life', + 'lighting', + 'limited', + 'limo', + 'link', + 'lk', + 'loans', + 'london', + 'lotte', + 'lotto', + 'lr', + 'ls', + 'lt', + 'ltda', + 'lu', + 'luxe', + 'luxury', + 'lv', + 'ly', + 'ma', + 'madrid', + 'maif', + 'maison', + 'management', + 'mango', + 'market', + 'marketing', + 'markets', + 'marriott', + 'mc', + 'md', + 'me', + 'media', + 'meet', + 'melbourne', + 'meme', + 'memorial', + 'menu', + 'mg', + 'mh', + 'miami', + 'mil', + 'mini', + 'mk', + 'ml', + 'mm', + 'mn', + 'mo', + 'mobi', + 'moda', + 'moe', + 'monash', + 'money', + 'mormon', + 'mortgage', + 'moscow', + 'motorcycles', + 'mov', + 'mp', + 'mq', + 'mr', + 'ms', + 'mt', + 'mtpc', + 'mu', + 'museum', + 'mv', + 'mw', + 'mx', + 'my', + 'mz', + 'na', + 'nagoya', + 'name', + 'navy', + 'nc', + 'ne', + 'net', + 'network', + 'neustar', + 'new', + 'nexus', + 'nf', + 'ng', + 'ngo', + 'nhk', + 'ni', + 'nico', + 'ninja', + 'nissan', + 'nl', + 'no', + 'np', + 'nr', + 'nra', + 'nrw', + 'ntt', + 'nu', + 'nyc', + 'nz', + 'okinawa', + 'om', + 'one', + 'ong', + 'onl', + 'online', + 'ooo', + 'oracle', + 'org', + 'organic', + 'osaka', + 'otsuka', + 'ovh', + 'pa', + 'page', + 'paris', + 'partners', + 'parts', + 'party', + 'pe', + 'pf', + 'pg', + 'ph', + 'pharmacy', + 'photo', + 'photography', + 'photos', + 'physio', + 'piaget', + 'pics', + 'pictet', + 'pictures', + 'pink', + 'pizza', + 'pk', + 'pl', + 'place', + 'plumbing', + 'pm', + 'pn', + 'pohl', + 'poker', + 'porn', + 'post', + 'pr', + 'praxi', + 'press', + 'pro', + 'prod', + 'productions', + 'prof', + 'properties', + 'property', + 'ps', + 'pt', + 'pub', + 'pw', + 'py', + 'qa', + 'qpon', + 'quebec', + 're', + 'realtor', + 'recipes', + 'red', + 'rehab', + 'reise', + 'reisen', + 'reit', + 'ren', + 'rentals', + 'repair', + 'report', + 'republican', + 'rest', + 'restaurant', + 'reviews', + 'rich', + 'rio', + 'rip', + 'ro', + 'rocks', + 'rodeo', + 'rs', + 'rsvp', + 'ru', + 'ruhr', + 'rw', + 'ryukyu', + 'sa', + 'saarland', + 'sale', + 'samsung', + 'sarl', + 'saxo', + 'sb', + 'sc', + 'sca', + 'scb', + 'schmidt', + 'school', + 'schule', + 'schwarz', + 'science', + 'scot', + 'sd', + 'se', + 'services', + 'sew', + 'sexy', + 'sg', + 'sh', + 'shiksha', + 'shoes', + 'shriram', + 'si', + 'singles', + 'site', + 'sj', + 'sk', + 'sky', + 'sl', + 'sm', + 'sn', + 'so', + 'social', + 'software', + 'sohu', + 'solar', + 'solutions', + 'soy', + 'space', + 'spiegel', + 'spreadbetting', + 'sr', + 'st', + 'study', + 'style', + 'su', + 'sucks', + 'supplies', + 'supply', + 'support', + 'surf', + 'surgery', + 'suzuki', + 'sv', + 'sx', + 'sy', + 'sydney', + 'systems', + 'sz', + 'taipei', + 'tatar', + 'tattoo', + 'tax', + 'tc', + 'td', + 'technology', + 'tel', + 'temasek', + 'tennis', + 'tf', + 'tg', + 'th', + 'tienda', + 'tips', + 'tires', + 'tirol', + 'tj', + 'tk', + 'tl', + 'tm', + 'tn', + 'to', + 'today', + 'tokyo', + 'tools', + 'top', + 'toshiba', + 'town', + 'toys', + 'tr', + 'trade', + 'trading', + 'training', + 'travel', + 'trust', + 'tt', + 'tui', + 'tv', + 'tw', + 'tz', + 'ua', + 'ug', + 'uk', + 'university', + 'uno', + 'uol', + 'us', + 'uy', + 'uz', + 'va', + 'vacations', + 'vc', + 've', + 'vegas', + 'ventures', + 'versicherung', + 'vet', + 'vg', + 'vi', + 'viajes', + 'video', + 'villas', + 'vision', + 'vlaanderen', + 'vn', + 'vodka', + 'vote', + 'voting', + 'voto', + 'voyage', + 'vu', + 'wales', + 'wang', + 'watch', + 'webcam', + 'website', + 'wed', + 'wedding', + 'wf', + 'whoswho', + 'wien', + 'wiki', + 'williamhill', + 'wme', + 'work', + 'works', + 'world', + 'ws', + 'wtc', + 'wtf', + 'xin', + '佛山', + '集团', + '在线', + '한국', + 'ভারত', + '八卦', + 'موقع', + '公益', + '公司', + '移动', + '我爱你', + 'москва', + 'қаз', + 'онлайн', + 'сайт', + 'срб', + 'бел', + '淡马锡', + 'орг', + '삼성', + 'சிங்கப்பூர்', + '商标', + '商店', + '商城', + 'дети', + 'мкд', + '中文网', + '中信', + '中国', + '中國', + '谷歌', + 'భారత్', + 'ලංකා', + 'ભારત', + 'भारत', + '网店', + 'संगठन', + '网络', + 'укр', + '香港', + '台湾', + '台灣', + '手机', + 'мон', + 'الجزائر', + 'عمان', + 'ایران', + 'امارات', + 'بازار', + 'الاردن', + 'بھارت', + 'المغرب', + 'السعودية', + 'مليسيا', + '政府', + 'شبكة', + 'გე', + '机构', + '组织机构', + 'ไทย', + 'سورية', + 'рус', + 'рф', + 'تونس', + 'みんな', + 'グーグル', + '世界', + 'ਭਾਰਤ', + '网址', + '游戏', + 'vermögensberater', + 'vermögensberatung', + '企业', + 'مصر', + 'قطر', + '广东', + 'இலங்கை', + 'இந்தியா', + '新加坡', + 'فلسطين', + '政务', + 'xxx', + 'xyz', + 'yachts', + 'yandex', + 'ye', + 'yodobashi', + 'yoga', + 'yokohama', + 'youtube', + 'yt', + 'za', + 'zip', + 'zm', + 'zone', + 'zuerich', + 'zw', ); /** @@ -127,6 +948,7 @@ class Hostname extends AbstractValidator * (.COM) International http://www.verisign.com/information-services/naming-services/internationalized-domain-names/index.html * (.DE) Germany http://www.denic.de/en/domains/idns/liste.html * (.DK) Danmark http://www.dk-hostmaster.dk/index.php?id=151 + * (.EE) Estonia https://www.iana.org/domains/idn-tables/tables/pl_et-pl_1.0.html * (.ES) Spain https://www.nic.es/media/2008-05/1210147705287.pdf * (.FI) Finland http://www.ficora.fi/en/index/palvelut/fiverkkotunnukset/aakkostenkaytto.html * (.GR) Greece https://grweb.ics.forth.gr/CharacterTable1_en.jsp @@ -178,6 +1000,7 @@ class Hostname extends AbstractValidator 'COM' => 'Hostname/Com.php', 'DE' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťţŧŭůűũųūŵŷźžż]{1,63}$/iu'), 'DK' => array(1 => '/^[\x{002d}0-9a-zäéöü]{1,63}$/iu'), + 'EE' => array(1 => '/^[\x{002d}0-9a-zäõöüšž]{1,63}$/iu'), 'ES' => array(1 => '/^[\x{002d}0-9a-zàáçèéíïñòóúü·]{1,63}$/iu'), 'EU' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿ]{1,63}$/iu', 2 => '/^[\x{002d}0-9a-zāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĺļľŀłńņňʼnŋōŏőœŕŗřśŝšťŧũūŭůűųŵŷźżž]{1,63}$/iu', @@ -478,15 +1301,15 @@ class Hostname extends AbstractValidator $this->setValue($value); // Check input against IP address schema - if (preg_match('/^[0-9a-f:.]*$/i', $value) && $this->getIpValidator() - ->setTranslator($this->getTranslator()) - ->isValid($value)) { + if (preg_match('/^[0-9a-f:.]*$/i', $value) + && $this->getIpValidator()->setTranslator($this->getTranslator())->isValid($value) + ) { if (!($this->getAllow() & self::ALLOW_IP)) { $this->error(self::IP_ADDRESS_NOT_ALLOWED); return false; - } else { - return true; } + + return true; } // Local hostnames are allowed to be partial (ending '.') @@ -504,18 +1327,18 @@ class Hostname extends AbstractValidator $domainParts = explode('.', $value); // Prevent partial IP V4 addresses (ending '.') - if ((count($domainParts) == 4) && preg_match('/^[0-9.a-e:.]*$/i', $value) && $this->getIpValidator() - ->setTranslator($this->getTranslator()) - ->isValid($value)) { + if (count($domainParts) == 4 && preg_match('/^[0-9.a-e:.]*$/i', $value) + && $this->getIpValidator()->setTranslator($this->getTranslator())->isValid($value) + ) { $this->error(self::INVALID_LOCAL_NAME); } $utf8StrWrapper = StringUtils::getWrapper('UTF-8'); // Check input against DNS hostname schema - if ((count($domainParts) > 1) - && ($utf8StrWrapper->strlen($value) >= 4) - && ($utf8StrWrapper->strlen($value) <= 254) + if (count($domainParts) > 1 + && $utf8StrWrapper->strlen($value) >= 4 + && $utf8StrWrapper->strlen($value) <= 254 ) { $status = false; @@ -523,7 +1346,8 @@ class Hostname extends AbstractValidator // First check TLD $matches = array(); if (preg_match('/([^.]{2,63})$/iu', end($domainParts), $matches) - || (array_key_exists(end($domainParts), $this->validIdns))) { + || (array_key_exists(end($domainParts), $this->validIdns)) + ) { reset($domainParts); // Hostname characters are: *(label dot)(label dot label); max 254 chars @@ -572,9 +1396,13 @@ class Hostname extends AbstractValidator } // Check dash (-) does not start, end or appear in 3rd and 4th positions - if (($utf8StrWrapper->strpos($domainPart, '-') === 0) - || (($utf8StrWrapper->strlen($domainPart) > 2) && ($utf8StrWrapper->strpos($domainPart, '-', 2) == 2) && ($utf8StrWrapper->strpos($domainPart, '-', 3) == 3)) - || ($utf8StrWrapper->strpos($domainPart, '-') === ($utf8StrWrapper->strlen($domainPart) - 1))) { + if ($utf8StrWrapper->strpos($domainPart, '-') === 0 + || ($utf8StrWrapper->strlen($domainPart) > 2 + && $utf8StrWrapper->strpos($domainPart, '-', 2) == 2 + && $utf8StrWrapper->strpos($domainPart, '-', 3) == 3 + ) + || ($utf8StrWrapper->strpos($domainPart, '-') === ($utf8StrWrapper->strlen($domainPart) - 1)) + ) { $this->error(self::INVALID_DASH); $status = false; break 2; @@ -583,13 +1411,12 @@ class Hostname extends AbstractValidator // Check each domain part $checked = false; foreach ($regexChars as $regexKey => $regexChar) { - ErrorHandler::start(); $status = preg_match($regexChar, $domainPart); - ErrorHandler::stop(); if ($status > 0) { $length = 63; if (array_key_exists($this->tld, $this->idnLength) - && (array_key_exists($regexKey, $this->idnLength[$this->tld]))) { + && array_key_exists($regexKey, $this->idnLength[$this->tld]) + ) { $length = $this->idnLength[$this->tld]; } @@ -627,23 +1454,20 @@ class Hostname extends AbstractValidator } } elseif ($this->getAllow() & self::ALLOW_DNS) { $this->error(self::INVALID_HOSTNAME); - $status = false; } // Check for URI Syntax (RFC3986) if ($this->getAllow() & self::ALLOW_URI) { if (preg_match("/^([a-zA-Z0-9-._~!$&\'()*+,;=]|%[[:xdigit:]]{2}){1,254}$/i", $value)) { return true; - } else { - $this->error(self::INVALID_URI); } + + $this->error(self::INVALID_URI); } // Check input against local network name schema; last chance to pass validation - ErrorHandler::start(); $regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}[\x2e]{0,1}){1,254}$/'; $status = preg_match($regexLocal, $value); - ErrorHandler::stop(); // If the input passes as a local network name, and local network names are allowed, then the // hostname passes validation diff --git a/library/Zend/Validator/Hostname/Biz.php b/library/Zend/Validator/Hostname/Biz.php index cadf8e3f..fd755c74 100644 --- a/library/Zend/Validator/Hostname/Biz.php +++ b/library/Zend/Validator/Hostname/Biz.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Hostname/Cn.php b/library/Zend/Validator/Hostname/Cn.php index 2a641855..64f6af61 100644 --- a/library/Zend/Validator/Hostname/Cn.php +++ b/library/Zend/Validator/Hostname/Cn.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Hostname/Com.php b/library/Zend/Validator/Hostname/Com.php index a86e806c..93f3834b 100644 --- a/library/Zend/Validator/Hostname/Com.php +++ b/library/Zend/Validator/Hostname/Com.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -169,8 +169,6 @@ return array( 68 => '/^[\x{A000}-\x{A48F}]{1,63}$/iu', 69 => '/^[\x{A490}-\x{A4CF}]{1,63}$/iu', 70 => '/^[\x{AC00}-\x{D7AF}]{1,63}$/iu', - 71 => '/^[\x{D800}-\x{DB7F}]{1,63}$/iu', - 72 => '/^[\x{DC00}-\x{DFFF}]{1,63}$/iu', 73 => '/^[\x{F900}-\x{FAFF}]{1,63}$/iu', 74 => '/^[\x{FB00}-\x{FB4F}]{1,63}$/iu', 75 => '/^[\x{FB50}-\x{FDFF}]{1,63}$/iu', diff --git a/library/Zend/Validator/Hostname/Jp.php b/library/Zend/Validator/Hostname/Jp.php index f1cf75fb..e0d871e5 100644 --- a/library/Zend/Validator/Hostname/Jp.php +++ b/library/Zend/Validator/Hostname/Jp.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Iban.php b/library/Zend/Validator/Iban.php index 6a96f74c..f6d542a1 100644 --- a/library/Zend/Validator/Iban.php +++ b/library/Zend/Validator/Iban.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Identical.php b/library/Zend/Validator/Identical.php index 25927163..ca0efb87 100644 --- a/library/Zend/Validator/Identical.php +++ b/library/Zend/Validator/Identical.php @@ -3,12 +3,13 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator; +use ArrayAccess; use Traversable; use Zend\Stdlib\ArrayUtils; @@ -146,17 +147,25 @@ class Identical extends AbstractValidator * matches that token. * * @param mixed $value - * @param array $context + * @param array|ArrayAccess $context + * @throws Exception\InvalidArgumentException If context is not array or ArrayObject * @return bool - * @throws Exception\RuntimeException if the token doesn't exist in the context array */ - public function isValid($value, array $context = null) + public function isValid($value, $context = null) { $this->setValue($value); $token = $this->getToken(); if (!$this->getLiteral() && $context !== null) { + if (!is_array($context) && !($context instanceof ArrayAccess)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Context passed to %s must be array, ArrayObject or null; received "%s"', + __METHOD__, + is_object($context) ? get_class($context) : gettype($context) + )); + } + if (is_array($token)) { while (is_array($token)) { $key = key($token); diff --git a/library/Zend/Validator/InArray.php b/library/Zend/Validator/InArray.php index 2460151b..be271ea0 100644 --- a/library/Zend/Validator/InArray.php +++ b/library/Zend/Validator/InArray.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,6 @@ class InArray extends AbstractValidator */ const COMPARE_NOT_STRICT = -1; - /** * @var array */ @@ -111,7 +110,7 @@ class InArray extends AbstractValidator /** * Sets the strict option mode - * InArray::CHECK_STRICT | InArray::CHECK_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY | InArray::CHECK_NOT_STRICT + * InArray::COMPARE_STRICT | InArray::COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY | InArray::COMPARE_NOT_STRICT * * @param int $strict * @return InArray Provides a fluent interface @@ -218,7 +217,7 @@ class InArray extends AbstractValidator } } - if (in_array($value, $haystack, $this->strict == self::COMPARE_STRICT ? true : false)) { + if (in_array($value, $haystack, self::COMPARE_STRICT == $this->strict)) { return true; } } diff --git a/library/Zend/Validator/Ip.php b/library/Zend/Validator/Ip.php index 9253a818..aac20828 100644 --- a/library/Zend/Validator/Ip.php +++ b/library/Zend/Validator/Ip.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/IsInstanceOf.php b/library/Zend/Validator/IsInstanceOf.php index 89219e50..d45fabda 100644 --- a/library/Zend/Validator/IsInstanceOf.php +++ b/library/Zend/Validator/IsInstanceOf.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator; diff --git a/library/Zend/Validator/Isbn.php b/library/Zend/Validator/Isbn.php index 96615375..00f7324b 100644 --- a/library/Zend/Validator/Isbn.php +++ b/library/Zend/Validator/Isbn.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -80,7 +80,7 @@ class Isbn extends AbstractValidator } } - return null; + return; } /** diff --git a/library/Zend/Validator/LessThan.php b/library/Zend/Validator/LessThan.php index 7925fd8e..0dbaee1a 100644 --- a/library/Zend/Validator/LessThan.php +++ b/library/Zend/Validator/LessThan.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/NotEmpty.php b/library/Zend/Validator/NotEmpty.php index 52a23f59..098af298 100644 --- a/library/Zend/Validator/NotEmpty.php +++ b/library/Zend/Validator/NotEmpty.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -58,7 +58,6 @@ class NotEmpty extends AbstractValidator self::NULL, self::EMPTY_ARRAY, self::STRING, - self::FLOAT, self::BOOLEAN ); diff --git a/library/Zend/Validator/Regex.php b/library/Zend/Validator/Regex.php index 0f484fff..b8dfb2fa 100644 --- a/library/Zend/Validator/Regex.php +++ b/library/Zend/Validator/Regex.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -98,7 +98,11 @@ class Regex extends AbstractValidator $error = ErrorHandler::stop(); if (false === $status) { - throw new Exception\InvalidArgumentException("Internal error parsing the pattern '{$this->pattern}'", 0, $error); + throw new Exception\InvalidArgumentException( + "Internal error parsing the pattern '{$this->pattern}'", + 0, + $error + ); } return $this; diff --git a/library/Zend/Validator/Sitemap/Changefreq.php b/library/Zend/Validator/Sitemap/Changefreq.php index a959b023..090d8042 100644 --- a/library/Zend/Validator/Sitemap/Changefreq.php +++ b/library/Zend/Validator/Sitemap/Changefreq.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Sitemap/Lastmod.php b/library/Zend/Validator/Sitemap/Lastmod.php index ace679fd..49293ab7 100644 --- a/library/Zend/Validator/Sitemap/Lastmod.php +++ b/library/Zend/Validator/Sitemap/Lastmod.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Sitemap/Loc.php b/library/Zend/Validator/Sitemap/Loc.php index 481b286e..54919178 100644 --- a/library/Zend/Validator/Sitemap/Loc.php +++ b/library/Zend/Validator/Sitemap/Loc.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Sitemap/Priority.php b/library/Zend/Validator/Sitemap/Priority.php index d5313f37..ea536934 100644 --- a/library/Zend/Validator/Sitemap/Priority.php +++ b/library/Zend/Validator/Sitemap/Priority.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/StaticValidator.php b/library/Zend/Validator/StaticValidator.php index 84eca563..dea88364 100644 --- a/library/Zend/Validator/StaticValidator.php +++ b/library/Zend/Validator/StaticValidator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Step.php b/library/Zend/Validator/Step.php index 8b82bfd4..b9e9e1ad 100644 --- a/library/Zend/Validator/Step.php +++ b/library/Zend/Validator/Step.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -146,7 +146,9 @@ class Step extends AbstractValidator } //find the maximum precision from both input params to give accurate results - $precision = strlen(substr($x, strpos($x, '.')+1)) + strlen(substr($y, strpos($y, '.')+1)); + $xFloatSegment = substr($x, strpos($x, '.') + 1) ?: ''; + $yFloatSegment = substr($y, strpos($y, '.') + 1) ?: ''; + $precision = strlen($xFloatSegment) + strlen($yFloatSegment); return round($x - $y * floor($x / $y), $precision); } diff --git a/library/Zend/Validator/StringLength.php b/library/Zend/Validator/StringLength.php index 53a162c6..b07a6c31 100644 --- a/library/Zend/Validator/StringLength.php +++ b/library/Zend/Validator/StringLength.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -87,8 +87,9 @@ class StringLength extends AbstractValidator public function setMin($min) { if (null !== $this->getMax() && $min > $this->getMax()) { - throw new Exception\InvalidArgumentException("The minimum must be less than or equal to the maximum length, but $min >" - . " " . $this->getMax()); + throw new Exception\InvalidArgumentException( + "The minimum must be less than or equal to the maximum length, but {$min} > {$this->getMax()}" + ); } $this->options['min'] = max(0, (int) $min); @@ -117,8 +118,9 @@ class StringLength extends AbstractValidator if (null === $max) { $this->options['max'] = null; } elseif ($max < $this->getMin()) { - throw new Exception\InvalidArgumentException("The maximum must be greater than or equal to the minimum length, but " - . "$max < " . $this->getMin()); + throw new Exception\InvalidArgumentException( + "The maximum must be greater than or equal to the minimum length, but {$max} < {$this->getMin()}" + ); } else { $this->options['max'] = (int) $max; } diff --git a/library/Zend/Validator/Timezone.php b/library/Zend/Validator/Timezone.php new file mode 100644 index 00000000..dd1ab7eb --- /dev/null +++ b/library/Zend/Validator/Timezone.php @@ -0,0 +1,174 @@ + 'location', + self::ABBREVIATION => 'abbreviation', + ); + + /** + * Default value for types; value = 3 + * + * @var array + */ + protected $defaultType = array( + self::LOCATION, + self::ABBREVIATION, + ); + + /** + * @var array + */ + protected $messageTemplates = array( + self::INVALID => 'Invalid timezone given.', + self::INVALID_TIMEZONE_LOCATION => 'Invalid timezone location given.', + self::INVALID_TIMEZONE_ABBREVIATION => 'Invalid timezone abbreviation given.', + ); + + /** + * Options for this validator + * + * @var array + */ + protected $options = array(); + + /** + * Constructor + * + * @param array|int $options OPTIONAL + */ + public function __construct($options = array()) + { + $opts['type'] = $this->defaultType; + + if (is_array($options)) { + if (array_key_exists('type', $options)) { + $opts['type'] = $options['type']; + } + } elseif (! empty($options)) { + $opts['type'] = $options; + } + + // setType called by parent constructor then setOptions method + parent::__construct($opts); + } + + /** + * Set the types + * + * @param int|array $type + * + * @throws Exception\InvalidArgumentException + */ + public function setType($type = null) + { + $type = $this->calculateTypeValue($type); + + if (!is_int($type) || ($type < 1) || ($type > self::ALL)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Unknown type "%s" provided', + (is_string($type) || is_int($type)) + ? $type + : (is_object($type) ? get_class($type) : gettype($type)) + )); + } + + $this->options['type'] = $type; + } + + /** + * Returns true if timezone location or timezone abbreviations is correct. + * + * @param mixed $value + * @return bool + */ + public function isValid($value) + { + if ($value !== null && !is_string($value)) { + $this->error(self::INVALID); + return false; + } + + $type = $this->options['type']; + $this->setValue($value); + + switch (true) { + // Check in locations and abbreviations + case (($type & self::LOCATION) && ($type & self::ABBREVIATION)): + $abbrs = DateTimeZone::listAbbreviations(); + $locations = DateTimeZone::listIdentifiers(); + + if (!array_key_exists($value, $abbrs) && !in_array($value, $locations)) { + $this->error(self::INVALID); + return false; + } + break; + + // Check only in locations + case ($type & self::LOCATION): + $locations = DateTimeZone::listIdentifiers(); + + if (!in_array($value, $locations)) { + $this->error(self::INVALID_TIMEZONE_LOCATION); + return false; + } + break; + + // Check only in abbreviations + case ($type & self::ABBREVIATION): + $abbrs = DateTimeZone::listAbbreviations(); + + if (!array_key_exists($value, $abbrs)) { + $this->error(self::INVALID_TIMEZONE_ABBREVIATION); + return false; + } + break; + } + + return true; + } + + /** + * @param array|int|string $type + * + * @return int + */ + protected function calculateTypeValue($type) + { + $types = (array) $type; + $detected = 0; + + foreach ($types as $value) { + if (is_int($value)) { + $detected |= $value; + } elseif (false !== ($position = array_search($value, $this->constants))) { + $detected |= array_search($value, $this->constants); + } + } + + return $detected; + } +} diff --git a/library/Zend/Validator/Translator/TranslatorAwareInterface.php b/library/Zend/Validator/Translator/TranslatorAwareInterface.php index a9fb45d3..fd0af1fd 100644 --- a/library/Zend/Validator/Translator/TranslatorAwareInterface.php +++ b/library/Zend/Validator/Translator/TranslatorAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) *; * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Translator/TranslatorInterface.php b/library/Zend/Validator/Translator/TranslatorInterface.php index 01981d37..3439e91a 100644 --- a/library/Zend/Validator/Translator/TranslatorInterface.php +++ b/library/Zend/Validator/Translator/TranslatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/Uri.php b/library/Zend/Validator/Uri.php index 6bd3e7c9..a6e5eab2 100644 --- a/library/Zend/Validator/Uri.php +++ b/library/Zend/Validator/Uri.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/ValidatorChain.php b/library/Zend/Validator/ValidatorChain.php index 0ff337cb..604afbfb 100644 --- a/library/Zend/Validator/ValidatorChain.php +++ b/library/Zend/Validator/ValidatorChain.php @@ -3,18 +3,24 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @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\Validator; use Countable; +use Zend\Stdlib\PriorityQueue; class ValidatorChain implements Countable, ValidatorInterface { + /** + * Default priority at which validators are added + */ + const DEFAULT_PRIORITY = 1; + /** * @var ValidatorPluginManager */ @@ -23,9 +29,9 @@ class ValidatorChain implements /** * Validator chain * - * @var array + * @var PriorityQueue */ - protected $validators = array(); + protected $validators; /** * Array of validation failure messages @@ -34,6 +40,14 @@ class ValidatorChain implements */ protected $messages = array(); + /** + * Initialize validator chain + */ + public function __construct() + { + $this->validators = new PriorityQueue(); + } + /** * Return the count of attached validators * @@ -88,16 +102,28 @@ class ValidatorChain implements * If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain, * if one exists, will not be executed. * - * @param ValidatorInterface $validator - * @param bool $breakChainOnFailure - * @return ValidatorChain Provides a fluent interface + * @param ValidatorInterface $validator + * @param bool $breakChainOnFailure + * @param int $priority Priority at which to enqueue validator; defaults to + * 1 (higher executes earlier) + * + * @throws Exception\InvalidArgumentException + * + * @return self */ - public function attach(ValidatorInterface $validator, $breakChainOnFailure = false) - { - $this->validators[] = array( - 'instance' => $validator, - 'breakChainOnFailure' => (bool) $breakChainOnFailure, + public function attach( + ValidatorInterface $validator, + $breakChainOnFailure = false, + $priority = self::DEFAULT_PRIORITY + ) { + $this->validators->insert( + array( + 'instance' => $validator, + 'breakChainOnFailure' => (bool) $breakChainOnFailure, + ), + $priority ); + return $this; } @@ -107,11 +133,12 @@ class ValidatorChain implements * @deprecated Please use attach() * @param ValidatorInterface $validator * @param bool $breakChainOnFailure + * @param int $priority * @return ValidatorChain Provides a fluent interface */ - public function addValidator(ValidatorInterface $validator, $breakChainOnFailure = false) + public function addValidator(ValidatorInterface $validator, $breakChainOnFailure = false, $priority = self::DEFAULT_PRIORITY) { - return $this->attach($validator, $breakChainOnFailure); + return $this->attach($validator, $breakChainOnFailure, $priority); } /** @@ -126,12 +153,21 @@ class ValidatorChain implements */ public function prependValidator(ValidatorInterface $validator, $breakChainOnFailure = false) { - array_unshift( - $this->validators, + $priority = self::DEFAULT_PRIORITY; + + if (!$this->validators->isEmpty()) { + $queue = $this->validators->getIterator(); + $queue->setExtractFlags(PriorityQueue::EXTR_PRIORITY); + $extractedNode = $queue->extract(); + $priority = $extractedNode[0] + 1; + } + + $this->validators->insert( array( - 'instance' => $validator, - 'breakChainOnFailure' => (bool) $breakChainOnFailure, - ) + 'instance' => $validator, + 'breakChainOnFailure' => (bool) $breakChainOnFailure, + ), + $priority ); return $this; } @@ -140,11 +176,12 @@ class ValidatorChain implements * Use the plugin manager to add a validator by name * * @param string $name - * @param array $options - * @param bool $breakChainOnFailure + * @param array $options + * @param bool $breakChainOnFailure + * @param int $priority * @return ValidatorChain */ - public function attachByName($name, $options = array(), $breakChainOnFailure = false) + public function attachByName($name, $options = array(), $breakChainOnFailure = false, $priority = self::DEFAULT_PRIORITY) { if (isset($options['break_chain_on_failure'])) { $breakChainOnFailure = (bool) $options['break_chain_on_failure']; @@ -154,8 +191,8 @@ class ValidatorChain implements $breakChainOnFailure = (bool) $options['breakchainonfailure']; } - $validator = $this->plugin($name, $options); - $this->attach($validator, $breakChainOnFailure); + $this->attach($this->plugin($name, $options), $breakChainOnFailure, $priority); + return $this; } @@ -224,8 +261,8 @@ class ValidatorChain implements */ public function merge(ValidatorChain $validatorChain) { - foreach ($validatorChain->validators as $validator) { - $this->validators[] = $validator; + foreach ($validatorChain->validators->toArray(PriorityQueue::EXTR_BOTH) as $item) { + $this->attach($item['data']['instance'], $item['data']['breakChainOnFailure'], $item['priority']); } return $this; @@ -244,11 +281,11 @@ class ValidatorChain implements /** * Get all the validators * - * @return array + * @return PriorityQueue */ public function getValidators() { - return $this->validators; + return $this->validators->toArray(PriorityQueue::EXTR_DATA); } /** @@ -262,6 +299,14 @@ class ValidatorChain implements return $this->isValid($value); } + /** + * Deep clone handling + */ + public function __clone() + { + $this->validators = clone $this->validators; + } + /** * Prepare validator chain for serialization * diff --git a/library/Zend/Validator/ValidatorInterface.php b/library/Zend/Validator/ValidatorInterface.php index d48aa158..6424ef7a 100644 --- a/library/Zend/Validator/ValidatorInterface.php +++ b/library/Zend/Validator/ValidatorInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/ValidatorPluginManager.php b/library/Zend/Validator/ValidatorPluginManager.php index d2b62a4e..4a7c21b0 100644 --- a/library/Zend/Validator/ValidatorPluginManager.php +++ b/library/Zend/Validator/ValidatorPluginManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -14,6 +14,16 @@ use Zend\ServiceManager\ConfigInterface; class ValidatorPluginManager extends AbstractPluginManager { + /** + * Default aliases + * + * @var array + */ + protected $aliases = array( + 'Zend\I18n\Validator\Float'=> 'Zend\I18n\Validator\IsFloat', + 'Zend\I18n\Validator\Int' => 'Zend\I18n\Validator\IsInt', + ); + /** * Default set of validators * @@ -82,17 +92,19 @@ class ValidatorPluginManager extends AbstractPluginManager 'fileupload' => 'Zend\Validator\File\Upload', 'fileuploadfile' => 'Zend\Validator\File\UploadFile', 'filewordcount' => 'Zend\Validator\File\WordCount', - 'float' => 'Zend\I18n\Validator\Float', + 'float' => 'Zend\I18n\Validator\IsFloat', 'greaterthan' => 'Zend\Validator\GreaterThan', 'hex' => 'Zend\Validator\Hex', 'hostname' => 'Zend\Validator\Hostname', 'iban' => 'Zend\Validator\Iban', 'identical' => 'Zend\Validator\Identical', 'inarray' => 'Zend\Validator\InArray', - 'int' => 'Zend\I18n\Validator\Int', + 'int' => 'Zend\I18n\Validator\IsInt', 'ip' => 'Zend\Validator\Ip', 'isbn' => 'Zend\Validator\Isbn', + 'isfloat' => 'Zend\I18n\Validator\IsFloat', 'isinstanceof' => 'Zend\Validator\IsInstanceOf', + 'isint' => 'Zend\I18n\Validator\IsInt', 'lessthan' => 'Zend\Validator\LessThan', 'notempty' => 'Zend\Validator\NotEmpty', 'phonenumber' => 'Zend\I18n\Validator\PhoneNumber', @@ -104,6 +116,7 @@ class ValidatorPluginManager extends AbstractPluginManager 'sitemappriority' => 'Zend\Validator\Sitemap\Priority', 'stringlength' => 'Zend\Validator\StringLength', 'step' => 'Zend\Validator\Step', + 'timezone' => 'Zend\Validator\Timezone', 'uri' => 'Zend\Validator\Uri', ); diff --git a/library/Zend/Validator/ValidatorPluginManagerAwareInterface.php b/library/Zend/Validator/ValidatorPluginManagerAwareInterface.php index 4d9c8d09..b5436b82 100644 --- a/library/Zend/Validator/ValidatorPluginManagerAwareInterface.php +++ b/library/Zend/Validator/ValidatorPluginManagerAwareInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/Validator/composer.json b/library/Zend/Validator/composer.json index 2e99da13..9709c7b0 100644 --- a/library/Zend/Validator/composer.json +++ b/library/Zend/Validator/composer.json @@ -8,23 +8,23 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Validator\\": "" } }, - "target-dir": "Zend/Validator", "require": { "php": ">=5.3.23", - "zendframework/zend-stdlib": "self.version" + "zendframework/zend-stdlib": "~2.4.0" }, "require-dev": { - "zendframework/zend-db": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-i18n": "self.version", - "zendframework/zend-math": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-session": "self.version", - "zendframework/zend-uri": "self.version" + "zendframework/zend-config": "~2.4.0", + "zendframework/zend-db": "~2.4.0", + "zendframework/zend-filter": "~2.4.0", + "zendframework/zend-i18n": "~2.4.0", + "zendframework/zend-math": "~2.4.0", + "zendframework/zend-servicemanager": "~2.4.0", + "zendframework/zend-session": "~2.4.0", + "zendframework/zend-uri": "~2.4.0" }, "suggest": { "zendframework/zend-db": "Zend\\Db component", @@ -38,8 +38,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/Version/Version.php b/library/Zend/Version/Version.php index d66926b1..6158a9c6 100644 --- a/library/Zend/Version/Version.php +++ b/library/Zend/Version/Version.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -20,7 +20,7 @@ final class Version /** * Zend Framework version identification - see compareVersion() */ - const VERSION = '2.3.4dev'; + const VERSION = '2.4.13'; /** * Github Service Identifier for version information is retrieved from diff --git a/library/Zend/Version/composer.json b/library/Zend/Version/composer.json index b3fd61e6..04d8fc51 100644 --- a/library/Zend/Version/composer.json +++ b/library/Zend/Version/composer.json @@ -8,25 +8,22 @@ ], "homepage": "https://github.com/zendframework/zf2", "autoload": { - "psr-0": { + "psr-4": { "Zend\\Version\\": "" } }, - "target-dir": "Zend/Version", "require": { "php": ">=5.3.23", "zendframework/zend-json": "self.version" }, "suggest": { - "zendframework/zend-http": "Allows use of Zend\\Http\\Client to check version information" - }, - "suggest": { + "zendframework/zend-http": "Allows use of Zend\\Http\\Client to check version information", "zendframework/zend-json": "To check latest version hosted in GitHub" }, "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } } } diff --git a/library/Zend/View/Exception/BadMethodCallException.php b/library/Zend/View/Exception/BadMethodCallException.php index 2c52e7c1..8d3e7b1e 100644 --- a/library/Zend/View/Exception/BadMethodCallException.php +++ b/library/Zend/View/Exception/BadMethodCallException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Exception/DomainException.php b/library/Zend/View/Exception/DomainException.php index fd23205b..b485db61 100644 --- a/library/Zend/View/Exception/DomainException.php +++ b/library/Zend/View/Exception/DomainException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Exception/ExceptionInterface.php b/library/Zend/View/Exception/ExceptionInterface.php index 6ddee6fe..469e0f48 100644 --- a/library/Zend/View/Exception/ExceptionInterface.php +++ b/library/Zend/View/Exception/ExceptionInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Exception/InvalidArgumentException.php b/library/Zend/View/Exception/InvalidArgumentException.php index 2204ae4a..dd4dbe2b 100644 --- a/library/Zend/View/Exception/InvalidArgumentException.php +++ b/library/Zend/View/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Exception/InvalidHelperException.php b/library/Zend/View/Exception/InvalidHelperException.php index 01c98910..49b39232 100644 --- a/library/Zend/View/Exception/InvalidHelperException.php +++ b/library/Zend/View/Exception/InvalidHelperException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Exception/RuntimeException.php b/library/Zend/View/Exception/RuntimeException.php index 579aa45a..efb80bcb 100644 --- a/library/Zend/View/Exception/RuntimeException.php +++ b/library/Zend/View/Exception/RuntimeException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Exception/UnexpectedValueException.php b/library/Zend/View/Exception/UnexpectedValueException.php index 95761b5c..b6d04736 100644 --- a/library/Zend/View/Exception/UnexpectedValueException.php +++ b/library/Zend/View/Exception/UnexpectedValueException.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/AbstractHelper.php b/library/Zend/View/Helper/AbstractHelper.php index 18ea1a97..ba7fe251 100644 --- a/library/Zend/View/Helper/AbstractHelper.php +++ b/library/Zend/View/Helper/AbstractHelper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/AbstractHtmlElement.php b/library/Zend/View/Helper/AbstractHtmlElement.php index 9da54a84..3cf73e9f 100644 --- a/library/Zend/View/Helper/AbstractHtmlElement.php +++ b/library/Zend/View/Helper/AbstractHtmlElement.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/BasePath.php b/library/Zend/View/Helper/BasePath.php index ddca8c71..d71a3453 100644 --- a/library/Zend/View/Helper/BasePath.php +++ b/library/Zend/View/Helper/BasePath.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/Cycle.php b/library/Zend/View/Helper/Cycle.php index 524002f2..992f9f34 100644 --- a/library/Zend/View/Helper/Cycle.php +++ b/library/Zend/View/Helper/Cycle.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/DeclareVars.php b/library/Zend/View/Helper/DeclareVars.php index b3f35fc5..4be8129d 100644 --- a/library/Zend/View/Helper/DeclareVars.php +++ b/library/Zend/View/Helper/DeclareVars.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/Doctype.php b/library/Zend/View/Helper/Doctype.php index f270756b..bbda21d9 100644 --- a/library/Zend/View/Helper/Doctype.php +++ b/library/Zend/View/Helper/Doctype.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -205,7 +205,7 @@ class Doctype extends AbstractHelper */ public function isXhtml() { - return (stristr($this->getDoctype(), 'xhtml') ? true : false); + return (bool) stristr($this->getDoctype(), 'xhtml'); } /** @@ -215,7 +215,7 @@ class Doctype extends AbstractHelper */ public function isHtml5() { - return (stristr($this->__invoke(), '') ? true : false); + return (bool) stristr($this->__invoke(), ''); } /** @@ -225,6 +225,6 @@ class Doctype extends AbstractHelper */ public function isRdfa() { - return ($this->isHtml5() || stristr($this->getDoctype(), 'rdfa') ? true : false); + return ($this->isHtml5() || stristr($this->getDoctype(), 'rdfa')); } } diff --git a/library/Zend/View/Helper/EscapeCss.php b/library/Zend/View/Helper/EscapeCss.php index 133f73ca..86b5d6cb 100644 --- a/library/Zend/View/Helper/EscapeCss.php +++ b/library/Zend/View/Helper/EscapeCss.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/EscapeHtml.php b/library/Zend/View/Helper/EscapeHtml.php index 177ce6c0..9bcf1ecf 100644 --- a/library/Zend/View/Helper/EscapeHtml.php +++ b/library/Zend/View/Helper/EscapeHtml.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/EscapeHtmlAttr.php b/library/Zend/View/Helper/EscapeHtmlAttr.php index 774f90b4..5ed9fe51 100644 --- a/library/Zend/View/Helper/EscapeHtmlAttr.php +++ b/library/Zend/View/Helper/EscapeHtmlAttr.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/EscapeJs.php b/library/Zend/View/Helper/EscapeJs.php index 806fab69..1ccc0398 100644 --- a/library/Zend/View/Helper/EscapeJs.php +++ b/library/Zend/View/Helper/EscapeJs.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/EscapeUrl.php b/library/Zend/View/Helper/EscapeUrl.php index b8af34e9..9b9ae038 100644 --- a/library/Zend/View/Helper/EscapeUrl.php +++ b/library/Zend/View/Helper/EscapeUrl.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/Escaper/AbstractHelper.php b/library/Zend/View/Helper/Escaper/AbstractHelper.php index 373e7ea9..7dc8aa71 100644 --- a/library/Zend/View/Helper/Escaper/AbstractHelper.php +++ b/library/Zend/View/Helper/Escaper/AbstractHelper.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -39,9 +39,11 @@ abstract class AbstractHelper extends Helper\AbstractHelper * Invoke this helper: escape a value * * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping + * @param int $recurse Expects one of the recursion constants; + * used to decide whether or not to recurse the given value when escaping * @throws Exception\InvalidArgumentException - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. + * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not + * allowing object recursion, returns a string. Otherwise, returns an array. */ public function __invoke($value, $recurse = self::RECURSE_NONE) { @@ -100,7 +102,7 @@ abstract class AbstractHelper extends Helper\AbstractHelper if (null !== $this->escaper) { throw new Exception\InvalidArgumentException( 'Character encoding settings cannot be changed once the Helper has been used or ' - . ' if a Zend\Escaper\Escaper object (with preset encoding option) is set.' + . ' if a Zend\Escaper\Escaper object (with preset encoding option) is set.' ); } diff --git a/library/Zend/View/Helper/FlashMessenger.php b/library/Zend/View/Helper/FlashMessenger.php index 9c36a1fb..2097454d 100644 --- a/library/Zend/View/Helper/FlashMessenger.php +++ b/library/Zend/View/Helper/FlashMessenger.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -41,6 +41,13 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA protected $messageOpenFormat = '
  • '; protected $messageSeparatorString = '
  • '; + /** + * Flag whether to escape messages + * + * @var bool + */ + protected $autoEscape = true; + /** * Html escape helper * @@ -94,40 +101,48 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA /** * Render Messages * - * @param string $namespace - * @param array $classes + * @param string $namespace + * @param array $classes + * @param null|bool $autoEscape * @return string */ - public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array()) + public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array(), $autoEscape = null) { $flashMessenger = $this->getPluginFlashMessenger(); $messages = $flashMessenger->getMessagesFromNamespace($namespace); - return $this->renderMessages($namespace, $messages, $classes); + return $this->renderMessages($namespace, $messages, $classes, $autoEscape); } /** * Render Current Messages * - * @param string $namespace - * @param array $classes + * @param string $namespace + * @param array $classes + * @param bool|null $autoEscape * @return string */ - public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array()) + public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array(), $autoEscape = null) { $flashMessenger = $this->getPluginFlashMessenger(); $messages = $flashMessenger->getCurrentMessagesFromNamespace($namespace); - return $this->renderMessages($namespace, $messages, $classes); + return $this->renderMessages($namespace, $messages, $classes, $autoEscape); } /** * Render Messages * - * @param array $messages - * @param array $classes + * @param string $namespace + * @param array $messages + * @param array $classes + * @param bool|null $autoEscape * @return string */ - protected function renderMessages($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $messages = array(), array $classes = array()) - { + protected function renderMessages( + $namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, + array $messages = array(), + array $classes = array(), + $autoEscape = null + ) { // Prepare classes for opening tag if (empty($classes)) { if (isset($this->classMessages[$namespace])) { @@ -137,30 +152,71 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA } $classes = array($classes); } + + if (null === $autoEscape) { + $autoEscape = $this->getAutoEscape(); + } + // Flatten message array $escapeHtml = $this->getEscapeHtmlHelper(); $messagesToPrint = array(); $translator = $this->getTranslator(); $translatorTextDomain = $this->getTranslatorTextDomain(); - array_walk_recursive($messages, function ($item) use (&$messagesToPrint, $escapeHtml, $translator, $translatorTextDomain) { - if ($translator !== null) { - $item = $translator->translate( - $item, - $translatorTextDomain - ); + array_walk_recursive( + $messages, + function ($item) use (& $messagesToPrint, $escapeHtml, $autoEscape, $translator, $translatorTextDomain) { + if ($translator !== null) { + $item = $translator->translate( + $item, + $translatorTextDomain + ); + } + + if ($autoEscape) { + $messagesToPrint[] = $escapeHtml($item); + return; + } + + $messagesToPrint[] = $item; } - $messagesToPrint[] = $escapeHtml($item); - }); + ); + if (empty($messagesToPrint)) { return ''; } + // Generate markup $markup = sprintf($this->getMessageOpenFormat(), ' class="' . implode(' ', $classes) . '"'); - $markup .= implode(sprintf($this->getMessageSeparatorString(), ' class="' . implode(' ', $classes) . '"'), $messagesToPrint); + $markup .= implode( + sprintf($this->getMessageSeparatorString(), ' class="' . implode(' ', $classes) . '"'), + $messagesToPrint + ); $markup .= $this->getMessageCloseString(); return $markup; } + /** + * Set whether or not auto escaping should be used + * + * @param bool $autoEscape + * @return self + */ + public function setAutoEscape($autoEscape = true) + { + $this->autoEscape = (bool) $autoEscape; + return $this; + } + + /** + * Return whether auto escaping is enabled or disabled + * + * return bool + */ + public function getAutoEscape() + { + return $this->autoEscape; + } + /** * Set the string used to close message representation * diff --git a/library/Zend/View/Helper/Gravatar.php b/library/Zend/View/Helper/Gravatar.php index a14c2941..a748cf19 100644 --- a/library/Zend/View/Helper/Gravatar.php +++ b/library/Zend/View/Helper/Gravatar.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/library/Zend/View/Helper/HeadLink.php b/library/Zend/View/Helper/HeadLink.php index 853bdf83..4e78dcba 100644 --- a/library/Zend/View/Helper/HeadLink.php +++ b/library/Zend/View/Helper/HeadLink.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,9 +33,21 @@ class HeadLink extends Placeholder\Container\AbstractStandalone /** * Allowed attributes * - * @var array + * @var string[] */ - protected $itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras'); + protected $itemKeys = array( + 'charset', + 'href', + 'hreflang', + 'id', + 'media', + 'rel', + 'rev', + 'sizes', + 'type', + 'title', + 'extras' + ); /** * Registry key for placeholder @@ -283,7 +295,11 @@ class HeadLink extends Placeholder\Container\AbstractStandalone $link .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value); } } else { - $link .= sprintf(' %s="%s"', $itemKey, ($this->autoEscape) ? $this->escape($attributes[$itemKey]) : $attributes[$itemKey]); + $link .= sprintf( + ' %s="%s"', + $itemKey, + ($this->autoEscape) ? $this->escape($attributes[$itemKey]) : $attributes[$itemKey] + ); } } } @@ -298,7 +314,10 @@ class HeadLink extends Placeholder\Container\AbstractStandalone return ''; } - if (isset($attributes['conditionalStylesheet']) && !empty($attributes['conditionalStylesheet']) && is_string($attributes['conditionalStylesheet'])) { + if (isset($attributes['conditionalStylesheet']) + && !empty($attributes['conditionalStylesheet']) + && is_string($attributes['conditionalStylesheet']) + ) { // inner wrap with comment end and start if !IE if (str_replace(' ', '', $attributes['conditionalStylesheet']) === '!IE') { $link = '' . $link . '' . $meta . '' . $html . '