What's really crazy to think about is how much flak Java took for YEARS upon YEARS from a rather non-trivial number of developers, managers, and media. It was ruthless at times. Looking back, it was pathetic. Now, all of a sudden, look at where we are. We're seeing all these not-Java languages looking more and more like Java, and conversely Java starting to impersonate the not-Javas. Weird. You have to give the team behind Java credit for pushing forward in spite of this. There's a real lesson to be learned here.
I don't understand why people say PHP is like Java. There's very little in common between the two. Because PHP has types? Lots of languages have types.
Why in the world are people comparing PHP and Java?
I think it's mostly because of PHP frameworks. From my experience with PHP (and, admittedly, not very much experience with Java), I got the impression that a lot of the PHP Framework developers read all the "state-of-the-art" Java literature on how you should build software and then they implemented that in PHP.
They just ignored the fact that Java is compiled which makes all the layers of abstraction less of an issue whereas PHP is interpreted at runtime* hence why there are few high traffic websites on PHP that don't have at least four layers of caching.
* Yes, I know this is getting better with every version, opcache getting a lot of attention in the last few minor releases and all that, but there is only so much optimization you can do with dozens and dozens of layers of factories and services. My guess is that it does a LOT more for "simple" software like WordPress and less for, say, Symfony based projects.
It somewhat ends up in a best of both world scenario though. Java 15 years ago (in my opinion) was so strict and rigid and abstract interface jokes were writing themselves in real life. PHP was in a fairly dark (though very lively) place as well.
Here we get a pretty good deal, I guess time matters.