You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-10
Original file line number
Diff line number
Diff line change
@@ -83,30 +83,51 @@ parameters:
83
83
84
84
Be aware that it may hide genuine errors in your application.
85
85
86
-
## Console command analysis
86
+
## Analysis of Symfony Console Commands
87
87
88
-
You can opt in for more advanced analysis by providing the console application from your own application. This will allow the correct argument and option types to be inferred when accessing `$input->getArgument()` or `$input->getOption()`.
88
+
You can opt in for more advanced analysis of [Symfony Console Commands](https://symfony.com/doc/current/console.html)
89
+
by providing the console application from your own application. This will allow the correct argument and option types to be inferred when accessing `$input->getArgument()` or `$input->getOption()`.
For example, in a Symfony project, `console-application.php` would look something like this:
97
+
Symfony 4:
97
98
98
99
```php
99
-
require __DIR__.'/../config/bootstrap.php';
100
-
$kernel = new \App\Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
101
-
return new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
100
+
// tests/console-application.php
101
+
102
+
use App\Kernel;
103
+
use Symfony\Bundle\FrameworkBundle\Console\Application;
104
+
105
+
require __DIR__ . '/../config/bootstrap.php';
106
+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
107
+
return new Application($kernel);
102
108
```
103
109
104
-
You may then encounter an error with PhpParser:
110
+
Symfony 5:
111
+
112
+
```php
113
+
// tests/console-application.php
105
114
106
-
```bash
107
-
Compile Error: Cannot Declare interface PhpParser\NodeVisitor, because the name is already in use
115
+
use App\Kernel;
116
+
use Symfony\Bundle\FrameworkBundle\Console\Application;
117
+
use Symfony\Component\Dotenv\Dotenv;
118
+
119
+
require __DIR__ . '/../vendor/autoload.php';
120
+
121
+
(new Dotenv())->bootEnv(__DIR__ . '/../.env');
122
+
123
+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
124
+
return new Application($kernel);
108
125
```
109
126
127
+
You may then encounter an error with PhpParser:
128
+
129
+
> Compile Error: Cannot Declare interface PhpParser\NodeVisitor, because the name is already in use
130
+
110
131
If this is the case, you should create a new environment for your application that will disable inlining. In `config/packages/phpstan_env/parameters.yaml`:
0 commit comments