Category
language · php-src-strict · parameters · compile-time fatal
Problem
php-src rejects $this as a parameter name at compile time (zend_compile_params). This compiler accepts function foo($this), methods, arrows, and by-ref function foo(&$this) — illegal programs run and print instead of aborting. VM and JIT both take the accept path.
| Repro |
Zend 8.2+ |
VM/JIT (2026-08-18 @ bf1e42be86) |
function foo($this) {} echo "accepted\n"; |
Fatal: Cannot use $this as parameter (rc=255) |
accepted (rc=0) |
function foo(&$this) {} |
same fatal |
accepted (rc=0) |
fn($this) => 1 |
same fatal |
accepted (rc=0) |
class C { function m($this) {} } |
same fatal |
accepted (rc=0) |
Sibling of #32152 (use ($this) lexical). Silent accept is a php-src-strict miss, not an error-text nit.
php-src reference
PHP implementation target
lib/Compiler.php param compile (zend_compile_params path next to maybeEmitOptionalBeforeRequiredParamDeprecations / assertNoThisInClosureUseVars) — when a param name is $this, emit Zend's compile fatal and abort
- Same path for JIT/AOT; no new
runtime/*.c logic
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_param_this.php 2>&1 | head -5'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_param_this.php 2>&1 | head -5'
Done when
Category
language· php-src-strict · parameters · compile-time fatalProblem
php-src rejects
$thisas a parameter name at compile time (zend_compile_params). This compiler acceptsfunction foo($this), methods, arrows, and by-reffunction foo(&$this)— illegal programs run and print instead of aborting. VM and JIT both take the accept path.bf1e42be86)function foo($this) {} echo "accepted\n";accepted(rc=0)function foo(&$this) {}accepted(rc=0)fn($this) => 1accepted(rc=0)class C { function m($this) {} }accepted(rc=0)Sibling of #32152 (
use ($this)lexical). Silent accept is a php-src-strict miss, not an error-text nit.php-src reference
Zend/zend_compile.c—zend_compile_params(); rejects$thisas a parameter name (Cannot use $this as parameter)PHP implementation target
lib/Compiler.phpparam compile (zend_compile_paramspath next tomaybeEmitOptionalBeforeRequiredParamDeprecations/assertNoThisInClosureUseVars) — when a param name is$this, emit Zend's compile fatal and abortruntime/*.clogicRepro
Done when
Cannot use $this as parameter(rc≠0, noacceptedoutput) for function / method / arrow / by-ref forms.phptguard undertest/compliance/cases/language/(e.g.param_this_compile_fatal.phpt)