- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- There's No Place Like
- Lucky Penny
- Mike's Job Search Job
- Teamwork
- Cuts Like a Knife
- Charge Me
- Que Sera, Sera
- Hot Dog
-
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
It should probably return FILE_NOT_FOUND, though
Admin
Depends. It might be used in calls to a function that takes some sort of predicate-callback as a parameter. Perhaps that indicates that there should be two versions of this hypothetical function, one that takes a predicate and one that takes no predicate but simply buttumes that the predicate-driven decision is always the "true" branch of the implied if(). (But that has a strong possibility of violating DRY / introducing duplicated code.)
So, we don't have enough information in the article to decide if this is really a WTF.
Admin
Yeah. If it's useful at all, it goes along with some sort of function that takes a plug-in filter expression. This is the plug-in for "no filtration; pass every record"
Admin
Also it could be called by reflection which constructs the name - it might otherwise construct isCurrency, isBirthday or anything else. Providing the isAnything function avoids having a special case if-then-else.
Admin
It looks like "null" (or "nothing" or whatever it is called here) also counts as "anything"
Admin
It does answer the question "Is anything really true?".
Admin
LOL. You can say it is philosophically correct.
Admin
Makes perfect sense. You can do tests for objects and for data types. But this will tell us if it's ANYTHING!
I'd really like to know what calls this -- or if it's ever called at all.
Admin
The submitter is simply not up to the submission.
Admin
This is probably in a library with other functions like isInteger, isString, isNumber, isNothing, isNull, isObject, etc... and at some stupid brainstorming session someone threw this in there. Probably a senior dev having a brain-fart and the junior dev tasked with implementing it just went ahead and did it.
Admin
More likely isBusinessObjectType1, isBusinessObjectType2, etc., and this one is, perhaps, more correctly "isAnyBusinessObject", for the purposes of filtering e.g. database results (as I noted above).
Admin
The tricky part is knowing when to use its peer function,
isSomething
...Admin
My kids used to play a variant of "Rock, Paper Scissors" which they called "Anything, Anything, Anything" (which by the way, nothing tops a Black Hole), so maybe that's what it's for?
Admin
Agreeing that it could be used as a callback. I once wrote a routine that printed the results in a rather convoluted format, and was factored so that it accepted 5 SQL cursors (the routine was used for multiple reports).
For reports where there were less than 5 output types I created cursors like these (I know I'm going to get the formatting wrong. Apologies in advance):
SELECT
NULL, NULL as STRING, NULL as DATE, NULL as DATE, NULL as DATE
FROM DUAL
WHERE 1=2
Admin
GP: Is Eris true? M2: Everything is true. GP: Even false things? M2: Even false things are true. GP: How can that be? M2: I don't know man, I didn't do it.
Admin
*led
Admin
Count me amongst those who think this is a perfectly ordinary match-everything filter to be passed to something that expects a filter.
Edit Admin
The real WTF is PHP.
Admin
if (isAnything(outThere)) say(something);
Admin
Yes, yes, PHP bad. Some day people will get some new material maybe :p
You can find a bunch of reasons why any language you dislike sucks. Or hell anything for us matter. Don't like mozzarella? There's probably some blog article you can Google that very convincingly lays out to others why mozzarella is the devil
Anyway, modern PHP improved a lot on past versions
Edit Admin
Oh that quote is from... Hmmm. I had to look it up and it was totally worth it: https://www.cs.cmu.edu/~tilt/principia/body.html
Admin
Not sure why static is being described as "most correct" here - if this were an implementation of an interface, it (potentially) wouldn't be controversial, barring the fact that the name is rather poor
Admin
I did this once. It replaced some useless code written by outsourcees that ran terribly. The client's GitHub actions, which no-one we could contact had the power to change, assumed that some code would be there, be over 80% covered by unit tests, and that these tests would pass.
I would have left the code as-is and just never used it, but the unit tests didn't pass even before we joined the project.
With functions like this, 80% coverage is an easy target