<?php
class Proxy extends Base {
public function __construct($initializer)
{
// do proxy initializing stuff, NOT calling base object's (i.e. parent's) constructor
}
}
class Base {
public function __construct($data)
{
echo $data;
}
}
$reflection = new ReflectionObject($proxy);
$parentReflection = $reflection->getParentClass();
$parentConstructor = $parentReflection->getMethod('__construct');
$parentConstructor->invoke($proxy, 'Hello world!');
Warning: Undefined variable $proxy in /in/U6XTj on line 15
Fatal error: Uncaught TypeError: ReflectionObject::__construct(): Argument #1 ($object) must be of type object, null given in /in/U6XTj:15
Stack trace:
#0 /in/U6XTj(15): ReflectionObject->__construct(NULL)
#1 {main}
thrown in /in/U6XTj on line 15
Process exited with code 255.
Notice: Undefined variable: proxy in /in/U6XTj on line 15
Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15
Fatal error: Uncaught Error: Internal error: Failed to retrieve the reflection object in /in/U6XTj:16
Stack trace:
#0 /in/U6XTj(16): ReflectionClass->getParentClass()
#1 {main}
thrown in /in/U6XTj on line 16
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26
Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15
Fatal error: Uncaught Error: Internal error: Failed to retrieve the reflection object in /in/U6XTj:16
Stack trace:
#0 /in/U6XTj(16): ReflectionClass->getParentClass()
#1 {main}
thrown in /in/U6XTj on line 16
Process exited with code 255.
Notice: Undefined variable: proxy in /in/U6XTj on line 15
Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15
Fatal error: ReflectionClass::getParentClass(): Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
Process exited with code 255.
Notice: Undefined variable: proxy in /in/U6XTj on line 15
Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15
Fatal error: Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
Process exited with code 255.
Output for 5.0.4
Notice: Undefined variable: proxy in /in/U6XTj on line 15
Warning: __construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15
Fatal error: Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: proxy in /in/U6XTj on line 15
Warning: __construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15
Fatal error: Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
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/U6XTj on line 3
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/U6XTj on line 3
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/U6XTj on line 3
Process exited with code 255.