Doc #71030 [NEW]: PHP 7.0 list() behavior

From: Date: Fri, 04 Dec 2015 16:41:25 +0000
Subject: Doc #71030 [NEW]: PHP 7.0 list() behavior
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12902@lists.php.net to get a copy of this message
From:             filippo dot desantis at gmail dot com
Operating system: OSX
PHP version:      7.0.0
Package:          *General Issues
Bug Type:         Documentation Problem
Bug description:PHP 7.0 list() behavior

Description:
------------
I'm using

PHP 7.0.0 (cli) (built: Dec  2 2015 13:35:31)
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

Running the example in the RFC
https://wiki.php.net/rfc/abstract_syntax_tree
for the list() function 

$a = [1, 2];
list($a, $b) = $a;
 
// OLD: $a = 1, $b = 2
// NEW: $a = 1, $b = null + "Undefined index 1"


I don't get the "NEW" result but the "OLD" one.

Looking for some more information I found in the documentation
(http://php.net/list) the warning "Modification of the array during
list() execution (e.g. using list($a, $b) = $b) results in undefined
behavior.".

I was wondering which of the two behaviour should be the good one :)






Test script:
---------------
<?php

$a = [1, 2];
list($a, $b) = $a;

var_dump($a, $b);


-- 
Edit bug report at https://bugs.php.net/bug.php?id=71030&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71030&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71030&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71030&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71030&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71030&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71030&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71030&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71030&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71030&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71030&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71030&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71030&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71030&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71030&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71030&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71030&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71030&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71030&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71030&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71030&r=mysqlcfg



Thread (2 messages)

« previous php.doc.bugs (#12902) next »