Remove error control operator '@' on line 94. Open
public function I_get_warning_for_unknown_locale()
{
/** @var AbstractTheurgistCode $sutClass */
$sutClass = self::getSutClass();
foreach ($sutClass::getPossibleValues() as $value) {
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
The method I_can_get_its_czech_translation uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
self::assertNotSame(
$inEnglish,
$sut->translateTo('cs'),
"Expected '{$value}' to be different in czech than in english"
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid excessively long variable names like $previousErrorReporting. Keep variable name length under 20. Open
$previousErrorReporting = error_reporting(-1 ^ E_USER_WARNING);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
The method I_can_get_original_value is not named in camelCase. Open
public function I_can_get_original_value()
{
/** @var AbstractTheurgistCode $sutClass */
$sutClass = self::getSutClass();
foreach ($sutClass::getPossibleValues() as $value) {
- Read upRead up
- 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() {
}
}
Source
The method I_can_get_its_english_translation is not named in camelCase. Open
public function I_can_get_its_english_translation()
{
/** @var AbstractTheurgistCode $sutClass */
$sutClass = self::getSutClass();
foreach ($sutClass::getPossibleValues() as $value) {
- Read upRead up
- 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() {
}
}
Source
The method I_can_get_its_czech_translation is not named in camelCase. Open
public function I_can_get_its_czech_translation()
{
/** @var AbstractTheurgistCode $sutClass */
$sutClass = self::getSutClass();
foreach ($sutClass::getPossibleValues() as $value) {
- Read upRead up
- 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() {
}
}
Source
The method I_get_warning_for_unknown_locale is not named in camelCase. Open
public function I_get_warning_for_unknown_locale()
{
/** @var AbstractTheurgistCode $sutClass */
$sutClass = self::getSutClass();
foreach ($sutClass::getPossibleValues() as $value) {
- Read upRead up
- 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() {
}
}