This Rector adds new default arguments in calls of defined methods and class types.
🔧 configure it!
<?php
declare(strict_types=1);
use Frosh\Rector\Rule\ClassMethod\AddArgumentToClassWithoutDefault;
use Frosh\Rector\Rule\ClassMethod\AddArgumentToClassWithoutDefaultRector;
use PHPStan\Type\ObjectType;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddArgumentToClassWithoutDefaultRector::class, [
new AddArgumentToClassWithoutDefault('SomeExampleClass', 'someMethod', 0, new ObjectType('SomeType'), 'someArgument'),
]);
};
↓
$someObject = new SomeExampleClass;
-$someObject->someMethod();
+$someObject->someMethod(true);
class MyCustomClass extends SomeExampleClass
{
- public function someMethod()
+ public function someMethod($value)
{
}
}
Adds banAll method to reverse proxy
class Test extends \Shopware\Core\Framework\Cache\ReverseProxy\AbstractReverseProxyGateway {
-
+ public function banAll(): void
+ {
+ }
}
Migrate extension metadata to state rector
-$context->addExtension(EntityIndexerRegistry::USE_INDEXING_QUEUE, new ArrayEntity());
+$context->addState(EntityIndexerRegistry::USE_INDEXING_QUEUE);
Move faker property to method call
-$this->faker->randomDigit
+$this->faker->randomDigit()
Replace UrlProviderInterface with AbstractClass
🔧 configure it!
<?php
declare(strict_types=1);
use Frosh\Rector\Rule\Class_\InterfaceReplacedWithAbstractClass;
use Frosh\Rector\Rule\Class_\InterfaceReplacedWithAbstractClassRector;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(InterfaceReplacedWithAbstractClassRector::class, [
new InterfaceReplacedWithAbstractClass('Foo', 'AbstractTest'),
]);
};
↓
-class Foo implements Test {
+class Foo extends AbstractTest {
}
NAME
🔧 configure it!
<?php
declare(strict_types=1);
use Frosh\Rector\Rule\ClassConstructor\MakeClassConstructorArgumentRequired;
use Frosh\Rector\Rule\ClassConstructor\MakeClassConstructorArgumentRequiredRector;
use PHPStan\Type\ArrayType;
use PHPStan\Type\StringType;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(MakeClassConstructorArgumentRequiredRector::class, [
new MakeClassConstructorArgumentRequired('Foo', 0, new ArrayType(new StringType(), new StringType())),
]);
};
↓
class Foo {
- public function __construct(array $foo = [])
+ public function __construct(array $foo)
{
}
}
NAME
class Foo
{
/**
- * @Route("/form/contact", name="frontend.form.contact.send", methods={"POST"}, defaults={"XmlHttpRequest"=true})
- * @Captcha
+ * @Route("/form/contact", name="frontend.form.contact.send", methods={"POST"}, defaults={"XmlHttpRequest"=true, "_captcha"=true})
*/
- public function sendContactForm()
+ public function sendContactForm(): Response
{
}
}
Migrates Annotations to Route annotation
-@LoginRequired
-@Route("/store-api/product", name="store-api.product.search", methods={"GET", "POST"})
+@Route("/store-api/product", name="store-api.product.search", methods={"GET", "POST"}, defaults={"_loginRequired"=true})
public function myAction()
NAME
/**
- * @RouteScope(scopes={"storefront"})
+ * @Route(defaults={"_routeScope"={"storefront"}})
*/
class Controller
{
}
This Rector removes an argument in the defined class construct.
🔧 configure it!
<?php
declare(strict_types=1);
use Frosh\Rector\Rule\ClassConstructor\RemoveArgumentFromClassConstruct;
use Frosh\Rector\Rule\ClassConstructor\RemoveArgumentFromClassConstructRector;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RemoveArgumentFromClassConstructRector::class, [
new RemoveArgumentFromClassConstruct('SomeExampleClass', 0),
]);
};
↓
-$someObject = new SomeExampleClass($example);
+$someObject = new SomeExampleClass();
Move single thumbnail generation call to batch
-$thumbnail->generateThumbnails($media, $context);
+$thumbnail->generate(new MediaCollection([$media]), $context);