Doc #80477 [Opn]: 2nd argument should be count not num
| From: | guillaume dot olivrin at protonmail dot com | Date: | Thu, 03 Dec 2020 08:39:23 +0000 |
| Subject: | Doc #80477 [Opn]: 2nd argument should be count not num | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-18181@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80477&edit=1
ID: 80477
User updated by: guillaume dot olivrin at protonmail dot com
Reported by: guillaume dot olivrin at protonmail dot com
Summary: 2nd argument should be count not num
Status: Open
Type: Documentation Problem
Package: Unknown/Other Function
Operating System: Windows 10 Pro
PHP Version: 8.0.0
Block user comment: N
Private report: N
New Comment:
Reproduce bug:
https://3v4l.org/b5k6W
See fix:
https://3v4l.org/pSqN6
Previous Comments:
------------------------------------------------------------------------
[2020-12-03 08:33:33] guillaume dot olivrin at protonmail dot com
Description:
------------
---
From manual page: https://php.net/function.array-fill
---
I tried PHP8 new functionnality 'named arguments' with this example below taken from a
presentation but it didn't work.
> array_fill(start_index: 2, num: 3, value: 'PHP8')
--> Fatal error: Uncaught Error: Unknown named parameter $num in Command line code:1
The documentation says :
> array_fill ( int $start_index , int $num , mixed $value ) : array
I used the following to get the argument name from my PHP8 :
> $reflx = new ReflectionFunction('array_fill'); print_r($reflx->getParameters());
--> count
I suggest a change in the documentation.
Test script:
---------------
Bug:
array_fill(start_index: 2, num: 3, value: 'PHP8')
Fixed:
array_fill(start_index: 2, count: 3, value: 'PHP8')
Expected result:
----------------
array(3) {
[2]=>
string(4) "PHP8"
[3]=>
string(4) "PHP8"
[4]=>
string(4) "PHP8"
}
Actual result:
--------------
Fatal error: Uncaught Error: Unknown named parameter $num in Command line code:1
Stack trace:
#0 {main}
thrown in Command line code on line 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80477&edit=1