Skip to content

Commit

Permalink
Merge pull request #42 from cakephp/deprecation-warnings
Browse files Browse the repository at this point in the history
Added deprecation warning for cell and element tags
  • Loading branch information
othercorey committed Apr 11, 2020
2 parents 4e33d7e + aa10e66 commit 4f2a223
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Twig/TokenParser/CellParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class CellParser extends IncludeTokenParser
*/
public function parse(Token $token): Node
{
static $warned = false;
if (!$warned) {
$warned = true;
deprecationWarning('`cell` tag is deprecated. Use `cell()` function instead.');
}

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

$variable = null;
Expand Down
6 changes: 6 additions & 0 deletions src/Twig/TokenParser/ElementParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class ElementParser extends IncludeTokenParser
*/
public function parse(Token $token): Node
{
static $warned = false;
if (!$warned) {
$warned = true;
deprecationWarning('`element` tag is deprecated. Use `element()` function 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 @@ -160,8 +160,10 @@ public function testMarkdownExtensionCustom()
*/
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 4f2a223

Please sign in to comment.