1--TEST--
2object containers behaviour with offsets
3--FILE--
4<?php
5
6require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc';
7
8const EXPECTED_OUTPUT = <<<OUTPUT
9Read before write:
10Cannot use object of type stdClass as array
11Write:
12Cannot use object of type stdClass as array
13Read:
14Cannot use object of type stdClass as array
15Read-Write:
16Cannot use object of type stdClass as array
17isset():
18Cannot use object of type stdClass as array
19empty():
20Cannot use object of type stdClass as array
21null coalesce:
22Cannot use object of type stdClass as array
23unset():
24Cannot use object of type stdClass as array
25Nested read:
26Cannot use object of type stdClass as array
27Nested write:
28Cannot use object of type stdClass as array
29Nested Read-Write:
30Cannot use object of type stdClass as array
31Nested isset():
32Cannot use object of type stdClass as array
33Nested empty():
34Cannot use object of type stdClass as array
35Nested null coalesce:
36Cannot use object of type stdClass as array
37Nested unset():
38Cannot use object of type stdClass as array
39
40OUTPUT;
41
42ob_start();
43foreach ($offsets as $dimension) {
44    $container = new stdClass();
45    $error = '(new stdClass())[' . zend_test_var_export($dimension) . '] has different outputs' . "\n";
46
47    include $var_dim_filename;
48    $varOutput = ob_get_contents();
49    ob_clean();
50    $varOutput = str_replace(
51        [$var_dim_filename],
52        ['%s'],
53        $varOutput
54    );
55
56    if ($varOutput !== EXPECTED_OUTPUT) {
57        file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_object_container_{$failuresNb}.txt", $varOutput);
58        ++$failuresNb;
59        $failures[] = $error;
60    }
61    ++$testCasesTotal;
62}
63ob_end_clean();
64
65echo "Executed tests\n";
66if ($failures !== []) {
67    echo "Failures:\n" . implode($failures);
68}
69
70?>
71--EXPECT--
72Executed tests
73