BC Check analyzes PHP code between two git commits to detect backward compatibility (BC) breaking changes using AST parsing. It helps library maintainers follow Semantic Versioning by identifying changes that could break dependent code.
"With a system of the size and importance of API, it is necessary to have some formalized rules to govern how updates are incorporated while still keeping the API stable." — Semantic Versioning 2.0.0
- BC Break Detection:
- Detects removed public/protected classes, methods, properties, and constants
- Detects method signature changes (parameters, types, defaults)
- Detects return type changes
- Detects visibility reductions
- Detects added
final,abstract,static,readonlymodifiers - Detects interface implementation changes
- Detects parent class changes
- Flexible Configuration:
- YAML-based configuration
- Regex patterns for include/exclude filtering
- Custom source directories
- External detector loading for custom BC break detection
- Multiple Output Formats:
- Human-readable text output
- JSON output for programmatic use
- GitHub Actions annotations
- SARIF (Static Analysis Results Interchange Format)
- Checkstyle XML
- JUnit XML
- GitLab Code Quality
- CI/CD Ready:
- Exit codes for build success/failure
- GitHub Actions, GitLab CI, CircleCI, Jenkins examples
- Docker support
composer require --dev phauthentic/bc-checkOr download the PHAR from the releases page.
- Installation - Install via Composer, PHAR, or Docker
- Usage - CLI usage, examples, output formats
- Configuration - YAML config options, regex patterns
- Detectors - List of all detected BC breaks
- Output Formats - Detailed format examples and specifications
- Custom Detectors - Create your own detectors
- CI Integration - GitHub Actions, GitLab CI, etc.
- Docker External Projects - Run via Docker against legacy codebases
- Development - Development setup and workflows
# Basic usage
vendor/bin/bc-check check /path/to/repo v1.0.0 v2.0.0
# With configuration file
vendor/bin/bc-check check /path/to/repo v1.0.0 v2.0.0 --config=bc-check.yaml
# JSON output
vendor/bin/bc-check check /path/to/repo v1.0.0 v2.0.0 --format=jsonFor more usage examples and options, see the Usage Guide.
If you find a bug or have a feature request, please open an issue on the GitHub repository.
When reporting issues, please provide:
- PHP version
- BC Check version
- Minimal code example that reproduces the issue
- Expected vs actual behavior
Copyright Florian Krämer
Licensed under the MIT License.