php.net |  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: andrey@php.net Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.0.16 OS: all
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrey@php.net
New email:
PHP Version: OS:

 

 [2017-03-15 13:03 UTC] andrey@php.net
Description:
------------
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
bool(true)
NULL

Patches

Pull Requests

History

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] andrey@php.net
-Package: *General Issues +Package: Scripting Engine problem
 [2017-03-15 13:59 UTC] andrey@php.net
Yes, but PHP doesn't understand named params.
 [2017-03-16 17:19 UTC] tpunt@php.net
-Assigned To: +Assigned To: tpunt
 [2017-03-16 18:05 UTC] nikic@php.net
-Status: Assigned +Status: Duplicate
 [2017-03-16 18:05 UTC] nikic@php.net
Duplicate of bug #68445.
 [2017-03-27 20:54 UTC] tpunt@php.net
-Assigned To: tpunt +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC