efabrica-team / phpstan-latte

PHPStan extension to check compiled latte templates
MIT License
43 stars 4 forks source link

Standalone presenter action template is not analysed if presenter dir and template dir are siblings #442

Closed lulco closed 1 year ago

MartinMystikJonas commented 1 year ago

Does this even work in Nette? I think action templates should be in same folder as presenter or in templates sub-folder. Or does it work for different locations too?

lulco commented 1 year ago

I have project with structure:

presenters
  FooPresenter.php
templates
  Foo
    add.latte
    default.latte

and it seems working. I have to check if this is standard way in nette

lulco commented 1 year ago

I think this code block is responsible for it:

 $dir = is_dir("$dir/templates") ? $dir : dirname($dir);

        $templateFileCandidates = [
            $dir . '/templates/' . $presenterName . '/' . $actionName . '.latte',
            $dir . '/templates/' . $presenterName . '.' . $actionName . '.latte',
        ];

This is from our extension but I copied it from Nette.

lulco commented 1 year ago

https://github.com/nette/application/blob/40977525fa022c65cbe582f18ad0b12e9ad34dfb/src/Application/UI/Presenter.php#L545