This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
10
{
11
use MultidimensionalArrayTrait;
12
13
public static $options = [
14
'includeHeaders' => true,
15
'inline' => 3,
16
'indent' => 2,
17
];
18
19
/**
20
* {@inheritdoc}
21
*/
22
public static function toString(Translations $translations, array $options = [])
Since toArray() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of toArray() to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{privatestaticfunctiongetTemperature(){return"-182 °C";}}printYourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.