Skip to content

Commit

Permalink
#2111 - Add list of class entries to ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Mar 7, 2021
1 parent 6c3bc50 commit 5bd5677
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Library/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -1517,7 +1519,7 @@ public function getClassEntryByClassName(
if ($classEntry !== null) {
return $classEntry;
}
}
}*/

switch (strtolower($className)) {
/**
Expand Down
31 changes: 31 additions & 0 deletions Library/ClassMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 5bd5677

Please sign in to comment.