diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index b04ed3d652..a500a6b721 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1203,7 +1203,7 @@ class acp_styles } $json = file_get_contents($this->styles_path . $dir . '/composer.json'); - $style_data = \phpbb\json_sanitizer::decode($json); + $style_data = \phpbb\json\sanitizer::decode($json); if (!is_array($style_data) || !isset($style_data['type']) || $style_data['type'] !== 'phpbb-style') { diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index 950080ef48..acf343e194 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -13,7 +13,7 @@ namespace phpbb\cache; -use phpbb\json_sanitizer; +use phpbb\json\sanitizer; /** * Class for grabbing/handling cached entries @@ -357,7 +357,7 @@ class service { // Re-parse cfg file $json = file_get_contents($filename); - $parsed_array = json_sanitizer::decode($json); + $parsed_array = sanitizer::decode($json); $parsed_array['filetime'] = @filemtime($filename); $this->driver->put('_cfg_' . $style['style_path'], $parsed_array); diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php index 0ba9b86a33..a6f1c1fa13 100644 --- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v310; -use phpbb\json_sanitizer; +use phpbb\json\sanitizer; class style_update_p1 extends \phpbb\db\migration\migration { @@ -85,7 +85,7 @@ class style_update_p1 extends \phpbb\db\migration\migration else if (file_exists($fileinfo->getPathname() . '/composer.json')) { $json = file_get_contents($fileinfo->getPathname() . '/composer.json'); - $style_data = json_sanitizer::decode($json); + $style_data = sanitizer::decode($json); if (isset($style_data['extra']['phpbb-version']) && version_compare($style_data['extra']['phpbb-version'], '3.3.0-dev', '>=')) { // 3.3 style diff --git a/phpBB/phpbb/json/sanitizer.php b/phpBB/phpbb/json/sanitizer.php index 8d6937e630..ea3112ee37 100644 --- a/phpBB/phpbb/json/sanitizer.php +++ b/phpBB/phpbb/json/sanitizer.php @@ -1,24 +1,25 @@ -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ -namespace phpbb; +namespace phpbb\json; use phpbb\request\type_cast_helper; /** -* JSON sanitizer class -*/ -class json_sanitizer + * JSON sanitizer class + */ +class sanitizer { /** * Sanitize json data @@ -27,7 +28,7 @@ class json_sanitizer * * @return array Sanitized data */ - static public function sanitize($data) + static public function sanitize(array $data) : array { if (!empty($data)) { @@ -48,7 +49,7 @@ class json_sanitizer * * @return array Data array */ - static public function decode($json) + static public function decode(string $json) : array { $data = json_decode($json, true); return !empty($data) ? self::sanitize($data) : []; diff --git a/phpBB/phpbb/language/language_file_helper.php b/phpBB/phpbb/language/language_file_helper.php index de395b64bd..d5fc716e1c 100644 --- a/phpBB/phpbb/language/language_file_helper.php +++ b/phpBB/phpbb/language/language_file_helper.php @@ -13,7 +13,7 @@ namespace phpbb\language; -use phpbb\json_sanitizer; +use phpbb\json\sanitizer; use Symfony\Component\Finder\Finder; /** @@ -55,7 +55,7 @@ class language_file_helper foreach ($finder as $file) { $json = $file->getContents(); - $data = json_sanitizer::decode($json); + $data = sanitizer::decode($json); $available_languages[] = $this->get_language_data_from_json($data); } @@ -72,7 +72,7 @@ class language_file_helper public function get_language_data_from_composer_file($path) { $json_data = file_get_contents($path); - return $this->get_language_data_from_json(json_sanitizer::decode($json_data)); + return $this->get_language_data_from_json(sanitizer::decode($json_data)); } /** diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 5bcd311ffe..7c6edbea95 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -390,7 +390,7 @@ class version_helper } // Sanitize any data we retrieve from a server - $info = json_sanitizer::decode($info); + $info = json\sanitizer::decode($info); if (empty($info['stable']) && empty($info['unstable'])) {