Schrank, to random
@Schrank@phpc.social avatar

Can I tell #phpstan which type a call has?

$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?

rubenrubiob, to php
@rubenrubiob@phpc.social avatar

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.

https://dev.to/rubenrubiob/type-hint-a-query-bus-in-php-3aik

#php #staticanalysis #phpstan #psalm #consultant #freelance

markusstaab, to random German
@markusstaab@phpc.social avatar

Just put togehter everything I know about the #phpstan result cache in a new blog post.

You will find a few usage examples and tipps about common pitfalls.

https://staabm.github.io/2023/10/21/phpstan-result-cache-gotchas.html

OndrejMirtes, to random
@OndrejMirtes@phpc.social avatar

assert() calls and inline @​var PHPDoc tags are usually just a crutch for bad design.

Try to prevent the problem instead, not react to it afterwards.

markusstaab, to github German
@markusstaab@phpc.social avatar

When running #PHPStan in #github #actions you might be interessted in the actions/cache/save@v3.

it persist your result cache even in failling builds so your next job/commit can work with it.

otherwise only successful jobs persist the result-cache.

https://github.com/actions/cache/tree/main/save#always-save-cache

markusstaab, to random German
@markusstaab@phpc.social avatar

todays #phpstan update contains a few memory consumption related improvements, which I was working on over the weekend.

art4, to php German
@art4@youthweb.social avatar

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?

#software #dev #Symfony #WebDev

art4,
@art4@youthweb.social avatar

@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.

markusstaab, to random German
@markusstaab@phpc.social avatar

If #phpstan is slow in analyzing your project, have a look at https://staabm.github.io/2022/12/23/phpstan-speedzember.html#how-to-find-slow-files-in-my-project which describes how to narrow the bottleneck

markusstaab, (edited ) to random German
@markusstaab@phpc.social avatar
markusstaab, to random German
@markusstaab@phpc.social avatar

#PHPStan is running a lot faster when it can utilize the result cache.

If you need to debug why the result cache is not used, you get more information as of 1.10.36+.

Run phpstan -vvv to get more info.

https://github.com/phpstan/phpstan-src/pull/2630

markusstaab, to random German
@markusstaab@phpc.social avatar

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.

markusstaab, to random German
@markusstaab@phpc.social avatar

In https://github.com/phpstan/phpstan-src/pull/2666 I am having a deep dive into #phpstan concept of variables-certainty... the goal is to improve detection of undefined variable vs. maybe undefined variable.

Its a side-quest which showed up while trying to improve !isset($array['xy']) in another PR.

markusstaab, to opensource German
@markusstaab@phpc.social avatar

@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.“

See https://staabm.github.io/2022/12/23/phpstan-speedzember.html

… or any other post in my #performance series https://staabm.github.io/archive.html#performance

markusstaab, to opensource German
@markusstaab@phpc.social avatar

thanks @getsentry for sponsoring my open source efforts.

since I am not on the payroll of e.g. #phpstan or #rector, I need sponsors like you, to be able to continously contribute to #opensource project

markusstaab, to random German
@markusstaab@phpc.social avatar

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.

https://phpstan.org/r/3cbc78a3-d4e3-4903-906a-a9399b66be46

markusstaab, to random German
@markusstaab@phpc.social avatar

For a few days I try to teach #phpstan the implications of the falsy-branch after isset().

The issue robot told me this will fix a few long standing open issues.

https://github.com/phpstan/phpstan-src/pull/2657

Fingers crossed this can be merged in the near future 🤞

markusstaab, to random German
@markusstaab@phpc.social avatar

These moments where fixing a single line in #PHPStan - targeted to fix a single bug - turns out better then initially expected 🥰

https://github.com/phpstan/phpstan-src/pull/2655

image/png

markusstaab, to random German
@markusstaab@phpc.social avatar

Another massive #PHPStan release ✌️

markusstaab, to random German
@markusstaab@phpc.social avatar

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.

https://github.com/symplify/phpstan-rules

markusstaab, to opensource German
@markusstaab@phpc.social avatar

I spent a big part of my sunday hunting down a memory and performance issue when testing #PHPStan rules with NodeScopeResolverTest in #phpunit reported in https://github.com/phpstan/phpstan/discussions/9914 by gnutix

if you see massive RAM/time used, try phpunit9 for now. Fix is under discussion.

#opensource

phpugdd, to random

Now on stage: @OndrejMirtes showing how to configure #PHPStan to maximum strictness at #PHPDD23

OndrejMirtes, to random
@OndrejMirtes@phpc.social avatar

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.

markusstaab, to opensource German
@markusstaab@phpc.social avatar

Since 2019 I contribute to #opensource #staticanalysis tooling.

450 PRs to #phpstan since june
265 PRs to #rectorphp since august

https://github.com/pulls?q=is%3Apr+author%3Astaabm+user%3Aphpstan
https://github.com/pulls?q=is%3Apr+author%3Astaabm+user%3Arectorphp

You should make sure I don't loose interest in saving your ass😜

https://github.com/sponsors/staabm

codito, to composer Polish
@codito@mas.to avatar

I am playing around with
SourceGraph's Batch Changes and it's a really great tool 🤩.

I was able to introduce into 19 repositories using one batch definition:

  • add package and helper scripts
  • add job
  • dump baseline
  • prepare changelog

💪😎

outofcontrol, to random
@outofcontrol@phpc.social avatar

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!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines