php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72038 Function calls with values to a by-ref parameter don't always throw a notice
Submitted: 2016-04-16 17:53 UTC Modified: 2016-04-16 18:00 UTC
From: bwoebi@php.net Assigned: bwoebi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2016-04-16 (Git) OS: Irrelevant
Private report: No CVE-ID: None
 [2016-04-16 17:53 UTC] bwoebi@php.net
Description:
------------
The following works as expected (with the first parameter of test() accepting a reference) and doesn't throw a notice:

test($foo = 2 /* anything not being an object */);

But objects omit that notice. Seems to be a PHP 4 relict, but today this should definitely emit a notice.

Test script:
---------------
test($foo = new stdClass);

function test(&$param) {
        $param = 1;
}

var_dump($foo);

Expected result:
----------------
Notice: Only variables should be passed by reference in - on line 5
object(stdClass)#1 (0) {
}


Actual result:
--------------
object(stdClass)#1 (0) {
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-16 18:00 UTC] bwoebi@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bwoebi
 [2016-04-16 18:36 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=15d1d4f45bea8c7f9eedf0534ffee804640baaf1
Log: Fixed bug #72038 (Function calls with values to a by-ref parameter don't always throw a notice)
 [2016-04-16 18:36 UTC] bwoebi@php.net
-Status: Assigned +Status: Closed
 [2016-04-16 18:38 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=15d1d4f45bea8c7f9eedf0534ffee804640baaf1
Log: Fixed bug #72038 (Function calls with values to a by-ref parameter don't always throw a notice)
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=15d1d4f45bea8c7f9eedf0534ffee804640baaf1
Log: Fixed bug #72038 (Function calls with values to a by-ref parameter don't always throw a notice)
 [2018-01-18 19:24 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=343850
Log: foo(new foobar()) raises a notice as of PHP 7.0.7 (doc bug #75844)

This is due to the fixing of #72038
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC