Skip to content

Commit

Permalink
Add compatibility for strict types (#4548)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan authored Apr 23, 2021
1 parent ddb6d87 commit b967d9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 14 additions & 2 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions system/View/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -579,17 +580,15 @@ 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) === '!}')
{
$escape = false;
}

return $this->prepareReplacement($matches, $content, $escape);
}, $template);

return $template;
}, (string) $template);
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit b967d9e

Please sign in to comment.