mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-23 03:56:23 +00:00
26 lines
365 B
Markdown
26 lines
365 B
Markdown
---
|
|
id: f0c76a12-b940-461d-8888-fecdab2fa971
|
|
title: Required
|
|
---
|
|
|
|
# Description
|
|
|
|
Attribute replacement for [@required](20201117112017-required).
|
|
|
|
# Syntax
|
|
|
|
``` php
|
|
use Symfony\Contracts\Service\Attribute\Required;
|
|
|
|
class SomeService
|
|
{
|
|
#[Required]
|
|
public Bar $bar;
|
|
|
|
#[Required]
|
|
public function setFoo(Foo $foo): void
|
|
{
|
|
// ...
|
|
}
|
|
}
|
|
```
|