diff --git a/rules/nette-kdyby/src/Naming/VariableNaming.php b/rules/nette-kdyby/src/Naming/VariableNaming.php index 21b36110210..272b2fce70c 100644 --- a/rules/nette-kdyby/src/Naming/VariableNaming.php +++ b/rules/nette-kdyby/src/Naming/VariableNaming.php @@ -68,7 +68,7 @@ final class VariableNaming $paramName = $this->nodeNameResolver->getName($node); if ($paramName !== null) { - return $paramName; + return StaticRectorStrings::underscoreToPascalCase($paramName); } if ($node instanceof String_) { diff --git a/rules/nette-kdyby/src/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector.php b/rules/nette-kdyby/src/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector.php index aadf81757b8..3ecb6e1f21b 100644 --- a/rules/nette-kdyby/src/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector.php +++ b/rules/nette-kdyby/src/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector.php @@ -194,6 +194,7 @@ PHP $shortEventClassName = $this->classNaming->getVariableName($eventClassName); $new = new New_(new FullyQualified($eventClassName)); + if ($methodCall->args) { $new->args = $methodCall->args; } diff --git a/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Fixture/fixture.php.inc b/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Fixture/fixture.php.inc index 4f88faec031..f9b86ccec18 100644 --- a/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Fixture/fixture.php.inc +++ b/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Fixture/fixture.php.inc @@ -13,7 +13,7 @@ final class SomeClass public function __construct(EventManager $eventManager) { - $this->eventManager = eventManager; + $this->eventManager = $eventManager; } public function run() @@ -40,7 +40,7 @@ final class SomeClass public function __construct(EventManager $eventManager) { - $this->eventManager = eventManager; + $this->eventManager = $eventManager; } public function run() diff --git a/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Fixture/duplicated_event_params.php.inc b/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Fixture/duplicated_event_params.php.inc index 6fb5f7b1140..ebf86434113 100644 --- a/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Fixture/duplicated_event_params.php.inc +++ b/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Fixture/duplicated_event_params.php.inc @@ -8,9 +8,9 @@ final class DuplicatedEventParams { public $onUpload; - public function run(SomeUser $user) + public function run(SomeUser $user, string $some_underscore) { - $this->onUpload($user['owner_id'], $user['name']); + $this->onUpload($user['owner_id'], $user['name'], $some_underscore); } } @@ -32,9 +32,9 @@ final class DuplicatedEventParams { $this->eventDispatcher = $eventDispatcher; } - public function run(SomeUser $user) + public function run(SomeUser $user, string $some_underscore) { - $duplicatedEventParamsUploadEvent = new \Rector\NetteKdyby\Tests\Rector\MethodCall\ReplaceMagicPropertyEventWithEventClassRector\Fixture\Event\DuplicatedEventParamsUploadEvent($user['owner_id'], $user['name']); + $duplicatedEventParamsUploadEvent = new \Rector\NetteKdyby\Tests\Rector\MethodCall\ReplaceMagicPropertyEventWithEventClassRector\Fixture\Event\DuplicatedEventParamsUploadEvent($user['owner_id'], $user['name'], $some_underscore); $this->eventDispatcher->dispatch($duplicatedEventParamsUploadEvent); } } diff --git a/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedDuplicatedEventParamsUploadEvent.php b/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedDuplicatedEventParamsUploadEvent.php index 7a26f64ddb2..9418f19868f 100644 --- a/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedDuplicatedEventParamsUploadEvent.php +++ b/rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source/ExpectedDuplicatedEventParamsUploadEvent.php @@ -12,10 +12,15 @@ final class DuplicatedEventParamsUploadEvent extends \Symfony\Contracts\EventDis * @var mixed */ private $userName; - public function __construct($userOwnerId, $userName) + /** + * @var string + */ + private $someUnderscore; + public function __construct($userOwnerId, $userName, string $someUnderscore) { $this->userOwnerId = $userOwnerId; $this->userName = $userName; + $this->someUnderscore = $someUnderscore; } public function getUserOwnerId() { @@ -25,4 +30,8 @@ final class DuplicatedEventParamsUploadEvent extends \Symfony\Contracts\EventDis { return $this->userName; } + public function getSomeUnderscore(): string + { + return $this->someUnderscore; + } }