Bug #74251 [Opn]: Parameter w/o default value after one with default value is not a syntax error

From: Date: Wed, 15 Mar 2017 13:59:44 +0000
Subject: Bug #74251 [Opn]: Parameter w/o default value after one with default value is not a syntax error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207854@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74251&edit=1 ID: 74251 Updated by: andrey@php.net Reported by: andrey@php.net Summary: Parameter w/o default value after one with default value is not a syntax error Status: Open Type: Bug Package: Scripting Engine problem Operating System: all PHP Version: 7.0.16 Block user comment: N Private report: N New Comment: Yes, but PHP doesn't understand named params. Previous Comments: ------------------------------------------------------------------------ [2017-03-15 13:11:52] 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:03:06] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74251&edit=1

« previous php.bugs (#207854) next »