Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Once you have most rules applied, it's best practice to include whole sets:
includes:
- vendor/symplify/phpstan-rules/config/code-complexity-rules.neon
- vendor/symplify/phpstan-rules/config/configurable-rules.neon
- vendor/symplify/phpstan-rules/config/naming-rules.neon
- vendor/symplify/phpstan-rules/config/static-rules.neon

# project specific
Expand All @@ -49,6 +48,16 @@ includes:

<br>

The naming rules (class/constant naming and namespace rules, e.g. interface must live in a "Contract" namespace) load automatically and are **enabled by default**. Turn them off with the `naming` parameter:

```yaml
parameters:
symplify:
naming: false
```

<br>

### Symfony/Laravel container `->get()`/`->make()` return type extensions

Want sharper type inference? The return type extensions are **disabled by default** — enable the ones that fit your stack:
Expand Down Expand Up @@ -332,6 +341,14 @@ rules:
- Symplify\PHPStanRules\Rules\Explicit\ExplicitClassPrefixSuffixRule
```

Reported under these identifiers:

```yaml
- identifier: symplify.explicitAbstractPrefixName
- identifier: symplify.explicitInterfaceSuffixName
- identifier: symplify.explicitTraitSuffixName
```

```php
<?php

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"phpstan": {
"includes": [
"config/services/services.neon",
"config/naming-rules.neon",
"config/ctor-rules.neon",
"config/mock-rules.neon",
"config/phpstan-extensions.neon"
Expand Down
23 changes: 22 additions & 1 deletion config/naming-rules.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
rules:
conditionalTags:
Symplify\PHPStanRules\Rules\Explicit\ExplicitClassPrefixSuffixRule:
phpstan.rules.rule: %symplify.naming%
Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule:
phpstan.rules.rule: %symplify.naming%
Symplify\PHPStanRules\Rules\UppercaseConstantRule:
phpstan.rules.rule: %symplify.naming%
Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule:
phpstan.rules.rule: %symplify.naming%

# namespace
Symplify\PHPStanRules\Rules\Domain\RequireExceptionNamespaceRule:
phpstan.rules.rule: %symplify.naming%
Symplify\PHPStanRules\Rules\Domain\RequireAttributeNamespaceRule:
phpstan.rules.rule: %symplify.naming%
Symplify\PHPStanRules\Rules\CheckRequiredInterfaceInContractNamespaceRule:
phpstan.rules.rule: %symplify.naming%

services:
- Symplify\PHPStanRules\Rules\Explicit\ExplicitClassPrefixSuffixRule
- Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule
- Symplify\PHPStanRules\Rules\UppercaseConstantRule
- Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule
- Symplify\PHPStanRules\Rules\Domain\RequireExceptionNamespaceRule
- Symplify\PHPStanRules\Rules\Domain\RequireAttributeNamespaceRule
- Symplify\PHPStanRules\Rules\CheckRequiredInterfaceInContractNamespaceRule
2 changes: 2 additions & 0 deletions config/phpstan-extensions.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
symplify:
naming: true
mocks: false
ctor: false
symfonyReturnType: false
Expand All @@ -13,6 +14,7 @@ parameters:

parametersSchema:
symplify: structure([
naming: bool()
mocks: bool()
ctor: bool()
symfonyReturnType: bool()
Expand Down
3 changes: 0 additions & 3 deletions config/static-rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ rules:
- Symplify\PHPStanRules\Rules\NoGlobalConstRule

# domain
- Symplify\PHPStanRules\Rules\Domain\RequireExceptionNamespaceRule
- Symplify\PHPStanRules\Rules\Domain\RequireAttributeNamespaceRule
- Symplify\PHPStanRules\Rules\CheckRequiredInterfaceInContractNamespaceRule
- Symplify\PHPStanRules\Rules\RequireAttributeNameRule

- Symplify\PHPStanRules\Rules\Enum\RequireUniqueEnumConstantRule
Expand Down
Loading