php / php/doc-en

array_intersect doesn't support named arguments

Open
#3,233 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

From manual page: https://php.net/function.array-intersect


array_intersect(arrays: $a, array: $b);
array_intersect(hello: $a, world: $c, array: $b);

When named arguments are supported this works normally, see

function foo($array, ...$arrays) {}
foo(arrays: $a, array: $b);
foo(hello: $a, world: $c, array: $b);

This isn't documented anywhere though.
This also affects https://www.php.net/manual/en/function.array-intersect-key.php and possibly a variety of other functions.

EDIT: this seems to be wrong for all functions that are documented with This function can now be called with only one parameter. Formerly, at least two parameters have been required. e.g. arary_diff,... too

EDIT2: looks like other functions that are not annotated like that, e.g. sprintf have the same issue.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the manual pages for array_intersect(), array_intersect_key(), array_diff(), and sprintf(), then compare their parameter documentation and named-argument behavior. Identify the other affected functions and update the relevant documentation consistently; done means the named-argument support and applicable parameter rules are accurately documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.