ComposerRequireChecker icon indicating copy to clipboard operation
ComposerRequireChecker copied to clipboard

Try to guess packages using BetterReflection.

Open guillaume-perreal opened this issue 5 years ago • 8 comments

See #52.

~~There are still a couple of issues:~~

~~* I do not like loading the project autoloader, since it automatically registers. Yet it is a cheap way to resolve symbols.~~ ~~* I am not satisfied with the handling of the autoloader-path configuration.~~

Use BetterReflection to guess the source package of unknown symbols from the vendor directory.

Known limitations:

  • Find classes only.
  • Do not support non-standard vendor locations (https://getcomposer.org/doc/06-config.md#vendor-dir), since BetterReflection does not either.

guillaume-perreal avatar Nov 15 '19 16:11 guillaume-perreal

I do not like loading the project autoloader, since it automatically registers. Yet it is a cheap way to resolve symbols.

It's a simple/reliable way to get things done - if you want to avoid it, then please use an approach like https://github.com/Roave/BetterReflection/blob/14f329c5a3201ee890d3d8c4959c8779b9de7f63/src/SourceLocator/Type/Composer/Factory/MakeLocatorForComposerJson.php (usage example in https://github.com/Roave/BackwardCompatibilityCheck/blob/d1175788acc330a8a02e92267247f9734e4ca04f/src/LocateSources/LocateSourcesViaComposerJson.php)

Ocramius avatar Nov 15 '19 17:11 Ocramius

If this is about solving the problem of having to include the autoloader, then let's please go with BetterReflection, which includes abstractions to figure out where things are :+1:

If this is about having a configurable autoloader path, then I'd be :-1: for it, because it adds a lot of un-needed complexity, whereas simplifying the autoload setup is less effort and less maintenance.

Ocramius avatar Nov 15 '19 17:11 Ocramius

MakeLocatorForComposerJson seems to be the right tool. I'll give it a try. Thanks for the pointer.

guillaume-perreal avatar Nov 15 '19 23:11 guillaume-perreal

@Ocramius any comment on this ?

guillaume-perreal avatar Nov 23 '19 11:11 guillaume-perreal

Haven't had time to check most of OSS work, sorry Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Sat, Nov 23, 2019 at 12:27 PM Guillaume Perréal [email protected] wrote:

@Ocramius https://github.com/Ocramius any comment on this ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/maglnet/ComposerRequireChecker/pull/162?email_source=notifications&email_token=AABFVEGDPG3LJGA7WQ6E2D3QVEHTXA5CNFSM4JN5QEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE7TFSI#issuecomment-557789897, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABFVEHPGWCKGX43VJZMTZLQVEHTXANCNFSM4JN5QEVQ .

Ocramius avatar Dec 04 '19 17:12 Ocramius

I would like to see this feature 👍

Can i somehow help here out @Ocramius? There was already one attempt to implement the same feature #91 but there the autoloader was used to get it done. But i like the AST approach via BetterReflection alot. This PR needs a rebase for sure.

DanielBadura avatar Jan 21 '21 13:01 DanielBadura

@DanielBadura since we now support "php": "^8", beware that you will have to wait until roave/better-reflection is tagged with PHP 8 support for a potential merge of such a feature.

In newer versions of BetterReflection, I added support for composer.json and installed.json scanning, which I use in:

  • https://github.com/Roave/BackwardCompatibilityCheck/blob/7917779c5ccc3df603c41a90146af113c5429a9f/src/LocateSources/LocateSourcesViaComposerJson.php#L22-L23
  • https://github.com/Roave/BackwardCompatibilityCheck/blob/7917779c5ccc3df603c41a90146af113c5429a9f/src/LocateDependencies/LocateDependenciesViaComposer.php#L57-L59

Ocramius avatar Jan 21 '21 15:01 Ocramius

Alright, tryin then my best over there 🚀

DanielBadura avatar Jan 21 '21 16:01 DanielBadura