ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\Setup\AbstractOfFinder Class Reference
+ Inheritance diagram for ILIAS\Setup\AbstractOfFinder:
+ Collaboration diagram for ILIAS\Setup\AbstractOfFinder:

Public Member Functions

 __construct ()
 

Protected Member Functions

 genericGetMatchingClassNames (callable $is_matching, array $additional_ignore=[], string $matching_path=null)
 The matcher finds the class names implementing the given interface, while ignoring paths in self::$ignore and and the additional patterns provided. More...
 
 getAllClassNames (array $additional_ignore, string $matching_path=null)
 

Protected Attributes

string $root
 
array $ignore
 
array $classmap = null
 

Detailed Description

Definition at line 28 of file AbstractOfFinder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\AbstractOfFinder::__construct ( )

Definition at line 54 of file AbstractOfFinder.php.

55  {
56  $this->root = substr(__FILE__, 0, strpos(__FILE__, DIRECTORY_SEPARATOR . "src"));
57  $external_classmap = include "./libs/composer/vendor/composer/autoload_classmap.php";
58  $this->classmap = $external_classmap ?: null;
59  }

Member Function Documentation

◆ genericGetMatchingClassNames()

ILIAS\Setup\AbstractOfFinder::genericGetMatchingClassNames ( callable  $is_matching,
array  $additional_ignore = [],
string  $matching_path = null 
)
protected

The matcher finds the class names implementing the given interface, while ignoring paths in self::$ignore and and the additional patterns provided.

Patterns are regexps (without delimiters) to define complete paths on the filesystem to be ignored or selected.

Parameters
callable$is_matchingwhich takes a as argument and returns a bool if the class is matching your criteria.
string[]$additional_ignore
string | null$matching_path

Definition at line 74 of file AbstractOfFinder.php.

References Vendor\Package\$e, and ILIAS\Setup\AbstractOfFinder\getAllClassNames().

Referenced by ILIAS\Setup\UsageOfAttributeFinder\getMatchingClassNames(), ILIAS\Setup\ImplementationOfInterfaceFinder\getMatchingClassNames(), and ILIAS\Tests\Setup\TestAbstractOfFinder\getMatchingClassNames().

78  : \Iterator {
79  foreach ($this->getAllClassNames($additional_ignore, $matching_path) as $class_name) {
80  try {
81  $reflection_class = new \ReflectionClass($class_name);
82  if ($is_matching($reflection_class)) {
83  yield $class_name;
84  }
85  } catch (\Throwable $e) {
86  // ignore
87  }
88  }
89  }
getAllClassNames(array $additional_ignore, string $matching_path=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllClassNames()

ILIAS\Setup\AbstractOfFinder::getAllClassNames ( array  $additional_ignore,
string  $matching_path = null 
)
protected
Parameters
string[]$additional_ignore

Definition at line 94 of file AbstractOfFinder.php.

References $path.

Referenced by ILIAS\Setup\AbstractOfFinder\genericGetMatchingClassNames().

94  : \Iterator
95  {
96  $ignore = array_merge($this->ignore, $additional_ignore);
97 
98  if (!is_array($this->classmap)) {
99  throw new \LogicException("Composer ClassMap not loaded");
100  }
101 
102  $regexp = implode(
103  "|",
104  array_map(
105  // fix path-separators to respect windows' backspaces.
106  fn($v): string => "(" . str_replace('/', '(/|\\\\)', $v) . ")",
107  $ignore
108  )
109  );
110  if ($matching_path) {
111  $matching_path = str_replace('/', '(/|\\\\)', $matching_path);
112  }
113 
114 
115  foreach ($this->classmap as $class_name => $file_path) {
116  $real_path = realpath($file_path);
117  if ($real_path === false) {
118  throw new \RuntimeException(
119  "Could not find file for class $class_name (path: $file_path). " .
120  "Please check the composer classmap, maybe it is outdated. " .
121  "You can regenerate it by executing 'composer du' or 'composer install' " .
122  "(which also ensures dependencies are correctly installed) in the ILIAS root directory."
123  );
124  }
125 
126  $path = str_replace($this->root, "", $real_path);
127  if ($matching_path && !preg_match("#^" . $matching_path . "$#", $path)) {
128  continue;
129  }
130  if (!preg_match("#^" . $regexp . "$#", $path)) {
131  yield $class_name;
132  }
133  }
134  }
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

Field Documentation

◆ $classmap

array ILIAS\Setup\AbstractOfFinder::$classmap = null
protected

Definition at line 52 of file AbstractOfFinder.php.

◆ $ignore

array ILIAS\Setup\AbstractOfFinder::$ignore
protected
Initial value:
= [
'.*/src/Setup/',
'.*/src/GlobalScreen/',
'.*/Customizing/.*/src/',
'.*/libs/',
'.*/test/',
'.*/tests/',
'.*/setup/',
'.*ilSOAPAuth.*',
'.*ilPDExternalFeedBlockGUI.*',
]

Definition at line 35 of file AbstractOfFinder.php.

◆ $root

string ILIAS\Setup\AbstractOfFinder::$root
protected

Definition at line 30 of file AbstractOfFinder.php.


The documentation for this class was generated from the following file: