diff --git a/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php b/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php index 134705f..c101788 100644 --- a/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php +++ b/src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php @@ -87,6 +87,17 @@ public function enterNode(Node $node) return $node; } } + + if ($node instanceof Node\Expr\StaticPropertyFetch) { + if ((string)$node->class !== "self") { + return; + } + + if ($this->isRenamed($node->name)) { + $node->name = $this->getNewName($node->name); + return $node; + } + } } /** diff --git a/tests/before/SimpleClass.php b/tests/before/SimpleClass.php index d96d29a..8e6df75 100644 --- a/tests/before/SimpleClass.php +++ b/tests/before/SimpleClass.php @@ -4,7 +4,10 @@ class SimpleClass { const CONSTANT_VARIABLE = "test"; - static $staticProperty = "test"; + public static $publicStaticProperty = "test"; + protected static $protectedStaticProperty = "test"; + private static $_privateStaticProperty = "test"; + private $_privateProperty; protected $_protectedProperty; @@ -15,6 +18,9 @@ private function _privateMethod() { $this->_privateProperty = $localVar; $this->_protectedProperty = $localVar; $this->publicProperty = $localVar; + self::$publicStaticProperty = "test"; + self::$protectedStaticProperty = "test"; + self::$_privateStaticProperty = "test"; } protected function _protectedMethod() { diff --git a/tests/expected/SimpleClass.php b/tests/expected/SimpleClass.php index 104ccd5..2ba8c4a 100644 --- a/tests/expected/SimpleClass.php +++ b/tests/expected/SimpleClass.php @@ -1,2 +1,2 @@ sp8839d9 = $spd8dce8; $this->_protectedProperty = $spd8dce8; $this->publicProperty = $spd8dce8; } protected function _protectedMethod() { $spd8dce8 = "test"; $this->sp8839d9 = $spd8dce8; $this->_protectedProperty = $spd8dce8; $this->publicProperty = $spd8dce8; } public function publicMethod() { $spd8dce8 = "test"; $this->sp8839d9 = $spd8dce8; $this->_protectedProperty = $spd8dce8; $this->publicProperty = $spd8dce8; $this->_protectedMethod(); $this->sp51fa3f(); } } $sp5de0e2 = new SimpleClass(); $sp5de0e2->publicMethod(); \ No newline at end of file +class SimpleClass { const CONSTANT_VARIABLE = "test"; public static $publicStaticProperty = "test"; protected static $protectedStaticProperty = "test"; private static $sp39db2b = "test"; private $sp8839d9; protected $_protectedProperty; public $publicProperty; private function sp51fa3f() { $spd8dce8 = "test"; $this->sp8839d9 = $spd8dce8; $this->_protectedProperty = $spd8dce8; $this->publicProperty = $spd8dce8; self::$publicStaticProperty = "test"; self::$protectedStaticProperty = "test"; self::$sp39db2b = "test"; } protected function _protectedMethod() { $spd8dce8 = "test"; $this->sp8839d9 = $spd8dce8; $this->_protectedProperty = $spd8dce8; $this->publicProperty = $spd8dce8; } public function publicMethod() { $spd8dce8 = "test"; $this->sp8839d9 = $spd8dce8; $this->_protectedProperty = $spd8dce8; $this->publicProperty = $spd8dce8; $this->_protectedMethod(); $this->sp51fa3f(); } } $sp5de0e2 = new SimpleClass(); $sp5de0e2->publicMethod(); \ No newline at end of file