php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80477 2nd argument should be count not num
Submitted: 2020-12-03 08:33 UTC Modified: 2020-12-04 00:36 UTC
From: guillaume dot olivrin at protonmail dot com Assigned: cmb (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 8.0.0 OS: Windows 10 Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: guillaume dot olivrin at protonmail dot com
New email:
PHP Version: OS:

 

 [2020-12-03 08:33 UTC] 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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-03 08:39 UTC] guillaume dot olivrin at protonmail dot com
Reproduce bug:
https://3v4l.org/b5k6W

See fix:
https://3v4l.org/pSqN6
 [2020-12-03 08:59 UTC] kocsismate@php.net
The following pull request has been associated:

Patch Name: Generate array methodsynopses based on stubs
On GitHub:  https://github.com/php/doc-en/pull/266
Patch:      https://github.com/php/doc-en/pull/266.patch
 [2020-12-03 09:05 UTC] kocsismate@php.net
Currently, the manual is not exactly up-to-date with PHP 8.0 changes. This project is in progress, and quite a few extensions already has the correct signatures (see the closed PRs): https://github.com/php/doc-en/pulls?q=is%3Apr+is%3Aopen+label%3Amethodsynopses

I quickly submitted a PR to fix the array signatures as well.
 [2020-12-04 00:36 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 19:01:28 2025 UTC