File tree 2 files changed +44
-0
lines changed
Filter options
src/Symfony/Component/VarDumper
2 files changed +44
-0
lines changed
Original file line number Diff line number Diff line change
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 \Caster ;
13
+
14
+ use Symfony \Component \HttpFoundation \Request ;
15
+ use Symfony \Component \VarDumper \Cloner \Stub ;
16
+
17
+ class SymfonyCaster
18
+ {
19
+ private static $ getters = array (
20
+ 'pathInfo ' => 'getPathInfo ' ,
21
+ 'requestUri ' => 'getRequestUri ' ,
22
+ 'baseUrl ' => 'getBaseUrl ' ,
23
+ 'basePath ' => 'getBasePath ' ,
24
+ 'method ' => 'getMethod ' ,
25
+ 'format ' => 'getRequestFormat ' ,
26
+ );
27
+
28
+ public static function castRequest (Request $ request , array $ a , Stub $ stub , $ isNested )
29
+ {
30
+ $ clone = null ;
31
+
32
+ foreach (self ::$ getters as $ prop => $ getter ) {
33
+ if (null === $ a [Caster::PREFIX_PROTECTED .$ prop ]) {
34
+ if (null === $ clone ) {
35
+ $ clone = clone $ request ;
36
+ }
37
+ $ a [Caster::PREFIX_VIRTUAL .$ prop ] = $ clone ->{$ getter }();
38
+ }
39
+ }
40
+
41
+ return $ a ;
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ abstract class AbstractCloner implements ClonerInterface
75
75
'Exception ' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castException ' ,
76
76
'Error ' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castError ' ,
77
77
'Symfony\Component\DependencyInjection\ContainerInterface ' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals ' ,
78
+ 'Symfony\Component\HttpFoundation\Request ' => 'Symfony\Component\VarDumper\Caster\SymfonyCaster::castRequest ' ,
78
79
'Symfony\Component\VarDumper\Exception\ThrowingCasterException ' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castThrowingCasterException ' ,
79
80
'Symfony\Component\VarDumper\Caster\TraceStub ' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castTraceStub ' ,
80
81
'Symfony\Component\VarDumper\Caster\FrameStub ' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castFrameStub ' ,
You can’t perform that action at this time.
0 commit comments