Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94317 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 348 invoked from network); 28 Jun 2016 21:24:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2016 21:24:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.213.52 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.213.52 mail-vk0-f52.google.com Received: from [209.85.213.52] ([209.85.213.52:35239] helo=mail-vk0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/51-25084-42BE2775 for ; Tue, 28 Jun 2016 17:24:52 -0400 Received: by mail-vk0-f52.google.com with SMTP id j2so40301318vkg.2 for ; Tue, 28 Jun 2016 14:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8A03G7+e10DXOTQDgKnhMS7MM0rZXEuaDSimsDVT0gs=; b=XELn0te14FL0Wy3j2ltIbtmIW9oUobo1C2cbaiCEo9M5PfCeIXjOW1djeYueCLos7H m3CrKdLs3DOSBRPmFMUfX9EdpIk4h3Dv/KF1IxJ35+8dyk3dCj8Dklr37JSGB13lh5Z7 6rMLW3g/4dLkNPFL9myc0crgAqg/vMEdNOmT7wkFheNLDXvikmOlwyMN8rEHd1o8Sw2A N/ojHStL6m8CLQj0f67h2nkkhEmet2cmBV1m+qR0TLajVXRmS9slSTzbit4iKQtaKhv7 82JD0FOhXsL06nH6W5fTkAwGzvskP5UaVT3ZDnR/d3J5K6Zr07TC/9rSR1y6h6X+Vh+1 8Eug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8A03G7+e10DXOTQDgKnhMS7MM0rZXEuaDSimsDVT0gs=; b=KAXQaMsFvWq9at3Hbv82BS0TwW8yltoqyABrmz13XiTLx69gkR3voJM7TiPDQleGse 9dNmiKaIQkNwIT0ZNuIrGaxv2mG3Ed+OjLG29tF0M3a6DDKTOd8Dt/PVOuCs/wGSQtYi mkuiXXT3TtwuvqncRNwdIRr6o73+v3uT2uu0//V5VEb7M6lY4k1Vu6DGO+nPJng4Tmhw wYAEEbAg+kzx3T+VcgU8hSAb77cokg4H9Bj0MZKIVQFUDdWlHQZdoSCxr79+l2S/xC2A BRJgSeQjifx/QL2robUSSQLVNlv6un4xAuIs+l0D7zxvkGaseqHZHXHB11nwPU3/6yTa N90w== X-Gm-Message-State: ALyK8tLCaV6NChuRkoYT2h3qIsiYHEaCjW65T6RprX7SZ/i4z6F7W3uiGiAbXfi9j1mFnZF7gkjsEukj+id4ig== X-Received: by 10.31.129.203 with SMTP id c194mr1740065vkd.26.1467149090253; Tue, 28 Jun 2016 14:24:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.88.148 with HTTP; Tue, 28 Jun 2016 14:24:49 -0700 (PDT) In-Reply-To: References: <211db59e-9c22-6df4-1f72-66ebbc5095bd@fleshgrinder.com> Date: Tue, 28 Jun 2016 23:24:49 +0200 Message-ID: To: Pedro Cordeiro Cc: Marco Pivetta , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Simple Annotations From: rasmus@mindplay.dk (Rasmus Schultz) 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 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?