{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/608","repository_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards","labels_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/608/comments","events_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/608/events","html_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/608","id":165947859,"number":608,"title":"Better cover the regex related rules.","user":{"login":"jrfnl","id":663378,"avatar_url":"https://avatars.githubusercontent.com/u/663378?v=3","gravatar_id":"","url":"https://api.github.com/users/jrfnl","html_url":"https://github.com/jrfnl","followers_url":"https://api.github.com/users/jrfnl/followers","following_url":"https://api.github.com/users/jrfnl/following{/other_user}","gists_url":"https://api.github.com/users/jrfnl/gists{/gist_id}","starred_url":"https://api.github.com/users/jrfnl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrfnl/subscriptions","organizations_url":"https://api.github.com/users/jrfnl/orgs","repos_url":"https://api.github.com/users/jrfnl/repos","events_url":"https://api.github.com/users/jrfnl/events{/privacy}","received_events_url":"https://api.github.com/users/jrfnl/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/labels/review-ready","name":"review-ready","color":"006b75"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-16T21:13:20Z","updated_at":"2016-07-17T17:25:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/pulls/608","html_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/608","diff_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/608.diff","patch_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/608.patch"},"body":"From the handbook:\r\n> Perl compatible regular expressions (PCRE, preg_ functions) should be used in preference to their POSIX counterparts. Never use the /e switch, use preg_replace_callback instead.\r\n>\r\n> It’s most convenient to use single-quoted strings for regular expressions since, contrary to double-quoted strings, they have only two metasequences: \\' and \\\\.\r\n\r\nRef: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#regular-expressions\r\n\r\nThis can be split into three distinct rules:\r\n1. Don't use `POSIX` functions\r\n2. Don't use the `/e` modifier\r\n3. Prefer single quoted stings.\r\n\r\nRule 1 was up to now not covered in core. Parts of it were covered in `extra` and in `vip`, but the implementations were inconsistent and both were incomplete.\r\nRule 2 was not covered at all.\r\nRule 3 is already covered by the single vs double quotes sniff.\r\n\r\nThis PR fixes the issues with covering rule 1 and 2 with the following two commits:\r\n\r\nSplit off `POSIX` Functions restrictions to its own sniff.\r\n\r\n* Removes similar checks from existing sniffs (`PHP.DiscouragedFunctions` and `VIP.RestrictedFunctions`).\r\n* Makes sure that *all* functions in the `POSIX` extension are covered by this check - they previously were not.\r\n* Add unit tests for the new sniff covering *all* `POSIX` functions.\r\n\r\nCopy in the `PregReplaceEModifierSniff` from the `PHPCompatibility` Sniff library.\r\n\r\n* Add a new `PHPCompatibility` folder to the `Sniff` folder.\r\n* Copy in the `PregReplaceEModifierSniff`.\r\n* Copy in the related parent class `PHPCompatibility_Sniff`.\r\n* Renamed both classes to follow the PSR1 autoloading pattern.\r\n* Added a readme to the `PHPCompatibility` sniff folder about its usage.\r\n* Excluded the `PHPCompatibility` folder from the PHPCS code style checks - this way we can just drop-in replace the file (ok, except for the class renaming) when there is a new version available.\r\n"},"comment":{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/comments/233193179","html_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/608#issuecomment-233193179","issue_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/608","id":233193179,"user":{"login":"jrfnl","id":663378,"avatar_url":"https://avatars.githubusercontent.com/u/663378?v=3","gravatar_id":"","url":"https://api.github.com/users/jrfnl","html_url":"https://github.com/jrfnl","followers_url":"https://api.github.com/users/jrfnl/followers","following_url":"https://api.github.com/users/jrfnl/following{/other_user}","gists_url":"https://api.github.com/users/jrfnl/gists{/gist_id}","starred_url":"https://api.github.com/users/jrfnl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrfnl/subscriptions","organizations_url":"https://api.github.com/users/jrfnl/orgs","repos_url":"https://api.github.com/users/jrfnl/repos","events_url":"https://api.github.com/users/jrfnl/events{/privacy}","received_events_url":"https://api.github.com/users/jrfnl/received_events","type":"User","site_admin":false},"created_at":"2016-07-17T17:25:54Z","updated_at":"2016-07-17T17:25:54Z","body":"> Is there no way that we can just have the PHPCompatibility sniff library as a dependency?\r\n\r\nSee #575 as well where I originally suggested that.\r\n\r\nThe only way I can think of would be to make it a dependency via composer and add it to the ruleset. Not sure how well that would work for the re-hashing to get PHPCS to recognize the installed standards, but I'd leave that up to @Rarst to advise on.\r\n\r\nThis is not fool-proof no matter what. Not everyone uses Composer, so this could mean people will start complaining about WPCS not working as it breaks on the missing ruleset.\r\n\r\n> Maybe it is best to just copy the sniff over, but I shy away from anything that might require routine maintenance. \r\n\r\nAs for now, for the handbook coverage, we'd only need the one sniff, that seemed like the simplest way to handle it.\r\nAs noted above, I've excluded it from the WPCS code standards check to make copy/paste maintenance as easy as possible.\r\n\r\nIf/when WPCS would want to start incorporating more sniffs from PHPCompatibility, then this should be revisited IMHO.."}}
{"actor":{"display_login":"jrfnl"}}