Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\NetteKdyby\Rector\MethodCall;

use Nette\Application\UI\Control;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Assign;
Expand Down Expand Up @@ -168,6 +169,11 @@ private function isLocalOnPropertyCall(MethodCall $methodCall): bool
return false;
}

// control event, inner only
if (is_a($className, Control::class, true)) {
return false;
}

if (method_exists($className, $methodName)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Rector\NetteKdyby\Tests\Rector\MethodCall\ReplaceMagicPropertyEventWithEventClassRector\Fixture;

use Nette\Application\UI\Control;
use Rector\NetteKdyby\Tests\Rector\MethodCall\ReplaceMagicPropertyEventWithEventClassRector\Source\SomeUser;

final class SkipOnSuccessInControl extends Control
{
public $onSuccess = [];

public $onBeforeSuccess = [];

public function run(SomeUser $user)
{
$this->onSuccess($user, 'run');

$this->onBeforeSuccess($user, 'run');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@

final class ReplaceMagicPropertyEventWithEventClassRectorTest extends AbstractRectorTestCase
{
public function test(): void
public function testSkip(): void
{
$this->doTestFile(__DIR__ . '/Fixture/fixture.php.inc');
$this->doTestFile(__DIR__ . '/Fixture/skip_on_success_in_control.php.inc');
}

public function testSimpleEvent(): void
{
$this->doTestFile(__DIR__ . '/Fixture/simple_event.php.inc');

$expectedEventFilePath = dirname($this->originalTempFile) . '/Event/FileManagerUploadEvent.php';
$this->assertFileExists($expectedEventFilePath);
Expand Down