Stan will check your PHP code before you run it

PHPStan is a static analysis tool for PHP

What it currently checks for?

  • Existence of classes used in instanceof, catch, typehints and other language constructs. PHP does not check this and just stays instead, rendering the surrounded code unused.
  • Existence and accessibility of called methods and functions. It also checks the number of passed arguments.
  • Whether a method returns the same type it declares to return.
  • Existence and visibility of accessed properties. It will also point out if a different type from the declared one is assigned to the property.
  • Correct number of parameters passed to sprintf/printf calls based on format strings.
  • Existence of variables while respecting scopes of branches and loops.
  • Useless casting like (string) ‘foo’ and strict comparisons (=== and !==) with different types as operands which always result in false.

The list is growing with every release. But it’s not the only thing that makes PHPStan useful.

2 Likes

So, it’s kind of like “lint” for PHP?

1 Like

lol I was literally going to post this. It basically is.

That title just scared the crap out of me! LOL

14 Likes

Well, we’re waiting here.

1 Like

STAN I LEFT THE STACK OF PAPERS ON YOUR DESK. if you could grade the php code before end of semester i’d appreciate it.

4 Likes

this seems nice but i really just want a button in my visual studio that runs this for me. sigh always behind on making stuff

I thought the same thing. Stan has time to check everyone’s PHP? Wow how generous.:grinning:

2 Likes

Stan, fix my code, its borked.

1 Like

sudo make -a sandwich

2 Likes

I might have said …

sudo make $(me) -a sandwich ■■■■■

haha :smiley:

Reminds me of my favorite Justice League quote (fictitious) Superman to Aquaman, “Go make me a tuna fish sandwich?” Do you really have to be root to make a sandwich?

4 Likes

I thought you meant @StanSimmons… glad to see you meant something else!