-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Packages with classmap autoloading are ignored #91
Comments
Hi @lulco thanks for reaching out! The problem in the current state is I am depending on the "string" from the psr0/psr4 value in However! I will have some time in the upcoming weeks to fully implement this feature. So stay tuned :) |
I would like to, but I am not sure how to do it. I have this in composer.json:
executing vendor/bin/composer-unused outputs the same as before:
|
You need to pass the
|
Ah now I read the description of PR :) So I added option -x and now all packages are marked as unused :))
|
Haha ok, not what I expected. So I can check it :) |
I had to create some minimal repository, so here it is:
In app folder I have just one class which uses RedisProxy.
I have composer unused installed "globally" in directory
|
Alright, will check that. Thanks 👍 |
Ah, I see what is wrong here. I located the problem here: https://github.com/composer-unused/composer-unused/pull/89/files#diff-a4550cf56729e9395c835d913c390bc2R44 I only take psr-0 and psr-4 from the root package (your project) into account. Will give you an update as soon as I have something. But good use case, thanks 👍 |
@lulco try again. I think I fixed the implementation accordingly :) |
Well, sorry :) still not working for me... I have added one more package (tomaj/nette-api using psr-4 autoloading): composer.json:
and implementation of ApiHandler MyApiHandler.php
Running without
So this package is found as used. But, I am sure I use php :) and not only in |
Well. Hm. Problem with php. You are not using any symbol (class, constant, function) from php itself. So it is detected as unused. 🤔 Need to think about that. |
Yeah I understand :) but I use another php keywords "class", "extends" etc... Now I am thinking about this: I am not using any php 7.3 feature, so it would be super cool if this was the reason why php is marked as unused :) but probably it would be the whole new package :D |
Yep but For the version check: We could print out a notice that no feature was used from the required version. But then again, this is totally up to the author what versions he/she wants to support :) |
Good news on the packages tho. Problem was that the FileSymbol parsing was only taking As for the |
Hi, I just download actual version of the branch and it looks promissing :) packages are marked as used now. But I found few problems:
Not sure if it is a bug :) I am using php-cs-fixer to find unused uses, so I would remove it and then your script will mark tomaj/nette-api package as unused |
Seems I have introduced a bug, should still be possible. Will look into it 👍
Another test case. Awesome thanks 😅👍
This is currently by design. I only parse constants or functions from Namespaces and only |
You can see the parsed "usages" here. https://www.github.com/composer-unused/composer-unused/tree/main/src%2FParser%2FPHP%2FStrategy |
Hi @lulco, I have found a series of small performance impacts as well as bugs inside it. So for example, |
Hi @icanhazstring, I have tested current version and ext-json works like expected. |
Will take another look. Thanks for testing 🙏 |
I have some observation: It is not only package
all of them (lulco/redis-proxy, nette/database, lulco/phoenix) are marked as unused. The only package which is used in this class was redis-proxy Sooo I moved
Run composer update and then run composer-unused command and voila, results are correct. |
Wait what? 🤔 |
I will add some kind of best practices section for composer-unused. As composer unused should always run last. After linting and static analysis to ensure that the code is clean as it should be. |
Ok, I can now confirm that
I do have slighty idea where this is coming from. I will add some new behavior to dump the found symbols to io in order to debug the properly :) |
great I will wait for new version to test :) |
Ok found the issue. This is why the order of the packages mattered. |
Hi @icanhazstring :) sorry, not really work for me :( I've installed 0.8.x-dev branch. My repo now contains only MyRedis class in app dir
and composer.json
It seems like only psr packages are analyzed. Did I miss something?
|
Hm. Did you run using |
yes, but I got error |
Ah yes. My bad, the current |
composer cannot install it:
|
Wow ok sorry. I did fuck up ;)
And run it via |
Great, now it works :) I think, we can close this issue as resolved. Thank you |
Awesome. Thanks for testing 🙏 |
90% of packages I used in one of my project has classmap src autoloading, so they are ignored with reason "Package provides no namespace". They have some namespaces, just it is not mentioned in composer
Is there a way how to use your great library with this type of packages?
Thank you for your work!
The text was updated successfully, but these errors were encountered: