mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 23:41:57 +02:00
add MagicEventeDispatcher test case for RemoveExtraParametersRector
This commit is contained in:
parent
4a3fee7223
commit
b91749477f
@ -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);
|
||||
}
|
||||
}
|
@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user