psalm fixes

This commit is contained in:
Robin Appelman 2022-04-08 17:25:10 +02:00
commit 3d85afde98
6 changed files with 19 additions and 15 deletions

View file

@ -76,11 +76,11 @@ class SearchPlugin extends ServerPlugin {
/** /**
* SEARCH is allowed for users files * SEARCH is allowed for users files
* *
* @param string $uri * @param string $path
* @return array * @return array
*/ */
public function getHTTPMethods($uri) { public function getHTTPMethods($path) {
$path = $this->pathHelper->getPathFromUri($uri); $path = $this->pathHelper->getPathFromUri($path);
if ($this->searchBackend->getArbiterPath() === $path) { if ($this->searchBackend->getArbiterPath() === $path) {
return ['SEARCH']; return ['SEARCH'];
} else { } else {
@ -95,9 +95,9 @@ class SearchPlugin extends ServerPlugin {
} }
public function searchHandler(RequestInterface $request, ResponseInterface $response) { public function searchHandler(RequestInterface $request, ResponseInterface $response) {
$contentType = $request->getHeader('Content-Type'); $contentType = $request->getHeader('Content-Type') ?? '';
// Currently we only support xml search queries // Currently, we only support xml search queries
if ((strpos($contentType, 'text/xml') === false) && (strpos($contentType, 'application/xml') === false)) { if ((strpos($contentType, 'text/xml') === false) && (strpos($contentType, 'application/xml') === false)) {
return true; return true;
} }

View file

@ -41,14 +41,15 @@ class Operator {
* The type of operation, one of the Operator::OPERATION_* constants * The type of operation, one of the Operator::OPERATION_* constants
*/ */
public $type; public $type;
/** /**
* @var (Literal|SearchPropDefinition|Operation)[] * @var (Literal|\SearchDAV\Backend\SearchPropertyDefinition|Operator)[]
* *
* The list of arguments for the operation * The list of arguments for the operation
* *
* - SearchPropDefinition: property for comparison * - SearchPropDefinition: property for comparison
* - Literal: literal value for comparison * - Literal: literal value for comparison
* - Operation: nested operation for and/or/not operations * - Operator: nested operation for and/or/not operations
* *
* Which type and what number of argument an Operator takes depends on the operator type. * Which type and what number of argument an Operator takes depends on the operator type.
*/ */

View file

@ -38,7 +38,7 @@ class Query {
*/ */
public $from; public $from;
/** /**
* @var Operator * @var ?Operator
* *
* The search operator, either a comparison ('gt', 'eq', ...) or a boolean operator ('and', 'or', 'not') * The search operator, either a comparison ('gt', 'eq', ...) or a boolean operator ('and', 'or', 'not')
*/ */

View file

@ -42,7 +42,7 @@ class BasicSearch implements XmlDeserializable {
*/ */
public $from; public $from;
/** /**
* @var Operator * @var ?Operator
* *
* The search operator, either a comparison ('gt', 'eq', ...) or a boolean operator ('and', 'or', 'not') * The search operator, either a comparison ('gt', 'eq', ...) or a boolean operator ('and', 'or', 'not')
*/ */
@ -79,11 +79,11 @@ class BasicSearch implements XmlDeserializable {
throw new ParseException('Missing {DAV:}from when parsing {DAV:}basicsearch'); throw new ParseException('Missing {DAV:}from when parsing {DAV:}basicsearch');
} }
$search->select = isset($elements['{DAV:}select']) ? $elements['{DAV:}select'] : []; $search->select = $elements['{DAV:}select'] ?? [];
$search->from = $elements['{DAV:}from']; $search->from = $elements['{DAV:}from'];
$search->where = isset($elements['{DAV:}where']) ? $elements['{DAV:}where'] : null; $search->where = $elements['{DAV:}where'] ?? null;
$search->orderBy = isset($elements['{DAV:}orderby']) ? $elements['{DAV:}orderby'] : []; $search->orderBy = $elements['{DAV:}orderby'] ?? [];
$search->limit = isset($elements['{DAV:}limit']) ? $elements['{DAV:}limit'] : new Limit(); $search->limit = $elements['{DAV:}limit'] ?? new Limit();
return $search; return $search;
} }

View file

@ -33,7 +33,7 @@ class Operator implements XmlDeserializable {
*/ */
public $type; public $type;
/** /**
* @var (Literal|string|Operation)[] * @var (Literal|string|Operator)[]
* *
* The list of arguments for the operation * The list of arguments for the operation
* *
@ -59,7 +59,7 @@ class Operator implements XmlDeserializable {
static function xmlDeserialize(Reader $reader): Operator { static function xmlDeserialize(Reader $reader): Operator {
$operator = new self(); $operator = new self();
$operator->type = $reader->getClark(); $operator->type = $reader->getClark() ?? '';
if ($reader->isEmptyElement) { if ($reader->isEmptyElement) {
$reader->next(); $reader->next();
return $operator; return $operator;

View file

@ -39,6 +39,9 @@ class QueryDiscoverResponse extends Response {
* @param null|int|string $httpStatus * @param null|int|string $httpStatus
*/ */
function __construct($href, BasicSearchSchema $schema = null, $httpStatus = null) { function __construct($href, BasicSearchSchema $schema = null, $httpStatus = null) {
if ($httpStatus !== null) {
$httpStatus = (string)$httpStatus;
}
parent::__construct($href, [], $httpStatus); parent::__construct($href, [], $httpStatus);
$this->schema = $schema; $this->schema = $schema;