by EGreg · 5y ago · 0 comments
class User
{
/**
* @Assert\All({
* @Assert\NotNull,
* @Assert\Length(min=5)
* })
*/
public string $name = '';
}
PHP 8.1
class User
{
#[\Assert\All(
new \Assert\NotNull,
new \Assert\Length(min: 6))
]
public string $name = '';
}Very similar to Java annotations.
That piece of code is about data validation.
See more at https://www.php.net/manual/en/language.attributes.overview.p...
https://front-line-php.com/cheat-sheet
It’s covered under “Attributes”.