Skip to content

W.I.P: Zend: container/offset semantics RFC: object handlers #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dd8f015
Zend/zend_execute.c: use zend_check_string_offset() for all string of…
Girgias Jan 25, 2024
c959a97
Zend: Move dimension handlers from object handlers to CE
Girgias Jan 31, 2024
c60d238
Add assertion and debug check function that interfaces are implemented
Girgias Feb 19, 2024
70b6a1b
Disable debug
Girgias Feb 20, 2024
1dc50b3
Deref offset in VM
Girgias May 28, 2024
967dc82
ext/simplexml: Convert SimpleXML to new dimension API
Girgias May 28, 2024
c1fdacc
ext/dom: Convert DOM classes to new dimension API
Girgias May 28, 2024
0912c26
ext/intl: Convert ResourceBundle to new dimension API
Girgias Feb 27, 2024
10540da
ext/pdo: Convert PDORow to new dimension API
Girgias Feb 27, 2024
d345728
ext/spl: Convert SplFixedArray to new API
Girgias Feb 27, 2024
8863b39
VM call offsetGet when offsetExists returns true
Girgias May 28, 2024
a398415
Zend: Convert WeakMap to new dimension API
Girgias May 28, 2024
56331e7
ext/spl: Convert SplObjectStorage to new API
Girgias May 30, 2024
838e4d4
ext/spl: Clean-up SplObjectStorage implementation
Girgias May 30, 2024
e157227
Use static struct for SplObjectStorage dimension handlers
Girgias Jun 8, 2024
04f72f5
ext/spl: [WIP] Convert ArrayObject to new API
Girgias May 31, 2024
3242ad9
ext/ffi: Convert CData to new API
Girgias Feb 21, 2024
f302e5d
Use static struct for function handlers in zend_test
Girgias Jun 8, 2024
8f9a6d7
Use static structs for internal classes
Girgias Jun 8, 2024
c27c676
ext/phar: expand test to cover issue with offsetGet
Girgias Jun 7, 2024
a360dfd
ext/phar: offsetExists should return false when file entry is not bas…
Girgias Jun 7, 2024
0016634
Fix append binary op
Girgias Jun 10, 2024
5027993
Fix issue when returning object by-ref in fetch
Girgias Jun 10, 2024
25172d8
Clean-up implementation of zend_legacy_ArrayAccess_fetch_dimension
Girgias Jun 10, 2024
89ecd6a
Fix by ref assignments for ArrayObject only
Girgias Jun 10, 2024
a9e946a
Support indirect, add tests for objects with binary op
Girgias Jun 11, 2024
9de2fd5
Fix ArrayAccess for good
Girgias Jun 11, 2024
096f98a
Fix indirect modification of offset when handler uses global
Girgias Jul 1, 2024
16ed7fc
Improve debug assertion now that conversion is mostly done
Girgias Jul 1, 2024
5047f2f
JIT Support
Girgias Jul 2, 2024
9b4e06a
Do we even need to create a ref?
Girgias Jul 2, 2024
7eff740
Add missing GMP extension
Girgias Jul 3, 2024
fd6a17c
ArrayObject arginfos
Girgias Jul 3, 2024
703e250
Define default ArrayAccess handlers for internal classes
Girgias Jul 3, 2024
809047c
ext/com: Convert to new API [W.I.P.]
Girgias Jul 3, 2024
172e5b5
Remove old dimension handlers
Girgias Jul 3, 2024
1b11052
Fix persistence code in opcache
Girgias Jul 9, 2024
b757191
opcache file persistence W.I.P.
Girgias Jul 9, 2024
cb78781
Remove unused zend_class_arrayaccess_funcs struct now
Girgias Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/tests/bug31683.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ string(2) "ok"
string(2) "ok"
string(2) "ok"
string(2) "ok"
string(2) "ok"
NULL
string(2) "ok"
string(2) "ok"
Expand All @@ -90,6 +91,7 @@ string(2) "ok"
string(2) "ok"
string(2) "ok"
string(2) "ok"
string(2) "ok"
NULL
string(2) "ok"
string(2) "ok"
Expand Down
4 changes: 4 additions & 0 deletions Zend/tests/bug63217.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,19 @@ var_dump($ao);
?>
--EXPECT--
offsetExists given string(1) "0"
offsetGet given string(1) "0"
offsetExists given string(3) "123"
offsetGet given string(3) "123"
offsetUnset given string(1) "0"
offsetUnset given string(3) "123"
offsetSet given string(1) "0"
offsetSet given string(3) "123"
offsetGet given string(1) "0"
offsetGet given string(3) "123"
offsetExists given string(1) "0"
offsetGet given string(1) "0"
offsetExists given string(3) "123"
offsetGet given string(3) "123"
offsetUnset given string(1) "0"
offsetUnset given string(3) "123"
offsetSet given string(1) "0"
Expand Down
4 changes: 3 additions & 1 deletion Zend/tests/bug69955.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ $c10 = new C10;

var_dump($c10[] += 5);
?>
--EXPECT--
--EXPECTF--
Inside C10::offsetGet
NULL

Notice: Indirect modification of overloaded element of C10 has no effect in %s on line %d

Inside C10::offsetSet
NULL
int(105)
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug75420.10.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ var_dump($obj[$name] ?? 12);
var_dump($name);
?>
--EXPECT--
string(6) "foofoo"
int(24)
int(42)
int(24)
2 changes: 1 addition & 1 deletion Zend/tests/bug75420.11.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ var_dump(empty($obj[$name]));
var_dump($name);
?>
--EXPECT--
string(3) "foo"
int(24)
bool(false)
int(24)
2 changes: 1 addition & 1 deletion Zend/tests/bug75420.12.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ var_dump(empty($obj[$name]));
var_dump($name);
?>
--EXPECT--
string(6) "foofoo"
int(24)
bool(false)
int(24)
20 changes: 20 additions & 0 deletions Zend/tests/bug75420.17.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #75420.17 (Indirect modification of magic method argument)
--FILE--
<?php
class Test implements ArrayAccess {
public function offsetExists($x): bool { $GLOBALS["obj"] = 24; return true; }
public function offsetGet($x): mixed { var_dump($x); return 42; }
public function offsetSet($x, $y): void { }
public function offsetUnset($x): void { }
}

$obj = new Test;
$name = "foo";
var_dump(isset($obj[$name]));
var_dump($obj);
?>
--EXPECT--
string(3) "foo"
bool(true)
int(24)
2 changes: 1 addition & 1 deletion Zend/tests/bug75420.9.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ var_dump($obj[$name] ?? 12);
var_dump($name);
?>
--EXPECT--
string(3) "foo"
int(24)
int(42)
int(24)
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@ offsetGet
offsetGet
offsetGet
offsetExists
offsetGet
offsetExists
offsetGet
offsetExists
offsetGet
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ int(25)
isset():
string(15) "CLASS_NAME::offsetExists"
VAR_DUMP_OF_OFFSET
string(12) "CLASS_NAME::offsetGet"
VAR_DUMP_OF_OFFSET
bool(true)
empty():
string(15) "CLASS_NAME::offsetExists"
Expand Down Expand Up @@ -100,7 +102,7 @@ Cannot unset offset in a non-array variable
OUTPUT;

ob_start();
foreach (['A', 'B'] as $class) {
foreach (['A'] as $class) {
foreach ($offsets as $dimension) {
$container = new $class();
$error = "(new $class())[" . zend_test_var_export($dimension) . '] has different outputs' . "\n";
Expand Down
86 changes: 32 additions & 54 deletions Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool(false)
Nested null coalesce:
int(30)
Nested unset():

OUTPUT;

$EXPECTED_OUTPUT_VALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_VALID_OFFSETS) . '$/s';
Expand All @@ -58,27 +59,33 @@ Deprecated: Implicit conversion from float %F to int loses precision in %s on li
Read:

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
int(15)
int(5)
Read-Write:

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
isset():

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
bool(true)
empty():

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
bool(false)
null coalesce:

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
int(35)

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
int(25)
Reference to dimension:

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
Value of reference:
int(35)
int(25)
Value of container dimension after write to reference (should be int(100) if successful):

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
Expand All @@ -90,9 +97,9 @@ Nested read:

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Warning: Undefined array key 0 in %s on line %d
Warning: Undefined array key %s in %s on line %d

Warning: Trying to access array offset on null in %s on line %d
Warning: Trying to access array offset on null in %s on line 74
NULL
Nested write:

Expand All @@ -108,20 +115,26 @@ Nested isset():

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
bool(true)
Nested empty():

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
bool(false)
Nested null coalesce:

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
int(25)

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
int(30)
Nested unset():

Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
Expand Down Expand Up @@ -164,57 +177,12 @@ Cannot access offset of type %s in isset or empty
Nested null coalesce:
Cannot access offset of type %s in isset or empty
Nested unset():

Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line %d
Cannot unset offset of type %s on ArrayObject
Cannot access offset of type %s on ArrayObject

OUTPUT;

$EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_INVALID_OFFSETS) . '$/s';

const EXPECTED_OUTPUT_NULL_OFFSET = <<<OUTPUT
Read before write:

Warning: Undefined array key "" in %s on line 8
NULL
Write:
Read:

Warning: Undefined array key "" in %s on line 22
NULL
Read-Write:

Warning: Undefined array key "" in %s on line 29
isset():
bool(false)
empty():
bool(true)
null coalesce:
string(7) "default"
Reference to dimension:
Value of reference:
NULL
Value of container dimension after write to reference (should be int(100) if successful):
int(100)
unset():
Nested read:

Warning: Undefined array key "" in %s on line 74

Warning: Trying to access array offset on null in %s on line 74
NULL
Nested write:
Nested Read-Write:
Nested isset():
bool(true)
Nested empty():
bool(false)
Nested null coalesce:
int(30)
Nested unset():

OUTPUT;

const EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS = <<<OUTPUT
Read before write:

Expand All @@ -236,14 +204,20 @@ Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 29
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 29
isset():

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 36

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 36
bool(true)
empty():

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 42

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 42
bool(false)
null coalesce:

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 48

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 48
int(25)
Reference to dimension:
Expand Down Expand Up @@ -280,18 +254,24 @@ Nested isset():

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
bool(true)
Nested empty():

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 101

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 101

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 101
bool(false)
Nested null coalesce:

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 107

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 107

Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 107
int(30)
Nested unset():
Expand Down Expand Up @@ -323,7 +303,6 @@ foreach ($offsets as $dimension) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_NULL_OFFSET
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_ArrayObject_container_{$failuresNb}.txt", $varOutput);
Expand Down Expand Up @@ -354,7 +333,6 @@ foreach ($offsets as $offset) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_NULL_OFFSET
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_ArrayObject_container_{$failuresNb}.txt", $varOutput);
Expand Down
Loading
Loading