deptrac
deptrac copied to clipboard
Deptrac does not recognize type aliases
Both PhpStan and Psalm allow users to define type aliases:
- PhpStan - https://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases
- Psalm - https://psalm.dev/docs/annotating_code/type_syntax/utility_types/#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.
What a coincidence, only encountered this just now as well :) Thanks for reporting it.
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: ~
I confirm this issue (and https://github.com/qossmic/deptrac/issues/849).