diff --git a/system/engine/registry.php b/system/engine/registry.php index 091aeb3..41ec241 100644 --- a/system/engine/registry.php +++ b/system/engine/registry.php @@ -192,22 +192,22 @@ final class Registry { */ static public function addPreference($jsonFilePath) { $dataArray = []; - if (file_exists($jsonFilePath)) { - $jsonData = file_get_contents($jsonFilePath); - + if (file_exists($jsonFilePath) && $jsonData = file_get_contents($jsonFilePath)) { + $dataArray = json_decode($jsonData, true); // Verifica se a conversão foi bem-sucedida if ($dataArray === null && json_last_error() !== JSON_ERROR_NONE) { // Se houver um erro na conversão, trata o erro - $error = new \Phacil\Framework\Exception(json_last_error_msg()); + $error = new \Phacil\Framework\Exception\Error(sprintf("DI preference %s error: ", $jsonFilePath). json_last_error_msg()); + $error->setSeverity(E_PARSE); return; } } if (isset($dataArray['preferences'])) self::$preferences = array_merge(self::$preferences, $dataArray['preferences']); - if(count($dataArray) > 1) { + if(count($dataArray) >= 1) { foreach($dataArray as $key => $value) { if($key !== "preferences") self::$diOptions[$key] = isset(self::$diOptions[$key]) ? self::array_merge_recursive_distinct(self::$diOptions[$key], $value) : $value; @@ -365,7 +365,7 @@ final class Registry { * @throws \Exception * @throws \Phacil\Framework\Exception */ - static public function checkType($class, $argument) { + protected static function checkType($class, $argument) { if(isset(self::$diOptions['type'])){ if(isset(self::$diOptions['type'][$class])){ if(isset(self::$diOptions['type'][$class][$argument])){