Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into rfc/escaper
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 84 changed files with 604 additions and 508 deletions.
7 changes: 2 additions & 5 deletions src/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

/**
Expand All @@ -29,15 +26,15 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractFilter implements Filter
abstract class AbstractFilter implements FilterInterface
{
/**
* Invoke filter as a command
*
* Proxies to {@link filter()}
*
* @param mixed $value
* @throws Zend\Filter\RuntimeException If filtering $value is impossible
* @throws Exception\ExceptionInterface If filtering $value is impossible
* @return mixed
*/
public function __invoke($value)
Expand Down
28 changes: 12 additions & 16 deletions src/Alnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

use Zend\Config\Config,
Zend\Locale\Locale as ZendLocale,
use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Locale\Locale as ZendLocale,
Zend\Registry;

/**
* @uses Zend\Filter\AbstractFilter
* @uses Zend\Locale\Locale
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand All @@ -54,21 +50,21 @@ class Alnum extends AbstractFilter
/**
* Locale to use
*
* @var \Zend\Locale\Locale object
* @var ZendLocale object
*/
protected $locale;

/**
* Sets default option values for this instance
*
* @param boolean $allowWhiteSpace
* @return void
* @param boolean|Traversable|array $allowWhiteSpace
*/
public function __construct($options = false)
{
if ($options instanceof Config) {
$options = $options->toArray();
} elseif (!is_array($options)) {
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (!is_array($options)) {
$options = func_get_args();
$temp = array();
if (!empty($options)) {
Expand Down Expand Up @@ -111,7 +107,7 @@ public function getAllowWhiteSpace()
* Sets the allowWhiteSpace option
*
* @param boolean $allowWhiteSpace
* @return \Zend\Filter\Alnum Provides a fluent interface
* @return Alnum Provides a fluent interface
*/
public function setAllowWhiteSpace($allowWhiteSpace)
{
Expand All @@ -133,7 +129,7 @@ public function getLocale()
* Sets the locale option
*
* @param boolean $locale
* @return \Zend\Filter\Alnum Provides a fluent interface
* @return Alnum Provides a fluent interface
*/
public function setLocale($locale = null)
{
Expand All @@ -142,7 +138,7 @@ public function setLocale($locale = null)
}

/**
* Defined by Zend_Filter_Interface
* Defined by Zend\Filter\FilterInterface
*
* Returns the string $value, removing all but alphabetic and digit characters
*
Expand Down
11 changes: 3 additions & 8 deletions src/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

use Traversable,
Expand All @@ -29,8 +26,6 @@
Zend\Stdlib\ArrayUtils;

/**
* @uses Zend\Filter\AbstractFilter
* @uses Zend\Locale\Locale
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -112,7 +107,7 @@ public function getAllowWhiteSpace()
* Sets the allowWhiteSpace option
*
* @param boolean $allowWhiteSpace
* @return \Zend\Filter\Alpha Provides a fluent interface
* @return Alpha Provides a fluent interface
*/
public function setAllowWhiteSpace($allowWhiteSpace)
{
Expand Down Expand Up @@ -172,7 +167,7 @@ public function getLocale()
* Sets the locale option
*
* @param boolean $locale
* @return \Zend\Filter\Alnum Provides a fluent interface
* @return Alpha Provides a fluent interface
*/
public function setLocale($locale = null)
{
Expand All @@ -181,7 +176,7 @@ public function setLocale($locale = null)
}

/**
* Defined by Zend_Filter_Interface
* Defined by Zend\Filter\FilterInterface
*
* Returns the string $value, removing all but alphabetic characters
*
Expand Down
6 changes: 1 addition & 5 deletions src/BaseName.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

/**
* @uses Zend\Filter\AbstractFilter
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand All @@ -33,7 +29,7 @@
class BaseName extends AbstractFilter
{
/**
* Defined by Zend_Filter_Interface
* Defined by Zend\Filter\FilterInterface
*
* Returns basename($value)
*
Expand Down
31 changes: 14 additions & 17 deletions src/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Locale\Locale;

/**
* @uses Zend\Filter\Exception
* @uses Zend\Filter\AbstractFilter
* @uses Zend\Locale\Locale
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -85,13 +82,14 @@ class Boolean extends AbstractFilter
/**
* Constructor
*
* @param string|array|\Zend\Config\Config $options OPTIONAL
* @param string|array|Traversable $options OPTIONAL
*/
public function __construct($options = null)
{
if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
} elseif (!is_array($options)) {
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (!is_array($options)) {
$options = func_get_args();
$temp = array();
if (!empty($options)) {
Expand Down Expand Up @@ -136,8 +134,8 @@ public function getType()
* Set the null types
*
* @param integer|array $type
* @throws \Zend\Filter\Exception
* @return \Zend\Filter\Boolean
* @throws Exception\InvalidArgumentException
* @return Boolean
*/
public function setType($type = null)
{
Expand Down Expand Up @@ -178,8 +176,8 @@ public function getLocale()
* Set the locales which are accepted
*
* @param string|array|\Zend\Locale\Locale $locale
* @throws \Zend\Filter\Exception
* @return \Zend\Filter\Boolean
* @throws Exception\ExceptionInterface
* @return Boolean
*/
public function setLocale($locale = null)
{
Expand Down Expand Up @@ -217,8 +215,7 @@ public function getCasting()
* @param boolean $locale When true this filter works like cast
* When false it recognises only true and false
* and all other values are returned as is
* @throws \Zend\Filter\Exception
* @return \Zend\Filter\Boolean
* @return Boolean
*/
public function setCasting($casting = true)
{
Expand All @@ -227,7 +224,7 @@ public function setCasting($casting = true)
}

/**
* Defined by Zend_Filter_Interface
* Defined by Zend\Filter\FilterInterface
*
* Returns a boolean representation of $value
*
Expand Down
11 changes: 3 additions & 8 deletions src/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

use Traversable,
Zend\Stdlib\ArrayUtils;

/**
* @uses Zend\Filter\Exception
* @uses Zend\Filter\AbstractFilter
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -93,8 +88,8 @@ public function getCallback()
/**
* Sets a new callback for this filter
*
* @param unknown_type $callback
* @return unknown
* @param \callable $callback
* @return Callback
*/
public function setCallback($callback, $options = null)
{
Expand All @@ -121,7 +116,7 @@ public function getOptions()
* Sets new default options to the callback filter
*
* @param mixed $options Default options to set
* @return \Zend\Filter\Callback
* @return Callback
*/
public function setOptions($options)
{
Expand Down
35 changes: 16 additions & 19 deletions src/Compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Filter;

use Traversable;
use Zend\Stdlib\ArrayUtils;

/**
* Compresses a given string
*
* @uses Zend\Filter\Exception
* @uses Zend\Filter\AbstractFilter
* @uses Zend\Loader
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand All @@ -49,16 +46,16 @@ class Compress extends AbstractFilter
/**
* Class constructor
*
* @param string|array $options (Optional) Options to set
* @param string|array|Traversable $options (Optional) Options to set
*/
public function __construct($options = null)
{
if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (is_string($options)) {
$this->setAdapter($options);
} elseif ($options instanceof Compress\CompressionAlgorithm) {
} elseif ($options instanceof Compress\CompressionAlgorithmInterface) {
$this->setAdapter($options);
} elseif (is_array($options)) {
$this->setOptions($options);
Expand All @@ -69,7 +66,7 @@ public function __construct($options = null)
* Set filter setate
*
* @param array $options
* @return \Zend\Filter\Compress
* @return Compress
*/
public function setOptions(array $options)
{
Expand All @@ -92,7 +89,7 @@ public function setOptions(array $options)
*/
public function getAdapter()
{
if ($this->_adapter instanceof Compress\CompressionAlgorithm) {
if ($this->_adapter instanceof Compress\CompressionAlgorithmInterface) {
return $this->_adapter;
}

Expand All @@ -110,8 +107,8 @@ public function getAdapter()
}

$this->_adapter = new $adapter($options);
if (!$this->_adapter instanceof Compress\CompressionAlgorithm) {
throw new Exception\InvalidArgumentException("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithm");
if (!$this->_adapter instanceof Compress\CompressionAlgorithmInterface) {
throw new Exception\InvalidArgumentException("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithmInterface");
}
return $this->_adapter;
}
Expand All @@ -129,17 +126,17 @@ public function getAdapterName()
/**
* Sets compression adapter
*
* @param string|\Zend\Filter\Compress\CompressInterface $adapter Adapter to use
* @return \Zend\Filter\Compress\Compress
* @param string|Compress\CompressionAlgorithmInterface $adapter Adapter to use
* @return Compress
*/
public function setAdapter($adapter)
{
if ($adapter instanceof Compress\CompressionAlgorithm) {
if ($adapter instanceof Compress\CompressionAlgorithmInterface) {
$this->_adapter = $adapter;
return $this;
}
if (!is_string($adapter)) {
throw new Exception\InvalidArgumentException('Invalid adapter provided; must be string or instance of Zend\\Filter\\Compress\\CompressionAlgorithm');
throw new Exception\InvalidArgumentException('Invalid adapter provided; must be string or instance of Zend\\Filter\\Compress\\CompressionAlgorithmInterface');
}
$this->_adapter = $adapter;

Expand All @@ -160,7 +157,7 @@ public function getAdapterOptions()
* Set adapter options
*
* @param array $options
* @return void
* @return Compress
*/
public function setAdapterOptions(array $options)
{
Expand Down
Loading

0 comments on commit 2d218aa

Please sign in to comment.