- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Except, of course, that you're adding extra code to allow for the case where everything that uses base64 is actually using your dodgy variant.
But in practice, it's more likely that some of the cases are using the dodgy version, and some are using the real thing. In which case you're going to have to patch half the code to use different functions anyway.
Admin
Really? You'd just update that function and assume that everything works? You wouldn't go searching the entire code base, in case someone has used the PHP standard library function instead of your wrapper?
Admin
Admin
I wouldn't call that WTF.. wrappers are often useful.
Admin
The WTF-ness of this article is debatable.
After all it is harmless, and some people just don't get it.
Admin
Admin
Frankly, I think a number of PHP's developers are getting fed up with having to support ancient mistakes on the grounds that too many people would spit the dummy if the mistakes were corrected.
Admin
Admin
Or maybe we could hold the function mapping in a 3rd-party ontology repository. Yeah, that would multiply the amount of crazy appropriately.
Admin
Not to mention inconsistently.
Admin
all I see in code is a wrapper for function that exist previously. who has not done this in programing life? i bet all of us are guilty at one point or another.
Admin
Better still, a function base64Encode with a second parameter "forward", e.g.
I've omitted the obvious bloat that should be added to increase the SLOC significantly (e.g. like the code I've posted earlier).
Maybe the $forward parameter should be set to false by default. Just to spice things up a little.
Admin
Admin
Admin
How do people not think that this is a WTF?
Nothing like coding or designing for problems that may or may not exist in the future. I'm in full agreement with the comment that has the world spinning function.
Create for wrapper after the depreciation. Sure you may have have to do a large number of swaps but that is dothing compared to wrapping every funtion (and remembering to use the correct wrapper every time).
Admin
Actually in PHP it's not entirely a bad idea... the problem being that register_globals, that old chesnut of evil, had variables magically appearing as if from nowhere, and with data in them.
Now admittedly, I'd have returned directly instead of mapping to a variable.
Interestingly, assignment via a ternary operator is slower than defaulting a variable, then doing a check for correct data, then assigning the variable if there is some. It might be 4 times the amount of code, but from a performance standpoint it wins.
Admin
Admin
Shield-stealing piles of shit!
Admin
And which is the One True Base64? The one originally formalized by RFC 989 (now deprecated), its revised form as found in RFC 1421, or one of the variants described in current RFCs 2045, 3548, or 4648?
Or one of a dozen other ad-hoc variants on the scheme that are also in common use?
(For what it's worth, PHP's native implementation is of the MIME variant from RFC 2045.)
Admin
You are correct
Fixed?
Admin
Admin
At least they can't have 10 problems.
Admin
They can, check again. But a less ambiguous version of the regex would be
/^[1-9]\d*$/
Admin
I think this conversation just goes to show why the "Now they have 2 problems" quote exists.
Admin
Sssshhh. That extra + was a trap for people who only think they know regex.
Admin
Admin
Actually I had to do similar thing in my project: I wrapped several built-in functions into a singleton class which I called Builtins.
The reason was I wanted to write unit tests, which is quite difficult with PHPUnit which does not allow you to mock library functions.
Eventually we found some different project which claimed to be able to mock global functions, but it also didn't alow to mess with builtins.
We also tried runkit library, and ... well, do I have to justify that? Actually I'd rather here "designers" of PHP language why did they put all these unreleated functions with different conventions and purposes into single global scope. Of course the quick answer is: because namespaces and Objects were introduced several years after PHP was born. But the real question is: how come that in the XXI century someone created a language which is not object oriented (nor functional, nor modular, nor ...)..
Admin
Shhhh. Your reasoning is ruining the fun of everyone who ragged on me for thinking this is not a WTF.
Admin
Or: if Matt Westwood gives geoffrey or Bob's retard son a "good kicking", from the point of view of both the victims the outcome is far from good ...
Admin
Why no complains about no new article yet?
Maybe here needs change name to NotNecerilyDailyWTF.com
Admin
Who are you to criticize me for being judgemental? That's very intolerant of you. If I want to be judgemental, that's just how I am.
Admin
Yes, creating wrappers for functions to implement a naming convention that you prefer to the one used by the library authors is a great idea! It improves readability and consistency.
But ... what if some members of your staff have different preferences for naming conventoins? What the programmer should really have done is made several sets of wrappers, one for each naming style he could think of. Like:
Then everyone can use their favorite naming convention and everything works! Plus, if Al wants to use a different encoding function than Sally, he can just pick one of parallel functions and change the implementation.
Admin
And of course, the XML file should be stored on a different computer, and you create a SOAP interface to communicate with it, so that if there are changes, you don't even have to modify data on the production server!
I would quibble that creating the XML from an Excel spreadsheet is not very enterprisey. You really should generate it from a UML diagram.
captcha: "aptent" A temporary canvas building used to store application install CDs.
Admin
I wonder WhyTF I keep coming here. This is the 3rd time today that I peeked hoping I would find my fcuking DAILY serving of WTF article, and not a fcuking thing. Alex, you suck.
Admin
By the way, tangential to debating the wisdom of the coding style, but: "seemingly a nice guy at first, but really just a phony"
So ... "I thought he was a nice person, but it turned out that he really wrote poor PHP code." How does that make him a "phony"? Do you mean that "nice guys" always write good PHP code? That people who write bad PHP are inherently rude?
I thought this was a web site about bad programming, but it turns out it really has a gray background.
Admin
Nice guys are considerate of others. By writing PHP code, (I'll assume you were attempting humor with "good PHP") a person is perpetuating a tool of torment to those who must follow them in maintaining whatever code base they've created. Therefore, yes, people who write PHP (I'll assume you were just being redundant with "bad PHP") are inherently rude.
Admin
I WISH I COULD MAKE THIS TEXT BIGGER.
Admin
Admin
Internally, yes.
But in another way, your code is now LESS consistent, because you're now using a different name for the function than the rest of the PHP-writing world, including language references like php.net.
Admin
It seems to have gone unmentioned that the predecessor chose to call the formal parameter to his base64Decode ..
?Methinks he didn't quite understand what base64 is for, even.
Admin
This is pointless. Anyone can sed -i through the code and replace it in the future if for some reason they need to.
Admin
PHP -- In the upgrade to 5 they made array_merge require both paramaters to be arrays, instead of automatically converting as it had previously. I had the job of going through our codebase on my project and changing array_merge( $param1, $param2 ) to array_merge( (array)$param1, $param2 ) in the cases where $param could have been something besides an array.
Admin
Listen, dick... this site makes money off of my coming here. I expect to be paid in fucking articles that are published as frequently as suggested by site name. If he doesn't make money running this, then shut it the fuck down: he obviously lost enthusiasm finding and publishing stories, cause they such big time lately.
Admin
SUCH = SUCK
Admin
Man you did not finished your PHP lessons, do you ?
PHP natively supports variadic arguments, see the doc for func_get_args().
And by the way, what you are writing already exists, is called http://php.net/manual/en/function.call-user-func.php
"Calls the callback given by the first parameter and passes the remaining parameters as arguments."
Do not even attempt to beat PHP weirdnes ... you won't be able to.
PHP implements all your WTFs natively.
"All your WTFs are belong to us", is the new PHP5 motto. Ever heard of "variable variables" ?
Admin
The inconsistent naming is something you just have to get used to. PHP wraps a lot of C and C++, some of it probably comes from there.
Wrapping base64 seems a bit pointless. I have wrapped things before, occasionally misguided but usually fruitful. For example, you wouldn't want to not wrap the mail() function with your own.
Admin
Admin
Admin
Admin
omg you are so hilarious
get a life... for real