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

Cannot instantiate abstract class Doctrine\Common\EventManager #105

Closed
Wirone opened this issue Nov 25, 2016 · 8 comments
Closed

Cannot instantiate abstract class Doctrine\Common\EventManager #105

Wirone opened this issue Nov 25, 2016 · 8 comments

Comments

@Wirone
Copy link

Wirone commented Nov 25, 2016

I've installed apigen/apigen globally and configured PHP to include global autoload.php using auto_prepend_file. It worked, until now. I've updated ApiGen (dev-master ddf5b27 => v4.1.2) and now I get in my Silex application:

FatalThrowableError in DoctrineServiceProvider.php line 104:

Cannot instantiate abstract class Doctrine\Common\EventManager
in DoctrineServiceProvider.php line 104
at DoctrineServiceProvider->Silex\Provider\{closure}(object(Application)) in Container.php line 113
at Container->offsetGet('dbs.event_manager') in DoctrineServiceProvider.php line 124
at DoctrineServiceProvider->Silex\Provider\{closure}(object(Application)) in Container.php line 113
at Container->offsetGet('db.event_manager') in DoctrineServiceProvider.php line 70
at DoctrineServiceProvider->Silex\Provider\{closure}(object(Application)) in Container.php line 113
at Container->offsetGet('dbs') in RepositoryServiceProvider.php line 43
at RepositoryServiceProvider->{closure}('default') in RepositoryServiceProvider.php line 52
at RepositoryServiceProvider->boot(object(Application)) in Application.php line 115
at Application->boot() in Application.php line 491
at Application->handle(object(Request)) in Application.php line 477
at Application->run() in index.php line 15

I open DoctrineServiceProvider, go to Doctrine\Common\EventManager and WTF? It's not abstract. Then I edit service provider and just before EventManager initialization I use:

$ref = new \ReflectionClass('Doctrine\Common\EventManager');
print $ref->getFileName() . ':' . $ref->getStartLine();

Effect?

<path>\Composer\vendor\kdyby\events\src\Doctrine\aliases.php:15

Why do you declare something which is incompatible with commonly used Doctrine class?

@enumag
Copy link
Member

enumag commented Nov 25, 2016

It's autoloaded only if the doctrine/common package is not installed. See https://github.com/Kdyby/Events/blob/master/src/Doctrine/compatibility.php.

@Wirone
Copy link
Author

Wirone commented Nov 25, 2016

When Composer's global autoloading is added to auto_prepend_file in php.ini it is always loaded before actual application's autoload, so these aliases are defined and used within application.

For now I moved it to auto_append_file, but it's not good since I have symfony/var-dumper installed globally and I wanted to load it at the beginning and use it.

@Wirone
Copy link
Author

Wirone commented Dec 19, 2016

In order to use auto_prepend_file (I miss dump for quick developing) I've tried to bypass it by removing apigen/apigen from Composer's global config and installing as standalone vendor in my docs root directory and configuring NetBeans to use it. But I got another error:

$ apigen.bat --debug

Fatal error: Class Kdyby\Events\SymfonyDispatcher contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Component\EventDispatcher\EventDispatcherInterface::getListenerPriority) in vendor\kdyby\events\src\Kdyby\Events\SymfonyDispatcher.php on line 30
ErrorException: Class Kdyby\Events\SymfonyDispatcher contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Component\EventDispatcher\EventDispatcherInterface::getListenerPriority) in vendor\kdyby\events\src\Kdyby\Events\SymfonyDispatcher.php:30
Stack trace:
#0 [internal function]: Tracy\Debugger::shutdownHandler()
#1 {main}

composer.json

{
    "prefer-stable": true,
    "require": {
        "apigen/apigen": "~4.1"
    }
}

composer info

$ composer info
andrewsville/php-token-reflection 1.4.0   Library emulating the PHP internal reflection using just the tokenized source code.
apigen/apigen                     v4.1.2  PHP source code API generator
apigen/theme-bootstrap            v1.1.3  Twitter Bootstrap theme for ApiGen
apigen/theme-default              v1.0.2  Default theme for ApiGen
herrera-io/json                   1.0.3   A library for simplifying JSON linting and validation.
herrera-io/phar-update            2.0.0   A library for self-updating Phars.
herrera-io/version                1.1.1   A library for creating, editing, and comparing semantic versioning numbers.
justinrainbow/json-schema         1.6.1   A library to validate a json schema.
kdyby/events                      v2.4.1  Events for Nette Framework
kukulich/fshl                     2.1.0   FSHL is a free, open source, universal, fast syntax highlighter written in PHP.
latte/latte                       v2.3.4  Latte: the amazing template engine for PHP
michelf/php-markdown              1.7.0   PHP Markdown
nette/application                 v2.4.2  Nette Application MVC Component
nette/bootstrap                   v2.4.1  Nette Bootstrap
nette/caching                     v2.5.2  Nette Caching Component
nette/component-model             v2.3.0  Nette Component Model
nette/di                          v2.4.4  Nette Dependency Injection Component
nette/finder                      v2.4.0  Nette Finder: Files Searching
nette/http                        v2.4.2  Nette HTTP Component
nette/mail                        v2.4.1  Nette Mail: Sending E-mails
nette/neon                        v2.4.0  Nette NEON: parser & generator for Nette Object Notation
nette/php-generator               v2.4.1  Nette PHP Generator
nette/reflection                  v2.4.0  Nette PHP Reflection Component
nette/robot-loader                v2.4.1  Nette RobotLoader: comfortable autoloading
nette/safe-stream                 v2.3.2  Nette SafeStream: Atomic Operations
nette/utils                       v2.4.1  Nette Utility Classes
psr/log                           1.0.2   Common interface for logging libraries
seld/jsonlint                     1.5.0   JSON Linter
symfony/console                   v2.8.15 Symfony Console Component
symfony/debug                     v3.0.9  Symfony Debug Component
symfony/options-resolver          v2.6.13 Symfony OptionsResolver Component
symfony/polyfill-mbstring         v1.3.0  Symfony polyfill for the Mbstring extension
symfony/yaml                      v2.8.15 Symfony Yaml Component
tracy/tracy                       v2.4.4  Tracy: useful PHP debugger

Sigh...

@fprochazka
Copy link
Member

Sorry, but I have no idea what is this good for, but this doesn't sound right to me

I've installed apigen/apigen globally and configured PHP to include global autoload.php using auto_prepend_file.

Possible solution might be for you the #97.

@Wirone
Copy link
Author

Wirone commented Mar 8, 2017

Ahahahaha. "doesn't sound right to me", ok, this is the final argument.

I'm going to tell Composer's developers that whole "global" thing is "not right". Let's download every vendor everytime instead of using e.g. symfony/var-dumper globally for all projects.

You made my day 😂

@fprochazka
Copy link
Member

Yeah, global dependencies are wrong :) I'm happy you agree!

@Majkl578
Copy link
Member

Majkl578 commented Mar 8, 2017

I'm going to tell Composer's developers that whole "global" thing is "not right".

You can of couse. Global installation is meant solely for projects that are used directly from CLI, not for libraries with dependants etc.

since I have symfony/var-dumper installed globally and I wanted to load it at the beginning and use it

This is definitely totally wrong.

Let's download every vendor everytime instead of using e.g. symfony/var-dumper globally for all projects.

Correct, that's intended way of how dependencies are supposed to work. Don't forget there are multiple versions etc.

@Wirone
Copy link
Author

Wirone commented Mar 8, 2017

I will not go further with this discussion because it does not make sense. I think global LIBRARIES (not dependencies! I'm using dump for debugging because I know it's installed and loaded, project does not depend on it in any way) are still better than "mocking" interfaces (not compatible...) from other libraries to fix own library. Cheers!

@Kdyby Kdyby locked and limited conversation to collaborators Mar 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants