Doctrine Common
  1. Doctrine Common
  2. DCOM-204

AnnotationDriver cannot find classes inside Phar files

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4.2
    • Component/s: Annotations
    • Labels:
      None

      Description

      If an application is packaged inside a Phar file, the annotation driver cannot find any classes. The problem is in the method AnnotationDriver::getAllClassNames()

      AnnotationDriver.php
       
      foreach ($iterator as $file) {
          $sourceFile = realpath($file[0]);
      
          require_once $sourceFile;
      
          $includedFiles[] = $sourceFile;
      }
      

      $iterator will hold all paths to the files found, however realpath() will return false since the files are inside a phar file.

      I have solved this locally in my application with the following, however I'm not sure if this is the right approach to solve the problem.

      AnnotationDriver.php
      $sourceFile = str_replace('\\', '/', $file[0]);
      if (!preg_match('#^phar://#i', $sourceFile)) {
          $sourceFile = realpath($sourceFile);
      }
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Johan Groth
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: