Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0def211

Browse filesBrowse files
patrickcarlohickmannicolas-grekas
authored andcommitted
[VarDumper] Fix global dump function return value for PHP7
1 parent b4bbc25 commit 0def211
Copy full SHA for 0def211

File tree

Expand file treeCollapse file tree

2 files changed

+59
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+59
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Resources/functions/dump.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818
function dump($var)
1919
{
20-
foreach (func_get_args() as $var) {
21-
VarDumper::dump($var);
20+
foreach (func_get_args() as $v) {
21+
VarDumper::dump($v);
2222
}
2323

2424
if (1 < func_num_args()) {
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\VarDumper\Tests\Dumper;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\VarDumper\Cloner\VarCloner;
16+
use Symfony\Component\VarDumper\Dumper\CliDumper;
17+
use Symfony\Component\VarDumper\VarDumper;
18+
19+
class FunctionsTest extends TestCase
20+
{
21+
public function testDumpReturnsFirstArg()
22+
{
23+
$this->setupVarDumper();
24+
25+
$var1 = 'a';
26+
27+
ob_start();
28+
$return = dump($var1);
29+
$out = ob_get_clean();
30+
31+
$this->assertEquals($var1, $return);
32+
}
33+
34+
public function testDumpReturnsAllArgsInArray()
35+
{
36+
$this->setupVarDumper();
37+
38+
$var1 = 'a';
39+
$var2 = 'b';
40+
$var3 = 'c';
41+
42+
ob_start();
43+
$return = dump($var1, $var2, $var3);
44+
$out = ob_get_clean();
45+
46+
$this->assertEquals(array($var1, $var2, $var3), $return);
47+
}
48+
49+
protected function setupVarDumper()
50+
{
51+
$cloner = new VarCloner();
52+
$dumper = new CliDumper('php://output');
53+
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
54+
$dumper->dump($cloner->cloneVar($var));
55+
});
56+
}
57+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.