Complete analysis of PHP code generated from Latte template
use Nette\Application\UI\Control;
class SomeClass extends Control
{
public function render()
{
$this->template->render(__DIR__ . '/some_control.latte', [
'some_type' => new SomeType
]);
}
}
// some_control.latte
{$some_type->missingMethod()}
❌
use Nette\Application\UI\Control;
class SomeClass extends Control
{
public function render()
{
$this->template->render(__DIR__ . '/some_control.latte', [
'some_type' => new SomeType
]);
}
}
// some_control.latte
{$some_type->existingMethod()}
👍
Passed "%s" variable that are not used in the template
use Nette\Application\UI\Control;
final class SomeControl extends Control
{
public function render()
{
$this->template->render(__DIR__ . '/some_file.latte');
}
}
// some_file.latte
{$usedValue}
❌
use Nette\Application\UI\Control;
final class SomeControl extends Control
{
public function render()
{
$this->template->render(__DIR__ . '/some_file.latte', [
'usedValue' => 'value'
]);
}
}
// some_file.latte
{$usedValue}
👍
Extra variables "%s" are passed to the template but never used there
use Nette\Application\UI\Control;
final class SomeControl extends Control
{
public function render()
{
$this->template->render(__DIR__ . '/some_file.latte');
}
}
❌
use Nette\Application\UI\Control;
final class SomeControl extends Control
{
public function render()
{
$this->template->render(__DIR__ . '/some_file.latte', [
'never_used_in_template' => 'value',
]);
}
}
👍