1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Cycle\Annotated\Annotation; |
||
6 | |||
7 | use Doctrine\Common\Annotations\Annotation\Target; |
||
8 | use JetBrains\PhpStorm\ExpectedValues; |
||
9 | use Spiral\Attributes\NamedArgumentConstructor; |
||
10 | |||
11 | /** |
||
12 | * @Annotation |
||
13 | * @NamedArgumentConstructor |
||
14 | * @Target({"PROPERTY", "ANNOTATION", "CLASS"}) |
||
15 | */ |
||
16 | #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] |
||
17 | #[NamedArgumentConstructor] |
||
18 | class ForeignKey |
||
19 | { |
||
20 | /** |
||
21 | * @param non-empty-string $target Role or class name of the target entity. |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
22 | * @param list<non-empty-string>|non-empty-string|null $innerKey You don't need to specify this if the attribute |
||
23 | * is used on a property. |
||
24 | * @param list<non-empty-string>|non-empty-string|null $outerKey Outer key in the target entity. |
||
25 | * Defaults to the primary key. |
||
26 | * @param 'CASCADE'|'NO ACTION'|'SET null' $action |
||
27 | * @param bool $indexCreate Note: MySQL and MSSQL might create an index for the foreign key automatically. |
||
28 | */ |
||
29 | public function __construct( |
||
30 | public string $target, |
||
31 | public array|string|null $innerKey = null, |
||
32 | public array|string|null $outerKey = null, |
||
33 | /** |
||
34 | * @Enum({"NO ACTION", "CASCADE", "SET NULL"}) |
||
35 | */ |
||
36 | #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])] |
||
37 | public string $action = 'CASCADE', |
||
38 | public bool $indexCreate = true, |
||
39 | ) { |
||
40 | } |
||
41 | } |
||
42 |