I'm thinking primarily of the benefit to base or abstract classes. For base classes which expect certain properties be set, they are exposed to the danger of remaining unset if the derived class overrides the constructor without calling the parent.
This solution is analogous to: class Foo { private $timestamp; private function __construct() { $this->timestamp = new DateTime(); $this->init(); } public function getTimestamp() { return $this->timestamp; } protected function init() { } } class Bar extends Foo { protected function init() { // pseudo constructor of Bar } } The problem now though is that derived classes of Foo are unable to do the same thing, whereas instantiated default properties would allow: class Foo { private $timestamp = new \DateTime(); public function getTimestamp() { return $this->timestamp; } } class Baz extends Foo { private $uuid = Uuid::create(); public function getUuid() { return $this->uuid; } } class Bar extends Baz { public function __construct() { // real constructor of Bar } } $bar = new Bar(); var_dump($bar->getTimestamp()); var_dump($bar->getUuid()); With Traits this is even more necessary, because every class (derived or base) would need to set the properties in each constructor. On 25 September 2015 at 22:21, Stanislav Malyshev <smalys...@gmail.com> wrote: > Hi! > > > ability to set default values of properties to instances of objects or > > calls to static methods or functions (expressions in general). > > That is what constructors are for. I.e. I can understand initializing > static properties (though it gives a lot of potential for weird race > conditions) but for non-statics constructor is exactly the place where > initialization should happen. > > -- > Stas Malyshev > smalys...@gmail.com >