diff --git a/Zend/tests/offsets/ArrayAccess_container_offset_behaviour.phpt b/Zend/tests/offsets/ArrayAccess_container_offset_behaviour.phpt index 189dc0c1a2e6..5a5fab352be3 100644 --- a/Zend/tests/offsets/ArrayAccess_container_offset_behaviour.phpt +++ b/Zend/tests/offsets/ArrayAccess_container_offset_behaviour.phpt @@ -40,6 +40,17 @@ VAR_DUMP_OF_OFFSET string(12) "CLASS_NAME::offsetGet" VAR_DUMP_OF_OFFSET int(5) +Reference to dimension: +string(12) "CLASS_NAME::offsetGet" +VAR_DUMP_OF_OFFSET + +Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 55 +Value of reference: +int(5) +Value of container dimension after write to reference (should be int(100) if successful): +string(12) "CLASS_NAME::offsetGet" +VAR_DUMP_OF_OFFSET +int(5) unset(): string(14) "CLASS_NAME::offsetUnset" VAR_DUMP_OF_OFFSET @@ -47,19 +58,19 @@ Nested read: string(12) "CLASS_NAME::offsetGet" VAR_DUMP_OF_OFFSET -Warning: Trying to access array offset on int in %s on line 62 +Warning: Trying to access array offset on int in %s on line 74 NULL Nested write: string(12) "CLASS_NAME::offsetGet" VAR_DUMP_OF_OFFSET -Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 69 +Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 81 Cannot use a scalar value as an array Nested Read-Write: string(12) "CLASS_NAME::offsetGet" VAR_DUMP_OF_OFFSET -Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 76 +Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 88 Cannot use a scalar value as an array Nested isset(): string(15) "CLASS_NAME::offsetExists" @@ -83,7 +94,7 @@ Nested unset(): string(12) "CLASS_NAME::offsetGet" VAR_DUMP_OF_OFFSET -Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 102 +Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 114 Cannot unset offset in a non-array variable OUTPUT; diff --git a/Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt b/Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt index 2e43d57d1840..ae4685f093ee 100644 --- a/Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt +++ b/Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt @@ -8,7 +8,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; const EXPECTED_OUTPUT_VALID_OFFSETS = <<getMessage(), PHP_EOL; +} +exportObject($o); + ?> --EXPECTF-- read op @@ -281,3 +290,7 @@ nested reference fetching Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d Error: Cannot use a scalar value as an array DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' +reference fetch-append + +Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d +DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized diff --git a/Zend/tests/offsets/invalid_container_offset_behaviour.phpt b/Zend/tests/offsets/invalid_container_offset_behaviour.phpt index a3d41bd3743b..2a403d339f86 100644 --- a/Zend/tests/offsets/invalid_container_offset_behaviour.phpt +++ b/Zend/tests/offsets/invalid_container_offset_behaviour.phpt @@ -36,13 +36,15 @@ empty(): bool(true) null coalesce: string(7) "default" +Reference to dimension: +Cannot use a scalar value as an array unset(): Cannot unset offset in a non-array variable Nested read: -Warning: Trying to access array offset on $containerStr in %s on line 62 +Warning: Trying to access array offset on $containerStr in %s on line 74 -Warning: Trying to access array offset on null in %s on line 62 +Warning: Trying to access array offset on null in %s on line 74 NULL Nested write: Cannot use a scalar value as an array diff --git a/Zend/tests/offsets/null_container_offset_behaviour.phpt b/Zend/tests/offsets/null_container_offset_behaviour.phpt index ec3f253e58a5..e80ff059469d 100644 --- a/Zend/tests/offsets/null_container_offset_behaviour.phpt +++ b/Zend/tests/offsets/null_container_offset_behaviour.phpt @@ -8,7 +8,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; const EXPECTED_OUTPUT_VALID_OFFSETS = <<getMessage(), "\n"; + } +} + +?> +--EXPECTF-- +NULL container: +array(1) { + [0]=> + &NULL +} +NULL +false container: + +Deprecated: Automatic conversion of false to array is deprecated in %s on line %d +array(1) { + [0]=> + &NULL +} +NULL +true container: +Error: Cannot use a scalar value as an array +4 container: +Error: Cannot use a scalar value as an array +5.5 container: +Error: Cannot use a scalar value as an array +'10' container: +Error: [] operator not supported for strings +'25.5' container: +Error: [] operator not supported for strings +'string' container: +Error: [] operator not supported for strings +[] container: +array(1) { + [0]=> + &NULL +} +NULL +STDERR container: +Error: Cannot use a scalar value as an array +new stdClass() container: +Error: Cannot use object of type stdClass as array +new ArrayObject() container: + +Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line %d +object(ArrayObject)#2 (1) { + ["storage":"ArrayObject":private]=> + array(0) { + } +} +NULL +new A() container: +string(12) "A::offsetGet" +NULL + +Notice: Indirect modification of overloaded element of A has no effect in %s on line %d +object(A)#3 (0) { +} +int(5) +new B() container: + +Notice: Indirect modification of overloaded element of B has no effect in %s on line %d +ArgumentCountError: B::offsetGet(): Argument #1 ($offset) not passed diff --git a/Zend/tests/offsets/string_container_offset_behaviour.phpt b/Zend/tests/offsets/string_container_offset_behaviour.phpt index 695008c5dbc2..55427957f7af 100644 --- a/Zend/tests/offsets/string_container_offset_behaviour.phpt +++ b/Zend/tests/offsets/string_container_offset_behaviour.phpt @@ -8,7 +8,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; const EXPECTED_OUTPUT_VALID_OFFSETS = <<getMessage(), "\n"; } +// Fetch reference +try { + echo "Reference to dimension:\n"; + $r = &$container[$dimension]; + echo "Value of reference:\n"; + var_dump($r); + $r = 100; + echo "Value of container dimension after write to reference (should be int(100) if successful):\n"; + var_dump($container[$dimension]); +} catch (\Throwable $e) { + echo $e->getMessage(), "\n"; +} // Unset try { echo "unset():\n";