And if it's not possible to coexist, than fork away. If you don't agree, fine, go and enable your strict validations for yourself, but please don't screw the rest of us. There is also high expectation you will manage to understand that we are not talking about "risky" or "bug prone" coding practices here, but we are defending a legitim vision which is the simple essence of the PHP language and that having to define every variable, array index, etc. There is high expectation this bad decision will be reverted or that a solution will be provided so we can coexist as a PHP community with one single codebase. But in the meantime, PHP can't wait around for you. Yes, you have to edit your code, and if you want to run old code on new software while knowing you can't afford to keep it up to date then I'm sorry you've decided to put yourself into that position. There are solutions available to you right now to deal with this new warning. Is there a belief that complaining about how legacy code from 10 years ago now runs with one more warning on modern PHP will accomplish some purpose? Is it PHP's responsibility to make sure that nobody has to change their code, even when they were observing risky and bug-prone practices? How long must it maintain compatibility with programming paradigms that date back to the '90s? Is there any point in continuing commenting on this issue? What's the goal of participating in this echo chamber? Is there an expectation that some some critical number of +1/-1 reactions will reverse a decision made and deployed more than 2 years ago in a new major version of the language? I'm going to ask some questions that I'm sure a lot of people are not going to like to hear: Really, it sounds like there's a lot of software out there that is just being plain neglected. One of the oldest software libraries in the world (it dates from the 1970s) was most recently updated last month there is always room for improvement. Only if the the outside world it interacts with never changes. What, introduced more powerful alternatives (the old functions couldn't fully access MySQL's functionality) ten years before officially deprecating the old functions, putting warning notices up that they will be removed, and then waiting two more years before removing them?Ĭome on, a code is written to last for ever, not re-writting it every few years, Like what happened when you removed the mysql commands. Now my code is broken and IT'S NOT MY FAULT. Then I was being told for three years that there is something wrong with my code that needed to be fixed but I still didn't do anything. I was told there might be something wrong with my code for twenty years, but I ignored it. It would be something likeĪnd would result in any undefined variable being treated as null, without emitting any error or warning, and would give instant backward-compatibility where needed, and solves the main motivation for the PHP9 pending change for the sake of the error-handling routines). $x++ would.Īdd a pragma or compiler directive, similar to Python 2's "from future import division". Treat a plain if() as allowing for undefined values. One would expect it to merely silence the warning, but it actually inverts the test, because the precedence is actually: E.g.īut without the logical inverse that makes for awkward readability.įix the precedence order to have = below ?.ĭoes not do what you expect. I can think of at least 4 compromise options that would help.Īdd a simple syntactic sugar for testing if a variable is truthy, without throwing an error. It may also be worth treating undefined variables the same way. To me, it seems sensible that a defined associative array, with a key that isn't present (and may not be expected), should not be a warning, especially if it's being tested for with if(). Ini_set ("error_reporting", E_ALL & ~E_NOTICE) Ini_set("array_key_missing_enotice", true) Instead, it would be better to have some sort of pragma in the main header Migrating and testing this code will take a long time, and furthermore, it's really ugly and harder to read: If ($_GET) #where xxx may or may not exist.Īnd in PHP8, we now get flooded with warnings "Undefined array key", which get in the way of real warnings. Rightly or wrongly, there are a lot of people, myself included, who have thousands of lines of code with things such as: This is now E_WARNING.Ĭan we please have a configuration option to put that back to E_NOTICE? In PHP 7, underfined array keys created E_NOTICE.
0 Comments
Leave a Reply. |