sstalle/php7cc package is a static code analyzer designed to identify PHP 5.x code incompatible with PHP 7.x+. It leverages PHP’s Abstract Syntax Tree (AST) to detect deprecated constructs, syntax changes, and potential runtime issues (e.g., foreach by reference, mysql_* functions, or register_globals).php artisan package:discover) but focuses on low-level syntax/behavioral incompatibilities not covered by Laravel’s ecosystem (e.g., Symfony’s deprecation component).Route::bind() in Laravel <8.0), requiring manual mapping.php artisan check:php7).eval()) or miss runtime errors (e.g., undefined constants).phpstan/extension-installer or phpstan/phpstan for stricter typing.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Outdated Package | High | Fork/maintain or replace with phpstan + custom rules. |
| False Positives | Medium | Whitelist known-safe patterns in config. |
| Performance Overhead | Low | Run in CI (not local dev) for large codebases. |
| Laravel-Specific Blind Spots | Medium | Supplement with laravel-shift/doctrine-db-dump-filter for ORM issues. |
roave/security-advisories, phpstan)?phpstan with phpstan/extension-installer.| Tool | Purpose |
|---|---|
phpstan/phpstan |
Static analysis for type safety. |
roave/security-advisories |
Dependency vulnerability scanning. |
laravel-shift/doctrine-db |
DBAL/ORM migration helpers. |
dealerdirect/phpcodesniffer |
PSR/Framework-specific linting. |
./vendor/bin/php7cc analyze app/ (or custom path) to generate a baseline report.E_DEPRECATED vs. E_STRICT).# .github/workflows/php7cc.yml
- name: PHP 7 Compatibility Check
run: ./vendor/bin/php7cc analyze app/ --format=json > php7cc-report.json
# Fail if non-zero exit code
// app/Console/Commands/CheckPhp7Compatibility.php
public function handle() {
$output = shell_exec('php7cc analyze app/ --format=json');
$issues = json_decode($output, true);
if (!empty($issues['errors'])) {
$this->error("PHP 7 incompatibilities found!");
exit(1);
}
}
phpstan + custom rules for PHP 7+ checks.mysql_* functions).match expressions, attributes).ext-phar is enabled for some features.php -v) and Laravel version (composer show laravel/framework).composer.json dev dependencies:
"require-dev": {
"sstalle/php7cc": "^1.0"
}
php7cc.json:
{
"whitelist": [
"app/Helpers/legacy.php:10" // Known safe dynamic code
]
}
mysql_* calls must be replaced with PDO").phpstan rules (e.g., phpstan/phpstan-deprecation-rules).token_get_all() for lightweight checks.eval(), create_function()).php -l (lint) and phpstan.How can I help you explore Laravel packages today?