Skip to content

Commit 8d2bcb1

Browse files
floriankraemerFlorian Krämer
andauthored
Rename DependencyConstraintsRule to ForbiddenDependenciesRule #20 (#21)
Co-authored-by: Florian Krämer <[email protected]>
1 parent 2876393 commit 8d2bcb1

File tree

6 files changed

+506
-459
lines changed

6 files changed

+506
-459
lines changed

docs/Rules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ services:
5555
- phpstan.rules.rule
5656

5757
# Dependency constraints - enforce layer boundaries
58+
# Note: Use ForbiddenDependenciesRule (DependencyConstraintsRule is deprecated)
5859
-
59-
class: Phauthentic\PHPStanRules\Architecture\DependencyConstraintsRule
60+
class: Phauthentic\PHPStanRules\Architecture\ForbiddenDependenciesRule
6061
arguments:
6162
forbiddenDependencies:
6263
# Domain layer cannot depend on Application, Infrastructure, or Presentation

docs/rules/Dependency-Constraints-Rule.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Dependency Constraints Rule
22

3+
> **⚠️ DEPRECATED:** This rule has been renamed to `ForbiddenDependenciesRule`. The `DependencyConstraintsRule` class is kept for backward compatibility but will be removed in a future major version. Please update your configuration to use `ForbiddenDependenciesRule` instead.
4+
35
Enforces dependency constraints between namespaces by checking `use` statements and optionally fully qualified class names (FQCNs).
46

57
The constructor takes an array of namespace dependencies. The key is the namespace that should not depend on the namespaces in the array of values.
@@ -10,6 +12,21 @@ In the example below nothing from `App\Domain` can depend on anything from `App\
1012

1113
### Basic Usage (Use Statements Only)
1214

15+
**Recommended (using new class name):**
16+
17+
```neon
18+
-
19+
class: Phauthentic\PHPStanRules\Architecture\ForbiddenDependenciesRule
20+
arguments:
21+
forbiddenDependencies: [
22+
'/^App\\Domain(?:\\\w+)*$/': ['/^App\\Controller\\/']
23+
]
24+
tags:
25+
- phpstan.rules.rule
26+
```
27+
28+
**Deprecated (backward compatibility):**
29+
1330
```neon
1431
-
1532
class: Phauthentic\PHPStanRules\Architecture\DependencyConstraintsRule
@@ -23,9 +40,11 @@ In the example below nothing from `App\Domain` can depend on anything from `App\
2340

2441
### With FQCN Checking Enabled
2542

43+
**Recommended (using new class name):**
44+
2645
```neon
2746
-
28-
class: Phauthentic\PHPStanRules\Architecture\DependencyConstraintsRule
47+
class: Phauthentic\PHPStanRules\Architecture\ForbiddenDependenciesRule
2948
arguments:
3049
forbiddenDependencies: [
3150
'/^App\\Capability(?:\\\w+)*$/': [
@@ -40,9 +59,11 @@ In the example below nothing from `App\Domain` can depend on anything from `App\
4059

4160
### With Selective Reference Types
4261

62+
**Recommended (using new class name):**
63+
4364
```neon
4465
-
45-
class: Phauthentic\PHPStanRules\Architecture\DependencyConstraintsRule
66+
class: Phauthentic\PHPStanRules\Architecture\ForbiddenDependenciesRule
4667
arguments:
4768
forbiddenDependencies: [
4869
'/^App\\Capability(?:\\\w+)*$/': [
@@ -86,7 +107,7 @@ This example prevents usage of PHP's built-in `DateTime` and `DateTimeImmutable`
86107

87108
```neon
88109
-
89-
class: Phauthentic\PHPStanRules\Architecture\DependencyConstraintsRule
110+
class: Phauthentic\PHPStanRules\Architecture\ForbiddenDependenciesRule
90111
arguments:
91112
forbiddenDependencies: [
92113
'/^App\\Capability(?:\\\w+)*$/': [
@@ -113,7 +134,7 @@ If you only want to check specific reference types (e.g., to improve performance
113134

114135
```neon
115136
-
116-
class: Phauthentic\PHPStanRules\Architecture\DependencyConstraintsRule
137+
class: Phauthentic\PHPStanRules\Architecture\ForbiddenDependenciesRule
117138
arguments:
118139
forbiddenDependencies: [
119140
'/^App\\Capability(?:\\\w+)*$/': [

0 commit comments

Comments
 (0)