Commit 6193f3fb authored by crell's avatar crell Committed by Stefan Bürk
Browse files

[TASK] Address type issues in FileSearchQuery

The $result property's doc type is causing issues
for PHPStan. Switching it to a typed property and
state resolves them.

Other types have been filled in as well as they're
private so safe.

Used command:

> ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #98002
Releases: main, 11.5
Change-Id: Ic960858eee4cd40ed010762a44dec944f5114e4a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75263

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Simon Schaufelberger's avatarSimon Schaufelberger <simonschaufi+typo3@gmail.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Simon Schaufelberger's avatarSimon Schaufelberger <simonschaufi+typo3@gmail.com>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
parent b732d6e9
......@@ -1075,11 +1075,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Classes/Resource/ResourceStorage.php
-
message: "#^If condition is always true\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/Resource/Search/FileSearchQuery.php
-
message: "#^Argument of an invalid type TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Index\\\\ExtractorInterface supplied for foreach, only iterables are supported\\.$#"
count: 1
......
......@@ -40,20 +40,14 @@ class FileSearchQuery
private const FILES_META_TABLE = 'sys_file_metadata';
/**
* @var QueryBuilder
*/
private $queryBuilder;
private QueryBuilder $queryBuilder;
/**
* @var QueryRestrictionInterface[]
*/
private $additionalRestrictions = [];
private array $additionalRestrictions = [];
/**
* @var Result
*/
private $result;
private ?Result $result = null;
public function __construct(QueryBuilder $queryBuilder = null)
{
......@@ -209,7 +203,7 @@ class FileSearchQuery
private function ensureQueryNotExecuted(): void
{
if ($this->result) {
if ($this->result !== null) {
throw new \RuntimeException('Cannot modify file query once it was executed. Create a new query instead.', 1555944032);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment