The class UserRepository has a coupling between objects value of 25. Consider to reduce the number of dependencies under 13. Open
class UserRepository extends ResourceRepository implements PasswordUpgraderInterface
{
protected ?UserPasswordHasherInterface $hasher = null;
public const USER_IMAGE_SIZE_SMALL = 1;
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The method reassignUserResourcesToFallback uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$childNode->setParent(null);
}
- 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
The method deleteUser uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$user->setActive(User::SOFT_DELETED);
$em->persist($user);
}
- 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
The method findUsersToSendMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->addOnlyMyFriendsQueryBuilder($currentUserId, $qb);
/*$dql = 'SELECT DISTINCT U
FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF
INNER JOIN ChamiloCoreBundle:User AS U
- 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
The method findUsersToSendMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ('true' === $allowSendMessageToAllUsers) {
$this->addNotCurrentUserQueryBuilder($currentUserId, $qb);
} else {
return [];
- 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
The method searchUsersByTags uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$qb->select('DISTINCT u.id, u.username, u.firstname, u.lastname, u.email, u.pictureUri, u.status');
}
- 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
The method findUsersToSendMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return [];
}
- 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
The method getExtraUserData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$extraData[$key] = $value;
}
- 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
The method relateUsers uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$existingRelation->setRelationType($relationType);
}
- 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
The method relateUsers uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$existingRelationInverse->setRelationType($relationType);
}
- 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 unused parameters such as '$limit'. Open
public function findUsersToSendMessage(int $currentUserId, ?string $searchFilter = null, int $limit = 10)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$dql'. Open
$dql = null;
- 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
The parameter $number_of_items is not named in camelCase. Open
public function searchUsersByTags(
string $tag,
?int $excludeUserId = null,
int $fieldId = 0,
int $from = 0,
- 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
Missing function doc comment Open
public function loadUserByIdentifier(string $identifier): ?User
- Exclude checks
Missing function doc comment Open
public function setHasher(UserPasswordHasherInterface $hasher): void
- Exclude checks
Missing function doc comment Open
public function canonicalize(string $string): string
- Exclude checks
Missing function doc comment Open
public function updatePassword(User $user): void
- Exclude checks
Add a single space around assignment operators Open
declare(strict_types=1);
- Exclude checks
Missing function doc comment Open
public function __construct(
- Exclude checks
Missing function doc comment Open
public function updateCanonicalFields(User $user): void
- Exclude checks
Missing function doc comment Open
public function updateUser(User $user, bool $andFlush = true): void
- Exclude checks
Missing function doc comment Open
public function createUser(): User
- Exclude checks
Missing class doc comment Open
class UserRepository extends ResourceRepository implements PasswordUpgraderInterface
- Exclude checks
Missing function doc comment Open
public function getExtraUserDataByField(int $userId, string $fieldVariable, bool $allVisibility = true): array
- Exclude checks
Missing function doc comment Open
public function getUserRelationWithType(int $userId, int $friendId): ?array
- Exclude checks
Missing function doc comment Open
public function isPasswordValid(User $user, string $plainPassword): bool
- Exclude checks
Missing function doc comment Open
public function addActiveAndNotAnonUserQueryBuilder(?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getFriendsNotInGroup(int $userId, int $groupId)
- Exclude checks
Missing function doc comment Open
public function addAccessUrlQueryBuilder(int $accessUrlId, ?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function deleteUser(User $user, bool $destroy = false): void
- Exclude checks
Declare public methods first,then protected ones and finally private ones Open
public function getFallbackUser(): ?User
- Exclude checks
Declare public methods first,then protected ones and finally private ones Open
public function getFriendsNotInGroup(int $userId, int $groupId)
- Exclude checks
Missing function doc comment Open
public function searchUsersByTags(
- Exclude checks
Missing function doc comment Open
public function getRootUser(): User
- Exclude checks
Missing function doc comment Open
public function addRoleListQueryBuilder(array $roles, ?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getFallbackUser(): ?User
- Exclude checks
Doc comment for parameter $accessUrlId does not match actual variable name $keyword Open
* @param int $accessUrlId The access URL ID
- Exclude checks
Missing function doc comment Open
public function findByUsername(string $username): ?User
- Exclude checks
Doc comment for parameter $keyword does not match actual variable name $role Open
* @param string $keyword The query to filter
- Exclude checks
Missing function doc comment Open
public function addExpirationDateQueryBuilder(?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
->setMaxResults($number_of_items)
- Exclude checks
Missing function doc comment Open
public function getExtraUserData(int $userId, bool $prefix = false, bool $allVisibility = true, bool $splitMultiple = false, ?int $fieldFilter = null): array
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
int $number_of_items = 10,
- Exclude checks
Missing function doc comment Open
public function getUserPicture(
- Exclude checks
Missing function doc comment Open
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
- Exclude checks
Missing function doc comment Open
public function addUserToResourceNode(int $userId, int $creatorId): ResourceNode
- Exclude checks
Missing function doc comment Open
public function relateUsers(User $user1, User $user2, int $relationType): void
- Exclude checks
Missing function doc comment Open
public function findByRoleList(array $roleList, string $keyword, int $accessUrlId = 0)
- Exclude checks
Arguments with default values must be at the end of the argument list Open
$addRandomId = true,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
private readonly IllustrationRepository $illustrationRepository
- Exclude checks
The variable $number_of_items is not named in camelCase. Open
public function searchUsersByTags(
string $tag,
?int $excludeUserId = null,
int $fieldId = 0,
int $from = 0,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}