From 3d68874c2c2cf1e84f884712945135bdf1329ed7 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 11 Apr 2023 00:20:13 +0200 Subject: [PATCH] fix static analysis --- .../Database/Mapper/DataMapperFactory.php | 21 ++++++++++++++----- DataStorage/Database/Mapper/ReadMapper.php | 6 ++++-- Localization/Defaults/CityMapper.php | 3 +++ Localization/Defaults/CountryMapper.php | 3 +++ Localization/Defaults/CurrencyMapper.php | 3 +++ Localization/Defaults/IbanMapper.php | 3 +++ Localization/Defaults/LanguageMapper.php | 3 +++ .../Database/TestModel/ConditionalMapper.php | 3 +++ 8 files changed, 38 insertions(+), 7 deletions(-) diff --git a/DataStorage/Database/Mapper/DataMapperFactory.php b/DataStorage/Database/Mapper/DataMapperFactory.php index d424772e5..33c052adc 100755 --- a/DataStorage/Database/Mapper/DataMapperFactory.php +++ b/DataStorage/Database/Mapper/DataMapperFactory.php @@ -26,6 +26,8 @@ use phpOMS\DataStorage\Database\Query\Where; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T */ class DataMapperFactory { @@ -117,7 +119,7 @@ class DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = ''; @@ -195,13 +197,16 @@ class DataMapperFactory * * @param ConnectionAbstract $db Database connection * - * @return ReadMapper + * @return ReadMapper * * @since 1.0.0 */ public static function get(ConnectionAbstract $db = null) : ReadMapper { - return (new ReadMapper(new static(), $db ?? self::$db))->get(); + /** @var ReadMapper $reader */ + $reader = new ReadMapper(new static(), $db ?? self::$db); + + return $reader->get(); } /** @@ -215,7 +220,10 @@ class DataMapperFactory */ public static function getRaw(ConnectionAbstract $db = null) : ReadMapper { - return (new ReadMapper(new static(), $db ?? self::$db))->getRaw(); + /** @var ReadMapper $reader */ + $reader = new ReadMapper(new static(), $db ?? self::$db); + + return $reader->getRaw(); } /** @@ -271,7 +279,10 @@ class DataMapperFactory */ public static function getAll(ConnectionAbstract $db = null) : ReadMapper { - return (new ReadMapper(new static(), $db ?? self::$db))->getAll(); + /** @var ReadMapper $reader */ + $reader = new ReadMapper(new static(), $db ?? self::$db); + + return $reader->getAll(); } /** diff --git a/DataStorage/Database/Mapper/ReadMapper.php b/DataStorage/Database/Mapper/ReadMapper.php index 006062275..a5475a035 100755 --- a/DataStorage/Database/Mapper/ReadMapper.php +++ b/DataStorage/Database/Mapper/ReadMapper.php @@ -25,6 +25,8 @@ use phpOMS\Utils\ArrayUtils; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template R */ final class ReadMapper extends DataMapperAbstract { @@ -132,7 +134,7 @@ final class ReadMapper extends DataMapperAbstract * * @param mixed ...$options Options to pass to read mapper * - * @return mixed + * @return R * * @since 1.0.0 */ @@ -164,7 +166,7 @@ final class ReadMapper extends DataMapperAbstract * Careful, this doesn't merge with the internal query. * If you want to merge it use ->query() instead * - * @return object|array + * @return R * * @since 1.0.0 */ diff --git a/Localization/Defaults/CityMapper.php b/Localization/Defaults/CityMapper.php index 15a95e6ba..0cad99e43 100755 --- a/Localization/Defaults/CityMapper.php +++ b/Localization/Defaults/CityMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of City + * @extends DataMapperFactory */ class CityMapper extends DataMapperFactory { diff --git a/Localization/Defaults/CountryMapper.php b/Localization/Defaults/CountryMapper.php index 0f6704f0a..851d24d57 100755 --- a/Localization/Defaults/CountryMapper.php +++ b/Localization/Defaults/CountryMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Country + * @extends DataMapperFactory */ class CountryMapper extends DataMapperFactory { diff --git a/Localization/Defaults/CurrencyMapper.php b/Localization/Defaults/CurrencyMapper.php index 74371b036..d16c6805e 100755 --- a/Localization/Defaults/CurrencyMapper.php +++ b/Localization/Defaults/CurrencyMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Currency + * @extends DataMapperFactory */ final class CurrencyMapper extends DataMapperFactory { diff --git a/Localization/Defaults/IbanMapper.php b/Localization/Defaults/IbanMapper.php index ce568b5d9..7a6d6a4da 100755 --- a/Localization/Defaults/IbanMapper.php +++ b/Localization/Defaults/IbanMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Iban + * @extends DataMapperFactory */ class IbanMapper extends DataMapperFactory { diff --git a/Localization/Defaults/LanguageMapper.php b/Localization/Defaults/LanguageMapper.php index bf2380aef..d9b8d86a1 100755 --- a/Localization/Defaults/LanguageMapper.php +++ b/Localization/Defaults/LanguageMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Language + * @extends DataMapperFactory */ class LanguageMapper extends DataMapperFactory { diff --git a/tests/DataStorage/Database/TestModel/ConditionalMapper.php b/tests/DataStorage/Database/TestModel/ConditionalMapper.php index 58515beef..d4e87374e 100755 --- a/tests/DataStorage/Database/TestModel/ConditionalMapper.php +++ b/tests/DataStorage/Database/TestModel/ConditionalMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Conditional + * @extends DataMapperFactory */ final class ConditionalMapper extends DataMapperFactory {