8000 [Validator] Improved inline documentation of CascadingStrategy and Tr… · symfony/symfony@9ca61df · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ca61df

Browse files
committed
[Validator] Improved inline documentation of CascadingStrategy and TraversalStrategy
1 parent 524a953 commit 9ca61df

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

src/Symfony/Component/Validator/Mapping/CascadingStrategy.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,41 @@
1212
namespace Symfony\Component\Validator\Mapping;
1313

1414
/**
15-
* @since %%NextVersion%%
15+
* Specifies whether an object should be cascaded.
16+
*
17+
* Cascading is relevant for any node type but class nodes. If such a node
18+
* contains an object of value, and if cascading is enabled, then the node
19+
* traverser will try to find class metadata for that object and validate the
20+
* object against that metadata.
21+
*
22+
* If no metadata is found for a cascaded object, and if that object implements
23+
* {@link \Traversable}, the node traverser will iterate over the object and
24+
* cascade each object or collection contained within, unless iteration is
25+
* prohibited by the specified {@link TraversalStrategy}.
26+
*
27+
* Although the constants currently represent a boolean switch, they are
28+
* implemented as bit mask in order to allow future extensions.
29+
*
30+
* @since 2.5
1631
* @author Bernhard Schussek <bschussek@gmail.com>
32+
*
33+
* @see TraversalStrategy
1734
*/
1835
class CascadingStrategy
1936
{
20-
const NONE = 0;
37+
/**
38+
* Specifies that a node should not be cascaded.
39+
*/
40+
const NONE = 1;
2141

22-
const CASCADE = 1;
42+
/**
43+
* Specifies that a node should be cascaded.
44+
*/
45+
const CASCADE = 2;
2346

47+
/**
48+
* Not instantiable.
49+
*/
2450
private function __construct()
2551
{
2652
}

src/Symfony/Component/Validator/Mapping/TraversalStrategy.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,50 @@
1212
namespace Symfony\Component\Validator\Mapping;
1313

1414
/**
15-
* @since %%NextVersion%%
15+
* Specifies whether and how a traversable object should be traversed.
16+
*
17+
* If the node traverser traverses a node whose value is an instance of
18+
* {@link \Traversable}, and if that node is either a class node or if
19+
* cascading is enabled, then the node's traversal strategy will be checked.
20+
* Depending on the requested traversal strategy, the node traverser will
21+
* iterate over the object and cascade each object or collection returned by
22+
* the iterator.
23+
*
24+
* The traversal strategy is ignored for arrays. Arrays are always iterated.
25+
*
26+
* @since 2.1
1627
* @author Bernhard Schussek <bschussek@gmail.com>
28+
*
29+
* @see CascadingStrategy
1730
*/
1831
class TraversalStrategy
1932
{
2033
/**
21-
* @var integer
34+
* Specifies that a node's value should be iterated only if it is an
35+
* instance of {@link \Traversable}.
2236
*/
2337
const IMPLICIT = 1;
2438

39+
/**
40+
* Specifies that a node's value should never be iterated.
41+
*/
2542
const NONE = 2;
2643

44+
/**
45+
* Specifies that a node's value should always be iterated. If the value is
46+
* not an instance of {@link \Traversable}, an exception should be thrown.
47+
*/
2748
const TRAVERSE = 4;
2849

50+
/**
51+
* Specifies that nested instances of {@link \Traversable} should never be
52+
* iterated. Can be combined with {@link IMPLICIT} or {@link TRAVERSE}.
53+
*/
2954
const STOP_RECURSION = 8;
3055

56+
/**
57+
* Not instantiable.
58+
*/
3159
private function __construct()
3260
{
3361
}

src/Symfony/Component/Validator/NodeTraverser/NonRecursiveNodeTraverser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
* @author Bernhard Schussek <bschussek@gmail.com>
5656
*
5757
* @see NodeTraverserInterface
58+
* @see CascadingStrategy
59+
* @see TraversalStrategy
5860
*/
5961
class NonRecursiveNodeTraverser implements NodeTraverserInterface
6062
{

0 commit comments

Comments
 (0)
0