Skip to content

Add compatibility for strict types #4548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +306 to +307
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate that we have to do this, but I guess until we get the interfaces discussion resolved this is the best we can do.

*/

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