Merge pull request #38619 from fsamapoor/replace_strpos_calls_in_files_external_app

Refactors "strpos" calls in /apps/files_external
This commit is contained in:
Simon L 2023-06-12 09:46:43 +02:00 committed by GitHub
commit ac57cf9f6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View file

@ -134,7 +134,7 @@ class Create extends Base {
$config = [];
foreach ($configInput as $configOption) {
if (!strpos($configOption, '=')) {
if (!str_contains($configOption, '=')) {
$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
return 1;
}

View file

@ -110,7 +110,7 @@ class FtpConnection {
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;
@ -122,7 +122,7 @@ class FtpConnection {
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;

View file

@ -60,7 +60,7 @@ class OwnCloud extends \OC\Files\Storage\DAV implements IDisableEncryptionStorag
$host = substr($host, 0, $hostSlashPos);
}
if (substr($contextPath, -1) !== '/') {
if (!str_ends_with($contextPath, '/')) {
$contextPath .= '/';
}

View file

@ -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;
}

View file

@ -139,13 +139,13 @@ class SMB extends Common implements INotifyStorage {
}
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];
}
/**