On 19/12/2020 11:28, Benjamin Eberlei wrote:
This is my take on parameter names now being public API, at its future
potential for code maintenance, refactoring and backwards compatibility.

https://wiki.php.net/rfc/named_parameter_alias_attribute


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]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to