diff --git a/LICENSE b/LICENSE index 912f02b..0fe04f5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2025 Aternos GmbH +Copyright (c) 2018-2026 Aternos GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/BaseModel.php b/src/BaseModel.php index 843efb3..c4cb04a 100644 --- a/src/BaseModel.php +++ b/src/BaseModel.php @@ -104,10 +104,11 @@ public function setId(mixed $id): static } /** - * Generate an unique identifier for the model + * Generate a unique identifier for the model */ - protected function generateId() + protected function generateId(): void { + /** @noinspection SpellCheckingInspection */ $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $charactersLength = strlen($characters); do { diff --git a/src/Driver/DriverRegistry.php b/src/Driver/DriverRegistry.php index 9817926..c6298d9 100644 --- a/src/Driver/DriverRegistry.php +++ b/src/Driver/DriverRegistry.php @@ -2,8 +2,8 @@ namespace Aternos\Model\Driver; -use Aternos\Model\Driver\OpenSearch\OpenSearch; use Aternos\Model\Driver\Mysqli\Mysqli; +use Aternos\Model\Driver\OpenSearch\OpenSearch; use Aternos\Model\Driver\Redis\Redis; use Aternos\Model\Driver\Test\TestDriver; use InvalidArgumentException; @@ -34,10 +34,12 @@ class DriverRegistry implements DriverRegistryInterface * Register a driver object by ID * * @param DriverInterface $driver + * @return $this */ - public function registerDriver(DriverInterface $driver) + public function registerDriver(DriverInterface $driver): static { $this->drivers[$driver->getId()] = $driver; + return $this; } /** @@ -47,10 +49,12 @@ public function registerDriver(DriverInterface $driver) * * @param string $id * @param string $class + * @return $this */ - public function registerDriverClass(string $id, string $class) + public function registerDriverClass(string $id, string $class): static { $this->classes[$id] = $class; + return $this; } /** diff --git a/src/Driver/Mysqli/MysqlConnectionFailedException.php b/src/Driver/Mysqli/MysqlConnectionFailedException.php index 7f25df5..d9efdd9 100644 --- a/src/Driver/Mysqli/MysqlConnectionFailedException.php +++ b/src/Driver/Mysqli/MysqlConnectionFailedException.php @@ -8,6 +8,6 @@ class MysqlConnectionFailedException extends MysqlException { public function __construct(Throwable $previous) { - parent::__construct("Could not connect to Mysqli database", $previous?->getCode(), $previous); + parent::__construct("Could not connect to Mysqli database", $previous->getCode(), $previous); } } diff --git a/src/Driver/Test/TestTableEntry.php b/src/Driver/Test/TestTableEntry.php index f0633ca..18e1761 100644 --- a/src/Driver/Test/TestTableEntry.php +++ b/src/Driver/Test/TestTableEntry.php @@ -2,13 +2,14 @@ namespace Aternos\Model\Driver\Test; +use ArrayAccess; use Aternos\Model\ModelInterface; use Aternos\Model\Query\SelectField; use Aternos\Model\Query\UpdateField; use Aternos\Model\Query\WhereCondition; use Aternos\Model\Query\WhereGroup; -class TestTableEntry implements \ArrayAccess +class TestTableEntry implements ArrayAccess { public function __construct(protected array $data) { diff --git a/src/GenericModel.php b/src/GenericModel.php index 9197b36..d29cef0 100644 --- a/src/GenericModel.php +++ b/src/GenericModel.php @@ -5,7 +5,6 @@ use Aternos\Model\Driver\DriverInterface; use Aternos\Model\Driver\DriverRegistry; use Aternos\Model\Driver\DriverRegistryInterface; -use Aternos\Model\Driver\Test\TestDriver; use Aternos\Model\Driver\Features\CacheableInterface; use Aternos\Model\Driver\Features\DeletableInterface; use Aternos\Model\Driver\Features\DeleteQueryableInterface; @@ -18,6 +17,7 @@ use Aternos\Model\Driver\Features\UpdateQueryableInterface; use Aternos\Model\Driver\Mysqli\Mysqli; use Aternos\Model\Driver\Redis\Redis; +use Aternos\Model\Driver\Test\TestDriver; use Aternos\Model\Query\CountField; use Aternos\Model\Query\DeleteQuery; use Aternos\Model\Query\GroupField; diff --git a/src/ModelCollection.php b/src/ModelCollection.php index cea2ef8..d45f0d2 100644 --- a/src/ModelCollection.php +++ b/src/ModelCollection.php @@ -31,11 +31,12 @@ public function __construct(array $models = []) * Add a model * * @param TModel $model - * @noinspection PhpDocSignatureInspection + * @return static */ - public function add(ModelInterface $model) + public function add(ModelInterface $model): static { $this->models[] = $model; + return $this; } /** diff --git a/src/Query/Generator/SQL.php b/src/Query/Generator/SQL.php index 5a57cdf..8c0509f 100644 --- a/src/Query/Generator/SQL.php +++ b/src/Query/Generator/SQL.php @@ -45,6 +45,7 @@ class SQL implements QueryGeneratorInterface * Callback function to escape values * * @var callable|string + * @noinspection SpellCheckingInspection */ public $escapeFunction = "addslashes"; diff --git a/src/Query/Query.php b/src/Query/Query.php index 4463101..76e275b 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -4,7 +4,6 @@ use Aternos\Model\ModelInterface; use InvalidArgumentException; -use UnexpectedValueException; /** * Class Query diff --git a/src/Query/WhereGroup.php b/src/Query/WhereGroup.php index 7250924..82f860b 100644 --- a/src/Query/WhereGroup.php +++ b/src/Query/WhereGroup.php @@ -54,10 +54,12 @@ public function __construct(array $conditions = [], int $conjunction = self:: AN * Add an element to the group * * @param WhereCondition|WhereGroup $conditionOrGroup + * @return $this */ - public function add(WhereCondition|WhereGroup $conditionOrGroup) + public function add(WhereCondition|WhereGroup $conditionOrGroup): static { $this->group[] = $conditionOrGroup; + return $this; } /**