lib/Notifications/Utility/PushUtility.php
Avoid assigning values to variables in if clauses and the like (line '36', column '18'). Open
Open
public static function getUserIdFromRegistrationId($registration_id) {
$Database = AppCore::GetDatabase();
$Memcached = AppCore::GetMemcached();
- 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
The parameter $User is not named in camelCase. Open
Open
public static function getCurrentNotification($User) {
if ($User instanceof User) {
$User = $User->id;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $registration_id is not named in camelCase. Open
Open
public static function getUserIdFromRegistrationId($registration_id) {
$Database = AppCore::GetDatabase();
$Memcached = AppCore::GetMemcached();
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
Open
}
- Exclude checks
Function closing brace must go on the next line following the body; found 2 blank lines before brace Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
class PushUtility {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
public static function getCurrentNotification($User) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
if ($User instanceof User) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
public static function getUserIdFromRegistrationId($registration_id) {
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
if (!$user_id = $Memcached->fetch($key)) {
- Exclude checks