<?php
class A {
private function __construct () {
echo "Created!\n";
}
public static function attemptToCreate ($should_it_succeed) {
if ($should_it_succeed) {
return new A();
}
return false;
}
}
//! new A(); - gives error
PD9waHAKCmNsYXNzIEEgewoJcHJpdmF0ZSBmdW5jdGlvbiBfX2NvbnN0cnVjdCAoKSB7CgkJZWNobyAiQ3JlYXRlZCFcbiI7Cgl9CglwdWJsaWMgc3RhdGljIGZ1bmN0aW9uIGF0dGVtcHRUb0NyZWF0ZSAoJHNob3VsZF9pdF9zdWNjZWVkKSB7CgkJaWYgKCRzaG91bGRfaXRfc3VjY2VlZCkgewoJCQlyZXR1cm4gbmV3IEEoKTsKCQl9CgkJcmV0dXJuIGZhbHNlOwoJfQp9Cgp2YXJfZHVtcChBOjphdHRlbXB0VG9DcmVhdGUoMCkpOwp2YXJfZHVtcChBOjphdHRlbXB0VG9DcmVhdGUoMSkpOwoKLy8hIG5ldyBBKCk7IC0gZ2l2ZXMgZXJyb3I=