Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #20680 DoctrineDataCollector: taught sanitizeParam to support…
… classes with __toString implemented. (FractalizeR) This PR was squashed before being merged into the 3.3-dev branch (closes #20680). Discussion ---------- DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. This PR teaches \Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::sanitizeParam support objects, which implement __toString and therefore can be represented as a string with more sense, than "(object) ClassName". It also includes test for the feature. | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | [20673](#20673) | License | MIT | Doc PR | no Commits ------- f2970f2 DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented.
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Symfony/Bridge/Doctrine/Tests/DataCollector/StringRepresentableClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Symfony\Bridge\Doctrine\Tests\DataCollector; | ||
|
||
/** | ||
* A class for testing __toString method behaviour. It's __toString returns a value, that was passed into constructor. | ||
*/ | ||
class StringRepresentableClass | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $representation; | ||
|
||
/** | ||
* CustomStringableClass constructor. | ||
* | ||
* @param string $representation | ||
*/ | ||
public function __construct($representation) | ||
{ | ||
$this->representation = $representation; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return $this->representation; | ||
} | ||
} |