Skip to content

Commit

Permalink
Document ORM drivers only really load ORM metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Apr 24, 2022
1 parent 2e4a872 commit ebfa2f5
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 460 deletions.
7 changes: 6 additions & 1 deletion lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder;
use Doctrine\ORM\Mapping\ClassMetadata as Metadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
Expand Down Expand Up @@ -69,10 +70,14 @@ public function __construct($reader, $paths = null)

/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @psalm-param Metadata<T> $metadata
*
* @template T of object
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
assert($metadata instanceof Mapping\ClassMetadata);
$class = $metadata->getReflectionClass()
// this happens when running annotation driver in combination with
// static reflection services. This is not the nicest fix
Expand Down
11 changes: 9 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder;
use Doctrine\ORM\Mapping\ClassMetadata as Metadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
Expand Down Expand Up @@ -98,10 +99,16 @@ public function isTransient($className)
return true;
}

/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @psalm-param Metadata<T> $metadata
*
* @template T of object
*/
public function loadMetadataForClass($className, ClassMetadata $metadata): void
{
assert($metadata instanceof ClassMetadataInfo);

$reflectionClass = $metadata->getReflectionClass();

$classAttributes = $this->reader->getClassAnnotations($reflectionClass);
Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\DBAL\Types\Types;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\ORM\Mapping\ClassMetadata as Metadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
Expand All @@ -21,6 +22,7 @@
use function array_diff;
use function array_keys;
use function array_merge;
use function assert;
use function count;
use function current;
use function in_array;
Expand Down Expand Up @@ -166,6 +168,11 @@ public function setInflector(Inflector $inflector): void

/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @psalm-param Metadata<T> $metadata
*
* @template T of object
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS

/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @psalm-param Metadata<T> $metadata
*
* @template T of object
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
Expand Down
6 changes: 6 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Yaml\Yaml;

use function array_map;
use function assert;
use function class_exists;
use function constant;
use function defined;
Expand Down Expand Up @@ -60,6 +61,11 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS

/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @psalm-param Metadata<T> $metadata
*
* @template T of object
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
Expand Down
Loading

0 comments on commit ebfa2f5

Please sign in to comment.