Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Injectable.php
Go to the documentation of this file.
1 <?php
7 
8 use Zend\Code\Reflection\ClassReflection;
9 use Zend\Code\Reflection\FileReflection;
10 use Zend\Code\Reflection\ParameterReflection;
11 
15 {
19  protected $dependencies = [];
20 
26  public function getDependencies(FileReflection $fileReflection)
27  {
28  foreach ($fileReflection->getClasses() as $class) {
30  foreach ($class->getMethods() as $method) {
32  if ($method->getDeclaringClass()->getName() != $class->getName()) {
33  continue;
34  }
35 
36  foreach ($method->getParameters() as $parameter) {
37  try {
39  $dependency = $parameter->getClass();
40  if ($dependency instanceof ClassReflection) {
41  $this->dependencies[] = $dependency->getName();
42  }
43  } catch (\ReflectionException $e) {
44  if (preg_match('#^Class ([A-Za-z0-9_\\\\]+) does not exist$#', $e->getMessage(), $result)) {
45  $this->dependencies[] = $result[1];
46  } else {
47  throw $e;
48  }
49  }
50  }
51  }
52  }
53 
54  return $this->dependencies;
55  }
56 }
$_option $_optionId $class
Definition: date.phtml:13
$method
Definition: info.phtml:13