tomzx / php-semver-checker
PHP语义版本检查器
v0.16.0
2023-06-19 02:21 UTC
Requires
- php: ^8.0
- hassankhan/config: ^3.0
- nikic/php-parser: ^4.0
- symfony/console: ^6.0
- symfony/yaml: ^6.0
- tomzx/finder: ^0.2
Requires (Dev)
- mockery/mockery: ^1.4.4
- phpunit/phpunit: ^9.5.10
- dev-master / 0.17.x-dev
- v0.16.0
- v0.15.1
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.1
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.1
- v0.8.0
- v0.7.0
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.0
- dev-dependabot/composer/symfony/console-5.4.22
- dev-dependabot/composer/phpunit/phpunit-9.6.6
- dev-dependabot/composer/nikic/php-parser-4.15.4
- dev-dependabot/composer/symfony/yaml-5.4.21
- dev-fixes/composer-github-token
This package is auto-updated.
Last update: 2024-09-19 05:09:40 UTC
README
PHP语义版本检查器是一个控制台库,允许您检查一组前后源代码。
检查完成后,您将得到一个列表,其中包含两个更改集之间的变化,这些变化遵循语义版本化2.0.0。对于这些变化中的每一个,都将给出变化的级别(MAJOR、MINOR、PATCH),以及变化的地点(文件和行号),以及为什么建议这种级别变化的原因。
对于持续集成
如果您想在CI管道中使用php-semver-checker
,我们建议您查看php-semver-checker-git
,该工具与Git集成,并将比较您最新的更改与您存储库的最新Git标签。
语义版本化2.0.0概述
给定版本号MAJOR.MINOR.PATCH,在以下情况下增加:
- MAJOR版本,当您进行不兼容的API更改时,
- MINOR版本,当您以向后兼容的方式添加功能时,
- PATCH版本,当您进行向后兼容的错误修复时。
入门
由于这仍然是一个alpha软件包,不建议将php-semver-checker
直接包含在您的composer.json中。然而,有几种使用此工具的方法
- 推荐方法下载最新的.phar构建。请注意,.phar构建通常比以下方法更不前沿。
php composer.phar create-project tomzx/php-semver-checker --stability=dev
将在您的当前工作目录中克隆一个新的php-semver-checker文件夹git clone https://github.com/tomzx/php-semver-checker.git
然后在克隆的新目录中执行php composer.phar install
请参阅示例部分以了解如何使用此工具的示例。
构建php-semver-checker.phar
首先,确保您已安装box。然后,在基本目录中,您可以运行以下命令,这将生成php-semver-checker.phar
文件。
box build
当前规则集和验证码
请参阅docs/Ruleset.md
以获取当前支持(和即将到来)的规则集的详尽列表。
验证码是一种唯一标识语义版本化触发器(一个条件,检测到时,要求您的代码更改进行版本化)的方法。
示例
php bin/php-semver-checker compare tests/fixtures/before tests/fixtures/after Suggested semantic versioning change: MAJOR Class (MAJOR) +-------+--------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+------+ | Level | Location | Target | Reason | Code | +-------+--------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+------+ | MAJOR | tests\fixtures\before\ClassRemoved.php:5 | fixtures\ClassRemoved | Class was removed. | V005 | | MAJOR | tests\fixtures\after\ClassMethodAdded.php:7 | fixtures\ClassMethodAdded::publicMethod | [public] Method has been added. | V015 | | MAJOR | tests\fixtures\after\ClassMethodAdded.php:12 | fixtures\ClassMethodAdded::protectedMethod | [protected] Method has been added. | V016 | | MAJOR | tests\fixtures\after\ClassMethodParameterChanged.php:7 | fixtures\ClassMethodParameterChanged::publicMethod | [public] Method parameter changed. | V010 | | MAJOR | tests\fixtures\after\ClassMethodParameterChanged.php:12 | fixtures\ClassMethodParameterChanged::protectedMethod | [protected] Method parameter changed. | V011 | | MAJOR | tests\fixtures\before\ClassMethodRemoved.php:7 | fixtures\ClassMethodRemoved::publicMethod | [public] Method has been removed. | V006 | | MAJOR | tests\fixtures\before\ClassMethodRemoved.php:12 | fixtures\ClassMethodRemoved::protectedMethod | [protected] Method has been removed. | V007 | | MAJOR | tests\fixtures\after\ClassPropertyAdded.php:7 | fixtures\ClassPropertyAdded::$a | [public] Property has been added. | V019 | | MAJOR | tests\fixtures\after\ClassPropertyAdded.php:9 | fixtures\ClassPropertyAdded::$b | [protected] Property has been added. | V020 | | MAJOR | tests\fixtures\before\ClassPropertyRemoved.php:7 | fixtures\ClassPropertyRemoved::$a | [public] Property has been removed. | V008 | | MAJOR | tests\fixtures\before\ClassPropertyRemoved.php:9 | fixtures\ClassPropertyRemoved::$b | [protected] Property has been removed. | V009 | | MINOR | tests\fixtures\after\ClassAdded.php:5 | fixtures\ClassAdded | Class was added. | V014 | | PATCH | tests\fixtures\after\ClassMethodAdded.php:17 | fixtures\ClassMethodAdded::privateMethod | [private] Method has been added. | V028 | | PATCH | tests\fixtures\after\ClassMethodImplementationChanged.php:7 | fixtures\ClassMethodImplementationChanged::publicMethod | [public] Method implementation changed. | V023 | | PATCH | tests\fixtures\after\ClassMethodImplementationChanged.php:12 | fixtures\ClassMethodImplementationChanged::protectedMethod | [protected] Method implementation changed. | V024 | | PATCH | tests\fixtures\after\ClassMethodImplementationChanged.php:17 | fixtures\ClassMethodImplementationChanged::privateMethod | [private] Method implementation changed. | V025 | | PATCH | tests\fixtures\after\ClassMethodParameterChanged.php:17 | fixtures\ClassMethodParameterChanged::privateMethod | [private] Method parameter changed. | V031 | | PATCH | tests\fixtures\after\ClassMethodParameterNameChanged.php:7 | fixtures\ClassMethodParameterNameChanged::publicMethod | [public] Method parameter name changed. | V060 | | PATCH | tests\fixtures\after\ClassMethodParameterNameChanged.php:12 | fixtures\ClassMethodParameterNameChanged::protectedMethod | [protected] Method parameter name changed. | V061 | | PATCH | tests\fixtures\after\ClassMethodParameterNameChanged.php:17 | fixtures\ClassMethodParameterNameChanged::privateMethod | [private] Method parameter name changed. | V062 | | PATCH | tests\fixtures\before\ClassMethodRemoved.php:17 | fixtures\ClassMethodRemoved::privateMethod | [private] Method has been removed. | V029 | | PATCH | tests\fixtures\after\ClassPropertyAdded.php:11 | fixtures\ClassPropertyAdded::$c | [private] Property has been added. | V026 | | PATCH | tests\fixtures\before\ClassPropertyRemoved.php:11 | fixtures\ClassPropertyRemoved::$c | [private] Property has been removed. | V027 | +-------+--------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+------+ Function (MAJOR) +-------+----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------+------+ | Level | Location | Target | Reason | Code | +-------+----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------+------+ | MAJOR | tests\fixtures\before\FunctionRemoved.php:5 | fixtures\functionRemoved::functionRemoved | Function has been removed. | V001 | | MAJOR | tests\fixtures\before\FunctionParameterChanged.php:5 | fixtures\functionParameterChanged::functionParameterChanged | Function parameter changed. | V002 | | MINOR | tests\fixtures\after\FunctionAdded.php:5 | fixtures\functionAdded::functionAdded | Function has been added. | V003 | | PATCH | tests\fixtures\after\FunctionImplementationChanged.php:5 | fixtures\functionImplementationChanged::functionImplementationChanged | Function implementation changed. | V004 | | PATCH | tests\fixtures\before\FunctionParameterNameChanged.php:5 | fixtures\functionParameterNameChanged::functionParameterNameChanged | Function parameter name changed. | V067 | +-------+----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------+------+ Interface (MAJOR) +-------+---------------------------------------------------------------+------------------------------------------------------------+-----------------------------------------+------+ | Level | Location | Target | Reason | Code | +-------+---------------------------------------------------------------+------------------------------------------------------------+-----------------------------------------+------+ | MAJOR | tests\fixtures\before\InterfaceRemoved.php:5 | fixtures\InterfaceRemoved | Interface was removed. | V033 | | MAJOR | tests\fixtures\after\InterfaceMethodAdded.php:7 | fixtures\InterfaceMethodAdded::newMethod | [public] Method has been added. | V034 | | MAJOR | tests\fixtures\after\InterfaceMethodParameterChaged.php:7 | fixtures\InterfaceMethodParameterChanged::newMethod | [public] Method parameter changed. | V036 | | MAJOR | tests\fixtures\before\InterfaceMethodRemoved.php:7 | fixtures\InterfaceMethodRemoved::newMethod | [public] Method has been removed. | V035 | | MINOR | tests\fixtures\after\InterfaceAdded.php:5 | fixtures\InterfaceAdded | Interface was added. | V032 | | PATCH | tests\fixtures\after\InterfaceMethodParameterNameChaged.php:7 | fixtures\InterfaceMethodParameterNameChanged::publicMethod | [public] Method parameter name changed. | V063 | +-------+---------------------------------------------------------------+------------------------------------------------------------+-----------------------------------------+------+ Trait (MAJOR) +-------+--------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+------+ | Level | Location | Target | Reason | Code | +-------+--------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+------+ | MAJOR | tests\fixtures\before\TraitRemoved.php:5 | fixtures\TraitRemoved | Trait was removed. | V037 | | MAJOR | tests\fixtures\after\TraitMethodAdded.php:7 | fixtures\TraitMethodAdded::publicMethod | [public] Method has been added. | V047 | | MAJOR | tests\fixtures\after\TraitMethodAdded.php:12 | fixtures\TraitMethodAdded::protectedMethod | [protected] Method has been added. | V048 | | MAJOR | tests\fixtures\after\TraitMethodAdded.php:17 | fixtures\TraitMethodAdded::privateMethod | [private] Method has been added. | V057 | | MAJOR | tests\fixtures\after\TraitMethodParameterChanged.php:7 | fixtures\TraitMethodParameterChanged::publicMethod | [public] Method parameter changed. | V042 | | MAJOR | tests\fixtures\after\TraitMethodParameterChanged.php:12 | fixtures\TraitMethodParameterChanged::protectedMethod | [protected] Method parameter changed. | V043 | | MAJOR | tests\fixtures\after\TraitMethodParameterChanged.php:17 | fixtures\TraitMethodParameterChanged::privateMethod | [private] Method parameter changed. | V059 | | MAJOR | tests\fixtures\before\TraitMethodRemoved.php:7 | fixtures\TraitMethodRemoved::publicMethod | [public] Method has been removed. | V038 | | MAJOR | tests\fixtures\before\TraitMethodRemoved.php:12 | fixtures\TraitMethodRemoved::protectedMethod | [protected] Method has been removed. | V039 | | MAJOR | tests\fixtures\before\TraitMethodRemoved.php:17 | fixtures\TraitMethodRemoved::privateMethod | [private] Method has been removed. | V058 | | MAJOR | tests\fixtures\after\TraitPropertyAdded.php:7 | fixtures\TraitPropertyAdded::$a | [public] Property has been added. | V049 | | MAJOR | tests\fixtures\after\TraitPropertyAdded.php:9 | fixtures\TraitPropertyAdded::$b | [protected] Property has been added. | V050 | | MAJOR | tests\fixtures\after\TraitPropertyAdded.php:11 | fixtures\TraitPropertyAdded::$c | [private] Property has been added. | V055 | | MAJOR | tests\fixtures\before\TraitPropertyRemoved.php:7 | fixtures\TraitPropertyRemoved::$a | [public] Property has been removed. | V040 | | MAJOR | tests\fixtures\before\TraitPropertyRemoved.php:9 | fixtures\TraitPropertyRemoved::$b | [protected] Property has been removed. | V041 | | MAJOR | tests\fixtures\before\TraitPropertyRemoved.php:11 | fixtures\TraitPropertyRemoved::$c | [private] Property has been removed. | V056 | | MINOR | tests\fixtures\after\TraitAdded.php:5 | fixtures\TraitAdded | Trait was added. | V046 | | PATCH | tests\fixtures\after\TraitMethodImplementationChanged.php:7 | fixtures\TraitMethodImplementationChanged::publicMethod | [public] Method implementation changed. | V052 | | PATCH | tests\fixtures\after\TraitMethodImplementationChanged.php:12 | fixtures\TraitMethodImplementationChanged::protectedMethod | [protected] Method implementation changed. | V053 | | PATCH | tests\fixtures\after\TraitMethodImplementationChanged.php:17 | fixtures\TraitMethodImplementationChanged::privateMethod | [private] Method implementation changed. | V054 | | PATCH | tests\fixtures\after\TraitMethodParameterNameChanged.php:7 | fixtures\TraitMethodParameterNameChanged::publicMethod | [public] Method parameter name changed. | V064 | | PATCH | tests\fixtures\after\TraitMethodParameterNameChanged.php:12 | fixtures\TraitMethodParameterNameChanged::protectedMethod | [protected] Method parameter name changed. | V065 | | PATCH | tests\fixtures\after\TraitMethodParameterNameChanged.php:17 | fixtures\TraitMethodParameterNameChanged::privateMethod | [private] Method parameter name changed. | V066 | +-------+--------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+------+ [Scanned files] Before: 26, After: 27, Identical: 0 Time: 1.43 seconds, Memory: 5.123 MB
贡献
添加新规则
- 将规则添加到
docs/Ruleset.md
文档中 - 运行
php scripts/extract-rules-from-ruleset.php
以生成要粘贴到Configuration/LevelMapping.php
文件中的最新数组 - 更新文档https://github.com/tomzx/php-semver-checker-docs