diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Mapping/FieldMapping.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/FieldMapping.php')
| -rw-r--r-- | vendor/doctrine/orm/src/Mapping/FieldMapping.php | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/FieldMapping.php b/vendor/doctrine/orm/src/Mapping/FieldMapping.php new file mode 100644 index 0000000..4c09196 --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/FieldMapping.php | |||
| @@ -0,0 +1,169 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM\Mapping; | ||
| 6 | |||
| 7 | use ArrayAccess; | ||
| 8 | use BackedEnum; | ||
| 9 | |||
| 10 | use function in_array; | ||
| 11 | use function property_exists; | ||
| 12 | |||
| 13 | /** @template-implements ArrayAccess<string, mixed> */ | ||
| 14 | final class FieldMapping implements ArrayAccess | ||
| 15 | { | ||
| 16 | use ArrayAccessImplementation; | ||
| 17 | |||
| 18 | /** The database length of the column. Optional. Default value taken from the type. */ | ||
| 19 | public int|null $length = null; | ||
| 20 | /** | ||
| 21 | * Marks the field as the primary key of the entity. Multiple | ||
| 22 | * fields of an entity can have the id attribute, forming a composite key. | ||
| 23 | */ | ||
| 24 | public bool|null $id = null; | ||
| 25 | public bool|null $nullable = null; | ||
| 26 | public bool|null $notInsertable = null; | ||
| 27 | public bool|null $notUpdatable = null; | ||
| 28 | public string|null $columnDefinition = null; | ||
| 29 | /** @psalm-var ClassMetadata::GENERATED_*|null */ | ||
| 30 | public int|null $generated = null; | ||
| 31 | /** @var class-string<BackedEnum>|null */ | ||
| 32 | public string|null $enumType = null; | ||
| 33 | /** | ||
| 34 | * The precision of a decimal column. | ||
| 35 | * Only valid if the column type is decimal | ||
| 36 | */ | ||
| 37 | public int|null $precision = null; | ||
| 38 | /** | ||
| 39 | * The scale of a decimal column. | ||
| 40 | * Only valid if the column type is decimal | ||
| 41 | */ | ||
| 42 | public int|null $scale = null; | ||
| 43 | /** Whether a unique constraint should be generated for the column. */ | ||
| 44 | public bool|null $unique = null; | ||
| 45 | /** | ||
| 46 | * @var class-string|null This is set when the field is inherited by this | ||
| 47 | * class from another (inheritance) parent <em>entity</em> class. The value | ||
| 48 | * is the FQCN of the topmost entity class that contains mapping information | ||
| 49 | * for this field. (If there are transient classes in the class hierarchy, | ||
| 50 | * these are ignored, so the class property may in fact come from a class | ||
| 51 | * further up in the PHP class hierarchy.) | ||
| 52 | * Fields initially declared in mapped superclasses are | ||
| 53 | * <em>not</em> considered 'inherited' in the nearest entity subclasses. | ||
| 54 | */ | ||
| 55 | public string|null $inherited = null; | ||
| 56 | |||
| 57 | public string|null $originalClass = null; | ||
| 58 | public string|null $originalField = null; | ||
| 59 | public bool|null $quoted = null; | ||
| 60 | /** | ||
| 61 | * @var class-string|null This is set when the field does not appear for | ||
| 62 | * the first time in this class, but is originally declared in another | ||
| 63 | * parent <em>entity or mapped superclass</em>. The value is the FQCN of | ||
| 64 | * the topmost non-transient class that contains mapping information for | ||
| 65 | * this field. | ||
| 66 | */ | ||
| 67 | public string|null $declared = null; | ||
| 68 | public string|null $declaredField = null; | ||
| 69 | public array|null $options = null; | ||
| 70 | public bool|null $version = null; | ||
| 71 | public string|int|null $default = null; | ||
| 72 | |||
| 73 | /** | ||
| 74 | * @param string $type The type name of the mapped field. Can be one of | ||
| 75 | * Doctrine's mapping types or a custom mapping type. | ||
| 76 | * @param string $fieldName The name of the field in the Entity. | ||
| 77 | * @param string $columnName The column name. Optional. Defaults to the field name. | ||
| 78 | */ | ||
| 79 | public function __construct( | ||
| 80 | public string $type, | ||
| 81 | public string $fieldName, | ||
| 82 | public string $columnName, | ||
| 83 | ) { | ||
| 84 | } | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @param array<string, mixed> $mappingArray | ||
| 88 | * @psalm-param array{ | ||
| 89 | * type: string, | ||
| 90 | * fieldName: string, | ||
| 91 | * columnName: string, | ||
| 92 | * length?: int|null, | ||
| 93 | * id?: bool|null, | ||
| 94 | * nullable?: bool|null, | ||
| 95 | * notInsertable?: bool|null, | ||
| 96 | * notUpdatable?: bool|null, | ||
| 97 | * columnDefinition?: string|null, | ||
| 98 | * generated?: ClassMetadata::GENERATED_*|null, | ||
| 99 | * enumType?: string|null, | ||
| 100 | * precision?: int|null, | ||
| 101 | * scale?: int|null, | ||
| 102 | * unique?: bool|null, | ||
| 103 | * inherited?: string|null, | ||
| 104 | * originalClass?: string|null, | ||
| 105 | * originalField?: string|null, | ||
| 106 | * quoted?: bool|null, | ||
| 107 | * declared?: string|null, | ||
| 108 | * declaredField?: string|null, | ||
| 109 | * options?: array<string, mixed>|null, | ||
| 110 | * version?: bool|null, | ||
| 111 | * default?: string|int|null, | ||
| 112 | * } $mappingArray | ||
| 113 | */ | ||
| 114 | public static function fromMappingArray(array $mappingArray): self | ||
| 115 | { | ||
| 116 | $mapping = new self( | ||
| 117 | $mappingArray['type'], | ||
| 118 | $mappingArray['fieldName'], | ||
| 119 | $mappingArray['columnName'], | ||
| 120 | ); | ||
| 121 | foreach ($mappingArray as $key => $value) { | ||
| 122 | if (in_array($key, ['type', 'fieldName', 'columnName'])) { | ||
| 123 | continue; | ||
| 124 | } | ||
| 125 | |||
| 126 | if (property_exists($mapping, $key)) { | ||
| 127 | $mapping->$key = $value; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | return $mapping; | ||
| 132 | } | ||
| 133 | |||
| 134 | /** @return list<string> */ | ||
| 135 | public function __sleep(): array | ||
| 136 | { | ||
| 137 | $serialized = ['type', 'fieldName', 'columnName']; | ||
| 138 | |||
| 139 | foreach (['nullable', 'notInsertable', 'notUpdatable', 'id', 'unique', 'version', 'quoted'] as $boolKey) { | ||
| 140 | if ($this->$boolKey) { | ||
| 141 | $serialized[] = $boolKey; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | foreach ( | ||
| 146 | [ | ||
| 147 | 'length', | ||
| 148 | 'columnDefinition', | ||
| 149 | 'generated', | ||
| 150 | 'enumType', | ||
| 151 | 'precision', | ||
| 152 | 'scale', | ||
| 153 | 'inherited', | ||
| 154 | 'originalClass', | ||
| 155 | 'originalField', | ||
| 156 | 'declared', | ||
| 157 | 'declaredField', | ||
| 158 | 'options', | ||
| 159 | 'default', | ||
| 160 | ] as $key | ||
| 161 | ) { | ||
| 162 | if ($this->$key !== null) { | ||
| 163 | $serialized[] = $key; | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | return $serialized; | ||
| 168 | } | ||
| 169 | } | ||
