more types

This commit is contained in:
Robin Appelman 2022-04-08 17:36:08 +02:00
commit d3eb42cd90
14 changed files with 32 additions and 34 deletions

View file

@ -54,7 +54,7 @@ class DiscoverHandler {
$this->queryParser = $queryParser;
}
public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response) {
public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response): bool {
if (!isset($xml['{DAV:}basicsearch'])) {
$response->setStatus(400);
$response->setBody('Unexpected xml content for query-schema-discovery, expected basicsearch');

View file

@ -37,7 +37,7 @@ class PathHelper {
$this->server = $server;
}
public function getPathFromUri($uri): ?string {
public function getPathFromUri(string $uri): ?string {
if (strpos($uri, '://') === false) {
return $uri;
}

View file

@ -55,7 +55,7 @@ class SearchHandler {
$this->server = $server;
}
public function handleSearchRequest($xml, ResponseInterface $response) {
public function handleSearchRequest($xml, ResponseInterface $response): bool {
if (!isset($xml['{DAV:}basicsearch'])) {
$response->setStatus(400);
$response->setBody('Unexpected xml content for searchrequest, expected basicsearch');
@ -129,7 +129,7 @@ class SearchHandler {
/**
* @param \SearchDAV\XML\Operator $operator
* @param array $allProps
* @param SearchPropertyDefinition[] $allProps
* @return Operator
* @throws BadRequest
*/
@ -166,11 +166,11 @@ class SearchHandler {
* If a depth of 1 is requested child elements will also be returned.
*
* @param SearchResult[] $results
* @param array $propertyNames
* @param string[] $propertyNames
* @param int $depth
* @return \Iterator
* @return \Iterator<array>
*/
private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0): \Iterator {
private function getPropertiesIteratorResults(array $results, array $propertyNames = [], int $depth = 0): \Iterator {
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;
$this->searchBackend->preloadPropertyFor(array_map(function (SearchResult $result): INode {
@ -179,7 +179,7 @@ class SearchHandler {
foreach ($results as $result) {
$node = $result->node;
$propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType);
$propFind = new PropFind($result->href, $propertyNames, $depth, $propFindType);
$r = $this->server->getPropertiesByNode($propFind, $node);
if ($r) {
$result = $propFind->getResultForMultiStatus();

View file

@ -57,7 +57,7 @@ class SearchPlugin extends ServerPlugin {
$this->queryParser = new QueryParser();
}
public function initialize(Server $server) {
public function initialize(Server $server): void {
$this->server = $server;
$this->pathHelper = new PathHelper($server);
$this->search = new SearchHandler($this->searchBackend, $this->pathHelper, $server);
@ -67,7 +67,7 @@ class SearchPlugin extends ServerPlugin {
$server->on('propFind', [$this, 'propFindHandler']);
}
public function propFindHandler(PropFind $propFind, INode $node) {
public function propFindHandler(PropFind $propFind, INode $node): void {
if ($propFind->getPath() === $this->searchBackend->getArbiterPath()) {
$propFind->handle('{DAV:}supported-query-grammar-set', new SupportedQueryGrammar());
}
@ -77,9 +77,9 @@ class SearchPlugin extends ServerPlugin {
* SEARCH is allowed for users files
*
* @param string $path
* @return array
* @return string[]
*/
public function getHTTPMethods($path) {
public function getHTTPMethods($path): array {
$path = $this->pathHelper->getPathFromUri($path);
if ($this->searchBackend->getArbiterPath() === $path) {
return ['SEARCH'];
@ -88,13 +88,13 @@ class SearchPlugin extends ServerPlugin {
}
}
public function optionHandler(RequestInterface $request, ResponseInterface $response) {
public function optionHandler(RequestInterface $request, ResponseInterface $response): void {
if ($request->getPath() === $this->searchBackend->getArbiterPath()) {
$response->addHeader('DASL', '<DAV:basicsearch>');
}
}
public function searchHandler(RequestInterface $request, ResponseInterface $response) {
public function searchHandler(RequestInterface $request, ResponseInterface $response): bool {
$contentType = $request->getHeader('Content-Type') ?? '';
// Currently, we only support xml search queries