Find the best Rector rule to solve your problem. Searching through 675 rules.
Found 7 rules:
Turns method names to new ones.
$someObject = new SomeExampleClass;
-$someObject->oldMethod();
+$someObject->newMethod();
Replaces defined classes by new ones.
namespace App;
-use SomeOldClass;
+use SomeNewClass;
-function someFunction(SomeOldClass $someOldClass): SomeOldClass
+function someFunction(SomeNewClass $someOldClass): SomeNewClass
{
- if ($someOldClass instanceof SomeOldClass) {
- return new SomeOldClass;
+ if ($someOldClass instanceof SomeNewClass) {
+ return new SomeNewClass;
}
}
Simplify use of assertions in WebTestCase
use PHPUnit\Framework\TestCase;
class SomeClass extends TestCase
{
public function test()
{
- $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+ $this->assertResponseIsSuccessful();
}
}
Simplify use of assertions in WebTestCase
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class SomeClass extends WebTestCase
{
public function test()
{
- $response = self::getClient()->getResponse();
-
- $this->assertSame(301, $response->getStatusCode());
- $this->assertSame('https://example.com', $response->headers->get('Location'));
+ $this->assertResponseStatusCodeSame(301);
+ $this->assertResponseRedirects('https://example.com');
}
}
Change Twig template short name to bundle syntax in render calls from controllers
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BaseController extends Controller
{
function indexAction()
{
- $this->render('appBundle:Landing\Main:index.html.twig');
+ $this->render('@app/Landing/Main/index.html.twig');
}
}
Intl static bundle method were changed to direct static calls
-$currencyBundle = \Symfony\Component\Intl\Intl::getCurrencyBundle();
-
-$currencyNames = $currencyBundle->getCurrencyNames();
+$currencyNames = \Symfony\Component\Intl\Currencies::getNames();
Change TwigBundle FilesystemLoader to native one
-use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
-use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
-use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
+use Twig\Loader\FilesystemLoader;
-$filesystemLoader = new FilesystemLoader(new TemplateLocator(), new TemplateParser());
-$filesystemLoader->addPath(__DIR__ . '/some-directory');
+$fileSystemLoader = new FilesystemLoader([__DIR__ . '/some-directory']);