You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (true === $this->atLeastOne || false === $this->allowEmptyValue) {
427
+
if (false === $this->allowEmptyValue) {
428
+
@trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), E_USER_DEPRECATED);
429
+
}
430
+
431
+
if (true === $this->atLeastOne) {
428
432
$node->setMinNumberOfElements(1);
429
433
}
430
434
@@ -486,9 +490,7 @@ protected function validateConcreteNode(ArrayNode $node)
486
490
}
487
491
488
492
if (false === $this->allowEmptyValue) {
489
-
thrownewInvalidDefinitionException(
490
-
sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s"', $path)
491
-
);
493
+
@trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php
+18-7Lines changed: 18 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,6 @@ public function providePrototypeNodeSpecificCalls()
54
54
array('defaultValue', array(array())),
55
55
array('addDefaultChildrenIfNoneSet', array()),
56
56
array('requiresAtLeastOneElement', array()),
57
-
array('cannotBeEmpty', array()),
58
57
array('useAttributeAsKey', array('foo')),
59
58
);
60
59
}
@@ -298,6 +297,20 @@ public function testRequiresAtLeastOneElement()
298
297
$this->addToAssertionCount(1);
299
298
}
300
299
300
+
/**
301
+
* @group legacy
302
+
* @expectedDeprecation Using Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::cannotBeEmpty() at path "root" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.
303
+
*/
304
+
publicfunctiontestCannotBeEmpty()
305
+
{
306
+
$node = newArrayNodeDefinition('root');
307
+
$node
308
+
->cannotBeEmpty()
309
+
->integerPrototype();
310
+
311
+
$node->getNode()->finalize(array());
312
+
}
313
+
301
314
publicfunctiontestSetDeprecated()
302
315
{
303
316
$node = newArrayNodeDefinition('root');
@@ -313,15 +326,13 @@ public function testSetDeprecated()
0 commit comments