Cannot create Doctrine\ORMEntityManager instance, inheritance error. #7067

Closed
opened 2026-01-22 15:44:03 +01:00 by admin · 3 comments
Owner

Originally created by @Vitsen15 on GitHub (Oct 26, 2022).

Bug Report

Q A
BC Break no
Version 2.13
PHP version 7.1.27

composer.json content:

"require": {
...
"doctrine/dbal": "^2.13",
"doctrine/orm": "^2.13",
"symfony/cache": "^4.4",
"symfony/var-dumper": "4.4.47",
"doctrine/annotations": "^1.13",
...
},

Summary

Getting Inheritance error when trying to create entity manager:

EntityManager::create($connection, $config);

Current behavior

When I'm trying to create EntityManager instance, I get the next error:

Declaration of Doctrine\ORM\Proxy\ProxyFactory::skipClass(Doctrine\Persistence\Mapping\ClassMetadata $metadata) must be compatible with Doctrine\Common\Proxy\AbstractProxyFactory::skipClass(Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)

How to reproduce

Create \Doctrine\ORM\Configuration object instance:

$cache = new FilesystemAdapter('rest');
$entitiesPaths = ['path/to/entities'];
$config = ORMSetup::createAnnotationMetadataConfiguration($entitiesPaths, $isDevMode);
$config->setResultCache($cache);

Then creating the \Doctrine\DBAL\Connection:

$connection = DriverManager::getConnection([
                'wrapperClass' => PrimaryReadReplicaConnection::class,
                'driver' => 'pdo_mysql',
                'keepReplica' => true,
                'primary' => [
                    'user' => $config->get('master.username'),
                    'host' => $config->get('master.hostname'),
                    'password' => $config->get('master.password'),
                    'dbname' => 'db',
                ],
                'replica' => [
                    [
                        'user' => $config->get('slave.username'),
                        'host' => $config->get('slave.hostname'),
                        'password' => $config->get('slave.password'),
                        'dbname' => 'db',
                    ]
                ]
            ]
        );

And to create Doctrine\ORMEntityManager instance:

$entityManager = EntityManager::create($connection, $config);

After this, error is occurred.

Expected behaviour

Doctrine\ORMEntityManager to be created.

Originally created by @Vitsen15 on GitHub (Oct 26, 2022). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.13 | PHP version | 7.1.27 composer.json content: > "require": { > ... > "doctrine/dbal": "^2.13", > "doctrine/orm": "^2.13", > "symfony/cache": "^4.4", > "symfony/var-dumper": "4.4.47", > "doctrine/annotations": "^1.13", > ... > }, #### Summary Getting Inheritance error when trying to create entity manager: `EntityManager::create($connection, $config);` #### Current behavior When I'm trying to create EntityManager instance, I get the next error: > Declaration of Doctrine\ORM\Proxy\ProxyFactory::skipClass(Doctrine\Persistence\Mapping\ClassMetadata $metadata) must be compatible with Doctrine\Common\Proxy\AbstractProxyFactory::skipClass(Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) #### How to reproduce Create `\Doctrine\ORM\Configuration` object instance: ``` $cache = new FilesystemAdapter('rest'); $entitiesPaths = ['path/to/entities']; $config = ORMSetup::createAnnotationMetadataConfiguration($entitiesPaths, $isDevMode); $config->setResultCache($cache); ``` Then creating the `\Doctrine\DBAL\Connection`: ``` $connection = DriverManager::getConnection([ 'wrapperClass' => PrimaryReadReplicaConnection::class, 'driver' => 'pdo_mysql', 'keepReplica' => true, 'primary' => [ 'user' => $config->get('master.username'), 'host' => $config->get('master.hostname'), 'password' => $config->get('master.password'), 'dbname' => 'db', ], 'replica' => [ [ 'user' => $config->get('slave.username'), 'host' => $config->get('slave.hostname'), 'password' => $config->get('slave.password'), 'dbname' => 'db', ] ] ] ); ``` And to create `Doctrine\ORMEntityManager` instance: `$entityManager = EntityManager::create($connection, $config);` After this, error is occurred. #### Expected behaviour <!-- What was the expected (correct) behaviour? --> `Doctrine\ORMEntityManager` to be created.
admin closed this issue 2026-01-22 15:44:03 +01:00
Author
Owner

@derrabus commented on GitHub (Oct 26, 2022):

Can you please show the output of composer show | grep doctrine?

@derrabus commented on GitHub (Oct 26, 2022): Can you please show the output of `composer show | grep doctrine`?
Author
Owner

@Vitsen15 commented on GitHub (Oct 26, 2022):

@derrabus, pls see the output of composer show | grep doctrine:

$ composer show | grep doctrine
doctrine/annotations               1.13.3  Docblock Annotations Parser
doctrine/cache                     2.2.0   PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such ...
doctrine/collections               1.8.0   PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                    3.4.3   PHP Doctrine Common project is a library that provides additional functionality that other Doctrine pro...
doctrine/dbal                      2.13.9  Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and...
doctrine/deprecations              v1.0.0  A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all d...
doctrine/event-manager             1.2.0   The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doct...
doctrine/inflector                 1.4.4   PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lo...
doctrine/instantiator              1.4.1   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                     1.2.3   PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm                       2.13.3  Object-Relational-Mapper for PHP
doctrine/persistence               2.5.5   The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doc...
@Vitsen15 commented on GitHub (Oct 26, 2022): @derrabus, pls see the output of `composer show | grep doctrine`: ``` $ composer show | grep doctrine doctrine/annotations 1.13.3 Docblock Annotations Parser doctrine/cache 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such ... doctrine/collections 1.8.0 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays. doctrine/common 3.4.3 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine pro... doctrine/dbal 2.13.9 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and... doctrine/deprecations v1.0.0 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all d... doctrine/event-manager 1.2.0 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doct... doctrine/inflector 1.4.4 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lo... doctrine/instantiator 1.4.1 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 1.2.3 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. doctrine/orm 2.13.3 Object-Relational-Mapper for PHP doctrine/persistence 2.5.5 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doc... ```
Author
Owner

@derrabus commented on GitHub (Oct 27, 2022):

There's something odd here. The signature of the AbstractProxyFactory::skipClass() method in doctrine/common 3.4.3 looks like this:

abstract protected function skipClass(\Doctrine\Persistence\Mapping\ClassMetadata $metadata);

Now, your error message prints the following signature:

Doctrine\Common\Proxy\AbstractProxyFactory::skipClass(Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)

Note that the namespace of the ClassMetadata class is different. That's an old namespace that we don't use anymore for quite a while now. I don't know where the AbstractProxyFactory class you are using is coming from, but I can tell for sure it's not the one from the doctrine/common 3.4.3 package.

I'm moving this issue to support now because it's apparently not a bug on our side.

@derrabus commented on GitHub (Oct 27, 2022): There's something odd here. The signature of the `AbstractProxyFactory::skipClass()` method in doctrine/common 3.4.3 looks like this: ```php abstract protected function skipClass(\Doctrine\Persistence\Mapping\ClassMetadata $metadata); ``` Now, your error message prints the following signature: ``` Doctrine\Common\Proxy\AbstractProxyFactory::skipClass(Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) ``` Note that the namespace of the `ClassMetadata` class is different. That's an old namespace that we don't use anymore for quite a while now. I don't know where the `AbstractProxyFactory` class you are using is coming from, but I can tell for sure it's not the one from the doctrine/common 3.4.3 package. I'm moving this issue to support now because it's apparently not a bug on our side.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7067