Parcourir la source

Check values passed to PreprocessorChain::offsetSet().

Daniele Alessandri il y a 14 ans
Parent
commit
1ee7926673
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      lib/Predis/Commands/Preprocessors/PreprocessorChain.php

+ 6 - 0
lib/Predis/Commands/Preprocessors/PreprocessorChain.php

@@ -47,6 +47,12 @@ class PreprocessorChain implements ICommandPreprocessorChain, \ArrayAccess {
     }
 
     public function offsetSet($index, $preprocessor) {
+        if (!$preprocessor instanceof ICommandPreprocessor) {
+            throw new \InvalidArgumentException(
+                'A preprocessor chain can hold only instances of classes implementing '.
+                'the Predis\Commands\Preprocessors\ICommandPreprocessor interface'
+            );
+        }
         $this->_preprocessors[$index] = $preprocessor;
     }