Merge branch '2.8' into 3.1
* 2.8: [Security] Fix test [Validator] phpize default option values test for the Validator component to be present [DependencyInjection] Fix on-invalid attribute type in xsd [FrameworkBundle] Fix PHP form templates on translatable attributes [VarDumper] Fix dumping by-ref variadics [Validator] add Indonesian translation fixed CS [config] Fix issue when key removed and left value only [Console] fixed BC issue with static closures [Security] AbstractVoter method supportsAttribute gives false positive if attribute is zero (0)
This commit is contained in:
commit
f4b3b87ef7
@ -758,6 +758,10 @@ class FrameworkExtension extends Extension
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!class_exists('Symfony\Component\Validator\Validation')) {
|
||||||
|
throw new LogicException('Validation support cannot be enabled as the Validator component is not installed.');
|
||||||
|
}
|
||||||
|
|
||||||
$loader->load('validator.xml');
|
$loader->load('validator.xml');
|
||||||
|
|
||||||
$validatorBuilder = $container->getDefinition('validator.builder');
|
$validatorBuilder = $container->getDefinition('validator.builder');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>" <?php if ($disabled): ?>disabled="disabled" <?php endif ?>
|
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>" <?php if ($disabled): ?>disabled="disabled" <?php endif ?>
|
||||||
<?php foreach ($attr as $k => $v): ?>
|
<?php foreach ($attr as $k => $v): ?>
|
||||||
<?php if (in_array($v, array('placeholder', 'title'), true)): ?>
|
<?php if (in_array($k, array('placeholder', 'title'), true)): ?>
|
||||||
<?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
|
<?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
|
||||||
<?php elseif ($v === true): ?>
|
<?php elseif ($v === true): ?>
|
||||||
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>
|
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php if (!empty($id)): ?>id="<?php echo $view->escape($id) ?>" <?php endif ?>
|
<?php if (!empty($id)): ?>id="<?php echo $view->escape($id) ?>" <?php endif ?>
|
||||||
<?php foreach ($attr as $k => $v): ?>
|
<?php foreach ($attr as $k => $v): ?>
|
||||||
<?php if (in_array($v, array('placeholder', 'title'), true)): ?>
|
<?php if (in_array($k, array('placeholder', 'title'), true)): ?>
|
||||||
<?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
|
<?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
|
||||||
<?php elseif ($v === true): ?>
|
<?php elseif ($v === true): ?>
|
||||||
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>
|
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>
|
||||||
|
@ -29,6 +29,10 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
protected $minNumberOfElements = 0;
|
protected $minNumberOfElements = 0;
|
||||||
protected $defaultValue = array();
|
protected $defaultValue = array();
|
||||||
protected $defaultChildren;
|
protected $defaultChildren;
|
||||||
|
/**
|
||||||
|
* @var NodeInterface[] An array of the prototypes of the simplified value children
|
||||||
|
*/
|
||||||
|
private $valuePrototypes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the minimum number of elements that a prototype based node must
|
* Sets the minimum number of elements that a prototype based node must
|
||||||
@ -194,9 +198,9 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$this->prototype->setName($k);
|
$prototype = $this->getPrototypeForChild($k);
|
||||||
try {
|
try {
|
||||||
$value[$k] = $this->prototype->finalize($v);
|
$value[$k] = $prototype->finalize($v);
|
||||||
} catch (UnsetKeyException $e) {
|
} catch (UnsetKeyException $e) {
|
||||||
unset($value[$k]);
|
unset($value[$k]);
|
||||||
}
|
}
|
||||||
@ -250,8 +254,18 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if only "value" is left
|
// if only "value" is left
|
||||||
if (1 == count($v) && isset($v['value'])) {
|
if (array_keys($v) === array('value')) {
|
||||||
$v = $v['value'];
|
$v = $v['value'];
|
||||||
|
if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && array_key_exists('value', $children)) {
|
||||||
|
$valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
|
||||||
|
$valuePrototype->parent = $this;
|
||||||
|
$originalClosures = $this->prototype->normalizationClosures;
|
||||||
|
if (is_array($originalClosures)) {
|
||||||
|
$valuePrototypeClosures = $valuePrototype->normalizationClosures;
|
||||||
|
$valuePrototype->normalizationClosures = is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures;
|
||||||
|
}
|
||||||
|
$this->valuePrototypes[$k] = $valuePrototype;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,11 +278,11 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prototype->setName($k);
|
$prototype = $this->getPrototypeForChild($k);
|
||||||
if (null !== $this->keyAttribute || $isAssoc) {
|
if (null !== $this->keyAttribute || $isAssoc) {
|
||||||
$normalized[$k] = $this->prototype->normalize($v);
|
$normalized[$k] = $prototype->normalize($v);
|
||||||
} else {
|
} else {
|
||||||
$normalized[] = $this->prototype->normalize($v);
|
$normalized[] = $prototype->normalize($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,10 +336,54 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prototype->setName($k);
|
$prototype = $this->getPrototypeForChild($k);
|
||||||
$leftSide[$k] = $this->prototype->merge($leftSide[$k], $v);
|
$leftSide[$k] = $prototype->merge($leftSide[$k], $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $leftSide;
|
return $leftSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a prototype for the child node that is associated to $key in the value array.
|
||||||
|
* For general child nodes, this will be $this->prototype.
|
||||||
|
* But if $this->removeKeyAttribute is true and there are only two keys in the child node:
|
||||||
|
* one is same as this->keyAttribute and the other is 'value', then the prototype will be different.
|
||||||
|
*
|
||||||
|
* For example, assume $this->keyAttribute is 'name' and the value array is as follows:
|
||||||
|
* array(
|
||||||
|
* array(
|
||||||
|
* 'name' => 'name001',
|
||||||
|
* 'value' => 'value001'
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* Now, the key is 0 and the child node is:
|
||||||
|
* array(
|
||||||
|
* 'name' => 'name001',
|
||||||
|
* 'value' => 'value001'
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* When normalizing the value array, the 'name' element will removed from the child node
|
||||||
|
* and its value becomes the new key of the child node:
|
||||||
|
* array(
|
||||||
|
* 'name001' => array('value' => 'value001')
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* Now only 'value' element is left in the child node which can be further simplified into a string:
|
||||||
|
* array('name001' => 'value001')
|
||||||
|
*
|
||||||
|
* Now, the key becomes 'name001' and the child node becomes 'value001' and
|
||||||
|
* the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.
|
||||||
|
*
|
||||||
|
* @param string $key The key of the child node
|
||||||
|
*
|
||||||
|
* @return mixed The prototype instance
|
||||||
|
*/
|
||||||
|
private function getPrototypeForChild($key)
|
||||||
|
{
|
||||||
|
$prototype = isset($this->valuePrototypes[$key]) ? $this->valuePrototypes[$key] : $this->prototype;
|
||||||
|
$prototype->setName($key);
|
||||||
|
|
||||||
|
return $prototype;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Config\Tests\Definition;
|
|||||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||||
use Symfony\Component\Config\Definition\ArrayNode;
|
use Symfony\Component\Config\Definition\ArrayNode;
|
||||||
use Symfony\Component\Config\Definition\ScalarNode;
|
use Symfony\Component\Config\Definition\ScalarNode;
|
||||||
|
use Symfony\Component\Config\Definition\VariableNode;
|
||||||
|
|
||||||
class PrototypedArrayNodeTest extends \PHPUnit_Framework_TestCase
|
class PrototypedArrayNodeTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@ -177,4 +178,164 @@ class PrototypedArrayNodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that when a key attribute is mapped, that key is removed from the array.
|
||||||
|
* And if only 'value' element is left in the array, it will replace its wrapper array.
|
||||||
|
*
|
||||||
|
* <things>
|
||||||
|
* <option id="option1" value="value1">
|
||||||
|
* </things>
|
||||||
|
*
|
||||||
|
* The above should finally be mapped to an array that looks like this
|
||||||
|
* (because "id" is the key attribute).
|
||||||
|
*
|
||||||
|
* array(
|
||||||
|
* 'things' => array(
|
||||||
|
* 'option1' => 'value1'
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* It's also possible to mix 'value-only' and 'non-value-only' elements in the array.
|
||||||
|
*
|
||||||
|
* <things>
|
||||||
|
* <option id="option1" value="value1">
|
||||||
|
* <option id="option2" value="value2" foo="foo2">
|
||||||
|
* </things>
|
||||||
|
*
|
||||||
|
* The above should finally be mapped to an array as follows
|
||||||
|
*
|
||||||
|
* array(
|
||||||
|
* 'things' => array(
|
||||||
|
* 'option1' => 'value1',
|
||||||
|
* 'option2' => array(
|
||||||
|
* 'value' => 'value2',
|
||||||
|
* 'foo' => 'foo2'
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* The 'value' element can also be ArrayNode:
|
||||||
|
*
|
||||||
|
* <things>
|
||||||
|
* <option id="option1">
|
||||||
|
* <value>
|
||||||
|
* <foo>foo1</foo>
|
||||||
|
* <bar>bar1</bar>
|
||||||
|
* </value>
|
||||||
|
* </option>
|
||||||
|
* </things>
|
||||||
|
*
|
||||||
|
* The above should be finally be mapped to an array as follows
|
||||||
|
*
|
||||||
|
* array(
|
||||||
|
* 'things' => array(
|
||||||
|
* 'option1' => array(
|
||||||
|
* 'foo' => 'foo1',
|
||||||
|
* 'bar' => 'bar1'
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* If using VariableNode for value node, it's also possible to mix different types of value nodes:
|
||||||
|
*
|
||||||
|
* <things>
|
||||||
|
* <option id="option1">
|
||||||
|
* <value>
|
||||||
|
* <foo>foo1</foo>
|
||||||
|
* <bar>bar1</bar>
|
||||||
|
* </value>
|
||||||
|
* </option>
|
||||||
|
* <option id="option2" value="value2">
|
||||||
|
* </things>
|
||||||
|
*
|
||||||
|
* The above should be finally mapped to an array as follows
|
||||||
|
*
|
||||||
|
* array(
|
||||||
|
* 'things' => array(
|
||||||
|
* 'option1' => array(
|
||||||
|
* 'foo' => 'foo1',
|
||||||
|
* 'bar' => 'bar1'
|
||||||
|
* ),
|
||||||
|
* 'option2' => 'value2'
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @dataProvider getDataForKeyRemovedLeftValueOnly
|
||||||
|
*/
|
||||||
|
public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, $children, $expected)
|
||||||
|
{
|
||||||
|
$node = new PrototypedArrayNode('root');
|
||||||
|
$node->setKeyAttribute('id', true);
|
||||||
|
|
||||||
|
// each item under the root is an array, with one scalar item
|
||||||
|
$prototype = new ArrayNode(null, $node);
|
||||||
|
$prototype->addChild(new ScalarNode('id'));
|
||||||
|
$prototype->addChild(new ScalarNode('foo'));
|
||||||
|
$prototype->addChild($value);
|
||||||
|
$node->setPrototype($prototype);
|
||||||
|
|
||||||
|
$normalized = $node->normalize($children);
|
||||||
|
$this->assertEquals($expected, $normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDataForKeyRemovedLeftValueOnly()
|
||||||
|
{
|
||||||
|
$scalarValue = new ScalarNode('value');
|
||||||
|
|
||||||
|
$arrayValue = new ArrayNode('value');
|
||||||
|
$arrayValue->addChild(new ScalarNode('foo'));
|
||||||
|
$arrayValue->addChild(new ScalarNode('bar'));
|
||||||
|
|
||||||
|
$variableValue = new VariableNode('value');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
$scalarValue,
|
||||||
|
array(
|
||||||
|
array('id' => 'option1', 'value' => 'value1'),
|
||||||
|
),
|
||||||
|
array('option1' => 'value1'),
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
$scalarValue,
|
||||||
|
array(
|
||||||
|
array('id' => 'option1', 'value' => 'value1'),
|
||||||
|
array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'option1' => 'value1',
|
||||||
|
'option2' => array('value' => 'value2', 'foo' => 'foo2'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
$arrayValue,
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'id' => 'option1',
|
||||||
|
'value' => array('foo' => 'foo1', 'bar' => 'bar1'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'option1' => array('foo' => 'foo1', 'bar' => 'bar1'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
array($variableValue,
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'id' => 'option1', 'value' => array('foo' => 'foo1', 'bar' => 'bar1'),
|
||||||
|
),
|
||||||
|
array('id' => 'option2', 'value' => 'value2'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'option1' => array('foo' => 'foo1', 'bar' => 'bar1'),
|
||||||
|
'option2' => 'value2',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,15 @@ class Command
|
|||||||
if ($code instanceof \Closure) {
|
if ($code instanceof \Closure) {
|
||||||
$r = new \ReflectionFunction($code);
|
$r = new \ReflectionFunction($code);
|
||||||
if (null === $r->getClosureThis()) {
|
if (null === $r->getClosureThis()) {
|
||||||
$code = \Closure::bind($code, $this);
|
if (PHP_VERSION_ID < 70000) {
|
||||||
|
// Bug in PHP5: https://bugs.php.net/bug.php?id=64761
|
||||||
|
// This means that we cannot bind static closures and therefore we must
|
||||||
|
// ignore any errors here. There is no way to test if the closure is
|
||||||
|
// bindable.
|
||||||
|
$code = @\Closure::bind($code, $this);
|
||||||
|
} else {
|
||||||
|
$code = \Closure::bind($code, $this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +334,29 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay());
|
$this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetCodeWithStaticClosure()
|
||||||
|
{
|
||||||
|
$command = new \TestCommand();
|
||||||
|
$command->setCode(self::createClosure());
|
||||||
|
$tester = new CommandTester($command);
|
||||||
|
$tester->execute(array());
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 70000) {
|
||||||
|
// Cannot bind static closures in PHP 5
|
||||||
|
$this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay());
|
||||||
|
} else {
|
||||||
|
// Can bind static closures in PHP 7
|
||||||
|
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function createClosure()
|
||||||
|
{
|
||||||
|
return function (InputInterface $input, OutputInterface $output) {
|
||||||
|
$output->writeln(isset($this) ? 'bound' : 'not bound');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetCodeWithNonClosureCallable()
|
public function testSetCodeWithNonClosureCallable()
|
||||||
{
|
{
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
|
@ -148,7 +148,7 @@
|
|||||||
<xsd:attribute name="id" type="xsd:string" />
|
<xsd:attribute name="id" type="xsd:string" />
|
||||||
<xsd:attribute name="key" type="xsd:string" />
|
<xsd:attribute name="key" type="xsd:string" />
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
<xsd:attribute name="on-invalid" type="xsd:string" />
|
<xsd:attribute name="on-invalid" type="invalid_sequence" />
|
||||||
<xsd:attribute name="strict" type="boolean" />
|
<xsd:attribute name="strict" type="boolean" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
@ -161,7 +161,7 @@
|
|||||||
<xsd:attribute name="id" type="xsd:string" />
|
<xsd:attribute name="id" type="xsd:string" />
|
||||||
<xsd:attribute name="key" type="xsd:string" />
|
<xsd:attribute name="key" type="xsd:string" />
|
||||||
<xsd:attribute name="index" type="xsd:integer" />
|
<xsd:attribute name="index" type="xsd:integer" />
|
||||||
<xsd:attribute name="on-invalid" type="xsd:string" />
|
<xsd:attribute name="on-invalid" type="invalid_sequence" />
|
||||||
<xsd:attribute name="strict" type="boolean" />
|
<xsd:attribute name="strict" type="boolean" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
$options = array();
|
$options = array();
|
||||||
}
|
}
|
||||||
} elseif (strlen((string) $node) > 0) {
|
} elseif (strlen((string) $node) > 0) {
|
||||||
$options = trim($node);
|
$options = XmlUtils::phpize(trim($node));
|
||||||
} else {
|
} else {
|
||||||
$options = null;
|
$options = null;
|
||||||
}
|
}
|
||||||
|
@ -310,6 +310,10 @@
|
|||||||
<source>This value does not match the expected {{ charset }} charset.</source>
|
<source>This value does not match the expected {{ charset }} charset.</source>
|
||||||
<target>Nilai ini tidak memenuhi set karakter {{ charset }} yang diharapkan.</target>
|
<target>Nilai ini tidak memenuhi set karakter {{ charset }} yang diharapkan.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="81">
|
||||||
|
<source>This is not a valid Business Identifier Code (BIC).</source>
|
||||||
|
<target>Ini bukan Business Identifier Code (BIC) yang sah.</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
@ -19,6 +19,7 @@ use Symfony\Component\Validator\Constraints\NotNull;
|
|||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Validator\Constraints\Regex;
|
use Symfony\Component\Validator\Constraints\Regex;
|
||||||
use Symfony\Component\Validator\Constraints\IsTrue;
|
use Symfony\Component\Validator\Constraints\IsTrue;
|
||||||
|
use Symfony\Component\Validator\Constraints\Traverse;
|
||||||
use Symfony\Component\Validator\Exception\MappingException;
|
use Symfony\Component\Validator\Exception\MappingException;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader;
|
use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader;
|
||||||
@ -57,6 +58,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$expected->addConstraint(new Callback('validateMe'));
|
$expected->addConstraint(new Callback('validateMe'));
|
||||||
$expected->addConstraint(new Callback('validateMeStatic'));
|
$expected->addConstraint(new Callback('validateMeStatic'));
|
||||||
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
|
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
|
||||||
|
$expected->addConstraint(new Traverse(false));
|
||||||
$expected->addPropertyConstraint('firstName', new NotNull());
|
$expected->addPropertyConstraint('firstName', new NotNull());
|
||||||
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
|
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
|
||||||
$expected->addPropertyConstraint('firstName', new Choice(array('A', 'B')));
|
$expected->addPropertyConstraint('firstName', new Choice(array('A', 'B')));
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
<value>callback</value>
|
<value>callback</value>
|
||||||
</constraint>
|
</constraint>
|
||||||
|
|
||||||
|
<!-- Traverse with boolean default option -->
|
||||||
|
<constraint name="Traverse">
|
||||||
|
false
|
||||||
|
</constraint>
|
||||||
|
|
||||||
<!-- PROPERTY CONSTRAINTS -->
|
<!-- PROPERTY CONSTRAINTS -->
|
||||||
|
|
||||||
<property name="firstName">
|
<property name="firstName">
|
||||||
|
@ -167,12 +167,12 @@ class ReflectionCaster
|
|||||||
|
|
||||||
foreach ($c->getParameters() as $v) {
|
foreach ($c->getParameters() as $v) {
|
||||||
$k = '$'.$v->name;
|
$k = '$'.$v->name;
|
||||||
if ($v->isPassedByReference()) {
|
|
||||||
$k = '&'.$k;
|
|
||||||
}
|
|
||||||
if (method_exists($v, 'isVariadic') && $v->isVariadic()) {
|
if (method_exists($v, 'isVariadic') && $v->isVariadic()) {
|
||||||
$k = '...'.$k;
|
$k = '...'.$k;
|
||||||
}
|
}
|
||||||
|
if ($v->isPassedByReference()) {
|
||||||
|
$k = '&'.$k;
|
||||||
|
}
|
||||||
$a[$prefix.'parameters'][$k] = $v;
|
$a[$prefix.'parameters'][$k] = $v;
|
||||||
}
|
}
|
||||||
if (isset($a[$prefix.'parameters'])) {
|
if (isset($a[$prefix.'parameters'])) {
|
||||||
|
Reference in New Issue
Block a user