andersundsehr/grumphp-fractor-task
GrumPHP task for running Fractor (TYPO3 Fractor) in your Git hooks. Configure fractor.php path, file extensions, ignore patterns, cache clearing, and diff output to enforce automated refactoring checks on commit.
triggered_by) and ignore patterns allow granular control, critical for Laravel’s monorepo or multi-package setups (e.g., ignoring vendor/, node_modules/).declare(strict_types=1) enforcement or class naming conventions).declare(strict_types=1) enforcement may clash with Laravel’s legacy code or dynamic properties (e.g., __get() magic methods).class_naming may conflict with Laravel’s PSR-4 or service container conventions.fractor.php to override defaults or ignore specific patterns (e.g., ignore_patterns: ["app/Providers/AppServiceProvider.php"]).clear_cache: false) and parallel task execution.ignore_patterns).strict_types validation).strict_types in non-PHP 8.1 files, ignoring magic methods)?fractor.php config to exclude Laravel-specific edge cases:
return [
'rules' => [
'strict_types' => ['active' => true, 'level' => 'warning', 'ignore_files' => ['app/Helpers/*.php']],
'class_naming' => ['prefix' => 'App\\', 'suffix' => '', 'ignore' => ['*ServiceProvider']],
],
];
- name: Run GrumPHP
run: ./vendor/bin/grumphp run --strict --exit-code-env GRUMPHP_EXIT_CODE
- name: Check exit code
if: env.GRUMPHP_EXIT_CODE != '0'
run: exit 1
laravel-pint, rector, phpstan) to avoid redundancy?phpcsfixer (formatting) but before phpstan (type checking):
tasks:
phpcs_fixer: ~
fractor: ~
phpstan: ~
fractor.php and document rule changes in ADRs.grumphp.yml in .github/). This package extends that workflow without reinvention.clear_cache: false).declare(strict_types=1), class naming) not covered by PHPStan or Psalm.strict_types) by disabling in one tool.composer.json:
composer require --dev andersundsehr/grumphp-fractor-task
grumphp.yml):
grumphp:
tasks:
fractor:
config: "config/fractor.php" # Custom Laravel-specific config
ignore_patterns: ["vendor/", "tests/", "node_modules/", "storage/"]
clear_cache: false # Enable caching for local dev
no_diffs: true # Disable diffs in CI for cleaner output
extensions:
- Andersundsehr\GrumPHPFractorTask\ExtensionLoader
fractor.php (override defaults for Laravel):
return [
'rules' => [
'strict_types' => [
'active' => true,
'level' => 'warning',
'ignore_files' => ['app/Helpers/*.php', 'app/Exceptions/Handler.php'],
],
'class_naming' => [
'prefix' => 'App\\',
'suffix' => '',
'ignore' => ['*ServiceProvider', '*Factory', '*Repository'],
],
'method_ordering' => ['active' => true, 'order' => ['public', 'protected', 'private']],
],
'paths' => ['app/', 'src/', 'packages/'], # Scope to Laravel-specific paths
];
./vendor/bin/grumphp run manually to validate. Use --no-cache to test CI behavior locally..github/workflows/ci.yml as a separate job (fail-fast):
- name: Run Fractor
run: ./vendor/bin/grumphp run --test --exit-code-env GRUMPHP_EXIT_CODE
- name: Check Fractor
if: env.GRUMPHP_EXIT_CODE != '0'
run: exit 1
How can I help you explore Laravel packages today?