Re: Re: Exceptions instead of Fatal Error when calling non existent method?

From: Date: Mon, 31 Dec 2007 12:48:52 +0000
Subject: Re: Re: Exceptions instead of Fatal Error when calling non existent method?
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-34297@lists.php.net to get a copy of this message
On 31.12.2007 15:09, Fredrik Holmström wrote: >> 2007/12/31, Mikko Koppanen >> Calling methods without knowing that they exist sounds like a hack to me. How about using >> abstract classes or interfaces? > > If you look at, for example, python - calling methods that don't > *know* exists is common practice, it's not a hack from my point of > view. It's just easier to ask forgiveness then permission, to quote > Hopper. > > I never understood the direction PHP is heading with type hinting, > static binding (SPL-Types?), etc. While I don't directly oppose it I > don't see any reason for it. I just thought that adding some type of > ability to handle unknown method calls (without forcing *every* class > to implement __call() in a specific way) There is no need to implement __call() in every class,. Just make sure their parent class implements it. Changing PHP's behavior in a backward-incompatible way that would affect everyone and *forcing everyone* to use exceptions seems to be really bad idea, especially taking into account that your problem can be easily solved without it. -- Wbr, Antony Dovgal

« previous php.internals (#34297) next »