You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code is executed in the class context of the view class and as you can see in the file, we try to typehint the class for $this. phpstan has been throwing errors for this when NOT using the fully namespaced class name. So when we have a use ...\HtmlView; statement for this at the top and then only reference the class as /** @var HtmlView $this */ in the layout, phpstan throws the error
Call to method ****** on an unknown class HtmlView.
Unfortunately I was unable to replicate this in the PHPStan playground. I thought it was related to the actual class, but when using the fully qualified name, it works fine. So /** @var \Joomla\Component\Actionlogs\Administrator\View\Actionlogs\HtmlView $this */ is fine with phpstan. The same typehint for any other variable also works fine, but using a different class name for $this again throws an error. So it seems that $this has a special handling which makes phpstan not understand the typehinting properly.
Code snippet that reproduces the problem
No response
Expected output
PHPStan should properly find the class.
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered:
Bug report
This is in part related to #7886.
First of all sorry for having issues to explain this properly. I'm a contributor to Joomla and our MVC system
include()
s layout files in the context of the view classes which only contain HTML and simple PHP. One example would be this: https://github.com/joomla/joomla-cms/blob/5.1-dev/administrator/components/com_actionlogs/tmpl/actionlogs/default.phpThe code is executed in the class context of the view class and as you can see in the file, we try to typehint the class for
$this
. phpstan has been throwing errors for this when NOT using the fully namespaced class name. So when we have ause ...\HtmlView;
statement for this at the top and then only reference the class as/** @var HtmlView $this */
in the layout, phpstan throws the errorUnfortunately I was unable to replicate this in the PHPStan playground. I thought it was related to the actual class, but when using the fully qualified name, it works fine. So
/** @var \Joomla\Component\Actionlogs\Administrator\View\Actionlogs\HtmlView $this */
is fine with phpstan. The same typehint for any other variable also works fine, but using a different class name for$this
again throws an error. So it seems that$this
has a special handling which makes phpstan not understand the typehinting properly.Code snippet that reproduces the problem
No response
Expected output
PHPStan should properly find the class.
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: