A massive BC break

Have you tried a tool like PHPStan to help you with this? It’s not perfect, but it can save a lot of manual labour.

3 Likes

There is another tool called rector which can scan your code and suggest changes to support various PHP versions. In theory it can even make the changes. I have never been overly fond of the notion of letting some tool make automatic changes to my code but just having a list of suggested changes can be a big help.

1 Like

I have been lurking on this thread for some time and have concluded that the advice you are being given by @m_hutley and others have been spot on. You seem to be working off some premises that are not entirely sound and I thought I would clear up some misconceptions. Do know that I have over 25 years of experience as a programmer and have used PHP for nearly 18+ years in all sorts of environments including a codebase that is being used by a billion dollar tech company which utilizes PHP for some of it.

First of all, PHP has, for several years now, been moving the language away from its more problematic roots and is thus enhancing it. They are “evolving it”. Evolving can certainly mean taking away some features to increase the usability and enhance the language. m_hutley came up with the perfect example with the mysql_ functions. Couldn’t have been said better. Every language deprecates and removes features as it introduces and changes others. That is just a given in all languages (I should know, I regularly work in 12 of them).

Secondly, as general programming practice, you should NEVER be relying on a language to duck type your intentions as a regular rule. This leaves the interpreter to “guess” what you want to be done on its context and while this can be leveraged in spots, you are leaving yourself open to bugs. In short, in any programming language, you should know your types and be as explicit as possible. I am not saying duck typing is essentially bad, but if you are leaving user input or input from a database to determine what happens in an operation, you are playing with serious fire. It is half the reason other languages have chosen to be strongly typed to begin with.

Third, documentation. I find PHP documentation to actually be one of the best sources of documentation for any language I have ever used. They outline signatures, types, explore caveats, make notes of deprecation and upcoming breaking changes for a given version (usually in break out note boxes) and even return types. Python doesn’t even show return types in their documentation it is frustrating. Are they going to miss something every now and then? Sure, but usually it is corrected quickly. Just watch how often the documentation is updated (php docs are time stamped)

Fourth, languages change and those changes break things. Those of us around for PHP 4 to 5 saw many many breaking changes. Then we saw many more on PHP 5 to 7. There are more from PHP 7 to 8 and surely going to be more from PHP 8 to 9. The PHP working group communicates and discusses changes regularly and you can even contribute yourself. If you want to help redirect the conversation, get involved!

Lastly, as already mentioned, we know you are frustrated with having to make a lot of changes for features you think are just wacko or doesn’t fit with the spirit of the language. There are many tools mentioned that can certainly help. But know you don’t have to change these things overnight. PHP usually supports prior versions for a while and even some of the biggest platforms on the planet that use PHP (do keep in mind that PHP runs nearly a third of the net’s websites) usually sit back several versions. WordPress for instance recommends 7.4+. So you have time to make changes or change to another language. You will still find out that other languages introduce as many breaking changes regularly. Honestly, .NET is worse in my opinion. A framework developed by a company with their own goals and biases.

No need to come on a board like this and get yourself worked up. Sure it can suck when things change, but you have time, options and plenty of people here in this community that can assist you with great advice. Many of whom have been through multiple PHP version changes before.

:slight_smile:

6 Likes

If you are such a fan of strict typing then why did you choose to code in a language that didn’t have it? That sounds as sensible as visiting a Chinese restaurant and then complaining that they don’t serve pizza

You sound as if you only write programs that are use-once-then-throw-away. I doubt if you have ever written, or been involved in writing, a large application that has been maintained over several versions of PHP.

If you are a fan of strict typing then why did you choose PHP in the first place?

This thread has been threading the line for a while, but now that it’s gone full ad hominem I’ll just close it.

Thanks all for participating.

3 Likes