Reputation: 227
I am using a static factory method to create a concrete implementation of an abstract class. But I am constantly getting the "Class Not Found" error.
I know that my "require" paths are correct because any other configuration leads to the "failed to open stream" error.
My question is, why am I getting this "Class Not Found?"
class A {
public function method () {
$obj = B::factorymethod();
}
}
abstract class B {
static function factory() {
return new C();
}
}
class C extends B {}
When I do this I get:
Fatal error: Class 'B' not found in C:\phpproject\C on line 11
A has require_once(B.php), B has require_once(C.php), C has require_once(B.php)... there are no other errors.
Upvotes: 0
Views: 2618
Reputation: 4118
Because you have used the non-existent keyword method
in your code, preventing your class from being properly recognized and evaluated, thus, not being discovered among correctly defined classes.
Upvotes: 2