Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Validator] Fixed calling getters before resolving groups
- Loading branch information
Showing
5 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Symfony/Component/Validator/Tests/Fixtures/EntityWithGroupedConstraintOnMethods.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Validator\Tests\Fixtures; | ||
|
||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class EntityWithGroupedConstraintOnMethods | ||
{ | ||
public $bar; | ||
|
||
public function isValidInFoo() | ||
{ | ||
return false; | ||
} | ||
|
||
public function getBar() | ||
{ | ||
throw new \Exception('Should not be called'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Symfony/Component/Validator/Validator/LazyProperty.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Validator\Validator; | ||
|
||
/** | ||
* A wrapper for a callable initializing a property from a getter. | ||
* | ||
* @internal | ||
*/ | ||
class LazyProperty | ||
{ | ||
private $propertyValueCallback; | ||
|
||
public function __construct(\Closure $propertyValueCallback) | ||
{ | ||
$this->propertyValueCallback = $propertyValueCallback; | ||
} | ||
|
||
public function getPropertyValue() | ||
{ | ||
return \call_user_func($this->propertyValueCallback); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters