Modern PHP is far from its older versions. It has decent DI and web frameworks, type hinting, exceptions, namespaces, a reasonable dependency manager. It's not the insane choice for new projects it was even ten years ago.
Now if only it gained generics I would be almost happy to use it.
Generics have userland support. PHP Core has better things to spend developer time on than generics (which are already a thing implemented in userland).
You may do so, but static analysis and code quality tools are far more widespread than in Java.
From what I can see Java is lacking in this regard. There is no linter with autofix capabilities and CheckStyle is quite lackluster. In PHP you drop a 3 line XML in the root and you have checks for PSRs and autofixes for them. Much better experience.
You also have to consider that there aren't that many PHP Core devs and they really do have much better things to spend their time on than an already solved problem. Bolting generics onto the language is no easy feat.
You're not looking very hard, because there's a vast number of static analysis tools for Java. Checkstyle is not even a static analysis tool; it's a format checker.
That's findbugs/spotbugs, checker framework, Sonar, PMD, Errorprone and the tools built into IntelliJ and eclipse. Most of these tools are widely used and predate Psalm or phpstan by decades.
And it's not a solved problem. The usage of generic classes in PHP libraries is laughably small. And some PHP developers think that it should be in the language too. Nikita Popov started an implementation of the generics RFC last year.
Aside from the fact that /u/dpash has answered you, let me remind you that Java is a (moderately) strongly-typed static language. PHP is neither, and so, ipso facto, needs a lot more analysis tools not to mention testing.
29
u/dpash Apr 20 '21
Especially when it's based on an outdated opinion of the language.
PHP evokes the same reaction.