Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors "strpos" calls in /apps/files_external #38619

Merged
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
2 changes: 1 addition & 1 deletion apps/files_external/lib/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$config = [];
foreach ($configInput as $configOption) {
if (!strpos($configOption, '=')) {
if (!str_contains($configOption, '=')) {
$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/Lib/Storage/FtpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function systype() {
public function nlist(string $path) {
$files = @ftp_nlist($this->connection, $path);
return array_map(function ($name) {
if (strpos($name, '/') !== false) {
if (str_contains($name, '/')) {
$name = basename($name);
}
return $name;
Expand All @@ -122,7 +122,7 @@ public function mlsd(string $path) {

if ($files !== false) {
return array_map(function ($file) {
if (strpos($file['name'], '/') !== false) {
if (str_contains($file['name'], '/')) {
$file['name'] = basename($file['name']);
}
return $file;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/OwnCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct($params) {
$host = substr($host, 0, $hostSlashPos);
}

if (substr($contextPath, -1) !== '/') {
if (!str_ends_with($contextPath, '/')) {
$contextPath .= '/';
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/SFTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SFTP extends \OC\Files\Storage\Common {
*/
private function splitHost($host) {
$input = $host;
if (strpos($host, '://') === false) {
if (!str_contains($host, '://')) {
// add a protocol to fix parse_url behavior with ipv6
$host = 'http://' . $host;
}
Expand Down
8 changes: 4 additions & 4 deletions apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ public function __construct($params) {
}

private function splitUser($user) {
if (strpos($user, '/')) {
if (str_contains($user, '/')) {
return explode('/', $user, 2);
} elseif (strpos($user, '\\')) {
} elseif (str_contains($user, '\\')) {
return explode('\\', $user);
} else {
return [null, $user];
}

return [null, $user];
}

/**
Expand Down