8000 DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. by FractalizeR · Pull Request #20680 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. #20680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DoctrineDataCollector applied fabpot.io formatting hints.
  • Loading branch information
FractalizeR committed Mar 2, 2017
commit c3ed81c566420aee40d9e6f07f44926307604a57
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private function sanitizeParam($var)
if (is_object($var)) {
return method_exists($var, '__toString') ?
array($var->__toString(), false) :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the class name should be dumped here as well. The way it is implemented will cause confusing results.

array(sprintf('Object(%s)', get_class($var)), false,);
array(sprintf('Object(%s)', get_class($var)), false);
}

if (is_array($var)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function paramProvider()
array(null, array(), null, true),
array(new \DateTime('2011-09-11'), array('date'), '2011-09-11', true),
array(fopen(__FILE__, 'r'), array(), 'Resource(stream)', false),
array(new \stdClass, array(), 'Object(stdClass)', false),
array(new \stdClass(), array(), 'Object(stdClass)', false),
array(new StringRepresentableClass('presentation test'), array(), 'presentation test', false),
);
}
Expand Down
8000
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@

/**
* A class for testing __toString method behaviour. It's __toString returns a value, that was passed into constructor.
*
* @package Symfony\Bridge\Doctrine\Tests\DataCollector
*/
class StringRepresentableClass
{
/**
* @var string
*/
private $representation;
/**
* @var string
*/
private $representation;

/**
* CustomStringableClass constructor.
*
* @param string $representation
*/
public function __construct($representation)
{
$this->representation = $representation;
}
/**
* CustomStringableClass constructor.
*
* @param string $representation
*/
public function __construct($representation)
{
$this->representation = $representation;
}

public function __toString()
{
return $this->representation;
}
public function __toString()
{
return $this->representation;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simplify this class by removing the representation property and hardcode the text here directly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see 26c54c7

}
}
0