Skip to content

Commit 4383575

Browse files
VincentLangletnicolas-grekas
authored andcommitted
[Translation] Deprecate TranslatableMessage::__toString
1 parent 02c27b9 commit 4383575

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.4
5+
---
6+
7+
* Deprecate `TranslatableMessage::__toString`
8+
49
7.3
510
---
611

Tests/TranslatableTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public function testFlattenedTrans($expected, $messages, $translatable)
4242
$this->assertSame($expected, $translatable->trans($translator, 'fr'));
4343
}
4444

45+
/**
46+
* @group legacy
47+
*/
4548
public function testToString()
4649
{
4750
$this->assertSame('Symfony is great!', (string) new TranslatableMessage('Symfony is great!'));

TranslatableMessage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ public function __construct(
2626
) {
2727
}
2828

29+
/**
30+
* @deprecated since Symfony 7.4
31+
*/
2932
public function __toString(): string
3033
{
34+
trigger_deprecation('symfony/translation', '7.4', 'Method "%s()" is deprecated.', __METHOD__);
35+
3136
return $this->getMessage();
3237
}
3338

0 commit comments

Comments
 (0)