diff --git a/library/Notifications/Model/Behavior/ObjectTags.php b/library/Notifications/Model/Behavior/ObjectTags.php index d86ee72a..e466140f 100644 --- a/library/Notifications/Model/Behavior/ObjectTags.php +++ b/library/Notifications/Model/Behavior/ObjectTags.php @@ -68,12 +68,7 @@ public function rewriteColumn($column, $relation = null): AliasedExpression public function rewriteColumnDefinition(ColumnDefinition $def, string $relation): void { - $parts = explode('.', substr($relation, 0, -4)); - $objectType = array_pop($parts); - - $name = $def->getName(); - // Programmatically translated since the full definition is available in class ObjectSuggestions - $def->setLabel(sprintf(t(ucfirst($objectType) . ' %s', '..'), $name)); + $def->setLabel(ucfirst($def->getName())); } public function isSelectableColumn(string $name): bool diff --git a/library/Notifications/Model/ObjectExtraTag.php b/library/Notifications/Model/ObjectExtraTag.php index 0490c46a..fc172ab6 100644 --- a/library/Notifications/Model/ObjectExtraTag.php +++ b/library/Notifications/Model/ObjectExtraTag.php @@ -9,6 +9,13 @@ use ipl\Orm\Model; use ipl\Orm\Relations; +/** + * ObjectExtraTag database model + * + * @property int $object_id + * @property string $tag + * @property string $value + */ class ObjectExtraTag extends Model { public function getTableName() diff --git a/library/Notifications/Model/ObjectIdTag.php b/library/Notifications/Model/ObjectIdTag.php index 80a3b2b7..b0d33621 100644 --- a/library/Notifications/Model/ObjectIdTag.php +++ b/library/Notifications/Model/ObjectIdTag.php @@ -9,6 +9,13 @@ use ipl\Orm\Model; use ipl\Orm\Relations; +/** + * ObjectIdTag database model + * + * @property int $object_id + * @property string $tag + * @property string $value + */ class ObjectIdTag extends Model { public function getTableName(): string diff --git a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php index 50d6e50d..6ca9b208 100644 --- a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php @@ -104,7 +104,8 @@ protected function fetchValueSuggestions($column, $searchTerm, Filter\Chain $sea if (strpos($column, ' ') !== false) { // $column may be a label - list($path, $_) = Seq::find( + /** @var string $path */ + [$path, $_] = Seq::find( self::collectFilterColumns($query->getModel(), $query->getResolver()), $column, false @@ -185,7 +186,7 @@ protected function fetchColumnSuggestions($searchTerm) // Custom variables only after the columns are exhausted and there's actually a chance the user sees them foreach ([new ObjectIdTag(), new ObjectExtraTag()] as $model) { $titleAdded = false; - /** @var Model $tag */ + /** @var ObjectIdTag|ObjectExtraTag $tag */ foreach ($this->queryTags($model, $searchTerm) as $tag) { $isIdTag = $tag instanceof ObjectIdTag; @@ -199,9 +200,8 @@ protected function fetchColumnSuggestions($searchTerm) } $relation = $isIdTag ? 'object.tag' : 'object.extra_tag'; - $tagName = $tag->tag; - yield $relation . '.' . $tagName => $tagName; + yield $relation . '.' . $tag->tag => ucfirst($tag->tag); } } } diff --git a/phpstan-baseline-standard.neon b/phpstan-baseline-standard.neon index 863e0252..a0fc4a5c 100644 --- a/phpstan-baseline-standard.neon +++ b/phpstan-baseline-standard.neon @@ -1025,11 +1025,6 @@ parameters: count: 1 path: library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php - - - message: "#^Parameter \\#1 \\$path of method ipl\\\\Orm\\\\Resolver\\:\\:qualifyPath\\(\\) expects string, mixed given\\.$#" - count: 1 - path: library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php - - message: "#^Property Icinga\\\\Module\\\\Notifications\\\\Web\\\\Control\\\\SearchBar\\\\ObjectSuggestions\\:\\:\\$model \\(ipl\\\\Orm\\\\Model\\) does not accept object\\.$#" count: 1