Conversation
Girgias
left a comment
There was a problem hiding this comment.
Looks good, other than the mix of parameter and arguments, which we might need to figure out when to use which in what context and try to normalize this in the whole docs :(
language/functions.xml
Outdated
| <para> | ||
| As of PHP 8.0.0, passing optional arguments after mandatory arguments | ||
| is deprecated. This can generally be resolved by dropping the default value. | ||
| One exception to this rule are parameters of the form |
There was a problem hiding this comment.
| One exception to this rule are parameters of the form | |
| One exception to this rule are arguments of the form |
To keep this consistent with the beginning of the paragraph?
There was a problem hiding this comment.
So I might have been getting the correctness wrong looking at: #241 (comment), so maybe ignore these comments.
There was a problem hiding this comment.
In this specific example, I think parameters is the correct wording indeed since it's about the function signature which is the place to use the word parameter, though I wouldn't be surprised if I had gotten it wrong elsewhere in the PR :-)
language/functions.xml
Outdated
| As of PHP 8.0.0, passing optional arguments after mandatory arguments | ||
| is deprecated. This can generally be resolved by dropping the default value. | ||
| One exception to this rule are parameters of the form | ||
| Type $param = &null;, where the &null; default makes the type implicitly |
There was a problem hiding this comment.
| Type $param = &null;, where the &null; default makes the type implicitly | |
| <code>Type $param = &null;</code>, where the &null; default makes the type implicitly |
Maybe? @cmb69 might want to confirm is that would work
There was a problem hiding this comment.
I'd be happy to do this, I wasn't sure if that'd undo the use of &null; tbh. I could totally use null directly instead, if that would be the case.
There was a problem hiding this comment.
It seems to me that <code><replaceable>Type</replaceable> $param = &null;</code> might be the proper markup, and might render as desired as well (fingers crossed!)
| <para> | ||
| PHP 8.0.0 introduced named arguments as an extension of the existing | ||
| positional parameters. Named arguments allow passing arguments to a | ||
| function based on the parameter name, rather than the parameter position. |
There was a problem hiding this comment.
| function based on the parameter name, rather than the parameter position. | |
| function based on the argument name, rather than the argument position. |
Again for consistency with the beginning of the paragraph
There was a problem hiding this comment.
I think this one is a legit use of argument, as it's again talking about the name vs position of the parameter at the function definition.
language/functions.xml
Outdated
| </example> | ||
|
|
||
| <para> | ||
| You can combine named arguments with positional arguments. In this case, |
There was a problem hiding this comment.
| You can combine named arguments with positional arguments. In this case, | |
| Named arguments can be combined with positional arguments. In this case, |
Usage of "you" in the docs is to be limited to the tutorial section for the most part
language/functions.xml
Outdated
| </para> | ||
|
|
||
| <example> | ||
| <title>Same as above example with a different order of parameters</title> |
There was a problem hiding this comment.
| <title>Same as above example with a different order of parameters</title> | |
| <title>Same example as above with a different order of parameters</title> |
|
@Girgias Feel free to create an issue for |
Also documents deprecation of optional args after mandatory ones
d3243d9 to
330fce5
Compare
|
Yup, by the looks of the failure, I do need to use null explicitly in the code block. Edit: @cmb69, I juuust saw your comment :-) Would you like me to replace it with that? Before this last commit I searched for |
Initial draft for documenting named arguments on the functions page.
Feedback is most welcomed! This PR could also use a quick fact-check and I'd appreciate pointing out what's missing that needs documentation.
This PR also documents deprecation of optional args after mandatory ones.