On Thu, Jul 2, 2020 at 1:20 PM Andrea Faulds <a...@ajf.me> wrote: > Hi, > > Nikita Popov wrote: > > > > Regarding the question of what to do with regard to LSP validation and > > parameter names changing during inheritance: During internal discussion, > > the following option has come up as a possible compromise: > > > > 1. When calling a method, also allow using parameter names from the > parent > > class/interface. > > 2. During inheritance, enforce that the same parameter name is not used > at > > different positions. > > > > This ensures that renaming parameter names during inheritance does not > > break code relying on parameter names of the parent method. At the same > > time, it prohibits genuine LSP violations, where a parameter has been > moved > > to a different position. > > > > I've run some static analysis to detect cases that would be affected by > the > > latter check, with these results: > > https://gist.github.com/nikic/6cc9891381a83b8dca5ebdaef1068f4d The first > > signature is the child method, and the second the parent method. I did > not > > put in the effort to make this completely precise, so there's both false > > positives and false negatives here. But it should be enough for a general > > impression. And the general impression is that these are indeed > legitimate > > LSP violations. > > > > This approach would be an alternative to either silently ignoring the > issue > > (as the RFC proposed), or to warning for all parameter renames. > > Would this do anything surprising when variadics are involved? >
The behavior of variadics is described in https://wiki.php.net/rfc/named_params#allow_using_parameter_names_from_parent_methods. The behavior there described there might be surprising. It's certainly one of the ways in which this approach is less straightforward than it initially appears. Regards, Nikita