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
This commit is contained in:
Nicolas Grekas 2017-09-23 16:36:46 +01:00
commit e84d2d0943

View File

@ -20,5 +20,11 @@ if (!function_exists('dump')) {
foreach (func_get_args() as $var) {
VarDumper::dump($var);
}
if (1 < func_num_args()) {
return func_get_args();
}
return $var;
}
}