定制 xefi/phpstan-xefi-rules 二次开发

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

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

xefi/phpstan-xefi-rules

Composer 安装命令:

composer require xefi/phpstan-xefi-rules

包简介

Some custom PHPStan extensions for a better code base

README 文档

README

CI state Packagist version

Some custom PHPStan extensions to improve the readability, maintainability and overall quality of your PHP code base.

Package based on PHPStan. You can find the source package here.

Supported PHP versions

PHP version This package version
8.x Latest

How to use it

1: First, you may use Composer to install this package as a development dependency into your project:

composer require --dev "xefi/phpstan-xefi-rules"

2: Then, create a phpstan.neon or phpstan.neon.dist file in the root of your application. It might look like this:

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

# The rest of your config file
parameters:
    paths:
        - src/

    # 0 to 10, level 10 is the highest level
    level: 0

The most important part is the includes one, that enables the rules of this package.

For all available options, please take a look at the PHPStan documentation: https://phpstan.org/config-reference

3: Finally, you may start analyzing your code using the phpstan console command:

./vendor/bin/phpstan

Rules

Banned Functions Rule

Identifier : xefi.bannedFunctions

Ensure banned functions like dd() are not called.

Boolean Property Naming Rule

Identifier : xefi.booleanPropertyNaming

Ensure that a Boolean is always named with an is at the beginning of its name, to clarify the condition it represents.

Max Line Per Class Rule

Identifier : xefi.maxLinePerClass

Guarantee that a class is no more than 200 lines long, to clearly separate roles between classes and encourage clarification.

Max Line Per Method Rule

Identifier : xefi.maxLinePerMethod

Guarantee that a method is no more than 40 lines long, to separate roles between classes and encourage specification.

No Basic Exception Rule

Identifier : xefi.noBasicException

Ensure that no base exceptions are thrown in order to make custom and specific exceptions everywhere for better maintainability.

No Delete Cascade Rule (Laravel)

Identifier : xefi.noCascadeDeleteLaravel

Prevents cascading deletions in SQL to avoid uncontrolled deletions.
This rule forces you to think about the need for a cascading deletion, and to handle such cases in your code if you need to, which also makes it possible to use the observers and events managed by the framework.

This rule only works for Laravel.
A Symfony rule is planned.

No Generic Word Rule

Identifier : xefi.noGenericWord

Prevent generic variable names such as array, string, str, result, res, data to encourage developers to use clear and detailed names such as users, filteredUsers, usersCount, cars, ...

No Laravel Observer Rule

Identifier : xefi.noLaravelObserver

Forbid the use of Observers in Laravel, as the behavior of observers is sometimes incomprehensible and uncontrollable.
This rule encourages the use of Events & Listeners, whose behavior is similar but much more explicit and stable.

No Try Catch Rule

Identifier : xefi.noTryCatch

Prevent try catch usage to ensure that the user uses PHP exceptions.
This makes the code more readable and errors are handled by the framework if there is one.

xefi/phpstan-xefi-rules 适用场景与选型建议

xefi/phpstan-xefi-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.82k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「rules」 「PHPStan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 xefi/phpstan-xefi-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xefi/phpstan-xefi-rules 我们能提供哪些服务?
定制开发 / 二次开发

基于 xefi/phpstan-xefi-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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