Rector Rules for Ray.Di
The rector/rector rules for Ray.Di.
Install
composer require ray/rector-ray --dev
Rules
AnnotationBindingRector
This Rector converts annotation bindings in PHPDoc into parameter attribute bindings.
🔧 configure it!
- class:
AnnotationBindingRector
use PHPStan\Type\ObjectType;
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
use Rector\Arguments\ValueObject\ArgumentAdder;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
AnnotationBindingRector::class
);
};
↓
class SomeClass
{
/**
- * @Named("a=foo, b=bar")
* @Foo
*/
- public function __construct(int $a, int $b)
+ public function __construct(#[Named('foo')] int $a, #[Named('bar')] int $b)
{
}
- /**
- * @Foo("a")
- */
- public function __construct(int $a, int $b)
+ public function __construct(#[Foo] int $a, int $b)
{
}