src/TranslatableTrait.php
Avoid using static access to class 'Atk4\Core\TraitUtil' in method '_'. Open
Open
if (TraitUtil::hasAppScopeTrait($this) && $this->issetApp() && method_exists($this->getApp(), '_')) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using short method names like TranslatableTrait::_(). The configured minimum method name length is 3. Open
Open
public function _(string $message, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
if (TraitUtil::hasAppScopeTrait($this) && $this->issetApp() && method_exists($this->getApp(), '_')) {
return $this->getApp()->_($message, $parameters, $domain, $locale);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
The method _ is not named in camelCase. Open
Open
public function _(string $message, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
if (TraitUtil::hasAppScopeTrait($this) && $this->issetApp() && method_exists($this->getApp(), '_')) {
return $this->getApp()->_($message, $parameters, $domain, $locale);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}