Skip to content

Commit

Permalink
feature #32026 [VarDumper] caster for HttpClient's response dumps all…
Browse files Browse the repository at this point in the history
… info (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[VarDumper] caster for HttpClient's response dumps all info

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

No need to dump the internal structure for responses IMHO, here is a caster that dumps the info instead:

![image](https://user-images.githubusercontent.com/243674/59434490-efb5a280-8deb-11e9-8714-5f1ccbc208b1.png)

Commits
-------

2b26837 [VarDumper] caster for HttpClient's response dumps all info
  • Loading branch information
fabpot committed Jun 13, 2019
2 parents 567cb27 + 2b26837 commit bad18dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php
Expand Up @@ -48,4 +48,16 @@ public static function castHttpClient($client, array $a, Stub $stub, $isNested)

return $a;
}

public static function castHttpClientResponse($response, array $a, Stub $stub, $isNested)
{
$stub->cut += \count($a);
$a = [];

foreach ($response->getInfo() + ['debug' => $response->getInfo('debug')] as $k => $v) {
$a[Caster::PREFIX_VIRTUAL.$k] = $v;
}

return $a;
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
Expand Up @@ -78,8 +78,8 @@ abstract class AbstractCloner implements ClonerInterface
'Symfony\Component\DependencyInjection\ContainerInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
'Symfony\Component\HttpClient\CurlHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\NativeHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
'Symfony\Component\HttpFoundation\Request' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castRequest'],
'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrowingCasterException'],
'Symfony\Component\VarDumper\Caster\TraceStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castTraceStub'],
Expand Down

0 comments on commit bad18dc

Please sign in to comment.