Doc #68993 [Opn->Csd]: Inconsistency in documentations of list-intrinsic.
Edit report at https://bugs.php.net/bug.php?id=68993&edit=1
ID: 68993
Updated by: stas@php.net
Reported by: minecraftshamrock at gmail dot com
Summary: Inconsistency in documentations of list-intrinsic.
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: PHP Language Specification
PHP Version: master-Git-2015-02-05 (Git)
-Assigned To:
+Assigned To: stas
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
I think this was fixed as pull 111 was merged.
Previous Comments:
------------------------------------------------------------------------
[2015-02-05 16:03:49] datibbaw@php.net
A change for this has been proposed a month ago:
https://github.com/php/php-langspec/pull/111
------------------------------------------------------------------------
[2015-02-05 13:18:06] minecraftshamrock at gmail dot com
Description:
------------
Original question on StackOverflow: https://stackoverflow.com/q/28343884/2324078
I saw the list-intrinsic specification
(https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#list), which states that for
a list-intrinsic construct, the right-hand side of the simple-assignment-expression must be an
expression that designates an array.
But the documentation of list from php.net (http://php.net/manual/en/function.list.php), gives an
example like the one in the attached test script of this ticket.
The thing is that PDOStatement::fetch(PDO::FETCH_NUM) returns FALSE if there is no further row. But
the right-hand side of the assignment-expression must be an array - and FALSE is not an array. So
this would result in a fatal-error, right?
Have I missed something, or is this really an inconsistency?
Test script:
---------------
$result = $pdo->query("SELECT id, name, salary FROM employees");
while (list($id, $name, $salary) = $result->fetch(PDO::FETCH_NUM)) {
//output $id, $name and $salary
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68993&edit=1
Thread (3 messages)