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
As you know, a zend-mvc view has fields that __get can return, used like this:
$page = $this->getView()->page;
PHPStan says Access to an undefined property which makes sense. Ondre recommends a @property above the class, which doesn't work in this case, because I don't own PhpRenderer.php
Before I trudge down the PropertiesClassReflectionExtension path, have you done any work on this, or do you have an easier solution?
The text was updated successfully, but these errors were encountered:
I've never used View specific attributes outside templates, as I consider it a smell of bad design.
By the way, there would be no solution to what you're trying to accomplish: view properties depend on runtime behaviors, and PHPStan can not and should not know runtime behaviors.
I suggest something like:
$view = $this->getView();
\Webmozart\Assert\Assert::true(isset($view->page));
// Or better$page = $view->vars('page');
\Webmozart\Assert\Assert::notNull($page);
This is legacy code, and while I'm taking full ownership, there are still a few bad practices I haven't spotted, so thanks.
This is in a view helper, though, so does that change whether or not it's a smell to you? The view property is part of the model, and the view helper needs to pull some things from that.
By the way, there would be no solution to what you're trying to accomplish
Couldn't a one-off, project-specific extension say, effectively, "if you do see this magic __get call, assume it's this type"?
As you know, a zend-mvc view has fields that
__get
can return, used like this:PHPStan says
Access to an undefined property
which makes sense.Ondre recommends a
@property
above the class, which doesn't work in this case, because I don't ownPhpRenderer.php
Before I trudge down the
PropertiesClassReflectionExtension
path, have you done any work on this, or do you have an easier solution?The text was updated successfully, but these errors were encountered: