Adds additional typehints to LotGD\Core\Tools\*
This commit is contained in:
@@ -20,7 +20,7 @@ trait Creator
|
||||
* @param array $arguments The values the instance should get
|
||||
* @throws AttributeMissingException
|
||||
* @throws WrongTypeException
|
||||
* @return \self The created Entity
|
||||
* @return CreateableInterface The created Entity
|
||||
*/
|
||||
public static function create(array $arguments): CreateableInterface
|
||||
{
|
||||
|
||||
@@ -15,12 +15,10 @@ trait ExtendableModel
|
||||
* @param mixed $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
public function __call(mixed $method, mixed $arguments)
|
||||
{
|
||||
$callback = ModelExtender::get(self::class, $method);
|
||||
|
||||
if ($callback) {
|
||||
return \call_user_func_array($callback, \array_merge([$this], $arguments));
|
||||
}
|
||||
return $callback(...[$this, ...$arguments]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use LotGD\Core\Game;
|
||||
*/
|
||||
trait GameAware
|
||||
{
|
||||
private $game;
|
||||
private Game $game;
|
||||
|
||||
/**
|
||||
* @param Game $game
|
||||
|
||||
@@ -19,7 +19,7 @@ trait MockCharacter
|
||||
* @param mixed $arguments
|
||||
* @throws IsNullException
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
public function __call(mixed $name, mixed $arguments)
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace LotGD\Core\Tools\Model;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use LotGD\Core\Models\CreateableInterface;
|
||||
use LotGD\Core\Models\SaveableInterface;
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@ trait Saveable
|
||||
{
|
||||
/**
|
||||
* Static, protected save function to call from trait-overwriting methods.
|
||||
* @param \LotGD\Core\Tools\Model\CreateableInterface $object
|
||||
* @param SaveableInterface $object
|
||||
* @param EntityManagerInterface $em
|
||||
*/
|
||||
public static function _save(SaveableInterface $object, EntityManagerInterface $em)
|
||||
|
||||
@@ -36,9 +36,9 @@ trait SoftDeletable
|
||||
|
||||
/**
|
||||
* Sets deletedAt to a specific date.
|
||||
* @param DateTime $deletedAt
|
||||
* @param ?DateTime $deletedAt
|
||||
*/
|
||||
public function setDeletedAt(DateTime $deletedAt = null)
|
||||
public function setDeletedAt(?DateTime $deletedAt = null)
|
||||
{
|
||||
$this->deletedAt = $deletedAt;
|
||||
}
|
||||
|
||||
@@ -17,14 +17,8 @@ use LotGD\Core\Exceptions\WrongTypeException;
|
||||
*/
|
||||
class OneToManyCollection implements Collection
|
||||
{
|
||||
/** @var string */
|
||||
private $typeClass;
|
||||
/** @var EntityManagerInterface */
|
||||
private $entityManager = null;
|
||||
/** @var array */
|
||||
private $collection;
|
||||
/** @var int */
|
||||
private $numberOfRows;
|
||||
private array $collection;
|
||||
private int $numberOfRows;
|
||||
|
||||
/**
|
||||
* Constructor for a one to many colelction of type $typeClass.
|
||||
@@ -32,15 +26,14 @@ class OneToManyCollection implements Collection
|
||||
* @param string $typeClass
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entityManager, string $typeClass)
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private string $typeClass
|
||||
) {
|
||||
if (\class_exists($typeClass) === false) {
|
||||
throw new ClassNotFoundException(\sprintf("The class %s has not been found.", $typeClass));
|
||||
}
|
||||
|
||||
$this->entityManager = $entityManager;
|
||||
$this->typeClass = $typeClass;
|
||||
|
||||
// Load eagerly everything.
|
||||
$this->collection = $this->entityManager->getRepository($this->typeClass)->findAll();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace LotGD\Core\Tools;
|
||||
*/
|
||||
class SceneDescription
|
||||
{
|
||||
private $description = [];
|
||||
private array $description = [];
|
||||
|
||||
/**
|
||||
* SceneDescription constructor.
|
||||
|
||||
Reference in New Issue
Block a user