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/persistence/src/Persistence/Mapping | |
| 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/persistence/src/Persistence/Mapping')
17 files changed, 2355 insertions, 0 deletions
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php b/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php new file mode 100644 index 0000000..e8f6aca --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php | |||
| @@ -0,0 +1,499 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\Driver\MappingDriver; | ||
| 8 | use Doctrine\Persistence\Proxy; | ||
| 9 | use Psr\Cache\CacheItemPoolInterface; | ||
| 10 | use ReflectionClass; | ||
| 11 | use ReflectionException; | ||
| 12 | |||
| 13 | use function array_combine; | ||
| 14 | use function array_keys; | ||
| 15 | use function array_map; | ||
| 16 | use function array_reverse; | ||
| 17 | use function array_unshift; | ||
| 18 | use function assert; | ||
| 19 | use function class_exists; | ||
| 20 | use function ltrim; | ||
| 21 | use function str_replace; | ||
| 22 | use function strpos; | ||
| 23 | use function strrpos; | ||
| 24 | use function substr; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the | ||
| 28 | * metadata mapping informations of a class which describes how a class should be mapped | ||
| 29 | * to a relational database. | ||
| 30 | * | ||
| 31 | * This class was abstracted from the ORM ClassMetadataFactory. | ||
| 32 | * | ||
| 33 | * @template CMTemplate of ClassMetadata | ||
| 34 | * @template-implements ClassMetadataFactory<CMTemplate> | ||
| 35 | */ | ||
| 36 | abstract class AbstractClassMetadataFactory implements ClassMetadataFactory | ||
| 37 | { | ||
| 38 | /** | ||
| 39 | * Salt used by specific Object Manager implementation. | ||
| 40 | * | ||
| 41 | * @var string | ||
| 42 | */ | ||
| 43 | protected $cacheSalt = '__CLASSMETADATA__'; | ||
| 44 | |||
| 45 | /** @var CacheItemPoolInterface|null */ | ||
| 46 | private $cache; | ||
| 47 | |||
| 48 | /** | ||
| 49 | * @var array<string, ClassMetadata> | ||
| 50 | * @psalm-var CMTemplate[] | ||
| 51 | */ | ||
| 52 | private $loadedMetadata = []; | ||
| 53 | |||
| 54 | /** @var bool */ | ||
| 55 | protected $initialized = false; | ||
| 56 | |||
| 57 | /** @var ReflectionService|null */ | ||
| 58 | private $reflectionService = null; | ||
| 59 | |||
| 60 | /** @var ProxyClassNameResolver|null */ | ||
| 61 | private $proxyClassNameResolver = null; | ||
| 62 | |||
| 63 | public function setCache(CacheItemPoolInterface $cache): void | ||
| 64 | { | ||
| 65 | $this->cache = $cache; | ||
| 66 | } | ||
| 67 | |||
| 68 | final protected function getCache(): ?CacheItemPoolInterface | ||
| 69 | { | ||
| 70 | return $this->cache; | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Returns an array of all the loaded metadata currently in memory. | ||
| 75 | * | ||
| 76 | * @return ClassMetadata[] | ||
| 77 | * @psalm-return CMTemplate[] | ||
| 78 | */ | ||
| 79 | public function getLoadedMetadata() | ||
| 80 | { | ||
| 81 | return $this->loadedMetadata; | ||
| 82 | } | ||
| 83 | |||
| 84 | /** | ||
| 85 | * {@inheritDoc} | ||
| 86 | */ | ||
| 87 | public function getAllMetadata() | ||
| 88 | { | ||
| 89 | if (! $this->initialized) { | ||
| 90 | $this->initialize(); | ||
| 91 | } | ||
| 92 | |||
| 93 | $driver = $this->getDriver(); | ||
| 94 | $metadata = []; | ||
| 95 | foreach ($driver->getAllClassNames() as $className) { | ||
| 96 | $metadata[] = $this->getMetadataFor($className); | ||
| 97 | } | ||
| 98 | |||
| 99 | return $metadata; | ||
| 100 | } | ||
| 101 | |||
| 102 | public function setProxyClassNameResolver(ProxyClassNameResolver $resolver): void | ||
| 103 | { | ||
| 104 | $this->proxyClassNameResolver = $resolver; | ||
| 105 | } | ||
| 106 | |||
| 107 | /** | ||
| 108 | * Lazy initialization of this stuff, especially the metadata driver, | ||
| 109 | * since these are not needed at all when a metadata cache is active. | ||
| 110 | * | ||
| 111 | * @return void | ||
| 112 | */ | ||
| 113 | abstract protected function initialize(); | ||
| 114 | |||
| 115 | /** | ||
| 116 | * Returns the mapping driver implementation. | ||
| 117 | * | ||
| 118 | * @return MappingDriver | ||
| 119 | */ | ||
| 120 | abstract protected function getDriver(); | ||
| 121 | |||
| 122 | /** | ||
| 123 | * Wakes up reflection after ClassMetadata gets unserialized from cache. | ||
| 124 | * | ||
| 125 | * @psalm-param CMTemplate $class | ||
| 126 | * | ||
| 127 | * @return void | ||
| 128 | */ | ||
| 129 | abstract protected function wakeupReflection( | ||
| 130 | ClassMetadata $class, | ||
| 131 | ReflectionService $reflService | ||
| 132 | ); | ||
| 133 | |||
| 134 | /** | ||
| 135 | * Initializes Reflection after ClassMetadata was constructed. | ||
| 136 | * | ||
| 137 | * @psalm-param CMTemplate $class | ||
| 138 | * | ||
| 139 | * @return void | ||
| 140 | */ | ||
| 141 | abstract protected function initializeReflection( | ||
| 142 | ClassMetadata $class, | ||
| 143 | ReflectionService $reflService | ||
| 144 | ); | ||
| 145 | |||
| 146 | /** | ||
| 147 | * Checks whether the class metadata is an entity. | ||
| 148 | * | ||
| 149 | * This method should return false for mapped superclasses or embedded classes. | ||
| 150 | * | ||
| 151 | * @psalm-param CMTemplate $class | ||
| 152 | * | ||
| 153 | * @return bool | ||
| 154 | */ | ||
| 155 | abstract protected function isEntity(ClassMetadata $class); | ||
| 156 | |||
| 157 | /** | ||
| 158 | * Removes the prepended backslash of a class string to conform with how php outputs class names | ||
| 159 | * | ||
| 160 | * @psalm-param class-string $className | ||
| 161 | * | ||
| 162 | * @psalm-return class-string | ||
| 163 | */ | ||
| 164 | private function normalizeClassName(string $className): string | ||
| 165 | { | ||
| 166 | return ltrim($className, '\\'); | ||
| 167 | } | ||
| 168 | |||
| 169 | /** | ||
| 170 | * {@inheritDoc} | ||
| 171 | * | ||
| 172 | * @throws ReflectionException | ||
| 173 | * @throws MappingException | ||
| 174 | */ | ||
| 175 | public function getMetadataFor(string $className) | ||
| 176 | { | ||
| 177 | $className = $this->normalizeClassName($className); | ||
| 178 | |||
| 179 | if (isset($this->loadedMetadata[$className])) { | ||
| 180 | return $this->loadedMetadata[$className]; | ||
| 181 | } | ||
| 182 | |||
| 183 | if (class_exists($className, false) && (new ReflectionClass($className))->isAnonymous()) { | ||
| 184 | throw MappingException::classIsAnonymous($className); | ||
| 185 | } | ||
| 186 | |||
| 187 | if (! class_exists($className, false) && strpos($className, ':') !== false) { | ||
| 188 | throw MappingException::nonExistingClass($className); | ||
| 189 | } | ||
| 190 | |||
| 191 | $realClassName = $this->getRealClass($className); | ||
| 192 | |||
| 193 | if (isset($this->loadedMetadata[$realClassName])) { | ||
| 194 | // We do not have the alias name in the map, include it | ||
| 195 | return $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; | ||
| 196 | } | ||
| 197 | |||
| 198 | try { | ||
| 199 | if ($this->cache !== null) { | ||
| 200 | $cached = $this->cache->getItem($this->getCacheKey($realClassName))->get(); | ||
| 201 | if ($cached instanceof ClassMetadata) { | ||
| 202 | /** @psalm-var CMTemplate $cached */ | ||
| 203 | $this->loadedMetadata[$realClassName] = $cached; | ||
| 204 | |||
| 205 | $this->wakeupReflection($cached, $this->getReflectionService()); | ||
| 206 | } else { | ||
| 207 | $loadedMetadata = $this->loadMetadata($realClassName); | ||
| 208 | $classNames = array_combine( | ||
| 209 | array_map([$this, 'getCacheKey'], $loadedMetadata), | ||
| 210 | $loadedMetadata | ||
| 211 | ); | ||
| 212 | |||
| 213 | foreach ($this->cache->getItems(array_keys($classNames)) as $item) { | ||
| 214 | if (! isset($classNames[$item->getKey()])) { | ||
| 215 | continue; | ||
| 216 | } | ||
| 217 | |||
| 218 | $item->set($this->loadedMetadata[$classNames[$item->getKey()]]); | ||
| 219 | $this->cache->saveDeferred($item); | ||
| 220 | } | ||
| 221 | |||
| 222 | $this->cache->commit(); | ||
| 223 | } | ||
| 224 | } else { | ||
| 225 | $this->loadMetadata($realClassName); | ||
| 226 | } | ||
| 227 | } catch (MappingException $loadingException) { | ||
| 228 | $fallbackMetadataResponse = $this->onNotFoundMetadata($realClassName); | ||
| 229 | |||
| 230 | if ($fallbackMetadataResponse === null) { | ||
| 231 | throw $loadingException; | ||
| 232 | } | ||
| 233 | |||
| 234 | $this->loadedMetadata[$realClassName] = $fallbackMetadataResponse; | ||
| 235 | } | ||
| 236 | |||
| 237 | if ($className !== $realClassName) { | ||
| 238 | // We do not have the alias name in the map, include it | ||
| 239 | $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; | ||
| 240 | } | ||
| 241 | |||
| 242 | return $this->loadedMetadata[$className]; | ||
| 243 | } | ||
| 244 | |||
| 245 | /** | ||
| 246 | * {@inheritDoc} | ||
| 247 | */ | ||
| 248 | public function hasMetadataFor(string $className) | ||
| 249 | { | ||
| 250 | $className = $this->normalizeClassName($className); | ||
| 251 | |||
| 252 | return isset($this->loadedMetadata[$className]); | ||
| 253 | } | ||
| 254 | |||
| 255 | /** | ||
| 256 | * Sets the metadata descriptor for a specific class. | ||
| 257 | * | ||
| 258 | * NOTE: This is only useful in very special cases, like when generating proxy classes. | ||
| 259 | * | ||
| 260 | * @psalm-param class-string $className | ||
| 261 | * @psalm-param CMTemplate $class | ||
| 262 | * | ||
| 263 | * @return void | ||
| 264 | */ | ||
| 265 | public function setMetadataFor(string $className, ClassMetadata $class) | ||
| 266 | { | ||
| 267 | $this->loadedMetadata[$this->normalizeClassName($className)] = $class; | ||
| 268 | } | ||
| 269 | |||
| 270 | /** | ||
| 271 | * Gets an array of parent classes for the given entity class. | ||
| 272 | * | ||
| 273 | * @psalm-param class-string $name | ||
| 274 | * | ||
| 275 | * @return string[] | ||
| 276 | * @psalm-return list<class-string> | ||
| 277 | */ | ||
| 278 | protected function getParentClasses(string $name) | ||
| 279 | { | ||
| 280 | // Collect parent classes, ignoring transient (not-mapped) classes. | ||
| 281 | $parentClasses = []; | ||
| 282 | |||
| 283 | foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) { | ||
| 284 | if ($this->getDriver()->isTransient($parentClass)) { | ||
| 285 | continue; | ||
| 286 | } | ||
| 287 | |||
| 288 | $parentClasses[] = $parentClass; | ||
| 289 | } | ||
| 290 | |||
| 291 | return $parentClasses; | ||
| 292 | } | ||
| 293 | |||
| 294 | /** | ||
| 295 | * Loads the metadata of the class in question and all it's ancestors whose metadata | ||
| 296 | * is still not loaded. | ||
| 297 | * | ||
| 298 | * Important: The class $name does not necessarily exist at this point here. | ||
| 299 | * Scenarios in a code-generation setup might have access to XML/YAML | ||
| 300 | * Mapping files without the actual PHP code existing here. That is why the | ||
| 301 | * {@see \Doctrine\Persistence\Mapping\ReflectionService} interface | ||
| 302 | * should be used for reflection. | ||
| 303 | * | ||
| 304 | * @param string $name The name of the class for which the metadata should get loaded. | ||
| 305 | * @psalm-param class-string $name | ||
| 306 | * | ||
| 307 | * @return array<int, string> | ||
| 308 | * @psalm-return list<string> | ||
| 309 | */ | ||
| 310 | protected function loadMetadata(string $name) | ||
| 311 | { | ||
| 312 | if (! $this->initialized) { | ||
| 313 | $this->initialize(); | ||
| 314 | } | ||
| 315 | |||
| 316 | $loaded = []; | ||
| 317 | |||
| 318 | $parentClasses = $this->getParentClasses($name); | ||
| 319 | $parentClasses[] = $name; | ||
| 320 | |||
| 321 | // Move down the hierarchy of parent classes, starting from the topmost class | ||
| 322 | $parent = null; | ||
| 323 | $rootEntityFound = false; | ||
| 324 | $visited = []; | ||
| 325 | $reflService = $this->getReflectionService(); | ||
| 326 | |||
| 327 | foreach ($parentClasses as $className) { | ||
| 328 | if (isset($this->loadedMetadata[$className])) { | ||
| 329 | $parent = $this->loadedMetadata[$className]; | ||
| 330 | |||
| 331 | if ($this->isEntity($parent)) { | ||
| 332 | $rootEntityFound = true; | ||
| 333 | |||
| 334 | array_unshift($visited, $className); | ||
| 335 | } | ||
| 336 | |||
| 337 | continue; | ||
| 338 | } | ||
| 339 | |||
| 340 | $class = $this->newClassMetadataInstance($className); | ||
| 341 | $this->initializeReflection($class, $reflService); | ||
| 342 | |||
| 343 | $this->doLoadMetadata($class, $parent, $rootEntityFound, $visited); | ||
| 344 | |||
| 345 | $this->loadedMetadata[$className] = $class; | ||
| 346 | |||
| 347 | $parent = $class; | ||
| 348 | |||
| 349 | if ($this->isEntity($class)) { | ||
| 350 | $rootEntityFound = true; | ||
| 351 | |||
| 352 | array_unshift($visited, $className); | ||
| 353 | } | ||
| 354 | |||
| 355 | $this->wakeupReflection($class, $reflService); | ||
| 356 | |||
| 357 | $loaded[] = $className; | ||
| 358 | } | ||
| 359 | |||
| 360 | return $loaded; | ||
| 361 | } | ||
| 362 | |||
| 363 | /** | ||
| 364 | * Provides a fallback hook for loading metadata when loading failed due to reflection/mapping exceptions | ||
| 365 | * | ||
| 366 | * Override this method to implement a fallback strategy for failed metadata loading | ||
| 367 | * | ||
| 368 | * @return ClassMetadata|null | ||
| 369 | * @psalm-return CMTemplate|null | ||
| 370 | */ | ||
| 371 | protected function onNotFoundMetadata(string $className) | ||
| 372 | { | ||
| 373 | return null; | ||
| 374 | } | ||
| 375 | |||
| 376 | /** | ||
| 377 | * Actually loads the metadata from the underlying metadata. | ||
| 378 | * | ||
| 379 | * @param bool $rootEntityFound True when there is another entity (non-mapped superclass) class above the current class in the PHP class hierarchy. | ||
| 380 | * @param list<class-string> $nonSuperclassParents All parent class names that are not marked as mapped superclasses, with the direct parent class being the first and the root entity class the last element. | ||
| 381 | * @psalm-param CMTemplate $class | ||
| 382 | * @psalm-param CMTemplate|null $parent | ||
| 383 | * | ||
| 384 | * @return void | ||
| 385 | */ | ||
| 386 | abstract protected function doLoadMetadata( | ||
| 387 | ClassMetadata $class, | ||
| 388 | ?ClassMetadata $parent, | ||
| 389 | bool $rootEntityFound, | ||
| 390 | array $nonSuperclassParents | ||
| 391 | ); | ||
| 392 | |||
| 393 | /** | ||
| 394 | * Creates a new ClassMetadata instance for the given class name. | ||
| 395 | * | ||
| 396 | * @psalm-param class-string<T> $className | ||
| 397 | * | ||
| 398 | * @return ClassMetadata<T> | ||
| 399 | * @psalm-return CMTemplate | ||
| 400 | * | ||
| 401 | * @template T of object | ||
| 402 | */ | ||
| 403 | abstract protected function newClassMetadataInstance(string $className); | ||
| 404 | |||
| 405 | /** | ||
| 406 | * {@inheritDoc} | ||
| 407 | */ | ||
| 408 | public function isTransient(string $className) | ||
| 409 | { | ||
| 410 | if (! $this->initialized) { | ||
| 411 | $this->initialize(); | ||
| 412 | } | ||
| 413 | |||
| 414 | if (class_exists($className, false) && (new ReflectionClass($className))->isAnonymous()) { | ||
| 415 | return false; | ||
| 416 | } | ||
| 417 | |||
| 418 | if (! class_exists($className, false) && strpos($className, ':') !== false) { | ||
| 419 | throw MappingException::nonExistingClass($className); | ||
| 420 | } | ||
| 421 | |||
| 422 | /** @psalm-var class-string $className */ | ||
| 423 | return $this->getDriver()->isTransient($className); | ||
| 424 | } | ||
| 425 | |||
| 426 | /** | ||
| 427 | * Sets the reflectionService. | ||
| 428 | * | ||
| 429 | * @return void | ||
| 430 | */ | ||
| 431 | public function setReflectionService(ReflectionService $reflectionService) | ||
| 432 | { | ||
| 433 | $this->reflectionService = $reflectionService; | ||
| 434 | } | ||
| 435 | |||
| 436 | /** | ||
| 437 | * Gets the reflection service associated with this metadata factory. | ||
| 438 | * | ||
| 439 | * @return ReflectionService | ||
| 440 | */ | ||
| 441 | public function getReflectionService() | ||
| 442 | { | ||
| 443 | if ($this->reflectionService === null) { | ||
| 444 | $this->reflectionService = new RuntimeReflectionService(); | ||
| 445 | } | ||
| 446 | |||
| 447 | return $this->reflectionService; | ||
| 448 | } | ||
| 449 | |||
| 450 | protected function getCacheKey(string $realClassName): string | ||
| 451 | { | ||
| 452 | return str_replace('\\', '__', $realClassName) . $this->cacheSalt; | ||
| 453 | } | ||
| 454 | |||
| 455 | /** | ||
| 456 | * Gets the real class name of a class name that could be a proxy. | ||
| 457 | * | ||
| 458 | * @psalm-param class-string<Proxy<T>>|class-string<T> $class | ||
| 459 | * | ||
| 460 | * @psalm-return class-string<T> | ||
| 461 | * | ||
| 462 | * @template T of object | ||
| 463 | */ | ||
| 464 | private function getRealClass(string $class): string | ||
| 465 | { | ||
| 466 | if ($this->proxyClassNameResolver === null) { | ||
| 467 | $this->createDefaultProxyClassNameResolver(); | ||
| 468 | } | ||
| 469 | |||
| 470 | assert($this->proxyClassNameResolver !== null); | ||
| 471 | |||
| 472 | return $this->proxyClassNameResolver->resolveClassName($class); | ||
| 473 | } | ||
| 474 | |||
| 475 | private function createDefaultProxyClassNameResolver(): void | ||
| 476 | { | ||
| 477 | $this->proxyClassNameResolver = new class implements ProxyClassNameResolver { | ||
| 478 | /** | ||
| 479 | * @psalm-param class-string<Proxy<T>>|class-string<T> $className | ||
| 480 | * | ||
| 481 | * @psalm-return class-string<T> | ||
| 482 | * | ||
| 483 | * @template T of object | ||
| 484 | */ | ||
| 485 | public function resolveClassName(string $className): string | ||
| 486 | { | ||
| 487 | $pos = strrpos($className, '\\' . Proxy::MARKER . '\\'); | ||
| 488 | |||
| 489 | if ($pos === false) { | ||
| 490 | /** @psalm-var class-string<T> */ | ||
| 491 | return $className; | ||
| 492 | } | ||
| 493 | |||
| 494 | /** @psalm-var class-string<T> */ | ||
| 495 | return substr($className, $pos + Proxy::MARKER_LENGTH + 2); | ||
| 496 | } | ||
| 497 | }; | ||
| 498 | } | ||
| 499 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadata.php b/vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadata.php new file mode 100644 index 0000000..f407ba3 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadata.php | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use ReflectionClass; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * Contract for a Doctrine persistence layer ClassMetadata class to implement. | ||
| 11 | * | ||
| 12 | * @template-covariant T of object | ||
| 13 | */ | ||
| 14 | interface ClassMetadata | ||
| 15 | { | ||
| 16 | /** | ||
| 17 | * Gets the fully-qualified class name of this persistent class. | ||
| 18 | * | ||
| 19 | * @return string | ||
| 20 | * @psalm-return class-string<T> | ||
| 21 | */ | ||
| 22 | public function getName(); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Gets the mapped identifier field name. | ||
| 26 | * | ||
| 27 | * The returned structure is an array of the identifier field names. | ||
| 28 | * | ||
| 29 | * @return array<int, string> | ||
| 30 | * @psalm-return list<string> | ||
| 31 | */ | ||
| 32 | public function getIdentifier(); | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Gets the ReflectionClass instance for this mapped class. | ||
| 36 | * | ||
| 37 | * @return ReflectionClass<T> | ||
| 38 | */ | ||
| 39 | public function getReflectionClass(); | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Checks if the given field name is a mapped identifier for this class. | ||
| 43 | * | ||
| 44 | * @return bool | ||
| 45 | */ | ||
| 46 | public function isIdentifier(string $fieldName); | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Checks if the given field is a mapped property for this class. | ||
| 50 | * | ||
| 51 | * @return bool | ||
| 52 | */ | ||
| 53 | public function hasField(string $fieldName); | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Checks if the given field is a mapped association for this class. | ||
| 57 | * | ||
| 58 | * @return bool | ||
| 59 | */ | ||
| 60 | public function hasAssociation(string $fieldName); | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Checks if the given field is a mapped single valued association for this class. | ||
| 64 | * | ||
| 65 | * @return bool | ||
| 66 | */ | ||
| 67 | public function isSingleValuedAssociation(string $fieldName); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * Checks if the given field is a mapped collection valued association for this class. | ||
| 71 | * | ||
| 72 | * @return bool | ||
| 73 | */ | ||
| 74 | public function isCollectionValuedAssociation(string $fieldName); | ||
| 75 | |||
| 76 | /** | ||
| 77 | * A numerically indexed list of field names of this persistent class. | ||
| 78 | * | ||
| 79 | * This array includes identifier fields if present on this class. | ||
| 80 | * | ||
| 81 | * @return array<int, string> | ||
| 82 | */ | ||
| 83 | public function getFieldNames(); | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Returns an array of identifier field names numerically indexed. | ||
| 87 | * | ||
| 88 | * @return array<int, string> | ||
| 89 | */ | ||
| 90 | public function getIdentifierFieldNames(); | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Returns a numerically indexed list of association names of this persistent class. | ||
| 94 | * | ||
| 95 | * This array includes identifier associations if present on this class. | ||
| 96 | * | ||
| 97 | * @return array<int, string> | ||
| 98 | */ | ||
| 99 | public function getAssociationNames(); | ||
| 100 | |||
| 101 | /** | ||
| 102 | * Returns a type name of this field. | ||
| 103 | * | ||
| 104 | * This type names can be implementation specific but should at least include the php types: | ||
| 105 | * integer, string, boolean, float/double, datetime. | ||
| 106 | * | ||
| 107 | * @return string|null | ||
| 108 | */ | ||
| 109 | public function getTypeOfField(string $fieldName); | ||
| 110 | |||
| 111 | /** | ||
| 112 | * Returns the target class name of the given association. | ||
| 113 | * | ||
| 114 | * @return string|null | ||
| 115 | * @psalm-return class-string|null | ||
| 116 | */ | ||
| 117 | public function getAssociationTargetClass(string $assocName); | ||
| 118 | |||
| 119 | /** | ||
| 120 | * Checks if the association is the inverse side of a bidirectional association. | ||
| 121 | * | ||
| 122 | * @return bool | ||
| 123 | */ | ||
| 124 | public function isAssociationInverseSide(string $assocName); | ||
| 125 | |||
| 126 | /** | ||
| 127 | * Returns the target field of the owning side of the association. | ||
| 128 | * | ||
| 129 | * @return string | ||
| 130 | */ | ||
| 131 | public function getAssociationMappedByTargetField(string $assocName); | ||
| 132 | |||
| 133 | /** | ||
| 134 | * Returns the identifier of this object as an array with field name as key. | ||
| 135 | * | ||
| 136 | * Has to return an empty array if no identifier isset. | ||
| 137 | * | ||
| 138 | * @return array<string, mixed> | ||
| 139 | */ | ||
| 140 | public function getIdentifierValues(object $object); | ||
| 141 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadataFactory.php b/vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadataFactory.php new file mode 100644 index 0000000..28b8303 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadataFactory.php | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Contract for a Doctrine persistence layer ClassMetadata class to implement. | ||
| 9 | * | ||
| 10 | * @template T of ClassMetadata | ||
| 11 | */ | ||
| 12 | interface ClassMetadataFactory | ||
| 13 | { | ||
| 14 | /** | ||
| 15 | * Forces the factory to load the metadata of all classes known to the underlying | ||
| 16 | * mapping driver. | ||
| 17 | * | ||
| 18 | * @return ClassMetadata[] The ClassMetadata instances of all mapped classes. | ||
| 19 | * @psalm-return list<T> | ||
| 20 | */ | ||
| 21 | public function getAllMetadata(); | ||
| 22 | |||
| 23 | /** | ||
| 24 | * Gets the class metadata descriptor for a class. | ||
| 25 | * | ||
| 26 | * @param class-string $className The name of the class. | ||
| 27 | * | ||
| 28 | * @return ClassMetadata | ||
| 29 | * @psalm-return T | ||
| 30 | */ | ||
| 31 | public function getMetadataFor(string $className); | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Checks whether the factory has the metadata for a class loaded already. | ||
| 35 | * | ||
| 36 | * @param class-string $className | ||
| 37 | * | ||
| 38 | * @return bool TRUE if the metadata of the class in question is already loaded, FALSE otherwise. | ||
| 39 | */ | ||
| 40 | public function hasMetadataFor(string $className); | ||
| 41 | |||
| 42 | /** | ||
| 43 | * Sets the metadata descriptor for a specific class. | ||
| 44 | * | ||
| 45 | * @param class-string $className | ||
| 46 | * @psalm-param T $class | ||
| 47 | * | ||
| 48 | * @return void | ||
| 49 | */ | ||
| 50 | public function setMetadataFor(string $className, ClassMetadata $class); | ||
| 51 | |||
| 52 | /** | ||
| 53 | * Returns whether the class with the specified name should have its metadata loaded. | ||
| 54 | * This is only the case if it is either mapped directly or as a MappedSuperclass. | ||
| 55 | * | ||
| 56 | * @psalm-param class-string $className | ||
| 57 | * | ||
| 58 | * @return bool | ||
| 59 | */ | ||
| 60 | public function isTransient(string $className); | ||
| 61 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/ColocatedMappingDriver.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/ColocatedMappingDriver.php new file mode 100644 index 0000000..e85ba70 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/ColocatedMappingDriver.php | |||
| @@ -0,0 +1,212 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\MappingException; | ||
| 8 | use FilesystemIterator; | ||
| 9 | use RecursiveDirectoryIterator; | ||
| 10 | use RecursiveIteratorIterator; | ||
| 11 | use RecursiveRegexIterator; | ||
| 12 | use ReflectionClass; | ||
| 13 | use RegexIterator; | ||
| 14 | |||
| 15 | use function array_merge; | ||
| 16 | use function array_unique; | ||
| 17 | use function assert; | ||
| 18 | use function get_declared_classes; | ||
| 19 | use function in_array; | ||
| 20 | use function is_dir; | ||
| 21 | use function preg_match; | ||
| 22 | use function preg_quote; | ||
| 23 | use function realpath; | ||
| 24 | use function str_replace; | ||
| 25 | use function strpos; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * The ColocatedMappingDriver reads the mapping metadata located near the code. | ||
| 29 | */ | ||
| 30 | trait ColocatedMappingDriver | ||
| 31 | { | ||
| 32 | /** | ||
| 33 | * The paths where to look for mapping files. | ||
| 34 | * | ||
| 35 | * @var array<int, string> | ||
| 36 | */ | ||
| 37 | protected $paths = []; | ||
| 38 | |||
| 39 | /** | ||
| 40 | * The paths excluded from path where to look for mapping files. | ||
| 41 | * | ||
| 42 | * @var array<int, string> | ||
| 43 | */ | ||
| 44 | protected $excludePaths = []; | ||
| 45 | |||
| 46 | /** | ||
| 47 | * The file extension of mapping documents. | ||
| 48 | * | ||
| 49 | * @var string | ||
| 50 | */ | ||
| 51 | protected $fileExtension = '.php'; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Cache for getAllClassNames(). | ||
| 55 | * | ||
| 56 | * @var array<int, string>|null | ||
| 57 | * @psalm-var list<class-string>|null | ||
| 58 | */ | ||
| 59 | protected $classNames; | ||
| 60 | |||
| 61 | /** | ||
| 62 | * Appends lookup paths to metadata driver. | ||
| 63 | * | ||
| 64 | * @param array<int, string> $paths | ||
| 65 | * | ||
| 66 | * @return void | ||
| 67 | */ | ||
| 68 | public function addPaths(array $paths) | ||
| 69 | { | ||
| 70 | $this->paths = array_unique(array_merge($this->paths, $paths)); | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Retrieves the defined metadata lookup paths. | ||
| 75 | * | ||
| 76 | * @return array<int, string> | ||
| 77 | */ | ||
| 78 | public function getPaths() | ||
| 79 | { | ||
| 80 | return $this->paths; | ||
| 81 | } | ||
| 82 | |||
| 83 | /** | ||
| 84 | * Append exclude lookup paths to metadata driver. | ||
| 85 | * | ||
| 86 | * @param string[] $paths | ||
| 87 | * | ||
| 88 | * @return void | ||
| 89 | */ | ||
| 90 | public function addExcludePaths(array $paths) | ||
| 91 | { | ||
| 92 | $this->excludePaths = array_unique(array_merge($this->excludePaths, $paths)); | ||
| 93 | } | ||
| 94 | |||
| 95 | /** | ||
| 96 | * Retrieve the defined metadata lookup exclude paths. | ||
| 97 | * | ||
| 98 | * @return array<int, string> | ||
| 99 | */ | ||
| 100 | public function getExcludePaths() | ||
| 101 | { | ||
| 102 | return $this->excludePaths; | ||
| 103 | } | ||
| 104 | |||
| 105 | /** | ||
| 106 | * Gets the file extension used to look for mapping files under. | ||
| 107 | * | ||
| 108 | * @return string | ||
| 109 | */ | ||
| 110 | public function getFileExtension() | ||
| 111 | { | ||
| 112 | return $this->fileExtension; | ||
| 113 | } | ||
| 114 | |||
| 115 | /** | ||
| 116 | * Sets the file extension used to look for mapping files under. | ||
| 117 | * | ||
| 118 | * @return void | ||
| 119 | */ | ||
| 120 | public function setFileExtension(string $fileExtension) | ||
| 121 | { | ||
| 122 | $this->fileExtension = $fileExtension; | ||
| 123 | } | ||
| 124 | |||
| 125 | /** | ||
| 126 | * {@inheritDoc} | ||
| 127 | * | ||
| 128 | * Returns whether the class with the specified name is transient. Only non-transient | ||
| 129 | * classes, that is entities and mapped superclasses, should have their metadata loaded. | ||
| 130 | * | ||
| 131 | * @psalm-param class-string $className | ||
| 132 | * | ||
| 133 | * @return bool | ||
| 134 | */ | ||
| 135 | abstract public function isTransient(string $className); | ||
| 136 | |||
| 137 | /** | ||
| 138 | * Gets the names of all mapped classes known to this driver. | ||
| 139 | * | ||
| 140 | * @return string[] The names of all mapped classes known to this driver. | ||
| 141 | * @psalm-return list<class-string> | ||
| 142 | */ | ||
| 143 | public function getAllClassNames() | ||
| 144 | { | ||
| 145 | if ($this->classNames !== null) { | ||
| 146 | return $this->classNames; | ||
| 147 | } | ||
| 148 | |||
| 149 | if ($this->paths === []) { | ||
| 150 | throw MappingException::pathRequiredForDriver(static::class); | ||
| 151 | } | ||
| 152 | |||
| 153 | $classes = []; | ||
| 154 | $includedFiles = []; | ||
| 155 | |||
| 156 | foreach ($this->paths as $path) { | ||
| 157 | if (! is_dir($path)) { | ||
| 158 | throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); | ||
| 159 | } | ||
| 160 | |||
| 161 | $iterator = new RegexIterator( | ||
| 162 | new RecursiveIteratorIterator( | ||
| 163 | new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), | ||
| 164 | RecursiveIteratorIterator::LEAVES_ONLY | ||
| 165 | ), | ||
| 166 | '/^.+' . preg_quote($this->fileExtension) . '$/i', | ||
| 167 | RecursiveRegexIterator::GET_MATCH | ||
| 168 | ); | ||
| 169 | |||
| 170 | foreach ($iterator as $file) { | ||
| 171 | $sourceFile = $file[0]; | ||
| 172 | |||
| 173 | if (preg_match('(^phar:)i', $sourceFile) === 0) { | ||
| 174 | $sourceFile = realpath($sourceFile); | ||
| 175 | } | ||
| 176 | |||
| 177 | foreach ($this->excludePaths as $excludePath) { | ||
| 178 | $realExcludePath = realpath($excludePath); | ||
| 179 | assert($realExcludePath !== false); | ||
| 180 | $exclude = str_replace('\\', '/', $realExcludePath); | ||
| 181 | $current = str_replace('\\', '/', $sourceFile); | ||
| 182 | |||
| 183 | if (strpos($current, $exclude) !== false) { | ||
| 184 | continue 2; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | require_once $sourceFile; | ||
| 189 | |||
| 190 | $includedFiles[] = $sourceFile; | ||
| 191 | } | ||
| 192 | } | ||
| 193 | |||
| 194 | $declared = get_declared_classes(); | ||
| 195 | |||
| 196 | foreach ($declared as $className) { | ||
| 197 | $rc = new ReflectionClass($className); | ||
| 198 | |||
| 199 | $sourceFile = $rc->getFileName(); | ||
| 200 | |||
| 201 | if (! in_array($sourceFile, $includedFiles, true) || $this->isTransient($className)) { | ||
| 202 | continue; | ||
| 203 | } | ||
| 204 | |||
| 205 | $classes[] = $className; | ||
| 206 | } | ||
| 207 | |||
| 208 | $this->classNames = $classes; | ||
| 209 | |||
| 210 | return $classes; | ||
| 211 | } | ||
| 212 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/DefaultFileLocator.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/DefaultFileLocator.php new file mode 100644 index 0000000..9b00e74 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/DefaultFileLocator.php | |||
| @@ -0,0 +1,175 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\MappingException; | ||
| 8 | use RecursiveDirectoryIterator; | ||
| 9 | use RecursiveIteratorIterator; | ||
| 10 | |||
| 11 | use function array_merge; | ||
| 12 | use function array_unique; | ||
| 13 | use function assert; | ||
| 14 | use function is_dir; | ||
| 15 | use function is_file; | ||
| 16 | use function is_string; | ||
| 17 | use function str_replace; | ||
| 18 | |||
| 19 | use const DIRECTORY_SEPARATOR; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Locates the file that contains the metadata information for a given class name. | ||
| 23 | * | ||
| 24 | * This behavior is independent of the actual content of the file. It just detects | ||
| 25 | * the file which is responsible for the given class name. | ||
| 26 | */ | ||
| 27 | class DefaultFileLocator implements FileLocator | ||
| 28 | { | ||
| 29 | /** | ||
| 30 | * The paths where to look for mapping files. | ||
| 31 | * | ||
| 32 | * @var array<int, string> | ||
| 33 | */ | ||
| 34 | protected $paths = []; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * The file extension of mapping documents. | ||
| 38 | * | ||
| 39 | * @var string|null | ||
| 40 | */ | ||
| 41 | protected $fileExtension; | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Initializes a new FileDriver that looks in the given path(s) for mapping | ||
| 45 | * documents and operates in the specified operating mode. | ||
| 46 | * | ||
| 47 | * @param string|array<int, string> $paths One or multiple paths where mapping documents | ||
| 48 | * can be found. | ||
| 49 | * @param string|null $fileExtension The file extension of mapping documents, | ||
| 50 | * usually prefixed with a dot. | ||
| 51 | */ | ||
| 52 | public function __construct($paths, ?string $fileExtension = null) | ||
| 53 | { | ||
| 54 | $this->addPaths((array) $paths); | ||
| 55 | $this->fileExtension = $fileExtension; | ||
| 56 | } | ||
| 57 | |||
| 58 | /** | ||
| 59 | * Appends lookup paths to metadata driver. | ||
| 60 | * | ||
| 61 | * @param array<int, string> $paths | ||
| 62 | * | ||
| 63 | * @return void | ||
| 64 | */ | ||
| 65 | public function addPaths(array $paths) | ||
| 66 | { | ||
| 67 | $this->paths = array_unique(array_merge($this->paths, $paths)); | ||
| 68 | } | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Retrieves the defined metadata lookup paths. | ||
| 72 | * | ||
| 73 | * @return array<int, string> | ||
| 74 | */ | ||
| 75 | public function getPaths() | ||
| 76 | { | ||
| 77 | return $this->paths; | ||
| 78 | } | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Gets the file extension used to look for mapping files under. | ||
| 82 | * | ||
| 83 | * @return string|null | ||
| 84 | */ | ||
| 85 | public function getFileExtension() | ||
| 86 | { | ||
| 87 | return $this->fileExtension; | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Sets the file extension used to look for mapping files under. | ||
| 92 | * | ||
| 93 | * @param string|null $fileExtension The file extension to set. | ||
| 94 | * | ||
| 95 | * @return void | ||
| 96 | */ | ||
| 97 | public function setFileExtension(?string $fileExtension) | ||
| 98 | { | ||
| 99 | $this->fileExtension = $fileExtension; | ||
| 100 | } | ||
| 101 | |||
| 102 | /** | ||
| 103 | * {@inheritDoc} | ||
| 104 | */ | ||
| 105 | public function findMappingFile(string $className) | ||
| 106 | { | ||
| 107 | $fileName = str_replace('\\', '.', $className) . $this->fileExtension; | ||
| 108 | |||
| 109 | // Check whether file exists | ||
| 110 | foreach ($this->paths as $path) { | ||
| 111 | if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) { | ||
| 112 | return $path . DIRECTORY_SEPARATOR . $fileName; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | throw MappingException::mappingFileNotFound($className, $fileName); | ||
| 117 | } | ||
| 118 | |||
| 119 | /** | ||
| 120 | * {@inheritDoc} | ||
| 121 | */ | ||
| 122 | public function getAllClassNames(string $globalBasename) | ||
| 123 | { | ||
| 124 | if ($this->paths === []) { | ||
| 125 | return []; | ||
| 126 | } | ||
| 127 | |||
| 128 | $classes = []; | ||
| 129 | |||
| 130 | foreach ($this->paths as $path) { | ||
| 131 | if (! is_dir($path)) { | ||
| 132 | throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); | ||
| 133 | } | ||
| 134 | |||
| 135 | $iterator = new RecursiveIteratorIterator( | ||
| 136 | new RecursiveDirectoryIterator($path), | ||
| 137 | RecursiveIteratorIterator::LEAVES_ONLY | ||
| 138 | ); | ||
| 139 | |||
| 140 | foreach ($iterator as $file) { | ||
| 141 | $fileName = $file->getBasename($this->fileExtension); | ||
| 142 | |||
| 143 | if ($fileName === $file->getBasename() || $fileName === $globalBasename) { | ||
| 144 | continue; | ||
| 145 | } | ||
| 146 | |||
| 147 | // NOTE: All files found here means classes are not transient! | ||
| 148 | |||
| 149 | assert(is_string($fileName)); | ||
| 150 | /** @psalm-var class-string */ | ||
| 151 | $class = str_replace('.', '\\', $fileName); | ||
| 152 | $classes[] = $class; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | return $classes; | ||
| 157 | } | ||
| 158 | |||
| 159 | /** | ||
| 160 | * {@inheritDoc} | ||
| 161 | */ | ||
| 162 | public function fileExists(string $className) | ||
| 163 | { | ||
| 164 | $fileName = str_replace('\\', '.', $className) . $this->fileExtension; | ||
| 165 | |||
| 166 | // Check whether file exists | ||
| 167 | foreach ($this->paths as $path) { | ||
| 168 | if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) { | ||
| 169 | return true; | ||
| 170 | } | ||
| 171 | } | ||
| 172 | |||
| 173 | return false; | ||
| 174 | } | ||
| 175 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileDriver.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileDriver.php new file mode 100644 index 0000000..c116233 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileDriver.php | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\ClassMetadata; | ||
| 8 | use Doctrine\Persistence\Mapping\MappingException; | ||
| 9 | |||
| 10 | use function array_keys; | ||
| 11 | use function array_merge; | ||
| 12 | use function array_unique; | ||
| 13 | use function array_values; | ||
| 14 | use function is_file; | ||
| 15 | use function str_replace; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * Base driver for file-based metadata drivers. | ||
| 19 | * | ||
| 20 | * A file driver operates in a mode where it loads the mapping files of individual | ||
| 21 | * classes on demand. This requires the user to adhere to the convention of 1 mapping | ||
| 22 | * file per class and the file names of the mapping files must correspond to the full | ||
| 23 | * class name, including namespace, with the namespace delimiters '\', replaced by dots '.'. | ||
| 24 | * | ||
| 25 | * @template T | ||
| 26 | */ | ||
| 27 | abstract class FileDriver implements MappingDriver | ||
| 28 | { | ||
| 29 | /** @var FileLocator */ | ||
| 30 | protected $locator; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * @var mixed[]|null | ||
| 34 | * @psalm-var array<class-string, T>|null | ||
| 35 | */ | ||
| 36 | protected $classCache; | ||
| 37 | |||
| 38 | /** @var string */ | ||
| 39 | protected $globalBasename = ''; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Initializes a new FileDriver that looks in the given path(s) for mapping | ||
| 43 | * documents and operates in the specified operating mode. | ||
| 44 | * | ||
| 45 | * @param string|array<int, string>|FileLocator $locator A FileLocator or one/multiple paths | ||
| 46 | * where mapping documents can be found. | ||
| 47 | */ | ||
| 48 | public function __construct($locator, ?string $fileExtension = null) | ||
| 49 | { | ||
| 50 | if ($locator instanceof FileLocator) { | ||
| 51 | $this->locator = $locator; | ||
| 52 | } else { | ||
| 53 | $this->locator = new DefaultFileLocator((array) $locator, $fileExtension); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Sets the global basename. | ||
| 59 | * | ||
| 60 | * @return void | ||
| 61 | */ | ||
| 62 | public function setGlobalBasename(string $file) | ||
| 63 | { | ||
| 64 | $this->globalBasename = $file; | ||
| 65 | } | ||
| 66 | |||
| 67 | /** | ||
| 68 | * Retrieves the global basename. | ||
| 69 | * | ||
| 70 | * @return string|null | ||
| 71 | */ | ||
| 72 | public function getGlobalBasename() | ||
| 73 | { | ||
| 74 | return $this->globalBasename; | ||
| 75 | } | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Gets the element of schema meta data for the class from the mapping file. | ||
| 79 | * This will lazily load the mapping file if it is not loaded yet. | ||
| 80 | * | ||
| 81 | * @psalm-param class-string $className | ||
| 82 | * | ||
| 83 | * @return T The element of schema meta data. | ||
| 84 | * | ||
| 85 | * @throws MappingException | ||
| 86 | */ | ||
| 87 | public function getElement(string $className) | ||
| 88 | { | ||
| 89 | if ($this->classCache === null) { | ||
| 90 | $this->initialize(); | ||
| 91 | } | ||
| 92 | |||
| 93 | if (isset($this->classCache[$className])) { | ||
| 94 | return $this->classCache[$className]; | ||
| 95 | } | ||
| 96 | |||
| 97 | $result = $this->loadMappingFile($this->locator->findMappingFile($className)); | ||
| 98 | |||
| 99 | if (! isset($result[$className])) { | ||
| 100 | throw MappingException::invalidMappingFile( | ||
| 101 | $className, | ||
| 102 | str_replace('\\', '.', $className) . $this->locator->getFileExtension() | ||
| 103 | ); | ||
| 104 | } | ||
| 105 | |||
| 106 | $this->classCache[$className] = $result[$className]; | ||
| 107 | |||
| 108 | return $result[$className]; | ||
| 109 | } | ||
| 110 | |||
| 111 | /** | ||
| 112 | * {@inheritDoc} | ||
| 113 | */ | ||
| 114 | public function isTransient(string $className) | ||
| 115 | { | ||
| 116 | if ($this->classCache === null) { | ||
| 117 | $this->initialize(); | ||
| 118 | } | ||
| 119 | |||
| 120 | if (isset($this->classCache[$className])) { | ||
| 121 | return false; | ||
| 122 | } | ||
| 123 | |||
| 124 | return ! $this->locator->fileExists($className); | ||
| 125 | } | ||
| 126 | |||
| 127 | /** | ||
| 128 | * {@inheritDoc} | ||
| 129 | */ | ||
| 130 | public function getAllClassNames() | ||
| 131 | { | ||
| 132 | if ($this->classCache === null) { | ||
| 133 | $this->initialize(); | ||
| 134 | } | ||
| 135 | |||
| 136 | if ($this->classCache === []) { | ||
| 137 | return $this->locator->getAllClassNames($this->globalBasename); | ||
| 138 | } | ||
| 139 | |||
| 140 | /** @psalm-var array<class-string, ClassMetadata<object>> $classCache */ | ||
| 141 | $classCache = $this->classCache; | ||
| 142 | |||
| 143 | /** @var list<class-string> $keys */ | ||
| 144 | $keys = array_keys($classCache); | ||
| 145 | |||
| 146 | return array_values(array_unique(array_merge( | ||
| 147 | $keys, | ||
| 148 | $this->locator->getAllClassNames($this->globalBasename) | ||
| 149 | ))); | ||
| 150 | } | ||
| 151 | |||
| 152 | /** | ||
| 153 | * Loads a mapping file with the given name and returns a map | ||
| 154 | * from class/entity names to their corresponding file driver elements. | ||
| 155 | * | ||
| 156 | * @param string $file The mapping file to load. | ||
| 157 | * | ||
| 158 | * @return mixed[] | ||
| 159 | * @psalm-return array<class-string, T> | ||
| 160 | */ | ||
| 161 | abstract protected function loadMappingFile(string $file); | ||
| 162 | |||
| 163 | /** | ||
| 164 | * Initializes the class cache from all the global files. | ||
| 165 | * | ||
| 166 | * Using this feature adds a substantial performance hit to file drivers as | ||
| 167 | * more metadata has to be loaded into memory than might actually be | ||
| 168 | * necessary. This may not be relevant to scenarios where caching of | ||
| 169 | * metadata is in place, however hits very hard in scenarios where no | ||
| 170 | * caching is used. | ||
| 171 | * | ||
| 172 | * @return void | ||
| 173 | */ | ||
| 174 | protected function initialize() | ||
| 175 | { | ||
| 176 | $this->classCache = []; | ||
| 177 | if ($this->globalBasename === '') { | ||
| 178 | return; | ||
| 179 | } | ||
| 180 | |||
| 181 | foreach ($this->locator->getPaths() as $path) { | ||
| 182 | $file = $path . '/' . $this->globalBasename . $this->locator->getFileExtension(); | ||
| 183 | if (! is_file($file)) { | ||
| 184 | continue; | ||
| 185 | } | ||
| 186 | |||
| 187 | $this->classCache = array_merge( | ||
| 188 | $this->classCache, | ||
| 189 | $this->loadMappingFile($file) | ||
| 190 | ); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | |||
| 194 | /** | ||
| 195 | * Retrieves the locator used to discover mapping files by className. | ||
| 196 | * | ||
| 197 | * @return FileLocator | ||
| 198 | */ | ||
| 199 | public function getLocator() | ||
| 200 | { | ||
| 201 | return $this->locator; | ||
| 202 | } | ||
| 203 | |||
| 204 | /** | ||
| 205 | * Sets the locator used to discover mapping files by className. | ||
| 206 | * | ||
| 207 | * @return void | ||
| 208 | */ | ||
| 209 | public function setLocator(FileLocator $locator) | ||
| 210 | { | ||
| 211 | $this->locator = $locator; | ||
| 212 | } | ||
| 213 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileLocator.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileLocator.php new file mode 100644 index 0000000..e57d539 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileLocator.php | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Locates the file that contains the metadata information for a given class name. | ||
| 9 | * | ||
| 10 | * This behavior is independent of the actual content of the file. It just detects | ||
| 11 | * the file which is responsible for the given class name. | ||
| 12 | */ | ||
| 13 | interface FileLocator | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * Locates mapping file for the given class name. | ||
| 17 | * | ||
| 18 | * @return string | ||
| 19 | */ | ||
| 20 | public function findMappingFile(string $className); | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Gets all class names that are found with this file locator. | ||
| 24 | * | ||
| 25 | * @param string $globalBasename Passed to allow excluding the basename. | ||
| 26 | * | ||
| 27 | * @return array<int, string> | ||
| 28 | * @psalm-return list<class-string> | ||
| 29 | */ | ||
| 30 | public function getAllClassNames(string $globalBasename); | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Checks if a file can be found for this class name. | ||
| 34 | * | ||
| 35 | * @return bool | ||
| 36 | */ | ||
| 37 | public function fileExists(string $className); | ||
| 38 | |||
| 39 | /** | ||
| 40 | * Gets all the paths that this file locator looks for mapping files. | ||
| 41 | * | ||
| 42 | * @return array<int, string> | ||
| 43 | */ | ||
| 44 | public function getPaths(); | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Gets the file extension that mapping files are suffixed with. | ||
| 48 | * | ||
| 49 | * @return string|null | ||
| 50 | */ | ||
| 51 | public function getFileExtension(); | ||
| 52 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriver.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriver.php new file mode 100644 index 0000000..9b6f0c8 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriver.php | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\ClassMetadata; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * Contract for metadata drivers. | ||
| 11 | */ | ||
| 12 | interface MappingDriver | ||
| 13 | { | ||
| 14 | /** | ||
| 15 | * Loads the metadata for the specified class into the provided container. | ||
| 16 | * | ||
| 17 | * @psalm-param class-string<T> $className | ||
| 18 | * @psalm-param ClassMetadata<T> $metadata | ||
| 19 | * | ||
| 20 | * @return void | ||
| 21 | * | ||
| 22 | * @template T of object | ||
| 23 | */ | ||
| 24 | public function loadMetadataForClass(string $className, ClassMetadata $metadata); | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Gets the names of all mapped classes known to this driver. | ||
| 28 | * | ||
| 29 | * @return array<int, string> The names of all mapped classes known to this driver. | ||
| 30 | * @psalm-return list<class-string> | ||
| 31 | */ | ||
| 32 | public function getAllClassNames(); | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Returns whether the class with the specified name should have its metadata loaded. | ||
| 36 | * This is only the case if it is either mapped as an Entity or a MappedSuperclass. | ||
| 37 | * | ||
| 38 | * @psalm-param class-string $className | ||
| 39 | * | ||
| 40 | * @return bool | ||
| 41 | */ | ||
| 42 | public function isTransient(string $className); | ||
| 43 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php new file mode 100644 index 0000000..8563dd2 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\ClassMetadata; | ||
| 8 | use Doctrine\Persistence\Mapping\MappingException; | ||
| 9 | |||
| 10 | use function array_keys; | ||
| 11 | use function spl_object_hash; | ||
| 12 | use function strpos; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * The DriverChain allows you to add multiple other mapping drivers for | ||
| 16 | * certain namespaces. | ||
| 17 | */ | ||
| 18 | class MappingDriverChain implements MappingDriver | ||
| 19 | { | ||
| 20 | /** | ||
| 21 | * The default driver. | ||
| 22 | * | ||
| 23 | * @var MappingDriver|null | ||
| 24 | */ | ||
| 25 | private $defaultDriver; | ||
| 26 | |||
| 27 | /** @var array<string, MappingDriver> */ | ||
| 28 | private $drivers = []; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * Gets the default driver. | ||
| 32 | * | ||
| 33 | * @return MappingDriver|null | ||
| 34 | */ | ||
| 35 | public function getDefaultDriver() | ||
| 36 | { | ||
| 37 | return $this->defaultDriver; | ||
| 38 | } | ||
| 39 | |||
| 40 | /** | ||
| 41 | * Set the default driver. | ||
| 42 | * | ||
| 43 | * @return void | ||
| 44 | */ | ||
| 45 | public function setDefaultDriver(MappingDriver $driver) | ||
| 46 | { | ||
| 47 | $this->defaultDriver = $driver; | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Adds a nested driver. | ||
| 52 | * | ||
| 53 | * @return void | ||
| 54 | */ | ||
| 55 | public function addDriver(MappingDriver $nestedDriver, string $namespace) | ||
| 56 | { | ||
| 57 | $this->drivers[$namespace] = $nestedDriver; | ||
| 58 | } | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Gets the array of nested drivers. | ||
| 62 | * | ||
| 63 | * @return array<string, MappingDriver> $drivers | ||
| 64 | */ | ||
| 65 | public function getDrivers() | ||
| 66 | { | ||
| 67 | return $this->drivers; | ||
| 68 | } | ||
| 69 | |||
| 70 | /** | ||
| 71 | * {@inheritDoc} | ||
| 72 | */ | ||
| 73 | public function loadMetadataForClass(string $className, ClassMetadata $metadata) | ||
| 74 | { | ||
| 75 | foreach ($this->drivers as $namespace => $driver) { | ||
| 76 | if (strpos($className, $namespace) === 0) { | ||
| 77 | $driver->loadMetadataForClass($className, $metadata); | ||
| 78 | |||
| 79 | return; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | if ($this->defaultDriver !== null) { | ||
| 84 | $this->defaultDriver->loadMetadataForClass($className, $metadata); | ||
| 85 | |||
| 86 | return; | ||
| 87 | } | ||
| 88 | |||
| 89 | throw MappingException::classNotFoundInNamespaces($className, array_keys($this->drivers)); | ||
| 90 | } | ||
| 91 | |||
| 92 | /** | ||
| 93 | * {@inheritDoc} | ||
| 94 | */ | ||
| 95 | public function getAllClassNames() | ||
| 96 | { | ||
| 97 | $classNames = []; | ||
| 98 | $driverClasses = []; | ||
| 99 | |||
| 100 | foreach ($this->drivers as $namespace => $driver) { | ||
| 101 | $oid = spl_object_hash($driver); | ||
| 102 | |||
| 103 | if (! isset($driverClasses[$oid])) { | ||
| 104 | $driverClasses[$oid] = $driver->getAllClassNames(); | ||
| 105 | } | ||
| 106 | |||
| 107 | foreach ($driverClasses[$oid] as $className) { | ||
| 108 | if (strpos($className, $namespace) !== 0) { | ||
| 109 | continue; | ||
| 110 | } | ||
| 111 | |||
| 112 | $classNames[$className] = true; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | if ($this->defaultDriver !== null) { | ||
| 117 | foreach ($this->defaultDriver->getAllClassNames() as $className) { | ||
| 118 | $classNames[$className] = true; | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | return array_keys($classNames); | ||
| 123 | } | ||
| 124 | |||
| 125 | /** | ||
| 126 | * {@inheritDoc} | ||
| 127 | */ | ||
| 128 | public function isTransient(string $className) | ||
| 129 | { | ||
| 130 | foreach ($this->drivers as $namespace => $driver) { | ||
| 131 | if (strpos($className, $namespace) === 0) { | ||
| 132 | return $driver->isTransient($className); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | if ($this->defaultDriver !== null) { | ||
| 137 | return $this->defaultDriver->isTransient($className); | ||
| 138 | } | ||
| 139 | |||
| 140 | return true; | ||
| 141 | } | ||
| 142 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/PHPDriver.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/PHPDriver.php new file mode 100644 index 0000000..1c1ab9c --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/PHPDriver.php | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\ClassMetadata; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * The PHPDriver includes php files which just populate ClassMetadataInfo | ||
| 11 | * instances with plain PHP code. | ||
| 12 | * | ||
| 13 | * @template-extends FileDriver<ClassMetadata<object>> | ||
| 14 | */ | ||
| 15 | class PHPDriver extends FileDriver | ||
| 16 | { | ||
| 17 | /** | ||
| 18 | * @var ClassMetadata | ||
| 19 | * @psalm-var ClassMetadata<object> | ||
| 20 | */ | ||
| 21 | protected $metadata; | ||
| 22 | |||
| 23 | /** @param string|array<int, string>|FileLocator $locator */ | ||
| 24 | public function __construct($locator) | ||
| 25 | { | ||
| 26 | parent::__construct($locator, '.php'); | ||
| 27 | } | ||
| 28 | |||
| 29 | /** | ||
| 30 | * {@inheritDoc} | ||
| 31 | */ | ||
| 32 | public function loadMetadataForClass(string $className, ClassMetadata $metadata) | ||
| 33 | { | ||
| 34 | $this->metadata = $metadata; | ||
| 35 | |||
| 36 | $this->loadMappingFile($this->locator->findMappingFile($className)); | ||
| 37 | } | ||
| 38 | |||
| 39 | /** | ||
| 40 | * {@inheritDoc} | ||
| 41 | */ | ||
| 42 | protected function loadMappingFile(string $file) | ||
| 43 | { | ||
| 44 | $metadata = $this->metadata; | ||
| 45 | include $file; | ||
| 46 | |||
| 47 | return [$metadata->getName() => $metadata]; | ||
| 48 | } | ||
| 49 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/StaticPHPDriver.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/StaticPHPDriver.php new file mode 100644 index 0000000..bbcff75 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/StaticPHPDriver.php | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\ClassMetadata; | ||
| 8 | use Doctrine\Persistence\Mapping\MappingException; | ||
| 9 | use RecursiveDirectoryIterator; | ||
| 10 | use RecursiveIteratorIterator; | ||
| 11 | use ReflectionClass; | ||
| 12 | |||
| 13 | use function array_merge; | ||
| 14 | use function array_unique; | ||
| 15 | use function get_declared_classes; | ||
| 16 | use function in_array; | ||
| 17 | use function is_dir; | ||
| 18 | use function method_exists; | ||
| 19 | use function realpath; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * The StaticPHPDriver calls a static loadMetadata() method on your entity | ||
| 23 | * classes where you can manually populate the ClassMetadata instance. | ||
| 24 | */ | ||
| 25 | class StaticPHPDriver implements MappingDriver | ||
| 26 | { | ||
| 27 | /** | ||
| 28 | * Paths of entity directories. | ||
| 29 | * | ||
| 30 | * @var array<int, string> | ||
| 31 | */ | ||
| 32 | private $paths = []; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Map of all class names. | ||
| 36 | * | ||
| 37 | * @var array<int, string> | ||
| 38 | * @psalm-var list<class-string> | ||
| 39 | */ | ||
| 40 | private $classNames; | ||
| 41 | |||
| 42 | /** @param array<int, string>|string $paths */ | ||
| 43 | public function __construct($paths) | ||
| 44 | { | ||
| 45 | $this->addPaths((array) $paths); | ||
| 46 | } | ||
| 47 | |||
| 48 | /** | ||
| 49 | * @param array<int, string> $paths | ||
| 50 | * | ||
| 51 | * @return void | ||
| 52 | */ | ||
| 53 | public function addPaths(array $paths) | ||
| 54 | { | ||
| 55 | $this->paths = array_unique(array_merge($this->paths, $paths)); | ||
| 56 | } | ||
| 57 | |||
| 58 | /** | ||
| 59 | * {@inheritDoc} | ||
| 60 | */ | ||
| 61 | public function loadMetadataForClass(string $className, ClassMetadata $metadata) | ||
| 62 | { | ||
| 63 | $className::loadMetadata($metadata); | ||
| 64 | } | ||
| 65 | |||
| 66 | /** | ||
| 67 | * {@inheritDoc} | ||
| 68 | * | ||
| 69 | * @todo Same code exists in ColocatedMappingDriver, should we re-use it | ||
| 70 | * somehow or not worry about it? | ||
| 71 | */ | ||
| 72 | public function getAllClassNames() | ||
| 73 | { | ||
| 74 | if ($this->classNames !== null) { | ||
| 75 | return $this->classNames; | ||
| 76 | } | ||
| 77 | |||
| 78 | if ($this->paths === []) { | ||
| 79 | throw MappingException::pathRequiredForDriver(static::class); | ||
| 80 | } | ||
| 81 | |||
| 82 | $classes = []; | ||
| 83 | $includedFiles = []; | ||
| 84 | |||
| 85 | foreach ($this->paths as $path) { | ||
| 86 | if (! is_dir($path)) { | ||
| 87 | throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); | ||
| 88 | } | ||
| 89 | |||
| 90 | $iterator = new RecursiveIteratorIterator( | ||
| 91 | new RecursiveDirectoryIterator($path), | ||
| 92 | RecursiveIteratorIterator::LEAVES_ONLY | ||
| 93 | ); | ||
| 94 | |||
| 95 | foreach ($iterator as $file) { | ||
| 96 | if ($file->getBasename('.php') === $file->getBasename()) { | ||
| 97 | continue; | ||
| 98 | } | ||
| 99 | |||
| 100 | $sourceFile = realpath($file->getPathName()); | ||
| 101 | require_once $sourceFile; | ||
| 102 | $includedFiles[] = $sourceFile; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | $declared = get_declared_classes(); | ||
| 107 | |||
| 108 | foreach ($declared as $className) { | ||
| 109 | $rc = new ReflectionClass($className); | ||
| 110 | |||
| 111 | $sourceFile = $rc->getFileName(); | ||
| 112 | |||
| 113 | if (! in_array($sourceFile, $includedFiles, true) || $this->isTransient($className)) { | ||
| 114 | continue; | ||
| 115 | } | ||
| 116 | |||
| 117 | $classes[] = $className; | ||
| 118 | } | ||
| 119 | |||
| 120 | $this->classNames = $classes; | ||
| 121 | |||
| 122 | return $classes; | ||
| 123 | } | ||
| 124 | |||
| 125 | /** | ||
| 126 | * {@inheritDoc} | ||
| 127 | */ | ||
| 128 | public function isTransient(string $className) | ||
| 129 | { | ||
| 130 | return ! method_exists($className, 'loadMetadata'); | ||
| 131 | } | ||
| 132 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/SymfonyFileLocator.php b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/SymfonyFileLocator.php new file mode 100644 index 0000000..428d5fb --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/SymfonyFileLocator.php | |||
| @@ -0,0 +1,265 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping\Driver; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Mapping\MappingException; | ||
| 8 | use InvalidArgumentException; | ||
| 9 | use RecursiveDirectoryIterator; | ||
| 10 | use RecursiveIteratorIterator; | ||
| 11 | use RuntimeException; | ||
| 12 | |||
| 13 | use function array_keys; | ||
| 14 | use function array_merge; | ||
| 15 | use function assert; | ||
| 16 | use function is_dir; | ||
| 17 | use function is_file; | ||
| 18 | use function is_int; | ||
| 19 | use function realpath; | ||
| 20 | use function sprintf; | ||
| 21 | use function str_replace; | ||
| 22 | use function strlen; | ||
| 23 | use function strpos; | ||
| 24 | use function strrpos; | ||
| 25 | use function strtr; | ||
| 26 | use function substr; | ||
| 27 | |||
| 28 | use const DIRECTORY_SEPARATOR; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * The Symfony File Locator makes a simplifying assumptions compared | ||
| 32 | * to the DefaultFileLocator. By assuming paths only contain entities of a certain | ||
| 33 | * namespace the mapping files consists of the short classname only. | ||
| 34 | */ | ||
| 35 | class SymfonyFileLocator implements FileLocator | ||
| 36 | { | ||
| 37 | /** | ||
| 38 | * The paths where to look for mapping files. | ||
| 39 | * | ||
| 40 | * @var array<int, string> | ||
| 41 | */ | ||
| 42 | protected $paths = []; | ||
| 43 | |||
| 44 | /** | ||
| 45 | * A map of mapping directory path to namespace prefix used to expand class shortnames. | ||
| 46 | * | ||
| 47 | * @var array<string, string> | ||
| 48 | */ | ||
| 49 | protected $prefixes = []; | ||
| 50 | |||
| 51 | /** | ||
| 52 | * File extension that is searched for. | ||
| 53 | * | ||
| 54 | * @var string|null | ||
| 55 | */ | ||
| 56 | protected $fileExtension; | ||
| 57 | |||
| 58 | /** | ||
| 59 | * Represents PHP namespace delimiters when looking for files | ||
| 60 | * | ||
| 61 | * @var string | ||
| 62 | */ | ||
| 63 | private $nsSeparator; | ||
| 64 | |||
| 65 | /** | ||
| 66 | * @param array<string, string> $prefixes | ||
| 67 | * @param string $nsSeparator String which would be used when converting FQCN | ||
| 68 | * to filename and vice versa. Should not be empty | ||
| 69 | */ | ||
| 70 | public function __construct( | ||
| 71 | array $prefixes, | ||
| 72 | string $fileExtension = '', | ||
| 73 | string $nsSeparator = '.' | ||
| 74 | ) { | ||
| 75 | $this->addNamespacePrefixes($prefixes); | ||
| 76 | $this->fileExtension = $fileExtension; | ||
| 77 | |||
| 78 | if ($nsSeparator === '') { | ||
| 79 | throw new InvalidArgumentException('Namespace separator should not be empty'); | ||
| 80 | } | ||
| 81 | |||
| 82 | $this->nsSeparator = $nsSeparator; | ||
| 83 | } | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Adds Namespace Prefixes. | ||
| 87 | * | ||
| 88 | * @param array<string, string> $prefixes | ||
| 89 | * | ||
| 90 | * @return void | ||
| 91 | */ | ||
| 92 | public function addNamespacePrefixes(array $prefixes) | ||
| 93 | { | ||
| 94 | $this->prefixes = array_merge($this->prefixes, $prefixes); | ||
| 95 | $this->paths = array_merge($this->paths, array_keys($prefixes)); | ||
| 96 | } | ||
| 97 | |||
| 98 | /** | ||
| 99 | * Gets Namespace Prefixes. | ||
| 100 | * | ||
| 101 | * @return string[] | ||
| 102 | */ | ||
| 103 | public function getNamespacePrefixes() | ||
| 104 | { | ||
| 105 | return $this->prefixes; | ||
| 106 | } | ||
| 107 | |||
| 108 | /** | ||
| 109 | * {@inheritDoc} | ||
| 110 | */ | ||
| 111 | public function getPaths() | ||
| 112 | { | ||
| 113 | return $this->paths; | ||
| 114 | } | ||
| 115 | |||
| 116 | /** | ||
| 117 | * {@inheritDoc} | ||
| 118 | */ | ||
| 119 | public function getFileExtension() | ||
| 120 | { | ||
| 121 | return $this->fileExtension; | ||
| 122 | } | ||
| 123 | |||
| 124 | /** | ||
| 125 | * Sets the file extension used to look for mapping files under. | ||
| 126 | * | ||
| 127 | * @param string $fileExtension The file extension to set. | ||
| 128 | * | ||
| 129 | * @return void | ||
| 130 | */ | ||
| 131 | public function setFileExtension(string $fileExtension) | ||
| 132 | { | ||
| 133 | $this->fileExtension = $fileExtension; | ||
| 134 | } | ||
| 135 | |||
| 136 | /** | ||
| 137 | * {@inheritDoc} | ||
| 138 | */ | ||
| 139 | public function fileExists(string $className) | ||
| 140 | { | ||
| 141 | $defaultFileName = str_replace('\\', $this->nsSeparator, $className) . $this->fileExtension; | ||
| 142 | foreach ($this->paths as $path) { | ||
| 143 | if (! isset($this->prefixes[$path])) { | ||
| 144 | // global namespace class | ||
| 145 | if (is_file($path . DIRECTORY_SEPARATOR . $defaultFileName)) { | ||
| 146 | return true; | ||
| 147 | } | ||
| 148 | |||
| 149 | continue; | ||
| 150 | } | ||
| 151 | |||
| 152 | $prefix = $this->prefixes[$path]; | ||
| 153 | |||
| 154 | if (strpos($className, $prefix . '\\') !== 0) { | ||
| 155 | continue; | ||
| 156 | } | ||
| 157 | |||
| 158 | $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', $this->nsSeparator) . $this->fileExtension; | ||
| 159 | |||
| 160 | if (is_file($filename)) { | ||
| 161 | return true; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | return false; | ||
| 166 | } | ||
| 167 | |||
| 168 | /** | ||
| 169 | * {@inheritDoc} | ||
| 170 | */ | ||
| 171 | public function getAllClassNames(?string $globalBasename = null) | ||
| 172 | { | ||
| 173 | if ($this->paths === []) { | ||
| 174 | return []; | ||
| 175 | } | ||
| 176 | |||
| 177 | $classes = []; | ||
| 178 | |||
| 179 | foreach ($this->paths as $path) { | ||
| 180 | if (! is_dir($path)) { | ||
| 181 | throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); | ||
| 182 | } | ||
| 183 | |||
| 184 | $iterator = new RecursiveIteratorIterator( | ||
| 185 | new RecursiveDirectoryIterator($path), | ||
| 186 | RecursiveIteratorIterator::LEAVES_ONLY | ||
| 187 | ); | ||
| 188 | |||
| 189 | foreach ($iterator as $file) { | ||
| 190 | $fileName = $file->getBasename($this->fileExtension); | ||
| 191 | |||
| 192 | if ($fileName === $file->getBasename() || $fileName === $globalBasename) { | ||
| 193 | continue; | ||
| 194 | } | ||
| 195 | |||
| 196 | // NOTE: All files found here means classes are not transient! | ||
| 197 | if (isset($this->prefixes[$path])) { | ||
| 198 | // Calculate namespace suffix for given prefix as a relative path from basepath to file path | ||
| 199 | $nsSuffix = strtr( | ||
| 200 | substr($this->realpath($file->getPath()), strlen($this->realpath($path))), | ||
| 201 | $this->nsSeparator, | ||
| 202 | '\\' | ||
| 203 | ); | ||
| 204 | |||
| 205 | /** @psalm-var class-string */ | ||
| 206 | $class = $this->prefixes[$path] . str_replace(DIRECTORY_SEPARATOR, '\\', $nsSuffix) . '\\' . str_replace($this->nsSeparator, '\\', $fileName); | ||
| 207 | } else { | ||
| 208 | /** @psalm-var class-string */ | ||
| 209 | $class = str_replace($this->nsSeparator, '\\', $fileName); | ||
| 210 | } | ||
| 211 | |||
| 212 | $classes[] = $class; | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | return $classes; | ||
| 217 | } | ||
| 218 | |||
| 219 | /** | ||
| 220 | * {@inheritDoc} | ||
| 221 | */ | ||
| 222 | public function findMappingFile(string $className) | ||
| 223 | { | ||
| 224 | $defaultFileName = str_replace('\\', $this->nsSeparator, $className) . $this->fileExtension; | ||
| 225 | foreach ($this->paths as $path) { | ||
| 226 | if (! isset($this->prefixes[$path])) { | ||
| 227 | if (is_file($path . DIRECTORY_SEPARATOR . $defaultFileName)) { | ||
| 228 | return $path . DIRECTORY_SEPARATOR . $defaultFileName; | ||
| 229 | } | ||
| 230 | |||
| 231 | continue; | ||
| 232 | } | ||
| 233 | |||
| 234 | $prefix = $this->prefixes[$path]; | ||
| 235 | |||
| 236 | if (strpos($className, $prefix . '\\') !== 0) { | ||
| 237 | continue; | ||
| 238 | } | ||
| 239 | |||
| 240 | $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', $this->nsSeparator) . $this->fileExtension; | ||
| 241 | if (is_file($filename)) { | ||
| 242 | return $filename; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | |||
| 246 | $pos = strrpos($className, '\\'); | ||
| 247 | assert(is_int($pos)); | ||
| 248 | |||
| 249 | throw MappingException::mappingFileNotFound( | ||
| 250 | $className, | ||
| 251 | substr($className, $pos + 1) . $this->fileExtension | ||
| 252 | ); | ||
| 253 | } | ||
| 254 | |||
| 255 | private function realpath(string $path): string | ||
| 256 | { | ||
| 257 | $realpath = realpath($path); | ||
| 258 | |||
| 259 | if ($realpath === false) { | ||
| 260 | throw new RuntimeException(sprintf('Could not get realpath for %s', $path)); | ||
| 261 | } | ||
| 262 | |||
| 263 | return $realpath; | ||
| 264 | } | ||
| 265 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php b/vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php new file mode 100644 index 0000000..f0bc4eb --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use Exception; | ||
| 8 | |||
| 9 | use function implode; | ||
| 10 | use function sprintf; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * A MappingException indicates that something is wrong with the mapping setup. | ||
| 14 | */ | ||
| 15 | class MappingException extends Exception | ||
| 16 | { | ||
| 17 | /** | ||
| 18 | * @param array<int, string> $namespaces | ||
| 19 | * | ||
| 20 | * @return self | ||
| 21 | */ | ||
| 22 | public static function classNotFoundInNamespaces( | ||
| 23 | string $className, | ||
| 24 | array $namespaces | ||
| 25 | ) { | ||
| 26 | return new self(sprintf( | ||
| 27 | "The class '%s' was not found in the chain configured namespaces %s", | ||
| 28 | $className, | ||
| 29 | implode(', ', $namespaces) | ||
| 30 | )); | ||
| 31 | } | ||
| 32 | |||
| 33 | /** @param class-string $driverClassName */ | ||
| 34 | public static function pathRequiredForDriver(string $driverClassName): self | ||
| 35 | { | ||
| 36 | return new self(sprintf( | ||
| 37 | 'Specifying the paths to your entities is required when using %s to retrieve all class names.', | ||
| 38 | $driverClassName | ||
| 39 | )); | ||
| 40 | } | ||
| 41 | |||
| 42 | /** @return self */ | ||
| 43 | public static function fileMappingDriversRequireConfiguredDirectoryPath( | ||
| 44 | ?string $path = null | ||
| 45 | ) { | ||
| 46 | if ($path !== null) { | ||
| 47 | $path = '[' . $path . ']'; | ||
| 48 | } | ||
| 49 | |||
| 50 | return new self(sprintf( | ||
| 51 | 'File mapping drivers must have a valid directory path, ' . | ||
| 52 | 'however the given path %s seems to be incorrect!', | ||
| 53 | (string) $path | ||
| 54 | )); | ||
| 55 | } | ||
| 56 | |||
| 57 | /** @return self */ | ||
| 58 | public static function mappingFileNotFound(string $entityName, string $fileName) | ||
| 59 | { | ||
| 60 | return new self(sprintf( | ||
| 61 | "No mapping file found named '%s' for class '%s'.", | ||
| 62 | $fileName, | ||
| 63 | $entityName | ||
| 64 | )); | ||
| 65 | } | ||
| 66 | |||
| 67 | /** @return self */ | ||
| 68 | public static function invalidMappingFile(string $entityName, string $fileName) | ||
| 69 | { | ||
| 70 | return new self(sprintf( | ||
| 71 | "Invalid mapping file '%s' for class '%s'.", | ||
| 72 | $fileName, | ||
| 73 | $entityName | ||
| 74 | )); | ||
| 75 | } | ||
| 76 | |||
| 77 | /** @return self */ | ||
| 78 | public static function nonExistingClass(string $className) | ||
| 79 | { | ||
| 80 | return new self(sprintf("Class '%s' does not exist", $className)); | ||
| 81 | } | ||
| 82 | |||
| 83 | /** @param class-string $className */ | ||
| 84 | public static function classIsAnonymous(string $className): self | ||
| 85 | { | ||
| 86 | return new self(sprintf('Class "%s" is anonymous', $className)); | ||
| 87 | } | ||
| 88 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/ProxyClassNameResolver.php b/vendor/doctrine/persistence/src/Persistence/Mapping/ProxyClassNameResolver.php new file mode 100644 index 0000000..2801d90 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/ProxyClassNameResolver.php | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Proxy; | ||
| 8 | |||
| 9 | interface ProxyClassNameResolver | ||
| 10 | { | ||
| 11 | /** | ||
| 12 | * @psalm-param class-string<Proxy<T>>|class-string<T> $className | ||
| 13 | * | ||
| 14 | * @psalm-return class-string<T> | ||
| 15 | * | ||
| 16 | * @template T of object | ||
| 17 | */ | ||
| 18 | public function resolveClassName(string $className): string; | ||
| 19 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/ReflectionService.php b/vendor/doctrine/persistence/src/Persistence/Mapping/ReflectionService.php new file mode 100644 index 0000000..9484e1f --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/ReflectionService.php | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use ReflectionClass; | ||
| 8 | use ReflectionProperty; | ||
| 9 | |||
| 10 | /** | ||
| 11 | * Very simple reflection service abstraction. | ||
| 12 | * | ||
| 13 | * This is required inside metadata layers that may require either | ||
| 14 | * static or runtime reflection. | ||
| 15 | */ | ||
| 16 | interface ReflectionService | ||
| 17 | { | ||
| 18 | /** | ||
| 19 | * Returns an array of the parent classes (not interfaces) for the given class. | ||
| 20 | * | ||
| 21 | * @psalm-param class-string $class | ||
| 22 | * | ||
| 23 | * @return string[] | ||
| 24 | * @psalm-return class-string[] | ||
| 25 | * | ||
| 26 | * @throws MappingException | ||
| 27 | */ | ||
| 28 | public function getParentClasses(string $class); | ||
| 29 | |||
| 30 | /** | ||
| 31 | * Returns the shortname of a class. | ||
| 32 | * | ||
| 33 | * @psalm-param class-string $class | ||
| 34 | * | ||
| 35 | * @return string | ||
| 36 | */ | ||
| 37 | public function getClassShortName(string $class); | ||
| 38 | |||
| 39 | /** | ||
| 40 | * @psalm-param class-string $class | ||
| 41 | * | ||
| 42 | * @return string | ||
| 43 | */ | ||
| 44 | public function getClassNamespace(string $class); | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Returns a reflection class instance or null. | ||
| 48 | * | ||
| 49 | * @psalm-param class-string<T> $class | ||
| 50 | * | ||
| 51 | * @return ReflectionClass|null | ||
| 52 | * @psalm-return ReflectionClass<T>|null | ||
| 53 | * | ||
| 54 | * @template T of object | ||
| 55 | */ | ||
| 56 | public function getClass(string $class); | ||
| 57 | |||
| 58 | /** | ||
| 59 | * Returns an accessible property (setAccessible(true)) or null. | ||
| 60 | * | ||
| 61 | * @psalm-param class-string $class | ||
| 62 | * | ||
| 63 | * @return ReflectionProperty|null | ||
| 64 | */ | ||
| 65 | public function getAccessibleProperty(string $class, string $property); | ||
| 66 | |||
| 67 | /** | ||
| 68 | * Checks if the class have a public method with the given name. | ||
| 69 | * | ||
| 70 | * @psalm-param class-string $class | ||
| 71 | * | ||
| 72 | * @return bool | ||
| 73 | */ | ||
| 74 | public function hasPublicMethod(string $class, string $method); | ||
| 75 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php b/vendor/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php new file mode 100644 index 0000000..399e057 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php | |||
| @@ -0,0 +1,111 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use Doctrine\Persistence\Reflection\RuntimeReflectionProperty; | ||
| 8 | use Doctrine\Persistence\Reflection\TypedNoDefaultReflectionProperty; | ||
| 9 | use ReflectionClass; | ||
| 10 | use ReflectionException; | ||
| 11 | use ReflectionMethod; | ||
| 12 | |||
| 13 | use function array_key_exists; | ||
| 14 | use function assert; | ||
| 15 | use function class_exists; | ||
| 16 | use function class_parents; | ||
| 17 | use function phpversion; | ||
| 18 | use function version_compare; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * PHP Runtime Reflection Service. | ||
| 22 | */ | ||
| 23 | class RuntimeReflectionService implements ReflectionService | ||
| 24 | { | ||
| 25 | /** @var bool */ | ||
| 26 | private $supportsTypedPropertiesWorkaround; | ||
| 27 | |||
| 28 | public function __construct() | ||
| 29 | { | ||
| 30 | $this->supportsTypedPropertiesWorkaround = version_compare(phpversion(), '7.4.0') >= 0; | ||
| 31 | } | ||
| 32 | |||
| 33 | /** | ||
| 34 | * {@inheritDoc} | ||
| 35 | */ | ||
| 36 | public function getParentClasses(string $class) | ||
| 37 | { | ||
| 38 | if (! class_exists($class)) { | ||
| 39 | throw MappingException::nonExistingClass($class); | ||
| 40 | } | ||
| 41 | |||
| 42 | $parents = class_parents($class); | ||
| 43 | |||
| 44 | assert($parents !== false); | ||
| 45 | |||
| 46 | return $parents; | ||
| 47 | } | ||
| 48 | |||
| 49 | /** | ||
| 50 | * {@inheritDoc} | ||
| 51 | */ | ||
| 52 | public function getClassShortName(string $class) | ||
| 53 | { | ||
| 54 | $reflectionClass = new ReflectionClass($class); | ||
| 55 | |||
| 56 | return $reflectionClass->getShortName(); | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * {@inheritDoc} | ||
| 61 | */ | ||
| 62 | public function getClassNamespace(string $class) | ||
| 63 | { | ||
| 64 | $reflectionClass = new ReflectionClass($class); | ||
| 65 | |||
| 66 | return $reflectionClass->getNamespaceName(); | ||
| 67 | } | ||
| 68 | |||
| 69 | /** | ||
| 70 | * @psalm-param class-string<T> $class | ||
| 71 | * | ||
| 72 | * @return ReflectionClass | ||
| 73 | * @psalm-return ReflectionClass<T> | ||
| 74 | * | ||
| 75 | * @template T of object | ||
| 76 | */ | ||
| 77 | public function getClass(string $class) | ||
| 78 | { | ||
| 79 | return new ReflectionClass($class); | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * {@inheritDoc} | ||
| 84 | */ | ||
| 85 | public function getAccessibleProperty(string $class, string $property) | ||
| 86 | { | ||
| 87 | $reflectionProperty = new RuntimeReflectionProperty($class, $property); | ||
| 88 | |||
| 89 | if ($this->supportsTypedPropertiesWorkaround && ! array_key_exists($property, $this->getClass($class)->getDefaultProperties())) { | ||
| 90 | $reflectionProperty = new TypedNoDefaultReflectionProperty($class, $property); | ||
| 91 | } | ||
| 92 | |||
| 93 | $reflectionProperty->setAccessible(true); | ||
| 94 | |||
| 95 | return $reflectionProperty; | ||
| 96 | } | ||
| 97 | |||
| 98 | /** | ||
| 99 | * {@inheritDoc} | ||
| 100 | */ | ||
| 101 | public function hasPublicMethod(string $class, string $method) | ||
| 102 | { | ||
| 103 | try { | ||
| 104 | $reflectionMethod = new ReflectionMethod($class, $method); | ||
| 105 | } catch (ReflectionException $e) { | ||
| 106 | return false; | ||
| 107 | } | ||
| 108 | |||
| 109 | return $reflectionMethod->isPublic(); | ||
| 110 | } | ||
| 111 | } | ||
diff --git a/vendor/doctrine/persistence/src/Persistence/Mapping/StaticReflectionService.php b/vendor/doctrine/persistence/src/Persistence/Mapping/StaticReflectionService.php new file mode 100644 index 0000000..c9f2147 --- /dev/null +++ b/vendor/doctrine/persistence/src/Persistence/Mapping/StaticReflectionService.php | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\Persistence\Mapping; | ||
| 6 | |||
| 7 | use function strpos; | ||
| 8 | use function strrev; | ||
| 9 | use function strrpos; | ||
| 10 | use function substr; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * PHP Runtime Reflection Service. | ||
| 14 | */ | ||
| 15 | class StaticReflectionService implements ReflectionService | ||
| 16 | { | ||
| 17 | /** | ||
| 18 | * {@inheritDoc} | ||
| 19 | */ | ||
| 20 | public function getParentClasses(string $class) | ||
| 21 | { | ||
| 22 | return []; | ||
| 23 | } | ||
| 24 | |||
| 25 | /** | ||
| 26 | * {@inheritDoc} | ||
| 27 | */ | ||
| 28 | public function getClassShortName(string $class) | ||
| 29 | { | ||
| 30 | $nsSeparatorLastPosition = strrpos($class, '\\'); | ||
| 31 | |||
| 32 | if ($nsSeparatorLastPosition !== false) { | ||
| 33 | $class = substr($class, $nsSeparatorLastPosition + 1); | ||
| 34 | } | ||
| 35 | |||
| 36 | return $class; | ||
| 37 | } | ||
| 38 | |||
| 39 | /** | ||
| 40 | * {@inheritDoc} | ||
| 41 | */ | ||
| 42 | public function getClassNamespace(string $class) | ||
| 43 | { | ||
| 44 | $namespace = ''; | ||
| 45 | |||
| 46 | if (strpos($class, '\\') !== false) { | ||
| 47 | $namespace = strrev(substr(strrev($class), (int) strpos(strrev($class), '\\') + 1)); | ||
| 48 | } | ||
| 49 | |||
| 50 | return $namespace; | ||
| 51 | } | ||
| 52 | |||
| 53 | /** | ||
| 54 | * {@inheritDoc} | ||
| 55 | * | ||
| 56 | * @return null | ||
| 57 | */ | ||
| 58 | public function getClass(string $class) | ||
| 59 | { | ||
| 60 | return null; | ||
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * {@inheritDoc} | ||
| 65 | */ | ||
| 66 | public function getAccessibleProperty(string $class, string $property) | ||
| 67 | { | ||
| 68 | return null; | ||
| 69 | } | ||
| 70 | |||
| 71 | /** | ||
| 72 | * {@inheritDoc} | ||
| 73 | */ | ||
| 74 | public function hasPublicMethod(string $class, string $method) | ||
| 75 | { | ||
| 76 | return true; | ||
| 77 | } | ||
| 78 | } | ||
