Skip to content
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

Lost variable name #436

Open
marcoas opened this issue Feb 20, 2025 · 1 comment
Open

Lost variable name #436

marcoas opened this issue Feb 20, 2025 · 1 comment

Comments

@marcoas
Copy link

marcoas commented Feb 20, 2025

I made my own function, for the use of KINT

function debug( $variable, $die = false, $expanded = false ) {
    if( $expanded ) {
      !d( $variable );

    } else {
      d( $variable );

    }

    if( $die ) die();

    return true;
}

The problem is that now, I always see "$variable" in the output of KINT, losing the original name of the variable.

Image

Can this be fixed with some configuration?

@jnvsor
Copy link
Member

jnvsor commented Feb 22, 2025

@marcoas You have to add your function to Kint::$aliases for kint to be able to detect the input variables. That said, if you just do that kint may still fail to detect the variable name if you use your extra parameters:

Kint::$aliases[] = 'debug';
debug($var, true);

For example if kint sees debug($var, true) but only receives 1 value it will assume that it has found the wrong call. You'll also lose the modifier in your first if since it's looking at the parent stack now, so you'd need to set and unset Kint::$return instead.

You'd need to set your base context manually if you want this to be robust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants