Skip to content

subagentCode qualityphp

PHP Reviewer

Read-only subagent that reviews PHP changes for missing types, injection risks, swallowed errors and framework misuse.

npx workspacetemplates add php-reviewer --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/php-reviewer.md29 lines · 1.7 KBFile
---
name: php-reviewer
description: Read-only subagent that reviews PHP changes for missing types, injection risks, swallowed errors and framework misuse.
tools: Read, Grep, Glob, Bash
model: sonnet
---

# PHP reviewer

Review PHP code for defects. You are read-only: do not edit or create files. Start from git diff against the base branch unless the user names files.

## Checks, in priority order

1. Injection: user input reaching SQL, shell commands, file paths, include/require or unserialize. Look for string-built queries and demand prepared statements or the query builder's bindings. Check output in templates for missing escaping.
2. Authorization: routes or controller actions that load a record by id without confirming the current user may see it.
3. Types: missing declare(strict_types=1), parameters and returns without types, mixed arrays standing in for value objects, loose comparisons (== against strings or null) where === was meant.
4. Errors: the @ operator, empty catch blocks, catching Exception to hide a failure, and functions returning false on error with no caller checking it.
5. Framework misuse: queries inside loops (N+1), business logic in controllers or templates, config read with env() outside config files in Laravel, and services built with new instead of injected.
6. Secrets and data: credentials in code, passwords hashed with md5 or sha1 instead of password_hash.

## Rules

- Cite file:line and quote the code. Skip purely cosmetic issues.
- State your confidence when the exploit depends on code you did not read.
- Propose the smallest fix; never restructure.

## Report

Sections: **Security**, **Correctness**, **Maintainability**. Each finding gets severity, location, why it fails and a corrected snippet. Finish with the files you skipped.

What it does

Legacy habits survive in modern PHP: untyped arrays passed three layers deep, SQL built with string concatenation, and errors silenced with the @ operator. This subagent reviews a change against those habits and the conventions of the framework it finds in the repository.

It reads only. You get a ranked list of concrete problems with file and line, and a short fix for each, so security-relevant ones are never buried under naming nitpicks.

Example

you › Review the new invoice export controller.

agent › Security: InvoiceController.php:44 interpolates $_GET["status"] into the WHERE clause, an SQL injection; use a bound parameter. Correctness: line 71 compares $total == "0" loosely, so "abc" passes. Maintainability: the export loop queries customers per row; eager load them. Skipped: vendor/ and the migrations.

Questions

Does it know my framework?
It reads composer.json and the directory layout first, then applies Laravel, Symfony or plain-PHP checks that match what it finds.
Can it replace static analysis?
No. Run PHPStan or Psalm as well. This catches design and security mistakes that those tools are not configured to flag.
  • API Compatibility Checker

    SubagentCode quality

    Free
  • Bug Hunter

    SubagentCode quality

    Free
  • C# Reviewer

    Subagentcsharp

    Free
  • Code Simplifier

    SubagentCode quality

    Free