From 94ee3dc8b0f0962e864ec791d67653b54cdfad75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Tue, 27 Jun 2017 10:41:30 +0200 Subject: [PATCH] [ticket/15253] Fix code style PHPBB3-15253 --- .../exception/filesystem_exception.php | 8 +++--- phpBB/phpbb/filesystem/helper.php | 5 ++-- phpBB/phpbb/storage/adapter/local.php | 8 ++++-- phpBB/phpbb/storage/exception/exception.php | 8 +++--- .../storage/exception/not_implemented.php | 25 +------------------ 5 files changed, 20 insertions(+), 34 deletions(-) diff --git a/phpBB/phpbb/filesystem/exception/filesystem_exception.php b/phpBB/phpbb/filesystem/exception/filesystem_exception.php index d68fa9adf3..ddff8046e5 100644 --- a/phpBB/phpbb/filesystem/exception/filesystem_exception.php +++ b/phpBB/phpbb/filesystem/exception/filesystem_exception.php @@ -13,7 +13,9 @@ namespace phpbb\filesystem\exception; -class filesystem_exception extends \phpbb\exception\runtime_exception +use phpbb\exception\runtime_exception; + +class filesystem_exception extends runtime_exception { /** * Constructor @@ -24,7 +26,7 @@ class filesystem_exception extends \phpbb\exception\runtime_exception * @param \Exception $previous The previous runtime_exception used for the runtime_exception chaining. * @param integer $code The Exception code. */ - public function __construct($message = "", $filename = '', $parameters = array(), \Exception $previous = null, $code = 0) + public function __construct($message = '', $filename = '', $parameters = array(), \Exception $previous = null, $code = 0) { parent::__construct($message, array_merge(array('filename' => $filename), $parameters), $previous, $code); } @@ -36,7 +38,7 @@ class filesystem_exception extends \phpbb\exception\runtime_exception */ public function get_filename() { - $parameters = parent::get_parameters(); + $parameters = $this->get_parameters(); return $parameters['filename']; } } diff --git a/phpBB/phpbb/filesystem/helper.php b/phpBB/phpbb/filesystem/helper.php index 2549a49929..a8a792bebc 100644 --- a/phpBB/phpbb/filesystem/helper.php +++ b/phpBB/phpbb/filesystem/helper.php @@ -13,6 +13,8 @@ namespace phpbb\filesystem; +use Symfony\Component\Filesystem\Filesystem as symfony_filesystem; + class helper { /** @@ -66,7 +68,6 @@ class helper */ protected static function phpbb_own_realpath($path) { - // Replace all directory separators with '/' $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); @@ -206,7 +207,7 @@ class helper */ public static function make_path_relative($end_path, $start_path) { - $symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem(); + $symfony_filesystem = new symfony_filesystem(); return $symfony_filesystem->makePathRelative($end_path, $start_path); } diff --git a/phpBB/phpbb/storage/adapter/local.php b/phpBB/phpbb/storage/adapter/local.php index dab6fbc34f..5d0651c466 100644 --- a/phpBB/phpbb/storage/adapter/local.php +++ b/phpBB/phpbb/storage/adapter/local.php @@ -15,6 +15,8 @@ namespace phpbb\storage\adapter; use phpbb\storage\exception\exception; use phpbb\filesystem\exception\filesystem_exception; +use phpbb\config\config; +use phpbb\filesystem\filesystem; /** * @internal Experimental @@ -34,7 +36,7 @@ class local implements adapter_interface /** * Constructor */ - public function __construct(\phpbb\config\config $config, \phpbb\filesystem\filesystem $filesystem, $phpbb_root_path, $path_key) + public function __construct(config $config, filesystem $filesystem, $phpbb_root_path, $path_key) { $this->filesystem = $filesystem; $this->root_path = $phpbb_root_path . $config[$path_key]; @@ -75,7 +77,9 @@ class local implements adapter_interface throw new exception('', $path); // FILE_DONT_EXIST } - if (($content = @file_get_contents($this->root_path . $path)) === false) + $content = @file_get_contents($this->root_path . $path); + + if ($content === false) { throw new exception('', $path); // CANNOT READ FILE } diff --git a/phpBB/phpbb/storage/exception/exception.php b/phpBB/phpbb/storage/exception/exception.php index ee42178961..4eca403cc1 100644 --- a/phpBB/phpbb/storage/exception/exception.php +++ b/phpBB/phpbb/storage/exception/exception.php @@ -13,7 +13,9 @@ namespace phpbb\storage\exception; -class exception extends \phpbb\exception\runtime_exception +use phpbb\exception\runtime_exception; + +class exception extends runtime_exception { /** * Constructor @@ -24,7 +26,7 @@ class exception extends \phpbb\exception\runtime_exception * @param \Exception $previous The previous runtime_exception used for the runtime_exception chaining. * @param integer $code The Exception code. */ - public function __construct($message = "", $filename = '', $parameters = array(), \Exception $previous = null, $code = 0) + public function __construct($message = '', $filename = '', $parameters = [], \Exception $previous = null, $code = 0) { parent::__construct($message, array_merge(array('filename' => $filename), $parameters), $previous, $code); } @@ -36,7 +38,7 @@ class exception extends \phpbb\exception\runtime_exception */ public function get_filename() { - $parameters = parent::get_parameters(); + $parameters = $this->get_parameters(); return $parameters['filename']; } } diff --git a/phpBB/phpbb/storage/exception/not_implemented.php b/phpBB/phpbb/storage/exception/not_implemented.php index 5504cfa76f..df535048e5 100644 --- a/phpBB/phpbb/storage/exception/not_implemented.php +++ b/phpBB/phpbb/storage/exception/not_implemented.php @@ -13,30 +13,7 @@ namespace phpbb\storage\exception; -class not_implemented extends \phpbb\exception\runtime_exception +class not_implemented extends exception { - /** - * Constructor - * - * @param string $message The Exception message to throw (must be a language variable). - * @param string $filename The file that caused the error. - * @param array $parameters The parameters to use with the language var. - * @param \Exception $previous The previous runtime_exception used for the runtime_exception chaining. - * @param integer $code The Exception code. - */ - public function __construct($message = "", $filename = '', $parameters = array(), \Exception $previous = null, $code = 0) - { - parent::__construct($message, array_merge(array('filename' => $filename), $parameters), $previous, $code); - } - /** - * Returns the filename that triggered the error - * - * @return string - */ - public function get_filename() - { - $parameters = parent::get_parameters(); - return $parameters['filename']; - } }