10000 [VarDumper] Fix `dd()` showing line with `null` · symfony/symfony@07d318a · GitHub
[go: up one dir, main page]

Skip to content

Commit 07d318a

Browse files
committed
[VarDumper] Fix dd() showing line with null
1 parent 8fd49c1 commit 07d318a

File tree

8 files changed

+96
-1
lines changed

8 files changed

+96
-1
lines changed

src/Symfony/Component/VarDumper/Resources/functions/dump.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function dd(mixed ...$vars): never
4949
header('HTTP/1.1 500 Internal Server Error');
5050
}
5151

52-
if (isset($vars[0]) && 1 === count($vars)) {
52+
if (array_key_exists(0, $vars) && 1 === count($vars)) {
5353
VarDumper::dump($vars[0]);
5454
} else {
5555
foreach ($vars as $k => $v) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Test dd() with multiple args shows line number
3+
--FILE--
4+
<?php
5+
6+
$vendor = __DIR__;
7+
while (!file_exists($vendor.'/vendor')) {
8+
$vendor = \dirname($vendor);
9+
}
10+
require $vendor.'/vendor/autoload.php';
11+
12+
dd(null, 1, 'foo');
13+
14+
--EXPECT--
15+
1 null
16+
2 1
17+
3 "foo"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test dd() with null doesn't show line number
3+
--FILE--
4+
<?php
5+
6+
$vendor = __DIR__;
7+
while (!file_exists($vendor.'/vendor')) {
8+
$vendor = \dirname($vendor);
9+
}
10+
require $vendor.'/vendor/autoload.php';
11+
12+
dd(null);
13+
14+
--EXPECT--
15+
null
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test dd() with one arg doesn't show line number
3+
--FILE--
4+
<?php
5+
6+
$vendor = __DIR__;
7+
while (!file_exists($vendor.'/vendor')) {
8+
$vendor = \dirname($vendor);
9+
}
10+
require $vendor.'/vendor/autoload.php';
11+
12+
dd('foo');
13+
14+
--EXPECT--
15+
"foo"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Test dump() with multiple args shows line number
3+
--FILE--
4+
<?php
5+
6+
$vendor = __DIR__;
7+
while (!file_exists($vendor.'/vendor')) {
8+
$vendor = \dirname($vendor);
9+
}
10+
require $vendor.'/vendor/autoload.php';
11+
12+
dump(null, 1, 'foo');
13+
14+
--EXPECT--
15+
1 null
16+
2 1
17+
3 "foo"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test dump() with null doesn't show line number
3+
--FILE--
4+
<?php
5+
6+
$vendor = __DIR__;
7+
while (!file_exists($vendor.'/vendor')) {
8+
$vendor = \dirname($vendor);
9+
}
10+
require $vendor.'/vendor/autoload.php';
11+
12+
dump(null);
13+
14+
--EXPECT--
15+
null
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test dump() with one arg doesn't show line number
3+
--FILE--
4+
<?php
5+
6+
$vendor = __DIR__;
7+
while (!file_exists($vendor.'/vendor')) {
8+
$vendor = \dirname($vendor);
9+
}
10+
require $vendor.'/vendor/autoload.php';
11+
12+
dump('foo');
13+
14+
--EXPECT--
15+
"foo"

src/Symfony/Component/VarDumper/phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<testsuites>
1818
<testsuite name="Symfony VarDumper Component Test Suite">
1919
<directory>./Tests/</directory>
20+
<directory suffix=".phpt">./Tests/Dumper/functions/</directory>
2021
</testsuite>
2122
</testsuites>
2223

0 commit comments

Comments
 (0)
0