#!/usr/bin/php -q $iterator */ $iterator = new RegexIterator($iterator, '~/src/\w+/composer.json$~'); $packages = []; $code = 0; foreach ($iterator as $file) { $filePath = $file->getPath(); $package = substr($filePath, strrpos($filePath, '/') + 1); $packages[$filePath . '/'] = $package; } ksort($packages); $issues = []; foreach ($packages as $path => $package) { if (!file_exists($path . 'phpstan.neon.dist')) { continue; } $exitCode = null; $output = []; exec('cd ' . $path . ' && composer install && vendor/bin/phpstan analyze ./', $output, $exitCode); if ($exitCode !== 0) { $code = $exitCode; $issues[] = 'Issue(s) detected with ' . $package . ' package: ' . PHP_EOL . implode(PHP_EOL, $output); } exec('cd ' . $path . ' && rm composer.lock && rm -rf vendor'); } echo implode(PHP_EOL . PHP_EOL, $issues); exit($code);