Download the PHP package voku/phpstan-agent-format without Composer

On this page you can find all versions of the php package voku/phpstan-agent-format. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpstan-agent-format

voku/phpstan-agent-format

🚮 Stop feeding AI agents console garbage. Give them structured repair envelopes instead.

voku/phpstan-agent-format adds a custom PHPStan formatter named agent that emits compact, deterministic repair envelopes for coding agents. The default output uses TOON for token-efficient LLM repair loops.


⚡ Quick start

Add the extension to your phpstan.neon:

Run PHPStan with the agent formatter:

That is enough to get agent-ready TOON output.


🤖 Use as an agent skill

Paste this into your coding agent's system prompt or context:

You are fixing PHPStan issues in this repository. Run vendor/bin/phpstan analyse --error-format=agent. Read the TOON envelope. Pick one cluster at a time. Use rootCauseSummary, repairStrategySummary, symbolContext, snippets, and contextTrace to understand the root cause. Make the smallest safe code change that removes the reported issue without changing unrelated behavior. Re-run PHPStan after each change and confirm the cluster disappears before moving on.

Recommended agent loop:

  1. Read summary — understand total issue count and how many clusters were found.
  2. Pick one cluster — use kind, ruleIdentifier, and affectedFiles to locate it.
  3. Read the representative issue — symbolContext and the code snippet show where to act.
  4. Make the smallest safe change, then re-run PHPStan.
  5. Confirm the cluster is gone before picking the next one.

When an agent needs JSON instead of TOON (e.g. for structured tool output), set agentFormat.outputMode: json.

PHPStan 2.3 auto-fix metadata

Starting with PHPStan 2.3.5, a representative issue can include fixable: true when PHPStan explicitly provides an automatic AST fix. This also survives conversion from PHPStan's --error-format=json exports. The field is omitted for older PHPStan versions, non-fixable issues, and unknown fixability. repairStrategySummary is an advisory hint, not a verified automatic fix.

phpstan analyse --fix and --fix-ignored belong to PHPStan itself, not this formatter. Do not run them as part of a read-only reporting or approval workflow; they can modify source files or ignored-error configuration. Verify diffs and rerun analysis/tests before accepting any fix. The extension stays registered through extension.neon for compatibility with PHPStan 2.1+, even though PHPStan 2.3.5 adds optional attribute-based registration.


🚮 Why this exists

The slot machine

We take PHPStan output, dump it into CI, copy it into an AI prompt, and then act surprised when the agent starts fixing symptoms instead of the problem.

❌ bad:

Then copy 500 lines of terminal output into an AI tool and ask:

Congratulations. You built a slot machine.

✅ better:

Then give the agent structured repair information:

This is not magic. This is basic tooling hygiene.

The problem with unstructured output

Static analysis output for humans is not automatically good input for agents.

Humans can read noisy CI logs and guess the hidden connection between ten errors. We can say: "Ah, this is probably one nullable value leaking through the service layer." Then we fix the source.

Agents are not there yet unless we give them better input.

Without structure, the agent sees this:

And then it does this:

That is not refactoring. That is automated panic.

What structured output looks like

❌ bad (three separate errors, same root cause, no context):

Agent reaction: Make everything nullable?

No. Bad agent. Sit.

✅ better (one cluster, two files, clear repair path):

Now we can work.

voku/phpstan-agent-format groups related findings, deduplicates repeated symptoms, and includes compact context traces — giving the agent something closer to a repair plan instead of a wall of terminal sadness.

And yes, this is still your job as a developer. The agent should not decide architecture. The agent should repair one cluster, with one small change, and then PHPStan should confirm that the problem disappeared.

Same rule as with legacy code: first think, then change, then check.


⚙️ Configure

Run:

Configuration options

Option Default Description
outputMode toon Serializer: toon, json, ndjson, markdown, compact
maxClusters 30 Maximum number of issue clusters in the report
maxIssuesPerCluster 3 Representative issues shown per cluster
snippetLinesBefore 2 Source context lines before the reported line
snippetLinesAfter 3 Source context lines after the reported line
includeDocblock false Includes the nearest relevant PHPDoc block for the reported symbol when available.
includeRelatedDefinition true Includes a compact declaration snippet plus parser-derived line/endLine range for the related class, method, function, property, or constant when it can be resolved safely.
tokenBudget 12000 Cap report size; reduction is deterministic when exceeded
redactPatterns [] Regex patterns to redact secrets from snippets and notices
itpContext false Append the architecture rules of the files that carry PHPStan issues as advisory notices (requires voku/itp-context, see below)

Architecture context from voku/itp-context

Then a plain vendor/bin/phpstan analyse is enough. The report gets an advisory notices section with the architecture rules of the files in which PHPStan reports issues (rules come from the #[Rule(...)] attributes of voku/itp-context). The formatter is a repair report, not an architecture index:

Context-rich representative issue example

When includeDocblock and includeRelatedDefinition are enabled, representative issues can include compact symbol context without expanding entire source files:

relatedDefinition.line is the parser start line (including attributes when present), and relatedDefinition.endLine is the inclusive parser end line so agents can run commands like sed -n '16,20p' src/UserMailer.php. If a docblock or related declaration cannot be resolved conservatively, the corresponding enabled field is emitted as null. Both fields respect redactPatterns and the token-budget reducer may remove them before shrinking root-cause and repair-strategy summaries.


📋 Output modes

Mode Alias Best for
agentToon toon Default — token-efficient agent repair loops
agentJson json Structured tool output, JSON-consuming agents
agentNdjson ndjson Streaming / line-delimited pipelines
agentMarkdown markdown Chat-based flows, paste into Copilot/Claude/ChatGPT
agentCompact compact Ultra-compact text for tight token budgets

Switch the mode per workflow:

Then hand the markdown report to your agent:


📐 Envelope shape (TOON)

📐 Envelope shape (JSON)

Representative issues include structured repair hints inside symbolContext, including the targeted parameter/property plus expected and inferred types when PHPStan exposes them.


🧩 Clustering strategy

First-pass clustering groups by:

Cluster kinds include:


💰 Token budget reduction strategy

When estimated tokens exceed tokenBudget, degradation is deterministic and ordered:

  1. Remove verbose/secondary details (secondary locations)
  2. Shrink snippets to focused lines
  3. Reduce representative issues per cluster
  4. Keep root cause + repair strategy summaries last

🔒 Security and privacy

Snippets are redacted using configurable regex patterns before serialization.


📁 Example outputs

See /examples/:


🔄 Reformat existing JSON exports

If you already produce phpstan --error-format=json, reformat that payload without rebuilding your pipeline:

The repository CI dogfoods both modes: PHPStan runs once with the default formatter, once with --error-format=agent, and again against committed fixture configs that exercise the agent envelope on real output.


All versions of phpstan-agent-format with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
phpstan/phpstan Version ^2.1
helgesverre/toon Version ^3.1.0
voku/simple-php-code-parser Version ^0.22
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package voku/phpstan-agent-format contains the following files

Loading the files please wait ...