Hi internals,
another RFC using attributes for 8.1. The patch itself for this is really
small, but the implications require a detailed discussion and scrutiny.
This is my take on parameter names now being public API, at its future
potential for code maintenance, refactoring and backwards compatibility.
There might be other approaches that I am unaware of that would be better.
This feature will probably also be helpful to allow more work on improving
named params API of internal/core APIs, as the time period between named
params RFC and 8.0 release was rather short and we might find that we want
to further improve the names of internal parameters.
https://wiki.php.net/rfc/named_parameter_alias_attribute
https://github.com/php/php-src/pull/6522
Looking forward to your feedback.
greetings
Benjamin
This is my take on parameter names now being public API, at its future
potential for code maintenance, refactoring and backwards compatibility.
Hi Benjamin,
This sounds like a sensible feature. The suggested name seems a bit
long, but I'm not quite sure what to replace it with.
It just occurred to me that there's a potential connection, in concept
if not implementation, with the #[Deprecated] RFC you also just posted:
parameter name aliases may well be used to provide a limited-time
transition mechanism rather than a permanent feature, so it might be
useful to allow them to be marked as deprecated.
e.g.
// Version 1.0: parameter name is misspelled
function doSomething(bool $formatNumters) { ... }
// Version 1.1: parameter name changed, old name added as a deprecated alias
// if the misspelled name is used, an E_DEPRECATED
is raised
function doSomething(#[ParameterNameAlias('formatNumters', deprecated:
true)] $formatNumbers) { ... }
// Version 2.0: alias removed; the misspelled name is now an error
function doSomething(#[ParameterNameAlias($formatNumbers) { ... }
Regards,
--
Rowan Tommins
[IMSoP]
On Sat, Dec 19, 2020 at 8:27 PM Rowan Tommins rowan.collins@gmail.com
wrote:
This is my take on parameter names now being public API, at its future
potential for code maintenance, refactoring and backwards compatibility.Hi Benjamin,
This sounds like a sensible feature. The suggested name seems a bit
long, but I'm not quite sure what to replace it with.It just occurred to me that there's a potential connection, in concept
if not implementation, with the #[Deprecated] RFC you also just posted:
parameter name aliases may well be used to provide a limited-time
transition mechanism rather than a permanent feature, so it might be
useful to allow them to be marked as deprecated.e.g.
// Version 1.0: parameter name is misspelled
function doSomething(bool $formatNumters) { ... }// Version 1.1: parameter name changed, old name added as a deprecated
alias
// if the misspelled name is used, anE_DEPRECATED
is raised
function doSomething(#[ParameterNameAlias('formatNumters', deprecated:
true)] $formatNumbers) { ... }// Version 2.0: alias removed; the misspelled name is now an error
function doSomething(#[ParameterNameAlias($formatNumbers) { ... }
Oh that is a great idea! It makes sense to allow developers to mark the
alias as the deprecated parameter name. I will add this to the RFC on my
next iteration.
Regards,
--
Rowan Tommins
[IMSoP]--
To unsubscribe, visit: https://www.php.net/unsub.php