PHP 5.2 and Interface Default Arguments: Fatal error

Something happened on the way to PHP heaven. A customer reported a fatal error where my unit tests caught none…

I had this in my interface:

interface my_interface {
    public function foo( $one, $two, $three );

and in my class:

class my_class implements my_interface {
    public function foo( $one, $two = '', $three = null );

And that gave a customer the following: Fatal error: Declaration of my_class::foo() must be compatible with that of my_interface::foo().

Turns out the customer was using PHP 5.2 and it requires the default arguments to be supplied already in the interface.

Tagged ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: