Skip to content

Commit e84d2d0

Browse files
feature #24280 [VarDumper] Make dump() a little bit more easier to use (freekmurze)
This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #24280). Discussion ---------- [VarDumper] Make `dump()` a little bit more easier to use | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes Imagine you have this code: ```php $object->method(); ``` If you want to dump the object, this is currently the way to do that: ```php dump($object); $object->method(); ``` This PR makes adding (and removing) the `dump` function easier. When using one argument is used, that argument is returned. ```php dump($object)->method(); ``` When dumping multiple things, they all get returned. So you can to this: ```php $object->someMethod(...dump($arg1, $arg2, $arg3)); ``` Commits ------- 42f0984 [VarDumper] Make `dump()` a little bit more easier to use
2 parents 0a9d46d + 42f0984 commit e84d2d0

File tree

1 file changed

+6
-0
lines changed
  • src/Symfony/Component/VarDumper/Resources/functions

1 file changed

+6
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ function dump($var)
2020
foreach (func_get_args() as $var) {
2121
VarDumper::dump($var);
2222
}
23+
24+
if (1 < func_num_args()) {
25+
return func_get_args();
26+
}
27+
28+
return $var;
2329
}
2430
}

0 commit comments

Comments
 (0)