From 5bd5677e29f9285a03da44bed3bf56fcb338bce6 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 7 Mar 2021 20:32:48 +0000 Subject: [PATCH] #2111 - Add list of class entries to ignore --- Library/ClassDefinition.php | 6 ++++-- Library/ClassMethod.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Library/ClassDefinition.php b/Library/ClassDefinition.php index d022b9e78c..23885c50f5 100644 --- a/Library/ClassDefinition.php +++ b/Library/ClassDefinition.php @@ -1458,8 +1458,10 @@ public function getClassEntryByClassName( * Special treatment for Reflection in 8.0. * Because in PHP 7.4 param arg info is lighter, * but also incomplete. + * + * TODO: Leave for future, maybe PHP code devs will make "reflection" ext public... */ - if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + /*if (version_compare(PHP_VERSION, '8.0.0', '>=')) { switch (strtolower($className)) { case 'reflector': $compilationContext->headersManager->add('ext/reflection/php_reflection'); @@ -1517,7 +1519,7 @@ public function getClassEntryByClassName( if ($classEntry !== null) { return $classEntry; } - } + }*/ switch (strtolower($className)) { /** diff --git a/Library/ClassMethod.php b/Library/ClassMethod.php index 84f30610c4..8621c62c72 100644 --- a/Library/ClassMethod.php +++ b/Library/ClassMethod.php @@ -169,6 +169,26 @@ class ClassMethod */ protected $callGathererPass; + /** + * All classes must be in lower case. + * + * @var array|string[] + */ + protected array $excludedClassEntries = [ + 'reflector', + 'reflectionexception', + 'reflection', + 'reflectionfunctionabstract', + 'reflectionfunction', + 'reflectionparameter', + 'reflectionclass', + 'reflectionobject', + 'reflectionmethod', + 'reflectionproperty', + 'reflectionextension', + 'reflectionzendextension', + ]; + /** * ClassMethod constructor. * @@ -2591,6 +2611,17 @@ private function detectClassNameEntry(string $className, CompilationContext $com return null; } + /** + * Excluded classes. + * + * Cases when we can't retrieve class entry. + * For example: php/ext/reflection, as there + * are no PHP_INSTALL_HEADERS. + */ + if (in_array(ltrim(strtolower($className), '\\'), $this->excludedClassEntries)) { + return null; + } + $isAlias = false; $aliasManager = $this->classDefinition->getAliasManager(); if ($aliasManager->isAlias($className)) {