Find the best Rector rule to solve your problem. Searching through 661 rules.
Found 7 rules:
Make event object a first argument of dispatch() method, event name as second
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class SomeClass
{
public function run(EventDispatcherInterface $eventDispatcher)
{
- $eventDispatcher->dispatch('event_name', new Event());
+ $eventDispatcher->dispatch(new Event(), 'event_name');
}
}
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']);
Removes parent construct method call in EventDispatcher class
use Symfony\Component\EventDispatcher\EventDispatcher;
final class SomeEventDispatcher extends EventDispatcher
{
public function __construct()
{
$value = 1000;
+ parent::__construct();
}
}