-
Notifications
You must be signed in to change notification settings - Fork 1
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
Tracking method used? #1
Comments
You are correct in assuming this package only uses the
I mostly wrote this package to support another package: watch-phpunit. Where i want to find out all dependencies, and it doesn't matter if they are direct dependencies or child dependencies. So in your example, class A depends on class B. And class B once again depends on class C, and this package should be able to detect that, as long as the dependency is somewhere in the code (not in the comments) explicitly. However, moving forward i do think that it would be better if it could infer that class A has a direct dependency on class C. So i'd like working together on that issue. |
So feel free to check out these classes:
This command dumps JSON with dependencies to disk. It has this format:
Although using PHPStan's type inference internally is not its primary usecase, some projects like Rector have been successfully using it. |
Hi,
I've been intrigued by finding this library because I'm facing a similar challenge in PHPStan. I'd like to know what method do you use to track file dependencies?
I've only been able to find this directory in your source code: https://github.com/BackEndTea/Dependency-Finder/tree/master/src/PHPParser/Visitor So I think that you only use
Name
AST node ocurrences as dependencies.But this problem is far more complex. Consider for example this scenario:
You have a class A that has property
private $bProperty
with injected class B. You call methoddoB
on$this->bProperty
that returns C. Now you call some method on theC
object.Now you're in a situation that class
A
depends on changes in classC
but AFAIK your tool is not able to track this.PHPStan solves this thanks to type inference - it knows about types of all expressions so it's able to reason about method calls, read phpDocs etc. The logic itself to find out about dependencies is in this class: https://github.com/phpstan/phpstan/blob/master/src/Dependency/DependencyResolver.php
Let me know if you want to work together on this problem :)
The text was updated successfully, but these errors were encountered: