Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 8529792

Browse files
committed
chore: updated readme file with new infos
1 parent d90e1bf commit 8529792

File tree

1 file changed

+69
-10
lines changed

1 file changed

+69
-10
lines changed

README.md

+69-10
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ includes:
146146
- vendor/phpstan/phpstan-phpunit/extension.neon
147147
- vendor/phpstan/phpstan-phpunit/rules.neon
148148
- vendor/phpstan/phpstan-strict-rules/rules.neon
149-
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
150149
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
151150
- vendor/slam/phpstan-extensions/conf/slam-rules.neon
152151
- vendor/symplify/phpstan-rules/config/services/services.neon
@@ -162,6 +161,8 @@ parameters:
162161
level: max
163162
inferPrivatePropertyTypeFromConstructor: true
164163
164+
tmpDir: %currentWorkingDirectory%/.build/phpstan
165+
165166
excludes_analyse:
166167
- vendor
167168
@@ -228,6 +229,52 @@ Add your config with this command.
228229
./vendor/bin/psalm --init
229230
```
230231

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+
231278
Now you need to add the `phpunit` and `mockery` plugin to the created `psalm.xml`
232279

233280
```diff
@@ -287,8 +334,22 @@ return static function (ContainerConfigurator $containerConfigurator): void {
287334
// Run Rector only on changed files
288335
$parameters->set(Option::ENABLE_CACHE, true);
289336

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);
292353

293354
$parameters->set(Option::SETS, [
294355
'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:
307368
```json
308369
{
309370
"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-
],
314371
"cs": "php-cs-fixer fix --config=\"./.php_cs\" --ansi",
315372
"cs:check": "php-cs-fixer fix --config=\"./.php_cs\" --ansi --dry-run",
316373
"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",
318376
"psalm": "psalm --threads=$(nproc)",
319-
"psalm:fix": "psalm --alter --issues=all --threads=$(nproc) --ansi",
377+
"psalm:fix": "psalm --alter --issues=all --threads=$(nproc)",
320378
"rector": "rector process --ansi --dry-run",
321379
"rector:fix": "rector process --ansi",
322-
"test": "phpunit"
380+
"test": "phpunit",
381+
"test:coverage": "phpunit --coverage-html=./.build/phpunit/coverage"
323382
}
324383
}
325384
```

0 commit comments

Comments
 (0)