|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php declare(strict_types=1); |
| 3 | + |
| 4 | +use Symfony\Component\Console\Input\InputArgument; |
| 5 | +use Symfony\Component\Console\Input\InputInterface; |
| 6 | +use Symfony\Component\Console\Input\InputOption; |
| 7 | +use Symfony\Component\Console\Output\OutputInterface; |
| 8 | + |
| 9 | +(function () { |
| 10 | + require_once __DIR__ . '/../vendor/autoload.php'; |
| 11 | + |
| 12 | + $command = new class() extends Symfony\Component\Console\Command\Command { |
| 13 | + |
| 14 | + protected function configure() |
| 15 | + { |
| 16 | + $this->setName('analyse') |
| 17 | + ->setDescription('Analyses source code') |
| 18 | + ->setDefinition([ |
| 19 | + new InputArgument('paths', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Paths with source code to run analysis on'), |
| 20 | + new InputOption('paths-file', null, InputOption::VALUE_REQUIRED, 'Path to a file with a list of paths to run analysis on'), |
| 21 | + new InputOption('configuration', 'c', InputOption::VALUE_REQUIRED, 'Path to project configuration file'), |
| 22 | + new InputOption('level', 'l', InputOption::VALUE_REQUIRED, 'Level of rule options - the higher the stricter'), |
| 23 | + new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not show progress bar, only results'), |
| 24 | + new InputOption('debug', null, InputOption::VALUE_NONE, 'Show debug information - which file is analysed, do not catch internal errors'), |
| 25 | + new InputOption('autoload-file', 'a', InputOption::VALUE_REQUIRED, 'Project\'s additional autoload file path'), |
| 26 | + new InputOption('error-format', null, InputOption::VALUE_REQUIRED, 'Format in which to print the result of the analysis', 'table'), |
| 27 | + new InputOption('memory-limit', null, InputOption::VALUE_REQUIRED, 'Memory limit for analysis'), |
| 28 | + new InputOption('xdebug', null, InputOption::VALUE_NONE, 'Allow running with XDebug for debugging purposes'), |
| 29 | + ]); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @return string[] |
| 34 | + */ |
| 35 | + public function getAliases(): array |
| 36 | + { |
| 37 | + return ['analyze']; |
| 38 | + } |
| 39 | + |
| 40 | + protected function execute(InputInterface $input, OutputInterface $output) |
| 41 | + { |
| 42 | + $output->writeln(''); |
| 43 | + $output->writeln('Thank you for using PHPStan!'); |
| 44 | + $output->writeln(''); |
| 45 | + $output->writeln('With the release of PHPStan 0.12, the primary Composer package used by most users,'); |
| 46 | + $output->writeln('<fg=cyan>phpstan/phpstan</>, has switched to a PHAR file. It works the same way as phpstan-shim.'); |
| 47 | + |
| 48 | + $output->writeln('The need for a separate PHAR distribution has ceased.'); |
| 49 | + $output->writeln('Package <fg=cyan>phpstan/phpstan-shim</> is no longer needed.'); |
| 50 | + $output->writeln(''); |
| 51 | + $output->writeln('You should upgrade to <fg=cyan>phpstan/phpstan</> 0.12 with the following steps:'); |
| 52 | + |
| 53 | + $output->writeln('1) In your composer.json, rewrite line with <fg=cyan>"phpstan/phpstan-shim"</>'); |
| 54 | + $output->writeln(' to <fg=cyan>"phpstan/phpstan": "^0.12"</>.'); |
| 55 | + $output->writeln('2) Delete your <fg=cyan>composer.lock</>.'); |
| 56 | + $output->writeln('3) Delete <fg=cyan>vendor/phpstan</> directory.'); |
| 57 | + $output->writeln('4) Delete <fg=cyan>vendor/bin/phpstan</> and <fg=cyan>vendor/bin/phpstan.phar</>.'); |
| 58 | + $output->writeln('5) Run <fg=cyan>composer install</>.'); |
| 59 | + |
| 60 | + $output->writeln(''); |
| 61 | + $output->writeln('If you have any problem upgrading, don\'t hesitate to describe your issue at:'); |
| 62 | + |
| 63 | + $output->writeln('https://github.com/phpstan/phpstan/issues/new/choose'); |
| 64 | + $output->writeln(''); |
| 65 | + |
| 66 | + return 1; |
| 67 | + } |
| 68 | + |
| 69 | + }; |
| 70 | + |
| 71 | + $application = new \Symfony\Component\Console\Application(); |
| 72 | + $application->add($command); |
| 73 | + $application->setDefaultCommand('analyse', true); |
| 74 | + $application->run(); |
| 75 | + |
| 76 | +})(); |
0 commit comments