Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions phpstan-baseline-7.4.neon
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,6 @@ parameters:
count: 1
path: src/lib/Repository/UserService.php

-
message: '#^Parameter \#1 \$array of function reset expects array\|object, null given\.$#'
identifier: argument.type
count: 3
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Parameter \#1 \$input of function array_keys expects array, string given\.$#'
identifier: argument.type
count: 3
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Parameter \#1 \$str of function trim expects string, bool\|float\|int\|string given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -466,9 +454,3 @@ parameters:
identifier: argument.type
count: 12
path: tests/lib/Repository/Service/Mock/UrlAliasTest.php

-
message: '#^Parameter \#1 \$array_arg of function key expects array\|object, string given\.$#'
identifier: argument.type
count: 4
path: tests/lib/Search/FieldNameResolverTest.php
12 changes: 0 additions & 12 deletions phpstan-baseline-gte-8.0.neon
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,6 @@ parameters:
count: 1
path: src/lib/Repository/UserService.php

-
message: '#^Parameter \#1 \$array of function array_keys expects array, string given\.$#'
identifier: argument.type
count: 3
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Parameter \#1 \$string of function trim expects string, bool\|float\|int\|string given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -460,9 +454,3 @@ parameters:
identifier: argument.type
count: 12
path: tests/lib/Repository/Service/Mock/UrlAliasTest.php

-
message: '#^Parameter \#1 \$array of function key expects array\|object, string given\.$#'
identifier: argument.type
count: 4
path: tests/lib/Search/FieldNameResolverTest.php
54 changes: 0 additions & 54 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26250,60 +26250,12 @@ parameters:
count: 1
path: src/lib/Search/Common/FieldNameGenerator.php

-
message: '#^Method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getAggregationFieldName\(\) should return string\|null but returns false\.$#'
identifier: return.type
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getFieldTypes\(\) should return array\<string, Ibexa\\Contracts\\Core\\Search\\FieldType\> but returns list\<mixed\>\.$#'
identifier: return.type
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getIndexFieldName\(\) should return string but returns array\<string, Ibexa\\Contracts\\Core\\Search\\FieldType\>\.$#'
identifier: return.type
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getIndexFieldName\(\) should return string but returns array\<string, null\>\.$#'
identifier: return.type
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getSearchableFieldMap\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getSortFieldName\(\) should return string\|null but returns false\.$#'
identifier: return.type
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Offset false does not exist on string\.$#'
identifier: offsetAccess.notFound
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Parameter \#1 \$criterionOrSortClause of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getIndexFieldName\(\) expects object, null given\.$#'
identifier: argument.type
count: 1
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Parameter \#5 \$name of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getIndexFieldName\(\) expects string, string\|null given\.$#'
identifier: argument.type
count: 2
path: src/lib/Search/Common/FieldNameResolver.php

-
message: '#^Access to an undefined property Ibexa\\Contracts\\Core\\Search\\FieldType\:\:\$raw\.$#'
identifier: property.notFound
Expand Down Expand Up @@ -74514,12 +74466,6 @@ parameters:
count: 1
path: tests/lib/Search/FieldNameResolverTest.php

-
message: '#^Parameter \#5 \$name of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getIndexFieldName\(\) expects string, null given\.$#'
identifier: argument.type
count: 4
path: tests/lib/Search/FieldNameResolverTest.php

-
message: '#^Property Ibexa\\Tests\\Core\\Search\\FieldNameResolverTest\:\:\$contentTypeHandlerMock \(Ibexa\\Contracts\\Core\\Persistence\\Content\\Type\\Handler&PHPUnit\\Framework\\MockObject\\MockObject\) in isset\(\) is not nullable\.$#'
identifier: isset.property
Expand Down
25 changes: 19 additions & 6 deletions src/lib/Search/Common/FieldNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getFieldNames(
* @param string|null $fieldTypeIdentifier
* @param string|null $name
*
* @return array<string, \Ibexa\Contracts\Core\Search\FieldType>
* @return array<string, \Ibexa\Contracts\Core\Search\FieldType|null>
*/
public function getFieldTypes(
Criterion $criterion,
Expand Down Expand Up @@ -163,6 +163,9 @@ public function getFieldTypes(

$fieldNames = array_keys($fieldNameWithSearchType);
$fieldName = reset($fieldNames);
if ($fieldName === false) {
continue;
}

$fieldTypeNameMap[$fieldName] = $fieldNameWithSearchType[$fieldName];
}
Expand Down Expand Up @@ -212,20 +215,25 @@ public function getSortFieldName(
true
));

return reset($fieldName);
$resolvedFieldName = reset($fieldName);
if ($resolvedFieldName === false) {
return null;
}

return $resolvedFieldName;
}

/**
* Returns index field name for the given parameters.
*
* @param object $criterionOrSortClause
* @param object|null $criterionOrSortClause
* @param string $contentTypeIdentifier
* @param string $fieldDefinitionIdentifier
* @param string $fieldTypeIdentifier
* @param string $name
* @param string|null $name
* @param bool $isSortField
*
* @return string
* @return array<string, \Ibexa\Contracts\Core\Search\FieldType|null>
*/
public function getIndexFieldName(
$criterionOrSortClause,
Expand Down Expand Up @@ -310,7 +318,12 @@ public function getAggregationFieldName(
)
);

return reset($fieldName);
$resolvedFieldName = reset($fieldName);
if ($resolvedFieldName === false) {
return null;
}

return $resolvedFieldName;
}
}

Expand Down
Loading