Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

/**
Expand Down
8 changes: 7 additions & 1 deletion tests/before/SimpleClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/SimpleClass.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
class SimpleClass { const CONSTANT_VARIABLE = "test"; static $staticProperty = "test"; private $sp8839d9; protected $_protectedProperty; public $publicProperty; private function sp51fa3f() { $spd8dce8 = "test"; $this->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();
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();