php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80248 Swapping parameter names during inheritance does not throw
Submitted: 2020-10-16 21:24 UTC Modified: 2020-10-16 21:35 UTC
From: michael dot vorisek at email dot cz Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 8.0.0RC2 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael dot vorisek at email dot cz
New email:
PHP Version: OS:

 

 [2020-10-16 21:24 UTC] michael dot vorisek at email dot cz
Description:
------------
see test script from https://wiki.php.net/rfc/named_params

It does not throw.

In addition, I think, any parameter name reused on different position should throw.

Test script:
---------------
interface I {
    public function test($foo, $bar);
}
 
class C implements I {
    public function test($bar, $foo) {}
}
 
// Fatal error: Parameter $foo of C::test() at position #2 conflicts with
//              parameter $foo of I::test() at position #1

Expected result:
----------------
catchable error

Actual result:
--------------
no error

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-16 21:35 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2020-10-16 21:35 UTC] nikic@php.net
Behavior described in the "Alternatives" section of a proposal is non-normative.
 [2020-10-16 21:47 UTC] michael dot vorisek at emal dot cz
Can this be addresses or is there any strong argument to allow it?

Example: https://3v4l.org/X8omS

by allowing reusing names for a different position, code may behave very unexpectedly when using/not using named arguments

renaming to a completely new name is safe
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC