qossmic / deptrac

Keep your architecture clean.
https://qossmic.github.io/deptrac
MIT License
2.6k stars 135 forks source link

Deptrac does not recognize type aliases #1355

Open patrickkusebauch opened 7 months ago

patrickkusebauch commented 7 months ago

Both PhpStan and Psalm allow users to define type aliases:

However, Deptrac does not recognize them and assumes there exists a class with the name of the alias. This results in Deptrac complaining about an uncovered dependency on a class that does not exist.

MetalArend commented 7 months ago

What a coincidence, only encountered this just now as well :) Thanks for reporting it.

MetalArend commented 7 months ago

I saw #849. Here is a fairly simple example to trigger the uncovered type found in a @phpstan-type annotation.

<?php

namespace App;

/**
 * @phpstan-type TestType array<mixed>
 */
final class Test
{
    /**
     * @param TestType $content
     */
    private function __construct(private readonly array $content)
    {
    }
}
parameters:
  paths:
    - ./src/App
  layers:
    - name: App
      collectors:
        - type: directory
          value: src/App/.*
  ruleset:
    App: ~
javaDeveloperKid commented 7 months ago

I confirm this issue (and https://github.com/qossmic/deptrac/issues/849).