diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 452f3484677b..b4bc12d90de2 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -18,7 +18,9 @@ use CodeIgniter\Format\JSONFormatter; use CodeIgniter\Format\XMLFormatter; use CodeIgniter\HTTP\DownloadResponse; +use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; +use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface; use Config\Services; use Config\Toolbar as ToolbarConfig; @@ -84,6 +86,11 @@ public function __construct(ToolbarConfig $config) */ public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string { + /** + * @var IncomingRequest $request + * @var Response $response + */ + // Data items used within the view. $data['url'] = current_url(); $data['method'] = $request->getMethod(true); @@ -295,6 +302,11 @@ protected function roundTo(float $number, int $increments = 5): float */ public function prepare(RequestInterface $request = null, ResponseInterface $response = null) { + /** + * @var IncomingRequest $request + * @var Response $response + */ + if (CI_DEBUG && ! is_cli()) { global $app; @@ -437,8 +449,8 @@ protected function format(string $data, string $format = 'html'): string { $history = new History(); $history->setFiles( - Services::request()->getGet('debugbar_time'), - $this->config->maxHistory + (int) Services::request()->getGet('debugbar_time'), + $this->config->maxHistory ); $data['collectors'][] = $history->getAsArray(); diff --git a/system/View/Parser.php b/system/View/Parser.php index 3a32020ac140..9bfb937067ca 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -570,6 +570,7 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f { // Any dollar signs in the pattern will be misinterpreted, so slash them $pattern = addcslashes($pattern, '$'); + $content = (string) $content; // Flesh out the main pattern from the delimiters and escape the hash // See https://regex101.com/r/IKdUlk/1 @@ -579,7 +580,7 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f } // Replace the content in the template - $template = preg_replace_callback($pattern, function ($matches) use ($content, $escape) { + return preg_replace_callback($pattern, function ($matches) use ($content, $escape) { // Check for {! !} syntax to not escape this one. if (strpos($matches[0], '{!') === 0 && substr($matches[0], -2) === '!}') { @@ -587,9 +588,7 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f } return $this->prepareReplacement($matches, $content, $escape); - }, $template); - - return $template; + }, (string) $template); } //--------------------------------------------------------------------