@@ -146,7 +146,6 @@ includes:
146
146
- vendor/phpstan/phpstan-phpunit/extension.neon
147
147
- vendor/phpstan/phpstan-phpunit/rules.neon
148
148
- vendor/phpstan/phpstan-strict-rules/rules.neon
149
- - vendor/phpstan/phpstan/conf/bleedingEdge.neon
150
149
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
151
150
- vendor/slam/phpstan-extensions/conf/slam-rules.neon
152
151
- vendor/symplify/phpstan-rules/config/services/services.neon
@@ -162,6 +161,8 @@ parameters:
162
161
level: max
163
162
inferPrivatePropertyTypeFromConstructor: true
164
163
164
+ tmpDir: %currentWorkingDirectory%/.build/phpstan
165
+
165
166
excludes_analyse:
166
167
- vendor
167
168
@@ -228,6 +229,52 @@ Add your config with this command.
228
229
./vendor/bin/psalm --init
229
230
```
230
231
232
+ or use our configuration
233
+
234
+ ``` xml
235
+ <?xml version =" 1.0" ?>
236
+ <psalm
237
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
238
+ xmlns =" https://getpsalm.org/schema/config"
239
+ xsi : schemaLocation =" https://getpsalm.org/schema/config/vendor/vimeo/psalm/config.xsd"
240
+ cacheDirectory =" ./.build/psalm"
241
+ errorBaseline =" psalm-baseline.xml"
242
+ resolveFromConfigFile =" true"
243
+ allowStringToStandInForClass =' true'
244
+ findUnusedCode =' true'
245
+ findUnusedVariablesAndParams =' true'
246
+ strictBinaryOperands =' true'
247
+ totallyTyped =' true'
248
+ usePhpDocMethodsWithoutMagicCall =' true'
249
+ phpVersion =' 8.0'
250
+ errorLevel =' 8'
251
+ >
252
+ <issueHandlers >
253
+ <LessSpecificReturnType errorLevel =" info" />
254
+ </issueHandlers >
255
+
256
+ <plugins >
257
+ <pluginClass class =" Psalm\PhpUnitPlugin\Plugin" />
258
+ </plugins >
259
+
260
+ <projectFiles >
261
+ <directory name =" src" />
262
+ <directory name =" tests" />
263
+ <ignoreFiles >
264
+ <directory name =" vendor" />
265
+ <directory name =" .build" />
266
+ <directory name =" .docker" />
267
+ <directory name =" .github" />
268
+ </ignoreFiles >
269
+ </projectFiles >
270
+
271
+ <issueHandlers >
272
+ <PossiblyUndefinedIntArrayOffset errorLevel =" error" />
273
+ <PossiblyUndefinedStringArrayOffset errorLevel =" error" />
274
+ </issueHandlers >
275
+ </psalm >
276
+ ```
277
+
231
278
Now you need to add the ` phpunit ` and ` mockery ` plugin to the created ` psalm.xml `
232
279
233
280
``` diff
@@ -287,8 +334,22 @@ return static function (ContainerConfigurator $containerConfigurator): void {
287
334
// Run Rector only on changed files
288
335
$parameters->set(Option::ENABLE_CACHE, true);
289
336
290
- // Path to phpstan with extensions, that PHPSTan in Rector uses to determine types
291
- $parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, getcwd() . '/phpstan.neon');
337
+ $phpstanPath = getcwd() . '/phpstan.neon';
338
+ $phpstanNeonContent = FileSystem::read($phpstanPath);
339
+ $bleedingEdgePattern = '#\n\s+-(.*?)bleedingEdge\.neon[\'|"]?#';
340
+
341
+ // bleeding edge clean out, see https://github.com/rectorphp/rector/issues/2431
342
+ if (Strings::match($phpstanNeonContent, $bleedingEdgePattern)) {
343
+ $temporaryPhpstanNeon = getcwd() . '/rector-temp-phpstan.neon';
344
+ $clearedPhpstanNeonContent = Strings::replace($phpstanNeonContent, $bleedingEdgePattern);
345
+
346
+ FileSystem::write($temporaryPhpstanNeon, $clearedPhpstanNeonContent);
347
+
348
+ $phpstanPath = $temporaryPhpstanNeon;
349
+ }
350
+
351
+ // Path to phpstan with extensions, that PHPStan in Rector uses to determine types
352
+ $parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, $phpstanPath);
292
353
293
354
$parameters->set(Option::SETS, [
294
355
'action-injection-to-constructor-injection', 'array-str-functions-to-static-call', 'early-return', 'doctrine-code-quality', 'dead-code', 'code-quality', 'type-declaration', 'order', 'psr4', 'type-declaration', 'type-declaration-strict', 'php71', 'php72', 'php73', 'php74', 'php80', 'phpunit91', 'phpunit-code-quality', 'phpunit-exception', 'phpunit-yield-data-provider',
@@ -307,19 +368,17 @@ Then edit your `composer.json` file and add these scripts:
307
368
``` json
308
369
{
309
370
"scripts" : {
310
- "coverage" : [
311
- " phpunit --dump-xdebug-filter=./.build/phpunit/.xdebug-filter.php" ,
312
- " phpunit --prepend=./.build/phpunit/.xdebug-filter.php --coverage-html=./.build/phpunit/coverage"
313
- ],
314
371
"cs" : " php-cs-fixer fix --config=\" ./.php_cs\" --ansi" ,
315
372
"cs:check" : " php-cs-fixer fix --config=\" ./.php_cs\" --ansi --dry-run" ,
316
373
"infection" : " XDEBUG_MODE=coverage infection --configuration=\" ./infection.json\" -j$(nproc) --ansi" ,
317
- "phpstan" : " phpstan analyse -c ./phpstan.neon --ansi" ,
374
+ "phpstan" : " phpstan analyse -c ./phpstan.neon --ansi --memory-limit=-1" ,
375
+ "phpstan:baseline" : " phpstan analyse -c ./phpstan.neon --ansi --generate-baseline --memory-limit=-1" ,
318
376
"psalm" : " psalm --threads=$(nproc)" ,
319
- "psalm:fix" : " psalm --alter --issues=all --threads=$(nproc) --ansi " ,
377
+ "psalm:fix" : " psalm --alter --issues=all --threads=$(nproc)" ,
320
378
"rector" : " rector process --ansi --dry-run" ,
321
379
"rector:fix" : " rector process --ansi" ,
322
- "test" : " phpunit"
380
+ "test" : " phpunit" ,
381
+ "test:coverage" : " phpunit --coverage-html=./.build/phpunit/coverage"
323
382
}
324
383
}
325
384
```
0 commit comments