Skip to content

Commit

Permalink
Convert some type hints into type declarations at LogRevisionsListener
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Jul 25, 2021
1 parent a06839e commit 09c5245
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/EventListener/LogRevisionsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class LogRevisionsListener implements EventSubscriber
private $quoteStrategy;

/**
* @var array
* @var string[]
*
* @phpstan-var array<string, string>
*/
private $insertRevisionSQL = [];

Expand All @@ -80,7 +82,9 @@ class LogRevisionsListener implements EventSubscriber
private $revisionId;

/**
* @var array
* @var object[]
*
* @phpstan-var array<string, object>
*/
private $extraUpdates = [];

Expand Down Expand Up @@ -283,13 +287,9 @@ public function onFlush(OnFlushEventArgs $eventArgs): void
}

/**
* get original entity data, including versioned field, if "version" constraint is used.
*
* @param mixed $entity
*
* @return array
* Get original entity data, including versioned field, if "version" constraint is used.
*/
private function getOriginalEntityData($entity)
private function getOriginalEntityData(object $entity): array
{
$class = $this->em->getClassMetadata(\get_class($entity));
$data = $this->uow->getOriginalEntityData($entity);
Expand Down Expand Up @@ -327,13 +327,9 @@ private function getRevisionId()
}

/**
* @param ClassMetadata $class
*
* @throws \Doctrine\DBAL\DBALException
*
* @return string
*/
private function getInsertRevisionSQL($class)
private function getInsertRevisionSQL(ClassMetadata $class): string
{
if (!isset($this->insertRevisionSQL[$class->name])) {
$placeholders = ['?', '?'];
Expand Down Expand Up @@ -392,11 +388,11 @@ private function getInsertRevisionSQL($class)
}

/**
* @param ClassMetadata $class
* @param array $entityData
* @param string $revType
* @param object[] $entityData
*
* @phpstan-param array<string, object> $entityData
*/
private function saveRevisionEntityData($class, $entityData, $revType): void
private function saveRevisionEntityData(ClassMetadata $class, array $entityData, string $revType): void
{
$params = [$this->getRevisionId(), $revType];
$types = [\PDO::PARAM_INT, \PDO::PARAM_STR];
Expand Down

0 comments on commit 09c5245

Please sign in to comment.