Skip to content

Conversation

IMSoP
Copy link
Collaborator

@IMSoP IMSoP commented Mar 3, 2021

  • 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.

(Inspired by this Stack Overflow question.)

@IMSoP
Copy link
Collaborator Author

IMSoP commented Mar 3, 2021

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.

Copy link
Member

@Girgias Girgias left a 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 .

Comment on lines 115 to 173
<function>echo</function> regards the precedence of the period operator in
<literal>echo</literal> regards the precedence of the period operator in
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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.

Copy link
Collaborator Author

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.
@IMSoP IMSoP force-pushed the no-parens-in-echo-print branch from db4781b to 0223029 Compare March 3, 2021 21:19
@cmb69
Copy link
Member

cmb69 commented Mar 10, 2021

Very good PR! Thank you!

Ideally, we'd use a different DocBook markup to give synopses for non-function constructs like this.

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. :)

@cmb69
Copy link
Member

cmb69 commented Mar 10, 2021

Applied as ede9d20.

@cmb69 cmb69 closed this Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants