Bug #81144 [NEW]: Cuckoo egg
From: wojtek at uniwizard dot com
Operating system: Alpine Linux 3.13
PHP version: 7.4.20
Package: Variables related
Bug Type: Bug
Bug description:Cuckoo egg
Description:
------------
Using the references of function/method arguments of a specific type, I
have the option to "throw" a variable of a specific type with a value of
a different type than the specified one.
Sample scipt started by simply: "php test.php"
Test script:
---------------
<?php
function test_function(int &$variableByReference, $value)
{
var_dump(['result 1 from inside test_function()' =>
$variableByReference]);
$variableByReference = $value;
var_dump(['result 2 from inside test_function()' =>
$variableByReference]);
}
$testVar1 = 234;
$testValue = 'cuckoo egg';
test_function($testVar1, $testValue);
var_dump(['result 3 from outside test_function()' => $testVar1]);
Expected result:
----------------
I expect, when set variable "$testValue = 'cuckoo egg';" and start
script, to get an error message something like this: "Fatal error:
Uncaught TypeError: Argument 1 passed to test_function() must be of the
type int, string given".
This means the value of the variable is tested ONLY on SET value of
reference, not RETURNED by reference value.
Actual result:
--------------
The script set anything to reference without testing return value (by
reference).
$ php test.php
array(1) {
["result 1 from inside test_function()"]=>
int(234)
}
array(1) {
["result 2 from inside test_function()"]=>
string(10) "cuckoo egg"
}
array(1) {
["result 3 from outside test_function()"]=>
string(10) "cuckoo egg"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=81144&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81144&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81144&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81144&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81144&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81144&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81144&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81144&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81144&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81144&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81144&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81144&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81144&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81144&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81144&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81144&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81144&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81144&r=mysqlcfg
Thread (2 messages)
- wojtek at uniwizard dot com