Procházet zdrojové kódy

Fix different behaviour of filter_var() with NULL on PHP 5.3.

Seriously, they could not possibly screw bool validation up any more
than they already had with filter_var().
Daniele Alessandri před 11 roky
rodič
revize
1a769e3cc3
1 změnil soubory, kde provedl 3 přidání a 2 odebrání
  1. 3 2
      lib/Predis/Configuration/ReplicationOption.php

+ 3 - 2
lib/Predis/Configuration/ReplicationOption.php

@@ -27,7 +27,8 @@ class ReplicationOption implements OptionInterface
      * {@inheritdoc}
      *
      * @todo There's more code than needed due to a bug in filter_var()
-     *       as discussed here https://bugs.php.net/bug.php?id=49510.
+     *       as discussed here https://bugs.php.net/bug.php?id=49510
+     *       and a different behaviour with NULL values on PHP 5.3.
      */
     public function filter(OptionsInterface $options, $value)
     {
@@ -35,7 +36,7 @@ class ReplicationOption implements OptionInterface
             return $value;
         }
 
-        if (is_bool($value)) {
+        if (is_bool($value) || $value === null) {
             return $value ? $this->getDefault($options) : null;
         }