From 2dcb6dc5d57ad549c52bd4208b57b2164d7332ca Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 1 Feb 2019 23:15:10 +0300 Subject: [PATCH] Flextype Core: Flextype - code fixes according Scrutinizer Tests. It seems like Flextype\Component\Files...ult_settings_file_path) can also be of type false; however, parameter $input of Flextype\YamlParser::decode() does only seem to accept string, maybe add an additional type check? Fixed --- flextype/Flextype.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/flextype/Flextype.php b/flextype/Flextype.php index eb98cccf..fb7b3875 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -154,9 +154,20 @@ class Flextype // Set settings if Flextype settings and Site settings config files exist if (Filesystem::has($default_settings_file_path) && Filesystem::has($site_settings_file_path)) { - // Get Flextype settings and Site settings - $default_settings = YamlParser::decode(Filesystem::read($default_settings_file_path)); - $site_settings = YamlParser::decode(Filesystem::read($site_settings_file_path)); + $default_settings = []; + $site_settings = []; + + if (($content = Filesystem::read($default_settings_file_path)) === false) { + throw new \RuntimeException('Load file: ' . $default_settings_file_path . ' - failed!'); + } else { + $default_settings = YamlParser::decode($content); + } + + if (($content = Filesystem::read($site_settings_file_path)) === false) { + throw new \RuntimeException('Load file: ' . $site_settings_file_path . ' - failed!'); + } else { + $site_settings = YamlParser::decode($content); + } // Merge settings $settings = array_replace_recursive($default_settings, $site_settings);