Statistics based on packagist(composer)
https://stitcher.io/blog/php-version-stats-january-2024
Statistics based on web servers in the wild
`if ($a) { $previouslyUndefined = 2; } if ($previouslyUndefined) { echo "yeah"; }`
PHP still knows what $previouslyUndefined is or isn't at the second if statement, but it'll throw an error now in the first statement if you hadn't declared it outside the block. Why? Who cares? Scope in PHP is still understood to be inline, not in block; there is no equivalent to let vs var in JS. Stop telling me where I can check a variable if you're not enforcing various kinds of scope.
If $a is true, that snippet will just execute with no errors. If $a is false you'll get a warning trying to check $previouslyUndefined in the second if. That behavior's been the same for a very long time. The blocks don't matter for scope but the fact that you never executed the line that would have defined the variable does.
Similarly, warnings on accessing array keys that don't exist, that's been a thing forever too. Pretty sure both go back with the same behavior to PHP 4, and probably earlier.
I do, if I typoed previouslyUndefined the first time. I get it adds boilerplate, but it also catches stupid bugs