Skip to content

Commit

Permalink
fix: adjust to PHP level and codebase
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Jul 4, 2023
1 parent 2930f89 commit 1eb9f18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getDirectoryListing() {
}, $folderContent);
}

protected function createNode(string $path, ?FileInfo $info = null, bool $infoHasSubMountsIncluded = true): INode {
protected function createNode(string $path, ?FileInfo $info = null): INode {
if (is_null($info)) {
$isDir = $this->view->is_dir($path);
} else {
Expand Down Expand Up @@ -326,7 +326,7 @@ protected function getAppDataDirectoryName(): string {
* @param int $id
* @return array
*/
protected function getByIdInRootMount(int $id): array {
protected function getByIdInRootMount(int $id): array {
if (!method_exists($this->root, 'createNode')) {
// Always expected to be false. Being a method of Folder, this is
// always implemented. For it is an internal method and should not
Expand All @@ -335,7 +335,7 @@ protected function getByIdInRootMount(int $id): array {
}
$mount = $this->root->getMount('');
$storage = $mount->getStorage();
$cacheEntry = $storage?->getCache($this->path)->get($id);
$cacheEntry = $storage ? $storage->getCache($this->path)->get($id) : null;
if (!$cacheEntry) {
return [];
}
Expand Down
8 changes: 6 additions & 2 deletions lib/private/Files/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Node implements INode {
* @param string $path
* @param FileInfo $fileInfo
*/
public function __construct($root, $view, $path, $fileInfo = null, ?Node $parent = null) {
public function __construct(IRootFolder $root, $view, $path, $fileInfo = null, ?Node $parent = null) {
if (Filesystem::normalizePath($view->getRoot()) !== '/') {
throw new PreConditionNotMetException('The view passed to the node should not have any fake root set');
}
Expand Down Expand Up @@ -285,7 +285,11 @@ public function isCreatable() {
return $this->getFileInfo()->isCreatable();
}

public function getParent(): INode|IRootFolder {
/**
* @return INode|IRootFolder

Check failure on line 289 in lib/private/Files/Node/Node.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

LessSpecificImplementedReturnType

lib/private/Files/Node/Node.php:289:13: LessSpecificImplementedReturnType: The inherited return type 'OCP\Files\Folder' for OCP\Files\Node::getParent is more specific than the implemented return type for OC\Files\Node\Node::getparent 'OCP\Files\IRootFolder|OCP\Files\Node' (see https://psalm.dev/166)

Check failure

Code scanning / Psalm

LessSpecificImplementedReturnType Error

The inherited return type 'OCP\Files\Folder' for OCP\Files\Node::getParent is more specific than the implemented return type for OC\Files\Node\Node::getparent 'OCP\Files\IRootFolder|OCP\Files\Node'
* @throws NotFoundException
*/
public function getParent() {
if ($this->parent === null) {
$newPath = dirname($this->path);
if ($newPath === '' || $newPath === '.' || $newPath === '/') {
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,10 @@ public function isShareable() {
}

/**
* @return INode|IRootFolder

Check failure on line 339 in lib/private/Files/Node/Root.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

LessSpecificImplementedReturnType

lib/private/Files/Node/Root.php:339:13: LessSpecificImplementedReturnType: The inherited return type 'OCP\Files\Folder' for OCP\Files\Node::getParent is more specific than the implemented return type for OC\Files\Node\Root::getparent 'OCP\Files\IRootFolder|OCP\Files\Node' (see https://psalm.dev/166)

Check failure

Code scanning / Psalm

LessSpecificImplementedReturnType Error

The inherited return type 'OCP\Files\Folder' for OCP\Files\Node::getParent is more specific than the implemented return type for OC\Files\Node\Root::getparent 'OCP\Files\IRootFolder|OCP\Files\Node'
* @throws \OCP\Files\NotFoundException
*/
public function getParent(): INode|IRootFolder {
public function getParent() {
throw new NotFoundException();
}

Expand Down

0 comments on commit 1eb9f18

Please sign in to comment.