<?php
abstract class HiddenFactory
{
protected function __construct()
{
}
protected static function create()
{
return new static();
}
}
class B extends HiddenFactory
{}
class A extends HiddenFactory
{
public static function createB()
{
return B::create();
}
}
$b = A::createB();
echo get_class($b);
B::create();
B
Fatal error: Uncaught Error: Call to protected method HiddenFactory::create() from global scope in /in/PgWEB:32
Stack trace:
#0 {main}
thrown in /in/PgWEB on line 32
Process exited with code 255.
B
Fatal error: Uncaught Error: Call to protected method HiddenFactory::create() from context '' in /in/PgWEB:32
Stack trace:
#0 {main}
thrown in /in/PgWEB on line 32
Process exited with code 255.