Request to create a RFC for const args
| From: | Sam McDonald | Date: | Mon, 19 Jun 2023 07:56:49 +0000 |
| Subject: | Request to create a RFC for const args | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-120615@lists.php.net to get a copy of this message | ||
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";
}
```
The same for complex types such as arrays and classes, if a 'const' arg is provided, while
in the function it can not be reassigned.
Please let me know if this is something the team is interested in and if I should proceed.
Kind regards.
Sam McDonald.
Sent from Outlook for Android<https://aka.ms/AAb9ysg>