-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refac: replace AbstractNodeVisitor with NodeVisitorInterface
- Loading branch information
Showing
3 changed files
with
12 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
use Twig\Node\Expression\ConstantExpression; | ||
use Twig\Node\Expression\FilterExpression; | ||
use Twig\Node\Node; | ||
use Twig\NodeVisitor\AbstractNodeVisitor; | ||
use Twig\NodeVisitor\NodeVisitorInterface; | ||
|
||
/** | ||
* Applies the value of the "desc" filter if the "trans" filter has no | ||
|
@@ -29,7 +29,7 @@ | |
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
final class DefaultApplyingNodeVisitor extends AbstractNodeVisitor | ||
final class DefaultApplyingNodeVisitor implements NodeVisitorInterface | ||
{ | ||
/** | ||
* @var bool | ||
|
@@ -41,7 +41,7 @@ public function setEnabled(bool $bool): void | |
$this->enabled = $bool; | ||
} | ||
|
||
public function doEnterNode(Node $node, Environment $env): Node | ||
public function enterNode(Node $node, Environment $env): Node | ||
{ | ||
if (!$this->enabled) { | ||
return $node; | ||
|
@@ -114,7 +114,7 @@ public function doEnterNode(Node $node, Environment $env): Node | |
return $node; | ||
} | ||
|
||
public function doLeaveNode(Node $node, Environment $env): Node | ||
public function leaveNode(Node $node, Environment $env): Node | ||
{ | ||
return $node; | ||
} | ||
|
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
use Twig\Node\Expression\Binary\ConcatBinary; | ||
use Twig\Node\Expression\ConstantExpression; | ||
use Twig\Node\Node; | ||
use Twig\NodeVisitor\AbstractNodeVisitor; | ||
use Twig\NodeVisitor\NodeVisitorInterface; | ||
|
||
/** | ||
* Performs equivalence transformations on the AST to ensure that | ||
|
@@ -25,17 +25,17 @@ | |
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
final class NormalizingNodeVisitor extends AbstractNodeVisitor | ||
final class NormalizingNodeVisitor implements NodeVisitorInterface | ||
{ | ||
protected function doEnterNode(Node $node, Environment $env): Node | ||
public function enterNode(Node $node, Environment $env): Node | ||
{ | ||
return $node; | ||
} | ||
|
||
/** | ||
* @return ConstantExpression|Node | ||
*/ | ||
protected function doLeaveNode(Node $node, Environment $env): Node | ||
public function leaveNode(Node $node, Environment $env): Node | ||
{ | ||
if ($node instanceof ConcatBinary | ||
&& ($left = $node->getNode('left')) instanceof ConstantExpression | ||
|
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 |
---|---|---|
|
@@ -14,14 +14,14 @@ | |
use Twig\Environment; | ||
use Twig\Node\Expression\FilterExpression; | ||
use Twig\Node\Node; | ||
use Twig\NodeVisitor\AbstractNodeVisitor; | ||
use Twig\NodeVisitor\NodeVisitorInterface; | ||
|
||
/** | ||
* Removes translation metadata filters from the AST. | ||
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
final class RemovingNodeVisitor extends AbstractNodeVisitor | ||
final class RemovingNodeVisitor implements NodeVisitorInterface | ||
{ | ||
/** | ||
* @var bool | ||
|
@@ -33,7 +33,7 @@ public function setEnabled(bool $bool): void | |
$this->enabled = $bool; | ||
} | ||
|
||
protected function doEnterNode(Node $node, Environment $env): Node | ||
public function enterNode(Node $node, Environment $env): Node | ||
{ | ||
if ($this->enabled && $node instanceof FilterExpression) { | ||
$name = $node->getNode('filter')->getAttribute('value'); | ||
|
@@ -46,7 +46,7 @@ protected function doEnterNode(Node $node, Environment $env): Node | |
return $node; | ||
} | ||
|
||
protected function doLeaveNode(Node $node, Environment $env): Node | ||
public function leaveNode(Node $node, Environment $env): Node | ||
{ | ||
return $node; | ||
} | ||
|