News for hackers. Stuff that matters.
Re: by cynicalsecurity on Wednesday February 14, 2024 @03:55AM (#39367923)
Please god no. People might think this is what PHP looks like in real life while it's far from the good practices that are normally used in PHP since ages.
Re: by jw1224 on Wednesday February 14, 2024 @04:12AM (#39368036)
After 15 years of PHP this is the first and only time I’ve ever seen someone actually use the “global” keyword. And to hijack $data, of all the variables you could choose…

> This library prioritizes development speed and simplicity over everything else, including best practices and standards.

Oh. At least we were warned!

Re: by nolok on Wednesday February 14, 2024 @05:24AM (#39368356)
Especially since it makes zero sense to do that. If you don't care about niceties and want to have a global variable without the absolute php-3 era failure prone jank just use a class static or hell even a function static or whatever. There is no reason whatsoever to use a global variable like that, hasn't been since ... decades now ? And then to name it data on top of it.
Re: by gorm on Wednesday February 14, 2024 @09:32AM (#39370174)
You are right, but for a project like this, with a name like this, it's rather artful and hacky. Nothing wrong in breaking the rules if you know what you are doing.
Re: by dns_snek on Wednesday February 14, 2024 @06:45AM (#39368760)
What's the significance of $data in PHP?
Re: by hennell on Wednesday February 14, 2024 @07:12AM (#39368952)
Nothing special, just it's hardly a rare name for a variable. And this sets it globally.
Re: by juancroldan on Wednesday February 14, 2024 @01:20PM (#39373189)
...inside a namespace called Oink
Re: by jw1224 on Wednesday February 14, 2024 @03:03PM (#39374515)
From the docs:

> Although any valid PHP code can be contained within a namespace, only four types of code are affected by namespaces: classes, interfaces, functions and constants.

Re: by onli on Wednesday February 14, 2024 @06:49AM (#39368805)
WordPress is the most relevant of all php projects and uses global. In 15 years I would have expected a php developer to at least have a look into the code base of the biggest project of that language...
Re: by throwaway11205 on Wednesday February 14, 2024 @04:41AM (#39368175)
The Java EE-like OOP mess of later years is no better.
Re: by nolok on Wednesday February 14, 2024 @05:28AM (#39368374)
It was sort of necessary for PHP renaissance, to clean up the act, but it's also "not PHP" as-in why bother using PHP if you're going to do it that way, I feel like. The whole joy of PHP is the magic of it just works coupled with a super short path from prototype to prod, but before the component-model that's now the norm and the language clean up it meant a lot of crap foundations. Wordpress is still here to attest to that.

That's why Symfony rose above, and why Laravel is taking over. Laravel is essentially "let's do a code igniter 2 but on top of symfony clean design this time".