@@ -15,37 +15,56 @@ includes:
1515 - vendor/bellangelo/phpstan-migration-rules/extension.neon
1616```
1717
18- ## Rule catalog
18+ ## Configuration
1919
20- Each rule below applies to migration files, regardless of framework, unless stated otherwise.
20+ All rules are enabled by default. You can customize behavior in your ` phpstan.neon ` :
2121
22- ### Rule: ` EnforceCollationRule `
23- Enforces that table definitions explicitly define a collation.
24- > Prevents relying on database defaults, which may differ between environments.
22+ ``` neon
23+ parameters:
24+ migrationRules:
25+ requiredCollation: utf8mb4 # Default is utf8
26+
27+ phinx:
28+ enforceCollation: true
29+ forbidAfter: true
30+ forbidMultipleTableCreations: true
2531
26- #### Configuration
32+ laravel:
33+ enforceCollation: true
34+ forbidAfter: true
35+ forbidMultipleTableCreations: true
36+ ```
2737
28- ``` yaml
38+ If you only use one framework, disable the other to avoid unnecessary processing:
39+
40+ ``` neon
2941parameters:
30- phpstanMigrationRules :
31- requiredCollation : utf8mb4 # Default is utf8
42+ migrationRules:
43+ phinx:
44+ enforceCollation: false
45+ forbidAfter: false
46+ forbidMultipleTableCreations: false
3247```
3348
34- #### Support
49+ ## Rule catalog
50+
51+ Each rule below applies to migration files for both Phinx and Laravel, unless stated otherwise.
52+
53+ ### Rule: ` EnforceCollationRule `
54+ Enforces that table definitions explicitly define a collation.
55+ > Prevents relying on database defaults, which may differ between environments.
3556
3657| Framework | How collation is detected |
3758| ---| ---|
38- | [Phinx](./src/Rules/Phinx/EnforceCollationRule.php) | ` table('name', ['collation' => '…'])` | [Phinx/EnforceCollationRule](./src/Rules/Phinx/EnforceCollationRule.php) |
39- | [Laravel](( ./src/Rules/Laravel/EnforceCollationRule.php) ) | `$table->collation('…')` or `$table->collation = '…'` inside the Blueprint callback |
59+ | [ Phinx] ( ./src/Rules/Phinx/EnforceCollationRule.php ) | ` table('name', ['collation' => '…']) ` |
60+ | [ Laravel] ( ./src/Rules/Laravel/EnforceCollationRule.php ) | ` $table->collation('…') ` or ` $table->collation = '…' ` inside the Blueprint callback |
4061
4162---
4263
4364### Rule: ` ForbidAfterRule `
4465Forbids column positioning via ` after ` .
4566> May trigger full table rewrites or long locks, unsafe for large or production tables.
4667
47- # ### Support
48-
4968| Framework | Forbidden usage |
5069| ---| ---|
5170| [ Phinx] ( ./src/Rules/Phinx/ForbidAfterRule.php ) | ` addColumn(..., ['after' => 'column']) ` |
@@ -55,11 +74,7 @@ Forbids column positioning via `after`.
5574
5675### Rule: ` ForbidMultipleTableCreationsRule `
5776Ensures each migration creates at most one table.
58- > Improves rollback safety and migration clarity
59-
60- ---
61-
62- # ### Support
77+ > Improves rollback safety and migration clarity.
6378
6479| Framework | What counts as a table creation |
6580| ---| ---|
0 commit comments