Skip to content

Commit

Permalink
Merge pull request #38619 from fsamapoor/replace_strpos_calls_in_file…
Browse files Browse the repository at this point in the history
…s_external_app

Refactors "strpos" calls in /apps/files_external
  • Loading branch information
szaimen authored Jun 12, 2023
2 parents c93be18 + 94f2f57 commit ac57cf9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
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

0 comments on commit ac57cf9

Please sign in to comment.