pk-fr / yakpro-po

YAK Pro - Php Obfuscator
http://www.php-obfuscator.com
Other
1.24k stars 350 forks source link

Class method should be obfuscated to same string as its class, if it is the class constructor #78

Open sedimentation-fault opened 4 years ago

sedimentation-fault commented 4 years ago

Suppose you have

class x {

function x() {
...
}

}

that is, you have a class method with the same name as the class. Prior to PHP 5.x, this was the standard way to define the class constructor - today we would use __construct(). If you have class and method obfuscation turned on, then class x will be renamed to a different name than its constructor method x(). Thus, x() will cease to be a constructor in the obfuscated program, as its new name will not match the new class name.

I consider this a bug, because using class-named methods as constructors does not throw any error in PHP 7.x. So if you want to be thorough, this should be corrected.

One could argue, of course, that we can (or should) ignore such method and class names for both class and method obfuscation. This is true, but it is a PITA if you have thousands of files.

Besides, it is a very nasty bug, because it took me two days to find out what is going on, namely that the constructor was not being executed, because it ceased being a constructor in the obfuscated script! :scream: