Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[VarDumper] Fix dd() showing line with null #50406

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
May 23, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function dd(mixed ...$vars): never
header('HTTP/1.1 500 Internal Server Error');
}

if (isset($vars[0]) && 1 === count($vars)) {
if (array_key_exists(0, $vars) && 1 === count($vars)) {
VarDumper::dump($vars[0]);
} else {
foreach ($vars as $k => $v) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Test dd() with multiple args shows line number
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

dd(null, 1, 'foo');

--EXPECT--
1 null
2 1
3 "foo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Test dd() with null doesn't show line number
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

dd(null);

--EXPECT--
null
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Test dd() with one arg doesn't show line number
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

dd('foo');

--EXPECT--
"foo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Test dump() with multiple args shows line number
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

dump(null, 1, 'foo');

--EXPECT--
1 null
2 1
3 "foo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Test dump() with null doesn't show line number
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

dump(null);

--EXPECT--
null
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Test dump() with one arg doesn't show line number
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

dump('foo');

--EXPECT--
"foo"
1 change: 1 addition & 0 deletions src/Symfony/Component/VarDumper/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<testsuites>
<testsuite name="Symfony VarDumper Component Test Suite">
<directory>./Tests/</directory>
<directory suffix=".phpt">./Tests/Dumper/functions/</directory>
</testsuite>
</testsuites>

Expand Down