sepehr-mohseni/strict-types 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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, cache
  • symfony - excludes var, public
  • wordpress - excludes wp-admin, wp-includes
  • drupal - excludes core
  • yii - excludes runtime, web/assets
  • codeigniter - 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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-03