From 3ea245f8f5c29b19341e025588e24549c796dcd1 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 9 Jan 2026 16:31:20 +0100 Subject: [PATCH] Update for v3 --- .github/workflows/run-integration.yml | 5 +-- .github/workflows/run-screenshots.yml | 2 -- .github/workflows/run-tests.yml | 4 +-- composer.json | 7 ++-- demo/assets.php | 14 ++++++++ demo/bootstrap.php | 2 +- src/DebugTwigExtension.php | 15 +++----- src/DumpTwigExtension.php | 4 +-- src/MeasureTwigExtension.php | 16 +++------ src/NamespacedTwigProfileCollector.php | 47 ++++++++------------------ 10 files changed, 45 insertions(+), 71 deletions(-) create mode 100644 demo/assets.php diff --git a/.github/workflows/run-integration.yml b/.github/workflows/run-integration.yml index b191bd3..478b3cd 100644 --- a/.github/workflows/run-integration.yml +++ b/.github/workflows/run-integration.yml @@ -7,9 +7,6 @@ on: pull_request: branches: - "*" - schedule: - - cron: '0 0 * * *' - jobs: php-tests: runs-on: ubuntu-latest @@ -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 }} diff --git a/.github/workflows/run-screenshots.yml b/.github/workflows/run-screenshots.yml index 38a5aec..9958f1f 100644 --- a/.github/workflows/run-screenshots.yml +++ b/.github/workflows/run-screenshots.yml @@ -7,8 +7,6 @@ on: pull_request: branches: - "*" - schedule: - - cron: '0 0 * * *' jobs: php-tests: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b33983c..ab5dbde 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,8 +7,6 @@ on: pull_request: branches: - "*" - schedule: - - cron: '0 0 * * *' jobs: php-tests: @@ -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 }} diff --git a/composer.json b/composer.json index 8130574..dab56fe 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -54,5 +54,6 @@ "branch-alias": { "dev-master": "2.0-dev" } - } + }, + "minimum-stability": "beta" } diff --git a/demo/assets.php b/demo/assets.php new file mode 100644 index 0000000..4867e40 --- /dev/null +++ b/demo/assets.php @@ -0,0 +1,14 @@ +handle($_GET); diff --git a/demo/bootstrap.php b/demo/bootstrap.php index bbe02ab..9d662af 100644 --- a/demo/bootstrap.php +++ b/demo/bootstrap.php @@ -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'); diff --git a/src/DebugTwigExtension.php b/src/DebugTwigExtension.php index a7f6bce..b62bf80 100644 --- a/src/DebugTwigExtension.php +++ b/src/DebugTwigExtension.php @@ -2,6 +2,7 @@ namespace DebugBar\Bridge\Twig; +use DebugBar\DataCollector\MessagesCollector; use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -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; diff --git a/src/DumpTwigExtension.php b/src/DumpTwigExtension.php index 83714cb..f903d49 100644 --- a/src/DumpTwigExtension.php +++ b/src/DumpTwigExtension.php @@ -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)); } } diff --git a/src/MeasureTwigExtension.php b/src/MeasureTwigExtension.php index d92cdd9..4298192 100644 --- a/src/MeasureTwigExtension.php +++ b/src/MeasureTwigExtension.php @@ -3,6 +3,7 @@ namespace DebugBar\Bridge\Twig; use DebugBar\Bridge\Twig\MeasureTwigTokenParser; +use DebugBar\DataCollector\TimeDataCollector; use Twig\Extension\AbstractExtension; /** @@ -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; diff --git a/src/NamespacedTwigProfileCollector.php b/src/NamespacedTwigProfileCollector.php index 1d5d3a6..2bc088d 100644 --- a/src/NamespacedTwigProfileCollector.php +++ b/src/NamespacedTwigProfileCollector.php @@ -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 @@ -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); @@ -100,7 +81,7 @@ public function setLoaderOrEnv($loaderOrEnv) * * @return array */ - public function getWidgets() + public function getWidgets(): array { return [ 'twig' => [ @@ -119,7 +100,7 @@ public function getWidgets() /** * @return array */ - public function getAssets() + public function getAssets(): array { return [ 'css' => 'widgets/templates/widget.css', @@ -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 = []; @@ -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); @@ -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;