$country->getIso() is string|null, but I'm sure it is string - or at least I'm fine ignoring the unexpected case 🙈
Or do I neet to put it in a var to add a /**@var to it?
When using static analysers in PHP, a generic service as a Query Bus is usually a point of pain. In this post, we will see how to type-hint a Query Bus correctly.
I'm planning to add return types to interface methods in a #PHP library. Because of #BC I plan to do this in a next major release.
What's the best practice to document this return type change now, so the users of the library can add the return types now instead of waiting for the major release? Is there a recommended #phpdoc annotation? Or should I use the ReturnTypeWillChange attribute?
@omerida
I'm not talking about doing the actual changes, I'm only talking about informing the users about the future work. Not every user is reading the issues or project blog. And yes, at least #PHP will throw exceptions after users upgrades to v2 without making the changes.
But I would like to offer a FC layer so users are informed upfront by their IDE, #PHPStan or other tools as early as possible. The goal is to improve the upgrade path.
If you experienced a "generic type mysqli_result error" when using #phpstandba in combination with #phpstan v1.10.36 or v1.10.37 - I just published a new 0.2.79 release which compensates this incompatibility.
@ufried is talking about sustainability in IT at #unkonf.
This really reminds me of my main motiviation to improve performance in #opensource static analysis tooling like #phpstan and #rectorphp
„We expect this changes to considerably reduce the amount of energy used in CI pipelines. So that’s my take on saving the planet and don’t waste energy.“
If you want #phpstan to catch your nullability issues, you either need to be on level 8, or alternatively enable the "checkNullables" feature flag via config.
You should use the Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule #PHPStan rule to make sure class-definitions fit your composer defined namespace/folder structure.
Proper PSR4 is important for e.g. Rector/PHPStan/Deptrac to work properly.
It's so annoying that we can't pass Collection<Dog> into Collection<Animal>, unless @template is covariant.
But with @template-covariant T, we can't use T in a @param.
@jiripudil is on the verge of solving this with so-called type projections aka call-site variance. #phpstan
Setting up #PHPStorm to handle #PHPStan / #Larastan, Laravel Pint, Code Sniffer and CS_Fixer (not sure if this is needed with Laravel Pint). What is the best way to set this up so I don't have to set this up for every project? Tried to point to a globally installed version of each but wasn't able to easily do this.
Suggestions or a pointer to a tutorial would be fabuluous!