Skip to content

Commit

Permalink
Added deprecation warning for cell and element tags
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Apr 10, 2020
1 parent c65e158 commit 86fe1d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Twig/TokenParser/CellParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class CellParser extends IncludeTokenParser
*/
public function parse(Token $token): Node
{
static $warned = false;
if (!$warned) {
$warned = true;
deprecationWarning(
'`cell` and `element` tags are deprecated. Use `cell()` and `element()` functions instead.'
);
}

$stream = $this->parser->getStream();

$variable = null;
Expand Down
8 changes: 8 additions & 0 deletions src/Twig/TokenParser/ElementParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class ElementParser extends IncludeTokenParser
*/
public function parse(Token $token): Node
{
static $warned = false;
if (!$warned) {
$warned = true;
deprecationWarning(
'`cell` and `element` tags are deprecated. Use `cell()` and `element()` functions instead.'
);
}

$stream = $this->parser->getStream();
$name = $this->parser->getExpressionParser()->parseExpression();

Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase/View/TwigViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ public function testCellsShareTwig()
*/
public function testDeprecatedTags()
{
$output = $this->view->render('deprecated_tags', false);
$this->assertSame("<b>10</b>\nblog_entry", $output);
$this->deprecated(function () {
$output = $this->view->render('deprecated_tags', false);
$this->assertSame("<b>10</b>\nblog_entry", $output);
});
}

/**
Expand Down

0 comments on commit 86fe1d7

Please sign in to comment.