Skip to content

getVariableName() won't work correct #12

@IamNeo1

Description

@IamNeo1

There are 2 problems in it.

The constructor was switched to the php 5+ call __construct. So __construct is in the Array and the clause fails because you are looking for the old constructor dBug.

OLD:

( 0 != strcasecmp( $arrCurrent["function"], "dbug" )

NEW:

( 0 != strcasecmp( $arrCurrent["function"], "__construct" )

When this part is corrected the function fails because the RegEx-pattern does not work. You added namespaces. So I have to this for example:
OLD:

new dBug( $trace_data, '', true );

NEW:

new dBug\dBug( $trace_data, '', true );

The pattern '/\bnew dBug\s*\(\s*(.+)\s*\);/i' looks for the old string. When I change the preg_match-function from
OLD:

preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);

to
NEW:

preg_match_all( '~(\bnew dBug\\\dBug\s*\(\s*)([^, ]*)(.*)(\s*\))~i', $code, $arrMatches );

and changes the return clause to

return isset( $arrMatches[2][0] ) ? $arrMatches[2][0] : '[multiline]';

only the name of the variable returned.

We are using dBug in our project and debugging a lot of variables. We are having a error page where we see all of them. So we are really need the variable names.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions