|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-06-16 09:35 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2021-06-16 09:35 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
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" }