Skip to content

Adds documentation for PregQuoteDelimiter - #2487

Closed
tikifez wants to merge 5 commits into
WordPress:developfrom
tikifez:docs/WordPress.PHP.PregQuoteDelimiter
Closed

tikifez wants to merge 5 commits into
WordPress:developfrom
tikifez:docs/WordPress.PHP.PregQuoteDelimiter

Conversation

@tikifez

@tikifez tikifez commented Sep 17, 2024 •

Copy link
Copy Markdown
Contributor

Related to #1722

@jrfnl jrfnl mentioned this pull request Sep 17, 2024
51 of 61 tasks
@rodrigoprimo

Copy link
Copy Markdown
Contributor

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.

@tikifez

tikifez commented Sep 17, 2024

Copy link
Copy Markdown
Contributor Author

Added code comparison with valid and invalid examples.

1 similar comment
@tikifez

tikifez commented Sep 17, 2024

Copy link
Copy Markdown
Contributor Author

Added code comparison with valid and invalid examples.

@rodrigoprimo rodrigoprimo left a comment

Copy link
Copy Markdown
Contributor

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"
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be aligned with . 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 is used.

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed unnecessary newlines.

>
Passing the $delimiter parameter to preg_quote() is strongly recommended to ensure the delimiter required by the PCRE functions are escaped.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

]]>
No newline at end of file

Copy link
Copy Markdown
Member

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.

preg_quote( $dir, '#' )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
preg_quote( $dir, '#' )
preg_quote( $dir, <em>'#'em> )

Use the ... to highlight the focus of the code snippet.

@rodrigoprimo

Copy link
Copy Markdown
Contributor

@tikifez, I was just wondering if you'll have a chance to finish this off in the near future. It would be great if this PR could be included in the next WPCS release.

If you haven't got time or lost interest, please let us know and we'll see if we can find someone to take over. Thanks!

@rodrigoprimo

Copy link
Copy Markdown
Contributor

@tikifez, please let us know within a week if you are still interested in finishing this PR. If we don't hear back from you, we will presume you don't have time, and we will see if we can find someone else to take over and finish it. Thanks for your work so far!

@jrfnl

jrfnl commented Dec 27, 2025

Copy link
Copy Markdown
Member

Closing as superseded by merged PR #2677

@jrfnl jrfnl closed this Dec 27, 2025
@jrfnl jrfnl added this to the 3.3.x milestone Jan 28, 2026
@jrfnl jrfnl modified the milestones: 3.3.x, 3.4.0 Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants