Skip to content

added php7 support #4

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 4, 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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],

"require": {
"nikic/php-parser": "~1@dev",
"nikic/php-parser": "~3@dev",
"symfony/console": "~2.5",
"symfony/dependency-injection": "~2.5",
"symfony/config": "~2.5",
Expand Down
2 changes: 1 addition & 1 deletion src/Naneau/Obfuscator/Resources/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ services:

# Parser
obfuscator.parser:
class: PhpParser\Parser
class: PhpParser\Parser\Php7
arguments:
- @obfuscator.lexer

Expand Down
7 changes: 6 additions & 1 deletion tests/before/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function functionB() {
return functionB($localVarB);
}

function functionC(?int $a): ?string {
return $a === null ? null : "Output: " . $a;
}

$localVarMainA = "local value";
$localVarMainB = functionB();
$localVarMainA = functionA($localVarMainA);
$localVarMainA = functionA($localVarMainA);
functionC();
2 changes: 1 addition & 1 deletion tests/expected/Functions.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
function functionA($spc5a579) { $sp0edd21 = 3; return $spc5a579 + $sp0edd21; } function functionB() { $sp6a6761 = 5; return functionB($sp6a6761); } $sp8851f9 = 'local value'; $sp7f60ff = functionB(); $sp8851f9 = functionA($sp8851f9);
function functionA($spc5a579) { $sp0edd21 = 3; return $spc5a579 + $sp0edd21; } function functionB() { $sp6a6761 = 5; return functionB($sp6a6761); } function functionC(?int $spf4ffb5) : ?string { return $spf4ffb5 === null ? null : "Output: " . $spf4ffb5; } $sp8851f9 = "local value"; $sp7f60ff = functionB(); $sp8851f9 = functionA($sp8851f9); functionC();
2 changes: 1 addition & 1 deletion tests/expected/MultipleClasses.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
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(); } }
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(); } }
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"; 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();