Skip to content
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
5 changes: 1 addition & 4 deletions .github/workflows/run-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
runs-on: ubuntu-latest
Expand All @@ -19,7 +16,7 @@ jobs:

strategy:
matrix:
php: [8.5, 8.4, 8.3, 8.2, 8.1]
php: [8.5, 8.4, 8.3, 8.2]

name: PHP${{ matrix.php }}

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/run-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
Expand All @@ -19,7 +17,7 @@ jobs:

strategy:
matrix:
php: [8.5, 8.4, 8.3, 8.2, 8.1]
php: [8.5, 8.4, 8.3, 8.2]

name: PHP${{ matrix.php }}

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
],
"require": {
"php": "^8.1",
"php-debugbar/php-debugbar": "^2",
"php": "^8.2",
"php-debugbar/php-debugbar": "^3",
"twig/twig": "^3.22"
},
"require-dev": {
Expand Down Expand Up @@ -54,5 +54,6 @@
"branch-alias": {
"dev-master": "2.0-dev"
}
}
},
"minimum-stability": "beta"
}
14 changes: 14 additions & 0 deletions demo/assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

/** @var \DebugBar\DebugBar $debugbar */
/** @var \DebugBar\JavascriptRenderer $debugbarRenderer */

//Disable session caching
session_cache_limiter('');

include 'bootstrap.php';

$openHandler = new DebugBar\AssetHandler($debugbar);
$openHandler->handle($_GET);
2 changes: 1 addition & 1 deletion demo/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

$debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer()
->setBaseUrl('../src/DebugBar/Resources')
->setAssetHandlerUrl('assets.php')
->setAjaxHandlerEnableTab(true)
->setHideEmptyTabs(true)
->setTheme($_GET['theme'] ?? 'auto');
Expand Down
15 changes: 4 additions & 11 deletions src/DebugTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DebugBar\Bridge\Twig;

use DebugBar\DataCollector\MessagesCollector;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
Expand All @@ -13,22 +14,14 @@
*/
class DebugTwigExtension extends AbstractExtension
{
/**
* @var \DebugBar\DataCollector\MessagesCollector|null
*/
protected $messagesCollector;
protected ?MessagesCollector $messagesCollector;

/**
* @var string
*/
protected $functionName;
protected string $functionName;

/**
*
* @param \DebugBar\DataCollector\MessagesCollector|null $app
* @param string $functionName
*/
public function __construct($messagesCollector, $functionName = 'debug')
public function __construct(?MessagesCollector $messagesCollector, string $functionName = 'debug')
{
$this->messagesCollector = $messagesCollector;
$this->functionName = $functionName;
Expand Down
4 changes: 2 additions & 2 deletions src/DumpTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public function dump(Environment $env, $context)
$data[$key] = $value;
}
}
$output .= $this->formatVar($data);
$output .= $this->getDataFormatter()->formatVar($data);
} else {
for ($i = 2; $i < $count; $i++) {
$output .= $this->formatVar(func_get_arg($i));
$output .= $this->getDataFormatter()->formatVar(func_get_arg($i));
}
}

Expand Down
16 changes: 4 additions & 12 deletions src/MeasureTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DebugBar\Bridge\Twig;

use DebugBar\Bridge\Twig\MeasureTwigTokenParser;
use DebugBar\DataCollector\TimeDataCollector;
use Twig\Extension\AbstractExtension;

/**
Expand All @@ -13,23 +14,14 @@
*/
class MeasureTwigExtension extends AbstractExtension
{
/**
* @var \DebugBar\DataCollector\TimeDataCollector|null
*/
protected $timeCollector;
protected ?TimeDataCollector $timeCollector;

/**
* @var string
*/
protected $tagName;
protected string $tagName;

/**
* Create a new auth extension.
*
* @param \DebugBar\DataCollector\TimeDataCollector|null $debugbar
* @param string $tagName
*/
public function __construct($timeCollector, $tagName = 'measure')
public function __construct(?TimeDataCollector $timeCollector, string $tagName = 'measure')
{
$this->timeCollector = $timeCollector;
$this->tagName = $tagName;
Expand Down
47 changes: 14 additions & 33 deletions src/NamespacedTwigProfileCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,17 @@
*/
class NamespacedTwigProfileCollector extends DataCollector implements Renderable, AssetProvider
{
/**
* @var Profile
*/
private $profile;
private Profile $profile;

/**
* @var LoaderInterface|Environment|null
*/
private $loader;
private LoaderInterface|Environment|null $loader;

/**
* @var int
*/
private $templateCount;

/**
* @var int
*/
private $blockCount;
private int $templateCount = 0;

private int $blockCount = 0;

private int $macroCount = 0;

/**
* @var int
*/
private $macroCount;
/**
* @var array[] {
* @var string $name
Expand All @@ -70,13 +57,7 @@ class NamespacedTwigProfileCollector extends DataCollector implements Renderable
*/
private $templates;

/**
* TwigProfileCollector constructor.
*
* @param Profile $profile
* @param LoaderInterface|Environment $loaderOrEnv
*/
public function __construct(Profile $profile, $loaderOrEnv = null)
public function __construct(Profile $profile, LoaderInterface|Environment|null $loaderOrEnv = null)
{
$this->profile = $profile;
$this->setLoaderOrEnv($loaderOrEnv);
Expand All @@ -100,7 +81,7 @@ public function setLoaderOrEnv($loaderOrEnv)
*
* @return array
*/
public function getWidgets()
public function getWidgets(): array
{
return [
'twig' => [
Expand All @@ -119,7 +100,7 @@ public function getWidgets()
/**
* @return array
*/
public function getAssets()
public function getAssets(): array
{
return [
'css' => 'widgets/templates/widget.css',
Expand All @@ -132,7 +113,7 @@ public function getAssets()
*
* @return array Collected data
*/
public function collect()
public function collect(): array
{
$this->templateCount = $this->blockCount = $this->macroCount = 0;
$this->templates = [];
Expand Down Expand Up @@ -163,12 +144,12 @@ public function collect()
*
* @return string
*/
public function getName()
public function getName(): string
{
return 'twig';
}

public function getHtmlCallGraph()
public function getHtmlCallGraph(): string
{
$dumper = new HtmlDumper();
return $dumper->dump($this->profile);
Expand All @@ -182,7 +163,7 @@ public function getHtmlCallGraph()
* @var bool ajax
* }
*/
public function getXdebugLink($template, $line = 1)
public function getXdebugLink(string $template, ?int $line = 1): ?array
{
if (is_null($this->loader)) {
return null;
Expand Down
Loading