mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #10389 from cakephp/issue-10385
Hash::filter() should not exclude 0.0
This commit is contained in:
commit
8f6cf96cca
3 changed files with 18 additions and 4 deletions
|
@ -43,7 +43,8 @@ before_script:
|
||||||
- sh -c "if [ '$PHPCS' = '1' ]; then composer global require 'cakephp/cakephp-codesniffer:1.*'; fi"
|
- sh -c "if [ '$PHPCS' = '1' ]; then composer global require 'cakephp/cakephp-codesniffer:1.*'; fi"
|
||||||
- sh -c "if [ '$PHPCS' = '1' ]; then ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/cakephp/cakephp-codesniffer; fi"
|
- sh -c "if [ '$PHPCS' = '1' ]; then ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/cakephp/cakephp-codesniffer; fi"
|
||||||
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||||
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.0" ]] ; then print "yes" | pecl install apcu-5.1.3; else print "yes" | pecl install apcu-4.0.11; fi
|
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]] ; then echo "yes" | pecl install apcu-5.1.3 || true; fi
|
||||||
|
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]] ; then echo "yes" | pecl install apcu-4.0.11 || true; fi
|
||||||
- echo -e "extension = apcu.so\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
- echo -e "extension = apcu.so\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- set +H
|
- set +H
|
||||||
|
|
|
@ -655,8 +655,21 @@ class HashTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testFilter() {
|
public function testFilter() {
|
||||||
$result = Hash::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false)));
|
$result = Hash::filter(array(
|
||||||
$expected = array('0', 2 => true, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be'));
|
'0',
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
0.0,
|
||||||
|
array('one thing', 'I can tell you', 'is you got to be', false)
|
||||||
|
));
|
||||||
|
$expected = array(
|
||||||
|
'0',
|
||||||
|
2 => true,
|
||||||
|
3 => 0,
|
||||||
|
4 => 0.0,
|
||||||
|
5 => array('one thing', 'I can tell you', 'is you got to be')
|
||||||
|
);
|
||||||
$this->assertSame($expected, $result);
|
$this->assertSame($expected, $result);
|
||||||
|
|
||||||
$result = Hash::filter(array(1, array(false)));
|
$result = Hash::filter(array(1, array(false)));
|
||||||
|
|
|
@ -573,7 +573,7 @@ class Hash {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected static function _filter($var) {
|
protected static function _filter($var) {
|
||||||
if ($var === 0 || $var === '0' || !empty($var)) {
|
if ($var === 0 || $var === 0.0 || $var === '0' || !empty($var)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue