Skip to content

Commit 427bbff

Browse files
committed
refactor: use strict comparison operator
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent ebfdbf8 commit 427bbff

File tree

10 files changed

+41
-41
lines changed

10 files changed

+41
-41
lines changed

lib/private/Archive/TAR.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ private function getHeader(string $file): ?array {
121121
$this->cachedHeaders = $this->tar->listContent();
122122
}
123123
foreach ($this->cachedHeaders as $header) {
124-
if ($file == $header['filename']
125-
|| $file . '/' == $header['filename']
126-
|| '/' . $file . '/' == $header['filename']
127-
|| '/' . $file == $header['filename']
124+
if ($file === $header['filename']
125+
|| $file . '/' === $header['filename']
126+
|| '/' . $file . '/' === $header['filename']
127+
|| '/' . $file === $header['filename']
128128
) {
129129
return $header;
130130
}
@@ -158,10 +158,10 @@ public function getFolder(string $path): array {
158158
$folderContent = [];
159159
$pathLength = strlen($path);
160160
foreach ($files as $file) {
161-
if ($file[0] == '/') {
161+
if ($file[0] === '/') {
162162
$file = substr($file, 1);
163163
}
164-
if (substr($file, 0, $pathLength) == $path && $file != $path) {
164+
if (substr($file, 0, $pathLength) === $path && $file !== $path) {
165165
$result = substr($file, $pathLength);
166166
if ($pos = strpos($result, '/')) {
167167
$result = substr($result, 0, $pos + 1);
@@ -250,12 +250,12 @@ public function fileExists(string $path): bool {
250250
$folderPath = rtrim($path, '/') . '/';
251251
$pathLength = strlen($folderPath);
252252
foreach ($files as $file) {
253-
if (strlen($file) > $pathLength && substr($file, 0, $pathLength) == $folderPath) {
253+
if (strlen($file) > $pathLength && substr($file, 0, $pathLength) === $folderPath) {
254254
return true;
255255
}
256256
}
257257
}
258-
if ($path[0] != '/') { //not all programs agree on the use of a leading /
258+
if ($path[0] !== '/') { //not all programs agree on the use of a leading /
259259
return $this->fileExists('/' . $path);
260260
} else {
261261
return false;
@@ -296,10 +296,10 @@ public function getStream(string $path, string $mode) {
296296
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
297297
if ($this->fileExists($path)) {
298298
$this->extractFile($path, $tmpFile);
299-
} elseif ($mode == 'r' || $mode == 'rb') {
299+
} elseif ($mode === 'r' || $mode === 'rb') {
300300
return false;
301301
}
302-
if ($mode == 'r' || $mode == 'rb') {
302+
if ($mode === 'r' || $mode === 'rb') {
303303
return fopen($tmpFile, $mode);
304304
} else {
305305
$handle = fopen($tmpFile, $mode);

lib/private/Archive/ZIP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getFolder(string $path): array {
9292
$folderContent = [];
9393
$pathLength = strlen($path);
9494
foreach ($files as $file) {
95-
if (substr($file, 0, $pathLength) == $path && $file != $path) {
95+
if (substr($file, 0, $pathLength) === $path && $file !== $path) {
9696
if (strrpos(substr($file, 0, -1), '/') <= $pathLength) {
9797
$folderContent[] = substr($file, $pathLength);
9898
}
@@ -220,7 +220,7 @@ public function writeBack(string $tmpFile, string $path): void {
220220
}
221221

222222
private function stripPath(string $path): string {
223-
if (!$path || $path[0] == '/') {
223+
if (!$path || $path[0] === '/') {
224224
return substr($path, 1);
225225
} else {
226226
return $path;

lib/private/Files/Cache/Wrapper/CacheJail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function formatCacheEntry($entry) {
104104
* @return ICacheEntry|false
105105
*/
106106
public function get($file) {
107-
if (is_string($file) || $file == '') {
107+
if (is_string($file) || $file === '') {
108108
$file = $this->getSourcePath($file);
109109
}
110110
return parent::get($file);

lib/private/Files/Node/LazyFolder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function getPermissions() {
258258
*/
259259
public function isReadable() {
260260
if (isset($this->data['permissions'])) {
261-
return ($this->data['permissions'] & Constants::PERMISSION_READ) == Constants::PERMISSION_READ;
261+
return ($this->data['permissions'] & Constants::PERMISSION_READ) === Constants::PERMISSION_READ;
262262
}
263263
return $this->__call(__FUNCTION__, func_get_args());
264264
}
@@ -268,7 +268,7 @@ public function isReadable() {
268268
*/
269269
public function isUpdateable() {
270270
if (isset($this->data['permissions'])) {
271-
return ($this->data['permissions'] & Constants::PERMISSION_UPDATE) == Constants::PERMISSION_UPDATE;
271+
return ($this->data['permissions'] & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE;
272272
}
273273
return $this->__call(__FUNCTION__, func_get_args());
274274
}
@@ -278,7 +278,7 @@ public function isUpdateable() {
278278
*/
279279
public function isDeletable() {
280280
if (isset($this->data['permissions'])) {
281-
return ($this->data['permissions'] & Constants::PERMISSION_DELETE) == Constants::PERMISSION_DELETE;
281+
return ($this->data['permissions'] & Constants::PERMISSION_DELETE) === Constants::PERMISSION_DELETE;
282282
}
283283
return $this->__call(__FUNCTION__, func_get_args());
284284
}
@@ -288,7 +288,7 @@ public function isDeletable() {
288288
*/
289289
public function isShareable() {
290290
if (isset($this->data['permissions'])) {
291-
return ($this->data['permissions'] & Constants::PERMISSION_SHARE) == Constants::PERMISSION_SHARE;
291+
return ($this->data['permissions'] & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE;
292292
}
293293
return $this->__call(__FUNCTION__, func_get_args());
294294
}

lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function processOperator(ISearchOperator &$operator) {
4040
}
4141

4242
private function isPathPrefixOperator(ISearchOperator $operator): bool {
43-
if ($operator instanceof ISearchBinaryOperator && $operator->getType() === ISearchBinaryOperator::OPERATOR_OR && count($operator->getArguments()) == 2) {
43+
if ($operator instanceof ISearchBinaryOperator && $operator->getType() === ISearchBinaryOperator::OPERATOR_OR && count($operator->getArguments()) === 2) {
4444
$a = $operator->getArguments()[0];
4545
$b = $operator->getArguments()[1];
4646
if ($this->operatorPairIsPathPrefix($a, $b) || $this->operatorPairIsPathPrefix($b, $a)) {

lib/private/Files/Storage/Common.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,15 @@ public function getETag(string $path): string|false {
391391
* @return string cleaned path
392392
*/
393393
public function cleanPath(string $path): string {
394-
if (strlen($path) == 0 || $path[0] != '/') {
394+
if (strlen($path) === 0 || $path[0] !== '/') {
395395
$path = '/' . $path;
396396
}
397397

398398
$output = [];
399399
foreach (explode('/', $path) as $chunk) {
400-
if ($chunk == '..') {
400+
if ($chunk === '..') {
401401
array_pop($output);
402-
} elseif ($chunk == '.') {
402+
} elseif ($chunk === '.') {
403403
} else {
404404
$output[] = $chunk;
405405
}
@@ -611,7 +611,7 @@ public function getMetaData(string $path): ?array {
611611
if ($data['mtime'] === false) {
612612
$data['mtime'] = time();
613613
}
614-
if ($data['mimetype'] == 'httpd/unix-directory') {
614+
if ($data['mimetype'] === 'httpd/unix-directory') {
615615
$data['size'] = -1; //unknown
616616
} else {
617617
$data['size'] = $this->filesize($path);

lib/private/Files/Storage/DAV.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public function filetype(string $path): string|false {
284284
/** @var ResourceType[] $response */
285285
$responseType = $response['{DAV:}resourcetype']->getValue();
286286
}
287-
return (count($responseType) > 0 && $responseType[0] == '{DAV:}collection') ? 'dir' : 'file';
287+
return (count($responseType) > 0 && $responseType[0] === '{DAV:}collection') ? 'dir' : 'file';
288288
} catch (\Exception $e) {
289289
$this->convertException($e, $path);
290290
}
@@ -572,7 +572,7 @@ private function getMetaFromPropfind(string $path, array $response): array {
572572
/** @var ResourceType[] $response */
573573
$responseType = $response['{DAV:}resourcetype']->getValue();
574574
}
575-
$type = (count($responseType) > 0 && $responseType[0] == '{DAV:}collection') ? 'dir' : 'file';
575+
$type = (count($responseType) > 0 && $responseType[0] === '{DAV:}collection') ? 'dir' : 'file';
576576
if ($type === 'dir') {
577577
$mimeType = 'httpd/unix-directory';
578578
} elseif (isset($response['{DAV:}getcontenttype'])) {
@@ -648,7 +648,7 @@ protected function simpleResponse(string $method, string $path, ?string $body, i
648648
$path = $this->cleanPath($path);
649649
try {
650650
$response = $this->client->request($method, $this->encodePath($path), $body);
651-
return $response['statusCode'] == $expected;
651+
return $response['statusCode'] === $expected;
652652
} catch (ClientHttpException $e) {
653653
if ($e->getHttpStatus() === 404 && $method === 'DELETE') {
654654
$this->statCache->clear($path . '/');

lib/private/Files/Storage/Local.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function getMetaData(string $path): ?array {
216216

217217
public function filetype(string $path): string|false {
218218
$filetype = filetype($this->getSourcePath($path));
219-
if ($filetype == 'link') {
219+
if ($filetype === 'link') {
220220
$filetype = filetype(realpath($this->getSourcePath($path)));
221221
}
222222
return $filetype;

lib/private/Files/Storage/Wrapper/Quota.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function mkdir(string $path): bool {
183183
return $this->storage->mkdir($path);
184184
}
185185
$free = $this->free_space($path);
186-
if ($this->shouldApplyQuota($path) && $free == 0) {
186+
if ($this->shouldApplyQuota($path) && $free === 0) {
187187
return false;
188188
}
189189

@@ -195,7 +195,7 @@ public function touch(string $path, ?int $mtime = null): bool {
195195
return $this->storage->touch($path, $mtime);
196196
}
197197
$free = $this->free_space($path);
198-
if ($free == 0) {
198+
if ($free === 0) {
199199
return false;
200200
}
201201

lib/private/Files/View.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getAbsolutePath($path = '/'): ?string {
104104
* @param string $fakeRoot
105105
*/
106106
public function chroot($fakeRoot): void {
107-
if (!$fakeRoot == '') {
107+
if ($fakeRoot !== '') {
108108
if ($fakeRoot[0] !== '/') {
109109
$fakeRoot = '/' . $fakeRoot;
110110
}
@@ -126,7 +126,7 @@ public function getRoot(): string {
126126
*/
127127
public function getRelativePath($path): ?string {
128128
$this->assertPathLength($path);
129-
if ($this->fakeRoot == '') {
129+
if ($this->fakeRoot === '') {
130130
return $path;
131131
}
132132

@@ -319,7 +319,7 @@ public function opendir($path) {
319319
* @return bool|mixed
320320
*/
321321
public function is_dir($path) {
322-
if ($path == '/') {
322+
if ($path === '/') {
323323
return true;
324324
}
325325
return $this->basicOperation('is_dir', $path);
@@ -330,7 +330,7 @@ public function is_dir($path) {
330330
* @return bool|mixed
331331
*/
332332
public function is_file($path) {
333-
if ($path == '/') {
333+
if ($path === '/') {
334334
return false;
335335
}
336336
return $this->basicOperation('is_file', $path);
@@ -496,7 +496,7 @@ public function isSharable($path) {
496496
* @return bool|mixed
497497
*/
498498
public function file_exists($path) {
499-
if ($path == '/') {
499+
if ($path === '/') {
500500
return true;
501501
}
502502
return $this->basicOperation('file_exists', $path);
@@ -728,7 +728,7 @@ public function rename($source, $target, array $options = []) {
728728
$target = $this->getRelativePath($absolutePath2);
729729
$exists = $this->file_exists($target);
730730

731-
if ($source == null || $target == null) {
731+
if ($source === null || $target === null) {
732732
return false;
733733
}
734734

@@ -925,7 +925,7 @@ public function copy($source, $target, $preserveMtime = false) {
925925
$source = $this->getRelativePath($absolutePath1);
926926
$target = $this->getRelativePath($absolutePath2);
927927

928-
if ($source == null || $target == null) {
928+
if ($source === null || $target === null) {
929929
return false;
930930
}
931931
$run = true;
@@ -960,7 +960,7 @@ public function copy($source, $target, $preserveMtime = false) {
960960
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE);
961961
$lockTypePath2 = ILockingProvider::LOCK_EXCLUSIVE;
962962

963-
if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
963+
if ($mount1->getMountPoint() === $mount2->getMountPoint()) {
964964
if ($storage1) {
965965
$result = $storage1->copy($internalPath1, $internalPath2);
966966
} else {
@@ -1131,7 +1131,7 @@ public function hash($type, $path, $raw = false): string|bool {
11311131
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
11321132
if (Filesystem::isValidPath($path)) {
11331133
$path = $this->getRelativePath($absolutePath);
1134-
if ($path == null) {
1134+
if ($path === null) {
11351135
return false;
11361136
}
11371137
if ($this->shouldEmitHooks($path)) {
@@ -1182,7 +1182,7 @@ private function basicOperation(string $operation, string $path, array $hooks =
11821182
&& !Filesystem::isFileBlacklisted($path)
11831183
) {
11841184
$path = $this->getRelativePath($absolutePath);
1185-
if ($path == null) {
1185+
if ($path === null) {
11861186
return false;
11871187
}
11881188

@@ -1250,7 +1250,7 @@ private function basicOperation(string $operation, string $path, array $hooks =
12501250
}
12511251

12521252
if ($this->shouldEmitHooks($path) && $result !== false) {
1253-
if ($operation != 'fopen') { //no post hooks for fopen, the file stream is still open
1253+
if ($operation !== 'fopen') { //no post hooks for fopen, the file stream is still open
12541254
$this->runHooks($hooks, $path, true);
12551255
}
12561256
}
@@ -1318,7 +1318,7 @@ private function runHooks($hooks, $path, $post = false) {
13181318
$run = true;
13191319
if ($this->shouldEmitHooks($relativePath)) {
13201320
foreach ($hooks as $hook) {
1321-
if ($hook != 'read') {
1321+
if ($hook !== 'read') {
13221322
\OC_Hook::emit(
13231323
Filesystem::CLASSNAME,
13241324
$prefix . $hook,
@@ -2252,7 +2252,7 @@ public function getUidAndFilename($filename) {
22522252
throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
22532253
}
22542254
$uid = $info->getOwner()->getUID();
2255-
if ($uid != \OC_User::getUser()) {
2255+
if ($uid !== \OC_User::getUser()) {
22562256
Filesystem::initMountPoints($uid);
22572257
$ownerView = new View('/' . $uid . '/files');
22582258
try {

0 commit comments

Comments
 (0)