|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65772 Implement "default" as a possible function/method argument value in calls
Submitted: 2013-09-27 06:49 UTC Modified: 2015-01-11 07:35 UTC
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: matteo_tassinari_TM at libero dot it Assigned: stas (profile)
Status: Assigned Package: Variables related
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-09-27 06:49 UTC] matteo_tassinari_TM at libero dot it
I think it would be useful if we could use the "default" keyword when passing parameters to a method/function so that the value for the parameter for which "default" is passed automatically takes the defined default value, without need of knowing it.

Test script:
For example, consider this:

function justToTest($a = 10, $b = 0) {
  var_dump($a, $b);

justToTest(default, 5);

Expected result:
The first call should show

int 10
int 0

The second call should show

int 5
int 0

The third call should show

int 10
int 5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-27 08:03 UTC]
Existing RFC for this exact thing:
 [2013-09-27 18:46 UTC]
-Status: Open +Status: Suspended -Assigned To: +Assigned To: stas
 [2013-09-27 18:46 UTC]
We don't really have a status for "it's in an active RFC", so I guess I'll 
suspend this and assign it to Stas for now, since it's his RFC.
 [2015-01-11 07:35 UTC]
-Status: Suspended +Status: Open
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC