php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68993 Inconsistency in documentations of list-intrinsic.
Submitted: 2015-02-05 13:18 UTC Modified: 2015-06-28 23:18 UTC
From: minecraftshamrock at gmail dot com Assigned: stas (profile)
Status: Closed Package: PHP Language Specification
PHP Version: master-Git-2015-02-05 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: minecraftshamrock at gmail dot com
New email:
PHP Version: OS:

 

 [2015-02-05 13:18 UTC] 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
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-05 16:03 UTC] datibbaw@php.net
A change for this has been proposed a month ago:

https://github.com/php/php-langspec/pull/111
 [2015-06-28 23:18 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2015-06-28 23:18 UTC] stas@php.net
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 12:01:23 2020 UTC