Skip to content

Commit 78832ba

Browse files
authored
Merge pull request #1 from php-debugbar/debugbar-v3
Update for v3
2 parents f68a772 + 3ea245f commit 78832ba

10 files changed

Lines changed: 45 additions & 71 deletions

.github/workflows/run-integration.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77
pull_request:
88
branches:
99
- "*"
10-
schedule:
11-
- cron: '0 0 * * *'
12-
1310
jobs:
1411
php-tests:
1512
runs-on: ubuntu-latest
@@ -19,7 +16,7 @@ jobs:
1916

2017
strategy:
2118
matrix:
22-
php: [8.5, 8.4, 8.3, 8.2, 8.1]
19+
php: [8.5, 8.4, 8.3, 8.2]
2320

2421
name: PHP${{ matrix.php }}
2522

.github/workflows/run-screenshots.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches:
99
- "*"
10-
schedule:
11-
- cron: '0 0 * * *'
1210

1311
jobs:
1412
php-tests:

.github/workflows/run-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches:
99
- "*"
10-
schedule:
11-
- cron: '0 0 * * *'
1210

1311
jobs:
1412
php-tests:
@@ -19,7 +17,7 @@ jobs:
1917

2018
strategy:
2119
matrix:
22-
php: [8.5, 8.4, 8.3, 8.2, 8.1]
20+
php: [8.5, 8.4, 8.3, 8.2]
2321

2422
name: PHP${{ matrix.php }}
2523

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.1",
21-
"php-debugbar/php-debugbar": "^2",
20+
"php": "^8.2",
21+
"php-debugbar/php-debugbar": "^3",
2222
"twig/twig": "^3.22"
2323
},
2424
"require-dev": {
@@ -54,5 +54,6 @@
5454
"branch-alias": {
5555
"dev-master": "2.0-dev"
5656
}
57-
}
57+
},
58+
"minimum-stability": "beta"
5859
}

demo/assets.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/** @var \DebugBar\DebugBar $debugbar */
6+
/** @var \DebugBar\JavascriptRenderer $debugbarRenderer */
7+
8+
//Disable session caching
9+
session_cache_limiter('');
10+
11+
include 'bootstrap.php';
12+
13+
$openHandler = new DebugBar\AssetHandler($debugbar);
14+
$openHandler->handle($_GET);

demo/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
$debugbar = new StandardDebugBar();
1111
$debugbarRenderer = $debugbar->getJavascriptRenderer()
12-
->setBaseUrl('../src/DebugBar/Resources')
12+
->setAssetHandlerUrl('assets.php')
1313
->setAjaxHandlerEnableTab(true)
1414
->setHideEmptyTabs(true)
1515
->setTheme($_GET['theme'] ?? 'auto');

src/DebugTwigExtension.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DebugBar\Bridge\Twig;
44

5+
use DebugBar\DataCollector\MessagesCollector;
56
use Twig\Environment;
67
use Twig\Extension\AbstractExtension;
78
use Twig\TwigFunction;
@@ -13,22 +14,14 @@
1314
*/
1415
class DebugTwigExtension extends AbstractExtension
1516
{
16-
/**
17-
* @var \DebugBar\DataCollector\MessagesCollector|null
18-
*/
19-
protected $messagesCollector;
17+
protected ?MessagesCollector $messagesCollector;
2018

2119
/**
2220
* @var string
2321
*/
24-
protected $functionName;
22+
protected string $functionName;
2523

26-
/**
27-
*
28-
* @param \DebugBar\DataCollector\MessagesCollector|null $app
29-
* @param string $functionName
30-
*/
31-
public function __construct($messagesCollector, $functionName = 'debug')
24+
public function __construct(?MessagesCollector $messagesCollector, string $functionName = 'debug')
3225
{
3326
$this->messagesCollector = $messagesCollector;
3427
$this->functionName = $functionName;

src/DumpTwigExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ public function dump(Environment $env, $context)
8383
$data[$key] = $value;
8484
}
8585
}
86-
$output .= $this->formatVar($data);
86+
$output .= $this->getDataFormatter()->formatVar($data);
8787
} else {
8888
for ($i = 2; $i < $count; $i++) {
89-
$output .= $this->formatVar(func_get_arg($i));
89+
$output .= $this->getDataFormatter()->formatVar(func_get_arg($i));
9090
}
9191
}
9292

src/MeasureTwigExtension.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace DebugBar\Bridge\Twig;
44

55
use DebugBar\Bridge\Twig\MeasureTwigTokenParser;
6+
use DebugBar\DataCollector\TimeDataCollector;
67
use Twig\Extension\AbstractExtension;
78

89
/**
@@ -13,23 +14,14 @@
1314
*/
1415
class MeasureTwigExtension extends AbstractExtension
1516
{
16-
/**
17-
* @var \DebugBar\DataCollector\TimeDataCollector|null
18-
*/
19-
protected $timeCollector;
17+
protected ?TimeDataCollector $timeCollector;
2018

2119
/**
2220
* @var string
2321
*/
24-
protected $tagName;
22+
protected string $tagName;
2523

26-
/**
27-
* Create a new auth extension.
28-
*
29-
* @param \DebugBar\DataCollector\TimeDataCollector|null $debugbar
30-
* @param string $tagName
31-
*/
32-
public function __construct($timeCollector, $tagName = 'measure')
24+
public function __construct(?TimeDataCollector $timeCollector, string $tagName = 'measure')
3325
{
3426
$this->timeCollector = $timeCollector;
3527
$this->tagName = $tagName;

src/NamespacedTwigProfileCollector.php

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,17 @@
3535
*/
3636
class NamespacedTwigProfileCollector extends DataCollector implements Renderable, AssetProvider
3737
{
38-
/**
39-
* @var Profile
40-
*/
41-
private $profile;
38+
private Profile $profile;
4239

43-
/**
44-
* @var LoaderInterface|Environment|null
45-
*/
46-
private $loader;
40+
private LoaderInterface|Environment|null $loader;
4741

48-
/**
49-
* @var int
50-
*/
51-
private $templateCount;
5242

53-
/**
54-
* @var int
55-
*/
56-
private $blockCount;
43+
private int $templateCount = 0;
44+
45+
private int $blockCount = 0;
46+
47+
private int $macroCount = 0;
5748

58-
/**
59-
* @var int
60-
*/
61-
private $macroCount;
6249
/**
6350
* @var array[] {
6451
* @var string $name
@@ -70,13 +57,7 @@ class NamespacedTwigProfileCollector extends DataCollector implements Renderable
7057
*/
7158
private $templates;
7259

73-
/**
74-
* TwigProfileCollector constructor.
75-
*
76-
* @param Profile $profile
77-
* @param LoaderInterface|Environment $loaderOrEnv
78-
*/
79-
public function __construct(Profile $profile, $loaderOrEnv = null)
60+
public function __construct(Profile $profile, LoaderInterface|Environment|null $loaderOrEnv = null)
8061
{
8162
$this->profile = $profile;
8263
$this->setLoaderOrEnv($loaderOrEnv);
@@ -100,7 +81,7 @@ public function setLoaderOrEnv($loaderOrEnv)
10081
*
10182
* @return array
10283
*/
103-
public function getWidgets()
84+
public function getWidgets(): array
10485
{
10586
return [
10687
'twig' => [
@@ -119,7 +100,7 @@ public function getWidgets()
119100
/**
120101
* @return array
121102
*/
122-
public function getAssets()
103+
public function getAssets(): array
123104
{
124105
return [
125106
'css' => 'widgets/templates/widget.css',
@@ -132,7 +113,7 @@ public function getAssets()
132113
*
133114
* @return array Collected data
134115
*/
135-
public function collect()
116+
public function collect(): array
136117
{
137118
$this->templateCount = $this->blockCount = $this->macroCount = 0;
138119
$this->templates = [];
@@ -163,12 +144,12 @@ public function collect()
163144
*
164145
* @return string
165146
*/
166-
public function getName()
147+
public function getName(): string
167148
{
168149
return 'twig';
169150
}
170151

171-
public function getHtmlCallGraph()
152+
public function getHtmlCallGraph(): string
172153
{
173154
$dumper = new HtmlDumper();
174155
return $dumper->dump($this->profile);
@@ -182,7 +163,7 @@ public function getHtmlCallGraph()
182163
* @var bool ajax
183164
* }
184165
*/
185-
public function getXdebugLink($template, $line = 1)
166+
public function getXdebugLink(string $template, ?int $line = 1): ?array
186167
{
187168
if (is_null($this->loader)) {
188169
return null;

0 commit comments

Comments
 (0)