-
-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Symfony 5.2] Add LogoutHandlerToLogoutEventSubscriberRector
- Loading branch information
1 parent
f515c8e
commit 0580c60
Showing
14 changed files
with
574 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
rules/symfony-code-quality/src/NodeFactory/EventReferenceFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\SymfonyCodeQuality\NodeFactory; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Expr\ClassConstFetch; | ||
use PhpParser\Node\Scalar\String_; | ||
use Rector\Core\PhpParser\Node\NodeFactory; | ||
use Rector\SymfonyCodeQuality\ValueObject\EventNameToClassAndConstant; | ||
|
||
final class EventReferenceFactory | ||
{ | ||
/** | ||
* @var NodeFactory | ||
*/ | ||
private $nodeFactory; | ||
|
||
public function __construct(NodeFactory $nodeFactory) | ||
{ | ||
$this->nodeFactory = $nodeFactory; | ||
} | ||
|
||
/** | ||
* @param EventNameToClassAndConstant[] $eventNamesToClassConstants | ||
* @return String_|ClassConstFetch | ||
*/ | ||
public function createEventName(string $eventName, array $eventNamesToClassConstants): Node | ||
{ | ||
if (class_exists($eventName)) { | ||
return $this->nodeFactory->createClassConstReference($eventName); | ||
} | ||
|
||
// is string a that could be caught in constant, e.g. KernelEvents? | ||
foreach ($eventNamesToClassConstants as $eventNameToClassConstant) { | ||
if ($eventNameToClassConstant->getEventName() !== $eventName) { | ||
continue; | ||
} | ||
|
||
return $this->nodeFactory->createClassConstFetch( | ||
$eventNameToClassConstant->getEventClass(), | ||
$eventNameToClassConstant->getEventConstant() | ||
); | ||
} | ||
|
||
return new String_($eventName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.