Skip to content

Commit 81c8f31

Browse files
authored
Merge pull request #7 from Cheburon/CLOUD-11922-obfuscate-error
fix obfuscator error
2 parents b0af549 + 9fe6b01 commit 81c8f31

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public function beforeTraverse(array $nodes)
5757
->resetRenamed()
5858
->skip($this->variableMethodCallsUsed($nodes));
5959

60-
$this->scanMethodDefinitions($nodes);
60+
if (!$this->shouldSkip()) {
61+
$this->scanMethodDefinitions($nodes);
62+
}
6163

6264
return $nodes;
6365
}
@@ -95,7 +97,7 @@ public function enterNode(Node $node)
9597
private function variableMethodCallsUsed(array $nodes)
9698
{
9799
foreach ($nodes as $node) {
98-
if ($node instanceof MethodCall && $node->name instanceof Variable) {
100+
if ($node instanceof MethodCall && $node->name instanceof Variable && $node->var->name === "this") {
99101
// A method call uses a Variable as its name
100102
return true;
101103
}

tests/before/SimpleClass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function publicMethod() {
3737
$this->publicProperty = $localVar;
3838
$this->_protectedMethod();
3939
$this->_privateMethod();
40+
$dt = new \DateTime();
41+
$dtMethodName = "getTimestamp";
42+
$dt->$dtMethodName();
4043
}
4144
}
4245

tests/expected/SimpleClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?php
2-
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();
2+
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();

0 commit comments

Comments
 (0)