Skip to content
Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"deepdiver1975/TarStreamer": "v0.1.0",
"doctrine/dbal": "2.7.2",
"guzzlehttp/guzzle": "6.3.3",
"icewind/searchdav": "1.0.1",
"icewind/searchdav": "1.0.2",
"icewind/streams": "v0.7.1",
"interfasys/lognormalizer": "^v1.0",
"jeremeamia/SuperClosure": "^2.4",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1315,27 +1315,27 @@
},
{
"name": "icewind/searchdav",
"version": "v1.0.1",
"version_normalized": "1.0.1.0",
"version": "v1.0.2",
"version_normalized": "1.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SearchDAV.git",
"reference": "b3fde1c79bc9c53f329f8ae1ee93d377903bf616"
"reference": "7174c023485c23037c6af786fce5a382fc72a75d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/icewind1991/SearchDAV/zipball/b3fde1c79bc9c53f329f8ae1ee93d377903bf616",
"reference": "b3fde1c79bc9c53f329f8ae1ee93d377903bf616",
"url": "https://api.github.com/repos/icewind1991/SearchDAV/zipball/7174c023485c23037c6af786fce5a382fc72a75d",
"reference": "7174c023485c23037c6af786fce5a382fc72a75d",
"shasum": ""
},
"require": {
"php": ">=5.6",
"php": ">=7.1",
"sabre/dav": "^3.2.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8"
},
"time": "2018-03-22T16:07:21+00:00",
"time": "2019-11-06T13:15:26+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/Backend/ISearchBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/Backend/SearchPropertyDefinition.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/Backend/SearchResult.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/DAV/DiscoverHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/DAV/PathHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/DAV/QueryParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
33 changes: 19 additions & 14 deletions icewind/searchdav/src/DAV/SearchHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -62,11 +62,6 @@ public function handleSearchRequest($xml, ResponseInterface $response) {
}
/** @var BasicSearch $query */
$query = $xml['{DAV:}basicsearch'];
if (!$query->where) {
$response->setStatus(400);
$response->setBody('Parse error: Missing {DAV:}where from {DAV:}basicsearch');
return false;
}
if (!$query->select) {
$response->setStatus(400);
$response->setBody('Parse error: Missing {DAV:}select from {DAV:}basicsearch');
Expand All @@ -89,7 +84,8 @@ public function handleSearchRequest($xml, ResponseInterface $response) {
$response->setBody($e->getMessage());
return false;
}
$data = $this->server->generateMultiStatus(iterator_to_array($this->getPropertiesIteratorResults($results, $query->select)), false);
$data = $this->server->generateMultiStatus(iterator_to_array($this->getPropertiesIteratorResults($results,
$query->select)), false);
$response->setBody($data);
return false;
}
Expand All @@ -98,9 +94,10 @@ public function handleSearchRequest($xml, ResponseInterface $response) {
* @param BasicSearch $xml
* @param SearchPropertyDefinition[] $allProps
* @return Query
* @throws BadRequest
*/
private function getQueryForXML(BasicSearch $xml, array $allProps) {
$orderBy = array_map(function(\SearchDAV\XML\Order $order) use ($allProps) {
$orderBy = array_map(function (\SearchDAV\XML\Order $order) use ($allProps) {
if (!isset($allProps[$order->property])) {
throw new BadRequest('requested order by property is not a valid property for this scope');
}
Expand All @@ -110,7 +107,7 @@ private function getQueryForXML(BasicSearch $xml, array $allProps) {
}
return new Order($prop, $order->order);
}, $xml->orderBy);
$select = array_map(function($propName) use ($allProps) {
$select = array_map(function ($propName) use ($allProps) {
if (!isset($allProps[$propName])) {
return;
}
Expand All @@ -122,13 +119,19 @@ private function getQueryForXML(BasicSearch $xml, array $allProps) {
}, $xml->select);
$select = array_filter($select);

$where = $this->transformOperator($xml->where, $allProps);
$where = $xml->where ? $this->transformOperator($xml->where, $allProps) : null;

return new Query($select, $xml->from, $where, $orderBy, $xml->limit);
}

/**
* @param \SearchDAV\XML\Operator $operator
* @param array $allProps
* @return Operator
* @throws BadRequest
*/
private function transformOperator(\SearchDAV\XML\Operator $operator, array $allProps) {
$arguments = array_map(function($argument) use ($allProps) {
$arguments = array_map(function ($argument) use ($allProps) {
if (is_string($argument)) {
if (!isset($allProps[$argument])) {
throw new BadRequest('requested search property is not a valid property for this scope');
Expand All @@ -138,10 +141,12 @@ private function transformOperator(\SearchDAV\XML\Operator $operator, array $all
throw new BadRequest('requested search property is not searchable');
}
return $prop;
} else if ($argument instanceof \SearchDAV\XML\Operator) {
return $this->transformOperator($argument, $allProps);
} else {
return $argument;
if ($argument instanceof \SearchDAV\XML\Operator) {
return $this->transformOperator($argument, $allProps);
} else {
return $argument;
}
}
}, $operator->arguments);

Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/DAV/SearchPlugin.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/Query/Limit.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/Query/Literal.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
Expand Down
4 changes: 2 additions & 2 deletions icewind/searchdav/src/Query/Operator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -60,7 +60,7 @@ class Operator {
* @param string $type
* @param array $arguments
*/
public function __construct($type = '', array $arguments = []) {
public function __construct(string $type = '', array $arguments = []) {
$this->type = $type;
$this->arguments = $arguments;
}
Expand Down
4 changes: 2 additions & 2 deletions icewind/searchdav/src/Query/Order.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -46,7 +46,7 @@ class Order {
* @param SearchPropertyDefinition $property
* @param string $order
*/
public function __construct(SearchPropertyDefinition $property, $order) {
public function __construct(SearchPropertyDefinition $property, string $order) {
$this->property = $property;
$this->order = $order;
}
Expand Down
6 changes: 3 additions & 3 deletions icewind/searchdav/src/Query/Query.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -65,11 +65,11 @@ class Query {
* Query constructor.
* @param SearchPropertyDefinition[] $select
* @param Scope[] $from
* @param Operator $where
* @param Operator|null $where
* @param Order[] $orderBy
* @param Limit $limit
*/
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->from = $from;
$this->where = $where;
Expand Down
4 changes: 2 additions & 2 deletions icewind/searchdav/src/Query/Scope.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -52,7 +52,7 @@ class Scope {
* @param int|string $depth
* @param string|null $path
*/
public function __construct($href = '', $depth = 1, $path = null) {
public function __construct(string $href = '', $depth = 1, string $path = null) {
$this->href = $href;
$this->depth = $depth;
$this->path = $path;
Expand Down
4 changes: 2 additions & 2 deletions icewind/searchdav/src/XML/BasicSearch.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -70,7 +70,7 @@ class BasicSearch implements XmlDeserializable {
* @return BasicSearch
* @throws ParseException
*/
static function xmlDeserialize(Reader $reader) {
static function xmlDeserialize(Reader $reader): BasicSearch {
$search = new self();

$elements = \Sabre\Xml\Deserializer\keyValue($reader);
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/XML/BasicSearchSchema.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down
4 changes: 2 additions & 2 deletions icewind/searchdav/src/XML/Limit.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -29,7 +29,7 @@
* The limit and offset of a search query
*/
class Limit extends \SearchDAV\Query\Limit implements XmlDeserializable {
static function xmlDeserialize(Reader $reader) {
static function xmlDeserialize(Reader $reader): Limit {
$limit = new self();

$elements = \Sabre\Xml\Deserializer\keyValue($reader);
Expand Down
11 changes: 8 additions & 3 deletions icewind/searchdav/src/XML/Literal.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
Expand Down Expand Up @@ -26,10 +26,15 @@
use Sabre\Xml\XmlDeserializable;

class Literal extends \SearchDAV\Query\Literal implements XmlDeserializable {
static function xmlDeserialize(Reader $reader) {
static function xmlDeserialize(Reader $reader): Literal {
$literal = new self();

$literal->value = $reader->readText();
if ($reader->isEmptyElement) {
$literal->value = '';
} else {
$literal->value = $reader->readText();
}

$reader->read();

return $literal;
Expand Down
Loading