automattic / jetpack-analyzer
分析 Jetpack 版本之间的差异
v2.0.0
2024-02-07 20:37 UTC
Requires
- php: >=7.0
- nikic/php-parser: 4.13.2
Requires (Dev)
- php: ^7.4 || ^8.0
- automattic/jetpack-changelogger: ^4.1.0
- dev-trunk / 2.0.x-dev
- v2.0.0
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.2
- v1.6.1
- 1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-prerelease
- dev-fix/slack-workflow-branch-detection
- dev-fix/release-branch-typo
- dev-update/generate-branch-plugin
- dev-release-v1.6.0
- dev-release-v1.5.0
- dev-feature/reorg
- dev-release-v1.4.0
- dev-release-v1.3.0
- dev-release-v1.2.0
- dev-release-v1.1.0
This package is auto-updated.
Last update: 2024-09-18 03:17:36 UTC
README
分析公共类、方法、变量和函数,以在版本之间查找破坏性更改
运行
composer run example
API
声明
此类表示从一个或多个文件中积累的公共声明列表。
公共声明包括
- 类
- 类方法(静态和实例)
- 公共类属性
- 函数
Declarations
可以通过使用$declarations->scan($dir, $exclude = array())
扫描文件和目录来找到每个声明。
您可以将这些声明print
、load
和save
为CSV。
您还可以使用->find_differences($previous_declarations)
生成旧代码库和新代码库之间的差异列表,例如Jetpack 7.4和Jetpack 7.5,它返回一个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' );
您可以将Declarations
的实例用作输入到(new Differences())->find($new_codebase, $old_codebase)
支持的声明
- 类
- 类属性(静态或实例)
- 类方法(静态或实例)
- 函数
差异
差异列表可用于检查对一组调用的兼容性。
这是通过解析任何外部文件查找调用来执行的。如果这些调用与两个Jetpack版本之间已更改的任何函数、方法、类或属性匹配,则将生成一个警告或错误列表。
// 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();
支持的差异
- 类缺失
- 类移动到另一个文件
- 类属性缺失
- 类属性移动到另一个文件
- 类方法缺失
- 类方法移动到另一个文件
- 函数缺失
- 函数移动到另一个文件
调用
每种相关类型的调用列表
- 函数调用
- 静态和实例方法调用
- 通过
new
实例化 - 对类属性的引用
这是所有这些类型的调用。要仅查找已缺失/更改的函数的调用,请查看下面的警告。
$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();
支持的调用
- new Class
- 分配/读取静态Class属性
- 调用静态Class方法
- 调用Function
警告
由比较Invocations
对象和Differences
对象生成的警告列表。
// assumes `$differences` and `$invocations` have already been generated as per above $warnings = new Automattic\Jetpack\Analyzer\Warnings(); $warnings->generate( $invocations, $differences ); $warnings->print();
支持的警告
- new Class
- 分配/读取静态Class属性
- 调用静态Class方法
- 调用Function