Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab716c6

Browse files
[VarDumper] Allow seamless use of Data clones
1 parente7a9f03 commitab716c6

File tree

38 files changed

+570
-421
lines changed

38 files changed

+570
-421
lines changed

‎src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
useSymfony\Component\Security\Http\Logout\LogoutUrlGenerator;
2121
useSymfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
2222
useSymfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
23+
useSymfony\Component\VarDumper\Caster\ClassStub;
2324
useSymfony\Component\VarDumper\Cloner\Data;
2425
useSymfony\Component\Security\Http\FirewallMapInterface;
2526
useSymfony\Bundle\SecurityBundle\Security\FirewallMap;
@@ -36,6 +37,7 @@ class SecurityDataCollector extends DataCollector
3637
private$logoutUrlGenerator;
3738
private$accessDecisionManager;
3839
private$firewallMap;
40+
private$hasVarDumper;
3941

4042
/**
4143
* Constructor.
@@ -53,6 +55,7 @@ public function __construct(TokenStorageInterface $tokenStorage = null, RoleHier
5355
$this->logoutUrlGenerator =$logoutUrlGenerator;
5456
$this->accessDecisionManager =$accessDecisionManager;
5557
$this->firewallMap =$firewallMap;
58+
$this->hasVarDumper =class_exists(ClassStub::class);
5659
}
5760

5861
/**
@@ -109,28 +112,23 @@ public function collect(Request $request, Response $response, \Exception $except
109112
$this->data =array(
110113
'enabled' =>true,
111114
'authenticated' =>$token->isAuthenticated(),
112-
'token' =>$this->cloneVar($token),
113-
'token_class' =>get_class($token),
115+
'token' =>$token,
116+
'token_class' =>$this->hasVarDumper ?newClassStub(get_class($token)) :get_class($token),
114117
'logout_url' =>$logoutUrl,
115118
'user' =>$token->getUsername(),
116-
'roles' =>$this->cloneVar(array_map(function (RoleInterface$role) {return$role->getRole(); },$assignedRoles)),
117-
'inherited_roles' =>$this->cloneVar(array_map(function (RoleInterface$role) {return$role->getRole(); },$inheritedRoles)),
119+
'roles' =>array_map(function (RoleInterface$role) {return$role->getRole(); },$assignedRoles),
120+
'inherited_roles' =>array_map(function (RoleInterface$role) {return$role->getRole(); },$inheritedRoles),
118121
'supports_role_hierarchy' =>null !==$this->roleHierarchy,
119122
);
120123
}
121124

122125
// collect voters and access decision manager information
123126
if ($this->accessDecisionManagerinstanceof TraceableAccessDecisionManager) {
124-
$this->data['access_decision_log'] =array_map(function ($decision) {
125-
$decision['object'] =$this->cloneVar($decision['object']);
126-
127-
return$decision;
128-
},$this->accessDecisionManager->getDecisionLog());
129-
127+
$this->data['access_decision_log'] =$this->accessDecisionManager->getDecisionLog();
130128
$this->data['voter_strategy'] =$this->accessDecisionManager->getStrategy();
131129

132130
foreach ($this->accessDecisionManager->getVoters()as$voter) {
133-
$this->data['voters'][] =get_class($voter);
131+
$this->data['voters'][] =$this->hasVarDumper ?newClassStub(get_class($voter)) :get_class($voter);
134132
}
135133
}else {
136134
$this->data['access_decision_log'] =array();
@@ -155,10 +153,12 @@ public function collect(Request $request, Response $response, \Exception $except
155153
'access_denied_handler' =>$firewallConfig->getAccessDeniedHandler(),
156154
'access_denied_url' =>$firewallConfig->getAccessDeniedUrl(),
157155
'user_checker' =>$firewallConfig->getUserChecker(),
158-
'listeners' =>$this->cloneVar($firewallConfig->getListeners()),
156+
'listeners' =>$firewallConfig->getListeners(),
159157
);
160158
}
161159
}
160+
161+
$this->data =$this->cloneVar($this->data);
162162
}
163163

164164
/**

‎src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ public function testCollectAuthenticationTokenAndRoles(array $roles, array $norm
6666

6767
$this->assertTrue($collector->isEnabled());
6868
$this->assertTrue($collector->isAuthenticated());
69-
$this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',$collector->getTokenClass());
69+
$this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',$collector->getTokenClass()->getValue());
7070
$this->assertTrue($collector->supportsRoleHierarchy());
71-
$this->assertSame($normalizedRoles,$collector->getRoles()->getRawData()[1]);
72-
if ($inheritedRoles) {
73-
$this->assertSame($inheritedRoles,$collector->getInheritedRoles()->getRawData()[1]);
74-
}else {
75-
$this->assertSame($inheritedRoles,$collector->getInheritedRoles()->getRawData()[0][0]);
76-
}
71+
$this->assertSame($normalizedRoles,$collector->getRoles()->getValue(true));
72+
$this->assertSame($inheritedRoles,$collector->getInheritedRoles()->getValue(true));
7773
$this->assertSame('hhamon',$collector->getUser());
7874
}
7975

@@ -107,7 +103,7 @@ public function testGetFirewall()
107103
$this->assertSame($firewallConfig->getAccessDeniedHandler(),$collected['access_denied_handler']);
108104
$this->assertSame($firewallConfig->getAccessDeniedUrl(),$collected['access_denied_url']);
109105
$this->assertSame($firewallConfig->getUserChecker(),$collected['user_checker']);
110-
$this->assertSame($firewallConfig->getListeners(),$collected['listeners']->getRawData()[0][0]);
106+
$this->assertSame($firewallConfig->getListeners(),$collected['listeners']->getValue());
111107
}
112108

113109
publicfunctiontestGetFirewallReturnsNull()

‎src/Symfony/Bundle/SecurityBundle/composer.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php":">=5.5.9",
2020
"symfony/security":"~3.3",
2121
"symfony/dependency-injection":"~3.3",
22-
"symfony/http-kernel":"~3.2",
22+
"symfony/http-kernel":"~3.3",
2323
"symfony/polyfill-php70":"~1.0"
2424
},
2525
"require-dev": {
@@ -37,12 +37,15 @@
3737
"symfony/twig-bridge":"~2.8|~3.0",
3838
"symfony/process":"~2.8|~3.0",
3939
"symfony/validator":"^3.2.5",
40-
"symfony/var-dumper":"~3.2",
40+
"symfony/var-dumper":"~3.3",
4141
"symfony/yaml":"~2.8|~3.0",
4242
"symfony/expression-language":"~2.8|~3.0",
4343
"doctrine/doctrine-bundle":"~1.4",
4444
"twig/twig":"~1.28|~2.0"
4545
},
46+
"conflict": {
47+
"symfony/var-dumper":"<3.3"
48+
},
4649
"suggest": {
4750
"symfony/security-acl":"For using the ACL functionality of this bundle"
4851
},

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<divclass="metric">
9191
<spanclass="value">
9292
{%ifkey=='time' %}
93-
{{'%0.2f'|format(1000*value) }} ms
93+
{{'%0.2f'|format(1000*value.value) }} ms
9494
{%else %}
9595
{{value }}
9696
{%endif %}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
{%fornameincollector.bundles|keys|sort %}
268268
<tr>
269269
<thscope="row"class="font-normal">{{name }}</th>
270-
<tdclass="font-normal">{{collector.bundles[name] }}</td>
270+
<tdclass="font-normal">{{profiler_dump(collector.bundles[name]) }}</td>
271271
</tr>
272272
{%endfor %}
273273
</tbody>

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
<tr>
7777
<tdclass="text-right">{{listener.priority|default('-') }}</td>
78-
<tdclass="font-normal">{{ profiler_dump(listener.data) }}</td>
78+
<tdclass="font-normal">{{ profiler_dump(listener.stub) }}</td>
7979
</tr>
8080

8181
{%ifloop.last %}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
<aclass="btn btn-link text-small sf-toggle"data-toggle-selector="#{{context_id }}"data-toggle-alt-content="Hide trace">Show trace</a>
183183

184184
<divid="{{context_id }}"class="context sf-toggle-content sf-toggle-hidden">
185-
{{ profiler_dump(log.context.seek('exception').seek('\0Exception\0trace'), maxDepth=2) }}
185+
{{ profiler_dump(log.context.exception['\0Exception\0trace'], maxDepth=2) }}
186186
</div>
187187
</span>
188188
{%elseiflog.contextisdefinedandlog.contextis notempty %}

‎src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public function dumpLog(\Twig_Environment $env, $message, Data $context)
9898
}
9999

100100
$replacements =array();
101-
foreach ($context->getRawData()[1]as$k =>$v) {
102-
$v ='{'.twig_escape_filter($env,$k).'}';
103-
$replacements['&quot;'.$v.'&quot;'] =$replacements[$v] =$this->dumpData($env,$context->seek($k));
101+
foreach ($contextas$k =>$v) {
102+
$k ='{'.twig_escape_filter($env,$k).'}';
103+
$replacements['&quot;'.$k.'&quot;'] =$replacements[$k] =$this->dumpData($env,$v);
104104
}
105105

106106
return'<span class="dump-inline">'.strtr($message,$replacements).'</span>';

‎src/Symfony/Bundle/WebProfilerBundle/composer.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"symfony/routing":"~2.8|~3.0",
2323
"symfony/twig-bridge":"~2.8|~3.0",
2424
"twig/twig":"~1.28|~2.0",
25-
"symfony/var-dumper":"~3.2"
25+
"symfony/var-dumper":"~3.3"
2626
},
2727
"require-dev": {
2828
"symfony/config":"~2.8|~3.0",
@@ -31,7 +31,8 @@
3131
"symfony/stopwatch":"~2.8|~3.0"
3232
},
3333
"conflict": {
34-
"symfony/event-dispatcher":"<3.2"
34+
"symfony/event-dispatcher":"<3.2",
35+
"symfony/var-dumper":"<3.3"
3536
},
3637
"autoload": {
3738
"psr-4": {"Symfony\\Bundle\\WebProfilerBundle\\":"" },

‎src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,13 @@ public function collect(Request $request, Response $response, \Exception $except
4545
$empty =array('calls' =>array(),'config' =>array(),'options' =>array(),'statistics' =>array());
4646
$this->data =array('instances' =>$empty,'total' =>$empty);
4747
foreach ($this->instancesas$name =>$instance) {
48-
$calls =$instance->getCalls();
49-
foreach ($callsas$call) {
50-
if (isset($call->result)) {
51-
$call->result =$this->cloneVar($call->result);
52-
}
53-
if (isset($call->argument)) {
54-
$call->argument =$this->cloneVar($call->argument);
55-
}
56-
}
57-
$this->data['instances']['calls'][$name] =$calls;
48+
$this->data['instances']['calls'][$name] =$instance->getCalls();
5849
}
5950

6051
$this->data['instances']['statistics'] =$this->calculateStatistics();
6152
$this->data['total']['statistics'] =$this->calculateTotalStatistics();
53+
54+
$this->data =$this->cloneVar($this->data);
6255
}
6356

6457
/**
@@ -133,7 +126,7 @@ private function calculateStatistics()
133126
$statistics[$name]['misses'] +=$count -$call->misses;
134127
}elseif ('hasItem' ===$call->name) {
135128
$statistics[$name]['reads'] +=1;
136-
if (false ===$call->result->getRawData()[0][0]) {
129+
if (false ===$call->result) {
137130
$statistics[$name]['misses'] +=1;
138131
}else {
139132
$statistics[$name]['hits'] +=1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp