adachsoft/cs-fixer-tool

AI tool-call compatible php-cs-fixer runner with safe path normalization and command executor integration.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

pkg:composer/adachsoft/cs-fixer-tool

v0.1.0 2026-02-10 06:58 UTC

This package is not auto-updated.

Last update: 2026-02-11 04:35:23 UTC


README

AI tool-call compatible php-cs-fixer runner for PHP code style checking and fixing. It integrates with the adachsoft/ai-tool-call SPI, uses normalized safe paths to protect against path traversal, and executes commands via adachsoft/command-executor-lib.

Installation

composer require adachsoft/cs-fixer-tool

Requirements

  • PHP >= 8.2
  • adachsoft/ai-tool-call >= 2.0.1
  • adachsoft/command-executor-lib >= 2.0.0
  • adachsoft/normalized-safe-path >= 0.1.0
  • php-cs-fixer available in your environment (typically vendor/bin/php-cs-fixer)

Integration with AiToolCall

Register the CS Fixer tool factory in your AiToolCallFacade builder:

use Adachsoft\CsFixerTool\Tool\CsFixerToolFactory;
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;

$builder->registerToolFactory(new CsFixerToolFactory(), new ConfigMap([
    'base_path' => '/var/www/project',
    'php_cs_fixer_path' => 'vendor/bin/php-cs-fixer',
    'default_timeout' => 300,        // optional, default: 300 seconds
    'max_output_length' => 10000,    // optional, default: 10000 chars
    'sanitize_base_path' => true     // optional, default: true
]));

base_path defines the root directory for all tool operations. All user-provided paths are resolved relative to this base and validated using normalized safe paths.

Tool Usage

The tool is exposed to the AI agent as run_php_cs_fixer.

Dry run (check only)

{
  "toolName": "run_php_cs_fixer",
  "parameters": {
    "path": "src/Service/MyService.php",
    "fix": false
  }
}

Apply fixes

{
  "toolName": "run_php_cs_fixer",
  "parameters": {
    "path": "src/Service/MyService.php",
    "fix": true
  }
}

The result contains:

  • command  the executed command string,
  • exitCode  process exit code,
  • stdout  sanitized standard output,
  • stderr  sanitized standard error output,
  • success  boolean indicating success,
  • cwd  working directory for the executed command.