2 ms·
I know. The question in this case is, why am I doing ridiculously stupid things in PHP? Why am I using static methods as an excuse for namespacing? The answer
by rmccue 13y ago
I know.
The question in this case is, why am I doing ridiculously stupid things in PHP? Why am I using static methods as an excuse for namespacing?
The answer is backwards compatibility. Requests has to work on the majority of hosts out there, which includes PHP 5.2. Namespaces were only introduced in PHP 5.3, so I can't make use of them (although I wish I could). If this was written for new, modern versions of PHP, there would be a lot of changes.
The same would be true for any interpreted language: you have to aim for the lowest common denominator with widely distributable software. I'm sure there are Python developers out there who've been itching to use Python 3 features for ages, but it's only just becoming viable to do so.
As for the flatten bit, it's turning an associative array into a positional array by concatenating the key and value as per RFC2616, which I can't really fit in a function name. To be honest, I didn't put a lot of thought into that function since it's for internal use only anyway. I'd love to hear any other things that bother you though.
Also, thanks to those defending my code in the comments, but suffice to say it's not perfect.