idrinth/php-cost-estimator 问题修复 & 功能扩展

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

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

idrinth/php-cost-estimator

Composer 安装命令:

composer create-project idrinth/php-cost-estimator

包简介

A simple tool to estimate the cost of a php script change

README 文档

README

This small tool is being build to statically analyze your code for potential performance issues.

Installation

composer require --global "php-cost-estimator/php-cost-estimator"
cd /your/project
estimate-cost estimate-cost:initialize

Usage

cd /your/project
estimate-cost

Output

The higher the number the more likely it is that the code is causing performance issues.

1xDe\Idrinth\PhpCostEstimator\Command\Check::execute@CLI => 189
- UsesFallbackToRootNamespace
  1xDe\Idrinth\PhpCostEstimator\Configuration\Merged::__construct@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Configuration\File::__construct@CLI => 2
  - UsesFallbackToRootNamespace
    1xis_file@CLI => 0
    1xis_array@CLI => 0
    1xRuntimeException::__construct@CLI => 0
  1xgetcwd@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Configuration\Cli::__construct@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\State\InheritanceList::__construct@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\State\CallableList::__construct@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\State\FunctionDefinitionList::__construct@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\State\TypeList::__construct@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Command\Check::iterateOverProject@CLI => 140
  - UsesFallbackToRootNamespace
    5xPhpParser\NodeTraverser::__construct@CLI => 0
    5xcount@CLI => 0
    5xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 130
    - UnnecessaryTypeDeclaration
    - UsesFallbackToRootNamespace
      50xstr_ends_with@CLI => 0
      25xstrtolower@CLI => 0
      25xis_dir@CLI => 0
      25xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 650
      - UnnecessaryTypeDeclaration
      - UsesFallbackToRootNamespace
        250xstr_ends_with@CLI => 0
        125xstrtolower@CLI => 0
        125xis_dir@CLI => 0
        125xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 3250
        - UnnecessaryTypeDeclaration
        - UsesFallbackToRootNamespace
          1250xstr_ends_with@CLI => 0
          625xstrtolower@CLI => 0
          625xis_dir@CLI => 0
          625xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 16250
          - UnnecessaryTypeDeclaration
          - UsesFallbackToRootNamespace
            6250xstr_ends_with@CLI => 0
            3125xstrtolower@CLI => 0
            3125xis_dir@CLI => 0
            3125xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 81250
            - UnnecessaryTypeDeclaration
            - UsesFallbackToRootNamespace
              31250xstr_ends_with@CLI => 0
              15625xstrtolower@CLI => 0
              15625xis_dir@CLI => 0
              15625xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 406250
              - UnnecessaryTypeDeclaration
              - UsesFallbackToRootNamespace
                156250xstr_ends_with@CLI => 0
                78125xstrtolower@CLI => 0
                78125xis_dir@CLI => 0
                15625xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => {-recursion-}
                78125xfile_get_contents@CLI => 0
              15625xfile_get_contents@CLI => 0
            3125xfile_get_contents@CLI => 0
          625xfile_get_contents@CLI => 0
        125xfile_get_contents@CLI => 0
      25xfile_get_contents@CLI => 0
    5xgetcwd@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Command\Check::iterateOverDependencies@CLI => 33
  - UnnecessaryTypeDeclaration
  - UsesFallbackToRootNamespace
    5xPhpParser\NodeTraverser::__construct@CLI => 0
    5xcount@CLI => 0
    1xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 26
    - UnnecessaryTypeDeclaration
    - UsesFallbackToRootNamespace
      10xstr_ends_with@CLI => 0
      5xstrtolower@CLI => 0
      5xis_dir@CLI => 0
      5xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 130
      - UnnecessaryTypeDeclaration
      - UsesFallbackToRootNamespace
        50xstr_ends_with@CLI => 0
        25xstrtolower@CLI => 0
        25xis_dir@CLI => 0
        25xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 650
        - UnnecessaryTypeDeclaration
        - UsesFallbackToRootNamespace
          250xstr_ends_with@CLI => 0
          125xstrtolower@CLI => 0
          125xis_dir@CLI => 0
          125xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 3250
          - UnnecessaryTypeDeclaration
          - UsesFallbackToRootNamespace
            1250xstr_ends_with@CLI => 0
            625xstrtolower@CLI => 0
            625xis_dir@CLI => 0
            625xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 16250
            - UnnecessaryTypeDeclaration
            - UsesFallbackToRootNamespace
              6250xstr_ends_with@CLI => 0
              3125xstrtolower@CLI => 0
              3125xis_dir@CLI => 0
              3125xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => 81250
              - UnnecessaryTypeDeclaration
              - UsesFallbackToRootNamespace
                31250xstr_ends_with@CLI => 0
                15625xstrtolower@CLI => 0
                15625xis_dir@CLI => 0
                3125xDe\Idrinth\PhpCostEstimator\Command\Check::iterateFolder@CLI => {-recursion-}
                15625xfile_get_contents@CLI => 0
              3125xfile_get_contents@CLI => 0
            625xfile_get_contents@CLI => 0
          125xfile_get_contents@CLI => 0
        25xfile_get_contents@CLI => 0
      5xfile_get_contents@CLI => 0
    1xgetcwd@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Command\Check::analyzeProject@CLI => 6
  - UnnecessaryTypeDeclaration
  - UsesFallbackToRootNamespace
    5xPhpParser\NodeTraverser::__construct@CLI => 0
    5xcount@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Command\Check::analyzeDependencies@CLI => 6
  - UnnecessaryTypeDeclaration
  - UsesFallbackToRootNamespace
    5xPhpParser\NodeTraverser::__construct@CLI => 0
    5xcount@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Command\Check::iterateOverResults@CLI => 1
  - UnnecessaryTypeDeclaration
1xDe\Idrinth\PhpCostEstimator\Command\Initialize::execute@CLI => 20
- UsesFallbackToRootNamespace
  1xgetcwd@CLI => 0
  1xis_file@CLI => 0
  1xmkdir@CLI => 0
  1xdirname@CLI => 0
  5xstr_ends_with@CLI => 0
  5xsubstr@CLI => 0
  1xsprintf@CLI => 0
  1xcount@CLI => 0
  1xfile_put_contents@CLI => 0
  1xstr_replace@CLI => 0
  1ximplode@CLI => 0
  1xfile_get_contents@CLI => 0
1xDe\Idrinth\PhpCostEstimator\Command\Reason::execute@CLI => 9
- UsesFallbackToRootNamespace
  1xReflectionClass::__construct@CLI => 0
  6xget_class@CLI => 0
  1xDe\Idrinth\PhpCostEstimator\Configuration\File::__construct@CLI => 2
  - UsesFallbackToRootNamespace
    1xis_file@CLI => 0
    1xis_array@CLI => 0
    1xRuntimeException::__construct@CLI => 0
  1xgetcwd@CLI => 0

Configuration

The configuration file is located at /your/project/.php-cost-estimator/config.php and will be generated by the initialize command. Feel free to adjust it and commit it to your version control.

<?php
declare(strict_types=1);

return [
    'rules' => [
        'De\\Idrinth\\PhpCostEstimator\\Rule\\BuildsUnusedObject',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\ConnectsToUnusedDatabase',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\LocksFileSystem',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\ParsesStaticTextFile',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\QueriesDatabase',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\ReadsFromFileSystem',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UnnecessaryCaching',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UnnecessaryTypeDeclaration',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesArrayKeyExists',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesFallbackToRootNamespace',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesInArrayOnLargeArray',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesReflection',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesRemoteCall',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesStaticComparison',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\UsesVersionSwitches',
        'De\\Idrinth\\PhpCostEstimator\\Rule\\WritesToFileSystem',
    ],
    'version' => '8.2.6',
    'folders' => [
        'src'
    ]
];

Contributing

All contributions are welcome, see CONTRIBUTING.md for details.

idrinth/php-cost-estimator 适用场景与选型建议

idrinth/php-cost-estimator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 4, 最近一次更新时间为 2023 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 idrinth/php-cost-estimator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-26