Skip to content

Commit

Permalink
Add more missing docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Oct 27, 2021
1 parent 78f600e commit d599c6a
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 14 deletions.
13 changes: 13 additions & 0 deletions src/AuditManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
use Doctrine\ORM\EntityManager;
use SimpleThings\EntityAudit\EventListener\CreateSchemaListener;
use SimpleThings\EntityAudit\EventListener\LogRevisionsListener;
use SimpleThings\EntityAudit\Metadata\MetadataFactory;

/**
* Audit Manager grants access to metadata and configuration
* and has a factory method for audit queries.
*/
class AuditManager
{
/**
* @var AuditConfiguration
*/
private $config;

/**
* @var MetadataFactory
*/
private $metadataFactory;

public function __construct(AuditConfiguration $config)
Expand All @@ -34,11 +41,17 @@ public function __construct(AuditConfiguration $config)
$this->metadataFactory = $config->createMetadataFactory();
}

/**
* @return MetadataFactory
*/
public function getMetadataFactory()
{
return $this->metadataFactory;
}

/**
* @return AuditConfiguration
*/
public function getConfiguration()
{
return $this->config;
Expand Down
9 changes: 4 additions & 5 deletions src/AuditReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AuditReader
/**
* Entity cache to prevent circular references.
*
* @var array
* @var array<string, array<string, array<int|string, object>>>
*
* @phpstan-var array<class-string, array<string, array<int|string, T>>>
*/
Expand Down Expand Up @@ -217,7 +217,7 @@ public function clearEntityCache(): void
* @throws ORMException
* @throws \RuntimeException
*
* @return object
* @return object|null
*
* @phpstan-param class-string<T> $className
* @phpstan-return T|null
Expand Down Expand Up @@ -649,11 +649,10 @@ public function diff($className, $id, $oldRevision, $newRevision)
* @param string $className
* @param object $entity
*
* @return array
* @return array<string, mixed>
*
* @phpstan-param class-string<T> $className
* @phpstan-param T $entity
* @phpstan-return array<string, mixed>
*/
public function getEntityValues($className, $entity)
{
Expand All @@ -678,7 +677,7 @@ public function getEntityValues($className, $entity)
* @throws Exception
* @throws ORMException
*
* @return object[]
* @return array<object|null>
*
* @phpstan-param class-string<T> $className
* @phpstan-return array<T|null>
Expand Down
8 changes: 6 additions & 2 deletions src/ChangedEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ChangedEntity
/**
* @var string
*
* @phpstan-var class-string<T> $className
* @phpstan-var class-string<T>
*/
private $className;

Expand All @@ -38,7 +38,7 @@ class ChangedEntity
/**
* @var object
*
* @phpstan-var T $entity
* @phpstan-var T
*/
private $entity;

Expand All @@ -56,6 +56,8 @@ public function __construct(string $className, array $id, string $revType, objec

/**
* @return string
*
* @phpstan-return class-string<T>
*/
public function getClassName()
{
Expand All @@ -80,6 +82,8 @@ public function getRevisionType()

/**
* @return object
*
* @phpstan-return T
*/
public function getEntity()
{
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/CreateSchemaListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(AuditManager $auditManager)
}

/**
* @return array
* @return string[]
*/
public function getSubscribedEvents()
{
Expand Down
11 changes: 6 additions & 5 deletions src/EventListener/LogRevisionsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __construct(AuditManager $auditManager)
}

/**
* @return array
* @return string[]
*/
public function getSubscribedEvents()
{
Expand Down Expand Up @@ -305,6 +305,9 @@ private function getOriginalEntityData(object $entity): array
return $data;
}

/**
* @return string|int
*/
private function getRevisionId()
{
if (null === $this->revisionId) {
Expand Down Expand Up @@ -392,9 +395,7 @@ private function getInsertRevisionSQL(ClassMetadata $class): string
}

/**
* @param object[] $entityData
*
* @phpstan-param array<string, object> $entityData
* @param array<string, object> $entityData
*/
private function saveRevisionEntityData(ClassMetadata $class, array $entityData, string $revType): void
{
Expand Down Expand Up @@ -494,7 +495,7 @@ private function getHash(object $entity): string
* @author Rob Caiger <[email protected]>
* @author Simon Mönch <[email protected]>
*
* @phpstan-return array<string, array<string, mixed>>
* @return array<string, array<string, mixed>>
*/
private function prepareUpdateData(EntityPersister $persister, object $entity): array
{
Expand Down
8 changes: 7 additions & 1 deletion src/Metadata/MetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
class MetadataFactory
{
/**
* @phpstan-var array<class-string> $auditedEntities
* @var string[]
*
* @phpstan-var class-string[]
*/
private $auditedEntities = [];

Expand All @@ -31,6 +33,8 @@ public function __construct(array $auditedEntities)
}

/**
* @param string $entity
*
* @phpstan-param class-string $entity
*/
public function isAudited($entity)
Expand All @@ -39,6 +43,8 @@ public function isAudited($entity)
}

/**
* @return array<string, string|int>
*
* @phpstan-return array<class-string, string|int>
*/
public function getAllClassNames()
Expand Down
6 changes: 6 additions & 0 deletions src/Revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ public function getRev()
return $this->rev;
}

/**
* @return \DateTime
*/
public function getTimestamp()
{
return $this->timestamp;
}

/**
* @return string
*/
public function getUsername()
{
return $this->username;
Expand Down
2 changes: 2 additions & 0 deletions src/User/TokenStorageUsernameCallable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
class TokenStorageUsernameCallable
{
/**
* NEXT_MAJOR: Inject the required services instead of using the container.
*
* @var Container
*/
private $container;
Expand Down

0 comments on commit d599c6a

Please sign in to comment.