title: Doctrine2 Update Caused AnnotationRegistry registerLoader Error in Zend Framework 3
body: <p>I'm working on a CMS based on Zend Framework 3.0 to manage a DB I with Doctrine. What is my problem when managing packages with composer? Recently, I updated all the packages to newest versions and sent it to server, nothing was changed in other files. After the update my site displayed the following error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() must be an instance of Doctrine\Common\Annotations\void, none returned in /home/platne/serwer18346/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117 Stack trace: #0 /home/platne/serwer18346/vendor/doctrine/doctrine-module/src/DoctrineModule/Module.php(57): Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(Object(Closure)) #1 /home/platne/serwer18346/vendor/zendframework/zend-modulemanager/src/Listener/InitTrigger.php(33): DoctrineModule\Module->init(Object(Zend\ModuleManager\ModuleManager)) #2 /home/platne/serwer18346/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\ModuleManager\Listener\InitTrigger->__invoke(Object(Zend\ModuleManager\ModuleEvent)) #3 /home/platne/serwer18346/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent)) #4 /home/p in /home/platne/serwer18346/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 117</p>
  </blockquote>
  
  <p>Some application code if needed:<br/>
  modules:</p>
  
  <pre><code>return [
      'Zend\Router',
      'Zend\Validator',
      'DoctrineModule',
      'DoctrineORMModule',
      'Core',
  ];
  </code></pre>
  
  <p>development.local(developer mode is active):</p>
  
  <pre><code>'doctrine' =&gt; [
          'connection' =&gt; [
              'orm_default' =&gt; [
                  'driverClass' =&gt; Doctrine\DBAL\Driver\PDOMySql\Driver::class,
                  'params' =&gt; [
                      'host' =&gt; '******',
                      'user' =&gt; '*******',
                      'password' =&gt; '******',
                      'dbname' =&gt; '*******',
                      'charset' =&gt; 'utf8'
                  ]
              ]
          ]
      ]
  </code></pre>
  
  <p>module.config:</p>
  
  <pre><code>'doctrine' =&gt; [
          'driver' =&gt; [
              __NAMESPACE__ . '_driver' =&gt; [
                  'class' =&gt; AnnotationDriver::class,
                  'cache' =&gt; 'array',
                  'paths' =&gt; [__DIR__.'/../src/Model']
              ],
              'orm_default' =&gt; [
                  'drivers' =&gt; [
                      __NAMESPACE__ . '\Model' =&gt; __NAMESPACE__ . '_driver'
                  ]
              ]
          ]
      ]
  </code></pre>
  
  <p>Controller Factory:</p>
  
  <pre><code>public function __invoke(ContainerInterface $container,$requestedName, array $options = null)
  {
      $controllerInstance = null;
      switch($requestedName){
          case 'Core\Controller\IndexController': $controllerInstance = $this-&gt;_invokeIndex($container); break;
          case 'Core\Controller\PagesController': $controllerInstance = $this-&gt;_invokePages($container); break;
      }
      return $controllerInstance;
  }
  
  protected function _invokeIndex(ContainerInterface $container)
  {
      return new Controller\IndexController(
          $container-&gt;get('doctrine.entitymanager.orm_default')
      );
  }
  
  protected function _invokePages(ContainerInterface $container)
  {
      return new Controller\PagesController(
          $container-&gt;get('doctrine.entitymanager.orm_default')
      );
  }
  </code></pre>
  
  <p>Controller Parent:</p>
  
  <pre><code> protected $_entityManager;
  
      /**
       * AppController constructor.
       * @param EntityManager $entityManager
       */
      public function __construct(EntityManager $entityManager)
      {
          $this-&gt;_entityManager = $entityManager;
      }
  
      /**
       * @return EntityManager
       */
      public function getEntityManager()
      {
          return $this-&gt;_entityManager;
      }
  </code></pre>
  
  <p>As I said this code worked before update. After update it show me that error, what is more after uploading previous versions the error remains. I triead rewriting code but with the same effect.</p>
  
  <p>Composer(without project data):</p>
  
  <pre><code>"require": {
      "zendframework/zend-mvc": "*",
      "zendframework/zend-developer-tools": "*",
      "zendframework/zend-session": "*",
      "zendframework/zend-authentication": "*",
      "zfcampus/zf-development-mode": "*",
      "doctrine/doctrine-orm-module": "*"
    },
    "autoload": {
      "psr-4": {
        "Core\\": "module/Core/src/"
      }
    }
  </code></pre>