php-src/Zend/tests/list_keyed_evaluation_order.inc
Andrea Faulds 37c8bb5868 Allow specifying keys on list() elements
Squashed commit of the following:

commit 0361dbe356
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Mar 25 16:59:20 2016 +0000

    UPGRADING and NEWS

commit dca9d4a36c
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Mar 25 16:45:18 2016 +0000

    Add tests contributed by @jesseschalken

commit e557f77eab
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Mar 25 16:44:51 2016 +0000

    Rebuild VM

commit 70942e4c3c
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Feb 24 13:12:26 2016 +0000

    Add test for evaluation order of nested list() keys

commit ed3592e80c
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Feb 24 12:42:04 2016 +0000

    Add test for evaluation order

commit 589756cbcc
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 19 17:29:34 2016 +0000

    Allow arbitrary expressions for key

commit 3f622077c3
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 19 17:45:10 2016 +0000

    Remove compile-time HANDLE_NUMERIC (see bug #63217)

commit bab758119a
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Jan 17 01:20:26 2016 +0000

    Handle numeric strings

commit 14bfe93ddc
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Jan 17 01:09:36 2016 +0000

    Allow trailing comma

commit f4c8b2cb30
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Jan 16 23:47:11 2016 +0000

    Add tests

commit 0085884a61
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Jan 16 22:24:23 2016 +0000

    Handle non-integer/string opcodes

commit e572d2d0ad
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Jan 16 21:10:33 2016 +0000

    Disallow mixing keyed and unkeyed list() elements

commit cede13ccfe
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Jan 10 20:46:44 2016 +0000

    list() with keys (no foreach or tests)
2016-03-25 17:18:42 +00:00

61 lines
1.5 KiB
PHP

<?php declare(strict_types=1);
// Observer objects for the Zend/tests/list_keyed_evaluation_order.* tests
class Stringable
{
private $name;
public function __construct(string $name) {
$this->name = $name;
}
public function __toString(): string {
echo "$this->name evaluated.", PHP_EOL;
return $this->name;
}
}
class Indexable implements ArrayAccess
{
private $array;
public function __construct(array $array) {
$this->array = $array;
}
public function offsetExists($offset): bool {
echo "Existence of offset $offset checked for.", PHP_EOL;
return isset($this->array[$offset]);
}
public function offsetUnset($offset): void {
unset($this->array[$offset]);
echo "Offset $offset removed.", PHP_EOL;
}
public function offsetGet($offset) {
echo "Offset $offset retrieved.", PHP_EOL;
return $this->array[$offset];
}
public function offsetSet($offset, $value): void {
$this->array[$offset] = $value;
echo "Offset $offset set to $value.", PHP_EOL;
}
}
class IndexableRetrievable
{
private $label;
private $indexable;
public function __construct(string $label, Indexable $indexable) {
$this->label = $label;
$this->indexable = $indexable;
}
public function getIndexable(): Indexable {
echo "Indexable $this->label retrieved.", PHP_EOL;
return $this->indexable;
}
}