Skip to content

Commit

Permalink
Fix compile-time processing
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Aug 1, 2022
1 parent 10c689f commit 30d9225
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ parameters:
- Nette\MemberAccessException

ignoreErrors:
-
- # false positive
message: "#^Parameter \\#1 \\$value of method Generator\\<int,array\\|null,array\\<int, Latte\\\\Compiler\\\\Nodes\\\\AreaNode\\|Latte\\\\Compiler\\\\Tag\\|null\\>,Nepada\\\\Bridges\\\\TexyLatte\\\\TexyNode\\>\\:\\:send\\(\\) expects array\\{Latte\\\\Compiler\\\\Nodes\\\\AreaNode, Latte\\\\Compiler\\\\Tag\\|null\\}, mixed given\\.$#"
count: 1
path: src/Bridges/TexyLatte/TexyNode.php
- # false positive
message: "#^Instanceof between Nepada\\\\Bridges\\\\TexyLatte\\\\TexyNode and Nepada\\\\Bridges\\\\TexyLatte\\\\TexyNode will always evaluate to true\\.$#"
count: 1
path: src/Bridges/TexyLatte/TexyNode.php
4 changes: 3 additions & 1 deletion src/Bridges/TexyLatte/TexyNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public static function create(Tag $tag, TemplateParser $parser, callable $proces
$parent->current();
$parent->send(yield); // phpcs:ignore
$node = $parent->getReturn();
$node->tagName = $tag->name;
if ($node instanceof self) {
$node->tagName = $tag->name;
}
return $node;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Bridges/fixtures/tags.custom-mode.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

<p>Simple block…</p>

<p>Texy Block &lt;br&gt;</p>

<p>&lt;span title=„&lt;br&gt;“&gt;e­xample@example­.com &amp; <a
Expand Down
4 changes: 4 additions & 0 deletions tests/Bridges/fixtures/tags.custom-mode.latte
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{var $tag = '<br>'}

{texy}
Simple block...
{/texy}

{texy custom}
Texy Block {$tag}

Expand Down
2 changes: 2 additions & 0 deletions tests/Bridges/fixtures/tags.custom-mode.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
%A%source: %a%Bridges/fixtures/tags.custom-mode.latte%a%
%A%
<p>Simple block…</p>
%A%
%a%ob_start%a%
%A%
%a%Texy Block%a%
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridges/fixtures/tags.default-mode.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

<p>Simple block…</p>

<p>Texy Block<br>
</p>

Expand Down
4 changes: 4 additions & 0 deletions tests/Bridges/fixtures/tags.default-mode.latte
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{var $tag = '<br>'}

{texy}
Simple block...
{/texy}

{texy}
Texy Block {$tag}

Expand Down
2 changes: 2 additions & 0 deletions tests/Bridges/fixtures/tags.default-mode.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
%A%source: %a%Bridges/fixtures/tags.default-mode.latte%a%
%A%
<p>Simple block…</p>
%A%
%a%ob_start%a%
%A%
%a%Texy Block%a%
Expand Down

0 comments on commit 30d9225

Please sign in to comment.