定制 dimionx/phpstan-rules 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dimionx/phpstan-rules

最新稳定版本:1.0.2

Composer 安装命令:

composer require --dev dimionx/phpstan-rules

包简介

Rule for PHPStan that detects when production code depends on classes from Composer dev-dependencies, with flexible configuration to selectively allow certain classes or namespaces where needed.

README 文档

README

PHPStan rule to detect usage of Composer dev-dependency classes in production code, with powerful configuration to re-allow specific classes or namespaces in places where they should be allowed.

Installation

Install the extension using Composer:

composer require --dev dimionx/phpstan-rules

Manual installation

For manual installation, add this to your phpstan.neon:

includes:
    - vendor/dimionx/phpstan-rules/extension.neon

Ignoring Errors

Only ignore errors for code that is never executed in production. Typical examples include:

  • Test files (*Test.php, */Tests/*, */tests/*)
  • Test helpers and utilities used exclusively in tests
  • Development-only scripts and tools
  • Fixture factories used solely for testing
  • Code generation scripts used during development
# phpstan.neon
parameters:
  ignoreErrors:
    # Ignore files that are allowed to use dev-packages
    -
      identifier: dev.packageUsedInProductionRule
      path: '*/Tests/*'

Features

  • Detects accidental usage of dev-dependency classes in production code
  • Configurable autoload types (PSR-4, PSR-0, classmap, files)
  • Namespace-based detection for comprehensive coverage
  • Flexible allowlists for legitimate cross-environment usage
  • composer.lock analysis for accurate dependency mapping

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-30