-
Notifications
You must be signed in to change notification settings - Fork 27
Description
I may try to pick this up in the future, but at the time of writing I don't have the faintest notion where to begin with this - and in the case of phtml
files, I'm not even sure it's possible.
For larger phpstan levels, it would be great if it understood the types of magic methods being called off of blocks based on how they're defined in layout.xml files.
As Examples:
<block class="Example\Module\Block\Example">
<arguments>
<argument name="sample_attribute" xsi:type="string">exValue</argument>
</arguments>
</block>
<!-- ... some other xml file -->
<block class="Example\Module\Block\Example">
<arguments>
<argument name="sample_attribute" xsi:type="object">Example\Module\ViewModel\Example</argument>
</arguments>
</block>
In this scenario, I think it'd be desirable for the signature of Example\Module\Block\Example::getSampleAttribute
to return null|string|\Example\Module\ViewModel\Example
If it were possible, it'd be great to limit this further by which attributes might exist in the template
being checked, e.g.
<block template="view.phtml">
<arguments>
<argument name="example" xsi:type="string">value</argument>
</arguments>
</block>
<block template="checkout.phtml">
<arguments>
<argument name="example" xsi:type="object">Example\Module\ViewModel\Example</argument>
</arguments>
</block>
If phpstan
was checking view.phtml
, it would know that getExample()
returns string
and in checkout.phtml
it would know that getExample
returns Example\Module\ViewModel\Example
but I doubt that's currently possible.