diff --git a/lib/private/Archive/TAR.php b/lib/private/Archive/TAR.php index 5ef8d233f1dae..f2b43862e2056 100644 --- a/lib/private/Archive/TAR.php +++ b/lib/private/Archive/TAR.php @@ -121,10 +121,10 @@ private function getHeader(string $file): ?array { $this->cachedHeaders = $this->tar->listContent(); } foreach ($this->cachedHeaders as $header) { - if ($file == $header['filename'] - || $file . '/' == $header['filename'] - || '/' . $file . '/' == $header['filename'] - || '/' . $file == $header['filename'] + if ($file === $header['filename'] + || $file . '/' === $header['filename'] + || '/' . $file . '/' === $header['filename'] + || '/' . $file === $header['filename'] ) { return $header; } @@ -158,10 +158,10 @@ public function getFolder(string $path): array { $folderContent = []; $pathLength = strlen($path); foreach ($files as $file) { - if ($file[0] == '/') { + if ($file[0] === '/') { $file = substr($file, 1); } - if (substr($file, 0, $pathLength) == $path && $file != $path) { + if (substr($file, 0, $pathLength) === $path && $file !== $path) { $result = substr($file, $pathLength); if ($pos = strpos($result, '/')) { $result = substr($result, 0, $pos + 1); @@ -250,12 +250,12 @@ public function fileExists(string $path): bool { $folderPath = rtrim($path, '/') . '/'; $pathLength = strlen($folderPath); foreach ($files as $file) { - if (strlen($file) > $pathLength && substr($file, 0, $pathLength) == $folderPath) { + if (strlen($file) > $pathLength && substr($file, 0, $pathLength) === $folderPath) { return true; } } } - if ($path[0] != '/') { //not all programs agree on the use of a leading / + if ($path[0] !== '/') { //not all programs agree on the use of a leading / return $this->fileExists('/' . $path); } else { return false; @@ -296,10 +296,10 @@ public function getStream(string $path, string $mode) { $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); if ($this->fileExists($path)) { $this->extractFile($path, $tmpFile); - } elseif ($mode == 'r' || $mode == 'rb') { + } elseif ($mode === 'r' || $mode === 'rb') { return false; } - if ($mode == 'r' || $mode == 'rb') { + if ($mode === 'r' || $mode === 'rb') { return fopen($tmpFile, $mode); } else { $handle = fopen($tmpFile, $mode); diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index f7deb3f204055..bd1a0d6d9ed19 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -92,7 +92,7 @@ public function getFolder(string $path): array { $folderContent = []; $pathLength = strlen($path); foreach ($files as $file) { - if (substr($file, 0, $pathLength) == $path && $file != $path) { + if (substr($file, 0, $pathLength) === $path && $file !== $path) { if (strrpos(substr($file, 0, -1), '/') <= $pathLength) { $folderContent[] = substr($file, $pathLength); } @@ -220,7 +220,7 @@ public function writeBack(string $tmpFile, string $path): void { } private function stripPath(string $path): string { - if (!$path || $path[0] == '/') { + if (!$path || $path[0] === '/') { return substr($path, 1); } else { return $path; diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 7fc5c8e3191ad..91bb31df872f4 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -104,7 +104,7 @@ protected function formatCacheEntry($entry) { * @return ICacheEntry|false */ public function get($file) { - if (is_string($file) || $file == '') { + if (is_string($file) || $file === '') { $file = $this->getSourcePath($file); } return parent::get($file); diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index c23a7d03ada9e..50b441ebc6903 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -258,7 +258,7 @@ public function getPermissions() { */ public function isReadable() { if (isset($this->data['permissions'])) { - return ($this->data['permissions'] & Constants::PERMISSION_READ) == Constants::PERMISSION_READ; + return ($this->data['permissions'] & Constants::PERMISSION_READ) === Constants::PERMISSION_READ; } return $this->__call(__FUNCTION__, func_get_args()); } @@ -268,7 +268,7 @@ public function isReadable() { */ public function isUpdateable() { if (isset($this->data['permissions'])) { - return ($this->data['permissions'] & Constants::PERMISSION_UPDATE) == Constants::PERMISSION_UPDATE; + return ($this->data['permissions'] & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE; } return $this->__call(__FUNCTION__, func_get_args()); } @@ -278,7 +278,7 @@ public function isUpdateable() { */ public function isDeletable() { if (isset($this->data['permissions'])) { - return ($this->data['permissions'] & Constants::PERMISSION_DELETE) == Constants::PERMISSION_DELETE; + return ($this->data['permissions'] & Constants::PERMISSION_DELETE) === Constants::PERMISSION_DELETE; } return $this->__call(__FUNCTION__, func_get_args()); } @@ -288,7 +288,7 @@ public function isDeletable() { */ public function isShareable() { if (isset($this->data['permissions'])) { - return ($this->data['permissions'] & Constants::PERMISSION_SHARE) == Constants::PERMISSION_SHARE; + return ($this->data['permissions'] & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE; } return $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php b/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php index 2994a9365a706..5e874aa159fd1 100644 --- a/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php +++ b/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php @@ -40,7 +40,7 @@ public function processOperator(ISearchOperator &$operator) { } private function isPathPrefixOperator(ISearchOperator $operator): bool { - if ($operator instanceof ISearchBinaryOperator && $operator->getType() === ISearchBinaryOperator::OPERATOR_OR && count($operator->getArguments()) == 2) { + if ($operator instanceof ISearchBinaryOperator && $operator->getType() === ISearchBinaryOperator::OPERATOR_OR && count($operator->getArguments()) === 2) { $a = $operator->getArguments()[0]; $b = $operator->getArguments()[1]; if ($this->operatorPairIsPathPrefix($a, $b) || $this->operatorPairIsPathPrefix($b, $a)) { diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index bea7430bd1ec3..6040059370f5d 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -391,15 +391,15 @@ public function getETag(string $path): string|false { * @return string cleaned path */ public function cleanPath(string $path): string { - if (strlen($path) == 0 || $path[0] != '/') { + if (strlen($path) === 0 || $path[0] !== '/') { $path = '/' . $path; } $output = []; foreach (explode('/', $path) as $chunk) { - if ($chunk == '..') { + if ($chunk === '..') { array_pop($output); - } elseif ($chunk == '.') { + } elseif ($chunk === '.') { } else { $output[] = $chunk; } @@ -611,7 +611,7 @@ public function getMetaData(string $path): ?array { if ($data['mtime'] === false) { $data['mtime'] = time(); } - if ($data['mimetype'] == 'httpd/unix-directory') { + if ($data['mimetype'] === 'httpd/unix-directory') { $data['size'] = -1; //unknown } else { $data['size'] = $this->filesize($path); diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 2d166b5438da1..e3b39cd983df2 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -284,7 +284,7 @@ public function filetype(string $path): string|false { /** @var ResourceType[] $response */ $responseType = $response['{DAV:}resourcetype']->getValue(); } - return (count($responseType) > 0 && $responseType[0] == '{DAV:}collection') ? 'dir' : 'file'; + return (count($responseType) > 0 && $responseType[0] === '{DAV:}collection') ? 'dir' : 'file'; } catch (\Exception $e) { $this->convertException($e, $path); } @@ -572,7 +572,7 @@ private function getMetaFromPropfind(string $path, array $response): array { /** @var ResourceType[] $response */ $responseType = $response['{DAV:}resourcetype']->getValue(); } - $type = (count($responseType) > 0 && $responseType[0] == '{DAV:}collection') ? 'dir' : 'file'; + $type = (count($responseType) > 0 && $responseType[0] === '{DAV:}collection') ? 'dir' : 'file'; if ($type === 'dir') { $mimeType = 'httpd/unix-directory'; } elseif (isset($response['{DAV:}getcontenttype'])) { @@ -648,7 +648,7 @@ protected function simpleResponse(string $method, string $path, ?string $body, i $path = $this->cleanPath($path); try { $response = $this->client->request($method, $this->encodePath($path), $body); - return $response['statusCode'] == $expected; + return $response['statusCode'] === $expected; } catch (ClientHttpException $e) { if ($e->getHttpStatus() === 404 && $method === 'DELETE') { $this->statCache->clear($path . '/'); diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index c46d4c6c8eb89..0a12b8d5314f6 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -216,7 +216,7 @@ public function getMetaData(string $path): ?array { public function filetype(string $path): string|false { $filetype = filetype($this->getSourcePath($path)); - if ($filetype == 'link') { + if ($filetype === 'link') { $filetype = filetype(realpath($this->getSourcePath($path))); } return $filetype; diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 4a9ef9f813814..2ee14c3abfa49 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -104,7 +104,7 @@ public function getAbsolutePath($path = '/'): ?string { * @param string $fakeRoot */ public function chroot($fakeRoot): void { - if (!$fakeRoot == '') { + if ($fakeRoot !== '') { if ($fakeRoot[0] !== '/') { $fakeRoot = '/' . $fakeRoot; } @@ -126,7 +126,7 @@ public function getRoot(): string { */ public function getRelativePath($path): ?string { $this->assertPathLength($path); - if ($this->fakeRoot == '') { + if ($this->fakeRoot === '') { return $path; } @@ -319,7 +319,7 @@ public function opendir($path) { * @return bool|mixed */ public function is_dir($path) { - if ($path == '/') { + if ($path === '/') { return true; } return $this->basicOperation('is_dir', $path); @@ -330,7 +330,7 @@ public function is_dir($path) { * @return bool|mixed */ public function is_file($path) { - if ($path == '/') { + if ($path === '/') { return false; } return $this->basicOperation('is_file', $path); @@ -496,7 +496,7 @@ public function isSharable($path) { * @return bool|mixed */ public function file_exists($path) { - if ($path == '/') { + if ($path === '/') { return true; } return $this->basicOperation('file_exists', $path); @@ -728,7 +728,7 @@ public function rename($source, $target, array $options = []) { $target = $this->getRelativePath($absolutePath2); $exists = $this->file_exists($target); - if ($source == null || $target == null) { + if ($source === null || $target === null) { return false; } @@ -925,7 +925,7 @@ public function copy($source, $target, $preserveMtime = false) { $source = $this->getRelativePath($absolutePath1); $target = $this->getRelativePath($absolutePath2); - if ($source == null || $target == null) { + if ($source === null || $target === null) { return false; } $run = true; @@ -960,7 +960,7 @@ public function copy($source, $target, $preserveMtime = false) { $this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE); $lockTypePath2 = ILockingProvider::LOCK_EXCLUSIVE; - if ($mount1->getMountPoint() == $mount2->getMountPoint()) { + if ($mount1->getMountPoint() === $mount2->getMountPoint()) { if ($storage1) { $result = $storage1->copy($internalPath1, $internalPath2); } else { @@ -1131,7 +1131,7 @@ public function hash($type, $path, $raw = false): string|bool { $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); if (Filesystem::isValidPath($path)) { $path = $this->getRelativePath($absolutePath); - if ($path == null) { + if ($path === null) { return false; } if ($this->shouldEmitHooks($path)) { @@ -1182,7 +1182,7 @@ private function basicOperation(string $operation, string $path, array $hooks = && !Filesystem::isFileBlacklisted($path) ) { $path = $this->getRelativePath($absolutePath); - if ($path == null) { + if ($path === null) { return false; } @@ -1250,7 +1250,7 @@ private function basicOperation(string $operation, string $path, array $hooks = } if ($this->shouldEmitHooks($path) && $result !== false) { - if ($operation != 'fopen') { //no post hooks for fopen, the file stream is still open + if ($operation !== 'fopen') { //no post hooks for fopen, the file stream is still open $this->runHooks($hooks, $path, true); } } @@ -1318,7 +1318,7 @@ private function runHooks($hooks, $path, $post = false) { $run = true; if ($this->shouldEmitHooks($relativePath)) { foreach ($hooks as $hook) { - if ($hook != 'read') { + if ($hook !== 'read') { \OC_Hook::emit( Filesystem::CLASSNAME, $prefix . $hook, @@ -2252,7 +2252,7 @@ public function getUidAndFilename($filename) { throw new NotFoundException($this->getAbsolutePath($filename) . ' not found'); } $uid = $info->getOwner()->getUID(); - if ($uid != \OC_User::getUser()) { + if ($uid !== \OC_User::getUser()) { Filesystem::initMountPoints($uid); $ownerView = new View('/' . $uid . '/files'); try {