Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95876 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87437 invoked from network); 9 Sep 2016 20:02:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Sep 2016 20:02:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=marijic.silvio@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marijic.silvio@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.52 as permitted sender) X-PHP-List-Original-Sender: marijic.silvio@gmail.com X-Host-Fingerprint: 209.85.218.52 mail-oi0-f52.google.com Received: from [209.85.218.52] ([209.85.218.52:33779] helo=mail-oi0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/07-46544-54513D75 for ; Fri, 09 Sep 2016 16:02:13 -0400 Received: by mail-oi0-f52.google.com with SMTP id y2so162661982oie.0 for ; Fri, 09 Sep 2016 13:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4GpRoplnOIlQxdbl2NGrsSE910W4c6lOT3G4AYvjJXA=; b=ID8/sCikdPjLV7/whmXi7sKRleEeE42aQ0px5u1r866ij6YmVlo2yCyrCh6wwqJw0v DDnapSgsYtIzFpj/v8QwImm0kqniTuEld/e6kr+uhKJsePejUXokdP0VHM8G17+zJ/E8 D8kQPrLuojy7oCLGeGR8EokLHvU9/qWkht8rLC3ieHXHxPCqTxrGbvzWnkMH7J+3GECh dsl+qVQx3zVql3RIsN02OpvWFa/ligKH4ysyzsYkQzjjH0THDobP8Ngr+FBrO6yFfZHw ObEgYuWNARFiz7pM/tczGMMoXFbi4vyTxuOslVw4vC8WSbiz/KTtk8ikeUzEfiMAFb7x wY5A== 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=4GpRoplnOIlQxdbl2NGrsSE910W4c6lOT3G4AYvjJXA=; b=fKZeRTH4B0tRvCEz+t6ikZ38LY+TlpXNE1oWu+7QssJX0UMU6HO6ZvZOGih31YspH2 krlhB+TJJdFN9csveLEsxuZWYKIz2P5x1Adm6MHznyOmVPs23QCXgerEn8BxHh10ZPHA S3JZifUY0MdVwnb93CJ053vLcXWOdgBOxTXcIH9aITiNSxR0a1e9k1BJ0nzkwW+eds5s O2h5P8GYAmUM2QgLttteSXKtPRCkeALUwSirMUF4bcMCWdsIL3+qx9bwvsFJW+fkzbv/ opkIaJLQ689E27ad34NhShzjOIZOaR92lxf4TjZ2MBHbg1UEgQT0zuX/DX+8D5j6GD58 c0DA== X-Gm-Message-State: AE9vXwOLjyUL8ILVGg51sHjvGl5HYiGb5hk3ICrd5IWlFh8ReECdNRbxb8ac0ivdcznl1su9HWxXxoK/q4EdUQ== X-Received: by 10.202.231.20 with SMTP id e20mr8791853oih.61.1473451330534; Fri, 09 Sep 2016 13:02:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.207.134 with HTTP; Fri, 9 Sep 2016 13:02:09 -0700 (PDT) In-Reply-To: References: Date: Fri, 9 Sep 2016 22:02:09 +0200 Message-ID: To: Fred Emmott Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a11413996268a1a053c189f4c Subject: Re: [PHP-DEV] RFC - Immutable classes From: marijic.silvio@gmail.com (=?UTF-8?Q?Silvio_Mariji=C4=87?=) --001a11413996268a1a053c189f4c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable It will be patched before this RFC goes into official discussion. 2016-09-09 22:01 GMT+02:00 Silvio Mariji=C4=87 : > @Fred > > Thanks for taking interest. I still need to fully patch reflection > extension for this. We had more important discussions in the past two wee= ks. > > Cheers, > Silvio > > 2016-09-09 21:46 GMT+02:00 Fred Emmott : > >> I see Reflection is still todo; should there be a similar escape hatch >> to ReflectionMethod::setAccessible()? >> >> This would allow things like: https://gist.github.com/ >> fredemmott/01ad55c0c03c8d7ba62bbd6e9fb23686 (apologies for the hack-like >> syntax) - the =E2=80=98every property must be a constructor parameter=E2= =80=99 approach in >> the RFC seems like it would rapidly become unwieldy for classes with a >> large number of properties. >> >> Regards, >> - Fred >> >> >> On Aug 8, 2016, at 3:31 AM, Silvio Mariji=C4=87 >> wrote: >> >> >> Hi, >> >> I would need your help with one idea. I'm working on one RFC that I'm >> would >> like to submit. Idea is that after you initialize object eg. after >> constructor returns, object would be locked, and you wouldn't be able to >> change properties on that object anymore. It would like this: >> >> > >> immutable class Email { >> >> public $email; >> public function __construct($email){ >> $this->email =3D $email; >> } >> } >> $email =3D new Email("example@email.com"); >> >> >> >> >> After instance of class is created, object is "frozen" so call like this >> >> $email->email =3D "new@email.com"; >> >> >> Would result in error. >> >> I have already implementation up to certain degree, but I need one advic= e >> from more experienced developers. Where is the place where I could put >> logic to lock object after the constructor has finished? Maybe in zend v= m >> on ZEND_NEW token? >> >> Some constraints are needed: >> >> 1. Child class that extends immutable class must be defined as immutab= le >> also. >> 2. If property on immutable class contains object, it must be instance >> of immutable class. >> 3. You can not have immutability per property, it either whole class o= r >> none. >> >> Thank you all in advance. >> >> -- >> Silvio Mariji=C4=87 >> Software Engineer >> 2e Systems >> >> >> > > > -- > Silvio Mariji=C4=87 > Software Engineer > 2e Systems > --=20 Silvio Mariji=C4=87 Software Engineer 2e Systems --001a11413996268a1a053c189f4c--