-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersrefactorDesirable refactoring of the feature/script in the issueDesirable refactoring of the feature/script in the issue
Description
With the release of PHP >8.x, named arguments have been added to the spec.
We can make use of them - primarily for functions and methods with a number of optional arguments - to make calling them easier to read.
Once the current refactoring of how pages are handles has been completed (see #14 #15), focus should be shifted to updating core functions, methods, and classes, and to implement usage of named arguments for applicable function calls.
Example
<?php
function NamedArgsTest($username, $email = null, $role = 'subscriber', $active = true) {
return [
'username' => $username,
'email' => $email,
'role' => $role,
'active' => $active
];
}
$NamedArgsOutput = NamedArgsTest(
username: "john_doe",
role: "admin"
);
var_dump($NamedArgsOutput);This outputs the following:
array (size=4)
'username' => string 'john_doe' (length=8)
'email' => null
'role' => string 'admin' (length=5)
'active' => boolean trueReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersrefactorDesirable refactoring of the feature/script in the issueDesirable refactoring of the feature/script in the issue