lib/Locations/Utility/LocationUtility.php
Avoid assigning values to variables in if clauses and the like (line '34', column '18'). Open
Open
public static function getLocationId($slug) {
$Redis = AppCore::GetRedis();
$Memcached = AppCore::GetMemcached();
$Database = (new AppCore)->getDatabaseConnection();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid unused local variables such as '$Redis'. Open
Open
$Redis = AppCore::GetRedis();
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
public static function getLocationId($slug) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
if (!$id = $Memcached->fetch($key)) {
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
class LocationUtility {
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks