-
Notifications
You must be signed in to change notification settings - Fork 134
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
@template-covariant
type always appears in Uncovered
#1399
Comments
The same problem occurs ( /**
* @phpstan-type arrayAlias array<string, mixed>
*/
class SomeClass
{
/**
* @return arrayAlias
*/
private function someMethod(): array
{
return [];
}
} |
To be fair in this case it really should be |
|
And I would propose the same solution. You should reference it with There is a larger argument that we should be able to fully support Psalm and PHPStan. |
The prefix is not really scoping, tools like PHPStan often introduce some features with prefixed annotation (like But I understand this might be hard for deptrac to be in-sync with all the tools. |
I also encountered the same problem. But i just swooped them into the baseline. I mean, it would be nice if deptrac could understand it and work with it, but not a must have i think. Also, there are cases where you define |
Currently, I'm using this to avoid this issue in general (as we use only class tokens): class ExcludeUncoveredHandler implements EventSubscriberInterface
{
public function handleUncovered(PostProcessEvent $event): void
{
$result = $event->getResult();
/** @var Uncovered $uncovered */
foreach ($result->allOf(Uncovered::class) as $uncovered) {
if ($this->isUncoveredIgnored($uncovered)) {
$result->remove($uncovered);
}
}
}
private function isUncoveredIgnored(Uncovered $uncovered): bool
{
/** @var class-string<object> $class */
$class = $uncovered->getDependency()->getDependent()->toString();
try {
/** @throws ReflectionException */
$reflectionClass = new ReflectionClass($class);
} catch (ReflectionException $e) {
return true; // prevent deptrac bugs like https://github.com/qossmic/deptrac/issues/1399
}
return false;
}
/**
* @return array<string, array{string}>
*/
public static function getSubscribedEvents(): array
{
return [
PostProcessEvent::class => ['handleUncovered'],
];
}
} services:
excludeUncoveredHandler:
class: App\EventHandler\ExcludeUncoveredHandler
tags:
- { name: kernel.event_subscriber } |
This could catch also other errors no? I would suggest just to utilize the baseline feature. I mean, this is exactly meant for such cases. |
We have other tooling to detect non-existing classes in codebase, so this should be safe in our case. If deptrac finds non-class token, it clearly does something wrong and I dont want that to be reported. |
When analysing following file
With this depfile:
I'm getting
Using just
@template
seems to work.The text was updated successfully, but these errors were encountered: