open-orchestra/open-orchestra-cms-bundle

View on GitHub
GroupBundle/Transformer/GroupTransformer.php

Summary

Maintainability
A
35 mins
Test Coverage

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $facadeClass,
        AuthorizationCheckerInterface $authorizationChecker,
        MultiLanguagesChoiceManagerInterface $multiLanguagesChoiceManager,
        GroupRepositoryInterface $groupRepository,
        BusinessRulesManager $businessRulesManager
Severity: Minor
Found in GroupBundle/Transformer/GroupTransformer.php - About 35 mins to fix

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

    protected function addSite(FacadeInterface $facade, GroupInterface $group)
    {
        if ($this->hasGroup(CMSGroupContext::SITE) && $site = $group->getSite()) {
            $facade->site = $this->getContext()->transform('site', $site);
        }

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 parameters such as '$params'.
Open

    public function reverseTransform(FacadeInterface $facade, array $params = array())

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

Class extends undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer
Open

class GroupTransformer extends AbstractSecurityCheckerAwareTransformer

Call to method __construct from undeclared class \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open

            throw new TransformerParameterTypeException();

Call to method choose from undeclared class \OpenOrchestra\ModelInterface\Manager\MultiLanguagesChoiceManagerInterface
Open

        $facade->label = $this->multiLanguagesChoiceManager->choose($group->getLabels());

Reference to undeclared property \OpenOrchestra\GroupBundle\Transformer\GroupTransformer->businessRulesManager
Open

                $this->businessRulesManager->isGranted(BusinessActionInterface::DELETE, $group, $nbrGroupsUsers)

Reference to instance property id from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

            return $this->groupRepository->find($facade->id);

Call to undeclared method \OpenOrchestra\GroupBundle\Transformer\GroupTransformer::newFacade
Open

        $facade = $this->newFacade();

Call to undeclared method \OpenOrchestra\GroupBundle\Transformer\GroupTransformer::hasGroup
Open

        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS)) {

Parameter $authorizationChecker has undeclared type \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open

    public function __construct(

Parameter $facade has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    protected function addRoles(FacadeInterface $facade, GroupInterface $group)

Parameter $facade has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    protected function addSite(FacadeInterface $facade, GroupInterface $group)

Return type of addSite() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    protected function addSite(FacadeInterface $facade, GroupInterface $group)

Return type of addRights() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    protected function addRights(FacadeInterface $facade, GroupInterface $group, array $nbrGroupsUsers)

Reference to undeclared property \OpenOrchestra\GroupBundle\Transformer\GroupTransformer->groupRepository
Open

            return $this->groupRepository->find($facade->id);

Saw an @param annotation for nbrUsers, but it was not found in the param list of function addRights(\OpenOrchestra\BaseApi\Facade\FacadeInterface $facade, \OpenOrchestra\Backoffice\Model\GroupInterface $group, array $nbrGroupsUsers) : \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

     * @param array           $nbrUsers

Call to method addRight from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

            $facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, GroupInterface::ENTITY_TYPE));

Reference to instance property id from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

        if (null !== $facade->id) {

Parameter $multiLanguagesChoiceManager has undeclared type \OpenOrchestra\ModelInterface\Manager\MultiLanguagesChoiceManagerInterface
Open

    public function __construct(

Call to undeclared method \OpenOrchestra\Backoffice\Model\GroupInterface::getId
Open

        $facade->nbrUsers = array_key_exists($group->getId(), $nbrGroupsUsers) ? $nbrGroupsUsers[$group->getId()] : 0;

Call to undeclared method \OpenOrchestra\GroupBundle\Transformer\GroupTransformer::getContext
Open

            $facade->site = $this->getContext()->transform('site', $site);

Reference to undeclared property \OpenOrchestra\GroupBundle\Transformer\GroupTransformer->businessRulesManager (Did you mean $businessRulesManager)
Open

        $this->businessRulesManager = $businessRulesManager;

Call to undeclared method \OpenOrchestra\Backoffice\Model\GroupInterface::getName
Open

        $facade->name = $group->getName();

Reference to undeclared property \OpenOrchestra\GroupBundle\Transformer\GroupTransformer->authorizationChecker
Open

            $facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, GroupInterface::ENTITY_TYPE));

Call to undeclared method \OpenOrchestra\Backoffice\Model\GroupInterface::getRoles
Open

            foreach ($group->getRoles() as $role) {

Call to method addRole from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

                $facade->addRole($role);

Reference to undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer
Open

        parent::__construct($facadeClass, $authorizationChecker);

@throws type of transform has undeclared type \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open

    public function transform($group, array $params = array())

Parameter $facade has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    protected function addRights(FacadeInterface $facade, GroupInterface $group, array $nbrGroupsUsers)

Reference to undeclared property \OpenOrchestra\GroupBundle\Transformer\GroupTransformer->authorizationChecker
Open

                $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $group) &&

Call to undeclared method \OpenOrchestra\GroupBundle\Transformer\GroupTransformer::hasGroup
Open

        if ($this->hasGroup(CMSGroupContext::GROUP_ROLES)) {

Parameter $facade has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function reverseTransform(FacadeInterface $facade, array $params = array())

Reference to instance property site from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

            $facade->site = $this->getContext()->transform('site', $site);

Call to method addRight from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

            $facade->addRight('can_delete',

Reference to undeclared property \OpenOrchestra\GroupBundle\Transformer\GroupTransformer->groupRepository (Did you mean $groupRepository)
Open

        $this->groupRepository = $groupRepository;

Return type of transform() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function transform($group, array $params = array())

Call to undeclared method \OpenOrchestra\Backoffice\Model\GroupInterface::getId
Open

        $facade->id = $group->getId();

Return type of addRoles() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    protected function addRoles(FacadeInterface $facade, GroupInterface $group)

Call to undeclared method \OpenOrchestra\GroupBundle\Transformer\GroupTransformer::hasGroup
Open

        if ($this->hasGroup(CMSGroupContext::SITE) && $site = $group->getSite()) {

Avoid excessively long variable names like $multiLanguagesChoiceManager. Keep variable name length under 20.
Open

    protected $multiLanguagesChoiceManager;

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

Avoid excessively long variable names like $multiLanguagesChoiceManager. Keep variable name length under 20.
Open

        MultiLanguagesChoiceManagerInterface $multiLanguagesChoiceManager,

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

There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found 0 spaces
Open

    ){

Line exceeds 120 characters; contains 153 characters
Open

            $facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, GroupInterface::ENTITY_TYPE));

Opening parenthesis of a multi-line function call must be the last content on the line
Open

            $facade->addRight('can_delete',

There are no issues that match your filters.

Category
Status