Jump to content

Strange behaviour when combining interfaces and static methods


gryphius

Recommended Posts

I'm running PHP 5.2 on Windows. My "problem" is best described with these two examples:

This one works as excected and prints 'Hello'.
[code]
SomeClass::sayHello();

class SomeClass {
public static function sayHello() {
echo 'Hello';
}
}
[/code]

The following one however results in "[b]Fatal error: Class 'SomeClass' not found[/b]". The only noteworthy change is the '[b]implements SomeInterface[/b]'.
[code]
SomeClass::sayHello();

interface SomeInterface {
}

class SomeClass implements SomeInterface {
public static function sayHello() {
echo 'Hello';
}
}
[/code]

The error can be solved by moving the line [b]SomeClass::sayHello();[/b] below the class definition.

My question: Does this behaviour make sense in any way that I don't get or is this a bug? It's nothing dramatic but still annoying.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.