phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Add --stop-on-failure option to halt analysis on first error

Open idsulik opened this issue 4 months ago • 1 comments

Summary

Adds a new --stop-on-failure CLI option that stops PHPStan analysis immediately when the first error is encountered in any file.

Changes

  • New CLI Option: --stop-on-failure flag added to AnalyseCommand
  • Sequential Mode: Forces sequential analysis (disables parallel processing) when enabled for proper file-by-file control
  • Error Handling: Stops on both regular PHPStan errors and internal errors (exceptions)
  • Backward Compatibility: No impact on existing behavior when option is not used

Use Cases

  • Incremental error fixing: Focus on fixing one error at a time
  • CI/CD pipelines: Fail fast on first error to save build time
  • Large codebases: Quick feedback without processing all files
  • Development workflows: Immediate feedback on first issue

Testing

  • ✅ Manual testing with multiple error files
  • ✅ Unit tests covering various scenarios
  • ✅ Backward compatibility verified
  • ✅ Help text updated and verified

Example Usage

# Stop on first failure
phpstan analyse src/ --stop-on-failure

# Combined with other options
phpstan analyse src/ --stop-on-failure --level 8 --no-progress

idsulik avatar Sep 05 '25 07:09 idsulik

Feels and probably is vibe-coded.

Is it bad or good?

it's missing the main point - --stop-on-failure has to stop only a non-ignored error.

thank you, I'll check and fix it

idsulik avatar Sep 05 '25 16:09 idsulik