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

Commit

Permalink
Merge branch 'hotfix/ZF-11878' of https://github.com/thomasweidner/zf2
Browse files Browse the repository at this point in the history
…into hotfix/zf-11878
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/Alnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ class Alnum extends AbstractFilter
* @param boolean $allowWhiteSpace
* @return void
*/
public function __construct($options = null)
public function __construct($options = false)
{
if ($options instanceof Config) {
$options = $options->toArray();
} elseif (!is_array($options)) {
$options = func_get_args();
$temp = array();
if (!empty($options)) {
$temp['allowwhitespace'] = array_shift($options);
$temp['allowWhiteSpace'] = array_shift($options);
}

if (!empty($options)) {
Expand All @@ -86,8 +86,8 @@ public function __construct($options = null)
self::$unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
}

if (array_key_exists('allowwhitespace', $options)) {
$this->setAllowWhiteSpace($options['allowwhitespace']);
if (array_key_exists('allowWhiteSpace', $options)) {
$this->setAllowWhiteSpace($options['allowWhiteSpace']);
}

if (!array_key_exists('locale', $options)) {
Expand Down Expand Up @@ -156,14 +156,14 @@ public function filter($value)
if (!self::$unicodeEnabled) {
// POSIX named classes are not supported, use alternative a-zA-Z0-9 match
$pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/';
} elseif (((string) $this->locale == 'ja')
|| ((string) $this->locale == 'ko')
} elseif (((string) $this->locale == 'ja')
|| ((string) $this->locale == 'ko')
|| ((string) $this->locale == 'zh')
) {
// The Alphabet means english alphabet.
// Use english alphabeth
$pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u';
} else {
// The Alphabet means each language's alphabet.
// Use native language alphabeth
$pattern = '/[^\p{L}\p{N}' . $whiteSpace . ']/u';
}

Expand Down
14 changes: 7 additions & 7 deletions src/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct($options = false)
$options = func_get_args();
$temp = array();
if (!empty($options)) {
$temp['allowwhitespace'] = array_shift($options);
$temp['allowWhiteSpace'] = array_shift($options);
}

if (!empty($options)) {
Expand All @@ -86,8 +86,8 @@ public function __construct($options = false)
self::$unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
}

if (array_key_exists('allowwhitespace', $options)) {
$this->setAllowWhiteSpace($options['allowwhitespace']);
if (array_key_exists('allowWhiteSpace', $options)) {
$this->setAllowWhiteSpace($options['allowWhiteSpace']);
}

if (!array_key_exists('locale', $options)) {
Expand Down Expand Up @@ -156,14 +156,14 @@ public function filter($value)
if (!self::$unicodeEnabled) {
// POSIX named classes are not supported, use alternative a-zA-Z match
$pattern = '/[^a-zA-Z' . $whiteSpace . ']/';
} elseif (((string) $this->locale == 'ja')
|| ((string) $this->locale == 'ko')
} elseif (((string) $this->locale == 'ja')
|| ((string) $this->locale == 'ko')
|| ((string) $this->locale == 'zh')
) {
// The Alphabet means english alphabet.
// Use english alphabeth
$pattern = '/[^a-zA-Z' . $whiteSpace . ']/u';
} else {
// The Alphabet means each language's alphabet.
// Use native language alphabeth
$pattern = '/[^\p{L}' . $whiteSpace . ']/u';
}

Expand Down
6 changes: 3 additions & 3 deletions test/AlnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace ZendTest\Filter;

use Zend\Filter\Alnum as AlnumFilter,
Zend\Locale\Locale,
Zend\Locale\Locale as ZendLocale,
Zend\Registry;

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ public function setUp()
self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
}
if (null === self::$_meansEnglishAlphabet) {
$this->_locale = new Locale('auto');
$this->_locale = new ZendLocale('auto');
self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
array('ja')
);
Expand Down Expand Up @@ -189,7 +189,7 @@ public function testAllowWhiteSpace()
*/
public function testRegistryLocale()
{
$locale = new Locale('ja');
$locale = new ZendLocale('ja');
\Zend\Registry::set('Zend_Locale', $locale);

if (!self::$_unicodeEnabled) {
Expand Down

0 comments on commit 7d18607

Please sign in to comment.