It will be patched before this RFC goes into official discussion. 2016-09-09 22:01 GMT+02:00 Silvio Marijić <marijic.sil...@gmail.com>:
> @Fred > > Thanks for taking interest. I still need to fully patch reflection > extension for this. We had more important discussions in the past two weeks. > > Cheers, > Silvio > > 2016-09-09 21:46 GMT+02:00 Fred Emmott <f...@fredemmott.co.uk>: > >> 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 ‘every property must be a constructor parameter’ 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ć <marijic.sil...@gmail.com> >> 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: >> >> <?php >> >> immutable class Email { >> >> public $email; >> public function __construct($email){ >> $this->email = $email; >> } >> } >> $email = new Email("exam...@email.com"); >> >> >> >> >> After instance of class is created, object is "frozen" so call like this >> >> $email->email = "n...@email.com"; >> >> >> Would result in error. >> >> I have already implementation up to certain degree, but I need one advice >> from more experienced developers. Where is the place where I could put >> logic to lock object after the constructor has finished? Maybe in zend vm >> on ZEND_NEW token? >> >> Some constraints are needed: >> >> 1. Child class that extends immutable class must be defined as immutable >> 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 or >> none. >> >> Thank you all in advance. >> >> -- >> Silvio Marijić >> Software Engineer >> 2e Systems >> >> >> > > > -- > Silvio Marijić > Software Engineer > 2e Systems > -- Silvio Marijić Software Engineer 2e Systems