Rule stringable_for_to_string¶
A class that implements the __toString() method must explicitly implement
the Stringable interface.
Examples¶
Example #1¶
--- Original
+++ New
<?php
-class Foo
+class Foo implements \Stringable
{
public function __toString()
{
return "Foo";
}
}
References¶
Fixer class: PhpCsFixer\Fixer\ClassNotation\StringableForToStringFixer
Test class: PhpCsFixer\Tests\Fixer\ClassNotation\StringableForToStringFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.