Review PHP code for language and runtime conventions: strict types, error handling, resource management, PSR standards, namespaces, null safety, generators, and testability. Language-only atomic skill; output is a findings list.
Review code in PHP for language and runtime conventions only. Do not define scope (diff vs codebase) or perform security/architecture analysis; those are handled by scope and cognitive skills. Emit a findings list in the standard format for aggregation. Focus on strict types and declarations, error handling, resource management, PSR standards (PSR-4, PSR-12), namespaces, null safety, generators and iterables, PHP version compatibility, and testability.
Core Objective
Primary goal: Produce a PHP language/runtime findings list covering strict types, error handling, resource management, PSR standards, namespaces, null safety, generators, version compatibility, and testability for the given code scope.
Success Criteria (ALL must be met):
✅ PHP-only scope: Only PHP language and runtime conventions are reviewed; no scope selection, security, or architecture analysis performed
✅ All nine PHP dimensions covered: Strict types, error handling, resource management, PSR standards, namespaces/autoloading, null safety, generators/iterables, PHP version compatibility, and testability are assessed where relevant
✅ Findings format compliant: Each finding includes Location, Category (language-php), Severity, Title, Description, and optional Suggestion
✅ File:line references: All findings reference specific file locations with line numbers
✅ Non-PHP code excluded: Non-PHP files are not analyzed for PHP-specific rules unless explicitly in scope
Acceptance Test: Does the output contain a PHP-focused findings list with file:line references covering all relevant language/runtime dimensions without performing security, architecture, or scope analysis?
Security analysis (injection, auth, CSRF) — use review-security
Architecture analysis — use review-architecture
SQL-specific analysis — use review-sql
Full orchestrated review — use orchestrate-code-review
Handoff point: When all PHP findings are emitted, hand off to orchestrate-code-review for aggregation. For SQL injection or security vulnerabilities found in PHP code, note them and suggest review-security.
Use Cases
Orchestrated review: Used as the language step when orchestrate-code-review runs scope → language → framework → library → cognitive for PHP projects.
PHP-only review: When the user wants only language/runtime conventions checked (e.g. after adding a new PHP file).
Pre-PR PHP checklist: Ensure type safety, resource cleanup, and PSR compliance are correct.
When to use: When the code under review is PHP and the task includes language/runtime quality. Scope is determined by the caller or user.
Behavior
Scope of this skill
Analyze: PHP language and runtime conventions in the given code scope (files or diff provided by the caller). Do not decide scope; accept the code range as input.
Do not: Perform scope selection, security review, or architecture review; do not review non-PHP files for PHP-specific rules unless explicitly in scope.
Review checklist (PHP dimension only)
Strict types and declarations: declare(strict_types=1) usage; typed properties and parameters; return type declarations; avoid implicit type coercion pitfalls.
Error handling: Exceptions vs errors; Throwable hierarchy; proper try-catch and rethrow; avoid empty catch or overly broad catch; error_reporting and error-to-exception conversion where relevant.
Resource management: fopen/fclose, database connections, streams; ensure resources are closed (try-finally or short-lived scope); avoid resource leaks.
PSR standards: PSR-4 autoloading and namespace-to-path mapping; PSR-12 coding style (indentation, braces, visibility); class and method naming.
Namespaces and autoloading: Proper use statements; avoid global namespace pollution; composer autoload alignment.
Null safety: Null coalescing (??), null-safe operator (?->); avoid @ error suppression; isset vs array_key_exists for arrays.
Generators and iterables: Correct yield usage; proper iterator implementation; memory-efficient iteration for large datasets.
PHP version compatibility: Features used vs php constraint in composer.json; deprecated APIs and migration paths.
Testability: Dependency injection; static and singleton usage; constructor injection; seams for mocking.
Tone and references
Professional and technical: Reference specific locations (file:line). Emit findings with Location, Category, Severity, Title, Description, Suggestion.
Input & Output
Input
Code scope: Files or directories (or diff) already selected by the user or by the scope skill. This skill does not decide scope; it reviews the provided PHP code for language conventions only.
Output
Emit zero or more findings in the format defined in specs/findings-list.md, with Categorylanguage-php.
Category for this skill is language-php.
Restrictions
Hard Boundaries
Do not perform security, architecture, or scope selection. Stay within PHP language and runtime conventions.
Do not give conclusions without specific locations or actionable suggestions.
Do not review non-PHP code for PHP-specific rules unless explicitly in scope.
Skill Boundaries
Do NOT do these (other skills handle them):
Do NOT select or define the code scope — scope is determined by the caller or orchestrate-code-review
Do NOT perform security analysis (SQL injection, XSS, CSRF) — use review-security
Do NOT perform architecture analysis — use review-architecture
Do NOT perform comprehensive SQL analysis — use review-sql
When to stop and hand off:
When all PHP findings are emitted, hand off to orchestrate-code-review for aggregation
When the user needs a full review (scope + language + cognitive), redirect to orchestrate-code-review
When SQL injection or security issues are found, note them and suggest review-security
Self-Check
Core Success Criteria
PHP-only scope: Only PHP language and runtime conventions are reviewed; no scope selection, security, or architecture analysis performed
All nine PHP dimensions covered: Strict types, error handling, resource management, PSR standards, namespaces/autoloading, null safety, generators/iterables, PHP version compatibility, and testability are assessed where relevant
Findings format compliant: Each finding includes Location, Category (language-php), Severity, Title, Description, and optional Suggestion
File:line references: All findings reference specific file locations with line numbers
Non-PHP code excluded: Non-PHP files are not analyzed for PHP-specific rules unless explicitly in scope
Process Quality Checks
Was only the PHP language/runtime dimension reviewed (no scope/security/architecture)?
Are strict types, error handling, resources, PSR, namespaces, null safety, generators, version compatibility, and testability covered where relevant?
Is each finding emitted with Location, Category=language-php, Severity, Title, Description, and optional Suggestion?
Are issues referenced with file:line?
Acceptance Test
Does the output contain a PHP-focused findings list with file:line references covering all relevant language/runtime dimensions without performing security, architecture, or scope analysis?
Examples
Example 1: Resource leak
Input: PHP function that opens a file with fopen() and does not close it in all code paths.
Expected: Emit a finding for resource management; suggest try-finally or ensure fclose() in all paths. Category = language-php.
Example 2: Missing strict types
Input: New PHP file without declare(strict_types=1) and parameters/return types missing.
Expected: Emit finding(s) for type safety; suggest adding strict types and typed parameters where feasible. Category = language-php.
Edge case: Mixed PHP and SQL
Input: PHP file with embedded SQL strings for database queries.
Expected: Review only PHP conventions (resource handling, error handling, types). Do not emit SQL-injection findings here; that is for review-security or review-sql.
1---2name: review-php3description: Review PHP code for language and runtime conventions: strict types, error handling, resource management, PSR standards, namespaces, null safety, generators, and testability. Language-only atomic skill; output is a findings list.4license: MIT5---67# Skill: Review PHP89## Purpose1011Review code in **PHP** for **language and runtime conventions** only. Do not define scope (diff vs codebase) or perform security/architecture analysis; those are handled by scope and cognitive skills. Emit a **findings list** in the standard format for aggregation. Focus on strict types and declarations, error handling, resource management, PSR standards (PSR-4, PSR-12), namespaces, null safety, generators and iterables, PHP version compatibility, and testability.1213---1415## Core Objective1617**Primary goal**: Produce a PHP language/runtime findings list covering strict types, error handling, resource management, PSR standards, namespaces, null safety, generators, version compatibility, and testability for the given code scope.1819**Success Criteria** (ALL must be met):20211. ✅ **PHP-only scope**: Only PHP language and runtime conventions are reviewed; no scope selection, security, or architecture analysis performed222. ✅ **All nine PHP dimensions covered**: Strict types, error handling, resource management, PSR standards, namespaces/autoloading, null safety, generators/iterables, PHP version compatibility, and testability are assessed where relevant233. ✅ **Findings format compliant**: Each finding includes Location, Category (`language-php`), Severity, Title, Description, and optional Suggestion244. ✅ **File:line references**: All findings reference specific file locations with line numbers255. ✅ **Non-PHP code excluded**: Non-PHP files are not analyzed for PHP-specific rules unless explicitly in scope2627**Acceptance Test**: Does the output contain a PHP-focused findings list with file:line references covering all relevant language/runtime dimensions without performing security, architecture, or scope analysis?2829---3031## Scope Boundaries3233**This skill handles**:3435- `declare(strict_types=1)`, typed properties, parameters, return types36- Exception handling (Throwable hierarchy, try-catch-finally, no empty catch)37- Resource management (fopen/fclose, database connections, try-finally patterns)38- PSR-4 autoloading and PSR-12 coding style39- Namespace and autoloading correctness40- Null coalescing (`??`), null-safe operator (`?->`), error suppression avoidance41- Generator and iterable correctness42- PHP version compatibility with composer.json constraints43- Testability (DI, static/singleton avoidance, constructor injection)4445**This skill does NOT handle**:4647- Scope selection — scope is provided by the caller48- Security analysis (injection, auth, CSRF) — use `review-security`49- Architecture analysis — use `review-architecture`50- SQL-specific analysis — use `review-sql`51- Full orchestrated review — use `orchestrate-code-review`5253**Handoff point**: When all PHP findings are emitted, hand off to `orchestrate-code-review` for aggregation. For SQL injection or security vulnerabilities found in PHP code, note them and suggest `review-security`.5455---5657## Use Cases5859- **Orchestrated review**: Used as the language step when [orchestrate-code-review](../orchestrate-code-review/SKILL.md) runs scope → language → framework → library → cognitive for PHP projects.60- **PHP-only review**: When the user wants only language/runtime conventions checked (e.g. after adding a new PHP file).61- **Pre-PR PHP checklist**: Ensure type safety, resource cleanup, and PSR compliance are correct.6263**When to use**: When the code under review is PHP and the task includes language/runtime quality. Scope is determined by the caller or user.6465---6667## Behavior6869### Scope of this skill7071- **Analyze**: PHP language and runtime conventions in the **given code scope** (files or diff provided by the caller). Do not decide scope; accept the code range as input.72- **Do not**: Perform scope selection, security review, or architecture review; do not review non-PHP files for PHP-specific rules unless explicitly in scope.7374### Review checklist (PHP dimension only)75761. **Strict types and declarations**: `declare(strict_types=1)` usage; typed properties and parameters; return type declarations; avoid implicit type coercion pitfalls.772. **Error handling**: Exceptions vs errors; `Throwable` hierarchy; proper try-catch and rethrow; avoid empty catch or overly broad catch; `error_reporting` and error-to-exception conversion where relevant.783. **Resource management**: `fopen`/`fclose`, database connections, streams; ensure resources are closed (try-finally or short-lived scope); avoid resource leaks.794. **PSR standards**: PSR-4 autoloading and namespace-to-path mapping; PSR-12 coding style (indentation, braces, visibility); class and method naming.805. **Namespaces and autoloading**: Proper `use` statements; avoid global namespace pollution; composer autoload alignment.816. **Null safety**: Null coalescing (`??`), null-safe operator (`?->`); avoid `@` error suppression; `isset` vs `array_key_exists` for arrays.827. **Generators and iterables**: Correct `yield` usage; proper iterator implementation; memory-efficient iteration for large datasets.838. **PHP version compatibility**: Features used vs `php` constraint in composer.json; deprecated APIs and migration paths.849. **Testability**: Dependency injection; static and singleton usage; constructor injection; seams for mocking.8586### Tone and references8788- **Professional and technical**: Reference specific locations (file:line). Emit findings with Location, Category, Severity, Title, Description, Suggestion.8990---9192## Input & Output9394### Input9596- **Code scope**: Files or directories (or diff) already selected by the user or by the scope skill. This skill does not decide scope; it reviews the provided PHP code for language conventions only.9798### Output99100- Emit zero or more **findings** in the format defined in [specs/findings-list.md](../../specs/findings-list.md), with **Category** `language-php`.101- Category for this skill is **language-php**.102103---104105## Restrictions106107### Hard Boundaries108109- **Do not** perform security, architecture, or scope selection. Stay within PHP language and runtime conventions.110- **Do not** give conclusions without specific locations or actionable suggestions.111- **Do not** review non-PHP code for PHP-specific rules unless explicitly in scope.112113### Skill Boundaries114115**Do NOT do these** (other skills handle them):116117- Do NOT select or define the code scope — scope is determined by the caller or `orchestrate-code-review`118- Do NOT perform security analysis (SQL injection, XSS, CSRF) — use `review-security`119- Do NOT perform architecture analysis — use `review-architecture`120- Do NOT perform comprehensive SQL analysis — use `review-sql`121122**When to stop and hand off**:123124- When all PHP findings are emitted, hand off to `orchestrate-code-review` for aggregation125- When the user needs a full review (scope + language + cognitive), redirect to `orchestrate-code-review`126- When SQL injection or security issues are found, note them and suggest `review-security`127128---129130## Self-Check131132### Core Success Criteria133134- [ ] **PHP-only scope**: Only PHP language and runtime conventions are reviewed; no scope selection, security, or architecture analysis performed135- [ ] **All nine PHP dimensions covered**: Strict types, error handling, resource management, PSR standards, namespaces/autoloading, null safety, generators/iterables, PHP version compatibility, and testability are assessed where relevant136- [ ] **Findings format compliant**: Each finding includes Location, Category (`language-php`), Severity, Title, Description, and optional Suggestion137- [ ] **File:line references**: All findings reference specific file locations with line numbers138- [ ] **Non-PHP code excluded**: Non-PHP files are not analyzed for PHP-specific rules unless explicitly in scope139140### Process Quality Checks141142- [ ] Was only the PHP language/runtime dimension reviewed (no scope/security/architecture)?143- [ ] Are strict types, error handling, resources, PSR, namespaces, null safety, generators, version compatibility, and testability covered where relevant?144- [ ] Is each finding emitted with Location, Category=language-php, Severity, Title, Description, and optional Suggestion?145- [ ] Are issues referenced with file:line?146147### Acceptance Test148149Does the output contain a PHP-focused findings list with file:line references covering all relevant language/runtime dimensions without performing security, architecture, or scope analysis?150151---152153## Examples154155### Example 1: Resource leak156157- **Input**: PHP function that opens a file with `fopen()` and does not close it in all code paths.158- **Expected**: Emit a finding for resource management; suggest try-finally or ensure `fclose()` in all paths. Category = language-php.159160### Example 2: Missing strict types161162- **Input**: New PHP file without `declare(strict_types=1)` and parameters/return types missing.163- **Expected**: Emit finding(s) for type safety; suggest adding strict types and typed parameters where feasible. Category = language-php.164165### Edge case: Mixed PHP and SQL166167- **Input**: PHP file with embedded SQL strings for database queries.168- **Expected**: Review only PHP conventions (resource handling, error handling, types). Do not emit SQL-injection findings here; that is for review-security or review-sql.
Run npx skillmds@latest add nesnilnehc/review-php in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Review PHP code for language and runtime conventions: strict types, error handling, resource management, PSR standards, namespaces, null safety, generators, and testability. Language-only atomic skill; output is a findings list. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free. This skill is licensed under MIT.
nesnilnehc (@nesnilnehc) published this skill. Their other Agent Skills are listed on their SkillMD profile.