Skip to content

fix obfuscator error #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2017
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
6 changes: 4 additions & 2 deletions src/Naneau/Obfuscator/Node/Visitor/ScramblePrivateMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function beforeTraverse(array $nodes)
->resetRenamed()
->skip($this->variableMethodCallsUsed($nodes));

$this->scanMethodDefinitions($nodes);
if (!$this->shouldSkip()) {
$this->scanMethodDefinitions($nodes);
}

return $nodes;
}
Expand Down Expand Up @@ -95,7 +97,7 @@ public function enterNode(Node $node)
private function variableMethodCallsUsed(array $nodes)
{
foreach ($nodes as $node) {
if ($node instanceof MethodCall && $node->name instanceof Variable) {
if ($node instanceof MethodCall && $node->name instanceof Variable && $node->var->name === "this") {
// A method call uses a Variable as its name
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/before/SimpleClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function publicMethod() {
$this->publicProperty = $localVar;
$this->_protectedMethod();
$this->_privateMethod();
$dt = new \DateTime();
$dtMethodName = "getTimestamp";
$dt->$dtMethodName();
}
}

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"; 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();
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(); $spce0ae5 = new \DateTime(); $sp167220 = "getTimestamp"; $spce0ae5->{$sp167220}(); } } $sp5de0e2 = new SimpleClass(); $sp5de0e2->publicMethod();