• Resolved bscandanavia

    (@bscandanavia)


    Hello,

    I’ve wrapped my d() calls in a wrapper debug function that, amongst other things, checks to make sure this plugin is installed (and to not throw errors when d() is not available on different staging/production setups, etc).

    The fallout of this is that Kint then lists the parameter names of my wrapper function. for example:

    
    debug($var, $var2){
      if(function_exists('d'){
        d($var, $var2);
      }
    }
    
    $test = 'foo';
    $test2 = 'bar;
    d($test, $test2);
    

    will create a kint output with $var $var2 as the source vars rather $test and $test2. Is there anyway to pass through the original variable names?

    I realize this is more of a question about Kint itself, but thought worth asking here.

    thank you,
    Erik

Viewing 1 replies (of 1 total)
  • Plugin Author Chris Dillon

    (@cdillon27)

    Hi Erik,

    I am not aware of an easy way. PHP has a thing called Reflection but it’s above my paygrade. 😀
    http://php.net/manual/en/reflectionparameter.getname.php

    A simple solution is to create a fallback. For example, an mu-plugin with

    
    function the_last_word() {
    	if ( !function_exists( 'd' ) ) {
    		function d() {}
    	}
    }
    add_action( 'wp', 'the_last_word' );

    may be easier to remember to do than removing all your d() calls.

Viewing 1 replies (of 1 total)

The topic ‘wrapper function pass through params’ is closed to new replies.