Passed
Push — master ( f305c6...0d75a3 )
by Julius
15:22 queued 12s
created
lib/private/Encryption/File.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 		// always add owner to the list of users with access to the file
74 74
 		$userIds = [$owner];
75 75
 
76
-		if (!$this->util->isFile($owner . '/' . $ownerPath)) {
76
+		if (!$this->util->isFile($owner.'/'.$ownerPath)) {
77 77
 			return ['users' => $userIds, 'public' => false];
78 78
 		}
79 79
 
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -35,98 +35,98 @@
 block discarded – undo
35 35
 use OCP\Share\IManager;
36 36
 
37 37
 class File implements \OCP\Encryption\IFile {
38
-	protected Util $util;
39
-	private IRootFolder $rootFolder;
40
-	private IManager $shareManager;
38
+    protected Util $util;
39
+    private IRootFolder $rootFolder;
40
+    private IManager $shareManager;
41 41
 
42
-	/**
43
-	 * Cache results of already checked folders
44
-	 * @var CappedMemoryCache<array>
45
-	 */
46
-	protected CappedMemoryCache $cache;
47
-	private ?IAppManager $appManager = null;
42
+    /**
43
+     * Cache results of already checked folders
44
+     * @var CappedMemoryCache<array>
45
+     */
46
+    protected CappedMemoryCache $cache;
47
+    private ?IAppManager $appManager = null;
48 48
 
49
-	public function __construct(Util $util,
50
-								IRootFolder $rootFolder,
51
-								IManager $shareManager) {
52
-		$this->util = $util;
53
-		$this->cache = new CappedMemoryCache();
54
-		$this->rootFolder = $rootFolder;
55
-		$this->shareManager = $shareManager;
56
-	}
49
+    public function __construct(Util $util,
50
+                                IRootFolder $rootFolder,
51
+                                IManager $shareManager) {
52
+        $this->util = $util;
53
+        $this->cache = new CappedMemoryCache();
54
+        $this->rootFolder = $rootFolder;
55
+        $this->shareManager = $shareManager;
56
+    }
57 57
 
58
-	public function getAppManager(): IAppManager {
59
-		// Lazy evaluate app manager as it initialize the db too early otherwise
60
-		if ($this->appManager) {
61
-			return $this->appManager;
62
-		}
63
-		$this->appManager = \OCP\Server::get(IAppManager::class);
64
-		return $this->appManager;
65
-	}
58
+    public function getAppManager(): IAppManager {
59
+        // Lazy evaluate app manager as it initialize the db too early otherwise
60
+        if ($this->appManager) {
61
+            return $this->appManager;
62
+        }
63
+        $this->appManager = \OCP\Server::get(IAppManager::class);
64
+        return $this->appManager;
65
+    }
66 66
 
67
-	/**
68
-	 * Get list of users with access to the file
69
-	 *
70
-	 * @param string $path to the file
71
-	 * @return array{users: string[], public: bool}
72
-	 */
73
-	public function getAccessList($path) {
74
-		// Make sure that a share key is generated for the owner too
75
-		[$owner, $ownerPath] = $this->util->getUidAndFilename($path);
67
+    /**
68
+     * Get list of users with access to the file
69
+     *
70
+     * @param string $path to the file
71
+     * @return array{users: string[], public: bool}
72
+     */
73
+    public function getAccessList($path) {
74
+        // Make sure that a share key is generated for the owner too
75
+        [$owner, $ownerPath] = $this->util->getUidAndFilename($path);
76 76
 
77
-		// always add owner to the list of users with access to the file
78
-		$userIds = [$owner];
77
+        // always add owner to the list of users with access to the file
78
+        $userIds = [$owner];
79 79
 
80
-		if (!$this->util->isFile($owner . '/' . $ownerPath)) {
81
-			return ['users' => $userIds, 'public' => false];
82
-		}
80
+        if (!$this->util->isFile($owner . '/' . $ownerPath)) {
81
+            return ['users' => $userIds, 'public' => false];
82
+        }
83 83
 
84
-		$ownerPath = substr($ownerPath, strlen('/files'));
85
-		$userFolder = $this->rootFolder->getUserFolder($owner);
86
-		try {
87
-			$file = $userFolder->get($ownerPath);
88
-		} catch (NotFoundException $e) {
89
-			$file = null;
90
-		}
91
-		$ownerPath = $this->util->stripPartialFileExtension($ownerPath);
84
+        $ownerPath = substr($ownerPath, strlen('/files'));
85
+        $userFolder = $this->rootFolder->getUserFolder($owner);
86
+        try {
87
+            $file = $userFolder->get($ownerPath);
88
+        } catch (NotFoundException $e) {
89
+            $file = null;
90
+        }
91
+        $ownerPath = $this->util->stripPartialFileExtension($ownerPath);
92 92
 
93
-		// first get the shares for the parent and cache the result so that we don't
94
-		// need to check all parents for every file
95
-		$parent = dirname($ownerPath);
96
-		$parentNode = $userFolder->get($parent);
97
-		if (isset($this->cache[$parent])) {
98
-			$resultForParents = $this->cache[$parent];
99
-		} else {
100
-			$resultForParents = $this->shareManager->getAccessList($parentNode);
101
-			$this->cache[$parent] = $resultForParents;
102
-		}
103
-		$userIds = array_merge($userIds, $resultForParents['users']);
104
-		$public = $resultForParents['public'] || $resultForParents['remote'];
93
+        // first get the shares for the parent and cache the result so that we don't
94
+        // need to check all parents for every file
95
+        $parent = dirname($ownerPath);
96
+        $parentNode = $userFolder->get($parent);
97
+        if (isset($this->cache[$parent])) {
98
+            $resultForParents = $this->cache[$parent];
99
+        } else {
100
+            $resultForParents = $this->shareManager->getAccessList($parentNode);
101
+            $this->cache[$parent] = $resultForParents;
102
+        }
103
+        $userIds = array_merge($userIds, $resultForParents['users']);
104
+        $public = $resultForParents['public'] || $resultForParents['remote'];
105 105
 
106 106
 
107
-		// Find out who, if anyone, is sharing the file
108
-		if ($file !== null) {
109
-			$resultForFile = $this->shareManager->getAccessList($file, false);
110
-			$userIds = array_merge($userIds, $resultForFile['users']);
111
-			$public = $resultForFile['public'] || $resultForFile['remote'] || $public;
112
-		}
107
+        // Find out who, if anyone, is sharing the file
108
+        if ($file !== null) {
109
+            $resultForFile = $this->shareManager->getAccessList($file, false);
110
+            $userIds = array_merge($userIds, $resultForFile['users']);
111
+            $public = $resultForFile['public'] || $resultForFile['remote'] || $public;
112
+        }
113 113
 
114
-		// check if it is a group mount
115
-		if ($this->getAppManager()->isEnabledForUser("files_external")) {
116
-			/** @var GlobalStoragesService $storageService */
117
-			$storageService = \OC::$server->get(GlobalStoragesService::class);
118
-			$storages = $storageService->getAllStorages();
119
-			foreach ($storages as $storage) {
120
-				if ($storage->getMountPoint() == substr($ownerPath, 0, strlen($storage->getMountPoint()))) {
121
-					$mountedFor = $this->util->getUserWithAccessToMountPoint($storage->getApplicableUsers(), $storage->getApplicableGroups());
122
-					$userIds = array_merge($userIds, $mountedFor);
123
-				}
124
-			}
125
-		}
114
+        // check if it is a group mount
115
+        if ($this->getAppManager()->isEnabledForUser("files_external")) {
116
+            /** @var GlobalStoragesService $storageService */
117
+            $storageService = \OC::$server->get(GlobalStoragesService::class);
118
+            $storages = $storageService->getAllStorages();
119
+            foreach ($storages as $storage) {
120
+                if ($storage->getMountPoint() == substr($ownerPath, 0, strlen($storage->getMountPoint()))) {
121
+                    $mountedFor = $this->util->getUserWithAccessToMountPoint($storage->getApplicableUsers(), $storage->getApplicableGroups());
122
+                    $userIds = array_merge($userIds, $mountedFor);
123
+                }
124
+            }
125
+        }
126 126
 
127
-		// Remove duplicate UIDs
128
-		$uniqueUserIds = array_unique($userIds);
127
+        // Remove duplicate UIDs
128
+        $uniqueUserIds = array_unique($userIds);
129 129
 
130
-		return ['users' => $uniqueUserIds, 'public' => $public];
131
-	}
130
+        return ['users' => $uniqueUserIds, 'public' => $public];
131
+    }
132 132
 }
Please login to merge, or discard this patch.
lib/private/TempManager.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	private function buildFileNameWithSuffix($absolutePath, $postFix = '') {
68 68
 		if ($postFix !== '') {
69
-			$postFix = '.' . ltrim($postFix, '.');
69
+			$postFix = '.'.ltrim($postFix, '.');
70 70
 			$postFix = str_replace(['\\', '/'], '', $postFix);
71 71
 			$absolutePath .= '-';
72 72
 		}
73 73
 
74
-		return $absolutePath . $postFix;
74
+		return $absolutePath.$postFix;
75 75
 	}
76 76
 
77 77
 	/**
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 			$this->current[] = $uniqueFileName;
128 128
 
129 129
 			// Build a name without postfix
130
-			$path = $this->buildFileNameWithSuffix($uniqueFileName . '-folder', $postFix);
130
+			$path = $this->buildFileNameWithSuffix($uniqueFileName.'-folder', $postFix);
131 131
 			mkdir($path, 0700);
132 132
 			$this->current[] = $path;
133 133
 
134
-			return $path . '/';
134
+			return $path.'/';
135 135
 		} else {
136 136
 			$this->log->warning(
137 137
 				'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions',
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		if ($dh) {
191 191
 			while (($file = readdir($dh)) !== false) {
192 192
 				if (substr($file, 0, 7) === self::TMP_PREFIX) {
193
-					$path = $this->tmpBaseDir . '/' . $file;
193
+					$path = $this->tmpBaseDir.'/'.$file;
194 194
 					$mtime = filemtime($path);
195 195
 					if ($mtime < $cutOfTime) {
196 196
 						$files[] = $path;
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -37,244 +37,244 @@
 block discarded – undo
37 37
 use Psr\Log\LoggerInterface;
38 38
 
39 39
 class TempManager implements ITempManager {
40
-	/** @var string[] Current temporary files and folders, used for cleanup */
41
-	protected $current = [];
42
-	/** @var string i.e. /tmp on linux systems */
43
-	protected $tmpBaseDir;
44
-	/** @var LoggerInterface */
45
-	protected $log;
46
-	/** @var IConfig */
47
-	protected $config;
48
-	/** @var IniGetWrapper */
49
-	protected $iniGetWrapper;
40
+    /** @var string[] Current temporary files and folders, used for cleanup */
41
+    protected $current = [];
42
+    /** @var string i.e. /tmp on linux systems */
43
+    protected $tmpBaseDir;
44
+    /** @var LoggerInterface */
45
+    protected $log;
46
+    /** @var IConfig */
47
+    protected $config;
48
+    /** @var IniGetWrapper */
49
+    protected $iniGetWrapper;
50 50
 
51
-	/** Prefix */
52
-	public const TMP_PREFIX = 'oc_tmp_';
51
+    /** Prefix */
52
+    public const TMP_PREFIX = 'oc_tmp_';
53 53
 
54
-	public function __construct(LoggerInterface $logger, IConfig $config, IniGetWrapper $iniGetWrapper) {
55
-		$this->log = $logger;
56
-		$this->config = $config;
57
-		$this->iniGetWrapper = $iniGetWrapper;
58
-		$this->tmpBaseDir = $this->getTempBaseDir();
59
-	}
54
+    public function __construct(LoggerInterface $logger, IConfig $config, IniGetWrapper $iniGetWrapper) {
55
+        $this->log = $logger;
56
+        $this->config = $config;
57
+        $this->iniGetWrapper = $iniGetWrapper;
58
+        $this->tmpBaseDir = $this->getTempBaseDir();
59
+    }
60 60
 
61
-	/**
62
-	 * Builds the filename with suffix and removes potential dangerous characters
63
-	 * such as directory separators.
64
-	 *
65
-	 * @param string $absolutePath Absolute path to the file / folder
66
-	 * @param string $postFix Postfix appended to the temporary file name, may be user controlled
67
-	 * @return string
68
-	 */
69
-	private function buildFileNameWithSuffix($absolutePath, $postFix = '') {
70
-		if ($postFix !== '') {
71
-			$postFix = '.' . ltrim($postFix, '.');
72
-			$postFix = str_replace(['\\', '/'], '', $postFix);
73
-			$absolutePath .= '-';
74
-		}
61
+    /**
62
+     * Builds the filename with suffix and removes potential dangerous characters
63
+     * such as directory separators.
64
+     *
65
+     * @param string $absolutePath Absolute path to the file / folder
66
+     * @param string $postFix Postfix appended to the temporary file name, may be user controlled
67
+     * @return string
68
+     */
69
+    private function buildFileNameWithSuffix($absolutePath, $postFix = '') {
70
+        if ($postFix !== '') {
71
+            $postFix = '.' . ltrim($postFix, '.');
72
+            $postFix = str_replace(['\\', '/'], '', $postFix);
73
+            $absolutePath .= '-';
74
+        }
75 75
 
76
-		return $absolutePath . $postFix;
77
-	}
76
+        return $absolutePath . $postFix;
77
+    }
78 78
 
79
-	/**
80
-	 * Create a temporary file and return the path
81
-	 *
82
-	 * @param string $postFix Postfix appended to the temporary file name
83
-	 * @return string
84
-	 */
85
-	public function getTemporaryFile($postFix = '') {
86
-		if (is_writable($this->tmpBaseDir)) {
87
-			// To create an unique file and prevent the risk of race conditions
88
-			// or duplicated temporary files by other means such as collisions
89
-			// we need to create the file using `tempnam` and append a possible
90
-			// postfix to it later
91
-			$file = tempnam($this->tmpBaseDir, self::TMP_PREFIX);
92
-			$this->current[] = $file;
79
+    /**
80
+     * Create a temporary file and return the path
81
+     *
82
+     * @param string $postFix Postfix appended to the temporary file name
83
+     * @return string
84
+     */
85
+    public function getTemporaryFile($postFix = '') {
86
+        if (is_writable($this->tmpBaseDir)) {
87
+            // To create an unique file and prevent the risk of race conditions
88
+            // or duplicated temporary files by other means such as collisions
89
+            // we need to create the file using `tempnam` and append a possible
90
+            // postfix to it later
91
+            $file = tempnam($this->tmpBaseDir, self::TMP_PREFIX);
92
+            $this->current[] = $file;
93 93
 
94
-			// If a postfix got specified sanitize it and create a postfixed
95
-			// temporary file
96
-			if ($postFix !== '') {
97
-				$fileNameWithPostfix = $this->buildFileNameWithSuffix($file, $postFix);
98
-				touch($fileNameWithPostfix);
99
-				chmod($fileNameWithPostfix, 0600);
100
-				$this->current[] = $fileNameWithPostfix;
101
-				return $fileNameWithPostfix;
102
-			}
94
+            // If a postfix got specified sanitize it and create a postfixed
95
+            // temporary file
96
+            if ($postFix !== '') {
97
+                $fileNameWithPostfix = $this->buildFileNameWithSuffix($file, $postFix);
98
+                touch($fileNameWithPostfix);
99
+                chmod($fileNameWithPostfix, 0600);
100
+                $this->current[] = $fileNameWithPostfix;
101
+                return $fileNameWithPostfix;
102
+            }
103 103
 
104
-			return $file;
105
-		} else {
106
-			$this->log->warning(
107
-				'Can not create a temporary file in directory {dir}. Check it exists and has correct permissions',
108
-				[
109
-					'dir' => $this->tmpBaseDir,
110
-				]
111
-			);
112
-			return false;
113
-		}
114
-	}
104
+            return $file;
105
+        } else {
106
+            $this->log->warning(
107
+                'Can not create a temporary file in directory {dir}. Check it exists and has correct permissions',
108
+                [
109
+                    'dir' => $this->tmpBaseDir,
110
+                ]
111
+            );
112
+            return false;
113
+        }
114
+    }
115 115
 
116
-	/**
117
-	 * Create a temporary folder and return the path
118
-	 *
119
-	 * @param string $postFix Postfix appended to the temporary folder name
120
-	 * @return string
121
-	 */
122
-	public function getTemporaryFolder($postFix = '') {
123
-		if (is_writable($this->tmpBaseDir)) {
124
-			// To create an unique directory and prevent the risk of race conditions
125
-			// or duplicated temporary files by other means such as collisions
126
-			// we need to create the file using `tempnam` and append a possible
127
-			// postfix to it later
128
-			$uniqueFileName = tempnam($this->tmpBaseDir, self::TMP_PREFIX);
129
-			$this->current[] = $uniqueFileName;
116
+    /**
117
+     * Create a temporary folder and return the path
118
+     *
119
+     * @param string $postFix Postfix appended to the temporary folder name
120
+     * @return string
121
+     */
122
+    public function getTemporaryFolder($postFix = '') {
123
+        if (is_writable($this->tmpBaseDir)) {
124
+            // To create an unique directory and prevent the risk of race conditions
125
+            // or duplicated temporary files by other means such as collisions
126
+            // we need to create the file using `tempnam` and append a possible
127
+            // postfix to it later
128
+            $uniqueFileName = tempnam($this->tmpBaseDir, self::TMP_PREFIX);
129
+            $this->current[] = $uniqueFileName;
130 130
 
131
-			// Build a name without postfix
132
-			$path = $this->buildFileNameWithSuffix($uniqueFileName . '-folder', $postFix);
133
-			mkdir($path, 0700);
134
-			$this->current[] = $path;
131
+            // Build a name without postfix
132
+            $path = $this->buildFileNameWithSuffix($uniqueFileName . '-folder', $postFix);
133
+            mkdir($path, 0700);
134
+            $this->current[] = $path;
135 135
 
136
-			return $path . '/';
137
-		} else {
138
-			$this->log->warning(
139
-				'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions',
140
-				[
141
-					'dir' => $this->tmpBaseDir,
142
-				]
143
-			);
144
-			return false;
145
-		}
146
-	}
136
+            return $path . '/';
137
+        } else {
138
+            $this->log->warning(
139
+                'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions',
140
+                [
141
+                    'dir' => $this->tmpBaseDir,
142
+                ]
143
+            );
144
+            return false;
145
+        }
146
+    }
147 147
 
148
-	/**
149
-	 * Remove the temporary files and folders generated during this request
150
-	 */
151
-	public function clean() {
152
-		$this->cleanFiles($this->current);
153
-	}
148
+    /**
149
+     * Remove the temporary files and folders generated during this request
150
+     */
151
+    public function clean() {
152
+        $this->cleanFiles($this->current);
153
+    }
154 154
 
155
-	/**
156
-	 * @param string[] $files
157
-	 */
158
-	protected function cleanFiles($files) {
159
-		foreach ($files as $file) {
160
-			if (file_exists($file)) {
161
-				try {
162
-					\OC_Helper::rmdirr($file);
163
-				} catch (\UnexpectedValueException $ex) {
164
-					$this->log->warning(
165
-						"Error deleting temporary file/folder: {file} - Reason: {error}",
166
-						[
167
-							'file' => $file,
168
-							'error' => $ex->getMessage(),
169
-						]
170
-					);
171
-				}
172
-			}
173
-		}
174
-	}
155
+    /**
156
+     * @param string[] $files
157
+     */
158
+    protected function cleanFiles($files) {
159
+        foreach ($files as $file) {
160
+            if (file_exists($file)) {
161
+                try {
162
+                    \OC_Helper::rmdirr($file);
163
+                } catch (\UnexpectedValueException $ex) {
164
+                    $this->log->warning(
165
+                        "Error deleting temporary file/folder: {file} - Reason: {error}",
166
+                        [
167
+                            'file' => $file,
168
+                            'error' => $ex->getMessage(),
169
+                        ]
170
+                    );
171
+                }
172
+            }
173
+        }
174
+    }
175 175
 
176
-	/**
177
-	 * Remove old temporary files and folders that were failed to be cleaned
178
-	 */
179
-	public function cleanOld() {
180
-		$this->cleanFiles($this->getOldFiles());
181
-	}
176
+    /**
177
+     * Remove old temporary files and folders that were failed to be cleaned
178
+     */
179
+    public function cleanOld() {
180
+        $this->cleanFiles($this->getOldFiles());
181
+    }
182 182
 
183
-	/**
184
-	 * Get all temporary files and folders generated by oc older than an hour
185
-	 *
186
-	 * @return string[]
187
-	 */
188
-	protected function getOldFiles() {
189
-		$cutOfTime = time() - 3600;
190
-		$files = [];
191
-		$dh = opendir($this->tmpBaseDir);
192
-		if ($dh) {
193
-			while (($file = readdir($dh)) !== false) {
194
-				if (substr($file, 0, 7) === self::TMP_PREFIX) {
195
-					$path = $this->tmpBaseDir . '/' . $file;
196
-					$mtime = filemtime($path);
197
-					if ($mtime < $cutOfTime) {
198
-						$files[] = $path;
199
-					}
200
-				}
201
-			}
202
-		}
203
-		return $files;
204
-	}
183
+    /**
184
+     * Get all temporary files and folders generated by oc older than an hour
185
+     *
186
+     * @return string[]
187
+     */
188
+    protected function getOldFiles() {
189
+        $cutOfTime = time() - 3600;
190
+        $files = [];
191
+        $dh = opendir($this->tmpBaseDir);
192
+        if ($dh) {
193
+            while (($file = readdir($dh)) !== false) {
194
+                if (substr($file, 0, 7) === self::TMP_PREFIX) {
195
+                    $path = $this->tmpBaseDir . '/' . $file;
196
+                    $mtime = filemtime($path);
197
+                    if ($mtime < $cutOfTime) {
198
+                        $files[] = $path;
199
+                    }
200
+                }
201
+            }
202
+        }
203
+        return $files;
204
+    }
205 205
 
206
-	/**
207
-	 * Get the temporary base directory configured on the server
208
-	 *
209
-	 * @return string Path to the temporary directory or null
210
-	 * @throws \UnexpectedValueException
211
-	 */
212
-	public function getTempBaseDir() {
213
-		if ($this->tmpBaseDir) {
214
-			return $this->tmpBaseDir;
215
-		}
206
+    /**
207
+     * Get the temporary base directory configured on the server
208
+     *
209
+     * @return string Path to the temporary directory or null
210
+     * @throws \UnexpectedValueException
211
+     */
212
+    public function getTempBaseDir() {
213
+        if ($this->tmpBaseDir) {
214
+            return $this->tmpBaseDir;
215
+        }
216 216
 
217
-		$directories = [];
218
-		if ($temp = $this->config->getSystemValue('tempdirectory', null)) {
219
-			$directories[] = $temp;
220
-		}
221
-		if ($temp = $this->iniGetWrapper->get('upload_tmp_dir')) {
222
-			$directories[] = $temp;
223
-		}
224
-		if ($temp = getenv('TMP')) {
225
-			$directories[] = $temp;
226
-		}
227
-		if ($temp = getenv('TEMP')) {
228
-			$directories[] = $temp;
229
-		}
230
-		if ($temp = getenv('TMPDIR')) {
231
-			$directories[] = $temp;
232
-		}
233
-		if ($temp = sys_get_temp_dir()) {
234
-			$directories[] = $temp;
235
-		}
217
+        $directories = [];
218
+        if ($temp = $this->config->getSystemValue('tempdirectory', null)) {
219
+            $directories[] = $temp;
220
+        }
221
+        if ($temp = $this->iniGetWrapper->get('upload_tmp_dir')) {
222
+            $directories[] = $temp;
223
+        }
224
+        if ($temp = getenv('TMP')) {
225
+            $directories[] = $temp;
226
+        }
227
+        if ($temp = getenv('TEMP')) {
228
+            $directories[] = $temp;
229
+        }
230
+        if ($temp = getenv('TMPDIR')) {
231
+            $directories[] = $temp;
232
+        }
233
+        if ($temp = sys_get_temp_dir()) {
234
+            $directories[] = $temp;
235
+        }
236 236
 
237
-		foreach ($directories as $dir) {
238
-			if ($this->checkTemporaryDirectory($dir)) {
239
-				return $dir;
240
-			}
241
-		}
237
+        foreach ($directories as $dir) {
238
+            if ($this->checkTemporaryDirectory($dir)) {
239
+                return $dir;
240
+            }
241
+        }
242 242
 
243
-		$temp = tempnam(dirname(__FILE__), '');
244
-		if (file_exists($temp)) {
245
-			unlink($temp);
246
-			return dirname($temp);
247
-		}
248
-		throw new \UnexpectedValueException('Unable to detect system temporary directory');
249
-	}
243
+        $temp = tempnam(dirname(__FILE__), '');
244
+        if (file_exists($temp)) {
245
+            unlink($temp);
246
+            return dirname($temp);
247
+        }
248
+        throw new \UnexpectedValueException('Unable to detect system temporary directory');
249
+    }
250 250
 
251
-	/**
252
-	 * Check if a temporary directory is ready for use
253
-	 *
254
-	 * @param mixed $directory
255
-	 * @return bool
256
-	 */
257
-	private function checkTemporaryDirectory($directory) {
258
-		// suppress any possible errors caused by is_writable
259
-		// checks missing or invalid path or characters, wrong permissions etc
260
-		try {
261
-			if (is_writable($directory)) {
262
-				return true;
263
-			}
264
-		} catch (\Exception $e) {
265
-		}
266
-		$this->log->warning('Temporary directory {dir} is not present or writable',
267
-			['dir' => $directory]
268
-		);
269
-		return false;
270
-	}
251
+    /**
252
+     * Check if a temporary directory is ready for use
253
+     *
254
+     * @param mixed $directory
255
+     * @return bool
256
+     */
257
+    private function checkTemporaryDirectory($directory) {
258
+        // suppress any possible errors caused by is_writable
259
+        // checks missing or invalid path or characters, wrong permissions etc
260
+        try {
261
+            if (is_writable($directory)) {
262
+                return true;
263
+            }
264
+        } catch (\Exception $e) {
265
+        }
266
+        $this->log->warning('Temporary directory {dir} is not present or writable',
267
+            ['dir' => $directory]
268
+        );
269
+        return false;
270
+    }
271 271
 
272
-	/**
273
-	 * Override the temporary base directory
274
-	 *
275
-	 * @param string $directory
276
-	 */
277
-	public function overrideTempBaseDir($directory) {
278
-		$this->tmpBaseDir = $directory;
279
-	}
272
+    /**
273
+     * Override the temporary base directory
274
+     *
275
+     * @param string $directory
276
+     */
277
+    public function overrideTempBaseDir($directory) {
278
+        $this->tmpBaseDir = $directory;
279
+    }
280 280
 }
Please login to merge, or discard this patch.
lib/private/Tagging/Tag.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -36,54 +36,54 @@
 block discarded – undo
36 36
  * @method void setName(string $name)
37 37
  */
38 38
 class Tag extends Entity {
39
-	protected $owner;
40
-	protected $type;
41
-	protected $name;
39
+    protected $owner;
40
+    protected $type;
41
+    protected $name;
42 42
 
43
-	/**
44
-	 * Constructor.
45
-	 *
46
-	 * @param string $owner The tag's owner
47
-	 * @param string $type The type of item this tag is used for
48
-	 * @param string $name The tag's name
49
-	 */
50
-	public function __construct($owner = null, $type = null, $name = null) {
51
-		$this->setOwner($owner);
52
-		$this->setType($type);
53
-		$this->setName($name);
54
-	}
43
+    /**
44
+     * Constructor.
45
+     *
46
+     * @param string $owner The tag's owner
47
+     * @param string $type The type of item this tag is used for
48
+     * @param string $name The tag's name
49
+     */
50
+    public function __construct($owner = null, $type = null, $name = null) {
51
+        $this->setOwner($owner);
52
+        $this->setType($type);
53
+        $this->setName($name);
54
+    }
55 55
 
56
-	/**
57
-	 * Transform a database columnname to a property
58
-	 *
59
-	 * @param string $columnName the name of the column
60
-	 * @return string the property name
61
-	 * @todo migrate existing database columns to the correct names
62
-	 * to be able to drop this direct mapping
63
-	 */
64
-	public function columnToProperty($columnName) {
65
-		if ($columnName === 'category') {
66
-			return 'name';
67
-		} elseif ($columnName === 'uid') {
68
-			return 'owner';
69
-		} else {
70
-			return parent::columnToProperty($columnName);
71
-		}
72
-	}
56
+    /**
57
+     * Transform a database columnname to a property
58
+     *
59
+     * @param string $columnName the name of the column
60
+     * @return string the property name
61
+     * @todo migrate existing database columns to the correct names
62
+     * to be able to drop this direct mapping
63
+     */
64
+    public function columnToProperty($columnName) {
65
+        if ($columnName === 'category') {
66
+            return 'name';
67
+        } elseif ($columnName === 'uid') {
68
+            return 'owner';
69
+        } else {
70
+            return parent::columnToProperty($columnName);
71
+        }
72
+    }
73 73
 
74
-	/**
75
-	 * Transform a property to a database column name
76
-	 *
77
-	 * @param string $property the name of the property
78
-	 * @return string the column name
79
-	 */
80
-	public function propertyToColumn($property) {
81
-		if ($property === 'name') {
82
-			return 'category';
83
-		} elseif ($property === 'owner') {
84
-			return 'uid';
85
-		} else {
86
-			return parent::propertyToColumn($property);
87
-		}
88
-	}
74
+    /**
75
+     * Transform a property to a database column name
76
+     *
77
+     * @param string $property the name of the property
78
+     * @return string the column name
79
+     */
80
+    public function propertyToColumn($property) {
81
+        if ($property === 'name') {
82
+            return 'category';
83
+        } elseif ($property === 'owner') {
84
+            return 'uid';
85
+        } else {
86
+            return parent::propertyToColumn($property);
87
+        }
88
+    }
89 89
 }
Please login to merge, or discard this patch.
Middleware/Security/Exceptions/StrictCookieMissingException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
  * @package OC\AppFramework\Middleware\Security\Exceptions
33 33
  */
34 34
 class StrictCookieMissingException extends SecurityException {
35
-	public function __construct() {
36
-		parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED);
37
-	}
35
+    public function __construct() {
36
+        parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED);
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 		$anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period');
86 86
 		$userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit');
87 87
 		$userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period');
88
-		$rateLimitIdentifier = get_class($controller) . '::' . $methodName;
88
+		$rateLimitIdentifier = get_class($controller).'::'.$methodName;
89 89
 		if ($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
90 90
 			$this->limiter->registerUserRequest(
91 91
 				$rateLimitIdentifier,
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -50,80 +50,80 @@
 block discarded – undo
50 50
  * @package OC\AppFramework\Middleware\Security
51 51
  */
52 52
 class RateLimitingMiddleware extends Middleware {
53
-	/** @var IRequest $request */
54
-	private $request;
55
-	/** @var IUserSession */
56
-	private $userSession;
57
-	/** @var ControllerMethodReflector */
58
-	private $reflector;
59
-	/** @var Limiter */
60
-	private $limiter;
53
+    /** @var IRequest $request */
54
+    private $request;
55
+    /** @var IUserSession */
56
+    private $userSession;
57
+    /** @var ControllerMethodReflector */
58
+    private $reflector;
59
+    /** @var Limiter */
60
+    private $limiter;
61 61
 
62
-	/**
63
-	 * @param IRequest $request
64
-	 * @param IUserSession $userSession
65
-	 * @param ControllerMethodReflector $reflector
66
-	 * @param Limiter $limiter
67
-	 */
68
-	public function __construct(IRequest $request,
69
-								IUserSession $userSession,
70
-								ControllerMethodReflector $reflector,
71
-								Limiter $limiter) {
72
-		$this->request = $request;
73
-		$this->userSession = $userSession;
74
-		$this->reflector = $reflector;
75
-		$this->limiter = $limiter;
76
-	}
62
+    /**
63
+     * @param IRequest $request
64
+     * @param IUserSession $userSession
65
+     * @param ControllerMethodReflector $reflector
66
+     * @param Limiter $limiter
67
+     */
68
+    public function __construct(IRequest $request,
69
+                                IUserSession $userSession,
70
+                                ControllerMethodReflector $reflector,
71
+                                Limiter $limiter) {
72
+        $this->request = $request;
73
+        $this->userSession = $userSession;
74
+        $this->reflector = $reflector;
75
+        $this->limiter = $limiter;
76
+    }
77 77
 
78
-	/**
79
-	 * {@inheritDoc}
80
-	 * @throws RateLimitExceededException
81
-	 */
82
-	public function beforeController($controller, $methodName) {
83
-		parent::beforeController($controller, $methodName);
78
+    /**
79
+     * {@inheritDoc}
80
+     * @throws RateLimitExceededException
81
+     */
82
+    public function beforeController($controller, $methodName) {
83
+        parent::beforeController($controller, $methodName);
84 84
 
85
-		$anonLimit = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'limit');
86
-		$anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period');
87
-		$userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit');
88
-		$userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period');
89
-		$rateLimitIdentifier = get_class($controller) . '::' . $methodName;
90
-		if ($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
91
-			$this->limiter->registerUserRequest(
92
-				$rateLimitIdentifier,
93
-				$userLimit,
94
-				$userPeriod,
95
-				$this->userSession->getUser()
96
-			);
97
-		} elseif ($anonLimit !== '' && $anonPeriod !== '') {
98
-			$this->limiter->registerAnonRequest(
99
-				$rateLimitIdentifier,
100
-				$anonLimit,
101
-				$anonPeriod,
102
-				$this->request->getRemoteAddress()
103
-			);
104
-		}
105
-	}
85
+        $anonLimit = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'limit');
86
+        $anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period');
87
+        $userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit');
88
+        $userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period');
89
+        $rateLimitIdentifier = get_class($controller) . '::' . $methodName;
90
+        if ($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
91
+            $this->limiter->registerUserRequest(
92
+                $rateLimitIdentifier,
93
+                $userLimit,
94
+                $userPeriod,
95
+                $this->userSession->getUser()
96
+            );
97
+        } elseif ($anonLimit !== '' && $anonPeriod !== '') {
98
+            $this->limiter->registerAnonRequest(
99
+                $rateLimitIdentifier,
100
+                $anonLimit,
101
+                $anonPeriod,
102
+                $this->request->getRemoteAddress()
103
+            );
104
+        }
105
+    }
106 106
 
107
-	/**
108
-	 * {@inheritDoc}
109
-	 */
110
-	public function afterException($controller, $methodName, \Exception $exception) {
111
-		if ($exception instanceof RateLimitExceededException) {
112
-			if (stripos($this->request->getHeader('Accept'), 'html') === false) {
113
-				$response = new DataResponse([], $exception->getCode());
114
-			} else {
115
-				$response = new TemplateResponse(
116
-					'core',
117
-					'429',
118
-					[],
119
-					TemplateResponse::RENDER_AS_GUEST
120
-				);
121
-				$response->setStatus($exception->getCode());
122
-			}
107
+    /**
108
+     * {@inheritDoc}
109
+     */
110
+    public function afterException($controller, $methodName, \Exception $exception) {
111
+        if ($exception instanceof RateLimitExceededException) {
112
+            if (stripos($this->request->getHeader('Accept'), 'html') === false) {
113
+                $response = new DataResponse([], $exception->getCode());
114
+            } else {
115
+                $response = new TemplateResponse(
116
+                    'core',
117
+                    '429',
118
+                    [],
119
+                    TemplateResponse::RENDER_AS_GUEST
120
+                );
121
+                $response->setStatus($exception->getCode());
122
+            }
123 123
 
124
-			return $response;
125
-		}
124
+            return $response;
125
+        }
126 126
 
127
-		throw $exception;
128
-	}
127
+        throw $exception;
128
+    }
129 129
 }
Please login to merge, or discard this patch.
apps/dav/lib/Comments/RootCollection.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@
 block discarded – undo
147 147
 		if (isset($this->entityTypeCollections[$name])) {
148 148
 			return $this->entityTypeCollections[$name];
149 149
 		}
150
-		throw new NotFound('Entity type "' . $name . '" not found."');
150
+		throw new NotFound('Entity type "'.$name.'" not found."');
151 151
 	}
152 152
 
153 153
 	/**
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -37,168 +37,168 @@
 block discarded – undo
37 37
 
38 38
 class RootCollection implements ICollection {
39 39
 
40
-	/** @var EntityTypeCollection[]|null */
41
-	private $entityTypeCollections;
42
-
43
-	/** @var ICommentsManager */
44
-	protected $commentsManager;
45
-
46
-	/** @var string */
47
-	protected $name = 'comments';
48
-
49
-	protected LoggerInterface $logger;
50
-
51
-	/** @var IUserManager */
52
-	protected $userManager;
53
-
54
-	/** @var IUserSession */
55
-	protected $userSession;
56
-
57
-	/** @var EventDispatcherInterface */
58
-	protected $dispatcher;
59
-
60
-	public function __construct(
61
-		ICommentsManager $commentsManager,
62
-		IUserManager $userManager,
63
-		IUserSession $userSession,
64
-		EventDispatcherInterface $dispatcher,
65
-		LoggerInterface $logger) {
66
-		$this->commentsManager = $commentsManager;
67
-		$this->logger = $logger;
68
-		$this->userManager = $userManager;
69
-		$this->userSession = $userSession;
70
-		$this->dispatcher = $dispatcher;
71
-	}
72
-
73
-	/**
74
-	 * initializes the collection. At this point of time, we need the logged in
75
-	 * user. Since it is not the case when the instance is created, we cannot
76
-	 * have this in the constructor.
77
-	 *
78
-	 * @throws NotAuthenticated
79
-	 */
80
-	protected function initCollections() {
81
-		if ($this->entityTypeCollections !== null) {
82
-			return;
83
-		}
84
-		$user = $this->userSession->getUser();
85
-		if (is_null($user)) {
86
-			throw new NotAuthenticated();
87
-		}
88
-
89
-		$event = new CommentsEntityEvent(CommentsEntityEvent::EVENT_ENTITY);
90
-		$this->dispatcher->dispatch(CommentsEntityEvent::EVENT_ENTITY, $event);
91
-
92
-		$this->entityTypeCollections = [];
93
-		foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) {
94
-			$this->entityTypeCollections[$entity] = new EntityTypeCollection(
95
-				$entity,
96
-				$this->commentsManager,
97
-				$this->userManager,
98
-				$this->userSession,
99
-				$this->logger,
100
-				$entityExistsFunction
101
-			);
102
-		}
103
-	}
104
-
105
-	/**
106
-	 * Creates a new file in the directory
107
-	 *
108
-	 * @param string $name Name of the file
109
-	 * @param resource|string $data Initial payload
110
-	 * @return null|string
111
-	 * @throws Forbidden
112
-	 */
113
-	public function createFile($name, $data = null) {
114
-		throw new Forbidden('Cannot create comments by id');
115
-	}
116
-
117
-	/**
118
-	 * Creates a new subdirectory
119
-	 *
120
-	 * @param string $name
121
-	 * @throws Forbidden
122
-	 */
123
-	public function createDirectory($name) {
124
-		throw new Forbidden('Permission denied to create collections');
125
-	}
126
-
127
-	/**
128
-	 * Returns a specific child node, referenced by its name
129
-	 *
130
-	 * This method must throw Sabre\DAV\Exception\NotFound if the node does not
131
-	 * exist.
132
-	 *
133
-	 * @param string $name
134
-	 * @return \Sabre\DAV\INode
135
-	 * @throws NotFound
136
-	 */
137
-	public function getChild($name) {
138
-		$this->initCollections();
139
-		if (isset($this->entityTypeCollections[$name])) {
140
-			return $this->entityTypeCollections[$name];
141
-		}
142
-		throw new NotFound('Entity type "' . $name . '" not found."');
143
-	}
144
-
145
-	/**
146
-	 * Returns an array with all the child nodes
147
-	 *
148
-	 * @return \Sabre\DAV\INode[]
149
-	 */
150
-	public function getChildren() {
151
-		$this->initCollections();
152
-		return $this->entityTypeCollections;
153
-	}
154
-
155
-	/**
156
-	 * Checks if a child-node with the specified name exists
157
-	 *
158
-	 * @param string $name
159
-	 * @return bool
160
-	 */
161
-	public function childExists($name) {
162
-		$this->initCollections();
163
-		return isset($this->entityTypeCollections[$name]);
164
-	}
165
-
166
-	/**
167
-	 * Deleted the current node
168
-	 *
169
-	 * @throws Forbidden
170
-	 */
171
-	public function delete() {
172
-		throw new Forbidden('Permission denied to delete this collection');
173
-	}
174
-
175
-	/**
176
-	 * Returns the name of the node.
177
-	 *
178
-	 * This is used to generate the url.
179
-	 *
180
-	 * @return string
181
-	 */
182
-	public function getName() {
183
-		return $this->name;
184
-	}
185
-
186
-	/**
187
-	 * Renames the node
188
-	 *
189
-	 * @param string $name The new name
190
-	 * @throws Forbidden
191
-	 */
192
-	public function setName($name) {
193
-		throw new Forbidden('Permission denied to rename this collection');
194
-	}
195
-
196
-	/**
197
-	 * Returns the last modification time, as a unix timestamp
198
-	 *
199
-	 * @return int
200
-	 */
201
-	public function getLastModified() {
202
-		return null;
203
-	}
40
+    /** @var EntityTypeCollection[]|null */
41
+    private $entityTypeCollections;
42
+
43
+    /** @var ICommentsManager */
44
+    protected $commentsManager;
45
+
46
+    /** @var string */
47
+    protected $name = 'comments';
48
+
49
+    protected LoggerInterface $logger;
50
+
51
+    /** @var IUserManager */
52
+    protected $userManager;
53
+
54
+    /** @var IUserSession */
55
+    protected $userSession;
56
+
57
+    /** @var EventDispatcherInterface */
58
+    protected $dispatcher;
59
+
60
+    public function __construct(
61
+        ICommentsManager $commentsManager,
62
+        IUserManager $userManager,
63
+        IUserSession $userSession,
64
+        EventDispatcherInterface $dispatcher,
65
+        LoggerInterface $logger) {
66
+        $this->commentsManager = $commentsManager;
67
+        $this->logger = $logger;
68
+        $this->userManager = $userManager;
69
+        $this->userSession = $userSession;
70
+        $this->dispatcher = $dispatcher;
71
+    }
72
+
73
+    /**
74
+     * initializes the collection. At this point of time, we need the logged in
75
+     * user. Since it is not the case when the instance is created, we cannot
76
+     * have this in the constructor.
77
+     *
78
+     * @throws NotAuthenticated
79
+     */
80
+    protected function initCollections() {
81
+        if ($this->entityTypeCollections !== null) {
82
+            return;
83
+        }
84
+        $user = $this->userSession->getUser();
85
+        if (is_null($user)) {
86
+            throw new NotAuthenticated();
87
+        }
88
+
89
+        $event = new CommentsEntityEvent(CommentsEntityEvent::EVENT_ENTITY);
90
+        $this->dispatcher->dispatch(CommentsEntityEvent::EVENT_ENTITY, $event);
91
+
92
+        $this->entityTypeCollections = [];
93
+        foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) {
94
+            $this->entityTypeCollections[$entity] = new EntityTypeCollection(
95
+                $entity,
96
+                $this->commentsManager,
97
+                $this->userManager,
98
+                $this->userSession,
99
+                $this->logger,
100
+                $entityExistsFunction
101
+            );
102
+        }
103
+    }
104
+
105
+    /**
106
+     * Creates a new file in the directory
107
+     *
108
+     * @param string $name Name of the file
109
+     * @param resource|string $data Initial payload
110
+     * @return null|string
111
+     * @throws Forbidden
112
+     */
113
+    public function createFile($name, $data = null) {
114
+        throw new Forbidden('Cannot create comments by id');
115
+    }
116
+
117
+    /**
118
+     * Creates a new subdirectory
119
+     *
120
+     * @param string $name
121
+     * @throws Forbidden
122
+     */
123
+    public function createDirectory($name) {
124
+        throw new Forbidden('Permission denied to create collections');
125
+    }
126
+
127
+    /**
128
+     * Returns a specific child node, referenced by its name
129
+     *
130
+     * This method must throw Sabre\DAV\Exception\NotFound if the node does not
131
+     * exist.
132
+     *
133
+     * @param string $name
134
+     * @return \Sabre\DAV\INode
135
+     * @throws NotFound
136
+     */
137
+    public function getChild($name) {
138
+        $this->initCollections();
139
+        if (isset($this->entityTypeCollections[$name])) {
140
+            return $this->entityTypeCollections[$name];
141
+        }
142
+        throw new NotFound('Entity type "' . $name . '" not found."');
143
+    }
144
+
145
+    /**
146
+     * Returns an array with all the child nodes
147
+     *
148
+     * @return \Sabre\DAV\INode[]
149
+     */
150
+    public function getChildren() {
151
+        $this->initCollections();
152
+        return $this->entityTypeCollections;
153
+    }
154
+
155
+    /**
156
+     * Checks if a child-node with the specified name exists
157
+     *
158
+     * @param string $name
159
+     * @return bool
160
+     */
161
+    public function childExists($name) {
162
+        $this->initCollections();
163
+        return isset($this->entityTypeCollections[$name]);
164
+    }
165
+
166
+    /**
167
+     * Deleted the current node
168
+     *
169
+     * @throws Forbidden
170
+     */
171
+    public function delete() {
172
+        throw new Forbidden('Permission denied to delete this collection');
173
+    }
174
+
175
+    /**
176
+     * Returns the name of the node.
177
+     *
178
+     * This is used to generate the url.
179
+     *
180
+     * @return string
181
+     */
182
+    public function getName() {
183
+        return $this->name;
184
+    }
185
+
186
+    /**
187
+     * Renames the node
188
+     *
189
+     * @param string $name The new name
190
+     * @throws Forbidden
191
+     */
192
+    public function setName($name) {
193
+        throw new Forbidden('Permission denied to rename this collection');
194
+    }
195
+
196
+    /**
197
+     * Returns the last modification time, as a unix timestamp
198
+     *
199
+     * @return int
200
+     */
201
+    public function getLastModified() {
202
+        return null;
203
+    }
204 204
 }
Please login to merge, or discard this patch.
apps/dav/lib/Comments/EntityCollection.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 		foreach (['id', 'name'] as $property) {
69 69
 			$$property = trim($$property);
70 70
 			if (empty($$property) || !is_string($$property)) {
71
-				throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string');
71
+				throw new \InvalidArgumentException('"'.$property.'" parameter must be non-empty string');
72 72
 			}
73 73
 		}
74 74
 		$this->id = $id;
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -41,151 +41,151 @@
 block discarded – undo
41 41
  * @package OCA\DAV\Comments
42 42
  */
43 43
 class EntityCollection extends RootCollection implements IProperties {
44
-	public const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker';
44
+    public const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker';
45 45
 
46
-	/** @var  string */
47
-	protected $id;
46
+    /** @var  string */
47
+    protected $id;
48 48
 
49
-	protected LoggerInterface $logger;
49
+    protected LoggerInterface $logger;
50 50
 
51
-	/**
52
-	 * @param string $id
53
-	 * @param string $name
54
-	 * @param ICommentsManager $commentsManager
55
-	 * @param IUserManager $userManager
56
-	 * @param IUserSession $userSession
57
-	 * @param LoggerInterface $logger
58
-	 */
59
-	public function __construct(
60
-		$id,
61
-		$name,
62
-		ICommentsManager $commentsManager,
63
-		IUserManager $userManager,
64
-		IUserSession $userSession,
65
-		LoggerInterface $logger
66
-	) {
67
-		foreach (['id', 'name'] as $property) {
68
-			$$property = trim($$property);
69
-			if (empty($$property) || !is_string($$property)) {
70
-				throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string');
71
-			}
72
-		}
73
-		$this->id = $id;
74
-		$this->name = $name;
75
-		$this->commentsManager = $commentsManager;
76
-		$this->logger = $logger;
77
-		$this->userManager = $userManager;
78
-		$this->userSession = $userSession;
79
-	}
51
+    /**
52
+     * @param string $id
53
+     * @param string $name
54
+     * @param ICommentsManager $commentsManager
55
+     * @param IUserManager $userManager
56
+     * @param IUserSession $userSession
57
+     * @param LoggerInterface $logger
58
+     */
59
+    public function __construct(
60
+        $id,
61
+        $name,
62
+        ICommentsManager $commentsManager,
63
+        IUserManager $userManager,
64
+        IUserSession $userSession,
65
+        LoggerInterface $logger
66
+    ) {
67
+        foreach (['id', 'name'] as $property) {
68
+            $$property = trim($$property);
69
+            if (empty($$property) || !is_string($$property)) {
70
+                throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string');
71
+            }
72
+        }
73
+        $this->id = $id;
74
+        $this->name = $name;
75
+        $this->commentsManager = $commentsManager;
76
+        $this->logger = $logger;
77
+        $this->userManager = $userManager;
78
+        $this->userSession = $userSession;
79
+    }
80 80
 
81
-	/**
82
-	 * returns the ID of this entity
83
-	 *
84
-	 * @return string
85
-	 */
86
-	public function getId() {
87
-		return $this->id;
88
-	}
81
+    /**
82
+     * returns the ID of this entity
83
+     *
84
+     * @return string
85
+     */
86
+    public function getId() {
87
+        return $this->id;
88
+    }
89 89
 
90
-	/**
91
-	 * Returns a specific child node, referenced by its name
92
-	 *
93
-	 * This method must throw Sabre\DAV\Exception\NotFound if the node does not
94
-	 * exist.
95
-	 *
96
-	 * @param string $name
97
-	 * @return \Sabre\DAV\INode
98
-	 * @throws NotFound
99
-	 */
100
-	public function getChild($name) {
101
-		try {
102
-			$comment = $this->commentsManager->get($name);
103
-			return new CommentNode(
104
-				$this->commentsManager,
105
-				$comment,
106
-				$this->userManager,
107
-				$this->userSession,
108
-				$this->logger
109
-			);
110
-		} catch (NotFoundException $e) {
111
-			throw new NotFound();
112
-		}
113
-	}
90
+    /**
91
+     * Returns a specific child node, referenced by its name
92
+     *
93
+     * This method must throw Sabre\DAV\Exception\NotFound if the node does not
94
+     * exist.
95
+     *
96
+     * @param string $name
97
+     * @return \Sabre\DAV\INode
98
+     * @throws NotFound
99
+     */
100
+    public function getChild($name) {
101
+        try {
102
+            $comment = $this->commentsManager->get($name);
103
+            return new CommentNode(
104
+                $this->commentsManager,
105
+                $comment,
106
+                $this->userManager,
107
+                $this->userSession,
108
+                $this->logger
109
+            );
110
+        } catch (NotFoundException $e) {
111
+            throw new NotFound();
112
+        }
113
+    }
114 114
 
115
-	/**
116
-	 * Returns an array with all the child nodes
117
-	 *
118
-	 * @return \Sabre\DAV\INode[]
119
-	 */
120
-	public function getChildren() {
121
-		return $this->findChildren();
122
-	}
115
+    /**
116
+     * Returns an array with all the child nodes
117
+     *
118
+     * @return \Sabre\DAV\INode[]
119
+     */
120
+    public function getChildren() {
121
+        return $this->findChildren();
122
+    }
123 123
 
124
-	/**
125
-	 * Returns an array of comment nodes. Result can be influenced by offset,
126
-	 * limit and date time parameters.
127
-	 *
128
-	 * @param int $limit
129
-	 * @param int $offset
130
-	 * @param \DateTime|null $datetime
131
-	 * @return CommentNode[]
132
-	 */
133
-	public function findChildren($limit = 0, $offset = 0, \DateTime $datetime = null) {
134
-		$comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime);
135
-		$result = [];
136
-		foreach ($comments as $comment) {
137
-			$result[] = new CommentNode(
138
-				$this->commentsManager,
139
-				$comment,
140
-				$this->userManager,
141
-				$this->userSession,
142
-				$this->logger
143
-			);
144
-		}
145
-		return $result;
146
-	}
124
+    /**
125
+     * Returns an array of comment nodes. Result can be influenced by offset,
126
+     * limit and date time parameters.
127
+     *
128
+     * @param int $limit
129
+     * @param int $offset
130
+     * @param \DateTime|null $datetime
131
+     * @return CommentNode[]
132
+     */
133
+    public function findChildren($limit = 0, $offset = 0, \DateTime $datetime = null) {
134
+        $comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime);
135
+        $result = [];
136
+        foreach ($comments as $comment) {
137
+            $result[] = new CommentNode(
138
+                $this->commentsManager,
139
+                $comment,
140
+                $this->userManager,
141
+                $this->userSession,
142
+                $this->logger
143
+            );
144
+        }
145
+        return $result;
146
+    }
147 147
 
148
-	/**
149
-	 * Checks if a child-node with the specified name exists
150
-	 *
151
-	 * @param string $name
152
-	 * @return bool
153
-	 */
154
-	public function childExists($name) {
155
-		try {
156
-			$this->commentsManager->get($name);
157
-			return true;
158
-		} catch (NotFoundException $e) {
159
-			return false;
160
-		}
161
-	}
148
+    /**
149
+     * Checks if a child-node with the specified name exists
150
+     *
151
+     * @param string $name
152
+     * @return bool
153
+     */
154
+    public function childExists($name) {
155
+        try {
156
+            $this->commentsManager->get($name);
157
+            return true;
158
+        } catch (NotFoundException $e) {
159
+            return false;
160
+        }
161
+    }
162 162
 
163
-	/**
164
-	 * Sets the read marker to the specified date for the logged in user
165
-	 */
166
-	public function setReadMarker(?string $value): bool {
167
-		$dateTime = new \DateTime($value ?? 'now');
168
-		$user = $this->userSession->getUser();
169
-		$this->commentsManager->setReadMark($this->name, $this->id, $dateTime, $user);
170
-		return true;
171
-	}
163
+    /**
164
+     * Sets the read marker to the specified date for the logged in user
165
+     */
166
+    public function setReadMarker(?string $value): bool {
167
+        $dateTime = new \DateTime($value ?? 'now');
168
+        $user = $this->userSession->getUser();
169
+        $this->commentsManager->setReadMark($this->name, $this->id, $dateTime, $user);
170
+        return true;
171
+    }
172 172
 
173
-	/**
174
-	 * @inheritdoc
175
-	 */
176
-	public function propPatch(PropPatch $propPatch) {
177
-		$propPatch->handle(self::PROPERTY_NAME_READ_MARKER, [$this, 'setReadMarker']);
178
-	}
173
+    /**
174
+     * @inheritdoc
175
+     */
176
+    public function propPatch(PropPatch $propPatch) {
177
+        $propPatch->handle(self::PROPERTY_NAME_READ_MARKER, [$this, 'setReadMarker']);
178
+    }
179 179
 
180
-	/**
181
-	 * @inheritdoc
182
-	 */
183
-	public function getProperties($properties) {
184
-		$marker = null;
185
-		$user = $this->userSession->getUser();
186
-		if (!is_null($user)) {
187
-			$marker = $this->commentsManager->getReadMark($this->name, $this->id, $user);
188
-		}
189
-		return [self::PROPERTY_NAME_READ_MARKER => $marker];
190
-	}
180
+    /**
181
+     * @inheritdoc
182
+     */
183
+    public function getProperties($properties) {
184
+        $marker = null;
185
+        $user = $this->userSession->getUser();
186
+        if (!is_null($user)) {
187
+            $marker = $this->commentsManager->getReadMark($this->name, $this->id, $user);
188
+        }
189
+        return [self::PROPERTY_NAME_READ_MARKER => $marker];
190
+    }
191 191
 }
Please login to merge, or discard this patch.
apps/dav/lib/Files/Sharing/FilesDropPlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 		$path = array_pop($path);
78 78
 
79 79
 		$newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view);
80
-		$url = $request->getBaseUrl() . $newName;
80
+		$url = $request->getBaseUrl().$newName;
81 81
 		$request->setUrl($url);
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -35,51 +35,51 @@
 block discarded – undo
35 35
  */
36 36
 class FilesDropPlugin extends ServerPlugin {
37 37
 
38
-	/** @var View */
39
-	private $view;
38
+    /** @var View */
39
+    private $view;
40 40
 
41
-	/** @var bool */
42
-	private $enabled = false;
41
+    /** @var bool */
42
+    private $enabled = false;
43 43
 
44
-	/**
45
-	 * @param View $view
46
-	 */
47
-	public function setView($view) {
48
-		$this->view = $view;
49
-	}
44
+    /**
45
+     * @param View $view
46
+     */
47
+    public function setView($view) {
48
+        $this->view = $view;
49
+    }
50 50
 
51
-	public function enable() {
52
-		$this->enabled = true;
53
-	}
51
+    public function enable() {
52
+        $this->enabled = true;
53
+    }
54 54
 
55 55
 
56
-	/**
57
-	 * This initializes the plugin.
58
-	 *
59
-	 * @param \Sabre\DAV\Server $server Sabre server
60
-	 *
61
-	 * @return void
62
-	 * @throws MethodNotAllowed
63
-	 */
64
-	public function initialize(\Sabre\DAV\Server $server) {
65
-		$server->on('beforeMethod:*', [$this, 'beforeMethod'], 999);
66
-		$this->enabled = false;
67
-	}
56
+    /**
57
+     * This initializes the plugin.
58
+     *
59
+     * @param \Sabre\DAV\Server $server Sabre server
60
+     *
61
+     * @return void
62
+     * @throws MethodNotAllowed
63
+     */
64
+    public function initialize(\Sabre\DAV\Server $server) {
65
+        $server->on('beforeMethod:*', [$this, 'beforeMethod'], 999);
66
+        $this->enabled = false;
67
+    }
68 68
 
69
-	public function beforeMethod(RequestInterface $request, ResponseInterface $response) {
70
-		if (!$this->enabled) {
71
-			return;
72
-		}
69
+    public function beforeMethod(RequestInterface $request, ResponseInterface $response) {
70
+        if (!$this->enabled) {
71
+            return;
72
+        }
73 73
 
74
-		if ($request->getMethod() !== 'PUT') {
75
-			throw new MethodNotAllowed('Only PUT is allowed on files drop');
76
-		}
74
+        if ($request->getMethod() !== 'PUT') {
75
+            throw new MethodNotAllowed('Only PUT is allowed on files drop');
76
+        }
77 77
 
78
-		$path = explode('/', $request->getPath());
79
-		$path = array_pop($path);
78
+        $path = explode('/', $request->getPath());
79
+        $path = array_pop($path);
80 80
 
81
-		$newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view);
82
-		$url = $request->getBaseUrl() . $newName;
83
-		$request->setUrl($url);
84
-	}
81
+        $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view);
82
+        $url = $request->getBaseUrl() . $newName;
83
+        $request->setUrl($url);
84
+    }
85 85
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/SyncSystemAddressBook.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		$output->writeln('Syncing users ...');
55 55
 		$progress = new ProgressBar($output);
56 56
 		$progress->start();
57
-		$this->syncService->syncInstance(function () use ($progress) {
57
+		$this->syncService->syncInstance(function() use ($progress) {
58 58
 			$progress->advance();
59 59
 		});
60 60
 
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -32,37 +32,37 @@
 block discarded – undo
32 32
 
33 33
 class SyncSystemAddressBook extends Command {
34 34
 
35
-	/** @var SyncService */
36
-	private $syncService;
35
+    /** @var SyncService */
36
+    private $syncService;
37 37
 
38
-	/**
39
-	 * @param SyncService $syncService
40
-	 */
41
-	public function __construct(SyncService $syncService) {
42
-		parent::__construct();
43
-		$this->syncService = $syncService;
44
-	}
38
+    /**
39
+     * @param SyncService $syncService
40
+     */
41
+    public function __construct(SyncService $syncService) {
42
+        parent::__construct();
43
+        $this->syncService = $syncService;
44
+    }
45 45
 
46
-	protected function configure() {
47
-		$this
48
-			->setName('dav:sync-system-addressbook')
49
-			->setDescription('Synchronizes users to the system addressbook');
50
-	}
46
+    protected function configure() {
47
+        $this
48
+            ->setName('dav:sync-system-addressbook')
49
+            ->setDescription('Synchronizes users to the system addressbook');
50
+    }
51 51
 
52
-	/**
53
-	 * @param InputInterface $input
54
-	 * @param OutputInterface $output
55
-	 */
56
-	protected function execute(InputInterface $input, OutputInterface $output): int {
57
-		$output->writeln('Syncing users ...');
58
-		$progress = new ProgressBar($output);
59
-		$progress->start();
60
-		$this->syncService->syncInstance(function () use ($progress) {
61
-			$progress->advance();
62
-		});
52
+    /**
53
+     * @param InputInterface $input
54
+     * @param OutputInterface $output
55
+     */
56
+    protected function execute(InputInterface $input, OutputInterface $output): int {
57
+        $output->writeln('Syncing users ...');
58
+        $progress = new ProgressBar($output);
59
+        $progress->start();
60
+        $this->syncService->syncInstance(function () use ($progress) {
61
+            $progress->advance();
62
+        });
63 63
 
64
-		$progress->finish();
65
-		$output->writeln('');
66
-		return 0;
67
-	}
64
+        $progress->finish();
65
+        $output->writeln('');
66
+        return 0;
67
+    }
68 68
 }
Please login to merge, or discard this patch.