Skip to content

Commit

Permalink
Seperate symfony rules into config/symfony-rules.neon (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
temp authored Feb 18, 2020
1 parent c854acc commit 0c646b8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ includes:
## Rules
1. `SlamPhpStan\SymfonyFilesystemRule`: forbid calls to raw filesystem functions well wrapped by
[`symfony/filesystem`](https://github.com/symfony/filesystem) component
1. `SlamPhpStan\SymfonyProcessRule`: forbid calls to raw system functions well wrapped by
[`symfony/process`](https://github.com/symfony/process) component
1. `SlamPhpStan\UnusedVariableRule`: check for variable inside functions never used after initial assignment
1. `SlamPhpStan\MissingClosureParameterTypehintRule`: requires parameter typehints for closures; WARNING: no PhpDoc
allowed, see [`phpstan/phpstan-strict-rules#87`](https://github.com/phpstan/phpstan-strict-rules/issues/87)
Expand All @@ -53,6 +49,22 @@ classes that extend or implement a certain class/interface
1. `SlamPhpStan\AccessStaticPropertyWithinModelContextRule`: inhibit the access to static attributes of a class within
classes that extend or implement a certain class/interface, useful to prohibit usage of singletons in models

## Symfony-specific config

A `symfony-rules.neon` config is present for Symfony projects:

```yaml
includes:
- vendor/slam/phpstan-extensions/conf/symfony-rules.neon
```

With the following configurations:

1. `SlamPhpStan\SymfonyFilesystemRule`: forbid calls to raw filesystem functions well wrapped by
[`symfony/filesystem`](https://github.com/symfony/filesystem) component
1. `SlamPhpStan\SymfonyProcessRule`: forbid calls to raw system functions well wrapped by
[`symfony/process`](https://github.com/symfony/process) component

## Yii-specific config

A `yii-rules.neon` config is present for Yii projects:
Expand Down
8 changes: 0 additions & 8 deletions conf/slam-rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ services:
class: SlamPhpStan\UnusedVariableRule
tags:
- phpstan.rules.rule
-
class: SlamPhpStan\SymfonyFilesystemRule
tags:
- phpstan.rules.rule
-
class: SlamPhpStan\SymfonyProcessRule
tags:
- phpstan.rules.rule
-
class: SlamPhpStan\MissingClosureParameterTypehintRule
tags:
Expand Down
9 changes: 9 additions & 0 deletions conf/symfony-rules.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
-
class: SlamPhpStan\SymfonyFilesystemRule
tags:
- phpstan.rules.rule
-
class: SlamPhpStan\SymfonyProcessRule
tags:
- phpstan.rules.rule
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-php-parser/extension.neon
- conf/slam-rules.neon
- conf/symfony-rules.neon
- conf/thecodingmachine-rules.neon

parameters:
Expand Down

0 comments on commit 0c646b8

Please sign in to comment.