Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static code analysis #1451

Open
borekb opened this issue May 17, 2019 · 2 comments
Open

Static code analysis #1451

borekb opened this issue May 17, 2019 · 2 comments
Assignees
Labels
scope: dev-infrastructure Build scripts, IDE settings, CI, Docker dev stack, testing, tooling, etc.
Milestone

Comments

@borekb
Copy link
Member

borekb commented May 17, 2019

During the past two years, I have spent most of my time in TypeScript and going back to PHP feels... not very pleasant to be honest. We can't do much about the language but we could modernize our codebase, for example, bump required version of PHP and use newer language features (#1408), or introduce more static checking.

We already have an issue about PHPStan – #1210 – however, I recently read this amazing article which discusses these tools:

It sparked my interest and I researched this area briefly. Here are the notes:

  • It's possible to use all three tools at once, as that article shows.
  • All three seem very good. Even using one of them would be a great benefit for VersionPress.
  • All have VSCode extensions. (Neither is supported directly in PhpStorm which probably isn't a surprise.)
  • I'm most inclined to use Psalm at this point because:
    • It has its own type hints like @psalm-param Closure(int):bool or @psalm-param 'Yes'|'No' which is awesome. (I believe that the tool needs to introduce some sort of its syntax because PHP & PHPDoc are not enough to describe the types properly.)
    • It's the most recent one so hopefully it learned from the others.
    • Has corporate backing (Vimeo).
    • Browsing Reddit while looking for for all three tools, there seem to positive sentiment around Psalm.
    • It can fix / update code.
  • Other tools I encountered during the research:

I plan to experiment with Psalm soon.

@borekb borekb added the scope: dev-infrastructure Build scripts, IDE settings, CI, Docker dev stack, testing, tooling, etc. label May 17, 2019
@borekb borekb added this to the 4.0 milestone May 17, 2019
@borekb borekb self-assigned this May 17, 2019
@borekb borekb mentioned this issue May 17, 2019
@borekb
Copy link
Member Author

borekb commented May 17, 2019

I have a hard time installing Psalm because we use some older libraries around Selenium which require older versions of PHPUnit which require a different version of phpdocumentor/reflection-docblock that what Psalm needs 😕.

That's bad because we can't easily upgrade. <Insert a rant here about how this wouldn't be a problem at all in JavaScript / npm, how I dislike the concept of classes, etc.>

I'm not sure how to resolve this. Psalm has a relatively long list of dependencies, as does any serious tool. Conflicts in versions are likely. What does the PHP world do in these situations?

@borekb
Copy link
Member Author

borekb commented May 19, 2019

This should be the solution:

https://github.com/bamarni/composer-bin-plugin

I hope it works reliably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: dev-infrastructure Build scripts, IDE settings, CI, Docker dev stack, testing, tooling, etc.
Projects
4.0-beta2 → 4.0-beta3
  
Awaiting triage
Development

No branches or pull requests

1 participant