8000 [VarDumper] Fix global dump function return value for PHP7 by patrickcarlohickman · Pull Request #28497 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] Fix global dump function return value for PHP7 #28497

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
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
[VarDumper] Fix global dump function return value for PHP7
  • Loading branch information
patrickcarlohickman authored and nicolas-grekas committed Sep 18, 2018
commit 0def211b9b67a815fb70476ab5297e57a02daf82
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Resources/functions/dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
function dump($var)
{
foreach (func_get_args() as $var) {
VarDumper::dump($var);
foreach (func_get_args() as $v) {
VarDumper::dump($v);
}

if (1 < func_num_args()) {
Expand Down
57 changes: 57 additions & 0 deletions src/Symfony/Component/VarDumper/Tests/Dumper/FunctionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\VarDumper\Tests\Dumper;

use PHPUnit\Framework\TestCase;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\VarDumper;

class FunctionsTest extends TestCase
{
public function testDumpReturnsFirstArg()
{
$this->setupVarDumper();

$var1 = 'a';

ob_start();
$return = dump($var1);
$out = ob_get_clean();

$this->assertEquals($var1, $return);
}

public function testDumpReturnsAllArgsInArray()
{
$this->setupVarDumper();

$var1 = 'a';
$var2 = 'b';
$var3 = 'c';

ob_start();
$return = dump($var1, $var2, $var3);
$out = ob_get_clean();

$this->assertEquals(array($var1, $var2, $var3), $return);
}

protected function setupVarDumper()
{
$cloner = new VarCloner();
$dumper = new CliDumper('php://output');
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
$dumper->dump($cloner->cloneVar($var));
});
}
}
0