ergebnis/rector-rules
Composer 安装命令:
composer require ergebnis/rector-rules
包简介
Provides rules for rector/rector.
README 文档
README
This project provides a composer package with rules for rector/rector.
Installation
Run
composer require --dev ergebnis/rector-rules
Rules
This project provides the following rules for rector/rector:
Ergebnis\Rector\Rules\Expressions\Arrays\SortAssociativeArrayByKeyRectorErgebnis\Rector\Rules\Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRectorErgebnis\Rector\Rules\Expressions\Matches\SortMatchArmsByConditionalRectorErgebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRectorErgebnis\Rector\Rules\Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRectorErgebnis\Rector\Rules\PHPUnit\ReplaceTestAttributeWithTestPrefixRector
Expressions\Arrays
Expressions\Arrays\SortAssociativeArrayByKeyRector
Sorts associative arrays by key.
$data = [ + 'bar' => [ + 'quux' => 'quuz', + 'quz' => 'qux', + ], 'foo' => [ 'foo', 'bar', 'baz', - ], - 'bar' => [ - 'quz' => 'qux', - 'quux' => 'quuz', ], ];
💡 Find out more in the rule documentation for Expressions\Arrays\SortAssociativeArrayByKeyRector.
Expressions\CallLikes
Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRector
Removes named arguments for single-parameter function and method calls.
-strlen(string: 'hello'); +strlen('hello');
💡 Find out more in the rule documentation for Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRector.
Expressions\Matches
Expressions\Matches\SortMatchArmsByConditionalRector
Sorts match arms by conditional when the conditionals are all integers or all strings.
match ($status) {
- 'pending' => handlePending(),
'active' => handleActive(),
'closed' => handleClosed(),
+ 'pending' => handlePending(),
};
💡 Find out more in the rule documentation for Expressions\Matches\SortMatchArmsByConditionalRector.
Faker
Faker\GeneratorPropertyFetchToMethodCallRector
Replaces references to deprecated properties of Faker\Generator with method calls.
-$faker->address; +$faker->address();
💡 Find out more in the rule documentation for Faker\GeneratorPropertyFetchToMethodCallRector.
Files
Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector
Replaces references to namespaced symbols (classes, functions, constants) whose fully-qualified name starts with a namespace prefix so they are relative to that prefix.
-use Foo\Bar; -use Foo\Bar\Baz\Qux; +use Foo\Bar\Baz; -new Bar\Baz\Qux\Quuz(); -new Qux\Quuz\Grauply(); +new Baz\Qux\Quuz(); +new Baz\Qux\Quuz\Grauply();
💡 Find out more in the rule documentation for Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector.
PHPUnit
PHPUnit\ReplaceTestAttributeWithTestPrefixRector
Replaces #[Test] attributes with test method prefixes.
use PHPUnit\Framework;
final class SomeTest extends Framework\TestCase
{
- #[Framework\Attributes\Test]
- public function onePlusOneShouldBeTwo(): void
+ public function testOnePlusOneShouldBeTwo(): void
{
self::assertSame(2, 1 + 1);
}
}
💡 Find out more in the rule documentation for PHPUnit\ReplaceTestAttributeWithTestPrefixRector.
Changelog
The maintainers of this project record notable changes to this project in a changelog.
Contributing
The maintainers of this project suggest following the contribution guide.
Code of Conduct
The maintainers of this project ask contributors to follow the code of conduct.
General Support Policy
The maintainers of this project provide limited support.
You can support the maintenance of this project by sponsoring @ergebnis.
PHP Version Support Policy
This project currently supports the following PHP versions:
- PHP 7.4 (has reached its end of life on November 28, 2022)
- PHP 8.0 (has reached its end of life on November 26, 2023)
- PHP 8.1 (has reached its end of life on December 31, 2025)
- PHP 8.2
- PHP 8.3
- PHP 8.4
- PHP 8.5
The maintainers of this project add support for a PHP version following its initial release and may drop support for a PHP version when it has reached its end of life.
Security Policy
This project has a security policy.
License
This project uses the MIT license.
Social
Follow @localheinz and @ergebnis on Twitter.
ergebnis/rector-rules 适用场景与选型建议
ergebnis/rector-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 249.59k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2023 年 09 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ergebnis/rector-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ergebnis/rector-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 249.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 9
- 依赖项目数: 36
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-30