Added package name collector
Closes qossmic/deptrac#1190
I've made a number of changes:
- Added
ReferenceBuilder::$metaDataso that we can store arbitrary details there and inject them into the references created - Created a
PackageNameclass, which is added toReferenceBuilder::$metaDatain FileReferenceVisitor - I can't use an extractor as the$referenceBuilderis aFileReferenceBuilderby the time the extractors are called for class-like nodes - Modified
PackageNameCollectorto look forPackageNames inTokenReferenceInterface::getMetaData()to determine package names - Modified parser tests to use a fixture, and added collector test
Some other notes:
I can't make use of file-level @package annotations, as nikic/php-parser doesn't support them. For now I'm therefore only handling class-like and function docblocks.
The recent work on pulling the docblock parsing into a separate method in FileReferenceVisitor::processClassLikeDocs() was nice. I wonder if it might be worth later looking at separating the various data-gathering processes there into their own registered classes, like extractors are currently.
Just re-read https://docs.phpdoc.org/3.0/guide/references/phpdoc/tags/package.html#description and thinking I should remove package name handling from global functions. They're only mentioned if the annotation is at the file-level docblock (which we can't handle).
Please update the git origin for development to https://github.com/qossmic/deptrac-src and reopen the PR. Thank you very much!