Skip to content

[Validator] New NodeTraverser implementation #10287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 86 commits into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
25cdc68
[Validator] Refactored ValidatorTest and ValidationVisitorTest into a…
webmozart Feb 12, 2014
a6ed4ca
[Validator] Prototype of the traverser implementation
webmozart Feb 17, 2014
a40189c
[Validator] Decoupled the new classes a bit
webmozart Feb 17, 2014
7e3a41d
[Validator] Moved visitors to NodeVisitor namespace
webmozart Feb 17, 2014
b1a9477
[Validator] Added ObjectInitializer visitor
webmozart Feb 17, 2014
1156bde
[Validator] Extracted code for group sequence resolving into GroupSeq…
webmozart Feb 17, 2014
321d5bb
[Validator] Throw exception if ObjectInitializer is constructed witho…
webmozart Feb 17, 2014
680f1ee
[Validator] Renamed $params to $parameters
webmozart Feb 17, 2014
8ae68c9
[Validator] Made tests green (yay!)
webmozart Feb 18, 2014
c1b1e03
[Validator] Added TODO reminder
webmozart Feb 18, 2014
5fbf848
[Validator] Added note about Callback constraint to CHANGELOG
webmozart Feb 18, 2014
8318286
[Validator] Completed GroupSequence implementation
webmozart Feb 18, 2014
f6b7288
[Validator] Removed unused use statement
webmozart Feb 18, 2014
4ea3ff6
[Validator] Finished inline documentation of ExecutionContext[Interface]
webmozart Feb 18, 2014
adc1437
[Validator] Fixed failing tests
webmozart Feb 18, 2014
499b2bb
[Validator] Completed test coverage of ExecutionContext
webmozart Feb 18, 2014
405a03b
[Validator] Updated deprecation notes in GroupSequence
webmozart Feb 18, 2014
9b07b0c
[Validator] Implemented BC validation of arrays through validate()
webmozart Feb 18, 2014
297ba4f
[Validator] Added a note why scalars are passed to cascadeObject() in…
webmozart Feb 18, 2014
09f744b
[Validator] Implemented BC traversal of traversables through validate()
webmozart Feb 18, 2014
ee1adad
[Validator] Implemented handling of arrays and Traversables in Legacy…
webmozart Feb 19, 2014
718601c
[Validator] Changed validateValue() to validate() in the new API
webmozart Feb 19, 2014
feb3d6f
[Validator] Tested the validation in a separate context
webmozart Feb 19, 2014
1e81f3b
[Validator] Finished test coverage and documentation of ExecutionCont…
webmozart Feb 19, 2014
9c9e715
[Validator] Completed documentation of GroupManagerInterface
webmozart Feb 19, 2014
2c65a28
[Validator] Completed test coverage and documentation of the Node cla…
webmozart Feb 19, 2014
a3555fb
[Validator] Fixed: Objects are not traversed unless they are instance…
webmozart Feb 19, 2014
bc29591
[Validator] Clearly separated classes supporting the API <2.5/2.5+
webmozart Feb 19, 2014
26eafa4
[Validator] Removed unused use statements
webmozart Feb 19, 2014
df41974
[Validator] Changed context manager to context factory
webmozart Feb 19, 2014
e440690
[Validator] Renamed validateCollection() to validateObjects()
webmozart Feb 19, 2014
e057b19
[Validator] Decoupled ContextRefresher from ExecutionContext
webmozart Feb 19, 2014
230f2a7
[Validator] Fixed exception message
webmozart Feb 19, 2014
cf1281f
[Validator] Added "Visitor" suffix to all node visitors
webmozart Feb 20, 2014
94583a9
[Validator] Changed NodeTraverser to traverse nodes iteratively, not …
webmozart Feb 20, 2014
117b1b9
[Validator] Wrapped collections into CollectionNode instances
webmozart Feb 20, 2014
51197f6
[Validator] Made traversal of Traversables consistent
webmozart Feb 20, 2014
08172bf
[Validator] Merged validate(), validateObject() and validateObjects()…
webmozart Feb 20, 2014
aeb6822
[Validator] Improved visitor names
webmozart Feb 20, 2014
4161371
[Validator] Removed unused use statements
webmozart Feb 20, 2014
76d8c9a
[Validator] Fixed typos
webmozart Feb 20, 2014
778ec24
[Validator] Removed helper class Traversal
webmozart Feb 20, 2014
6fc6ecd
[Validator] Fixed tests under PHP<5.3.9
webmozart Feb 20, 2014
2936d10
[Validator] Removed unused use statement
webmozart Feb 20, 2014
e8fa15b
[Validator] Fixed the new validator API under PHP < 5.3.9
webmozart Feb 20, 2014
8558377
[Validator] Added deprecation notes
webmozart Feb 20, 2014
dbce5a2
[Validator] Updated outdated doc blocks
webmozart Feb 20, 2014
822fe47
[Validator] Completed inline documentation of the Node classes and th…
webmozart Feb 21, 2014
186c115
[Validator] Improved test coverage of NonRecursiveNodeTraverser
webmozart Feb 21, 2014
299c2dc
[Validator] Improved test coverage and prevented duplicate validation…
webmozart Feb 21, 2014
be7f055
[Validator] Visitors may now abort the traversal by returning false f…
webmozart Feb 21, 2014
9986f03
[Validator] Added inline documentation for the PropertyPath utility c…
webmozart Feb 21, 2014
524a953
[Validator] Improved inline documentation of the validators
webmozart Feb 21, 2014
9ca61df
[Validator] Improved inline documentation of CascadingStrategy and Tr…
webmozart Feb 21, 2014
01ceeda
[Validator] Improved test coverage of the Traverse constraint
webmozart Feb 21, 2014
79387a7
[Validator] Improved inline documentation of the metadata classes
webmozart Feb 21, 2014
987313d
[Validator] Improved inline documentation of the violation builder
webmozart Feb 21, 2014
93fdff7
[Validator] The supported API versions can now be passed to the Valid…
webmozart Feb 21, 2014
886e05e
[Validator] Removed unused use statement
webmozart Feb 21, 2014
f61d31e
[Validator] Fixed grammar
webmozart Feb 21, 2014
23534ca
[Validator] Added a recursive clone of the new implementation for spe…
webmozart Feb 22, 2014
38e26fb
[Validator] Decoupled RecursiveContextualValidator from Node
webmozart Feb 22, 2014
274d4e6
[Validator] Changed ValidatorBuilder to always use LegacyExecutionCon…
webmozart Mar 11, 2014
eeed509
[Validator] Improved phpdoc of RecursiveValidator
webmozart Mar 11, 2014
5c479d8
[Validator] Simplified validateNodeForGroup
webmozart Mar 11, 2014
eed29d8
[Validator] Improved performance of *ContextualValidator::validate()
webmozart Mar 11, 2014
50bb84d
[Validator] Optimized RecursiveContextualValidator
webmozart Mar 11, 2014
be508e0
[Validator] Merged DefaultGroupReplacingVisitor and ContextUpdateVisi…
webmozart Mar 11, 2014
1622eb3
[Validator] Fixed reference to removed class in ValidatorBuilder
webmozart Mar 11, 2014
94ef21e
[Validator] Optimized use statements
webmozart Mar 17, 2014
73c9cc5
[Validator] Optimized performance by calling spl_object_hash() only o…
webmozart Mar 17, 2014
2f23d97
[Validator] Reduced number of method calls on the execution context
webmozart Mar 17, 2014
029a716
[Validator] Moved logic of replaceDefaultGroup() to validateNode()
webmozart Mar 17, 2014
3183aed
[Validator] Improved performance of cache key generation
webmozart Mar 17, 2014
90c27bb
[Validator] Removed traverser implementation
webmozart Mar 18, 2014
166d71a
[Validator] Removed unused property
webmozart Mar 18, 2014
7bc952d
[Validator] Improved inline documentation of RecursiveContextualValid…
webmozart Mar 18, 2014
1b111d0
[Validator] Fixed typos pointed out by @cordoval
webmozart Mar 18, 2014
0946dbe
[Validator] Adapted CHANGELOG
webmozart Mar 18, 2014
9b204c9
[FrameworkBundle] Implemented configuration to select the desired Val…
webmozart Mar 18, 2014
c5629bb
[Validator] Added getObject() to ExecutionContextInterface
webmozart Mar 18, 2014
3dc2b4d
[Validator] Made "symfony/property-access" an optional dependency
webmozart Mar 18, 2014
0bfde4a
[Validator] Fixed misnamed method calls in FrameworkExtension
webmozart Mar 18, 2014
b1badea
[Validator] Fixed failing CsrfFormLoginTest
webmozart Mar 30, 2014
68d8018
[Validator] Documented changes in the UPGRADE files
webmozart Mar 30, 2014
ca6a722
[Validator] Converted `@deprecate` doc comment into regular doc comment
webmozart Mar 30, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 114 additions & 1 deletion UPGRADE-2.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ Validator

After:

Default email validation is now done via a simple regex which may cause invalid emails (not RFC compilant) to be
Default email validation is now done via a simple regex which may cause invalid emails (not RFC compilant) to be
valid. This is the default behaviour.

Strict email validation has to be explicitly activated in the configuration file by adding

```
framework:
//...
Expand All @@ -68,7 +69,119 @@ Validator
//...

```

Also you have to add to your composer.json:

```
"egulias/email-validator": "1.1.*"
```

* `ClassMetadata::getGroupSequence()` now returns `GroupSequence` instances
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"now returns a GroupSequence instance" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please clarify your question?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it return a single one or multiple? The first line makes me think it returns a list of GroupSequence's but the following line talks as it returns a single instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it now. It returns one only, will fix :)

instead of an array. The sequence implements `\Traversable`, `\ArrayAccess`
and `\Countable`, so in most cases you should be fine. If you however use the
sequence with PHP's `array_*()` functions, you should cast it to an array
first using `iterator_to_array()`:

Before:

```
$sequence = $metadata->getGroupSequence();
$result = array_map($callback, $sequence);
```

After:

```
$sequence = iterator_to_array($metadata->getGroupSequence());
$result = array_map($callback, $sequence);
```

* The array type hint in `ClassMetadata::setGroupSequence()` was removed. If
you overwrite this method, make sure to remove the type hint as well. The
method should now accept `GroupSequence` instances just as well as arrays.

Before:

```
public function setGroupSequence(array $groups)
{
// ...
}
```

After:

```
public function setGroupSequence($groupSequence)
{
// ...
}
```

* The validation engine in `Symfony\Component\Validator\Validator` was replaced
by a new one in `Symfony\Component\Validator\Validator\RecursiveValidator`.
With that change, several classes were deprecated that will be removed in
Symfony 3.0. Also, the API of the validator was slightly changed. More
details about that can be found in UPGRADE-3.0.

You can choose the desired API via the new "api" entry in
app/config/config.yml:

```
framework:
validation:
enabled: true
api: auto
```

When running PHP 5.3.9 or higher, Symfony will then use an implementation
that supports both the old API and the new one:

```
framework:
validation:
enabled: true
api: 2.5-bc
```

When running PHP lower than 5.3.9, that compatibility layer is not supported.
On those versions, the old implementation will be used instead:

```
framework:
validation:
enabled: true
api: 2.4
```

If you develop a new application that doesn't rely on the old API, you can
also set the API to 2.5. In that case, the backwards compatibility layer
will not be activated:

```
framework:
validation:
enabled: true
api: 2.5
```

When using the validator outside of the Symfony full-stack framework, the
desired API can be selected using `setApiVersion()` on the validator builder:

```
// Previous implementation
$validator = Validation::createValidatorBuilder()
->setApiVersion(Validation::API_VERSION_2_4)
->getValidator();

// New implementation with backwards compatibility support
$validator = Validation::createValidatorBuilder()
->setApiVersion(Validation::API_VERSION_2_5_BC)
->getValidator();

// New implementation without backwards compatibility support
$validator = Validation::createValidatorBuilder()
->setApiVersion(Validation::API_VERSION_2_5)
->getValidator();
```

Loading