Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ parentheses, spaces, and braces. The `case` statement MUST be indented once
from `switch`, and the `break` keyword (or other terminating keywords) MUST be
indented at the same level as the `case` body. There MUST be a comment such as
`// no break` when fall-through is intentional in a non-empty `case` body.
The `case` and `default` keywords MUST use colons as shown in the sample code below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `case` and `default` keywords MUST use colons as shown in the sample code below.
The `case` and `default` keywords MUST use colons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer the existing language, so that it also applies to formatting of the colons (e.g. there shouldn't be whitespace between case and :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there shouldn't be whitespace, that should be made explicit in the text. The code sample should demonstrate the intend of the text, not leave the reader to draw their own conclusions (which can be wildly different per person).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That the example applies to whitespace is already explicit in the text:

A switch structure looks like the following. Note the placement of parentheses, spaces, and braces.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can only repeat what I said before:

The code sample should demonstrate the intend of the text, not leave the reader to draw their own conclusions (which can be wildly different per person).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A switch structure looks like the following. Note the placement of parentheses, spaces, and braces.

Perhaps adding colons to this list is enough and we call it a day?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I beg of you all, please read what I wrote before.

If you think it is acceptable for a standard to imply rules via code samples, just leave the code samples and get rid of all the rules.

If you want tooling like PHPCS and CS-fixer to write detection and fixing tools, the rules have to be made explicit in text as otherwise, the implementations of PHPCS and CS-fixer will differ (as has happened before). If the standard is open to different interpretations, it reduces the value of something being a standard and will only cause friction for the users of the standard.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


```php
<?php
Expand Down