From 0c7aff07ad0a2064588c9e6255bb86dcfb2a5089 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 22 May 2019 10:59:21 +0200 Subject: [PATCH 01/72] Travis: run the code style related and ruleset checks in separate stages Travis now offers stages. Using stages we can: - Run the code style related checks before running any unit tests and stop the build early if any are detected. - Remove the duplicate unit test runs - i.e. previously we had an extra (third) build against PHP 7.2 (now changed to 7.3) which would run the code style related checks, but would also re-run the unit tests. This extra build will now no longer run the unit tests. While this does mean that the unit tests will run with a slight delay (the `Sniff` and `Rulesets` stages have to finish before they start), it also means that we: * Get code style errors reported earlier as it's been moved to be the first stage and the build will just stop if any are found. * We won't be wasting Travis's resources on builds which will have to be re-run anyway. Ref: https://docs.travis-ci.com/user/build-stages/ Note that `Allowed failures` is no longer listed as a separate block in the Travis result overview, but is _is_ respected. For more discussion about this: * https://github.com/travis-ci/travis-ci/issues/7789 * https://travis-ci.community/t/always-show-allow-failures-allowed-failures-when-build-stages-are-used/217 * https://travis-ci.community/t/work-out-kinks-in-interactions-between-stages-allow-fail-and-fast-finish/1090 * https://github.com/travis-ci/travis-ci/issues/9677 --- .travis.yml | 114 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 44 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb60dd86aa..93399c75b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,16 +27,67 @@ env: # Lowest supported release in the 3.x series with which WPCS is compatible. - PHPCS_BRANCH="3.3.1" -matrix: +stages: + - sniff + - rulesets + - test + +jobs: fast_finish: true include: - # Run PHPCS against WPCS. I just picked to run it against 7.2. - - php: 7.2 - env: PHPCS_BRANCH="dev-master" SNIFF=1 + - stage: sniff + php: 7.3 + env: PHPCS_BRANCH="dev-master" addons: apt: packages: - libxml2-utils + script: + # WordPress Coding Standards. + # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + # @link http://pear.php.net/package/PHP_CodeSniffer/ + - $(pwd)/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 + + # Validate the xml files. + # @link http://xmlsoft.org/xmllint.html + # For the build to properly error when validating against a scheme, these each have to be in their own condition. + - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml + - xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample + + # Check the code-style consistency of the xml files. + - diff -B --tabsize=4 ./WordPress/ruleset.xml <(xmllint --format "./WordPress/ruleset.xml") + - diff -B --tabsize=4 ./WordPress-Core/ruleset.xml <(xmllint --format "./WordPress-Core/ruleset.xml") + - diff -B --tabsize=4 ./WordPress-Docs/ruleset.xml <(xmllint --format "./WordPress-Docs/ruleset.xml") + - diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml") + - diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample") + + # Make sure the rulesets don't thrown unexpected errors or warnings. + # This check needs to be run against a high PHP version to prevent triggering the syntax error check. + # It also needs to be run against all PHPCS versions WPCS is tested against. + - stage: rulesets + php: 7.3 + env: PHPCS_BRANCH="dev-master" + script: + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Core + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Docs + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Extra + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress + + # Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files. + # This is not an exhaustive test, but should give an early indication for typical fixer conflicts. + # For the first run, the exit code will be 1 (= all fixable errors fixed). + # `travis_retry` should then kick in to run the fixer again which should now return 0 (= no fixable errors found). + # All error codes for the PHPCBF: https://github.com/squizlabs/PHP_CodeSniffer/issues/1270#issuecomment-272768413 + - travis_retry $(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary + + - stage: rulesets + php: 7.3 + env: PHPCS_BRANCH="3.3.1" + script: + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Core + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Docs + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Extra + - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress allow_failures: # Allow failures for unstable builds. @@ -51,7 +102,7 @@ before_install: - export PHPUNIT_DIR=/tmp/phpunit - composer require squizlabs/php_codesniffer:${PHPCS_BRANCH} --update-no-dev --no-suggest --no-scripts - | - if [[ "$SNIFF" == "1" ]]; then + if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Sniff" ]]; then composer install --dev --no-suggest # The `dev` required DealerDirect Composer plugin takes care of the installed_paths. else @@ -63,42 +114,17 @@ before_install: - if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then wget -P $PHPUNIT_DIR https://phar.phpunit.de/phpunit-7.phar && chmod +x $PHPUNIT_DIR/phpunit-7.phar; fi script: - # Lint the PHP files against parse errors. - - if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -path ./bin -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi - # Run the unit tests. - - | - if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then - php $PHPUNIT_DIR/phpunit-7.phar --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php - else - phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php - fi - # Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files. - # This is not an exhaustive test, but should give an early indication for typical fixer conflicts. - # For the first run, the exit code will be 1 (= all fixable errors fixed). - # `travis_retry` should then kick in to run the fixer again which should now return 0 (= no fixable errors found). - # All error codes for the PHPCBF: https://github.com/squizlabs/PHP_CodeSniffer/issues/1270#issuecomment-272768413 - - if [[ "$SNIFF" == "1" ]]; then travis_retry $(pwd)/vendor/bin/phpcbf -p ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary; fi - # Make sure the rulesets don't thrown unexpected errors or warnings. - # This check needs to be run against a high PHP version to prevent triggering the syntax error check. - # It also needs to be run against all PHPCS versions WPCS is tested against. - - if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress-Core; fi - - if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress-Docs; fi - - if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress-Extra; fi - - if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress; fi - # WordPress Coding Standards. - # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards - # @link http://pear.php.net/package/PHP_CodeSniffer/ - - if [[ "$SNIFF" == "1" ]]; then $(pwd)/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1; fi - # Validate the xml files. - # @link http://xmlsoft.org/xmllint.html - - if [[ "$SNIFF" == "1" ]]; then xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml; fi - - if [[ "$SNIFF" == "1" ]]; then xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample; fi - # Check the code-style consistency of the xml files. - - if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress/ruleset.xml <(xmllint --format "./WordPress/ruleset.xml"); fi - - if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Core/ruleset.xml <(xmllint --format "./WordPress-Core/ruleset.xml"); fi - - if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Docs/ruleset.xml <(xmllint --format "./WordPress-Docs/ruleset.xml"); fi - - if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml"); fi - - if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample"); fi - # Validate the composer.json file. - # @link https://getcomposer.org/doc/03-cli.md#validate - - if [[ "$LINT" == "1" ]]; then composer validate --no-check-all --strict; fi + # Lint the PHP files against parse errors. + - if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -path ./bin -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi + + # Validate the composer.json file. + # @link https://getcomposer.org/doc/03-cli.md#validate + - if [[ "$LINT" == "1" ]]; then composer validate --no-check-all --strict; fi + + # Run the unit tests. + - | + if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then + php $PHPUNIT_DIR/phpunit-7.phar --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php + else + phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php + fi From fc44f79556168cd6204a2c7ef72750b318cee2d1 Mon Sep 17 00:00:00 2001 From: Stephen Edgar Date: Wed, 22 May 2019 11:06:12 +0100 Subject: [PATCH 02/72] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 93399c75b5..f4fb839d60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ jobs: - diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml") - diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample") - # Make sure the rulesets don't thrown unexpected errors or warnings. + # Make sure the rulesets don't throw unexpected errors or warnings. # This check needs to be run against a high PHP version to prevent triggering the syntax error check. # It also needs to be run against all PHPCS versions WPCS is tested against. - stage: rulesets From c6cb5c8f83b3eafbe5e84f103a867ec283d12936 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 22 May 2019 17:01:02 +0200 Subject: [PATCH 03/72] ValidHookName: bug fix / skip over array keys String array keys for variable array access would also be examined as part of the hook name, while those should be skipped over as they are not part of the _hook_name. This fixes that. Includes unit test. This commit also lowers the nesting level of the loop by continuing early whenever possible. --- .../NamingConventions/ValidHookNameSniff.php | 82 ++++++++++++------- .../ValidHookNameUnitTest.1.inc | 5 ++ .../ValidHookNameUnitTest.php | 1 + 3 files changed, 58 insertions(+), 30 deletions(-) diff --git a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php index e7dc9b9e86..0103108a35 100644 --- a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -10,6 +10,7 @@ namespace WordPressCS\WordPress\Sniffs\NamingConventions; use WordPressCS\WordPress\AbstractFunctionParameterSniff; +use PHP_CodeSniffer\Util\Tokens; /** * Use lowercase letters in action and filter names. Separate words via underscores. @@ -108,39 +109,60 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p $content[ $i ] = $this->tokens[ $i ]['content']; $expected[ $i ] = $this->tokens[ $i ]['content']; - if ( \in_array( $this->tokens[ $i ]['code'], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) { - $string = $this->strip_quotes( $this->tokens[ $i ]['content'] ); - - /* - * Here be dragons - a double quoted string can contain extrapolated variables - * which don't have to comply with these rules. - */ - if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) { - $transform = $this->transform_complex_string( $string, $regex ); - $case_transform = $this->transform_complex_string( $string, $regex, 'case' ); - $punct_transform = $this->transform_complex_string( $string, $regex, 'punctuation' ); - } else { - $transform = $this->transform( $string, $regex ); - $case_transform = $this->transform( $string, $regex, 'case' ); - $punct_transform = $this->transform( $string, $regex, 'punctuation' ); - } + // Skip past potential variable array access: $var['Key']. + if ( \T_VARIABLE === $this->tokens[ $i ]['code'] ) { + do { + $open_bracket = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true ); + if ( false === $open_bracket + || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $open_bracket ]['code'] + || ! isset( $this->tokens[ $open_bracket ]['bracket_closer'] ) + ) { + continue 2; + } - if ( $string === $transform ) { - continue; - } + $i = $this->tokens[ $open_bracket ]['bracket_closer']; - if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) { - $expected[ $i ] = '"' . $transform . '"'; - } else { - $expected[ $i ] = '\'' . $transform . '\''; - } + } while ( isset( $this->tokens[ $i ] ) && $i <= $parameters[1]['end'] ); - if ( $string !== $case_transform ) { - $case_errors++; - } - if ( $string !== $punct_transform ) { - $underscores++; - } + continue; + } + + // Skip past non-string tokens. + if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) === false ) { + continue; + } + + $string = $this->strip_quotes( $this->tokens[ $i ]['content'] ); + + /* + * Here be dragons - a double quoted string can contain extrapolated variables + * which don't have to comply with these rules. + */ + if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) { + $transform = $this->transform_complex_string( $string, $regex ); + $case_transform = $this->transform_complex_string( $string, $regex, 'case' ); + $punct_transform = $this->transform_complex_string( $string, $regex, 'punctuation' ); + } else { + $transform = $this->transform( $string, $regex ); + $case_transform = $this->transform( $string, $regex, 'case' ); + $punct_transform = $this->transform( $string, $regex, 'punctuation' ); + } + + if ( $string === $transform ) { + continue; + } + + if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) { + $expected[ $i ] = '"' . $transform . '"'; + } else { + $expected[ $i ] = '\'' . $transform . '\''; + } + + if ( $string !== $case_transform ) { + $case_errors++; + } + if ( $string !== $punct_transform ) { + $underscores++; } } diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc index bda73caaf5..7fd072418e 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc @@ -83,3 +83,8 @@ do_action( "admin_Head_{${$object->getName()}}_Action_{${$object->getName()}}_Ac // Make sure that deprecated hook names are ignored for this sniff. do_action_deprecated( "admin_Head_$Post admin_Head_$Post" ); // Ok. apply_filters_deprecated( "admin_Head_$Post->ID admin_Head_$Post->ID" ); // Ok. + +// Ignore array keys. +do_action( 'prefix_block_' . $block['blockName'] ); // Ok. +do_action( 'prefix_block_' . $block [ 'blockName' ] . '_More_hookname' ); // Error - use lowercase (second part of the hook name). +do_action( "prefix_block_{$block['blockName']}" ); // Ok. diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php index b128f1da7b..565c4ccf6e 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php @@ -68,6 +68,7 @@ public function getErrorList( $testFile = 'ValidHookNameUnitTest.1.inc' ) { 79 => 1, 80 => 1, 81 => 1, + 89 => 1, ); case 'ValidHookNameUnitTest.2.inc': From ea20e20c009d03374b99e3046be32e0e00657bb1 Mon Sep 17 00:00:00 2001 From: losnappas Date: Sat, 1 Jun 2019 11:57:38 +0000 Subject: [PATCH 04/72] Sniff::$sanitizingFunctions: Add wp_sanitize_redirect (#1716) Ref: https://developer.wordpress.org/reference/functions/wp_sanitize_redirect/ Fixes 1715 --- WordPress/Sniff.php | 1 + WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.inc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 1d5edc4e28..8c3a86cb40 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -287,6 +287,7 @@ abstract class Sniff implements PHPCS_Sniff { 'wp_parse_id_list' => true, 'wp_redirect' => true, 'wp_safe_redirect' => true, + 'wp_sanitize_redirect' => true, 'wp_strip_all_tags' => true, ); diff --git a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.inc b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.inc index 46dad6254c..b70afe7f0a 100644 --- a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.inc +++ b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.inc @@ -331,3 +331,5 @@ function test_using_different_unslashing_functions() { $sane = sanitize_text_field(stripslashes_deep($_GET['test'])); // Ok. $sane = sanitize_text_field( stripslashes_from_strings_only( $_GET['test'] ) ); // OK. } + +echo wp_sanitize_redirect( wp_unslash( $_GET['test'] ) ); // OK. From 1418e16fda96d61aa43d2d9448d75cb56198c0ba Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 4 Jun 2019 22:02:25 +0200 Subject: [PATCH 05/72] Add RECOVERY_MODE_COOKIE to whitelisted core constants --- WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index de46e0bdae..4655f953dd 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -164,6 +164,7 @@ class PrefixAllGlobalsSniff extends AbstractFunctionParameterSniff { 'ADMIN_COOKIE_PATH' => true, 'PLUGINS_COOKIE_PATH' => true, 'COOKIE_DOMAIN' => true, + 'RECOVERY_MODE_COOKIE' => true, 'FORCE_SSL_ADMIN' => true, 'FORCE_SSL_LOGIN' => true, 'AUTOSAVE_INTERVAL' => true, From dd25d8ad6568f8f04575235cbdc87d71c4ac1e66 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Wed, 26 Jun 2019 14:13:13 +0100 Subject: [PATCH 06/72] Composer: Update repo URL references The repo has moved organization within GitHub. --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index f306ca7bdc..8fd557c301 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "authors": [ { "name": "Contributors", - "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" } ], "require": { @@ -42,8 +42,8 @@ ] }, "support": { - "issues": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues", - "wiki": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki", - "source": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards" + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki", + "source": "https://github.com/WordPress/WordPress-Coding-Standards" } } From c3bdb1df5fe12caa6371e4305a834886a7d60105 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 27 Jun 2019 12:51:21 +0200 Subject: [PATCH 07/72] Travis: add "quicktest" stage for non-PR/merge builds The "quicktest" stage will only run a CS check, ruleset check, linting and the unit tests against low/high PHP/PHPCS combinations. This should catch most issues. The more comprehensive complete build against a larger combination of PHP/PHPCS combination will now only be run on PRs and merges to `develop`/`master`. --- .travis.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4fb839d60..294a81aee6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,14 +27,23 @@ env: # Lowest supported release in the 3.x series with which WPCS is compatible. - PHPCS_BRANCH="3.3.1" +# Define the stages used. +# For non-PRs, only the sniff, ruleset and quicktest stages are run. +# For pull requests and merges, the full script is run (skipping quicktest). +# Note: for pull requests, "develop" should be the base branch name. +# See: https://docs.travis-ci.com/user/conditions-v1 stages: - - sniff - - rulesets - - test + - name: sniff + - name: rulesets + - name: quicktest + if: type = push AND branch NOT IN (master, develop) + - name: test + if: branch IN (master, develop) jobs: fast_finish: true include: + #### SNIFF STAGE #### - stage: sniff php: 7.3 env: PHPCS_BRANCH="dev-master" @@ -61,6 +70,7 @@ jobs: - diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml") - diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample") + #### RULESET STAGE #### # Make sure the rulesets don't throw unexpected errors or warnings. # This check needs to be run against a high PHP version to prevent triggering the syntax error check. # It also needs to be run against all PHPCS versions WPCS is tested against. @@ -89,6 +99,19 @@ jobs: - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Extra - $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress + #### QUICK TEST STAGE #### + # This is a much quicker test which only runs the unit tests and linting against the low/high + # supported PHP/PHPCS combinations. + - stage: quicktest + php: 7.3 + env: PHPCS_BRANCH="dev-master" LINT=1 + - php: 7.3 + env: PHPCS_BRANCH="3.3.1" + - php: 5.4 + env: PHPCS_BRANCH="dev-master" LINT=1 + - php: 5.4 + env: PHPCS_BRANCH="3.3.1" + allow_failures: # Allow failures for unstable builds. - php: "7.4snapshot" From d0b9d93221abaf86bae76fc96fbd517d0209a631 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 28 May 2019 02:59:38 +0200 Subject: [PATCH 08/72] RestrictedPHPFunctions: add error for use of date() As this sniff is already included in the WP Core ruleset and the enhancement request is about PHP native functions, this seemed liked a logical sniff to add this to. I've elected to make this an `error` instead of a `warning` as the code within WP Core has been cleaned up for this issue now and it would be good to prevent new instances of `date()` creeping in. Fixes 1713 --- WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php | 8 ++++++++ WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc | 3 +++ WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php | 1 + 3 files changed, 12 insertions(+) diff --git a/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php b/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php index 6bde3337d4..27faaa51a6 100644 --- a/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php @@ -17,6 +17,7 @@ * @package WPCS\WordPressCodingStandards * * @since 0.14.0 + * @since 2.2.0 New group `date` added. */ class RestrictedPHPFunctionsSniff extends AbstractFunctionRestrictionsSniff { @@ -42,6 +43,13 @@ public function getGroups() { 'create_function', ), ), + 'date' => array( + 'type' => 'error', + 'message' => '%s() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.', + 'functions' => array( + 'date', + ), + ), ); } diff --git a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc index 84dbd1d7b3..2a4e8754b5 100644 --- a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc +++ b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc @@ -3,3 +3,6 @@ add_action( 'widgets_init', create_function( '', // Error. 'return register_widget( "time_more_on_time_widget" );' ) ); + +$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) ); // Error. +$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) ); // OK. diff --git a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php index e39e473eb5..30ad0b2b00 100644 --- a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php @@ -28,6 +28,7 @@ class RestrictedPHPFunctionsUnitTest extends AbstractSniffUnitTest { public function getErrorList() { return array( 3 => 1, + 7 => 2, ); } From ce7e4a7b24650eda0d7e5a6b7f7d01c3c6cef4e1 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 27 Jun 2019 22:28:26 +0100 Subject: [PATCH 09/72] Add `$plugin` to the list of global variables that shouldn't be overridden. --- WordPress/Sniff.php | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 8c3a86cb40..6fc8842051 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -708,6 +708,7 @@ abstract class Sniff implements PHPCS_Sniff { 'PHP_SELF' => true, 'phpmailer' => true, 'plugin_page' => true, + 'plugin' => true, 'plugins' => true, 'post' => true, 'post_default_category' => true, From d50ee5864a295bb2f3780431dcb90fa62b72eb6a Mon Sep 17 00:00:00 2001 From: Flip Date: Thu, 20 Jun 2019 17:42:13 +0200 Subject: [PATCH 10/72] New error handling Deprecated Classes, Functions, Parameters and Parameter Values --- .../Docs/WP/DeprecatedClassesStandard.xml | 19 +++++++++++++++++++ .../Docs/WP/DeprecatedFunctionsStandard.xml | 19 +++++++++++++++++++ .../WP/DeprecatedParameterValuesStandard.xml | 19 +++++++++++++++++++ .../Docs/WP/DeprecatedParametersStandard.xml | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 WordPress/Docs/WP/DeprecatedClassesStandard.xml create mode 100644 WordPress/Docs/WP/DeprecatedFunctionsStandard.xml create mode 100644 WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml create mode 100644 WordPress/Docs/WP/DeprecatedParametersStandard.xml diff --git a/WordPress/Docs/WP/DeprecatedClassesStandard.xml b/WordPress/Docs/WP/DeprecatedClassesStandard.xml new file mode 100644 index 0000000000..42d57e56f1 --- /dev/null +++ b/WordPress/Docs/WP/DeprecatedClassesStandard.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml b/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml new file mode 100644 index 0000000000..7a0eaf9390 --- /dev/null +++ b/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml b/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml new file mode 100644 index 0000000000..b084f2466c --- /dev/null +++ b/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/WordPress/Docs/WP/DeprecatedParametersStandard.xml b/WordPress/Docs/WP/DeprecatedParametersStandard.xml new file mode 100644 index 0000000000..f754081c72 --- /dev/null +++ b/WordPress/Docs/WP/DeprecatedParametersStandard.xml @@ -0,0 +1,19 @@ + + + + + + + + + + $string ); // Deprecated WP 2.1 + ]]> + + + From fab1ed525e057c19d723bf7c93feaf0a48512abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Mon, 1 Jul 2019 05:33:31 +0200 Subject: [PATCH 11/72] Documentation: Update all links to the repository (#1748) The GitHub repository has moved from the dedicated `WordPress-Coding-Standards` organisation to the `WordPress` organisation. This: * Updates all links which pointed to the old repo on GH to the new one. * Updates the badges in the Readme to pick up things up correctly again for the new repo. * Updated all links to Travis from `.org` to `.com` as the build CI has moved as well. --- .github/CONTRIBUTING.md | 4 +- .travis.yml | 2 +- CHANGELOG.md | 142 +++++++++--------- README.md | 38 ++--- WordPress-Core/ruleset.xml | 20 +-- WordPress-Extra/ruleset.xml | 40 ++--- ...stractArrayAssignmentRestrictionsSniff.php | 2 +- WordPress/AbstractClassRestrictionsSniff.php | 2 +- WordPress/AbstractFunctionParameterSniff.php | 2 +- .../AbstractFunctionRestrictionsSniff.php | 2 +- WordPress/PHPCSHelper.php | 2 +- WordPress/Sniff.php | 2 +- .../Arrays/ArrayDeclarationSpacingSniff.php | 2 +- .../Sniffs/Arrays/ArrayIndentationSniff.php | 2 +- .../ArrayKeySpacingRestrictionsSniff.php | 2 +- .../Arrays/CommaAfterArrayItemSniff.php | 2 +- .../MultipleStatementAlignmentSniff.php | 2 +- .../Classes/ClassInstantiationSniff.php | 2 +- .../AssignmentInConditionSniff.php | 2 +- .../CodeAnalysis/EmptyStatementSniff.php | 2 +- .../Sniffs/DB/DirectDatabaseQuerySniff.php | 2 +- .../DB/PreparedSQLPlaceholdersSniff.php | 2 +- WordPress/Sniffs/DB/PreparedSQLSniff.php | 2 +- .../Sniffs/DB/RestrictedClassesSniff.php | 2 +- .../Sniffs/DB/RestrictedFunctionsSniff.php | 2 +- WordPress/Sniffs/DB/SlowDBQuerySniff.php | 2 +- WordPress/Sniffs/Files/FileNameSniff.php | 2 +- .../PrefixAllGlobalsSniff.php | 2 +- .../ValidFunctionNameSniff.php | 2 +- .../NamingConventions/ValidHookNameSniff.php | 2 +- .../ValidVariableNameSniff.php | 2 +- .../Sniffs/PHP/DevelopmentFunctionsSniff.php | 2 +- .../PHP/DiscouragedPHPFunctionsSniff.php | 2 +- WordPress/Sniffs/PHP/DontExtractSniff.php | 2 +- WordPress/Sniffs/PHP/IniSetSniff.php | 2 +- .../Sniffs/PHP/NoSilencedErrorsSniff.php | 2 +- WordPress/Sniffs/PHP/POSIXFunctionsSniff.php | 2 +- .../Sniffs/PHP/PregQuoteDelimiterSniff.php | 2 +- .../PHP/RestrictedPHPFunctionsSniff.php | 2 +- .../Sniffs/PHP/StrictComparisonsSniff.php | 2 +- WordPress/Sniffs/PHP/StrictInArraySniff.php | 2 +- WordPress/Sniffs/PHP/TypeCastsSniff.php | 2 +- WordPress/Sniffs/PHP/YodaConditionsSniff.php | 2 +- .../Sniffs/Security/EscapeOutputSniff.php | 2 +- .../Security/NonceVerificationSniff.php | 2 +- .../Sniffs/Security/PluginMenuSlugSniff.php | 2 +- .../Sniffs/Security/SafeRedirectSniff.php | 2 +- .../Security/ValidatedSanitizedInputSniff.php | 4 +- .../Sniffs/Utils/I18nTextDomainFixerSniff.php | 2 +- .../Sniffs/WP/AlternativeFunctionsSniff.php | 2 +- WordPress/Sniffs/WP/CapitalPDangitSniff.php | 2 +- WordPress/Sniffs/WP/CronIntervalSniff.php | 2 +- .../Sniffs/WP/DeprecatedClassesSniff.php | 2 +- .../Sniffs/WP/DeprecatedFunctionsSniff.php | 2 +- .../WP/DeprecatedParameterValuesSniff.php | 2 +- .../Sniffs/WP/DeprecatedParametersSniff.php | 2 +- .../Sniffs/WP/DiscouragedConstantsSniff.php | 2 +- .../Sniffs/WP/DiscouragedFunctionsSniff.php | 2 +- .../WP/EnqueuedResourceParametersSniff.php | 2 +- .../Sniffs/WP/EnqueuedResourcesSniff.php | 2 +- .../WP/GlobalVariablesOverrideSniff.php | 2 +- WordPress/Sniffs/WP/I18nSniff.php | 2 +- WordPress/Sniffs/WP/PostsPerPageSniff.php | 2 +- WordPress/Sniffs/WP/TimezoneChangeSniff.php | 2 +- .../WhiteSpace/CastStructureSpacingSniff.php | 2 +- .../ControlStructureSpacingSniff.php | 2 +- .../WhiteSpace/DisallowInlineTabsSniff.php | 2 +- .../WhiteSpace/OperatorSpacingSniff.php | 2 +- .../WhiteSpace/PrecisionAlignmentSniff.php | 2 +- .../ArrayDeclarationSpacingUnitTest.php | 2 +- .../Tests/Arrays/ArrayIndentationUnitTest.php | 2 +- .../ArrayKeySpacingRestrictionsUnitTest.php | 2 +- .../Arrays/CommaAfterArrayItemUnitTest.php | 2 +- .../MultipleStatementAlignmentUnitTest.php | 2 +- .../Classes/ClassInstantiationUnitTest.php | 2 +- .../AssignmentInConditionUnitTest.php | 2 +- .../CodeAnalysis/EmptyStatementUnitTest.php | 2 +- .../Tests/DB/DirectDatabaseQueryUnitTest.php | 2 +- .../DB/PreparedSQLPlaceholdersUnitTest.php | 2 +- WordPress/Tests/DB/PreparedSQLUnitTest.php | 2 +- .../Tests/DB/RestrictedClassesUnitTest.php | 2 +- .../Tests/DB/RestrictedFunctionsUnitTest.php | 2 +- WordPress/Tests/DB/SlowDBQueryUnitTest.php | 2 +- WordPress/Tests/Files/FileNameUnitTest.php | 2 +- .../PrefixAllGlobalsUnitTest.php | 2 +- .../ValidFunctionNameUnitTest.php | 2 +- .../ValidHookNameUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- .../PHP/DevelopmentFunctionsUnitTest.php | 2 +- .../PHP/DiscouragedPHPFunctionsUnitTest.php | 2 +- WordPress/Tests/PHP/DontExtractUnitTest.php | 2 +- WordPress/Tests/PHP/IniSetUnitTest.php | 2 +- .../Tests/PHP/NoSilencedErrorsUnitTest.php | 2 +- .../Tests/PHP/POSIXFunctionsUnitTest.php | 2 +- .../Tests/PHP/PregQuoteDelimiterUnitTest.php | 2 +- .../PHP/RestrictedPHPFunctionsUnitTest.php | 2 +- .../Tests/PHP/StrictComparisonsUnitTest.php | 2 +- WordPress/Tests/PHP/StrictInArrayUnitTest.php | 2 +- WordPress/Tests/PHP/TypeCastsUnitTest.php | 2 +- .../Tests/PHP/YodaConditionsUnitTest.php | 2 +- .../Tests/Security/EscapeOutputUnitTest.php | 2 +- .../Security/NonceVerificationUnitTest.php | 2 +- .../Tests/Security/PluginMenuSlugUnitTest.php | 2 +- .../Tests/Security/SafeRedirectUnitTest.php | 2 +- .../ValidatedSanitizedInputUnitTest.php | 2 +- .../Utils/I18nTextDomainFixerUnitTest.php | 2 +- .../Tests/WP/AlternativeFunctionsUnitTest.php | 2 +- WordPress/Tests/WP/CapitalPDangitUnitTest.php | 2 +- WordPress/Tests/WP/CronIntervalUnitTest.php | 2 +- .../Tests/WP/DeprecatedClassesUnitTest.php | 2 +- .../Tests/WP/DeprecatedFunctionsUnitTest.php | 2 +- .../WP/DeprecatedParameterValuesUnitTest.php | 2 +- .../Tests/WP/DeprecatedParametersUnitTest.php | 2 +- .../Tests/WP/DiscouragedConstantsUnitTest.php | 2 +- .../Tests/WP/DiscouragedFunctionsUnitTest.php | 2 +- .../WP/EnqueuedResourceParametersUnitTest.php | 2 +- .../Tests/WP/EnqueuedResourcesUnitTest.php | 2 +- .../WP/GlobalVariablesOverrideUnitTest.1.inc | 6 +- .../WP/GlobalVariablesOverrideUnitTest.php | 2 +- WordPress/Tests/WP/I18nUnitTest.php | 2 +- WordPress/Tests/WP/PostsPerPageUnitTest.php | 2 +- WordPress/Tests/WP/TimezoneChangeUnitTest.php | 2 +- .../CastStructureSpacingUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.1.inc | 2 +- ...ontrolStructureSpacingUnitTest.1.inc.fixed | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- .../WhiteSpace/DisallowInlineTabsUnitTest.php | 2 +- .../WhiteSpace/OperatorSpacingUnitTest.php | 2 +- .../WhiteSpace/PrecisionAlignmentUnitTest.php | 2 +- phpcs.xml.dist.sample | 2 +- 130 files changed, 250 insertions(+), 250 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2a6e2d2496..34b96be5c7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -30,7 +30,7 @@ Once a commit is made to `develop`, a PR should be opened from `develop` into `m When writing sniffs, always remember that any `public` sniff property can be overruled via a custom ruleset by the end-user. Only make a property `public` if that is the intended behaviour. -When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch. +When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch. ## Whitelist comments @@ -51,7 +51,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test suite for unit testing the sniffs. -Presuming you have installed `PHP_CodeSniffer` and the WordPress-Coding-Standards as [noted in the README](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#how-to-use-this), all you need now is `PHPUnit`. +Presuming you have installed `PHP_CodeSniffer` and the WordPress-Coding-Standards as [noted in the README](https://github.com/WordPress/WordPress-Coding-Standards#how-to-use-this), all you need now is `PHPUnit`. > N.B.: If you installed WPCS using Composer, make sure you used `--prefer-source` or run `composer install --prefer-source` now to make sure the unit tests are available. > Other than that, you're all set already as Composer will have installed PHPUnit for you. diff --git a/.travis.yml b/.travis.yml index 294a81aee6..2eb7d0e9e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ jobs: - libxml2-utils script: # WordPress Coding Standards. - # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + # @link https://github.com/WordPress/WordPress-Coding-Standards # @link http://pear.php.net/package/PHP_CodeSniffer/ - $(pwd)/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index a777dc0905..53270b436b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ _No documentation available about unreleased changes as of yet._ ### Changed - The `WordPress.WP.CapitalPDangit` will now ignore misspelled instances of `WordPress` within constant declarations. This covers both constants declared using `defined()` as well as constants declared using the `const` keyword. -- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.9`. +- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.9`. ### Removed - `paginate_comments_links()` from the list of auto-escaped functions `Sniff::$autoEscapedFunctions`. @@ -53,7 +53,7 @@ _No documentation available about unreleased changes as of yet._ ### Changed - Moved the `WordPress.PHP.StrictComparisons`, `WordPress.PHP.StrictInArray` and the `WordPress.CodeAnalysis.AssignmentInCondition` sniff from the `WordPress-Extra` to the `WordPress-Core` ruleset. - The `Squiz.Commenting.InlineComment.SpacingAfter` error is no longer included in the `WordPress-Docs` ruleset. -- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.8`. +- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.8`. - The `WordPress.WP.DeprecatedFunctions` sniff will now detect functions deprecated in WP 5.1. - The `WordPress.Security.NonceVerification` sniff now allows for variable type testing, comparisons, unslashing and sanitization before the nonce check. A nonce check within the same scope, however, is still required. - The `WordPress.Security.ValidatedSanitizedInput` sniff now allows for using a superglobal in an array-value comparison without sanitization, same as when the superglobal is used in a scalar value comparison. @@ -116,7 +116,7 @@ Also, all previously deprecated sniffs, properties and methods have been removed Please read the complete changelog carefully before you upgrade. -If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WPCS sniffs, please read the [Developers Upgrade Guide to WordPressCS 2.0.0](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-2.0.0-for-Developers-of-external-standards). +If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WPCS sniffs, please read the [Developers Upgrade Guide to WordPressCS 2.0.0](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-2.0.0-for-Developers-of-external-standards). ### Changes since 2.0.0-RC1 @@ -126,7 +126,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of ### Changes since 1.2.1 For a full list of changes from the 1.2.1 version, please review the following changelog: -* https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases/tag/2.0.0-RC1 +* https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/2.0.0-RC1 ## [2.0.0-RC1] - 2018-12-31 @@ -141,7 +141,7 @@ Also, all previously deprecated sniffs, properties and methods have been removed Please read the complete changelog carefully before you upgrade. -If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WPCS sniffs, please read the [Developers Upgrade Guide to WordPressCS 2.0.0](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-2.0.0-for-Developers-of-external-standards). +If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WPCS sniffs, please read the [Developers Upgrade Guide to WordPressCS 2.0.0](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-2.0.0-for-Developers-of-external-standards). ### Added - `Generic.PHP.DiscourageGoto`, `Generic.PHP.LowerCaseType`, `Generic.WhiteSpace.ArbitraryParenthesesSpacing` and `PSR12.Keywords.ShortFormTypeKeywords` to the `WordPress-Core` ruleset. @@ -181,8 +181,8 @@ If you are a maintainer of an external standard based on WordPressCS and any of - `WordPress.NamingConventions.ValidVariableName`: Added unit tests confirming support for multi-variable/property declarations. - The `get_name_suggestion()` method has been moved from the `WordPress.NamingConventions.ValidFunctionName` sniff to the base `Sniff` class, renamed to `get_snake_case_name_suggestion()` and made static. - The rulesets are now validated against the `PHP_CodeSniffer` XSD schema. -- Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to use the recommended ruleset syntax for `PHP_CodeSniffer` 3.3.1+, including using the new [array property format](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0) which is now supported. -- Dev: The command to run the unit tests has changed. Please see the updated instructions in the [CONTRIBUTING.md](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/.github/CONTRIBUTING.md) file. +- Updated the [custom ruleset example](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to use the recommended ruleset syntax for `PHP_CodeSniffer` 3.3.1+, including using the new [array property format](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0) which is now supported. +- Dev: The command to run the unit tests has changed. Please see the updated instructions in the [CONTRIBUTING.md](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/.github/CONTRIBUTING.md) file. The `bin/pre-commit` example git hook has been updated to match. Additionally a `run-tests` script has been added to the `composer.json` file for your convenience. To facilitate this, PHPUnit has been added to `require-dev`, even though it is strictly speaking a dependency of PHPCS, not of WPCS. - Dev: The DealerDirect PHPCS Composer plugin has been added to `require-dev`. @@ -190,7 +190,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of - User facing documentation, including the wiki, as well as inline documentation has been updated for all the changes contained in WordPressCS 2.0 and other recommended best practices for `PHP_CodeSniffer` 3.3.1+. ### Deprecated -- The use of the [WordPressCS native whitelist comments](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors), which were introduced in WPCS 0.4.0, have been deprecated and support will be removed in WPCS 3.0.0. +- The use of the [WordPressCS native whitelist comments](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors), which were introduced in WPCS 0.4.0, have been deprecated and support will be removed in WPCS 3.0.0. The WordPressCS native whitelist comments will continue to work for now, but a deprecation warning will be thrown when they are encountered. You are encouraged to upgrade our whitelist comment to use the [PHPCS native selective ignore annotations](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.2.0) as introduced in `PHP_CodeSniffer` 3.2.0, as soon as possible. @@ -203,7 +203,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of For checking a theme/plugin for hosting on the WordPress.com VIP platform, please use the [Automattic VIP coding standards](https://github.com/Automattic/VIP-Coding-Standards) instead. - Support for array properties set in a custom ruleset without the `type="array"` attribute. Support for this was deprecated in WPCS 1.0.0. - If in doubt about how properties should be set in your custom ruleset, please refer to the [Customizable sniff properties](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) wiki page which contains XML code examples for setting each and every WPCS native sniff property. + If in doubt about how properties should be set in your custom ruleset, please refer to the [Customizable sniff properties](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) wiki page which contains XML code examples for setting each and every WPCS native sniff property. As the minimum `PHP_CodeSniffer` version is now 3.3.1, you can now also use the [new format for setting array properties](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0), so this would be a great moment to review and update your custom ruleset. Note: the ability to set select properties from the command-line as comma-delimited strings is _not_ affected by this change. - The following sniffs have been removed outright without deprecation. @@ -278,7 +278,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of Note: This will be the last release supporting PHP_CodeSniffer 2.x. ### Changed -- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.7`. +- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.7`. - The `WordPress.NamingConventions.PrefixAllGlobals` sniff will now report the error for hook names and constant names declared with `define()` on the line containing the parameter for the hook/constant name. Previously, it would report the error on the line containing the function call. - Various minor housekeeping fixes to inline documentation, rulesets, code. @@ -319,7 +319,7 @@ Note: This will be the last release supporting PHP_CodeSniffer 2.x. - Minor hardening and efficiency improvements to the `WordPress.NamingConventions.PrefixAllGlobals` sniff. - The inline documentation of the `WordPress-Core` ruleset has been updated to be in line again with [the handbook](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/). - The inline links to documentation about the VIP requirements have been updated. -- Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to recommend using `PHPCompatibilityWP` rather than `PHPCompatibility`. +- Updated the [custom ruleset example](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to recommend using `PHPCompatibilityWP` rather than `PHPCompatibility`. - All sniffs are now also being tested against PHP 7.3 for consistent sniff results. Note: PHP 7.3 is only supported in combination with PHPCS 3.3.1 or higher as `PHP_CodeSniffer` itself has an incompatibility in earlier versions. - Minor grammar fixes in text strings and documentation. @@ -351,7 +351,7 @@ Note: This will be the last release supporting PHP_CodeSniffer 2.x. The user-defined whitelist will always be respected. By default, this property is set to `true` for the `WordPress-Core` ruleset and to `false` for the `WordPress-Extra` ruleset (which is stricter regarding these kind of best practices). - Metrics to the `WordPress.NamingConventions.PrefixAllGlobals` sniff to aid people in determining the most commonly used prefix in a legacy project. - For an example of how to use this feature, please see the detailed explanation in the [pull request](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1437). + For an example of how to use this feature, please see the detailed explanation in the [pull request](https://github.com/WordPress/WordPress-Coding-Standards/pull/1437). ### Changed - The `PEAR.Functions.FunctionCallSignature` sniff, which is part of the `WordPress-Core` ruleset, used to allow multiple function call parameters per line in multi-line function calls. This will no longer be allowed. @@ -412,7 +412,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - New utility method `Sniff::is_use_of_global_constant()`. - A rationale to the package suggestion made via `composer.json`. - CI: Validation of the `composer.json` file on each build. -- A wiki page with instructions on how to [set up WPCS to run with Eclipse on XAMPP](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/How-to-use-WPCS-with-Eclipse-and-XAMPP). +- A wiki page with instructions on how to [set up WPCS to run with Eclipse on XAMPP](https://github.com/WordPress/WordPress-Coding-Standards/wiki/How-to-use-WPCS-with-Eclipse-and-XAMPP). - Readme: A link to an external resource with more examples for setting up PHPCS for CI. - Readme: A badge-based quick overview of the project. @@ -433,7 +433,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - The `WordPress.VIP.PostsPerPage` sniff has been split into two distinct sniffs: - `WordPress.WP.PostsPerPage` which will check for the use of a high pagination limit and will throw a `warning` when this is encountered. For the `VIP` ruleset, the error level remains `error`. - `WordPress.VIP.PostsPerPage` wich will check for disabling of pagination. -- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.6`. +- The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.6`. - The `WordPress.WP.AlternativeFunctions` sniff will now only throw a warning if/when the recommended alternative function is available in the minimum supported WP version of a project. In addition to this, certain alternatives are only valid alternatives in certain circumstances, like when the WP version only supports the first parameter of the PHP function it is trying to replace. This will now be taken into account for: @@ -456,8 +456,8 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - CI: Each change will now also be checked for PHP cross-version compatibility. - CI: The rulesets will now also be tested on each change to ensure no unexpected messages are thrown. - CI: Minor changes to the script to make the build testing faster. -- Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) for the changes contained in this release and to reflect current best practices regarding the PHPCompatibility standard. -- The instructions on how to set up WPCS for various IDEs have been moved from the `README` to the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki). +- Updated the [custom ruleset example](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) for the changes contained in this release and to reflect current best practices regarding the PHPCompatibility standard. +- The instructions on how to set up WPCS for various IDEs have been moved from the `README` to the [wiki](https://github.com/WordPress/WordPress-Coding-Standards/wiki). - Updated output examples in `README.md` and `CONTRIBUTING.md` and other minor changes to these files. - Updated references to the PHPCompatibility standard to reflect its new location and recommend using PHPCompatibilityWP. @@ -490,11 +490,11 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - `Variables` - `XSS` - The `posts_per_page` property in the `WordPress.VIP.PostsPerPage` sniff has been deprecated as the related functionality has been moved to the `WordPress.WP.PostsPerPage` sniff. - See [WP PostsPerPage: post limit](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#wp-postsperpage-post-limit) for more information about this property. + See [WP PostsPerPage: post limit](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#wp-postsperpage-post-limit) for more information about this property. - The `exclude` property which is available to most sniffs which extend the `AbstractArrayAssignmentRestrictions`, `AbstractFunctionRestrictions` and `AbstractVariableRestrictions` classes or any of their children, used to be a `string` property and expected a comma-delimited list of groups to exclude. The type of the property has now been changed to `array`. Custom rulesets which pass this property need to be adjusted to reflect this change. Support for passing the property as a comma-delimited string has been deprecated and will be removed in WPCS 2.0.0. - See [Excluding a group of checks](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#excluding-a-group-of-checks) for more information about the sniffs affected by this change. + See [Excluding a group of checks](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#excluding-a-group-of-checks) for more information about the sniffs affected by this change. - The `AbstractVariableRestrictionsSniff` class has been deprecated as all sniffs depending on this class have been deprecated. Unless a new sniff is created in the near future which uses this class, the abstract class will be removed in WPCS 2.0.0. - The `Sniff::has_html_open_tag()` utility method has been deprecated as it is now only used by deprecated sniffs. The method will be removed in WPCS 2.0.0. @@ -509,7 +509,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu PHPCS 3.2.0 introduced new annotations which can be used inline to selectively disable/ignore certain sniffs. **Note**: The initial implementation of the new annotations was buggy. If you intend to start using these new style annotations, you are strongly advised to use PHPCS 3.3.0 or higher. For more information about these annotations, please refer to the [PHPCS Wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file). - - The [WPCS native whitelist comments](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) can now be combined with the new style PHPCS whitelist annotations in the `-- for reasons` part of the annotation. + - The [WPCS native whitelist comments](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) can now be combined with the new style PHPCS whitelist annotations in the `-- for reasons` part of the annotation. - `WordPress.Arrays.ArrayDeclarationSpacing`: the fixer will now handle the new style annotations correctly. - `WordPress.Arrays.CommaAfterArrayItem`: prevent a fixer loop when new style annotations are encountered. - `WordPress.Files.FileName`: respect the new style annotations if these would selectively disable this sniff. @@ -579,10 +579,10 @@ If you are a maintainer of an external standard based on WPCS and any of your cu ### Added - `WordPress.Arrays.MultipleStatementAlignment` sniff to the `WordPress-Core` ruleset which will align the array assignment operator for multi-item, multi-line associative arrays. - This new sniff offers four custom properties to customize its behaviour: [`ignoreNewlines`](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-for-new-lines), [`exact`](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-non-exact-alignment), [`maxColumn`](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-maximum-column) and [`alignMultilineItems`](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-dealing-with-multi-line-items). + This new sniff offers four custom properties to customize its behaviour: [`ignoreNewlines`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-for-new-lines), [`exact`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-non-exact-alignment), [`maxColumn`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-maximum-column) and [`alignMultilineItems`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-dealing-with-multi-line-items). - `WordPress.DB.PreparedSQLPlaceholders` sniff to the `WordPress-Core` ruleset which will analyse the placeholders passed to `$wpdb->prepare()` for their validity, check whether queries using `IN ()` and `LIKE` statements are created correctly and will check whether a correct number of replacements are passed. This sniff should help detect queries which are impacted by the security fixes to `$wpdb->prepare()` which shipped with WP 4.8.2 and 4.8.3. - The sniff also adds a new ["PreparedSQLPlaceholders replacement count" whitelist comment](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors#preparedsql-placeholders-vs-replacements) for pertinent replacement count vs placeholder mismatches. Please consider carefully whether something could be a bug when you are tempted to use the whitelist comment and if so, [report it](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/new). + The sniff also adds a new ["PreparedSQLPlaceholders replacement count" whitelist comment](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors#preparedsql-placeholders-vs-replacements) for pertinent replacement count vs placeholder mismatches. Please consider carefully whether something could be a bug when you are tempted to use the whitelist comment and if so, [report it](https://github.com/WordPress/WordPress-Coding-Standards/issues/new). - `WordPress.PHP.DiscourageGoto` sniff to the `WordPress-Core` ruleset. - `WordPress.PHP.RestrictedFunctions` sniff to the `WordPress-Core` ruleset which initially forbids the use of `create_function()`. This was previous only discouraged under certain circumstances. @@ -591,7 +591,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - `WordPress.WhiteSpace.SemicolonSpacing` sniff to the `WordPress-Core` ruleset which will throw a (fixable) error when whitespace is found before a semi-colon, except for when the semi-colon denotes an empty `for()` condition. - `WordPress.CodeAnalysis.AssignmentInCondition` sniff to the `WordPress-Extra` ruleset. - `WordPress.WP.DiscouragedConstants` sniff to the `WordPress-Extra` and `WordPress-VIP` rulesets to detect usage of deprecated WordPress constants, such as `STYLESHEETPATH` and `HEADER_IMAGE`. -- Ability to pass the `minimum_supported_version` to use for the `DeprecatedFunctions`, `DeprecatedClasses` and `DeprecatedParameters` sniff in one go. You can pass a `minimum_supported_wp_version` runtime variable for this [from the command line or pass it using a `config` directive in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#setting-minimum-supported-wp-version-for-all-sniffs-in-one-go-wpcs-0140). +- Ability to pass the `minimum_supported_version` to use for the `DeprecatedFunctions`, `DeprecatedClasses` and `DeprecatedParameters` sniff in one go. You can pass a `minimum_supported_wp_version` runtime variable for this [from the command line or pass it using a `config` directive in a custom ruleset](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#setting-minimum-supported-wp-version-for-all-sniffs-in-one-go-wpcs-0140). - `Generic.Formatting.MultipleStatementAlignment` - customized to have a `maxPadding` of `40` -, `Generic.Functions.FunctionCallArgumentSpacing` and `Squiz.WhiteSpace.ObjectOperatorSpacing` to the `WordPress-Core` ruleset. - `Squiz.Scope.MethodScope`, `Squiz.Scope.MemberVarScope`, `Squiz.WhiteSpace.ScopeKeywordSpacing`, `PSR2.Methods.MethodDeclaration`, `Generic.Files.OneClassPerFile`, `Generic.Files.OneInterfacePerFile`, `Generic.Files.OneTraitPerFile`, `PEAR.Files.IncludingFile`, `Squiz.WhiteSpace.LanguageConstructSpacing`, `PSR2.Namespaces.NamespaceDeclaration` to the `WordPress-Extra` ruleset. - The `is_class_constant()`, `is_class_property` and `valid_direct_scope()` utility methods to the `WordPress\Sniff` class. @@ -600,13 +600,13 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - When passing an array property via a custom ruleset to PHP_CodeSniffer, spaces around the key/value are taken as intentional and parsed as part of the array key/value. In practice, this leads to confusion and WPCS does not expect any values which could be preceded/followed by a space, so for the WordPress Coding Standard native array properties, like `customAutoEscapedFunction`, `text_domain`, `prefixes`, WPCS will now trim whitespace from the keys/values received before use. - The WPCS native whitelist comments used to only work when they were put on the _end of the line_ of the code they applied to. As of now, they will also be recognized when they are be put at the _end of the statement_ they apply to. - The `WordPress.Arrays.ArrayDeclarationSpacing` sniff used to enforce all associative arrays to be multi-line. The handbook has been updated to only require this for multi-item associative arrays and the sniff has been updated accordingly. - [The original behaviour can still be enforced](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#arrays-forcing-single-item-associative-arrays-to-be-multi-line) by setting the new `allow_single_item_single_line_associative_arrays` property to `false` in a custom ruleset. + [The original behaviour can still be enforced](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#arrays-forcing-single-item-associative-arrays-to-be-multi-line) by setting the new `allow_single_item_single_line_associative_arrays` property to `false` in a custom ruleset. - The `WordPress.NamingConventions.PrefixAllGlobals` sniff will now allow for a limited list of WP core hooks which are intended to be called by plugins and themes. - The `WordPress.PHP.DiscouragedFunctions` sniff used to include `create_function`. This check has been moved to the new `WordPress.PHP.RestrictedFunctions` sniff. - The `WordPress.PHP.StrictInArray` sniff now has a separate error code `FoundNonStrictFalse` for when the `$strict` parameter has been set to `false`. This allows for excluding the warnings for that particular situation, which will normally be intentional, via a custom ruleset. -- The `WordPress.VIP.CronInterval` sniff now allows for customizing the minimum allowed cron interval by [setting a property in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-croninterval-minimum-interval). +- The `WordPress.VIP.CronInterval` sniff now allows for customizing the minimum allowed cron interval by [setting a property in a custom ruleset](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-croninterval-minimum-interval). - The `WordPress.VIP.RestrictedFunctions` sniff used to prohibit the use of certain WP native functions, recommending the use of `wpcom_vip_get_term_link()`, `wpcom_vip_get_term_by()` and `wpcom_vip_get_category_by_slug()` instead, as the WP native functions were not being cached. As the results of the relevant WP native functions are cached as of WP 4.8, the advice has now been reversed i.e. use the WP native functions instead of `wpcom...` functions. -- The `WordPress.VIP.PostsPerPage` sniff now allows for customizing the `post_per_page` limit for which the sniff will trigger by [setting a property in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-postsperpage-post-limit). +- The `WordPress.VIP.PostsPerPage` sniff now allows for customizing the `post_per_page` limit for which the sniff will trigger by [setting a property in a custom ruleset](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-postsperpage-post-limit). - The `WordPress.WP.I18n` sniff will now allow and actively encourage omitting the text domain in I18n function calls if the text domain passed via the `text_domain` property is `default`, i.e. the domain used by Core. When `default` is one of several text domains passed via the `text_domain` property, the error thrown when the domain is missing has been downgraded to a `warning`. - The `WordPress.XSS.EscapeOutput` sniff now has a separate error code `OutputNotEscapedShortEcho` and the error message texts have been updated. @@ -619,7 +619,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - Various minor documentation fixes. - Improved the Atom setup instructions in the Readme. - Updated the unit testing information in Contributing. -- Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) for the changes contained in this release and to make it more explicit what is recommended versus example code. +- Updated the [custom ruleset example](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) for the changes contained in this release and to make it more explicit what is recommended versus example code. - The minimum recommended version for the suggested `DealerDirect/phpcodesniffer-composer-installer` Composer plugin has gone up to `0.4.3`. This patch version fixes support for PHP 5.3. ### Fixed @@ -645,7 +645,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu ### Added - Support for PHP_CodeSniffer 3.0.2+. The minimum required PHPCS version (2.9.0) stays the same. -- Support for the PHPCS 3 `--ignore-annotations` command line option. If you pass this option, both PHPCS native `@ignore ...` annotations as well as the WPCS specific [whitelist flags](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) will be ignored. +- Support for the PHPCS 3 `--ignore-annotations` command line option. If you pass this option, both PHPCS native `@ignore ...` annotations as well as the WPCS specific [whitelist flags](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) will be ignored. ### Changed - The minimum required PHP version is now 5.3 when used in combination with PHPCS 2.x and PHP 5.4 when used in combination with PHPCS 3.x. @@ -678,9 +678,9 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - `WordPress.Classes.ClassInstantion` sniff to the `WordPress-Extra` ruleset to detect - and auto-fix - missing parentheses on object instantiation and superfluous whitespace in PHP and JS files. The sniff will also detect `new` being assigned by reference. - `WordPress.CodeAnalysis.EmptyStatement` sniff to the `WordPress-Extra` ruleset to detect - and auto-fix - superfluous semi-colons and empty PHP open-close tag combinations. - `WordPress.NamingConventions.PrefixAllGlobals` sniff to the `WordPress-Extra` ruleset to verify that all functions, classes, interfaces, traits, variables, constants and hook names which are declared/defined in the global namespace are prefixed with one of the prefixes provided via a custom property or via the command line. - To activate this sniff, [one or more allowed prefixes should be provided to the sniff](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace). This can be done using a custom ruleset or via the command line. + To activate this sniff, [one or more allowed prefixes should be provided to the sniff](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace). This can be done using a custom ruleset or via the command line. PHP superglobals and WP global variables are exempt from variable name prefixing. Deprecated hook names will also be disregarded when non-prefixed. Back-fills for known native PHP functionality is also accounted for. - For verified exceptions, [unprefixed code can be whitelisted](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors#non-prefixed-functionclassvariableconstant-in-the-global-namespace). + For verified exceptions, [unprefixed code can be whitelisted](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors#non-prefixed-functionclassvariableconstant-in-the-global-namespace). Code in unit test files is automatically exempt from this sniff. - `WordPress.WP.DeprecatedClasses` sniff to the `WordPress-Extra` ruleset to detect usage of deprecated WordPress classes. - `WordPress.WP.DeprecatedParameters` sniff to the `WordPress-Extra` ruleset to detect deprecated parameters being passed to WordPress functions with a value other than the expected default. @@ -696,7 +696,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - Improved support for detecting issues in code using heredoc and/or nowdoc syntax. - Improved sniff efficiency, precision and performance for a number of sniffs. - Updated a few sniffs to take advantage of new features and fixes which are included in PHP_CodeSniffer 2.9.0. -- `WordPress.Files.Filename`: The "file name mirrors the class name prefixed with 'class'" check for PHP files containing a class will no longer be applied to typical unit test classes, i.e. for classes which extend `WP_UnitTestCase`, `PHPUnit_Framework_TestCase` and `PHPUnit\Framework\TestCase`. Additional test case base classes can be passed to the sniff using the new [`custom_test_class_whitelist` property](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes). +- `WordPress.Files.Filename`: The "file name mirrors the class name prefixed with 'class'" check for PHP files containing a class will no longer be applied to typical unit test classes, i.e. for classes which extend `WP_UnitTestCase`, `PHPUnit_Framework_TestCase` and `PHPUnit\Framework\TestCase`. Additional test case base classes can be passed to the sniff using the new [`custom_test_class_whitelist` property](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes). - The `WordPress.Files.FileName` sniff allows now for more theme-specific template hierarchy based file name exceptions. - The whitelist flag for the `WordPress.VIP.SlowQuery` sniff was `tax_query` which was unintuitive. This has now been changed to `slow query` to be in line with other whitelist flags. - The `WordPress.WhiteSpace.OperatorSpacing` sniff will now ignore operator spacing within `declare()` statements. @@ -705,7 +705,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu - The `WordPress.XSS.EscapeOutput` sniff will now also detect unescaped output when the short open echo tags ` [![Latest Stable Version](https://poser.pugx.org/wp-coding-standards/wpcs/v/stable)](https://packagist.org/packages/wp-coding-standards/wpcs) -[![Travis Build Status](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?branch=master)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards) -[![Release Date of the Latest Version](https://img.shields.io/github/release-date/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?maxAge=1800)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases) +[![Travis Build Status](https://travis-ci.com/WordPress/WordPress-Coding-Standards.svg?branch=master)](https://travis-ci.com/WordPress/WordPress-Coding-Standards) +[![Release Date of the Latest Version](https://img.shields.io/github/release-date/WordPress/WordPress-Coding-Standards.svg?maxAge=1800)](https://github.com/WordPress/WordPress-Coding-Standards/releases) :construction: [![Latest Unstable Version](https://img.shields.io/badge/unstable-dev--develop-e68718.svg?maxAge=2419200)](https://packagist.org/packages/wp-coding-standards/wpcs#dev-develop) -[![Travis Build Status](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?branch=develop)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards) -[![Last Commit to Unstable](https://img.shields.io/github/last-commit/WordPress-Coding-Standards/WordPress-Coding-Standards/develop.svg)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/commits/develop) +[![Travis Build Status](https://travis-ci.com/WordPress/WordPress-Coding-Standards.svg?branch=develop)](https://travis-ci.com/WordPress/WordPress-Coding-Standards) +[![Last Commit to Unstable](https://img.shields.io/github/last-commit/WordPress/WordPress-Coding-Standards/develop.svg)](https://github.com/WordPress/WordPress-Coding-Standards/commits/develop) [![Minimum PHP Version](https://img.shields.io/packagist/php-v/wp-coding-standards/wpcs.svg?maxAge=3600)](https://packagist.org/packages/wp-coding-standards/wpcs) -[![Tested on PHP 5.4 to nightly](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%20nightly-green.svg?maxAge=2419200)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards) +[![Tested on PHP 5.4 to 7.4 snapshot](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4snapshot-green.svg?maxAge=2419200)](https://travis-ci.com/WordPress/WordPress-Coding-Standards) -[![License: MIT](https://poser.pugx.org/wp-coding-standards/wpcs/license)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/LICENSE) +[![License: MIT](https://poser.pugx.org/wp-coding-standards/wpcs/license)](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/LICENSE) [![Total Downloads](https://poser.pugx.org/wp-coding-standards/wpcs/downloads)](https://packagist.org/packages/wp-coding-standards/wpcs/stats) -[![Number of Contributors](https://img.shields.io/github/contributors/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?maxAge=3600)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors) +[![Number of Contributors](https://img.shields.io/github/contributors/WordPress/WordPress-Coding-Standards.svg?maxAge=3600)](https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors) @@ -48,12 +48,12 @@ This project is a collection of [PHP_CodeSniffer](https://github.com/squizlabs/P ## Project history - On 22nd April 2009, the original project from [Urban Giraffe](https://urbangiraffe.com/articles/wordpress-codesniffer-standard/) was packaged and published. - - In May 2011 the project was forked and [added](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/commit/04fd547c691ca2baae3fa8e195a46b0c9dd671c5) to GitHub by [Chris Adams](https://chrisadams.me.uk/). + - In May 2011 the project was forked and [added](https://github.com/WordPress/WordPress-Coding-Standards/commit/04fd547c691ca2baae3fa8e195a46b0c9dd671c5) to GitHub by [Chris Adams](https://chrisadams.me.uk/). - In April 2012 [XWP](https://xwp.co/) started to dedicate resources to develop and lead the creation of the sniffs and rulesets for `WordPress-Core`, `WordPress-VIP` (WordPress.com VIP), and `WordPress-Extra`. - - In May 2015, an initial documentation ruleset was [added](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/commit/b1a4bf8232a22563ef66f8a529357275a49f47dc#diff-a17c358c3262a26e9228268eb0a7b8c8) as `WordPress-Docs`. + - In May 2015, an initial documentation ruleset was [added](https://github.com/WordPress/WordPress-Coding-Standards/commit/b1a4bf8232a22563ef66f8a529357275a49f47dc#diff-a17c358c3262a26e9228268eb0a7b8c8) as `WordPress-Docs`. - In 2015, [J.D. Grimes](https://github.com/JDGrimes) began significant contributions, along with maintenance from [Gary Jones](https://github.com/GaryJones). - In 2016, [Juliette Reinders Folmer](https://github.com/jrfnl) began contributing heavily, adding more commits in a year than anyone else in the five years since the project was added to GitHub. - - In July 2018, version [`1.0.0`](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases/tag/1.0.0) of the project was released. + - In July 2018, version [`1.0.0`](https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/1.0.0) of the project was released. ## Installation @@ -94,7 +94,7 @@ It is strongly suggested to `require` one of these plugins in your project to ha 2. Clone the WordPress standards repository: - git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs + git clone -b master https://github.com/WordPress/WordPress-Coding-Standards.git wpcs 3. Add its path to the PHP_CodeSniffer configuration: @@ -110,7 +110,7 @@ To summarize: ```bash cd ~/projects git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs -git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs +git clone -b master https://github.com/WordPress/WordPress-Coding-Standards.git wpcs cd phpcs ./bin/phpcs --config-set installed_paths ../wpcs ``` @@ -144,7 +144,7 @@ If you need to further customize the selection of sniffs for your project - you The WordPress Coding Standard contains a number of sniffs which are configurable. This means that you can turn parts of the sniff on or off, or change the behaviour by setting a property for the sniff in your custom `.phpcs.xml.dist` file. -You can find a complete list of all the properties you can change in the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties). +You can find a complete list of all the properties you can change in the [wiki](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties). ### Recommended additional rulesets @@ -217,15 +217,15 @@ Will result in following output: ### Using PHPCS and WPCS from within your IDE * **PhpStorm** : Please see "[PHP Code Sniffer with WordPress Coding Standards Integration](https://confluence.jetbrains.com/display/PhpStorm/WordPress+Development+using+PhpStorm#WordPressDevelopmentusingPhpStorm-PHPCodeSnifferwithWordPressCodingStandardsIntegrationinPhpStorm)" in the PhpStorm documentation. -* **Sublime Text** : Please see "[Setting up WPCS to work in Sublime Text](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Setting-up-WPCS-to-work-in-Sublime-Text)" in the wiki. -* **Atom**: Please see "[Setting up WPCS to work in Atom](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Setting-up-WPCS-to-work-in-Atom)" in the wiki. +* **Sublime Text** : Please see "[Setting up WPCS to work in Sublime Text](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Setting-up-WPCS-to-work-in-Sublime-Text)" in the wiki. +* **Atom**: Please see "[Setting up WPCS to work in Atom](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Setting-up-WPCS-to-work-in-Atom)" in the wiki. * **Visual Studio**: Please see "[Setting up PHP CodeSniffer in Visual Studio Code](https://tommcfarlin.com/php-codesniffer-in-visual-studio-code/)", a tutorial by Tom McFarlin. -* **Eclipse with XAMPP**: Please see "[Setting up WPCS when using Eclipse with XAMPP](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/How-to-use-WPCS-with-Eclipse-and-XAMPP)" in the wiki. +* **Eclipse with XAMPP**: Please see "[Setting up WPCS when using Eclipse with XAMPP](https://github.com/WordPress/WordPress-Coding-Standards/wiki/How-to-use-WPCS-with-Eclipse-and-XAMPP)" in the wiki. ## Running your code through WPCS automatically using CI tools -### [Travis CI](https://travis-ci.org/) +### [Travis CI](https://travis-ci.com/) To integrate PHPCS with WPCS with Travis CI, you'll need to install both `before_install` and add the run command to the `script`. If your project uses Composer, the typical instructions might be different. @@ -249,7 +249,7 @@ before_install: # Install PHP_CodeSniffer. - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi # Install WordPress Coding Standards. - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_DIR; fi + - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress/WordPress-Coding-Standards.git $SNIFFS_DIR; fi # Set install path for WordPress Coding Standards. - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --config-set installed_paths $SNIFFS_DIR; fi # After CodeSniffer install you should refresh your path. @@ -269,7 +269,7 @@ More examples and advice about integrating PHPCS in your Travis build tests can ## Fixing errors or whitelisting them -You can find information on how to deal with some of the more frequent issues in the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki). +You can find information on how to deal with some of the more frequent issues in the [wiki](https://github.com/WordPress/WordPress-Coding-Standards/wiki). ### Tools shipped with WPCS diff --git a/WordPress-Core/ruleset.xml b/WordPress-Core/ruleset.xml index 9a3485b353..24ceda47b6 100644 --- a/WordPress-Core/ruleset.xml +++ b/WordPress-Core/ruleset.xml @@ -17,7 +17,7 @@ + https://github.com/WordPress/WordPress-Coding-Standards/issues/527 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/1330 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/632 --> @@ -276,11 +276,11 @@ ############################################################################# --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/639 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/640 --> @@ -325,10 +325,10 @@ Hyphens should separate words. --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/642 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/642 --> @@ -345,7 +345,7 @@ Handbook: PHP - Interpolation for Naming Dynamic Hooks. Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#interpolation-for-naming-dynamic-hooks - https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/751 + https://github.com/WordPress/WordPress-Coding-Standards/issues/751 ############################################################################# --> @@ -365,7 +365,7 @@ --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/643 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/607 --> diff --git a/WordPress-Extra/ruleset.xml b/WordPress-Extra/ruleset.xml index ffdb2310bf..c43d6c6803 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -6,7 +6,7 @@ + https://github.com/WordPress/WordPress-Coding-Standards/pull/382 --> @@ -25,18 +25,18 @@ + https://github.com/WordPress/WordPress-Coding-Standards/issues/607 --> + https://github.com/WordPress/WordPress-Coding-Standards/pull/809 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/1143 --> warning @@ -49,11 +49,11 @@ + https://github.com/WordPress/WordPress-Coding-Standards/issues/1153 --> - + @@ -63,7 +63,7 @@ + https://github.com/WordPress/WordPress-Coding-Standards/issues/1101 --> @@ -78,11 +78,11 @@ + https://github.com/WordPress/WordPress-Coding-Standards/pull/1264 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/73 --> @@ -96,27 +96,27 @@ + https://github.com/WordPress/WordPress-Coding-Standards/issues/35 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/26 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/1447 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/1146 --> + https://github.com/WordPress/WordPress-Coding-Standards/pull/646 --> + https://github.com/WordPress/WordPress-Coding-Standards/issues/522 --> @@ -131,7 +131,7 @@ - + + https://github.com/WordPress/WordPress-Coding-Standards/issues/1371 --> + https://github.com/WordPress/WordPress-Coding-Standards/pull/1450 --> @@ -160,7 +160,7 @@ + https://github.com/WordPress/WordPress-Coding-Standards/pull/1463 --> diff --git a/WordPress/AbstractArrayAssignmentRestrictionsSniff.php b/WordPress/AbstractArrayAssignmentRestrictionsSniff.php index 6095db0d72..7c662cd0f5 100644 --- a/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +++ b/WordPress/AbstractArrayAssignmentRestrictionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/AbstractClassRestrictionsSniff.php b/WordPress/AbstractClassRestrictionsSniff.php index ad46cb83a4..9374622e1f 100644 --- a/WordPress/AbstractClassRestrictionsSniff.php +++ b/WordPress/AbstractClassRestrictionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/AbstractFunctionParameterSniff.php b/WordPress/AbstractFunctionParameterSniff.php index 5c059a6df2..482ba0080a 100644 --- a/WordPress/AbstractFunctionParameterSniff.php +++ b/WordPress/AbstractFunctionParameterSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/AbstractFunctionRestrictionsSniff.php b/WordPress/AbstractFunctionRestrictionsSniff.php index 4553e3f472..e208c90ac1 100644 --- a/WordPress/AbstractFunctionRestrictionsSniff.php +++ b/WordPress/AbstractFunctionRestrictionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/PHPCSHelper.php b/WordPress/PHPCSHelper.php index 1e79685f46..1599a97a1b 100644 --- a/WordPress/PHPCSHelper.php +++ b/WordPress/PHPCSHelper.php @@ -3,7 +3,7 @@ * PHPCS cross-version compatibility helper class. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 8c3a86cb40..c271e9c562 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -3,7 +3,7 @@ * Represents a PHP_CodeSniffer sniff for sniffing WordPress coding standards. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php b/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php index f5c6257f3c..3b3c5aaa47 100644 --- a/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php b/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php index 2285a7cc79..08c85213e1 100644 --- a/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php b/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php index b209409368..7e990d0dfc 100644 --- a/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php b/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php index 296a406105..16baac99ad 100644 --- a/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php +++ b/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php b/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php index ccecf224a7..c5bd8380fe 100644 --- a/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +++ b/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Classes/ClassInstantiationSniff.php b/WordPress/Sniffs/Classes/ClassInstantiationSniff.php index 37b942f6f0..3572fbeed2 100644 --- a/WordPress/Sniffs/Classes/ClassInstantiationSniff.php +++ b/WordPress/Sniffs/Classes/ClassInstantiationSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index fa3d9db7f5..bf5879b8df 100644 --- a/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php b/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php index 2b92e1c7a1..b9e99f7fb4 100644 --- a/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php +++ b/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php b/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php index 35b4e6447b..c6fe9c7a87 100644 --- a/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php +++ b/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php b/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php index 405eb094d0..8f184c6be7 100644 --- a/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +++ b/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/DB/PreparedSQLSniff.php b/WordPress/Sniffs/DB/PreparedSQLSniff.php index 5ddf1d92fc..a3ed993542 100644 --- a/WordPress/Sniffs/DB/PreparedSQLSniff.php +++ b/WordPress/Sniffs/DB/PreparedSQLSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/DB/RestrictedClassesSniff.php b/WordPress/Sniffs/DB/RestrictedClassesSniff.php index 564a629ace..5ae13ee57b 100644 --- a/WordPress/Sniffs/DB/RestrictedClassesSniff.php +++ b/WordPress/Sniffs/DB/RestrictedClassesSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php b/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php index 1981f3a8e0..dbab49fec9 100644 --- a/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php +++ b/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/DB/SlowDBQuerySniff.php b/WordPress/Sniffs/DB/SlowDBQuerySniff.php index d0e547d4a7..4feebdcb60 100644 --- a/WordPress/Sniffs/DB/SlowDBQuerySniff.php +++ b/WordPress/Sniffs/DB/SlowDBQuerySniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Files/FileNameSniff.php b/WordPress/Sniffs/Files/FileNameSniff.php index 43eb1061b9..598bc39bda 100644 --- a/WordPress/Sniffs/Files/FileNameSniff.php +++ b/WordPress/Sniffs/Files/FileNameSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index 4655f953dd..a00f0cf2ad 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 645bed3d9d..c88835cb6f 100644 --- a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php index 0103108a35..88ab8394e4 100644 --- a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php index dad06cac71..34314ff186 100644 --- a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php b/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php index 79fe642bca..59e914dcf7 100644 --- a/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php b/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php index e2691c2e60..39f87c098d 100644 --- a/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/DontExtractSniff.php b/WordPress/Sniffs/PHP/DontExtractSniff.php index 0b9b984b3a..af2233bbe1 100644 --- a/WordPress/Sniffs/PHP/DontExtractSniff.php +++ b/WordPress/Sniffs/PHP/DontExtractSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/IniSetSniff.php b/WordPress/Sniffs/PHP/IniSetSniff.php index afd58f1bf8..79841b5396 100644 --- a/WordPress/Sniffs/PHP/IniSetSniff.php +++ b/WordPress/Sniffs/PHP/IniSetSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php b/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php index cc7b5fcb0c..6e0dba4679 100644 --- a/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php +++ b/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php b/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php index aade23c63c..9fb1cdcbeb 100644 --- a/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php b/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php index f5e1a5a8ce..af88c404ac 100644 --- a/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php +++ b/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php b/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php index 27faaa51a6..b7f3bb14a1 100644 --- a/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/StrictComparisonsSniff.php b/WordPress/Sniffs/PHP/StrictComparisonsSniff.php index 97f3c4e406..85fe055490 100644 --- a/WordPress/Sniffs/PHP/StrictComparisonsSniff.php +++ b/WordPress/Sniffs/PHP/StrictComparisonsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/StrictInArraySniff.php b/WordPress/Sniffs/PHP/StrictInArraySniff.php index f50ce14b9f..d7c12056aa 100644 --- a/WordPress/Sniffs/PHP/StrictInArraySniff.php +++ b/WordPress/Sniffs/PHP/StrictInArraySniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/TypeCastsSniff.php b/WordPress/Sniffs/PHP/TypeCastsSniff.php index 47376ff39c..7aded55fec 100644 --- a/WordPress/Sniffs/PHP/TypeCastsSniff.php +++ b/WordPress/Sniffs/PHP/TypeCastsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/PHP/YodaConditionsSniff.php b/WordPress/Sniffs/PHP/YodaConditionsSniff.php index 0587da884d..c85ee6027e 100644 --- a/WordPress/Sniffs/PHP/YodaConditionsSniff.php +++ b/WordPress/Sniffs/PHP/YodaConditionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Security/EscapeOutputSniff.php b/WordPress/Sniffs/Security/EscapeOutputSniff.php index d1dae3af85..09a7cbd0ea 100644 --- a/WordPress/Sniffs/Security/EscapeOutputSniff.php +++ b/WordPress/Sniffs/Security/EscapeOutputSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Security/NonceVerificationSniff.php b/WordPress/Sniffs/Security/NonceVerificationSniff.php index e9b2cf6603..15f4a60408 100644 --- a/WordPress/Sniffs/Security/NonceVerificationSniff.php +++ b/WordPress/Sniffs/Security/NonceVerificationSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Security/PluginMenuSlugSniff.php b/WordPress/Sniffs/Security/PluginMenuSlugSniff.php index 1d6edf0957..d22402efc8 100644 --- a/WordPress/Sniffs/Security/PluginMenuSlugSniff.php +++ b/WordPress/Sniffs/Security/PluginMenuSlugSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Security/SafeRedirectSniff.php b/WordPress/Sniffs/Security/SafeRedirectSniff.php index 4d14631356..2f6aa6a686 100644 --- a/WordPress/Sniffs/Security/SafeRedirectSniff.php +++ b/WordPress/Sniffs/Security/SafeRedirectSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php b/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php index 4b65ac65be..a545c58078 100644 --- a/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php +++ b/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ @@ -15,7 +15,7 @@ /** * Flag any non-validated/sanitized input ( _GET / _POST / etc. ). * - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/69 + * @link https://github.com/WordPress/WordPress-Coding-Standards/issues/69 * * @package WPCS\WordPressCodingStandards * diff --git a/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php b/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php index 8437b4d249..b01e066126 100644 --- a/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php +++ b/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php b/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php index 52e1356f21..43ad575cd3 100644 --- a/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php +++ b/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/CapitalPDangitSniff.php b/WordPress/Sniffs/WP/CapitalPDangitSniff.php index 3c270154a1..edbd3ebe97 100644 --- a/WordPress/Sniffs/WP/CapitalPDangitSniff.php +++ b/WordPress/Sniffs/WP/CapitalPDangitSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/CronIntervalSniff.php b/WordPress/Sniffs/WP/CronIntervalSniff.php index d7e91b8321..7cfdddd919 100644 --- a/WordPress/Sniffs/WP/CronIntervalSniff.php +++ b/WordPress/Sniffs/WP/CronIntervalSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php index cd69ba988b..7a13aa5727 100644 --- a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php index 8525dc33bb..641edbfbfd 100644 --- a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php b/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php index 01a2f7f860..2d567cbca1 100644 --- a/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/DeprecatedParametersSniff.php b/WordPress/Sniffs/WP/DeprecatedParametersSniff.php index b6918cdb39..a6ba90aa4c 100644 --- a/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedParametersSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php index 6539b49cc5..f2f8dc64a8 100644 --- a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +++ b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php b/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php index ba640858f6..89d8e09c47 100644 --- a/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php +++ b/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php b/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php index 0a0d0a6245..7b85aded0b 100644 --- a/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php +++ b/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php b/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php index e8d0333ad4..27572e95d1 100644 --- a/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +++ b/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php b/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php index 57b64d07a5..8392324d90 100644 --- a/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php +++ b/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/I18nSniff.php b/WordPress/Sniffs/WP/I18nSniff.php index 01797b5f78..6d0bc1946b 100644 --- a/WordPress/Sniffs/WP/I18nSniff.php +++ b/WordPress/Sniffs/WP/I18nSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/PostsPerPageSniff.php b/WordPress/Sniffs/WP/PostsPerPageSniff.php index 8e45afe78d..968a0342b9 100644 --- a/WordPress/Sniffs/WP/PostsPerPageSniff.php +++ b/WordPress/Sniffs/WP/PostsPerPageSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WP/TimezoneChangeSniff.php b/WordPress/Sniffs/WP/TimezoneChangeSniff.php index c57f8556cb..5712df975c 100644 --- a/WordPress/Sniffs/WP/TimezoneChangeSniff.php +++ b/WordPress/Sniffs/WP/TimezoneChangeSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php index 0aa4ff9cc2..c19f0f821a 100755 --- a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index b0654ae4f1..29e9240057 100644 --- a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php b/WordPress/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php index 6539def540..c20a4d33e6 100644 --- a/WordPress/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +++ b/WordPress/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php index 26c12e20b1..17e5090c72 100644 --- a/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php b/WordPress/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php index 5df4a72fea..010ec9438b 100644 --- a/WordPress/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +++ b/WordPress/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php @@ -3,7 +3,7 @@ * WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php b/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php index 713d8b8cb5..2c521e0357 100644 --- a/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php index 3b6983ff21..4bc179dca2 100644 --- a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php b/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php index a688f67ef1..958f5abab7 100644 --- a/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php b/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php index 7763f55ee5..fa5905d91a 100644 --- a/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php +++ b/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php index bc6cc60268..62eda13d2b 100644 --- a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php +++ b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Classes/ClassInstantiationUnitTest.php b/WordPress/Tests/Classes/ClassInstantiationUnitTest.php index d06cb98de0..21b74950e7 100644 --- a/WordPress/Tests/Classes/ClassInstantiationUnitTest.php +++ b/WordPress/Tests/Classes/ClassInstantiationUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/WordPress/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index f92dcbeb02..57785b8370 100644 --- a/WordPress/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/WordPress/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.php b/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.php index 22ca38d56c..7c0d72be94 100644 --- a/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.php +++ b/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php b/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php index bb527e39f1..cf15554f92 100644 --- a/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php +++ b/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php b/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php index 3259bb0b5c..1cf42f021f 100644 --- a/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php +++ b/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/DB/PreparedSQLUnitTest.php b/WordPress/Tests/DB/PreparedSQLUnitTest.php index f525dde0e6..03f7c6d8fa 100644 --- a/WordPress/Tests/DB/PreparedSQLUnitTest.php +++ b/WordPress/Tests/DB/PreparedSQLUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/DB/RestrictedClassesUnitTest.php b/WordPress/Tests/DB/RestrictedClassesUnitTest.php index c15d35543a..b5df274d02 100644 --- a/WordPress/Tests/DB/RestrictedClassesUnitTest.php +++ b/WordPress/Tests/DB/RestrictedClassesUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php b/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php index 362500ecfc..5149dbb8fb 100644 --- a/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php +++ b/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/DB/SlowDBQueryUnitTest.php b/WordPress/Tests/DB/SlowDBQueryUnitTest.php index 24af5c213d..987e4d412d 100644 --- a/WordPress/Tests/DB/SlowDBQueryUnitTest.php +++ b/WordPress/Tests/DB/SlowDBQueryUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Files/FileNameUnitTest.php b/WordPress/Tests/Files/FileNameUnitTest.php index af0a46c2f2..3d26c76efe 100644 --- a/WordPress/Tests/Files/FileNameUnitTest.php +++ b/WordPress/Tests/Files/FileNameUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php index 6db20b24ae..aa169b940d 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 10649e220d..0c1db47bc7 100644 --- a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php index 565c4ccf6e..dfa253c850 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php index 934826f5d4..85e1d22524 100644 --- a/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php b/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php index aef75ef7e1..c008eb6afa 100644 --- a/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php b/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php index 0b43deffe5..1670834cd2 100644 --- a/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/DontExtractUnitTest.php b/WordPress/Tests/PHP/DontExtractUnitTest.php index c8862b6b7f..6654bdac00 100644 --- a/WordPress/Tests/PHP/DontExtractUnitTest.php +++ b/WordPress/Tests/PHP/DontExtractUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/IniSetUnitTest.php b/WordPress/Tests/PHP/IniSetUnitTest.php index 4543d44a7e..11c1f75218 100644 --- a/WordPress/Tests/PHP/IniSetUnitTest.php +++ b/WordPress/Tests/PHP/IniSetUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php b/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php index b9db72b0f5..5bd5ddfc84 100644 --- a/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php b/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php index 13dbdecc3c..e9df9b0d5a 100644 --- a/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php b/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php index 0615bbca22..a4b4ac6160 100644 --- a/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php +++ b/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php index 30ad0b2b00..3d21aa7195 100644 --- a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/StrictComparisonsUnitTest.php b/WordPress/Tests/PHP/StrictComparisonsUnitTest.php index 79a42f6991..b7ada4d896 100644 --- a/WordPress/Tests/PHP/StrictComparisonsUnitTest.php +++ b/WordPress/Tests/PHP/StrictComparisonsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/StrictInArrayUnitTest.php b/WordPress/Tests/PHP/StrictInArrayUnitTest.php index 66c9ed19b7..7394afeda5 100644 --- a/WordPress/Tests/PHP/StrictInArrayUnitTest.php +++ b/WordPress/Tests/PHP/StrictInArrayUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/TypeCastsUnitTest.php b/WordPress/Tests/PHP/TypeCastsUnitTest.php index 5f681f8d7f..9349f1b838 100644 --- a/WordPress/Tests/PHP/TypeCastsUnitTest.php +++ b/WordPress/Tests/PHP/TypeCastsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/PHP/YodaConditionsUnitTest.php b/WordPress/Tests/PHP/YodaConditionsUnitTest.php index 9640da2b7d..cab9a34b36 100644 --- a/WordPress/Tests/PHP/YodaConditionsUnitTest.php +++ b/WordPress/Tests/PHP/YodaConditionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.php b/WordPress/Tests/Security/EscapeOutputUnitTest.php index 52b554be55..1d803fc349 100644 --- a/WordPress/Tests/Security/EscapeOutputUnitTest.php +++ b/WordPress/Tests/Security/EscapeOutputUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Security/NonceVerificationUnitTest.php b/WordPress/Tests/Security/NonceVerificationUnitTest.php index 964ab9501a..c3fb8a67b0 100644 --- a/WordPress/Tests/Security/NonceVerificationUnitTest.php +++ b/WordPress/Tests/Security/NonceVerificationUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Security/PluginMenuSlugUnitTest.php b/WordPress/Tests/Security/PluginMenuSlugUnitTest.php index 9141fa90a1..3b81976073 100644 --- a/WordPress/Tests/Security/PluginMenuSlugUnitTest.php +++ b/WordPress/Tests/Security/PluginMenuSlugUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Security/SafeRedirectUnitTest.php b/WordPress/Tests/Security/SafeRedirectUnitTest.php index 14e4686f11..d16634cbe5 100644 --- a/WordPress/Tests/Security/SafeRedirectUnitTest.php +++ b/WordPress/Tests/Security/SafeRedirectUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php index ca0821bd59..493465ea3f 100644 --- a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php +++ b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php index 7f13fe3e88..88df73124d 100644 --- a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php +++ b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php index 55107f0f6a..98f42d5633 100644 --- a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php +++ b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/CapitalPDangitUnitTest.php b/WordPress/Tests/WP/CapitalPDangitUnitTest.php index 1139ee348e..0f7454a6ae 100644 --- a/WordPress/Tests/WP/CapitalPDangitUnitTest.php +++ b/WordPress/Tests/WP/CapitalPDangitUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/CronIntervalUnitTest.php b/WordPress/Tests/WP/CronIntervalUnitTest.php index 704923cc5f..afbf6a6b69 100644 --- a/WordPress/Tests/WP/CronIntervalUnitTest.php +++ b/WordPress/Tests/WP/CronIntervalUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php index c70673deb2..b58576ccf2 100644 --- a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php index ba45e47476..b3b217c7cf 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php b/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php index f128e6fb34..dd3c909379 100644 --- a/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/DeprecatedParametersUnitTest.php b/WordPress/Tests/WP/DeprecatedParametersUnitTest.php index af86abf2e5..e91ad712cf 100644 --- a/WordPress/Tests/WP/DeprecatedParametersUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedParametersUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php b/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php index 8437893bb0..9d48851857 100644 --- a/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php +++ b/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php b/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php index 4491430637..f081e22da8 100644 --- a/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php index 8e60e6b57d..5fa96cd25c 100644 --- a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php +++ b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php b/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php index 2b0da6f255..2ca0095815 100644 --- a/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php +++ b/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc index 3d6609e715..321054f812 100644 --- a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc +++ b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc @@ -39,7 +39,7 @@ function global_vars() { } // Test against cross-contamination of global detection. -// https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/486 +// https://github.com/WordPress/WordPress-Coding-Standards/issues/486 function local_var_only() { $pagenow = 'test'; // Ok, function scope. } @@ -58,7 +58,7 @@ add_filter( 'comments_open', function( $open, $post_id ) { $closure = function() { $page = 'test' }; // Ok, check against cross-contaminiation from within a closure. // Allow overriding globals in functions within unit test classes. -// https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/300#issuecomment-158778606 +// https://github.com/WordPress/WordPress-Coding-Standards/issues/300#issuecomment-158778606 trait WP_UnitTestCase { public function test_something() { @@ -177,7 +177,7 @@ function global_vars() { $closure = function ( $pagenow ) { // OK, local to the closure. $pagenow = 'something'; // OK, local to the closure. }; - + $pagenow = 'something else'; // Bad. return $closure( $pagenow ); // OK, not an assignment. diff --git a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php index 0f77e278e0..b29c957436 100644 --- a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php +++ b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/I18nUnitTest.php b/WordPress/Tests/WP/I18nUnitTest.php index bab594676f..6f986b8868 100644 --- a/WordPress/Tests/WP/I18nUnitTest.php +++ b/WordPress/Tests/WP/I18nUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/PostsPerPageUnitTest.php b/WordPress/Tests/WP/PostsPerPageUnitTest.php index 22dd5c0715..212408ed84 100644 --- a/WordPress/Tests/WP/PostsPerPageUnitTest.php +++ b/WordPress/Tests/WP/PostsPerPageUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WP/TimezoneChangeUnitTest.php b/WordPress/Tests/WP/TimezoneChangeUnitTest.php index 2b623f644a..81e86d1e6e 100644 --- a/WordPress/Tests/WP/TimezoneChangeUnitTest.php +++ b/WordPress/Tests/WP/TimezoneChangeUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php index b90f1c1148..8a06a67409 100644 --- a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc index ab0d8568b6..20d16585e0 100644 --- a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc +++ b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc @@ -5,7 +5,7 @@ while( have_posts() ) { // Okay, comments are okay here. // Okay, comments are okay here as well. } // Okay, comments are okay here. -// See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/40 . +// See https://github.com/WordPress/WordPress-Coding-Standards/issues/40 . if ( true ) { // code. diff --git a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed index ef625e6362..94e7256ca9 100644 --- a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed +++ b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed @@ -5,7 +5,7 @@ while ( have_posts() ) { // Okay, comments are okay here. // Okay, comments are okay here as well. } // Okay, comments are okay here. -// See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/40 . +// See https://github.com/WordPress/WordPress-Coding-Standards/issues/40 . if ( true ) { // code. diff --git a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index e295978e2b..d98d8417e8 100644 --- a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php b/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php index 5f360ca429..edaac2c7ea 100644 --- a/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php +++ b/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php index 421c61fd8d..f31f3f4992 100644 --- a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php b/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php index 1da0d8fbeb..a7ed8c5601 100644 --- a/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php +++ b/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for WordPress Coding Standard. * * @package WPCS\WordPressCodingStandards - * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards + * @link https://github.com/WordPress/WordPress-Coding-Standards * @license https://opensource.org/licenses/MIT MIT */ diff --git a/phpcs.xml.dist.sample b/phpcs.xml.dist.sample index e6e2ab99f6..a524efd077 100644 --- a/phpcs.xml.dist.sample +++ b/phpcs.xml.dist.sample @@ -68,7 +68,7 @@ For information on additional custom properties available, check out the wiki: - https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties + https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties --> From 0af5b18632cc0c981937035982d494b95078880d Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Tue, 2 Jul 2019 12:57:57 +0300 Subject: [PATCH 12/72] Added remaining plugin load globals --- WordPress/Sniff.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 7a8370ae6d..dde62b0af3 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -686,9 +686,11 @@ abstract class Sniff implements PHPCS_Sniff { 'mode' => true, 'monthnum' => true, 'more' => true, + 'mu_plugin' => true, 'multipage' => true, 'names' => true, 'nav_menu_selected_id' => true, + 'network_plugin' => true, 'new_whitelist_options' => true, 'numpages' => true, 'one_theme_location_no_menus' => true, From 8d861ab195ddc488fc36380fbefb6bd094451532 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 5 Jul 2019 01:29:57 +0200 Subject: [PATCH 13/72] WordPress ruleset: efficiency fix Rulesets are processed top-to-bottom, one rule at the time. For the `WordPress` ruleset, this means that PHPCS would first load the `WordPress-Core` ruleset and process all rules in that file, then read the `WordPress-Docs` ruleset and lastly, the `WordPress-Extra` ruleset. As the `WordPress-Extra` ruleset includes `WordPress-Core`, it would re-process the `WordPress-Core` ruleset a second time and then process the additional rules in the `Extra` ruleset. This means that in effect, the `WordPress-Core` ruleset is processed twice when using the `WordPress` ruleset which is inefficient. By commenting that rule out, we still document that the `WordPress` ruleset includes `WordPress-Core` without double processing the ruleset. --- WordPress/ruleset.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WordPress/ruleset.xml b/WordPress/ruleset.xml index 80bfb8d3bf..fd24ae6318 100644 --- a/WordPress/ruleset.xml +++ b/WordPress/ruleset.xml @@ -3,7 +3,10 @@ WordPress Coding Standards + From bf3ef482d2d3012ddcf7447fd268cb41daedc86e Mon Sep 17 00:00:00 2001 From: Christopher Kanitz Date: Fri, 5 Jul 2019 12:42:00 +0200 Subject: [PATCH 14/72] Docs/WordPress.WhiteSpace.CastStructureSpacing (#1738) Adds documentation for the WordPress.WhiteSpace.CastStructureSpacing Related to #1722 --- .../CastStructureSpacingStandard.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml diff --git a/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml b/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml new file mode 100644 index 0000000000..f30f4dc3ba --- /dev/null +++ b/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml @@ -0,0 +1,19 @@ + + + + + + + (int) '420'; + ]]> + + + =(int) '420'; + ]]> + + + From d00b44ba67ae47faf7d2727faf0c9485a1e7f1d9 Mon Sep 17 00:00:00 2001 From: Christopher Kanitz Date: Fri, 5 Jul 2019 13:02:48 +0200 Subject: [PATCH 15/72] Docs/WordPress.WhiteSpace.PrecisionAlignment (#1725) Adds documentation for the WordPress.WhiteSpace.PrecisionAlignmentSniff Related to #1722 --- .../WhiteSpace/PrecisionAlignmentStandard.xml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 WordPress/Docs/WhiteSpace/PrecisionAlignmentStandard.xml diff --git a/WordPress/Docs/WhiteSpace/PrecisionAlignmentStandard.xml b/WordPress/Docs/WhiteSpace/PrecisionAlignmentStandard.xml new file mode 100644 index 0000000000..ca819ffd7d --- /dev/null +++ b/WordPress/Docs/WhiteSpace/PrecisionAlignmentStandard.xml @@ -0,0 +1,31 @@ + + + + + + + [tab]$var = true; + ]]> + + + [space][space]$var = true; + ]]> + + + + + [tab][space][space][space][space]$var = true; + ]]> + + + [tab][space][space][space]$var = true; + ]]> + + + From d8baf910d0516325a7201e51d648ec07b2ed6582 Mon Sep 17 00:00:00 2001 From: Niels de Blaauw Date: Tue, 16 Jul 2019 17:17:10 +0200 Subject: [PATCH 16/72] Fixes #1733 - Error on short prefixes --- .../PrefixAllGlobalsSniff.php | 21 ++++++++++++++++ .../PrefixAllGlobalsUnitTest.1.inc | 25 +++++++++++++++++++ .../PrefixAllGlobalsUnitTest.php | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index a00f0cf2ad..305a16b908 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -33,6 +33,17 @@ class PrefixAllGlobalsSniff extends AbstractFunctionParameterSniff { */ const ERROR_MSG = '%s by a theme/plugin should start with the theme/plugin prefix. Found: "%s".'; + /** + * Minimal number of characters the prefix needs in order to be valid. + * + * @since 2.2.0 + * + * @link https://github.com/WordPress/WordPress-Coding-Standards/issues/1733 Issue 1733. + * + * @var int + */ + const MIN_PREFIX_LENGTH = 3; + /** * Target prefixes. * @@ -914,6 +925,16 @@ private function validate_prefixes() { continue; } + if ( function_exists( 'iconv_strlen' ) && iconv_strlen( $prefix, $this->phpcsFile->config->encoding ) < self::MIN_PREFIX_LENGTH ) { + $this->phpcsFile->addError( + 'The "%s" prefix is too short. Short prefixes are not unique enough and may cause name collisions with other code.', + 0, + 'ShortPrefixPassed', + array( $prefix ) + ); + continue; + } + // Validate the prefix against characters allowed for function, class, constant names etc. if ( preg_match( '`^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\\\\]*$`', $prefix ) !== 1 ) { $this->phpcsFile->addWarning( diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc index 10b79f3a86..2ffac46aae 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc @@ -425,3 +425,28 @@ define( ); // phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] + +/* + * Bad: Issue https://github.com/WordPress/WordPress-Coding-Standards/issues/1733. + * + * Short prefixes are not allowed. The errors are triggered + * on LINE 1 for the unit-test, because it's the phpcs:set command that is + * wrong, not the implementing code. + */ +// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] a +function a_do_something(){} + +// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] aa +function aa_do_something(){} + +// The following line mimicks an empty prefix value. +// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] , +function aa_do_something(){} + +// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] 😊 +function 😊_do_something(){} + +// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] 😊😊 +function 😊😊_do_something(){} + +// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php index aa169b940d..702b7abd5c 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php @@ -32,7 +32,7 @@ public function getErrorList( $testFile = 'PrefixAllGlobalsUnitTest.1.inc' ) { switch ( $testFile ) { case 'PrefixAllGlobalsUnitTest.1.inc': return array( - 1 => 2, // 1 x error for blacklisted prefix passed. + 1 => 8, // 2 x error for blacklisted prefix passed. 4 x error for short prefixes. 2 x no prefix. 10 => 1, 18 => 1, 21 => 1, From c8c576e9993a03ed3f21239ebe15b5a528d93edf Mon Sep 17 00:00:00 2001 From: Niels de Blaauw Date: Tue, 16 Jul 2019 17:28:08 +0200 Subject: [PATCH 17/72] Adds fallback for sniff when iconv is not available --- .../Sniffs/NamingConventions/PrefixAllGlobalsSniff.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index 305a16b908..82eb07ad1d 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -933,6 +933,14 @@ private function validate_prefixes() { array( $prefix ) ); continue; + } elseif ( ! function_exists( 'iconv_strlen' ) && strlen( $prefix, $this->phpcsFile->config->encoding ) < self::MIN_PREFIX_LENGTH ) { + $this->phpcsFile->addError( + 'The "%s" prefix is too short. Short prefixes are not unique enough and may cause name collisions with other code.', + 0, + 'ShortPrefixPassed', + array( $prefix ) + ); + continue; } // Validate the prefix against characters allowed for function, class, constant names etc. From 13a8bc10b54a3557f622e04fd700ca81828ac986 Mon Sep 17 00:00:00 2001 From: Christopher Kanitz Date: Thu, 18 Jul 2019 06:45:05 +0200 Subject: [PATCH 18/72] Docs/WordPress.WhiteSpace.DisallowInlineTabs (#1735) Adds documentation for the WordPress.WhiteSpace.DisallowInlineTabs sniff Related to #1722 --- .../WhiteSpace/DisallowInlineTabsStandard.xml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 WordPress/Docs/WhiteSpace/DisallowInlineTabsStandard.xml diff --git a/WordPress/Docs/WhiteSpace/DisallowInlineTabsStandard.xml b/WordPress/Docs/WhiteSpace/DisallowInlineTabsStandard.xml new file mode 100644 index 0000000000..16f1da2fb9 --- /dev/null +++ b/WordPress/Docs/WhiteSpace/DisallowInlineTabsStandard.xml @@ -0,0 +1,25 @@ + + + + + + + [space]=> 'lor', + 'b'[space][space][space]=> 'em', +); + ]]> + + + [tab]=> 'lor', + 'b'[tab]=> 'em', +); + ]]> + + + From 42332cc9f518a10efa258e5cf7e9008571215f8d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Jul 2019 20:07:38 +0200 Subject: [PATCH 19/72] CastStructureSpacing: allow for no whitespace before a cast when used in combination with a spread operator Includes updated docs. Related 1762 Related 1524 --- WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml | 4 ++++ WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php | 5 ++++- WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc | 2 ++ .../Tests/WhiteSpace/CastStructureSpacingUnitTest.inc.fixed | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml b/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml index f30f4dc3ba..8539325b37 100644 --- a/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml +++ b/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml @@ -2,12 +2,16 @@ (int) '420'; + +// No space between spread operator and cast. +$a = function_call( ...(array) $mixed ); ]]> diff --git a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php index c19f0f821a..5231785a11 100755 --- a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php @@ -24,6 +24,7 @@ * @since 0.11.0 The error level for all errors thrown by this sniff has been raised from warning to error. * @since 0.12.0 This class now extends the WordPressCS native `Sniff` class. * @since 0.13.0 Class name changed: this class is now namespaced. + * @since 2.2.0 Added exception for whitespace between spread operator and cast. */ class CastStructureSpacingSniff extends Sniff { @@ -45,7 +46,9 @@ public function register() { */ public function process_token( $stackPtr ) { - if ( \T_WHITESPACE !== $this->tokens[ ( $stackPtr - 1 ) ]['code'] ) { + if ( \T_WHITESPACE !== $this->tokens[ ( $stackPtr - 1 ) ]['code'] + && \T_ELLIPSIS !== $this->tokens[ ( $stackPtr - 1 ) ]['code'] + ) { $error = 'No space before opening casting parenthesis is prohibited'; $fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBeforeOpenParenthesis' ); if ( true === $fix ) { diff --git a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc index b17bc2ce92..29c1ce52d5 100644 --- a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc +++ b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc @@ -20,3 +20,5 @@ $unset2 = (unset) $unset; // Ok. $float1 =(float )$float; // Bad; n.b. spacing within the cast is dealt with by an upstream sniff. $float2 = (float) $float; // Ok. + +function_call( ...(array) $mixed ); // OK. diff --git a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc.fixed b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc.fixed index a4ff985fe2..b596241f06 100644 --- a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc.fixed +++ b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.inc.fixed @@ -20,3 +20,5 @@ $unset2 = (unset) $unset; // Ok. $float1 = (float )$float; // Bad; n.b. spacing within the cast is dealt with by an upstream sniff. $float2 = (float) $float; // Ok. + +function_call( ...(array) $mixed ); // OK. From acbeee62c4985a62d1c142f898319978096ad5e9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Jul 2019 21:30:56 +0200 Subject: [PATCH 20/72] :sparkles: New DisallowShortTernary sniff This new sniff addresses the new "_The short ternary operator must not be used._" rule which was recently added to the handbook. The sniff has been added to the `WordPress-Core` ruleset. Refs: * https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#ternary-operator * https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/ Includes unit tests. Includes documentation. --- WordPress-Core/ruleset.xml | 2 + .../Docs/PHP/DisallowShortTernaryStandard.xml | 19 ++++++ .../Sniffs/PHP/DisallowShortTernarySniff.php | 65 +++++++++++++++++++ .../PHP/DisallowShortTernaryUnitTest.inc | 12 ++++ .../PHP/DisallowShortTernaryUnitTest.php | 46 +++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 WordPress/Docs/PHP/DisallowShortTernaryStandard.xml create mode 100644 WordPress/Sniffs/PHP/DisallowShortTernarySniff.php create mode 100644 WordPress/Tests/PHP/DisallowShortTernaryUnitTest.inc create mode 100644 WordPress/Tests/PHP/DisallowShortTernaryUnitTest.php diff --git a/WordPress-Core/ruleset.xml b/WordPress-Core/ruleset.xml index 24ceda47b6..2c28c42b5b 100644 --- a/WordPress-Core/ruleset.xml +++ b/WordPress-Core/ruleset.xml @@ -367,6 +367,8 @@ An exception would be using ! empty(), as testing for false here is generally more intuitive. https://github.com/WordPress/WordPress-Coding-Standards/issues/643 --> + + + + + + + + + - From 75993cc487dad8603d09eab1cd914edf454e5131 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 12 Sep 2019 00:35:05 +0200 Subject: [PATCH 43/72] AlternativeFunctions: add extra unit test Just to be sure this was covered correctly (which it luckily was). --- WordPress/Tests/WP/AlternativeFunctionsUnitTest.inc | 3 +++ WordPress/Tests/WP/AlternativeFunctionsUnitTest.php | 1 + 2 files changed, 4 insertions(+) diff --git a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.inc b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.inc index a9646d98e9..7bfaf9b14d 100644 --- a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.inc +++ b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.inc @@ -68,3 +68,6 @@ readfile( 'php://filter/resource=http://www.example.com' ); // Warning. file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello World"); // Warning. curl_version(); // OK. + +// Safeguard that additional logic uses case-insensitive function name check. +Strip_Tags( $something ); // Warning. diff --git a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php index 98f42d5633..f25dec8cd3 100644 --- a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php +++ b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php @@ -63,6 +63,7 @@ public function getWarningList() { 49 => 1, 67 => 1, 68 => 1, + 73 => 1, ); } From 9a89756ee98302be652b6ab974151fc4feddca69 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 19 Sep 2019 23:47:23 +0200 Subject: [PATCH 44/72] YodaConditions: minor efficiency fix Performance: Don't unnecessarily use `array_merge()`. --- WordPress/Sniffs/PHP/YodaConditionsSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Sniffs/PHP/YodaConditionsSniff.php b/WordPress/Sniffs/PHP/YodaConditionsSniff.php index c85ee6027e..9f3f3d10d3 100644 --- a/WordPress/Sniffs/PHP/YodaConditionsSniff.php +++ b/WordPress/Sniffs/PHP/YodaConditionsSniff.php @@ -108,7 +108,7 @@ public function process_token( $stackPtr ) { if ( \in_array( $this->tokens[ $next_non_empty ]['code'], array( \T_SELF, \T_PARENT, \T_STATIC ), true ) ) { $next_non_empty = $this->phpcsFile->findNext( - array_merge( Tokens::$emptyTokens, array( \T_DOUBLE_COLON ) ), + ( Tokens::$emptyTokens + array( \T_DOUBLE_COLON => \T_DOUBLE_COLON ) ), ( $next_non_empty + 1 ), null, true From dda05c132cc121f72fb051b49436537eb38bd0c4 Mon Sep 17 00:00:00 2001 From: jrfnl <663378+jrfnl@users.noreply.github.com> Date: Fri, 20 Sep 2019 14:00:15 +0200 Subject: [PATCH 45/72] Docs/Deprecated WP: various minor fixes to the XML docs --- .../Docs/WP/DeprecatedClassesStandard.xml | 10 +++---- .../Docs/WP/DeprecatedFunctionsStandard.xml | 8 +++--- .../WP/DeprecatedParameterValuesStandard.xml | 12 ++++----- .../Docs/WP/DeprecatedParametersStandard.xml | 27 +++++++++++++++---- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/WordPress/Docs/WP/DeprecatedClassesStandard.xml b/WordPress/Docs/WP/DeprecatedClassesStandard.xml index 42d57e56f1..4d06f6e35c 100644 --- a/WordPress/Docs/WP/DeprecatedClassesStandard.xml +++ b/WordPress/Docs/WP/DeprecatedClassesStandard.xml @@ -1,18 +1,18 @@ - + - + WP_User_Query(); ]]> - + WP_User_Search(); // Deprecated WP 3.1. ]]> diff --git a/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml b/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml index 7a0eaf9390..7fcc9c4e5b 100644 --- a/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml +++ b/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml @@ -5,14 +5,14 @@ ]]> - + get_sites(); ]]> - + wp_get_sites(); // Deprecated WP 4.6. ]]> diff --git a/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml b/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml index b084f2466c..0348fdffed 100644 --- a/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml +++ b/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml @@ -1,18 +1,18 @@ - + - + 'url' ); ]]> - + 'home' ); // Deprecated WP 2.2.0. ]]> diff --git a/WordPress/Docs/WP/DeprecatedParametersStandard.xml b/WordPress/Docs/WP/DeprecatedParametersStandard.xml index f754081c72..6399ca62fb 100644 --- a/WordPress/Docs/WP/DeprecatedParametersStandard.xml +++ b/WordPress/Docs/WP/DeprecatedParametersStandard.xml @@ -1,18 +1,35 @@ - + after the deprecated parameter, only ever pass the default value. ]]> - + - + $string ); // Deprecated WP 2.1 +// First - and only - parameter deprecated. +get_the_author( $string ); + ]]> + + + + + '', 'yes' ); + ]]> + + + 'oops', 'yes' ); ]]> From 54f1017ce3036481474e8926982bcb65fb7ad8cb Mon Sep 17 00:00:00 2001 From: jrfnl <663378+jrfnl@users.noreply.github.com> Date: Fri, 20 Sep 2019 15:56:58 +0200 Subject: [PATCH 46/72] DisallowShortTernary: improve docs The valid example line was a bit too long... oops... --- WordPress/Docs/PHP/DisallowShortTernaryStandard.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/Docs/PHP/DisallowShortTernaryStandard.xml b/WordPress/Docs/PHP/DisallowShortTernaryStandard.xml index 87bfda811a..c81b2fd82d 100644 --- a/WordPress/Docs/PHP/DisallowShortTernaryStandard.xml +++ b/WordPress/Docs/PHP/DisallowShortTernaryStandard.xml @@ -7,7 +7,8 @@ ? $data['height'] : 0; +$height = ! empty( $data['height'] ) ? + $data['height'] : 0; ]]> From 6aec3211d170d687b2eb078c11d7b91c2d314b39 Mon Sep 17 00:00:00 2001 From: oltho Date: Fri, 20 Sep 2019 16:17:21 +0200 Subject: [PATCH 47/72] Documentation Class Instantiation --- .../Classes/ClassInstantiationStandard.xml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 WordPress/Docs/Classes/ClassInstantiationStandard.xml diff --git a/WordPress/Docs/Classes/ClassInstantiationStandard.xml b/WordPress/Docs/Classes/ClassInstantiationStandard.xml new file mode 100644 index 0000000000..b25fd34ce7 --- /dev/null +++ b/WordPress/Docs/Classes/ClassInstantiationStandard.xml @@ -0,0 +1,53 @@ + + + + + + + (); + ]]> + + + + + + + + + + + + + + (); + ]]> + + + + + + + + + + + & new Foobar(); + ]]> + + + From aecdaa763576c785779ecb214067436dbba3900b Mon Sep 17 00:00:00 2001 From: oltho Date: Sat, 28 Sep 2019 01:36:17 +0200 Subject: [PATCH 48/72] Proccessed feedback from jrfnl --- .../Docs/Classes/ClassInstantiationStandard.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/WordPress/Docs/Classes/ClassInstantiationStandard.xml b/WordPress/Docs/Classes/ClassInstantiationStandard.xml index b25fd34ce7..cdd749ecdd 100644 --- a/WordPress/Docs/Classes/ClassInstantiationStandard.xml +++ b/WordPress/Docs/Classes/ClassInstantiationStandard.xml @@ -1,7 +1,7 @@ @@ -18,16 +18,16 @@ $a = new Foobar; - + - + (); ]]> @@ -35,18 +35,18 @@ $a = new Foobar (); new Foobar(); ]]> & new Foobar(); +$a = & new Foobar(); ]]> From 85f30163edeb4d0d03895af5bcbac537ebc28135 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 3 Oct 2019 09:43:14 +0200 Subject: [PATCH 49/72] CapitalPDangit: minor tweak Allow for the `test` TLD. Includes unit test. --- WordPress/Sniffs/WP/CapitalPDangitSniff.php | 4 ++-- WordPress/Tests/WP/CapitalPDangitUnitTest.inc | 3 +++ WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/WordPress/Sniffs/WP/CapitalPDangitSniff.php b/WordPress/Sniffs/WP/CapitalPDangitSniff.php index edbd3ebe97..bf98233fb9 100644 --- a/WordPress/Sniffs/WP/CapitalPDangitSniff.php +++ b/WordPress/Sniffs/WP/CapitalPDangitSniff.php @@ -28,7 +28,7 @@ class CapitalPDangitSniff extends Sniff { * Regex to match a large number or spelling variations of WordPress in text strings. * * Prevents matches on: - * - URLs for wordpress.org/com/net/tv. + * - URLs for wordpress.org/com/net/test/tv. * - `@...` usernames starting with `wordpress` * - email addresses with a domain starting with `wordpress` * - email addresses with a user name ending with `wordpress` @@ -42,7 +42,7 @@ class CapitalPDangitSniff extends Sniff { * * @var string */ - const WP_REGEX = '#(?\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i'; + const WP_REGEX = '#(?\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i'; /** * Regex to match a large number or spelling variations of WordPress in class names. diff --git a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc index 33622aa88c..e29ee8942f 100644 --- a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc +++ b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc @@ -188,3 +188,6 @@ class TestMe { ANOTHER => array( 'a' => 'b' ), WORDPRESS_SOMETHING = 'wordpress'; // OK (complex declaration to make sure start of statement is detected correctly). } + +// Allow "test" domain. +$value = function_call( 'git.wordpress.test' ); diff --git a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed index 7dc636aa88..0a00f5ec0d 100644 --- a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed +++ b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed @@ -188,3 +188,6 @@ class TestMe { ANOTHER => array( 'a' => 'b' ), WORDPRESS_SOMETHING = 'wordpress'; // OK (complex declaration to make sure start of statement is detected correctly). } + +// Allow "test" domain. +$value = function_call( 'git.wordpress.test' ); From 28bc1449da4285327e9b5284f367802e182769f0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Oct 2019 04:31:06 +0200 Subject: [PATCH 50/72] Sniff: add new `is_function_deprecated()` utility function This new function: * Tries to find a function docblock, if it exists. * If found, checks if the docblock contains at least one `@deprecated` tag. Returns boolean true/false. Note: this method is `static` to allow the `ValidFunctionName` sniff which extends an upstream sniff to use the method as well. --- WordPress/Sniff.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 1abc6c920a..ed6bc3e1b7 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -3385,4 +3385,38 @@ protected function get_list_variables( $stackPtr, $list_open_close = array() ) { return $var_pointers; } + /** + * Check whether a function has been marked as deprecated via a @deprecated tag + * in the function docblock. + * + * {@internal This method is static to allow the ValidFunctionName class to use it.}} + * + * @since 2.2.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of a T_FUNCTION + * token in the stack. + * + * @return bool + */ + public static function is_function_deprecated( File $phpcsFile, $stackPtr ) { + $tokens = $phpcsFile->getTokens(); + $find = Tokens::$methodPrefixes; + $find[] = \T_WHITESPACE; + + $comment_end = $phpcsFile->findPrevious( $find, ( $stackPtr - 1 ), null, true ); + if ( \T_DOC_COMMENT_CLOSE_TAG !== $tokens[ $comment_end ]['code'] ) { + // Function doesn't have a doc comment or is using the wrong type of comment. + return false; + } + + $comment_start = $tokens[ $comment_end ]['comment_opener']; + foreach ( $tokens[ $comment_start ]['comment_tags'] as $tag ) { + if ( '@deprecated' === $tokens[ $tag ]['content'] ) { + return true; + } + } + + return false; + } } From 6226cdcfcc055e7d305ad9bef541e3016cf37a4d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Oct 2019 04:29:22 +0200 Subject: [PATCH 51/72] ValidFunctionName: ignore deprecated functions Check the function docblock for a `@deprecated` tag and if found, bow out. Includes unit tests. Fixes 1797 --- .../ValidFunctionNameSniff.php | 22 ++++++++++++++++++- .../ValidFunctionNameUnitTest.inc | 22 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php index c88835cb6f..d8826ce1cf 100644 --- a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -24,6 +24,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 2.0.0 The `get_name_suggestion()` method has been moved to the * WordPress native `Sniff` base class as `get_snake_case_name_suggestion()`. + * @since 2.2.0 Will now ignore functions and methods which are marked as @deprecated. * * Last synced with parent class December 2018 up to commit ee167761d7756273b8ad0ad68bf3db1f2c211bb8. * @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -43,6 +44,16 @@ class ValidFunctionNameSniff extends PHPCS_PEAR_ValidFunctionNameSniff { * @return void */ protected function processTokenOutsideScope( File $phpcsFile, $stackPtr ) { + + if ( Sniff::is_function_deprecated( $phpcsFile, $stackPtr ) === true ) { + /* + * Deprecated functions don't have to comply with the naming conventions, + * otherwise functions deprecated in favour of a function with a compliant + * name would still trigger an error. + */ + return; + } + $functionName = $phpcsFile->getDeclarationName( $stackPtr ); if ( ! isset( $functionName ) ) { @@ -51,7 +62,7 @@ protected function processTokenOutsideScope( File $phpcsFile, $stackPtr ) { } if ( '' === ltrim( $functionName, '_' ) ) { - // Ignore special functions. + // Ignore special functions, like __(). return; } @@ -102,6 +113,15 @@ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currSco return; } + if ( Sniff::is_function_deprecated( $phpcsFile, $stackPtr ) === true ) { + /* + * Deprecated functions don't have to comply with the naming conventions, + * otherwise functions deprecated in favour of a function with a compliant + * name would still trigger an error. + */ + return; + } + $methodName = $phpcsFile->getDeclarationName( $stackPtr ); if ( ! isset( $methodName ) ) { diff --git a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc index 642fe78a80..f0403333ee 100644 --- a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc +++ b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc @@ -123,3 +123,25 @@ abstract class My_Class { public function my_Class() {} public function _MY_CLASS() {} } + +/** + * Function description. + * + * @since 1.2.3 + * @deprecated 2.3.4 + * + * @return void + */ +function __deprecatedFunction() {} + +class Deprecated { + /** + * Function description. + * + * @since 1.2.3 + * @deprecated 2.3.4 + * + * @return void + */ + public static function __deprecatedMethod() {} +} From d5640f852cce350a30f529b9d819a46f60007531 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Oct 2019 04:35:43 +0200 Subject: [PATCH 52/72] PrefixAllGlobals: ignore deprecated functions Check the function docblock for a `@deprecated` tag and if found, bow out. Includes unit tests. Fixes 1797 Note: the same should probably also be done for classes/interfaces/traits/constants marked as deprecated, but that's for another PR. --- .../NamingConventions/PrefixAllGlobalsSniff.php | 12 +++++++++++- .../PrefixAllGlobalsUnitTest.1.inc | 13 +++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index a77bcd0b91..eadf332601 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -21,7 +21,8 @@ * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.2.0 Now also checks whether namespaces are prefixed. - * @since 2.2.0 Now also checks variables assigned via the list() construct. + * @since 2.2.0 - Now also checks variables assigned via the list() construct. + * - Now also ignores global functions which are marked as @deprecated. * * @uses \WordPressCS\WordPress\Sniff::$custom_test_class_whitelist */ @@ -382,6 +383,15 @@ public function process_token( $stackPtr ) { return; } + if ( $this->is_function_deprecated( $this->phpcsFile, $stackPtr ) === true ) { + /* + * Deprecated functions don't have to comply with the naming conventions, + * otherwise functions deprecated in favour of a function with a compliant + * name would still trigger an error. + */ + return; + } + $item_name = $this->phpcsFile->getDeclarationName( $stackPtr ); if ( isset( $this->built_in_functions[ $item_name ] ) ) { // Backfill for PHP native function. diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc index 655096a4c3..12404130e6 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc @@ -471,11 +471,20 @@ function acronym_lists_in_function_scope() { list( $foo['key'], $foo[ $c ] ) = $array; // OK. Variable array key should be ignored. } -// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] +// Issue #1797 - Ignore non-prefixed deprecated functions. +/** + * Function description. + * + * @since 1.2.3 + * @deprecated 2.3.4 + * + * @return void + */ +function deprecated_function() {} /* * Bad: Issue https://github.com/WordPress/WordPress-Coding-Standards/issues/1733. - * + * * Short prefixes are not allowed. The errors are triggered * on LINE 1 for the unit-test, because it's the phpcs:set command that is * wrong, not the implementing code. From b5f989d7876a9d46810b6bd52c249fc127d4c69c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 7 Oct 2019 06:18:28 +0200 Subject: [PATCH 53/72] DeprecatedClasses: update the sniff Add some more deprecated classes to the list. Refs: * https://core.trac.wordpress.org/ticket/42364 * https://core.trac.wordpress.org/ticket/47699 --- WordPress/Sniffs/WP/DeprecatedClassesSniff.php | 14 ++++++++++++++ WordPress/Tests/WP/DeprecatedClassesUnitTest.inc | 3 +++ WordPress/Tests/WP/DeprecatedClassesUnitTest.php | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php index 4692eef599..9d1f95bff4 100644 --- a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php @@ -48,6 +48,20 @@ class DeprecatedClassesSniff extends AbstractClassRestrictionsSniff { 'alt' => 'WP_User_Query', 'version' => '3.1.0', ), + + // WP 4.9.0. + 'Customize_New_Menu_Section' => array( + 'version' => '4.9.0', + ), + 'WP_Customize_New_Menu_Control' => array( + 'version' => '4.9.0', + ), + + // WP 5.3.0. + 'Services_JSON' => array( + 'alt' => 'The PHP native JSON extension', + 'version' => '5.3.0', + ), ); diff --git a/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc b/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc index fcd27c2fa3..b0b678d944 100644 --- a/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc +++ b/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc @@ -17,3 +17,6 @@ $a = (new WP_User_Search())->query(); /* * Warning. */ +class Prefix_Menu_section extends Customize_New_Menu_Section {} +WP_Customize_New_Menu_Control::foo(); +$json = new Services_JSON; diff --git a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php index b58576ccf2..01a0554152 100644 --- a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php @@ -36,7 +36,7 @@ public function getErrorList() { * @return array => */ public function getWarningList() { - return array(); + return array_fill( 20, 3, 1 ); } } From e38cee87efefd5c9c97a719f9a0ba0d7a26bc073 Mon Sep 17 00:00:00 2001 From: Mike Hermans Date: Sun, 13 Oct 2019 10:56:36 +0200 Subject: [PATCH 54/72] Docs/WordPress.Arrays.ArrayIndentation (#1744) Adds documentations for the WordPress.Arrays.ArrayIndentation sniff Related to #1722 --- .../Docs/Arrays/ArrayIndentationStandard.xml | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 WordPress/Docs/Arrays/ArrayIndentationStandard.xml diff --git a/WordPress/Docs/Arrays/ArrayIndentationStandard.xml b/WordPress/Docs/Arrays/ArrayIndentationStandard.xml new file mode 100644 index 0000000000..5b9a1deea3 --- /dev/null +++ b/WordPress/Docs/Arrays/ArrayIndentationStandard.xml @@ -0,0 +1,112 @@ + + + + + + + 22, +); + ]]> + + + 22, + ); + ]]> + + + + + + + + 22, + 'comment_count' => array( + 'value' => 25, + 'compare' => '>=', + ), + 'post_type' => array( + 'post', + 'page', + ), +); + ]]> + + + 22, + 'comment_count' => array( + 'value' => 25, + 'compare' => '>=', + ), + 'post_type' => array( + 'post', + 'page', + ), +); + ]]> + + + + + + + + 'start of phrase' + . 'concatented additional phrase' + . 'more text', +); + ]]> + + + 'start of phrase' +. 'concatented additional phrase' +. 'more text', +); + ]]> + + + + + + + + << + start of phrase + concatented additional phrase + more text +EOD +, +); + ]]> + + + From 058be1bc5b2c5f20bcb0fb44603e43abe6315be4 Mon Sep 17 00:00:00 2001 From: Mike Hermans Date: Sun, 13 Oct 2019 22:21:42 +0200 Subject: [PATCH 55/72] Docs/ArrayKeySpacingRestrictions and Array.MultipleStatementAlignment (#1737) Adds documentations for the `WordPress.Arrays.ArrayKeySpacingRestrictions` sniff and the `WordPress.Arrays.MultipleStatementAlignment` sniff. Related to #1722 --- .../ArrayKeySpacingRestrictionsStandard.xml | 27 +++++++++++ .../MultipleStatementAlignmentStandard.xml | 46 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml create mode 100644 WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml diff --git a/WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml b/WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml new file mode 100644 index 0000000000..c1e27a1324 --- /dev/null +++ b/WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml @@ -0,0 +1,27 @@ + + + + + + + [ $post_id ]; +$post_title = $post[ 'concatenated' . $title ]; +$post = $posts[ HOME_PAGE ]; +$post = $posts[123]; +$post_title = $post['post_title']; + ]]> + + + [$post_id]; +$post_title = $post['concatenated' . $title ]; +$post = $posts[HOME_PAGE]; +$post = $posts[ 123 ]; +$post_title = $post[ 'post_title' ]; + ]]> + + + diff --git a/WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml b/WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml new file mode 100644 index 0000000000..b3f87cbbe5 --- /dev/null +++ b/WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml @@ -0,0 +1,46 @@ + + + + + + + => 22 ); +$bar = array( 'year' => $current_year ); + ]]> + + + =>22 ); +$bar = array( 'year'=> $current_year ); + ]]> + + + + + + + + => 22, + 'year' => $current_year, + 'monthnum' => $current_month, +); + ]]> + + + => 22, + 'year' => $current_year, + 'monthnum' => $current_month, +); + ]]> + + + From 5c82777d0e4c626eb7da8d23458370dc23b705ea Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 15 Oct 2019 01:02:49 +0200 Subject: [PATCH 56/72] DeprecatedFunctions: update function list ... with functions which will be deprecated in WP 5.3. Not updating the `Sniff::$minimum_supported_version` property yet as WP 5.3 has not yet been released. --- WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php | 14 ++++++++++++++ WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc | 4 ++++ WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php index fb4ad43230..7793917096 100644 --- a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php @@ -1345,6 +1345,20 @@ class DeprecatedFunctionsSniff extends AbstractFunctionRestrictionsSniff { 'alt' => '', 'version' => '5.1.0', ), + + // WP 5.3.0. + '_wp_json_prepare_data' => array( + 'alt' => '', + 'version' => '5.3.0', + ), + '_wp_privacy_requests_screen_options' => array( + 'alt' => '', + 'version' => '5.3.0', + ), + 'update_user_status' => array( + 'alt' => 'wp_update_user()', + 'version' => '5.3.0', + ), ); /** diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc index 6a41db6cc6..03c075a44b 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc @@ -341,3 +341,7 @@ wp_ajax_press_this_save_post(); /* ============ WP 5.1 ============ */ insert_blog(); install_blog(); +/* ============ WP 5.3 ============ */ +_wp_json_prepare_data(); +_wp_privacy_requests_screen_options(); +update_user_status(); diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php index b3b217c7cf..21a90b3b79 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php @@ -75,10 +75,10 @@ public function getErrorList() { */ public function getWarningList() { - $warnings = array_fill( 337, 7, 1 ); + $warnings = array_fill( 337, 11, 1 ); // Unset the lines related to version comments. - unset( $warnings[341] ); + unset( $warnings[341], $warnings[344] ); return $warnings; } From 0e88b837d9d29796b818917fc5a28b0fdc8318b5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 22 Oct 2019 07:51:33 +0200 Subject: [PATCH 57/72] ValidHookName: minor efficiency tweaks Instead of checking whether a `..._deprecated()` function was matched after the function matching, remove the deprecated hook invocation functions from the target function array in `getGroups()`. This allows the sniff to fail earlier. Also remove redundant check for `$parameters[1]`. If there are no parameters, the `process_parameters()` function wouldn't be called anyway. --- .../NamingConventions/ValidHookNameSniff.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php index 4ce141e142..c8e8a54461 100644 --- a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -73,6 +73,13 @@ class ValidHookNameSniff extends AbstractFunctionParameterSniff { */ public function getGroups() { $this->target_functions = $this->hookInvokeFunctions; + + // No need to examine the names of deprecated hooks. + unset( + $this->target_functions['do_action_deprecated'], + $this->target_functions['apply_filters_deprecated'] + ); + return parent::getGroups(); } @@ -89,14 +96,6 @@ public function getGroups() { * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { - // Ignore deprecated hook names. - if ( strpos( $matched_content, '_deprecated' ) > 0 ) { - return; - } - - if ( ! isset( $parameters[1] ) ) { - return; - } $regex = $this->prepare_regex(); From 62d9924f773296870375928de72ab7b959bc6c32 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 24 Oct 2019 01:02:56 +0200 Subject: [PATCH 58/72] ValidHookName: add documentation Related to 1722 --- .../ValidHookNameStandard.xml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 WordPress/Docs/NamingConventions/ValidHookNameStandard.xml diff --git a/WordPress/Docs/NamingConventions/ValidHookNameStandard.xml b/WordPress/Docs/NamingConventions/ValidHookNameStandard.xml new file mode 100644 index 0000000000..479dbd9ba5 --- /dev/null +++ b/WordPress/Docs/NamingConventions/ValidHookNameStandard.xml @@ -0,0 +1,32 @@ + + + + + + + + 'prefix_hook_name', $var ); + ]]> + + + 'Prefix_Hook_NAME', $var ); + ]]> + + + + + 'prefix_hook_name', $var ); + ]]> + + + 'prefix\hook-name', $var ); + ]]> + + + From 7947bce347122daa530b0b11864d34fb35e6e465 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 5 Oct 2019 03:29:33 +0200 Subject: [PATCH 59/72] New "DateTime.RestrictedFunctions" sniff This introduces a new `WordPress.DateTime.RestrictedFunctions` sniff which initially includes two groups: * `timezone_change` - moved from the `WordPress.WP.TimezoneChange` sniff * `date` - moved from the `WordPress.PHP.RestrictedPHPFunctions` sniff (group not yet in a released WPCS version yet) The `WordPress.WP.TimezoneChange` sniff is now deprecated. * The sniff is no longer included in the WPCS rulesets. * If the sniff is explicitly included via a custom ruleset, deprecation notices will be thrown. * If the `exclude` property is set from with a custom ruleset, a deprecation notice will be thrown. The new sniff is now included in the `Core` ruleset. Note: once WP Core upgrades, the one instance of using `date_default_timezone_set()` in WP Core (in `wp-settings.php`) will need to be whitelisted inline. There are a few more occurrences in the unit tests, but those can be ignored via file based excludes. Fixes 1805 --- WordPress-Core/ruleset.xml | 4 ++ WordPress-Extra/ruleset.xml | 1 - .../DateTime/RestrictedFunctionsSniff.php | 62 ++++++++++++++++ .../PHP/RestrictedPHPFunctionsSniff.php | 8 --- WordPress/Sniffs/WP/TimezoneChangeSniff.php | 72 ++++++++++++++----- .../DateTime/RestrictedFunctionsUnitTest.inc | 9 +++ .../DateTime/RestrictedFunctionsUnitTest.php | 44 ++++++++++++ .../PHP/RestrictedPHPFunctionsUnitTest.inc | 3 - .../PHP/RestrictedPHPFunctionsUnitTest.php | 1 - WordPress/Tests/WP/TimezoneChangeUnitTest.inc | 6 +- WordPress/Tests/WP/TimezoneChangeUnitTest.php | 7 +- WordPress/ruleset.xml | 6 +- 12 files changed, 187 insertions(+), 36 deletions(-) create mode 100644 WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php create mode 100644 WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.inc create mode 100644 WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php diff --git a/WordPress-Core/ruleset.xml b/WordPress-Core/ruleset.xml index 5d4c5deb66..949d16efe2 100644 --- a/WordPress-Core/ruleset.xml +++ b/WordPress-Core/ruleset.xml @@ -519,4 +519,8 @@ + + + diff --git a/WordPress-Extra/ruleset.xml b/WordPress-Extra/ruleset.xml index f44b0db786..a795891878 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -145,7 +145,6 @@ - diff --git a/WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php b/WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php new file mode 100644 index 0000000000..0da070190c --- /dev/null +++ b/WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php @@ -0,0 +1,62 @@ + array( + 'type' => 'error', + 'message' => 'Using %s() and similar isn\'t allowed, instead use WP internal timezone support.', + 'functions' => array( + 'date_default_timezone_set', + ), + ), + + /* + * Use gmdate(), not date(). + * Don't rely on the current PHP time zone as it might have been changed by third party code. + * + * @link https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/ + * @link https://core.trac.wordpress.org/ticket/46438 + * @link https://github.com/WordPress/WordPress-Coding-Standards/issues/1713 + */ + 'date' => array( + 'type' => 'error', + 'message' => '%s() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.', + 'functions' => array( + 'date', + ), + ), + ); + } + +} diff --git a/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php b/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php index b7f3bb14a1..280c94d919 100644 --- a/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php @@ -17,7 +17,6 @@ * @package WPCS\WordPressCodingStandards * * @since 0.14.0 - * @since 2.2.0 New group `date` added. */ class RestrictedPHPFunctionsSniff extends AbstractFunctionRestrictionsSniff { @@ -43,13 +42,6 @@ public function getGroups() { 'create_function', ), ), - 'date' => array( - 'type' => 'error', - 'message' => '%s() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.', - 'functions' => array( - 'date', - ), - ), ); } diff --git a/WordPress/Sniffs/WP/TimezoneChangeSniff.php b/WordPress/Sniffs/WP/TimezoneChangeSniff.php index 5712df975c..f376c5e3a3 100644 --- a/WordPress/Sniffs/WP/TimezoneChangeSniff.php +++ b/WordPress/Sniffs/WP/TimezoneChangeSniff.php @@ -9,7 +9,7 @@ namespace WordPressCS\WordPress\Sniffs\WP; -use WordPressCS\WordPress\AbstractFunctionRestrictionsSniff; +use WordPressCS\WordPress\Sniffs\DateTime\RestrictedFunctionsSniff; /** * Disallow the changing of timezone. @@ -23,32 +23,66 @@ * class instead of the upstream `Generic.PHP.ForbiddenFunctions` sniff. * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `WP` category. + * + * @deprecated 2.2.0 Use the `WordPress.DateTime.RestrictedFunctions` sniff instead. + * This `WordPress.WP.TimezoneChange` sniff will be removed in WPCS 3.0.0. */ -class TimezoneChangeSniff extends AbstractFunctionRestrictionsSniff { +class TimezoneChangeSniff extends RestrictedFunctionsSniff { /** - * Groups of functions to restrict. + * Keep track of whether the warnings have been thrown to prevent + * the messages being thrown for every token triggering the sniff. * - * Example: groups => array( - * 'lambda' => array( - * 'type' => 'error' | 'warning', - * 'message' => 'Use anonymous functions instead please!', - * 'functions' => array( 'file_get_contents', 'create_function' ), - * ) - * ) + * @since 2.2.0 + * + * @var array + */ + private $thrown = array( + 'DeprecatedSniff' => false, + 'FoundPropertyForDeprecatedSniff' => false, + ); + + /** + * Don't use. + * + * @deprecated 2.2.0 * * @return array */ public function getGroups() { - return array( - 'timezone_change' => array( - 'type' => 'error', - 'message' => 'Using %s() and similar isn\'t allowed, instead use WP internal timezone support.', - 'functions' => array( - 'date_default_timezone_set', - ), - ), - ); + $groups = parent::getGroups(); + return array( 'timezone_change' => $groups['timezone_change'] ); } + /** + * Don't use. + * + * @since 2.2.0 Added to allow for throwing the deprecation notices. + * @deprecated 2.2.0 + * + * @param int $stackPtr The position of the current token in the stack. + * + * @return void|int + */ + public function process_token( $stackPtr ) { + if ( false === $this->thrown['DeprecatedSniff'] ) { + $this->thrown['DeprecatedSniff'] = $this->phpcsFile->addWarning( + 'The "WordPress.WP.TimezoneChange" sniff has been deprecated. Use the "WordPress.DateTime.RestrictedFunctions" sniff instead. Please update your custom ruleset.', + 0, + 'DeprecatedSniff' + ); + } + + if ( ! empty( $this->exclude ) + && false === $this->thrown['FoundPropertyForDeprecatedSniff'] + ) { + $this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning( + 'The "WordPress.WP.TimezoneChange" sniff has been deprecated. Use the "WordPress.DateTime.RestrictedFunctions" sniff instead. "exclude" property setting found. Please update your custom ruleset.', + 0, + 'FoundPropertyForDeprecatedSniff' + ); + } + + return parent::process_token( $stackPtr ); + } } diff --git a/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.inc b/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.inc new file mode 100644 index 0000000000..25227b5178 --- /dev/null +++ b/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.inc @@ -0,0 +1,9 @@ +setTimezone( new DateTimeZone( 'America/Toronto' ) ); // Yay! + +$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) ); // Error. +$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) ); // OK. diff --git a/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php b/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php new file mode 100644 index 0000000000..ecfc78867f --- /dev/null +++ b/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php @@ -0,0 +1,44 @@ + => + */ + public function getErrorList() { + return array( + 3 => 1, + 8 => 2, + ); + } + + /** + * Returns the lines where warnings should occur. + * + * @return array => + */ + public function getWarningList() { + return array(); + } + +} diff --git a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc index 2a4e8754b5..84dbd1d7b3 100644 --- a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc +++ b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.inc @@ -3,6 +3,3 @@ add_action( 'widgets_init', create_function( '', // Error. 'return register_widget( "time_more_on_time_widget" );' ) ); - -$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) ); // Error. -$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) ); // OK. diff --git a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php index 3d21aa7195..af8707d3cd 100644 --- a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php @@ -28,7 +28,6 @@ class RestrictedPHPFunctionsUnitTest extends AbstractSniffUnitTest { public function getErrorList() { return array( 3 => 1, - 7 => 2, ); } diff --git a/WordPress/Tests/WP/TimezoneChangeUnitTest.inc b/WordPress/Tests/WP/TimezoneChangeUnitTest.inc index 4e38791f9b..c1a374c306 100644 --- a/WordPress/Tests/WP/TimezoneChangeUnitTest.inc +++ b/WordPress/Tests/WP/TimezoneChangeUnitTest.inc @@ -2,5 +2,7 @@ date_default_timezone_set( 'Foo/Bar' ); // Bad. -$date = new DateTime(); -$date->setTimezone( new DateTimeZone( 'America/Toronto' ) ); // Yay! +// phpcs:set WordPress.WP.TimezoneChange exclude[] timezone_change +date_default_timezone_set( 'Foo/Bar' ); // OK. + +// phpcs:set WordPress.WP.TimezoneChange exclude[] diff --git a/WordPress/Tests/WP/TimezoneChangeUnitTest.php b/WordPress/Tests/WP/TimezoneChangeUnitTest.php index 81e86d1e6e..906883077b 100644 --- a/WordPress/Tests/WP/TimezoneChangeUnitTest.php +++ b/WordPress/Tests/WP/TimezoneChangeUnitTest.php @@ -19,6 +19,9 @@ * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `WP` category. + * @since 2.2.0 The sniff has been deprecated. This unit test file now + * only tests that the deprecation warnings are correctly thrown + * and that the sniff falls through to the parent correctly. */ class TimezoneChangeUnitTest extends AbstractSniffUnitTest { @@ -39,7 +42,9 @@ public function getErrorList() { * @return array => */ public function getWarningList() { - return array(); + return array( + 1 => 2, + ); } } diff --git a/WordPress/ruleset.xml b/WordPress/ruleset.xml index fd24ae6318..20ff9a38cc 100644 --- a/WordPress/ruleset.xml +++ b/WordPress/ruleset.xml @@ -8,6 +8,10 @@ --> - + + + + + From 864e4fd65be99694f3d6eaf8b638f6bd02c8ef29 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 24 Oct 2019 16:11:07 +0200 Subject: [PATCH 60/72] EscapeOutput: allow for typical pattern with `_deprecated_file()` The first parameter passed to `_deprecated_file()` generally is `basename( __FILE__ )` based on the code currently in WP Core. As the result of that function call is safe, I'm proposing making an exception for that particular code pattern. Includes unit tests. Note: the current code does not allow for comments in the first parameter. This would be rare encounter in these function calls anyway and allowance for it can be added later if needs be. --- WordPress/Sniffs/Security/EscapeOutputSniff.php | 14 ++++++++++++++ WordPress/Tests/Security/EscapeOutputUnitTest.inc | 3 +++ WordPress/Tests/Security/EscapeOutputUnitTest.php | 1 + 3 files changed, 18 insertions(+) diff --git a/WordPress/Sniffs/Security/EscapeOutputSniff.php b/WordPress/Sniffs/Security/EscapeOutputSniff.php index fa4100e4ce..cb33eaaeee 100644 --- a/WordPress/Sniffs/Security/EscapeOutputSniff.php +++ b/WordPress/Sniffs/Security/EscapeOutputSniff.php @@ -198,6 +198,20 @@ public function process_token( $stackPtr ) { $end_of_statement = ( $first_param['end'] + 1 ); unset( $first_param ); } + + /* + * If the first param to `_deprecated_file()` follows the typical `basename( __FILE__ )` + * pattern, it doesn't need to be escaped. + */ + if ( '_deprecated_file' === $function ) { + $first_param = $this->get_function_call_parameter( $stackPtr, 1 ); + + // Quick check. This disregards comments. + if ( preg_match( '`^basename\s*\(\s*__FILE__\s*\)$`', $first_param['raw'] ) === 1 ) { + $stackPtr = ( $first_param['end'] + 2 ); + } + unset( $first_param ); + } } // Checking for the ignore comment, ex: //xss ok. diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.inc b/WordPress/Tests/Security/EscapeOutputUnitTest.inc index 875f575f23..bd74d93ac9 100644 --- a/WordPress/Tests/Security/EscapeOutputUnitTest.inc +++ b/WordPress/Tests/Security/EscapeOutputUnitTest.inc @@ -292,3 +292,6 @@ echo esc_html( get_the_title() ); // Ok. echo implode( '
', map_deep( $items, 'esc_html' ) ); // Ok. echo implode( '
', map_deep( $items, 'foo' ) ); // Bad. + +_deprecated_file( basename( __FILE__ ), '1.3.0' ); // Ok. +_deprecated_file( $file, '1.3.0' ); // Error. diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.php b/WordPress/Tests/Security/EscapeOutputUnitTest.php index 1d803fc349..bd81edd244 100644 --- a/WordPress/Tests/Security/EscapeOutputUnitTest.php +++ b/WordPress/Tests/Security/EscapeOutputUnitTest.php @@ -80,6 +80,7 @@ public function getErrorList() { 266 => 1, 289 => 1, 294 => 1, + 297 => 1, ); } From e4f838c19de4f325c1894373498c8070bbaedc7a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 5 Oct 2019 09:28:30 +0200 Subject: [PATCH 61/72] :sparkles: New DateTime.CurrentTimeTimestamp sniff This new sniff adds a check for use of current_time() to retrieve a timestamp. A (fixable) `error` will be thrown when the `$gmt` parameter is set to `true` or `1`, a `warning` when it is not. Includes unit tests. Includes fixer. Includes documentation. This new sniff has been added to the `Core` ruleset. Fixes 1791 --- WordPress-Core/ruleset.xml | 3 + .../DateTime/CurrentTimeTimestampStandard.xml | 31 ++++ .../DateTime/CurrentTimeTimestampSniff.php | 174 ++++++++++++++++++ .../DateTime/CurrentTimeTimestampUnitTest.inc | 25 +++ .../CurrentTimeTimestampUnitTest.inc.fixed | 22 +++ .../DateTime/CurrentTimeTimestampUnitTest.php | 50 +++++ 6 files changed, 305 insertions(+) create mode 100644 WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml create mode 100644 WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php create mode 100644 WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.inc create mode 100644 WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.inc.fixed create mode 100644 WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.php diff --git a/WordPress-Core/ruleset.xml b/WordPress-Core/ruleset.xml index 949d16efe2..0bff5a0d43 100644 --- a/WordPress-Core/ruleset.xml +++ b/WordPress-Core/ruleset.xml @@ -523,4 +523,7 @@ See: https://github.com/WordPress/WordPress-Coding-Standards/issues/1713 --> + + + diff --git a/WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml b/WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml new file mode 100644 index 0000000000..add8ed2378 --- /dev/null +++ b/WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml @@ -0,0 +1,31 @@ + + + + + + + time(); + ]]> + + + current_time( 'timestamp', true ); + ]]> + + + + + 'Y-m-d' ); + ]]> + + + current_time( 'U', false ); + ]]> + + + diff --git a/WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php b/WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php new file mode 100644 index 0000000000..180ae240d2 --- /dev/null +++ b/WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php @@ -0,0 +1,174 @@ + => + */ + protected $target_functions = array( + 'current_time' => true, + ); + + /** + * Process the parameters of a matched function. + * + * @since 2.2.0 + * + * @param int $stackPtr The position of the current token in the stack. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (function name) which was matched. + * @param array $parameters Array with information about the parameters. + * + * @return void + */ + public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { + /* + * We already know there will be valid open & close parentheses as otherwise the parameter + * retrieval function call would have returned an empty array, so no additional checks needed. + */ + $open_parens = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, $stackPtr ); + $close_parens = $this->tokens[ $open_parens ]['parenthesis_closer']; + + /* + * Check whether the first parameter is a timestamp format. + */ + for ( $i = $parameters[1]['start']; $i <= $parameters[1]['end']; $i++ ) { + if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) { + continue; + } + + if ( isset( Tokens::$textStringTokens[ $this->tokens[ $i ]['code'] ] ) ) { + $content_first = trim( $this->strip_quotes( $this->tokens[ $i ]['content'] ) ); + if ( 'U' !== $content_first && 'timestamp' !== $content_first ) { + // Most likely valid use of current_time(). + return; + } + + continue; + } + + if ( isset( Tokens::$heredocTokens[ $this->tokens[ $i ]['code'] ] ) ) { + continue; + } + + /* + * If we're still here, we've encountered an unexpected token, like a variable or + * function call. Bow out as we can't determine the runtime value. + */ + return; + } + + $gmt_true = false; + + /* + * Check whether the second parameter, $gmt, is a set to `true` or `1`. + */ + if ( isset( $parameters[2] ) ) { + $content_second = ''; + if ( 'true' === $parameters[2]['raw'] || '1' === $parameters[2]['raw'] ) { + $content_second = $parameters[2]['raw']; + $gmt_true = true; + } else { + // Do a more extensive parameter check. + for ( $i = $parameters[2]['start']; $i <= $parameters[2]['end']; $i++ ) { + if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) { + continue; + } + + $content_second .= $this->tokens[ $i ]['content']; + } + + if ( 'true' === $content_second || '1' === $content_second ) { + $gmt_true = true; + } + } + } + + /* + * Non-UTC timestamp requested. + */ + if ( false === $gmt_true ) { + $this->phpcsFile->addWarning( + 'Calling current_time() with a $type of "timestamp" or "U" is strongly discouraged as it will not return a Unix (UTC) timestamp. Please consider using a non-timestamp format or otherwise refactoring this code.', + $stackPtr, + 'Requested' + ); + + return; + } + + /* + * UTC timestamp requested. Should use time() instead. + */ + $has_comment = $this->phpcsFile->findNext( Tokens::$commentTokens, ( $stackPtr + 1 ), ( $close_parens + 1 ) ); + $error = 'Don\'t use current_time() for retrieving a Unix (UTC) timestamp. Use time() instead. Found: %s'; + $error_code = 'RequestedUTC'; + + $code_snippet = "current_time( '" . $content_first . "'"; + if ( isset( $content_second ) ) { + $code_snippet .= ', ' . $content_second; + } + $code_snippet .= ' )'; + + if ( false !== $has_comment ) { + // If there are comments, we don't auto-fix as it would remove those comments. + $this->phpcsFile->addError( $error, $stackPtr, $error_code, array( $code_snippet ) ); + + return; + } + + $fix = $this->phpcsFile->addFixableError( $error, $stackPtr, $error_code, array( $code_snippet ) ); + if ( true === $fix ) { + $this->phpcsFile->fixer->beginChangeset(); + + for ( $i = ( $stackPtr + 1 ); $i < $close_parens; $i++ ) { + $this->phpcsFile->fixer->replaceToken( $i, '' ); + } + + $this->phpcsFile->fixer->replaceToken( $stackPtr, 'time(' ); + $this->phpcsFile->fixer->endChangeset(); + } + } + +} diff --git a/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.inc b/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.inc new file mode 100644 index 0000000000..ac89fb1943 --- /dev/null +++ b/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.inc @@ -0,0 +1,25 @@ + => + */ + public function getErrorList() { + return array( + 9 => 1, + 11 => 1, + 17 => 1, + ); + } + + /** + * Returns the lines where warnings should occur. + * + * @return array => + */ + public function getWarningList() { + return array( + 22 => 1, + 23 => 1, + 24 => 1, + 25 => 1, + ); + } + +} From 52de928c942c11743180df0871e777418c602ab1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 28 Oct 2019 01:31:15 +0100 Subject: [PATCH 62/72] ValidHookName: improve error messages * Trim whitespace off the "expected" and "found" values which are used in the error messages. * Ignore comments and PHPCS annotations when building up the "expected" and "found" values. * Improve line precision by throwing the error on the line where the hook name starts, not the line containing the function call. Includes unit test. The unit test basically only tests part 3 of the change. The error message improvement needs visual inspection as the message content is not tested. --- .../NamingConventions/ValidHookNameSniff.php | 20 +++++++++++++++---- .../ValidHookNameUnitTest.1.inc | 6 ++++++ .../ValidHookNameUnitTest.php | 3 ++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php index c8e8a54461..4c56d96c8f 100644 --- a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -105,6 +105,11 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p $expected = array(); for ( $i = $parameters[1]['start']; $i <= $parameters[1]['end']; $i++ ) { + // Skip past comment tokens. + if ( isset( Tokens::$commentTokens[ $this->tokens[ $i ]['code'] ] ) !== false ) { + continue; + } + $content[ $i ] = $this->tokens[ $i ]['content']; $expected[ $i ] = $this->tokens[ $i ]['content']; @@ -165,18 +170,25 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p } } + $first_non_empty = $this->phpcsFile->findNext( + Tokens::$emptyTokens, + $parameters[1]['start'], + ( $parameters[1]['end'] + 1 ), + true + ); + $data = array( - implode( '', $expected ), - implode( '', $content ), + trim( implode( '', $expected ) ), + trim( implode( '', $content ) ), ); if ( $case_errors > 0 ) { $error = 'Hook names should be lowercase. Expected: %s, but found: %s.'; - $this->phpcsFile->addError( $error, $stackPtr, 'NotLowercase', $data ); + $this->phpcsFile->addError( $error, $first_non_empty, 'NotLowercase', $data ); } if ( $underscores > 0 ) { $error = 'Words in hook names should be separated using underscores. Expected: %s, but found: %s.'; - $this->phpcsFile->addWarning( $error, $stackPtr, 'UseUnderscores', $data ); + $this->phpcsFile->addWarning( $error, $first_non_empty, 'UseUnderscores', $data ); } } diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc index 7fd072418e..039ca6484e 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc @@ -88,3 +88,9 @@ apply_filters_deprecated( "admin_Head_$Post->ID admin_Head_$Post->ID" ); // Ok. do_action( 'prefix_block_' . $block['blockName'] ); // Ok. do_action( 'prefix_block_' . $block [ 'blockName' ] . '_More_hookname' ); // Error - use lowercase (second part of the hook name). do_action( "prefix_block_{$block['blockName']}" ); // Ok. + +// Don't include comments in the suggestion. +do_action( + // phpcs:ignore Stnd.Cat.Sniff -- For reasons. + 'prefix_hook-name' /* comment */ +); diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php index dfa253c850..c55be6b044 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php @@ -39,7 +39,7 @@ public function getErrorList( $testFile = 'ValidHookNameUnitTest.1.inc' ) { 28 => 1, 29 => 1, 30 => 1, - 32 => 1, + 33 => 1, 53 => 1, 54 => 1, 55 => 1, @@ -96,6 +96,7 @@ public function getWarningList( $testFile = 'ValidHookNameUnitTest.1.inc' ) { 68 => 1, 72 => 1, 77 => 1, + 95 => 1, ); case 'ValidHookNameUnitTest.2.inc': From ef7f86e583b80820c4751c7c68c9e0a66a83567b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 28 Oct 2019 21:14:04 +0100 Subject: [PATCH 63/72] PrefixAllGlobals: minor efficiency tweak Similar to 1815, but then for the `PrefixAllGlobals` sniff, allowing it to fail earlier for calls to deprecated hooks. --- .../NamingConventions/PrefixAllGlobalsSniff.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index eadf332601..8374faf675 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -241,7 +241,12 @@ public function register() { * @return array */ public function getGroups() { - $this->target_functions = $this->hookInvokeFunctions; + $this->target_functions = $this->hookInvokeFunctions; + unset( + $this->target_functions['do_action_deprecated'], + $this->target_functions['apply_filters_deprecated'] + ); + $this->target_functions['define'] = true; return parent::getGroups(); @@ -793,11 +798,6 @@ protected function process_list_assignment( $stackPtr ) { */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { - // Ignore deprecated hook names. - if ( strpos( $matched_content, '_deprecated' ) > 0 ) { - return; - } - // No matter whether it is a constant definition or a hook call, both use the first parameter. if ( ! isset( $parameters[1] ) ) { return; From c65d63b7261786d2a10eed90a54b436cc098ddaa Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 1 Nov 2019 05:18:43 +0100 Subject: [PATCH 64/72] Update default minimum supported WP version What with the target release date for WPCS 2.2.0 being November 11 and the target release date of WP 5.3 being November 12, updating this property before the release is probably a good idea. --- WordPress/Sniff.php | 2 +- WordPress/Tests/WP/DeprecatedClassesUnitTest.inc | 6 ++++-- WordPress/Tests/WP/DeprecatedClassesUnitTest.php | 9 +++++++-- WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc | 8 ++++---- WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php | 9 +++++---- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index ed6bc3e1b7..15533f7ee0 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -82,7 +82,7 @@ abstract class Sniff implements PHPCS_Sniff { * * @var string WordPress version. */ - public $minimum_supported_version = '4.9'; + public $minimum_supported_version = '5.0'; /** * Custom list of classes which test classes can extend. diff --git a/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc b/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc index b0b678d944..02f3dad196 100644 --- a/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc +++ b/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc @@ -13,10 +13,12 @@ echo \WP_User_Search::prepare_query(); class My_User_Search extends WP_User_Search {} class Our_User_Search implements WP_User_Search {} $a = (new WP_User_Search())->query(); +/* ============ WP 4.9 ============ */ +class Prefix_Menu_section extends Customize_New_Menu_Section {} +WP_Customize_New_Menu_Control::foo(); /* * Warning. */ -class Prefix_Menu_section extends Customize_New_Menu_Section {} -WP_Customize_New_Menu_Control::foo(); +/* ============ WP 5.3 ============ */ $json = new Services_JSON; diff --git a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php index 01a0554152..e5abbb46b7 100644 --- a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php @@ -27,7 +27,12 @@ class DeprecatedClassesUnitTest extends AbstractSniffUnitTest { * @return array => */ public function getErrorList() { - return array_fill( 9, 7, 1 ); + $errors = array_fill( 9, 10, 1 ); + + // Unset the lines related to version comments. + unset( $errors[16] ); + + return $errors; } /** @@ -36,7 +41,7 @@ public function getErrorList() { * @return array => */ public function getWarningList() { - return array_fill( 20, 3, 1 ); + return array_fill( 24, 1, 1 ); } } diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc index 03c075a44b..b7095678b5 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc @@ -329,15 +329,15 @@ wp_get_network(); wp_kses_js_entities(); /* ============ WP 4.8 ============ */ wp_dashboard_plugins_output(); - -/* - * Warning. - */ /* ============ WP 4.9 ============ */ get_shortcut_link(); is_user_option_local(); wp_ajax_press_this_add_category(); wp_ajax_press_this_save_post(); + +/* + * Warning. + */ /* ============ WP 5.1 ============ */ insert_blog(); install_blog(); diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php index 21a90b3b79..6f20c09dca 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php @@ -28,7 +28,7 @@ class DeprecatedFunctionsUnitTest extends AbstractSniffUnitTest { */ public function getErrorList() { - $errors = array_fill( 8, 324, 1 ); + $errors = array_fill( 8, 329, 1 ); // Unset the lines related to version comments. unset( @@ -62,7 +62,8 @@ public function getErrorList() { $errors[311], $errors[319], $errors[323], - $errors[330] + $errors[330], + $errors[332] ); return $errors; @@ -75,10 +76,10 @@ public function getErrorList() { */ public function getWarningList() { - $warnings = array_fill( 337, 11, 1 ); + $warnings = array_fill( 342, 6, 1 ); // Unset the lines related to version comments. - unset( $warnings[341], $warnings[344] ); + unset( $warnings[344] ); return $warnings; } From 86d7dbca0de9ecde168a733a071886eface9be13 Mon Sep 17 00:00:00 2001 From: Niels de Blaauw Date: Thu, 31 Oct 2019 12:44:50 +0100 Subject: [PATCH 65/72] Adds documentation for WordPress.WP.CronInterval Update WordPress/Docs/WP/CronIntervalStandard.xml Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com> Update WordPress/Docs/WP/CronIntervalStandard.xml Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com> Update WordPress/Docs/WP/CronIntervalStandard.xml Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com> Update WordPress/Docs/WP/CronIntervalStandard.xml Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com> Update WordPress/Docs/WP/CronIntervalStandard.xml Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com> Seperates function definition --- WordPress/Docs/WP/CronIntervalStandard.xml | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 WordPress/Docs/WP/CronIntervalStandard.xml diff --git a/WordPress/Docs/WP/CronIntervalStandard.xml b/WordPress/Docs/WP/CronIntervalStandard.xml new file mode 100644 index 0000000000..55a9037d47 --- /dev/null +++ b/WordPress/Docs/WP/CronIntervalStandard.xml @@ -0,0 +1,41 @@ + + + + + + + HOUR_IN_SECONDS, + 'display' => __( 'Every hour' ) + ); + return $schedules; +} + +add_filter( + 'cron_schedules', + 'adjust_schedules' +); + ]]> + + + 9 * 60, + 'display' => __( 'Every 9 minutes' ) + ); + return $schedules; +} + +add_filter( + 'cron_schedules', + 'adjust_schedules' +); + ]]> + + + From ae449aa0f511fd08e0cf057fdc85b5660297ce7b Mon Sep 17 00:00:00 2001 From: Niels de Blaauw Date: Sat, 2 Nov 2019 05:54:09 +0100 Subject: [PATCH 66/72] :sparkles: New NamingConventions.ValidPostTypeSlug sniff Adds a new `WordPress.NamingConventions.ValidPostTypeSlug` sniff. Checks if the first parameter given to a register_post_type() call is actually a valid value. --- WordPress-Extra/ruleset.xml | 3 + .../ValidPostTypeSlugStandard.xml | 117 ++++++++++ .../ValidPostTypeSlugSniff.php | 208 ++++++++++++++++++ .../ValidPostTypeSlugUnitTest.inc | 52 +++++ .../ValidPostTypeSlugUnitTest.php | 76 +++++++ 5 files changed, 456 insertions(+) create mode 100644 WordPress/Docs/NamingConventions/ValidPostTypeSlugStandard.xml create mode 100644 WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php create mode 100644 WordPress/Tests/NamingConventions/ValidPostTypeSlugUnitTest.inc create mode 100644 WordPress/Tests/NamingConventions/ValidPostTypeSlugUnitTest.php diff --git a/WordPress-Extra/ruleset.xml b/WordPress-Extra/ruleset.xml index a795891878..4a2f95997a 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -130,6 +130,9 @@ + + +