From 223fd4ae37ac4cfa70995330805c6a5a1007804b Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Fri, 27 Feb 2026 11:12:05 +0100 Subject: [PATCH 1/6] `MillisecondTimestamp`: Remove unused variable `$err` --- src/Behavior/MillisecondTimestamp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Behavior/MillisecondTimestamp.php b/src/Behavior/MillisecondTimestamp.php index 65d8033..70aa94b 100644 --- a/src/Behavior/MillisecondTimestamp.php +++ b/src/Behavior/MillisecondTimestamp.php @@ -31,7 +31,7 @@ public function toDb($value, $key, $context) if (! $value instanceof DateTime) { try { $value = new DateTime($value); - } catch (Exception $err) { + } catch (Exception) { throw new ValueConversionException(sprintf('Invalid date time format provided: %s', $value)); } } From 27b42b3ff4b97cca89f39e2643c7f4f1a825bad3 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 2 Mar 2026 08:08:10 +0100 Subject: [PATCH 2/6] `UnionModel`: Add strict type declarations This change required adjustments to the following dependencies: icingadb-web: - library/Icingadb/Model/ServicegroupSummary - library/Icingadb/Model/Hostgroupsummary icingaweb2-module-nagvis: - library/Nagvis/Model/HostgroupSummary - library/Nagvis/Model/ServicegroupSummary --- src/UnionModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UnionModel.php b/src/UnionModel.php index 5373bb9..d70c982 100644 --- a/src/UnionModel.php +++ b/src/UnionModel.php @@ -13,7 +13,7 @@ abstract class UnionModel extends Model * * @return UnionQuery */ - public static function on(Connection $db) + public static function on(Connection $db): UnionQuery { return (new UnionQuery()) ->setDb($db) @@ -25,5 +25,5 @@ public static function on(Connection $db) * * @return array */ - abstract public function getUnions(); + abstract public function getUnions(): array; } From 9ca1ef4df72e6cc8409bdb1688d14490cee8bdc5 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 2 Mar 2026 08:46:52 +0100 Subject: [PATCH 3/6] `ResultSet`: Add strict type declarations This change required adjustments to the following dependencies: icingadb-web: - library/Icingadb/Model/UnreachableParent/ResultSet - library/Icingadb/Redis/VolatileStateResults dependencies-web: requires no changes but depends on the icingadb-web changes --- src/ResultSet.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ResultSet.php b/src/ResultSet.php index d4a1123..6121826 100644 --- a/src/ResultSet.php +++ b/src/ResultSet.php @@ -3,23 +3,24 @@ namespace ipl\Orm; use ArrayIterator; +use Generator; use Iterator; use Traversable; class ResultSet implements Iterator { - protected $cache; + protected ArrayIterator $cache; /** @var bool Whether cache is disabled */ - protected $isCacheDisabled = false; + protected bool $isCacheDisabled = false; - protected $generator; + protected Generator $generator; - protected $limit; + protected ?int $limit; - protected $position; + protected ?int $position = null; - public function __construct(Traversable $traversable, $limit = null) + public function __construct(Traversable $traversable, ?int $limit = null) { $this->cache = new ArrayIterator(); $this->generator = $this->yieldTraversable($traversable); @@ -33,7 +34,7 @@ public function __construct(Traversable $traversable, $limit = null) * * @return static */ - public static function fromQuery(Query $query) + public static function fromQuery(Query $query): static { return new static($query->yieldResults(), $query->getLimit()); } @@ -45,25 +46,24 @@ public static function fromQuery(Query $query) * * @return $this */ - public function disableCache() + public function disableCache(): static { $this->isCacheDisabled = true; return $this; } - public function hasMore() + public function hasMore(): bool { return $this->generator->valid(); } - public function hasResult() + public function hasResult(): bool { return $this->generator->valid(); } - #[\ReturnTypeWillChange] - public function current() + public function current(): mixed { if ($this->position === null) { $this->advance(); @@ -117,7 +117,7 @@ public function rewind(): void } } - protected function advance() + protected function advance(): void { if (! $this->generator->valid()) { return; @@ -134,7 +134,7 @@ protected function advance() } } - protected function yieldTraversable(Traversable $traversable) + protected function yieldTraversable(Traversable $traversable): Generator { foreach ($traversable as $key => $value) { yield $key => $value; From 017a6350bc62dcc1f9a3788db2e7d7fb49e43ceb Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 2 Mar 2026 11:50:50 +0100 Subject: [PATCH 4/6] `RewriteFilterBehavior::rewriteCondition()`: Add strict type declarations This change required adjustments to the following dependencies: icingadb-web: - library/Icingadb/Model/CustomvarFlat - library/Icingadb/Model/Behavior/Bitmask - library/Icingadb/Model/BehaviorFlattenedObjectVars - library/Icingadb/Model/Behavior/HasProblematicParent - library/Icingadb/Model/Behavior/Reroute x509: - library/X509/Model/Behavior/ExpressionInjector notifications-web: - library/Notifications/Model/Behavior/IcingaCustomVars - library/Notifications/Model/Behavior/IdTagAggregator - library/Notifications/Model/Behavior/ObjectTags kubernetes-web: - library/Kubernetes/Model/Behavior/Uuid partnerportal: - library/Partnerportal/Model/Behavior/AggregatedColumn.php --- src/Behavior/Binary.php | 5 ++++- src/Contract/RewriteFilterBehavior.php | 6 +++--- tests/ApiIdentity.php | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Behavior/Binary.php b/src/Behavior/Binary.php index 43e3e11..365b5fb 100644 --- a/src/Behavior/Binary.php +++ b/src/Behavior/Binary.php @@ -9,6 +9,7 @@ use ipl\Orm\Query; use ipl\Sql\Adapter\Pgsql; use ipl\Stdlib\Filter\Condition; +use ipl\Stdlib\Filter\Rule; use UnexpectedValueException; use function ipl\Stdlib\get_php_type; @@ -72,7 +73,7 @@ public function setQuery(Query $query) return $this; } - public function rewriteCondition(Condition $condition, $relation = null) + public function rewriteCondition(Condition $condition, ?string $relation = null): null { /** * TODO(lippserd): Duplicate code because {@see RewriteFilterBehavior}s come after {@see PropertyBehavior}s. @@ -100,5 +101,7 @@ public function rewriteCondition(Condition $condition, $relation = null) } } } + + return null; } } diff --git a/src/Contract/RewriteFilterBehavior.php b/src/Contract/RewriteFilterBehavior.php index af6de5b..01cf5a0 100644 --- a/src/Contract/RewriteFilterBehavior.php +++ b/src/Contract/RewriteFilterBehavior.php @@ -17,9 +17,9 @@ interface RewriteFilterBehavior extends Behavior * Processing of the condition will be restarted, hence the column has to be an absolute path again. * * @param Filter\Condition $condition - * @param string $relation The absolute path (with a trailing dot) of the model + * @param ?string $relation The absolute path (with a trailing dot) of the model * - * @return Filter\Rule|null + * @return ?Filter\Rule */ - public function rewriteCondition(Filter\Condition $condition, $relation = null); + public function rewriteCondition(Filter\Condition $condition, ?string $relation = null): ?Filter\Rule; } diff --git a/tests/ApiIdentity.php b/tests/ApiIdentity.php index 99626e1..c5db2a3 100644 --- a/tests/ApiIdentity.php +++ b/tests/ApiIdentity.php @@ -9,6 +9,7 @@ use ipl\Orm\Model; use ipl\Orm\Relations; use ipl\Stdlib\Filter\Condition; +use ipl\Stdlib\Filter\Rule; class ApiIdentity extends Model { @@ -50,8 +51,9 @@ public function isSelectableColumn(string $name): bool return $name === 'api_token'; } - public function rewriteCondition(Condition $condition, $relation = null) + public function rewriteCondition(Condition $condition, ?string $relation = null): ?Rule { + return null; } }; From eba697ba1fb681e84df110f35028728ebd135b4f Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Wed, 4 Mar 2026 09:33:10 +0100 Subject: [PATCH 5/6] `RewriteColumnBehavior::rewriteColumn()`: Add strict type declarations This change required adjustments to the following dependencies: icingadb-web: - library/Icingadb/Model/Behavior/FlattenedObjectVars.php - library/Icingadb/Model/Behavior/HasProblematicParent.php icinga-notifications-web: - library/Notifications/Model/Behavior/IcingaCustomVars.php - library/Notifications/Model/Behavior/IdTagAggregator.php - library/Notifications/Model/Behavior/ObjectTags.php partnerportal: - library/Partnerportal/Model/Behavior/ActiveContracts.php - library/Partnerportal/Model/Behavior/NextContractEnd.php - library/Partnerportal/Model/Behavior/TotalContracts.php --- src/Contract/RewriteColumnBehavior.php | 2 +- tests/ApiIdentity.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Contract/RewriteColumnBehavior.php b/src/Contract/RewriteColumnBehavior.php index b6f545b..ad2fa4e 100644 --- a/src/Contract/RewriteColumnBehavior.php +++ b/src/Contract/RewriteColumnBehavior.php @@ -16,7 +16,7 @@ interface RewriteColumnBehavior extends RewriteFilterBehavior * * @return mixed */ - public function rewriteColumn($column, ?string $relation = null); + public function rewriteColumn(mixed $column, ?string $relation = null): mixed; /** * Get whether {@see rewriteColumn} might return an otherwise unknown column or expression diff --git a/tests/ApiIdentity.php b/tests/ApiIdentity.php index c5db2a3..d9fe1f0 100644 --- a/tests/ApiIdentity.php +++ b/tests/ApiIdentity.php @@ -34,12 +34,14 @@ public function getColumns() public function createBehaviors(Behaviors $behaviors) { $rewriteBehavior = new class () implements RewriteColumnBehavior { - public function rewriteColumn($column, $relation = null) + public function rewriteColumn(mixed $column, ?string $relation = null): ?AliasedExpression { if ($column === 'api_token') { $relation = str_replace('.', '_', $relation); return new AliasedExpression("{$relation}_api_token", '"api_token retrieval not permitted"'); } + + return null; } public function rewriteColumnDefinition(ColumnDefinition $def, string $relation): void From dad674df3c2d98ac60d830c0bb3cc22fcfdbfef5 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Wed, 4 Mar 2026 13:40:58 +0100 Subject: [PATCH 6/6] `QueryAwareBehavior::setQuery()`: Add strict type declarations The return type is also added for `Binary::setQuery()` This change required adjustments to the following dependencies: notifications-web: - library/Notifications/Model/Behavior/IdTagAggregator - library/Notifications/Model/Behavior/ObjectTags x509: - library/X509/Model/Behavior/ExpressionInjector - library/X509/Model/Behavior/Ip icingadb-web: - library/Icingadb/Model/Behavior/FlattenedObjectVars - library/Icingadb/Model/Behavior/HasProblematicParent --- src/Behavior/Binary.php | 2 +- src/Contract/QueryAwareBehavior.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Behavior/Binary.php b/src/Behavior/Binary.php index 365b5fb..b42ef64 100644 --- a/src/Behavior/Binary.php +++ b/src/Behavior/Binary.php @@ -66,7 +66,7 @@ public function toDb($value, $key, $_) return sprintf('\\x%s', bin2hex($value)); } - public function setQuery(Query $query) + public function setQuery(Query $query): static { $this->isPostgres = $query->getDb()->getAdapter() instanceof Pgsql; diff --git a/src/Contract/QueryAwareBehavior.php b/src/Contract/QueryAwareBehavior.php index b67bf51..b1b7b11 100644 --- a/src/Contract/QueryAwareBehavior.php +++ b/src/Contract/QueryAwareBehavior.php @@ -14,5 +14,5 @@ interface QueryAwareBehavior extends Behavior * * @return $this */ - public function setQuery(Query $query); + public function setQuery(Query $query): static; }