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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 03:01:27 2024 UTC