Page 2 of 2
Posted: Thu Mar 29, 2007 5:09 am
by Jenk
d11wtq wrote:When you don't pass args to the public constructor PHP only generates E_WARNING. Trying to access private members if E_FATAL.
* snip *
SimpleTest swallows those warning though probably.
SimpleTest does take in those errors, but doesn't swallow unless I include the expectError()'s (or use the deprecated swallowErrors() )
My point/request is just that - the error level should be, imo, E_FATAL, not E_WARNING

Posted: Thu Mar 29, 2007 5:49 am
by Chris Corbyn
PHP can use "null" as the value, just like when you try to echo $foo before it's created. That's why it's not fatal. Wrong functions names, or acess to private members on the other hand means quite simply that PHP cannot let you do what you want because there's nothing for it to call.
Posted: Thu Mar 29, 2007 6:07 am
by Jenk
Yes, I can see that, but why do we have:
if we can still just ignore required params which will have a default of null?
I'm influenced by just about every other language I've used I guess.. if the constructor (or any method/function) does not fit both the name, parameters, and state (static/not static) it dies, where as PHP is the only one to not die.

Ergo the parameters and state declaration are just as important as the access declaration.
Posted: Thu Mar 29, 2007 7:15 am
by Chris Corbyn
Because it's "wrong" to ignore the required params, but PHP being loosely typed can just set null, but not quietly. Other languages are more strictly typed (I'm going to assume you refer to java) and wouldn't physically work if you don't pass args, because as you know, the parameters are actually part of the method signature. In PHP, the method signature is just its name.
Posted: Thu Mar 29, 2007 7:33 am
by Jenk
Not just Java, SmallTalk, VB, C based languages etc. too
