PHP — 152 Operations for AI Agents
This page is the canonical reference an AI coding agent uses to refactor, query, and analyze PHP code through the act MCP server. 152 operations available: 78 refactor, 18 query, 42 analysis, 14 verification. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.
Query
18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.
callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch
Refactor
| Operation | Description |
|---|---|
add-braces-to-statement |
Add braces to single-line control structure body |
add-const-modifier |
Add const modifier to class property or variable |
add-field-initialization |
Add initialization for uninitialized class field in constructor |
add-null-check-guard |
Wrap expression in null/isset check |
add-nullable-type |
Convert null checks to nullable type hint (?) |
add-type-declaration |
Add type hint to parameter or return type |
add-visibility-modifier |
Add public/protected/private to property/method |
change-visibility-modifier |
Change public to protected or vice versa |
convert-array-syntax-to-short |
Convert array() syntax to short [] syntax |
convert-closure-to-arrow-function |
Convert closure to arrow function (fn() =>) |
convert-comment-to-docblock |
Convert inline comment to PHPDoc block |
convert-if-else-to-ternary |
Convert if-else to ternary operator |
convert-property-to-getter |
Convert public property access to getter method |
convert-property-to-getter-setter |
Convert public property to private with getter and setter methods |
convert-string-concatenation-to-interpolation |
Convert string concatenation to variable interpolation |
convert-ternary-to-if-else |
Convert ternary operator to if-else statement |
extract-class |
Extract methods/fields to new class |
extract-constant |
Extract magic number/string into named constant |
extract-function |
Extract code block into new function with parameter inference |
extract-method |
Extract code block into new method with parameter inference |
extract-variable |
Extract expression into new variable with proper scope |
extract_function |
Extract a code selection into a new function — automatically infers parameters, return types, and inserts the call site. Use instead of manually cutting/pasting code. Works without LSP; LSP improves type inference. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool), receipt (bool)] |
extract_variable |
Extract an expression into a named variable — inserts the declaration and replaces the expression with the variable name. Works without LSP. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool)] |
generate-constant |
Generate class constant from value |
generate-constructor |
Generate __construct() method with property assignments |
generate-docblock-method |
Generate @method annotation in class docblock |
generate-docblock-param |
Generate @param documentation for parameter |
generate-docblock-property |
Generate @property annotation in class docblock |
generate-docblock-return |
Generate @return documentation |
generate-docblock-throws |
Generate @throws documentation |
generate-equals-method |
Generate comparison logic (== / ===/compare) |
generate-exception-class |
Generate custom exception class |
generate-getter-setter-pair |
Generate both getter and setter for property |
generate-interface |
Generate interface from class public methods |
generate-magic-call |
Generate __call magic method for class |
generate-magic-get |
Generate __get magic method for class |
generate-magic-isset |
Generate __isset magic method for class |
generate-magic-set |
Generate __set magic method for class |
generate-magic-static-call |
Generate __callStatic magic method for class |
generate-magic-tostring |
Generate __toString magic method for class |
generate-magic-unset |
Generate __unset magic method for class |
generate-method-stub |
Generate empty method with signature |
generate-property-getter |
Generate public getter method for property |
generate-property-setter |
Generate public setter method for property |
generate-test-class |
Generate test class for class under test |
generate-test-method |
Generate test method stub with assertions |
generate-trait |
Generate trait from class methods |
group-use-statements |
Group related use statements by namespace |
inline |
Inline a variable, function, or method — replace every usage with its definition body, then remove the original. The inverse of extract. Works without LSP (single-file); LSP enables cross-file inlining. Params: file (string), symbol (string) [, line (u32), preview (bool), receipt (bool)] |
inline-function |
Inline function by replacing call with function body |
inline-variable |
Inline variable by replacing with its expression |
insert_body |
Replace a function's implementation body with new code. AST-validated — rejects if the result has parse errors, so you can't accidentally break syntax. Use instead of manual text editing for function rewrites. Params: file (string), symbol (string), code (string) [, commit (bool)] |
invert-boolean-expression |
Invert a boolean expression using De Morgan's laws |
invert-if-else |
Swap if/else branches and invert condition |
merge-nested-if-statements |
Merge nested if statements into single condition with && |
move_symbol |
Move a function, class, or type to a different file and automatically update all imports across the codebase. Use instead of manually cut/paste + fixing imports. Works without LSP (single-file); LSP enables cross-file import updates. Params: file (string), symbol (string), destination (string) [, preview (bool), receipt (bool)] |
recipe_run |
Run a codemod recipe: declarative match → transform → optional verify across modeled grammars. Preview lists matches; apply writes with optional E7 receipts and all-or-nothing rollback. Returns a per-site report. |
remove-unnecessary-braces |
Remove unnecessary braces from single-statement control structure |
remove-unreachable-code |
Remove code after return/throw/exit |
remove-unused-use-statement |
Remove unused import declarations |
rename |
Rename a symbol and automatically update ALL references across the codebase. Safer and faster than find-and-replace — AST-aware, won't rename strings or comments. Works without LSP (single-file); LSP enables cross-file renames. Params: file (string), old_name (string), new_name (string) [, line (u32), column (u32), preview (bool), receipt (bool)] |
rename-class |
Rename a class and all instantiations/references |
rename-constant |
Rename a constant declaration and usages |
rename-function |
Rename a function declaration and all call sites |
rename-method |
Rename a method and all call references in class context |
rename-parameter |
Rename function/method parameter across all usages |
rename-variable |
Rename a variable across all references in scope |
simplify-boolean-expression |
Simplify redundant boolean expression |
simplify-if-statement |
Simplify if statement that returns boolean |
sort-use-statements |
Alphabetically sort use declarations |
split-if-statement |
Split compound if condition into nested if statements |
split-variable-declaration |
Split variable declaration and assignment into separate statements |
use-constructor-promotion |
Convert constructor property assignment to PHP 8.0 constructor promotion |
use-match-expression |
Convert switch statement to PHP 8.0 match expression |
use-named-arguments |
Convert positional arguments to PHP 8.0 named arguments |
use-null-coalescing-operator |
Convert isset/ternary to null coalescing operator (??) |
use-null-safe-operator |
Convert null check chain to null-safe operator (?->) |
wrap-in-try-catch |
Wrap statement in try-catch block |
Analysis
42 analysis tools, the same on every supported language. Descriptions live in the shared reference: /docs/analysis-tools.
analyze_api_diff analyze_chokepoints analyze_clones analyze_clusters analyze_cohesion analyze_conformance analyze_coupling analyze_cycle_risk analyze_cycles analyze_dead_code analyze_depth analyze_entry_points analyze_export analyze_extraction analyze_fan_balance analyze_features analyze_hotspots analyze_impact analyze_inconsistencies analyze_inheritance analyze_interface_bloat analyze_interfaces analyze_layers analyze_orphan_types analyze_patterns analyze_platform_deps analyze_readiness analyze_roles analyze_seams analyze_stability analyze_surface analyze_test_gaps analyze_thickness analyze_type_completeness churn_hotspots co_change_clusters coverage_overlay ownership_map profile_overlay simulate split_module trace_overlay
Verify
14 verify tools, the same on every supported language. Descriptions live in the shared reference: /docs/verification.
bisect_regression gate generate_test_harness scan secret_surface summarize_pr taint_flow unsafe_surface verify_behavioral_equivalence verify_contract_preserved verify_diff_semantics verify_port_parity verify_side_effects verify_test_impact