diff --git a/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateMethod.php b/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateMethod.php index 257c276..3a00661 100644 --- a/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateMethod.php +++ b/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateMethod.php @@ -75,8 +75,7 @@ public function enterNode(Node $node) } // Scramble calls - if ($node instanceof MethodCall || $node instanceof StaticCall) { - + if (($node instanceof MethodCall && $node->var->name === 'this') || ($node instanceof StaticCall && $node->class instanceof Node\Name && $node->class->toString() === 'self')) { // Node wasn't renamed if (!$this->isRenamed($node->name)) { return; diff --git a/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php b/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php index 86c77cf..134705f 100644 --- a/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php +++ b/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php @@ -78,7 +78,7 @@ public function enterNode(Node $node) { if ($node instanceof PropertyFetch) { - if (!is_string($node->name)) { + if (!is_string($node->name) || $node->var->name !== "this") { return; } diff --git a/tests/before/MultipleClasses.php b/tests/before/MultipleClasses.php index f499458..d121ae2 100644 --- a/tests/before/MultipleClasses.php +++ b/tests/before/MultipleClasses.php @@ -29,10 +29,32 @@ public function publicMethod() { echo "This is public method of second class"; $this->_privateProperty = parent::$publicProperty; } + + static public function anotherPublicMethod() { + } } class ThirdClass { + + private $publicProperty; + + static private function anotherPublicMethod() { + + } + public function __construct(SecondClass $secondObject) { $secondObject->publicMethod(); + $secondObject::anotherPublicMethod(); + $secondObject->publicProperty = 'test'; + } + + private function publicMethod() { + echo 'test'; + } + + protected function someFunc() { + $this->publicProperty = 'test'; + $this->publicMethod(); + self::anotherPublicMethod(); } } \ No newline at end of file diff --git a/tests/expected/MultipleClasses.php b/tests/expected/MultipleClasses.php index a6e9e81..3afbca5 100644 --- a/tests/expected/MultipleClasses.php +++ b/tests/expected/MultipleClasses.php @@ -1,2 +1,2 @@ sp8839d9 = parent::$_protectedProperty; } public function publicMethod() { parent::publicMethod(); echo 'This is public method of second class'; $this->sp8839d9 = parent::$publicProperty; } } class ThirdClass { public function __construct(SecondClass $spb91639) { $spb91639->publicMethod(); } } \ No newline at end of file +class FirstClass { protected $_protectedProperty; public $publicProperty; protected function _protectedMethod() { echo 'This is protected method of first class'; } public function publicMethod() { echo 'This is public method of first class'; } } class SecondClass extends FirstClass { private $sp8839d9; protected function _protectedMethod() { parent::_protectedMethod(); echo 'This is protected method of second class'; $this->sp8839d9 = parent::$_protectedProperty; } public function publicMethod() { parent::publicMethod(); echo 'This is public method of second class'; $this->sp8839d9 = parent::$publicProperty; } public static function anotherPublicMethod() { } } class ThirdClass { private $spa36ab6; private static function spe81a11() { } public function __construct(SecondClass $spb91639) { $spb91639->publicMethod(); $spb91639::anotherPublicMethod(); $spb91639->publicProperty = 'test'; } private function sp70ab23() { echo 'test'; } protected function someFunc() { $this->spa36ab6 = 'test'; $this->sp70ab23(); self::spe81a11(); } } \ No newline at end of file