kint-php / kint

Kint - Advanced PHP dumper
https://kint-php.github.io/kint/
MIT License
2.77k stars 290 forks source link

Is it possible to see all the methods in a class #423

Closed marcoczen closed 3 days ago

marcoczen commented 3 days ago

Guys,

I am on Kint 5.1.1. Its been great ( i started using Kint fom 3.x). I am wondering if there is a way to see a class and all its methods/functions ? Something like;

d( someClassName);

and that Kint prints out all the methods / functions in the said class ?

jnvsor commented 3 days ago

I was gonna say this can't be done without an instance, and I had a whole thing typed out with philosophical reasons not to do it, and benchmarks showing calling get_class on every string makes it take at least 10 times as long to dump, and recommendations to use new ReflectionClass($class)->newInstanceWithoutConstructor() even though it's a dirty hack and then I thought:

Hang on. If I only do this check at the top level dumps can't I ignore all of this?

So I did and it worked. I'll put it up as 6.0-beta4 this weekend

jnvsor commented 3 days ago

Done in a2c87f273b79ad12104ab04b1657c40f0fb89f58

marcoczen commented 3 days ago

Wow .. that was fast .... Awesome ... I am using kint in the form of a phar file. So how do i get a new phar with this feature added ?

jnvsor commented 3 days ago

If you just check the build folder of the master branch you can get it there. It's still a beta of the next major version so please report any issues you find with it!

marcoczen commented 3 days ago

https://github.com/kint-php/kint/tree/master/build

I found 'kint.phar' under the folder. Will use it. Also - is there a way we can check the version of the kint.phat ? I opened it up using vscode but could not find any test string saying 'version 6.0 beta 4' or equivalent. Am i doing it wrong ?

jnvsor commented 3 days ago

Nope. There's no version information in the phar file, and I don't plan on adding any. (Keeping code and git tags synced is a pain and can't really be done in CI either without breaking the reproducible builds)

It could be done if we had a permanent storage for GHA build artifacts but as far as I can tell they're limited to 90 days which means if I go for a while without committing the build will disappear

marcoczen commented 3 days ago

Noted. Thanks.

I replaced my kint_v511.phar with this new kint.phar' and I got an error 'PHP Fatal error: Uncaught Error: Class "Kint" not found'.

Prev:

require_once __DIR__.'/../kint_v511.phar'

Now ( Not working )

require_once __DIR__.'/../kint_v6b4.phar'

Is there a build step that I m missing ?

jnvsor commented 3 days ago

It should just work the same and the tests check the phar too...

Is the fatal error coming from inside the phar or from your code? Did you move the require location?

marcoczen commented 3 days ago

Prev ( working )

require_once DIR.'/../kint_v511.phar';

Now ( Not working )

require_once DIR.'/../kint_v6b4.phar';

Is there a build step that I m missing ?

jnvsor commented 3 days ago

No I mean the fatal error should tell you where it's being caused, it should give you a file and line number

marcoczen commented 3 days ago

Update - I re-downloaded the phar file . All good. Thanks.