php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68446 Array constant not accepted for array parameter default
Submitted: 2014-11-18 22:27 UTC Modified: 2014-11-23 22:58 UTC
From: ajf at ajf dot me Assigned: bwoebi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.6.3 OS: OS X Yosemite
Private report: No CVE-ID: None
 [2014-11-18 22:27 UTC] ajf at ajf dot me
Description:
------------
I made a constant array and tried to use it as the default for an array parameter, but it wouldn't accept it.

Test script:
---------------
<?php

const FOO = [];

function foobar(array $foo = FOO) {}

Actual result:
--------------
Fatal error: Default value for parameters with array type hint can only be an array or NULL in %s on line 5

Process exited with code 255.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-23 20:11 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ef138b0c7c4e9532e205f45c18a72aa1d279c24
Log: Fix bug #68446 (bug with constant defaults and type hints)
 [2014-11-23 20:11 UTC] bwoebi@php.net
-Status: Open +Status: Closed
 [2014-11-23 22:51 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ef138b0c7c4e9532e205f45c18a72aa1d279c24
Log: Fix bug #68446 (bug with constant defaults and type hints)
 [2014-11-23 22:51 UTC] stas@php.net
-Status: Closed +Status: Re-Opened -Assigned To: +Assigned To: bwoebi
 [2014-11-23 22:51 UTC] stas@php.net
What about master branch? Was it intentionally not merged?
 [2014-11-23 22:53 UTC] stas@php.net
-Status: Re-Opened +Status: Closed
 [2014-11-23 22:53 UTC] stas@php.net
oops, looks like I was too hasty
 [2014-11-23 22:58 UTC] bwoebi@php.net
Yeah, sorry. It took me some time to figure out how to port that fix to master. Had to basically reimplement the whole thing for master.
 [2014-11-25 11:28 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aba95c239986e05bbae87cc1b7195fcf6da094bc
Log: Revert &quot;Fix bug #68446 (bug with constant defaults and type hints)&quot;
 [2014-11-25 12:06 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aba95c239986e05bbae87cc1b7195fcf6da094bc
Log: Revert &quot;Fix bug #68446 (bug with constant defaults and type hints)&quot;
 [2014-11-26 16:21 UTC] ab@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aba95c239986e05bbae87cc1b7195fcf6da094bc
Log: Revert &quot;Fix bug #68446 (bug with constant defaults and type hints)&quot;
 [2014-11-26 16:21 UTC] ab@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ef138b0c7c4e9532e205f45c18a72aa1d279c24
Log: Fix bug #68446 (bug with constant defaults and type hints)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC