-
Notifications
You must be signed in to change notification settings - Fork 824
Clarify the syntax and role of arguments for echo and print #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The method synopsis at the top of both pages will still display with parentheses. Ideally, we'd use a different DocBook markup to give synopses for non-function constructs like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks rather good except that a clarification could be needed about precedence with .
reference/strings/functions/echo.xml
Outdated
<function>echo</function> regards the precedence of the period operator in | ||
<literal>echo</literal> regards the precedence of the period operator in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still accurate as of PHP 8? Precedence of .
was changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, the +
example now does the right thing, but the ternary still needs the parentheses: https://3v4l.org/Rgp73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes good point about the ternary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. I've left the addition example in, because there's still plenty of people running 7.x. I have removed a reference to pre-5.4 behaviour elsewhere, though.
- Rather than implying that parentheses are optional, make clear that they are never part of the syntax for these keywords. - Don't spend so many examples on different types of string. - Do include examples of non-string arguments. - Add a note with additional examples of how parentheses interact. - Don't refer to either construct as "function-like", instead use the term "expression" consistently. - Additional tidying to make the pages more consistent with each other. - Add "print" to the list of language constructs which are documented as functions. - Remove mention of what PHP versions below 5.4 did with short echo tags.
db4781b
to
0223029
Compare
Very good PR! Thank you!
ACK. Maybe adding a "role" attribute and supporting this in PhD might be a viable solution. Generally, I am more concerned regarding the constrol structures documentation which is super informal. Given that https://github.com/php/php-langspec is abandoned, it would be good to have a formal grammar specification in the manual. Apparently, DocBook 4.5 supports EBNF, so one may dream. :) |
Applied as ede9d20. |
(Inspired by this Stack Overflow question.)