You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Corrupted variable type Argument #1 ($string) must be of type string, string given #21972
TypeError: strtolower(): Argument #1 ($string) must be of type string, string given
But I expected this output instead:
$b = "false"
PHP Version
8.4.20
Operating System
Ubuntu / docker
What is confusing here is that we use strict types thus the return type of getTypedValue always has to be a string. This does not throw a TypeError so it should be a string.
If we add more debugging to the return value before putting it to strtolower:
$a = $this->getTypedValue();
// do debugging here$b = strtolower($a);
printing the value: "false"
gettype($a) type: "unknown type"
check if its a class (print $a::class): Cannot use \"::class\" on string
From my experience, without looking into details, "string given", when string is expected, happens when references containing a string are passed around, without references being expected (i.e. there was no automatic unwrapping of the reference happening due to some reason).
I think this happens since a typed by-value return could leak an internal reference wrapper after a by-reference argument call. OPcache could then infer the returned value as string and elide later checks, while the actual zval still had IS_REFERENCE at the outer level. (so when you use gettype its unknown type)
This is a simple fix I guess :) See if this works #21973
Activity
bwoebi commentedon May 7, 2026
From my experience, without looking into details, "string given", when string is expected, happens when references containing a string are passed around, without references being expected (i.e. there was no automatic unwrapping of the reference happening due to some reason).
LamentXU123 commentedon May 7, 2026
I think this happens since a typed by-value return could leak an internal reference wrapper after a by-reference argument call. OPcache could then infer the returned value as
stringand elide later checks, while the actual zval still hadIS_REFERENCEat the outer level. (so when you use gettype its unknown type)This is a simple fix I guess :) See if this works #21973
susnux commentedon Jun 30, 2026
Resolved with #21973 🥳
salmart-dev commentedon Jun 30, 2026
It seems like the underlying bug affects PHP 8.3.31 too.