-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #587 from grossmannmartin/mg-nodevisitor
Removed usage of deprecated AbstractNodeVisitor
- Loading branch information
Showing
5 changed files
with
21 additions
and
57 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 |
---|---|---|
|
@@ -29,7 +29,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 | ||
|
@@ -39,7 +39,7 @@ | |
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
class DefaultApplyingNodeVisitor extends AbstractNodeVisitor | ||
class DefaultApplyingNodeVisitor implements NodeVisitorInterface | ||
{ | ||
/** | ||
* @var bool | ||
|
@@ -51,10 +51,7 @@ public function setEnabled($bool) | |
$this->enabled = (bool) $bool; | ||
} | ||
|
||
/** | ||
* @return Node | ||
*/ | ||
public function doEnterNode(Node $node, Environment $env) | ||
public function enterNode(Node $node, Environment $env): Node | ||
{ | ||
if (!$this->enabled) { | ||
return $node; | ||
|
@@ -133,18 +130,12 @@ public function doEnterNode(Node $node, Environment $env) | |
return $node; | ||
} | ||
|
||
/** | ||
* @return Node | ||
*/ | ||
public function doLeaveNode(Node $node, Environment $env) | ||
public function leaveNode(Node $node, Environment $env): Node | ||
{ | ||
return $node; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getPriority() | ||
public function getPriority(): int | ||
{ | ||
return -2; | ||
} | ||
|
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 |
---|---|---|
|
@@ -24,7 +24,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 | ||
|
@@ -34,20 +34,14 @@ | |
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
class NormalizingNodeVisitor extends AbstractNodeVisitor | ||
class NormalizingNodeVisitor implements NodeVisitorInterface | ||
{ | ||
/** | ||
* @return Node | ||
*/ | ||
protected function doEnterNode(Node $node, Environment $env) | ||
public function enterNode(Node $node, Environment $env): Node | ||
{ | ||
return $node; | ||
} | ||
|
||
/** | ||
* @return ConstantExpression|Node | ||
*/ | ||
protected function doLeaveNode(Node $node, Environment $env) | ||
public function leaveNode(Node $node, Environment $env): Node | ||
{ | ||
if ( | ||
$node instanceof ConcatBinary | ||
|
@@ -60,10 +54,7 @@ protected function doLeaveNode(Node $node, Environment $env) | |
return $node; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getPriority() | ||
public function getPriority(): int | ||
{ | ||
return -3; | ||
} | ||
|
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 |
---|---|---|
|
@@ -23,14 +23,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]> | ||
*/ | ||
class RemovingNodeVisitor extends AbstractNodeVisitor | ||
class RemovingNodeVisitor implements NodeVisitorInterface | ||
{ | ||
/** | ||
* @var bool | ||
|
@@ -42,10 +42,7 @@ public function setEnabled($bool) | |
$this->enabled = (bool) $bool; | ||
} | ||
|
||
/** | ||
* @return Node | ||
*/ | ||
protected function doEnterNode(Node $node, Environment $env) | ||
public function enterNode(Node $node, Environment $env): Node | ||
{ | ||
if ($this->enabled && $node instanceof FilterExpression) { | ||
$name = $node->getNode('filter')->getAttribute('value'); | ||
|
@@ -58,18 +55,12 @@ protected function doEnterNode(Node $node, Environment $env) | |
return $node; | ||
} | ||
|
||
/** | ||
* @return Node | ||
*/ | ||
protected function doLeaveNode(Node $node, Environment $env) | ||
public function leaveNode(Node $node, Environment $env): Node | ||
{ | ||
return $node; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getPriority() | ||
public function getPriority(): int | ||
{ | ||
return -1; | ||
} | ||
|
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