add MagicEventeDispatcher test case for RemoveExtraParametersRector

This commit is contained in:
Tomas Votruba 2019-06-05 17:46:42 +02:00
parent 4a3fee7223
commit b91749477f
4 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?php
namespace Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Fixture;
use Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Source\MagicEventDispatcher;
final class SkipCommentedParamFuncGetArgs
{
public function run()
{
$magicEventDispatcher = new MagicEventDispatcher();
$magicEventDispatcher->dispatch(1, 2);
}
}

View File

@ -17,6 +17,7 @@ final class RemoveExtraParametersRectorTest extends AbstractRectorTestCase
__DIR__ . '/Fixture/static_calls.php.inc',
__DIR__ . '/Fixture/external_scope.php.inc',
__DIR__ . '/Fixture/static_call_parent.php.inc',
__DIR__ . '/Fixture/skip_commented_param_func_get_args.php.inc',
]);
}

View File

@ -0,0 +1,19 @@
<?php declare(strict_types=1);
namespace Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Source;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
final class MagicEventDispatcher
{
/**
* {@inheritdoc}
*
* @param string|null $eventName
*/
public function dispatch($event/*, string $eventName = null*/)
{
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null;
}
}

View File

@ -13,6 +13,7 @@ class KeepStringEventConstant
/** @var Event|CustomEvent $customEvent */
$customEvent = new CustomEvent();
$eventDispatcher->dispatch(CustomEvent::NAME, $customEvent);
$eventDispatcher->dispatch($customEvent, CustomEvent::NAME);
}
}
@ -24,6 +25,7 @@ namespace Rector\Symfony\Tests\Rector\MethodCall\MakeDispatchFirstArgumentEventR
use Rector\Symfony\Tests\Rector\MethodCall\MakeDispatchFirstArgumentEventRector\Source\CustomEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Contracts\EventDispatcher\Event;
class KeepStringEventConstant
{
@ -32,6 +34,7 @@ class KeepStringEventConstant
/** @var Event|CustomEvent $customEvent */
$customEvent = new CustomEvent();
$eventDispatcher->dispatch($customEvent, CustomEvent::NAME);
$eventDispatcher->dispatch($customEvent, CustomEvent::NAME);
}
}