Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / config / Definition / Builder / ExprBuilder.php
index 150a2ec9ab3a3d58651138e3324c50ba8e7eebc1..5c070bee7c38181b9f04ad573bd64726e481b224 100644 (file)
@@ -25,11 +25,6 @@ class ExprBuilder
     public $ifPart;
     public $thenPart;
 
-    /**
-     * Constructor.
-     *
-     * @param NodeDefinition $node The related node
-     */
     public function __construct(NodeDefinition $node)
     {
         $this->node = $node;
@@ -38,8 +33,6 @@ class ExprBuilder
     /**
      * Marks the expression as being always used.
      *
-     * @param \Closure $then
-     *
      * @return $this
      */
     public function always(\Closure $then = null)
@@ -58,8 +51,6 @@ class ExprBuilder
      *
      * The default one tests if the value is true.
      *
-     * @param \Closure $closure
-     *
      * @return $this
      */
     public function ifTrue(\Closure $closure = null)
@@ -80,7 +71,7 @@ class ExprBuilder
      */
     public function ifString()
     {
-        $this->ifPart = function ($v) { return is_string($v); };
+        $this->ifPart = function ($v) { return \is_string($v); };
 
         return $this;
     }
@@ -116,7 +107,7 @@ class ExprBuilder
      */
     public function ifArray()
     {
-        $this->ifPart = function ($v) { return is_array($v); };
+        $this->ifPart = function ($v) { return \is_array($v); };
 
         return $this;
     }
@@ -124,13 +115,11 @@ class ExprBuilder
     /**
      * Tests if the value is in an array.
      *
-     * @param array $array
-     *
      * @return $this
      */
     public function ifInArray(array $array)
     {
-        $this->ifPart = function ($v) use ($array) { return in_array($v, $array, true); };
+        $this->ifPart = function ($v) use ($array) { return \in_array($v, $array, true); };
 
         return $this;
     }
@@ -138,21 +127,30 @@ class ExprBuilder
     /**
      * Tests if the value is not in an array.
      *
-     * @param array $array
-     *
      * @return $this
      */
     public function ifNotInArray(array $array)
     {
-        $this->ifPart = function ($v) use ($array) { return !in_array($v, $array, true); };
+        $this->ifPart = function ($v) use ($array) { return !\in_array($v, $array, true); };
 
         return $this;
     }
 
     /**
-     * Sets the closure to run if the test pass.
+     * Transforms variables of any type into an array.
      *
-     * @param \Closure $closure
+     * @return $this
+     */
+    public function castToArray()
+    {
+        $this->ifPart = function ($v) { return !\is_array($v); };
+        $this->thenPart = function ($v) { return array($v); };
+
+        return $this;
+    }
+
+    /**
+     * Sets the closure to run if the test pass.
      *
      * @return $this
      */
@@ -188,7 +186,7 @@ class ExprBuilder
      */
     public function thenInvalid($message)
     {
-        $this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
+        $this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
 
         return $this;
     }