From eba66ebd78ba51d5ca042c9e4cef6a8bfa35151f Mon Sep 17 00:00:00 2001 From: pk-fr Date: Mon, 2 Mar 2020 18:01:30 +0100 Subject: [PATCH] fix bug with use without alias --- .../parser_extensions/my_node_visitor.php | 27 ++++++++++--------- version.php | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/classes/parser_extensions/my_node_visitor.php b/include/classes/parser_extensions/my_node_visitor.php index 6247664..06559ec 100644 --- a/include/classes/parser_extensions/my_node_visitor.php +++ b/include/classes/parser_extensions/my_node_visitor.php @@ -529,20 +529,23 @@ public function leaveNode(PhpParser\Node $node) { if ($conf->obfuscate_function_name || $conf->obfuscate_class_name) { - if (!$conf->obfuscate_function_name || !$conf->obfuscate_class_name) + if (isset($node->alias)) { - fprintf(STDERR, "Warning:[use alias] cannot determine at compile time if it is a function or a class alias".PHP_EOL."\tyou must obfuscate both functions and classes or none...".PHP_EOL."\tObfuscated code may not work!".PHP_EOL); - } - $scrambler = $t_scrambler['function_or_class']; - $name = $this->get_identifier_name($node->alias); - if ( is_string($name) && (strlen($name) !== 0) ) - { - $r = $scrambler->scramble($name); - if ($r!==$name) + if (!$conf->obfuscate_function_name || !$conf->obfuscate_class_name) { - //$node->alias = $r; - $this->set_identifier_name($node->alias,$r); - $node_modified = true; + fprintf(STDERR, "Warning:[use alias] cannot determine at compile time if it is a function or a class alias".PHP_EOL."\tyou must obfuscate both functions and classes or none...".PHP_EOL."\tObfuscated code may not work!".PHP_EOL); + } + $scrambler = $t_scrambler['function_or_class']; + $name = $this->get_identifier_name($node->alias); + if ( is_string($name) && (strlen($name) !== 0) ) + { + $r = $scrambler->scramble($name); + if ($r!==$name) + { + //$node->alias = $r; + $this->set_identifier_name($node->alias,$r); + $node_modified = true; + } } } } diff --git a/version.php b/version.php index 4fd7672..5331de8 100644 --- a/version.php +++ b/version.php @@ -11,6 +11,6 @@ // Use and abuse at your own risks. //======================================================================== -$yakpro_po_version = "2.0.7"; +$yakpro_po_version = "2.0.8"; ?> \ No newline at end of file