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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC