sepehr-mohseni/strict-types
最新稳定版本:v1.0.0
Composer 安装命令:
composer require sepehr-mohseni/strict-types
包简介
A powerful CLI tool to manage strict_types declarations in PHP files with framework presets, dry-run mode, and comprehensive testing
README 文档
README
A CLI tool for managing declare(strict_types=1); in PHP projects.
Requirements
- PHP 7.4+
Installation
composer require --dev sepehr-mohseni/strict-types
Usage
# Add strict_types to files ./vendor/bin/strict-types add src/ # Check coverage ./vendor/bin/strict-types check . # Remove strict_types ./vendor/bin/strict-types remove src/ # Generate config file ./vendor/bin/strict-types init
Commands
| Command | Description |
|---|---|
add |
Add declare(strict_types=1); to PHP files |
remove |
Remove the declaration from files |
check |
Report strict_types coverage |
init |
Create .strict-types.json config |
help |
Show help |
version |
Show version |
Options
--dry-run Preview changes --backup Create .bak files before modifying --no-recursive Skip subdirectories --preset=<name> Use framework preset --exclude=<pattern> Exclude files matching pattern --json Output JSON (check command) -v, --verbose Verbose output -q, --quiet Suppress output
Framework Presets
Auto-detected or manually specified:
laravel- excludes blade templates, storage, cachesymfony- excludes var, publicwordpress- excludes wp-admin, wp-includesdrupal- excludes coreyii- excludes runtime, web/assetscodeigniter- excludes system, writable
Configuration
Create .strict-types.json:
{
"exclude_patterns": ["*.blade.php"],
"exclude_directories": ["vendor", "node_modules"],
"dry_run": false,
"backup": true,
"recursive": true
}
Examples
# Laravel project with backup ./vendor/bin/strict-types add --preset=laravel --backup . # Check and output JSON for CI ./vendor/bin/strict-types check --json src/ > report.json # Dry run to preview ./vendor/bin/strict-types add --dry-run app/
CI Integration
# GitHub Actions - name: Check strict_types run: ./vendor/bin/strict-types check --json . > coverage.json
Testing
composer test
License
MIT
Author
Sepehr Mohseni - GitHub
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-03