8000 added more information about a resource in error and debug messages · brki/symfony@2e1747b · GitHub
[go: up one dir, main page]

10000
Skip to content

Commit 2e1747b

Browse files
committed
added more information about a resource in error and debug messages
1 parent 01ecaa4 commit 2e1747b

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private function sanitizeContext($context)
9494
}
9595

9696
if (is_resource($context)) {
97-
return 'Resource';
97+
return sprintf('Resource(%s)', get_resource_type($context));
9898
}
9999

100100
if (is_object($context)) {

src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function setController($controller)
6868
private function varToString($var)
6969
{
7070
if (is_object($var)) {
71-
return sprintf('[object](%s)', get_class($var));
71+
return sprintf('Object(%s)', get_class($var));
7272
}
7373

7474
if (is_array($var)) {
@@ -77,13 +77,25 @@ private function varToString($var)
7777
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
7878
}
7979

80-
return sprintf("[array](%s)", implode(', ', $a));
80+
return sprintf("Array(%s)", implode(', ', $a));
8181
}
8282

8383
if (is_resource($var)) {
84-
return '[resource]';
84+
return sprintf('Resource(%s)', get_resource_type($var));
8585
}
8686

87-
return str_replace("\n", '', var_export((string) $var, true));
87+
if (null === $var) {
88+
return 'null';
89+
}
90+
91+
if (false === $var) {
92+
return 'false';
93+
}
94+
95+
if (true === $var) {
96+
return 'true';
97+
}
98+
99+
return (string) $var;
88100
}
89101
}

src/Symfony/Component/HttpKernel/Exception/FlattenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private function flattenArgs($args)
182182
} elseif (is_bool($value)) {
183183
$result[$key] = array('boolean', $value);
184184
} elseif (is_resource($value)) {
185-
$result[$key] = array('resource', '');
185+
$result[$key] = array('resource', get_resource_type($value));
186186
} else {
187187
$result[$key] = array('string', (string) $value);
188188
}

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static public function dump($value)
7373
{
7474
switch (true) {
7575
case is_resource($value):
76-
throw new DumpException('Unable to dump PHP resources in a YAML file.');
76+
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
7777
case is_object($value):
7878
return '!!php/object:'.serialize($value);
7979
case is_array($value):

tests/Symfony/Tests/Component/HttpKernel/DataCollector/LoggerDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getCollectTestData()
4646
array(
4747
1,
4848
array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')))),
49-
array(array('message' => 'foo', 'context' => array('foo' => 'Resource'))),
49+
array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'))),
5050
),
5151
array(
5252
1,

0 commit comments

Comments
 (0)
0