Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Implement colocated mapping driver" #9670

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ This is now deprecated. Please extend `EntityRepository` instead.
+$entityManager->getRepository(CmsUser::class);
```

## BC Break: `AttributeDriver` and `AnnotationDriver` no longer extends parent class from `doctrine/persistence`

Both these classes used to extend an abstract `AnnotationDriver` class defined
in `doctrine/persistence`, and no longer do.

## Deprecate `AttributeDriver::getReader()` and `AnnotationDriver::getReader()`

That method was inherited from the abstract `AnnotationDriver` class of
`doctrine/persistence`, and does not seem to serve any purpose.

## Un-deprecate `Doctrine\ORM\Proxy\Proxy`

Because no forward-compatible new proxy solution had been implemented yet, the
Expand Down
65 changes: 2 additions & 63 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
namespace Doctrine\ORM\Mapping\Driver;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\ColocatedMappingDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver;
use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;
Expand All @@ -32,19 +29,8 @@
/**
* The AnnotationDriver reads the mapping metadata from docblock annotations.
*/
class AnnotationDriver implements MappingDriver
class AnnotationDriver extends AbstractAnnotationDriver
{
use ColocatedMappingDriver;

/**
* The annotation reader.
*
* @internal this property will be private in 3.0
*
* @var Reader
*/
protected $reader;

/**
* @var int[]
* @psalm-var array<class-string, int>
Expand All @@ -54,20 +40,6 @@ class AnnotationDriver implements MappingDriver
Mapping\MappedSuperclass::class => 2,
];

/**
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
* docblock annotations.
*
* @param Reader $reader The AnnotationReader to use
* @param string|string[]|null $paths One or multiple paths where mapping classes can be found.
*/
public function __construct($reader, $paths = null)
{
$this->reader = $reader;

$this->addPaths((array) $paths);
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -814,39 +786,6 @@ private function columnToArray(string $fieldName, Mapping\Column $column): array
return $mapping;
}

/**
* Retrieve the current annotation reader
*
* @return Reader
*/
public function getReader()
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/9587',
'%s is deprecated with no replacement',
__METHOD__
);

return $this->reader;
}

/**
* {@inheritDoc}
*/
public function isTransient($className)
{
$classAnnotations = $this->reader->getClassAnnotations(new ReflectionClass($className));

foreach ($classAnnotations as $annot) {
if (isset($this->entityAnnotationClasses[get_class($annot)])) {
return false;
}
}

return true;
}

/**
* Factory method for the Annotation Driver.
*
Expand Down
29 changes: 2 additions & 27 deletions lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

namespace Doctrine\ORM\Mapping\Driver;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\ColocatedMappingDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Persistence\Mapping\Driver\AnnotationDriver;
use LogicException;
use ReflectionClass;
use ReflectionMethod;
Expand All @@ -27,10 +25,8 @@

use const PHP_VERSION_ID;

class AttributeDriver implements MappingDriver
class AttributeDriver extends AnnotationDriver
{
use ColocatedMappingDriver;

/** @var array<string,int> */
// @phpcs:ignore
protected $entityAnnotationClasses = [
Expand All @@ -41,8 +37,6 @@ class AttributeDriver implements MappingDriver
/**
* The annotation reader.
*
* @internal this property will be private in 3.0
*
* @var AttributeReader
*/
protected $reader;
Expand All @@ -63,25 +57,6 @@ public function __construct(array $paths)
$this->addPaths($paths);
}

/**
* Retrieve the current annotation reader
*
* @deprecated no replacement planned.
*
* @return AttributeReader
*/
public function getReader()
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/9587',
'%s is deprecated with no replacement',
__METHOD__
);

return $this->reader;
}

/**
* {@inheritDoc}
*/
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php

-
message: "#^PHPDoc type Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeReader of property Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeDriver\\:\\:\\$reader is not covariant with PHPDoc type Doctrine\\\\Common\\\\Annotations\\\\Reader of overridden property Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\AnnotationDriver\\:\\:\\$reader\\.$#"
count: 1
path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php

-
message: "#^PHPDoc type array\\<string, int\\> of property Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeDriver\\:\\:\\$entityAnnotationClasses is not covariant with PHPDoc type array\\<class\\-string, bool\\|int\\> of overridden property Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\AnnotationDriver\\:\\:\\$entityAnnotationClasses\\.$#"
count: 1
path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php

-
message: "#^Parameter \\#1 \\$metadata of static method Doctrine\\\\ORM\\\\Mapping\\\\Builder\\\\EntityListenerBuilder\\:\\:bindEntityListener\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo&Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\<T of object\\> given\\.$#"
count: 1
Expand Down
7 changes: 7 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,9 @@
<code>$mapping</code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType occurrences="1"/>
<NonInvariantDocblockPropertyType occurrences="1">
<code>$entityAnnotationClasses</code>
</NonInvariantDocblockPropertyType>
<PossiblyNullArgument occurrences="1">
<code>$listenerClassName</code>
</PossiblyNullArgument>
Expand Down Expand Up @@ -762,6 +765,10 @@
<code>$mapping</code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType occurrences="1"/>
<NonInvariantDocblockPropertyType occurrences="2">
<code>$entityAnnotationClasses</code>
<code>$reader</code>
</NonInvariantDocblockPropertyType>
<PossiblyNullArgument occurrences="1">
<code>$listenerClassName</code>
</PossiblyNullArgument>
Expand Down