Skip to content

Commit dba7099

Browse files
inform the type in the array displacement error message.
1 parent 0717f23 commit dba7099

File tree

9 files changed

+29
-41
lines changed

9 files changed

+29
-41
lines changed

Zend/tests/036.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ try {
1111

1212
?>
1313
--EXPECT--
14-
Illegal offset type: cannot be of type object
14+
Illegal offset type: cannot be of type Closure

Zend/tests/038.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ try {
1111

1212
?>
1313
--EXPECT--
14-
Illegal offset type
14+
Illegal offset type: cannot be of type Closure

Zend/tests/offset_array.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int(1)
5656

5757
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
5858
int(%d)
59-
Illegal offset type: cannot be of type object
59+
Illegal offset type: cannot be of type stdClass
6060
Illegal offset type: cannot be of type array
6161
Illegal offset type: cannot be of type array
6262
Done

Zend/zend_execute.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,9 +1440,9 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(v
14401440
zend_throw_error(NULL, "Cannot use object as array");
14411441
}
14421442

1443-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void)
1443+
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(const zval *offset)
14441444
{
1445-
zend_type_error("Illegal offset type");
1445+
zend_type_error("Illegal offset type: cannot be of type %s", zend_zval_type_name(offset));
14461446
}
14471447

14481448
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_string_offset(const zval *offset)
@@ -2313,14 +2313,8 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval
23132313
case IS_TRUE:
23142314
value->lval = 1;
23152315
return IS_LONG;
2316-
case IS_ARRAY:
2317-
zend_type_error("Illegal offset type: cannot be of type array");
2318-
return IS_ARRAY;
2319-
case IS_OBJECT:
2320-
zend_type_error("Illegal offset type: cannot be of type object");
2321-
return IS_OBJECT;
23222316
default:
2323-
zend_illegal_offset();
2317+
zend_illegal_offset(dim);
23242318
return IS_NULL;
23252319
}
23262320
}
@@ -2393,14 +2387,8 @@ static zend_never_inline zend_uchar slow_index_convert_w(HashTable *ht, const zv
23932387
case IS_TRUE:
23942388
value->lval = 1;
23952389
return IS_LONG;
2396-
case IS_ARRAY:
2397-
zend_type_error("Illegal offset type: cannot be of type array");
2398-
return IS_ARRAY;
2399-
case IS_OBJECT:
2400-
zend_type_error("Illegal offset type: cannot be of type object");
2401-
return IS_OBJECT;
24022390
default:
2403-
zend_illegal_offset();
2391+
zend_illegal_offset(dim);
24042392
return IS_NULL;
24052393
}
24062394
}
@@ -2982,7 +2970,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable
29822970
str = ZSTR_EMPTY_ALLOC();
29832971
goto str_key;
29842972
} else {
2985-
zend_illegal_offset();
2973+
zend_illegal_offset(key);
29862974
return 0;
29872975
}
29882976
}

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6023,7 +6023,7 @@ ZEND_VM_C_LABEL(num_index):
60236023
str = ZSTR_EMPTY_ALLOC();
60246024
ZEND_VM_C_GOTO(str_index);
60256025
} else {
6026-
zend_illegal_offset();
6026+
zend_illegal_offset(offset);
60276027
zval_ptr_dtor_nogc(expr_ptr);
60286028
}
60296029
FREE_OP2();

Zend/zend_vm_execute.h

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/opcache/tests/jit/assign_dim_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ array(1) {
161161
int(1)
162162
}
163163
}
164-
Illegal offset type: cannot be of type object
164+
Illegal offset type: cannot be of type Closure
165165
array(1) {
166166
[0]=>
167167
array(2) {

ext/opcache/tests/opt/inference_002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ opcache.optimization_level=-1
99
var_dump([[]=>&$x]);
1010
?>
1111
--EXPECTF--
12-
Fatal error: Uncaught TypeError: Illegal offset type in %sinference_002.php:2
12+
Fatal error: Uncaught TypeError: Illegal offset type: cannot be of type array in %sinference_002.php:2
1313
Stack trace:
1414
#0 {main}
15-
thrown in %sinference_002.php on line 2
15+
thrown in %sinference_002.php on line 2

ext/standard/tests/array/array_key_exists.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ bool(false)
202202
bool(true)
203203

204204
*** Testing error conditions ***
205-
Illegal offset type
205+
Illegal offset type: cannot be of type array
206206

207207
*** Testing operation on objects ***
208208
array_key_exists(): Argument #2 ($array) must be of type array, key_check given

0 commit comments

Comments
 (0)