automattic/jetpack-analyzer
Composer 安装命令:
composer require --dev automattic/jetpack-analyzer
包简介
Analyze differences between Jetpack versions
关键字:
README 文档
README
Analyzes public classes, methods, variables and functions to search for breaking changes between versions
Running
composer run example
API
Declarations
This class represents a list of public declarations accumulated from one or more files.
Public declarations include:
- classes
- class methods (static and instance)
- public class properties
- functions
Declarations can find each declaration by scanning files and directories using $declarations->scan( $dir, $exclude = array() ).
You can print, load, and save those declarations as CSV.
You can also generate a list of differences between old and new code bases, e.g. Jetpack 7.4 and Jetpack 7.5, using ->find_differences( $previous_declarations ), which returns an instance of Automattic\Jetpack\Analyzer\Differences.
$declarations = new Automattic\Jetpack\Analyzer\Declarations(); // single file $declarations->scan( $base_path . '/class.jetpack.php' ); // OR recursively scan a directory $exclude = array( '.git', 'vendor', 'tests', 'docker', 'bin', 'scss', 'images', 'docs', 'languages', 'node_modules' ); $declarations->scan( $base_path, $exclude ); // print the declarations $declarations->print(); // save the declarations as CSV $declarations->save( 'path/to/jetpack-trunk.csv' ); // load some other declarations $jp74_declarations->load( 'path/to/jetpack-branch-7.4.csv' );
You can use instances of Declarations as input to (new Differences())->find( $new_codebase, $old_codebase )
Supported declarations:
- Class
- Class property (static or instance)
- Class method (static or instance)
- Function
Differences
A list of differences can be used to check compatibity against a set of invocations.
This is performed by parsing any external file looking for invocations. If those invocations match any functions, methods, classes or properties that have been changed between the two Jetpack versions, then a list of warnings or errors will be produced.
// load declarations from a file, or scan using ->scan() $trunk_declarations->load( 'path/to/codebase-1.0.csv' ); $other_declarations->load( 'path/to/codebase-2.0.csv' ); // OR $trunk_declarations->scan( 'path/to/trunk_branch', array( '.git', 'node_modules' ) ); $other_declarations->scan( 'path/to/other_branch', array( '.git', 'node_modules' ) ); $differences = new Automattic\Jetpack\Analyzer\Differences(); $differences->find( $trunk_declarations, $jp74_declarations ); $differences->print();
Supported differences:
- Class missing
- Class moved to another file
- Class property missing
- Class property moved to another file
- Class method missing
- Class method moved to another file
- Function missing
- Function moved to another file
Invocations
A list of invocations of every relevant type:
- function calls
- static and instance method calls
- instantiation via
new - references to class props
This is ALL invocations of these types. To find just the invocations of missing/different functions, look at Warnings below.
$invocations = new Automattic\Jetpack\Analyzer\Invocations(); $invocations->scan( 'path/to/example.php' ); // can be a file or directory // OR $invocations->scan( 'path/to/repo', array( '.git', '.gitmodules', 'assets' ) ); $invocations->print();
Supported invocations:
- new Class
- assign/read static Class property
- invoke static Class method
- call Function
Warnings
A list of warnings generated by comparing an Invocations object with a Differences object.
// assumes `$differences` and `$invocations` have already been generated as per above $warnings = new Automattic\Jetpack\Analyzer\Warnings(); $warnings->generate( $invocations, $differences ); $warnings->print();
Supported warnings:
- new Class
- assign/read static Class property
- invoke static Class method
- call Function
automattic/jetpack-analyzer 适用场景与选型建议
automattic/jetpack-analyzer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 09 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「static analysis」 「jetpack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 automattic/jetpack-analyzer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 automattic/jetpack-analyzer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 automattic/jetpack-analyzer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Creates a custom autoloader for a plugin or theme.
Jetpack Coding Standards. Based on the WordPress Coding Standards, with some additions.
A custom installer plugin for Composer to move Jetpack packages out of `vendor/` so WordPress's translation infrastructure will find their strings.
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
TwigStan is a static analyzer for Twig templates powered by PHPStan
Sentiment analysis library for PHP.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2019-09-14