This was just an example of a value object - for example: class HttpMethod { private $method;
protected function __construct($method) { $this->method = $method; } public function getMethod() { return $this->method; } public static function get() { return new self("GET"); } public static function post() { return new self("POST"); } // ... } You could picture using a flyweight constructor inside those factory methods maybe, and probably other patterns... I think there's plenty of cases for "named constructors", this is just the PHP variety of that. There are also cases (such as this one) where only certain constructions are permitted - allowing any string for HTTP method (e.g. wrong names, wrong case etc.) is prevented by protecting the constructor... On Tue, Jun 28, 2016 at 9:10 PM, Pedro Cordeiro <pedronar...@gmail.com> wrote: > >> << HttpMethod::post() >> // equivalent to static method-call >> HttpMethod::post() > > > What would this, specifically, do? Would it call HttpMethod::post() when the > class gets instantiated and return its return on a > ReflectionClass::getAnnotations()? Why is it necessary to be able to > evaluate expressions on annotations? I do agree that throwing > errors/exceptions when classes are not found is needed (otherwise we wont be > able to use value-objects), but evaluating expressions seems a little crazy > for me... why should metadata be computed in runtime? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php