kint-php / kint

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

no resolv modifiers #251

Closed carschrotter closed 7 years ago

carschrotter commented 7 years ago

Hello, I have problem when using the static dump method from class with modifiers, then this do not work. Example $dump = @Kint::dump($value); print out the value and not save in the variable. The problematic code is on "src/SourceParser.php" line 182:

                if (!$prev_tokens[0] || $prev_tokens[0][0] !== T_STRING || strtolower($prev_tokens[0][1]) !== $class) {
                    continue;
                }

you see strtolower($prev_tokens[0][1]) and $class is on code not convert to lower. Change to the following code work fine:

                if (!$prev_tokens[0] || $prev_tokens[0][0] !== T_STRING || $prev_tokens[0][1]!== $class) {
                    continue;
                }

ps. sorry for the Bad English. I am talking about this only very circularly.

jnvsor commented 7 years ago

Oh my, I seem to have forgotten an strtolower. Does this diff work in your use case?

diff --git a/src/SourceParser.php b/src/SourceParser.php
index d8d8d08..befc6cf 100644
--- a/src/SourceParser.php
+++ b/src/SourceParser.php
@@ -130,7 +130,7 @@ class Kint_SourceParser

         if (is_array($function)) {
             $class = explode('\\', $function[0]);
-            $class = end($class);
+            $class = strtolower(end($class));
             $function = strtolower($function[1]);
         } else {
             $class = null;
carschrotter commented 7 years ago

Hello, I have applied this fixed manually (I use composer for installation, no git repo). And it works fine with me!

jnvsor commented 7 years ago

All right, I'll push that soon

jnvsor commented 7 years ago

Pushed. Thanks for the bug report!