chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Entity/Group.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid assigning values to variables in if clauses and the like (line '74', column '23').
Open

    public function removeRole(string $role): self
    {
        if (false !== $key = array_search(strtoupper($role), $this->roles, true)) {
            unset($this->roles[$key]);
            $this->roles = array_values($this->roles);
Severity: Minor
Found in src/CoreBundle/Entity/Group.php by phpmd

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

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

        #[Assert\NotBlank]

Missing function doc comment
Open

    public function __toString(): string

Missing function doc comment
Open

    public function getRoles(): array

Missing function doc comment
Open

    public function __construct(

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Column(name: 'id', type: 'integer')]

Missing function doc comment
Open

    public function getTitle(): string

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[Assert\NotBlank]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Column(name: 'code', type: 'string', length: 40, nullable: false, unique: true)]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[ORM\Entity]

Missing function doc comment
Open

    public function removeRole(string $role): self

Add a single space around assignment operators
Open

declare(strict_types=1);

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'groups')]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[ORM\Table(name: 'fos_group')]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Id]

You must use "/**" style comments for a class comment
Open

class Group implements Stringable

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\GeneratedValue(strategy: 'AUTO')]

The first parameter of a multi-line function declaration must be on the line after the opening bracket
Open

        protected string $title,

Missing function doc comment
Open

    public function setTitle(string $title): self

Missing function doc comment
Open

    public function addRole(string $role): self

Missing function doc comment
Open

    public function setCode(string $code): self

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

        #[ORM\Column(name: 'roles', type: 'array')]

Missing function doc comment
Open

    public function setRoles(array $roles): self

Missing function doc comment
Open

    public function getCode(): string

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

        #[ORM\Column(name: 'title', type: 'string', length: 255, unique: true, nullable: false)]

Missing function doc comment
Open

    public function hasRole(string $role): bool

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected array $roles = [

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected string $title,

There are no issues that match your filters.

Category
Status