Esempio n. 1
0
 /**
  * Retrieves list of classes for given path
  *
  * @param string $path path to dir with files
  *
  * @return array
  * @throws FileSystemException
  */
 public function getList($path)
 {
     $classes = [];
     foreach ($this->classesScanner->getList($path) as $className) {
         $classes[$className] = $this->classReaderDecorator->getConstructor($className);
     }
     return $classes;
 }
Esempio n. 2
0
 /**
  * Returns constructor with defined arguments
  *
  * @param DefinitionsCollection $definitionsCollection
  * @param ConfigInterface $config
  * @return array|mixed
  * @throws \ReflectionException
  */
 private function getConfigForScope(DefinitionsCollection $definitionsCollection, ConfigInterface $config)
 {
     $constructors = [];
     $argumentsResolver = $this->argumentsResolverFactory->create($config);
     foreach ($definitionsCollection->getInstancesNamesList() as $instanceType) {
         if (!$this->typeReader->isConcrete($instanceType)) {
             continue;
         }
         $constructor = $definitionsCollection->getInstanceArguments($instanceType);
         $constructors[$instanceType] = $argumentsResolver->getResolvedConstructorArguments($instanceType, $constructor);
     }
     foreach (array_keys($config->getVirtualTypes()) as $instanceType) {
         $originalType = $config->getInstanceType($instanceType);
         if (!$definitionsCollection->hasInstance($originalType)) {
             if (!$this->typeReader->isConcrete($originalType)) {
                 continue;
             }
             $constructor = $this->classReaderDecorator->getConstructor($originalType);
         } else {
             $constructor = $definitionsCollection->getInstanceArguments($originalType);
         }
         $constructors[$instanceType] = $argumentsResolver->getResolvedConstructorArguments($instanceType, $constructor);
     }
     return $constructors;
 }
Esempio n. 3
0
 /**
  * Retrieves list of classes and arguments for given path
  * [CLASS NAME => ConstructorArgument[]]
  *
  * @param string $path
  * @return array
  * @throws FilesystemException
  */
 public function getList($path)
 {
     $realPath = realpath($path);
     if (!(bool) $realPath) {
         throw new FilesystemException();
     }
     $classes = [];
     $recursiveIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($realPath, \FilesystemIterator::FOLLOW_SYMLINKS), \RecursiveIteratorIterator::SELF_FIRST);
     /** @var $fileItem \SplFileInfo */
     foreach ($recursiveIterator as $fileItem) {
         if (!$this->isPhpFile($fileItem)) {
             continue;
         }
         $fileScanner = new FileScanner($fileItem->getRealPath());
         $classNames = $fileScanner->getClassNames();
         foreach ($classNames as $className) {
             if (!class_exists($className)) {
                 require_once $fileItem->getRealPath();
             }
             $classes[$className] = $this->classReaderDecorator->getConstructor($className);
         }
     }
     return $classes;
 }
 public function testGetParents()
 {
     $stringArray = ['Parent_Class_Name1', 'Interface_1'];
     $this->classReaderMock->expects($this->once())->method('getParents')->with('Child_Class_Name')->willReturn($stringArray);
     $this->assertEquals($stringArray, $this->model->getParents('Child_Class_Name'));
 }