|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74251 Parameter w/o default value after one with default value is not a syntax error
Submitted: 2017-03-15 13:03 UTC Modified: 2017-03-27 20:54 UTC
From: Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.0.16 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2017-03-15 13:03 UTC]
The error is only at runtime. The linter obviously doesn't catch that. PHPStorm (as a reasonable IDE) also doesn't catch that. In languages PHP tries to follow this is a syntax error.

Test script:
$ php -r 'function a($b=true, $c){ var_dump($b,$c); } a(); '

Expected result:
error: default argument missing for parameter 2

Actual result:
Warning: Missing argument 2 for a(), called in Command line code on line 1 and defined in Command line code on line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-15 13:11 UTC] spam2 at rhsoft dot net
if PHP would understand named params like viusal basic 6.0 this all would be no problem because a($c=1) would work and $b have the implicit defualt auf true.....
 [2017-03-15 13:31 UTC]
-Package: *General Issues +Package: Scripting Engine problem
 [2017-03-15 13:59 UTC]
Yes, but PHP doesn't understand named params.
 [2017-03-16 17:19 UTC]
-Assigned To: +Assigned To: tpunt
 [2017-03-16 18:05 UTC]
-Status: Assigned +Status: Duplicate
 [2017-03-16 18:05 UTC]
Duplicate of bug #68445.
 [2017-03-27 20:54 UTC]
-Assigned To: tpunt +Assigned To:
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Dec 06 09:01:28 2023 UTC