{"action":"created","comment":{"url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/comments/70981676","id":70981676,"diff_hunk":"@@ -0,0 +1,62 @@\n+<?php\n+/**\n+ * Sniff to check theme for deregister and register of core scripts (jquery)\n+ *\n+ * @category Theme\n+ * @package  PHP_CodeSniffer\n+ * @author   Simon Prosser <pross@pross.org.uk>\n+ */\n+class WordPress_Sniffs_Theme_NoDeregisterCoreScriptSniff extends WordPress_Sniffs_Functions_FunctionRestrictionsSniff {\n+\t/**\n+\t * Returns an array of tokens this test wants to listen for.\n+\t *\n+\t * @return array\n+\t */\n+\tpublic function register() {\n+\t\treturn array(\n+\t\t\t\tT_STRING,\n+\t\t\t\tT_CONSTANT_ENCAPSED_STRING,\n+\t\t\t\tT_DOUBLE_QUOTED_STRING,\n+\t\t\t   );\n+\n+\t}//end register()\n+\n+\n+\t/**\n+\t * Processes this test, when one of its tokens is encountered.\n+\t *\n+\t * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.\n+\t * @param int                  $stackPtr  The position of the current token\n+\t *                                        in the stack passed in $tokens.\n+\t *\n+\t * @return void\n+\t */\n+\tpublic function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {\n+\n+\t\t$tokens  = $phpcsFile->getTokens();\n+\t\t$token   = $tokens[ $stackPtr ];\n+\n+\t\t$content = trim( $token['content'], '\"\\'' );\n+\n+\t\t$functions = array(\n+\t\t\t'wp_deregister_script',\n+\t\t\t'wp_register_script',\n+\t\t);\n+\n+\t\t$scripts = array(\n+\t\t\t'jquery',\n+\t\t);\n+\n+\t\tif ( in_array( $content, $functions, true ) ) {\n+\n+\t\t\t$script = $phpcsFile->findNext( array( T_CONSTANT_ENCAPSED_STRING, T_DOUBLE_QUOTED_STRING ), $stackPtr );\n+\n+\t\t\t$content = preg_replace( '/[^a-zA-Z0-9]+/', '', html_entity_decode( $tokens[ $script ]['content'], ENT_QUOTES ) );","path":"WordPress/Sniffs/Theme/NoDeregisterCoreScriptSniff.php","position":54,"original_position":54,"commit_id":"6e2262ec7159b111e9ac2069e25589d7fc81a901","original_commit_id":"6e2262ec7159b111e9ac2069e25589d7fc81a901","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},"body":"Hang on - may bad, that's for the function call content string. What about making that one liner of line 39 a separate function and calling that for the content of this token as well ?\r\nIt's more obvious what you are trying to do with that one.\r\n","created_at":"2016-07-15T14:27:05Z","updated_at":"2016-07-15T14:27:05Z","html_url":"https://github.com/WPTRT/WordPress-Coding-Standards/pull/26#discussion_r70981676","pull_request_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/comments/70981676"},"html":{"href":"https://github.com/WPTRT/WordPress-Coding-Standards/pull/26#discussion_r70981676"},"pull_request":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26","id":77201181,"html_url":"https://github.com/WPTRT/WordPress-Coding-Standards/pull/26","diff_url":"https://github.com/WPTRT/WordPress-Coding-Standards/pull/26.diff","patch_url":"https://github.com/WPTRT/WordPress-Coding-Standards/pull/26.patch","issue_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues/26","number":26,"state":"open","locked":false,"title":"Add rule to prevent deregistering scripts.","user":{"login":"Pross","id":265860,"avatar_url":"https://avatars.githubusercontent.com/u/265860?v=3","gravatar_id":"","url":"https://api.github.com/users/Pross","html_url":"https://github.com/Pross","followers_url":"https://api.github.com/users/Pross/followers","following_url":"https://api.github.com/users/Pross/following{/other_user}","gists_url":"https://api.github.com/users/Pross/gists{/gist_id}","starred_url":"https://api.github.com/users/Pross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pross/subscriptions","organizations_url":"https://api.github.com/users/Pross/orgs","repos_url":"https://api.github.com/users/Pross/repos","events_url":"https://api.github.com/users/Pross/events{/privacy}","received_events_url":"https://api.github.com/users/Pross/received_events","type":"User","site_admin":false},"body":"Added wp_deregister_script with a unit test.\r\n\r\nNot sure if this is the way to do this, please let me know if it isnt!","created_at":"2016-07-12T22:15:09Z","updated_at":"2016-07-15T14:27:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"359542e0b362266c713078ae8204135f4471c360","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26/commits","review_comments_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26/comments","review_comment_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues/26/comments","statuses_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/statuses/6e2262ec7159b111e9ac2069e25589d7fc81a901","head":{"label":"Pross:feature/theme-review-sniffs","ref":"feature/theme-review-sniffs","sha":"6e2262ec7159b111e9ac2069e25589d7fc81a901","user":{"login":"Pross","id":265860,"avatar_url":"https://avatars.githubusercontent.com/u/265860?v=3","gravatar_id":"","url":"https://api.github.com/users/Pross","html_url":"https://github.com/Pross","followers_url":"https://api.github.com/users/Pross/followers","following_url":"https://api.github.com/users/Pross/following{/other_user}","gists_url":"https://api.github.com/users/Pross/gists{/gist_id}","starred_url":"https://api.github.com/users/Pross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pross/subscriptions","organizations_url":"https://api.github.com/users/Pross/orgs","repos_url":"https://api.github.com/users/Pross/repos","events_url":"https://api.github.com/users/Pross/events{/privacy}","received_events_url":"https://api.github.com/users/Pross/received_events","type":"User","site_admin":false},"repo":{"id":63193145,"name":"WordPress-Coding-Standards","full_name":"Pross/WordPress-Coding-Standards","owner":{"login":"Pross","id":265860,"avatar_url":"https://avatars.githubusercontent.com/u/265860?v=3","gravatar_id":"","url":"https://api.github.com/users/Pross","html_url":"https://github.com/Pross","followers_url":"https://api.github.com/users/Pross/followers","following_url":"https://api.github.com/users/Pross/following{/other_user}","gists_url":"https://api.github.com/users/Pross/gists{/gist_id}","starred_url":"https://api.github.com/users/Pross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pross/subscriptions","organizations_url":"https://api.github.com/users/Pross/orgs","repos_url":"https://api.github.com/users/Pross/repos","events_url":"https://api.github.com/users/Pross/events{/privacy}","received_events_url":"https://api.github.com/users/Pross/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Pross/WordPress-Coding-Standards","description":"PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions","fork":true,"url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards","forks_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/forks","keys_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/teams","hooks_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/hooks","issue_events_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/issues/events{/number}","events_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/events","assignees_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/assignees{/user}","branches_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/branches{/branch}","tags_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/tags","blobs_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/git/refs{/sha}","trees_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/statuses/{sha}","languages_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/languages","stargazers_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/stargazers","contributors_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/contributors","subscribers_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/subscribers","subscription_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/subscription","commits_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/commits{/sha}","git_commits_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/git/commits{/sha}","comments_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/comments{/number}","issue_comment_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/issues/comments{/number}","contents_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/contents/{+path}","compare_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/merges","archive_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/downloads","issues_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/issues{/number}","pulls_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/pulls{/number}","milestones_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/milestones{/number}","notifications_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/labels{/name}","releases_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/releases{/id}","deployments_url":"https://api.github.com/repos/Pross/WordPress-Coding-Standards/deployments","created_at":"2016-07-12T21:21:38Z","updated_at":"2016-07-12T21:21:39Z","pushed_at":"2016-07-14T17:45:58Z","git_url":"git://github.com/Pross/WordPress-Coding-Standards.git","ssh_url":"git@github.com:Pross/WordPress-Coding-Standards.git","clone_url":"https://github.com/Pross/WordPress-Coding-Standards.git","svn_url":"https://github.com/Pross/WordPress-Coding-Standards","homepage":"","size":937,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"feature/theme-review-sniffs"}},"base":{"label":"WPTRT:feature/theme-review-sniffs","ref":"feature/theme-review-sniffs","sha":"ecf92e9bb051a2e1f97b4417f7bddcd8faf3ed25","user":{"login":"WPTRT","id":584881,"avatar_url":"https://avatars.githubusercontent.com/u/584881?v=3","gravatar_id":"","url":"https://api.github.com/users/WPTRT","html_url":"https://github.com/WPTRT","followers_url":"https://api.github.com/users/WPTRT/followers","following_url":"https://api.github.com/users/WPTRT/following{/other_user}","gists_url":"https://api.github.com/users/WPTRT/gists{/gist_id}","starred_url":"https://api.github.com/users/WPTRT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPTRT/subscriptions","organizations_url":"https://api.github.com/users/WPTRT/orgs","repos_url":"https://api.github.com/users/WPTRT/repos","events_url":"https://api.github.com/users/WPTRT/events{/privacy}","received_events_url":"https://api.github.com/users/WPTRT/received_events","type":"Organization","site_admin":false},"repo":{"id":63002462,"name":"WordPress-Coding-Standards","full_name":"WPTRT/WordPress-Coding-Standards","owner":{"login":"WPTRT","id":584881,"avatar_url":"https://avatars.githubusercontent.com/u/584881?v=3","gravatar_id":"","url":"https://api.github.com/users/WPTRT","html_url":"https://github.com/WPTRT","followers_url":"https://api.github.com/users/WPTRT/followers","following_url":"https://api.github.com/users/WPTRT/following{/other_user}","gists_url":"https://api.github.com/users/WPTRT/gists{/gist_id}","starred_url":"https://api.github.com/users/WPTRT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPTRT/subscriptions","organizations_url":"https://api.github.com/users/WPTRT/orgs","repos_url":"https://api.github.com/users/WPTRT/repos","events_url":"https://api.github.com/users/WPTRT/events{/privacy}","received_events_url":"https://api.github.com/users/WPTRT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WPTRT/WordPress-Coding-Standards","description":"PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions","fork":true,"url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards","forks_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/forks","keys_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/teams","hooks_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/hooks","issue_events_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues/events{/number}","events_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/events","assignees_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/assignees{/user}","branches_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/branches{/branch}","tags_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/tags","blobs_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/git/refs{/sha}","trees_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/statuses/{sha}","languages_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/languages","stargazers_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/stargazers","contributors_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/contributors","subscribers_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/subscribers","subscription_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/subscription","commits_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/commits{/sha}","git_commits_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/git/commits{/sha}","comments_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/comments{/number}","issue_comment_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues/comments{/number}","contents_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/contents/{+path}","compare_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/merges","archive_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/downloads","issues_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues{/number}","pulls_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls{/number}","milestones_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/milestones{/number}","notifications_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/labels{/name}","releases_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/releases{/id}","deployments_url":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/deployments","created_at":"2016-07-10T14:26:33Z","updated_at":"2016-07-15T00:56:59Z","pushed_at":"2016-07-14T23:29:58Z","git_url":"git://github.com/WPTRT/WordPress-Coding-Standards.git","ssh_url":"git@github.com:WPTRT/WordPress-Coding-Standards.git","clone_url":"https://github.com/WPTRT/WordPress-Coding-Standards.git","svn_url":"https://github.com/WPTRT/WordPress-Coding-Standards","homepage":"","size":946,"stargazers_count":3,"watchers_count":3,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":22,"forks":4,"open_issues":22,"watchers":3,"default_branch":"feature/theme-review-sniffs"}},"_links":{"self":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26"},"html":{"href":"https://github.com/WPTRT/WordPress-Coding-Standards/pull/26"},"issue":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues/26"},"comments":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/WPTRT/WordPress-Coding-Standards/statuses/6e2262ec7159b111e9ac2069e25589d7fc81a901"}}}}
{"actor":{"display_login":"jrfnl"}}