dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
487 stars 136 forks source link

Add mixed type hint for magic properties #443

Closed dakujem closed 1 year ago

dakujem commented 1 year ago

Description of the problem

While using Dibi with PhpStorm (the prevalent PHP IDE), I'm constantly being warned about using void where I should not. image

I'm pushed to either disable the inspection or suppress it for the given statement/block etc. image

But this inspection is useful and I do not wish to suppress it.

Solution of the problem

Instead, we can just add mixed return type-hint to the magic Row::__get method to "confuse" PhpStorm. image We can do this, because we are actually using Row magically without type safety so there is no sacrifice to make. With mixed as the return value type, PS accepts it can not infer the type of the property and stops complaining.

We can then omit the suppressions image

and we end up with clean code: image

We are still warned that we acces the properties using "magic" (Property accessed via magic method).

dg commented 1 year ago

thanks, fixed

dakujem commented 1 year ago

Hey, David, you closed this without merging to master. Not sure it was intentional. c8457ab58ad2a27863af2721f3bc590bb24045db does not close this PR, bud closes #444 instead. @dg

dg commented 1 year ago

It is in master as part of "coding standards" commit, because all methods should have types.

dakujem commented 1 year ago

yeah, that's better