Category
Language · php-src-strict · resource dim fetch
Problem
Using a resource as an array container must match Zend:
| Op |
Zend 8.4.24 |
VM (PROFILE=8.4) |
Read $r[0] |
Warning Trying to access array offset on resource; continues (null) |
Error: Cannot use object of type Resource as array |
Write $r[0]=1 |
Error: Cannot use a scalar value as an array |
Error: Cannot use object of type Resource as array |
isset($r[0]) / empty($r[0]) |
false / true (no throw) |
Fatal same Resource Error |
Probed 2026-08-10 — php:8.4-cli 8.4.24 vs PHP_COMPILER_PROFILE=8.4 php bin/vm.php.
Related closed: #4867 (generic non-container Warning), #29550 (resource used as offset key), #29559 (string-offset TypeError wording Resource vs resource) — this issue is resource as the array subject.
php-src reference
PHP implementation target
- Dim fetch/isset/empty on resource in
lib/VM/ (and JIT): Warning + null on read; write Error text matching Zend (Cannot use a scalar value as an array); isset/empty soft false/true
- Prefer shared type-dispatch with other non-array dim paths; PHP-in-PHP; no new
runtime/*.c
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
printf "%s\n" "<?php
\$f = fopen(\"php://memory\", \"r\");
try { var_export(\$f[0]); echo PHP_EOL; } catch (Throwable \$e) { echo get_class(\$e), \":\", \$e->getMessage(), PHP_EOL; }
var_export(isset(\$f[0])); echo PHP_EOL;
fclose(\$f);
" >/tmp/res_dim.php
php -d error_reporting=E_ALL -d display_errors=1 bin/vm.php /tmp/res_dim.php
'
Done when
Category
Language· php-src-strict · resource dim fetchProblem
Using a resource as an array container must match Zend:
$r[0]Trying to access array offset on resource; continues (null)Error: Cannot use object of type Resource as array$r[0]=1Error: Cannot use a scalar value as an arrayError: Cannot use object of type Resource as arrayisset($r[0])/empty($r[0])false/true(no throw)Probed 2026-08-10 —
php:8.4-cli8.4.24 vsPHP_COMPILER_PROFILE=8.4php bin/vm.php.Related closed: #4867 (generic non-container Warning), #29550 (resource used as offset key), #29559 (string-offset TypeError wording
Resourcevsresource) — this issue is resource as the array subject.php-src reference
Zend/zend_execute.c— dim fetch/assign on non-arrayZend/zend_vm_def.h—ZEND_FETCH_DIM_*/ZEND_ASSIGN_DIMPHP implementation target
lib/VM/(and JIT): Warning + null on read; write Error text matching Zend (Cannot use a scalar value as an array); isset/empty soft false/trueruntime/*.cRepro
Done when
Trying to access array offset on resource(not Resource Error)Cannot use a scalar value as an array)isset/emptyon resource dim do not throw; values match Zend.phptundertest/compliance/cases/