From b6b8d9f1440f20c779836a6cd9060d6ba05eb54d Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 11 Aug 2016 00:33:06 +0200 Subject: [PATCH] Clean some PHP code. --- src/_h5ai/private/php/class-bootstrap.php | 2 +- src/_h5ai/private/php/core/class-json.php | 14 +++++++------- src/_h5ai/private/php/core/class-setup.php | 2 +- src/_h5ai/private/php/ext/class-archive.php | 6 +++--- src/_h5ai/private/php/ext/class-thumb.php | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/_h5ai/private/php/class-bootstrap.php b/src/_h5ai/private/php/class-bootstrap.php index 306b4c37..43565239 100644 --- a/src/_h5ai/private/php/class-bootstrap.php +++ b/src/_h5ai/private/php/class-bootstrap.php @@ -17,7 +17,7 @@ class Bootstrap { if ($context->is_api_request()) { (new Api($context))->apply(); - } else if ($context->is_info_request()) { + } elseif ($context->is_info_request()) { $public_href = $setup->get('PUBLIC_HREF'); $x_head_tags = $context->get_x_head_html(); $fallback_mode = false; diff --git a/src/_h5ai/private/php/core/class-json.php b/src/_h5ai/private/php/core/class-json.php index 4b429ba7..f662b9fc 100644 --- a/src/_h5ai/private/php/core/class-json.php +++ b/src/_h5ai/private/php/core/class-json.php @@ -28,7 +28,7 @@ class Json { $insideComment = false; $json = ''; - for ($i = 0; $i < strlen($commented_json); $i += 1) { + for ($i = 0, $len = strlen($commented_json); $i < $len; $i += 1) { $char = $commented_json[$i]; $charchar = $char . @$commented_json[$i + 1]; $prevChar = @$commented_json[$i - 1]; @@ -39,22 +39,22 @@ class Json { if ($insideString) { $json .= $char; - } else if (!$insideComment && $charchar === '//') { + } elseif (!$insideComment && $charchar === '//') { $insideComment = Json::SINGLE; $i += 1; - } else if (!$insideComment && $charchar === '/*') { + } elseif (!$insideComment && $charchar === '/*') { $insideComment = Json::MULTI; $i += 1; - } else if (!$insideComment) { + } elseif (!$insideComment) { $json .= $char; - } else if ($insideComment === Json::SINGLE && $charchar === "\r\n") { + } elseif ($insideComment === Json::SINGLE && $charchar === "\r\n") { $insideComment = false; $json .= $charchar; $i += 1; - } else if ($insideComment === Json::SINGLE && $char === "\n") { + } elseif ($insideComment === Json::SINGLE && $char === "\n") { $insideComment = false; $json .= $char; - } else if ($insideComment === Json::MULTI && $charchar === '*/') { + } elseif ($insideComment === Json::MULTI && $charchar === '*/') { $insideComment = false; $i += 1; } diff --git a/src/_h5ai/private/php/core/class-setup.php b/src/_h5ai/private/php/core/class-setup.php index 688767bd..d0c3fb2c 100644 --- a/src/_h5ai/private/php/core/class-setup.php +++ b/src/_h5ai/private/php/core/class-setup.php @@ -126,7 +126,7 @@ class Setup { $cmd = false; if ($cmds['command']) { $cmd = 'command -v'; - } else if ($cmds['which']) { + } elseif ($cmds['which']) { $cmd = 'which'; } diff --git a/src/_h5ai/private/php/ext/class-archive.php b/src/_h5ai/private/php/ext/class-archive.php index e143e070..fec07de3 100644 --- a/src/_h5ai/private/php/ext/class-archive.php +++ b/src/_h5ai/private/php/ext/class-archive.php @@ -37,9 +37,9 @@ class Archive { if ($type === 'php-tar') { return $this->php_tar($this->dirs, $this->files); - } else if ($type === 'shell-tar') { + } elseif ($type === 'shell-tar') { return $this->shell_cmd(Archive::$TAR_PASSTHRU_CMD); - } else if ($type === 'shell-zip') { + } elseif ($type === 'shell-zip') { return $this->shell_cmd(Archive::$ZIP_PASSTHRU_CMD); } return false; @@ -73,7 +73,7 @@ class Archive { header('Content-Length: ' . $total_size); foreach ($dirs as $real_dir => $archived_dir) { - echo $this->php_tar_header($archived_dir, 0, @filemtime($real_dir . DIRECTORY_SEPARATOR . "."), 5); + echo $this->php_tar_header($archived_dir, 0, @filemtime($real_dir . DIRECTORY_SEPARATOR . '.'), 5); } foreach ($files as $real_file => $archived_file) { diff --git a/src/_h5ai/private/php/ext/class-thumb.php b/src/_h5ai/private/php/ext/class-thumb.php index 847c125a..d52d3e85 100644 --- a/src/_h5ai/private/php/ext/class-thumb.php +++ b/src/_h5ai/private/php/ext/class-thumb.php @@ -32,16 +32,16 @@ class Thumb { $capture_path = $source_path; if ($type === 'img') { $capture_path = $source_path; - } else if ($type === 'mov') { + } elseif ($type === 'mov') { if ($this->setup->get('HAS_CMD_AVCONV')) { $capture_path = $this->capture(Thumb::$AVCONV_CMDV, $source_path); - } else if ($this->setup->get('HAS_CMD_FFMPEG')) { + } elseif ($this->setup->get('HAS_CMD_FFMPEG')) { $capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path); } - } else if ($type === 'doc') { + } elseif ($type === 'doc') { if ($this->setup->get('HAS_CMD_CONVERT')) { $capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path); - } else if ($this->setup->get('HAS_CMD_GM')) { + } elseif ($this->setup->get('HAS_CMD_GM')) { $capture_path = $this->capture(Thumb::$GM_CONVERT_CMDV, $source_path); } } @@ -238,7 +238,7 @@ class Image { } $exif = exif_read_data($exif_source_file); - switch(@$exif['Orientation']) { + switch (@$exif['Orientation']) { case 3: $this->rotate(180); break;