<?php
class Pirate
{
private function __construct()
{
}
public static function construct()
{
$reflection = new ReflectionClass(__CLASS__);
$reflection->newInstanceArgs([]);
}
}
class Car extends Pirate
{
}
var_dump(Pirate::construct());
Fatal error: Uncaught ReflectionException: Access to non-public constructor of class Pirate in /in/cpAjV:13
Stack trace:
#0 /in/cpAjV(13): ReflectionClass->newInstanceArgs(Array)
#1 /in/cpAjV(22): Pirate::construct()
#2 {main}
thrown in /in/cpAjV on line 13
Process exited with code 255.
Fatal error: Uncaught exception 'ReflectionException' with message 'Access to non-public constructor of class Pirate' in /in/cpAjV:13
Stack trace:
#0 /in/cpAjV(13): ReflectionClass->newInstanceArgs(Array)
#1 /in/cpAjV(22): Pirate::construct()
#2 {main}
thrown in /in/cpAjV on line 13
Process exited with code 255.
Parse error: syntax error, unexpected '[', expecting ')' in /in/cpAjV on line 13
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[', expecting ')' in /in/cpAjV on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cpAjV on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cpAjV on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/cpAjV on line 5
Process exited with code 255.