Merge pull request 'chore: Bump phpstan version' (#15) from CarlSchwan/SearchDAV:carl/bump-phpstan into master

Reviewed-on: https://codeberg.org/icewind/SearchDAV/pulls/15
Reviewed-by: Robin Appelman <icewind@noreply.codeberg.org>
This commit is contained in:
Robin Appelman 2026-07-15 14:17:25 +02:00
commit 34d37c11e6
6 changed files with 26 additions and 27 deletions

View file

@ -15,7 +15,7 @@
"require-dev": { "require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.0",
"friendsofphp/php-cs-fixer": "^2", "friendsofphp/php-cs-fixer": "^2",
"phpstan/phpstan": "^0.12", "phpstan/phpstan": "^2.2",
"psalm/phar": "^4.3", "psalm/phar": "^4.3",
"phpunit/phpunit": "^8" "phpunit/phpunit": "^8"
}, },
@ -34,6 +34,6 @@
"cs:check": "php-cs-fixer fix --dry-run --diff", "cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix", "cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar", "psalm": "psalm.phar",
"phpstan": "phpstan analyse --level 5 src" "phpstan": "phpstan analyse --level 6 src"
} }
} }

View file

@ -34,14 +34,9 @@ use SearchDAV\XML\QueryDiscoverResponse;
use SearchDAV\XML\Scope; use SearchDAV\XML\Scope;
class DiscoverHandler { class DiscoverHandler {
/** @var ISearchBackend */ private ISearchBackend $searchBackend;
private $searchBackend; private PathHelper $pathHelper;
private QueryParser $queryParser;
/** @var PathHelper */
private $pathHelper;
/** @var QueryParser */
private $queryParser;
/** /**
* @param ISearchBackend $searchBackend * @param ISearchBackend $searchBackend
@ -54,6 +49,9 @@ class DiscoverHandler {
$this->queryParser = $queryParser; $this->queryParser = $queryParser;
} }
/**
* @param array<string, mixed>|object|string $xml
*/
public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response): bool { public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response): bool {
if (!isset($xml['{DAV:}basicsearch'])) { if (!isset($xml['{DAV:}basicsearch'])) {
$response->setStatus(400); $response->setStatus(400);

View file

@ -25,13 +25,10 @@ use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Server; use Sabre\DAV\Server;
class PathHelper { class PathHelper {
/** @var Server */ private Server $server;
private $server;
/** /**
* PathHelper constructor. * PathHelper constructor.
*
* @param Server $server
*/ */
public function __construct(Server $server) { public function __construct(Server $server) {
$this->server = $server; $this->server = $server;
@ -42,7 +39,7 @@ class PathHelper {
return $uri; return $uri;
} }
try { try {
return ($uri === '' && $this->server->getBaseUri() === '/') ? '' : $this->server->calculateUri($uri); return $this->server->calculateUri($uri);
} catch (Forbidden $e) { } catch (Forbidden $e) {
return null; return null;
} }

View file

@ -34,6 +34,7 @@ use function Sabre\Xml\Deserializer\keyValue;
use function Sabre\Xml\Deserializer\repeatingElements; use function Sabre\Xml\Deserializer\repeatingElements;
class QueryParser extends Service { class QueryParser extends Service {
/** @var array<string, string> */
public $namespaceMap = [ public $namespaceMap = [
'DAV:' => 'd', 'DAV:' => 'd',
'http://sabredav.org/ns' => 's', 'http://sabredav.org/ns' => 's',

View file

@ -35,14 +35,9 @@ use SearchDAV\Query\Query;
use SearchDAV\XML\BasicSearch; use SearchDAV\XML\BasicSearch;
class SearchHandler { class SearchHandler {
/** @var ISearchBackend */ private ISearchBackend $searchBackend;
private $searchBackend; private PathHelper $pathHelper;
private Server $server;
/** @var PathHelper */
private $pathHelper;
/** @var Server */
private $server;
/** /**
* @param ISearchBackend $searchBackend * @param ISearchBackend $searchBackend
@ -55,6 +50,9 @@ class SearchHandler {
$this->server = $server; $this->server = $server;
} }
/**
* @param array<string, mixed>|object|string $xml
*/
public function handleSearchRequest($xml, ResponseInterface $response): bool { public function handleSearchRequest($xml, ResponseInterface $response): bool {
if (!isset($xml['{DAV:}basicsearch'])) { if (!isset($xml['{DAV:}basicsearch'])) {
$response->setStatus(400); $response->setStatus(400);
@ -168,7 +166,7 @@ class SearchHandler {
* @param SearchResult[] $results * @param SearchResult[] $results
* @param string[] $propertyNames * @param string[] $propertyNames
* @param int $depth * @param int $depth
* @return \Iterator<array> * @return \Iterator<array<string, mixed>>
*/ */
private function getPropertiesIteratorResults(array $results, array $propertyNames = [], int $depth = 0): \Iterator { private function getPropertiesIteratorResults(array $results, array $propertyNames = [], int $depth = 0): \Iterator {
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS; $propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;

View file

@ -31,13 +31,13 @@ use function Sabre\Xml\Deserializer\keyValue;
*/ */
class BasicSearch implements XmlDeserializable { class BasicSearch implements XmlDeserializable {
/** /**
* @var string[] * @var list<string>
* *
* The list of properties to be selected, specified in clark notation * The list of properties to be selected, specified in clark notation
*/ */
public $select; public $select;
/** /**
* @var Scope[] * @var list<Scope>
* *
* The collections to perform the search in * The collections to perform the search in
*/ */
@ -49,7 +49,7 @@ class BasicSearch implements XmlDeserializable {
*/ */
public $where; public $where;
/** /**
* @var Order[] * @var list<Order>
* *
* The list of order operations that should be used to order the results. * The list of order operations that should be used to order the results.
* *
@ -66,6 +66,11 @@ class BasicSearch implements XmlDeserializable {
*/ */
public $limit; public $limit;
/**
* @param list<string> $select
* @param list<Scope> $from
* @param list<Order> $orderBy
*/
public function __construct(array $select, array $from, ?Operator $where, array $orderBy, Limit $limit) { public function __construct(array $select, array $from, ?Operator $where, array $orderBy, Limit $limit) {
$this->select = $select; $this->select = $select;
$this->from = $from; $this->from = $from;