3434use OC \Files \Utils \PathHelper ;
3535use OCP \Files \FileInfo ;
3636use OCP \Files \InvalidPathException ;
37+ use OCP \Files \IRootFolder ;
38+ use OCP \Files \Node as INode ;
3739use OCP \Files \NotFoundException ;
3840use OCP \Files \NotPermittedException ;
3941use OCP \Lock \LockedException ;
4042use OCP \PreConditionNotMetException ;
4143use Symfony \Component \EventDispatcher \GenericEvent ;
4244
4345// FIXME: this class really should be abstract
44- class Node implements \ OCP \ Files \Node {
46+ class Node implements INode {
4547 /**
4648 * @var \OC\Files\View $view
4749 */
4850 protected $ view ;
4951
50- /**
51- * @var \OC\Files\Node\Root $root
52- */
53- protected $ root ;
52+ protected IRootFolder $ root ;
5453
5554 /**
5655 * @var string $path Absolute path to the node (e.g. /admin/files/folder/file)
@@ -72,7 +71,7 @@ class Node implements \OCP\Files\Node {
7271 * @param string $path
7372 * @param FileInfo $fileInfo
7473 */
75- public function __construct ($ root , $ view , $ path , $ fileInfo = null , ?Node $ parent = null , bool $ infoHasSubMountsIncluded = true ) {
74+ public function __construct (IRootFolder $ root , $ view , $ path , $ fileInfo = null , ?Node $ parent = null , bool $ infoHasSubMountsIncluded = true ) {
7675 if (Filesystem::normalizePath ($ view ->getRoot ()) !== '/ ' ) {
7776 throw new PreConditionNotMetException ('The view passed to the node should not have any fake root set ' );
7877 }
@@ -130,7 +129,9 @@ protected function sendHooks($hooks, array $args = null) {
130129 $ args = !empty ($ args ) ? $ args : [$ this ];
131130 $ dispatcher = \OC ::$ server ->getEventDispatcher ();
132131 foreach ($ hooks as $ hook ) {
133- $ this ->root ->emit ('\OC\Files ' , $ hook , $ args );
132+ if (method_exists ($ this ->root , 'emit ' )) {
133+ $ this ->root ->emit ('\OC\Files ' , $ hook , $ args );
134+ }
134135 $ dispatcher ->dispatch ('\OCP\Files:: ' . $ hook , new GenericEvent ($ args ));
135136 }
136137 }
@@ -290,10 +291,7 @@ public function isCreatable() {
290291 return $ this ->getFileInfo (false )->isCreatable ();
291292 }
292293
293- /**
294- * @return Node
295- */
296- public function getParent () {
294+ public function getParent (): INode |IRootFolder {
297295 if ($ this ->parent === null ) {
298296 $ newPath = dirname ($ this ->path );
299297 if ($ newPath === '' || $ newPath === '. ' || $ newPath === '/ ' ) {
@@ -402,7 +400,7 @@ public function unlock($type) {
402400
403401 /**
404402 * @param string $targetPath
405- * @return \OC\Files\Node\Node
403+ * @return INode
406404 * @throws InvalidPathException
407405 * @throws NotFoundException
408406 * @throws NotPermittedException if copy not allowed or failed
@@ -428,7 +426,7 @@ public function copy($targetPath) {
428426
429427 /**
430428 * @param string $targetPath
431- * @return \OC\Files\Node\Node
429+ * @return INode
432430 * @throws InvalidPathException
433431 * @throws NotFoundException
434432 * @throws NotPermittedException if move not allowed or failed
0 commit comments