Marked Translation class as implementing Stringable
#307
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.








v3.3This PR adds
Stringableas phpdoc annotation toeZ\Publish\API\Repository\Values\Translation.Reasoning
When working with content validation it become apparent for me that this class is lacking
Stringableinterface.Ibexa\Core\FieldType\ValidationError::getTranslatableMessagereturns aTranslationobject that - judging by our implementations:Plural&Message- should always have__toString()method.Of course,
Stringabledid not exist at the moment when this code was written.However, because there is no guarantee that user code that extends it does indeed implement this method, and because
Stringableinterface is available from PHP 8.0, I'm opting to mark the class as implementing it via phpdoc instead. Otherwise we could break user code or require a polyfill (which is in itself an option, due to it's lightweight nature).We cannot simply add this method to
Translationwithout hiding the fact that implementation is missing, because as per php docs:I propose that for 3.3:
Translationdenoting the intent of implementingStringablebut for 4.x:
symfony/polyfill-php80StringableinTranslation__toString()method, so that user code does not break.Checklist:
Provided automated test coverage.$ composer fix-cs).@ezsystems/engineering-team).