-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Adds documentation for PregQuoteDelimiter #2487
base: develop
Are you sure you want to change the base?
Adds documentation for PregQuoteDelimiter #2487
Conversation
Just documenting here that I chatted in person with @tikifez and he will add valid and invalid examples. No need to review this PR yet. |
Added code comparison with valid and invalid examples. |
1 similar comment
Added code comparison with valid and invalid examples. |
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.
Thanks for working on this PR, @tikifez! I'm not a maintainer of the project so take my review with a grain of salt. That being said, I left some comments based on my own experience creating PHPCS and WPCS sniffs.
Also, please make sure to include a reference to the parent issue as mentioned in the description of #1722:
Please mention this issue in your pull request description Related to #1722 so your pull request will show up in this issue.
title="Preg Quote Delimiter" | ||
> | ||
<standard> | ||
<![CDATA[ |
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.
<![CDATA
should be aligned with <standard>
. Here is an example of a recently added documentation: https://github.com/rodrigoprimo/WordPress-Coding-Standards/blob/694bdf514d518004cefc0a22923fedeb0091eaca/WordPress/Docs/WP/GetMetaSingleStandard.xml#L7
Here and in the other places where <![CDATA
is used.
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.
Aligned items.
Passing the $delimiter parameter to preg_quote() is strongly recommended to ensure the delimiter required by the PCRE functions are escaped. | ||
]]> | ||
</standard> | ||
|
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.
This newline is not necessary.
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.
Removed unnecessary newlines.
> | ||
<standard> | ||
<![CDATA[ | ||
Passing the $delimiter parameter to preg_quote() is strongly recommended to ensure the delimiter required by the PCRE functions are escaped. |
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.
to ensure the delimiter required by the PCRE functions are escaped.
I haven't looked deeply into this so I might be missing something, but I'm not sure this is the reason to recommend that the $delimiter
parameter is passed.
I got this from the issue where this sniff was introduced:
Verify that the optional second parameter $delimiter of preg_quote() is always passed.
Too often I come across code where it is missing and unless it is passed, the default / delimiters are presumed, which is often wrong.
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 the description and changed the example valid code to be one from WordPress core.
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |
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.
Add a clear line at the end of the file please.
<code_comparison> | ||
<code title="Valid: The delimiter is included."> | ||
<![CDATA[ | ||
preg_quote( $dir, '#' ) |
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.
preg_quote( $dir, '#' ) | |
preg_quote( $dir, <em>'#'</em> ) |
Use the <em>...</em>
to highlight the focus of the code snippet.
Related to #1722