定制 struggle-for-php/sfp-deptrac-builtin 二次开发

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

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

struggle-for-php/sfp-deptrac-builtin

最新稳定版本:0.2.1

Composer 安装命令:

composer require --dev struggle-for-php/sfp-deptrac-builtin

包简介

Deptrac extension to enforce application on framework rule.

README 文档

README

PHP Web application on framework should not use network function like header(). But this rule is Implicit !. This extension is attempted to find violate such rule.

Example

  • examples/src/Action/UserShowAction.php includes
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        \header('Location: http://www.example.com/');
    }
$ cd examples/
$ ./vendor/bin/deptrac analyse
 107/107 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ----------- ----------------------------------------------------------------------------------
  Reason      Action
 ----------- ----------------------------------------------------------------------------------
  Violation   Foo\Action\UserShowAction must not depend on header() (Sending Raw HTTP)
              /home/sasezaki/dev/sfp-deptrac-builtin/examples/src/Action/UserShowAction.php:20
 ----------- ----------------------------------------------------------------------------------


 -------------------- -----
  Report
 -------------------- -----
  Violations           1
  Skipped violations   0
  Uncovered            24
  Allowed              48
  Warnings             0
  Errors               0
 -------------------- -----

Q&A

  • Q. Why not use PHPCS forbiddenFunctionNames ?

    • A. IMO, forbiddenFunctionNames is only should be used for dangerous function (its own) or alias function. Reason of forbidden header() usage in application is layer problem.
  • Q. When called header() with 'Location: ..., then should be called exit() on same scope, is it not ?

    • A. Maybe..

Inspired

This extension is developed inspired from this talk.

https://speakerdeck.com/asumikam/phpcon-2022

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固