Re: Request to create a RFC for const args

From: Date: Mon, 19 Jun 2023 09:47:49 +0000
Subject: Re: Request to create a RFC for const args
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-120616@lists.php.net to get a copy of this message
2023-06-19 9:56 GMT+02:00, Sam McDonald <s.mcdonald@outlook.com.au>: > Hello php internals team, > I would like to put forward an RFC for a new feature. I am a long time user, > but have never participated as yet to the RFC. > > This is my first step to gather reaction/feedback from the team. > > I would be happy to implement the feature and post a PR or have someone from > the team implement this. > > The feature I want to put forward is "const function arguments" (same for > methods) > > This feature is available in cpp, and I believe would be a benefit to the > php community. > > My RFC would fully detail and clarify what this is and how it works. > > This feature allows the user to specify "const" on a function arg, so that > the argument while in a function can not be reassigned. > > The following example would throw an exception at compile/runtime. > > ``` > public function foo(const int $bar) > { > $bar =3D "buz"; > } > ``` Isn't this similar to my own idea of readonly function arguments? https://externals.io/message/120203#120210 Perhaps more limited in scope? Olle

« previous php.internals (#120616) next »