Created
September 5, 2022 23:15
-
-
Save kschatzle/5394a3abc427659d21ef6f854e01c0f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Confirmed Fatal errors by hand. | |
* | |
* Properties have to have typehint. Following is invalid. | |
* public $array; | |
* | |
* Properties cannot have default. Following is invalid. | |
* public $array = []; | |
* | |
* Child classes must also be readonly. Following is invalid. | |
* $a = new class() extends A {}; | |
* | |
*/ | |
readonly class A | |
{ | |
public array $array; | |
public function __construct(array $array = []) | |
{ | |
$this->array = $array; | |
} | |
public function get() | |
{ | |
return $this->array; | |
} | |
} | |
readonly class A1 extends A | |
{ | |
public \Closure $closure; | |
public function __construct($array, \Closure $closure) | |
{ | |
$this->closure = $closure; | |
parent::__construct($array); | |
} | |
public function getProphecy() { | |
return \call_user_func($this->closure); | |
} | |
public function get() | |
{ | |
return $this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment