diff --git a/composer.json b/composer.json index 5452a4d..809568d 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,12 @@ ], "license": "MIT", "require-dev": { + "php-coveralls/php-coveralls": "2.5.2", "phpunit/phpunit": "9.5.21", - "squizlabs/php_codesniffer": "3.7.1", - "php-coveralls/php-coveralls": "2.5.2" + "squizlabs/php_codesniffer": "3.7.1" }, "require": { - "phpugph/components": "1.0.5" + "phpugph/components": "1.0.6" }, "autoload": { "psr-4": { diff --git a/src/HandlebarsCompiler.php b/src/HandlebarsCompiler.php index e4e4b16..9ebc9a4 100644 --- a/src/HandlebarsCompiler.php +++ b/src/HandlebarsCompiler.php @@ -44,7 +44,7 @@ class HandlebarsCompiler /** * @const string BLOCK_VARIABLE_VALUE */ - const BLOCK_VARIABLE_VALUE = '\r\t$buffer .= htmlspecialchars($data->find(\'%s\'), ENT_COMPAT, \'UTF-8\');\r'; + const BLOCK_VARIABLE_VALUE = '\r\t$buffer .= htmlspecialchars($data->find(\'%s\') ?? \'\', ENT_COMPAT, \'UTF-8\');\r'; /** * @const string BLOCK_ESCAPE_HELPER_OPEN @@ -59,7 +59,7 @@ class HandlebarsCompiler /** * @const string BLOCK_VARIABLE_HELPER_OPEN */ - const BLOCK_VARIABLE_HELPER_OPEN = '\r\t$buffer .= htmlspecialchars($helper[\'%s\']('; + const BLOCK_VARIABLE_HELPER_OPEN = '\r\t$buffer .= htmlspecialchars((string) $helper[\'%s\']('; /** * @const string BLOCK_VARIABLE_HELPER_CLOSE diff --git a/src/HandlebarsHandler.php b/src/HandlebarsHandler.php index 37fe485..0080592 100644 --- a/src/HandlebarsHandler.php +++ b/src/HandlebarsHandler.php @@ -79,13 +79,13 @@ public function compile($template) $file = $this->cache . '/' . $this->prefix . $name . '.php'; // @codeCoverageIgnoreStart - if (is_dir((string) $this->cache) && file_exists($file)) { + if (is_dir($this->cache ?? '') && file_exists($file)) { $callback = include($file); } else { $code = $this->resolve(HandlebarsCompiler::class, $this, $template) ->compile(); - if (is_dir((string) $this->cache)) { + if (is_dir($this->cache ?? '')) { file_put_contents($file, $code); }