Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | well… |
RFC? | no |
Symfony version | all since 2.5.0 |
While #23032 also deals with arrays, this bug is specific to traversing mixed hierarchies of arrays and objects. The issue is that arrays are added to the todo list for traversing if they carry any constraint. This behaviour has been introduced in the original implementation of RecursiveContextualValidator
back in 2.5.0. Older versions behaved correctly (tested with latest 2.3). This is a BC break with unsupported versions, I’m not sure if it qualifies.
Minimal test scenario:
<?php
class Foo
{
/** @Assert\Count(min=1, max=1) */
public $bars;
public function __construct()
{
$this->bars = array(new Bar());
}
}
class Bar
{
/** @Assert\NotBlank */
public $baz;
}
$validator->validate(new Foo());
If the Count
constraint is removed, validation passes, as validation does not traverse $bars
by default.
I created a failing test that also works below 2.5.