<?php
class CanNotSetProperties extends BadMethodCallException {
}
trait Immutable {
public function __set($property, $value) {
throw new CanNotSetProperties;
}
}
final class Test {
use Immutable;
private function __construct()
{
echo 'hello';
}
}
$test = new Test;
$test->__construct();
Fatal error: Uncaught Error: Call to private Test::__construct() from global scope in /in/OS4pt:22
Stack trace:
#0 {main}
thrown in /in/OS4pt on line 22
Process exited with code 255.
Fatal error: Uncaught Error: Call to private Test::__construct() from invalid context in /in/OS4pt:22
Stack trace:
#0 {main}
thrown in /in/OS4pt on line 22
Process exited with code 255.