Skip to content
Merged
Changes from 14 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
280 changes: 280 additions & 0 deletions src/Standards/Squiz/Docs/Commenting/BlockCommentStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
<documentation title="Block Comment">
<standard>
<![CDATA[
A block comment is a multiline comment delimited by an opener "/*" and a closer "*/" which are each on their own line and the content is in between.
Copy link
Member

Choose a reason for hiding this comment

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

Just checking: is it "multiline" or "multi-line" ? Whichever it should be, let's use it consistently (here versus line 48 of the docs "Valid: Multi-line block comment").

Also, how about this ?

Suggested change
A block comment is a multiline comment delimited by an opener "/*" and a closer "*/" which are each on their own line and the content is in between.
A block comment is a multiline comment delimited by an opener "/*" and a closer "*/" which are each on their own line with the comment text in between.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can see, UK English uses multi-line, US English doesn't.

Which would you prefer?

Copy link
Member

@jrfnl jrfnl Mar 23, 2025

Choose a reason for hiding this comment

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

I prefer consistency, whether it is the one or the other ;-)

I know there are some typical words which are written differently in US vs UK English - "modernize" vs "modernise" comes to mind.
Might be worth checking the code base/docs to see what's mostly used, US or UK English, though I'm not sure if this was strictly adhered to in the past anyhow.

If a spot check shows a mix of both, I suggest we open an issue to choose one and make the docs consistently use that language variant (as a separate task, outside the scope of this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking a small number of differences, such as multi-line vs multiline, ise vs ize, colour vs color, and such shows a mixture in the repository. Some spellings occur more in comments, others in docs, others in code, and others differ across three of those areas. Obviously color/background-color in CSS doesn't count, but for example, there's NamedColourSniff and T_COLOUR, but also the private colorizeVariableInput() method in the Help utility class.

Regarding this PR, it looks like multi-line is used more often outside of things like PHP class names where the hyphen isn't an option. I'll update the PR to use multi-line consistently. At least it'll make it easier to change in one go should the variant of English be changed in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for checking that @costdev. I'm not too concerned about the CSS sniff/tokens as those will be removed soon anyway, but I think opening an issue about language consistency might be a good idea. Want to do the honours ?

]]>
</standard>
<code_comparison>
<code title="Valid: Uses a valid opener and closer.">
<![CDATA[
<em>/*</em>
A block comment.
<em>*/</em>
]]>
</code>
<code title="Invalid: Uses /** **/.">
<![CDATA[
<em>/**</em>
A block comment.
<em>**/</em>
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Uses a valid opener and closer.">
<![CDATA[
<em>/*</em>
* A block comment
* with multiple lines.
<em>*/</em>
]]>
</code>
<code title="Invalid: Uses multiple // or #.">
<![CDATA[
<em>//</em> A block comment
<em>//</em> with multiple lines.

<em>#</em> A block comment
<em>#</em> with multiple lines.
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
Single line block comments are not allowed.
]]>
</standard>
<code_comparison>
<code title="Valid: Multi-line block comment.">
<![CDATA[
<em>/*
A block comment.
*/</em>
]]>
</code>
<code title="Invalid: Single line block comment.">
<![CDATA[
<em>/* A block comment. */</em>
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
A block comment should not be empty.
]]>
</standard>
<code_comparison>
<code title="Valid: A block comment with contents.">
<![CDATA[
/*
<em> A block comment.</em>
*/
]]>
</code>
<code title="Invalid: An empty block comment.">
<![CDATA[
/*
<em></em>
*/
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
Block comment text should start on a new line immediately after the opener.
]]>
</standard>
<code_comparison>
<code title="Valid: Text starts on a new line.">
<![CDATA[
/*
<em> A block comment.</em>
*/
]]>
</code>
<code title="Invalid: Text starts on the same line.">
<![CDATA[
/* <em>A block comment.</em>
*/
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
If there are no asterisks at the start of each line, the contents of the docblock should be indented by at least 4 spaces.
]]>
</standard>
<code_comparison>
<code title="Valid: Indented by at least 4 spaces.">
<![CDATA[
/*
<em> </em>A block comment
<em> </em>with multiple lines.
<em> </em>And a second paragraph.
*/
]]>
</code>
<code title="Invalid: Indented by less than 4 spaces.">
<![CDATA[
/*
<em> </em>A block comment
<em> </em>with
<em> </em>multiple lines.
*/
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
If asterisks are used, they should be aligned.
]]>
</standard>
<code_comparison>
<code title="Valid: Asterisks are aligned.">
<![CDATA[
/<em>*</em>
<em>*</em> A block comment
<em>*</em> with
<em>*</em> multiple lines.
<em>*</em>/
]]>
</code>
<code title="Invalid: Asterisks are not aligned.">
<![CDATA[
/*
* A block comment
<em>*</em> with
* multiple lines.
<em>*</em>/
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
A block comment should start with a capital letter.
]]>
</standard>
<code_comparison>
<code title="Valid: Starts with a capital letter.">
<![CDATA[
/*
<em>A</em> block comment.
*/
]]>
</code>
<code title="Invalid: Does not start with a capital letter.">
<![CDATA[
/*
<em>a</em> block comment.
*/
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The block comment closer should be on a new line.
]]>
</standard>
<code_comparison>
<code title="Valid: Closer is on a new line.">
<![CDATA[
/*
A block comment.
<em>*/</em>
]]>
</code>
<code title="Invalid: Closer is not on a new line.">
<![CDATA[
/*
A block comment.<em> */</em>
]]>
</code>
</code_comparison>
<standard>
If asterisks are used, the closer's asterisk should be aligned with these. Otherwise, the closer's asterisk should be aligned with the opener's slash.
</standard>
<code_comparison>
<code title="Valid: The closer's asterisk is aligned with other asterisks.">
<![CDATA[
/<em>*</em>
<em>*</em> A block comment
<em>*</em>/
]]>
</code>
<code title="Invalid: The closer's asterisk is not aligned with other asterisks.">
<![CDATA[
/*
* A block comment.
<em>*</em>/
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: The closer's asterisk is aligned with the opener's slash.">
<![CDATA[
<em>/</em>*
A block comment.
<em>*</em>/
]]>
</code>
<code title="Invalid: The closer's asterisk is not aligned with the opener's slash.">
<![CDATA[
/*
A block comment.
<em> *</em>/
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
There should be an empty line after the block comment.
]]>
</standard>
<code_comparison>
<code title="Valid: An empty line after the comment.">
<![CDATA[
/*
A block comment.
*/
<em></em>
echo 'Content';
]]>
</code>
<code title="Invalid: No empty line after the comment.">
<![CDATA[
/*
A block comment.
*/
<em>echo 'Content';</em>
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
A block comment immediately after a PHP open tag should not have a preceeding blank line.
]]>
</standard>
<code_comparison>
<code title="Valid: No blank line after an open tag.">
<![CDATA[
<?php
<em></em>/*
* A block comment
* with
* multiple lines.
*/
]]>
</code>
<code title="Invalid: A blank line after an open tag.">
<![CDATA[
<?php
<em></em>
/*
* A block comment
* with
* multiple lines.
*/
]]>
</code>
</code_comparison>
</documentation>