Find the best Rector rule to solve your problem. Searching through 669 rules.
Found 10 rules:
Remove unused @var annotation for properties and class constants
final class SomeClass
{
- /**
- * @var string
- */
public string $name = 'name';
}
Remove useless @readonly annotation on native readonly type
final class SomeClass
{
- /**
- * @readonly
- */
private readonly string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}
Remove @return docblock with same type as defined in PHP
use stdClass;
class SomeClass
{
- /**
- * @return stdClass
- */
public function foo(): stdClass
{
}
}
Remove @param docblock with same type as parameter type
class SomeClass
{
/**
- * @param string $a
* @param string $b description
*/
public function foo(string $a, string $b)
{
}
}
Remove @var/@param/@return null docblock
class SomeClass
{
- /**
- * @return null
- */
public function foo()
{
return null;
}
}
Convert inline @var tags to calls to assert()
-/** @var Foo $foo */
-$foo = createFoo();
+$foo = createFoo();
+assert($foo instanceof Foo);
It will removes the dump data just like dd or dump functions from the code.`
class MyController
{
public function store()
{
- dd('test');
return true;
}
public function update()
{
- dump('test');
return true;
}
}
Replace calls to get_class() and get_parent_class() without arguments with self::class and parent::class.
class Example extends StdClass {
public function whoAreYou() {
- return get_class() . ' daughter of ' . get_parent_class();
+ return self::class . ' daughter of ' . parent::class;
}
}
Remove extra parameters
-strlen("asdf", 1);
+strlen("asdf");
Remove parameter of method call
final class SomeClass
{
public function run(Caller $caller)
{
- $caller->process(1, 2);
+ $caller->process(1);
}
}