From f8f668f208661c09c925230b430b2acf51264d0e Mon Sep 17 00:00:00 2001 From: gkdev Date: Sun, 10 Sep 2023 00:15:50 +0300 Subject: [PATCH] fix: errors after phpstan lint --- src/Engine.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Engine.php b/src/Engine.php index 71a34d9..4f6feb1 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -33,12 +33,12 @@ function loadTexts(array $module): array } try { - $content = file_get_contents($textsFile); - $texts = $content ? json_decode($content, true, 512, JSON_THROW_ON_ERROR) : ''; + $content = (string)file_get_contents($textsFile); + $texts = json_decode($content, true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { } - $isEmptyConfig = !isset($texts) || !$texts; + $isEmptyConfig = !isset($texts) || $texts === ''; if ($isEmptyConfig) { throw new RuntimeException("Config $textsFile wasn't loaded"); } @@ -56,7 +56,8 @@ function buildGame(string $moduleName): array } require_once $moduleFile; - return "BrainGames\Games\\$moduleName\loader"($module); + $loader = "BrainGames\Games\\$moduleName\loader"; + return is_callable($loader) ? $loader($module) : []; } function greetUser(array $module): array