diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/AttributeOverrides.php')
-rw-r--r-- | vendor/doctrine/orm/src/Mapping/AttributeOverrides.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/AttributeOverrides.php b/vendor/doctrine/orm/src/Mapping/AttributeOverrides.php new file mode 100644 index 0000000..9c7b9db --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/AttributeOverrides.php | |||
@@ -0,0 +1,38 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Mapping; | ||
6 | |||
7 | use Attribute; | ||
8 | |||
9 | use function array_values; | ||
10 | use function is_array; | ||
11 | |||
12 | /** This attribute is used to override the mapping of a entity property. */ | ||
13 | #[Attribute(Attribute::TARGET_CLASS)] | ||
14 | final class AttributeOverrides implements MappingAttribute | ||
15 | { | ||
16 | /** | ||
17 | * One or more field or property mapping overrides. | ||
18 | * | ||
19 | * @var list<AttributeOverride> | ||
20 | */ | ||
21 | public readonly array $overrides; | ||
22 | |||
23 | /** @param array<AttributeOverride>|AttributeOverride $overrides */ | ||
24 | public function __construct(array|AttributeOverride $overrides) | ||
25 | { | ||
26 | if (! is_array($overrides)) { | ||
27 | $overrides = [$overrides]; | ||
28 | } | ||
29 | |||
30 | foreach ($overrides as $override) { | ||
31 | if (! ($override instanceof AttributeOverride)) { | ||
32 | throw MappingException::invalidOverrideType('AttributeOverride', $override); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | $this->overrides = array_values($overrides); | ||
37 | } | ||
38 | } | ||