Skip to content

Commit d0e2e69

Browse files
author
Vyacheslav Gulyam
committed
added private property scrambler fixes
1 parent 390514a commit d0e2e69

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateMethod.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ class ScramblePrivateMethod extends ScramblerVisitor
4545
use TrackingRenamerTrait;
4646
use SkipTrait;
4747

48-
/**
49-
* Active class
50-
*
51-
* @var ClassNode|bool
52-
**/
53-
private $currentClassNode;
54-
5548
/**
5649
* Before node traversal
5750
*
@@ -81,10 +74,6 @@ public function enterNode(Node $node)
8174
return;
8275
}
8376

84-
if ($node instanceof ClassNode) {
85-
$this->currentClassNode = $node;
86-
}
87-
8877
// Scramble calls
8978
if (($node instanceof MethodCall && $node->var->name === 'this') || ($node instanceof StaticCall && $node->class instanceof Node\Name && $node->class->toString() === 'self')) {
9079
// Node wasn't renamed

src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function enterNode(Node $node)
7878
{
7979
if ($node instanceof PropertyFetch) {
8080

81-
if (!is_string($node->name)) {
81+
if (!is_string($node->name) || $node->var->name !== "this") {
8282
return;
8383
}
8484

tests/before/MultipleClasses.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,24 @@ static public function anotherPublicMethod() {
3636

3737
class ThirdClass {
3838

39+
private $publicProperty;
40+
3941
static private function anotherPublicMethod() {
4042

4143
}
4244

4345
public function __construct(SecondClass $secondObject) {
4446
$secondObject->publicMethod();
4547
$secondObject::anotherPublicMethod();
48+
$secondObject->publicProperty = 'test';
4649
}
4750

4851
private function publicMethod() {
4952
echo 'test';
5053
}
5154

5255
protected function someFunc() {
56+
$this->publicProperty = 'test';
5357
$this->publicMethod();
5458
self::anotherPublicMethod();
5559
}

tests/expected/MultipleClasses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?php
2-
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 static function spe81a11() { } public function __construct(SecondClass $spb91639) { $spb91639->publicMethod(); $spb91639::anotherPublicMethod(); } private function sp70ab23() { echo 'test'; } protected function someFunc() { $this->sp70ab23(); self::spe81a11(); } }
2+
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(); } }

0 commit comments

Comments
 (0)