becklyn/rector
最新稳定版本:1.0.1
Composer 安装命令:
composer require becklyn/rector
包简介
A collection of various refactoring rules for projects that use Rector and mainly Symfony
README 文档
README
This package contains a list of Rector rules that help you up-grading your Symfony-based code base and keeping it deprecation-free.
Installation
Easily get this package via Composer: composer require --dev becklyn/rector
Usage
Add the rules that you want
This bundle uses a default AJAX protocol, that is used in the AjaxResponseBuilder and can be used for your
project. The ajax call will always return an error 200, as it shouldn't flood the error tracking (with error 400
AJAX request).
The protocol looks like this:
// rector.php use Becklyn\Rector\Symfony\ReplaceControllerThisGetWithThisContainerGet; use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { // … $rectorConfig->rule(ReplaceControllerThisGetWithThisContainerGet::class); // … };
Available rules
Becklyn\\Rector\\Symfony\\ReplaceControllerThisGetWithThisContainerGet
Controllers that were trying to access dependencies via $this->get(…) will be refactored to use $this->container->get(…).
Before:
class ExtendingAbstractController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { public function run() { $this->get(SomeClass::class); } public function runFaster() { $service = $this->get(SomeOtherClass::class); } public function runEvenFaster() { return $this->get(BestClass::class); } }
After:
class ExtendingAbstractController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { public function run() { $this->container->get(SomeClass::class); } public function runFaster() { $service = $this->container->get(SomeOtherClass::class); } public function runEvenFaster() { return $this->container->get(BestClass::class); } }
统计信息
- 总下载量: 4.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-10