public function DeprecationAnalyser::runPhpStan in Upgrade Status 8
Run PHPStan on the given paths.
Parameters
array $paths: List of paths.
Return value
mixed Results in self::ERROR_FORMAT.
1 call to DeprecationAnalyser::runPhpStan()
- DeprecationAnalyser::analyse in src/
DeprecationAnalyser.php - Analyse the codebase of an extension including all its sub-components.
File
- src/
DeprecationAnalyser.php, line 305
Class
Namespace
Drupal\upgrade_statusCode
public function runPhpStan(array $paths) {
// Analyse code in the given directory with PHPStan. The most sensible way
// we could find was to pretend we have Symfony console inputs and outputs
// and take the result from there. PHPStan as-is is highly tied to the
// console and we could not identify an independent PHP API to use.
try {
$result = CommandHelper::begin($this->inputInterface, $this->outputInterface, $paths, NULL, NULL, NULL, $this->phpstanNeonPath, NULL, FALSE);
} catch (Exception $e) {
$this->logger
->error($e);
}
$container = $result
->getContainer();
$error_formatter_service = sprintf('errorFormatter.%s', self::ERROR_FORMAT);
if (!$container
->hasService($error_formatter_service)) {
$this->logger
->error('Error formatter @formatter not found.', [
'@formatter' => self::ERROR_FORMAT,
]);
}
else {
$errorFormatter = $container
->getService($error_formatter_service);
$application = $container
->getByType(AnalyseApplication::class);
$result
->handleReturn($application
->analyse($result
->getFiles(), $result
->isOnlyFiles(), $result
->getConsoleStyle(), $errorFormatter, $result
->isDefaultLevelUsed(), FALSE, NULL));
return $this->outputInterface
->fetch();
}
}