yousha / codecop
A lightweight static analyzer that scan PHP files for quality issues.
Requires
- php: 8.3.*
- ext-mbstring: *
- ext-tokenizer: *
Requires (Dev)
- ergebnis/composer-normalize: 2.47.*
- friendsofphp/php-cs-fixer: 3.75.*
- icanhazstring/composer-unused: 0.9.*
- maglnet/composer-require-checker: 4.16.*
- overtrue/phplint: 9.6.*
- phpunit/phpunit: 12.1.*
- rector/rector: 2.0.*
README
A lightweight static analyzer that scan PHP files for quality issues.
Contents
Overview
CodeCop is a lightweight yet powerful static analysis tool designed specifically for PHP codebases. This command-line utility scans PHP files within a specified directory (and its subdirectories) to identify common code quality issues that can affect maintainability, reliability, and consistency of PHP applications. The tool focuses on enforcing modern PHP best practices and detecting potential problems before they make their way into production environments.
Features
- No external dependency/library
- Validates strict type(
declare(strict_types=1)
) declaration - Enforces
final
orabstract
for all classes - Requires return types for all methods (except
__construct
) - Skips non-project directories automatically
- Handles anonymous classes properly
- Detects non-UTF-8 encoded files
- Warns about UTF-8 BOM (Byte Order Mark)
- Supported PHP: 8.3
- Supported platforms: Windows, GNU/Linux, MacOS
Requirements
- PHP >= 8.3
- Composer >= 2
Installation
composer require yousha/codecop --dev
Usage
php vendor/bin/codecop.php
Output:
PHP Code Analyzer - Scans PHP files for code quality issues.
Usage: php bin/codecop.php
Options: --help Show this help message --version Show version information
Examples: php bin/codecop.php . php bin/codecop.php src/ php bin/codecop.php /path/to/your/project
Basic usage:
php vendor/bin/codecop.php src/
Check version:
php vendor/bin/codecop.php --version
Get help:
php vendor/bin/codecop.php --help
Support
Changelog
See CHANGELOG.txt file.
ToDo
See TODO.txt file.
Notice
See NOTICE.txt file.
License
This open-source software is distributed under the GPL-3.0 license. See LICENSE file.