4 ms·
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.
by cynicalsecurity 3y ago
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.
- jw1224 3y agoAfter 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!
- nolok 3y agoEspecially 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.
- gorm 3y agoYou 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.
- dns_snek 3y agoWhat's the significance of $data in PHP?
- hennell 3y agoNothing special, just it's hardly a rare name for a variable. And this sets it globally.
- manbitesdog 3y ago...inside a namespace called Oink
- jw1224 3y agoFrom 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.
- onli 3y agoWordPress 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...
- throwaway11205 3y agoThe Java EE-like OOP mess of later years is no better.
- nolok 3y agoIt 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".