Question about settings #7964
-
I have the following loop (this is for loading the relationships of specific models): foreach($this as $order) {
/** @var Order $order */
$order->load('merchant');
$order->load('payments');
} Whenever I run the fixer, it updates to this: foreach ($this as $order) {
// @var Order $order
$order->load('merchant');
$order->load('payments');
} What can I do to keep the doc block as is? After running the fixer and then running phpstan errors (can't call load() on mixed). Thanks for the help! |
Beta Was this translation helpful? Give feedback.
Answered by
Wirone
Apr 22, 2024
Replies: 1 comment 1 reply
-
You should provide proper internal types to the class that you iterate over, so type of the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Wirone
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should provide proper internal types to the class that you iterate over, so type of the
$order
is inferred automatically, and known to IDE and PHPStan. It probably requires some generics and other stuff. In general, the@var Order $order
should not be needed there. It's more about your code's architecture than Fixer config.