-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #360
- Loading branch information
Showing
4 changed files
with
71 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
namespace Hal\Component\Ast; | ||
|
||
use PhpParser\NodeTraverser as Mother; | ||
|
||
class Php5NodeTraverser extends Mother | ||
{ | ||
/** @var Traverser */ | ||
private $traverser; | ||
|
||
public function __construct($cloneNodes = false, $stopCondition = null) | ||
{ | ||
parent::__construct(); | ||
$this->traverser = new Traverser($this, $stopCondition); | ||
} | ||
|
||
public function traverseNode(Node $node) | ||
{ | ||
return parent::traverseNode($node); | ||
} | ||
|
||
protected function traverseArray(array $nodes) | ||
{ | ||
return $this->traverser->traverseArray($nodes, $this->visitors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace Hal\Component\Ast; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\NodeTraverser as Mother; | ||
|
||
class Php7NodeTraverser extends Mother | ||
{ | ||
/** @var Traverser */ | ||
private $traverser; | ||
|
||
public function __construct($cloneNodes = false, $stopCondition = null) | ||
{ | ||
parent::__construct(); | ||
$this->traverser = new Traverser($this, $stopCondition); | ||
} | ||
|
||
public function traverseNode(Node $node): Node | ||
{ | ||
return parent::traverseNode($node); | ||
} | ||
|
||
protected function traverseArray(array $nodes): array | ||
{ | ||
return $this->traverser->traverseArray($nodes, $this->visitors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
namespace Test\Hal\Component\Ast; | ||
|
||
use Hal\Component\Ast\NodeTraverser; | ||
use PhpParser\NodeTraverser as BaseTraverser; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
class NodeTraverserTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testItCanBeInstantiated() | ||
{ | ||
$this->assertInstanceOf(BaseTraverser::class, new NodeTraverser()); | ||
} | ||
} |