Skip to content

Commit 7efed17

Browse files
committed
docs: rewrite SKILL.md with imperative style per skill-creator guidelines
- Add "When X, consult Y" format for all 9 references - Document 3 previously undocumented references: - adapter-registry-pattern.md - migration-strategies.md - phpstan-compliance.md - Add "Running Scripts" section with "To do X, run Y" format - Organize references by category (PHP Features, Standards, Tools, etc.)
1 parent f6b8cce commit 7efed17

File tree

1 file changed

+64
-23
lines changed

1 file changed

+64
-23
lines changed

skills/php-modernization/SKILL.md

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,93 @@ Modernize PHP applications to PHP 8.x with type safety, PSR compliance, and stat
1414
- **Static Analysis**: PHPStan (level 9+), PHPat, Rector, PHP-CS-Fixer
1515
- **Type Safety**: DTOs/VOs over arrays, generics via PHPDoc
1616

17-
## Reference Files
17+
## Using Reference Documentation
1818

19-
| Reference | Purpose |
20-
|-----------|---------|
21-
| `references/php8-features.md` | PHP 8.0-8.5 features |
22-
| `references/psr-per-compliance.md` | Active PSR/PER standards |
23-
| `references/static-analysis-tools.md` | PHPStan, PHPat, Rector, PHP-CS-Fixer configs |
24-
| `references/type-safety.md` | Type system strategies |
25-
| `references/request-dtos.md` | Request DTOs, safe integer handling |
26-
| `references/symfony-patterns.md` | Modern Symfony architecture |
19+
### PHP Version Features
20+
21+
When implementing PHP 8.0-8.5 features (constructor promotion, readonly properties, enums, match expressions, attributes), consult `references/php8-features.md`.
22+
23+
### Standards Compliance
24+
25+
When ensuring PSR/PER compliance or configuring PHP-CS-Fixer with `@PER-CS`, consult `references/psr-per-compliance.md` for active PHP-FIG standards.
26+
27+
When configuring PHPStan levels or understanding level requirements, consult `references/phpstan-compliance.md` for level overview and production configuration.
28+
29+
### Static Analysis Tools
30+
31+
When setting up PHPStan, PHPat, Rector, or PHP-CS-Fixer, consult `references/static-analysis-tools.md` for configuration examples and integration patterns.
32+
33+
### Type Safety
34+
35+
When implementing type-safe code or migrating from arrays to DTOs, consult `references/type-safety.md` for type system strategies and best practices.
36+
37+
When creating request DTOs or handling safe integer conversion, consult `references/request-dtos.md` for DTO patterns and validation approaches.
38+
39+
### Architecture Patterns
40+
41+
When implementing adapter registry patterns for multiple external services, consult `references/adapter-registry-pattern.md` for dynamic adapter instantiation from database configuration.
42+
43+
When using Symfony DI, events, or modern framework patterns, consult `references/symfony-patterns.md` for architecture best practices.
44+
45+
### Migration Planning
46+
47+
When planning PHP version upgrades or modernization projects, consult `references/migration-strategies.md` for assessment phases, compatibility checks, and migration workflows.
48+
49+
## Running Scripts
50+
51+
### Project Verification
52+
53+
To verify a PHP project meets modernization requirements:
54+
55+
```bash
56+
scripts/verify-php-project.sh /path/to/project
57+
```
58+
59+
This script checks:
60+
- PHPStan level compliance
61+
- PHP-CS-Fixer configuration
62+
- Type declaration coverage
63+
- DTO usage patterns
2764

2865
## Required Tools
2966

67+
When setting up a modernized PHP project, ensure these tools are configured:
68+
3069
| Tool | Requirement |
3170
|------|-------------|
3271
| PHPStan | **Level 9 minimum**, level 10 recommended |
3372
| PHPat | Required for defined architectures |
34-
| Rector | Required for modernization |
35-
| PHP-CS-Fixer | Required with `@PER-CS` |
36-
37-
See `references/static-analysis-tools.md` for configuration examples.
73+
| Rector | Required for automated modernization |
74+
| PHP-CS-Fixer | Required with `@PER-CS` ruleset |
3875

3976
## Core Rules
4077

41-
**DTOs Required** - Never pass raw arrays for structured data:
78+
### DTOs Required
79+
80+
When passing structured data, always use DTOs instead of arrays:
81+
4282
```php
4383
// Bad: public function createUser(array $data): array
4484
// Good: public function createUser(CreateUserDTO $dto): UserDTO
4585
```
4686

47-
**Enums Required** - Never use string/int constants for fixed values:
87+
### Enums Required
88+
89+
When defining fixed value sets, always use backed enums instead of constants:
90+
4891
```php
4992
// Bad: const STATUS_DRAFT = 'draft'; function setStatus(string $s)
5093
// Good: enum Status: string { case Draft = 'draft'; }
5194
```
5295

53-
**PSR Compliance** - Type-hint against PSR interfaces (PSR-3, PSR-6, PSR-7, PSR-11, PSR-14, PSR-18).
96+
### PSR Interface Compliance
97+
98+
When type-hinting dependencies, use PSR interfaces (PSR-3, PSR-6, PSR-7, PSR-11, PSR-14, PSR-18).
5499

55100
## Migration Checklist
56101

102+
When modernizing a PHP project, verify these requirements:
103+
57104
- [ ] `declare(strict_types=1)` in all files
58105
- [ ] PER Coding Style via PHP-CS-Fixer (`@PER-CS`)
59106
- [ ] PHPStan level 9+ (level 10 for new projects)
@@ -63,7 +110,7 @@ See `references/static-analysis-tools.md` for configuration examples.
63110
- [ ] Backed enums for all status/type values
64111
- [ ] Type-hint against PSR interfaces
65112

66-
## Scoring
113+
## Scoring Criteria
67114

68115
| Criterion | Requirement |
69116
|-----------|-------------|
@@ -72,12 +119,6 @@ See `references/static-analysis-tools.md` for configuration examples.
72119
| DTOs/VOs | No array params/returns for structured data |
73120
| Enums | Backed enums for fixed value sets |
74121

75-
## Verification
76-
77-
```bash
78-
./scripts/verify-php-project.sh /path/to/project
79-
```
80-
81122
---
82123

83124
> **Contributing:** https://github.com/netresearch/php-modernization-skill

0 commit comments

Comments
 (0)