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
WIP: Add scanning using symbols #89
Conversation
49b917b
to
f3c6075
Compare
Goto logic to load symbols from required dependencies:
|
Working example to compare a single $rootPackage = $composer->getPackage(); // self
//$rootSymbolLoader = new RootSymbolLoader();
$dependencySymbolLoader = new DependencySymbolLoader(
new FunctionConstantSymbolProvider(
new SymbolNameParser(
(new ParserFactory())->create(ParserFactory::ONLY_PHP7),
new SymbolNodeVisitor()
),
new FileContentProvider()
),
new SymbolLoader()
);
$requiredDependencies = [];
foreach ($rootPackage->getRequires() as $require) {
$composerPackage = $resolvePackage($require);
if ($composerPackage === null) {
continue;
}
$requiredDependencies[] = new RequiredDependency(
$composerPackage,
(new SymbolList())->addAll(
$dependencySymbolLoader->load($composerPackage)
)
);
}
$usedSymbols = [new Symbol(PackageInterface::class)];
foreach ($requiredDependencies as $requiredDependency) {
foreach ($usedSymbols as $usedSymbol) {
if ($requiredDependency->provides($usedSymbol)) {
$requiredDependency->markUsed();
continue 2;
}
}
} |
Current having a problem with nested Todo:
|
TIL: you can't reuse a generator 😅 That was the problem. Using |
Quick question: do you expect performance decrease from this change? |
Hi @Jean85. Good question. For the most part there would be not much difference. The following steps are done
With this in mind, most packages I could find are defining a namespace they provide. Only for special packages that only define a classmap or simply files, they would have more impact. But I am trying to avoid that impact using generators. So the files will be only parsed when needed. |
Also, the current idea is to have an option in place to activate the new behavior for people to try it out. So everything else works as before. This way I can optimize the new implementation in different scopes. |
0981f4f
to
64c3440
Compare
ae2ba8c
to
8f9ab39
Compare
This will be used with the new symbol matching implementation Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
This is to avoid a full scan of the complete package structure which is not necessary. It represents the same logic as before with composer-unused. Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
This will provide a generator with all symbols for a given composer package Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Reduce the amount of used symbols by avoiding duplicates. Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
This will be used for better console logging or logging in general. Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
8465b25
to
40a460a
Compare
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Noticed another problem that might come up and should be considered: So the current implementation on src/Symbol/Loader/FileSymbolLoader.php does not cover all possibilities and should be covered by tests for these cases. One consideration might be to use |
Resolve issue with used extension symbols Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
This was added to prevent stacking up symbols from previous analysed packages. Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
Merged the current work into |
Work in Progress
This will rework how dependencies and usages are handled.
Previously only Namespaces were checked, which doesn't work well for constants or functions that are provided by a dependency but don't have a namespace.
More information see #85
How to test:
Then run
Current state: