2015-03-12 12:33 GMT+01:00 Johannes Ott <m...@deroetzi.de>: > Am 12.03.2015 um 12:16 schrieb Crypto Compress: > > Hello Johannes, > > > > class Foo { > > private static function __static() { > > throw new Exception("boom"); > > } > > } > > > > while(true) { > > try { > > $foo = new Foo; > > } catch (Exception ex) {} > > } > > > > Would this code be valid? > > Have to think about this issue, but on the first look I would say yes! > > Because the meaning of the static constructor is to do some necassary > initialize for the class it should be able to throw an Exception if it > cannot do it's work correctly. For example if it needs to read some > configuration from a Database and is not able to connect. >
How would it behave for the second call? If the first initialize fails due to some exception, should that static constructor be executed again? > For the caller I although would say, that the error inside the static > constructor should be catchable, for the simple fact that every Error > should be catchable for user-errorhandling. > > What is your point of view for this? I'm open for discussion about this. > > Regards > -- > DerOetzi > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Regards, Niklas