X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FDefinition%2FBuilder%2FExprBuilder.php;fp=vendor%2Fsymfony%2Fconfig%2FDefinition%2FBuilder%2FExprBuilder.php;h=64c0f5578ad41be6cda336c2cf3fd32516884019;hp=150a2ec9ab3a3d58651138e3324c50ba8e7eebc1;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/symfony/config/Definition/Builder/ExprBuilder.php b/vendor/symfony/config/Definition/Builder/ExprBuilder.php index 150a2ec9a..64c0f5578 100644 --- a/vendor/symfony/config/Definition/Builder/ExprBuilder.php +++ b/vendor/symfony/config/Definition/Builder/ExprBuilder.php @@ -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) @@ -124,8 +115,6 @@ class ExprBuilder /** * Tests if the value is in an array. * - * @param array $array - * * @return $this */ public function ifInArray(array $array) @@ -138,8 +127,6 @@ class ExprBuilder /** * Tests if the value is not in an array. * - * @param array $array - * * @return $this */ public function ifNotInArray(array $array) @@ -150,9 +137,20 @@ class ExprBuilder } /** - * 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; }