Passed
Push — master ( 27fb46...dad31c )
by rakekniven
15:02 queued 12s
created
lib/private/App/AppStore/Version/VersionParser.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 * @return bool
33 33
 	 */
34 34
 	private function isValidVersionString($versionString) {
35
-		return (bool)preg_match('/^[0-9.]+$/', $versionString);
35
+		return (bool) preg_match('/^[0-9.]+$/', $versionString);
36 36
 	}
37 37
 
38 38
 	/**
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -30,56 +30,56 @@
 block discarded – undo
30 30
  * @package OC\App\AppStore
31 31
  */
32 32
 class VersionParser {
33
-	/**
34
-	 * @param string $versionString
35
-	 * @return bool
36
-	 */
37
-	private function isValidVersionString($versionString) {
38
-		return (bool)preg_match('/^[0-9.]+$/', $versionString);
39
-	}
33
+    /**
34
+     * @param string $versionString
35
+     * @return bool
36
+     */
37
+    private function isValidVersionString($versionString) {
38
+        return (bool)preg_match('/^[0-9.]+$/', $versionString);
39
+    }
40 40
 
41
-	/**
42
-	 * Returns the version for a version string
43
-	 *
44
-	 * @param string $versionSpec
45
-	 * @return Version
46
-	 * @throws \Exception If the version cannot be parsed
47
-	 */
48
-	public function getVersion($versionSpec) {
49
-		// * indicates that the version is compatible with all versions
50
-		if ($versionSpec === '*') {
51
-			return new Version('', '');
52
-		}
41
+    /**
42
+     * Returns the version for a version string
43
+     *
44
+     * @param string $versionSpec
45
+     * @return Version
46
+     * @throws \Exception If the version cannot be parsed
47
+     */
48
+    public function getVersion($versionSpec) {
49
+        // * indicates that the version is compatible with all versions
50
+        if ($versionSpec === '*') {
51
+            return new Version('', '');
52
+        }
53 53
 
54
-		// Count the amount of =, if it is one then it's either maximum or minimum
55
-		// version. If it is two then it is maximum and minimum.
56
-		$versionElements = explode(' ', $versionSpec);
57
-		$firstVersion = isset($versionElements[0]) ? $versionElements[0] : '';
58
-		$firstVersionNumber = substr($firstVersion, 2);
59
-		$secondVersion = isset($versionElements[1]) ? $versionElements[1] : '';
60
-		$secondVersionNumber = substr($secondVersion, 2);
54
+        // Count the amount of =, if it is one then it's either maximum or minimum
55
+        // version. If it is two then it is maximum and minimum.
56
+        $versionElements = explode(' ', $versionSpec);
57
+        $firstVersion = isset($versionElements[0]) ? $versionElements[0] : '';
58
+        $firstVersionNumber = substr($firstVersion, 2);
59
+        $secondVersion = isset($versionElements[1]) ? $versionElements[1] : '';
60
+        $secondVersionNumber = substr($secondVersion, 2);
61 61
 
62
-		switch (count($versionElements)) {
63
-			case 1:
64
-				if (!$this->isValidVersionString($firstVersionNumber)) {
65
-					break;
66
-				}
67
-				if (strpos($firstVersion, '>') === 0) {
68
-					return new Version($firstVersionNumber, '');
69
-				}
70
-				return new Version('', $firstVersionNumber);
71
-			case 2:
72
-				if (!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
73
-					break;
74
-				}
75
-				return new Version($firstVersionNumber, $secondVersionNumber);
76
-		}
62
+        switch (count($versionElements)) {
63
+            case 1:
64
+                if (!$this->isValidVersionString($firstVersionNumber)) {
65
+                    break;
66
+                }
67
+                if (strpos($firstVersion, '>') === 0) {
68
+                    return new Version($firstVersionNumber, '');
69
+                }
70
+                return new Version('', $firstVersionNumber);
71
+            case 2:
72
+                if (!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
73
+                    break;
74
+                }
75
+                return new Version($firstVersionNumber, $secondVersionNumber);
76
+        }
77 77
 
78
-		throw new \Exception(
79
-			sprintf(
80
-				'Version cannot be parsed: %s',
81
-				$versionSpec
82
-			)
83
-		);
84
-	}
78
+        throw new \Exception(
79
+            sprintf(
80
+                'Version cannot be parsed: %s',
81
+                $versionSpec
82
+            )
83
+        );
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/Bundle.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,36 +24,36 @@
 block discarded – undo
24 24
 use OCP\IL10N;
25 25
 
26 26
 abstract class Bundle {
27
-	/** @var IL10N */
28
-	protected $l10n;
27
+    /** @var IL10N */
28
+    protected $l10n;
29 29
 
30
-	/**
31
-	 * @param IL10N $l10n
32
-	 */
33
-	public function __construct(IL10N $l10n) {
34
-		$this->l10n = $l10n;
35
-	}
30
+    /**
31
+     * @param IL10N $l10n
32
+     */
33
+    public function __construct(IL10N $l10n) {
34
+        $this->l10n = $l10n;
35
+    }
36 36
 
37
-	/**
38
-	 * Get the identifier of the bundle
39
-	 *
40
-	 * @return string
41
-	 */
42
-	final public function getIdentifier() {
43
-		return substr(strrchr(get_class($this), '\\'), 1);
44
-	}
37
+    /**
38
+     * Get the identifier of the bundle
39
+     *
40
+     * @return string
41
+     */
42
+    final public function getIdentifier() {
43
+        return substr(strrchr(get_class($this), '\\'), 1);
44
+    }
45 45
 
46
-	/**
47
-	 * Get the name of the bundle
48
-	 *
49
-	 * @return string
50
-	 */
51
-	abstract public function getName();
46
+    /**
47
+     * Get the name of the bundle
48
+     *
49
+     * @return string
50
+     */
51
+    abstract public function getName();
52 52
 
53
-	/**
54
-	 * Get the list of app identifiers in the bundle
55
-	 *
56
-	 * @return array
57
-	 */
58
-	abstract public function getAppIdentifiers();
53
+    /**
54
+     * Get the list of app identifiers in the bundle
55
+     *
56
+     * @return array
57
+     */
58
+    abstract public function getAppIdentifiers();
59 59
 }
Please login to merge, or discard this patch.
lib/private/Share20/LegacyHooks.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 		/** @var IShare[] $deletedShares */
67 67
 		$deletedShares = $e->getArgument('deletedShares');
68 68
 
69
-		$formattedDeletedShares = array_map(function ($share) {
69
+		$formattedDeletedShares = array_map(function($share) {
70 70
 			return $this->formatHookParams($share);
71 71
 		}, $deletedShares);
72 72
 
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -34,144 +34,144 @@
 block discarded – undo
34 34
 
35 35
 class LegacyHooks {
36 36
 
37
-	/** @var EventDispatcherInterface */
38
-	private $eventDispatcher;
39
-
40
-	/**
41
-	 * LegacyHooks constructor.
42
-	 *
43
-	 * @param EventDispatcherInterface $eventDispatcher
44
-	 */
45
-	public function __construct(EventDispatcherInterface $eventDispatcher) {
46
-		$this->eventDispatcher = $eventDispatcher;
47
-
48
-		$this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
49
-		$this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
50
-		$this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
51
-		$this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
52
-		$this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
53
-	}
54
-
55
-	/**
56
-	 * @param GenericEvent $e
57
-	 */
58
-	public function preUnshare(GenericEvent $e) {
59
-		/** @var IShare $share */
60
-		$share = $e->getSubject();
61
-
62
-		$formatted = $this->formatHookParams($share);
63
-		\OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
64
-	}
65
-
66
-	/**
67
-	 * @param GenericEvent $e
68
-	 */
69
-	public function postUnshare(GenericEvent $e) {
70
-		/** @var IShare $share */
71
-		$share = $e->getSubject();
72
-
73
-		$formatted = $this->formatHookParams($share);
74
-
75
-		/** @var IShare[] $deletedShares */
76
-		$deletedShares = $e->getArgument('deletedShares');
77
-
78
-		$formattedDeletedShares = array_map(function ($share) {
79
-			return $this->formatHookParams($share);
80
-		}, $deletedShares);
81
-
82
-		$formatted['deletedShares'] = $formattedDeletedShares;
83
-
84
-		\OC_Hook::emit(Share::class, 'post_unshare', $formatted);
85
-	}
86
-
87
-	/**
88
-	 * @param GenericEvent $e
89
-	 */
90
-	public function postUnshareFromSelf(GenericEvent $e) {
91
-		/** @var IShare $share */
92
-		$share = $e->getSubject();
93
-
94
-		$formatted = $this->formatHookParams($share);
95
-		$formatted['itemTarget'] = $formatted['fileTarget'];
96
-		$formatted['unsharedItems'] = [$formatted];
97
-
98
-		\OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
99
-	}
100
-
101
-	private function formatHookParams(IShare $share) {
102
-		// Prepare hook
103
-		$shareType = $share->getShareType();
104
-		$sharedWith = '';
105
-		if ($shareType === IShare::TYPE_USER ||
106
-			$shareType === IShare::TYPE_GROUP ||
107
-			$shareType === IShare::TYPE_REMOTE) {
108
-			$sharedWith = $share->getSharedWith();
109
-		}
110
-
111
-		$hookParams = [
112
-			'id' => $share->getId(),
113
-			'itemType' => $share->getNodeType(),
114
-			'itemSource' => $share->getNodeId(),
115
-			'shareType' => $shareType,
116
-			'shareWith' => $sharedWith,
117
-			'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
118
-			'uidOwner' => $share->getSharedBy(),
119
-			'fileSource' => $share->getNodeId(),
120
-			'fileTarget' => $share->getTarget()
121
-		];
122
-		return $hookParams;
123
-	}
124
-
125
-	public function preShare(GenericEvent $e) {
126
-		/** @var IShare $share */
127
-		$share = $e->getSubject();
128
-
129
-		// Pre share hook
130
-		$run = true;
131
-		$error = '';
132
-		$preHookData = [
133
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
134
-			'itemSource' => $share->getNode()->getId(),
135
-			'shareType' => $share->getShareType(),
136
-			'uidOwner' => $share->getSharedBy(),
137
-			'permissions' => $share->getPermissions(),
138
-			'fileSource' => $share->getNode()->getId(),
139
-			'expiration' => $share->getExpirationDate(),
140
-			'token' => $share->getToken(),
141
-			'itemTarget' => $share->getTarget(),
142
-			'shareWith' => $share->getSharedWith(),
143
-			'run' => &$run,
144
-			'error' => &$error,
145
-		];
146
-		\OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
147
-
148
-		if ($run === false) {
149
-			$e->setArgument('error', $error);
150
-			$e->stopPropagation();
151
-		}
152
-
153
-		return $e;
154
-	}
155
-
156
-	public function postShare(GenericEvent $e) {
157
-		/** @var IShare $share */
158
-		$share = $e->getSubject();
159
-
160
-		$postHookData = [
161
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
162
-			'itemSource' => $share->getNode()->getId(),
163
-			'shareType' => $share->getShareType(),
164
-			'uidOwner' => $share->getSharedBy(),
165
-			'permissions' => $share->getPermissions(),
166
-			'fileSource' => $share->getNode()->getId(),
167
-			'expiration' => $share->getExpirationDate(),
168
-			'token' => $share->getToken(),
169
-			'id' => $share->getId(),
170
-			'shareWith' => $share->getSharedWith(),
171
-			'itemTarget' => $share->getTarget(),
172
-			'fileTarget' => $share->getTarget(),
173
-		];
174
-
175
-		\OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
-	}
37
+    /** @var EventDispatcherInterface */
38
+    private $eventDispatcher;
39
+
40
+    /**
41
+     * LegacyHooks constructor.
42
+     *
43
+     * @param EventDispatcherInterface $eventDispatcher
44
+     */
45
+    public function __construct(EventDispatcherInterface $eventDispatcher) {
46
+        $this->eventDispatcher = $eventDispatcher;
47
+
48
+        $this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
49
+        $this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
50
+        $this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
51
+        $this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
52
+        $this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
53
+    }
54
+
55
+    /**
56
+     * @param GenericEvent $e
57
+     */
58
+    public function preUnshare(GenericEvent $e) {
59
+        /** @var IShare $share */
60
+        $share = $e->getSubject();
61
+
62
+        $formatted = $this->formatHookParams($share);
63
+        \OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
64
+    }
65
+
66
+    /**
67
+     * @param GenericEvent $e
68
+     */
69
+    public function postUnshare(GenericEvent $e) {
70
+        /** @var IShare $share */
71
+        $share = $e->getSubject();
72
+
73
+        $formatted = $this->formatHookParams($share);
74
+
75
+        /** @var IShare[] $deletedShares */
76
+        $deletedShares = $e->getArgument('deletedShares');
77
+
78
+        $formattedDeletedShares = array_map(function ($share) {
79
+            return $this->formatHookParams($share);
80
+        }, $deletedShares);
81
+
82
+        $formatted['deletedShares'] = $formattedDeletedShares;
83
+
84
+        \OC_Hook::emit(Share::class, 'post_unshare', $formatted);
85
+    }
86
+
87
+    /**
88
+     * @param GenericEvent $e
89
+     */
90
+    public function postUnshareFromSelf(GenericEvent $e) {
91
+        /** @var IShare $share */
92
+        $share = $e->getSubject();
93
+
94
+        $formatted = $this->formatHookParams($share);
95
+        $formatted['itemTarget'] = $formatted['fileTarget'];
96
+        $formatted['unsharedItems'] = [$formatted];
97
+
98
+        \OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
99
+    }
100
+
101
+    private function formatHookParams(IShare $share) {
102
+        // Prepare hook
103
+        $shareType = $share->getShareType();
104
+        $sharedWith = '';
105
+        if ($shareType === IShare::TYPE_USER ||
106
+            $shareType === IShare::TYPE_GROUP ||
107
+            $shareType === IShare::TYPE_REMOTE) {
108
+            $sharedWith = $share->getSharedWith();
109
+        }
110
+
111
+        $hookParams = [
112
+            'id' => $share->getId(),
113
+            'itemType' => $share->getNodeType(),
114
+            'itemSource' => $share->getNodeId(),
115
+            'shareType' => $shareType,
116
+            'shareWith' => $sharedWith,
117
+            'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
118
+            'uidOwner' => $share->getSharedBy(),
119
+            'fileSource' => $share->getNodeId(),
120
+            'fileTarget' => $share->getTarget()
121
+        ];
122
+        return $hookParams;
123
+    }
124
+
125
+    public function preShare(GenericEvent $e) {
126
+        /** @var IShare $share */
127
+        $share = $e->getSubject();
128
+
129
+        // Pre share hook
130
+        $run = true;
131
+        $error = '';
132
+        $preHookData = [
133
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
134
+            'itemSource' => $share->getNode()->getId(),
135
+            'shareType' => $share->getShareType(),
136
+            'uidOwner' => $share->getSharedBy(),
137
+            'permissions' => $share->getPermissions(),
138
+            'fileSource' => $share->getNode()->getId(),
139
+            'expiration' => $share->getExpirationDate(),
140
+            'token' => $share->getToken(),
141
+            'itemTarget' => $share->getTarget(),
142
+            'shareWith' => $share->getSharedWith(),
143
+            'run' => &$run,
144
+            'error' => &$error,
145
+        ];
146
+        \OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
147
+
148
+        if ($run === false) {
149
+            $e->setArgument('error', $error);
150
+            $e->stopPropagation();
151
+        }
152
+
153
+        return $e;
154
+    }
155
+
156
+    public function postShare(GenericEvent $e) {
157
+        /** @var IShare $share */
158
+        $share = $e->getSubject();
159
+
160
+        $postHookData = [
161
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
162
+            'itemSource' => $share->getNode()->getId(),
163
+            'shareType' => $share->getShareType(),
164
+            'uidOwner' => $share->getSharedBy(),
165
+            'permissions' => $share->getPermissions(),
166
+            'fileSource' => $share->getNode()->getId(),
167
+            'expiration' => $share->getExpirationDate(),
168
+            'token' => $share->getToken(),
169
+            'id' => $share->getId(),
170
+            'shareWith' => $share->getSharedWith(),
171
+            'itemTarget' => $share->getTarget(),
172
+            'fileTarget' => $share->getTarget(),
173
+        ];
174
+
175
+        \OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
+    }
177 177
 }
Please login to merge, or discard this patch.
lib/private/Share20/Share.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function setId($id) {
88 88
 		if (is_int($id)) {
89
-			$id = (string)$id;
89
+			$id = (string) $id;
90 90
 		}
91 91
 
92 92
 		if (!is_string($id)) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		if ($this->providerId === null || $this->id === null) {
116 116
 			throw new \UnexpectedValueException;
117 117
 		}
118
-		return $this->providerId . ':' . $this->id;
118
+		return $this->providerId.':'.$this->id;
119 119
 	}
120 120
 
121 121
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 			$nodes = $userFolder->getById($this->fileId);
165 165
 			if (empty($nodes)) {
166
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
166
+				throw new NotFoundException('Node for share not found, fileid: '.$this->fileId);
167 167
 			}
168 168
 
169 169
 			$this->node = $nodes[0];
Please login to merge, or discard this patch.
Indentation   +539 added lines, -539 removed lines patch added patch discarded remove patch
@@ -42,543 +42,543 @@
 block discarded – undo
42 42
 
43 43
 class Share implements IShare {
44 44
 
45
-	/** @var string */
46
-	private $id;
47
-	/** @var string */
48
-	private $providerId;
49
-	/** @var Node */
50
-	private $node;
51
-	/** @var int */
52
-	private $fileId;
53
-	/** @var string */
54
-	private $nodeType;
55
-	/** @var int */
56
-	private $shareType;
57
-	/** @var string */
58
-	private $sharedWith;
59
-	/** @var string */
60
-	private $sharedWithDisplayName;
61
-	/** @var string */
62
-	private $sharedWithAvatar;
63
-	/** @var string */
64
-	private $sharedBy;
65
-	/** @var string */
66
-	private $shareOwner;
67
-	/** @var int */
68
-	private $permissions;
69
-	/** @var int */
70
-	private $status;
71
-	/** @var string */
72
-	private $note = '';
73
-	/** @var \DateTime */
74
-	private $expireDate;
75
-	/** @var string */
76
-	private $password;
77
-	/** @var bool */
78
-	private $sendPasswordByTalk = false;
79
-	/** @var string */
80
-	private $token;
81
-	/** @var int */
82
-	private $parent;
83
-	/** @var string */
84
-	private $target;
85
-	/** @var \DateTime */
86
-	private $shareTime;
87
-	/** @var bool */
88
-	private $mailSend;
89
-	/** @var string */
90
-	private $label = '';
91
-
92
-	/** @var IRootFolder */
93
-	private $rootFolder;
94
-
95
-	/** @var IUserManager */
96
-	private $userManager;
97
-
98
-	/** @var ICacheEntry|null */
99
-	private $nodeCacheEntry;
100
-
101
-	/** @var bool */
102
-	private $hideDownload = false;
103
-
104
-	public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
105
-		$this->rootFolder = $rootFolder;
106
-		$this->userManager = $userManager;
107
-	}
108
-
109
-	/**
110
-	 * @inheritdoc
111
-	 */
112
-	public function setId($id) {
113
-		if (is_int($id)) {
114
-			$id = (string)$id;
115
-		}
116
-
117
-		if (!is_string($id)) {
118
-			throw new \InvalidArgumentException('String expected.');
119
-		}
120
-
121
-		if ($this->id !== null) {
122
-			throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
123
-		}
124
-
125
-		$this->id = trim($id);
126
-		return $this;
127
-	}
128
-
129
-	/**
130
-	 * @inheritdoc
131
-	 */
132
-	public function getId() {
133
-		return $this->id;
134
-	}
135
-
136
-	/**
137
-	 * @inheritdoc
138
-	 */
139
-	public function getFullId() {
140
-		if ($this->providerId === null || $this->id === null) {
141
-			throw new \UnexpectedValueException;
142
-		}
143
-		return $this->providerId . ':' . $this->id;
144
-	}
145
-
146
-	/**
147
-	 * @inheritdoc
148
-	 */
149
-	public function setProviderId($id) {
150
-		if (!is_string($id)) {
151
-			throw new \InvalidArgumentException('String expected.');
152
-		}
153
-
154
-		if ($this->providerId !== null) {
155
-			throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
156
-		}
157
-
158
-		$this->providerId = trim($id);
159
-		return $this;
160
-	}
161
-
162
-	/**
163
-	 * @inheritdoc
164
-	 */
165
-	public function setNode(Node $node) {
166
-		$this->fileId = null;
167
-		$this->nodeType = null;
168
-		$this->node = $node;
169
-		return $this;
170
-	}
171
-
172
-	/**
173
-	 * @inheritdoc
174
-	 */
175
-	public function getNode() {
176
-		if ($this->node === null) {
177
-			if ($this->shareOwner === null || $this->fileId === null) {
178
-				throw new NotFoundException();
179
-			}
180
-
181
-			// for federated shares the owner can be a remote user, in this
182
-			// case we use the initiator
183
-			if ($this->userManager->userExists($this->shareOwner)) {
184
-				$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
185
-			} else {
186
-				$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
187
-			}
188
-
189
-			$nodes = $userFolder->getById($this->fileId);
190
-			if (empty($nodes)) {
191
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
192
-			}
193
-
194
-			$this->node = $nodes[0];
195
-		}
196
-
197
-		return $this->node;
198
-	}
199
-
200
-	/**
201
-	 * @inheritdoc
202
-	 */
203
-	public function setNodeId($fileId) {
204
-		$this->node = null;
205
-		$this->fileId = $fileId;
206
-		return $this;
207
-	}
208
-
209
-	/**
210
-	 * @inheritdoc
211
-	 */
212
-	public function getNodeId() {
213
-		if ($this->fileId === null) {
214
-			$this->fileId = $this->getNode()->getId();
215
-		}
216
-
217
-		return $this->fileId;
218
-	}
219
-
220
-	/**
221
-	 * @inheritdoc
222
-	 */
223
-	public function setNodeType($type) {
224
-		if ($type !== 'file' && $type !== 'folder') {
225
-			throw new \InvalidArgumentException();
226
-		}
227
-
228
-		$this->nodeType = $type;
229
-		return $this;
230
-	}
231
-
232
-	/**
233
-	 * @inheritdoc
234
-	 */
235
-	public function getNodeType() {
236
-		if ($this->nodeType === null) {
237
-			if ($this->getNodeCacheEntry()) {
238
-				$info = $this->getNodeCacheEntry();
239
-				$this->nodeType = $info->getMimeType() === FileInfo::MIMETYPE_FOLDER ? 'folder' : 'file';
240
-			} else {
241
-				$node = $this->getNode();
242
-				$this->nodeType = $node instanceof File ? 'file' : 'folder';
243
-			}
244
-		}
245
-
246
-		return $this->nodeType;
247
-	}
248
-
249
-	/**
250
-	 * @inheritdoc
251
-	 */
252
-	public function setShareType($shareType) {
253
-		$this->shareType = $shareType;
254
-		return $this;
255
-	}
256
-
257
-	/**
258
-	 * @inheritdoc
259
-	 */
260
-	public function getShareType() {
261
-		return $this->shareType;
262
-	}
263
-
264
-	/**
265
-	 * @inheritdoc
266
-	 */
267
-	public function setSharedWith($sharedWith) {
268
-		if (!is_string($sharedWith)) {
269
-			throw new \InvalidArgumentException();
270
-		}
271
-		$this->sharedWith = $sharedWith;
272
-		return $this;
273
-	}
274
-
275
-	/**
276
-	 * @inheritdoc
277
-	 */
278
-	public function getSharedWith() {
279
-		return $this->sharedWith;
280
-	}
281
-
282
-	/**
283
-	 * @inheritdoc
284
-	 */
285
-	public function setSharedWithDisplayName($displayName) {
286
-		if (!is_string($displayName)) {
287
-			throw new \InvalidArgumentException();
288
-		}
289
-		$this->sharedWithDisplayName = $displayName;
290
-		return $this;
291
-	}
292
-
293
-	/**
294
-	 * @inheritdoc
295
-	 */
296
-	public function getSharedWithDisplayName() {
297
-		return $this->sharedWithDisplayName;
298
-	}
299
-
300
-	/**
301
-	 * @inheritdoc
302
-	 */
303
-	public function setSharedWithAvatar($src) {
304
-		if (!is_string($src)) {
305
-			throw new \InvalidArgumentException();
306
-		}
307
-		$this->sharedWithAvatar = $src;
308
-		return $this;
309
-	}
310
-
311
-	/**
312
-	 * @inheritdoc
313
-	 */
314
-	public function getSharedWithAvatar() {
315
-		return $this->sharedWithAvatar;
316
-	}
317
-
318
-	/**
319
-	 * @inheritdoc
320
-	 */
321
-	public function setPermissions($permissions) {
322
-		//TODO checkes
323
-
324
-		$this->permissions = $permissions;
325
-		return $this;
326
-	}
327
-
328
-	/**
329
-	 * @inheritdoc
330
-	 */
331
-	public function getPermissions() {
332
-		return $this->permissions;
333
-	}
334
-
335
-	/**
336
-	 * @inheritdoc
337
-	 */
338
-	public function setStatus(int $status): IShare {
339
-		$this->status = $status;
340
-		return $this;
341
-	}
342
-
343
-	/**
344
-	 * @inheritdoc
345
-	 */
346
-	public function getStatus(): int {
347
-		return $this->status;
348
-	}
349
-
350
-	/**
351
-	 * @inheritdoc
352
-	 */
353
-	public function setNote($note) {
354
-		$this->note = $note;
355
-		return $this;
356
-	}
357
-
358
-	/**
359
-	 * @inheritdoc
360
-	 */
361
-	public function getNote() {
362
-		if (is_string($this->note)) {
363
-			return $this->note;
364
-		}
365
-		return '';
366
-	}
367
-
368
-	/**
369
-	 * @inheritdoc
370
-	 */
371
-	public function setLabel($label) {
372
-		$this->label = $label;
373
-		return $this;
374
-	}
375
-
376
-	/**
377
-	 * @inheritdoc
378
-	 */
379
-	public function getLabel() {
380
-		return $this->label;
381
-	}
382
-
383
-	/**
384
-	 * @inheritdoc
385
-	 */
386
-	public function setExpirationDate($expireDate) {
387
-		//TODO checks
388
-
389
-		$this->expireDate = $expireDate;
390
-		return $this;
391
-	}
392
-
393
-	/**
394
-	 * @inheritdoc
395
-	 */
396
-	public function getExpirationDate() {
397
-		return $this->expireDate;
398
-	}
399
-
400
-	/**
401
-	 * @inheritdoc
402
-	 */
403
-	public function isExpired() {
404
-		return $this->getExpirationDate() !== null &&
405
-			$this->getExpirationDate() <= new \DateTime();
406
-	}
407
-
408
-	/**
409
-	 * @inheritdoc
410
-	 */
411
-	public function setSharedBy($sharedBy) {
412
-		if (!is_string($sharedBy)) {
413
-			throw new \InvalidArgumentException();
414
-		}
415
-		//TODO checks
416
-		$this->sharedBy = $sharedBy;
417
-
418
-		return $this;
419
-	}
420
-
421
-	/**
422
-	 * @inheritdoc
423
-	 */
424
-	public function getSharedBy() {
425
-		//TODO check if set
426
-		return $this->sharedBy;
427
-	}
428
-
429
-	/**
430
-	 * @inheritdoc
431
-	 */
432
-	public function setShareOwner($shareOwner) {
433
-		if (!is_string($shareOwner)) {
434
-			throw new \InvalidArgumentException();
435
-		}
436
-		//TODO checks
437
-
438
-		$this->shareOwner = $shareOwner;
439
-		return $this;
440
-	}
441
-
442
-	/**
443
-	 * @inheritdoc
444
-	 */
445
-	public function getShareOwner() {
446
-		//TODO check if set
447
-		return $this->shareOwner;
448
-	}
449
-
450
-	/**
451
-	 * @inheritdoc
452
-	 */
453
-	public function setPassword($password) {
454
-		$this->password = $password;
455
-		return $this;
456
-	}
457
-
458
-	/**
459
-	 * @inheritdoc
460
-	 */
461
-	public function getPassword() {
462
-		return $this->password;
463
-	}
464
-
465
-	/**
466
-	 * @inheritdoc
467
-	 */
468
-	public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
469
-		$this->sendPasswordByTalk = $sendPasswordByTalk;
470
-		return $this;
471
-	}
472
-
473
-	/**
474
-	 * @inheritdoc
475
-	 */
476
-	public function getSendPasswordByTalk(): bool {
477
-		return $this->sendPasswordByTalk;
478
-	}
479
-
480
-	/**
481
-	 * @inheritdoc
482
-	 */
483
-	public function setToken($token) {
484
-		$this->token = $token;
485
-		return $this;
486
-	}
487
-
488
-	/**
489
-	 * @inheritdoc
490
-	 */
491
-	public function getToken() {
492
-		return $this->token;
493
-	}
494
-
495
-	/**
496
-	 * Set the parent of this share
497
-	 *
498
-	 * @param int parent
499
-	 * @return \OCP\Share\IShare
500
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
501
-	 */
502
-	public function setParent($parent) {
503
-		$this->parent = $parent;
504
-		return $this;
505
-	}
506
-
507
-	/**
508
-	 * Get the parent of this share.
509
-	 *
510
-	 * @return int
511
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
512
-	 */
513
-	public function getParent() {
514
-		return $this->parent;
515
-	}
516
-
517
-	/**
518
-	 * @inheritdoc
519
-	 */
520
-	public function setTarget($target) {
521
-		$this->target = $target;
522
-		return $this;
523
-	}
524
-
525
-	/**
526
-	 * @inheritdoc
527
-	 */
528
-	public function getTarget() {
529
-		return $this->target;
530
-	}
531
-
532
-	/**
533
-	 * @inheritdoc
534
-	 */
535
-	public function setShareTime(\DateTime $shareTime) {
536
-		$this->shareTime = $shareTime;
537
-		return $this;
538
-	}
539
-
540
-	/**
541
-	 * @inheritdoc
542
-	 */
543
-	public function getShareTime() {
544
-		return $this->shareTime;
545
-	}
546
-
547
-	/**
548
-	 * @inheritdoc
549
-	 */
550
-	public function setMailSend($mailSend) {
551
-		$this->mailSend = $mailSend;
552
-		return $this;
553
-	}
554
-
555
-	/**
556
-	 * @inheritdoc
557
-	 */
558
-	public function getMailSend() {
559
-		return $this->mailSend;
560
-	}
561
-
562
-	/**
563
-	 * @inheritdoc
564
-	 */
565
-	public function setNodeCacheEntry(ICacheEntry $entry) {
566
-		$this->nodeCacheEntry = $entry;
567
-	}
568
-
569
-	/**
570
-	 * @inheritdoc
571
-	 */
572
-	public function getNodeCacheEntry() {
573
-		return $this->nodeCacheEntry;
574
-	}
575
-
576
-	public function setHideDownload(bool $hide): IShare {
577
-		$this->hideDownload = $hide;
578
-		return $this;
579
-	}
580
-
581
-	public function getHideDownload(): bool {
582
-		return $this->hideDownload;
583
-	}
45
+    /** @var string */
46
+    private $id;
47
+    /** @var string */
48
+    private $providerId;
49
+    /** @var Node */
50
+    private $node;
51
+    /** @var int */
52
+    private $fileId;
53
+    /** @var string */
54
+    private $nodeType;
55
+    /** @var int */
56
+    private $shareType;
57
+    /** @var string */
58
+    private $sharedWith;
59
+    /** @var string */
60
+    private $sharedWithDisplayName;
61
+    /** @var string */
62
+    private $sharedWithAvatar;
63
+    /** @var string */
64
+    private $sharedBy;
65
+    /** @var string */
66
+    private $shareOwner;
67
+    /** @var int */
68
+    private $permissions;
69
+    /** @var int */
70
+    private $status;
71
+    /** @var string */
72
+    private $note = '';
73
+    /** @var \DateTime */
74
+    private $expireDate;
75
+    /** @var string */
76
+    private $password;
77
+    /** @var bool */
78
+    private $sendPasswordByTalk = false;
79
+    /** @var string */
80
+    private $token;
81
+    /** @var int */
82
+    private $parent;
83
+    /** @var string */
84
+    private $target;
85
+    /** @var \DateTime */
86
+    private $shareTime;
87
+    /** @var bool */
88
+    private $mailSend;
89
+    /** @var string */
90
+    private $label = '';
91
+
92
+    /** @var IRootFolder */
93
+    private $rootFolder;
94
+
95
+    /** @var IUserManager */
96
+    private $userManager;
97
+
98
+    /** @var ICacheEntry|null */
99
+    private $nodeCacheEntry;
100
+
101
+    /** @var bool */
102
+    private $hideDownload = false;
103
+
104
+    public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
105
+        $this->rootFolder = $rootFolder;
106
+        $this->userManager = $userManager;
107
+    }
108
+
109
+    /**
110
+     * @inheritdoc
111
+     */
112
+    public function setId($id) {
113
+        if (is_int($id)) {
114
+            $id = (string)$id;
115
+        }
116
+
117
+        if (!is_string($id)) {
118
+            throw new \InvalidArgumentException('String expected.');
119
+        }
120
+
121
+        if ($this->id !== null) {
122
+            throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
123
+        }
124
+
125
+        $this->id = trim($id);
126
+        return $this;
127
+    }
128
+
129
+    /**
130
+     * @inheritdoc
131
+     */
132
+    public function getId() {
133
+        return $this->id;
134
+    }
135
+
136
+    /**
137
+     * @inheritdoc
138
+     */
139
+    public function getFullId() {
140
+        if ($this->providerId === null || $this->id === null) {
141
+            throw new \UnexpectedValueException;
142
+        }
143
+        return $this->providerId . ':' . $this->id;
144
+    }
145
+
146
+    /**
147
+     * @inheritdoc
148
+     */
149
+    public function setProviderId($id) {
150
+        if (!is_string($id)) {
151
+            throw new \InvalidArgumentException('String expected.');
152
+        }
153
+
154
+        if ($this->providerId !== null) {
155
+            throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
156
+        }
157
+
158
+        $this->providerId = trim($id);
159
+        return $this;
160
+    }
161
+
162
+    /**
163
+     * @inheritdoc
164
+     */
165
+    public function setNode(Node $node) {
166
+        $this->fileId = null;
167
+        $this->nodeType = null;
168
+        $this->node = $node;
169
+        return $this;
170
+    }
171
+
172
+    /**
173
+     * @inheritdoc
174
+     */
175
+    public function getNode() {
176
+        if ($this->node === null) {
177
+            if ($this->shareOwner === null || $this->fileId === null) {
178
+                throw new NotFoundException();
179
+            }
180
+
181
+            // for federated shares the owner can be a remote user, in this
182
+            // case we use the initiator
183
+            if ($this->userManager->userExists($this->shareOwner)) {
184
+                $userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
185
+            } else {
186
+                $userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
187
+            }
188
+
189
+            $nodes = $userFolder->getById($this->fileId);
190
+            if (empty($nodes)) {
191
+                throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
192
+            }
193
+
194
+            $this->node = $nodes[0];
195
+        }
196
+
197
+        return $this->node;
198
+    }
199
+
200
+    /**
201
+     * @inheritdoc
202
+     */
203
+    public function setNodeId($fileId) {
204
+        $this->node = null;
205
+        $this->fileId = $fileId;
206
+        return $this;
207
+    }
208
+
209
+    /**
210
+     * @inheritdoc
211
+     */
212
+    public function getNodeId() {
213
+        if ($this->fileId === null) {
214
+            $this->fileId = $this->getNode()->getId();
215
+        }
216
+
217
+        return $this->fileId;
218
+    }
219
+
220
+    /**
221
+     * @inheritdoc
222
+     */
223
+    public function setNodeType($type) {
224
+        if ($type !== 'file' && $type !== 'folder') {
225
+            throw new \InvalidArgumentException();
226
+        }
227
+
228
+        $this->nodeType = $type;
229
+        return $this;
230
+    }
231
+
232
+    /**
233
+     * @inheritdoc
234
+     */
235
+    public function getNodeType() {
236
+        if ($this->nodeType === null) {
237
+            if ($this->getNodeCacheEntry()) {
238
+                $info = $this->getNodeCacheEntry();
239
+                $this->nodeType = $info->getMimeType() === FileInfo::MIMETYPE_FOLDER ? 'folder' : 'file';
240
+            } else {
241
+                $node = $this->getNode();
242
+                $this->nodeType = $node instanceof File ? 'file' : 'folder';
243
+            }
244
+        }
245
+
246
+        return $this->nodeType;
247
+    }
248
+
249
+    /**
250
+     * @inheritdoc
251
+     */
252
+    public function setShareType($shareType) {
253
+        $this->shareType = $shareType;
254
+        return $this;
255
+    }
256
+
257
+    /**
258
+     * @inheritdoc
259
+     */
260
+    public function getShareType() {
261
+        return $this->shareType;
262
+    }
263
+
264
+    /**
265
+     * @inheritdoc
266
+     */
267
+    public function setSharedWith($sharedWith) {
268
+        if (!is_string($sharedWith)) {
269
+            throw new \InvalidArgumentException();
270
+        }
271
+        $this->sharedWith = $sharedWith;
272
+        return $this;
273
+    }
274
+
275
+    /**
276
+     * @inheritdoc
277
+     */
278
+    public function getSharedWith() {
279
+        return $this->sharedWith;
280
+    }
281
+
282
+    /**
283
+     * @inheritdoc
284
+     */
285
+    public function setSharedWithDisplayName($displayName) {
286
+        if (!is_string($displayName)) {
287
+            throw new \InvalidArgumentException();
288
+        }
289
+        $this->sharedWithDisplayName = $displayName;
290
+        return $this;
291
+    }
292
+
293
+    /**
294
+     * @inheritdoc
295
+     */
296
+    public function getSharedWithDisplayName() {
297
+        return $this->sharedWithDisplayName;
298
+    }
299
+
300
+    /**
301
+     * @inheritdoc
302
+     */
303
+    public function setSharedWithAvatar($src) {
304
+        if (!is_string($src)) {
305
+            throw new \InvalidArgumentException();
306
+        }
307
+        $this->sharedWithAvatar = $src;
308
+        return $this;
309
+    }
310
+
311
+    /**
312
+     * @inheritdoc
313
+     */
314
+    public function getSharedWithAvatar() {
315
+        return $this->sharedWithAvatar;
316
+    }
317
+
318
+    /**
319
+     * @inheritdoc
320
+     */
321
+    public function setPermissions($permissions) {
322
+        //TODO checkes
323
+
324
+        $this->permissions = $permissions;
325
+        return $this;
326
+    }
327
+
328
+    /**
329
+     * @inheritdoc
330
+     */
331
+    public function getPermissions() {
332
+        return $this->permissions;
333
+    }
334
+
335
+    /**
336
+     * @inheritdoc
337
+     */
338
+    public function setStatus(int $status): IShare {
339
+        $this->status = $status;
340
+        return $this;
341
+    }
342
+
343
+    /**
344
+     * @inheritdoc
345
+     */
346
+    public function getStatus(): int {
347
+        return $this->status;
348
+    }
349
+
350
+    /**
351
+     * @inheritdoc
352
+     */
353
+    public function setNote($note) {
354
+        $this->note = $note;
355
+        return $this;
356
+    }
357
+
358
+    /**
359
+     * @inheritdoc
360
+     */
361
+    public function getNote() {
362
+        if (is_string($this->note)) {
363
+            return $this->note;
364
+        }
365
+        return '';
366
+    }
367
+
368
+    /**
369
+     * @inheritdoc
370
+     */
371
+    public function setLabel($label) {
372
+        $this->label = $label;
373
+        return $this;
374
+    }
375
+
376
+    /**
377
+     * @inheritdoc
378
+     */
379
+    public function getLabel() {
380
+        return $this->label;
381
+    }
382
+
383
+    /**
384
+     * @inheritdoc
385
+     */
386
+    public function setExpirationDate($expireDate) {
387
+        //TODO checks
388
+
389
+        $this->expireDate = $expireDate;
390
+        return $this;
391
+    }
392
+
393
+    /**
394
+     * @inheritdoc
395
+     */
396
+    public function getExpirationDate() {
397
+        return $this->expireDate;
398
+    }
399
+
400
+    /**
401
+     * @inheritdoc
402
+     */
403
+    public function isExpired() {
404
+        return $this->getExpirationDate() !== null &&
405
+            $this->getExpirationDate() <= new \DateTime();
406
+    }
407
+
408
+    /**
409
+     * @inheritdoc
410
+     */
411
+    public function setSharedBy($sharedBy) {
412
+        if (!is_string($sharedBy)) {
413
+            throw new \InvalidArgumentException();
414
+        }
415
+        //TODO checks
416
+        $this->sharedBy = $sharedBy;
417
+
418
+        return $this;
419
+    }
420
+
421
+    /**
422
+     * @inheritdoc
423
+     */
424
+    public function getSharedBy() {
425
+        //TODO check if set
426
+        return $this->sharedBy;
427
+    }
428
+
429
+    /**
430
+     * @inheritdoc
431
+     */
432
+    public function setShareOwner($shareOwner) {
433
+        if (!is_string($shareOwner)) {
434
+            throw new \InvalidArgumentException();
435
+        }
436
+        //TODO checks
437
+
438
+        $this->shareOwner = $shareOwner;
439
+        return $this;
440
+    }
441
+
442
+    /**
443
+     * @inheritdoc
444
+     */
445
+    public function getShareOwner() {
446
+        //TODO check if set
447
+        return $this->shareOwner;
448
+    }
449
+
450
+    /**
451
+     * @inheritdoc
452
+     */
453
+    public function setPassword($password) {
454
+        $this->password = $password;
455
+        return $this;
456
+    }
457
+
458
+    /**
459
+     * @inheritdoc
460
+     */
461
+    public function getPassword() {
462
+        return $this->password;
463
+    }
464
+
465
+    /**
466
+     * @inheritdoc
467
+     */
468
+    public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
469
+        $this->sendPasswordByTalk = $sendPasswordByTalk;
470
+        return $this;
471
+    }
472
+
473
+    /**
474
+     * @inheritdoc
475
+     */
476
+    public function getSendPasswordByTalk(): bool {
477
+        return $this->sendPasswordByTalk;
478
+    }
479
+
480
+    /**
481
+     * @inheritdoc
482
+     */
483
+    public function setToken($token) {
484
+        $this->token = $token;
485
+        return $this;
486
+    }
487
+
488
+    /**
489
+     * @inheritdoc
490
+     */
491
+    public function getToken() {
492
+        return $this->token;
493
+    }
494
+
495
+    /**
496
+     * Set the parent of this share
497
+     *
498
+     * @param int parent
499
+     * @return \OCP\Share\IShare
500
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
501
+     */
502
+    public function setParent($parent) {
503
+        $this->parent = $parent;
504
+        return $this;
505
+    }
506
+
507
+    /**
508
+     * Get the parent of this share.
509
+     *
510
+     * @return int
511
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
512
+     */
513
+    public function getParent() {
514
+        return $this->parent;
515
+    }
516
+
517
+    /**
518
+     * @inheritdoc
519
+     */
520
+    public function setTarget($target) {
521
+        $this->target = $target;
522
+        return $this;
523
+    }
524
+
525
+    /**
526
+     * @inheritdoc
527
+     */
528
+    public function getTarget() {
529
+        return $this->target;
530
+    }
531
+
532
+    /**
533
+     * @inheritdoc
534
+     */
535
+    public function setShareTime(\DateTime $shareTime) {
536
+        $this->shareTime = $shareTime;
537
+        return $this;
538
+    }
539
+
540
+    /**
541
+     * @inheritdoc
542
+     */
543
+    public function getShareTime() {
544
+        return $this->shareTime;
545
+    }
546
+
547
+    /**
548
+     * @inheritdoc
549
+     */
550
+    public function setMailSend($mailSend) {
551
+        $this->mailSend = $mailSend;
552
+        return $this;
553
+    }
554
+
555
+    /**
556
+     * @inheritdoc
557
+     */
558
+    public function getMailSend() {
559
+        return $this->mailSend;
560
+    }
561
+
562
+    /**
563
+     * @inheritdoc
564
+     */
565
+    public function setNodeCacheEntry(ICacheEntry $entry) {
566
+        $this->nodeCacheEntry = $entry;
567
+    }
568
+
569
+    /**
570
+     * @inheritdoc
571
+     */
572
+    public function getNodeCacheEntry() {
573
+        return $this->nodeCacheEntry;
574
+    }
575
+
576
+    public function setHideDownload(bool $hide): IShare {
577
+        $this->hideDownload = $hide;
578
+        return $this;
579
+    }
580
+
581
+    public function getHideDownload(): bool {
582
+        return $this->hideDownload;
583
+    }
584 584
 }
Please login to merge, or discard this patch.
lib/private/Repair/MoveUpdaterStepFile.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 
29 29
 class MoveUpdaterStepFile implements IRepairStep {
30 30
 
31
-	/** @var \OCP\IConfig */
32
-	protected $config;
31
+    /** @var \OCP\IConfig */
32
+    protected $config;
33 33
 
34
-	/**
35
-	 * @param \OCP\IConfig $config
36
-	 */
37
-	public function __construct($config) {
38
-		$this->config = $config;
39
-	}
34
+    /**
35
+     * @param \OCP\IConfig $config
36
+     */
37
+    public function __construct($config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	public function getName() {
42
-		return 'Move .step file of updater to backup location';
43
-	}
41
+    public function getName() {
42
+        return 'Move .step file of updater to backup location';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
46
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
47
-		$instanceId = $this->config->getSystemValue('instanceid', null);
45
+    public function run(IOutput $output) {
46
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
47
+        $instanceId = $this->config->getSystemValue('instanceid', null);
48 48
 
49
-		if (!is_string($instanceId) || empty($instanceId)) {
50
-			return;
51
-		}
49
+        if (!is_string($instanceId) || empty($instanceId)) {
50
+            return;
51
+        }
52 52
 
53
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
54
-		$stepFile = $updaterFolderPath . '/.step';
55
-		if (file_exists($stepFile)) {
56
-			$output->info('.step file exists');
53
+        $updaterFolderPath = $dataDir . '/updater-' . $instanceId;
54
+        $stepFile = $updaterFolderPath . '/.step';
55
+        if (file_exists($stepFile)) {
56
+            $output->info('.step file exists');
57 57
 
58
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
58
+            $previousStepFile = $updaterFolderPath . '/.step-previous-update';
59 59
 
60
-			// cleanup
61
-			if (file_exists($previousStepFile)) {
62
-				if (\OC_Helper::rmdirr($previousStepFile)) {
63
-					$output->info('.step-previous-update removed');
64
-				} else {
65
-					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
66
-					return;
67
-				}
68
-			}
60
+            // cleanup
61
+            if (file_exists($previousStepFile)) {
62
+                if (\OC_Helper::rmdirr($previousStepFile)) {
63
+                    $output->info('.step-previous-update removed');
64
+                } else {
65
+                    $output->info('.step-previous-update can\'t be removed - abort move of .step file');
66
+                    return;
67
+                }
68
+            }
69 69
 
70
-			// move step file
71
-			if (rename($stepFile, $previousStepFile)) {
72
-				$output->info('.step file moved to .step-previous-update');
73
-			} else {
74
-				$output->warning('.step file can\'t be moved');
75
-			}
76
-		}
77
-	}
70
+            // move step file
71
+            if (rename($stepFile, $previousStepFile)) {
72
+                $output->info('.step file moved to .step-previous-update');
73
+            } else {
74
+                $output->warning('.step file can\'t be moved');
75
+            }
76
+        }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	public function run(IOutput $output) {
46
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
46
+		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
47 47
 		$instanceId = $this->config->getSystemValue('instanceid', null);
48 48
 
49 49
 		if (!is_string($instanceId) || empty($instanceId)) {
50 50
 			return;
51 51
 		}
52 52
 
53
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
54
-		$stepFile = $updaterFolderPath . '/.step';
53
+		$updaterFolderPath = $dataDir.'/updater-'.$instanceId;
54
+		$stepFile = $updaterFolderPath.'/.step';
55 55
 		if (file_exists($stepFile)) {
56 56
 			$output->info('.step file exists');
57 57
 
58
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
58
+			$previousStepFile = $updaterFolderPath.'/.step-previous-update';
59 59
 
60 60
 			// cleanup
61 61
 			if (file_exists($previousStepFile)) {
Please login to merge, or discard this patch.
lib/private/Share/SearchResultSorter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 	public function sort($a, $b) {
54 54
 		if (!isset($a[$this->key]) || !isset($b[$this->key])) {
55 55
 			if (!is_null($this->log)) {
56
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
56
+				$this->log->error('Sharing dialogue: cannot sort due to '.
57 57
 								  'missing array key', ['app' => 'core']);
58 58
 			}
59 59
 			return 0;
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
 use OCP\ILogger;
30 30
 
31 31
 class SearchResultSorter {
32
-	private $search;
33
-	private $encoding;
34
-	private $key;
35
-	private $log;
32
+    private $search;
33
+    private $encoding;
34
+    private $key;
35
+    private $log;
36 36
 
37
-	/**
38
-	 * @param string $search the search term as was given by the user
39
-	 * @param string $key the array key containing the value that should be compared
40
-	 * against
41
-	 * @param string $encoding optional, encoding to use, defaults to UTF-8
42
-	 * @param ILogger $log optional
43
-	 */
44
-	public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
45
-		$this->encoding = $encoding;
46
-		$this->key = $key;
47
-		$this->log = $log;
48
-		$this->search = mb_strtolower($search, $this->encoding);
49
-	}
37
+    /**
38
+     * @param string $search the search term as was given by the user
39
+     * @param string $key the array key containing the value that should be compared
40
+     * against
41
+     * @param string $encoding optional, encoding to use, defaults to UTF-8
42
+     * @param ILogger $log optional
43
+     */
44
+    public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
45
+        $this->encoding = $encoding;
46
+        $this->key = $key;
47
+        $this->log = $log;
48
+        $this->search = mb_strtolower($search, $this->encoding);
49
+    }
50 50
 
51
-	/**
52
-	 * User and Group names matching the search term at the beginning shall appear
53
-	 * on top of the share dialog. Following entries in alphabetical order.
54
-	 * Callback function for usort. https://www.php.net/usort
55
-	 */
56
-	public function sort($a, $b) {
57
-		if (!isset($a[$this->key]) || !isset($b[$this->key])) {
58
-			if (!is_null($this->log)) {
59
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
60
-								  'missing array key', ['app' => 'core']);
61
-			}
62
-			return 0;
63
-		}
64
-		$nameA = mb_strtolower($a[$this->key], $this->encoding);
65
-		$nameB = mb_strtolower($b[$this->key], $this->encoding);
66
-		$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
67
-		$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
51
+    /**
52
+     * User and Group names matching the search term at the beginning shall appear
53
+     * on top of the share dialog. Following entries in alphabetical order.
54
+     * Callback function for usort. https://www.php.net/usort
55
+     */
56
+    public function sort($a, $b) {
57
+        if (!isset($a[$this->key]) || !isset($b[$this->key])) {
58
+            if (!is_null($this->log)) {
59
+                $this->log->error('Sharing dialogue: cannot sort due to ' .
60
+                                    'missing array key', ['app' => 'core']);
61
+            }
62
+            return 0;
63
+        }
64
+        $nameA = mb_strtolower($a[$this->key], $this->encoding);
65
+        $nameB = mb_strtolower($b[$this->key], $this->encoding);
66
+        $i = mb_strpos($nameA, $this->search, 0, $this->encoding);
67
+        $j = mb_strpos($nameB, $this->search, 0, $this->encoding);
68 68
 
69
-		if ($i === $j || $i > 0 && $j > 0) {
70
-			return strcmp(mb_strtolower($nameA, $this->encoding),
71
-						  mb_strtolower($nameB, $this->encoding));
72
-		} elseif ($i === 0) {
73
-			return -1;
74
-		} else {
75
-			return 1;
76
-		}
77
-	}
69
+        if ($i === $j || $i > 0 && $j > 0) {
70
+            return strcmp(mb_strtolower($nameA, $this->encoding),
71
+                            mb_strtolower($nameB, $this->encoding));
72
+        } elseif ($i === 0) {
73
+            return -1;
74
+        } else {
75
+            return 1;
76
+        }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
lib/private/CapabilitiesManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
61 61
 				}
62 62
 			} else {
63
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
63
+				throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface');
64 64
 			}
65 65
 		}
66 66
 
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -36,56 +36,56 @@
 block discarded – undo
36 36
 
37 37
 class CapabilitiesManager {
38 38
 
39
-	/** @var \Closure[] */
40
-	private $capabilities = [];
39
+    /** @var \Closure[] */
40
+    private $capabilities = [];
41 41
 
42
-	/** @var LoggerInterface */
43
-	private $logger;
42
+    /** @var LoggerInterface */
43
+    private $logger;
44 44
 
45
-	public function __construct(LoggerInterface $logger) {
46
-		$this->logger = $logger;
47
-	}
45
+    public function __construct(LoggerInterface $logger) {
46
+        $this->logger = $logger;
47
+    }
48 48
 
49
-	/**
50
-	 * Get an array of al the capabilities that are registered at this manager
51
-	 *
52
-	 * @param bool $public get public capabilities only
53
-	 * @throws \InvalidArgumentException
54
-	 * @return array
55
-	 */
56
-	public function getCapabilities(bool $public = false) : array {
57
-		$capabilities = [];
58
-		foreach ($this->capabilities as $capability) {
59
-			try {
60
-				$c = $capability();
61
-			} catch (QueryException $e) {
62
-				$this->logger->error('CapabilitiesManager', [
63
-					'exception' => $e,
64
-				]);
65
-				continue;
66
-			}
49
+    /**
50
+     * Get an array of al the capabilities that are registered at this manager
51
+     *
52
+     * @param bool $public get public capabilities only
53
+     * @throws \InvalidArgumentException
54
+     * @return array
55
+     */
56
+    public function getCapabilities(bool $public = false) : array {
57
+        $capabilities = [];
58
+        foreach ($this->capabilities as $capability) {
59
+            try {
60
+                $c = $capability();
61
+            } catch (QueryException $e) {
62
+                $this->logger->error('CapabilitiesManager', [
63
+                    'exception' => $e,
64
+                ]);
65
+                continue;
66
+            }
67 67
 
68
-			if ($c instanceof ICapability) {
69
-				if (!$public || $c instanceof IPublicCapability) {
70
-					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
71
-				}
72
-			} else {
73
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
74
-			}
75
-		}
68
+            if ($c instanceof ICapability) {
69
+                if (!$public || $c instanceof IPublicCapability) {
70
+                    $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
71
+                }
72
+            } else {
73
+                throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
74
+            }
75
+        }
76 76
 
77
-		return $capabilities;
78
-	}
77
+        return $capabilities;
78
+    }
79 79
 
80
-	/**
81
-	 * In order to improve lazy loading a closure can be registered which will be called in case
82
-	 * capabilities are actually requested
83
-	 *
84
-	 * $callable has to return an instance of OCP\Capabilities\ICapability
85
-	 *
86
-	 * @param \Closure $callable
87
-	 */
88
-	public function registerCapability(\Closure $callable) {
89
-		$this->capabilities[] = $callable;
90
-	}
80
+    /**
81
+     * In order to improve lazy loading a closure can be registered which will be called in case
82
+     * capabilities are actually requested
83
+     *
84
+     * $callable has to return an instance of OCP\Capabilities\ICapability
85
+     *
86
+     * @param \Closure $callable
87
+     */
88
+    public function registerCapability(\Closure $callable) {
89
+        $this->capabilities[] = $callable;
90
+    }
91 91
 }
Please login to merge, or discard this patch.
lib/private/OCS/Result.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 	 * @return $this
136 136
 	 */
137 137
 	public function addHeader($name, $value) {
138
-		$name = trim($name);  // always remove leading and trailing whitespace
138
+		$name = trim($name); // always remove leading and trailing whitespace
139 139
 		// to be able to reliably check for security
140 140
 		// headers
141 141
 
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -33,127 +33,127 @@
 block discarded – undo
33 33
 
34 34
 class Result {
35 35
 
36
-	/** @var array  */
37
-	protected $data;
38
-
39
-	/** @var null|string */
40
-	protected $message;
41
-
42
-	/** @var int */
43
-	protected $statusCode;
44
-
45
-	/** @var integer */
46
-	protected $items;
47
-
48
-	/** @var integer */
49
-	protected $perPage;
50
-
51
-	/** @var array */
52
-	private $headers = [];
53
-
54
-	/**
55
-	 * create the OCS_Result object
56
-	 * @param mixed $data the data to return
57
-	 * @param int $code
58
-	 * @param null|string $message
59
-	 * @param array $headers
60
-	 */
61
-	public function __construct($data = null, $code = 100, $message = null, $headers = []) {
62
-		if ($data === null) {
63
-			$this->data = [];
64
-		} elseif (!is_array($data)) {
65
-			$this->data = [$this->data];
66
-		} else {
67
-			$this->data = $data;
68
-		}
69
-		$this->statusCode = $code;
70
-		$this->message = $message;
71
-		$this->headers = $headers;
72
-	}
73
-
74
-	/**
75
-	 * optionally set the total number of items available
76
-	 * @param int $items
77
-	 */
78
-	public function setTotalItems($items) {
79
-		$this->items = $items;
80
-	}
81
-
82
-	/**
83
-	 * optionally set the the number of items per page
84
-	 * @param int $items
85
-	 */
86
-	public function setItemsPerPage($items) {
87
-		$this->perPage = $items;
88
-	}
89
-
90
-	/**
91
-	 * get the status code
92
-	 * @return int
93
-	 */
94
-	public function getStatusCode() {
95
-		return $this->statusCode;
96
-	}
97
-
98
-	/**
99
-	 * get the meta data for the result
100
-	 * @return array
101
-	 */
102
-	public function getMeta() {
103
-		$meta = [];
104
-		$meta['status'] = $this->succeeded() ? 'ok' : 'failure';
105
-		$meta['statuscode'] = $this->statusCode;
106
-		$meta['message'] = $this->message;
107
-		if ($this->items !== null) {
108
-			$meta['totalitems'] = $this->items;
109
-		}
110
-		if ($this->perPage !== null) {
111
-			$meta['itemsperpage'] = $this->perPage;
112
-		}
113
-		return $meta;
114
-	}
115
-
116
-	/**
117
-	 * get the result data
118
-	 * @return array
119
-	 */
120
-	public function getData() {
121
-		return $this->data;
122
-	}
123
-
124
-	/**
125
-	 * return bool Whether the method succeeded
126
-	 * @return bool
127
-	 */
128
-	public function succeeded() {
129
-		return ($this->statusCode == 100);
130
-	}
131
-
132
-	/**
133
-	 * Adds a new header to the response
134
-	 * @param string $name The name of the HTTP header
135
-	 * @param string $value The value, null will delete it
136
-	 * @return $this
137
-	 */
138
-	public function addHeader($name, $value) {
139
-		$name = trim($name);  // always remove leading and trailing whitespace
140
-		// to be able to reliably check for security
141
-		// headers
142
-
143
-		if (is_null($value)) {
144
-			unset($this->headers[$name]);
145
-		} else {
146
-			$this->headers[$name] = $value;
147
-		}
148
-
149
-		return $this;
150
-	}
151
-
152
-	/**
153
-	 * Returns the set headers
154
-	 * @return array the headers
155
-	 */
156
-	public function getHeaders() {
157
-		return $this->headers;
158
-	}
36
+    /** @var array  */
37
+    protected $data;
38
+
39
+    /** @var null|string */
40
+    protected $message;
41
+
42
+    /** @var int */
43
+    protected $statusCode;
44
+
45
+    /** @var integer */
46
+    protected $items;
47
+
48
+    /** @var integer */
49
+    protected $perPage;
50
+
51
+    /** @var array */
52
+    private $headers = [];
53
+
54
+    /**
55
+     * create the OCS_Result object
56
+     * @param mixed $data the data to return
57
+     * @param int $code
58
+     * @param null|string $message
59
+     * @param array $headers
60
+     */
61
+    public function __construct($data = null, $code = 100, $message = null, $headers = []) {
62
+        if ($data === null) {
63
+            $this->data = [];
64
+        } elseif (!is_array($data)) {
65
+            $this->data = [$this->data];
66
+        } else {
67
+            $this->data = $data;
68
+        }
69
+        $this->statusCode = $code;
70
+        $this->message = $message;
71
+        $this->headers = $headers;
72
+    }
73
+
74
+    /**
75
+     * optionally set the total number of items available
76
+     * @param int $items
77
+     */
78
+    public function setTotalItems($items) {
79
+        $this->items = $items;
80
+    }
81
+
82
+    /**
83
+     * optionally set the the number of items per page
84
+     * @param int $items
85
+     */
86
+    public function setItemsPerPage($items) {
87
+        $this->perPage = $items;
88
+    }
89
+
90
+    /**
91
+     * get the status code
92
+     * @return int
93
+     */
94
+    public function getStatusCode() {
95
+        return $this->statusCode;
96
+    }
97
+
98
+    /**
99
+     * get the meta data for the result
100
+     * @return array
101
+     */
102
+    public function getMeta() {
103
+        $meta = [];
104
+        $meta['status'] = $this->succeeded() ? 'ok' : 'failure';
105
+        $meta['statuscode'] = $this->statusCode;
106
+        $meta['message'] = $this->message;
107
+        if ($this->items !== null) {
108
+            $meta['totalitems'] = $this->items;
109
+        }
110
+        if ($this->perPage !== null) {
111
+            $meta['itemsperpage'] = $this->perPage;
112
+        }
113
+        return $meta;
114
+    }
115
+
116
+    /**
117
+     * get the result data
118
+     * @return array
119
+     */
120
+    public function getData() {
121
+        return $this->data;
122
+    }
123
+
124
+    /**
125
+     * return bool Whether the method succeeded
126
+     * @return bool
127
+     */
128
+    public function succeeded() {
129
+        return ($this->statusCode == 100);
130
+    }
131
+
132
+    /**
133
+     * Adds a new header to the response
134
+     * @param string $name The name of the HTTP header
135
+     * @param string $value The value, null will delete it
136
+     * @return $this
137
+     */
138
+    public function addHeader($name, $value) {
139
+        $name = trim($name);  // always remove leading and trailing whitespace
140
+        // to be able to reliably check for security
141
+        // headers
142
+
143
+        if (is_null($value)) {
144
+            unset($this->headers[$name]);
145
+        } else {
146
+            $this->headers[$name] = $value;
147
+        }
148
+
149
+        return $this;
150
+    }
151
+
152
+    /**
153
+     * Returns the set headers
154
+     * @return array the headers
155
+     */
156
+    public function getHeaders() {
157
+        return $this->headers;
158
+    }
159 159
 }
Please login to merge, or discard this patch.
lib/private/Files/FileInfo.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return int|null
152 152
 	 */
153 153
 	public function getId() {
154
-		return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
154
+		return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null;
155 155
 	}
156 156
 
157 157
 	/**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	public function getEtag() {
182 182
 		$this->updateEntryfromSubMounts();
183 183
 		if (count($this->childEtags) > 0) {
184
-			$combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
184
+			$combinedEtag = $this->data['etag'].'::'.implode('::', $this->childEtags);
185 185
 			return md5($combinedEtag);
186 186
 		} else {
187 187
 			return $this->data['etag'];
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$relativeEntryPath = substr($entryPath, strlen($this->getPath()));
378 378
 			// attach the permissions to propagate etag on permision changes of submounts
379 379
 			$permissions = isset($data['permissions']) ? $data['permissions'] : 0;
380
-			$this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
380
+			$this->childEtags[] = $relativeEntryPath.'/'.$data['etag'].$permissions;
381 381
 		}
382 382
 	}
383 383
 
Please login to merge, or discard this patch.
Indentation   +376 added lines, -376 removed lines patch added patch discarded remove patch
@@ -38,380 +38,380 @@
 block discarded – undo
38 38
 use OCP\IUser;
39 39
 
40 40
 class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
41
-	/**
42
-	 * @var array $data
43
-	 */
44
-	private $data;
45
-
46
-	/**
47
-	 * @var string $path
48
-	 */
49
-	private $path;
50
-
51
-	/**
52
-	 * @var \OC\Files\Storage\Storage $storage
53
-	 */
54
-	private $storage;
55
-
56
-	/**
57
-	 * @var string $internalPath
58
-	 */
59
-	private $internalPath;
60
-
61
-	/**
62
-	 * @var \OCP\Files\Mount\IMountPoint
63
-	 */
64
-	private $mount;
65
-
66
-	/**
67
-	 * @var IUser
68
-	 */
69
-	private $owner;
70
-
71
-	/**
72
-	 * @var string[]
73
-	 */
74
-	private $childEtags = [];
75
-
76
-	/**
77
-	 * @var IMountPoint[]
78
-	 */
79
-	private $subMounts = [];
80
-
81
-	private $subMountsUsed = false;
82
-
83
-	/**
84
-	 * The size of the file/folder without any sub mount
85
-	 *
86
-	 * @var int
87
-	 */
88
-	private $rawSize = 0;
89
-
90
-	/**
91
-	 * @param string|boolean $path
92
-	 * @param Storage\Storage $storage
93
-	 * @param string $internalPath
94
-	 * @param array|ICacheEntry $data
95
-	 * @param \OCP\Files\Mount\IMountPoint $mount
96
-	 * @param \OCP\IUser|null $owner
97
-	 */
98
-	public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {
99
-		$this->path = $path;
100
-		$this->storage = $storage;
101
-		$this->internalPath = $internalPath;
102
-		$this->data = $data;
103
-		$this->mount = $mount;
104
-		$this->owner = $owner;
105
-		$this->rawSize = $this->data['size'] ?? 0;
106
-	}
107
-
108
-	public function offsetSet($offset, $value) {
109
-		$this->data[$offset] = $value;
110
-	}
111
-
112
-	public function offsetExists($offset) {
113
-		return isset($this->data[$offset]);
114
-	}
115
-
116
-	public function offsetUnset($offset) {
117
-		unset($this->data[$offset]);
118
-	}
119
-
120
-	public function offsetGet($offset) {
121
-		if ($offset === 'type') {
122
-			return $this->getType();
123
-		} elseif ($offset === 'etag') {
124
-			return $this->getEtag();
125
-		} elseif ($offset === 'size') {
126
-			return $this->getSize();
127
-		} elseif ($offset === 'mtime') {
128
-			return $this->getMTime();
129
-		} elseif ($offset === 'permissions') {
130
-			return $this->getPermissions();
131
-		} elseif (isset($this->data[$offset])) {
132
-			return $this->data[$offset];
133
-		} else {
134
-			return null;
135
-		}
136
-	}
137
-
138
-	/**
139
-	 * @return string
140
-	 */
141
-	public function getPath() {
142
-		return $this->path;
143
-	}
144
-
145
-	/**
146
-	 * @return \OCP\Files\Storage
147
-	 */
148
-	public function getStorage() {
149
-		return $this->storage;
150
-	}
151
-
152
-	/**
153
-	 * @return string
154
-	 */
155
-	public function getInternalPath() {
156
-		return $this->internalPath;
157
-	}
158
-
159
-	/**
160
-	 * Get FileInfo ID or null in case of part file
161
-	 *
162
-	 * @return int|null
163
-	 */
164
-	public function getId() {
165
-		return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
166
-	}
167
-
168
-	/**
169
-	 * @return string
170
-	 */
171
-	public function getMimetype() {
172
-		return $this->data['mimetype'];
173
-	}
174
-
175
-	/**
176
-	 * @return string
177
-	 */
178
-	public function getMimePart() {
179
-		return $this->data['mimepart'];
180
-	}
181
-
182
-	/**
183
-	 * @return string
184
-	 */
185
-	public function getName() {
186
-		return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath());
187
-	}
188
-
189
-	/**
190
-	 * @return string
191
-	 */
192
-	public function getEtag() {
193
-		$this->updateEntryfromSubMounts();
194
-		if (count($this->childEtags) > 0) {
195
-			$combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
196
-			return md5($combinedEtag);
197
-		} else {
198
-			return $this->data['etag'];
199
-		}
200
-	}
201
-
202
-	/**
203
-	 * @return int
204
-	 */
205
-	public function getSize($includeMounts = true) {
206
-		if ($includeMounts) {
207
-			$this->updateEntryfromSubMounts();
208
-			return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
209
-		} else {
210
-			return $this->rawSize;
211
-		}
212
-	}
213
-
214
-	/**
215
-	 * @return int
216
-	 */
217
-	public function getMTime() {
218
-		$this->updateEntryfromSubMounts();
219
-		return (int) $this->data['mtime'];
220
-	}
221
-
222
-	/**
223
-	 * @return bool
224
-	 */
225
-	public function isEncrypted() {
226
-		return $this->data['encrypted'];
227
-	}
228
-
229
-	/**
230
-	 * Return the currently version used for the HMAC in the encryption app
231
-	 *
232
-	 * @return int
233
-	 */
234
-	public function getEncryptedVersion() {
235
-		return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1;
236
-	}
237
-
238
-	/**
239
-	 * @return int
240
-	 */
241
-	public function getPermissions() {
242
-		$perms = (int) $this->data['permissions'];
243
-		if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
244
-			$perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
245
-		}
246
-		return $perms;
247
-	}
248
-
249
-	/**
250
-	 * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
251
-	 */
252
-	public function getType() {
253
-		if (!isset($this->data['type'])) {
254
-			$this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
255
-		}
256
-		return $this->data['type'];
257
-	}
258
-
259
-	public function getData() {
260
-		return $this->data;
261
-	}
262
-
263
-	/**
264
-	 * @param int $permissions
265
-	 * @return bool
266
-	 */
267
-	protected function checkPermissions($permissions) {
268
-		return ($this->getPermissions() & $permissions) === $permissions;
269
-	}
270
-
271
-	/**
272
-	 * @return bool
273
-	 */
274
-	public function isReadable() {
275
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
276
-	}
277
-
278
-	/**
279
-	 * @return bool
280
-	 */
281
-	public function isUpdateable() {
282
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
283
-	}
284
-
285
-	/**
286
-	 * Check whether new files or folders can be created inside this folder
287
-	 *
288
-	 * @return bool
289
-	 */
290
-	public function isCreatable() {
291
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
292
-	}
293
-
294
-	/**
295
-	 * @return bool
296
-	 */
297
-	public function isDeletable() {
298
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
299
-	}
300
-
301
-	/**
302
-	 * @return bool
303
-	 */
304
-	public function isShareable() {
305
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
306
-	}
307
-
308
-	/**
309
-	 * Check if a file or folder is shared
310
-	 *
311
-	 * @return bool
312
-	 */
313
-	public function isShared() {
314
-		$sid = $this->getStorage()->getId();
315
-		if (!is_null($sid)) {
316
-			$sid = explode(':', $sid);
317
-			return ($sid[0] === 'shared');
318
-		}
319
-
320
-		return false;
321
-	}
322
-
323
-	public function isMounted() {
324
-		$storage = $this->getStorage();
325
-		if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
326
-			return false;
327
-		}
328
-		$sid = $storage->getId();
329
-		if (!is_null($sid)) {
330
-			$sid = explode(':', $sid);
331
-			return ($sid[0] !== 'home' and $sid[0] !== 'shared');
332
-		}
333
-
334
-		return false;
335
-	}
336
-
337
-	/**
338
-	 * Get the mountpoint the file belongs to
339
-	 *
340
-	 * @return \OCP\Files\Mount\IMountPoint
341
-	 */
342
-	public function getMountPoint() {
343
-		return $this->mount;
344
-	}
345
-
346
-	/**
347
-	 * Get the owner of the file
348
-	 *
349
-	 * @return \OCP\IUser
350
-	 */
351
-	public function getOwner() {
352
-		return $this->owner;
353
-	}
354
-
355
-	/**
356
-	 * @param IMountPoint[] $mounts
357
-	 */
358
-	public function setSubMounts(array $mounts) {
359
-		$this->subMounts = $mounts;
360
-	}
361
-
362
-	private function updateEntryfromSubMounts() {
363
-		if ($this->subMountsUsed) {
364
-			return;
365
-		}
366
-		$this->subMountsUsed = true;
367
-		foreach ($this->subMounts as $mount) {
368
-			$subStorage = $mount->getStorage();
369
-			if ($subStorage) {
370
-				$subCache = $subStorage->getCache('');
371
-				$rootEntry = $subCache->get('');
372
-				$this->addSubEntry($rootEntry, $mount->getMountPoint());
373
-			}
374
-		}
375
-	}
376
-
377
-	/**
378
-	 * Add a cache entry which is the child of this folder
379
-	 *
380
-	 * Sets the size, etag and size to for cross-storage childs
381
-	 *
382
-	 * @param array|ICacheEntry $data cache entry for the child
383
-	 * @param string $entryPath full path of the child entry
384
-	 */
385
-	public function addSubEntry($data, $entryPath) {
386
-		$this->data['size'] += isset($data['size']) ? $data['size'] : 0;
387
-		if (isset($data['mtime'])) {
388
-			$this->data['mtime'] = max($this->data['mtime'], $data['mtime']);
389
-		}
390
-		if (isset($data['etag'])) {
391
-			// prefix the etag with the relative path of the subentry to propagate etag on mount moves
392
-			$relativeEntryPath = substr($entryPath, strlen($this->getPath()));
393
-			// attach the permissions to propagate etag on permision changes of submounts
394
-			$permissions = isset($data['permissions']) ? $data['permissions'] : 0;
395
-			$this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
396
-		}
397
-	}
398
-
399
-	/**
400
-	 * @inheritdoc
401
-	 */
402
-	public function getChecksum() {
403
-		return $this->data['checksum'];
404
-	}
405
-
406
-	public function getExtension(): string {
407
-		return pathinfo($this->getName(), PATHINFO_EXTENSION);
408
-	}
409
-
410
-	public function getCreationTime(): int {
411
-		return (int) $this->data['creation_time'];
412
-	}
413
-
414
-	public function getUploadTime(): int {
415
-		return (int) $this->data['upload_time'];
416
-	}
41
+    /**
42
+     * @var array $data
43
+     */
44
+    private $data;
45
+
46
+    /**
47
+     * @var string $path
48
+     */
49
+    private $path;
50
+
51
+    /**
52
+     * @var \OC\Files\Storage\Storage $storage
53
+     */
54
+    private $storage;
55
+
56
+    /**
57
+     * @var string $internalPath
58
+     */
59
+    private $internalPath;
60
+
61
+    /**
62
+     * @var \OCP\Files\Mount\IMountPoint
63
+     */
64
+    private $mount;
65
+
66
+    /**
67
+     * @var IUser
68
+     */
69
+    private $owner;
70
+
71
+    /**
72
+     * @var string[]
73
+     */
74
+    private $childEtags = [];
75
+
76
+    /**
77
+     * @var IMountPoint[]
78
+     */
79
+    private $subMounts = [];
80
+
81
+    private $subMountsUsed = false;
82
+
83
+    /**
84
+     * The size of the file/folder without any sub mount
85
+     *
86
+     * @var int
87
+     */
88
+    private $rawSize = 0;
89
+
90
+    /**
91
+     * @param string|boolean $path
92
+     * @param Storage\Storage $storage
93
+     * @param string $internalPath
94
+     * @param array|ICacheEntry $data
95
+     * @param \OCP\Files\Mount\IMountPoint $mount
96
+     * @param \OCP\IUser|null $owner
97
+     */
98
+    public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {
99
+        $this->path = $path;
100
+        $this->storage = $storage;
101
+        $this->internalPath = $internalPath;
102
+        $this->data = $data;
103
+        $this->mount = $mount;
104
+        $this->owner = $owner;
105
+        $this->rawSize = $this->data['size'] ?? 0;
106
+    }
107
+
108
+    public function offsetSet($offset, $value) {
109
+        $this->data[$offset] = $value;
110
+    }
111
+
112
+    public function offsetExists($offset) {
113
+        return isset($this->data[$offset]);
114
+    }
115
+
116
+    public function offsetUnset($offset) {
117
+        unset($this->data[$offset]);
118
+    }
119
+
120
+    public function offsetGet($offset) {
121
+        if ($offset === 'type') {
122
+            return $this->getType();
123
+        } elseif ($offset === 'etag') {
124
+            return $this->getEtag();
125
+        } elseif ($offset === 'size') {
126
+            return $this->getSize();
127
+        } elseif ($offset === 'mtime') {
128
+            return $this->getMTime();
129
+        } elseif ($offset === 'permissions') {
130
+            return $this->getPermissions();
131
+        } elseif (isset($this->data[$offset])) {
132
+            return $this->data[$offset];
133
+        } else {
134
+            return null;
135
+        }
136
+    }
137
+
138
+    /**
139
+     * @return string
140
+     */
141
+    public function getPath() {
142
+        return $this->path;
143
+    }
144
+
145
+    /**
146
+     * @return \OCP\Files\Storage
147
+     */
148
+    public function getStorage() {
149
+        return $this->storage;
150
+    }
151
+
152
+    /**
153
+     * @return string
154
+     */
155
+    public function getInternalPath() {
156
+        return $this->internalPath;
157
+    }
158
+
159
+    /**
160
+     * Get FileInfo ID or null in case of part file
161
+     *
162
+     * @return int|null
163
+     */
164
+    public function getId() {
165
+        return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
166
+    }
167
+
168
+    /**
169
+     * @return string
170
+     */
171
+    public function getMimetype() {
172
+        return $this->data['mimetype'];
173
+    }
174
+
175
+    /**
176
+     * @return string
177
+     */
178
+    public function getMimePart() {
179
+        return $this->data['mimepart'];
180
+    }
181
+
182
+    /**
183
+     * @return string
184
+     */
185
+    public function getName() {
186
+        return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath());
187
+    }
188
+
189
+    /**
190
+     * @return string
191
+     */
192
+    public function getEtag() {
193
+        $this->updateEntryfromSubMounts();
194
+        if (count($this->childEtags) > 0) {
195
+            $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
196
+            return md5($combinedEtag);
197
+        } else {
198
+            return $this->data['etag'];
199
+        }
200
+    }
201
+
202
+    /**
203
+     * @return int
204
+     */
205
+    public function getSize($includeMounts = true) {
206
+        if ($includeMounts) {
207
+            $this->updateEntryfromSubMounts();
208
+            return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
209
+        } else {
210
+            return $this->rawSize;
211
+        }
212
+    }
213
+
214
+    /**
215
+     * @return int
216
+     */
217
+    public function getMTime() {
218
+        $this->updateEntryfromSubMounts();
219
+        return (int) $this->data['mtime'];
220
+    }
221
+
222
+    /**
223
+     * @return bool
224
+     */
225
+    public function isEncrypted() {
226
+        return $this->data['encrypted'];
227
+    }
228
+
229
+    /**
230
+     * Return the currently version used for the HMAC in the encryption app
231
+     *
232
+     * @return int
233
+     */
234
+    public function getEncryptedVersion() {
235
+        return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1;
236
+    }
237
+
238
+    /**
239
+     * @return int
240
+     */
241
+    public function getPermissions() {
242
+        $perms = (int) $this->data['permissions'];
243
+        if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
244
+            $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
245
+        }
246
+        return $perms;
247
+    }
248
+
249
+    /**
250
+     * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
251
+     */
252
+    public function getType() {
253
+        if (!isset($this->data['type'])) {
254
+            $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
255
+        }
256
+        return $this->data['type'];
257
+    }
258
+
259
+    public function getData() {
260
+        return $this->data;
261
+    }
262
+
263
+    /**
264
+     * @param int $permissions
265
+     * @return bool
266
+     */
267
+    protected function checkPermissions($permissions) {
268
+        return ($this->getPermissions() & $permissions) === $permissions;
269
+    }
270
+
271
+    /**
272
+     * @return bool
273
+     */
274
+    public function isReadable() {
275
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
276
+    }
277
+
278
+    /**
279
+     * @return bool
280
+     */
281
+    public function isUpdateable() {
282
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
283
+    }
284
+
285
+    /**
286
+     * Check whether new files or folders can be created inside this folder
287
+     *
288
+     * @return bool
289
+     */
290
+    public function isCreatable() {
291
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
292
+    }
293
+
294
+    /**
295
+     * @return bool
296
+     */
297
+    public function isDeletable() {
298
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
299
+    }
300
+
301
+    /**
302
+     * @return bool
303
+     */
304
+    public function isShareable() {
305
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
306
+    }
307
+
308
+    /**
309
+     * Check if a file or folder is shared
310
+     *
311
+     * @return bool
312
+     */
313
+    public function isShared() {
314
+        $sid = $this->getStorage()->getId();
315
+        if (!is_null($sid)) {
316
+            $sid = explode(':', $sid);
317
+            return ($sid[0] === 'shared');
318
+        }
319
+
320
+        return false;
321
+    }
322
+
323
+    public function isMounted() {
324
+        $storage = $this->getStorage();
325
+        if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
326
+            return false;
327
+        }
328
+        $sid = $storage->getId();
329
+        if (!is_null($sid)) {
330
+            $sid = explode(':', $sid);
331
+            return ($sid[0] !== 'home' and $sid[0] !== 'shared');
332
+        }
333
+
334
+        return false;
335
+    }
336
+
337
+    /**
338
+     * Get the mountpoint the file belongs to
339
+     *
340
+     * @return \OCP\Files\Mount\IMountPoint
341
+     */
342
+    public function getMountPoint() {
343
+        return $this->mount;
344
+    }
345
+
346
+    /**
347
+     * Get the owner of the file
348
+     *
349
+     * @return \OCP\IUser
350
+     */
351
+    public function getOwner() {
352
+        return $this->owner;
353
+    }
354
+
355
+    /**
356
+     * @param IMountPoint[] $mounts
357
+     */
358
+    public function setSubMounts(array $mounts) {
359
+        $this->subMounts = $mounts;
360
+    }
361
+
362
+    private function updateEntryfromSubMounts() {
363
+        if ($this->subMountsUsed) {
364
+            return;
365
+        }
366
+        $this->subMountsUsed = true;
367
+        foreach ($this->subMounts as $mount) {
368
+            $subStorage = $mount->getStorage();
369
+            if ($subStorage) {
370
+                $subCache = $subStorage->getCache('');
371
+                $rootEntry = $subCache->get('');
372
+                $this->addSubEntry($rootEntry, $mount->getMountPoint());
373
+            }
374
+        }
375
+    }
376
+
377
+    /**
378
+     * Add a cache entry which is the child of this folder
379
+     *
380
+     * Sets the size, etag and size to for cross-storage childs
381
+     *
382
+     * @param array|ICacheEntry $data cache entry for the child
383
+     * @param string $entryPath full path of the child entry
384
+     */
385
+    public function addSubEntry($data, $entryPath) {
386
+        $this->data['size'] += isset($data['size']) ? $data['size'] : 0;
387
+        if (isset($data['mtime'])) {
388
+            $this->data['mtime'] = max($this->data['mtime'], $data['mtime']);
389
+        }
390
+        if (isset($data['etag'])) {
391
+            // prefix the etag with the relative path of the subentry to propagate etag on mount moves
392
+            $relativeEntryPath = substr($entryPath, strlen($this->getPath()));
393
+            // attach the permissions to propagate etag on permision changes of submounts
394
+            $permissions = isset($data['permissions']) ? $data['permissions'] : 0;
395
+            $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
396
+        }
397
+    }
398
+
399
+    /**
400
+     * @inheritdoc
401
+     */
402
+    public function getChecksum() {
403
+        return $this->data['checksum'];
404
+    }
405
+
406
+    public function getExtension(): string {
407
+        return pathinfo($this->getName(), PATHINFO_EXTENSION);
408
+    }
409
+
410
+    public function getCreationTime(): int {
411
+        return (int) $this->data['creation_time'];
412
+    }
413
+
414
+    public function getUploadTime(): int {
415
+        return (int) $this->data['upload_time'];
416
+    }
417 417
 }
Please login to merge, or discard this patch.