Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Is someone reading the data from the PHP file itself?
There are very care cases where introspection like that might be desired. Very very rare.
This one doesn't make much sense. It's the kind of thing you might see if you have to do something in one file and there's enough memory to parse it but not keep it in memory. -
Thats.. a bit weird, but not actually rare.
golang has a similar problem.
Say you want to include a dataset - Json, or protobuf format in your public OSS lib. But you can't do it directly - lang specs dictate libs are pure code. So.... you turn your dataset into a const in your code. byte arrays, or huge longass comments like this one. -
mirazmac4395y@RANTSMCPANTS Yeah but the list is not too long, probably 20 key => value paired data, one just could store the value in an array within the same class. Storing as comment and then parsing the file line by line and even caching seems overkill.
-
mirazmac4395y@pai-shinoda Yeah, I'm amazed that this library still works just fine with almost zero errors even with PHP7.
-
Quirinus7525yPHP supports embedding data (eg. some binary data) at the end, and even has some magic constants or functions for that.
I dont remember their names, but this guy is doing it wrong.
Not that I support the practice anyway, but it's there. -
mirazmac4395y@Quirinus I guess you're talking about the __halt_compiler(); function, but that is for binary data, this is is just key => value pair small enough to be stored in an array or a JSON file.
Related Rants
Recently for a project I needed to read/write ID3 tags from MP3 files. And after a long search, I found this bloated, monolithic but quite stable library, "getID3".
So, I was looking through the code-base and I found this. This guy literally storing the key value based data embedded as comments within the class file. Then wrote a method to parse the data and even used caching to ensure maximum speed! And such usage is repeated all over the code-base.
So, this is what people used do before arrays were invented :3
rant
php
getid3
legacy code