Skip to content

Instantly share code, notes, and snippets.

@kschatzle
Created September 5, 2022 23:15
Show Gist options
  • Save kschatzle/5394a3abc427659d21ef6f854e01c0f6 to your computer and use it in GitHub Desktop.
Save kschatzle/5394a3abc427659d21ef6f854e01c0f6 to your computer and use it in GitHub Desktop.
/**
* 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