Skip to content

Commit

Permalink
added more information about a resource in error and debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 20, 2011
1 parent 01ecaa4 commit 2e1747b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
Expand Up @@ -94,7 +94,7 @@ private function sanitizeContext($context)
}

if (is_resource($context)) {
return 'Resource';
return sprintf('Resource(%s)', get_resource_type($context));
}

if (is_object($context)) {
Expand Down
20 changes: 16 additions & 4 deletions src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php
Expand Up @@ -68,7 +68,7 @@ public function setController($controller)
private function varToString($var)
{
if (is_object($var)) {
return sprintf('[object](%s)', get_class($var));
return sprintf('Object(%s)', get_class($var));
}

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

return sprintf("[array](%s)", implode(', ', $a));
return sprintf("Array(%s)", implode(', ', $a));
}

if (is_resource($var)) {
return '[resource]';
return sprintf('Resource(%s)', get_resource_type($var));
}

return str_replace("\n", '', var_export((string) $var, true));
if (null === $var) {
return 'null';
}

if (false === $var) {
return 'false';
}

if (true === $var) {
return 'true';
}

return (string) $var;
}
}
Expand Up @@ -182,7 +182,7 @@ private function flattenArgs($args)
} elseif (is_bool($value)) {
$result[$key] = array('boolean', $value);
} elseif (is_resource($value)) {
$result[$key] = array('resource', '');
$result[$key] = array('resource', get_resource_type($value));
} else {
$result[$key] = array('string', (string) $value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -73,7 +73,7 @@ static public function dump($value)
{
switch (true) {
case is_resource($value):
throw new DumpException('Unable to dump PHP resources in a YAML file.');
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
case is_object($value):
return '!!php/object:'.serialize($value);
case is_array($value):
Expand Down
Expand Up @@ -46,7 +46,7 @@ public function getCollectTestData()
array(
1,
array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')))),
array(array('message' => 'foo', 'context' => array('foo' => 'Resource'))),
array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'))),
),
array(
1,
Expand Down

0 comments on commit 2e1747b

Please sign in to comment.