PhpCsFixer\Console\ConfigurationResolver::getConfig PHP 메소드

getConfig() 공개 메소드

Returns config instance.
public getConfig ( ) : PhpCsFixer\ConfigInterface
리턴 PhpCsFixer\ConfigInterface
    public function getConfig()
    {
        if (null === $this->config) {
            foreach ($this->computeConfigFiles() as $configFile) {
                if (!file_exists($configFile)) {
                    continue;
                }
                $config = (include $configFile);
                // verify that the config has an instance of Config
                if (!$config instanceof ConfigInterface) {
                    throw new InvalidConfigurationException(sprintf('The config file: "%s" does not return a "PhpCsFixer\\ConfigInterface" instance. Got: "%s".', $configFile, is_object($config) ? get_class($config) : gettype($config)));
                }
                $this->config = $config;
                $this->configFile = $configFile;
                break;
            }
            if (null === $this->config) {
                $this->config = $this->defaultConfig;
            }
        }
        return $this->config;
    }

Usage Example

 /**
  * @dataProvider provideResolveIntersectionOfPathsCases
  */
 public function testResolveIntersectionOfPaths($expected, $configFinder, array $path, $pathMode, $config = null)
 {
     if (null !== $configFinder) {
         $this->config->finder($configFinder);
     }
     $this->resolver->setOption('path', $path)->setOption('path-mode', $pathMode)->setOption('config', $config)->resolve();
     if ($expected instanceof \Exception) {
         $this->setExpectedException(get_class($expected));
     }
     $intersectionItems = array_map(function (\SplFileInfo $file) {
         return $file->getRealPath();
     }, iterator_to_array($this->resolver->getConfig()->getFinder(), false));
     sort($expected);
     sort($intersectionItems);
     $this->assertSame($expected, $intersectionItems);
 }
All Usage Examples Of PhpCsFixer\Console\ConfigurationResolver::getConfig