Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor folder as a layer question #1405

Open
MihaiNeagu opened this issue Mar 25, 2024 · 2 comments
Open

Vendor folder as a layer question #1405

MihaiNeagu opened this issue Mar 25, 2024 · 2 comments
Labels

Comments

@MihaiNeagu
Copy link

Regarding the treatment of the vendor as a layer, I have the following depfile

parameters:
  ProjectName: MyProject

deptrac:
  paths:
    - ./src/MyProject
    - ./vendor
  exclude_files:
    - '#.*test.*#'
  layers:
    - name: DomainLayer
      collectors:
        - type: classNameRegex
          value: '#^%ProjectName%\\Domain.*#'
    - name: ApplicationLayer
      collectors:
        - type: classNameRegex
          value: '#^%ProjectName%\\Application.*#'
    - name: InfrastructureLayer
      collectors:
        - type: classNameRegex
          value: '#^%ProjectName%\\Infra.*#'

    - name: InternalPackagesLayer
      collectors:
        - type: directory
          value: 'vendor/symfony/*'
        - type: directory
          value: 'vendor/doctrine/*'
        - type: directory
          value: 'vendor/some-package/*'

    - name: ExternalPackagesLayer
      collectors:
        - type: bool
          must:
            - type: directory
              value: 'vendor/*'
          must_not:
            - type: layer
              value: InternalPackagesLayer

  ruleset:
    InternalPackagesLayer:
      - ExternalPackagesLayer
    ExternalPackagesLayer:
      - InternalPackagesLayer
    InfrastructureLayer:
      - DomainLayer
      - ApplicationLayer
      - InternalPackagesLayer
      - ExternalPackagesLayer
    ApplicationLayer:
      - DomainLayer
      - InternalPackagesLayer
    DomainLayer:
      - InternalPackagesLayer

Event though InternalPackagedLayer is set to depend on ExternalPackagesLayer and viceversa, somehow deptrac returns errors for violations of dependencies between these two layers.

Some examples:

Reason      InternalPackagesLayer                                                                                                                                                 
  Violation   Symfony\Bundle\FrameworkBundle\Test\BrowserKitAssertionsTrait must not depend on PHPUnit\Framework\ExpectationFailedException (ExternalPackagesLayer)                 
  Violation   Symfony\Bundle\FrameworkBundle\Test\BrowserKitAssertionsTrait must not depend on PHPUnit\Framework\ExpectationFailedException (ExternalPackagesLayer)                 
  Violation   Symfony\Bundle\FrameworkBundle\Test\KernelTestCase must not depend on PHPUnit\Framework\Reorderable (ExternalPackagesLayer)                                           
  Violation   Symfony\Bundle\FrameworkBundle\Test\KernelTestCase must not depend on PHPUnit\Framework\SelfDescribing (ExternalPackagesLayer)                                        
  Violation   Symfony\Bundle\FrameworkBundle\Test\WebTestCase must not depend on PHPUnit\Framework\Reorderable (ExternalPackagesLayer)                                              
  Violation   Symfony\Bundle\FrameworkBundle\Test\WebTestCase must not depend on PHPUnit\Framework\SelfDescribing (ExternalPackagesLayer)                                           

and

Reason      ExternalPackagesLayer                                                                                                           
  Violation   GuzzleHttp\Utils must not depend on Symfony\Polyfill\Intl\Idn\Idn (InternalPackagesLayer)                                       
  Violation   GuzzleHttp\Utils must not depend on Symfony\Polyfill\Intl\Idn\Idn (InternalPackagesLayer)                                       
  Violation   GuzzleHttp\Utils must not depend on Symfony\Polyfill\Intl\Idn\Idn (InternalPackagesLayer)                                       
  Violation   GuzzleHttp\Utils must not depend on Symfony\Polyfill\Intl\Idn\Idn (InternalPackagesLayer)                                       
  Violation   PHPStan\PharAutoloader must not depend on Symfony\Polyfill\Php80\Php80 (InternalPackagesLayer)                                  
  Violation   PHPStan\PharAutoloader must not depend on Symfony\Polyfill\Mbstring\Mbstring (InternalPackagesLayer)                            
  Violation   PHPStan\PharAutoloader must not depend on Symfony\Polyfill\Intl\Normalizer\Normalizer (InternalPackagesLayer)                   
  Violation   PHPStan\PharAutoloader must not depend on Symfony\Polyfill\Php73\Php73 (InternalPackagesLayer)                                  
  Violation   PHPStan\PharAutoloader must not depend on Symfony\Polyfill\Intl\Grapheme\Grapheme (InternalPackagesLayer)                       
  Violation   PHPStan\PharAutoloader must not depend on Symfony\Polyfill\Php81\Php81 (InternalPackagesLayer)                                  

What am I doing wrong here?

Originally posted by @MihaiNeagu in #506 (comment)

@patrickkusebauch
Copy link
Collaborator

Hello,
There is nothing wrong that I can see with the config. Can you provide a minimal reproducer in a stand-alone repository that I could debug?

Also, for handling vendor dependencies, I would suggest taking a look at composer collector. It might fit your use case better.

@MihaiNeagu
Copy link
Author

Hello,

My apologies, I will return with a reproducer repo as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants