Bug #68182 [Com]: array("foo", "bar")() is invalid syntax

From: Date: Fri, 14 Apr 2023 12:28:38 +0000
Subject: Bug #68182 [Com]: array("foo", "bar")() is invalid syntax
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244198@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68182&edit=1 ID: 68182 Comment by: surveyuncle at gmail dot com Reported by: chx@php.net Summary: array("foo", "bar")() is invalid syntax Status: Open Type: Bug Package: PHP Language Specification PHP Version: PHP-5.6 Block user comment: N Private report: N New Comment: (https://pointclickcarecna.site/)github.com Previous Comments: ------------------------------------------------------------------------ [2022-12-15 05:52:54] nazi dot farhadi3171 at gmail dot com ok for the info i will try to figure it out for more (https://www.pointclickcarecna.net/)github.com ------------------------------------------------------------------------ [2016-11-11 21:55:59] nikic@php.net function-call-expression now has a callable-expression as the LHS, which should accurate represent what is (syntactically) allowed on the LHS. However, this does not resolve the inaccuracy wrt array *values*. ------------------------------------------------------------------------ [2014-10-08 19:07:09] requinix@php.net Yeah, the constraints doesn't mention that arrays are allowed. And > postfix-expression must designate a function... by being a value of type > string (but not a string literal) that contains the function's name UVS allows literals http://3v4l.org/V6tTG Side note: the sentence immediately after > The number of arguments present in a function call must be at least as many > as the number of parameters defined for that function. should clarify that it's the number of *required* parameters. Then at the end of the Semantics section, > If postfix-expression is a string, this is a variable function call which links to 13-functions.md#variable-functions that says > If a variable name is followed by the function-call operator () (§§), and > the value of that variable is a string containing the name of a function > currently defined and visible, that function will be executed. which also doesn't include arrays. ------------------------------------------------------------------------ [2014-10-08 17:24:14] ajf@php.net In that case, we should change this is master to reflect it being accepted by PHP7's Uniform Variable Syntax. ------------------------------------------------------------------------ [2014-10-08 14:54:08] cmbecker69 at gmx dot de > According to the specs, any postfix expression + argument list > is a valid function call. No. While it is syntatically valid, there are further constraints: | postfix-expression must designate a function, either by being | its name, by being a value of type string (but not a string | literal) that contains the function's name, or by being a variable | whose type is Closure (§§) or a derived type thereof. array("foo", "bar") doesn't fulfill these constraints. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=68182 -- Edit this bug report at https://bugs.php.net/bug.php?id=68182&edit=1

« previous php.bugs (#244198) next »