This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/zendframework/zf2
- Loading branch information
30 parents
908a1c4
+
128be4b
+
34cd6a3
+
ec2aab9
+
809bd88
+
77026e3
+
c2796da
+
0ee8602
+
bf4e728
+
cd33c2d
+
32497e5
+
79eb7d0
+
8cc5d58
+
869ab1c
+
436e613
+
ab7d56c
+
6dbeef6
+
84670b1
+
cccfba9
+
2717653
+
b4dd364
+
460818e
+
b5ac15d
+
2d218aa
+
046d669
+
5597f80
+
98dc299
+
01b3149
+
b0177b5
+
74f8270
commit cb0afaa
Showing
124 changed files
with
2,323 additions
and
5,780 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,94 @@ | ||
<?php | ||
/** | ||
* Zend Framework | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://framework.zend.com/license/new-bsd | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_Filter | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @link https://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Filter | ||
*/ | ||
|
||
namespace Zend\Filter; | ||
|
||
use Traversable; | ||
use Zend\Stdlib\ArrayUtils; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Filter | ||
* @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 FilterInterface | ||
{ | ||
/** | ||
* Filter options | ||
* | ||
* @var array | ||
*/ | ||
protected $options = array(); | ||
|
||
/** | ||
* Is PCRE is compiled with UTF-8 and Unicode support | ||
* | ||
* @var boolean | ||
**/ | ||
protected static $hasPcreUnicodeSupport = null; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public static function hasPcreUnicodeSupport() | ||
{ | ||
if (static::$hasPcreUnicodeSupport === null) { | ||
if (defined('PREG_BAD_UTF8_OFFSET_ERROR') || @preg_match('/\pL/u', 'a') == 1){ | ||
static::$hasPcreUnicodeSupport = true; | ||
} else { | ||
static::$hasPcreUnicodeSupport = false; | ||
} | ||
} | ||
return static::$hasPcreUnicodeSupport; | ||
} | ||
|
||
/** | ||
* @param array|Traversable $options | ||
* @return AbstractFilter | ||
* @throws Exception\InvalidArgumentException | ||
*/ | ||
public function setOptions($options) | ||
{ | ||
if (!is_array($options) && !$options instanceof Traversable) { | ||
throw new Exception\InvalidArgumentException(sprintf( | ||
'"%s" expects an array or Traversable; received "%s"', | ||
__METHOD__, | ||
(is_object($options) ? get_class($options) : gettype($options)) | ||
)); | ||
} | ||
|
||
foreach ($options as $key => $value) { | ||
$setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); | ||
if (method_exists($this, $setter)) { | ||
$this->{$setter}($value); | ||
} 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 | ||
)); | ||
} | ||
} | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve options representing object state | ||
* | ||
* @return array | ||
*/ | ||
public function getOptions() | ||
{ | ||
return $this->options; | ||
} | ||
|
||
/** | ||
* Invoke filter as a command | ||
* | ||
|
@@ -41,4 +102,14 @@ public function __invoke($value) | |
{ | ||
return $this->filter($value); | ||
} | ||
|
||
/** | ||
* | ||
* @param mixed $options | ||
* @return bool | ||
*/ | ||
protected static function isOptions($options) | ||
{ | ||
return (is_array($options) || $options instanceof Traversable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link https://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Filter | ||
*/ | ||
|
||
namespace Zend\Filter; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Filter | ||
*/ | ||
abstract class AbstractUnicode extends AbstractFilter | ||
{ | ||
/** | ||
* Set the input encoding for the given string | ||
* | ||
* @param string|null $encoding | ||
* @return StringToLower | ||
* @throws Exception\InvalidArgumentException | ||
* @throws Exception\ExtensionNotLoadedException | ||
*/ | ||
public function setEncoding($encoding = null) | ||
{ | ||
if ($encoding !== null) { | ||
if (!function_exists('mb_strtolower')) { | ||
throw new Exception\ExtensionNotLoadedException(sprintf( | ||
'%s requires mbstring extension to be loaded', | ||
get_class($this) | ||
)); | ||
} | ||
|
||
$encoding = strtolower($encoding); | ||
$mbEncodings = array_map('strtolower', mb_list_encodings()); | ||
if (!in_array($encoding, $mbEncodings)) { | ||
throw new Exception\InvalidArgumentException(sprintf( | ||
"Encoding '%s' is not supported by mbstring extension", | ||
$encoding | ||
)); | ||
} | ||
} | ||
|
||
$this->options['encoding'] = $encoding; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Returns the set encoding | ||
* | ||
* @return string | ||
*/ | ||
public function getEncoding() | ||
{ | ||
if ($this->options['encoding'] === null && function_exists('mb_internal_encoding')) { | ||
$this->options['encoding'] = mb_internal_encoding(); | ||
} | ||
|
||
return $this->options['encoding']; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.