Could you perchance think of an example where this would be necessary?
There are times when killing the stack is intended. It doesn't have to be "null" per se - but something that resolves to false in a PHP boolean context.
One example (off the top of my head) would be "userCan". Say you're writing an extension that's supposed to limit access to something. It may be your extension's intent to set the $result to false and then actually return false so no other more lenient extension has a chance to display the protected resource.
There are other cases I've run into, but I'd have to look in the codebase for them. Pretty much whereever you see something like this:
if ( !wfRunHooks( 'SomethingOrOther', array( &$this, &anotherThing ) ) { // whatever }
Tends to indicate a case where an extension might rightly choose to return false on purpose.
-- Jim
On 6/20/07, Daniel Cannon cannon.danielc@gmail.com wrote:
On 6/20/07, Jim Wilson wilson.jim.r@gmail.com wrote:
Since not returning anything in PHP is equivalent (more or less) to returning null, is there any concern that the extension writer's intent was to do so? Or is this simply a massive case of forgotten "return true" statements?
I believe it's "simply a massive case of forgotten 'return true' statements."
I totally agree that the the forgetting of return true is a big problem -
I've done it myself. I'm just not fully convinced that throwing a full stop is the best answer. (I'd like to hear what others think on the matter).
Personally, I find this to be a good solution. I've lately become quite used to fail-fast languages such as java, and I've found that such eager exception throwing *really* helps you to not make such simple mistakes that result in hours of debugging. It's much better to have something explode on you than have programs that pretend to work, but with subtle and hard-to-find bugs.
I frankly can't think of a situation where someone would *need* to return null--at least, I've not seen a case of it yet; I'm sure in cases where you want to return null, you can get by fine with returning true. Could you perchance think of an example where this would be necessary?
-- Daniel Cannon (AmiDaniel)
http://amidaniel.com cannon.danielc@gmail.com _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l