mirror of
https://github.com/php/php-src.git
synced 2024-12-19 15:00:15 +08:00
37c8bb5868
Squashed commit of the following: commit0361dbe356
Author: Andrea Faulds <ajf@ajf.me> Date: Fri Mar 25 16:59:20 2016 +0000 UPGRADING and NEWS commitdca9d4a36c
Author: Andrea Faulds <ajf@ajf.me> Date: Fri Mar 25 16:45:18 2016 +0000 Add tests contributed by @jesseschalken commite557f77eab
Author: Andrea Faulds <ajf@ajf.me> Date: Fri Mar 25 16:44:51 2016 +0000 Rebuild VM commit70942e4c3c
Author: Andrea Faulds <ajf@ajf.me> Date: Wed Feb 24 13:12:26 2016 +0000 Add test for evaluation order of nested list() keys commited3592e80c
Author: Andrea Faulds <ajf@ajf.me> Date: Wed Feb 24 12:42:04 2016 +0000 Add test for evaluation order commit589756cbcc
Author: Andrea Faulds <ajf@ajf.me> Date: Tue Jan 19 17:29:34 2016 +0000 Allow arbitrary expressions for key commit3f622077c3
Author: Andrea Faulds <ajf@ajf.me> Date: Tue Jan 19 17:45:10 2016 +0000 Remove compile-time HANDLE_NUMERIC (see bug #63217) commitbab758119a
Author: Andrea Faulds <ajf@ajf.me> Date: Sun Jan 17 01:20:26 2016 +0000 Handle numeric strings commit14bfe93ddc
Author: Andrea Faulds <ajf@ajf.me> Date: Sun Jan 17 01:09:36 2016 +0000 Allow trailing comma commitf4c8b2cb30
Author: Andrea Faulds <ajf@ajf.me> Date: Sat Jan 16 23:47:11 2016 +0000 Add tests commit0085884a61
Author: Andrea Faulds <ajf@ajf.me> Date: Sat Jan 16 22:24:23 2016 +0000 Handle non-integer/string opcodes commite572d2d0ad
Author: Andrea Faulds <ajf@ajf.me> Date: Sat Jan 16 21:10:33 2016 +0000 Disallow mixing keyed and unkeyed list() elements commitcede13ccfe
Author: Andrea Faulds <ajf@ajf.me> Date: Sun Jan 10 20:46:44 2016 +0000 list() with keys (no foreach or tests)
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
--TEST--
|
|
list() with keys and ArrayAccess
|
|
--FILE--
|
|
<?php
|
|
|
|
$antonymObject = new ArrayObject;
|
|
$antonymObject["good"] = "bad";
|
|
$antonymObject["happy"] = "sad";
|
|
|
|
list("good" => $good, "happy" => $happy) = $antonymObject;
|
|
var_dump($good, $happy);
|
|
|
|
echo PHP_EOL;
|
|
|
|
$stdClassCollection = new SplObjectStorage;
|
|
$foo = new StdClass;
|
|
$stdClassCollection[$foo] = "foo";
|
|
$bar = new StdClass;
|
|
$stdClassCollection[$bar] = "bar";
|
|
|
|
list($foo => $fooStr, $bar => $barStr) = $stdClassCollection;
|
|
var_dump($fooStr, $barStr);
|
|
|
|
echo PHP_EOL;
|
|
|
|
class IndexPrinter implements ArrayAccess
|
|
{
|
|
public function offsetGet($offset) {
|
|
echo "GET ";
|
|
var_dump($offset);
|
|
}
|
|
public function offsetSet($offset, $value) {
|
|
}
|
|
public function offsetExists($offset) {
|
|
}
|
|
public function offsetUnset($offset) {
|
|
}
|
|
}
|
|
|
|
$op = new IndexPrinter;
|
|
list(123 => $x) = $op;
|
|
// PHP shouldn't convert this to an integer offset, because it's ArrayAccess
|
|
list("123" => $x) = $op;
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(3) "bad"
|
|
string(3) "sad"
|
|
|
|
string(3) "foo"
|
|
string(3) "bar"
|
|
|
|
GET int(123)
|
|
GET string(3) "123"
|