Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dfb4ccf

Browse filesBrowse files
committed
feature #14693 [3.0][Translator] changed the visibility of the locale from protected to private. (aitboudad)
This PR was merged into the 3.0-dev branch. Discussion ---------- [3.0][Translator] changed the visibility of the locale from protected to private. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | yes | Fixed tickets | ~ | Tests pass? | yes | License | MIT Commits ------- 94de779 [Translator] changed the visibility of the locale from protected to private.
2 parents a2bdc72 + 94de779 commit dfb4ccf
Copy full SHA for dfb4ccf

File tree

Expand file treeCollapse file tree

4 files changed

+46
-5
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+46
-5
lines changed

‎UPGRADE-3.0.md

Copy file name to clipboardExpand all lines: UPGRADE-3.0.md
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,41 @@ UPGRADE FROM 2.x to 3.0
604604
* The `Translator::setFallbackLocale()` method has been removed in favor of
605605
`Translator::setFallbackLocales()`.
606606

607+
* The visibility of the `locale` property has been changed from protected to private. Rely on `getLocale` and `setLocale`
608+
instead.
609+
610+
Before:
611+
612+
```php
613+
class CustomTranslator extends Translator
614+
{
615+
public function fooMethod()
616+
{
617+
// get locale
618+
$locale = $this->locale;
619+
620+
// update locale
621+
$this->locale = $locale;
622+
}
623+
}
624+
```
625+
626+
After:
627+
628+
```php
629+
class CustomTranslator extends Translator
630+
{
631+
public function fooMethod()
632+
{
633+
// get locale
634+
$locale = $this->getLocale();
635+
636+
// update locale
637+
$this->setLocale($locale);
638+
}
639+
}
640+
```
641+
607642
### Twig Bridge
608643

609644
* The `twig:lint` command has been deprecated since Symfony 2.7 and will be

‎src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ public function testTransWithCaching()
9494
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
9595
}
9696

97+
/**
98+
* @expectedException \InvalidArgumentException
99+
*/
97100
public function testTransWithCachingWithInvalidLocale()
98101
{
99102
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
100103
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
101-
$translator->setLocale('invalid locale');
102104

103-
$this->setExpectedException('\InvalidArgumentException');
104105
$translator->trans('foo');
105106
}
106107

@@ -302,8 +303,8 @@ class TranslatorWithInvalidLocale extends Translator
302303
/**
303304
* {@inheritdoc}
304305
*/
305-
public function setLocale($locale)
306+
public function getLocale()
306307
{
307-
$this->locale = $locale;
308+
return 'invalid locale';
308309
}
309310
}

‎src/Symfony/Component/Translation/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* Changed the visibility of the locale property in `Translator` from protected to private.
8+
49
2.8.0
510
-----
611

‎src/Symfony/Component/Translation/Translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Translator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
3434
/**
3535
* @var string
3636
*/
37-
protected $locale;
37+
private $locale;
3838

3939
/**
4040
* @var array

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.