├── phpstan.neon.dist ├── .github └── workflows │ ├── coding-standards.yml │ ├── continuous-integration.yml │ ├── release-on-milestone-closed.yml │ └── static-analysis.yml ├── lib └── Doctrine │ └── Common │ └── Reflection │ ├── Compatibility │ ├── Php7 │ │ ├── ReflectionMethod.php │ │ └── ReflectionClass.php │ ├── Php8 │ │ ├── ReflectionMethod.php │ │ └── ReflectionClass.php │ ├── ReflectionClass.php │ └── ReflectionMethod.php │ ├── ClassFinderInterface.php │ ├── ReflectionProviderInterface.php │ ├── TypedNoDefaultReflectionProperty.php │ ├── RuntimePublicReflectionProperty.php │ ├── Psr0FindFile.php │ ├── StaticReflectionProperty.php │ ├── StaticReflectionMethod.php │ ├── StaticReflectionClass.php │ └── StaticReflectionParser.php ├── .doctrine-project.json ├── README.md ├── LICENSE └── composer.json /phpstan.neon.dist: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 3 3 | paths: 4 | - lib 5 | - tests 6 | phpVersion: 80106 7 | 8 | includes: 9 | - vendor/phpstan/phpstan-phpunit/extension.neon 10 | -------------------------------------------------------------------------------- /.github/workflows/coding-standards.yml: -------------------------------------------------------------------------------- 1 | name: "Coding Standards" 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "*.x" 7 | push: 8 | branches: 9 | - "*.x" 10 | 11 | jobs: 12 | coding-standards: 13 | uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1" 14 | with: 15 | php-version: "8.1" 16 | composer-root-version: "1.2" 17 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/Compatibility/Php7/ReflectionMethod.php: -------------------------------------------------------------------------------- 1 | = 80000) { 10 | class_alias('Doctrine\Common\Reflection\Compatibility\Php8\ReflectionClass', 'Doctrine\Common\Reflection\Compatibility\ReflectionClass'); 11 | } else { 12 | class_alias('Doctrine\Common\Reflection\Compatibility\Php7\ReflectionClass', 'Doctrine\Common\Reflection\Compatibility\ReflectionClass'); 13 | } 14 | 15 | if (false) { 16 | trait ReflectionClass 17 | { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/Compatibility/ReflectionMethod.php: -------------------------------------------------------------------------------- 1 | = 80000) { 10 | class_alias('Doctrine\Common\Reflection\Compatibility\Php8\ReflectionMethod', 'Doctrine\Common\Reflection\Compatibility\ReflectionMethod'); 11 | } else { 12 | class_alias('Doctrine\Common\Reflection\Compatibility\Php7\ReflectionMethod', 'Doctrine\Common\Reflection\Compatibility\ReflectionMethod'); 13 | } 14 | 15 | if (false) { 16 | trait ReflectionMethod 17 | { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/Compatibility/Php8/ReflectionClass.php: -------------------------------------------------------------------------------- 1 | isInitialized($object) ? parent::getValue($object) : null; 24 | } 25 | 26 | /** 27 | * {@inheritDoc} 28 | * 29 | * Works around the problem with setting typed no default properties to 30 | * NULL which is not supported, instead unset() to uninitialize. 31 | * 32 | * @link https://github.com/doctrine/orm/issues/7999 33 | */ 34 | #[ReturnTypeWillChange] 35 | public function setValue($object, $value = null) 36 | { 37 | if ($value === null && $this->hasType() && ! $this->getType()->allowsNull()) { 38 | $propertyName = $this->getName(); 39 | 40 | $unsetter = function () use ($propertyName) { 41 | unset($this->$propertyName); 42 | }; 43 | $unsetter = $unsetter->bindTo($object, $this->getDeclaringClass()->getName()); 44 | $unsetter(); 45 | 46 | return; 47 | } 48 | 49 | parent::setValue($object, $value); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/RuntimePublicReflectionProperty.php: -------------------------------------------------------------------------------- 1 | getName(); 25 | 26 | if ($object instanceof Proxy && ! $object->__isInitialized()) { 27 | $originalInitializer = $object->__getInitializer(); 28 | $object->__setInitializer(null); 29 | $val = $object->$name ?? null; 30 | $object->__setInitializer($originalInitializer); 31 | 32 | return $val; 33 | } 34 | 35 | return isset($object->$name) ? parent::getValue($object) : null; 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | * 41 | * Avoids triggering lazy loading via `__set` if the provided object 42 | * is a {@see \Doctrine\Common\Proxy\Proxy}. 43 | * 44 | * @link https://bugs.php.net/bug.php?id=63463 45 | */ 46 | #[ReturnTypeWillChange] 47 | public function setValue($object, $value = null) 48 | { 49 | if (! ($object instanceof Proxy && ! $object->__isInitialized())) { 50 | parent::setValue($object, $value); 51 | 52 | return; 53 | } 54 | 55 | $originalInitializer = $object->__getInitializer(); 56 | $object->__setInitializer(null); 57 | parent::setValue($object, $value); 58 | $object->__setInitializer($originalInitializer); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/Psr0FindFile.php: -------------------------------------------------------------------------------- 1 | prefixes = $prefixes; 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | public function findFile($class) 38 | { 39 | if ($class[0] === '\\') { 40 | $class = substr($class, 1); 41 | } 42 | 43 | $lastNsPos = strrpos($class, '\\'); 44 | 45 | if ($lastNsPos !== false) { 46 | // namespaced class name 47 | $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $lastNsPos)) . DIRECTORY_SEPARATOR; 48 | $className = substr($class, $lastNsPos + 1); 49 | } else { 50 | // PEAR-like class name 51 | $classPath = null; 52 | $className = $class; 53 | } 54 | 55 | $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; 56 | 57 | foreach ($this->prefixes as $prefix => $dirs) { 58 | if (strpos($class, $prefix) !== 0) { 59 | continue; 60 | } 61 | 62 | foreach ($dirs as $dir) { 63 | if (is_file($dir . DIRECTORY_SEPARATOR . $classPath)) { 64 | return $dir . DIRECTORY_SEPARATOR . $classPath; 65 | } 66 | } 67 | } 68 | 69 | return null; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "doctrine/reflection", 3 | "type": "library", 4 | "description": "The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on top of the reflection functionality that comes with PHP. It allows you to get the reflection information about classes, methods and properties statically.", 5 | "keywords": [ 6 | "reflection", 7 | "static" 8 | ], 9 | "homepage": "https://www.doctrine-project.org/projects/reflection.html", 10 | "license": "MIT", 11 | "authors": [ 12 | {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, 13 | {"name": "Roman Borschel", "email": "roman@code-factory.org"}, 14 | {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, 15 | {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, 16 | {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}, 17 | {"name": "Marco Pivetta", "email": "ocramius@gmail.com"} 18 | ], 19 | "require": { 20 | "php": "^7.1 || ^8.0", 21 | "ext-tokenizer": "*", 22 | "doctrine/annotations": "^1.0 || ^2.0" 23 | }, 24 | "require-dev": { 25 | "doctrine/coding-standard": "^9", 26 | "doctrine/common": "^3.3", 27 | "phpstan/phpstan": "^1.4.10", 28 | "phpstan/phpstan-phpunit": "^1", 29 | "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" 30 | }, 31 | "conflict": { 32 | "doctrine/common": "<2.9" 33 | }, 34 | "autoload": { 35 | "psr-4": { 36 | "Doctrine\\Common\\": "lib/Doctrine/Common" 37 | } 38 | }, 39 | "autoload-dev": { 40 | "psr-4": { 41 | "Doctrine\\Tests\\": "tests/Doctrine/Tests", 42 | "Doctrine\\Tests_PHP74\\": "tests/Doctrine/Tests_PHP74" 43 | } 44 | }, 45 | "config": { 46 | "allow-plugins": { 47 | "dealerdirect/phpcodesniffer-composer-installer": true 48 | }, 49 | "sort-packages": true 50 | }, 51 | "abandoned": "roave/better-reflection" 52 | } 53 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/StaticReflectionProperty.php: -------------------------------------------------------------------------------- 1 | staticReflectionParser = $staticReflectionParser; 31 | $this->propertyName = $propertyName; 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | #[ReturnTypeWillChange] 38 | public function getName() 39 | { 40 | return $this->propertyName; 41 | } 42 | 43 | /** 44 | * @return StaticReflectionParser 45 | */ 46 | protected function getStaticReflectionParser() 47 | { 48 | return $this->staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', $this->propertyName); 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | #[ReturnTypeWillChange] 55 | public function getDeclaringClass() 56 | { 57 | return $this->getStaticReflectionParser()->getReflectionClass(); 58 | } 59 | 60 | /** 61 | * {@inheritDoc} 62 | */ 63 | #[ReturnTypeWillChange] 64 | public function getDocComment() 65 | { 66 | return $this->getStaticReflectionParser()->getDocComment('property', $this->propertyName); 67 | } 68 | 69 | /** 70 | * @return string[] 71 | */ 72 | public function getUseStatements() 73 | { 74 | return $this->getStaticReflectionParser()->getUseStatements(); 75 | } 76 | 77 | /** 78 | * {@inheritDoc} 79 | */ 80 | public static function export($class, $name, $return = false) 81 | { 82 | throw new ReflectionException('Method not implemented'); 83 | } 84 | 85 | /** 86 | * {@inheritDoc} 87 | */ 88 | #[ReturnTypeWillChange] 89 | public function getModifiers() 90 | { 91 | throw new ReflectionException('Method not implemented'); 92 | } 93 | 94 | /** 95 | * {@inheritDoc} 96 | */ 97 | #[ReturnTypeWillChange] 98 | public function getValue($object = null) 99 | { 100 | throw new ReflectionException('Method not implemented'); 101 | } 102 | 103 | /** 104 | * {@inheritDoc} 105 | */ 106 | #[ReturnTypeWillChange] 107 | public function isDefault() 108 | { 109 | throw new ReflectionException('Method not implemented'); 110 | } 111 | 112 | /** 113 | * {@inheritDoc} 114 | */ 115 | #[ReturnTypeWillChange] 116 | public function isPrivate() 117 | { 118 | throw new ReflectionException('Method not implemented'); 119 | } 120 | 121 | /** 122 | * {@inheritDoc} 123 | */ 124 | #[ReturnTypeWillChange] 125 | public function isProtected() 126 | { 127 | throw new ReflectionException('Method not implemented'); 128 | } 129 | 130 | /** 131 | * {@inheritDoc} 132 | */ 133 | #[ReturnTypeWillChange] 134 | public function isPublic() 135 | { 136 | throw new ReflectionException('Method not implemented'); 137 | } 138 | 139 | /** 140 | * {@inheritDoc} 141 | */ 142 | #[ReturnTypeWillChange] 143 | public function isStatic() 144 | { 145 | throw new ReflectionException('Method not implemented'); 146 | } 147 | 148 | /** 149 | * {@inheritDoc} 150 | */ 151 | #[ReturnTypeWillChange] 152 | public function setAccessible($accessible) 153 | { 154 | throw new ReflectionException('Method not implemented'); 155 | } 156 | 157 | /** 158 | * {@inheritDoc} 159 | */ 160 | #[ReturnTypeWillChange] 161 | public function setValue($object, $value = null) 162 | { 163 | throw new ReflectionException('Method not implemented'); 164 | } 165 | 166 | /** 167 | * {@inheritDoc} 168 | */ 169 | public function __toString() 170 | { 171 | throw new ReflectionException('Method not implemented'); 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/StaticReflectionMethod.php: -------------------------------------------------------------------------------- 1 | staticReflectionParser = $staticReflectionParser; 34 | $this->methodName = $methodName; 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | #[ReturnTypeWillChange] 41 | public function getName() 42 | { 43 | return $this->methodName; 44 | } 45 | 46 | /** 47 | * @return StaticReflectionParser 48 | */ 49 | protected function getStaticReflectionParser() 50 | { 51 | return $this->staticReflectionParser->getStaticReflectionParserForDeclaringClass('method', $this->methodName); 52 | } 53 | 54 | /** 55 | * {@inheritDoc} 56 | */ 57 | #[ReturnTypeWillChange] 58 | public function getDeclaringClass() 59 | { 60 | return $this->getStaticReflectionParser()->getReflectionClass(); 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | #[ReturnTypeWillChange] 67 | public function getNamespaceName() 68 | { 69 | return $this->getStaticReflectionParser()->getNamespaceName(); 70 | } 71 | 72 | /** 73 | * {@inheritDoc} 74 | */ 75 | #[ReturnTypeWillChange] 76 | public function getDocComment() 77 | { 78 | return $this->getStaticReflectionParser()->getDocComment('method', $this->methodName); 79 | } 80 | 81 | /** 82 | * @return string[] 83 | */ 84 | public function getUseStatements() 85 | { 86 | return $this->getStaticReflectionParser()->getUseStatements(); 87 | } 88 | 89 | /** 90 | * {@inheritDoc} 91 | */ 92 | public static function export($class, $name, $return = false) 93 | { 94 | throw new ReflectionException('Method not implemented'); 95 | } 96 | 97 | /** 98 | * {@inheritDoc} 99 | */ 100 | #[ReturnTypeWillChange] 101 | public function getClosure($object = null) 102 | { 103 | throw new ReflectionException('Method not implemented'); 104 | } 105 | 106 | /** 107 | * {@inheritDoc} 108 | */ 109 | #[ReturnTypeWillChange] 110 | public function getModifiers() 111 | { 112 | throw new ReflectionException('Method not implemented'); 113 | } 114 | 115 | /** 116 | * {@inheritDoc} 117 | */ 118 | #[ReturnTypeWillChange] 119 | public function getPrototype() 120 | { 121 | throw new ReflectionException('Method not implemented'); 122 | } 123 | 124 | /** 125 | * {@inheritDoc} 126 | */ 127 | #[ReturnTypeWillChange] 128 | public function invokeArgs($object, array $args) 129 | { 130 | throw new ReflectionException('Method not implemented'); 131 | } 132 | 133 | /** 134 | * {@inheritDoc} 135 | */ 136 | #[ReturnTypeWillChange] 137 | public function isAbstract() 138 | { 139 | throw new ReflectionException('Method not implemented'); 140 | } 141 | 142 | /** 143 | * {@inheritDoc} 144 | */ 145 | #[ReturnTypeWillChange] 146 | public function isConstructor() 147 | { 148 | throw new ReflectionException('Method not implemented'); 149 | } 150 | 151 | /** 152 | * {@inheritDoc} 153 | */ 154 | #[ReturnTypeWillChange] 155 | public function isDestructor() 156 | { 157 | throw new ReflectionException('Method not implemented'); 158 | } 159 | 160 | /** 161 | * {@inheritDoc} 162 | */ 163 | #[ReturnTypeWillChange] 164 | public function isFinal() 165 | { 166 | throw new ReflectionException('Method not implemented'); 167 | } 168 | 169 | /** 170 | * {@inheritDoc} 171 | */ 172 | #[ReturnTypeWillChange] 173 | public function isPrivate() 174 | { 175 | throw new ReflectionException('Method not implemented'); 176 | } 177 | 178 | /** 179 | * {@inheritDoc} 180 | */ 181 | #[ReturnTypeWillChange] 182 | public function isProtected() 183 | { 184 | throw new ReflectionException('Method not implemented'); 185 | } 186 | 187 | /** 188 | * {@inheritDoc} 189 | */ 190 | #[ReturnTypeWillChange] 191 | public function isPublic() 192 | { 193 | throw new ReflectionException('Method not implemented'); 194 | } 195 | 196 | /** 197 | * {@inheritDoc} 198 | */ 199 | #[ReturnTypeWillChange] 200 | public function isStatic() 201 | { 202 | throw new ReflectionException('Method not implemented'); 203 | } 204 | 205 | /** 206 | * {@inheritDoc} 207 | */ 208 | #[ReturnTypeWillChange] 209 | public function setAccessible($accessible) 210 | { 211 | throw new ReflectionException('Method not implemented'); 212 | } 213 | 214 | /** 215 | * {@inheritDoc} 216 | */ 217 | public function __toString() 218 | { 219 | throw new ReflectionException('Method not implemented'); 220 | } 221 | 222 | /** 223 | * {@inheritDoc} 224 | */ 225 | #[ReturnTypeWillChange] 226 | public function getClosureThis() 227 | { 228 | throw new ReflectionException('Method not implemented'); 229 | } 230 | 231 | /** 232 | * {@inheritDoc} 233 | */ 234 | #[ReturnTypeWillChange] 235 | public function getEndLine() 236 | { 237 | throw new ReflectionException('Method not implemented'); 238 | } 239 | 240 | /** 241 | * {@inheritDoc} 242 | */ 243 | #[ReturnTypeWillChange] 244 | public function getExtension() 245 | { 246 | throw new ReflectionException('Method not implemented'); 247 | } 248 | 249 | /** 250 | * {@inheritDoc} 251 | */ 252 | #[ReturnTypeWillChange] 253 | public function getExtensionName() 254 | { 255 | throw new ReflectionException('Method not implemented'); 256 | } 257 | 258 | /** 259 | * {@inheritDoc} 260 | */ 261 | #[ReturnTypeWillChange] 262 | public function getFileName() 263 | { 264 | throw new ReflectionException('Method not implemented'); 265 | } 266 | 267 | /** 268 | * {@inheritDoc} 269 | */ 270 | #[ReturnTypeWillChange] 271 | public function getNumberOfParameters() 272 | { 273 | throw new ReflectionException('Method not implemented'); 274 | } 275 | 276 | /** 277 | * {@inheritDoc} 278 | */ 279 | #[ReturnTypeWillChange] 280 | public function getNumberOfRequiredParameters() 281 | { 282 | throw new ReflectionException('Method not implemented'); 283 | } 284 | 285 | /** 286 | * {@inheritDoc} 287 | */ 288 | #[ReturnTypeWillChange] 289 | public function getParameters() 290 | { 291 | throw new ReflectionException('Method not implemented'); 292 | } 293 | 294 | /** 295 | * {@inheritDoc} 296 | */ 297 | #[ReturnTypeWillChange] 298 | public function getShortName() 299 | { 300 | throw new ReflectionException('Method not implemented'); 301 | } 302 | 303 | /** 304 | * {@inheritDoc} 305 | */ 306 | #[ReturnTypeWillChange] 307 | public function getStartLine() 308 | { 309 | throw new ReflectionException('Method not implemented'); 310 | } 311 | 312 | /** 313 | * {@inheritDoc} 314 | */ 315 | #[ReturnTypeWillChange] 316 | public function getStaticVariables() 317 | { 318 | throw new ReflectionException('Method not implemented'); 319 | } 320 | 321 | /** 322 | * {@inheritDoc} 323 | */ 324 | #[ReturnTypeWillChange] 325 | public function inNamespace() 326 | { 327 | throw new ReflectionException('Method not implemented'); 328 | } 329 | 330 | /** 331 | * {@inheritDoc} 332 | */ 333 | #[ReturnTypeWillChange] 334 | public function isClosure() 335 | { 336 | throw new ReflectionException('Method not implemented'); 337 | } 338 | 339 | /** 340 | * {@inheritDoc} 341 | */ 342 | #[ReturnTypeWillChange] 343 | public function isDeprecated() 344 | { 345 | throw new ReflectionException('Method not implemented'); 346 | } 347 | 348 | /** 349 | * {@inheritDoc} 350 | */ 351 | #[ReturnTypeWillChange] 352 | public function isInternal() 353 | { 354 | throw new ReflectionException('Method not implemented'); 355 | } 356 | 357 | /** 358 | * {@inheritDoc} 359 | */ 360 | #[ReturnTypeWillChange] 361 | public function isUserDefined() 362 | { 363 | throw new ReflectionException('Method not implemented'); 364 | } 365 | 366 | /** 367 | * {@inheritDoc} 368 | */ 369 | #[ReturnTypeWillChange] 370 | public function returnsReference() 371 | { 372 | throw new ReflectionException('Method not implemented'); 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/StaticReflectionClass.php: -------------------------------------------------------------------------------- 1 | staticReflectionParser = $staticReflectionParser; 24 | } 25 | 26 | /** 27 | * {@inheritDoc} 28 | */ 29 | #[ReturnTypeWillChange] 30 | public function getName() 31 | { 32 | return $this->staticReflectionParser->getClassName(); 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | #[ReturnTypeWillChange] 39 | public function getDocComment() 40 | { 41 | return $this->staticReflectionParser->getDocComment(); 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | */ 47 | #[ReturnTypeWillChange] 48 | public function getNamespaceName() 49 | { 50 | return $this->staticReflectionParser->getNamespaceName(); 51 | } 52 | 53 | /** 54 | * @return string[] 55 | */ 56 | public function getUseStatements() 57 | { 58 | return $this->staticReflectionParser->getUseStatements(); 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | #[ReturnTypeWillChange] 65 | public function getMethod($name) 66 | { 67 | return $this->staticReflectionParser->getReflectionMethod($name); 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | #[ReturnTypeWillChange] 74 | public function getProperty($name) 75 | { 76 | return $this->staticReflectionParser->getReflectionProperty($name); 77 | } 78 | 79 | /** 80 | * {@inheritDoc} 81 | */ 82 | public static function export($argument, $return = false) 83 | { 84 | throw new ReflectionException('Method not implemented'); 85 | } 86 | 87 | /** 88 | * {@inheritDoc} 89 | */ 90 | #[ReturnTypeWillChange] 91 | public function getConstant($name) 92 | { 93 | throw new ReflectionException('Method not implemented'); 94 | } 95 | 96 | /** 97 | * {@inheritDoc} 98 | */ 99 | #[ReturnTypeWillChange] 100 | public function getConstructor() 101 | { 102 | throw new ReflectionException('Method not implemented'); 103 | } 104 | 105 | /** 106 | * {@inheritDoc} 107 | */ 108 | #[ReturnTypeWillChange] 109 | public function getDefaultProperties() 110 | { 111 | throw new ReflectionException('Method not implemented'); 112 | } 113 | 114 | /** 115 | * {@inheritDoc} 116 | */ 117 | #[ReturnTypeWillChange] 118 | public function getEndLine() 119 | { 120 | throw new ReflectionException('Method not implemented'); 121 | } 122 | 123 | /** 124 | * {@inheritDoc} 125 | */ 126 | #[ReturnTypeWillChange] 127 | public function getExtension() 128 | { 129 | throw new ReflectionException('Method not implemented'); 130 | } 131 | 132 | /** 133 | * {@inheritDoc} 134 | */ 135 | #[ReturnTypeWillChange] 136 | public function getExtensionName() 137 | { 138 | throw new ReflectionException('Method not implemented'); 139 | } 140 | 141 | /** 142 | * {@inheritDoc} 143 | */ 144 | #[ReturnTypeWillChange] 145 | public function getFileName() 146 | { 147 | throw new ReflectionException('Method not implemented'); 148 | } 149 | 150 | /** 151 | * {@inheritDoc} 152 | */ 153 | #[ReturnTypeWillChange] 154 | public function getInterfaceNames() 155 | { 156 | throw new ReflectionException('Method not implemented'); 157 | } 158 | 159 | /** 160 | * {@inheritDoc} 161 | */ 162 | #[ReturnTypeWillChange] 163 | public function getInterfaces() 164 | { 165 | throw new ReflectionException('Method not implemented'); 166 | } 167 | 168 | /** 169 | * {@inheritDoc} 170 | */ 171 | #[ReturnTypeWillChange] 172 | public function getMethods($filter = null) 173 | { 174 | throw new ReflectionException('Method not implemented'); 175 | } 176 | 177 | /** 178 | * {@inheritDoc} 179 | */ 180 | #[ReturnTypeWillChange] 181 | public function getModifiers() 182 | { 183 | throw new ReflectionException('Method not implemented'); 184 | } 185 | 186 | /** 187 | * {@inheritDoc} 188 | */ 189 | #[ReturnTypeWillChange] 190 | public function getParentClass() 191 | { 192 | throw new ReflectionException('Method not implemented'); 193 | } 194 | 195 | /** 196 | * {@inheritDoc} 197 | */ 198 | #[ReturnTypeWillChange] 199 | public function getProperties($filter = null) 200 | { 201 | throw new ReflectionException('Method not implemented'); 202 | } 203 | 204 | /** 205 | * {@inheritDoc} 206 | */ 207 | #[ReturnTypeWillChange] 208 | public function getShortName() 209 | { 210 | throw new ReflectionException('Method not implemented'); 211 | } 212 | 213 | /** 214 | * {@inheritDoc} 215 | */ 216 | #[ReturnTypeWillChange] 217 | public function getStartLine() 218 | { 219 | throw new ReflectionException('Method not implemented'); 220 | } 221 | 222 | /** 223 | * {@inheritDoc} 224 | */ 225 | #[ReturnTypeWillChange] 226 | public function getStaticProperties() 227 | { 228 | throw new ReflectionException('Method not implemented'); 229 | } 230 | 231 | /** 232 | * {@inheritDoc} 233 | */ 234 | #[ReturnTypeWillChange] 235 | public function getStaticPropertyValue($name, $default = '') 236 | { 237 | throw new ReflectionException('Method not implemented'); 238 | } 239 | 240 | /** 241 | * {@inheritDoc} 242 | */ 243 | #[ReturnTypeWillChange] 244 | public function getTraitAliases() 245 | { 246 | throw new ReflectionException('Method not implemented'); 247 | } 248 | 249 | /** 250 | * {@inheritDoc} 251 | */ 252 | #[ReturnTypeWillChange] 253 | public function getTraitNames() 254 | { 255 | throw new ReflectionException('Method not implemented'); 256 | } 257 | 258 | /** 259 | * {@inheritDoc} 260 | */ 261 | #[ReturnTypeWillChange] 262 | public function getTraits() 263 | { 264 | throw new ReflectionException('Method not implemented'); 265 | } 266 | 267 | /** 268 | * {@inheritDoc} 269 | */ 270 | #[ReturnTypeWillChange] 271 | public function hasConstant($name) 272 | { 273 | throw new ReflectionException('Method not implemented'); 274 | } 275 | 276 | /** 277 | * {@inheritDoc} 278 | */ 279 | #[ReturnTypeWillChange] 280 | public function hasMethod($name) 281 | { 282 | throw new ReflectionException('Method not implemented'); 283 | } 284 | 285 | /** 286 | * {@inheritDoc} 287 | */ 288 | #[ReturnTypeWillChange] 289 | public function hasProperty($name) 290 | { 291 | throw new ReflectionException('Method not implemented'); 292 | } 293 | 294 | /** 295 | * {@inheritDoc} 296 | */ 297 | #[ReturnTypeWillChange] 298 | public function implementsInterface($interface) 299 | { 300 | throw new ReflectionException('Method not implemented'); 301 | } 302 | 303 | /** 304 | * {@inheritDoc} 305 | */ 306 | #[ReturnTypeWillChange] 307 | public function inNamespace() 308 | { 309 | throw new ReflectionException('Method not implemented'); 310 | } 311 | 312 | /** 313 | * {@inheritDoc} 314 | */ 315 | #[ReturnTypeWillChange] 316 | public function isAbstract() 317 | { 318 | throw new ReflectionException('Method not implemented'); 319 | } 320 | 321 | /** 322 | * {@inheritDoc} 323 | */ 324 | #[ReturnTypeWillChange] 325 | public function isCloneable() 326 | { 327 | throw new ReflectionException('Method not implemented'); 328 | } 329 | 330 | /** 331 | * {@inheritDoc} 332 | */ 333 | #[ReturnTypeWillChange] 334 | public function isFinal() 335 | { 336 | throw new ReflectionException('Method not implemented'); 337 | } 338 | 339 | /** 340 | * {@inheritDoc} 341 | */ 342 | #[ReturnTypeWillChange] 343 | public function isInstance($object) 344 | { 345 | throw new ReflectionException('Method not implemented'); 346 | } 347 | 348 | /** 349 | * {@inheritDoc} 350 | */ 351 | #[ReturnTypeWillChange] 352 | public function isInstantiable() 353 | { 354 | throw new ReflectionException('Method not implemented'); 355 | } 356 | 357 | /** 358 | * {@inheritDoc} 359 | */ 360 | #[ReturnTypeWillChange] 361 | public function isInterface() 362 | { 363 | throw new ReflectionException('Method not implemented'); 364 | } 365 | 366 | /** 367 | * {@inheritDoc} 368 | */ 369 | #[ReturnTypeWillChange] 370 | public function isInternal() 371 | { 372 | throw new ReflectionException('Method not implemented'); 373 | } 374 | 375 | /** 376 | * {@inheritDoc} 377 | */ 378 | #[ReturnTypeWillChange] 379 | public function isIterateable() 380 | { 381 | throw new ReflectionException('Method not implemented'); 382 | } 383 | 384 | /** 385 | * {@inheritDoc} 386 | */ 387 | #[ReturnTypeWillChange] 388 | public function isSubclassOf($class) 389 | { 390 | throw new ReflectionException('Method not implemented'); 391 | } 392 | 393 | /** 394 | * {@inheritDoc} 395 | */ 396 | #[ReturnTypeWillChange] 397 | public function isTrait() 398 | { 399 | throw new ReflectionException('Method not implemented'); 400 | } 401 | 402 | /** 403 | * {@inheritDoc} 404 | */ 405 | #[ReturnTypeWillChange] 406 | public function isUserDefined() 407 | { 408 | throw new ReflectionException('Method not implemented'); 409 | } 410 | 411 | /** 412 | * {@inheritDoc} 413 | */ 414 | #[ReturnTypeWillChange] 415 | public function newInstanceArgs(array $args = []) 416 | { 417 | throw new ReflectionException('Method not implemented'); 418 | } 419 | 420 | /** 421 | * {@inheritDoc} 422 | */ 423 | #[ReturnTypeWillChange] 424 | public function newInstanceWithoutConstructor() 425 | { 426 | throw new ReflectionException('Method not implemented'); 427 | } 428 | 429 | /** 430 | * {@inheritDoc} 431 | */ 432 | #[ReturnTypeWillChange] 433 | public function setStaticPropertyValue($name, $value) 434 | { 435 | throw new ReflectionException('Method not implemented'); 436 | } 437 | 438 | /** 439 | * {@inheritDoc} 440 | */ 441 | public function __toString() 442 | { 443 | throw new ReflectionException('Method not implemented'); 444 | } 445 | } 446 | -------------------------------------------------------------------------------- /lib/Doctrine/Common/Reflection/StaticReflectionParser.php: -------------------------------------------------------------------------------- 1 | '', 96 | 'property' => [], 97 | 'method' => [], 98 | ]; 99 | 100 | /** 101 | * The name of the class this class extends, if any. 102 | * 103 | * @var string 104 | */ 105 | protected $parentClassName = ''; 106 | 107 | /** 108 | * The parent PSR-0 Parser. 109 | * 110 | * @var StaticReflectionParser 111 | */ 112 | protected $parentStaticReflectionParser; 113 | 114 | /** 115 | * Parses a class residing in a PSR-0 hierarchy. 116 | * 117 | * @param string $className The full, namespaced class name. 118 | * @param ClassFinderInterface $finder A ClassFinder object which finds the class. 119 | * @param bool $classAnnotationOptimize Only retrieve the class docComment. 120 | * Presumes there is only one statement per line. 121 | */ 122 | public function __construct($className, $finder, $classAnnotationOptimize = false) 123 | { 124 | $this->className = ltrim($className, '\\'); 125 | $lastNsPos = strrpos($this->className, '\\'); 126 | 127 | if ($lastNsPos !== false) { 128 | $this->namespace = substr($this->className, 0, $lastNsPos); 129 | $this->shortClassName = substr($this->className, $lastNsPos + 1); 130 | } else { 131 | $this->shortClassName = $this->className; 132 | } 133 | 134 | $this->finder = $finder; 135 | $this->classAnnotationOptimize = $classAnnotationOptimize; 136 | } 137 | 138 | /** 139 | * @return void 140 | */ 141 | protected function parse() 142 | { 143 | $fileName = $this->finder->findFile($this->className); 144 | 145 | if ($this->parsed || ! $fileName) { 146 | return; 147 | } 148 | 149 | $this->parsed = true; 150 | $contents = file_get_contents($fileName); 151 | if ($this->classAnnotationOptimize) { 152 | $regex = sprintf('/\A.*^\s*((abstract|final)\s+)?class\s+%s\s+/sm', $this->shortClassName); 153 | 154 | if (preg_match($regex, $contents, $matches)) { 155 | $contents = $matches[0]; 156 | } 157 | } 158 | 159 | $tokenParser = new TokenParser($contents); 160 | $docComment = ''; 161 | $lastToken = false; 162 | 163 | while ($token = $tokenParser->next(false)) { 164 | switch ($token[0]) { 165 | case T_USE: 166 | $this->useStatements = array_merge($this->useStatements, $tokenParser->parseUseStatement()); 167 | break; 168 | case T_DOC_COMMENT: 169 | $docComment = $token[1]; 170 | break; 171 | case T_CLASS: 172 | if ($lastToken !== T_PAAMAYIM_NEKUDOTAYIM && $lastToken !== T_NEW) { 173 | $this->docComment['class'] = $docComment; 174 | $docComment = ''; 175 | } 176 | 177 | break; 178 | case T_VAR: 179 | case T_PRIVATE: 180 | case T_PROTECTED: 181 | case T_PUBLIC: 182 | $token = $tokenParser->next(); 183 | if ($token[0] === T_VARIABLE) { 184 | $propertyName = substr($token[1], 1); 185 | $this->docComment['property'][$propertyName] = $docComment; 186 | continue 2; 187 | } 188 | 189 | if ($token[0] !== T_FUNCTION) { 190 | // For example, it can be T_FINAL. 191 | continue 2; 192 | } 193 | // No break. 194 | case T_FUNCTION: 195 | // The next string after function is the name, but 196 | // there can be & before the function name so find the 197 | // string. 198 | while (($token = $tokenParser->next()) && $token[0] !== T_STRING) { 199 | continue; 200 | } 201 | 202 | if ($token === null) { 203 | break; 204 | } 205 | 206 | $methodName = $token[1]; 207 | $this->docComment['method'][$methodName] = $docComment; 208 | $docComment = ''; 209 | break; 210 | case T_EXTENDS: 211 | $this->parentClassName = $tokenParser->parseClass(); 212 | $nsPos = strpos($this->parentClassName, '\\'); 213 | $fullySpecified = false; 214 | if ($nsPos === 0) { 215 | $fullySpecified = true; 216 | } else { 217 | if ($nsPos) { 218 | $prefix = strtolower(substr($this->parentClassName, 0, $nsPos)); 219 | $postfix = substr($this->parentClassName, $nsPos); 220 | } else { 221 | $prefix = strtolower($this->parentClassName); 222 | $postfix = ''; 223 | } 224 | 225 | foreach ($this->useStatements as $alias => $use) { 226 | if ($alias !== $prefix) { 227 | continue; 228 | } 229 | 230 | $this->parentClassName = '\\' . $use . $postfix; 231 | $fullySpecified = true; 232 | } 233 | } 234 | 235 | if (! $fullySpecified) { 236 | $this->parentClassName = '\\' . $this->namespace . '\\' . $this->parentClassName; 237 | } 238 | 239 | break; 240 | } 241 | 242 | $lastToken = is_array($token) ? $token[0] : false; 243 | } 244 | } 245 | 246 | /** 247 | * @return StaticReflectionParser 248 | */ 249 | protected function getParentStaticReflectionParser() 250 | { 251 | if (empty($this->parentStaticReflectionParser)) { 252 | $this->parentStaticReflectionParser = new static($this->parentClassName, $this->finder); 253 | } 254 | 255 | return $this->parentStaticReflectionParser; 256 | } 257 | 258 | /** 259 | * @return string 260 | */ 261 | public function getClassName() 262 | { 263 | return $this->className; 264 | } 265 | 266 | /** 267 | * @return string 268 | */ 269 | public function getNamespaceName() 270 | { 271 | return $this->namespace; 272 | } 273 | 274 | /** 275 | * {@inheritDoc} 276 | */ 277 | public function getReflectionClass() 278 | { 279 | return new StaticReflectionClass($this); 280 | } 281 | 282 | /** 283 | * {@inheritDoc} 284 | */ 285 | public function getReflectionMethod($methodName) 286 | { 287 | return new StaticReflectionMethod($this, $methodName); 288 | } 289 | 290 | /** 291 | * {@inheritDoc} 292 | */ 293 | public function getReflectionProperty($propertyName) 294 | { 295 | return new StaticReflectionProperty($this, $propertyName); 296 | } 297 | 298 | /** 299 | * Gets the use statements from this file. 300 | * 301 | * @return string[] 302 | */ 303 | public function getUseStatements() 304 | { 305 | $this->parse(); 306 | 307 | return $this->useStatements; 308 | } 309 | 310 | /** 311 | * Gets the doc comment. 312 | * 313 | * @param string $type The type: 'class', 'property' or 'method'. 314 | * @param string $name The name of the property or method, not needed for 'class'. 315 | * 316 | * @return string The doc comment, empty string if none. 317 | */ 318 | public function getDocComment($type = 'class', $name = '') 319 | { 320 | $this->parse(); 321 | 322 | return $name ? $this->docComment[$type][$name] : $this->docComment[$type]; 323 | } 324 | 325 | /** 326 | * Gets the PSR-0 parser for the declaring class. 327 | * 328 | * @param string $type The type: 'property' or 'method'. 329 | * @param string $name The name of the property or method. 330 | * 331 | * @return StaticReflectionParser A static reflection parser for the declaring class. 332 | * 333 | * @throws ReflectionException 334 | */ 335 | public function getStaticReflectionParserForDeclaringClass($type, $name) 336 | { 337 | $this->parse(); 338 | if (isset($this->docComment[$type][$name])) { 339 | return $this; 340 | } 341 | 342 | if (! empty($this->parentClassName)) { 343 | return $this->getParentStaticReflectionParser()->getStaticReflectionParserForDeclaringClass($type, $name); 344 | } 345 | 346 | throw new ReflectionException('Invalid ' . $type . ' "' . $name . '"'); 347 | } 348 | } 349 | --------------------------------------------------------------------------------