ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Setup\ImplementationOfInterfaceFinder Class Reference
+ Inheritance diagram for ILIAS\Setup\ImplementationOfInterfaceFinder:
+ Collaboration diagram for ILIAS\Setup\ImplementationOfInterfaceFinder:

Public Member Functions

 __construct ()
 
 getMatchingClassNames (string $interface, 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...
 

Protected Member Functions

 getAllClassNames (array $additional_ignore, string $matching_path=null)
 

Protected Attributes

 $root
 
 $ignore
 
 $classmap = null
 

Detailed Description

Definition at line 10 of file ImplementationOfInterfaceFinder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\ImplementationOfInterfaceFinder::__construct ( )

Definition at line 37 of file ImplementationOfInterfaceFinder.php.

38  {
39  $this->root = substr(__FILE__, 0, strpos(__FILE__, "/src"));
40  $this->classmap = include "./libs/composer/vendor/composer/autoload_classmap.php";
41  }

Member Function Documentation

◆ getAllClassNames()

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

Definition at line 73 of file ImplementationOfInterfaceFinder.php.

References ILIAS\Setup\ImplementationOfInterfaceFinder\$ignore.

Referenced by ILIAS\Setup\ImplementationOfInterfaceFinder\getMatchingClassNames().

73  : \Iterator
74  {
75  $ignore = array_merge($this->ignore, $additional_ignore);
76 
77  if (!is_array($this->classmap)) {
78  throw new \LogicException("Composer ClassMap not loaded");
79  }
80 
81  $regexp = implode(
82  "|",
83  array_map(
84  // fix path-separators to respect windows' backspaces.
85  function ($v) {
86  return "(" . str_replace('/', '(/|\\\\)', $v) . ")";
87  },
88  $ignore
89  )
90  );
91  if ($matching_path) {
92  $matching_path = str_replace('/', '(/|\\\\)', $matching_path);
93  }
94 
95 
96  foreach ($this->classmap as $class_name => $file_path) {
97  $path = str_replace($this->root, "", realpath($file_path));
98  if ($matching_path && !preg_match("#^" . $matching_path . "$#", $path)) {
99  continue;
100  }
101  if (!preg_match("#^" . $regexp . "$#", $path)) {
102  yield $class_name;
103  }
104  }
105  }
+ Here is the caller graph for this function:

◆ getMatchingClassNames()

ILIAS\Setup\ImplementationOfInterfaceFinder::getMatchingClassNames ( string  $interface,
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.

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

Parameters
string[]$additional_ignore
string$matching_path

Definition at line 53 of file ImplementationOfInterfaceFinder.php.

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

57  : \Iterator {
58  foreach ($this->getAllClassNames($additional_ignore, $matching_path) as $class_name) {
59  try {
60  $r = new \ReflectionClass($class_name);
61  if ($r->isInstantiable() && $r->implementsInterface($interface)) {
62  yield $class_name;
63  }
64  } catch (\Throwable $e) {
65  // noting to do here
66  }
67  }
68  }
getAllClassNames(array $additional_ignore, string $matching_path=null)
+ Here is the call graph for this function:

Field Documentation

◆ $classmap

ILIAS\Setup\ImplementationOfInterfaceFinder::$classmap = null
protected

Definition at line 35 of file ImplementationOfInterfaceFinder.php.

◆ $ignore

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

Definition at line 20 of file ImplementationOfInterfaceFinder.php.

Referenced by ILIAS\Setup\ImplementationOfInterfaceFinder\getAllClassNames().

◆ $root

ILIAS\Setup\ImplementationOfInterfaceFinder::$root
protected

Definition at line 15 of file ImplementationOfInterfaceFinder.php.


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