| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Doctrine\Persistence\Mapping\Driver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Doctrine\Common\Annotations\Reader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Doctrine\Persistence\Mapping\MappingException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use FilesystemIterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use RecursiveDirectoryIterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use RecursiveIteratorIterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use RecursiveRegexIterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use ReflectionClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use RegexIterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use function array_merge; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use function array_unique; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use function get_class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use function get_declared_classes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use function in_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use function is_dir; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use function preg_match; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use function preg_quote; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use function realpath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use function str_replace; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use function strpos; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * The AnnotationDriver reads the mapping metadata from docblock annotations. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | abstract class AnnotationDriver implements MappingDriver | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      * The annotation reader. | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * @var Reader | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     protected $reader; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      * The paths where to look for mapping files. | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * @var string[] | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     protected $paths = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      * The paths excluded from path where to look for mapping files. | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |      * @var string[] | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |     protected $excludePaths = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      * The file extension of mapping documents. | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      * @var string | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |     protected $fileExtension = '.php'; | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |      * Cache for AnnotationDriver#getAllClassNames(). | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |      * @var string[]|null | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     protected $classNames; | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |      * Name of the entity annotations as keys. | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |      * @var string[] | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     protected $entityAnnotationClasses = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |      * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |      * docblock annotations. | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      * @param Reader               $reader The AnnotationReader to use, duck-typed. | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      * @param string|string[]|null $paths  One or multiple paths where mapping classes can be found. | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 79 | 1 |  |     public function __construct($reader, $paths = null) | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 81 | 1 |  |         $this->reader = $reader; | 
            
                                                                        
                            
            
                                    
            
            
                | 82 | 1 |  |         if (! $paths) { | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 | 1 |  |         $this->addPaths((array) $paths); | 
            
                                                                        
                            
            
                                    
            
            
                | 87 | 1 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |      * Appends lookup paths to metadata driver. | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |      * @param string[] $paths | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 96 | 1 |  |     public function addPaths(array $paths) | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 98 | 1 |  |         $this->paths = array_unique(array_merge($this->paths, $paths)); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 | 1 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |      * Retrieves the defined metadata lookup paths. | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |      * @return string[] | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |     public function getPaths() | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |         return $this->paths; | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      * Append exclude lookup paths to metadata driver. | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |      * @param string[] $paths | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |     public function addExcludePaths(array $paths) | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |         $this->excludePaths = array_unique(array_merge($this->excludePaths, $paths)); | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |      * Retrieve the defined metadata lookup exclude paths. | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |      * @return string[] | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     public function getExcludePaths() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 128 |  |  |         return $this->excludePaths; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 131 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |      * Retrieve the current annotation reader | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |      * @return Reader | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |     public function getReader() | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |         return $this->reader; | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |      * Gets the file extension used to look for mapping files under. | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     public function getFileExtension() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 148 |  |  |         return $this->fileExtension; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 149 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |      * Sets the file extension used to look for mapping files under. | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |      * @param string $fileExtension The file extension to set. | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     public function setFileExtension($fileExtension) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 160 |  |  |         $this->fileExtension = $fileExtension; | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |      * Returns whether the class with the specified name is transient. Only non-transient | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |      * classes, that is entities and mapped superclasses, should have their metadata loaded. | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |      * A class is non-transient if it is annotated with an annotation | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |      * from the {@see AnnotationDriver::entityAnnotationClasses}. | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |      * @param string $className | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |      * @return bool | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 1 |  |     public function isTransient($className) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 1 |  |         $classAnnotations = $this->reader->getClassAnnotations(new ReflectionClass($className)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 1 |  |         foreach ($classAnnotations as $annot) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 1 |  |             if (isset($this->entityAnnotationClasses[get_class($annot)])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 | 1 |  |                 return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 184 | 1 |  |         return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |      * {@inheritDoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 1 |  |     public function getAllClassNames() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 1 |  |         if ($this->classNames !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             return $this->classNames; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 1 |  |         if (! $this->paths) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             throw MappingException::pathRequired(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 | 1 |  |         $classes       = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 1 |  |         $includedFiles = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 1 |  |         foreach ($this->paths as $path) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 1 |  |             if (! is_dir($path)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |                 throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 | 1 |  |             $iterator = new RegexIterator( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 | 1 |  |                 new RecursiveIteratorIterator( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 | 1 |  |                     new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 1 |  |                     RecursiveIteratorIterator::LEAVES_ONLY | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 | 1 |  |                 '/^.+' . preg_quote($this->fileExtension) . '$/i', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 | 1 |  |                 RecursiveRegexIterator::GET_MATCH | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 1 |  |             foreach ($iterator as $file) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 | 1 |  |                 $sourceFile = $file[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 | 1 |  |                 if (! preg_match('(^phar:)i', $sourceFile)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 | 1 |  |                     $sourceFile = realpath($sourceFile); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 | 1 |  |                 foreach ($this->excludePaths as $excludePath) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                     $exclude = str_replace('\\', '/', realpath($excludePath)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                     $current = str_replace('\\', '/', $sourceFile); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                     if (strpos($current, $exclude) !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |                         continue 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 | 1 |  |                 require_once $sourceFile; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 | 1 |  |                 $includedFiles[] = $sourceFile; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 | 1 |  |         $declared = get_declared_classes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 1 |  |         foreach ($declared as $className) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 | 1 |  |             $rc         = new ReflectionClass($className); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 | 1 |  |             $sourceFile = $rc->getFileName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 | 1 |  |             if (! in_array($sourceFile, $includedFiles) || $this->isTransient($className)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 | 1 |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 | 1 |  |             $classes[] = $className; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 | 1 |  |         $this->classNames = $classes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 253 | 1 |  |         return $classes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 257 |  |  | class_exists(\Doctrine\Persistence\Mapping\Driver\AnnotationDriver::class); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 258 |  |  |  | 
            
                        
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.