Skip to content

Commit e6b3ed4

Browse files
committed
UIMacros: modifiers are deprecated in {control}, {link} and {plink}
1 parent 9b0b6c8 commit e6b3ed4

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/Bridges/ApplicationLatte/UIMacros.php

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public function finalize()
8181
*/
8282
public function macroControl(MacroNode $node, PhpWriter $writer)
8383
{
84+
if ($node->modifiers) {
85+
trigger_error('Modifiers are deprecated in ' . $node->getNotation(), E_USER_DEPRECATED);
86+
}
8487
$words = $node->tokenizer->fetchWords();
8588
if (!$words) {
8689
throw new CompileException('Missing control name in {control}');
@@ -120,6 +123,9 @@ public function macroControl(MacroNode $node, PhpWriter $writer)
120123
*/
121124
public function macroLink(MacroNode $node, PhpWriter $writer)
122125
{
126+
if ($node->modifiers) {
127+
trigger_error('Modifiers are deprecated in ' . $node->getNotation(), E_USER_DEPRECATED);
128+
}
123129
$node->modifiers = preg_replace('#\|safeurl\s*(?=\||$)#Di', '', $node->modifiers);
124130
return $writer->using($node, $this->getCompiler())
125131
->write('echo %escape(%modify('
@@ -161,6 +167,9 @@ public function macroExtends(MacroNode $node, PhpWriter $writer)
161167
*/
162168
public function macroTemplatePrint(MacroNode $node)
163169
{
170+
if ($node->modifiers) {
171+
throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
172+
}
164173
$this->printTemplate = var_export($node->tokenizer->fetchWord() ?: null, true);
165174
}
166175
}

tests/Bridges.Latte/UIMacros.control.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ UIMacros::install($compiler);
1818

1919
// {control ...}
2020
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); ?>', $compiler->expandMacro('control', 'form', '')->openingCode);
21-
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); echo ($this->filters->filter)(%a%); ?>', $compiler->expandMacro('control', 'form', 'filter')->openingCode);
21+
@Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); echo ($this->filters->filter)(%a%); ?>', $compiler->expandMacro('control', 'form', 'filter')->openingCode); // @ deprecated
2222
Assert::match('<?php %a% if (is_object($form)) %a% else %a% $this->global->uiControl->getComponent($form); %a%->render(); ?>', $compiler->expandMacro('control', '$form', '')->openingCode);
2323
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType(); ?>', $compiler->expandMacro('control', 'form:type', '')->openingCode);
2424
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->{"render$type"}(); ?>', $compiler->expandMacro('control', 'form:$type', '')->openingCode);
2525
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType(\'param\'); ?>', $compiler->expandMacro('control', 'form:type param', '')->openingCode);
2626
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(array_merge([], $params, [])); ?>', $compiler->expandMacro('control', 'form (expand) $params', '')->openingCode);
2727
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType([\'param\' => 123]); ?>', $compiler->expandMacro('control', 'form:type param => 123', '')->openingCode);
2828
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType([\'param\' => 123]); ?>', $compiler->expandMacro('control', 'form:type, param => 123', '')->openingCode);
29-
Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); echo ($this->filters->striptags)(%a%); ?>', $compiler->expandMacro('control', 'form', 'striptags')->openingCode);
29+
@Assert::match('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); echo ($this->filters->striptags)(%a%); ?>', $compiler->expandMacro('control', 'form', 'striptags')->openingCode); // @ deprecated

tests/Bridges.Latte/UIMacros.link.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ UIMacros::install($compiler);
1919

2020
// {link ...}
2121
Assert::same('<?php echo $this->global->uiControl->link("p") ?>', $compiler->expandMacro('link', 'p', '')->openingCode);
22-
Assert::same('<?php echo ($this->filters->filter)($this->global->uiControl->link("p")) ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode);
22+
@Assert::same('<?php echo ($this->filters->filter)($this->global->uiControl->link("p")) ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode); // @ deprecated
2323
Assert::same('<?php echo $this->global->uiControl->link("p:a") ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode);
2424
Assert::same('<?php echo $this->global->uiControl->link($dest) ?>', $compiler->expandMacro('link', '$dest', '')->openingCode);
2525
Assert::same('<?php echo $this->global->uiControl->link($p:$a) ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode);

0 commit comments

Comments
 (0)