Skip to content
This repository was archived by the owner on Dec 9, 2019. It is now read-only.

Commit f2b69bd

Browse files
committed
Instructions how to upgrade to phpstan/phpstan
1 parent f36a437 commit f2b69bd

File tree

8 files changed

+109
-71
lines changed

8 files changed

+109
-71
lines changed

README.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
# PHPStan shim
1+
# phpstan/phpstan-shim
22

3-
The prefixed `.phar` distribution is built using [phpstan-compiler](https://github.com/phpstan/phpstan-compiler).
3+
**Thank you for using PHPStan!**
44

5-
## Usage
5+
With the release of **PHPStan 0.12**, the primary Composer package used by most users,
6+
`phpstan/phpstan`, has switched to a PHAR file. It works the same way as `phpstan-shim`.
7+
The need for a separate PHAR distribution has ceased.
8+
Package `phpstan/phpstan-shim` is no longer needed.
69

7-
Install the package
10+
You should upgrade to `phpstan/phpstan` 0.12 with the following steps:
811

9-
```bash
10-
composer require --dev phpstan/phpstan-shim
11-
```
12+
1) In your composer.json, rewrite line with `"phpstan/phpstan-shim"`
13+
to `"phpstan/phpstan": "^0.12"`.
14+
2) Delete your `composer.lock`.
15+
3) Delete `vendor/phpstan` directory.
16+
4) Delete `vendor/bin/phpstan` and `vendor/bin/phpstan.phar`.
17+
5) Run composer install.
1218

13-
and use it like the original executable
14-
15-
```bash
16-
vendor/bin/phpstan.phar analyse src
17-
```
18-
19-
Check out the main repo for more options [https://github.com/phpstan/phpstan](https://github.com/phpstan/phpstan).
20-
21-
For technical reasons, if your project depends on `nikic/php-parser` package, make sure you have the `PHAR` PHP extension enabled, otherwise the composer autoloader will not work as expected.
22-
23-
## Configuration
24-
25-
It is recommended that you set a `tmpDir` in your `phpstan.neon`, otherwise it uses the system temp directory.
26-
27-
```
28-
parameters:
29-
tmpDir: var/cache/phpstan
30-
```
19+
If you have any problem upgrading, don't hesitate to describe your issue at:
20+
https://github.com/phpstan/phpstan/issues/new/choose

bootstrap.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

composer.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
22
"name": "phpstan/phpstan-shim",
3-
"description": "PHPStan Phar distribution",
3+
"description": "PHPStan PHAR distribution - deprecated",
44
"license": ["MIT"],
55
"require": {
6-
"php": "~7.1",
7-
"nikic/php-parser": "^4.2.3"
8-
},
9-
"replace": {
10-
"phpstan/phpstan": "self.version"
6+
"php": "~7.1"
117
},
128
"bin": [
139
"phpstan",
@@ -17,8 +13,5 @@
1713
"branch-alias": {
1814
"dev-master": "0.12-dev"
1915
}
20-
},
21-
"autoload": {
22-
"files": ["bootstrap.php"]
2316
}
2417
}

phpstan

-2.34 MB
Binary file not shown.

phpstan.phar

-2.34 MB
Binary file not shown.

src/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor
2+
/composer.lock

src/bin/phpstan

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
})();

src/composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"require": {
3+
"php": "~7.1",
4+
"symfony/console": "^4.4"
5+
},
6+
"bin": [
7+
"bin/phpstan"
8+
],
9+
"config": {
10+
"platform": {
11+
"php": "7.1.3"
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)