Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/private/Archive/TAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Archive/ZIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Wrapper/CacheJail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions lib/private/Files/Node/LazyFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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 . '/');
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -126,7 +126,7 @@ public function getRoot(): string {
*/
public function getRelativePath($path): ?string {
$this->assertPathLength($path);
if ($this->fakeRoot == '') {
if ($this->fakeRoot === '') {
return $path;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Loading