Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Less strict version of NoMixed* #4567

Open
dereuromark opened this issue Nov 23, 2023 · 0 comments
Open

Less strict version of NoMixed* #4567

dereuromark opened this issue Nov 23, 2023 · 0 comments

Comments

@dereuromark
Copy link
Contributor

dereuromark commented Nov 23, 2023

I ran them as per https://tomasvotruba.com/blog/not-all-mixed-types-are-equally-useless/

Is there a less strict version of the NoMixed rules?

rules:
    - Symplify\PHPStanRules\Rules\Explicit\NoMixedPropertyFetcherRule
    - Symplify\PHPStanRules\Rules\Explicit\NoMixedMethodCallerRule

They find like 600 issues in a smaller app.

Some seem to be false positive and otherwise not an issue for PHPStan as a whole.

Example:

        $order = $this->Orders->newEmptyEntity();     

Those appear to be fine for PHPStan, as Orders is resolved as

 * @property \App\Model\Table\OrdersTable&\Cake\ORM\Association\BelongsTo $Orders

on the class itself, which then in return resolves newEmptyEntity() on that OrdersTable:

 * @method \App\Model\Entity\Order newEmptyEntity()

It errors with

  380    Anonymous variables in a "$order->..." property fetch can lead to false dead property. Make sure the variable type is known 

But it is clickable, and resolves properly through the Order docblock:

 * @property int|null $user_id

So it would be more interesting to us to find the actual "undefined" objects where we call property/method on.
As those are prio to be fixed.

So maybe some param to make it only fail for actual missing ones, and assume the docblocks to be "acceptable" as the defined type?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant