Skip to content

Method-scoped Attributes and Attribute parameters are not detected #203

@darthf1

Description

@darthf1

Hi!

I have a class in the Domain namespace, which has Doctrine's attributes for ORM mapping. My classes have the following imports:

<?php

declare(strict_types=1);

namespace Domain\MyDomain;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

With the test below:

public function testDomainLayerOnlyDependsOnDomainLayer(): Rule
{
    return PHPat::rule()
        ->classes(
            Selector::namespace('/^Domain.*/', true),
        )
        ->shouldNotDependOn()
        ->classes(
            Selector::NOT(Selector::namespace('/^Domain.*/', true)),
        )
    ;
}

I get:

 ------ ------------------------------------------------------------------------------------------------- 
  Line   src/Domain/MyDomain\MyClass.php                                                           
 ------ ------------------------------------------------------------------------------------------------- 
  43     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  48     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  51     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  54     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  57     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  60     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  63     Domain\MyDomain\MyClass should not depend on Doctrine\DBAL\Types\Types                    
  69     Domain\MyDomain\MyClass should not depend on Doctrine\Common\Collections\Collection       
  75     Domain\MyDomain\MyClass should not depend on Doctrine\Common\Collections\Collection       
  95     Domain\MyDomain\MyClass should not depend on Doctrine\Common\Collections\ArrayCollection  
  102    Domain\MyDomain\MyClass should not depend on Doctrine\Common\Collections\ArrayCollection  
 ------ ------------------------------------------------------------------------------------------------- 

There is no mention of the import:

use Doctrine\ORM\Mapping as ORM;

Using a direct import also is not reported:

use Doctrine\ORM\Mapping\Column;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions