-
-
Notifications
You must be signed in to change notification settings - Fork 699
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 (#5337)
- Loading branch information
1 parent
a54819a
commit e0db712
Showing
23 changed files
with
597 additions
and
98 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
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); | ||
} | ||
} |
Oops, something went wrong.