Download the PHP package nazonohito51/dependency-analyzer without Composer
On this page you can find all versions of the php package nazonohito51/dependency-analyzer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nazonohito51/dependency-analyzer
More information about nazonohito51/dependency-analyzer
Files in nazonohito51/dependency-analyzer
Package dependency-analyzer
Short Description Analyze/Verify class dependencies in PHP.
License MIT
Informations about the package dependency-analyzer
DependencyAnalyzer
Analyze/Verify dependency map for php.
Description
Dependency analyzer help you to keep cleaning your architecture.
If you start to managing dependencies between classes likely Clean Architecture or Layered Architecture, you will aware inspecting dependency between classes by eyes is very difficult in PHP. This library analyze dependencies in your repository, and take some way of using it to you.(Example: Create UML graph, Verify by your rule, Detect cycle path)
Basic Usages
This library have several functions. If you have error when use them, see Trouble Shooting.
Create dependency graph
Analysis dependency map and create graph. Now, dependency analyzer support only Plant UML format.
Maybe, your graph will have many classes, and is very complex! If you need to simplify your graph, see Advanced Usage.
Verify your dependency rule
In Clean Architecture, there is dependency rules between classes. You can define your dependency rule, and this library will detect rule violation in your repository and notify them to you.
First, you can define your rule by php file, like below:
'component'
is a group of classes. (About class name matching rule, see wiki.)
'depender'
is classes/components that depend on component.
'dependee'
is classes/components that is depended on component.
You can restrict depender/dependee.
Then, you can verify your repository like this:
If there is rule violation, notify you of them.
More detail about rule file, see wiki. More example about rule file, see this repository rule file.
Verify your dependency rule by phpdoc
In verify dependency, you can use phpdoc too.
You can restrict depener of class by writing @da-internal
.
Then, you can verify your repository. (command is same as Verify your dependency rule) Of course, you can use rule file and phpdoc at same time. In the process of analyzing repository, this library collect phpdoc, and verify your repository. If there is rule violation, notify you of them.
More detail about phpdoc, see wiki.
Detect cycle dependency
In Acyclic dependencies principle, dependencies graph should have no cycles. You can detect cycles like this:
What is dependency?
Dependency is knowledge of interface that is had by class. In classes collaboration, every class always have knowledge of interface of other classes. If a interface is changed, classes what have knowledge of that interface is must fixed.
Dependency is created by below php syntaxes.
- extends/implements
- use trait
- new object
- type hinting (defined by phpdoc too)
- return type declaration (defined by phpdoc too)
- fetch public property/constant
- call public method
- class class method
- throw
- catch
- instanceof
- foreach access
- array dim access
- call function
This library analyze those syntaxes by using PHPStan, and create dependency graph. If you want to know detail, see example.
Advanced Usages
Create dependency graph
TBD...
- rule file
- namespace
- group
- comment
Verify your dependency rule
TBD...
- namespace rule
- magic keyword
TODO
- [x] Display error details
- [ ] README
- [ ] graph
- [x] wiki
- [x] Analyze Facade
- [x] Response object & format
- [x] use table format
- [ ] comment of Plant UML
- [x] fix namespace pattern matting(adjust file pattern matting)
- [x] only !\Hoge\Fuga
- [ ] Graph format(another puml)
- [ ] original rule logic
- [x] remove dependency to vertex, edge
- [ ] Improve performance by using cache
- [x] Analyze per class member(property/method/constant)
All versions of dependency-analyzer with dependencies
phpstan/phpstan Version ~0.11.0
clue/graph Version ~0.9
symfony/console Version ~4
phplucidframe/console-table Version ~1.2