Version Description
Download this release
Release Info
Developer | diegoquinteiro |
Plugin | Instant Articles for WP |
Version | 4.0.4 |
Comparing to | |
See all releases |
Code changes from version 4.0.3 to 4.0.4
- CHANGELOG.md +9 -2
- facebook-instant-articles.php +2 -2
- readme.txt +11 -3
- release.sh +26 -4
- vendor/autoload.php +2 -2
- vendor/composer/ClassLoader.php +13 -45
- vendor/composer/LICENSE +1 -1
- vendor/composer/autoload_psr4.php +1 -1
- vendor/composer/autoload_real.php +8 -8
- vendor/composer/autoload_static.php +6 -6
- vendor/composer/installed.json +179 -176
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php +1 -1
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ImageRule.php +24 -0
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/custom-html-ia.xml +5 -0
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/custom-html-rules.json +39 -0
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/custom.html +13 -0
- vendor/facebook/graph-sdk/src/Facebook/Authentication/OAuth2Client.php +1 -1
- vendor/facebook/graph-sdk/src/Facebook/Facebook.php +2 -2
- vendor/wp-coding-standards/wpcs/.travis.yml +58 -16
- vendor/wp-coding-standards/wpcs/CHANGELOG.md +71 -1
- vendor/wp-coding-standards/wpcs/README.md +26 -12
- vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml +306 -229
- vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml +4 -4
- vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml +24 -8
- vendor/wp-coding-standards/wpcs/WordPress-VIP/ruleset.xml +10 -10
- vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +10 -11
- vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php +22 -56
- vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php +26 -3
- vendor/wp-coding-standards/wpcs/WordPress/AbstractVariableRestrictionsSniff.php +25 -20
- vendor/wp-coding-standards/wpcs/WordPress/Sniff.php +503 -48
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php +6 -7
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php +8 -2
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +167 -188
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +479 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +17 -19
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php +280 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CSRF/NonceVerificationSniff.php +25 -10
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Classes/ClassInstantiationSniff.php +196 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php +138 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php +32 -23
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Functions/DontExtractSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Functions/FunctionCallSignatureNoParamsSniff.php +86 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Functions/FunctionRestrictionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +738 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +17 -13
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +2 -2
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +3 -3
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/YodaConditionsSniff.php +37 -23
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php +3 -6
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/CronIntervalSniff.php +2 -2
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php +4 -4
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/FileSystemWritesDisallowSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/PostsPerPageSniff.php +0 -11
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/RestrictedFunctionsSniff.php +5 -16
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/RestrictedVariablesSniff.php +8 -8
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/SessionFunctionsUsageSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php +10 -12
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/SlowDBQuerySniff.php +19 -11
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/TimezoneChangeSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php +5 -2
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Variables/GlobalVariablesSniff.php +9 -255
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Variables/VariableRestrictionsSniff.php +7 -7
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php +282 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +113 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +782 -566
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +345 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php +5 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +18 -17
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php +14 -15
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/PreparedSQLSniff.php +12 -5
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +10 -12
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +51 -59
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +105 -0
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php +25 -167
- vendor/wp-coding-standards/wpcs/WordPress/Sniffs/XSS/EscapeOutputSniff.php +95 -14
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayAssignmentRestrictionsUnitTest.php +1 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.inc +7 -2
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.inc.fixed +32 -32
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php +5 -3
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.1.inc +336 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.1.inc.fixed +336 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.2.inc +338 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.2.inc.fixed +338 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php +140 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.inc +155 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.inc.fixed +148 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php +72 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.1.inc +90 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.1.inc.fixed +90 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.2.inc +17 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.2.inc.fixed +17 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.js +4 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.js.fixed +4 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.php +98 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.inc +45 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.inc.fixed +40 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.php +47 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTest.php +15 -2
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/NonStrictClassNames/ClassNonStrictClass.inc +3 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/NonStrictClassNames/non-strict-class.inc +3 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/NonStrictClassNames/unrelated-filename.inc +3 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-custom-unit.inc +5 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-phpunit.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-phpunit6.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-wpunit.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/category-another_slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/category-slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/content-another_slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/content-slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/page-slug_slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/tag-another_slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/tag-slug.inc +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Functions/FunctionCallSignatureNoParamsUnitTest.inc +9 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Functions/FunctionCallSignatureNoParamsUnitTest.inc.fixed +9 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Functions/FunctionCallSignatureNoParamsUnitTest.php +40 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc +15 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.inc +301 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php +138 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/StrictComparisonsUnitTest.inc +11 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/StrictComparisonsUnitTest.php +3 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/YodaConditionsUnitTest.inc +36 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/YodaConditionsUnitTest.php +4 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/DirectDatabaseQueryUnitTest.inc +57 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/DirectDatabaseQueryUnitTest.php +4 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedFunctionsUnitTest.inc +4 -4
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedFunctionsUnitTest.php +0 -4
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedVariablesUnitTest.inc +10 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedVariablesUnitTest.php +6 -4
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/SlowDBQueryUnitTest.inc +2 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/SlowDBQueryUnitTest.php +1 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/ValidatedSanitizedInputUnitTest.inc +14 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/ValidatedSanitizedInputUnitTest.php +1 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Variables/GlobalVariablesUnitTest.inc +2 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/Variables/GlobalVariablesUnitTest.php +1 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.1.inc +10 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.inc +176 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed +176 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.php +74 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc +19 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedClassesUnitTest.php +38 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc +218 -144
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php +21 -2
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedParametersUnitTest.inc +66 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedParametersUnitTest.php +49 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/EnqueuedResourcesUnitTest.inc +22 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php +12 -13
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/I18nUnitTest.inc +23 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/I18nUnitTest.inc.fixed +23 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/I18nUnitTest.php +4 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/PreparedSQLUnitTest.inc +50 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/PreparedSQLUnitTest.php +21 -1
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php +7 -7
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc +57 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc.fixed +51 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +3 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.inc +39 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.inc.fixed +39 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php +60 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc +50 -39
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed +48 -37
- vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php +14 -4
- vendor/wp-coding-standards/wpcs/WordPress/Tests/XSS/EscapeOutputUnitTest.inc +20 -0
- vendor/wp-coding-standards/wpcs/WordPress/Tests/XSS/EscapeOutputUnitTest.php +4 -0
- vendor/wp-coding-standards/wpcs/WordPress/ruleset.xml +1 -1
- vendor/wp-coding-standards/wpcs/composer.json +8 -2
- vendor/wp-coding-standards/wpcs/phpcs.xml.dist.sample +95 -0
CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1 |
## Change Log
|
2 |
|
3 |
-
### 4.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
- [#708](https://github.com/automattic/facebook-instant-articles-wp/pull/708) Do not process non-post pages. Fixes #707 (@diegoquinteiro)
|
5 |
- [#709](https://github.com/automattic/facebook-instant-articles-wp/pull/709) Add cache layer for avoiding transforming the article at page render (@diegoquinteiro)
|
6 |
|
@@ -169,4 +176,4 @@
|
|
169 |
### 0.2 (2016/03/09 19:44 +00:00)
|
170 |
- [#41](https://github.com/automattic/facebook-instant-articles-wp/pull/41) Add support for subtitles through the filter instant_articles_subtitle (@bjornjohansen)
|
171 |
- [#39](https://github.com/automattic/facebook-instant-articles-wp/pull/39) Jetpack compat: YouTube and Facebook embeds (@bjornjohansen)
|
172 |
-
- [#22](https://github.com/automattic/facebook-instant-articles-wp/pull/22) Migrate the wpcom-helper.php from WordPress.com. (@philipjohn)
|
1 |
## Change Log
|
2 |
|
3 |
+
### 4.0.4 (2017/07/27 20:13 +00:00)
|
4 |
+
- [#738](https://github.com/automattic/facebook-instant-articles-wp/pull/738) Add changelog to script (@diegoquinteiro)
|
5 |
+
- [#737](https://github.com/automattic/facebook-instant-articles-wp/pull/737) Updates IA SDK to 1.6.2 and dependencies (@diegoquinteiro)
|
6 |
+
|
7 |
+
### 4.0.3 (2017/07/20 18:07 +00:00)
|
8 |
+
- [#725](https://github.com/automattic/facebook-instant-articles-wp/pull/725) Restore the $current_blog global and fix the post ID reference (@kasparsd)
|
9 |
+
|
10 |
+
### 4.0.2 (2017/06/30 19:36 +00:00)
|
11 |
- [#708](https://github.com/automattic/facebook-instant-articles-wp/pull/708) Do not process non-post pages. Fixes #707 (@diegoquinteiro)
|
12 |
- [#709](https://github.com/automattic/facebook-instant-articles-wp/pull/709) Add cache layer for avoiding transforming the article at page render (@diegoquinteiro)
|
13 |
|
176 |
### 0.2 (2016/03/09 19:44 +00:00)
|
177 |
- [#41](https://github.com/automattic/facebook-instant-articles-wp/pull/41) Add support for subtitles through the filter instant_articles_subtitle (@bjornjohansen)
|
178 |
- [#39](https://github.com/automattic/facebook-instant-articles-wp/pull/39) Jetpack compat: YouTube and Facebook embeds (@bjornjohansen)
|
179 |
+
- [#22](https://github.com/automattic/facebook-instant-articles-wp/pull/22) Migrate the wpcom-helper.php from WordPress.com. (@philipjohn)
|
facebook-instant-articles.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Description: Add support for Instant Articles for Facebook to your WordPress site.
|
5 |
* Author: Automattic, Dekode, Facebook
|
6 |
* Author URI: https://vip.wordpress.com/plugins/instant-articles/
|
7 |
-
* Version: 4.0.
|
8 |
* Text Domain: instant-articles
|
9 |
* License: GPLv2
|
10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -68,7 +68,7 @@ if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
|
|
68 |
|
69 |
defined( 'ABSPATH' ) || die( 'Shame on you' );
|
70 |
|
71 |
-
define( 'IA_PLUGIN_VERSION', '4.0.
|
72 |
define( 'IA_PLUGIN_PATH_FULL', __FILE__ );
|
73 |
define( 'IA_PLUGIN_PATH', plugin_basename( __FILE__ ) );
|
74 |
define( 'IA_PLUGIN_FILE_BASENAME', pathinfo( __FILE__, PATHINFO_FILENAME ) );
|
4 |
* Description: Add support for Instant Articles for Facebook to your WordPress site.
|
5 |
* Author: Automattic, Dekode, Facebook
|
6 |
* Author URI: https://vip.wordpress.com/plugins/instant-articles/
|
7 |
+
* Version: 4.0.4
|
8 |
* Text Domain: instant-articles
|
9 |
* License: GPLv2
|
10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
68 |
|
69 |
defined( 'ABSPATH' ) || die( 'Shame on you' );
|
70 |
|
71 |
+
define( 'IA_PLUGIN_VERSION', '4.0.4' );
|
72 |
define( 'IA_PLUGIN_PATH_FULL', __FILE__ );
|
73 |
define( 'IA_PLUGIN_PATH', plugin_basename( __FILE__ ) );
|
74 |
define( 'IA_PLUGIN_FILE_BASENAME', pathinfo( __FILE__, PATHINFO_FILENAME ) );
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: trrine, olethomas, bjornjohansen, dekode, automattic, facebook
|
|
3 |
Tags: instant articles, facebook, mobile
|
4 |
Requires at least: 4.3
|
5 |
Tested up to: 4.8
|
6 |
-
Stable tag: 4.0.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -84,8 +84,16 @@ Usually simply visiting the permalinks settings page in the WordPress dashboard
|
|
84 |
1. Customized transformer rules enabled on the main Settings page. The particular configuration shown here would cause `<u>` and `<bold>` tags in the source markup to be rendered in *italics* and **bold**, respectively, in the generated Instant Article.
|
85 |
|
86 |
== Changelog ==
|
|
|
87 |
|
88 |
-
### 4.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
- [#708](https://github.com/automattic/facebook-instant-articles-wp/pull/708) Do not process non-post pages. Fixes #707 (@diegoquinteiro)
|
90 |
- [#709](https://github.com/automattic/facebook-instant-articles-wp/pull/709) Add cache layer for avoiding transforming the article at page render (@diegoquinteiro)
|
91 |
|
@@ -254,4 +262,4 @@ Usually simply visiting the permalinks settings page in the WordPress dashboard
|
|
254 |
### 0.2 (2016/03/09 19:44 +00:00)
|
255 |
- [#41](https://github.com/automattic/facebook-instant-articles-wp/pull/41) Add support for subtitles through the filter instant_articles_subtitle (@bjornjohansen)
|
256 |
- [#39](https://github.com/automattic/facebook-instant-articles-wp/pull/39) Jetpack compat: YouTube and Facebook embeds (@bjornjohansen)
|
257 |
-
- [#22](https://github.com/automattic/facebook-instant-articles-wp/pull/22) Migrate the wpcom-helper.php from WordPress.com. (@philipjohn)
|
3 |
Tags: instant articles, facebook, mobile
|
4 |
Requires at least: 4.3
|
5 |
Tested up to: 4.8
|
6 |
+
Stable tag: 4.0.4
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
84 |
1. Customized transformer rules enabled on the main Settings page. The particular configuration shown here would cause `<u>` and `<bold>` tags in the source markup to be rendered in *italics* and **bold**, respectively, in the generated Instant Article.
|
85 |
|
86 |
== Changelog ==
|
87 |
+
## Change Log
|
88 |
|
89 |
+
### 4.0.4 (2017/07/27 20:13 +00:00)
|
90 |
+
- [#738](https://github.com/automattic/facebook-instant-articles-wp/pull/738) Add changelog to script (@diegoquinteiro)
|
91 |
+
- [#737](https://github.com/automattic/facebook-instant-articles-wp/pull/737) Updates IA SDK to 1.6.2 and dependencies (@diegoquinteiro)
|
92 |
+
|
93 |
+
### 4.0.3 (2017/07/20 18:07 +00:00)
|
94 |
+
- [#725](https://github.com/automattic/facebook-instant-articles-wp/pull/725) Restore the $current_blog global and fix the post ID reference (@kasparsd)
|
95 |
+
|
96 |
+
### 4.0.2 (2017/06/30 19:36 +00:00)
|
97 |
- [#708](https://github.com/automattic/facebook-instant-articles-wp/pull/708) Do not process non-post pages. Fixes #707 (@diegoquinteiro)
|
98 |
- [#709](https://github.com/automattic/facebook-instant-articles-wp/pull/709) Add cache layer for avoiding transforming the article at page render (@diegoquinteiro)
|
99 |
|
262 |
### 0.2 (2016/03/09 19:44 +00:00)
|
263 |
- [#41](https://github.com/automattic/facebook-instant-articles-wp/pull/41) Add support for subtitles through the filter instant_articles_subtitle (@bjornjohansen)
|
264 |
- [#39](https://github.com/automattic/facebook-instant-articles-wp/pull/39) Jetpack compat: YouTube and Facebook embeds (@bjornjohansen)
|
265 |
+
- [#22](https://github.com/automattic/facebook-instant-articles-wp/pull/22) Migrate the wpcom-helper.php from WordPress.com. (@philipjohn)
|
release.sh
CHANGED
@@ -25,7 +25,7 @@ ${green}Options:${reset}
|
|
25 |
-c <command> Runs only a single command. Possible commands are:
|
26 |
- bump_version: generate a new version tag on the repository
|
27 |
- release: release a new version on GitHub
|
28 |
-
- publish: publishes the target version to the WordPress
|
29 |
plugin repository
|
30 |
|
31 |
|
@@ -142,11 +142,18 @@ else
|
|
142 |
fi
|
143 |
|
144 |
if ! type "js" > /dev/null; then
|
145 |
-
error_message "SpiderMonkey interpreter not found, please install SpiderMonkey before continuing"
|
146 |
else
|
147 |
message "Found SpiderMonkey"
|
148 |
fi
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
#------------------------------------
|
151 |
# Check if we are in the right folder
|
152 |
#------------------------------------
|
@@ -279,6 +286,23 @@ function bump_version {
|
|
279 |
run git add facebook-instant-articles.php
|
280 |
run rm facebook-instant-articles.php-e
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
confirm "Commit version bump on master with message 'Bump version to $version'?"
|
283 |
run git commit -m "Bump version to $version"
|
284 |
|
@@ -370,7 +394,6 @@ function release {
|
|
370 |
|
371 |
message "Creating binary file"
|
372 |
run composer install
|
373 |
-
run composer update
|
374 |
run zip -qr facebook-instant-articles-wp.zip .
|
375 |
|
376 |
message "Uploading binary for release..."
|
@@ -424,7 +447,6 @@ function publish {
|
|
424 |
|
425 |
message "Updating composer dependencies"
|
426 |
run composer install
|
427 |
-
run composer update
|
428 |
|
429 |
message "Checking out SVN repository..."
|
430 |
run cd $tmp_dir
|
25 |
-c <command> Runs only a single command. Possible commands are:
|
26 |
- bump_version: generate a new version tag on the repository
|
27 |
- release: release a new version on GitHub
|
28 |
+
- publish: publishes the target version to the WordPress
|
29 |
plugin repository
|
30 |
|
31 |
|
142 |
fi
|
143 |
|
144 |
if ! type "js" > /dev/null; then
|
145 |
+
error_message "SpiderMonkey interpreter not found, please install SpiderMonkey before continuing: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey"
|
146 |
else
|
147 |
message "Found SpiderMonkey"
|
148 |
fi
|
149 |
|
150 |
+
|
151 |
+
if ! type "github-changes" > /dev/null; then
|
152 |
+
error_message "github-changes tool not found. Please run: npm install -g git-changes"
|
153 |
+
else
|
154 |
+
message "Found github-changes"
|
155 |
+
fi
|
156 |
+
|
157 |
#------------------------------------
|
158 |
# Check if we are in the right folder
|
159 |
#------------------------------------
|
286 |
run git add facebook-instant-articles.php
|
287 |
run rm facebook-instant-articles.php-e
|
288 |
|
289 |
+
confirm "Update CHANGELOG.md for $version?"
|
290 |
+
message "Updating CHANGELOG.md for $version"
|
291 |
+
run github-changes -o automattic -r facebook-instant-articles-wp -a --only-pulls --use-commit-body --tag-name $version
|
292 |
+
run git diff
|
293 |
+
confirm "Add changes to commit?"
|
294 |
+
run git add CHANGELOG.md
|
295 |
+
|
296 |
+
confirm "Update changelog on readme.txt?"
|
297 |
+
message "Updating changelog on readme.txt"
|
298 |
+
run sed '/== Changelog ==/q' ./readme.txt >> ./readme2.txt
|
299 |
+
run cat ./CHANGELOG.md >> ./readme2.txt
|
300 |
+
run rm ./readme.txt
|
301 |
+
run mv ./readme2.txt ./readme.txt
|
302 |
+
run git diff
|
303 |
+
confirm "Add changes to commit?"
|
304 |
+
run git add readme.txt
|
305 |
+
|
306 |
confirm "Commit version bump on master with message 'Bump version to $version'?"
|
307 |
run git commit -m "Bump version to $version"
|
308 |
|
394 |
|
395 |
message "Creating binary file"
|
396 |
run composer install
|
|
|
397 |
run zip -qr facebook-instant-articles-wp.zip .
|
398 |
|
399 |
message "Uploading binary for release..."
|
447 |
|
448 |
message "Updating composer dependencies"
|
449 |
run composer install
|
|
|
450 |
|
451 |
message "Checking out SVN repository..."
|
452 |
run cd $tmp_dir
|
vendor/autoload.php
CHANGED
@@ -2,6 +2,6 @@
|
|
2 |
|
3 |
// autoload.php @generated by Composer
|
4 |
|
5 |
-
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
2 |
|
3 |
// autoload.php @generated by Composer
|
4 |
|
5 |
+
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit36fdde57bb31390b63c9fa4f374d8837::getLoader();
|
vendor/composer/ClassLoader.php
CHANGED
@@ -53,9 +53,8 @@ class ClassLoader
|
|
53 |
|
54 |
private $useIncludePath = false;
|
55 |
private $classMap = array();
|
|
|
56 |
private $classMapAuthoritative = false;
|
57 |
-
private $missingClasses = array();
|
58 |
-
private $apcuPrefix;
|
59 |
|
60 |
public function getPrefixes()
|
61 |
{
|
@@ -272,26 +271,6 @@ class ClassLoader
|
|
272 |
return $this->classMapAuthoritative;
|
273 |
}
|
274 |
|
275 |
-
/**
|
276 |
-
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
277 |
-
*
|
278 |
-
* @param string|null $apcuPrefix
|
279 |
-
*/
|
280 |
-
public function setApcuPrefix($apcuPrefix)
|
281 |
-
{
|
282 |
-
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* The APCu prefix in use, or null if APCu caching is not enabled.
|
287 |
-
*
|
288 |
-
* @return string|null
|
289 |
-
*/
|
290 |
-
public function getApcuPrefix()
|
291 |
-
{
|
292 |
-
return $this->apcuPrefix;
|
293 |
-
}
|
294 |
-
|
295 |
/**
|
296 |
* Registers this instance as an autoloader.
|
297 |
*
|
@@ -334,34 +313,29 @@ class ClassLoader
|
|
334 |
*/
|
335 |
public function findFile($class)
|
336 |
{
|
|
|
|
|
|
|
|
|
|
|
337 |
// class map lookup
|
338 |
if (isset($this->classMap[$class])) {
|
339 |
return $this->classMap[$class];
|
340 |
}
|
341 |
-
if ($this->classMapAuthoritative
|
342 |
return false;
|
343 |
}
|
344 |
-
if (null !== $this->apcuPrefix) {
|
345 |
-
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
346 |
-
if ($hit) {
|
347 |
-
return $file;
|
348 |
-
}
|
349 |
-
}
|
350 |
|
351 |
$file = $this->findFileWithExtension($class, '.php');
|
352 |
|
353 |
// Search for Hack files if we are running on HHVM
|
354 |
-
if (
|
355 |
$file = $this->findFileWithExtension($class, '.hh');
|
356 |
}
|
357 |
|
358 |
-
if (
|
359 |
-
apcu_add($this->apcuPrefix.$class, $file);
|
360 |
-
}
|
361 |
-
|
362 |
-
if (false === $file) {
|
363 |
// Remember that this class does not exist.
|
364 |
-
$this->
|
365 |
}
|
366 |
|
367 |
return $file;
|
@@ -374,13 +348,9 @@ class ClassLoader
|
|
374 |
|
375 |
$first = $class[0];
|
376 |
if (isset($this->prefixLengthsPsr4[$first])) {
|
377 |
-
$
|
378 |
-
|
379 |
-
|
380 |
-
$search = $subPath.'\\';
|
381 |
-
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
-
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
383 |
-
$length = $this->prefixLengthsPsr4[$first][$search];
|
384 |
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
385 |
return $file;
|
386 |
}
|
@@ -429,8 +399,6 @@ class ClassLoader
|
|
429 |
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
430 |
return $file;
|
431 |
}
|
432 |
-
|
433 |
-
return false;
|
434 |
}
|
435 |
}
|
436 |
|
53 |
|
54 |
private $useIncludePath = false;
|
55 |
private $classMap = array();
|
56 |
+
|
57 |
private $classMapAuthoritative = false;
|
|
|
|
|
58 |
|
59 |
public function getPrefixes()
|
60 |
{
|
271 |
return $this->classMapAuthoritative;
|
272 |
}
|
273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
/**
|
275 |
* Registers this instance as an autoloader.
|
276 |
*
|
313 |
*/
|
314 |
public function findFile($class)
|
315 |
{
|
316 |
+
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
317 |
+
if ('\\' == $class[0]) {
|
318 |
+
$class = substr($class, 1);
|
319 |
+
}
|
320 |
+
|
321 |
// class map lookup
|
322 |
if (isset($this->classMap[$class])) {
|
323 |
return $this->classMap[$class];
|
324 |
}
|
325 |
+
if ($this->classMapAuthoritative) {
|
326 |
return false;
|
327 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
$file = $this->findFileWithExtension($class, '.php');
|
330 |
|
331 |
// Search for Hack files if we are running on HHVM
|
332 |
+
if ($file === null && defined('HHVM_VERSION')) {
|
333 |
$file = $this->findFileWithExtension($class, '.hh');
|
334 |
}
|
335 |
|
336 |
+
if ($file === null) {
|
|
|
|
|
|
|
|
|
337 |
// Remember that this class does not exist.
|
338 |
+
return $this->classMap[$class] = false;
|
339 |
}
|
340 |
|
341 |
return $file;
|
348 |
|
349 |
$first = $class[0];
|
350 |
if (isset($this->prefixLengthsPsr4[$first])) {
|
351 |
+
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
352 |
+
if (0 === strpos($class, $prefix)) {
|
353 |
+
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
|
|
|
|
|
|
|
|
354 |
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
355 |
return $file;
|
356 |
}
|
399 |
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
400 |
return $file;
|
401 |
}
|
|
|
|
|
402 |
}
|
403 |
}
|
404 |
|
vendor/composer/LICENSE
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
|
2 |
-
Copyright (c) Nils Adermann, Jordi Boggiano
|
3 |
|
4 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
of this software and associated documentation files (the "Software"), to deal
|
1 |
|
2 |
+
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
|
3 |
|
4 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
of this software and associated documentation files (the "Software"), to deal
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -7,6 +7,6 @@ $baseDir = dirname($vendorDir);
|
|
7 |
|
8 |
return array(
|
9 |
'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
|
10 |
-
'Facebook\\InstantArticles\\' => array($vendorDir . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles', $vendorDir . '/facebook/facebook-instant-articles-sdk-
|
11 |
'Facebook\\' => array($vendorDir . '/facebook/graph-sdk/src/Facebook'),
|
12 |
);
|
7 |
|
8 |
return array(
|
9 |
'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
|
10 |
+
'Facebook\\InstantArticles\\' => array($vendorDir . '/facebook/facebook-instant-articles-sdk-extensions-in-php/src/Facebook/InstantArticles', $vendorDir . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles'),
|
11 |
'Facebook\\' => array($vendorDir . '/facebook/graph-sdk/src/Facebook'),
|
12 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitf36cb54df1aca911ac0e2796769910db
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
-
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitf36cb54df1aca911ac0e2796769910db
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit36fdde57bb31390b63c9fa4f374d8837
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit36fdde57bb31390b63c9fa4f374d8837', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit36fdde57bb31390b63c9fa4f374d8837', 'loadClassLoader'));
|
25 |
|
26 |
+
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit36fdde57bb31390b63c9fa4f374d8837::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit36fdde57bb31390b63c9fa4f374d8837::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequire36fdde57bb31390b63c9fa4f374d8837($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequire36fdde57bb31390b63c9fa4f374d8837($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'c65d09b6820da036953a371c8c73a9b1' => __DIR__ . '/..' . '/facebook/graph-sdk/src/Facebook/polyfills.php',
|
@@ -29,8 +29,8 @@ class ComposerStaticInitf36cb54df1aca911ac0e2796769910db
|
|
29 |
),
|
30 |
'Facebook\\InstantArticles\\' =>
|
31 |
array (
|
32 |
-
0 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles',
|
33 |
-
1 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-
|
34 |
),
|
35 |
'Facebook\\' =>
|
36 |
array (
|
@@ -375,9 +375,9 @@ class ComposerStaticInitf36cb54df1aca911ac0e2796769910db
|
|
375 |
public static function getInitializer(ClassLoader $loader)
|
376 |
{
|
377 |
return \Closure::bind(function () use ($loader) {
|
378 |
-
$loader->prefixLengthsPsr4 =
|
379 |
-
$loader->prefixDirsPsr4 =
|
380 |
-
$loader->classMap =
|
381 |
|
382 |
}, null, ClassLoader::class);
|
383 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit36fdde57bb31390b63c9fa4f374d8837
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'c65d09b6820da036953a371c8c73a9b1' => __DIR__ . '/..' . '/facebook/graph-sdk/src/Facebook/polyfills.php',
|
29 |
),
|
30 |
'Facebook\\InstantArticles\\' =>
|
31 |
array (
|
32 |
+
0 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-extensions-in-php/src/Facebook/InstantArticles',
|
33 |
+
1 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles',
|
34 |
),
|
35 |
'Facebook\\' =>
|
36 |
array (
|
375 |
public static function getInitializer(ClassLoader $loader)
|
376 |
{
|
377 |
return \Closure::bind(function () use ($loader) {
|
378 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit36fdde57bb31390b63c9fa4f374d8837::$prefixLengthsPsr4;
|
379 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit36fdde57bb31390b63c9fa4f374d8837::$prefixDirsPsr4;
|
380 |
+
$loader->classMap = ComposerStaticInit36fdde57bb31390b63c9fa4f374d8837::$classMap;
|
381 |
|
382 |
}, null, ClassLoader::class);
|
383 |
}
|
vendor/composer/installed.json
CHANGED
@@ -1,64 +1,4 @@
|
|
1 |
[
|
2 |
-
{
|
3 |
-
"name": "facebook/graph-sdk",
|
4 |
-
"version": "5.5.0",
|
5 |
-
"version_normalized": "5.5.0.0",
|
6 |
-
"source": {
|
7 |
-
"type": "git",
|
8 |
-
"url": "https://github.com/facebook/php-graph-sdk.git",
|
9 |
-
"reference": "93d7dc87e55a541d2e27d38f3aed40abbffdf6e1"
|
10 |
-
},
|
11 |
-
"dist": {
|
12 |
-
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/facebook/php-graph-sdk/zipball/93d7dc87e55a541d2e27d38f3aed40abbffdf6e1",
|
14 |
-
"reference": "93d7dc87e55a541d2e27d38f3aed40abbffdf6e1",
|
15 |
-
"shasum": ""
|
16 |
-
},
|
17 |
-
"require": {
|
18 |
-
"php": "^5.4|^7.0"
|
19 |
-
},
|
20 |
-
"require-dev": {
|
21 |
-
"guzzlehttp/guzzle": "~5.0",
|
22 |
-
"mockery/mockery": "~0.8",
|
23 |
-
"phpunit/phpunit": "~4.0"
|
24 |
-
},
|
25 |
-
"suggest": {
|
26 |
-
"guzzlehttp/guzzle": "Allows for implementation of the Guzzle HTTP client",
|
27 |
-
"paragonie/random_compat": "Provides a better CSPRNG option in PHP 5"
|
28 |
-
},
|
29 |
-
"time": "2017-04-20T14:15:02+00:00",
|
30 |
-
"type": "library",
|
31 |
-
"extra": {
|
32 |
-
"branch-alias": {
|
33 |
-
"dev-master": "5.x-dev"
|
34 |
-
}
|
35 |
-
},
|
36 |
-
"installation-source": "dist",
|
37 |
-
"autoload": {
|
38 |
-
"psr-4": {
|
39 |
-
"Facebook\\": "src/Facebook/"
|
40 |
-
},
|
41 |
-
"files": [
|
42 |
-
"src/Facebook/polyfills.php"
|
43 |
-
]
|
44 |
-
},
|
45 |
-
"notification-url": "https://packagist.org/downloads/",
|
46 |
-
"license": [
|
47 |
-
"Facebook Platform"
|
48 |
-
],
|
49 |
-
"authors": [
|
50 |
-
{
|
51 |
-
"name": "Facebook",
|
52 |
-
"homepage": "https://github.com/facebook/php-graph-sdk/contributors"
|
53 |
-
}
|
54 |
-
],
|
55 |
-
"description": "Facebook SDK for PHP",
|
56 |
-
"homepage": "https://github.com/facebook/php-graph-sdk",
|
57 |
-
"keywords": [
|
58 |
-
"facebook",
|
59 |
-
"sdk"
|
60 |
-
]
|
61 |
-
},
|
62 |
{
|
63 |
"name": "apache/log4php",
|
64 |
"version": "2.3.0",
|
@@ -71,7 +11,7 @@
|
|
71 |
"require": {
|
72 |
"php": ">=5.2.7"
|
73 |
},
|
74 |
-
"time": "2012-10-
|
75 |
"type": "library",
|
76 |
"installation-source": "source",
|
77 |
"autoload": {
|
@@ -92,56 +32,83 @@
|
|
92 |
]
|
93 |
},
|
94 |
{
|
95 |
-
"name": "
|
96 |
-
"version": "
|
97 |
-
"version_normalized": "
|
98 |
"source": {
|
99 |
"type": "git",
|
100 |
-
"url": "https://github.com/
|
101 |
-
"reference": "
|
102 |
},
|
103 |
"dist": {
|
104 |
"type": "zip",
|
105 |
-
"url": "https://api.github.com/repos/
|
106 |
-
"reference": "
|
107 |
"shasum": ""
|
108 |
},
|
109 |
"require": {
|
110 |
-
"
|
111 |
-
"
|
112 |
-
"
|
113 |
-
"
|
114 |
},
|
115 |
"require-dev": {
|
116 |
-
"
|
117 |
-
"phpunit/phpunit": "^4.8",
|
118 |
-
"squizlabs/php_codesniffer": "^2.6.0"
|
119 |
},
|
120 |
-
"time": "2017-
|
|
|
|
|
|
|
|
|
121 |
"type": "library",
|
|
|
|
|
|
|
|
|
|
|
122 |
"installation-source": "dist",
|
123 |
"autoload": {
|
124 |
-
"
|
125 |
-
"
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
},
|
128 |
"notification-url": "https://packagist.org/downloads/",
|
129 |
"license": [
|
130 |
-
"
|
131 |
],
|
132 |
"authors": [
|
133 |
{
|
134 |
-
"name": "
|
135 |
-
"
|
136 |
}
|
137 |
],
|
138 |
-
"description": "
|
139 |
-
"homepage": "
|
140 |
"keywords": [
|
141 |
-
"
|
142 |
-
"
|
143 |
-
"instant",
|
144 |
-
"sdk"
|
145 |
]
|
146 |
},
|
147 |
{
|
@@ -166,7 +133,7 @@
|
|
166 |
"require-dev": {
|
167 |
"phpunit/phpunit": "^4.8"
|
168 |
},
|
169 |
-
"time": "2017-06-
|
170 |
"type": "library",
|
171 |
"installation-source": "dist",
|
172 |
"autoload": {
|
@@ -197,121 +164,63 @@
|
|
197 |
]
|
198 |
},
|
199 |
{
|
200 |
-
"name": "
|
201 |
-
"version": "
|
202 |
-
"version_normalized": "
|
203 |
"source": {
|
204 |
"type": "git",
|
205 |
-
"url": "https://github.com/
|
206 |
-
"reference": "
|
207 |
},
|
208 |
"dist": {
|
209 |
"type": "zip",
|
210 |
-
"url": "https://api.github.com/repos/
|
211 |
-
"reference": "
|
212 |
"shasum": ""
|
213 |
},
|
214 |
"require": {
|
215 |
-
"
|
216 |
-
"ext-tokenizer": "*",
|
217 |
-
"ext-xmlwriter": "*",
|
218 |
-
"php": ">=5.1.2"
|
219 |
},
|
220 |
"require-dev": {
|
|
|
|
|
221 |
"phpunit/phpunit": "~4.0"
|
222 |
},
|
223 |
-
"
|
224 |
-
|
225 |
-
"
|
226 |
-
|
227 |
-
|
228 |
"type": "library",
|
229 |
"extra": {
|
230 |
"branch-alias": {
|
231 |
-
"dev-master": "
|
232 |
}
|
233 |
},
|
234 |
"installation-source": "dist",
|
235 |
"autoload": {
|
236 |
-
"
|
237 |
-
"
|
238 |
-
|
239 |
-
|
240 |
-
"
|
241 |
-
"CodeSniffer/Fixer.php",
|
242 |
-
"CodeSniffer/Report.php",
|
243 |
-
"CodeSniffer/Reporting.php",
|
244 |
-
"CodeSniffer/Sniff.php",
|
245 |
-
"CodeSniffer/Tokens.php",
|
246 |
-
"CodeSniffer/Reports/",
|
247 |
-
"CodeSniffer/Tokenizers/",
|
248 |
-
"CodeSniffer/DocGenerators/",
|
249 |
-
"CodeSniffer/Standards/AbstractPatternSniff.php",
|
250 |
-
"CodeSniffer/Standards/AbstractScopeSniff.php",
|
251 |
-
"CodeSniffer/Standards/AbstractVariableSniff.php",
|
252 |
-
"CodeSniffer/Standards/IncorrectPatternException.php",
|
253 |
-
"CodeSniffer/Standards/Generic/Sniffs/",
|
254 |
-
"CodeSniffer/Standards/MySource/Sniffs/",
|
255 |
-
"CodeSniffer/Standards/PEAR/Sniffs/",
|
256 |
-
"CodeSniffer/Standards/PSR1/Sniffs/",
|
257 |
-
"CodeSniffer/Standards/PSR2/Sniffs/",
|
258 |
-
"CodeSniffer/Standards/Squiz/Sniffs/",
|
259 |
-
"CodeSniffer/Standards/Zend/Sniffs/"
|
260 |
]
|
261 |
},
|
262 |
"notification-url": "https://packagist.org/downloads/",
|
263 |
"license": [
|
264 |
-
"
|
265 |
-
],
|
266 |
-
"authors": [
|
267 |
-
{
|
268 |
-
"name": "Greg Sherwood",
|
269 |
-
"role": "lead"
|
270 |
-
}
|
271 |
-
],
|
272 |
-
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
273 |
-
"homepage": "http://www.squizlabs.com/php-codesniffer",
|
274 |
-
"keywords": [
|
275 |
-
"phpcs",
|
276 |
-
"standards"
|
277 |
-
]
|
278 |
-
},
|
279 |
-
{
|
280 |
-
"name": "wp-coding-standards/wpcs",
|
281 |
-
"version": "0.11.0",
|
282 |
-
"version_normalized": "0.11.0.0",
|
283 |
-
"source": {
|
284 |
-
"type": "git",
|
285 |
-
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
|
286 |
-
"reference": "407e4b85f547a5251185f89ceae6599917343388"
|
287 |
-
},
|
288 |
-
"dist": {
|
289 |
-
"type": "zip",
|
290 |
-
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/407e4b85f547a5251185f89ceae6599917343388",
|
291 |
-
"reference": "407e4b85f547a5251185f89ceae6599917343388",
|
292 |
-
"shasum": ""
|
293 |
-
},
|
294 |
-
"require": {
|
295 |
-
"squizlabs/php_codesniffer": "^2.8.1"
|
296 |
-
},
|
297 |
-
"time": "2017-03-20T23:17:58+00:00",
|
298 |
-
"type": "library",
|
299 |
-
"installation-source": "dist",
|
300 |
-
"notification-url": "https://packagist.org/downloads/",
|
301 |
-
"license": [
|
302 |
-
"MIT"
|
303 |
],
|
304 |
"authors": [
|
305 |
{
|
306 |
-
"name": "
|
307 |
-
"homepage": "https://github.com/
|
308 |
}
|
309 |
],
|
310 |
-
"description": "
|
|
|
311 |
"keywords": [
|
312 |
-
"
|
313 |
-
"
|
314 |
-
"wordpress"
|
315 |
]
|
316 |
},
|
317 |
{
|
@@ -332,7 +241,7 @@
|
|
332 |
"require": {
|
333 |
"php": ">=5.3.9"
|
334 |
},
|
335 |
-
"time": "2017-05-
|
336 |
"type": "library",
|
337 |
"extra": {
|
338 |
"branch-alias": {
|
@@ -368,5 +277,99 @@
|
|
368 |
],
|
369 |
"description": "Symfony CssSelector Component",
|
370 |
"homepage": "https://symfony.com"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
]
|
1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
{
|
3 |
"name": "apache/log4php",
|
4 |
"version": "2.3.0",
|
11 |
"require": {
|
12 |
"php": ">=5.2.7"
|
13 |
},
|
14 |
+
"time": "2012-10-26 09:13:25",
|
15 |
"type": "library",
|
16 |
"installation-source": "source",
|
17 |
"autoload": {
|
32 |
]
|
33 |
},
|
34 |
{
|
35 |
+
"name": "squizlabs/php_codesniffer",
|
36 |
+
"version": "2.9.1",
|
37 |
+
"version_normalized": "2.9.1.0",
|
38 |
"source": {
|
39 |
"type": "git",
|
40 |
+
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
41 |
+
"reference": "dcbed1074f8244661eecddfc2a675430d8d33f62"
|
42 |
},
|
43 |
"dist": {
|
44 |
"type": "zip",
|
45 |
+
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62",
|
46 |
+
"reference": "dcbed1074f8244661eecddfc2a675430d8d33f62",
|
47 |
"shasum": ""
|
48 |
},
|
49 |
"require": {
|
50 |
+
"ext-simplexml": "*",
|
51 |
+
"ext-tokenizer": "*",
|
52 |
+
"ext-xmlwriter": "*",
|
53 |
+
"php": ">=5.1.2"
|
54 |
},
|
55 |
"require-dev": {
|
56 |
+
"phpunit/phpunit": "~4.0"
|
|
|
|
|
57 |
},
|
58 |
+
"time": "2017-05-22 02:43:20",
|
59 |
+
"bin": [
|
60 |
+
"scripts/phpcs",
|
61 |
+
"scripts/phpcbf"
|
62 |
+
],
|
63 |
"type": "library",
|
64 |
+
"extra": {
|
65 |
+
"branch-alias": {
|
66 |
+
"dev-master": "2.x-dev"
|
67 |
+
}
|
68 |
+
},
|
69 |
"installation-source": "dist",
|
70 |
"autoload": {
|
71 |
+
"classmap": [
|
72 |
+
"CodeSniffer.php",
|
73 |
+
"CodeSniffer/CLI.php",
|
74 |
+
"CodeSniffer/Exception.php",
|
75 |
+
"CodeSniffer/File.php",
|
76 |
+
"CodeSniffer/Fixer.php",
|
77 |
+
"CodeSniffer/Report.php",
|
78 |
+
"CodeSniffer/Reporting.php",
|
79 |
+
"CodeSniffer/Sniff.php",
|
80 |
+
"CodeSniffer/Tokens.php",
|
81 |
+
"CodeSniffer/Reports/",
|
82 |
+
"CodeSniffer/Tokenizers/",
|
83 |
+
"CodeSniffer/DocGenerators/",
|
84 |
+
"CodeSniffer/Standards/AbstractPatternSniff.php",
|
85 |
+
"CodeSniffer/Standards/AbstractScopeSniff.php",
|
86 |
+
"CodeSniffer/Standards/AbstractVariableSniff.php",
|
87 |
+
"CodeSniffer/Standards/IncorrectPatternException.php",
|
88 |
+
"CodeSniffer/Standards/Generic/Sniffs/",
|
89 |
+
"CodeSniffer/Standards/MySource/Sniffs/",
|
90 |
+
"CodeSniffer/Standards/PEAR/Sniffs/",
|
91 |
+
"CodeSniffer/Standards/PSR1/Sniffs/",
|
92 |
+
"CodeSniffer/Standards/PSR2/Sniffs/",
|
93 |
+
"CodeSniffer/Standards/Squiz/Sniffs/",
|
94 |
+
"CodeSniffer/Standards/Zend/Sniffs/"
|
95 |
+
]
|
96 |
},
|
97 |
"notification-url": "https://packagist.org/downloads/",
|
98 |
"license": [
|
99 |
+
"BSD-3-Clause"
|
100 |
],
|
101 |
"authors": [
|
102 |
{
|
103 |
+
"name": "Greg Sherwood",
|
104 |
+
"role": "lead"
|
105 |
}
|
106 |
],
|
107 |
+
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
108 |
+
"homepage": "http://www.squizlabs.com/php-codesniffer",
|
109 |
"keywords": [
|
110 |
+
"phpcs",
|
111 |
+
"standards"
|
|
|
|
|
112 |
]
|
113 |
},
|
114 |
{
|
133 |
"require-dev": {
|
134 |
"phpunit/phpunit": "^4.8"
|
135 |
},
|
136 |
+
"time": "2017-06-26 19:59:19",
|
137 |
"type": "library",
|
138 |
"installation-source": "dist",
|
139 |
"autoload": {
|
164 |
]
|
165 |
},
|
166 |
{
|
167 |
+
"name": "facebook/graph-sdk",
|
168 |
+
"version": "5.6.0",
|
169 |
+
"version_normalized": "5.6.0.0",
|
170 |
"source": {
|
171 |
"type": "git",
|
172 |
+
"url": "https://github.com/facebook/php-graph-sdk.git",
|
173 |
+
"reference": "34f5e5993c67acd264017373f23848961585dcac"
|
174 |
},
|
175 |
"dist": {
|
176 |
"type": "zip",
|
177 |
+
"url": "https://api.github.com/repos/facebook/php-graph-sdk/zipball/34f5e5993c67acd264017373f23848961585dcac",
|
178 |
+
"reference": "34f5e5993c67acd264017373f23848961585dcac",
|
179 |
"shasum": ""
|
180 |
},
|
181 |
"require": {
|
182 |
+
"php": "^5.4|^7.0"
|
|
|
|
|
|
|
183 |
},
|
184 |
"require-dev": {
|
185 |
+
"guzzlehttp/guzzle": "~5.0",
|
186 |
+
"mockery/mockery": "~0.8",
|
187 |
"phpunit/phpunit": "~4.0"
|
188 |
},
|
189 |
+
"suggest": {
|
190 |
+
"guzzlehttp/guzzle": "Allows for implementation of the Guzzle HTTP client",
|
191 |
+
"paragonie/random_compat": "Provides a better CSPRNG option in PHP 5"
|
192 |
+
},
|
193 |
+
"time": "2017-07-23 14:06:52",
|
194 |
"type": "library",
|
195 |
"extra": {
|
196 |
"branch-alias": {
|
197 |
+
"dev-master": "5.x-dev"
|
198 |
}
|
199 |
},
|
200 |
"installation-source": "dist",
|
201 |
"autoload": {
|
202 |
+
"psr-4": {
|
203 |
+
"Facebook\\": "src/Facebook/"
|
204 |
+
},
|
205 |
+
"files": [
|
206 |
+
"src/Facebook/polyfills.php"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
]
|
208 |
},
|
209 |
"notification-url": "https://packagist.org/downloads/",
|
210 |
"license": [
|
211 |
+
"Facebook Platform"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
],
|
213 |
"authors": [
|
214 |
{
|
215 |
+
"name": "Facebook",
|
216 |
+
"homepage": "https://github.com/facebook/php-graph-sdk/contributors"
|
217 |
}
|
218 |
],
|
219 |
+
"description": "Facebook SDK for PHP",
|
220 |
+
"homepage": "https://github.com/facebook/php-graph-sdk",
|
221 |
"keywords": [
|
222 |
+
"facebook",
|
223 |
+
"sdk"
|
|
|
224 |
]
|
225 |
},
|
226 |
{
|
241 |
"require": {
|
242 |
"php": ">=5.3.9"
|
243 |
},
|
244 |
+
"time": "2017-05-01 14:31:55",
|
245 |
"type": "library",
|
246 |
"extra": {
|
247 |
"branch-alias": {
|
277 |
],
|
278 |
"description": "Symfony CssSelector Component",
|
279 |
"homepage": "https://symfony.com"
|
280 |
+
},
|
281 |
+
{
|
282 |
+
"name": "facebook/facebook-instant-articles-sdk-php",
|
283 |
+
"version": "v1.6.2",
|
284 |
+
"version_normalized": "1.6.2.0",
|
285 |
+
"source": {
|
286 |
+
"type": "git",
|
287 |
+
"url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
|
288 |
+
"reference": "f18461923e17af6f05120c687c9f20a540f3d420"
|
289 |
+
},
|
290 |
+
"dist": {
|
291 |
+
"type": "zip",
|
292 |
+
"url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/f18461923e17af6f05120c687c9f20a540f3d420",
|
293 |
+
"reference": "f18461923e17af6f05120c687c9f20a540f3d420",
|
294 |
+
"shasum": ""
|
295 |
+
},
|
296 |
+
"require": {
|
297 |
+
"apache/log4php": "2.3.0",
|
298 |
+
"facebook/graph-sdk": "~5.0",
|
299 |
+
"php": "^5.4 || ^7.0",
|
300 |
+
"symfony/css-selector": "2.8.* || ^3.0"
|
301 |
+
},
|
302 |
+
"require-dev": {
|
303 |
+
"fzaninotto/faker": "^1.6.0",
|
304 |
+
"phpunit/phpunit": "^4.8",
|
305 |
+
"squizlabs/php_codesniffer": "^2.6.0"
|
306 |
+
},
|
307 |
+
"time": "2017-07-27 19:19:51",
|
308 |
+
"type": "library",
|
309 |
+
"installation-source": "dist",
|
310 |
+
"autoload": {
|
311 |
+
"psr-4": {
|
312 |
+
"Facebook\\InstantArticles\\": "src/Facebook/InstantArticles/"
|
313 |
+
}
|
314 |
+
},
|
315 |
+
"notification-url": "https://packagist.org/downloads/",
|
316 |
+
"license": [
|
317 |
+
"proprietary"
|
318 |
+
],
|
319 |
+
"authors": [
|
320 |
+
{
|
321 |
+
"name": "Facebook",
|
322 |
+
"homepage": "https://github.com/facebook/facebook-instant-articles-sdk-php/contributors"
|
323 |
+
}
|
324 |
+
],
|
325 |
+
"description": "Facebook Instant Articles SDK for PHP",
|
326 |
+
"homepage": "https://github.com/facebook/facebook-instant-articles-sdk-php",
|
327 |
+
"keywords": [
|
328 |
+
"articles",
|
329 |
+
"facebook",
|
330 |
+
"instant",
|
331 |
+
"sdk"
|
332 |
+
]
|
333 |
+
},
|
334 |
+
{
|
335 |
+
"name": "wp-coding-standards/wpcs",
|
336 |
+
"version": "0.12.0",
|
337 |
+
"version_normalized": "0.12.0.0",
|
338 |
+
"source": {
|
339 |
+
"type": "git",
|
340 |
+
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
|
341 |
+
"reference": "300c15796584d6b63f31841daf674886303af573"
|
342 |
+
},
|
343 |
+
"dist": {
|
344 |
+
"type": "zip",
|
345 |
+
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/300c15796584d6b63f31841daf674886303af573",
|
346 |
+
"reference": "300c15796584d6b63f31841daf674886303af573",
|
347 |
+
"shasum": ""
|
348 |
+
},
|
349 |
+
"require": {
|
350 |
+
"squizlabs/php_codesniffer": "^2.9.0"
|
351 |
+
},
|
352 |
+
"suggest": {
|
353 |
+
"dealerdirect/phpcodesniffer-composer-installer": "*"
|
354 |
+
},
|
355 |
+
"time": "2017-07-20 20:11:03",
|
356 |
+
"type": "phpcodesniffer-standard",
|
357 |
+
"installation-source": "dist",
|
358 |
+
"notification-url": "https://packagist.org/downloads/",
|
359 |
+
"license": [
|
360 |
+
"MIT"
|
361 |
+
],
|
362 |
+
"authors": [
|
363 |
+
{
|
364 |
+
"name": "Contributors",
|
365 |
+
"homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
|
366 |
+
}
|
367 |
+
],
|
368 |
+
"description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
|
369 |
+
"keywords": [
|
370 |
+
"phpcs",
|
371 |
+
"standards",
|
372 |
+
"wordpress"
|
373 |
+
]
|
374 |
}
|
375 |
]
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php
CHANGED
@@ -34,7 +34,7 @@ use Facebook\InstantArticles\Validators\Type;
|
|
34 |
|
35 |
class InstantArticle extends Element implements Container, InstantArticleInterface
|
36 |
{
|
37 |
-
const CURRENT_VERSION = '1.6.
|
38 |
|
39 |
/**
|
40 |
* The meta properties that are used on <head>
|
34 |
|
35 |
class InstantArticle extends Element implements Container, InstantArticleInterface
|
36 |
{
|
37 |
+
const CURRENT_VERSION = '1.6.2';
|
38 |
|
39 |
/**
|
40 |
* The meta properties that are used on <head>
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ImageRule.php
CHANGED
@@ -9,6 +9,8 @@
|
|
9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
10 |
|
11 |
use Facebook\InstantArticles\Elements\Image;
|
|
|
|
|
12 |
use Facebook\InstantArticles\Elements\Paragraph;
|
13 |
use Facebook\InstantArticles\Elements\InstantArticle;
|
14 |
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
@@ -19,12 +21,15 @@ class ImageRule extends ConfigurationSelectorRule
|
|
19 |
const PROPERTY_IMAGE_URL = 'image.url';
|
20 |
const PROPERTY_LIKE = 'image.like';
|
21 |
const PROPERTY_COMMENTS = 'image.comments';
|
|
|
|
|
22 |
|
23 |
const ASPECT_FIT = 'aspect-fit';
|
24 |
const ASPECT_FIT_ONLY = 'aspect-fit-only';
|
25 |
const FULLSCREEN = 'fullscreen';
|
26 |
const NON_INTERACTIVE = 'non-interactive';
|
27 |
|
|
|
28 |
public function getContextClass()
|
29 |
{
|
30 |
return
|
@@ -49,6 +54,8 @@ class ImageRule extends ConfigurationSelectorRule
|
|
49 |
self::PROPERTY_IMAGE_URL,
|
50 |
self::PROPERTY_LIKE,
|
51 |
self::PROPERTY_COMMENTS,
|
|
|
|
|
52 |
self::ASPECT_FIT,
|
53 |
self::ASPECT_FIT_ONLY,
|
54 |
self::FULLSCREEN,
|
@@ -117,6 +124,23 @@ class ImageRule extends ConfigurationSelectorRule
|
|
117 |
$image->enableComments();
|
118 |
}
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
$suppress_warnings = $transformer->suppress_warnings;
|
121 |
$transformer->suppress_warnings = true;
|
122 |
$transformer->transform($image, $node);
|
9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
10 |
|
11 |
use Facebook\InstantArticles\Elements\Image;
|
12 |
+
use Facebook\InstantArticles\Elements\Caption;
|
13 |
+
use Facebook\InstantArticles\Elements\Cite;
|
14 |
use Facebook\InstantArticles\Elements\Paragraph;
|
15 |
use Facebook\InstantArticles\Elements\InstantArticle;
|
16 |
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
21 |
const PROPERTY_IMAGE_URL = 'image.url';
|
22 |
const PROPERTY_LIKE = 'image.like';
|
23 |
const PROPERTY_COMMENTS = 'image.comments';
|
24 |
+
const PROPERTY_CREDIT = 'image.credit';
|
25 |
+
const PROPERTY_CAPTION = 'image.caption';
|
26 |
|
27 |
const ASPECT_FIT = 'aspect-fit';
|
28 |
const ASPECT_FIT_ONLY = 'aspect-fit-only';
|
29 |
const FULLSCREEN = 'fullscreen';
|
30 |
const NON_INTERACTIVE = 'non-interactive';
|
31 |
|
32 |
+
|
33 |
public function getContextClass()
|
34 |
{
|
35 |
return
|
54 |
self::PROPERTY_IMAGE_URL,
|
55 |
self::PROPERTY_LIKE,
|
56 |
self::PROPERTY_COMMENTS,
|
57 |
+
self::PROPERTY_CREDIT,
|
58 |
+
self::PROPERTY_CAPTION,
|
59 |
self::ASPECT_FIT,
|
60 |
self::ASPECT_FIT_ONLY,
|
61 |
self::FULLSCREEN,
|
124 |
$image->enableComments();
|
125 |
}
|
126 |
|
127 |
+
$caption = null;
|
128 |
+
if ($this->getProperty(self::PROPERTY_CAPTION, $node)) {
|
129 |
+
$caption = Caption::create();
|
130 |
+
$transformer->transform($caption, $this->getProperty(self::PROPERTY_CAPTION, $node));
|
131 |
+
}
|
132 |
+
if ($this->getProperty(self::PROPERTY_CREDIT, $node)) {
|
133 |
+
if ($caption === null) {
|
134 |
+
$caption = Caption::create();
|
135 |
+
}
|
136 |
+
$credit = Cite::create();
|
137 |
+
$transformer->transform($credit, $this->getProperty(self::PROPERTY_CREDIT, $node));
|
138 |
+
$caption->withCredit($credit);
|
139 |
+
}
|
140 |
+
if ($caption !== null) {
|
141 |
+
$image->withCaption($caption);
|
142 |
+
}
|
143 |
+
|
144 |
$suppress_warnings = $transformer->suppress_warnings;
|
145 |
$transformer->suppress_warnings = true;
|
146 |
$transformer->transform($image, $node);
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/custom-html-ia.xml
CHANGED
@@ -197,6 +197,11 @@
|
|
197 |
<img src="http://example.com/image.jpg"/>
|
198 |
<figcaption>caption</figcaption>
|
199 |
</figure>
|
|
|
|
|
|
|
|
|
|
|
200 |
</article>
|
201 |
</body>
|
202 |
</html>
|
197 |
<img src="http://example.com/image.jpg"/>
|
198 |
<figcaption>caption</figcaption>
|
199 |
</figure>
|
200 |
+
<figure>
|
201 |
+
<img src="http://example.com/image.jpg"/>
|
202 |
+
<figcaption>caption <i><b>bold italic</b></i> and <a href="http://domain.com">link</a><cite>photo credit <i><b>bold italic</b></i> and <a href="http://domain.com">link</a></cite></figcaption>
|
203 |
+
</figure>
|
204 |
+
<figure><img src="http://example.com/credit-image.jpg"/></figure>
|
205 |
</article>
|
206 |
</body>
|
207 |
</html>
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/custom-html-rules.json
CHANGED
@@ -601,6 +601,45 @@
|
|
601 |
]
|
602 |
}
|
603 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
}
|
|
|
605 |
]
|
606 |
}
|
601 |
]
|
602 |
}
|
603 |
}
|
604 |
+
},
|
605 |
+
{
|
606 |
+
"class": "ImageRule",
|
607 |
+
"selector": ".image-with-credit-and-caption",
|
608 |
+
"properties": {
|
609 |
+
"image.url": {
|
610 |
+
"type": "string",
|
611 |
+
"selector": "img",
|
612 |
+
"attribute": "src"
|
613 |
+
},
|
614 |
+
"image.caption": {
|
615 |
+
"type": "element",
|
616 |
+
"selector": "p.caption"
|
617 |
+
},
|
618 |
+
"image.credit": {
|
619 |
+
"type": "element",
|
620 |
+
"selector": "p.credit"
|
621 |
+
}
|
622 |
+
}
|
623 |
+
},
|
624 |
+
{
|
625 |
+
"class": "ImageRule",
|
626 |
+
"selector": ".image-with-credit-only",
|
627 |
+
"properties": {
|
628 |
+
"image.url": {
|
629 |
+
"type": "string",
|
630 |
+
"selector": "img",
|
631 |
+
"attribute": "src"
|
632 |
+
},
|
633 |
+
"image.caption": {
|
634 |
+
"type": "element",
|
635 |
+
"selector": "p.caption"
|
636 |
+
},
|
637 |
+
"image.credit": {
|
638 |
+
"type": "element",
|
639 |
+
"selector": "p.credit"
|
640 |
+
}
|
641 |
+
}
|
642 |
}
|
643 |
+
|
644 |
]
|
645 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/custom.html
CHANGED
@@ -217,5 +217,18 @@
|
|
217 |
<img class="wp-image-22553 size-large" src="http://example.com/image.jpg" alt="alt text" width="800" height="552" srcset="http://example.com/image-800.jpg 800w, http://example.com/image-400.jpg 400w, http://example.com/image-768.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" />
|
218 |
<p class="wp-caption-text">caption</p>
|
219 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
</body>
|
221 |
</html>
|
217 |
<img class="wp-image-22553 size-large" src="http://example.com/image.jpg" alt="alt text" width="800" height="552" srcset="http://example.com/image-800.jpg 800w, http://example.com/image-400.jpg 400w, http://example.com/image-768.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" />
|
218 |
<p class="wp-caption-text">caption</p>
|
219 |
</div>
|
220 |
+
<div class="image-with-credit-and-caption">
|
221 |
+
<a href="http://example.com/image.jpg">
|
222 |
+
<img src="http://example.com/image.jpg"/>
|
223 |
+
</a>
|
224 |
+
<p class="caption">caption <i><b>bold italic</b></i> and <a href="http://domain.com">link</a></p>
|
225 |
+
<p class="credit">photo credit <i><b>bold italic</b></i> and <a href="http://domain.com">link</a></p>
|
226 |
+
</div>
|
227 |
+
<div class="image-with-credit-only">
|
228 |
+
<a href="http://example.com/credit-image.jpg">
|
229 |
+
<img src="http://example.com/credit-image.jpg"/>
|
230 |
+
</a>
|
231 |
+
<p class="credit">photo ONLY credit <i><b>bold italic</b></i> and <a href="http://domain.com">link</a></p>
|
232 |
+
</div>
|
233 |
</body>
|
234 |
</html>
|
vendor/facebook/graph-sdk/src/Facebook/Authentication/OAuth2Client.php
CHANGED
@@ -125,8 +125,8 @@ class OAuth2Client
|
|
125 |
* Generates an authorization URL to begin the process of authenticating a user.
|
126 |
*
|
127 |
* @param string $redirectUrl The callback URL to redirect to.
|
128 |
-
* @param array $scope An array of permissions to request.
|
129 |
* @param string $state The CSPRNG-generated CSRF value.
|
|
|
130 |
* @param array $params An array of parameters to generate URL.
|
131 |
* @param string $separator The separator to use in http_build_query().
|
132 |
*
|
125 |
* Generates an authorization URL to begin the process of authenticating a user.
|
126 |
*
|
127 |
* @param string $redirectUrl The callback URL to redirect to.
|
|
|
128 |
* @param string $state The CSPRNG-generated CSRF value.
|
129 |
+
* @param array $scope An array of permissions to request.
|
130 |
* @param array $params An array of parameters to generate URL.
|
131 |
* @param string $separator The separator to use in http_build_query().
|
132 |
*
|
vendor/facebook/graph-sdk/src/Facebook/Facebook.php
CHANGED
@@ -53,12 +53,12 @@ class Facebook
|
|
53 |
/**
|
54 |
* @const string Version number of the Facebook PHP SDK.
|
55 |
*/
|
56 |
-
const VERSION = '5.
|
57 |
|
58 |
/**
|
59 |
* @const string Default Graph API version for requests.
|
60 |
*/
|
61 |
-
const DEFAULT_GRAPH_VERSION = 'v2.
|
62 |
|
63 |
/**
|
64 |
* @const string The name of the environment variable that contains the app ID.
|
53 |
/**
|
54 |
* @const string Version number of the Facebook PHP SDK.
|
55 |
*/
|
56 |
+
const VERSION = '5.6.0';
|
57 |
|
58 |
/**
|
59 |
* @const string Default Graph API version for requests.
|
60 |
*/
|
61 |
+
const DEFAULT_GRAPH_VERSION = 'v2.10';
|
62 |
|
63 |
/**
|
64 |
* @const string The name of the environment variable that contains the app ID.
|
vendor/wp-coding-standards/wpcs/.travis.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1 |
sudo: false
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
language:
|
4 |
- php
|
5 |
|
6 |
php:
|
7 |
-
- 5.2
|
8 |
-
- 5.3
|
9 |
- 5.4
|
10 |
- 5.5
|
11 |
- 5.6
|
@@ -13,46 +16,74 @@ php:
|
|
13 |
- 7.1
|
14 |
|
15 |
env:
|
16 |
-
|
17 |
-
- PHPCS_BRANCH=2.
|
|
|
|
|
18 |
|
19 |
matrix:
|
20 |
fast_finish: true
|
21 |
include:
|
22 |
# Run PHPCS against WPCS. I just picked to run it against 5.5.
|
23 |
- php: 5.5
|
24 |
-
env: PHPCS_BRANCH=
|
|
|
|
|
|
|
|
|
25 |
# Run against PHPCS 3.0. I just picked to run it against 5.6.
|
26 |
- php: 5.6
|
27 |
-
env: PHPCS_BRANCH=
|
28 |
# Run against HHVM and PHP nightly.
|
29 |
- php: hhvm
|
30 |
sudo: required
|
31 |
dist: trusty
|
32 |
-
group: edge
|
33 |
-
env: PHPCS_BRANCH=
|
34 |
- php: nightly
|
35 |
-
env: PHPCS_BRANCH=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
allow_failures:
|
37 |
# Allow failures for unstable builds.
|
38 |
- php: nightly
|
39 |
- php: hhvm
|
40 |
-
- env: PHPCS_BRANCH=
|
41 |
|
42 |
before_install:
|
|
|
43 |
- export PHPCS_DIR=/tmp/phpcs
|
44 |
- export PHPUNIT_DIR=/tmp/phpunit
|
45 |
-
- export PHPCS_BIN=$(if [[ $PHPCS_BRANCH ==
|
46 |
- mkdir -p $PHPCS_DIR && git clone --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git -b $PHPCS_BRANCH $PHPCS_DIR
|
47 |
- $PHPCS_BIN --config-set installed_paths $(pwd)
|
48 |
-
# Download PHPUnit 5.x for builds on PHP 7, nightly and HHVM as
|
49 |
-
#
|
50 |
-
|
|
|
|
|
|
|
51 |
|
52 |
script:
|
53 |
-
|
|
|
|
|
54 |
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then phpunit --filter WordPress /tmp/phpcs/tests/AllTests.php; fi
|
55 |
-
- if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." ]]; then php $PHPUNIT_DIR/phpunit-5.7.phar --filter WordPress /tmp/phpcs/tests/AllTests.php; fi
|
56 |
# WordPress Coding Standards.
|
57 |
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
58 |
# @link http://pear.php.net/package/PHP_CodeSniffer/
|
@@ -63,3 +94,14 @@ script:
|
|
63 |
# --standard: Use WordPress as the standard.
|
64 |
# --extensions: Only sniff PHP files.
|
65 |
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -n . --standard=./bin/phpcs.xml --extensions=php; fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
sudo: false
|
2 |
|
3 |
+
dist: trusty
|
4 |
+
|
5 |
+
cache:
|
6 |
+
apt: true
|
7 |
+
|
8 |
language:
|
9 |
- php
|
10 |
|
11 |
php:
|
|
|
|
|
12 |
- 5.4
|
13 |
- 5.5
|
14 |
- 5.6
|
16 |
- 7.1
|
17 |
|
18 |
env:
|
19 |
+
# Branch for patches against 2.x. `master` is now 3.x which WPCS is not (yet) compatible with.
|
20 |
+
- PHPCS_BRANCH=2.9 LINT=1
|
21 |
+
# Tagged release
|
22 |
+
- PHPCS_BRANCH=2.9.0
|
23 |
|
24 |
matrix:
|
25 |
fast_finish: true
|
26 |
include:
|
27 |
# Run PHPCS against WPCS. I just picked to run it against 5.5.
|
28 |
- php: 5.5
|
29 |
+
env: PHPCS_BRANCH=2.9 SNIFF=1
|
30 |
+
addons:
|
31 |
+
apt:
|
32 |
+
packages:
|
33 |
+
- libxml2-utils
|
34 |
# Run against PHPCS 3.0. I just picked to run it against 5.6.
|
35 |
- php: 5.6
|
36 |
+
env: PHPCS_BRANCH=master
|
37 |
# Run against HHVM and PHP nightly.
|
38 |
- php: hhvm
|
39 |
sudo: required
|
40 |
dist: trusty
|
41 |
+
group: edge
|
42 |
+
env: PHPCS_BRANCH=2.9 LINT=1
|
43 |
- php: nightly
|
44 |
+
env: PHPCS_BRANCH=2.9 LINT=1
|
45 |
+
# Test PHP 5.3 with short_open_tags set to On (is Off by default)
|
46 |
+
- php: 5.3
|
47 |
+
env: PHPCS_BRANCH=2.9 SHORT_OPEN_TAGS=true
|
48 |
+
dist: precise
|
49 |
+
- php: 5.3
|
50 |
+
env: PHPCS_BRANCH=2.9
|
51 |
+
dist: precise
|
52 |
+
- php: 5.3
|
53 |
+
env: PHPCS_BRANCH=2.9.0
|
54 |
+
dist: precise
|
55 |
+
- php: 5.2
|
56 |
+
env: PHPCS_BRANCH=2.9
|
57 |
+
dist: precise
|
58 |
+
- php: 5.2
|
59 |
+
env: PHPCS_BRANCH=2.9.0
|
60 |
+
dist: precise
|
61 |
allow_failures:
|
62 |
# Allow failures for unstable builds.
|
63 |
- php: nightly
|
64 |
- php: hhvm
|
65 |
+
- env: PHPCS_BRANCH=master
|
66 |
|
67 |
before_install:
|
68 |
+
- export XMLLINT_INDENT=" "
|
69 |
- export PHPCS_DIR=/tmp/phpcs
|
70 |
- export PHPUNIT_DIR=/tmp/phpunit
|
71 |
+
- export PHPCS_BIN=$(if [[ $PHPCS_BRANCH == master ]]; then echo $PHPCS_DIR/bin/phpcs; else echo $PHPCS_DIR/scripts/phpcs; fi)
|
72 |
- mkdir -p $PHPCS_DIR && git clone --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git -b $PHPCS_BRANCH $PHPCS_DIR
|
73 |
- $PHPCS_BIN --config-set installed_paths $(pwd)
|
74 |
+
# Download PHPUnit 5.x for builds on PHP 7, nightly and HHVM as the PHPCS
|
75 |
+
# test suite is currently not compatible with PHPUnit 6.x.
|
76 |
+
# Fixed at a very specific PHPUnit version which is also compatible with HHVM.
|
77 |
+
- if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." ]]; then wget -P $PHPUNIT_DIR https://phar.phpunit.de/phpunit-5.7.17.phar && chmod +x $PHPUNIT_DIR/phpunit-5.7.17.phar; fi
|
78 |
+
# Selectively adjust the ini values for the build image to test ini value dependent sniff features.
|
79 |
+
- if [[ "$SHORT_OPEN_TAGS" == "true" ]]; then echo "short_open_tag = On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
|
80 |
|
81 |
script:
|
82 |
+
# Lint the PHP files against parse errors.
|
83 |
+
- if [[ "$LINT" == "1" ]]; then if find . -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
|
84 |
+
# Run the unit tests.
|
85 |
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then phpunit --filter WordPress /tmp/phpcs/tests/AllTests.php; fi
|
86 |
+
- if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." ]]; then php $PHPUNIT_DIR/phpunit-5.7.17.phar --filter WordPress /tmp/phpcs/tests/AllTests.php; fi
|
87 |
# WordPress Coding Standards.
|
88 |
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
89 |
# @link http://pear.php.net/package/PHP_CodeSniffer/
|
94 |
# --standard: Use WordPress as the standard.
|
95 |
# --extensions: Only sniff PHP files.
|
96 |
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -n . --standard=./bin/phpcs.xml --extensions=php; fi
|
97 |
+
# Validate the xml files.
|
98 |
+
# @link http://xmlsoft.org/xmllint.html
|
99 |
+
- if [[ "$SNIFF" == "1" ]]; then xmllint --noout ./*/ruleset.xml; fi
|
100 |
+
- if [[ "$SNIFF" == "1" ]]; then xmllint --noout ./phpcs.xml.dist.sample; fi
|
101 |
+
# Check the code-style consistency of the xml files.
|
102 |
+
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress/ruleset.xml <(xmllint --format "./WordPress/ruleset.xml"); fi
|
103 |
+
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Core/ruleset.xml <(xmllint --format "./WordPress-Core/ruleset.xml"); fi
|
104 |
+
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Docs/ruleset.xml <(xmllint --format "./WordPress-Docs/ruleset.xml"); fi
|
105 |
+
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml"); fi
|
106 |
+
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-VIP/ruleset.xml <(xmllint --format "./WordPress-VIP/ruleset.xml"); fi
|
107 |
+
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample"); fi
|
vendor/wp-coding-standards/wpcs/CHANGELOG.md
CHANGED
@@ -8,6 +8,75 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
|
|
8 |
|
9 |
_Nothing yet._
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
## [0.11.0] - 2017-03-20
|
12 |
|
13 |
### Important notes for end-users:
|
@@ -366,7 +435,8 @@ See the comparison for full list.
|
|
366 |
|
367 |
Initial tagged release.
|
368 |
|
369 |
-
[Unreleased]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/
|
|
|
370 |
[0.11.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.10.0...0.11.0
|
371 |
[0.10.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.9.0...0.10.0
|
372 |
[0.9.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.8.0...0.9.0
|
8 |
|
9 |
_Nothing yet._
|
10 |
|
11 |
+
## [0.12.0] - 2017-07-21
|
12 |
+
|
13 |
+
### Added
|
14 |
+
- A default file encoding setting to the `WordPress-Core` ruleset. All files sniffed will now be regarded as `utf-8` by default.
|
15 |
+
- `WordPress.Arrays.ArrayIndentation` sniff to the `WordPress-Core` ruleset to verify - and auto-fix - the indentation of array items and the array closer for multi-line arrays. This replaces the (partial) indentation fixing contained within the `WordPress.Array.ArrayDeclarationSpacing` sniff.
|
16 |
+
- `WordPress.Arrays.CommaAfterArrayItem` sniff to the `WordPress-Core` ruleset to enforce that each array item is followed by a comma - except for the last item in a single-line array - and checks the spacing around the comma. This replaces (and improves) the checks which were previously included in the `WordPress.Arrays.ArrayDeclaration` sniff which were causing incorrect fixes and fixer conflicts.
|
17 |
+
- `WordPress.Functions.FunctionCallSignatureNoParams` sniff to the `WordPress-Core` ruleset to verify that function calls without parameters do not have any whitespace between the parentheses.
|
18 |
+
- `WordPress.WhiteSpace.DisallowInlineTabs` to the `WordPress-Core` ruleset to verify - and auto-fix - that spaces are used for mid-line alignment.
|
19 |
+
- `WordPress.WP.CapitalPDangit` sniff to the `WordPress-Core` ruleset to - where relevant - verify that `WordPress` is spelled correctly. For misspellings in text strings and comment text, the sniff can auto-fix violations.
|
20 |
+
- `Squiz.Classes.SelfMemberReference` whitespace related checks to the `WordPress-Core` ruleset and the additional check for using `self` rather than a FQN to the `WordPress-Extra` ruleset.
|
21 |
+
- `Squiz.PHP.EmbeddedPhp` sniff to the `WordPress-Core` ruleset to check PHP code embedded within HTML blocks.
|
22 |
+
- `PSR2.ControlStructures.SwitchDeclaration` to the `WordPress-Core` ruleset to check for the correct layout of `switch` control structures.
|
23 |
+
- `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.
|
24 |
+
- `WordPress.CodeAnalysis.EmptyStatement` sniff to the `WordPress-Extra` ruleset to detect - and auto-fix - superfluous semi-colons and empty PHP open-close tag combinations.
|
25 |
+
- `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.
|
26 |
+
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.
|
27 |
+
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.
|
28 |
+
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).
|
29 |
+
Code in unit test files is automatically exempt from this sniff.
|
30 |
+
- `WordPress.WP.DeprecatedClasses` sniff to the `WordPress-Extra` ruleset to detect usage of deprecated WordPress classes.
|
31 |
+
- `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.
|
32 |
+
- The `sanitize_textarea_field()` function to the `sanitizingFunctions` list used by the `WordPress.CSRF.NonceVerification`, `WordPress.VIP.ValidatedSanitizedInput` and `WordPress.XSS.EscapeOutput` sniffs.
|
33 |
+
- The `find_array_open_closer()` utility method to the `WordPress_Sniff` class.
|
34 |
+
- Information about setting `installed_paths` using a custom ruleset to the Readme.
|
35 |
+
- Additional support links to the `composer.json` file.
|
36 |
+
- Support for Composer PHPCS plugins which sort out the `installed_paths` setting.
|
37 |
+
- Linting and code-style check of the XML ruleset files provided by WPCS.
|
38 |
+
|
39 |
+
### Changed
|
40 |
+
- The minimum required PHP_CodeSniffer version to 2.9.0 (was 2.8.1). **Take note**: PHPCS 3.x is not (yet) supported. The next release is expected to fix that.
|
41 |
+
- Improved support for detecting issues in code using heredoc and/or nowdoc syntax.
|
42 |
+
- Improved sniff efficiency, precision and performance for a number of sniffs.
|
43 |
+
- Updated a few sniffs to take advantage of new features and fixes which are included in PHP_CodeSniffer 2.9.0.
|
44 |
+
- `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).
|
45 |
+
- The `WordPress.Files.FileName` sniff allows now for more theme-specific template hierarchy based file name exceptions.
|
46 |
+
- 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.
|
47 |
+
- The `WordPress.WhiteSpace.OperatorSpacing` sniff will now ignore operator spacing within `declare()` statements.
|
48 |
+
- The `WordPress.WhiteSpace.OperatorSpacing` sniff now extends the upstream `Squiz.WhiteSpace.OperatorSpacing` sniff for improved results and will now also examine the spacing around ternary operators and logical (`&&`, `||`) operators.
|
49 |
+
- The `WordPress.WP.DeprecatedFunctions` sniff will now detect functions deprecated in WP 4.7 and 4.8. Additionally, a number of other deprecated functions which were previously not being detected have been added to the sniff and for a number of functions the "alternative" for the deprecated function has been added/improved.
|
50 |
+
- The `WordPress.XSS.EscapeOutput` sniff will now also detect unescaped output when the short open echo tags `<?=` are used.
|
51 |
+
- Updated the list of WP globals which is used by both the `WordPress.Variables.GlobalVariables` and the `WordPress.NamingConventions.PrefixAllGlobals` sniffs.
|
52 |
+
- Updated the information on using a custom ruleset and associated naming conventions in the Readme.
|
53 |
+
- Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to provide a better starting point and renamed the file to follow current PHPCS best practices.
|
54 |
+
- Various inline documentation improvements.
|
55 |
+
- Updated the link to the PHPStorm documentation in the Readme.
|
56 |
+
- Various textual improvements to the Readme.
|
57 |
+
- Minor improvements to the build script.
|
58 |
+
|
59 |
+
### Removed
|
60 |
+
- `Squiz.Commenting.LongConditionClosingComment` sniff from the `WordPress-Core` ruleset. This rule has been removed from the WP Coding Standards handbook.
|
61 |
+
- The exclusion of the `Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace` error from the `WordPress-Core` ruleset.
|
62 |
+
- The exclusion of the `PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket` and `PEAR.Functions.FunctionCallSignature.CloseBracketLine` error from the `WordPress-Core` ruleset when used in combination with the fixer, i.e. `phpcbf`. The exclusions remain in place for `phpcs` runs.
|
63 |
+
- `wp_get_post_terms()`, `wp_get_post_categories()`, `wp_get_post_tags()` and `wp_get_object_terms()` from the `WordPress.VIP.RestrictedFunctions` sniff as these functions are now cached natively since WP 4.7.
|
64 |
+
|
65 |
+
### Fixed
|
66 |
+
- The `WordPress.Array.ArrayDeclarationSpacing` could be overeager when fixing associative arrays to be multi-line. Non-associative single-line arrays which contained a nested associative array would also be auto-fixed by the sniff, while only the nested associated array should be fixed.
|
67 |
+
- The `WordPress.Files.FileName` sniff did not play nice with IDEs passing a filename to PHPCS via `--stdin-path=`.
|
68 |
+
- The `WordPress.Files.FileName` sniff was being triggered on code passed via `stdin` where there is no file name to examine.
|
69 |
+
- The `WordPress.PHP.YodaConditions` sniff would give a false positive for the result of a condition being assigned to a variable.
|
70 |
+
- The `WordPress.VIP.RestrictedVariables` sniff was potentially underreporting issues when the variables being restricted were a combination of variables, object properties and array members.
|
71 |
+
- The auto-fixer in the `WordPress.WhiteSpace.ControlStructureSpacing` sniff which deals with "blank line after control structure" issues could cause comments at the end of control structures to be removed.
|
72 |
+
- The `WordPress.WP.DeprecatedFunctions` sniff was reporting the wrong WP version for the deprecation of a number of functions.
|
73 |
+
- The `WordPress.WP.EnqueuedResources` sniff would potentially underreport issues in certain circumstances.
|
74 |
+
- The `WordPress.XSS.EscapeOutput` sniff will no now longer report issues when it encounters a `__DIR__`, `(unset)` cast or a floating point number, and will correctly disregard more arithmetic operators when deciding whether to report an issue or not.
|
75 |
+
- The [whitelisting of errors using flags](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) was sometimes a bit too eager and could accidentally whitelist code which was not intended to be whitelisted.
|
76 |
+
- Various (potential) `Undefined variable`, `Undefined index` and `Undefined offset` notices.
|
77 |
+
- Grammer in one of the `WordPress.WP.I18n` error messages.
|
78 |
+
|
79 |
+
|
80 |
## [0.11.0] - 2017-03-20
|
81 |
|
82 |
### Important notes for end-users:
|
435 |
|
436 |
Initial tagged release.
|
437 |
|
438 |
+
[Unreleased]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/master...HEAD
|
439 |
+
[0.12.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.11.0...0.12.0
|
440 |
[0.11.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.10.0...0.11.0
|
441 |
[0.10.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.9.0...0.10.0
|
442 |
[0.9.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.8.0...0.9.0
|
vendor/wp-coding-standards/wpcs/README.md
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
+ [Atom](#atom)
|
22 |
+ [Visual Studio](#visual-studio)
|
23 |
* [Running your code through WPCS automatically using CI tools](#running-your-code-through-wpcs-automatically-using-ci-tools)
|
24 |
-
+ [
|
25 |
* [Fixing errors or whitelisting them](#fixing-errors-or-whitelisting-them)
|
26 |
* [Contributing](#contributing)
|
27 |
* [License](#license)
|
@@ -34,20 +34,20 @@ This project is a collection of [PHP_CodeSniffer](https://github.com/squizlabs/P
|
|
34 |
|
35 |
- In April 2009 original project from [Urban Giraffe](http://urbangiraffe.com/articles/wordpress-codesniffer-standard/) was published.
|
36 |
- In May 2011 the project was forked on GitHub by [Chris Adams](http://chrisadams.me.uk/).
|
37 |
-
- In April 2012 [XWP](https://xwp.co/) started to dedicate resources to
|
38 |
-
- In 2015, [J.D. Grimes](https://github.com/JDGrimes) began significant contributions, along with
|
39 |
- In 2016, [Juliette Reinders Folmer](https://github.com/jrfnl) began contributing heavily, adding more commits in a year than anyone else in 5 years previous since the project's inception.
|
40 |
|
41 |
## Installation
|
42 |
|
43 |
### Requirements
|
44 |
|
45 |
-
The WordPress Coding Standards require PHP 5.2 or higher and the [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version **2.
|
46 |
The WordPress Coding Standards are currently [not compatible with the upcoming PHPCS 3 release](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/718).
|
47 |
|
48 |
### Composer
|
49 |
|
50 |
-
Standards can be installed with [Composer](https://getcomposer.org/) dependency manager:
|
51 |
|
52 |
composer create-project wp-coding-standards/wpcs --no-dev
|
53 |
|
@@ -58,22 +58,36 @@ Running this command will:
|
|
58 |
3. Register WordPress standards in PHP_CodeSniffer configuration.
|
59 |
4. Make `phpcs` command available from `wpcs/vendor/bin`.
|
60 |
|
61 |
-
For convenience of using `phpcs` as global command you
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
### Standalone
|
64 |
|
65 |
1. Install PHP_CodeSniffer by following its [installation instructions](https://github.com/squizlabs/PHP_CodeSniffer#installation) (via Composer, PEAR, or Git checkout).
|
66 |
|
67 |
-
Do ensure, if for example you're using
|
68 |
|
69 |
2. Clone WordPress standards repository:
|
70 |
|
71 |
git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
|
72 |
|
73 |
-
3. Add its path to PHP_CodeSniffer configuration:
|
74 |
|
75 |
phpcs --config-set installed_paths /path/to/wpcs
|
76 |
|
|
|
|
|
|
|
|
|
77 |
|
78 |
To summarize:
|
79 |
|
@@ -93,7 +107,7 @@ You should then see `WordPress-Core` et al listed when you run `phpcs -i`.
|
|
93 |
|
94 |
### Standards subsets
|
95 |
|
96 |
-
The project encompasses a super–set of the sniffs that the WordPress community may need. If you use the `WordPress` standard you will get all the checks. Some of them might be unnecessary for your environment, for example those specific to WordPress VIP coding requirements.
|
97 |
|
98 |
You can use the following as standard names when invoking `phpcs` to select sniffs, fitting your needs:
|
99 |
|
@@ -107,7 +121,7 @@ You can use the following as standard names when invoking `phpcs` to select snif
|
|
107 |
|
108 |
### Using a custom ruleset
|
109 |
|
110 |
-
If you need to further customize the selection of sniffs for your project — you can create a custom `phpcs.xml` standard. See provided [
|
111 |
|
112 |
### Customizing sniff behaviour
|
113 |
|
@@ -121,7 +135,7 @@ The [PHPCompatibility](https://github.com/wimg/PHPCompatibility) ruleset comes h
|
|
121 |
The [PHPCompatibility](https://github.com/wimg/PHPCompatibility) sniffs are designed to analyse your code for cross-PHP version compatibility.
|
122 |
Install it as a separate ruleset and either run it separately against your code or add it to your custom ruleset.
|
123 |
|
124 |
-
Whichever way you run it, do make sure you set the `testVersion` to run the sniffs against. The `testVersion` determines for which PHP versions you will
|
125 |
|
126 |
For more information about setting the `testVersion`, see:
|
127 |
* [PHPCompatibility: Using the compatibility sniffs](https://github.com/wimg/PHPCompatibility#using-the-compatibility-sniffs)
|
@@ -161,7 +175,7 @@ Will result in following output:
|
|
161 |
|
162 |
### PhpStorm
|
163 |
|
164 |
-
Please see “[PHP Code Sniffer with WordPress Coding Standards Integration](https://
|
165 |
|
166 |
### Sublime Text
|
167 |
|
21 |
+ [Atom](#atom)
|
22 |
+ [Visual Studio](#visual-studio)
|
23 |
* [Running your code through WPCS automatically using CI tools](#running-your-code-through-wpcs-automatically-using-ci-tools)
|
24 |
+
+ [Travis CI](#travis-ci)
|
25 |
* [Fixing errors or whitelisting them](#fixing-errors-or-whitelisting-them)
|
26 |
* [Contributing](#contributing)
|
27 |
* [License](#license)
|
34 |
|
35 |
- In April 2009 original project from [Urban Giraffe](http://urbangiraffe.com/articles/wordpress-codesniffer-standard/) was published.
|
36 |
- In May 2011 the project was forked on GitHub by [Chris Adams](http://chrisadams.me.uk/).
|
37 |
+
- 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`.
|
38 |
+
- In 2015, [J.D. Grimes](https://github.com/JDGrimes) began significant contributions, along with maintenance from [Gary Jones](https://github.com/GaryJones).
|
39 |
- In 2016, [Juliette Reinders Folmer](https://github.com/jrfnl) began contributing heavily, adding more commits in a year than anyone else in 5 years previous since the project's inception.
|
40 |
|
41 |
## Installation
|
42 |
|
43 |
### Requirements
|
44 |
|
45 |
+
The WordPress Coding Standards require PHP 5.2 or higher and the [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version **2.9.0** or higher.
|
46 |
The WordPress Coding Standards are currently [not compatible with the upcoming PHPCS 3 release](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/718).
|
47 |
|
48 |
### Composer
|
49 |
|
50 |
+
Standards can be installed with the [Composer](https://getcomposer.org/) dependency manager:
|
51 |
|
52 |
composer create-project wp-coding-standards/wpcs --no-dev
|
53 |
|
58 |
3. Register WordPress standards in PHP_CodeSniffer configuration.
|
59 |
4. Make `phpcs` command available from `wpcs/vendor/bin`.
|
60 |
|
61 |
+
For the convenience of using `phpcs` as a global command, you may want to add the `wpcs/vendor/bin` path to a PATH environment in your operating system.
|
62 |
+
|
63 |
+
#### Installing WPCS as a dependency
|
64 |
+
|
65 |
+
When installing the WordPress Coding Standards as a dependency in a larger project, the above mentioned step 3 will not be executed automatically.
|
66 |
+
|
67 |
+
There are two actively maintained Composer plugins which can handle the registration of standards with PHP_CodeSniffer for you:
|
68 |
+
* [composer-phpcodesniffer-standards-plugin](https://github.com/higidi/composer-phpcodesniffer-standards-plugin)
|
69 |
+
* [phpcodesniffer-composer-installer](https://github.com/DealerDirect/phpcodesniffer-composer-installer)
|
70 |
+
|
71 |
+
It is strongly suggested to `require` one of these plugins in your project to handle the registration of external standards with PHPCS for you.
|
72 |
|
73 |
### Standalone
|
74 |
|
75 |
1. Install PHP_CodeSniffer by following its [installation instructions](https://github.com/squizlabs/PHP_CodeSniffer#installation) (via Composer, PEAR, or Git checkout).
|
76 |
|
77 |
+
Do ensure that PHP_CodeSniffer's version matches our requirements(#requirements), if, for example, you're using VVV(https://github.com/Varying-Vagrant-Vagrants/VVV).
|
78 |
|
79 |
2. Clone WordPress standards repository:
|
80 |
|
81 |
git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
|
82 |
|
83 |
+
3. Add its path to the PHP_CodeSniffer configuration:
|
84 |
|
85 |
phpcs --config-set installed_paths /path/to/wpcs
|
86 |
|
87 |
+
**Pro-tip:** Alternatively, you can tell PHP_CodeSniffer the path to the WordPress standards by adding the following snippet to your custom ruleset:
|
88 |
+
```xml
|
89 |
+
<config name="installed_paths" value="/path/to/wpcs" />
|
90 |
+
```
|
91 |
|
92 |
To summarize:
|
93 |
|
107 |
|
108 |
### Standards subsets
|
109 |
|
110 |
+
The project encompasses a super–set of the sniffs that the WordPress community may need. If you use the `WordPress` standard you will get all the checks. Some of them might be unnecessary for your environment, for example, those specific to WordPress VIP coding requirements.
|
111 |
|
112 |
You can use the following as standard names when invoking `phpcs` to select sniffs, fitting your needs:
|
113 |
|
121 |
|
122 |
### Using a custom ruleset
|
123 |
|
124 |
+
If you need to further customize the selection of sniffs for your project — you can create a custom ruleset file. When you name this file either `phpcs.xml` or `phpcs.xml.dist`, PHP_CodeSniffer will automatically locate it as long as it is placed in the directory from which you run the CodeSniffer or in a directory above it. If you follow these naming conventions you don't have to supply a `--standard` arg. For more info, read about [using a default configuration file](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). See also provided [`phpcs.xml.dist.sample`](phpcs.xml.dist.sample) file and [fully annotated example](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) in PHP_CodeSniffer documentation.
|
125 |
|
126 |
### Customizing sniff behaviour
|
127 |
|
135 |
The [PHPCompatibility](https://github.com/wimg/PHPCompatibility) sniffs are designed to analyse your code for cross-PHP version compatibility.
|
136 |
Install it as a separate ruleset and either run it separately against your code or add it to your custom ruleset.
|
137 |
|
138 |
+
Whichever way you run it, do make sure you set the `testVersion` to run the sniffs against. The `testVersion` determines for which PHP versions you will receive compatibility information. The recommended setting for this at this moment is `5.2-7.1` to support the same PHP versions as WordPress Core supports.
|
139 |
|
140 |
For more information about setting the `testVersion`, see:
|
141 |
* [PHPCompatibility: Using the compatibility sniffs](https://github.com/wimg/PHPCompatibility#using-the-compatibility-sniffs)
|
175 |
|
176 |
### PhpStorm
|
177 |
|
178 |
+
Please see “[PHP Code Sniffer with WordPress Coding Standards Integration](https://confluence.jetbrains.com/display/PhpStorm/WordPress+Development+using+PhpStorm#WordPressDevelopmentusingPhpStorm-PHPCodeSnifferwithWordPressCodingStandardsIntegrationinPhpStorm)” in PhpStorm documentation.
|
179 |
|
180 |
### Sublime Text
|
181 |
|
vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml
CHANGED
@@ -2,330 +2,407 @@
|
|
2 |
<ruleset name="WordPress Core">
|
3 |
<description>Non-controversial generally-agreed upon WordPress Coding Standards</description>
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
<!--
|
6 |
-
|
7 |
-
|
|
|
|
|
8 |
-->
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
|
19 |
|
20 |
<!--
|
21 |
-
|
22 |
-
|
|
|
|
|
23 |
-->
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
<
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
<!--
|
54 |
-
|
55 |
-
|
|
|
|
|
56 |
-->
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
<!-- Covers rule: If you consider a long block unavoidable, please put a short comment at the end ...
|
64 |
-
- typically this is appropriate for a logic block, longer than about 35 rows. -->
|
65 |
-
<rule ref="Squiz.Commenting.LongConditionClosingComment">
|
66 |
-
<properties>
|
67 |
-
<property name="lineLimit" value="35" />
|
68 |
-
<property name="commentFormat" value="// End %s()." />
|
69 |
-
</properties>
|
70 |
-
<exclude name="Squiz.Commenting.LongConditionClosingComment.SpacingBefore" />
|
71 |
-
</rule>
|
72 |
-
|
73 |
-
<!-- Covers rule: Braces should always be used, even when they are not required. -->
|
74 |
-
<rule ref="Generic.ControlStructures.InlineControlStructure" />
|
75 |
|
76 |
|
77 |
<!--
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
-->
|
81 |
-
|
82 |
|
83 |
|
84 |
<!--
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
-->
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
|
93 |
-
|
94 |
|
95 |
-
|
96 |
-
|
97 |
|
98 |
|
99 |
<!--
|
100 |
-
|
101 |
-
|
|
|
|
|
102 |
-->
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
|
108 |
<!--
|
109 |
-
|
110 |
-
|
|
|
|
|
111 |
-->
|
112 |
-
|
113 |
-
|
|
|
114 |
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
|
119 |
<!--
|
120 |
-
|
121 |
-
|
|
|
|
|
122 |
-->
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
175 |
|
176 |
|
177 |
<!--
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
-->
|
181 |
-
|
182 |
-
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
|
188 |
-
|
189 |
-
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
|
195 |
|
196 |
<!--
|
197 |
-
|
198 |
-
|
|
|
|
|
199 |
-->
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
|
204 |
|
205 |
<!--
|
206 |
-
|
207 |
-
|
|
|
|
|
208 |
-->
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
|
215 |
-
|
216 |
-
|
217 |
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
|
231 |
|
232 |
<!--
|
233 |
-
|
234 |
-
|
|
|
|
|
235 |
-->
|
236 |
|
237 |
|
238 |
<!--
|
239 |
-
|
240 |
-
|
|
|
241 |
|
242 |
-
|
|
|
243 |
-->
|
244 |
-
|
245 |
|
246 |
-
|
247 |
-
|
248 |
|
249 |
-
|
250 |
-
|
251 |
|
252 |
|
253 |
<!--
|
254 |
-
|
255 |
-
|
|
|
|
|
256 |
-->
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
|
261 |
|
262 |
<!--
|
263 |
-
|
264 |
-
|
|
|
|
|
265 |
-->
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
|
270 |
|
271 |
<!--
|
272 |
-
|
273 |
-
|
|
|
|
|
274 |
-->
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
|
|
279 |
|
280 |
|
281 |
<!--
|
282 |
-
|
283 |
-
|
|
|
|
|
284 |
-->
|
285 |
-
|
286 |
|
287 |
|
288 |
<!--
|
289 |
-
|
290 |
-
|
|
|
|
|
291 |
-->
|
292 |
-
|
293 |
|
294 |
|
295 |
<!--
|
296 |
-
|
|
|
|
|
297 |
-->
|
298 |
-
|
299 |
-
|
300 |
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
|
308 |
-
|
309 |
-
|
310 |
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
|
315 |
-
|
316 |
-
|
317 |
|
318 |
-
|
319 |
-
|
320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
<!--
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
|
|
326 |
-->
|
327 |
-
|
328 |
-
|
329 |
|
|
|
|
|
330 |
|
331 |
</ruleset>
|
2 |
<ruleset name="WordPress Core">
|
3 |
<description>Non-controversial generally-agreed upon WordPress Coding Standards</description>
|
4 |
|
5 |
+
<!-- Treat all files as UTF-8. -->
|
6 |
+
<config name="encoding" value="utf-8"/>
|
7 |
+
|
8 |
+
<!-- Default tab width for indentation fixes and such. -->
|
9 |
+
<arg name="tab-width" value="4"/>
|
10 |
+
|
11 |
<!--
|
12 |
+
#############################################################################
|
13 |
+
Handbook: PHP - Single and Double Quotes.
|
14 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#single-and-double-quotes
|
15 |
+
#############################################################################
|
16 |
-->
|
17 |
+
<!-- Covers rule: Use single and double quotes when appropriate.
|
18 |
+
If you're not evaluating anything in the string, use single quotes. -->
|
19 |
+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
|
20 |
+
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
|
21 |
+
<severity>0</severity>
|
22 |
+
</rule>
|
23 |
|
24 |
+
<!-- Rule: Text that goes into attributes should be run through esc_attr().
|
25 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/527 -->
|
26 |
|
27 |
|
28 |
<!--
|
29 |
+
#############################################################################
|
30 |
+
Handbook: PHP - Indentation.
|
31 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#indentation
|
32 |
+
#############################################################################
|
33 |
-->
|
34 |
+
<!-- Covers rule: Your indentation should always reflect logical structure. -->
|
35 |
+
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
36 |
+
<properties>
|
37 |
+
<property name="exact" value="false"/>
|
38 |
+
<property name="indent" value="4"/>
|
39 |
+
<property name="tabIndent" value="true"/>
|
40 |
+
<property name="ignoreIndentationTokens" type="array" value="T_HEREDOC,T_NOWDOC,T_INLINE_HTML"/>
|
41 |
+
</properties>
|
42 |
+
</rule>
|
43 |
+
<rule ref="WordPress.Arrays.ArrayIndentation"/>
|
44 |
+
|
45 |
+
<!-- Covers rule: Use real tabs and not spaces. -->
|
46 |
+
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
|
47 |
+
|
48 |
+
<!-- Generic array layout check. -->
|
49 |
+
<rule ref="WordPress.Arrays.ArrayDeclaration">
|
50 |
+
<exclude name="WordPress.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
|
51 |
+
<exclude name="WordPress.Arrays.ArrayDeclaration.CommaAfterLast"/>
|
52 |
+
<exclude name="WordPress.Arrays.ArrayDeclaration.NoSpaceAfterComma"/>
|
53 |
+
<exclude name="WordPress.Arrays.ArrayDeclaration.SpaceAfterComma"/>
|
54 |
+
<exclude name="WordPress.Arrays.ArrayDeclaration.SpaceBeforeComma"/>
|
55 |
+
</rule>
|
56 |
+
|
57 |
+
<!-- Covers rule: Note the comma after the last array item: this is recommended. -->
|
58 |
+
<rule ref="WordPress.Arrays.CommaAfterArrayItem"/>
|
59 |
+
|
60 |
+
<!-- Covers rule: For associative arrays, values should start on a new line.
|
61 |
+
Also covers various single-line array whitespace issues. -->
|
62 |
+
<rule ref="WordPress.Arrays.ArrayDeclarationSpacing"/>
|
63 |
+
|
64 |
+
<!-- Covers rule: For switch structures case should indent one tab from the
|
65 |
+
switch statement and break one tab from the case statement. -->
|
66 |
+
<rule ref="PSR2.ControlStructures.SwitchDeclaration">
|
67 |
+
<!-- Prevent duplicate messages for the same issue. Covered by other sniffs. -->
|
68 |
+
<exclude name="PSR2.ControlStructures.SwitchDeclaration.NotLower"/>
|
69 |
+
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakNotNewLine"/>
|
70 |
+
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLine"/>
|
71 |
+
</rule>
|
72 |
+
|
73 |
+
<!-- Covers rule: ... while spaces can be used mid-line for alignment. -->
|
74 |
+
<rule ref="WordPress.WhiteSpace.DisallowInlineTabs"/>
|
75 |
|
76 |
<!--
|
77 |
+
#############################################################################
|
78 |
+
Handbook: PHP - Brace Style.
|
79 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#brace-style
|
80 |
+
#############################################################################
|
81 |
-->
|
82 |
+
<!-- Covers rule: Braces shall be used for all blocks. -->
|
83 |
+
<rule ref="Squiz.ControlStructures.ControlSignature"/>
|
84 |
+
|
85 |
+
<!-- Covers rule: Braces should always be used, even when they are not required. -->
|
86 |
+
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
<!--
|
90 |
+
#############################################################################
|
91 |
+
Handbook: PHP - Use elseif, not else if.
|
92 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#use-elseif-not-else-if
|
93 |
+
#############################################################################
|
94 |
-->
|
95 |
+
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
|
96 |
|
97 |
|
98 |
<!--
|
99 |
+
#############################################################################
|
100 |
+
Handbook: PHP - Regular Expressions.
|
101 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#regular-expressions
|
102 |
+
#############################################################################
|
103 |
-->
|
104 |
+
<!-- Covers rule: Perl compatible regular expressions should be used in preference
|
105 |
+
to their POSIX counterparts. -->
|
106 |
+
<rule ref="WordPress.PHP.POSIXFunctions"/>
|
107 |
|
108 |
+
<!-- Rule: Never use the /e switch, use preg_replace_callback instead.
|
109 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/632 -->
|
110 |
|
111 |
+
<!-- Rule: It's most convenient to use single-quoted strings for regular expressions.
|
112 |
+
Already covered by Squiz.Strings.DoubleQuoteUsage -->
|
113 |
|
114 |
|
115 |
<!--
|
116 |
+
#############################################################################
|
117 |
+
Handbook: PHP - Opening and Closing PHP Tags.
|
118 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#opening-and-closing-php-tags
|
119 |
+
#############################################################################
|
120 |
-->
|
121 |
+
<!-- Covers rule: When embedding multi-line PHP snippets within a HTML block, the
|
122 |
+
PHP open and close tags must be on a line by themselves. -->
|
123 |
+
<rule ref="Squiz.PHP.EmbeddedPhp">
|
124 |
+
<exclude name="Squiz.PHP.EmbeddedPhp.SpacingBefore"/>
|
125 |
+
<exclude name="Squiz.PHP.EmbeddedPhp.Indent"/>
|
126 |
+
<exclude name="Squiz.PHP.EmbeddedPhp.OpenTagIndent"/>
|
127 |
+
<exclude name="Squiz.PHP.EmbeddedPhp.SpacingAfter"/>
|
128 |
+
</rule>
|
129 |
|
130 |
|
131 |
<!--
|
132 |
+
#############################################################################
|
133 |
+
Handbook: PHP - No Shorthand PHP Tags.
|
134 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#no-shorthand-php-tags
|
135 |
+
#############################################################################
|
136 |
-->
|
137 |
+
<!-- Covers rule: Never use shorthand PHP start tags. Always use full PHP tags. -->
|
138 |
+
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
139 |
+
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
|
140 |
|
141 |
+
|
142 |
+
<!--
|
143 |
+
#############################################################################
|
144 |
+
Handbook: PHP - Remove Trailing Spaces.
|
145 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#remove-trailing-spaces
|
146 |
+
#############################################################################
|
147 |
+
-->
|
148 |
+
<!-- Covers rule: Remove trailing whitespace at the end of each line of code. -->
|
149 |
+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
|
150 |
+
|
151 |
+
<!-- Covers rule: Omitting the closing PHP tag at the end of a file is preferred. -->
|
152 |
+
<rule ref="PSR2.Files.ClosingTag"/>
|
153 |
|
154 |
|
155 |
<!--
|
156 |
+
#############################################################################
|
157 |
+
Handbook: PHP - Space Usage.
|
158 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#space-usage
|
159 |
+
#############################################################################
|
160 |
-->
|
161 |
+
<!-- Covers rule: Always put spaces after commas, and on both sides of logical,
|
162 |
+
comparison, string and assignment operators. -->
|
163 |
+
<rule ref="WordPress.WhiteSpace.OperatorSpacing"/>
|
164 |
+
<rule ref="Squiz.Strings.ConcatenationSpacing">
|
165 |
+
<properties>
|
166 |
+
<property name="spacing" value="1"/>
|
167 |
+
<property name="ignoreNewlines" value="true"/>
|
168 |
+
</properties>
|
169 |
+
</rule>
|
170 |
+
|
171 |
+
<!-- Covers rule: Put spaces on both sides of the opening and closing parenthesis of
|
172 |
+
if, elseif, foreach, for, and switch blocks. -->
|
173 |
+
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"/>
|
174 |
+
|
175 |
+
<!-- Covers rule: Define a function like so: function my_function( $param1 = 'foo', $param2 = 'bar' ) { -->
|
176 |
+
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
|
177 |
+
<properties>
|
178 |
+
<property name="checkClosures" value="true"/>
|
179 |
+
</properties>
|
180 |
+
</rule>
|
181 |
+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
|
182 |
+
<properties>
|
183 |
+
<property name="equalsSpacing" value="1"/>
|
184 |
+
<property name="requiredSpacesAfterOpen" value="1"/>
|
185 |
+
<property name="requiredSpacesBeforeClose" value="1"/>
|
186 |
+
</properties>
|
187 |
+
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose"/>
|
188 |
+
</rule>
|
189 |
+
|
190 |
+
<!-- Covers rule: Call a function, like so: my_function( $param1, func_param( $param2 ) ); -->
|
191 |
+
<rule ref="PEAR.Functions.FunctionCallSignature">
|
192 |
+
<properties>
|
193 |
+
<property name="requiredSpacesAfterOpen" value="1"/>
|
194 |
+
<property name="requiredSpacesBeforeClose" value="1"/>
|
195 |
+
</properties>
|
196 |
+
</rule>
|
197 |
+
<rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
|
198 |
+
<severity phpcs-only="true">0</severity>
|
199 |
+
</rule>
|
200 |
+
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
|
201 |
+
<severity phpcs-only="true">0</severity>
|
202 |
+
</rule>
|
203 |
+
<!-- Related to issue #970 / https://github.com/squizlabs/PHP_CodeSniffer/issues/1512 -->
|
204 |
+
<rule ref="WordPress.Functions.FunctionCallSignatureNoParams"/>
|
205 |
+
|
206 |
+
<!-- Rule: Perform logical comparisons, like so: if ( ! $foo ) { -->
|
207 |
+
|
208 |
+
<!-- Covers rule: When type casting, do it like so: $foo = (boolean) $bar; -->
|
209 |
+
<rule ref="Generic.Formatting.SpaceAfterCast"/>
|
210 |
+
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
|
211 |
+
<rule ref="WordPress.WhiteSpace.CastStructureSpacing"/>
|
212 |
+
|
213 |
+
<!-- Covers rule: ... array items, only include a space around the index if it is a variable. -->
|
214 |
+
<rule ref="WordPress.Arrays.ArrayKeySpacingRestrictions"/>
|
215 |
|
216 |
|
217 |
<!--
|
218 |
+
#############################################################################
|
219 |
+
Handbook: PHP - Formatting SQL statements.
|
220 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#formatting-sql-statements
|
221 |
+
#############################################################################
|
222 |
-->
|
223 |
+
<!-- Rule: Always capitalize the SQL parts of the statement like UPDATE or WHERE.
|
224 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/639 -->
|
225 |
|
226 |
+
<!-- Rule: Functions that update the database should expect their parameters to lack
|
227 |
+
SQL slash escaping when passed.
|
228 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/640 -->
|
229 |
|
230 |
+
<!-- Rule: in $wpdb->prepare - only %s and %d are used as placeholders. Note that they are not "quoted"!
|
231 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/641 -->
|
232 |
|
233 |
+
<!-- Covers rule: Escaping should be done as close to the time of the query as possible,
|
234 |
+
preferably by using $wpdb->prepare() -->
|
235 |
+
<rule ref="WordPress.WP.PreparedSQL"/>
|
236 |
|
237 |
|
238 |
<!--
|
239 |
+
#############################################################################
|
240 |
+
Handbook: PHP - Database Queries.
|
241 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#database-queries
|
242 |
+
#############################################################################
|
243 |
-->
|
244 |
+
<!-- Covers rule: Avoid touching the database directly. -->
|
245 |
+
<rule ref="WordPress.DB.RestrictedFunctions"/>
|
246 |
+
<rule ref="WordPress.DB.RestrictedClasses"/>
|
247 |
|
248 |
|
249 |
<!--
|
250 |
+
#############################################################################
|
251 |
+
Handbook: PHP - Naming Conventions.
|
252 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions
|
253 |
+
#############################################################################
|
254 |
-->
|
255 |
+
<!-- Covers rule: Use lowercase letters in variable, action, and function names.
|
256 |
+
Separate words via underscores. -->
|
257 |
+
<rule ref="WordPress.NamingConventions.ValidFunctionName"/>
|
258 |
+
<rule ref="WordPress.NamingConventions.ValidHookName"/>
|
259 |
+
<rule ref="WordPress.NamingConventions.ValidVariableName"/>
|
260 |
|
261 |
+
<!-- Covers rule: Class names should use capitalized words separated by underscores. -->
|
262 |
+
<rule ref="PEAR.NamingConventions.ValidClassName"/>
|
263 |
|
264 |
+
<!-- Covers rule: Constants should be in all upper-case with underscores separating words. -->
|
265 |
+
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
|
266 |
|
267 |
+
<!-- Covers rule: Files should be named descriptively using lowercase letters.
|
268 |
+
Hyphens should separate words. -->
|
269 |
+
<!-- Covers rule: Class file names should be based on the class name with "class-"
|
270 |
+
prepended and the underscores in the class name replaced with hyphens.
|
271 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/642 -->
|
272 |
+
<!-- Covers rule: Files containing template tags in wp-includes should have "-template"
|
273 |
+
appended to the end of the name.
|
274 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/642 -->
|
275 |
+
<rule ref="WordPress.Files.FileName"/>
|
276 |
|
277 |
|
278 |
<!--
|
279 |
+
#############################################################################
|
280 |
+
Handbook: PHP - Self-Explanatory Flag Values for Function Arguments.
|
281 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#self-explanatory-flag-values-for-function-arguments
|
282 |
+
#############################################################################
|
283 |
-->
|
284 |
|
285 |
|
286 |
<!--
|
287 |
+
#############################################################################
|
288 |
+
Handbook: PHP - Interpolation for Naming Dynamic Hooks.
|
289 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#interpolation-for-naming-dynamic-hooks
|
290 |
|
291 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/751
|
292 |
+
#############################################################################
|
293 |
-->
|
294 |
+
<!-- Rule: Dynamic hooks should be named using interpolation rather than concatenation. -->
|
295 |
|
296 |
+
<!-- Rule: Variables used in hook tags should be wrapped in curly braces { and },
|
297 |
+
with the complete outer tag name wrapped in double quotes. -->
|
298 |
|
299 |
+
<!-- Rule: Where possible, dynamic values in tag names should also be as succinct
|
300 |
+
and to the point as possible. -->
|
301 |
|
302 |
|
303 |
<!--
|
304 |
+
#############################################################################
|
305 |
+
Handbook: PHP - Ternary Operator.
|
306 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#ternary-operator
|
307 |
+
#############################################################################
|
308 |
-->
|
309 |
+
<!-- Rule: Always have Ternaries test if the statement is true, not false.
|
310 |
+
An exception would be using ! empty(), as testing for false here is generally more intuitive.
|
311 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/643 -->
|
312 |
|
313 |
|
314 |
<!--
|
315 |
+
#############################################################################
|
316 |
+
Handbook: PHP - Yoda Conditions.
|
317 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#yoda-conditions
|
318 |
+
#############################################################################
|
319 |
-->
|
320 |
+
<!-- Covers rule: When doing logical comparisons, always put the variable on the right side,
|
321 |
+
constants or literals on the left. -->
|
322 |
+
<rule ref="WordPress.PHP.YodaConditions"/>
|
323 |
|
324 |
|
325 |
<!--
|
326 |
+
#############################################################################
|
327 |
+
Handbook: PHP - Clever Code.
|
328 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#clever-code
|
329 |
+
#############################################################################
|
330 |
-->
|
331 |
+
<!-- Rule: In general, readability is more important than cleverness or brevity.
|
332 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/607 -->
|
333 |
+
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
|
334 |
+
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
335 |
+
|
336 |
+
<!-- Rule: In a switch statement... If a case contains a block, then falls through
|
337 |
+
to the next block, this must be explicitly commented. -->
|
338 |
+
<!-- Covered by the PSR2.ControlStructures.SwitchDeclaration sniff. -->
|
339 |
|
340 |
|
341 |
<!--
|
342 |
+
#############################################################################
|
343 |
+
Handbook: PHP - (No) Error Control Operator @.
|
344 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#error-control-operator
|
345 |
+
#############################################################################
|
346 |
-->
|
347 |
+
<rule ref="Generic.PHP.NoSilencedErrors"/>
|
348 |
|
349 |
|
350 |
<!--
|
351 |
+
#############################################################################
|
352 |
+
Handbook: PHP - Don't extract().
|
353 |
+
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#dont-extract
|
354 |
+
#############################################################################
|
355 |
-->
|
356 |
+
<rule ref="WordPress.Functions.DontExtract"/>
|
357 |
|
358 |
|
359 |
<!--
|
360 |
+
#############################################################################
|
361 |
+
Not in the handbook: Generic sniffs.
|
362 |
+
#############################################################################
|
363 |
-->
|
364 |
+
<!-- Important to prevent issues with content being sent before headers. -->
|
365 |
+
<rule ref="Generic.Files.ByteOrderMark"/>
|
366 |
|
367 |
+
<!-- All line endings should be \n. -->
|
368 |
+
<rule ref="Generic.Files.LineEndings">
|
369 |
+
<properties>
|
370 |
+
<property name="eolChar" value="\n"/>
|
371 |
+
</properties>
|
372 |
+
</rule>
|
373 |
|
374 |
+
<!-- All files should end with a new line. -->
|
375 |
+
<rule ref="Generic.Files.EndFileNewline"/>
|
376 |
|
377 |
+
<!-- Lowercase PHP constants, like true, false and null. -->
|
378 |
+
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions -->
|
379 |
+
<rule ref="Generic.PHP.LowerCaseConstant"/>
|
380 |
|
381 |
+
<!-- Lowercase PHP keywords, like class, function and case. -->
|
382 |
+
<rule ref="Generic.PHP.LowerCaseKeyword"/>
|
383 |
|
384 |
+
<!-- Class opening braces should be on the same line as the statement. -->
|
385 |
+
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
|
386 |
|
387 |
+
<!-- References to self in a class should be lower-case and not have extraneous spaces,
|
388 |
+
per implicit conventions in the core codebase; the NotUsed code refers to using the
|
389 |
+
fully-qualified class name instead of self, for which there are instances in core. -->
|
390 |
+
<rule ref="Squiz.Classes.SelfMemberReference"/>
|
391 |
+
<rule ref="Squiz.Classes.SelfMemberReference.NotUsed">
|
392 |
+
<severity>0</severity>
|
393 |
+
</rule>
|
394 |
|
395 |
<!--
|
396 |
+
#############################################################################
|
397 |
+
Not in the coding standard handbook: WP specific sniffs.
|
398 |
+
Ref: https://make.wordpress.org/core/handbook/best-practices/internationalization/ (limited info)
|
399 |
+
Ref: https://developer.wordpress.org/plugins/internationalization/ (more extensive)
|
400 |
+
#############################################################################
|
401 |
-->
|
402 |
+
<!-- Check for correct usage of the WP i18n functions. -->
|
403 |
+
<rule ref="WordPress.WP.I18n"/>
|
404 |
|
405 |
+
<!-- Check for correct spelling of WordPress. -->
|
406 |
+
<rule ref="WordPress.WP.CapitalPDangit"/>
|
407 |
|
408 |
</ruleset>
|
vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml
CHANGED
@@ -83,14 +83,14 @@
|
|
83 |
<exclude name="Squiz.Commenting.VariableComment.VarOrder"/>
|
84 |
|
85 |
<!-- It is too early for PHP7 features to be required -->
|
86 |
-
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"
|
87 |
</rule>
|
88 |
|
89 |
<!-- Make this sniff less likely to trigger on end comments. -->
|
90 |
<rule ref="Squiz.PHP.CommentedOutCode">
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
</rule>
|
95 |
|
96 |
<rule ref="Generic.Commenting">
|
83 |
<exclude name="Squiz.Commenting.VariableComment.VarOrder"/>
|
84 |
|
85 |
<!-- It is too early for PHP7 features to be required -->
|
86 |
+
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
|
87 |
</rule>
|
88 |
|
89 |
<!-- Make this sniff less likely to trigger on end comments. -->
|
90 |
<rule ref="Squiz.PHP.CommentedOutCode">
|
91 |
+
<properties>
|
92 |
+
<property name="maxPercentage" value="45"/>
|
93 |
+
</properties>
|
94 |
</rule>
|
95 |
|
96 |
<rule ref="Generic.Commenting">
|
vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
<rule ref="Generic.PHP.DeprecatedFunctions"/>
|
8 |
<rule ref="Generic.PHP.ForbiddenFunctions"/>
|
9 |
<rule ref="Generic.Functions.CallTimePassByReference"/>
|
10 |
-
<rule ref="Generic.CodeAnalysis.EmptyStatement"
|
11 |
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
|
12 |
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
|
13 |
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
|
@@ -17,9 +17,10 @@
|
|
17 |
<rule ref="Generic.Classes.DuplicateClassName"/>
|
18 |
<rule ref="Generic.Strings.UnnecessaryStringConcat">
|
19 |
<properties>
|
20 |
-
<property name="allowMultiline" value="true"
|
21 |
</properties>
|
22 |
</rule>
|
|
|
23 |
|
24 |
<!-- More generic PHP best practices.
|
25 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/607 -->
|
@@ -30,7 +31,7 @@
|
|
30 |
|
31 |
<!-- And even more generic PHP best practices.
|
32 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/809 -->
|
33 |
-
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"
|
34 |
|
35 |
<!-- This sniff is not refined enough for general use -->
|
36 |
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/382#discussion_r29970107 -->
|
@@ -42,20 +43,28 @@
|
|
42 |
|
43 |
<rule ref="WordPress-Core"/>
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
<rule ref="WordPress.XSS.EscapeOutput"/>
|
46 |
|
47 |
<!-- Verify that a nonce check is done before using values in superglobals.
|
48 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/73 -->
|
49 |
-
<rule ref="WordPress.CSRF.NonceVerification"
|
50 |
|
51 |
<rule ref="WordPress.PHP.DevelopmentFunctions"/>
|
52 |
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
|
53 |
<!-- WP core still supports PHP 5.2+ -->
|
54 |
<properties>
|
55 |
-
<property name="exclude" value="create_function"
|
56 |
</properties>
|
57 |
</rule>
|
58 |
<rule ref="WordPress.WP.DeprecatedFunctions"/>
|
|
|
|
|
59 |
<rule ref="WordPress.WP.AlternativeFunctions"/>
|
60 |
<rule ref="WordPress.WP.DiscouragedFunctions"/>
|
61 |
|
@@ -75,12 +84,12 @@
|
|
75 |
|
76 |
<!-- Encourage the use of strict ( === and !== ) comparisons.
|
77 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/242 -->
|
78 |
-
<rule ref="WordPress.PHP.StrictComparisons"
|
79 |
|
80 |
<!-- Check that in_array() and array_search() use strict comparisons.
|
81 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/399
|
82 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/503 -->
|
83 |
-
<rule ref="WordPress.PHP.StrictInArray"
|
84 |
|
85 |
<!-- Discourage use of the backtick operator (execution of shell commands).
|
86 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/646 -->
|
@@ -88,7 +97,7 @@
|
|
88 |
|
89 |
<!-- Check for PHP Parse errors.
|
90 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/522 -->
|
91 |
-
<rule ref="Generic.PHP.Syntax"
|
92 |
|
93 |
<!-- Make the translators comment check which is included in core stricter. -->
|
94 |
<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
|
@@ -98,4 +107,11 @@
|
|
98 |
<type>error</type>
|
99 |
</rule>
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
</ruleset>
|
7 |
<rule ref="Generic.PHP.DeprecatedFunctions"/>
|
8 |
<rule ref="Generic.PHP.ForbiddenFunctions"/>
|
9 |
<rule ref="Generic.Functions.CallTimePassByReference"/>
|
10 |
+
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
|
11 |
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
|
12 |
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
|
13 |
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
|
17 |
<rule ref="Generic.Classes.DuplicateClassName"/>
|
18 |
<rule ref="Generic.Strings.UnnecessaryStringConcat">
|
19 |
<properties>
|
20 |
+
<property name="allowMultiline" value="true"/>
|
21 |
</properties>
|
22 |
</rule>
|
23 |
+
<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
|
24 |
|
25 |
<!-- More generic PHP best practices.
|
26 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/607 -->
|
31 |
|
32 |
<!-- And even more generic PHP best practices.
|
33 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/809 -->
|
34 |
+
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
|
35 |
|
36 |
<!-- This sniff is not refined enough for general use -->
|
37 |
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/382#discussion_r29970107 -->
|
43 |
|
44 |
<rule ref="WordPress-Core"/>
|
45 |
|
46 |
+
<!-- Warn against using fully-qualified class names instead of the self keyword. -->
|
47 |
+
<rule ref="Squiz.Classes.SelfMemberReference.NotUsed">
|
48 |
+
<!-- Restore default severity of 5 which WordPress-Core sets to 0. -->
|
49 |
+
<severity>5</severity>
|
50 |
+
</rule>
|
51 |
+
|
52 |
<rule ref="WordPress.XSS.EscapeOutput"/>
|
53 |
|
54 |
<!-- Verify that a nonce check is done before using values in superglobals.
|
55 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/73 -->
|
56 |
+
<rule ref="WordPress.CSRF.NonceVerification"/>
|
57 |
|
58 |
<rule ref="WordPress.PHP.DevelopmentFunctions"/>
|
59 |
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
|
60 |
<!-- WP core still supports PHP 5.2+ -->
|
61 |
<properties>
|
62 |
+
<property name="exclude" value="create_function"/>
|
63 |
</properties>
|
64 |
</rule>
|
65 |
<rule ref="WordPress.WP.DeprecatedFunctions"/>
|
66 |
+
<rule ref="WordPress.WP.DeprecatedClasses"/>
|
67 |
+
<rule ref="WordPress.WP.DeprecatedParameters"/>
|
68 |
<rule ref="WordPress.WP.AlternativeFunctions"/>
|
69 |
<rule ref="WordPress.WP.DiscouragedFunctions"/>
|
70 |
|
84 |
|
85 |
<!-- Encourage the use of strict ( === and !== ) comparisons.
|
86 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/242 -->
|
87 |
+
<rule ref="WordPress.PHP.StrictComparisons"/>
|
88 |
|
89 |
<!-- Check that in_array() and array_search() use strict comparisons.
|
90 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/399
|
91 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/503 -->
|
92 |
+
<rule ref="WordPress.PHP.StrictInArray"/>
|
93 |
|
94 |
<!-- Discourage use of the backtick operator (execution of shell commands).
|
95 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/646 -->
|
97 |
|
98 |
<!-- Check for PHP Parse errors.
|
99 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/522 -->
|
100 |
+
<rule ref="Generic.PHP.Syntax"/>
|
101 |
|
102 |
<!-- Make the translators comment check which is included in core stricter. -->
|
103 |
<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
|
107 |
<type>error</type>
|
108 |
</rule>
|
109 |
|
110 |
+
<!-- Verify that everything in the global namespace is prefixed. -->
|
111 |
+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"/>
|
112 |
+
|
113 |
+
<!-- Check that object instantiations always have braces & are not assigned by reference.
|
114 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/919 -->
|
115 |
+
<rule ref="WordPress.Classes.ClassInstantiation"/>
|
116 |
+
|
117 |
</ruleset>
|
vendor/wp-coding-standards/wpcs/WordPress-VIP/ruleset.xml
CHANGED
@@ -24,19 +24,19 @@
|
|
24 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#validation-sanitization-and-escaping -->
|
25 |
<!-- https://vip.wordpress.com/documentation/best-practices/security/validating-sanitizing-escaping/ -->
|
26 |
<rule ref="WordPress.XSS.EscapeOutput"/>
|
27 |
-
<rule ref="WordPress.CSRF.NonceVerification"
|
28 |
|
29 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-instead-of -->
|
30 |
-
<rule ref="WordPress.PHP.StrictComparisons"
|
31 |
|
32 |
<!-- https://vip.wordpress.com/documentation/best-practices/database-queries/ -->
|
33 |
-
<rule ref="WordPress.WP.PreparedSQL"
|
34 |
|
35 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output -->
|
36 |
<rule ref="Squiz.PHP.CommentedOutCode">
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
</rule>
|
41 |
|
42 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#eval-and-create_function -->
|
@@ -53,7 +53,7 @@
|
|
53 |
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
|
54 |
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/633#issuecomment-266634811 -->
|
55 |
<properties>
|
56 |
-
<property name="exclude" value="obfuscation"
|
57 |
</properties>
|
58 |
</rule>
|
59 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#settings-alteration -->
|
@@ -62,7 +62,7 @@
|
|
62 |
</rule>
|
63 |
|
64 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output -->
|
65 |
-
<rule ref="WordPress.PHP.DevelopmentFunctions"
|
66 |
<rule ref="WordPress.PHP.DevelopmentFunctions.error_log">
|
67 |
<type>error</type>
|
68 |
</rule>
|
@@ -72,13 +72,13 @@
|
|
72 |
</rule>
|
73 |
|
74 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-in_array-without-strict-parameter -->
|
75 |
-
<rule ref="WordPress.PHP.StrictInArray"
|
76 |
|
77 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#use-wp_parse_url-instead-of-parse_url -->
|
78 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#use-wp_json_encode-over-json_encode -->
|
79 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#filesystem-writes -->
|
80 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#remote-calls -->
|
81 |
-
<rule ref="WordPress.WP.AlternativeFunctions"
|
82 |
<!-- VIP recommends other functions -->
|
83 |
<rule ref="WordPress.WP.AlternativeFunctions.curl">
|
84 |
<message>Using cURL functions is highly discouraged within VIP context. Check (Fetching Remote Data) on VIP Documentation.</message>
|
24 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#validation-sanitization-and-escaping -->
|
25 |
<!-- https://vip.wordpress.com/documentation/best-practices/security/validating-sanitizing-escaping/ -->
|
26 |
<rule ref="WordPress.XSS.EscapeOutput"/>
|
27 |
+
<rule ref="WordPress.CSRF.NonceVerification"/>
|
28 |
|
29 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-instead-of -->
|
30 |
+
<rule ref="WordPress.PHP.StrictComparisons"/>
|
31 |
|
32 |
<!-- https://vip.wordpress.com/documentation/best-practices/database-queries/ -->
|
33 |
+
<rule ref="WordPress.WP.PreparedSQL"/>
|
34 |
|
35 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output -->
|
36 |
<rule ref="Squiz.PHP.CommentedOutCode">
|
37 |
+
<properties>
|
38 |
+
<property name="maxPercentage" value="45"/>
|
39 |
+
</properties>
|
40 |
</rule>
|
41 |
|
42 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#eval-and-create_function -->
|
53 |
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
|
54 |
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/633#issuecomment-266634811 -->
|
55 |
<properties>
|
56 |
+
<property name="exclude" value="obfuscation"/>
|
57 |
</properties>
|
58 |
</rule>
|
59 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#settings-alteration -->
|
62 |
</rule>
|
63 |
|
64 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output -->
|
65 |
+
<rule ref="WordPress.PHP.DevelopmentFunctions"/>
|
66 |
<rule ref="WordPress.PHP.DevelopmentFunctions.error_log">
|
67 |
<type>error</type>
|
68 |
</rule>
|
72 |
</rule>
|
73 |
|
74 |
<!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-in_array-without-strict-parameter -->
|
75 |
+
<rule ref="WordPress.PHP.StrictInArray"/>
|
76 |
|
77 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#use-wp_parse_url-instead-of-parse_url -->
|
78 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#use-wp_json_encode-over-json_encode -->
|
79 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#filesystem-writes -->
|
80 |
<!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#remote-calls -->
|
81 |
+
<rule ref="WordPress.WP.AlternativeFunctions"/>
|
82 |
<!-- VIP recommends other functions -->
|
83 |
<rule ref="WordPress.WP.AlternativeFunctions.curl">
|
84 |
<message>Using cURL functions is highly discouraged within VIP context. Check (Fetching Remote Data) on VIP Documentation.</message>
|
vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php
CHANGED
@@ -68,13 +68,12 @@ abstract class WordPress_AbstractArrayAssignmentRestrictionsSniff extends WordPr
|
|
68 |
* This method should be overridden in extending classes.
|
69 |
*
|
70 |
* Example: groups => array(
|
71 |
-
*
|
72 |
-
*
|
73 |
-
*
|
74 |
-
*
|
75 |
-
*
|
76 |
-
*
|
77 |
-
* )
|
78 |
* )
|
79 |
*
|
80 |
* @return array
|
@@ -106,7 +105,7 @@ abstract class WordPress_AbstractArrayAssignmentRestrictionsSniff extends WordPr
|
|
106 |
|
107 |
$token = $this->tokens[ $stackPtr ];
|
108 |
|
109 |
-
if (
|
110 |
$equal = $this->phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
|
111 |
if ( T_EQUAL !== $this->tokens[ $equal ]['code'] ) {
|
112 |
return; // This is not an assignment!
|
@@ -124,7 +123,7 @@ abstract class WordPress_AbstractArrayAssignmentRestrictionsSniff extends WordPr
|
|
124 |
if ( in_array( $token['code'], array( T_CLOSE_SQUARE_BRACKET, T_DOUBLE_ARROW ), true ) ) {
|
125 |
$operator = $stackPtr; // T_DOUBLE_ARROW.
|
126 |
if ( T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
|
127 |
-
$operator = $this->phpcsFile->findNext(
|
128 |
}
|
129 |
|
130 |
$keyIdx = $this->phpcsFile->findPrevious( array( T_WHITESPACE, T_CLOSE_SQUARE_BRACKET ), ( $operator - 1 ), null, true );
|
@@ -185,9 +184,9 @@ abstract class WordPress_AbstractArrayAssignmentRestrictionsSniff extends WordPr
|
|
185 |
);
|
186 |
}
|
187 |
}
|
188 |
-
}
|
189 |
|
190 |
-
} // End
|
191 |
|
192 |
/**
|
193 |
* Callback to process each confirmed key, to check value.
|
68 |
* This method should be overridden in extending classes.
|
69 |
*
|
70 |
* Example: groups => array(
|
71 |
+
* 'groupname' => array(
|
72 |
+
* 'type' => 'error' | 'warning',
|
73 |
+
* 'message' => 'Dont use this one please!',
|
74 |
+
* 'keys' => array( 'key1', 'another_key' ),
|
75 |
+
* 'callback' => array( 'class', 'method' ), // Optional.
|
76 |
+
* )
|
|
|
77 |
* )
|
78 |
*
|
79 |
* @return array
|
105 |
|
106 |
$token = $this->tokens[ $stackPtr ];
|
107 |
|
108 |
+
if ( T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
|
109 |
$equal = $this->phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
|
110 |
if ( T_EQUAL !== $this->tokens[ $equal ]['code'] ) {
|
111 |
return; // This is not an assignment!
|
123 |
if ( in_array( $token['code'], array( T_CLOSE_SQUARE_BRACKET, T_DOUBLE_ARROW ), true ) ) {
|
124 |
$operator = $stackPtr; // T_DOUBLE_ARROW.
|
125 |
if ( T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
|
126 |
+
$operator = $this->phpcsFile->findNext( T_EQUAL, ( $stackPtr + 1 ) );
|
127 |
}
|
128 |
|
129 |
$keyIdx = $this->phpcsFile->findPrevious( array( T_WHITESPACE, T_CLOSE_SQUARE_BRACKET ), ( $operator - 1 ), null, true );
|
184 |
);
|
185 |
}
|
186 |
}
|
187 |
+
}
|
188 |
|
189 |
+
} // End process_token().
|
190 |
|
191 |
/**
|
192 |
* Callback to process each confirmed key, to check value.
|
vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_AbstractFunctionRestrictionsSniff {
|
18 |
|
19 |
/**
|
20 |
-
* Regex pattern with placeholder for the
|
21 |
*
|
22 |
* @var string
|
23 |
*/
|
@@ -36,11 +36,11 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
|
|
36 |
* This method should be overridden in extending classes.
|
37 |
*
|
38 |
* Example: groups => array(
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
*
|
43 |
-
*
|
44 |
* )
|
45 |
*
|
46 |
* You can use * wildcards to target a group of (namespaced) classes.
|
@@ -76,6 +76,10 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
|
|
76 |
/**
|
77 |
* Processes this test, when one of its tokens is encountered.
|
78 |
*
|
|
|
|
|
|
|
|
|
79 |
* @param int $stackPtr The position of the current token in the stack.
|
80 |
*
|
81 |
* @return int|void Integer stack pointer to skip forward or void to continue
|
@@ -85,7 +89,16 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
|
|
85 |
// Reset the temporary storage before processing the token.
|
86 |
unset( $this->classname );
|
87 |
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
/**
|
@@ -118,7 +131,7 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
|
|
118 |
}
|
119 |
|
120 |
if ( T_DOUBLE_COLON === $token['code'] ) {
|
121 |
-
$nameEnd = $this->phpcsFile->findPrevious(
|
122 |
$nameStart = ( $this->phpcsFile->findPrevious( array( T_STRING, T_NS_SEPARATOR, T_NAMESPACE ), ( $nameEnd - 1 ), null, true, null, true ) + 1 );
|
123 |
$length = ( $nameEnd - ( $nameStart - 1) );
|
124 |
$classname = $this->phpcsFile->getTokensAsString( $nameStart, $length );
|
@@ -189,11 +202,7 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
|
|
189 |
*/
|
190 |
protected function prepare_name_for_regex( $classname ) {
|
191 |
$classname = trim( $classname, '\\' ); // Make sure all classnames have a \ prefix, but only one.
|
192 |
-
|
193 |
-
$classname = preg_quote( $classname, '`' );
|
194 |
-
$classname = str_replace( '#', '.*', $classname ); // Replace placeholder with regex wildcard.
|
195 |
-
|
196 |
-
return $classname;
|
197 |
}
|
198 |
|
199 |
/**
|
@@ -232,47 +241,4 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
|
|
232 |
return $classname;
|
233 |
}
|
234 |
|
235 |
-
/**
|
236 |
-
* Determine the namespace name based on whether this is a scoped namespace or a file namespace.
|
237 |
-
*
|
238 |
-
* @param int $search_from The token position to search up from.
|
239 |
-
* @return string Namespace name or empty string if it couldn't be determined or no namespace applied.
|
240 |
-
*/
|
241 |
-
protected function determine_namespace( $search_from ) {
|
242 |
-
$namespace = '';
|
243 |
-
|
244 |
-
if ( ! empty( $this->tokens[ $search_from ]['conditions'] ) ) {
|
245 |
-
// Scoped namespace {}.
|
246 |
-
foreach ( $this->tokens[ $search_from ]['conditions'] as $pointer => $type ) {
|
247 |
-
if ( T_NAMESPACE === $type && $this->tokens[ $pointer ]['scope_closer'] > $search_from ) {
|
248 |
-
$namespace = $this->get_namespace_name( $pointer );
|
249 |
-
}
|
250 |
-
break; // We only need to check the highest level condition.
|
251 |
-
}
|
252 |
-
} else {
|
253 |
-
// Let's see if we can find a file namespace instead.
|
254 |
-
$first = $this->phpcsFile->findNext( array( T_NAMESPACE ), 0, $search_from );
|
255 |
-
|
256 |
-
if ( false !== $first && empty( $this->tokens[ $first ]['scope_condition'] ) ) {
|
257 |
-
$namespace = $this->get_namespace_name( $first );
|
258 |
-
}
|
259 |
-
}
|
260 |
-
|
261 |
-
return $namespace;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Get the namespace name based on the position of the namespace scope opener.
|
266 |
-
*
|
267 |
-
* @param int $namespace_token The token position to search from.
|
268 |
-
* @return string Namespace name.
|
269 |
-
*/
|
270 |
-
protected function get_namespace_name( $namespace_token ) {
|
271 |
-
$nameEnd = ( $this->phpcsFile->findNext( array( T_OPEN_CURLY_BRACKET, T_WHITESPACE, T_SEMICOLON ), ( $namespace_token + 2 ) ) - 1 );
|
272 |
-
$length = ( $nameEnd - ( $namespace_token + 1 ) );
|
273 |
-
$namespace = $this->phpcsFile->getTokensAsString( ( $namespace_token + 2 ), $length );
|
274 |
-
|
275 |
-
return $namespace;
|
276 |
-
}
|
277 |
-
|
278 |
} // End class.
|
17 |
abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_AbstractFunctionRestrictionsSniff {
|
18 |
|
19 |
/**
|
20 |
+
* Regex pattern with placeholder for the class names.
|
21 |
*
|
22 |
* @var string
|
23 |
*/
|
36 |
* This method should be overridden in extending classes.
|
37 |
*
|
38 |
* Example: groups => array(
|
39 |
+
* 'lambda' => array(
|
40 |
+
* 'type' => 'error' | 'warning',
|
41 |
+
* 'message' => 'Avoid direct calls to the database.',
|
42 |
+
* 'classes' => array( 'PDO', '\Namespace\Classname' ),
|
43 |
+
* )
|
44 |
* )
|
45 |
*
|
46 |
* You can use * wildcards to target a group of (namespaced) classes.
|
76 |
/**
|
77 |
* Processes this test, when one of its tokens is encountered.
|
78 |
*
|
79 |
+
* {@internal Unlike in the `WordPress_AbstractFunctionRestrictionsSniff`,
|
80 |
+
* we can't do a preliminary check on classes as at this point
|
81 |
+
* we don't know the class name yet.}}
|
82 |
+
*
|
83 |
* @param int $stackPtr The position of the current token in the stack.
|
84 |
*
|
85 |
* @return int|void Integer stack pointer to skip forward or void to continue
|
89 |
// Reset the temporary storage before processing the token.
|
90 |
unset( $this->classname );
|
91 |
|
92 |
+
$this->excluded_groups = $this->merge_custom_array( $this->exclude );
|
93 |
+
if ( array_diff_key( $this->groups, $this->excluded_groups ) === array() ) {
|
94 |
+
// All groups have been excluded.
|
95 |
+
// Don't remove the listener as the exclude property can be changed inline.
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
|
99 |
+
if ( true === $this->is_targetted_token( $stackPtr ) ) {
|
100 |
+
return $this->check_for_matches( $stackPtr );
|
101 |
+
}
|
102 |
}
|
103 |
|
104 |
/**
|
131 |
}
|
132 |
|
133 |
if ( T_DOUBLE_COLON === $token['code'] ) {
|
134 |
+
$nameEnd = $this->phpcsFile->findPrevious( T_STRING, ( $stackPtr - 1 ) );
|
135 |
$nameStart = ( $this->phpcsFile->findPrevious( array( T_STRING, T_NS_SEPARATOR, T_NAMESPACE ), ( $nameEnd - 1 ), null, true, null, true ) + 1 );
|
136 |
$length = ( $nameEnd - ( $nameStart - 1) );
|
137 |
$classname = $this->phpcsFile->getTokensAsString( $nameStart, $length );
|
202 |
*/
|
203 |
protected function prepare_name_for_regex( $classname ) {
|
204 |
$classname = trim( $classname, '\\' ); // Make sure all classnames have a \ prefix, but only one.
|
205 |
+
return parent::prepare_name_for_regex( $classname );
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
|
208 |
/**
|
241 |
return $classname;
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php
CHANGED
@@ -68,6 +68,15 @@ abstract class WordPress_AbstractFunctionRestrictionsSniff extends WordPress_Sni
|
|
68 |
*/
|
69 |
protected $excluded_groups = array();
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
/**
|
72 |
* Groups of functions to restrict.
|
73 |
*
|
@@ -129,12 +138,14 @@ abstract class WordPress_AbstractFunctionRestrictionsSniff extends WordPress_Sni
|
|
129 |
$this->groups = array_merge( $this->groups, self::$unittest_groups );
|
130 |
}
|
131 |
|
|
|
132 |
foreach ( $this->groups as $groupName => $group ) {
|
133 |
if ( empty( $group[ $key ] ) ) {
|
134 |
unset( $this->groups[ $groupName ] );
|
135 |
} else {
|
136 |
-
$items
|
137 |
-
$
|
|
|
138 |
|
139 |
$this->groups[ $groupName ]['regex'] = sprintf( $this->regex_pattern, $items );
|
140 |
}
|
@@ -144,6 +155,11 @@ abstract class WordPress_AbstractFunctionRestrictionsSniff extends WordPress_Sni
|
|
144 |
return false;
|
145 |
}
|
146 |
|
|
|
|
|
|
|
|
|
|
|
147 |
return true;
|
148 |
}
|
149 |
|
@@ -164,11 +180,18 @@ abstract class WordPress_AbstractFunctionRestrictionsSniff extends WordPress_Sni
|
|
164 |
return;
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
if ( true === $this->is_targetted_token( $stackPtr ) ) {
|
168 |
return $this->check_for_matches( $stackPtr );
|
169 |
}
|
170 |
|
171 |
-
} // End
|
172 |
|
173 |
/**
|
174 |
* Verify is the current token is a function call.
|
68 |
*/
|
69 |
protected $excluded_groups = array();
|
70 |
|
71 |
+
/**
|
72 |
+
* Regex containing the name of all functions handled by a sniff.
|
73 |
+
*
|
74 |
+
* Set in `register()` and used to do an initial check.
|
75 |
+
*
|
76 |
+
* @var string
|
77 |
+
*/
|
78 |
+
private $prelim_check_regex;
|
79 |
+
|
80 |
/**
|
81 |
* Groups of functions to restrict.
|
82 |
*
|
138 |
$this->groups = array_merge( $this->groups, self::$unittest_groups );
|
139 |
}
|
140 |
|
141 |
+
$all_items = array();
|
142 |
foreach ( $this->groups as $groupName => $group ) {
|
143 |
if ( empty( $group[ $key ] ) ) {
|
144 |
unset( $this->groups[ $groupName ] );
|
145 |
} else {
|
146 |
+
$items = array_map( array( $this, 'prepare_name_for_regex' ), $group[ $key ] );
|
147 |
+
$all_items[] = $items;
|
148 |
+
$items = implode( '|', $items );
|
149 |
|
150 |
$this->groups[ $groupName ]['regex'] = sprintf( $this->regex_pattern, $items );
|
151 |
}
|
155 |
return false;
|
156 |
}
|
157 |
|
158 |
+
// Create one "super-regex" to allow for initial filtering.
|
159 |
+
$all_items = call_user_func_array( 'array_merge', $all_items );
|
160 |
+
$all_items = implode( '|', array_unique( $all_items ) );
|
161 |
+
$this->prelim_check_regex = sprintf( $this->regex_pattern, $all_items );
|
162 |
+
|
163 |
return true;
|
164 |
}
|
165 |
|
180 |
return;
|
181 |
}
|
182 |
|
183 |
+
// Preliminary check. If the content of the T_STRING is not one of the functions we're
|
184 |
+
// looking for, we can bow out before doing the heavy lifting of checking whether
|
185 |
+
// this is a function call.
|
186 |
+
if ( preg_match( $this->prelim_check_regex, $this->tokens[ $stackPtr ]['content'] ) !== 1 ) {
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
|
190 |
if ( true === $this->is_targetted_token( $stackPtr ) ) {
|
191 |
return $this->check_for_matches( $stackPtr );
|
192 |
}
|
193 |
|
194 |
+
} // End process_token().
|
195 |
|
196 |
/**
|
197 |
* Verify is the current token is a function call.
|
vendor/wp-coding-standards/wpcs/WordPress/AbstractVariableRestrictionsSniff.php
CHANGED
@@ -60,6 +60,7 @@ abstract class WordPress_AbstractVariableRestrictionsSniff extends WordPress_Sni
|
|
60 |
T_DOUBLE_COLON,
|
61 |
T_OPEN_SQUARE_BRACKET,
|
62 |
T_DOUBLE_QUOTED_STRING,
|
|
|
63 |
);
|
64 |
|
65 |
}
|
@@ -70,13 +71,13 @@ abstract class WordPress_AbstractVariableRestrictionsSniff extends WordPress_Sni
|
|
70 |
* This method should be overridden in extending classes.
|
71 |
*
|
72 |
* Example: groups => array(
|
73 |
-
*
|
74 |
-
*
|
75 |
-
*
|
76 |
-
*
|
77 |
-
*
|
78 |
-
*
|
79 |
-
*
|
80 |
* )
|
81 |
*
|
82 |
* @return array
|
@@ -126,11 +127,13 @@ abstract class WordPress_AbstractVariableRestrictionsSniff extends WordPress_Sni
|
|
126 |
$patterns = array();
|
127 |
|
128 |
// Simple variable.
|
129 |
-
if ( in_array( $token['code'], array( T_VARIABLE, T_DOUBLE_QUOTED_STRING ), true ) && ! empty( $group['variables'] ) ) {
|
130 |
$patterns = array_merge( $patterns, $group['variables'] );
|
131 |
$var = $token['content'];
|
132 |
|
133 |
-
}
|
|
|
|
|
134 |
// Object var, ex: $foo->bar / $foo::bar / Foo::bar / Foo::$bar .
|
135 |
$patterns = array_merge( $patterns, $group['object_vars'] );
|
136 |
|
@@ -138,15 +141,17 @@ abstract class WordPress_AbstractVariableRestrictionsSniff extends WordPress_Sni
|
|
138 |
$child = $this->phpcsFile->findNext( array( T_STRING, T_VAR, T_VARIABLE ), $stackPtr );
|
139 |
$var = implode( '', array( $this->tokens[ $owner ]['content'], $token['content'], $this->tokens[ $child ]['content'] ) );
|
140 |
|
141 |
-
}
|
|
|
|
|
142 |
// Array members.
|
143 |
$patterns = array_merge( $patterns, $group['array_members'] );
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
}
|
151 |
|
152 |
if ( empty( $patterns ) ) {
|
@@ -155,13 +160,13 @@ abstract class WordPress_AbstractVariableRestrictionsSniff extends WordPress_Sni
|
|
155 |
|
156 |
$patterns = array_map( array( $this, 'test_patterns' ), $patterns );
|
157 |
$pattern = implode( '|', $patterns );
|
158 |
-
$delim = ( T_OPEN_SQUARE_BRACKET !== $token['code'] ) ? '\b' : '';
|
159 |
|
160 |
-
if ( T_DOUBLE_QUOTED_STRING === $token['code'] ) {
|
161 |
$var = $token['content'];
|
162 |
}
|
163 |
|
164 |
-
if ( preg_match( '#(' . $pattern . ')' . $delim . '#', $var, $match ) !== 1 ) {
|
165 |
continue;
|
166 |
}
|
167 |
|
@@ -175,9 +180,9 @@ abstract class WordPress_AbstractVariableRestrictionsSniff extends WordPress_Sni
|
|
175 |
|
176 |
return; // Show one error only.
|
177 |
|
178 |
-
}
|
179 |
|
180 |
-
} // End
|
181 |
|
182 |
/**
|
183 |
* Transform a wildcard pattern to a usable regex pattern.
|
60 |
T_DOUBLE_COLON,
|
61 |
T_OPEN_SQUARE_BRACKET,
|
62 |
T_DOUBLE_QUOTED_STRING,
|
63 |
+
T_HEREDOC,
|
64 |
);
|
65 |
|
66 |
}
|
71 |
* This method should be overridden in extending classes.
|
72 |
*
|
73 |
* Example: groups => array(
|
74 |
+
* 'wpdb' => array(
|
75 |
+
* 'type' => 'error' | 'warning',
|
76 |
+
* 'message' => 'Dont use this one please!',
|
77 |
+
* 'variables' => array( '$val', '$var' ),
|
78 |
+
* 'object_vars' => array( '$foo->bar', .. ),
|
79 |
+
* 'array_members' => array( '$foo['bar']', .. ),
|
80 |
+
* )
|
81 |
* )
|
82 |
*
|
83 |
* @return array
|
127 |
$patterns = array();
|
128 |
|
129 |
// Simple variable.
|
130 |
+
if ( in_array( $token['code'], array( T_VARIABLE, T_DOUBLE_QUOTED_STRING, T_HEREDOC ), true ) && ! empty( $group['variables'] ) ) {
|
131 |
$patterns = array_merge( $patterns, $group['variables'] );
|
132 |
$var = $token['content'];
|
133 |
|
134 |
+
}
|
135 |
+
|
136 |
+
if ( in_array( $token['code'], array( T_OBJECT_OPERATOR, T_DOUBLE_COLON, T_DOUBLE_QUOTED_STRING, T_HEREDOC ), true ) && ! empty( $group['object_vars'] ) ) {
|
137 |
// Object var, ex: $foo->bar / $foo::bar / Foo::bar / Foo::$bar .
|
138 |
$patterns = array_merge( $patterns, $group['object_vars'] );
|
139 |
|
141 |
$child = $this->phpcsFile->findNext( array( T_STRING, T_VAR, T_VARIABLE ), $stackPtr );
|
142 |
$var = implode( '', array( $this->tokens[ $owner ]['content'], $token['content'], $this->tokens[ $child ]['content'] ) );
|
143 |
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( in_array( $token['code'], array( T_OPEN_SQUARE_BRACKET, T_DOUBLE_QUOTED_STRING, T_HEREDOC ), true ) && ! empty( $group['array_members'] ) ) {
|
147 |
// Array members.
|
148 |
$patterns = array_merge( $patterns, $group['array_members'] );
|
149 |
|
150 |
+
if ( isset( $token['bracket_closer'] ) ) {
|
151 |
+
$owner = $this->phpcsFile->findPrevious( T_VARIABLE, $stackPtr );
|
152 |
+
$inside = $this->phpcsFile->getTokensAsString( $stackPtr, ( $token['bracket_closer'] - $stackPtr + 1 ) );
|
153 |
+
$var = implode( '', array( $this->tokens[ $owner ]['content'], $inside ) );
|
154 |
+
}
|
155 |
}
|
156 |
|
157 |
if ( empty( $patterns ) ) {
|
160 |
|
161 |
$patterns = array_map( array( $this, 'test_patterns' ), $patterns );
|
162 |
$pattern = implode( '|', $patterns );
|
163 |
+
$delim = ( T_OPEN_SQUARE_BRACKET !== $token['code'] && T_HEREDOC !== $token['code'] ) ? '\b' : '';
|
164 |
|
165 |
+
if ( T_DOUBLE_QUOTED_STRING === $token['code'] || T_HEREDOC === $token['code'] ) {
|
166 |
$var = $token['content'];
|
167 |
}
|
168 |
|
169 |
+
if ( empty( $var ) || preg_match( '#(' . $pattern . ')' . $delim . '#', $var, $match ) !== 1 ) {
|
170 |
continue;
|
171 |
}
|
172 |
|
180 |
|
181 |
return; // Show one error only.
|
182 |
|
183 |
+
}
|
184 |
|
185 |
+
} // End process_token().
|
186 |
|
187 |
/**
|
188 |
* Transform a wildcard pattern to a usable regex pattern.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniff.php
CHANGED
@@ -14,6 +14,17 @@
|
|
14 |
*
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
* @since 0.4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
*/
|
18 |
abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
19 |
|
@@ -258,7 +269,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
258 |
'sanitize_email' => true,
|
259 |
'sanitize_file_name' => true,
|
260 |
'sanitize_hex_color_no_hash' => true,
|
261 |
-
'sanitize_hex_color'
|
262 |
'sanitize_html_class' => true,
|
263 |
'sanitize_meta' => true,
|
264 |
'sanitize_mime_type' => true,
|
@@ -267,6 +278,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
267 |
'sanitize_term_field' => true,
|
268 |
'sanitize_term' => true,
|
269 |
'sanitize_text_field' => true,
|
|
|
270 |
'sanitize_title_for_query' => true,
|
271 |
'sanitize_title_with_dashes' => true,
|
272 |
'sanitize_title' => true,
|
@@ -477,6 +489,273 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
477 |
'current_filter' => 0, // No hook name argument.
|
478 |
);
|
479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
/**
|
481 |
* Whitelist of classes which test classes can extend.
|
482 |
*
|
@@ -487,6 +766,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
487 |
protected $test_class_whitelist = array(
|
488 |
'WP_UnitTestCase' => true,
|
489 |
'PHPUnit_Framework_TestCase' => true,
|
|
|
490 |
);
|
491 |
|
492 |
/**
|
@@ -494,9 +774,9 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
494 |
*
|
495 |
* This property allows end-users to add to the $test_class_whitelist via their ruleset.
|
496 |
* This property will need to be set for each sniff which uses the
|
497 |
-
* `
|
498 |
-
* Currently the method is
|
499 |
-
*
|
500 |
*
|
501 |
* Example usage:
|
502 |
* <rule ref="WordPress.[Subset].[Sniffname]">
|
@@ -529,23 +809,6 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
529 |
*/
|
530 |
protected $tokens;
|
531 |
|
532 |
-
/**
|
533 |
-
* A list of superglobals that incorporate user input.
|
534 |
-
*
|
535 |
-
* @since 0.5.0
|
536 |
-
* @since 0.11.0 Changed from static to non-static.
|
537 |
-
*
|
538 |
-
* @var string[]
|
539 |
-
*/
|
540 |
-
protected $input_superglobals = array(
|
541 |
-
'$_COOKIE',
|
542 |
-
'$_GET',
|
543 |
-
'$_FILES',
|
544 |
-
'$_POST',
|
545 |
-
'$_REQUEST',
|
546 |
-
'$_SERVER',
|
547 |
-
);
|
548 |
-
|
549 |
/**
|
550 |
* Set sniff properties and hand off to child class for processing of the token.
|
551 |
*
|
@@ -819,13 +1082,13 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
819 |
|
820 |
$last = $this->tokens[ $lastPtr ];
|
821 |
|
822 |
-
// Ignore if not a comment.
|
823 |
-
if ( T_COMMENT !== $last['code'] ) {
|
824 |
return false;
|
825 |
}
|
826 |
|
827 |
// Now let's see if the comment contains the whitelist remark we're looking for.
|
828 |
-
return ( preg_match( '
|
829 |
}
|
830 |
|
831 |
/**
|
@@ -833,7 +1096,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
833 |
*
|
834 |
* Unit test methods are identified as such:
|
835 |
* - Method name starts with `test_`.
|
836 |
-
* - Method is within a
|
837 |
*
|
838 |
* @since 0.11.0
|
839 |
*
|
@@ -860,6 +1123,31 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
860 |
$structureToken = $traitToken;
|
861 |
}
|
862 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
863 |
// Add any potentially whitelisted custom test classes to the whitelist.
|
864 |
$whitelist = $this->merge_custom_array(
|
865 |
$this->custom_test_class_whitelist,
|
@@ -867,13 +1155,13 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
867 |
);
|
868 |
|
869 |
// Is the class/trait one of the whitelisted test classes ?
|
870 |
-
$className = $this->phpcsFile->getDeclarationName( $
|
871 |
if ( isset( $whitelist[ $className ] ) ) {
|
872 |
return true;
|
873 |
}
|
874 |
|
875 |
// Does the class/trait extend one of the whitelisted test classes ?
|
876 |
-
$extendedClassName = $this->phpcsFile->findExtendedClassName( $
|
877 |
if ( isset( $whitelist[ $extendedClassName ] ) ) {
|
878 |
return true;
|
879 |
}
|
@@ -892,15 +1180,20 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
892 |
*
|
893 |
* @since 0.5.0
|
894 |
*
|
895 |
-
* @param int $stackPtr The index of the token in the stack. This must
|
896 |
* either a T_VARIABLE or T_CLOSE_SQUARE_BRACKET token.
|
897 |
*
|
898 |
* @return bool Whether the token is a variable being assigned a value.
|
899 |
*/
|
900 |
protected function is_assignment( $stackPtr ) {
|
901 |
|
902 |
-
|
903 |
-
|
|
|
|
|
|
|
|
|
|
|
904 |
return false;
|
905 |
}
|
906 |
|
@@ -1177,17 +1470,24 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1177 |
// Arrays might be sanitized via array_map().
|
1178 |
if ( 'array_map' === $functionName ) {
|
1179 |
|
1180 |
-
// Get the first parameter
|
1181 |
-
$
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1191 |
}
|
1192 |
}
|
1193 |
|
@@ -1243,7 +1543,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1243 |
);
|
1244 |
|
1245 |
// If it isn't a bracket, this isn't an array-access.
|
1246 |
-
if ( T_OPEN_SQUARE_BRACKET !== $this->tokens[ $open_bracket ]['code'] ) {
|
1247 |
return false;
|
1248 |
}
|
1249 |
|
@@ -1341,7 +1641,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1341 |
|
1342 |
$scope_end = $stackPtr;
|
1343 |
|
1344 |
-
}
|
1345 |
|
1346 |
for ( $i = ( $scope_start + 1 ); $i < $scope_end; $i++ ) {
|
1347 |
|
@@ -1408,7 +1708,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1408 |
true
|
1409 |
);
|
1410 |
|
1411 |
-
if (
|
1412 |
return true;
|
1413 |
}
|
1414 |
|
@@ -1431,7 +1731,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1431 |
);
|
1432 |
}
|
1433 |
|
1434 |
-
if (
|
1435 |
return true;
|
1436 |
}
|
1437 |
|
@@ -1481,7 +1781,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1481 |
*
|
1482 |
* @since 0.9.0
|
1483 |
*
|
1484 |
-
* @param string $string A T_DOUBLE_QUOTED_STRING token.
|
1485 |
*
|
1486 |
* @return array Variable names (without '$' sigil).
|
1487 |
*/
|
@@ -1489,7 +1789,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1489 |
$variables = array();
|
1490 |
if ( preg_match_all( '/(?P<backslashes>\\\\*)\$(?P<symbol>\w+)/', $string, $match_sets, PREG_SET_ORDER ) ) {
|
1491 |
foreach ( $match_sets as $matches ) {
|
1492 |
-
if ( ( strlen( $matches['backslashes'] ) % 2 ) === 0 ) {
|
1493 |
$variables[] = $matches['symbol'];
|
1494 |
}
|
1495 |
}
|
@@ -1688,7 +1988,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1688 |
// Prepare for the next parameter.
|
1689 |
$param_start = ( $next_comma + 1 );
|
1690 |
$cnt++;
|
1691 |
-
}
|
1692 |
|
1693 |
return $parameters;
|
1694 |
}
|
@@ -1720,6 +2020,161 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
|
1720 |
return $parameters[ $param_offset ];
|
1721 |
}
|
1722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1723 |
/**
|
1724 |
* Check if a content string contains a specific html open tag.
|
1725 |
*
|
14 |
*
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
* @since 0.4.0
|
17 |
+
*
|
18 |
+
* {@internal This class contains numerous properties where the array format looks
|
19 |
+
* like `'string' => true`, i.e. the array item is set as the array key.
|
20 |
+
* This allows for sniffs to verify whether something is in one of these
|
21 |
+
* lists using `isset()` rather than `in_array()` which is a much more
|
22 |
+
* efficient (faster) check to execute and therefore improves the
|
23 |
+
* performance of the sniffs.
|
24 |
+
* The `true` value in those cases is used as a placeholder and has no
|
25 |
+
* meaning in and of itself.
|
26 |
+
* In the rare few cases where the array values *do* have meaning, this
|
27 |
+
* is documented in the property documentation.}}
|
28 |
*/
|
29 |
abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
|
30 |
|
269 |
'sanitize_email' => true,
|
270 |
'sanitize_file_name' => true,
|
271 |
'sanitize_hex_color_no_hash' => true,
|
272 |
+
'sanitize_hex_color' => true,
|
273 |
'sanitize_html_class' => true,
|
274 |
'sanitize_meta' => true,
|
275 |
'sanitize_mime_type' => true,
|
278 |
'sanitize_term_field' => true,
|
279 |
'sanitize_term' => true,
|
280 |
'sanitize_text_field' => true,
|
281 |
+
'sanitize_textarea_field' => true,
|
282 |
'sanitize_title_for_query' => true,
|
283 |
'sanitize_title_with_dashes' => true,
|
284 |
'sanitize_title' => true,
|
489 |
'current_filter' => 0, // No hook name argument.
|
490 |
);
|
491 |
|
492 |
+
/**
|
493 |
+
* List of global WP variables.
|
494 |
+
*
|
495 |
+
* @since 0.3.0
|
496 |
+
* @since 0.11.0 Changed visibility from public to protected.
|
497 |
+
* @since 0.12.0 Renamed from `$globals` to `$wp_globals` to be more descriptive.
|
498 |
+
* @since 0.12.0 Moved from WordPress_Sniffs_Variables_GlobalVariablesSniff to WordPress_Sniff
|
499 |
+
*
|
500 |
+
* @var array
|
501 |
+
*/
|
502 |
+
protected $wp_globals = array(
|
503 |
+
'_links_add_base' => true,
|
504 |
+
'_links_add_target' => true,
|
505 |
+
'_menu_item_sort_prop' => true,
|
506 |
+
'_nav_menu_placeholder' => true,
|
507 |
+
'_new_bundled_files' => true,
|
508 |
+
'_old_files' => true,
|
509 |
+
'_parent_pages' => true,
|
510 |
+
'_registered_pages' => true,
|
511 |
+
'_updated_user_settings' => true,
|
512 |
+
'_wp_additional_image_sizes' => true,
|
513 |
+
'_wp_admin_css_colors' => true,
|
514 |
+
'_wp_default_headers' => true,
|
515 |
+
'_wp_deprecated_widgets_callbacks' => true,
|
516 |
+
'_wp_last_object_menu' => true,
|
517 |
+
'_wp_last_utility_menu' => true,
|
518 |
+
'_wp_menu_nopriv' => true,
|
519 |
+
'_wp_nav_menu_max_depth' => true,
|
520 |
+
'_wp_post_type_features' => true,
|
521 |
+
'_wp_real_parent_file' => true,
|
522 |
+
'_wp_registered_nav_menus' => true,
|
523 |
+
'_wp_sidebars_widgets' => true,
|
524 |
+
'_wp_submenu_nopriv' => true,
|
525 |
+
'_wp_suspend_cache_invalidation' => true,
|
526 |
+
'_wp_theme_features' => true,
|
527 |
+
'_wp_using_ext_object_cache' => true,
|
528 |
+
'action' => true,
|
529 |
+
'active_signup' => true,
|
530 |
+
'admin_body_class' => true,
|
531 |
+
'admin_page_hooks' => true,
|
532 |
+
'all_links' => true,
|
533 |
+
'allowedentitynames' => true,
|
534 |
+
'allowedposttags' => true,
|
535 |
+
'allowedtags' => true,
|
536 |
+
'auth_secure_cookie' => true,
|
537 |
+
'authordata' => true,
|
538 |
+
'avail_post_mime_types' => true,
|
539 |
+
'avail_post_stati' => true,
|
540 |
+
'blog_id' => true,
|
541 |
+
'blog_title' => true,
|
542 |
+
'blogname' => true,
|
543 |
+
'cat' => true,
|
544 |
+
'cat_id' => true,
|
545 |
+
'charset_collate' => true,
|
546 |
+
'comment' => true,
|
547 |
+
'comment_alt' => true,
|
548 |
+
'comment_depth' => true,
|
549 |
+
'comment_status' => true,
|
550 |
+
'comment_thread_alt' => true,
|
551 |
+
'comment_type' => true,
|
552 |
+
'comments' => true,
|
553 |
+
'compress_css' => true,
|
554 |
+
'compress_scripts' => true,
|
555 |
+
'concatenate_scripts' => true,
|
556 |
+
'current_screen' => true,
|
557 |
+
'current_site' => true,
|
558 |
+
'current_user' => true,
|
559 |
+
'currentcat' => true,
|
560 |
+
'currentday' => true,
|
561 |
+
'currentmonth' => true,
|
562 |
+
'custom_background' => true,
|
563 |
+
'custom_image_header' => true,
|
564 |
+
'default_menu_order' => true,
|
565 |
+
'descriptions' => true,
|
566 |
+
'domain' => true,
|
567 |
+
'editor_styles' => true,
|
568 |
+
'error' => true,
|
569 |
+
'errors' => true,
|
570 |
+
'EZSQL_ERROR' => true,
|
571 |
+
'feeds' => true,
|
572 |
+
'GETID3_ERRORARRAY' => true,
|
573 |
+
'hook_suffix' => true,
|
574 |
+
'HTTP_RAW_POST_DATA' => true,
|
575 |
+
'id' => true,
|
576 |
+
'in_comment_loop' => true,
|
577 |
+
'interim_login' => true,
|
578 |
+
'is_apache' => true,
|
579 |
+
'is_chrome' => true,
|
580 |
+
'is_gecko' => true,
|
581 |
+
'is_IE' => true,
|
582 |
+
'is_IIS' => true,
|
583 |
+
'is_iis7' => true,
|
584 |
+
'is_macIE' => true,
|
585 |
+
'is_opera' => true,
|
586 |
+
'is_safari' => true,
|
587 |
+
'is_winIE' => true,
|
588 |
+
'l10n' => true,
|
589 |
+
'link' => true,
|
590 |
+
'link_id' => true,
|
591 |
+
'locale' => true,
|
592 |
+
'locked_post_status' => true,
|
593 |
+
'lost' => true,
|
594 |
+
'm' => true,
|
595 |
+
'map' => true,
|
596 |
+
'menu' => true,
|
597 |
+
'menu_order' => true,
|
598 |
+
'merged_filters' => true,
|
599 |
+
'mode' => true,
|
600 |
+
'monthnum' => true,
|
601 |
+
'more' => true,
|
602 |
+
'multipage' => true,
|
603 |
+
'names' => true,
|
604 |
+
'nav_menu_selected_id' => true,
|
605 |
+
'new_whitelist_options' => true,
|
606 |
+
'numpages' => true,
|
607 |
+
'one_theme_location_no_menus' => true,
|
608 |
+
'opml' => true,
|
609 |
+
'order' => true,
|
610 |
+
'orderby' => true,
|
611 |
+
'overridden_cpage' => true,
|
612 |
+
'page' => true,
|
613 |
+
'paged' => true,
|
614 |
+
'pagenow' => true,
|
615 |
+
'pages' => true,
|
616 |
+
'parent_file' => true,
|
617 |
+
'pass_allowed_html' => true,
|
618 |
+
'pass_allowed_protocols' => true,
|
619 |
+
'path' => true,
|
620 |
+
'per_page' => true,
|
621 |
+
'PHP_SELF' => true,
|
622 |
+
'phpmailer' => true,
|
623 |
+
'plugin_page' => true,
|
624 |
+
'plugins' => true,
|
625 |
+
'post' => true,
|
626 |
+
'post_default_category' => true,
|
627 |
+
'post_default_title' => true,
|
628 |
+
'post_ID' => true,
|
629 |
+
'post_id' => true,
|
630 |
+
'post_mime_types' => true,
|
631 |
+
'post_type' => true,
|
632 |
+
'post_type_object' => true,
|
633 |
+
'posts' => true,
|
634 |
+
'preview' => true,
|
635 |
+
'previouscat' => true,
|
636 |
+
'previousday' => true,
|
637 |
+
'previousweekday' => true,
|
638 |
+
'redir_tab' => true,
|
639 |
+
'required_mysql_version' => true,
|
640 |
+
'required_php_version' => true,
|
641 |
+
'rnd_value' => true,
|
642 |
+
'role' => true,
|
643 |
+
's' => true,
|
644 |
+
'search' => true,
|
645 |
+
'self' => true,
|
646 |
+
'shortcode_tags' => true,
|
647 |
+
'show_admin_bar' => true,
|
648 |
+
'sidebars_widgets' => true,
|
649 |
+
'status' => true,
|
650 |
+
'submenu' => true,
|
651 |
+
'submenu_file' => true,
|
652 |
+
'super_admins' => true,
|
653 |
+
'tab' => true,
|
654 |
+
'table_prefix' => true,
|
655 |
+
'tabs' => true,
|
656 |
+
'tag' => true,
|
657 |
+
'targets' => true,
|
658 |
+
'tax' => true,
|
659 |
+
'taxnow' => true,
|
660 |
+
'taxonomy' => true,
|
661 |
+
'term' => true,
|
662 |
+
'text_direction' => true,
|
663 |
+
'theme_field_defaults' => true,
|
664 |
+
'themes_allowedtags' => true,
|
665 |
+
'timeend' => true,
|
666 |
+
'timestart' => true,
|
667 |
+
'tinymce_version' => true,
|
668 |
+
'title' => true,
|
669 |
+
'totals' => true,
|
670 |
+
'type' => true,
|
671 |
+
'typenow' => true,
|
672 |
+
'updated_timestamp' => true,
|
673 |
+
'upgrading' => true,
|
674 |
+
'urls' => true,
|
675 |
+
'user_email' => true,
|
676 |
+
'user_ID' => true,
|
677 |
+
'user_identity' => true,
|
678 |
+
'user_level' => true,
|
679 |
+
'user_login' => true,
|
680 |
+
'user_url' => true,
|
681 |
+
'userdata' => true,
|
682 |
+
'usersearch' => true,
|
683 |
+
'whitelist_options' => true,
|
684 |
+
'withcomments' => true,
|
685 |
+
'wp' => true,
|
686 |
+
'wp_actions' => true,
|
687 |
+
'wp_admin_bar' => true,
|
688 |
+
'wp_cockneyreplace' => true,
|
689 |
+
'wp_current_db_version' => true,
|
690 |
+
'wp_current_filter' => true,
|
691 |
+
'wp_customize' => true,
|
692 |
+
'wp_dashboard_control_callbacks' => true,
|
693 |
+
'wp_db_version' => true,
|
694 |
+
'wp_did_header' => true,
|
695 |
+
'wp_embed' => true,
|
696 |
+
'wp_file_descriptions' => true,
|
697 |
+
'wp_filesystem' => true,
|
698 |
+
'wp_filter' => true,
|
699 |
+
'wp_hasher' => true,
|
700 |
+
'wp_header_to_desc' => true,
|
701 |
+
'wp_importers' => true,
|
702 |
+
'wp_json' => true,
|
703 |
+
'wp_list_table' => true,
|
704 |
+
'wp_local_package' => true,
|
705 |
+
'wp_locale' => true,
|
706 |
+
'wp_meta_boxes' => true,
|
707 |
+
'wp_object_cache' => true,
|
708 |
+
'wp_plugin_paths' => true,
|
709 |
+
'wp_post_statuses' => true,
|
710 |
+
'wp_post_types' => true,
|
711 |
+
'wp_queries' => true,
|
712 |
+
'wp_query' => true,
|
713 |
+
'wp_registered_sidebars' => true,
|
714 |
+
'wp_registered_widget_controls' => true,
|
715 |
+
'wp_registered_widget_updates' => true,
|
716 |
+
'wp_registered_widgets' => true,
|
717 |
+
'wp_rewrite' => true,
|
718 |
+
'wp_rich_edit' => true,
|
719 |
+
'wp_rich_edit_exists' => true,
|
720 |
+
'wp_roles' => true,
|
721 |
+
'wp_scripts' => true,
|
722 |
+
'wp_settings_errors' => true,
|
723 |
+
'wp_settings_fields' => true,
|
724 |
+
'wp_settings_sections' => true,
|
725 |
+
'wp_smiliessearch' => true,
|
726 |
+
'wp_styles' => true,
|
727 |
+
'wp_taxonomies' => true,
|
728 |
+
'wp_the_query' => true,
|
729 |
+
'wp_theme_directories' => true,
|
730 |
+
'wp_themes' => true,
|
731 |
+
'wp_user_roles' => true,
|
732 |
+
'wp_version' => true,
|
733 |
+
'wp_widget_factory' => true,
|
734 |
+
'wp_xmlrpc_server' => true,
|
735 |
+
'wpcommentsjavascript' => true,
|
736 |
+
'wpcommentspopupfile' => true,
|
737 |
+
'wpdb' => true,
|
738 |
+
'wpsmiliestrans' => true,
|
739 |
+
'year' => true,
|
740 |
+
);
|
741 |
+
|
742 |
+
/**
|
743 |
+
* A list of superglobals that incorporate user input.
|
744 |
+
*
|
745 |
+
* @since 0.5.0
|
746 |
+
* @since 0.11.0 Changed from static to non-static.
|
747 |
+
*
|
748 |
+
* @var string[]
|
749 |
+
*/
|
750 |
+
protected $input_superglobals = array(
|
751 |
+
'$_COOKIE',
|
752 |
+
'$_GET',
|
753 |
+
'$_FILES',
|
754 |
+
'$_POST',
|
755 |
+
'$_REQUEST',
|
756 |
+
'$_SERVER',
|
757 |
+
);
|
758 |
+
|
759 |
/**
|
760 |
* Whitelist of classes which test classes can extend.
|
761 |
*
|
766 |
protected $test_class_whitelist = array(
|
767 |
'WP_UnitTestCase' => true,
|
768 |
'PHPUnit_Framework_TestCase' => true,
|
769 |
+
'PHPUnit\Framework\TestCase' => true,
|
770 |
);
|
771 |
|
772 |
/**
|
774 |
*
|
775 |
* This property allows end-users to add to the $test_class_whitelist via their ruleset.
|
776 |
* This property will need to be set for each sniff which uses the
|
777 |
+
* `is_test_class()` method.
|
778 |
+
* Currently the method is used by the `WordPress.Variables.GlobalVariables`,
|
779 |
+
* `WordPress.NamingConventions.PrefixAllGlobals` and the `WordPress.Files.Filename` sniffs.
|
780 |
*
|
781 |
* Example usage:
|
782 |
* <rule ref="WordPress.[Subset].[Sniffname]">
|
809 |
*/
|
810 |
protected $tokens;
|
811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
/**
|
813 |
* Set sniff properties and hand off to child class for processing of the token.
|
814 |
*
|
1082 |
|
1083 |
$last = $this->tokens[ $lastPtr ];
|
1084 |
|
1085 |
+
// Ignore if not a comment or not on the same line.
|
1086 |
+
if ( T_COMMENT !== $last['code'] || $last['line'] !== $this->tokens[ $end_of_line ]['line'] ) {
|
1087 |
return false;
|
1088 |
}
|
1089 |
|
1090 |
// Now let's see if the comment contains the whitelist remark we're looking for.
|
1091 |
+
return ( preg_match( '#\b' . preg_quote( $comment, '#' ) . '\b#i', $last['content'] ) === 1 );
|
1092 |
}
|
1093 |
|
1094 |
/**
|
1096 |
*
|
1097 |
* Unit test methods are identified as such:
|
1098 |
* - Method name starts with `test_`.
|
1099 |
+
* - Method is within a unit test class.
|
1100 |
*
|
1101 |
* @since 0.11.0
|
1102 |
*
|
1123 |
$structureToken = $traitToken;
|
1124 |
}
|
1125 |
|
1126 |
+
return $this->is_test_class( $structureToken );
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
/**
|
1130 |
+
* Check if a class token is part of a unit test suite.
|
1131 |
+
*
|
1132 |
+
* Unit test classes are identified as such:
|
1133 |
+
* - Class which either extends WP_UnitTestCase or PHPUnit_Framework_TestCase
|
1134 |
+
* or a custom whitelisted unit test class.
|
1135 |
+
*
|
1136 |
+
* @since 0.12.0 Split off from the `is_token_in_test_method()` method.
|
1137 |
+
*
|
1138 |
+
* @param int $stackPtr The position of the token to be examined.
|
1139 |
+
* This should be a class, anonymous class or trait token.
|
1140 |
+
*
|
1141 |
+
* @return bool True if the class is a unit test class, false otherwise.
|
1142 |
+
*/
|
1143 |
+
protected function is_test_class( $stackPtr ) {
|
1144 |
+
|
1145 |
+
if ( ! isset( $this->tokens[ $stackPtr ] )
|
1146 |
+
|| in_array( $this->tokens[ $stackPtr ]['type'], array( 'T_CLASS', 'T_ANON_CLASS', 'T_TRAIT' ), true ) === false
|
1147 |
+
) {
|
1148 |
+
return false;
|
1149 |
+
}
|
1150 |
+
|
1151 |
// Add any potentially whitelisted custom test classes to the whitelist.
|
1152 |
$whitelist = $this->merge_custom_array(
|
1153 |
$this->custom_test_class_whitelist,
|
1155 |
);
|
1156 |
|
1157 |
// Is the class/trait one of the whitelisted test classes ?
|
1158 |
+
$className = $this->phpcsFile->getDeclarationName( $stackPtr );
|
1159 |
if ( isset( $whitelist[ $className ] ) ) {
|
1160 |
return true;
|
1161 |
}
|
1162 |
|
1163 |
// Does the class/trait extend one of the whitelisted test classes ?
|
1164 |
+
$extendedClassName = $this->phpcsFile->findExtendedClassName( $stackPtr );
|
1165 |
if ( isset( $whitelist[ $extendedClassName ] ) ) {
|
1166 |
return true;
|
1167 |
}
|
1180 |
*
|
1181 |
* @since 0.5.0
|
1182 |
*
|
1183 |
+
* @param int $stackPtr The index of the token in the stack. This must point to
|
1184 |
* either a T_VARIABLE or T_CLOSE_SQUARE_BRACKET token.
|
1185 |
*
|
1186 |
* @return bool Whether the token is a variable being assigned a value.
|
1187 |
*/
|
1188 |
protected function is_assignment( $stackPtr ) {
|
1189 |
|
1190 |
+
static $valid = array(
|
1191 |
+
T_VARIABLE => true,
|
1192 |
+
T_CLOSE_SQUARE_BRACKET => true,
|
1193 |
+
);
|
1194 |
+
|
1195 |
+
// Must be a variable, constant or closing square bracket (see below).
|
1196 |
+
if ( ! isset( $valid[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
|
1197 |
return false;
|
1198 |
}
|
1199 |
|
1470 |
// Arrays might be sanitized via array_map().
|
1471 |
if ( 'array_map' === $functionName ) {
|
1472 |
|
1473 |
+
// Get the first parameter.
|
1474 |
+
$callback = $this->get_function_call_parameter( ( $function_opener - 1 ), 1 );
|
1475 |
+
|
1476 |
+
if ( ! empty( $callback ) ) {
|
1477 |
+
/*
|
1478 |
+
* If this is a function callback (not a method callback array) and we're able
|
1479 |
+
* to resolve the function name, do so.
|
1480 |
+
*/
|
1481 |
+
$first_non_empty = $this->phpcsFile->findNext(
|
1482 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
1483 |
+
$callback['start'],
|
1484 |
+
( $callback['end'] + 1 ),
|
1485 |
+
true
|
1486 |
+
);
|
1487 |
+
|
1488 |
+
if ( false !== $first_non_empty && T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
|
1489 |
+
$functionName = $this->strip_quotes( $this->tokens[ $first_non_empty ]['content'] );
|
1490 |
+
}
|
1491 |
}
|
1492 |
}
|
1493 |
|
1543 |
);
|
1544 |
|
1545 |
// If it isn't a bracket, this isn't an array-access.
|
1546 |
+
if ( false === $open_bracket || T_OPEN_SQUARE_BRACKET !== $this->tokens[ $open_bracket ]['code'] ) {
|
1547 |
return false;
|
1548 |
}
|
1549 |
|
1641 |
|
1642 |
$scope_end = $stackPtr;
|
1643 |
|
1644 |
+
}
|
1645 |
|
1646 |
for ( $i = ( $scope_start + 1 ); $i < $scope_end; $i++ ) {
|
1647 |
|
1708 |
true
|
1709 |
);
|
1710 |
|
1711 |
+
if ( isset( PHP_CodeSniffer_Tokens::$comparisonTokens[ $this->tokens[ $previous_token ]['code'] ] ) ) {
|
1712 |
return true;
|
1713 |
}
|
1714 |
|
1731 |
);
|
1732 |
}
|
1733 |
|
1734 |
+
if ( isset( PHP_CodeSniffer_Tokens::$comparisonTokens[ $this->tokens[ $next_token ]['code'] ] ) ) {
|
1735 |
return true;
|
1736 |
}
|
1737 |
|
1781 |
*
|
1782 |
* @since 0.9.0
|
1783 |
*
|
1784 |
+
* @param string $string A T_DOUBLE_QUOTED_STRING or T_HEREDOC token.
|
1785 |
*
|
1786 |
* @return array Variable names (without '$' sigil).
|
1787 |
*/
|
1789 |
$variables = array();
|
1790 |
if ( preg_match_all( '/(?P<backslashes>\\\\*)\$(?P<symbol>\w+)/', $string, $match_sets, PREG_SET_ORDER ) ) {
|
1791 |
foreach ( $match_sets as $matches ) {
|
1792 |
+
if ( ! isset( $matches['backslashes'] ) || ( strlen( $matches['backslashes'] ) % 2 ) === 0 ) {
|
1793 |
$variables[] = $matches['symbol'];
|
1794 |
}
|
1795 |
}
|
1988 |
// Prepare for the next parameter.
|
1989 |
$param_start = ( $next_comma + 1 );
|
1990 |
$cnt++;
|
1991 |
+
}
|
1992 |
|
1993 |
return $parameters;
|
1994 |
}
|
2020 |
return $parameters[ $param_offset ];
|
2021 |
}
|
2022 |
|
2023 |
+
/**
|
2024 |
+
* Find the array opener & closer based on a T_ARRAY or T_OPEN_SHORT_ARRAY token.
|
2025 |
+
*
|
2026 |
+
* @param int $stackPtr The stack pointer to the array token.
|
2027 |
+
*
|
2028 |
+
* @return array|bool Array with two keys `opener`, `closer` or false if
|
2029 |
+
* either or these could not be determined.
|
2030 |
+
*/
|
2031 |
+
protected function find_array_open_close( $stackPtr ) {
|
2032 |
+
/*
|
2033 |
+
* Determine the array opener & closer.
|
2034 |
+
*/
|
2035 |
+
if ( T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) {
|
2036 |
+
if ( isset( $this->tokens[ $stackPtr ]['parenthesis_opener'] ) ) {
|
2037 |
+
$opener = $this->tokens[ $stackPtr ]['parenthesis_opener'];
|
2038 |
+
|
2039 |
+
if ( isset( $this->tokens[ $opener ]['parenthesis_closer'] ) ) {
|
2040 |
+
$closer = $this->tokens[ $opener ]['parenthesis_closer'];
|
2041 |
+
}
|
2042 |
+
}
|
2043 |
+
} else {
|
2044 |
+
// Short array syntax.
|
2045 |
+
$opener = $stackPtr;
|
2046 |
+
|
2047 |
+
if ( isset( $this->tokens[ $stackPtr ]['bracket_closer'] ) ) {
|
2048 |
+
$closer = $this->tokens[ $stackPtr ]['bracket_closer'];
|
2049 |
+
}
|
2050 |
+
}
|
2051 |
+
|
2052 |
+
if ( isset( $opener, $closer ) ) {
|
2053 |
+
return array(
|
2054 |
+
'opener' => $opener,
|
2055 |
+
'closer' => $closer,
|
2056 |
+
);
|
2057 |
+
}
|
2058 |
+
|
2059 |
+
return false;
|
2060 |
+
}
|
2061 |
+
|
2062 |
+
/**
|
2063 |
+
* Determine the namespace name an arbitrary token lives in.
|
2064 |
+
*
|
2065 |
+
* @since 0.10.0
|
2066 |
+
* @since 0.12.0 Moved from the WordPress_AbstractClassRestrictionsSniff to this sniff.
|
2067 |
+
*
|
2068 |
+
* @param int $stackPtr The token position for which to determine the namespace.
|
2069 |
+
*
|
2070 |
+
* @return string Namespace name or empty string if it couldn't be determined or no namespace applies.
|
2071 |
+
*/
|
2072 |
+
public function determine_namespace( $stackPtr ) {
|
2073 |
+
|
2074 |
+
// Check for the existence of the token.
|
2075 |
+
if ( ! isset( $this->tokens[ $stackPtr ] ) ) {
|
2076 |
+
return '';
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
// Check for scoped namespace {}.
|
2080 |
+
if ( ! empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
|
2081 |
+
$namespacePtr = $this->phpcsFile->getCondition( $stackPtr, T_NAMESPACE );
|
2082 |
+
if ( false !== $namespacePtr ) {
|
2083 |
+
$namespace = $this->get_declared_namespace_name( $namespacePtr );
|
2084 |
+
if ( false !== $namespace ) {
|
2085 |
+
return $namespace;
|
2086 |
+
}
|
2087 |
+
|
2088 |
+
// We are in a scoped namespace, but couldn't determine the name.
|
2089 |
+
// Searching for a global namespace is futile.
|
2090 |
+
return '';
|
2091 |
+
}
|
2092 |
+
}
|
2093 |
+
|
2094 |
+
/*
|
2095 |
+
* Not in a scoped namespace, so let's see if we can find a non-scoped namespace instead.
|
2096 |
+
* Keeping in mind that:
|
2097 |
+
* - there can be multiple non-scoped namespaces in a file (bad practice, but it happens).
|
2098 |
+
* - the namespace keyword can also be used as part of a function/method call and such.
|
2099 |
+
* - that a non-named namespace resolves to the global namespace.
|
2100 |
+
*/
|
2101 |
+
$previousNSToken = $stackPtr;
|
2102 |
+
$namespace = false;
|
2103 |
+
do {
|
2104 |
+
$previousNSToken = $this->phpcsFile->findPrevious( T_NAMESPACE, ( $previousNSToken - 1 ) );
|
2105 |
+
|
2106 |
+
// Stop if we encounter a scoped namespace declaration as we already know we're not in one.
|
2107 |
+
if ( ! empty( $this->tokens[ $previousNSToken ]['scope_condition'] )
|
2108 |
+
&& $this->tokens[ $previousNSToken ]['scope_condition'] === $previousNSToken
|
2109 |
+
) {
|
2110 |
+
break;
|
2111 |
+
}
|
2112 |
+
|
2113 |
+
$namespace = $this->get_declared_namespace_name( $previousNSToken );
|
2114 |
+
|
2115 |
+
} while ( false === $namespace && false !== $previousNSToken );
|
2116 |
+
|
2117 |
+
// If we still haven't got a namespace, return an empty string.
|
2118 |
+
if ( false === $namespace ) {
|
2119 |
+
return '';
|
2120 |
+
}
|
2121 |
+
|
2122 |
+
return $namespace;
|
2123 |
+
}
|
2124 |
+
|
2125 |
+
/**
|
2126 |
+
* Get the complete namespace name for a namespace declaration.
|
2127 |
+
*
|
2128 |
+
* For hierarchical namespaces, the name will be composed of several tokens,
|
2129 |
+
* i.e. MyProject\Sub\Level which will be returned together as one string.
|
2130 |
+
*
|
2131 |
+
* @since 0.12.0 A lesser variant of this method previously existed in the
|
2132 |
+
* WordPress_AbstractClassRestrictionsSniff.
|
2133 |
+
*
|
2134 |
+
* @param int|bool $stackPtr The position of a T_NAMESPACE token.
|
2135 |
+
*
|
2136 |
+
* @return string|false Namespace name or false if not a namespace declaration.
|
2137 |
+
* Namespace name can be an empty string for global namespace declaration.
|
2138 |
+
*/
|
2139 |
+
public function get_declared_namespace_name( $stackPtr ) {
|
2140 |
+
|
2141 |
+
// Check for the existence of the token.
|
2142 |
+
if ( false === $stackPtr || ! isset( $this->tokens[ $stackPtr ] ) ) {
|
2143 |
+
return false;
|
2144 |
+
}
|
2145 |
+
|
2146 |
+
if ( T_NAMESPACE !== $this->tokens[ $stackPtr ]['code'] ) {
|
2147 |
+
return false;
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
if ( T_NS_SEPARATOR === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
|
2151 |
+
// Not a namespace declaration, but use of, i.e. `namespace\someFunction();`.
|
2152 |
+
return false;
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
$nextToken = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
|
2156 |
+
if ( T_OPEN_CURLY_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
|
2157 |
+
// Declaration for global namespace when using multiple namespaces in a file.
|
2158 |
+
// I.e.: `namespace {}`.
|
2159 |
+
return '';
|
2160 |
+
}
|
2161 |
+
|
2162 |
+
// Ok, this should be a namespace declaration, so get all the parts together.
|
2163 |
+
$validTokens = array(
|
2164 |
+
T_STRING => true,
|
2165 |
+
T_NS_SEPARATOR => true,
|
2166 |
+
T_WHITESPACE => true,
|
2167 |
+
);
|
2168 |
+
|
2169 |
+
$namespaceName = '';
|
2170 |
+
while ( isset( $validTokens[ $this->tokens[ $nextToken ]['code'] ] ) ) {
|
2171 |
+
$namespaceName .= trim( $this->tokens[ $nextToken ]['content'] );
|
2172 |
+
$nextToken++;
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
return $namespaceName;
|
2176 |
+
}
|
2177 |
+
|
2178 |
/**
|
2179 |
* Check if a content string contains a specific html open tag.
|
2180 |
*
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php
CHANGED
@@ -27,13 +27,12 @@ class WordPress_Sniffs_Arrays_ArrayAssignmentRestrictionsSniff extends WordPress
|
|
27 |
* Groups of variables to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
* )
|
37 |
* )
|
38 |
*
|
39 |
* @return array
|
27 |
* Groups of variables to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
+
* 'groupname' => array(
|
31 |
+
* 'type' => 'error' | 'warning',
|
32 |
+
* 'message' => 'Dont use this one please!',
|
33 |
+
* 'keys' => array( 'key1', 'another_key' ),
|
34 |
+
* 'callback' => array( 'class', 'method' ), // Optional.
|
35 |
+
* )
|
|
|
36 |
* )
|
37 |
*
|
38 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php
CHANGED
@@ -142,6 +142,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
142 |
$currentEntry = array();
|
143 |
|
144 |
if ($tokens[$nextToken]['code'] === T_COMMA) {
|
|
|
145 |
$stackPtrCount = 0;
|
146 |
if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
|
147 |
$stackPtrCount = count( $tokens[ $stackPtr ]['nested_parenthesis'] );
|
@@ -163,7 +164,6 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
163 |
continue;
|
164 |
}
|
165 |
|
166 |
-
/*
|
167 |
if ($keyUsed === true && $tokens[$lastToken]['code'] === T_COMMA) {
|
168 |
$error = 'No key specified for array entry; first entry specifies key';
|
169 |
$phpcsFile->addError( $error, $nextToken, 'NoKeySpecified' );
|
@@ -172,6 +172,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
172 |
*/
|
173 |
|
174 |
if ($keyUsed === false) {
|
|
|
175 |
if ($tokens[($nextToken - 1)]['code'] === T_WHITESPACE) {
|
176 |
$content = $tokens[ ( $nextToken - 2 ) ]['content'];
|
177 |
if ( $tokens[ ( $nextToken - 1 ) ]['content'] === $phpcsFile->eolChar ) {
|
@@ -191,6 +192,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
191 |
$phpcsFile->fixer->replaceToken( ( $nextToken - 1 ), '' );
|
192 |
}
|
193 |
}
|
|
|
194 |
|
195 |
$valueContent = $phpcsFile->findNext(
|
196 |
PHP_CodeSniffer_Tokens::$emptyTokens,
|
@@ -200,7 +202,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
200 |
);
|
201 |
|
202 |
$indices[] = array( 'value' => $valueContent );
|
203 |
-
$singleUsed = true;
|
204 |
}//end if
|
205 |
|
206 |
$lastToken = $nextToken;
|
@@ -320,6 +322,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
320 |
true
|
321 |
);
|
322 |
|
|
|
323 |
if ($tokens[$trailingContent]['code'] !== T_COMMA) {
|
324 |
$phpcsFile->recordMetric( $stackPtr, 'Array end comma', 'no' );
|
325 |
$error = 'Comma required after last value in array declaration';
|
@@ -330,6 +333,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
330 |
} else {
|
331 |
$phpcsFile->recordMetric( $stackPtr, 'Array end comma', 'yes' );
|
332 |
}
|
|
|
333 |
|
334 |
$lastValueLine = false;
|
335 |
foreach ( $indices as $value ) {
|
@@ -531,6 +535,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
531 |
*/
|
532 |
|
533 |
// Check each line ends in a comma.
|
|
|
534 |
$valueLine = $tokens[ $index['value'] ]['line'];
|
535 |
$nextComma = false;
|
536 |
for ( $i = $index['value']; $i < $arrayEnd; $i++ ) {
|
@@ -604,6 +609,7 @@ class WordPress_Sniffs_Arrays_ArrayDeclarationSniff extends Squiz_Sniffs_Arrays_
|
|
604 |
$phpcsFile->fixer->replaceToken( ( $nextComma - 1 ), '' );
|
605 |
}
|
606 |
}
|
|
|
607 |
}//end foreach
|
608 |
|
609 |
}//end processMultiLineArray()
|
142 |
$currentEntry = array();
|
143 |
|
144 |
if ($tokens[$nextToken]['code'] === T_COMMA) {
|
145 |
+
/*
|
146 |
$stackPtrCount = 0;
|
147 |
if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
|
148 |
$stackPtrCount = count( $tokens[ $stackPtr ]['nested_parenthesis'] );
|
164 |
continue;
|
165 |
}
|
166 |
|
|
|
167 |
if ($keyUsed === true && $tokens[$lastToken]['code'] === T_COMMA) {
|
168 |
$error = 'No key specified for array entry; first entry specifies key';
|
169 |
$phpcsFile->addError( $error, $nextToken, 'NoKeySpecified' );
|
172 |
*/
|
173 |
|
174 |
if ($keyUsed === false) {
|
175 |
+
/*
|
176 |
if ($tokens[($nextToken - 1)]['code'] === T_WHITESPACE) {
|
177 |
$content = $tokens[ ( $nextToken - 2 ) ]['content'];
|
178 |
if ( $tokens[ ( $nextToken - 1 ) ]['content'] === $phpcsFile->eolChar ) {
|
192 |
$phpcsFile->fixer->replaceToken( ( $nextToken - 1 ), '' );
|
193 |
}
|
194 |
}
|
195 |
+
*/
|
196 |
|
197 |
$valueContent = $phpcsFile->findNext(
|
198 |
PHP_CodeSniffer_Tokens::$emptyTokens,
|
202 |
);
|
203 |
|
204 |
$indices[] = array( 'value' => $valueContent );
|
205 |
+
// $singleUsed = true;
|
206 |
}//end if
|
207 |
|
208 |
$lastToken = $nextToken;
|
322 |
true
|
323 |
);
|
324 |
|
325 |
+
/*
|
326 |
if ($tokens[$trailingContent]['code'] !== T_COMMA) {
|
327 |
$phpcsFile->recordMetric( $stackPtr, 'Array end comma', 'no' );
|
328 |
$error = 'Comma required after last value in array declaration';
|
333 |
} else {
|
334 |
$phpcsFile->recordMetric( $stackPtr, 'Array end comma', 'yes' );
|
335 |
}
|
336 |
+
*/
|
337 |
|
338 |
$lastValueLine = false;
|
339 |
foreach ( $indices as $value ) {
|
535 |
*/
|
536 |
|
537 |
// Check each line ends in a comma.
|
538 |
+
/*
|
539 |
$valueLine = $tokens[ $index['value'] ]['line'];
|
540 |
$nextComma = false;
|
541 |
for ( $i = $index['value']; $i < $arrayEnd; $i++ ) {
|
609 |
$phpcsFile->fixer->replaceToken( ( $nextComma - 1 ), '' );
|
610 |
}
|
611 |
}
|
612 |
+
*/
|
613 |
}//end foreach
|
614 |
|
615 |
}//end processMultiLineArray()
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php
CHANGED
@@ -7,12 +7,14 @@
|
|
7 |
* @license https://opensource.org/licenses/MIT MIT
|
8 |
*/
|
9 |
|
10 |
-
if ( ! class_exists( 'Squiz_Sniffs_Arrays_ArrayDeclarationSniff', true ) ) {
|
11 |
-
throw new PHP_CodeSniffer_Exception( 'Class Squiz_Sniffs_Arrays_ArrayDeclarationSniff not found' );
|
12 |
-
}
|
13 |
-
|
14 |
/**
|
15 |
-
* Enforces WordPress array format
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
*
|
17 |
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#indentation
|
18 |
*
|
@@ -22,227 +24,204 @@ if ( ! class_exists( 'Squiz_Sniffs_Arrays_ArrayDeclarationSniff', true ) ) {
|
|
22 |
* from the WordPress_Sniffs_Arrays_ArrayDeclaration sniff into
|
23 |
* this sniff.
|
24 |
* - Added sniffing & fixing for associative arrays.
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* process logic which routes the processing to the single-line/multi-line methods.
|
28 |
-
* Other than that, the actual sniffing from the upstream sniff is disregarded.
|
29 |
-
* In other words: no real syncing with upstream necessary.}}
|
30 |
-
*
|
31 |
-
* Last synced with parent class October 5 2016 at commit ea32814346ecf29791de701b3fa464a9ca43f45b.
|
32 |
-
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php
|
33 |
*/
|
34 |
-
class WordPress_Sniffs_Arrays_ArrayDeclarationSpacingSniff extends
|
35 |
|
36 |
/**
|
37 |
-
*
|
|
|
|
|
|
|
38 |
*
|
39 |
-
* @since 0.
|
40 |
-
* @since 0.11.0 Moved from WordPress_Sniffs_Arrays_ArrayDeclaration to this sniff.
|
41 |
*
|
42 |
-
* @
|
43 |
-
* @param int $stackPtr The position of the current token
|
44 |
-
* in the stack passed in $tokens.
|
45 |
-
* @param int $arrayStart Position of the array opener in the token stack.
|
46 |
-
* @param int $arrayEnd Position of the array closer in the token stack.
|
47 |
*/
|
48 |
-
|
|
|
|
|
|
|
49 |
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
return;
|
53 |
}
|
54 |
|
55 |
-
$
|
56 |
-
|
57 |
-
|
58 |
-
if ( T_WHITESPACE !== $tokens[ ( $arrayStart + 1 ) ]['code'] ) {
|
59 |
-
|
60 |
-
$warning = 'Missing space after array opener.';
|
61 |
-
$fix = $phpcsFile->addFixableError( $warning, $arrayStart, 'NoSpaceAfterArrayOpener' );
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
} elseif ( ' ' !== $tokens[ ( $arrayStart + 1 ) ]['content'] ) {
|
67 |
-
|
68 |
-
$fix = $phpcsFile->addFixableError(
|
69 |
-
'Expected 1 space after array opener, found %s.',
|
70 |
-
$arrayStart,
|
71 |
-
'SpaceAfterArrayOpener',
|
72 |
-
array( strlen( $tokens[ ( $arrayStart + 1 ) ]['content'] ) )
|
73 |
-
);
|
74 |
-
|
75 |
-
if ( true === $fix ) {
|
76 |
-
$phpcsFile->fixer->replaceToken( ( $arrayStart + 1 ), ' ' );
|
77 |
-
}
|
78 |
}
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
$fix = $phpcsFile->addFixableError( $warning, $arrayEnd, 'NoSpaceBeforeArrayCloser' );
|
84 |
-
|
85 |
-
if ( true === $fix ) {
|
86 |
-
$phpcsFile->fixer->addContentBefore( $arrayEnd, ' ' );
|
87 |
-
}
|
88 |
-
} elseif ( ' ' !== $tokens[ ( $arrayEnd - 1 ) ]['content'] ) {
|
89 |
-
|
90 |
-
$fix = $phpcsFile->addFixableError(
|
91 |
-
'Expected 1 space before array closer, found %s.',
|
92 |
-
$arrayEnd,
|
93 |
-
'SpaceBeforeArrayCloser',
|
94 |
-
array( strlen( $tokens[ ( $arrayEnd - 1 ) ]['content'] ) )
|
95 |
-
);
|
96 |
-
|
97 |
-
if ( true === $fix ) {
|
98 |
-
$phpcsFile->fixer->replaceToken( ( $arrayEnd - 1 ), ' ' );
|
99 |
-
}
|
100 |
}
|
101 |
|
102 |
-
|
|
|
|
|
|
|
103 |
if ( false !== $array_has_keys ) {
|
104 |
-
$fix = $phpcsFile->addFixableError(
|
105 |
-
'When an array uses associative keys, each value should start on a new line.',
|
106 |
-
$arrayEnd,
|
107 |
-
'AssociativeKeyFound'
|
108 |
-
);
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
|
118 |
-
if (
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
-
|
|
|
124 |
}
|
125 |
}
|
126 |
}
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* (Don't) Process a multi-line array.
|
131 |
-
*
|
132 |
-
* {@internal Multi-line arrays are handled by the upstream sniff via the
|
133 |
-
* WordPress_Sniffs_Arrays_ArrayDeclaration sniff.}}
|
134 |
-
*
|
135 |
-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
136 |
-
* @param int $stackPtr The position of the current token
|
137 |
-
* in the stack passed in $tokens.
|
138 |
-
* @param int $arrayStart Position of the array opener in the token stack.
|
139 |
-
* @param int $arrayEnd Position of the array closer in the token stack.
|
140 |
-
*/
|
141 |
-
public function processMultiLineArray( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $arrayStart, $arrayEnd ) {
|
142 |
-
return;
|
143 |
-
} // End processMultiLineArray().
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Create & apply a changeset for a single line array with associative keys.
|
147 |
-
*
|
148 |
-
* @since 0.11.0
|
149 |
-
*
|
150 |
-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
151 |
-
* @param int $arrayStart Position of the array opener in the token stack.
|
152 |
-
* @param int $arrayEnd Position of the array closer in the token stack.
|
153 |
-
* @return void
|
154 |
-
*/
|
155 |
-
protected function fix_associative_array( PHP_CodeSniffer_File $phpcsFile, $arrayStart, $arrayEnd ) {
|
156 |
|
157 |
-
|
|
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
}
|
165 |
|
166 |
-
if (
|
167 |
-
|
168 |
-
$indentation = str_replace( ' ', "\t", $tokens[ ( $i + 1 ) ]['content'] );
|
169 |
}
|
170 |
-
|
171 |
-
}
|
172 |
-
unset( $i );
|
173 |
-
|
174 |
-
$value_indentation = "\t" . $indentation;
|
175 |
-
|
176 |
-
// Which nesting level is the one we are interested in ?
|
177 |
-
$nesting_count = 1;
|
178 |
-
if ( T_OPEN_SHORT_ARRAY === $tokens[ $arrayStart ]['code'] ) {
|
179 |
-
$nesting_count = 0;
|
180 |
-
}
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
$phpcsFile->fixer->addNewline( $arrayStart );
|
190 |
-
if ( T_WHITESPACE === $tokens[ ( $arrayStart + 1 ) ]['code'] ) {
|
191 |
-
$phpcsFile->fixer->replaceToken( ( $arrayStart + 1 ), $value_indentation );
|
192 |
-
} else {
|
193 |
-
$phpcsFile->fixer->addContentBefore( ( $arrayStart + 1 ), $value_indentation );
|
194 |
-
}
|
195 |
-
|
196 |
-
for ( $ptr = ( $arrayStart + 1 ); $ptr < $arrayEnd; $ptr++ ) {
|
197 |
-
$ptr = $phpcsFile->findNext( array( T_COMMA, T_OPEN_SHORT_ARRAY ), $ptr, $arrayEnd );
|
198 |
|
199 |
-
if (
|
200 |
-
|
201 |
}
|
|
|
202 |
|
203 |
-
|
204 |
-
// Necessary as the nesting level in that case is still the same.
|
205 |
-
if ( 'T_OPEN_SHORT_ARRAY' === $tokens[ $ptr ]['type']
|
206 |
-
&& ( isset( $tokens[ $ptr ]['bracket_opener'] )
|
207 |
-
&& $tokens[ $ptr ]['bracket_opener'] === $ptr )
|
208 |
-
&& isset( $tokens[ $ptr ]['bracket_closer'] )
|
209 |
-
) {
|
210 |
-
$ptr = $tokens[ $ptr ]['bracket_closer'];
|
211 |
-
continue;
|
212 |
-
}
|
213 |
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
)
|
219 |
-
continue;
|
220 |
-
}
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
if ( T_WHITESPACE === $tokens[ ( $ptr + 1 ) ]['code'] ) {
|
225 |
-
$phpcsFile->fixer->replaceToken( ( $ptr + 1 ), $value_indentation );
|
226 |
-
} else {
|
227 |
-
$phpcsFile->fixer->addContentBefore( ( $ptr + 1 ), $value_indentation );
|
228 |
-
}
|
229 |
}
|
230 |
-
}
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
235 |
|
236 |
-
if (
|
237 |
-
$phpcsFile->fixer->replaceToken( ( $
|
238 |
-
} else {
|
239 |
-
$phpcsFile->fixer->addContentBefore( $arrayEnd, "\n" . $indentation );
|
240 |
}
|
241 |
-
} elseif ( $value_indentation === $phpcsFile->fixer->getTokenContent( ( $arrayEnd - 1 ) ) ) {
|
242 |
-
$phpcsFile->fixer->replaceToken( ( $arrayEnd - 1 ), $indentation );
|
243 |
}
|
244 |
-
|
245 |
-
$phpcsFile->fixer->endChangeset();
|
246 |
-
} // End fix_associative_array().
|
247 |
|
248 |
} // End class.
|
7 |
* @license https://opensource.org/licenses/MIT MIT
|
8 |
*/
|
9 |
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
+
* Enforces WordPress array spacing format.
|
12 |
+
*
|
13 |
+
* WordPress specific checks which are not covered by the `WordPress.Arrays.ArrayDeclaration`/
|
14 |
+
* `Squiz.Arrays.ArrayDeclaration` sniff.
|
15 |
+
*
|
16 |
+
* - Checks for one space after the array opener / before the array closer in single-line arrays.
|
17 |
+
* - Checks that associative arrays are multi-line.
|
18 |
*
|
19 |
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#indentation
|
20 |
*
|
24 |
* from the WordPress_Sniffs_Arrays_ArrayDeclaration sniff into
|
25 |
* this sniff.
|
26 |
* - Added sniffing & fixing for associative arrays.
|
27 |
+
* @since 0.12.0 Decoupled this sniff from the upstream sniff completely.
|
28 |
+
* This sniff now extends the `WordPress_Sniff` instead.
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
*/
|
30 |
+
class WordPress_Sniffs_Arrays_ArrayDeclarationSpacingSniff extends WordPress_Sniff {
|
31 |
|
32 |
/**
|
33 |
+
* Token this sniff targets.
|
34 |
+
*
|
35 |
+
* Also used for distinguishing between the array and an array value
|
36 |
+
* which is also an array.
|
37 |
*
|
38 |
+
* @since 0.12.0
|
|
|
39 |
*
|
40 |
+
* @var array
|
|
|
|
|
|
|
|
|
41 |
*/
|
42 |
+
private $targets = array(
|
43 |
+
T_ARRAY => T_ARRAY,
|
44 |
+
T_OPEN_SHORT_ARRAY => T_OPEN_SHORT_ARRAY,
|
45 |
+
);
|
46 |
|
47 |
+
/**
|
48 |
+
* Returns an array of tokens this test wants to listen for.
|
49 |
+
*
|
50 |
+
* @since 0.12.0
|
51 |
+
*
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
public function register() {
|
55 |
+
return $this->targets;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Processes this test, when one of its tokens is encountered.
|
60 |
+
*
|
61 |
+
* @since 0.12.0 The actual checks contained in this method used to
|
62 |
+
* be in the `processSingleLineArray()` method.
|
63 |
+
*
|
64 |
+
* @param int $stackPtr The position of the current token in the stack.
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function process_token( $stackPtr ) {
|
69 |
+
/*
|
70 |
+
* Determine the array opener & closer.
|
71 |
+
*/
|
72 |
+
$array_open_close = $this->find_array_open_close( $stackPtr );
|
73 |
+
if ( false === $array_open_close ) {
|
74 |
+
// Array open/close could not be determined.
|
75 |
return;
|
76 |
}
|
77 |
|
78 |
+
$opener = $array_open_close['opener'];
|
79 |
+
$closer = $array_open_close['closer'];
|
80 |
+
unset( $array_open_close );
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
// This array is empty, so the below checks aren't necessary.
|
83 |
+
if ( ( $opener + 1 ) === $closer ) {
|
84 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
+
// We're only interested in single-line arrays.
|
88 |
+
if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) {
|
89 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
|
92 |
+
/*
|
93 |
+
* Check that associative arrays are always multi-line.
|
94 |
+
*/
|
95 |
+
$array_has_keys = $this->phpcsFile->findNext( T_DOUBLE_ARROW, $opener, $closer );
|
96 |
if ( false !== $array_has_keys ) {
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
$array_items = $this->get_function_call_parameters( $stackPtr );
|
99 |
+
|
100 |
+
if ( ! empty( $array_items ) ) {
|
101 |
+
/*
|
102 |
+
* Make sure the double arrow is for *this* array, not for a nested one.
|
103 |
+
*/
|
104 |
+
$array_has_keys = false; // Reset before doing more detailed check.
|
105 |
+
foreach ( $array_items as $item ) {
|
106 |
+
for ( $ptr = $item['start']; $ptr <= $item['end']; $ptr++ ) {
|
107 |
+
if ( T_DOUBLE_ARROW === $this->tokens[ $ptr ]['code'] ) {
|
108 |
+
$array_has_keys = true;
|
109 |
+
break 2;
|
110 |
+
}
|
111 |
+
|
112 |
+
// Skip passed any nested arrays.
|
113 |
+
if ( isset( $this->targets[ $this->tokens[ $ptr ]['code'] ] ) ) {
|
114 |
+
$nested_array_open_close = $this->find_array_open_close( $ptr );
|
115 |
+
if ( false === $nested_array_open_close ) {
|
116 |
+
// Nested array open/close could not be determined.
|
117 |
+
continue;
|
118 |
+
}
|
119 |
+
|
120 |
+
$ptr = $nested_array_open_close['closer'];
|
121 |
+
}
|
122 |
+
}
|
123 |
}
|
124 |
|
125 |
+
if ( true === $array_has_keys ) {
|
126 |
+
|
127 |
+
$fix = $this->phpcsFile->addFixableError(
|
128 |
+
'When an array uses associative keys, each value should start on a new line.',
|
129 |
+
$closer,
|
130 |
+
'AssociativeKeyFound'
|
131 |
+
);
|
132 |
+
|
133 |
+
if ( true === $fix ) {
|
134 |
+
|
135 |
+
$this->phpcsFile->fixer->beginChangeset();
|
136 |
+
|
137 |
+
foreach ( $array_items as $item ) {
|
138 |
+
/*
|
139 |
+
* Add a line break before the first non-empty token in the array item.
|
140 |
+
* Prevents extraneous whitespace at the start of the line which could be
|
141 |
+
* interpreted as alignment whitespace.
|
142 |
+
*/
|
143 |
+
$first_non_empty = $this->phpcsFile->findNext(
|
144 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
145 |
+
$item['start'],
|
146 |
+
( $item['end'] + 1 ),
|
147 |
+
true
|
148 |
+
);
|
149 |
+
if ( false === $first_non_empty ) {
|
150 |
+
continue;
|
151 |
+
}
|
152 |
+
|
153 |
+
if ( $item['start'] <= ( $first_non_empty - 1 )
|
154 |
+
&& T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ]['code']
|
155 |
+
) {
|
156 |
+
// Remove whitespace which would otherwise becoming trailing
|
157 |
+
// (as it gives problems with the fixed file).
|
158 |
+
$this->phpcsFile->fixer->replaceToken( ( $first_non_empty - 1 ), '' );
|
159 |
+
}
|
160 |
+
|
161 |
+
$this->phpcsFile->fixer->addNewlineBefore( $first_non_empty );
|
162 |
+
}
|
163 |
+
|
164 |
+
$this->phpcsFile->fixer->endChangeset();
|
165 |
}
|
166 |
|
167 |
+
// No need to check for spacing around parentheses as this array should be multi-line.
|
168 |
+
return;
|
169 |
}
|
170 |
}
|
171 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
/*
|
174 |
+
* Check that there is a single space after the array opener and before the array closer.
|
175 |
+
*/
|
176 |
+
if ( T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ]['code'] ) {
|
177 |
|
178 |
+
$fix = $this->phpcsFile->addFixableError(
|
179 |
+
'Missing space after array opener.',
|
180 |
+
$opener,
|
181 |
+
'NoSpaceAfterArrayOpener'
|
182 |
+
);
|
|
|
183 |
|
184 |
+
if ( true === $fix ) {
|
185 |
+
$this->phpcsFile->fixer->addContent( $opener, ' ' );
|
|
|
186 |
}
|
187 |
+
} elseif ( ' ' !== $this->tokens[ ( $opener + 1 ) ]['content'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
+
$fix = $this->phpcsFile->addFixableError(
|
190 |
+
'Expected 1 space after array opener, found %s.',
|
191 |
+
$opener,
|
192 |
+
'SpaceAfterArrayOpener',
|
193 |
+
array( strlen( $this->tokens[ ( $opener + 1 ) ]['content'] ) )
|
194 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
+
if ( true === $fix ) {
|
197 |
+
$this->phpcsFile->fixer->replaceToken( ( $opener + 1 ), ' ' );
|
198 |
}
|
199 |
+
}
|
200 |
|
201 |
+
if ( T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ]['code'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
+
$fix = $this->phpcsFile->addFixableError(
|
204 |
+
'Missing space before array closer.',
|
205 |
+
$closer,
|
206 |
+
'NoSpaceBeforeArrayCloser'
|
207 |
+
);
|
|
|
|
|
208 |
|
209 |
+
if ( true === $fix ) {
|
210 |
+
$this->phpcsFile->fixer->addContentBefore( $closer, ' ' );
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
+
} elseif ( ' ' !== $this->tokens[ ( $closer - 1 ) ]['content'] ) {
|
213 |
|
214 |
+
$fix = $this->phpcsFile->addFixableError(
|
215 |
+
'Expected 1 space before array closer, found %s.',
|
216 |
+
$closer,
|
217 |
+
'SpaceBeforeArrayCloser',
|
218 |
+
array( strlen( $this->tokens[ ( $closer - 1 ) ]['content'] ) )
|
219 |
+
);
|
220 |
|
221 |
+
if ( true === $fix ) {
|
222 |
+
$this->phpcsFile->fixer->replaceToken( ( $closer - 1 ), ' ' );
|
|
|
|
|
223 |
}
|
|
|
|
|
224 |
}
|
225 |
+
}
|
|
|
|
|
226 |
|
227 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php
ADDED
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Enforces WordPress array indentation for multi-line arrays.
|
12 |
+
*
|
13 |
+
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#indentation
|
14 |
+
*
|
15 |
+
* @package WPCS\WordPressCodingStandards
|
16 |
+
*
|
17 |
+
* @since 0.12.0
|
18 |
+
*
|
19 |
+
* {@internal This sniff should eventually be pulled upstream as part of a solution
|
20 |
+
* for https://github.com/squizlabs/PHP_CodeSniffer/issues/582 }}
|
21 |
+
*/
|
22 |
+
class WordPress_Sniffs_Arrays_ArrayIndentationSniff extends WordPress_Sniff {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Should tabs be used for indenting?
|
26 |
+
*
|
27 |
+
* If TRUE, fixes will be made using tabs instead of spaces.
|
28 |
+
* The size of each tab is important, so it should be specified
|
29 |
+
* using the --tab-width CLI argument.
|
30 |
+
*
|
31 |
+
* {@internal While for WPCS this should always be `true`, this property
|
32 |
+
* was added in anticipation of upstreaming the sniff.
|
33 |
+
* This property is the same as used in `Generic.WhiteSpace.ScopeIndent`.}}
|
34 |
+
*
|
35 |
+
* @var bool
|
36 |
+
*/
|
37 |
+
public $tabIndent = true;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* The --tab-width CLI value that is being used.
|
41 |
+
*
|
42 |
+
* @var int
|
43 |
+
*/
|
44 |
+
private $tab_width;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Tokens to ignore for subsequent lines in a multi-line array item.
|
48 |
+
*
|
49 |
+
* Property is set in the register() method.
|
50 |
+
*
|
51 |
+
* @var array
|
52 |
+
*/
|
53 |
+
private $ignore_tokens = array();
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Returns an array of tokens this test wants to listen for.
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function register() {
|
62 |
+
/*
|
63 |
+
* Set the $ignore_tokens property.
|
64 |
+
*
|
65 |
+
* Existing heredoc, nowdoc and inline HTML indentation should be respected at all times.
|
66 |
+
*/
|
67 |
+
$this->ignore_tokens = PHP_CodeSniffer_Tokens::$heredocTokens;
|
68 |
+
unset( $this->ignore_tokens[ T_START_HEREDOC ], $this->ignore_tokens[ T_START_NOWDOC ] );
|
69 |
+
$this->ignore_tokens[ T_INLINE_HTML ] = T_INLINE_HTML;
|
70 |
+
|
71 |
+
return array(
|
72 |
+
T_ARRAY,
|
73 |
+
T_OPEN_SHORT_ARRAY,
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Processes this test, when one of its tokens is encountered.
|
79 |
+
*
|
80 |
+
* @param int $stackPtr The position of the current token in the stack.
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function process_token( $stackPtr ) {
|
85 |
+
if ( ! isset( $this->tab_width ) ) {
|
86 |
+
$cli_values = $this->phpcsFile->phpcs->cli->getCommandLineValues();
|
87 |
+
if ( ! isset( $cli_values['tabWidth'] ) || 0 === $cli_values['tabWidth'] ) {
|
88 |
+
// We have no idea how wide tabs are, so assume 4 spaces for fixing.
|
89 |
+
$this->tab_width = 4;
|
90 |
+
} else {
|
91 |
+
$this->tab_width = $cli_values['tabWidth'];
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
/*
|
96 |
+
* Determine the array opener & closer.
|
97 |
+
*/
|
98 |
+
$array_open_close = $this->find_array_open_close( $stackPtr );
|
99 |
+
if ( false === $array_open_close ) {
|
100 |
+
// Array open/close could not be determined.
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
$opener = $array_open_close['opener'];
|
105 |
+
$closer = $array_open_close['closer'];
|
106 |
+
|
107 |
+
if ( $this->tokens[ $opener ]['line'] === $this->tokens[ $closer ]['line'] ) {
|
108 |
+
// Not interested in single line arrays.
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
|
112 |
+
/*
|
113 |
+
* Check the closing bracket is lined up with the start of the content on the line
|
114 |
+
* containing the array opener.
|
115 |
+
*/
|
116 |
+
$opener_line_spaces = $this->get_indentation_size( $opener );
|
117 |
+
$closer_line_spaces = ( $this->tokens[ $closer ]['column'] - 1 );
|
118 |
+
|
119 |
+
if ( $closer_line_spaces !== $opener_line_spaces ) {
|
120 |
+
$error = 'Array closer not aligned correctly; expected %s space(s) but found %s';
|
121 |
+
$error_code = 'CloseBraceNotAligned';
|
122 |
+
|
123 |
+
/*
|
124 |
+
* Report & fix the issue if the close brace is on its own line with
|
125 |
+
* nothing or only indentation whitespace before it.
|
126 |
+
*/
|
127 |
+
if ( 0 === $closer_line_spaces
|
128 |
+
|| ( T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
|
129 |
+
&& 1 === $this->tokens[ ( $closer - 1 ) ]['column'] )
|
130 |
+
) {
|
131 |
+
$this->add_array_alignment_error(
|
132 |
+
$closer,
|
133 |
+
$error,
|
134 |
+
$error_code,
|
135 |
+
$opener_line_spaces,
|
136 |
+
$closer_line_spaces,
|
137 |
+
$this->get_indentation_string( $opener_line_spaces )
|
138 |
+
);
|
139 |
+
} else {
|
140 |
+
/*
|
141 |
+
* Otherwise, only report the error, don't try and fix it (yet).
|
142 |
+
*
|
143 |
+
* It will get corrected in a future loop of the fixer once the closer
|
144 |
+
* has been moved to its own line by the `ArrayDeclaration` sniff.
|
145 |
+
*/
|
146 |
+
$this->phpcsFile->addError(
|
147 |
+
$error,
|
148 |
+
$closer,
|
149 |
+
$error_code,
|
150 |
+
array( $opener_line_spaces, $closer_line_spaces )
|
151 |
+
);
|
152 |
+
}
|
153 |
+
|
154 |
+
unset( $error, $error_code );
|
155 |
+
}
|
156 |
+
|
157 |
+
/*
|
158 |
+
* Verify & correct the array item indentation.
|
159 |
+
*/
|
160 |
+
$array_items = $this->get_function_call_parameters( $stackPtr );
|
161 |
+
if ( empty( $array_items ) ) {
|
162 |
+
// Strange, no array items found.
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
|
166 |
+
$expected_spaces = ( $opener_line_spaces + $this->tab_width );
|
167 |
+
$expected_indent = $this->get_indentation_string( $expected_spaces );
|
168 |
+
$end_of_previous_item = $opener;
|
169 |
+
|
170 |
+
foreach ( $array_items as $item ) {
|
171 |
+
$end_of_this_item = ( $item['end'] + 1 );
|
172 |
+
|
173 |
+
// Find the line on which the item starts.
|
174 |
+
$first_content = $this->phpcsFile->findNext(
|
175 |
+
array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
|
176 |
+
$item['start'],
|
177 |
+
$end_of_this_item,
|
178 |
+
true
|
179 |
+
);
|
180 |
+
|
181 |
+
if ( false === $first_content ) {
|
182 |
+
$end_of_previous_item = $end_of_this_item;
|
183 |
+
continue;
|
184 |
+
}
|
185 |
+
|
186 |
+
// Bow out from reporting and fixing mixed multi-line/single-line arrays.
|
187 |
+
// That is handled by the ArrayDeclarationSniff.
|
188 |
+
if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
|
189 |
+
|| ( 1 !== $this->tokens[ $first_content ]['column']
|
190 |
+
&& T_WHITESPACE !== $this->tokens[ ( $first_content - 1 ) ]['code'] )
|
191 |
+
) {
|
192 |
+
return $closer;
|
193 |
+
}
|
194 |
+
|
195 |
+
$found_spaces = ( $this->tokens[ $first_content ]['column'] - 1 );
|
196 |
+
|
197 |
+
if ( $found_spaces !== $expected_spaces ) {
|
198 |
+
$this->add_array_alignment_error(
|
199 |
+
$first_content,
|
200 |
+
'Array item not aligned correctly; expected %s spaces but found %s',
|
201 |
+
'ItemNotAligned',
|
202 |
+
$expected_spaces,
|
203 |
+
$found_spaces,
|
204 |
+
$expected_indent
|
205 |
+
);
|
206 |
+
}
|
207 |
+
|
208 |
+
// No need for further checking if this is a one-line array item.
|
209 |
+
if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $item['end'] ]['line'] ) {
|
210 |
+
$end_of_previous_item = $end_of_this_item;
|
211 |
+
continue;
|
212 |
+
}
|
213 |
+
|
214 |
+
/*
|
215 |
+
* Multi-line array items.
|
216 |
+
*
|
217 |
+
* Verify & if needed, correct the indentation of subsequent lines.
|
218 |
+
* Subsequent lines may be indented more or less than the mimimum expected indent,
|
219 |
+
* but the "first line after" should be indented - at least - as much as the very first line
|
220 |
+
* of the array item.
|
221 |
+
* Indentation correction for subsequent lines will be based on that diff.
|
222 |
+
*/
|
223 |
+
|
224 |
+
// Find first token on second line of the array item.
|
225 |
+
// If the second line is a heredoc/nowdoc, continue on until we find a line with a different token.
|
226 |
+
for ( $ptr = ( $first_content + 1 ); $ptr <= $item['end']; $ptr++ ) {
|
227 |
+
if ( $this->tokens[ $first_content ]['line'] !== $this->tokens[ $ptr ]['line']
|
228 |
+
&& ! isset( $this->ignore_tokens[ $this->tokens[ $ptr ]['code'] ] )
|
229 |
+
) {
|
230 |
+
break;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
$first_content_on_line2 = $this->phpcsFile->findNext(
|
235 |
+
array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
|
236 |
+
$ptr,
|
237 |
+
$end_of_this_item,
|
238 |
+
true
|
239 |
+
);
|
240 |
+
|
241 |
+
if ( false === $first_content_on_line2 ) {
|
242 |
+
/*
|
243 |
+
* Apparently there were only tokens in the ignore list on subsequent lines.
|
244 |
+
*
|
245 |
+
* In that case, the comma after the array item might be on a line by itself,
|
246 |
+
* so check its placement.
|
247 |
+
*/
|
248 |
+
if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
|
249 |
+
&& T_COMMA === $this->tokens[ $end_of_this_item ]['code']
|
250 |
+
&& ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
|
251 |
+
) {
|
252 |
+
$this->add_array_alignment_error(
|
253 |
+
$end_of_this_item,
|
254 |
+
'Comma after multi-line array item not aligned correctly; expected %s spaces, but found %s',
|
255 |
+
'MultiLineArrayItemCommaNotAligned',
|
256 |
+
$expected_spaces,
|
257 |
+
( $this->tokens[ $end_of_this_item ]['column'] - 1 ),
|
258 |
+
$expected_indent
|
259 |
+
);
|
260 |
+
}
|
261 |
+
|
262 |
+
$end_of_previous_item = $end_of_this_item;
|
263 |
+
continue;
|
264 |
+
}
|
265 |
+
|
266 |
+
$found_spaces_on_line2 = $this->get_indentation_size( $first_content_on_line2 );
|
267 |
+
$expected_spaces_on_line2 = $expected_spaces;
|
268 |
+
|
269 |
+
if ( $found_spaces < $found_spaces_on_line2 ) {
|
270 |
+
$expected_spaces_on_line2 += ( $found_spaces_on_line2 - $found_spaces );
|
271 |
+
}
|
272 |
+
|
273 |
+
if ( $found_spaces_on_line2 !== $expected_spaces_on_line2 ) {
|
274 |
+
|
275 |
+
$fix = $this->phpcsFile->addFixableError(
|
276 |
+
'Multi-line array item not aligned correctly; expected %s spaces, but found %s',
|
277 |
+
$first_content_on_line2,
|
278 |
+
'MultiLineArrayItemNotAligned',
|
279 |
+
array(
|
280 |
+
$expected_spaces_on_line2,
|
281 |
+
$found_spaces_on_line2,
|
282 |
+
)
|
283 |
+
);
|
284 |
+
|
285 |
+
if ( true === $fix ) {
|
286 |
+
$expected_indent_on_line2 = $this->get_indentation_string( $expected_spaces_on_line2 );
|
287 |
+
|
288 |
+
$this->phpcsFile->fixer->beginChangeset();
|
289 |
+
|
290 |
+
// Fix second line for the array item.
|
291 |
+
if ( 1 === $this->tokens[ $first_content_on_line2 ]['column']
|
292 |
+
&& T_COMMENT === $this->tokens[ $first_content_on_line2 ]['code']
|
293 |
+
) {
|
294 |
+
$actual_comment = ltrim( $this->tokens[ $first_content_on_line2 ]['content'] );
|
295 |
+
$replacement = $expected_indent_on_line2 . $actual_comment;
|
296 |
+
|
297 |
+
$this->phpcsFile->fixer->replaceToken( $first_content_on_line2, $replacement );
|
298 |
+
|
299 |
+
} else {
|
300 |
+
$this->fix_alignment_error( $first_content_on_line2, $expected_indent_on_line2 );
|
301 |
+
}
|
302 |
+
|
303 |
+
// Fix subsequent lines.
|
304 |
+
for ( $i = ( $first_content_on_line2 + 1 ); $i <= $item['end']; $i++ ) {
|
305 |
+
// We're only interested in the first token on each line.
|
306 |
+
if ( 1 !== $this->tokens[ $i ]['column'] ) {
|
307 |
+
if ( $this->tokens[ $i ]['line'] === $this->tokens[ $item['end'] ]['line'] ) {
|
308 |
+
// We might as well quit if we're past the first token on the last line.
|
309 |
+
break;
|
310 |
+
}
|
311 |
+
continue;
|
312 |
+
}
|
313 |
+
|
314 |
+
$first_content_on_line = $this->phpcsFile->findNext(
|
315 |
+
array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
|
316 |
+
$i,
|
317 |
+
$end_of_this_item,
|
318 |
+
true
|
319 |
+
);
|
320 |
+
|
321 |
+
if ( false === $first_content_on_line ) {
|
322 |
+
break;
|
323 |
+
}
|
324 |
+
|
325 |
+
// Ignore lines with heredoc and nowdoc tokens.
|
326 |
+
if ( isset( $this->ignore_tokens[ $this->tokens[ $first_content_on_line ]['code'] ] ) ) {
|
327 |
+
$i = $first_content_on_line;
|
328 |
+
continue;
|
329 |
+
}
|
330 |
+
|
331 |
+
$found_spaces_on_line = $this->get_indentation_size( $first_content_on_line );
|
332 |
+
$expected_spaces_on_line = ( $expected_spaces_on_line2 + ( $found_spaces_on_line - $found_spaces_on_line2 ) );
|
333 |
+
$expected_spaces_on_line = max( $expected_spaces_on_line, 0 ); // Can't be below 0.
|
334 |
+
$expected_indent_on_line = $this->get_indentation_string( $expected_spaces_on_line );
|
335 |
+
|
336 |
+
if ( $found_spaces_on_line !== $expected_spaces_on_line ) {
|
337 |
+
if ( 1 === $this->tokens[ $first_content_on_line ]['column']
|
338 |
+
&& T_COMMENT === $this->tokens[ $first_content_on_line ]['code']
|
339 |
+
) {
|
340 |
+
$actual_comment = ltrim( $this->tokens[ $first_content_on_line ]['content'] );
|
341 |
+
$replacement = $expected_indent_on_line . $actual_comment;
|
342 |
+
|
343 |
+
$this->phpcsFile->fixer->replaceToken( $first_content_on_line, $replacement );
|
344 |
+
} else {
|
345 |
+
$this->fix_alignment_error( $first_content_on_line, $expected_indent_on_line );
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
// Move past any potential empty lines between the previous non-empty line and this one.
|
350 |
+
// No need to do the fixes twice.
|
351 |
+
$i = $first_content_on_line;
|
352 |
+
}
|
353 |
+
|
354 |
+
/*
|
355 |
+
* Check the placement of the comma after the array item as it might be on a line by itself.
|
356 |
+
*/
|
357 |
+
if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
|
358 |
+
&& T_COMMA === $this->tokens[ $end_of_this_item ]['code']
|
359 |
+
&& ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
|
360 |
+
) {
|
361 |
+
$this->add_array_alignment_error(
|
362 |
+
$end_of_this_item,
|
363 |
+
'Comma after array item not aligned correctly; expected %s spaces, but found %s',
|
364 |
+
'MultiLineArrayItemCommaNotAligned',
|
365 |
+
$expected_spaces,
|
366 |
+
( $this->tokens[ $end_of_this_item ]['column'] - 1 ),
|
367 |
+
$expected_indent
|
368 |
+
);
|
369 |
+
}
|
370 |
+
|
371 |
+
$this->phpcsFile->fixer->endChangeset();
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
$end_of_previous_item = $end_of_this_item;
|
376 |
+
}
|
377 |
+
|
378 |
+
} // End process_token().
|
379 |
+
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Determine the line indentation whitespace.
|
383 |
+
*
|
384 |
+
* @param int $ptr Stack pointer to an arbitrary token on a line.
|
385 |
+
*
|
386 |
+
* @return int Nr of spaces found. Where necessary, tabs are translated to spaces.
|
387 |
+
*/
|
388 |
+
protected function get_indentation_size( $ptr ) {
|
389 |
+
|
390 |
+
// Find the first token on the line.
|
391 |
+
for ( ; $ptr >= 0; $ptr-- ) {
|
392 |
+
if ( 1 === $this->tokens[ $ptr ]['column'] ) {
|
393 |
+
break;
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
$whitespace = '';
|
398 |
+
|
399 |
+
if ( T_WHITESPACE === $this->tokens[ $ptr ]['code']
|
400 |
+
|| T_DOC_COMMENT_WHITESPACE === $this->tokens[ $ptr ]['code']
|
401 |
+
) {
|
402 |
+
return $this->tokens[ $ptr ]['length'];
|
403 |
+
}
|
404 |
+
|
405 |
+
/*
|
406 |
+
* Special case for multi-line, non-docblock comments.
|
407 |
+
* Only applicable for subsequent lines in an array item.
|
408 |
+
*
|
409 |
+
* First/Single line is tokenized as T_WHITESPACE + T_COMMENT
|
410 |
+
* Subsequent lines are tokenized as T_COMMENT including the indentation whitespace.
|
411 |
+
*/
|
412 |
+
if ( T_COMMENT === $this->tokens[ $ptr ]['code'] ) {
|
413 |
+
$content = $this->tokens[ $ptr ]['content'];
|
414 |
+
$actual_comment = ltrim( $content );
|
415 |
+
$whitespace = str_replace( $actual_comment, '', $content );
|
416 |
+
}
|
417 |
+
|
418 |
+
return strlen( $whitespace );
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Create an indentation string.
|
423 |
+
*
|
424 |
+
* @param int $nr Number of spaces the indentation should be.
|
425 |
+
*
|
426 |
+
* @return string
|
427 |
+
*/
|
428 |
+
protected function get_indentation_string( $nr ) {
|
429 |
+
if ( 0 >= $nr ) {
|
430 |
+
return '';
|
431 |
+
}
|
432 |
+
|
433 |
+
// Space-based indentation.
|
434 |
+
if ( false === $this->tabIndent ) {
|
435 |
+
return str_repeat( ' ', $nr );
|
436 |
+
}
|
437 |
+
|
438 |
+
// Tab-based indentation.
|
439 |
+
$num_tabs = (int) floor( $nr / $this->tab_width );
|
440 |
+
$remaining = ( $nr % $this->tab_width );
|
441 |
+
$tab_indent = str_repeat( "\t", $num_tabs );
|
442 |
+
$tab_indent .= str_repeat( ' ', $remaining );
|
443 |
+
|
444 |
+
return $tab_indent;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Throw an error and fix incorrect array alignment.
|
449 |
+
*
|
450 |
+
* @param int $ptr Stack pointer to the first content on the line.
|
451 |
+
* @param string $error Error message.
|
452 |
+
* @param string $error_code Error code.
|
453 |
+
* @param int $expected Expected nr of spaces (tabs translated to space value).
|
454 |
+
* @param int $found Found nr of spaces (tabs translated to space value).
|
455 |
+
* @param string $new_indent Whitespace indent replacement content.
|
456 |
+
*/
|
457 |
+
protected function add_array_alignment_error( $ptr, $error, $error_code, $expected, $found, $new_indent ) {
|
458 |
+
|
459 |
+
$fix = $this->phpcsFile->addFixableError( $error, $ptr, $error_code, array( $expected, $found ) );
|
460 |
+
if ( true === $fix ) {
|
461 |
+
$this->fix_alignment_error( $ptr, $new_indent );
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Fix incorrect array alignment.
|
467 |
+
*
|
468 |
+
* @param int $ptr Stack pointer to the first content on the line.
|
469 |
+
* @param string $new_indent Whitespace indent replacement content.
|
470 |
+
*/
|
471 |
+
protected function fix_alignment_error( $ptr, $new_indent ) {
|
472 |
+
if ( 1 === $this->tokens[ $ptr ]['column'] ) {
|
473 |
+
$this->phpcsFile->fixer->addContentBefore( $ptr, $new_indent );
|
474 |
+
} else {
|
475 |
+
$this->phpcsFile->fixer->replaceToken( ( $ptr - 1 ), $new_indent );
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php
CHANGED
@@ -15,9 +15,10 @@
|
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
-
* @since 0.7.0
|
|
|
19 |
*/
|
20 |
-
class WordPress_Sniffs_Arrays_ArrayKeySpacingRestrictionsSniff
|
21 |
|
22 |
/**
|
23 |
* Returns an array of tokens this test wants to listen for.
|
@@ -34,52 +35,49 @@ class WordPress_Sniffs_Arrays_ArrayKeySpacingRestrictionsSniff implements PHP_Co
|
|
34 |
/**
|
35 |
* Processes this test, when one of its tokens is encountered.
|
36 |
*
|
37 |
-
* @param
|
38 |
-
* @param int $stackPtr The position of the current token
|
39 |
-
* in the stack passed in $tokens.
|
40 |
*
|
41 |
* @return void
|
42 |
*/
|
43 |
-
public function
|
44 |
-
$tokens = $phpcsFile->getTokens();
|
45 |
|
46 |
-
$token = $tokens[ $stackPtr ];
|
47 |
if ( ! isset( $token['bracket_closer'] ) ) {
|
48 |
-
$phpcsFile->addWarning( 'Missing bracket closer.', $stackPtr, 'MissingBracketCloser' );
|
49 |
return;
|
50 |
}
|
51 |
|
52 |
-
$need_spaces = $phpcsFile->findNext(
|
53 |
array( T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_WHITESPACE, T_MINUS ),
|
54 |
( $stackPtr + 1 ),
|
55 |
$token['bracket_closer'],
|
56 |
true
|
57 |
);
|
58 |
|
59 |
-
$spaced1 = ( T_WHITESPACE === $tokens[ ( $stackPtr + 1 ) ]['code'] );
|
60 |
-
$spaced2 = ( T_WHITESPACE === $tokens[ ( $token['bracket_closer'] - 1 ) ]['code'] );
|
61 |
|
62 |
-
// It should have spaces
|
63 |
if ( false !== $need_spaces && ! ( $spaced1 && $spaced2 ) ) {
|
64 |
$error = 'Array keys must be surrounded by spaces unless they contain a string or an integer.';
|
65 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpacesAroundArrayKeys' );
|
66 |
if ( true === $fix ) {
|
67 |
if ( ! $spaced1 ) {
|
68 |
-
$phpcsFile->fixer->addContentBefore( ( $stackPtr + 1 ), ' ' );
|
69 |
}
|
70 |
if ( ! $spaced2 ) {
|
71 |
-
$phpcsFile->fixer->addContentBefore( $token['bracket_closer'], ' ' );
|
72 |
}
|
73 |
}
|
74 |
} elseif ( false === $need_spaces && ( $spaced1 || $spaced2 ) ) {
|
75 |
$error = 'Array keys must NOT be surrounded by spaces if they only contain a string or an integer.';
|
76 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpacesAroundArrayKeys' );
|
77 |
if ( true === $fix ) {
|
78 |
if ( $spaced1 ) {
|
79 |
-
$phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' );
|
80 |
}
|
81 |
if ( $spaced2 ) {
|
82 |
-
$phpcsFile->fixer->replaceToken( ( $token['bracket_closer'] - 1 ), '' );
|
83 |
}
|
84 |
}
|
85 |
}
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
+
* @since 0.7.0 This sniff now has the ability to fix a number of the issues it flags.
|
19 |
+
* @since 0.12.0 This class now extends WordPress_Sniff.
|
20 |
*/
|
21 |
+
class WordPress_Sniffs_Arrays_ArrayKeySpacingRestrictionsSniff extends WordPress_Sniff {
|
22 |
|
23 |
/**
|
24 |
* Returns an array of tokens this test wants to listen for.
|
35 |
/**
|
36 |
* Processes this test, when one of its tokens is encountered.
|
37 |
*
|
38 |
+
* @param int $stackPtr The position of the current token in the stack.
|
|
|
|
|
39 |
*
|
40 |
* @return void
|
41 |
*/
|
42 |
+
public function process_token( $stackPtr ) {
|
|
|
43 |
|
44 |
+
$token = $this->tokens[ $stackPtr ];
|
45 |
if ( ! isset( $token['bracket_closer'] ) ) {
|
46 |
+
$this->phpcsFile->addWarning( 'Missing bracket closer.', $stackPtr, 'MissingBracketCloser' );
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
+
$need_spaces = $this->phpcsFile->findNext(
|
51 |
array( T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_WHITESPACE, T_MINUS ),
|
52 |
( $stackPtr + 1 ),
|
53 |
$token['bracket_closer'],
|
54 |
true
|
55 |
);
|
56 |
|
57 |
+
$spaced1 = ( T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] );
|
58 |
+
$spaced2 = ( T_WHITESPACE === $this->tokens[ ( $token['bracket_closer'] - 1 ) ]['code'] );
|
59 |
|
60 |
+
// It should have spaces unless if it only has strings or numbers as the key.
|
61 |
if ( false !== $need_spaces && ! ( $spaced1 && $spaced2 ) ) {
|
62 |
$error = 'Array keys must be surrounded by spaces unless they contain a string or an integer.';
|
63 |
+
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpacesAroundArrayKeys' );
|
64 |
if ( true === $fix ) {
|
65 |
if ( ! $spaced1 ) {
|
66 |
+
$this->phpcsFile->fixer->addContentBefore( ( $stackPtr + 1 ), ' ' );
|
67 |
}
|
68 |
if ( ! $spaced2 ) {
|
69 |
+
$this->phpcsFile->fixer->addContentBefore( $token['bracket_closer'], ' ' );
|
70 |
}
|
71 |
}
|
72 |
} elseif ( false === $need_spaces && ( $spaced1 || $spaced2 ) ) {
|
73 |
$error = 'Array keys must NOT be surrounded by spaces if they only contain a string or an integer.';
|
74 |
+
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'SpacesAroundArrayKeys' );
|
75 |
if ( true === $fix ) {
|
76 |
if ( $spaced1 ) {
|
77 |
+
$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' );
|
78 |
}
|
79 |
if ( $spaced2 ) {
|
80 |
+
$this->phpcsFile->fixer->replaceToken( ( $token['bracket_closer'] - 1 ), '' );
|
81 |
}
|
82 |
}
|
83 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php
ADDED
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Enforces a comma after each array item and the spacing around it.
|
12 |
+
*
|
13 |
+
* Rules:
|
14 |
+
* - For multi-line arrays, a comma is needed after each array item.
|
15 |
+
* - Same for single-line arrays, but no comma is allowed after the last array item.
|
16 |
+
* - There should be no space between the comma and the end of the array item.
|
17 |
+
* - There should be exactly one space between the comma and the start of the
|
18 |
+
* next array item for single-line items.
|
19 |
+
*
|
20 |
+
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#indentation
|
21 |
+
*
|
22 |
+
* @package WPCS\WordPressCodingStandards
|
23 |
+
*
|
24 |
+
* @since 0.12.0
|
25 |
+
*/
|
26 |
+
class WordPress_Sniffs_Arrays_CommaAfterArrayItemSniff extends WordPress_Sniff {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns an array of tokens this test wants to listen for.
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function register() {
|
34 |
+
return array(
|
35 |
+
T_ARRAY,
|
36 |
+
T_OPEN_SHORT_ARRAY,
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Processes this test, when one of its tokens is encountered.
|
42 |
+
*
|
43 |
+
* @param int $stackPtr The position of the current token in the stack.
|
44 |
+
*
|
45 |
+
* @return void
|
46 |
+
*/
|
47 |
+
public function process_token( $stackPtr ) {
|
48 |
+
/*
|
49 |
+
* Determine the array opener & closer.
|
50 |
+
*/
|
51 |
+
$array_open_close = $this->find_array_open_close( $stackPtr );
|
52 |
+
if ( false === $array_open_close ) {
|
53 |
+
// Array open/close could not be determined.
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$opener = $array_open_close['opener'];
|
58 |
+
$closer = $array_open_close['closer'];
|
59 |
+
unset( $array_open_close );
|
60 |
+
|
61 |
+
// This array is empty, so the below checks aren't necessary.
|
62 |
+
if ( ( $opener + 1 ) === $closer ) {
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
|
66 |
+
$single_line = true;
|
67 |
+
if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) {
|
68 |
+
$single_line = false;
|
69 |
+
}
|
70 |
+
|
71 |
+
$array_items = $this->get_function_call_parameters( $stackPtr );
|
72 |
+
if ( empty( $array_items ) ) {
|
73 |
+
// Strange, no array items found.
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
$array_item_count = count( $array_items );
|
78 |
+
|
79 |
+
// Note: $item_index is 1-based and the array items are split on the commas!
|
80 |
+
foreach ( $array_items as $item_index => $item ) {
|
81 |
+
$maybe_comma = ( $item['end'] + 1 );
|
82 |
+
$is_comma = false;
|
83 |
+
if ( isset( $this->tokens[ $maybe_comma ] ) && T_COMMA === $this->tokens[ $maybe_comma ]['code'] ) {
|
84 |
+
$is_comma = true;
|
85 |
+
}
|
86 |
+
|
87 |
+
/*
|
88 |
+
* Check if this is a comma at the end of the last item in a single line array.
|
89 |
+
*/
|
90 |
+
if ( true === $single_line && $item_index === $array_item_count ) {
|
91 |
+
|
92 |
+
if ( true === $is_comma ) {
|
93 |
+
$fix = $this->phpcsFile->addFixableError(
|
94 |
+
'Comma not allowed after last value in single-line array declaration',
|
95 |
+
$maybe_comma,
|
96 |
+
'CommaAfterLast'
|
97 |
+
);
|
98 |
+
|
99 |
+
if ( true === $fix ) {
|
100 |
+
$this->phpcsFile->fixer->replaceToken( $maybe_comma, '' );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/*
|
105 |
+
* No need to do the spacing checks for the last item in a single line array.
|
106 |
+
* This is handled by another sniff checking the spacing before the array closer.
|
107 |
+
*/
|
108 |
+
continue;
|
109 |
+
}
|
110 |
+
|
111 |
+
$last_content = $this->phpcsFile->findPrevious(
|
112 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
113 |
+
$item['end'],
|
114 |
+
$item['start'],
|
115 |
+
true
|
116 |
+
);
|
117 |
+
|
118 |
+
if ( false === $last_content ) {
|
119 |
+
// Shouldn't be able to happen, but just in case, ignore this array item.
|
120 |
+
continue;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Make sure every item in a multi-line array has a comma at the end.
|
125 |
+
*
|
126 |
+
* Should in reality only be triggered by the last item in a multi-line array
|
127 |
+
* as otherwise we'd have a parse error already.
|
128 |
+
*/
|
129 |
+
if ( false === $is_comma && false === $single_line ) {
|
130 |
+
|
131 |
+
$fix = $this->phpcsFile->addFixableError(
|
132 |
+
'Each array item in a multi-line array declaration must end in a comma',
|
133 |
+
$last_content,
|
134 |
+
'NoComma'
|
135 |
+
);
|
136 |
+
|
137 |
+
if ( true === $fix ) {
|
138 |
+
$this->phpcsFile->fixer->addContent( $last_content, ',' );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( false === $is_comma ) {
|
143 |
+
// Can't check spacing around the comma if there is no comma.
|
144 |
+
continue;
|
145 |
+
}
|
146 |
+
|
147 |
+
/*
|
148 |
+
* Check for whitespace at the end of the array item.
|
149 |
+
*/
|
150 |
+
if ( $last_content !== $item['end']
|
151 |
+
// Ignore whitespace at the end of a multi-line item if it is the end of a heredoc/nowdoc.
|
152 |
+
&& ( true === $single_line
|
153 |
+
|| ! isset( PHP_CodeSniffer_Tokens::$heredocTokens[ $this->tokens[ $last_content ]['code'] ] ) )
|
154 |
+
) {
|
155 |
+
$newlines = 0;
|
156 |
+
$spaces = 0;
|
157 |
+
for ( $i = $item['end']; $i > $last_content; $i-- ) {
|
158 |
+
|
159 |
+
if ( T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
|
160 |
+
if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) {
|
161 |
+
$newlines++;
|
162 |
+
} else {
|
163 |
+
$spaces += $this->tokens[ $i ]['length'];
|
164 |
+
}
|
165 |
+
} elseif ( T_COMMENT === $this->tokens[ $i ]['code'] ) {
|
166 |
+
break;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
$space_phrases = array();
|
171 |
+
if ( $spaces > 0 ) {
|
172 |
+
$space_phrases[] = $spaces . ' spaces';
|
173 |
+
}
|
174 |
+
if ( $newlines > 0 ) {
|
175 |
+
$space_phrases[] = $newlines . ' newlines';
|
176 |
+
}
|
177 |
+
unset( $newlines, $spaces );
|
178 |
+
|
179 |
+
$fix = $this->phpcsFile->addFixableError(
|
180 |
+
'Expected 0 spaces between "%s" and comma; %s found',
|
181 |
+
$maybe_comma,
|
182 |
+
'SpaceBeforeComma',
|
183 |
+
array(
|
184 |
+
$this->tokens[ $last_content ]['content'],
|
185 |
+
implode( ' and ', $space_phrases ),
|
186 |
+
)
|
187 |
+
);
|
188 |
+
|
189 |
+
if ( true === $fix ) {
|
190 |
+
$this->phpcsFile->fixer->beginChangeset();
|
191 |
+
for ( $i = $item['end']; $i > $last_content; $i-- ) {
|
192 |
+
|
193 |
+
if ( T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
|
194 |
+
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
195 |
+
|
196 |
+
} elseif ( T_COMMENT === $this->tokens[ $i ]['code'] ) {
|
197 |
+
// We need to move the comma to before the comment.
|
198 |
+
$this->phpcsFile->fixer->addContent( $last_content, ',' );
|
199 |
+
$this->phpcsFile->fixer->replaceToken( $maybe_comma, '' );
|
200 |
+
|
201 |
+
/*
|
202 |
+
* No need to worry about removing too much whitespace in
|
203 |
+
* combination with a `//` comment as in that case, the newline
|
204 |
+
* is part of the comment, so we're good.
|
205 |
+
*/
|
206 |
+
|
207 |
+
break;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
$this->phpcsFile->fixer->endChangeset();
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
if ( ! isset( $this->tokens[ ( $maybe_comma + 1 ) ] ) ) {
|
215 |
+
// Shouldn't be able to happen, but just in case.
|
216 |
+
continue;
|
217 |
+
}
|
218 |
+
|
219 |
+
/*
|
220 |
+
* Check whitespace after the comma.
|
221 |
+
*/
|
222 |
+
$next_token = $this->tokens[ ( $maybe_comma + 1 ) ];
|
223 |
+
|
224 |
+
if ( T_WHITESPACE === $next_token['code'] ) {
|
225 |
+
|
226 |
+
if ( false === $single_line && $this->phpcsFile->eolChar === $next_token['content'] ) {
|
227 |
+
continue;
|
228 |
+
}
|
229 |
+
|
230 |
+
$next_non_whitespace = $this->phpcsFile->findNext(
|
231 |
+
T_WHITESPACE,
|
232 |
+
($maybe_comma + 1 ),
|
233 |
+
$closer,
|
234 |
+
true
|
235 |
+
);
|
236 |
+
|
237 |
+
if ( false === $next_non_whitespace
|
238 |
+
|| ( false === $single_line
|
239 |
+
&& $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $maybe_comma ]['line']
|
240 |
+
&& T_COMMENT === $this->tokens[ $next_non_whitespace ]['code'] )
|
241 |
+
) {
|
242 |
+
continue;
|
243 |
+
}
|
244 |
+
|
245 |
+
$space_length = $next_token['length'];
|
246 |
+
if ( 1 === $space_length ) {
|
247 |
+
continue;
|
248 |
+
}
|
249 |
+
|
250 |
+
$fix = $this->phpcsFile->addFixableError(
|
251 |
+
'Expected 1 space between comma and "%s"; %s found',
|
252 |
+
$maybe_comma,
|
253 |
+
'SpaceAfterComma',
|
254 |
+
array(
|
255 |
+
$this->tokens[ $next_non_whitespace ]['content'],
|
256 |
+
$space_length,
|
257 |
+
)
|
258 |
+
);
|
259 |
+
|
260 |
+
if ( true === $fix ) {
|
261 |
+
$this->phpcsFile->fixer->replaceToken( ( $maybe_comma + 1 ), ' ' );
|
262 |
+
}
|
263 |
+
} else {
|
264 |
+
// This is either a comment or a mixed single/multi-line array.
|
265 |
+
// Just add a space and let other sniffs sort out the array layout.
|
266 |
+
$fix = $this->phpcsFile->addFixableError(
|
267 |
+
'Expected 1 space between comma and "%s"; 0 found',
|
268 |
+
$maybe_comma,
|
269 |
+
'NoSpaceAfterComma',
|
270 |
+
array( $next_token['content'] )
|
271 |
+
);
|
272 |
+
|
273 |
+
if ( true === $fix ) {
|
274 |
+
$this->phpcsFile->fixer->addContent( $maybe_comma, ' ' );
|
275 |
+
}
|
276 |
+
}
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CSRF/NonceVerificationSniff.php
CHANGED
@@ -18,15 +18,33 @@
|
|
18 |
*/
|
19 |
class WordPress_Sniffs_CSRF_NonceVerificationSniff extends WordPress_Sniff {
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Superglobals to give an error for when not accompanied by an nonce check.
|
23 |
*
|
24 |
* @since 0.5.0
|
25 |
* @since 0.11.0 Changed visibility from public to protected.
|
26 |
*
|
|
|
|
|
27 |
* @var array
|
28 |
*/
|
29 |
-
protected $errorForSuperGlobals = array(
|
30 |
|
31 |
/**
|
32 |
* Superglobals to give a warning for when not accompanied by an nonce check.
|
@@ -36,9 +54,11 @@ class WordPress_Sniffs_CSRF_NonceVerificationSniff extends WordPress_Sniff {
|
|
36 |
* @since 0.5.0
|
37 |
* @since 0.11.0 Changed visibility from public to protected.
|
38 |
*
|
|
|
|
|
39 |
* @var array
|
40 |
*/
|
41 |
-
protected $warnForSuperGlobals = array(
|
42 |
|
43 |
/**
|
44 |
* Custom list of functions which verify nonces.
|
@@ -107,12 +127,7 @@ class WordPress_Sniffs_CSRF_NonceVerificationSniff extends WordPress_Sniff {
|
|
107 |
|
108 |
$instance = $this->tokens[ $stackPtr ];
|
109 |
|
110 |
-
$superglobals
|
111 |
-
$this->errorForSuperGlobals
|
112 |
-
, $this->warnForSuperGlobals
|
113 |
-
);
|
114 |
-
|
115 |
-
if ( ! in_array( $instance['content'], $superglobals, true ) ) {
|
116 |
return;
|
117 |
}
|
118 |
|
@@ -138,11 +153,11 @@ class WordPress_Sniffs_CSRF_NonceVerificationSniff extends WordPress_Sniff {
|
|
138 |
$this->addMessage(
|
139 |
'Processing form data without nonce verification.',
|
140 |
$stackPtr,
|
141 |
-
|
142 |
'NoNonceVerification'
|
143 |
);
|
144 |
|
145 |
-
} // End
|
146 |
|
147 |
/**
|
148 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
18 |
*/
|
19 |
class WordPress_Sniffs_CSRF_NonceVerificationSniff extends WordPress_Sniff {
|
20 |
|
21 |
+
/**
|
22 |
+
* Superglobals to notify about when not accompanied by an nonce check.
|
23 |
+
*
|
24 |
+
* A value of `true` results in an error. A value of `false` in a warning.
|
25 |
+
*
|
26 |
+
* @since 0.12.0
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $superglobals = array(
|
31 |
+
'$_POST' => true,
|
32 |
+
'$_FILE' => true,
|
33 |
+
'$_GET' => false,
|
34 |
+
'$_REQUEST' => false,
|
35 |
+
);
|
36 |
+
|
37 |
/**
|
38 |
* Superglobals to give an error for when not accompanied by an nonce check.
|
39 |
*
|
40 |
* @since 0.5.0
|
41 |
* @since 0.11.0 Changed visibility from public to protected.
|
42 |
*
|
43 |
+
* @deprecated 0.12.0 Replaced by $superglobals property.
|
44 |
+
*
|
45 |
* @var array
|
46 |
*/
|
47 |
+
protected $errorForSuperGlobals = array();
|
48 |
|
49 |
/**
|
50 |
* Superglobals to give a warning for when not accompanied by an nonce check.
|
54 |
* @since 0.5.0
|
55 |
* @since 0.11.0 Changed visibility from public to protected.
|
56 |
*
|
57 |
+
* @deprecated 0.12.0 Replaced by $superglobals property.
|
58 |
+
*
|
59 |
* @var array
|
60 |
*/
|
61 |
+
protected $warnForSuperGlobals = array();
|
62 |
|
63 |
/**
|
64 |
* Custom list of functions which verify nonces.
|
127 |
|
128 |
$instance = $this->tokens[ $stackPtr ];
|
129 |
|
130 |
+
if ( ! isset( $this->superglobals[ $instance['content'] ] ) ) {
|
|
|
|
|
|
|
|
|
|
|
131 |
return;
|
132 |
}
|
133 |
|
153 |
$this->addMessage(
|
154 |
'Processing form data without nonce verification.',
|
155 |
$stackPtr,
|
156 |
+
$this->superglobals[ $instance['content'] ],
|
157 |
'NoNonceVerification'
|
158 |
);
|
159 |
|
160 |
+
} // End process_token().
|
161 |
|
162 |
/**
|
163 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Classes/ClassInstantiationSniff.php
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* WordPress_Sniffs_Classes_ClassInstantiationSniff.
|
12 |
+
*
|
13 |
+
* Verifies object instantiation statements.
|
14 |
+
* - Demand the use of parenthesis.
|
15 |
+
* - Demand no space between the class name and the parenthesis.
|
16 |
+
* - Forbid assigning new by reference.
|
17 |
+
*
|
18 |
+
* {@internal Note: This sniff currently does not examine the parenthesis of new object
|
19 |
+
* instantiations where the class name is held in a variable variable.}}
|
20 |
+
*
|
21 |
+
* @package WPCS\WordPressCodingStandards
|
22 |
+
*
|
23 |
+
* @since 0.12.0
|
24 |
+
*/
|
25 |
+
class WordPress_Sniffs_Classes_ClassInstantiationSniff extends WordPress_Sniff {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* A list of tokenizers this sniff supports.
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
public $supportedTokenizers = array(
|
33 |
+
'PHP',
|
34 |
+
'JS',
|
35 |
+
);
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Tokens which can be part of a "classname".
|
39 |
+
*
|
40 |
+
* Set from within the register() method.
|
41 |
+
*
|
42 |
+
* @var array
|
43 |
+
*/
|
44 |
+
protected $classname_tokens = array();
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Returns an array of tokens this test wants to listen for.
|
48 |
+
*
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function register() {
|
52 |
+
/*
|
53 |
+
* Set the $classname_tokens property.
|
54 |
+
*
|
55 |
+
* Currently does not account for classnames passed as a variable variable.
|
56 |
+
*/
|
57 |
+
$this->classname_tokens = PHP_CodeSniffer_Tokens::$emptyTokens;
|
58 |
+
$this->classname_tokens[ T_NS_SEPARATOR ] = T_NS_SEPARATOR;
|
59 |
+
$this->classname_tokens[ T_STRING ] = T_STRING;
|
60 |
+
$this->classname_tokens[ T_SELF ] = T_SELF;
|
61 |
+
$this->classname_tokens[ T_STATIC ] = T_STATIC;
|
62 |
+
$this->classname_tokens[ T_PARENT ] = T_PARENT;
|
63 |
+
$this->classname_tokens[ T_ANON_CLASS ] = T_ANON_CLASS;
|
64 |
+
// Classname in a variable.
|
65 |
+
$this->classname_tokens[ T_VARIABLE ] = T_VARIABLE;
|
66 |
+
$this->classname_tokens[ T_DOUBLE_COLON ] = T_DOUBLE_COLON;
|
67 |
+
$this->classname_tokens[ T_OBJECT_OPERATOR ] = T_OBJECT_OPERATOR;
|
68 |
+
$this->classname_tokens[ T_OPEN_SQUARE_BRACKET ] = T_OPEN_SQUARE_BRACKET;
|
69 |
+
$this->classname_tokens[ T_CLOSE_SQUARE_BRACKET ] = T_CLOSE_SQUARE_BRACKET;
|
70 |
+
|
71 |
+
return array(
|
72 |
+
T_NEW,
|
73 |
+
T_STRING, // JS.
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Processes this test, when one of its tokens is encountered.
|
79 |
+
*
|
80 |
+
* @param int $stackPtr The position of the current token in the stack.
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function process_token( $stackPtr ) {
|
85 |
+
// Make sure we have the right token, JS vs PHP.
|
86 |
+
if ( ( 'PHP' === $this->phpcsFile->tokenizerType && T_NEW !== $this->tokens[ $stackPtr ]['code'] )
|
87 |
+
|| ( 'JS' === $this->phpcsFile->tokenizerType
|
88 |
+
&& ( T_STRING !== $this->tokens[ $stackPtr ]['code']
|
89 |
+
|| 'new' !== strtolower( $this->tokens[ $stackPtr ]['content'] ) ) )
|
90 |
+
) {
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
|
94 |
+
/*
|
95 |
+
* Check for new by reference used in PHP files.
|
96 |
+
*/
|
97 |
+
if ( 'PHP' === $this->phpcsFile->tokenizerType ) {
|
98 |
+
$prev_non_empty = $this->phpcsFile->findPrevious(
|
99 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
100 |
+
($stackPtr - 1),
|
101 |
+
null,
|
102 |
+
true
|
103 |
+
);
|
104 |
+
|
105 |
+
if ( false !== $prev_non_empty && 'T_BITWISE_AND' === $this->tokens[ $prev_non_empty ]['type'] ) {
|
106 |
+
$this->phpcsFile->recordMetric( $stackPtr, 'Assigning new by reference', 'yes' );
|
107 |
+
|
108 |
+
$this->phpcsFile->addError(
|
109 |
+
'Assigning the return value of new by reference is no longer supported by PHP.',
|
110 |
+
$stackPtr,
|
111 |
+
'NewByReferenceFound'
|
112 |
+
);
|
113 |
+
} else {
|
114 |
+
$this->phpcsFile->recordMetric( $stackPtr, 'Assigning new by reference', 'no' );
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/*
|
119 |
+
* Check for parenthesis & correct placement thereof.
|
120 |
+
*/
|
121 |
+
$next_non_empty_after_class_name = $this->phpcsFile->findNext(
|
122 |
+
$this->classname_tokens,
|
123 |
+
($stackPtr + 1),
|
124 |
+
null,
|
125 |
+
true,
|
126 |
+
null,
|
127 |
+
true
|
128 |
+
);
|
129 |
+
|
130 |
+
if ( false === $next_non_empty_after_class_name ) {
|
131 |
+
// Live coding.
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
// Walk back to the last part of the class name.
|
136 |
+
$has_comment = false;
|
137 |
+
for ( $classname_ptr = ( $next_non_empty_after_class_name - 1 ); $classname_ptr >= $stackPtr; $classname_ptr-- ) {
|
138 |
+
if ( ! isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $this->tokens[ $classname_ptr ]['code'] ] ) ) {
|
139 |
+
// Prevent a false positive on variable variables, disregard them for now.
|
140 |
+
if ( $stackPtr === $classname_ptr ) {
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
break;
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( T_WHITESPACE !== $this->tokens[ $classname_ptr ]['code'] ) {
|
148 |
+
$has_comment = true;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
if ( T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty_after_class_name ]['code'] ) {
|
153 |
+
$this->phpcsFile->recordMetric( $stackPtr, 'Object instantiation with parenthesis', 'no' );
|
154 |
+
|
155 |
+
$fix = $this->phpcsFile->addFixableError(
|
156 |
+
'Parenthesis should always be used when instantiating a new object.',
|
157 |
+
$classname_ptr,
|
158 |
+
'MissingParenthesis'
|
159 |
+
);
|
160 |
+
|
161 |
+
if ( true === $fix ) {
|
162 |
+
$this->phpcsFile->fixer->addContent( $classname_ptr, '()' );
|
163 |
+
}
|
164 |
+
} else {
|
165 |
+
$this->phpcsFile->recordMetric( $stackPtr, 'Object instantiation with parenthesis', 'yes' );
|
166 |
+
|
167 |
+
if ( ( $next_non_empty_after_class_name - 1 ) !== $classname_ptr ) {
|
168 |
+
$this->phpcsFile->recordMetric(
|
169 |
+
$stackPtr,
|
170 |
+
'Space between classname and parenthesis',
|
171 |
+
( $next_non_empty_after_class_name - $classname_ptr )
|
172 |
+
);
|
173 |
+
|
174 |
+
$error = 'There must be no spaces between the class name and the open parenthesis when instantiating a new object.';
|
175 |
+
$error_code = 'SpaceBeforeParenthesis';
|
176 |
+
|
177 |
+
if ( false === $has_comment ) {
|
178 |
+
$fix = $this->phpcsFile->addFixableError( $error, $next_non_empty_after_class_name, $error_code );
|
179 |
+
|
180 |
+
if ( true === $fix ) {
|
181 |
+
$this->phpcsFile->fixer->beginChangeset();
|
182 |
+
for ( $i = ( $next_non_empty_after_class_name - 1 ); $i > $classname_ptr; $i-- ) {
|
183 |
+
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
184 |
+
}
|
185 |
+
$this->phpcsFile->fixer->endChangeset();
|
186 |
+
}
|
187 |
+
} else {
|
188 |
+
$fix = $this->phpcsFile->addError( $error, $next_non_empty_after_class_name, $error_code );
|
189 |
+
}
|
190 |
+
} else {
|
191 |
+
$this->phpcsFile->recordMetric( $stackPtr, 'Space between classname and parenthesis', 0 );
|
192 |
+
}
|
193 |
+
}
|
194 |
+
} // End process_token().
|
195 |
+
|
196 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Checks against empty statements.
|
12 |
+
*
|
13 |
+
* - Check against two semi-colons with no executable code in between.
|
14 |
+
* - Check against an empty PHP open - close tag combination.
|
15 |
+
*
|
16 |
+
* {@internal This check should at some point in the future be pulled upstream and probably
|
17 |
+
* merged into the upstream `Generic.CodeAnalysis.EmptyStatement` sniff.
|
18 |
+
* This will need to wait until the WPCS minimum requirements have gone up
|
19 |
+
* beyond PHPCS 3.x though as it is not likely that new features will be accepted
|
20 |
+
* still for the PHPCS 2.x branch.}}
|
21 |
+
*
|
22 |
+
* @package WPCS\WordPressCodingStandards
|
23 |
+
*
|
24 |
+
* @since 0.12.0
|
25 |
+
*/
|
26 |
+
class WordPress_Sniffs_CodeAnalysis_EmptyStatementSniff extends WordPress_Sniff {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns an array of tokens this test wants to listen for.
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function register() {
|
34 |
+
return array(
|
35 |
+
T_SEMICOLON,
|
36 |
+
T_CLOSE_TAG,
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Processes this test, when one of its tokens is encountered.
|
42 |
+
*
|
43 |
+
* @param int $stackPtr The position of the current token in the stack.
|
44 |
+
*
|
45 |
+
* @return int Integer stack pointer to skip the rest of the file.
|
46 |
+
*/
|
47 |
+
public function process_token( $stackPtr ) {
|
48 |
+
|
49 |
+
switch ( $this->tokens[ $stackPtr ]['type'] ) {
|
50 |
+
/*
|
51 |
+
* Detect `something();;`.
|
52 |
+
*/
|
53 |
+
case 'T_SEMICOLON':
|
54 |
+
$prevNonEmpty = $this->phpcsFile->findPrevious(
|
55 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
56 |
+
( $stackPtr - 1 ),
|
57 |
+
null,
|
58 |
+
true
|
59 |
+
);
|
60 |
+
|
61 |
+
if ( false === $prevNonEmpty
|
62 |
+
|| ( T_SEMICOLON !== $this->tokens[ $prevNonEmpty ]['code']
|
63 |
+
&& T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code'] )
|
64 |
+
) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
$fix = $this->phpcsFile->addFixableWarning(
|
69 |
+
'Empty PHP statement detected: superfluous semi-colon.',
|
70 |
+
$stackPtr,
|
71 |
+
'SemicolonWithoutCodeDetected'
|
72 |
+
);
|
73 |
+
if ( true === $fix ) {
|
74 |
+
$this->phpcsFile->fixer->beginChangeset();
|
75 |
+
|
76 |
+
if ( T_OPEN_TAG === $this->tokens[ $prevNonEmpty ]['code'] ) {
|
77 |
+
/*
|
78 |
+
* Check for superfluous whitespace after the semi-colon which will be
|
79 |
+
* removed as the `<?php ` open tag token already contains whitespace,
|
80 |
+
* either a space or a new line and in case of a new line, the indentation
|
81 |
+
* should be done via tabs, so spaces can be safely removed.
|
82 |
+
*/
|
83 |
+
if ( T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
|
84 |
+
$replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ]['content'] );
|
85 |
+
$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $replacement );
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
for ( $i = $stackPtr; $i > $prevNonEmpty; $i-- ) {
|
90 |
+
if ( T_SEMICOLON !== $this->tokens[ $i ]['code']
|
91 |
+
&& T_WHITESPACE !== $this->tokens[ $i ]['code']
|
92 |
+
) {
|
93 |
+
break;
|
94 |
+
}
|
95 |
+
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->phpcsFile->fixer->endChangeset();
|
99 |
+
}
|
100 |
+
break;
|
101 |
+
|
102 |
+
/*
|
103 |
+
* Detect `<?php ?>`.
|
104 |
+
*/
|
105 |
+
case 'T_CLOSE_TAG':
|
106 |
+
$prevNonEmpty = $this->phpcsFile->findPrevious(
|
107 |
+
T_WHITESPACE,
|
108 |
+
( $stackPtr - 1 ),
|
109 |
+
null,
|
110 |
+
true
|
111 |
+
);
|
112 |
+
|
113 |
+
if ( false === $prevNonEmpty || T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code'] ) {
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
$fix = $this->phpcsFile->addFixableWarning(
|
118 |
+
'Empty PHP open/close tag combination detected.',
|
119 |
+
$prevNonEmpty,
|
120 |
+
'EmptyPHPOpenCloseTagsDetected'
|
121 |
+
);
|
122 |
+
if ( true === $fix ) {
|
123 |
+
$this->phpcsFile->fixer->beginChangeset();
|
124 |
+
for ( $i = $prevNonEmpty; $i <= $stackPtr; $i++ ) {
|
125 |
+
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
126 |
+
}
|
127 |
+
$this->phpcsFile->fixer->endChangeset();
|
128 |
+
}
|
129 |
+
break;
|
130 |
+
|
131 |
+
default:
|
132 |
+
/* Deliberately left empty. */
|
133 |
+
break;
|
134 |
+
}
|
135 |
+
|
136 |
+
} // End process_token().
|
137 |
+
|
138 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php
CHANGED
@@ -27,11 +27,11 @@ class WordPress_Sniffs_DB_RestrictedClassesSniff extends WordPress_AbstractClass
|
|
27 |
* Groups of classes to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
* )
|
36 |
*
|
37 |
* @return array
|
27 |
* Groups of classes to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
+
* 'lambda' => array(
|
31 |
+
* 'type' => 'error' | 'warning',
|
32 |
+
* 'message' => 'Avoid direct calls to the database.',
|
33 |
+
* 'classes' => array( 'PDO', '\Namespace\Classname' ),
|
34 |
+
* )
|
35 |
* )
|
36 |
*
|
37 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php
CHANGED
@@ -27,11 +27,11 @@ class WordPress_Sniffs_DB_RestrictedFunctionsSniff extends WordPress_AbstractFun
|
|
27 |
* Groups of functions to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
* )
|
36 |
*
|
37 |
* @return array
|
27 |
* Groups of functions to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
+
* 'lambda' => array(
|
31 |
+
* 'type' => 'error' | 'warning',
|
32 |
+
* 'message' => 'Use anonymous functions instead please!',
|
33 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
34 |
+
* )
|
35 |
* )
|
36 |
*
|
37 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php
CHANGED
@@ -21,8 +21,11 @@
|
|
21 |
* template tags end in `-template`. Based on @subpackage file DocBlock tag.
|
22 |
* - This sniff will now allow for underscores in file names for certain theme
|
23 |
* specific exceptions if the `$is_theme` property is set to `true`.
|
|
|
|
|
|
|
24 |
*/
|
25 |
-
class WordPress_Sniffs_Files_FileNameSniff
|
26 |
|
27 |
/**
|
28 |
* Regex for the theme specific exceptions.
|
@@ -35,6 +38,8 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
35 |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types
|
36 |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#embeds
|
37 |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#attachment
|
|
|
|
|
38 |
* @link https://en.wikipedia.org/wiki/Media_type#Naming
|
39 |
*
|
40 |
* @since 0.11.0
|
@@ -44,7 +49,8 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
44 |
const THEME_EXCEPTIONS_REGEX = '`
|
45 |
^ # Anchor to the beginning of the string.
|
46 |
(?:
|
47 |
-
|
|
|
48 |
-[^\.]+ # These need to be followed by a dash and some chars.
|
49 |
|
|
50 |
(?:application|audio|example|image|message|model|multipart|text|video) #Top-level mime-types
|
@@ -117,15 +123,19 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
117 |
/**
|
118 |
* Processes this test, when one of its tokens is encountered.
|
119 |
*
|
120 |
-
* @param
|
121 |
-
* @param int $stackPtr The position of the current token in the
|
122 |
-
* stack passed in $tokens.
|
123 |
*
|
124 |
-
* @return int
|
|
|
125 |
*/
|
126 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
$file = $phpcsFile->getFileName();
|
129 |
$fileName = basename( $file );
|
130 |
$expected = strtolower( str_replace( '_', '-', $fileName ) );
|
131 |
|
@@ -133,7 +143,7 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
133 |
* Generic check for lowercase hyphenated file names.
|
134 |
*/
|
135 |
if ( $fileName !== $expected && ( false === $this->is_theme || 1 !== preg_match( self::THEME_EXCEPTIONS_REGEX, $fileName ) ) ) {
|
136 |
-
$phpcsFile->addError(
|
137 |
'Filenames should be all lowercase with hyphens as word separators. Expected %s, but found %s.',
|
138 |
0,
|
139 |
'NotHyphenatedLowercase',
|
@@ -147,13 +157,13 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
147 |
* the file name reflects the class name.
|
148 |
*/
|
149 |
if ( true === $this->strict_class_file_names ) {
|
150 |
-
$has_class = $phpcsFile->findNext( T_CLASS, $stackPtr );
|
151 |
-
if ( false !== $has_class ) {
|
152 |
-
$class_name = $phpcsFile->getDeclarationName( $has_class );
|
153 |
$expected = 'class-' . strtolower( str_replace( '_', '-', $class_name ) );
|
154 |
|
155 |
if ( substr( $fileName, 0, -4 ) !== $expected && ! isset( $this->class_exceptions[ $fileName ] ) ) {
|
156 |
-
$phpcsFile->addError(
|
157 |
'Class file names should be based on the class name with "class-" prepended. Expected %s, but found %s.',
|
158 |
0,
|
159 |
'InvalidClassFileName',
|
@@ -171,21 +181,20 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
171 |
* Check non-class files in "wp-includes" with a "@subpackage Template" tag for a "-template" suffix.
|
172 |
*/
|
173 |
if ( false !== strpos( $file, DIRECTORY_SEPARATOR . 'wp-includes' . DIRECTORY_SEPARATOR ) ) {
|
174 |
-
$subpackage_tag = $phpcsFile->findNext( T_DOC_COMMENT_TAG, $stackPtr, null, false, '@subpackage' );
|
175 |
if ( false !== $subpackage_tag ) {
|
176 |
-
$subpackage = $phpcsFile->findNext( T_DOC_COMMENT_STRING, $subpackage_tag );
|
177 |
if ( false !== $subpackage ) {
|
178 |
-
$tokens = $phpcsFile->getTokens();
|
179 |
$fileName_end = substr( $fileName, -13 );
|
180 |
-
$has_class = $phpcsFile->findNext( T_CLASS, $stackPtr );
|
181 |
|
182 |
-
if ( ( 'Template' === trim( $tokens[ $subpackage ]['content'] )
|
183 |
-
&& $tokens[ $subpackage_tag ]['line'] === $tokens[ $subpackage ]['line'] )
|
184 |
&& ( ( ! defined( 'PHP_CODESNIFFER_IN_TESTS' ) && '-template.php' !== $fileName_end )
|
185 |
|| ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) && '-template.inc' !== $fileName_end ) )
|
186 |
&& false === $has_class
|
187 |
) {
|
188 |
-
$phpcsFile->addError(
|
189 |
'Files containing template tags should have "-template" appended to the end of the file name. Expected %s, but found %s.',
|
190 |
0,
|
191 |
'InvalidTemplateTagFileName',
|
@@ -197,11 +206,11 @@ class WordPress_Sniffs_Files_FileNameSniff implements PHP_CodeSniffer_Sniff {
|
|
197 |
}
|
198 |
}
|
199 |
}
|
200 |
-
}
|
201 |
|
202 |
// Only run this sniff once per file, no need to run it again.
|
203 |
-
return ( $phpcsFile->numTokens + 1 );
|
204 |
|
205 |
-
} // End
|
206 |
|
207 |
} // End class.
|
21 |
* template tags end in `-template`. Based on @subpackage file DocBlock tag.
|
22 |
* - This sniff will now allow for underscores in file names for certain theme
|
23 |
* specific exceptions if the `$is_theme` property is set to `true`.
|
24 |
+
* @since 0.12.0 - Now extends the `WordPress_Sniff` class.
|
25 |
+
*
|
26 |
+
* @uses WordPress_Sniff::$custom_test_class_whitelist
|
27 |
*/
|
28 |
+
class WordPress_Sniffs_Files_FileNameSniff extends WordPress_Sniff {
|
29 |
|
30 |
/**
|
31 |
* Regex for the theme specific exceptions.
|
38 |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types
|
39 |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#embeds
|
40 |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#attachment
|
41 |
+
* @link https://developer.wordpress.org/themes/template-files-section/partial-and-miscellaneous-template-files/#content-slug-php
|
42 |
+
* @link https://wphierarchy.com/
|
43 |
* @link https://en.wikipedia.org/wiki/Media_type#Naming
|
44 |
*
|
45 |
* @since 0.11.0
|
49 |
const THEME_EXCEPTIONS_REGEX = '`
|
50 |
^ # Anchor to the beginning of the string.
|
51 |
(?:
|
52 |
+
# Template prefixes which can have exceptions.
|
53 |
+
(?:archive|category|content|embed|page|single|tag|taxonomy)
|
54 |
-[^\.]+ # These need to be followed by a dash and some chars.
|
55 |
|
|
56 |
(?:application|audio|example|image|message|model|multipart|text|video) #Top-level mime-types
|
123 |
/**
|
124 |
* Processes this test, when one of its tokens is encountered.
|
125 |
*
|
126 |
+
* @param int $stackPtr The position of the current token in the stack.
|
|
|
|
|
127 |
*
|
128 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
129 |
+
* normal file processing.
|
130 |
*/
|
131 |
+
public function process_token( $stackPtr ) {
|
132 |
+
|
133 |
+
// Usage of `strip_quotes` is to ensure `stdin_path` passed by IDEs does not include quotes.
|
134 |
+
$file = $this->strip_quotes( $this->phpcsFile->getFileName() );
|
135 |
+
if ( 'STDIN' === $file ) {
|
136 |
+
return;
|
137 |
+
}
|
138 |
|
|
|
139 |
$fileName = basename( $file );
|
140 |
$expected = strtolower( str_replace( '_', '-', $fileName ) );
|
141 |
|
143 |
* Generic check for lowercase hyphenated file names.
|
144 |
*/
|
145 |
if ( $fileName !== $expected && ( false === $this->is_theme || 1 !== preg_match( self::THEME_EXCEPTIONS_REGEX, $fileName ) ) ) {
|
146 |
+
$this->phpcsFile->addError(
|
147 |
'Filenames should be all lowercase with hyphens as word separators. Expected %s, but found %s.',
|
148 |
0,
|
149 |
'NotHyphenatedLowercase',
|
157 |
* the file name reflects the class name.
|
158 |
*/
|
159 |
if ( true === $this->strict_class_file_names ) {
|
160 |
+
$has_class = $this->phpcsFile->findNext( T_CLASS, $stackPtr );
|
161 |
+
if ( false !== $has_class && false === $this->is_test_class( $has_class ) ) {
|
162 |
+
$class_name = $this->phpcsFile->getDeclarationName( $has_class );
|
163 |
$expected = 'class-' . strtolower( str_replace( '_', '-', $class_name ) );
|
164 |
|
165 |
if ( substr( $fileName, 0, -4 ) !== $expected && ! isset( $this->class_exceptions[ $fileName ] ) ) {
|
166 |
+
$this->phpcsFile->addError(
|
167 |
'Class file names should be based on the class name with "class-" prepended. Expected %s, but found %s.',
|
168 |
0,
|
169 |
'InvalidClassFileName',
|
181 |
* Check non-class files in "wp-includes" with a "@subpackage Template" tag for a "-template" suffix.
|
182 |
*/
|
183 |
if ( false !== strpos( $file, DIRECTORY_SEPARATOR . 'wp-includes' . DIRECTORY_SEPARATOR ) ) {
|
184 |
+
$subpackage_tag = $this->phpcsFile->findNext( T_DOC_COMMENT_TAG, $stackPtr, null, false, '@subpackage' );
|
185 |
if ( false !== $subpackage_tag ) {
|
186 |
+
$subpackage = $this->phpcsFile->findNext( T_DOC_COMMENT_STRING, $subpackage_tag );
|
187 |
if ( false !== $subpackage ) {
|
|
|
188 |
$fileName_end = substr( $fileName, -13 );
|
189 |
+
$has_class = $this->phpcsFile->findNext( T_CLASS, $stackPtr );
|
190 |
|
191 |
+
if ( ( 'Template' === trim( $this->tokens[ $subpackage ]['content'] )
|
192 |
+
&& $this->tokens[ $subpackage_tag ]['line'] === $this->tokens[ $subpackage ]['line'] )
|
193 |
&& ( ( ! defined( 'PHP_CODESNIFFER_IN_TESTS' ) && '-template.php' !== $fileName_end )
|
194 |
|| ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) && '-template.inc' !== $fileName_end ) )
|
195 |
&& false === $has_class
|
196 |
) {
|
197 |
+
$this->phpcsFile->addError(
|
198 |
'Files containing template tags should have "-template" appended to the end of the file name. Expected %s, but found %s.',
|
199 |
0,
|
200 |
'InvalidTemplateTagFileName',
|
206 |
}
|
207 |
}
|
208 |
}
|
209 |
+
}
|
210 |
|
211 |
// Only run this sniff once per file, no need to run it again.
|
212 |
+
return ( $this->phpcsFile->numTokens + 1 );
|
213 |
|
214 |
+
} // End process_token().
|
215 |
|
216 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Functions/DontExtractSniff.php
CHANGED
@@ -22,11 +22,11 @@ class WordPress_Sniffs_Functions_DontExtractSniff extends WordPress_AbstractFunc
|
|
22 |
* Groups of functions to restrict.
|
23 |
*
|
24 |
* Example: groups => array(
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
* )
|
31 |
*
|
32 |
* @return array
|
22 |
* Groups of functions to restrict.
|
23 |
*
|
24 |
* Example: groups => array(
|
25 |
+
* 'lambda' => array(
|
26 |
+
* 'type' => 'error' | 'warning',
|
27 |
+
* 'message' => 'Use anonymous functions instead please!',
|
28 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
29 |
+
* )
|
30 |
* )
|
31 |
*
|
32 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Functions/FunctionCallSignatureNoParamsSniff.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Enforces no whitespace between the parenthesis of a function call without parameters.
|
12 |
+
*
|
13 |
+
* @link https://make.wordpress.org/core/handbook/coding-standards/php/#space-usage
|
14 |
+
*
|
15 |
+
* @package WPCS\WordPressCodingStandards
|
16 |
+
*
|
17 |
+
* @since 0.12.0
|
18 |
+
*/
|
19 |
+
class WordPress_Sniffs_Functions_FunctionCallSignatureNoParamsSniff extends WordPress_Sniff {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Returns an array of tokens this test wants to listen for.
|
23 |
+
*
|
24 |
+
* @return array
|
25 |
+
*/
|
26 |
+
public function register() {
|
27 |
+
return PHP_CodeSniffer_Tokens::$functionNameTokens;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Processes this test, when one of its tokens is encountered.
|
32 |
+
*
|
33 |
+
* @param int $stackPtr The position of the current token in the stack.
|
34 |
+
*
|
35 |
+
* @return int Integer stack pointer to skip the rest of the file.
|
36 |
+
*/
|
37 |
+
public function process_token( $stackPtr ) {
|
38 |
+
|
39 |
+
// Find the next non-empty token.
|
40 |
+
$openParenthesis = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
41 |
+
|
42 |
+
if ( T_OPEN_PARENTHESIS !== $this->tokens[ $openParenthesis ]['code'] ) {
|
43 |
+
// Not a function call.
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( ! isset( $this->tokens[ $openParenthesis ]['parenthesis_closer'] ) ) {
|
48 |
+
// Not a function call.
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
|
52 |
+
// Find the previous non-empty token.
|
53 |
+
$search = PHP_CodeSniffer_Tokens::$emptyTokens;
|
54 |
+
$search[] = T_BITWISE_AND;
|
55 |
+
$previous = $this->phpcsFile->findPrevious( $search, ( $stackPtr - 1 ), null, true );
|
56 |
+
if ( T_FUNCTION === $this->tokens[ $previous ]['code'] ) {
|
57 |
+
// It's a function definition, not a function call.
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
$closer = $this->tokens[ $openParenthesis ]['parenthesis_closer'];
|
62 |
+
|
63 |
+
if ( ( $closer - 1 ) === $openParenthesis ) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
$nextNonWhitespace = $this->phpcsFile->findNext( T_WHITESPACE, ( $openParenthesis + 1 ), null, true );
|
68 |
+
|
69 |
+
if ( $nextNonWhitespace !== $closer ) {
|
70 |
+
// Function has params or comment between parenthesis.
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
$fix = $this->phpcsFile->addFixableError(
|
75 |
+
'Function calls without parameters should have no spaces between the parenthesis.',
|
76 |
+
( $openParenthesis + 1 ),
|
77 |
+
'WhitespaceFound'
|
78 |
+
);
|
79 |
+
if ( true === $fix ) {
|
80 |
+
// If there is only whitespace between the parenthesis, it will just be the one token.
|
81 |
+
$this->phpcsFile->fixer->replaceToken( ( $openParenthesis + 1 ), '' );
|
82 |
+
}
|
83 |
+
|
84 |
+
} // End process_token().
|
85 |
+
|
86 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Functions/FunctionRestrictionsSniff.php
CHANGED
@@ -26,11 +26,11 @@ class WordPress_Sniffs_Functions_FunctionRestrictionsSniff extends WordPress_Abs
|
|
26 |
* Groups of functions to restrict.
|
27 |
*
|
28 |
* Example: groups => array(
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
* )
|
35 |
*
|
36 |
* @return array
|
26 |
* Groups of functions to restrict.
|
27 |
*
|
28 |
* Example: groups => array(
|
29 |
+
* 'lambda' => array(
|
30 |
+
* 'type' => 'error' | 'warning',
|
31 |
+
* 'message' => 'Use anonymous functions instead please!',
|
32 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
33 |
+
* )
|
34 |
* )
|
35 |
*
|
36 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php
ADDED
@@ -0,0 +1,738 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Verify that everything defined in the global namespace is prefixed with a theme/plugin specific prefix.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
*
|
15 |
+
* @since 0.12.0
|
16 |
+
*
|
17 |
+
* @uses WordPress_Sniff::$custom_test_class_whitelist
|
18 |
+
*/
|
19 |
+
class WordPress_Sniffs_NamingConventions_PrefixAllGlobalsSniff extends WordPress_AbstractFunctionParameterSniff {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Error message template.
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
const ERROR_MSG = '%s by a theme/plugin should start with the theme/plugin prefix. Found: "%s".';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Target prefixes.
|
30 |
+
*
|
31 |
+
* @since 0.12.0
|
32 |
+
*
|
33 |
+
* @var string[]|string
|
34 |
+
*/
|
35 |
+
public $prefixes = '';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Prefix blacklist.
|
39 |
+
*
|
40 |
+
* @since 0.12.0
|
41 |
+
*
|
42 |
+
* @var string[]
|
43 |
+
*/
|
44 |
+
protected $prefix_blacklist = array(
|
45 |
+
'wp' => true,
|
46 |
+
'_' => true,
|
47 |
+
);
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Target prefixes after validation.
|
51 |
+
*
|
52 |
+
* @since 0.12.0
|
53 |
+
*
|
54 |
+
* @var string[]
|
55 |
+
*/
|
56 |
+
private $validated_prefixes = array();
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Cache of previously set prefixes.
|
60 |
+
*
|
61 |
+
* Prevents having to do the same prefix validation over and over again.
|
62 |
+
*
|
63 |
+
* @since 0.12.0
|
64 |
+
*
|
65 |
+
* @var string[]
|
66 |
+
*/
|
67 |
+
private $previous_prefixes = array();
|
68 |
+
|
69 |
+
/**
|
70 |
+
* A list of all PHP superglobals with the exception of $GLOBALS which is handled separately.
|
71 |
+
*
|
72 |
+
* @since 0.12.0
|
73 |
+
*
|
74 |
+
* @var array
|
75 |
+
*/
|
76 |
+
protected $superglobals = array(
|
77 |
+
'_COOKIE' => true,
|
78 |
+
'_ENV' => true,
|
79 |
+
'_GET' => true,
|
80 |
+
'_FILES' => true,
|
81 |
+
'_POST' => true,
|
82 |
+
'_REQUEST' => true,
|
83 |
+
'_SERVER' => true,
|
84 |
+
'_SESSION' => true,
|
85 |
+
);
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Returns an array of tokens this test wants to listen for.
|
89 |
+
*
|
90 |
+
* @since 0.12.0
|
91 |
+
*
|
92 |
+
* @return array
|
93 |
+
*/
|
94 |
+
public function register() {
|
95 |
+
$targets = array(
|
96 |
+
T_FUNCTION => T_FUNCTION,
|
97 |
+
T_CLASS => T_CLASS,
|
98 |
+
T_INTERFACE => T_INTERFACE,
|
99 |
+
T_TRAIT => T_TRAIT,
|
100 |
+
T_CONST => T_CONST,
|
101 |
+
T_VARIABLE => T_VARIABLE,
|
102 |
+
T_DOLLAR => T_DOLLAR, // Variable variables.
|
103 |
+
);
|
104 |
+
|
105 |
+
// Add function call target for hook names and constants defined using define().
|
106 |
+
$parent = parent::register();
|
107 |
+
if ( ! empty( $parent ) ) {
|
108 |
+
$targets[] = T_STRING;
|
109 |
+
}
|
110 |
+
|
111 |
+
return $targets;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Groups of functions to restrict.
|
116 |
+
*
|
117 |
+
* @since 0.12.0
|
118 |
+
*
|
119 |
+
* @return array
|
120 |
+
*/
|
121 |
+
public function getGroups() {
|
122 |
+
$this->target_functions = $this->hookInvokeFunctions;
|
123 |
+
$this->target_functions['define'] = true;
|
124 |
+
|
125 |
+
return parent::getGroups();
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Processes this test, when one of its tokens is encountered.
|
130 |
+
*
|
131 |
+
* @since 0.12.0
|
132 |
+
*
|
133 |
+
* @param int $stackPtr The position of the current token in the stack.
|
134 |
+
*
|
135 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
136 |
+
* normal file processing.
|
137 |
+
*/
|
138 |
+
public function process_token( $stackPtr ) {
|
139 |
+
/*
|
140 |
+
* Allow for whitelisting.
|
141 |
+
*
|
142 |
+
* Generally speaking a theme/plugin should *only* execute their own hooks, but there may be a
|
143 |
+
* good reason to execute a core hook.
|
144 |
+
*
|
145 |
+
* Similarly, newer PHP or WP functions or constants may need to be emulated for continued support
|
146 |
+
* of older PHP and WP versions.
|
147 |
+
*/
|
148 |
+
if ( $this->has_whitelist_comment( 'prefix', $stackPtr ) ) {
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
// Allow overruling the prefixes set in a ruleset via the command line.
|
153 |
+
$cl_prefixes = trim( PHP_CodeSniffer::getConfigData( 'prefixes' ) );
|
154 |
+
if ( ! empty( $cl_prefixes ) ) {
|
155 |
+
$this->prefixes = $cl_prefixes;
|
156 |
+
}
|
157 |
+
|
158 |
+
$this->prefixes = $this->merge_custom_array( $this->prefixes, array(), false );
|
159 |
+
if ( empty( $this->prefixes ) ) {
|
160 |
+
// No prefixes passed, nothing to do.
|
161 |
+
return;
|
162 |
+
}
|
163 |
+
|
164 |
+
$this->validate_prefixes();
|
165 |
+
if ( empty( $this->validated_prefixes ) ) {
|
166 |
+
// No _valid_ prefixes passed, nothing to do.
|
167 |
+
return;
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( T_STRING === $this->tokens[ $stackPtr ]['code'] ) {
|
171 |
+
// Disallow excluding function groups for this sniff.
|
172 |
+
$this->exclude = '';
|
173 |
+
|
174 |
+
return parent::process_token( $stackPtr );
|
175 |
+
|
176 |
+
} elseif ( T_DOLLAR === $this->tokens[ $stackPtr ]['code'] ) {
|
177 |
+
|
178 |
+
return $this->process_variable_variable( $stackPtr );
|
179 |
+
|
180 |
+
} elseif ( T_VARIABLE === $this->tokens[ $stackPtr ]['code'] ) {
|
181 |
+
|
182 |
+
return $this->process_variable_assignment( $stackPtr );
|
183 |
+
|
184 |
+
} else {
|
185 |
+
|
186 |
+
// Namespaced methods, classes and constants do not need to be prefixed.
|
187 |
+
$namespace = $this->determine_namespace( $stackPtr );
|
188 |
+
if ( '' !== $namespace && '\\' !== $namespace ) {
|
189 |
+
return;
|
190 |
+
}
|
191 |
+
|
192 |
+
$item_name = '';
|
193 |
+
$error_text = 'Unknown syntax used by';
|
194 |
+
$error_code = 'NonPrefixedSyntaxFound';
|
195 |
+
|
196 |
+
switch ( $this->tokens[ $stackPtr ]['type'] ) {
|
197 |
+
case 'T_FUNCTION':
|
198 |
+
// Methods in a class do not need to be prefixed.
|
199 |
+
if ( $this->phpcsFile->hasCondition( $stackPtr, array( T_CLASS, T_ANON_CLASS, T_INTERFACE, T_TRAIT ) ) === true ) {
|
200 |
+
return;
|
201 |
+
}
|
202 |
+
|
203 |
+
$item_name = $this->phpcsFile->getDeclarationName( $stackPtr );
|
204 |
+
if ( function_exists( $item_name ) ) {
|
205 |
+
// Backfill for PHP native function.
|
206 |
+
return;
|
207 |
+
}
|
208 |
+
|
209 |
+
$error_text = 'Functions declared';
|
210 |
+
$error_code = 'NonPrefixedFunctionFound';
|
211 |
+
break;
|
212 |
+
|
213 |
+
case 'T_CLASS':
|
214 |
+
case 'T_INTERFACE':
|
215 |
+
case 'T_TRAIT':
|
216 |
+
// Ignore test classes.
|
217 |
+
if ( true === $this->is_test_class( $stackPtr ) ) {
|
218 |
+
if ( $this->tokens[ $stackPtr ]['scope_condition'] === $stackPtr && isset( $this->tokens[ $stackPtr ]['scope_closer'] ) ) {
|
219 |
+
// Skip forward to end of test class.
|
220 |
+
return $this->tokens[ $stackPtr ]['scope_closer'];
|
221 |
+
}
|
222 |
+
return;
|
223 |
+
}
|
224 |
+
|
225 |
+
$item_name = $this->phpcsFile->getDeclarationName( $stackPtr );
|
226 |
+
$error_text = 'Classes declared';
|
227 |
+
$error_code = 'NonPrefixedClassFound';
|
228 |
+
|
229 |
+
switch ( $this->tokens[ $stackPtr ]['type'] ) {
|
230 |
+
case 'T_CLASS':
|
231 |
+
if ( class_exists( $item_name ) ) {
|
232 |
+
// Backfill for PHP native class.
|
233 |
+
return;
|
234 |
+
}
|
235 |
+
break;
|
236 |
+
|
237 |
+
case 'T_INTERFACE':
|
238 |
+
if ( interface_exists( $item_name ) ) {
|
239 |
+
// Backfill for PHP native interface.
|
240 |
+
return;
|
241 |
+
}
|
242 |
+
|
243 |
+
$error_text = 'Interfaces declared';
|
244 |
+
$error_code = 'NonPrefixedInterfaceFound';
|
245 |
+
break;
|
246 |
+
|
247 |
+
case 'T_TRAIT':
|
248 |
+
if ( function_exists( 'trait_exists' ) && trait_exists( $item_name ) ) {
|
249 |
+
// Backfill for PHP native trait.
|
250 |
+
return;
|
251 |
+
}
|
252 |
+
|
253 |
+
$error_text = 'Traits declared';
|
254 |
+
$error_code = 'NonPrefixedTraitFound';
|
255 |
+
break;
|
256 |
+
|
257 |
+
default:
|
258 |
+
// Left empty on purpose.
|
259 |
+
break;
|
260 |
+
}
|
261 |
+
|
262 |
+
break;
|
263 |
+
|
264 |
+
case 'T_CONST':
|
265 |
+
// Constants in a class do not need to be prefixed.
|
266 |
+
if ( $this->phpcsFile->hasCondition( $stackPtr, array( T_CLASS, T_ANON_CLASS, T_INTERFACE, T_TRAIT ) ) === true ) {
|
267 |
+
return;
|
268 |
+
}
|
269 |
+
|
270 |
+
$constant_name_ptr = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
|
271 |
+
if ( false === $constant_name_ptr ) {
|
272 |
+
// Live coding.
|
273 |
+
return;
|
274 |
+
}
|
275 |
+
|
276 |
+
$item_name = $this->tokens[ $constant_name_ptr ]['content'];
|
277 |
+
if ( defined( $item_name ) ) {
|
278 |
+
// Backfill for PHP native constant.
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
|
282 |
+
$error_text = 'Global constants defined';
|
283 |
+
$error_code = 'NonPrefixedConstantFound';
|
284 |
+
break;
|
285 |
+
|
286 |
+
default:
|
287 |
+
// Left empty on purpose.
|
288 |
+
break;
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
if ( empty( $item_name ) || $this->is_prefixed( $item_name ) === true ) {
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
$this->phpcsFile->addError(
|
297 |
+
self::ERROR_MSG,
|
298 |
+
$stackPtr,
|
299 |
+
$error_code,
|
300 |
+
array(
|
301 |
+
$error_text,
|
302 |
+
$item_name,
|
303 |
+
)
|
304 |
+
);
|
305 |
+
}
|
306 |
+
|
307 |
+
} // End process_token().
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Handle variable variable defined in the global namespace.
|
311 |
+
*
|
312 |
+
* @since 0.12.0
|
313 |
+
*
|
314 |
+
* @param int $stackPtr The position of the current token in the stack.
|
315 |
+
*
|
316 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
317 |
+
* normal file processing.
|
318 |
+
*/
|
319 |
+
protected function process_variable_variable( $stackPtr ) {
|
320 |
+
static $indicators = array(
|
321 |
+
T_OPEN_CURLY_BRACKET => true,
|
322 |
+
T_VARIABLE => true,
|
323 |
+
);
|
324 |
+
|
325 |
+
// Is this a variable variable ?
|
326 |
+
// Not concerned with nested ones as those will be recognized on their own token.
|
327 |
+
$next_non_empty = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
|
328 |
+
if ( false === $next_non_empty || ! isset( $indicators[ $this->tokens[ $next_non_empty ]['code'] ] ) ) {
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
|
332 |
+
if ( T_OPEN_CURLY_BRACKET === $this->tokens[ $next_non_empty ]['code']
|
333 |
+
&& isset( $this->tokens[ $next_non_empty ]['bracket_closer'] )
|
334 |
+
) {
|
335 |
+
// Skip over the variable part.
|
336 |
+
$next_non_empty = $this->tokens[ $next_non_empty ]['bracket_closer'];
|
337 |
+
}
|
338 |
+
|
339 |
+
$maybe_assignment = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $next_non_empty + 1 ), null, true, null, true );
|
340 |
+
|
341 |
+
while ( false !== $maybe_assignment
|
342 |
+
&& T_OPEN_SQUARE_BRACKET === $this->tokens[ $maybe_assignment ]['code']
|
343 |
+
&& isset( $this->tokens[ $maybe_assignment ]['bracket_closer'] )
|
344 |
+
) {
|
345 |
+
$maybe_assignment = $this->phpcsFile->findNext(
|
346 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
347 |
+
( $this->tokens[ $maybe_assignment ]['bracket_closer'] + 1 ),
|
348 |
+
null,
|
349 |
+
true,
|
350 |
+
null,
|
351 |
+
true
|
352 |
+
);
|
353 |
+
}
|
354 |
+
|
355 |
+
if ( false === $maybe_assignment ) {
|
356 |
+
return;
|
357 |
+
}
|
358 |
+
|
359 |
+
if ( ! isset( PHP_CodeSniffer_Tokens::$assignmentTokens[ $this->tokens[ $maybe_assignment ]['code'] ] ) ) {
|
360 |
+
// Not an assignment.
|
361 |
+
return;
|
362 |
+
}
|
363 |
+
|
364 |
+
$error = self::ERROR_MSG;
|
365 |
+
|
366 |
+
/*
|
367 |
+
* Local variable variables in a function do not need to be prefixed.
|
368 |
+
* But a variable variable could evaluate to the name of an imported global
|
369 |
+
* variable.
|
370 |
+
* Not concerned with imported variable variables (global.. ) as that has been
|
371 |
+
* forbidden since PHP 7.0. Presuming cross-version code and if not, that
|
372 |
+
* is for the PHPCompatibility standard to detect.
|
373 |
+
*/
|
374 |
+
if ( $this->phpcsFile->hasCondition( $stackPtr, array( T_FUNCTION, T_CLOSURE ) ) === true ) {
|
375 |
+
$condition = $this->phpcsFile->getCondition( $stackPtr, T_FUNCTION );
|
376 |
+
if ( false === $condition ) {
|
377 |
+
$condition = $this->phpcsFile->getCondition( $stackPtr, T_CLOSURE );
|
378 |
+
}
|
379 |
+
|
380 |
+
$has_global = $this->phpcsFile->findPrevious( T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $condition ]['scope_opener'] );
|
381 |
+
if ( false === $has_global ) {
|
382 |
+
// No variable import happening.
|
383 |
+
return;
|
384 |
+
}
|
385 |
+
|
386 |
+
$error = 'Variable variable which could potentially override an imported global variable detected. ' . $error;
|
387 |
+
}
|
388 |
+
|
389 |
+
$variable_name = $this->phpcsFile->getTokensAsString( $stackPtr, ( ( $next_non_empty - $stackPtr ) + 1 ) );
|
390 |
+
|
391 |
+
// Still here ? In that case, the variable name should be prefixed.
|
392 |
+
$this->phpcsFile->addWarning(
|
393 |
+
$error,
|
394 |
+
$stackPtr,
|
395 |
+
'NonPrefixedVariableFound',
|
396 |
+
array(
|
397 |
+
'Variables defined',
|
398 |
+
$variable_name,
|
399 |
+
)
|
400 |
+
);
|
401 |
+
|
402 |
+
// Skip over the variable part of the variable.
|
403 |
+
return ( $next_non_empty + 1 );
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Check that defined global variables are prefixed.
|
408 |
+
*
|
409 |
+
* @since 0.12.0
|
410 |
+
*
|
411 |
+
* @param int $stackPtr The position of the current token in the stack.
|
412 |
+
*
|
413 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
414 |
+
* normal file processing.
|
415 |
+
*/
|
416 |
+
protected function process_variable_assignment( $stackPtr ) {
|
417 |
+
|
418 |
+
// We're only concerned with variables which are being defined.
|
419 |
+
// `is_assigment()` will not recognize property assignments, which is good in this case.
|
420 |
+
if ( false === $this->is_assignment( $stackPtr ) ) {
|
421 |
+
return;
|
422 |
+
}
|
423 |
+
|
424 |
+
$is_error = true;
|
425 |
+
$variable_name = substr( $this->tokens[ $stackPtr ]['content'], 1 ); // Strip the dollar sign.
|
426 |
+
|
427 |
+
// Bow out early if we know for certain no prefix is needed.
|
428 |
+
if ( $this->variable_prefixed_or_whitelisted( $variable_name ) === true ) {
|
429 |
+
return;
|
430 |
+
}
|
431 |
+
|
432 |
+
if ( 'GLOBALS' === $variable_name ) {
|
433 |
+
$array_open = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
|
434 |
+
if ( false === $array_open || T_OPEN_SQUARE_BRACKET !== $this->tokens[ $array_open ]['code'] ) {
|
435 |
+
// Live coding or something very silly.
|
436 |
+
return;
|
437 |
+
}
|
438 |
+
|
439 |
+
$array_key = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $array_open + 1 ), null, true, null, true );
|
440 |
+
if ( false === $array_key ) {
|
441 |
+
// No key found, nothing to do.
|
442 |
+
return;
|
443 |
+
}
|
444 |
+
|
445 |
+
$stackPtr = $array_key;
|
446 |
+
$variable_name = $this->strip_quotes( $this->tokens[ $array_key ]['content'] );
|
447 |
+
|
448 |
+
// Check whether a prefix is needed.
|
449 |
+
if ( isset( PHP_CodeSniffer_Tokens::$stringTokens[ $this->tokens[ $array_key ]['code'] ] )
|
450 |
+
&& $this->variable_prefixed_or_whitelisted( $variable_name ) === true
|
451 |
+
) {
|
452 |
+
return;
|
453 |
+
}
|
454 |
+
|
455 |
+
if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $array_key ]['code'] ) {
|
456 |
+
// If the array key is a double quoted string, try again with only
|
457 |
+
// the part before the first variable (if any).
|
458 |
+
$exploded = explode( '$', $variable_name );
|
459 |
+
$first = rtrim( $exploded[0], '{' );
|
460 |
+
if ( '' !== $first ) {
|
461 |
+
if ( $this->variable_prefixed_or_whitelisted( $first ) === true ) {
|
462 |
+
return;
|
463 |
+
}
|
464 |
+
} else {
|
465 |
+
// If the first part was dynamic, throw a warning.
|
466 |
+
$is_error = false;
|
467 |
+
}
|
468 |
+
} elseif ( ! isset( PHP_CodeSniffer_Tokens::$stringTokens[ $this->tokens[ $array_key ]['code'] ] ) ) {
|
469 |
+
// Dynamic array key, throw a warning.
|
470 |
+
$is_error = false;
|
471 |
+
}
|
472 |
+
} else {
|
473 |
+
// Function parameters do not need to be prefixed.
|
474 |
+
if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
|
475 |
+
foreach ( $this->tokens[ $stackPtr ]['nested_parenthesis'] as $opener => $closer ) {
|
476 |
+
if ( isset( $this->tokens[ $opener ]['parenthesis_owner'] ) && T_FUNCTION === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code'] ) {
|
477 |
+
return;
|
478 |
+
}
|
479 |
+
}
|
480 |
+
unset( $opener, $closer );
|
481 |
+
}
|
482 |
+
|
483 |
+
// Properties in a class do not need to be prefixed.
|
484 |
+
$conditions = array_keys( $this->tokens[ $stackPtr ]['conditions'] );
|
485 |
+
$ptr = array_pop( $conditions );
|
486 |
+
if ( isset( $this->tokens[ $ptr ] )
|
487 |
+
&& in_array( $this->tokens[ $ptr ]['code'], array( T_CLASS, T_ANON_CLASS, T_TRAIT ), true )
|
488 |
+
) {
|
489 |
+
return;
|
490 |
+
}
|
491 |
+
|
492 |
+
// Local variables in a function do not need to be prefixed unless they are being imported.
|
493 |
+
if ( $this->phpcsFile->hasCondition( $stackPtr, array( T_FUNCTION, T_CLOSURE ) ) === true ) {
|
494 |
+
$condition = $this->phpcsFile->getCondition( $stackPtr, T_FUNCTION );
|
495 |
+
if ( false === $condition ) {
|
496 |
+
$condition = $this->phpcsFile->getCondition( $stackPtr, T_CLOSURE );
|
497 |
+
}
|
498 |
+
|
499 |
+
$has_global = $this->phpcsFile->findPrevious( T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $condition ]['scope_opener'] );
|
500 |
+
if ( false === $has_global ) {
|
501 |
+
// No variable import happening.
|
502 |
+
return;
|
503 |
+
}
|
504 |
+
|
505 |
+
// Ok, this may be an imported global variable.
|
506 |
+
$end_of_statement = $this->phpcsFile->findNext( T_SEMICOLON, ( $has_global + 1 ) );
|
507 |
+
if ( false === $end_of_statement ) {
|
508 |
+
// No semi-colon - live coding.
|
509 |
+
return;
|
510 |
+
}
|
511 |
+
|
512 |
+
for ( $ptr = ( $has_global + 1 ); $ptr <= $end_of_statement; $ptr++ ) {
|
513 |
+
// Move the stack pointer to the next variable.
|
514 |
+
$ptr = $this->phpcsFile->findNext( T_VARIABLE, $ptr, $end_of_statement, false, null, true );
|
515 |
+
|
516 |
+
if ( false === $ptr ) {
|
517 |
+
// Reached the end of the global statement without finding the variable,
|
518 |
+
// so this must be a local variable.
|
519 |
+
return;
|
520 |
+
}
|
521 |
+
|
522 |
+
if ( substr( $this->tokens[ $ptr ]['content'], 1 ) === $variable_name ) {
|
523 |
+
break;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
unset( $condition, $has_global, $end_of_statement, $ptr, $imported );
|
528 |
+
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
// Still here ? In that case, the variable name should be prefixed.
|
533 |
+
$this->addMessage(
|
534 |
+
self::ERROR_MSG,
|
535 |
+
$stackPtr,
|
536 |
+
$is_error,
|
537 |
+
'NonPrefixedVariableFound',
|
538 |
+
array(
|
539 |
+
'Variables defined',
|
540 |
+
'$' . $variable_name,
|
541 |
+
)
|
542 |
+
);
|
543 |
+
|
544 |
+
} // End process_variable_assignment().
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Process the parameters of a matched function.
|
548 |
+
*
|
549 |
+
* @since 0.12.0
|
550 |
+
*
|
551 |
+
* @param int $stackPtr The position of the current token in the stack.
|
552 |
+
* @param array $group_name The name of the group which was matched.
|
553 |
+
* @param string $matched_content The token content (function name) which was matched.
|
554 |
+
* @param array $parameters Array with information about the parameters.
|
555 |
+
*
|
556 |
+
* @return void
|
557 |
+
*/
|
558 |
+
public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
|
559 |
+
|
560 |
+
// Ignore deprecated hook names.
|
561 |
+
if ( strpos( $matched_content, '_deprecated' ) > 0 ) {
|
562 |
+
return;
|
563 |
+
}
|
564 |
+
|
565 |
+
// No matter whether it is a constant definition or a hook call, both use the first parameter.
|
566 |
+
if ( ! isset( $parameters[1] ) ) {
|
567 |
+
return;
|
568 |
+
}
|
569 |
+
|
570 |
+
$is_error = true;
|
571 |
+
$raw_content = $this->strip_quotes( $parameters[1]['raw'] );
|
572 |
+
|
573 |
+
if ( $this->is_prefixed( $raw_content ) === true ) {
|
574 |
+
return;
|
575 |
+
} else {
|
576 |
+
// This may be a dynamic hook/constant name.
|
577 |
+
$first_non_empty = $this->phpcsFile->findNext(
|
578 |
+
PHP_CodeSniffer_Tokens::$emptyTokens,
|
579 |
+
$parameters[1]['start'],
|
580 |
+
( $parameters[1]['end'] + 1 ),
|
581 |
+
true
|
582 |
+
);
|
583 |
+
|
584 |
+
if ( false === $first_non_empty ) {
|
585 |
+
return;
|
586 |
+
}
|
587 |
+
|
588 |
+
$first_non_empty_content = $this->strip_quotes( $this->tokens[ $first_non_empty ]['content'] );
|
589 |
+
|
590 |
+
// Try again with just the first token if it's a text string.
|
591 |
+
if ( isset( PHP_CodeSniffer_Tokens::$stringTokens[ $this->tokens[ $first_non_empty ]['code'] ] )
|
592 |
+
&& $this->is_prefixed( $first_non_empty_content ) === true
|
593 |
+
) {
|
594 |
+
return;
|
595 |
+
}
|
596 |
+
|
597 |
+
if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
|
598 |
+
// If the first part of the parameter is a double quoted string, try again with only
|
599 |
+
// the part before the first variable (if any).
|
600 |
+
$exploded = explode( '$', $first_non_empty_content );
|
601 |
+
$first = rtrim( $exploded[0], '{' );
|
602 |
+
if ( '' !== $first ) {
|
603 |
+
if ( $this->is_prefixed( $first ) === true ) {
|
604 |
+
return;
|
605 |
+
}
|
606 |
+
} else {
|
607 |
+
// Start of hook/constant name is dynamic, throw a warning.
|
608 |
+
$is_error = false;
|
609 |
+
}
|
610 |
+
} elseif ( ! isset( PHP_CodeSniffer_Tokens::$stringTokens[ $this->tokens[ $first_non_empty ]['code'] ] ) ) {
|
611 |
+
// Dynamic hook/constant name, throw a warning.
|
612 |
+
$is_error = false;
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
if ( 'define' === $matched_content ) {
|
617 |
+
if ( defined( $raw_content ) ) {
|
618 |
+
// Backfill for PHP native constant.
|
619 |
+
return;
|
620 |
+
}
|
621 |
+
|
622 |
+
$data = array( 'Global constants defined' );
|
623 |
+
$error_code = 'NonPrefixedConstantFound';
|
624 |
+
} else {
|
625 |
+
$data = array( 'Hook names invoked' );
|
626 |
+
$error_code = 'NonPrefixedHooknameFound';
|
627 |
+
}
|
628 |
+
|
629 |
+
$data[] = $raw_content;
|
630 |
+
|
631 |
+
$this->addMessage( self::ERROR_MSG, $parameters[1]['start'], $is_error, $error_code, $data );
|
632 |
+
|
633 |
+
} // End process_parameters().
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Check if a function/class/constant/variable name is prefixed with one of the expected prefixes.
|
637 |
+
*
|
638 |
+
* @since 0.12.0
|
639 |
+
*
|
640 |
+
* @param string $name Name to check for a prefix.
|
641 |
+
*
|
642 |
+
* @return bool True when the name is the prefix or starts with the prefix + an underscore.
|
643 |
+
* False otherwise.
|
644 |
+
*/
|
645 |
+
private function is_prefixed( $name ) {
|
646 |
+
|
647 |
+
foreach ( $this->validated_prefixes as $prefix ) {
|
648 |
+
if ( strtolower( $name ) === $prefix ) {
|
649 |
+
// Ok, prefix *is* the hook/constant name.
|
650 |
+
return true;
|
651 |
+
|
652 |
+
} else {
|
653 |
+
$prefix_found = stripos( $name, $prefix . '_' );
|
654 |
+
|
655 |
+
if ( 0 === $prefix_found ) {
|
656 |
+
// Ok, prefix found as start of hook/constant name.
|
657 |
+
return true;
|
658 |
+
}
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
return false;
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Check if a variable name might need a prefix.
|
667 |
+
*
|
668 |
+
* Prefix is not needed for:
|
669 |
+
* - superglobals,
|
670 |
+
* - WP native globals,
|
671 |
+
* - variables which are already prefixed.
|
672 |
+
*
|
673 |
+
* @param string $name Variable name without the dollar sign.
|
674 |
+
* @return bool True if the variable name is whitelisted or already prefixed.
|
675 |
+
* False otherwise.
|
676 |
+
*/
|
677 |
+
private function variable_prefixed_or_whitelisted( $name ) {
|
678 |
+
// Ignore superglobals and WP global variables.
|
679 |
+
if ( isset( $this->superglobals[ $name ] ) || isset( $this->wp_globals[ $name ] ) ) {
|
680 |
+
return true;
|
681 |
+
}
|
682 |
+
|
683 |
+
return $this->is_prefixed( $name );
|
684 |
+
}
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Validate an array of prefixes as passed through a custom property or via the command line.
|
688 |
+
*
|
689 |
+
* Checks that the prefix:
|
690 |
+
* - is not one of the blacklisted ones.
|
691 |
+
* - complies with the PHP rules for valid function, class, variable, constant names.
|
692 |
+
*
|
693 |
+
* @since 0.12.0
|
694 |
+
*/
|
695 |
+
private function validate_prefixes() {
|
696 |
+
if ( $this->previous_prefixes === $this->prefixes ) {
|
697 |
+
return;
|
698 |
+
}
|
699 |
+
|
700 |
+
// Set the cache *before* validation so as to not break the above compare.
|
701 |
+
$this->previous_prefixes = $this->prefixes;
|
702 |
+
|
703 |
+
// Validate the passed prefix(es).
|
704 |
+
foreach ( $this->prefixes as $key => $prefix ) {
|
705 |
+
$prefixLC = strtolower( $prefix );
|
706 |
+
|
707 |
+
if ( isset( $this->prefix_blacklist[ $prefixLC ] ) ) {
|
708 |
+
$this->phpcsFile->addError(
|
709 |
+
'The "%s" prefix is not allowed.',
|
710 |
+
0,
|
711 |
+
'ForbiddenPrefixPassed',
|
712 |
+
array( $prefix )
|
713 |
+
);
|
714 |
+
unset( $this->prefixes[ $key ] );
|
715 |
+
continue;
|
716 |
+
}
|
717 |
+
|
718 |
+
// Validate the prefix against characters allowed for function, class, constant names etc.
|
719 |
+
if ( preg_match( '`^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$`', $prefix ) !== 1 ) {
|
720 |
+
$this->phpcsFile->addError(
|
721 |
+
'The "%s" prefix is not a valid function/class/variable/constant prefix in PHP.',
|
722 |
+
0,
|
723 |
+
'InvalidPrefixPassed',
|
724 |
+
array( $prefix )
|
725 |
+
);
|
726 |
+
unset( $this->prefixes[ $key ] );
|
727 |
+
}
|
728 |
+
|
729 |
+
// Lowercase the prefix to allow for direct compare.
|
730 |
+
$this->prefixes[ $key ] = $prefixLC;
|
731 |
+
}
|
732 |
+
|
733 |
+
// Set the validated prefixes cache.
|
734 |
+
$this->validated_prefixes = $this->prefixes;
|
735 |
+
|
736 |
+
} // End validate_prefixes().
|
737 |
+
|
738 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php
CHANGED
@@ -87,15 +87,10 @@ class WordPress_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sni
|
|
87 |
}
|
88 |
|
89 |
if ( strtolower( $functionName ) !== $functionName ) {
|
90 |
-
$suggested = preg_replace( '/([A-Z])/', '_$1', $functionName );
|
91 |
-
$suggested = strtolower( $suggested );
|
92 |
-
$suggested = str_replace( '__', '_', $suggested );
|
93 |
-
$suggested = trim( $suggested, '_' );
|
94 |
-
|
95 |
$error = 'Function name "%s" is not in snake case format, try "%s"';
|
96 |
$errorData = array(
|
97 |
$functionName,
|
98 |
-
$
|
99 |
);
|
100 |
$phpcsFile->addError( $error, $stackPtr, 'FunctionNameInvalid', $errorData );
|
101 |
}
|
@@ -120,7 +115,7 @@ class WordPress_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sni
|
|
120 |
return;
|
121 |
}
|
122 |
|
123 |
-
$className
|
124 |
|
125 |
// Ignore special functions.
|
126 |
if ( '' === ltrim( $methodName, '_' ) ) {
|
@@ -159,20 +154,29 @@ class WordPress_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sni
|
|
159 |
|
160 |
// Check for all lowercase.
|
161 |
if ( strtolower( $methodName ) !== $methodName ) {
|
162 |
-
$suggested = preg_replace( '/([A-Z])/', '_$1', $methodName );
|
163 |
-
$suggested = strtolower( $suggested );
|
164 |
-
$suggested = str_replace( '__', '_', $suggested );
|
165 |
-
$suggested = trim( $suggested, '_' );
|
166 |
-
|
167 |
$error = 'Method name "%s" in class %s is not in snake case format, try "%s"';
|
168 |
$errorData = array(
|
169 |
$methodName,
|
170 |
$className,
|
171 |
-
$
|
172 |
);
|
173 |
$phpcsFile->addError( $error, $stackPtr, 'MethodNameInvalid', $errorData );
|
174 |
}
|
175 |
|
176 |
} // End processTokenWithinScope().
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
} // End class.
|
87 |
}
|
88 |
|
89 |
if ( strtolower( $functionName ) !== $functionName ) {
|
|
|
|
|
|
|
|
|
|
|
90 |
$error = 'Function name "%s" is not in snake case format, try "%s"';
|
91 |
$errorData = array(
|
92 |
$functionName,
|
93 |
+
$this->get_name_suggestion( $functionName ),
|
94 |
);
|
95 |
$phpcsFile->addError( $error, $stackPtr, 'FunctionNameInvalid', $errorData );
|
96 |
}
|
115 |
return;
|
116 |
}
|
117 |
|
118 |
+
$className = $phpcsFile->getDeclarationName( $currScope );
|
119 |
|
120 |
// Ignore special functions.
|
121 |
if ( '' === ltrim( $methodName, '_' ) ) {
|
154 |
|
155 |
// Check for all lowercase.
|
156 |
if ( strtolower( $methodName ) !== $methodName ) {
|
|
|
|
|
|
|
|
|
|
|
157 |
$error = 'Method name "%s" in class %s is not in snake case format, try "%s"';
|
158 |
$errorData = array(
|
159 |
$methodName,
|
160 |
$className,
|
161 |
+
$this->get_name_suggestion( $methodName ),
|
162 |
);
|
163 |
$phpcsFile->addError( $error, $stackPtr, 'MethodNameInvalid', $errorData );
|
164 |
}
|
165 |
|
166 |
} // End processTokenWithinScope().
|
167 |
|
168 |
+
/**
|
169 |
+
* Transform the existing function/method name to one which complies with the naming conventions.
|
170 |
+
*
|
171 |
+
* @param string $name The function/method name.
|
172 |
+
* @return string
|
173 |
+
*/
|
174 |
+
protected function get_name_suggestion( $name ) {
|
175 |
+
$suggested = preg_replace( '/([A-Z])/', '_$1', $name );
|
176 |
+
$suggested = strtolower( $suggested );
|
177 |
+
$suggested = str_replace( '__', '_', $suggested );
|
178 |
+
$suggested = trim( $suggested, '_' );
|
179 |
+
return $suggested;
|
180 |
+
}
|
181 |
+
|
182 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php
CHANGED
@@ -137,7 +137,7 @@ class WordPress_Sniffs_NamingConventions_ValidHookNameSniff extends WordPress_Ab
|
|
137 |
$underscores++;
|
138 |
}
|
139 |
}
|
140 |
-
}
|
141 |
|
142 |
$data = array(
|
143 |
implode( '', $expected ),
|
@@ -153,7 +153,7 @@ class WordPress_Sniffs_NamingConventions_ValidHookNameSniff extends WordPress_Ab
|
|
153 |
$this->phpcsFile->addWarning( $error, $stackPtr, 'UseUnderscores', $data );
|
154 |
}
|
155 |
|
156 |
-
} // End
|
157 |
|
158 |
/**
|
159 |
* Prepare the punctuation regular expression.
|
137 |
$underscores++;
|
138 |
}
|
139 |
}
|
140 |
+
}
|
141 |
|
142 |
$data = array(
|
143 |
implode( '', $expected ),
|
153 |
$this->phpcsFile->addWarning( $error, $stackPtr, 'UseUnderscores', $data );
|
154 |
}
|
155 |
|
156 |
+
} // End process_parameters().
|
157 |
|
158 |
/**
|
159 |
* Prepare the punctuation regular expression.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php
CHANGED
@@ -166,9 +166,9 @@ class WordPress_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_Code
|
|
166 |
$data = array( $original_var_name );
|
167 |
$phpcs_file->addError( $error, $var, 'NotSnakeCaseMemberVar', $data );
|
168 |
}
|
169 |
-
}
|
170 |
-
}
|
171 |
-
}
|
172 |
|
173 |
$in_class = false;
|
174 |
$obj_operator = $phpcs_file->findPrevious( array( T_WHITESPACE ), ( $stack_ptr - 1 ), null, true );
|
166 |
$data = array( $original_var_name );
|
167 |
$phpcs_file->addError( $error, $var, 'NotSnakeCaseMemberVar', $data );
|
168 |
}
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
|
173 |
$in_class = false;
|
174 |
$obj_operator = $phpcs_file->findPrevious( array( T_WHITESPACE ), ( $stack_ptr - 1 ), null, true );
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php
CHANGED
@@ -20,11 +20,11 @@ class WordPress_Sniffs_PHP_DevelopmentFunctionsSniff extends WordPress_AbstractF
|
|
20 |
* Groups of functions to restrict.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
20 |
* Groups of functions to restrict.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
+
* 'lambda' => array(
|
24 |
+
* 'type' => 'error' | 'warning',
|
25 |
+
* 'message' => 'Use anonymous functions instead please!',
|
26 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
27 |
+
* )
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php
CHANGED
@@ -20,11 +20,11 @@ class WordPress_Sniffs_PHP_DiscouragedPHPFunctionsSniff extends WordPress_Abstra
|
|
20 |
* Groups of functions to discourage.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
20 |
* Groups of functions to discourage.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
+
* 'lambda' => array(
|
24 |
+
* 'type' => 'error' | 'warning',
|
25 |
+
* 'message' => 'Use anonymous functions instead please!',
|
26 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
27 |
+
* )
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php
CHANGED
@@ -25,11 +25,11 @@ class WordPress_Sniffs_PHP_POSIXFunctionsSniff extends WordPress_AbstractFunctio
|
|
25 |
* Groups of functions to restrict.
|
26 |
*
|
27 |
* Example: groups => array(
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
* )
|
34 |
*
|
35 |
* @return array
|
25 |
* Groups of functions to restrict.
|
26 |
*
|
27 |
* Example: groups => array(
|
28 |
+
* 'lambda' => array(
|
29 |
+
* 'type' => 'error' | 'warning',
|
30 |
+
* 'message' => 'Use anonymous functions instead please!',
|
31 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
32 |
+
* )
|
33 |
* )
|
34 |
*
|
35 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/YodaConditionsSniff.php
CHANGED
@@ -15,8 +15,18 @@
|
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
|
|
18 |
*/
|
19 |
-
class WordPress_Sniffs_PHP_YodaConditionsSniff
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
* Returns an array of tokens this test wants to listen for.
|
@@ -24,6 +34,16 @@ class WordPress_Sniffs_PHP_YodaConditionsSniff implements PHP_CodeSniffer_Sniff
|
|
24 |
* @return array
|
25 |
*/
|
26 |
public function register() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
return array(
|
28 |
T_IS_EQUAL,
|
29 |
T_IS_NOT_EQUAL,
|
@@ -36,40 +56,34 @@ class WordPress_Sniffs_PHP_YodaConditionsSniff implements PHP_CodeSniffer_Sniff
|
|
36 |
/**
|
37 |
* Processes this test, when one of its tokens is encountered.
|
38 |
*
|
39 |
-
* @param
|
40 |
-
* @param int $stackPtr The position of the current token in the
|
41 |
-
* stack passed in $tokens.
|
42 |
*
|
43 |
* @return void
|
44 |
*/
|
45 |
-
public function
|
46 |
-
$tokens = $phpcsFile->getTokens();
|
47 |
-
|
48 |
-
$beginners = array_merge(
|
49 |
-
PHP_CodeSniffer_Tokens::$booleanOperators
|
50 |
-
, array( T_IF, T_ELSEIF )
|
51 |
-
);
|
52 |
|
53 |
-
$
|
54 |
|
55 |
$needs_yoda = false;
|
56 |
|
57 |
// Note: going backwards!
|
58 |
-
for ( $i = $stackPtr; $i > $
|
59 |
|
60 |
// Ignore whitespace.
|
61 |
-
if (
|
62 |
continue;
|
63 |
}
|
64 |
|
65 |
// If this is a variable or array, we've seen all we need to see.
|
66 |
-
if ( T_VARIABLE === $tokens[ $i ]['code']
|
|
|
|
|
67 |
$needs_yoda = true;
|
68 |
break;
|
69 |
}
|
70 |
|
71 |
// If this is a function call or something, we are OK.
|
72 |
-
if (
|
73 |
return;
|
74 |
}
|
75 |
}
|
@@ -79,14 +93,14 @@ class WordPress_Sniffs_PHP_YodaConditionsSniff implements PHP_CodeSniffer_Sniff
|
|
79 |
}
|
80 |
|
81 |
// Check if this is a var to var comparison, e.g.: if ( $var1 == $var2 ).
|
82 |
-
$next_non_empty = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
83 |
|
84 |
-
if (
|
85 |
-
$next_non_empty = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $next_non_empty + 1 ), null, true );
|
86 |
}
|
87 |
|
88 |
-
if ( in_array( $tokens[ $next_non_empty ]['code'], array( T_SELF, T_PARENT, T_STATIC ), true ) ) {
|
89 |
-
$next_non_empty = $phpcsFile->findNext(
|
90 |
array_merge( PHP_CodeSniffer_Tokens::$emptyTokens, array( T_DOUBLE_COLON ) )
|
91 |
, ( $next_non_empty + 1 )
|
92 |
, null
|
@@ -94,11 +108,11 @@ class WordPress_Sniffs_PHP_YodaConditionsSniff implements PHP_CodeSniffer_Sniff
|
|
94 |
);
|
95 |
}
|
96 |
|
97 |
-
if ( T_VARIABLE === $tokens[ $next_non_empty ]['code'] ) {
|
98 |
return;
|
99 |
}
|
100 |
|
101 |
-
$phpcsFile->addError( 'Use Yoda Condition checks, you must.', $stackPtr, 'NotYoda' );
|
102 |
|
103 |
} // End process().
|
104 |
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
+
* @since 0.12.0 This class now extends WordPress_Sniff.
|
19 |
*/
|
20 |
+
class WordPress_Sniffs_PHP_YodaConditionsSniff extends WordPress_Sniff {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* The tokens that indicate the start of a condition.
|
24 |
+
*
|
25 |
+
* @since 0.12.0
|
26 |
+
*
|
27 |
+
* @var array
|
28 |
+
*/
|
29 |
+
protected $condition_start_tokens;
|
30 |
|
31 |
/**
|
32 |
* Returns an array of tokens this test wants to listen for.
|
34 |
* @return array
|
35 |
*/
|
36 |
public function register() {
|
37 |
+
|
38 |
+
$starters = PHP_CodeSniffer_Tokens::$booleanOperators;
|
39 |
+
$starters += PHP_CodeSniffer_Tokens::$assignmentTokens;
|
40 |
+
$starters[ T_CASE ] = T_CASE;
|
41 |
+
$starters[ T_RETURN ] = T_RETURN;
|
42 |
+
$starters[ T_SEMICOLON ] = T_SEMICOLON;
|
43 |
+
$starters[ T_OPEN_PARENTHESIS ] = T_OPEN_PARENTHESIS;
|
44 |
+
|
45 |
+
$this->condition_start_tokens = $starters;
|
46 |
+
|
47 |
return array(
|
48 |
T_IS_EQUAL,
|
49 |
T_IS_NOT_EQUAL,
|
56 |
/**
|
57 |
* Processes this test, when one of its tokens is encountered.
|
58 |
*
|
59 |
+
* @param int $stackPtr The position of the current token in the stack.
|
|
|
|
|
60 |
*
|
61 |
* @return void
|
62 |
*/
|
63 |
+
public function process_token( $stackPtr ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
+
$start = $this->phpcsFile->findPrevious( $this->condition_start_tokens, $stackPtr, null, false, null, true );
|
66 |
|
67 |
$needs_yoda = false;
|
68 |
|
69 |
// Note: going backwards!
|
70 |
+
for ( $i = $stackPtr; $i > $start; $i-- ) {
|
71 |
|
72 |
// Ignore whitespace.
|
73 |
+
if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
74 |
continue;
|
75 |
}
|
76 |
|
77 |
// If this is a variable or array, we've seen all we need to see.
|
78 |
+
if ( T_VARIABLE === $this->tokens[ $i ]['code']
|
79 |
+
|| T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ]['code']
|
80 |
+
) {
|
81 |
$needs_yoda = true;
|
82 |
break;
|
83 |
}
|
84 |
|
85 |
// If this is a function call or something, we are OK.
|
86 |
+
if ( T_CLOSE_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
|
87 |
return;
|
88 |
}
|
89 |
}
|
93 |
}
|
94 |
|
95 |
// Check if this is a var to var comparison, e.g.: if ( $var1 == $var2 ).
|
96 |
+
$next_non_empty = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
97 |
|
98 |
+
if ( isset( PHP_CodeSniffer_Tokens::$castTokens[ $this->tokens[ $next_non_empty ]['code'] ] ) ) {
|
99 |
+
$next_non_empty = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $next_non_empty + 1 ), null, true );
|
100 |
}
|
101 |
|
102 |
+
if ( in_array( $this->tokens[ $next_non_empty ]['code'], array( T_SELF, T_PARENT, T_STATIC ), true ) ) {
|
103 |
+
$next_non_empty = $this->phpcsFile->findNext(
|
104 |
array_merge( PHP_CodeSniffer_Tokens::$emptyTokens, array( T_DOUBLE_COLON ) )
|
105 |
, ( $next_non_empty + 1 )
|
106 |
, null
|
108 |
);
|
109 |
}
|
110 |
|
111 |
+
if ( T_VARIABLE === $this->tokens[ $next_non_empty ]['code'] ) {
|
112 |
return;
|
113 |
}
|
114 |
|
115 |
+
$this->phpcsFile->addError( 'Use Yoda Condition checks, you must.', $stackPtr, 'NotYoda' );
|
116 |
|
117 |
} // End process().
|
118 |
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php
CHANGED
@@ -135,12 +135,9 @@ class WordPress_Sniffs_VIP_AdminBarRemovalSniff extends WordPress_AbstractFuncti
|
|
135 |
*/
|
136 |
public function register() {
|
137 |
// Set up all string targets.
|
138 |
-
$
|
139 |
-
$targets[ T_INLINE_HTML ] = T_INLINE_HTML;
|
140 |
-
$targets[ T_HEREDOC ] = T_HEREDOC;
|
141 |
-
$targets[ T_NOWDOC ] = T_NOWDOC;
|
142 |
|
143 |
-
$
|
144 |
|
145 |
// Add CSS style target.
|
146 |
$targets[] = T_STYLE;
|
@@ -193,7 +190,7 @@ class WordPress_Sniffs_VIP_AdminBarRemovalSniff extends WordPress_AbstractFuncti
|
|
193 |
return parent::process_token( $stackPtr );
|
194 |
}
|
195 |
|
196 |
-
} // End
|
197 |
|
198 |
/**
|
199 |
* Process the parameters of a matched function.
|
135 |
*/
|
136 |
public function register() {
|
137 |
// Set up all string targets.
|
138 |
+
$this->string_tokens = PHP_CodeSniffer_Tokens::$textStringTokens;
|
|
|
|
|
|
|
139 |
|
140 |
+
$targets = $this->string_tokens;
|
141 |
|
142 |
// Add CSS style target.
|
143 |
$targets[] = T_STYLE;
|
190 |
return parent::process_token( $stackPtr );
|
191 |
}
|
192 |
|
193 |
+
} // End process_token().
|
194 |
|
195 |
/**
|
196 |
* Process the parameters of a matched function.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/CronIntervalSniff.php
CHANGED
@@ -63,7 +63,7 @@ class WordPress_Sniffs_VIP_CronIntervalSniff extends WordPress_Sniff {
|
|
63 |
|
64 |
// If within add_filter.
|
65 |
$functionPtr = $this->phpcsFile->findPrevious( T_STRING, key( $token['nested_parenthesis'] ) );
|
66 |
-
if ( 'add_filter' !== $this->tokens[ $functionPtr ]['content'] ) {
|
67 |
return;
|
68 |
}
|
69 |
|
@@ -167,7 +167,7 @@ class WordPress_Sniffs_VIP_CronIntervalSniff extends WordPress_Sniff {
|
|
167 |
return;
|
168 |
}
|
169 |
|
170 |
-
} // End
|
171 |
|
172 |
/**
|
173 |
* Add warning about unclear cron schedule change.
|
63 |
|
64 |
// If within add_filter.
|
65 |
$functionPtr = $this->phpcsFile->findPrevious( T_STRING, key( $token['nested_parenthesis'] ) );
|
66 |
+
if ( false === $functionPtr || 'add_filter' !== $this->tokens[ $functionPtr ]['content'] ) {
|
67 |
return;
|
68 |
}
|
69 |
|
167 |
return;
|
168 |
}
|
169 |
|
170 |
+
} // End process_token().
|
171 |
|
172 |
/**
|
173 |
* Add warning about unclear cron schedule change.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php
CHANGED
@@ -113,7 +113,7 @@ class WordPress_Sniffs_VIP_DirectDatabaseQuerySniff extends WordPress_Sniff {
|
|
113 |
return;
|
114 |
}
|
115 |
|
116 |
-
$is_object_call = $this->phpcsFile->findNext(
|
117 |
if ( false === $is_object_call ) {
|
118 |
return; // This is not a call to the wpdb object.
|
119 |
}
|
@@ -127,7 +127,7 @@ class WordPress_Sniffs_VIP_DirectDatabaseQuerySniff extends WordPress_Sniff {
|
|
127 |
return;
|
128 |
}
|
129 |
|
130 |
-
$endOfStatement = $this->phpcsFile->findNext(
|
131 |
$endOfLineComment = '';
|
132 |
for ( $i = ( $endOfStatement + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
|
133 |
|
@@ -147,7 +147,7 @@ class WordPress_Sniffs_VIP_DirectDatabaseQuerySniff extends WordPress_Sniff {
|
|
147 |
|
148 |
// Check for Database Schema Changes.
|
149 |
$_pos = $stackPtr;
|
150 |
-
while ( $_pos = $this->phpcsFile->findNext(
|
151 |
if ( preg_match( '#\b(?:ALTER|CREATE|DROP)\b#i', $this->tokens[ $_pos ]['content'] ) > 0 ) {
|
152 |
$this->phpcsFile->addError( 'Attempting a database schema change is highly discouraged.', $_pos, 'SchemaChange' );
|
153 |
}
|
@@ -211,7 +211,7 @@ class WordPress_Sniffs_VIP_DirectDatabaseQuerySniff extends WordPress_Sniff {
|
|
211 |
|
212 |
return $endOfStatement;
|
213 |
|
214 |
-
} // End
|
215 |
|
216 |
/**
|
217 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
113 |
return;
|
114 |
}
|
115 |
|
116 |
+
$is_object_call = $this->phpcsFile->findNext( T_OBJECT_OPERATOR, ( $stackPtr + 1 ), null, false, null, true );
|
117 |
if ( false === $is_object_call ) {
|
118 |
return; // This is not a call to the wpdb object.
|
119 |
}
|
127 |
return;
|
128 |
}
|
129 |
|
130 |
+
$endOfStatement = $this->phpcsFile->findNext( T_SEMICOLON, ( $stackPtr + 1 ), null, false, null, true );
|
131 |
$endOfLineComment = '';
|
132 |
for ( $i = ( $endOfStatement + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
|
133 |
|
147 |
|
148 |
// Check for Database Schema Changes.
|
149 |
$_pos = $stackPtr;
|
150 |
+
while ( $_pos = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$textStringTokens, ( $_pos + 1 ), $endOfStatement, false, null, true ) ) {
|
151 |
if ( preg_match( '#\b(?:ALTER|CREATE|DROP)\b#i', $this->tokens[ $_pos ]['content'] ) > 0 ) {
|
152 |
$this->phpcsFile->addError( 'Attempting a database schema change is highly discouraged.', $_pos, 'SchemaChange' );
|
153 |
}
|
211 |
|
212 |
return $endOfStatement;
|
213 |
|
214 |
+
} // End process_token().
|
215 |
|
216 |
/**
|
217 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/FileSystemWritesDisallowSniff.php
CHANGED
@@ -31,11 +31,11 @@ class WordPress_Sniffs_VIP_FileSystemWritesDisallowSniff extends WordPress_Abstr
|
|
31 |
* Groups of functions to restrict.
|
32 |
*
|
33 |
* Example: groups => array(
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
* )
|
40 |
*
|
41 |
* @return array
|
31 |
* Groups of functions to restrict.
|
32 |
*
|
33 |
* Example: groups => array(
|
34 |
+
* 'lambda' => array(
|
35 |
+
* 'type' => 'error' | 'warning',
|
36 |
+
* 'message' => 'Use anonymous functions instead please!',
|
37 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
38 |
+
* )
|
39 |
* )
|
40 |
*
|
41 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/PostsPerPageSniff.php
CHANGED
@@ -20,17 +20,6 @@ class WordPress_Sniffs_VIP_PostsPerPageSniff extends WordPress_AbstractArrayAssi
|
|
20 |
|
21 |
/**
|
22 |
* Groups of variables to restrict.
|
23 |
-
* This should be overridden in extending classes.
|
24 |
-
*
|
25 |
-
* Example: groups => array(
|
26 |
-
* 'wpdb' => array(
|
27 |
-
* 'type' => 'error' | 'warning',
|
28 |
-
* 'message' => 'Dont use this one please!',
|
29 |
-
* 'variables' => array( '$val', '$var' ),
|
30 |
-
* 'object_vars' => array( '$foo->bar', .. ),
|
31 |
-
* 'array_members' => array( '$foo['bar']', .. ),
|
32 |
-
* )
|
33 |
-
* )
|
34 |
*
|
35 |
* @return array
|
36 |
*/
|
20 |
|
21 |
/**
|
22 |
* Groups of variables to restrict.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
*
|
24 |
* @return array
|
25 |
*/
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/RestrictedFunctionsSniff.php
CHANGED
@@ -31,11 +31,11 @@ class WordPress_Sniffs_VIP_RestrictedFunctionsSniff extends WordPress_AbstractFu
|
|
31 |
* Groups of functions to restrict.
|
32 |
*
|
33 |
* Example: groups => array(
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
* )
|
40 |
*
|
41 |
* @return array
|
@@ -168,17 +168,6 @@ class WordPress_Sniffs_VIP_RestrictedFunctionsSniff extends WordPress_AbstractFu
|
|
168 |
),
|
169 |
),
|
170 |
|
171 |
-
'wp_get_post_terms' => array(
|
172 |
-
'type' => 'error',
|
173 |
-
'message' => '%s() is highly discouraged due to not being cached; please use get_the_terms() along with wp_list_pluck() to extract the IDs.',
|
174 |
-
'functions' => array(
|
175 |
-
'wp_get_post_terms',
|
176 |
-
'wp_get_post_categories',
|
177 |
-
'wp_get_post_tags',
|
178 |
-
'wp_get_object_terms',
|
179 |
-
),
|
180 |
-
),
|
181 |
-
|
182 |
'term_exists' => array(
|
183 |
'type' => 'error',
|
184 |
'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_term_exists() instead.',
|
31 |
* Groups of functions to restrict.
|
32 |
*
|
33 |
* Example: groups => array(
|
34 |
+
* 'lambda' => array(
|
35 |
+
* 'type' => 'error' | 'warning',
|
36 |
+
* 'message' => 'Use anonymous functions instead please!',
|
37 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
38 |
+
* )
|
39 |
* )
|
40 |
*
|
41 |
* @return array
|
168 |
),
|
169 |
),
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
'term_exists' => array(
|
172 |
'type' => 'error',
|
173 |
'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_term_exists() instead.',
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/RestrictedVariablesSniff.php
CHANGED
@@ -22,13 +22,13 @@ class WordPress_Sniffs_VIP_RestrictedVariablesSniff extends WordPress_AbstractVa
|
|
22 |
* Groups of variables to restrict.
|
23 |
*
|
24 |
* Example: groups => array(
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
* )
|
33 |
*
|
34 |
* @return array
|
@@ -51,7 +51,7 @@ class WordPress_Sniffs_VIP_RestrictedVariablesSniff extends WordPress_AbstractVa
|
|
51 |
'message' => 'Due to using Batcache, server side based client related logic will not work, use JS instead.',
|
52 |
'variables' => array(
|
53 |
'$_COOKIE',
|
54 |
-
|
55 |
'array_members' => array(
|
56 |
'$_SERVER[\'HTTP_USER_AGENT\']',
|
57 |
'$_SERVER[\'REMOTE_ADDR\']',
|
22 |
* Groups of variables to restrict.
|
23 |
*
|
24 |
* Example: groups => array(
|
25 |
+
* 'wpdb' => array(
|
26 |
+
* 'type' => 'error' | 'warning',
|
27 |
+
* 'message' => 'Dont use this one please!',
|
28 |
+
* 'variables' => array( '$val', '$var' ),
|
29 |
+
* 'object_vars' => array( '$foo->bar', .. ),
|
30 |
+
* 'array_members' => array( '$foo['bar']', .. ),
|
31 |
+
* )
|
32 |
* )
|
33 |
*
|
34 |
* @return array
|
51 |
'message' => 'Due to using Batcache, server side based client related logic will not work, use JS instead.',
|
52 |
'variables' => array(
|
53 |
'$_COOKIE',
|
54 |
+
),
|
55 |
'array_members' => array(
|
56 |
'$_SERVER[\'HTTP_USER_AGENT\']',
|
57 |
'$_SERVER[\'REMOTE_ADDR\']',
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/SessionFunctionsUsageSniff.php
CHANGED
@@ -24,11 +24,11 @@ class WordPress_Sniffs_VIP_SessionFunctionsUsageSniff extends WordPress_Abstract
|
|
24 |
* Groups of functions to restrict.
|
25 |
*
|
26 |
* Example: groups => array(
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
* )
|
33 |
*
|
34 |
* @return array
|
24 |
* Groups of functions to restrict.
|
25 |
*
|
26 |
* Example: groups => array(
|
27 |
+
* 'lambda' => array(
|
28 |
+
* 'type' => 'error' | 'warning',
|
29 |
+
* 'message' => 'Use anonymous functions instead please!',
|
30 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
31 |
+
* )
|
32 |
* )
|
33 |
*
|
34 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php
CHANGED
@@ -18,8 +18,9 @@
|
|
18 |
* @since 0.3.0
|
19 |
* @since 0.10.0 The sniff no longer needlessly extends the Generic_Sniffs_PHP_ForbiddenFunctionsSniff
|
20 |
* which it didn't use.
|
|
|
21 |
*/
|
22 |
-
class WordPress_Sniffs_VIP_SessionVariableUsageSniff
|
23 |
|
24 |
/**
|
25 |
* Returns an array of tokens this test wants to listen for.
|
@@ -36,21 +37,18 @@ class WordPress_Sniffs_VIP_SessionVariableUsageSniff implements PHP_CodeSniffer_
|
|
36 |
/**
|
37 |
* Processes this test, when one of its tokens is encountered.
|
38 |
*
|
39 |
-
* @param
|
40 |
-
* @param int $stackPtr The position of the current token
|
41 |
-
* in the stack passed in $tokens.
|
42 |
-
*
|
43 |
-
* @todo Allow T_CONSTANT_ENCAPSED_STRING?
|
44 |
*
|
45 |
* @return void
|
46 |
*/
|
47 |
-
public function
|
48 |
-
$
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
52 |
}
|
53 |
-
|
54 |
}
|
55 |
|
56 |
} // End class.
|
18 |
* @since 0.3.0
|
19 |
* @since 0.10.0 The sniff no longer needlessly extends the Generic_Sniffs_PHP_ForbiddenFunctionsSniff
|
20 |
* which it didn't use.
|
21 |
+
* @since 0.12.0 This class now extends WordPress_Sniff.
|
22 |
*/
|
23 |
+
class WordPress_Sniffs_VIP_SessionVariableUsageSniff extends WordPress_Sniff {
|
24 |
|
25 |
/**
|
26 |
* Returns an array of tokens this test wants to listen for.
|
37 |
/**
|
38 |
* Processes this test, when one of its tokens is encountered.
|
39 |
*
|
40 |
+
* @param int $stackPtr The position of the current token in the stack.
|
|
|
|
|
|
|
|
|
41 |
*
|
42 |
* @return void
|
43 |
*/
|
44 |
+
public function process_token( $stackPtr ) {
|
45 |
+
if ( '$_SESSION' === $this->tokens[ $stackPtr ]['content'] ) {
|
46 |
+
$this->phpcsFile->addError(
|
47 |
+
'Usage of $_SESSION variable is prohibited.',
|
48 |
+
$stackPtr,
|
49 |
+
'SessionVarsProhibited'
|
50 |
+
);
|
51 |
}
|
|
|
52 |
}
|
53 |
|
54 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/SlowDBQuerySniff.php
CHANGED
@@ -15,22 +15,14 @@
|
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
|
|
|
|
|
|
18 |
*/
|
19 |
class WordPress_Sniffs_VIP_SlowDBQuerySniff extends WordPress_AbstractArrayAssignmentRestrictionsSniff {
|
20 |
|
21 |
/**
|
22 |
* Groups of variables to restrict.
|
23 |
-
* This should be overridden in extending classes.
|
24 |
-
*
|
25 |
-
* Example: groups => array(
|
26 |
-
* 'wpdb' => array(
|
27 |
-
* 'type' => 'error' | 'warning',
|
28 |
-
* 'message' => 'Dont use this one please!',
|
29 |
-
* 'variables' => array( '$val', '$var' ),
|
30 |
-
* 'object_vars' => array( '$foo->bar', .. ),
|
31 |
-
* 'array_members' => array( '$foo['bar']', .. ),
|
32 |
-
* )
|
33 |
-
* )
|
34 |
*
|
35 |
* @return array
|
36 |
*/
|
@@ -61,7 +53,23 @@ class WordPress_Sniffs_VIP_SlowDBQuerySniff extends WordPress_AbstractArrayAssig
|
|
61 |
*/
|
62 |
public function process_token( $stackPtr ) {
|
63 |
|
|
|
|
|
|
|
|
|
64 |
if ( $this->has_whitelist_comment( 'tax_query', $stackPtr ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
return;
|
66 |
}
|
67 |
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
+
* @since 0.12.0 Introduced new and more intuitively named 'slow query' whitelist
|
19 |
+
* comment, replacing the 'tax_query' whitelist comment which is now
|
20 |
+
* deprecated.
|
21 |
*/
|
22 |
class WordPress_Sniffs_VIP_SlowDBQuerySniff extends WordPress_AbstractArrayAssignmentRestrictionsSniff {
|
23 |
|
24 |
/**
|
25 |
* Groups of variables to restrict.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
*
|
27 |
* @return array
|
28 |
*/
|
53 |
*/
|
54 |
public function process_token( $stackPtr ) {
|
55 |
|
56 |
+
if ( $this->has_whitelist_comment( 'slow query', $stackPtr ) ) {
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
if ( $this->has_whitelist_comment( 'tax_query', $stackPtr ) ) {
|
61 |
+
/*
|
62 |
+
* Only throw the warning about a deprecated comment when the sniff would otherwise
|
63 |
+
* have been triggered on the array key.
|
64 |
+
*/
|
65 |
+
if ( in_array( $this->tokens[ $stackPtr ]['code'], array( T_CONSTANT_ENCAPSED_STRING, T_DOUBLE_QUOTED_STRING ), true ) ) {
|
66 |
+
$this->phpcsFile->addWarning(
|
67 |
+
'The "tax_query" whitelist comment is deprecated in favor of the "slow query" whitelist comment.',
|
68 |
+
$stackPtr,
|
69 |
+
'DeprecatedWhitelistFlagFound'
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
return;
|
74 |
}
|
75 |
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/TimezoneChangeSniff.php
CHANGED
@@ -24,11 +24,11 @@ class WordPress_Sniffs_VIP_TimezoneChangeSniff extends WordPress_AbstractFunctio
|
|
24 |
* Groups of functions to restrict.
|
25 |
*
|
26 |
* Example: groups => array(
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
* )
|
33 |
*
|
34 |
* @return array
|
24 |
* Groups of functions to restrict.
|
25 |
*
|
26 |
* Example: groups => array(
|
27 |
+
* 'lambda' => array(
|
28 |
+
* 'type' => 'error' | 'warning',
|
29 |
+
* 'message' => 'Use anonymous functions instead please!',
|
30 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
31 |
+
* )
|
32 |
* )
|
33 |
*
|
34 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php
CHANGED
@@ -70,6 +70,7 @@ class WordPress_Sniffs_VIP_ValidatedSanitizedInputSniff extends WordPress_Sniff
|
|
70 |
return array(
|
71 |
T_VARIABLE,
|
72 |
T_DOUBLE_QUOTED_STRING,
|
|
|
73 |
);
|
74 |
}
|
75 |
|
@@ -85,7 +86,9 @@ class WordPress_Sniffs_VIP_ValidatedSanitizedInputSniff extends WordPress_Sniff
|
|
85 |
$superglobals = $this->input_superglobals;
|
86 |
|
87 |
// Handling string interpolation.
|
88 |
-
if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $stackPtr ]['code']
|
|
|
|
|
89 |
$interpolated_variables = array_map(
|
90 |
create_function( '$symbol', 'return "$" . $symbol;' ), // Replace with closure when 5.3 is minimum requirement for PHPCS.
|
91 |
$this->get_interpolated_variables( $this->tokens[ $stackPtr ]['content'] )
|
@@ -142,7 +145,7 @@ class WordPress_Sniffs_VIP_ValidatedSanitizedInputSniff extends WordPress_Sniff
|
|
142 |
$this->phpcsFile->addError( 'Detected usage of a non-sanitized input variable: %s', $stackPtr, 'InputNotSanitized', $error_data );
|
143 |
}
|
144 |
|
145 |
-
} // End
|
146 |
|
147 |
/**
|
148 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
70 |
return array(
|
71 |
T_VARIABLE,
|
72 |
T_DOUBLE_QUOTED_STRING,
|
73 |
+
T_HEREDOC,
|
74 |
);
|
75 |
}
|
76 |
|
86 |
$superglobals = $this->input_superglobals;
|
87 |
|
88 |
// Handling string interpolation.
|
89 |
+
if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $stackPtr ]['code']
|
90 |
+
|| T_HEREDOC === $this->tokens[ $stackPtr ]['code']
|
91 |
+
) {
|
92 |
$interpolated_variables = array_map(
|
93 |
create_function( '$symbol', 'return "$" . $symbol;' ), // Replace with closure when 5.3 is minimum requirement for PHPCS.
|
94 |
$this->get_interpolated_variables( $this->tokens[ $stackPtr ]['content'] )
|
145 |
$this->phpcsFile->addError( 'Detected usage of a non-sanitized input variable: %s', $stackPtr, 'InputNotSanitized', $error_data );
|
146 |
}
|
147 |
|
148 |
+
} // End process_token().
|
149 |
|
150 |
/**
|
151 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Variables/GlobalVariablesSniff.php
CHANGED
@@ -10,264 +10,18 @@
|
|
10 |
/**
|
11 |
* WordPress_Sniffs_Variables_GlobalVariablesSniff.
|
12 |
*
|
13 |
-
* Warns about
|
14 |
*
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
-
* @since 0.4.0
|
|
|
|
|
|
|
19 |
*/
|
20 |
class WordPress_Sniffs_Variables_GlobalVariablesSniff extends WordPress_Sniff {
|
21 |
|
22 |
-
/**
|
23 |
-
* List of global WP variables.
|
24 |
-
*
|
25 |
-
* @since 0.3.0
|
26 |
-
* @since 0.11.0 Changed visibility from public to protected.
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
protected $globals = array(
|
31 |
-
'comment',
|
32 |
-
'comment_alt',
|
33 |
-
'comment_depth',
|
34 |
-
'comment_thread_alt',
|
35 |
-
'wp_rewrite',
|
36 |
-
'in_comment_loop',
|
37 |
-
'wp_query',
|
38 |
-
'withcomments',
|
39 |
-
'post',
|
40 |
-
'wpdb',
|
41 |
-
'id',
|
42 |
-
'user_login',
|
43 |
-
'user_ID',
|
44 |
-
'user_identity',
|
45 |
-
'overridden_cpage',
|
46 |
-
'wpcommentspopupfile',
|
47 |
-
'wpcommentsjavascript',
|
48 |
-
'shortcode_tags',
|
49 |
-
'wp_version',
|
50 |
-
'wp_scripts',
|
51 |
-
'comments',
|
52 |
-
'is_IE',
|
53 |
-
'_wp_registered_nav_menus',
|
54 |
-
'_menu_item_sort_prop',
|
55 |
-
'wp_roles',
|
56 |
-
'wp_object_cache',
|
57 |
-
'currentcat',
|
58 |
-
'previouscat',
|
59 |
-
'blog_id',
|
60 |
-
'is_macIE',
|
61 |
-
'is_winIE',
|
62 |
-
'plugin_page',
|
63 |
-
'wp_themes',
|
64 |
-
'wp_rich_edit_exists',
|
65 |
-
'allowedposttags',
|
66 |
-
'allowedtags',
|
67 |
-
'allowedentitynames',
|
68 |
-
'pass_allowed_html',
|
69 |
-
'pass_allowed_protocols',
|
70 |
-
'wp_post_statuses',
|
71 |
-
'wp_post_types',
|
72 |
-
'wp',
|
73 |
-
'_wp_post_type_features',
|
74 |
-
'_wp_suspend_cache_invalidation',
|
75 |
-
'wp_theme_directories',
|
76 |
-
'wp_locale',
|
77 |
-
'locale',
|
78 |
-
'l10n',
|
79 |
-
'_wp_additional_image_sizes',
|
80 |
-
'wp_embed',
|
81 |
-
'wp_taxonomies',
|
82 |
-
'sidebars_widgets',
|
83 |
-
'wp_registered_widgets',
|
84 |
-
'wp_registered_widget_controls',
|
85 |
-
'wp_registered_sidebars',
|
86 |
-
'wp_registered_widget_updates',
|
87 |
-
'_wp_admin_css_colors',
|
88 |
-
'concatenate_scripts',
|
89 |
-
'compress_scripts',
|
90 |
-
'wp_styles',
|
91 |
-
'compress_css',
|
92 |
-
'wp_the_query',
|
93 |
-
'_updated_user_settings',
|
94 |
-
'wp_filter',
|
95 |
-
'wp_actions',
|
96 |
-
'merged_filters',
|
97 |
-
'wp_current_filter',
|
98 |
-
'wp_plugin_paths',
|
99 |
-
'GETID3_ERRORARRAY',
|
100 |
-
'current_user',
|
101 |
-
'phpmailer',
|
102 |
-
'is_IIS',
|
103 |
-
'wp_hasher',
|
104 |
-
'rnd_value',
|
105 |
-
'auth_secure_cookie',
|
106 |
-
'userdata',
|
107 |
-
'user_level',
|
108 |
-
'user_email',
|
109 |
-
'user_url',
|
110 |
-
'wp_customize',
|
111 |
-
'wp_widget_factory',
|
112 |
-
'_wp_deprecated_widgets_callbacks',
|
113 |
-
'_wp_sidebars_widgets',
|
114 |
-
'error',
|
115 |
-
'wp_cockneyreplace',
|
116 |
-
'wpsmiliestrans',
|
117 |
-
'wp_smiliessearch',
|
118 |
-
'_links_add_base',
|
119 |
-
'_links_add_target',
|
120 |
-
'tinymce_version',
|
121 |
-
'PHP_SELF',
|
122 |
-
'required_php_version',
|
123 |
-
'upgrading',
|
124 |
-
'timestart',
|
125 |
-
'timeend',
|
126 |
-
'table_prefix',
|
127 |
-
'_wp_using_ext_object_cache',
|
128 |
-
'text_direction',
|
129 |
-
'custom_image_header',
|
130 |
-
'post_default_title',
|
131 |
-
'post_default_category',
|
132 |
-
'currentday',
|
133 |
-
'previousday',
|
134 |
-
'wp_header_to_desc',
|
135 |
-
'wp_xmlrpc_server',
|
136 |
-
'submenu',
|
137 |
-
'is_apache',
|
138 |
-
'is_iis7',
|
139 |
-
'current_site',
|
140 |
-
'domain',
|
141 |
-
'm',
|
142 |
-
'monthnum',
|
143 |
-
'year',
|
144 |
-
'posts',
|
145 |
-
'previousweekday',
|
146 |
-
'wp_rich_edit',
|
147 |
-
'is_gecko',
|
148 |
-
'is_opera',
|
149 |
-
'is_safari',
|
150 |
-
'is_chrome',
|
151 |
-
'wp_local_package',
|
152 |
-
'wp_user_roles',
|
153 |
-
'super_admins',
|
154 |
-
'_wp_default_headers',
|
155 |
-
'editor_styles',
|
156 |
-
'_wp_theme_features',
|
157 |
-
'custom_background',
|
158 |
-
'wp_did_header',
|
159 |
-
'wp_admin_bar',
|
160 |
-
'tag',
|
161 |
-
'show_admin_bar',
|
162 |
-
'pagenow',
|
163 |
-
'HTTP_RAW_POST_DATA',
|
164 |
-
'path',
|
165 |
-
'wp_json',
|
166 |
-
'page',
|
167 |
-
'more',
|
168 |
-
'preview',
|
169 |
-
'pages',
|
170 |
-
'multipage',
|
171 |
-
'numpages',
|
172 |
-
'paged',
|
173 |
-
'authordata',
|
174 |
-
'currentmonth',
|
175 |
-
'EZSQL_ERROR',
|
176 |
-
'required_mysql_version',
|
177 |
-
'wp_db_version',
|
178 |
-
'opml',
|
179 |
-
'map',
|
180 |
-
'updated_timestamp',
|
181 |
-
'all_links',
|
182 |
-
'names',
|
183 |
-
'urls',
|
184 |
-
'targets',
|
185 |
-
'descriptions',
|
186 |
-
'feeds',
|
187 |
-
'wp_filesystem',
|
188 |
-
'menu_order',
|
189 |
-
'default_menu_order',
|
190 |
-
'_wp_nav_menu_max_depth',
|
191 |
-
'_nav_menu_placeholder',
|
192 |
-
'wp_meta_boxes',
|
193 |
-
'one_theme_location_no_menus',
|
194 |
-
'nav_menu_selected_id',
|
195 |
-
'post_ID',
|
196 |
-
'link_id',
|
197 |
-
'action',
|
198 |
-
'link',
|
199 |
-
'tabs',
|
200 |
-
'tab',
|
201 |
-
'type',
|
202 |
-
'term',
|
203 |
-
'redir_tab',
|
204 |
-
'post_mime_types',
|
205 |
-
'menu',
|
206 |
-
'admin_page_hooks',
|
207 |
-
'_registered_pages',
|
208 |
-
'_parent_pages',
|
209 |
-
'_wp_last_object_menu',
|
210 |
-
'_wp_last_utility_menu',
|
211 |
-
'_wp_real_parent_file',
|
212 |
-
'_wp_submenu_nopriv',
|
213 |
-
'parent_file',
|
214 |
-
'typenow',
|
215 |
-
'_wp_menu_nopriv',
|
216 |
-
'title',
|
217 |
-
'new_whitelist_options',
|
218 |
-
'whitelist_options',
|
219 |
-
'wp_list_table',
|
220 |
-
's',
|
221 |
-
'mode',
|
222 |
-
'post_type_object',
|
223 |
-
'avail_post_stati',
|
224 |
-
'per_page',
|
225 |
-
'locked_post_status',
|
226 |
-
'cat',
|
227 |
-
'lost',
|
228 |
-
'avail_post_mime_types',
|
229 |
-
'$var',
|
230 |
-
'errors',
|
231 |
-
'cat_id',
|
232 |
-
'orderby',
|
233 |
-
'order',
|
234 |
-
'post_type',
|
235 |
-
'taxonomy',
|
236 |
-
'tax',
|
237 |
-
'wp_queries',
|
238 |
-
'charset_collate',
|
239 |
-
'wp_current_db_version',
|
240 |
-
'wp_importers',
|
241 |
-
'wp_file_descriptions',
|
242 |
-
'theme_field_defaults',
|
243 |
-
'themes_allowedtags',
|
244 |
-
'post_id',
|
245 |
-
'comment_status',
|
246 |
-
'search',
|
247 |
-
'comment_type',
|
248 |
-
'wp_settings_sections',
|
249 |
-
'wp_settings_fields',
|
250 |
-
'wp_settings_errors',
|
251 |
-
'hook_suffix',
|
252 |
-
'admin_body_class',
|
253 |
-
'current_screen',
|
254 |
-
'taxnow',
|
255 |
-
'status',
|
256 |
-
'totals',
|
257 |
-
'_old_files',
|
258 |
-
'_new_bundled_files',
|
259 |
-
'usersearch',
|
260 |
-
'role',
|
261 |
-
'wp_dashboard_control_callbacks',
|
262 |
-
'plugins',
|
263 |
-
'self',
|
264 |
-
'submenu_file',
|
265 |
-
'blogname',
|
266 |
-
'blog_title',
|
267 |
-
'active_signup',
|
268 |
-
'interim_login',
|
269 |
-
);
|
270 |
-
|
271 |
/**
|
272 |
* Returns an array of tokens this test wants to listen for.
|
273 |
*
|
@@ -312,7 +66,7 @@ class WordPress_Sniffs_Variables_GlobalVariablesSniff extends WordPress_Sniff {
|
|
312 |
}
|
313 |
}
|
314 |
|
315 |
-
if ( !
|
316 |
return;
|
317 |
}
|
318 |
|
@@ -335,7 +89,7 @@ class WordPress_Sniffs_Variables_GlobalVariablesSniff extends WordPress_Sniff {
|
|
335 |
}
|
336 |
|
337 |
if ( T_VARIABLE === $var['code'] ) {
|
338 |
-
if (
|
339 |
$search[] = $var['content'];
|
340 |
}
|
341 |
}
|
@@ -398,9 +152,9 @@ class WordPress_Sniffs_Variables_GlobalVariablesSniff extends WordPress_Sniff {
|
|
398 |
}
|
399 |
}
|
400 |
}
|
401 |
-
}
|
402 |
|
403 |
-
} // End
|
404 |
|
405 |
/**
|
406 |
* Add the error if there is no whitelist comment present and the assignment
|
10 |
/**
|
11 |
* WordPress_Sniffs_Variables_GlobalVariablesSniff.
|
12 |
*
|
13 |
+
* Warns about overwriting WordPress native global variables.
|
14 |
*
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
+
* @since 0.4.0 This class now extends WordPress_Sniff.
|
19 |
+
* @since 0.12.0 The $wp_globals property has been moved to the WordPress_Sniff.
|
20 |
+
*
|
21 |
+
* @uses WordPress_Sniff::$custom_test_class_whitelist
|
22 |
*/
|
23 |
class WordPress_Sniffs_Variables_GlobalVariablesSniff extends WordPress_Sniff {
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* Returns an array of tokens this test wants to listen for.
|
27 |
*
|
66 |
}
|
67 |
}
|
68 |
|
69 |
+
if ( ! isset( $this->wp_globals[ $var_name ] ) ) {
|
70 |
return;
|
71 |
}
|
72 |
|
89 |
}
|
90 |
|
91 |
if ( T_VARIABLE === $var['code'] ) {
|
92 |
+
if ( isset( $this->wp_globals[ substr( $var['content'], 1 ) ] ) ) {
|
93 |
$search[] = $var['content'];
|
94 |
}
|
95 |
}
|
152 |
}
|
153 |
}
|
154 |
}
|
155 |
+
}
|
156 |
|
157 |
+
} // End process_token().
|
158 |
|
159 |
/**
|
160 |
* Add the error if there is no whitelist comment present and the assignment
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Variables/VariableRestrictionsSniff.php
CHANGED
@@ -27,13 +27,13 @@ class WordPress_Sniffs_Variables_VariableRestrictionsSniff extends WordPress_Abs
|
|
27 |
* Groups of variables to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
* )
|
38 |
*
|
39 |
* @return array
|
27 |
* Groups of variables to restrict.
|
28 |
*
|
29 |
* Example: groups => array(
|
30 |
+
* 'wpdb' => array(
|
31 |
+
* 'type' => 'error' | 'warning',
|
32 |
+
* 'message' => 'Dont use this one please!',
|
33 |
+
* 'variables' => array( '$val', '$var' ),
|
34 |
+
* 'object_vars' => array( '$foo->bar', .. ),
|
35 |
+
* 'array_members' => array( '$foo['bar']', .. ),
|
36 |
+
* )
|
37 |
* )
|
38 |
*
|
39 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php
CHANGED
@@ -20,11 +20,11 @@ class WordPress_Sniffs_WP_AlternativeFunctionsSniff extends WordPress_AbstractFu
|
|
20 |
* Groups of functions to restrict.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
20 |
* Groups of functions to restrict.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
+
* 'lambda' => array(
|
24 |
+
* 'type' => 'error' | 'warning',
|
25 |
+
* 'message' => 'Use anonymous functions instead please!',
|
26 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
27 |
+
* )
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Capital P Dangit!
|
12 |
+
*
|
13 |
+
* Verify the correct spelling of `WordPress` in text strings, comments and class names.
|
14 |
+
*
|
15 |
+
* @package WPCS\WordPressCodingStandards
|
16 |
+
*
|
17 |
+
* @since 0.12.0
|
18 |
+
*/
|
19 |
+
class WordPress_Sniffs_WP_CapitalPDangitSniff extends WordPress_Sniff {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Regex to match a large number or spelling variations of WordPress in text strings.
|
23 |
+
*
|
24 |
+
* Prevents matches on:
|
25 |
+
* - URLs for wordpress.org/com/net/tv.
|
26 |
+
* - `@...` usernames starting with `wordpress`
|
27 |
+
* - email addresses with a domain starting with `wordpress`
|
28 |
+
* - email addresses with a user name ending with `wordpress`
|
29 |
+
* - (most) variable names.
|
30 |
+
* - directory paths containing a folder starting or ending with `wordpress`.
|
31 |
+
* - file names containing `wordpress` for a limited set of extensions.
|
32 |
+
* - `wordpress` prefixed or suffixed with dashes as those are indicators that the
|
33 |
+
* term is probably used as part of a CSS class, such as `fa-wordpress`
|
34 |
+
* or filename/path like `class-wordpress-importer.php`.
|
35 |
+
* - back-tick quoted `wordpress`.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
const WP_REGEX = '#(?<![\\\\/\$@`-])\b(Word[ _-]*Pres+)\b(?![@/`-]|\.(?:org|com|net|tv)|[^\s<>\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Regex to match a large number or spelling variations of WordPress in class names.
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
const WP_CLASSNAME_REGEX = '`(?:^|_)(Word[_]*Pres+)(?:_|$)`i';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* String tokens we want to listen for.
|
50 |
+
*
|
51 |
+
* @var array
|
52 |
+
*/
|
53 |
+
private $text_string_tokens = array(
|
54 |
+
T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
|
55 |
+
T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING,
|
56 |
+
T_HEREDOC => T_HEREDOC,
|
57 |
+
T_NOWDOC => T_NOWDOC,
|
58 |
+
T_INLINE_HTML => T_INLINE_HTML,
|
59 |
+
);
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Comment tokens we want to listen for as they contain text strings.
|
63 |
+
*
|
64 |
+
* @var array
|
65 |
+
*/
|
66 |
+
private $comment_text_tokens = array(
|
67 |
+
T_DOC_COMMENT => T_DOC_COMMENT,
|
68 |
+
T_DOC_COMMENT_STRING => T_DOC_COMMENT_STRING,
|
69 |
+
T_COMMENT => T_COMMENT,
|
70 |
+
);
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Class-like structure tokens to listen for.
|
74 |
+
*
|
75 |
+
* Using proper spelling in class, interface and trait names does not conflict with the naming conventions.
|
76 |
+
*
|
77 |
+
* @var array
|
78 |
+
*/
|
79 |
+
private $class_tokens = array(
|
80 |
+
T_CLASS => T_CLASS,
|
81 |
+
T_INTERFACE => T_INTERFACE,
|
82 |
+
T_TRAIT => T_TRAIT,
|
83 |
+
);
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Combined text string and comment tokens array.
|
87 |
+
*
|
88 |
+
* This property is set in the register() method and used for lookups.
|
89 |
+
*
|
90 |
+
* @var array
|
91 |
+
*/
|
92 |
+
private $text_and_comment_tokens = array();
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Returns an array of tokens this test wants to listen for.
|
96 |
+
*
|
97 |
+
* @since 0.12.0
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
public function register() {
|
102 |
+
// Union the arrays - keeps the array keys.
|
103 |
+
$this->text_and_comment_tokens = ( $this->text_string_tokens + $this->comment_text_tokens );
|
104 |
+
|
105 |
+
$targets = ( $this->text_and_comment_tokens + $this->class_tokens );
|
106 |
+
|
107 |
+
// Also sniff for array tokens to make skipping anything within those more efficient.
|
108 |
+
$targets[ T_ARRAY ] = T_ARRAY;
|
109 |
+
$targets[ T_OPEN_SHORT_ARRAY ] = T_OPEN_SHORT_ARRAY;
|
110 |
+
|
111 |
+
return $targets;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Processes this test, when one of its tokens is encountered.
|
116 |
+
*
|
117 |
+
* @since 0.12.0
|
118 |
+
*
|
119 |
+
* @param int $stackPtr The position of the current token in the stack.
|
120 |
+
*
|
121 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
122 |
+
* normal file processing.
|
123 |
+
*/
|
124 |
+
public function process_token( $stackPtr ) {
|
125 |
+
|
126 |
+
if ( $this->has_whitelist_comment( 'spelling', $stackPtr ) ) {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
/*
|
131 |
+
* Ignore tokens within an array definition as this is a false positive in 80% of all cases.
|
132 |
+
*
|
133 |
+
* The return values skip to the end of the array.
|
134 |
+
* This prevents the sniff "hanging" on very long configuration arrays.
|
135 |
+
*/
|
136 |
+
if ( T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['bracket_closer'] ) ) {
|
137 |
+
return $this->tokens[ $stackPtr ]['bracket_closer'];
|
138 |
+
} elseif ( T_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['parenthesis_closer'] ) ) {
|
139 |
+
return $this->tokens[ $stackPtr ]['parenthesis_closer'];
|
140 |
+
}
|
141 |
+
|
142 |
+
/*
|
143 |
+
* Deal with misspellings in class/interface/trait names.
|
144 |
+
* These are not auto-fixable, but need the attention of a developer.
|
145 |
+
*/
|
146 |
+
if ( isset( $this->class_tokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
|
147 |
+
$classname = $this->phpcsFile->getDeclarationName( $stackPtr );
|
148 |
+
if ( empty( $classname ) ) {
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
if ( preg_match_all( self::WP_CLASSNAME_REGEX, $classname, $matches, PREG_PATTERN_ORDER ) > 0 ) {
|
153 |
+
$mispelled = $this->retrieve_misspellings( $matches[1] );
|
154 |
+
|
155 |
+
if ( ! empty( $mispelled ) ) {
|
156 |
+
$this->phpcsFile->addWarning(
|
157 |
+
'Please spell "WordPress" correctly. Found: "%s" as part of the class/interface/trait name.',
|
158 |
+
$stackPtr,
|
159 |
+
'MisspelledClassName',
|
160 |
+
array( implode( ', ', $mispelled ) )
|
161 |
+
);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
|
168 |
+
/*
|
169 |
+
* Deal with misspellings in text strings and documentation.
|
170 |
+
*/
|
171 |
+
|
172 |
+
// Ignore content of docblock @link tags.
|
173 |
+
if ( T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ]['code']
|
174 |
+
|| T_DOC_COMMENT === $this->tokens[ $stackPtr ]['code']
|
175 |
+
) {
|
176 |
+
|
177 |
+
$comment_start = $this->phpcsFile->findPrevious( T_DOC_COMMENT_OPEN_TAG, ( $stackPtr - 1 ) );
|
178 |
+
if ( false !== $comment_start ) {
|
179 |
+
$comment_tag = $this->phpcsFile->findPrevious( T_DOC_COMMENT_TAG, ( $stackPtr - 1 ), $comment_start );
|
180 |
+
if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ]['content'] ) {
|
181 |
+
// @link tag, so ignore.
|
182 |
+
return;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
// Ignore any text strings which are array keys `$var['key']` as this is a false positive in 80% of all cases.
|
188 |
+
if ( T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ]['code'] ) {
|
189 |
+
$prevToken = $this->phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
|
190 |
+
if ( false !== $prevToken && T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ]['code'] ) {
|
191 |
+
$nextToken = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
|
192 |
+
if ( false !== $nextToken && T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
|
193 |
+
return;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
$content = $this->tokens[ $stackPtr ]['content'];
|
199 |
+
|
200 |
+
if ( preg_match_all( self::WP_REGEX, $content, $matches, ( PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) ) > 0 ) {
|
201 |
+
/*
|
202 |
+
* Prevent some typical false positives.
|
203 |
+
*/
|
204 |
+
if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
|
205 |
+
$offset = 0;
|
206 |
+
foreach ( $matches[1] as $key => $match_data ) {
|
207 |
+
$next_offset = ( $match_data[1] + strlen( $match_data[0] ) );
|
208 |
+
|
209 |
+
// Prevent matches on part of a URL.
|
210 |
+
if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[0], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
|
211 |
+
unset( $matches[1][ $key ] );
|
212 |
+
} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[0], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
|
213 |
+
// Prevent matches on html attributes like: `value="wordpress"`.
|
214 |
+
unset( $matches[1][ $key ] );
|
215 |
+
} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[0], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
|
216 |
+
// Prevent matches on xpath queries and such: `\'wordpress\'`.
|
217 |
+
unset( $matches[1][ $key ] );
|
218 |
+
} elseif ( preg_match( '`(?:\?|&|&)[a-z0-9_]+=' . preg_quote( $match_data[0], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
|
219 |
+
// Prevent matches on url query strings: `?something=wordpress`.
|
220 |
+
unset( $matches[1][ $key ] );
|
221 |
+
}
|
222 |
+
|
223 |
+
$offset = $next_offset;
|
224 |
+
}
|
225 |
+
|
226 |
+
if ( empty( $matches[1] ) ) {
|
227 |
+
return;
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
$mispelled = $this->retrieve_misspellings( $matches[1] );
|
232 |
+
|
233 |
+
if ( empty( $mispelled ) ) {
|
234 |
+
return;
|
235 |
+
}
|
236 |
+
|
237 |
+
$fix = $this->phpcsFile->addFixableWarning(
|
238 |
+
'Please spell "WordPress" correctly. Found %s misspelling(s): %s',
|
239 |
+
$stackPtr,
|
240 |
+
'Misspelled',
|
241 |
+
array(
|
242 |
+
count( $mispelled ),
|
243 |
+
implode( ', ', $mispelled ),
|
244 |
+
)
|
245 |
+
);
|
246 |
+
|
247 |
+
if ( true === $fix ) {
|
248 |
+
// Apply fixes based on offset to ensure we don't replace false positives.
|
249 |
+
$replacement = $content;
|
250 |
+
foreach ( $matches[1] as $match ) {
|
251 |
+
$replacement = substr_replace( $replacement, 'WordPress', $match[1], strlen( $match[0] ) );
|
252 |
+
}
|
253 |
+
|
254 |
+
$this->phpcsFile->fixer->replaceToken( $stackPtr, $replacement );
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
} // End process_token().
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Retrieve a list of misspellings based on an array of matched variations on the target word.
|
262 |
+
*
|
263 |
+
* @param array $match_stack Array of matched variations of the target word.
|
264 |
+
* @return array Array containing only the misspelled variants.
|
265 |
+
*/
|
266 |
+
protected function retrieve_misspellings( $match_stack ) {
|
267 |
+
$mispelled = array();
|
268 |
+
foreach ( $match_stack as $match ) {
|
269 |
+
// Deal with multi-dimensional arrays when capturing offset.
|
270 |
+
if ( is_array( $match ) ) {
|
271 |
+
$match = $match[0];
|
272 |
+
}
|
273 |
+
|
274 |
+
if ( 'WordPress' !== $match ) {
|
275 |
+
$mispelled[] = $match;
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
return $mispelled;
|
280 |
+
}
|
281 |
+
|
282 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedClassesSniff.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Restricts the use of deprecated WordPress classes and suggests alternatives.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
*
|
15 |
+
* @since 0.12.0
|
16 |
+
*/
|
17 |
+
class WordPress_Sniffs_WP_DeprecatedClassesSniff extends WordPress_AbstractClassRestrictionsSniff {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Minimum WordPress version.
|
21 |
+
*
|
22 |
+
* This sniff will throw an error when usage of a deprecated class is
|
23 |
+
* detected if the class was deprecated before the minimum supported
|
24 |
+
* WP version; a warning otherwise.
|
25 |
+
* By default, it is set to presume that a project will support the current
|
26 |
+
* WP version and up to three releases before.
|
27 |
+
* This variable allows changing the minimum supported WP version used by
|
28 |
+
* this sniff by setting a property in a custom phpcs.xml ruleset.
|
29 |
+
*
|
30 |
+
* Example usage:
|
31 |
+
* <rule ref="WordPress.WP.DeprecatedClasses">
|
32 |
+
* <properties>
|
33 |
+
* <property name="minimum_supported_version" value="4.3"/>
|
34 |
+
* </properties>
|
35 |
+
* </rule>
|
36 |
+
*
|
37 |
+
* @var string WordPress versions.
|
38 |
+
*/
|
39 |
+
public $minimum_supported_version = '4.5';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* List of deprecated classes with alternative when available.
|
43 |
+
*
|
44 |
+
* To be updated after every major release.
|
45 |
+
*
|
46 |
+
* Version numbers should be fully qualified.
|
47 |
+
*
|
48 |
+
* @var array
|
49 |
+
*/
|
50 |
+
private $deprecated_classes = array(
|
51 |
+
|
52 |
+
// WP 3.1.0.
|
53 |
+
'WP_User_Search' => array(
|
54 |
+
'alt' => 'WP_User_Query',
|
55 |
+
'version' => '3.1.0',
|
56 |
+
),
|
57 |
+
);
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Groups of classes to restrict.
|
62 |
+
*
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
public function getGroups() {
|
66 |
+
// Make sure all array keys are lowercase.
|
67 |
+
$keys = array_keys( $this->deprecated_classes );
|
68 |
+
$keys = array_map( 'strtolower', $keys );
|
69 |
+
$this->deprecated_classes = array_combine( $keys, $this->deprecated_classes );
|
70 |
+
|
71 |
+
return array(
|
72 |
+
'deprecated_classes' => array(
|
73 |
+
'classes' => $keys,
|
74 |
+
),
|
75 |
+
);
|
76 |
+
|
77 |
+
} // End getGroups().
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Process a matched token.
|
81 |
+
*
|
82 |
+
* @param int $stackPtr The position of the current token in the stack.
|
83 |
+
* @param array $group_name The name of the group which was matched. Will
|
84 |
+
* always be 'deprecated_functions'.
|
85 |
+
* @param string $matched_content The token content (class name) which was matched.
|
86 |
+
*
|
87 |
+
* @return void
|
88 |
+
*/
|
89 |
+
public function process_matched_token( $stackPtr, $group_name, $matched_content ) {
|
90 |
+
$class_name = ltrim( strtolower( $matched_content ), '\\' );
|
91 |
+
|
92 |
+
$message = 'The %s class has been deprecated since WordPress version %s.';
|
93 |
+
$data = array(
|
94 |
+
ltrim( $matched_content, '\\' ),
|
95 |
+
$this->deprecated_classes[ $class_name ]['version'],
|
96 |
+
);
|
97 |
+
|
98 |
+
if ( ! empty( $this->deprecated_classes[ $class_name ]['alt'] ) ) {
|
99 |
+
$message .= ' Use %s instead.';
|
100 |
+
$data[] = $this->deprecated_classes[ $class_name ]['alt'];
|
101 |
+
}
|
102 |
+
|
103 |
+
$this->addMessage(
|
104 |
+
$message,
|
105 |
+
$stackPtr,
|
106 |
+
( version_compare( $this->deprecated_classes[ $class_name ]['version'], $this->minimum_supported_version, '<' ) ),
|
107 |
+
$this->string_to_errorcode( $matched_content . 'Found' ),
|
108 |
+
$data
|
109 |
+
);
|
110 |
+
|
111 |
+
} // End process_matched_token().
|
112 |
+
|
113 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php
CHANGED
@@ -28,7 +28,7 @@ class WordPress_Sniffs_WP_DeprecatedFunctionsSniff extends WordPress_AbstractFun
|
|
28 |
* this sniff by setting a property in a custom phpcs.xml ruleset.
|
29 |
*
|
30 |
* Example usage:
|
31 |
-
* <rule ref="WordPress.WP.
|
32 |
* <properties>
|
33 |
* <property name="minimum_supported_version" value="4.3"/>
|
34 |
* </properties>
|
@@ -36,1058 +36,1274 @@ class WordPress_Sniffs_WP_DeprecatedFunctionsSniff extends WordPress_AbstractFun
|
|
36 |
*
|
37 |
* @var string WordPress versions.
|
38 |
*/
|
39 |
-
public $minimum_supported_version = '4.
|
40 |
|
41 |
/**
|
42 |
* List of deprecated functions with alternative when available.
|
43 |
*
|
44 |
* To be updated after every major release.
|
45 |
-
* Last updated for WordPress 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
*
|
47 |
* @var array
|
48 |
*/
|
49 |
private $deprecated_functions = array(
|
50 |
-
|
51 |
-
|
52 |
-
'version' => '0.71',
|
53 |
-
),
|
54 |
'the_category_head' => array(
|
55 |
'alt' => 'get_the_category_by_ID()',
|
56 |
'version' => '0.71',
|
57 |
),
|
|
|
|
|
|
|
|
|
58 |
|
|
|
59 |
'permalink_link' => array(
|
60 |
'alt' => 'the_permalink()',
|
61 |
-
'version' => '1.2',
|
62 |
),
|
63 |
|
|
|
64 |
'start_wp' => array(
|
|
|
65 |
'alt' => 'the Loop',
|
66 |
-
'version' => '1.5',
|
67 |
),
|
|
|
|
|
68 |
'get_postdata' => array(
|
69 |
'alt' => 'get_post()',
|
70 |
'version' => '1.5.1',
|
71 |
),
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
'
|
|
|
76 |
),
|
77 |
'next_post' => array(
|
78 |
'alt' => 'next_post_link()',
|
79 |
-
'version' => '2.0',
|
80 |
),
|
81 |
-
'
|
82 |
-
'alt' => '
|
83 |
-
'version' => '2.0',
|
84 |
),
|
85 |
'user_can_create_draft' => array(
|
86 |
'alt' => 'current_user_can()',
|
87 |
-
'version' => '2.0',
|
88 |
),
|
89 |
-
'
|
90 |
'alt' => 'current_user_can()',
|
91 |
-
'version' => '2.0',
|
92 |
),
|
93 |
'user_can_delete_post' => array(
|
94 |
'alt' => 'current_user_can()',
|
95 |
-
'version' => '2.0',
|
96 |
),
|
97 |
-
'
|
|
|
|
|
|
|
|
|
98 |
'alt' => 'current_user_can()',
|
99 |
-
'version' => '2.0',
|
100 |
),
|
101 |
'user_can_edit_post_comments' => array(
|
102 |
'alt' => 'current_user_can()',
|
103 |
-
'version' => '2.0',
|
104 |
),
|
105 |
-
'
|
106 |
'alt' => 'current_user_can()',
|
107 |
-
'version' => '2.0',
|
108 |
),
|
109 |
'user_can_edit_user' => array(
|
110 |
'alt' => 'current_user_can()',
|
111 |
-
'version' => '2.0',
|
112 |
),
|
113 |
-
'
|
114 |
-
'alt' => '
|
115 |
-
'version' => '2.0',
|
116 |
),
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
'
|
|
|
121 |
),
|
122 |
-
'
|
123 |
-
'alt' => '
|
124 |
-
'version' => '2.1',
|
125 |
),
|
126 |
-
'
|
127 |
-
'alt' => '
|
128 |
-
'version' => '2.1',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
),
|
130 |
'get_linkobjects' => array(
|
131 |
'alt' => 'get_bookmarks()',
|
132 |
-
'version' => '2.1',
|
133 |
),
|
134 |
-
'
|
135 |
'alt' => 'get_bookmarks()',
|
136 |
-
'version' => '2.1',
|
137 |
),
|
138 |
-
'
|
139 |
-
'alt' => '
|
140 |
-
'version' => '2.1',
|
141 |
),
|
142 |
-
'
|
143 |
-
'alt' => '',
|
144 |
-
'version' => '2.1',
|
145 |
),
|
146 |
-
'
|
147 |
-
'alt' => '
|
148 |
-
'version' => '2.1',
|
149 |
),
|
150 |
-
'
|
151 |
-
'alt' => '
|
152 |
-
'version' => '2.1',
|
153 |
),
|
154 |
-
'
|
155 |
-
'alt' => '
|
156 |
-
'version' => '2.1',
|
157 |
),
|
158 |
-
'
|
159 |
-
'alt' => '
|
160 |
-
'version' => '2.1',
|
161 |
),
|
162 |
-
'
|
163 |
-
'alt' => '
|
164 |
-
'version' => '2.1',
|
165 |
),
|
166 |
-
'
|
167 |
-
'alt' => '
|
168 |
-
'version' => '2.1',
|
169 |
),
|
170 |
-
'
|
171 |
-
'alt' => '
|
172 |
-
'version' => '2.1',
|
173 |
),
|
174 |
-
'
|
175 |
-
'alt' => '
|
176 |
-
'version' => '2.1',
|
177 |
),
|
178 |
-
'
|
179 |
-
'alt' => '
|
180 |
-
'version' => '2.1',
|
181 |
),
|
182 |
-
'
|
183 |
-
'alt' => '
|
184 |
-
'version' => '2.1',
|
185 |
),
|
186 |
'wp_get_links' => array(
|
187 |
'alt' => 'wp_list_bookmarks()',
|
188 |
-
'version' => '2.1',
|
189 |
-
),
|
190 |
-
'get_links' => array(
|
191 |
-
'alt' => 'get_bookmarks()',
|
192 |
-
'version' => '2.1',
|
193 |
),
|
194 |
-
'
|
195 |
'alt' => 'wp_list_bookmarks()',
|
196 |
-
'version' => '2.1',
|
197 |
-
),
|
198 |
-
'links_popup_script' => array(
|
199 |
-
'alt' => '',
|
200 |
-
'version' => '2.1',
|
201 |
),
|
202 |
-
'
|
203 |
-
'alt' => '
|
204 |
-
'version' => '2.1',
|
205 |
-
),
|
206 |
-
'get_linkcatname' => array(
|
207 |
-
'alt' => 'get_category()',
|
208 |
-
'version' => '2.1',
|
209 |
),
|
210 |
-
'
|
211 |
-
'alt' => '
|
212 |
-
'version' => '2.1',
|
213 |
),
|
214 |
-
'
|
215 |
-
'alt' => '
|
216 |
-
'version' => '2.1',
|
217 |
),
|
218 |
|
|
|
219 |
'comments_rss' => array(
|
220 |
'alt' => 'get_post_comments_feed_link()',
|
221 |
-
'version' => '2.2',
|
222 |
),
|
223 |
|
|
|
224 |
'permalink_single_rss' => array(
|
225 |
-
'alt' => '
|
226 |
-
'version' => '2.3',
|
227 |
),
|
228 |
|
|
|
229 |
'comments_rss_link' => array(
|
230 |
'alt' => 'post_comments_feed_link()',
|
231 |
-
'version' => '2.5',
|
232 |
-
),
|
233 |
-
'get_category_rss_link' => array(
|
234 |
-
'alt' => 'get_category_feed_link()',
|
235 |
-
'version' => '2.5',
|
236 |
),
|
237 |
-
'
|
238 |
-
'alt' => '
|
239 |
-
'version' => '2.5',
|
240 |
),
|
241 |
-
'
|
242 |
-
'alt' => '
|
243 |
-
'version' => '2.5',
|
244 |
),
|
245 |
'get_attachment_icon_src' => array(
|
246 |
'alt' => 'wp_get_attachment_image_src()',
|
247 |
-
'version' => '2.5',
|
248 |
-
),
|
249 |
-
'get_attachment_icon' => array(
|
250 |
-
'alt' => 'wp_get_attachment_image()',
|
251 |
-
'version' => '2.5',
|
252 |
),
|
253 |
'get_attachment_innerHTML' => array(
|
254 |
'alt' => 'wp_get_attachment_image()',
|
255 |
-
'version' => '2.5',
|
256 |
),
|
257 |
-
'
|
258 |
-
'alt' => '',
|
259 |
-
'version' => '2.5',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
),
|
261 |
'gzip_compression' => array(
|
262 |
'alt' => '',
|
263 |
-
'version' => '2.5',
|
264 |
),
|
265 |
-
'
|
266 |
-
'alt' => '
|
267 |
-
'version' => '2.5',
|
268 |
),
|
269 |
'wp_get_cookie_login' => array(
|
270 |
'alt' => '',
|
271 |
-
'version' => '2.5',
|
272 |
),
|
273 |
'wp_login' => array(
|
274 |
'alt' => 'wp_signon()',
|
275 |
-
'version' => '2.5',
|
|
|
|
|
|
|
|
|
276 |
),
|
277 |
|
|
|
278 |
'dropdown_categories' => array(
|
279 |
'alt' => 'wp_category_checklist()',
|
280 |
-
'version' => '2.6',
|
281 |
),
|
282 |
'dropdown_link_categories' => array(
|
283 |
'alt' => 'wp_link_category_checklist()',
|
284 |
-
'version' => '2.6',
|
285 |
),
|
286 |
|
|
|
287 |
'get_commentdata' => array(
|
288 |
'alt' => 'get_comment()',
|
289 |
-
'version' => '2.7',
|
290 |
),
|
291 |
// This is a method i.e. WP_Filesystem_Base::find_base_dir() See #731.
|
292 |
'find_base_dir' => array(
|
293 |
'alt' => 'WP_Filesystem::abspath()',
|
294 |
-
'version' => '2.7',
|
295 |
),
|
296 |
// This is a method i.e. WP_Filesystem_Base::get_base_dir() See #731.
|
297 |
'get_base_dir' => array(
|
298 |
'alt' => 'WP_Filesystem::abspath()',
|
299 |
-
'version' => '2.7',
|
300 |
),
|
301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
'get_catname' => array(
|
303 |
'alt' => 'get_cat_name()',
|
304 |
-
'version' => '2.8',
|
305 |
),
|
306 |
-
'
|
307 |
-
'alt' => '
|
308 |
-
'version' => '2.8',
|
309 |
),
|
310 |
'get_the_author_description' => array(
|
311 |
-
'alt' =>
|
312 |
-
'version' => '2.8',
|
313 |
-
),
|
314 |
-
'the_author_description' => array(
|
315 |
-
'alt' => 'the_author_meta(\'description\')',
|
316 |
-
'version' => '2.8',
|
317 |
),
|
318 |
-
'
|
319 |
-
'alt' => '
|
320 |
-
'version' => '2.8',
|
321 |
),
|
322 |
'get_the_author_firstname' => array(
|
323 |
'alt' => 'get_the_author_meta(\'first_name\')',
|
324 |
-
'version' => '2.8',
|
325 |
),
|
326 |
-
'
|
327 |
-
'alt' => '
|
328 |
-
'version' => '2.8',
|
|
|
|
|
|
|
|
|
329 |
),
|
330 |
'get_the_author_lastname' => array(
|
331 |
'alt' => 'get_the_author_meta(\'last_name\')',
|
332 |
-
'version' => '2.8',
|
333 |
),
|
334 |
-
'
|
335 |
-
'alt' => '
|
336 |
-
'version' => '2.8',
|
|
|
|
|
|
|
|
|
337 |
),
|
338 |
'get_the_author_nickname' => array(
|
339 |
'alt' => 'get_the_author_meta(\'nickname\')',
|
340 |
-
'version' => '2.8',
|
341 |
-
),
|
342 |
-
'the_author_nickname' => array(
|
343 |
-
'alt' => 'the_author_meta(\'nickname\')',
|
344 |
-
'version' => '2.8',
|
345 |
-
),
|
346 |
-
'get_the_author_email' => array(
|
347 |
-
'alt' => 'get_the_author_meta(\'email\')',
|
348 |
-
'version' => '2.8',
|
349 |
-
),
|
350 |
-
'the_author_email' => array(
|
351 |
-
'alt' => 'the_author_meta(\'email\')',
|
352 |
-
'version' => '2.8',
|
353 |
-
),
|
354 |
-
'get_the_author_icq' => array(
|
355 |
-
'alt' => 'get_the_author_meta(\'icq\')',
|
356 |
-
'version' => '2.8',
|
357 |
),
|
358 |
-
'
|
359 |
-
'alt' => '
|
360 |
-
'version' => '2.8',
|
361 |
),
|
362 |
'get_the_author_yim' => array(
|
363 |
'alt' => 'get_the_author_meta(\'yim\')',
|
364 |
-
'version' => '2.8',
|
365 |
),
|
366 |
-
'
|
367 |
-
'alt' => '
|
368 |
-
'version' => '2.8',
|
369 |
),
|
370 |
-
'
|
371 |
-
'alt' => '
|
372 |
-
'version' => '2.8',
|
373 |
),
|
374 |
-
'
|
375 |
-
'alt' => '
|
376 |
-
'version' => '2.8',
|
377 |
),
|
378 |
-
'
|
379 |
-
'alt' => '
|
380 |
-
'version' => '2.8',
|
381 |
),
|
382 |
'the_author_aim' => array(
|
383 |
'alt' => 'the_author_meta(\'aim\')',
|
384 |
-
'version' => '2.8',
|
385 |
),
|
386 |
-
'
|
387 |
-
'alt' => '
|
388 |
-
'version' => '2.8',
|
389 |
),
|
390 |
-
'
|
391 |
-
'alt' => '
|
392 |
-
'version' => '2.8',
|
393 |
),
|
394 |
-
'
|
395 |
-
'alt' => 'the_author_meta(\'
|
396 |
-
'version' => '2.8',
|
397 |
),
|
398 |
-
'
|
399 |
-
'alt' => '
|
400 |
-
'version' => '2.8',
|
401 |
),
|
402 |
'the_author_ID' => array(
|
403 |
'alt' => 'the_author_meta(\'ID\')',
|
404 |
-
'version' => '2.8',
|
405 |
),
|
406 |
-
'
|
407 |
-
'alt' => '
|
408 |
-
'version' => '2.8',
|
409 |
-
),
|
410 |
-
'__ngettext_noop' => array(
|
411 |
-
'alt' => '_n_noop()',
|
412 |
-
'version' => '2.8',
|
413 |
),
|
414 |
-
'
|
415 |
-
'alt' => '
|
416 |
-
'version' => '2.8',
|
417 |
),
|
418 |
-
'
|
419 |
-
'alt' => '
|
420 |
-
'version' => '2.8',
|
421 |
),
|
422 |
-
'
|
423 |
-
'alt' => '
|
424 |
-
'version' => '2.8',
|
425 |
),
|
426 |
-
'
|
427 |
-
'alt' => '
|
428 |
-
'version' => '2.8',
|
429 |
),
|
430 |
-
'
|
431 |
-
'alt' => '
|
432 |
-
'version' => '2.8',
|
433 |
),
|
434 |
'unregister_sidebar_widget' => array(
|
435 |
'alt' => 'wp_unregister_sidebar_widget()',
|
436 |
-
'version' => '2.8',
|
437 |
-
),
|
438 |
-
'register_widget_control' => array(
|
439 |
-
'alt' => 'wp_register_widget_control()',
|
440 |
-
'version' => '2.8',
|
441 |
),
|
442 |
'unregister_widget_control' => array(
|
443 |
'alt' => 'wp_unregister_widget_control()',
|
444 |
-
'version' => '2.8',
|
|
|
|
|
|
|
|
|
445 |
),
|
446 |
|
447 |
-
|
448 |
-
|
449 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
),
|
451 |
'make_url_footnote' => array(
|
452 |
'alt' => '',
|
453 |
-
'version' => '2.9',
|
454 |
),
|
455 |
-
'
|
456 |
-
'alt' => '
|
457 |
-
'version' => '2.9',
|
458 |
),
|
459 |
-
|
460 |
'translate_with_context' => array(
|
461 |
'alt' => '_x()',
|
462 |
-
'version' => '
|
463 |
),
|
464 |
-
|
465 |
-
|
466 |
-
|
|
|
|
|
467 |
),
|
468 |
-
'
|
469 |
-
'alt' => '
|
470 |
-
'version' => '3.0',
|
|
|
|
|
|
|
|
|
471 |
),
|
472 |
'clean_url' => array(
|
473 |
'alt' => 'esc_url()',
|
474 |
-
'version' => '3.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
),
|
476 |
'delete_usermeta' => array(
|
477 |
'alt' => 'delete_user_meta()',
|
478 |
-
'version' => '3.0',
|
479 |
),
|
480 |
-
'
|
481 |
-
'alt' => '
|
482 |
-
'version' => '3.0',
|
483 |
),
|
484 |
-
'
|
485 |
-
'alt' => '
|
486 |
-
'version' => '3.0',
|
487 |
),
|
488 |
-
'
|
489 |
-
'alt' => '
|
490 |
-
'version' => '3.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
),
|
492 |
'get_profile' => array(
|
493 |
'alt' => 'get_the_author_meta()',
|
494 |
-
'version' => '3.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
),
|
496 |
'get_usernumposts' => array(
|
497 |
'alt' => 'count_user_posts()',
|
498 |
-
'version' => '3.0',
|
499 |
),
|
500 |
-
'
|
501 |
-
'alt' => '',
|
502 |
-
'version' => '3.0',
|
503 |
),
|
504 |
-
'
|
505 |
-
'alt' => '',
|
506 |
-
'version' => '3.0',
|
|
|
|
|
|
|
|
|
507 |
),
|
508 |
'is_taxonomy' => array(
|
509 |
'alt' => 'taxonomy_exists()',
|
510 |
-
'version' => '3.0',
|
511 |
),
|
512 |
'is_term' => array(
|
513 |
'alt' => 'term_exists()',
|
514 |
-
'version' => '3.0',
|
515 |
),
|
516 |
-
'
|
517 |
-
'alt' => '
|
518 |
-
'version' => '3.0',
|
519 |
),
|
520 |
-
'
|
521 |
-
'alt' => '
|
522 |
-
'version' => '3.0',
|
523 |
),
|
524 |
'remove_option_update_handler' => array(
|
525 |
'alt' => 'unregister_setting()',
|
526 |
-
'version' => '3.0',
|
527 |
),
|
528 |
-
'
|
529 |
-
'alt' => '',
|
530 |
-
'version' => '3.0',
|
531 |
),
|
532 |
-
'
|
533 |
-
'alt' => '',
|
534 |
-
'version' => '3.0',
|
535 |
),
|
536 |
'use_codepress' => array(
|
537 |
'alt' => '',
|
538 |
-
'version' => '3.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
),
|
540 |
'wp_shrink_dimensions' => array(
|
541 |
'alt' => 'wp_constrain_dimensions()',
|
542 |
-
'version' => '3.0',
|
543 |
),
|
544 |
-
|
545 |
-
|
546 |
-
'
|
547 |
-
'version' => '3.1',
|
548 |
),
|
549 |
-
'
|
550 |
'alt' => '',
|
551 |
-
'version' => '3.
|
552 |
),
|
553 |
-
|
|
|
|
|
554 |
'alt' => 'get_users()',
|
555 |
-
'version' => '3.1',
|
556 |
),
|
557 |
-
'
|
558 |
'alt' => '',
|
559 |
-
'version' => '3.1',
|
560 |
),
|
561 |
'get_editable_authors' => array(
|
562 |
-
'alt' => '',
|
563 |
-
'version' => '3.1',
|
564 |
),
|
565 |
'get_editable_user_ids' => array(
|
566 |
-
'alt' => '',
|
567 |
-
'version' => '3.1',
|
568 |
),
|
569 |
'get_nonauthor_user_ids' => array(
|
570 |
-
'alt' => '',
|
571 |
-
'version' => '3.1',
|
572 |
-
),
|
573 |
-
'WP_User_Search' => array(
|
574 |
-
'alt' => 'WP_User_Query',
|
575 |
-
'version' => '3.1',
|
576 |
-
),
|
577 |
-
'get_others_unpublished_posts' => array(
|
578 |
-
'alt' => '',
|
579 |
-
'version' => '3.1',
|
580 |
),
|
581 |
'get_others_drafts' => array(
|
582 |
'alt' => '',
|
583 |
-
'version' => '3.1',
|
584 |
),
|
585 |
'get_others_pending' => array(
|
586 |
'alt' => '',
|
587 |
-
'version' => '3.1',
|
588 |
),
|
589 |
-
|
590 |
-
'wp_timezone_supported' => array(
|
591 |
-
'alt' => '',
|
592 |
-
'version' => '3.2',
|
593 |
-
),
|
594 |
-
'wp_dashboard_quick_press' => array(
|
595 |
'alt' => '',
|
596 |
-
'version' => '3.
|
597 |
),
|
598 |
-
'
|
599 |
-
'alt' => '
|
600 |
-
'version' => '3.
|
601 |
),
|
602 |
-
'
|
603 |
-
'alt' => '
|
604 |
-
'version' => '3.
|
605 |
),
|
606 |
-
'
|
607 |
-
|
608 |
-
'
|
|
|
609 |
),
|
610 |
-
'
|
611 |
-
'alt' => '
|
612 |
-
'version' => '3.
|
613 |
),
|
|
|
|
|
614 |
'favorite_actions' => array(
|
615 |
'alt' => 'WP_Admin_Bar',
|
616 |
-
'version' => '3.2',
|
617 |
),
|
618 |
-
|
619 |
-
|
620 |
-
'
|
621 |
-
'version' => '3.3',
|
622 |
),
|
623 |
-
'
|
624 |
'alt' => '',
|
625 |
-
'version' => '3.
|
626 |
),
|
627 |
-
|
628 |
-
|
629 |
-
|
|
|
|
|
630 |
),
|
631 |
'get_boundary_post_rel_link' => array(
|
632 |
'alt' => '',
|
633 |
-
'version' => '3.3',
|
634 |
-
),
|
635 |
-
'start_post_rel_link' => array(
|
636 |
-
'alt' => '',
|
637 |
-
'version' => '3.3',
|
638 |
),
|
639 |
'get_index_rel_link' => array(
|
640 |
'alt' => '',
|
641 |
-
'version' => '3.3',
|
642 |
-
),
|
643 |
-
'index_rel_link' => array(
|
644 |
-
'alt' => '',
|
645 |
-
'version' => '3.3',
|
646 |
),
|
647 |
'get_parent_post_rel_link' => array(
|
648 |
'alt' => '',
|
649 |
-
'version' => '3.3',
|
650 |
),
|
651 |
-
'
|
|
|
|
|
|
|
|
|
652 |
'alt' => '',
|
653 |
-
'version' => '3.3',
|
654 |
),
|
655 |
-
'
|
|
|
|
|
|
|
|
|
656 |
'alt' => '',
|
657 |
-
'version' => '3.3',
|
658 |
),
|
659 |
'is_blog_user' => array(
|
660 |
-
'alt' => '
|
661 |
-
'version' => '3.3',
|
662 |
),
|
663 |
-
'
|
664 |
-
'alt' => '
|
665 |
-
'version' => '3.3',
|
666 |
),
|
667 |
-
'
|
668 |
-
'alt' => '
|
669 |
-
'version' => '3.3',
|
670 |
),
|
671 |
-
'
|
672 |
-
'alt' => '
|
673 |
-
'version' => '3.3',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
),
|
675 |
'screen_layout' => array(
|
676 |
'alt' => '$current_screen->render_screen_layout()',
|
677 |
-
'version' => '3.3',
|
678 |
-
),
|
679 |
-
'screen_options' => array(
|
680 |
-
'alt' => '$current_screen->render_per_page_options()',
|
681 |
-
'version' => '3.3',
|
682 |
),
|
683 |
'screen_meta' => array(
|
684 |
'alt' => '$current_screen->render_screen_meta()',
|
685 |
-
'version' => '3.3',
|
686 |
),
|
687 |
-
'
|
688 |
-
'alt' => '
|
689 |
-
'version' => '3.3',
|
690 |
),
|
691 |
-
'
|
692 |
-
'alt' => '
|
693 |
-
'version' => '3.3',
|
694 |
),
|
695 |
-
'
|
696 |
-
'alt' => '
|
697 |
-
'version' => '3.3',
|
698 |
),
|
699 |
-
'
|
700 |
-
'alt' => '
|
701 |
-
'version' => '3.3',
|
702 |
),
|
703 |
-
'
|
704 |
-
'alt' => 'wp_media_insert_url_form(
|
705 |
-
'version' => '3.3',
|
706 |
),
|
707 |
-
'
|
708 |
-
'alt' => 'wp_media_insert_url_form(
|
709 |
-
'version' => '3.3',
|
710 |
),
|
711 |
'type_url_form_video' => array(
|
712 |
-
'alt' => 'wp_media_insert_url_form(
|
713 |
-
'version' => '3.3',
|
714 |
),
|
715 |
-
'
|
716 |
-
'alt' => '
|
717 |
-
'version' => '3.3',
|
718 |
),
|
719 |
-
'
|
720 |
-
'alt' => '
|
721 |
-
'version' => '3.3',
|
722 |
),
|
723 |
-
|
724 |
-
|
725 |
-
'
|
726 |
-
'version' => '3.4',
|
727 |
),
|
728 |
-
'
|
729 |
-
'alt' => '
|
730 |
-
'version' => '3.
|
731 |
),
|
732 |
-
'
|
733 |
-
'alt' => '
|
734 |
-
'version' => '3.
|
735 |
),
|
736 |
-
'
|
737 |
'alt' => '',
|
738 |
-
'version' => '3.
|
739 |
-
),
|
740 |
-
'add_custom_image_header' => array(
|
741 |
-
'alt' => 'add_theme_support( \'custom-header\', $args )',
|
742 |
-
'version' => '3.4',
|
743 |
),
|
744 |
-
'
|
745 |
-
'alt' => '
|
746 |
-
'version' => '3.
|
747 |
),
|
|
|
|
|
748 |
'add_custom_background' => array(
|
749 |
'alt' => 'add_theme_support( \'custom-background\', $args )',
|
750 |
-
'version' => '3.4',
|
751 |
),
|
752 |
-
'
|
753 |
-
'alt' => '
|
754 |
-
'version' => '3.4',
|
755 |
),
|
756 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
'alt' => 'wp_get_theme()',
|
758 |
-
'version' => '3.4',
|
759 |
),
|
760 |
-
'
|
761 |
-
'alt' => '
|
762 |
-
'version' => '3.4',
|
763 |
),
|
764 |
-
'
|
765 |
-
'alt' => '
|
766 |
-
'version' => '3.4',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
767 |
),
|
768 |
'get_allowed_themes' => array(
|
769 |
'alt' => 'wp_get_themes( array( \'allowed\' => true ) )',
|
770 |
-
'version' => '3.4',
|
771 |
),
|
772 |
'get_broken_themes' => array(
|
773 |
'alt' => 'wp_get_themes( array( \'errors\' => true )',
|
774 |
-
'version' => '3.4',
|
775 |
),
|
776 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
777 |
'alt' => 'wp_get_theme()',
|
778 |
-
'version' => '3.4',
|
|
|
|
|
|
|
|
|
779 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
780 |
'wp_explain_nonce' => array(
|
781 |
-
'alt' => 'wp_nonce_ays',
|
782 |
'version' => '3.4.1',
|
783 |
),
|
784 |
|
785 |
-
|
786 |
-
|
787 |
-
'
|
|
|
788 |
),
|
789 |
'_get_post_ancestors' => array(
|
790 |
'alt' => '',
|
791 |
-
'version' => '3.5',
|
792 |
-
),
|
793 |
-
'wp_load_image' => array(
|
794 |
-
'alt' => 'wp_get_image_editor()',
|
795 |
-
'version' => '3.5',
|
796 |
),
|
797 |
-
'
|
798 |
-
'alt' => '
|
799 |
-
'version' => '3.5',
|
800 |
),
|
801 |
-
'
|
802 |
-
'alt' => '
|
803 |
-
'version' => '3.5',
|
804 |
),
|
805 |
-
'
|
806 |
-
'alt' => '
|
807 |
-
'version' => '3.5',
|
808 |
),
|
809 |
'_save_post_hook' => array(
|
810 |
'alt' => '',
|
811 |
-
'version' => '3.5',
|
812 |
),
|
813 |
'gd_edit_image_support' => array(
|
814 |
-
'alt' => 'wp_image_editor_supports',
|
815 |
-
'version' => '3.5',
|
816 |
),
|
817 |
-
'
|
818 |
-
'alt' => '',
|
819 |
-
'version' => '3.5',
|
820 |
-
),
|
821 |
-
'_media_button' => array(
|
822 |
-
'alt' => '',
|
823 |
-
'version' => '3.5',
|
824 |
),
|
825 |
'get_post_to_edit' => array(
|
826 |
'alt' => 'get_post()',
|
827 |
-
'version' => '3.5',
|
828 |
),
|
829 |
-
'
|
830 |
-
'alt' => '
|
831 |
-
'version' => '3.5',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
832 |
),
|
833 |
'wp_create_thumbnail' => array(
|
834 |
'alt' => 'image_resize()',
|
835 |
-
'version' => '3.5',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
),
|
837 |
|
|
|
838 |
'get_user_id_from_string' => array(
|
839 |
'alt' => 'get_user_by()',
|
840 |
-
'version' => '3.6',
|
841 |
),
|
842 |
'wp_convert_bytes_to_hr' => array(
|
843 |
'alt' => 'size_format()',
|
844 |
-
'version' => '3.6',
|
845 |
),
|
846 |
'wp_nav_menu_locations_meta_box' => array(
|
847 |
'alt' => '',
|
848 |
-
'version' => '3.6',
|
849 |
),
|
850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
851 |
'the_attachment_links' => array(
|
852 |
'alt' => '',
|
853 |
-
'version' => '3.7',
|
854 |
),
|
855 |
'wp_update_core' => array(
|
856 |
-
'alt' => 'new Core_Upgrader()',
|
857 |
-
'version' => '3.7',
|
858 |
),
|
859 |
'wp_update_plugin' => array(
|
860 |
-
'alt' => 'new Plugin_Upgrader()',
|
861 |
-
'version' => '3.7',
|
862 |
),
|
863 |
'wp_update_theme' => array(
|
864 |
-
'alt' => 'new Theme_Upgrader()',
|
865 |
-
'version' => '3.7',
|
866 |
-
),
|
867 |
-
'_search_terms_tidy' => array(
|
868 |
-
'alt' => '',
|
869 |
-
'version' => '3.7',
|
870 |
-
),
|
871 |
-
'get_blogaddress_by_domain' => array(
|
872 |
-
'alt' => '',
|
873 |
-
'version' => '3.7',
|
874 |
),
|
875 |
|
|
|
876 |
'get_screen_icon' => array(
|
877 |
'alt' => '',
|
878 |
-
'version' => '3.8',
|
879 |
),
|
880 |
'screen_icon' => array(
|
881 |
'alt' => '',
|
882 |
-
'version' => '3.8',
|
883 |
),
|
884 |
'wp_dashboard_incoming_links' => array(
|
885 |
'alt' => '',
|
886 |
-
'version' => '3.8',
|
887 |
),
|
888 |
'wp_dashboard_incoming_links_control' => array(
|
889 |
'alt' => '',
|
890 |
-
'version' => '3.8',
|
891 |
),
|
892 |
'wp_dashboard_incoming_links_output' => array(
|
893 |
'alt' => '',
|
894 |
-
'version' => '3.8',
|
895 |
),
|
896 |
'wp_dashboard_plugins' => array(
|
897 |
'alt' => '',
|
898 |
-
'version' => '3.8',
|
899 |
),
|
900 |
'wp_dashboard_primary_control' => array(
|
901 |
'alt' => '',
|
902 |
-
'version' => '3.8',
|
903 |
),
|
904 |
'wp_dashboard_recent_comments_control' => array(
|
905 |
'alt' => '',
|
906 |
-
'version' => '3.8',
|
907 |
),
|
908 |
'wp_dashboard_secondary' => array(
|
909 |
'alt' => '',
|
910 |
-
'version' => '3.8',
|
911 |
),
|
912 |
'wp_dashboard_secondary_control' => array(
|
913 |
'alt' => '',
|
914 |
-
'version' => '3.8',
|
915 |
),
|
916 |
'wp_dashboard_secondary_output' => array(
|
917 |
'alt' => '',
|
918 |
-
'version' => '3.8',
|
919 |
),
|
920 |
|
921 |
-
|
|
|
922 |
'alt' => '',
|
923 |
-
'version' => '3.9',
|
924 |
),
|
925 |
'default_topic_count_text' => array(
|
926 |
'alt' => '',
|
927 |
-
'version' => '3.9',
|
928 |
),
|
929 |
'format_to_post' => array(
|
930 |
'alt' => '',
|
931 |
-
'version' => '3.9',
|
932 |
),
|
933 |
'get_current_site_name' => array(
|
934 |
'alt' => 'get_current_site()',
|
935 |
-
'version' => '3.9',
|
936 |
),
|
937 |
-
'
|
938 |
'alt' => '',
|
939 |
-
'version' => '3.9',
|
940 |
),
|
941 |
-
'
|
942 |
'alt' => '',
|
943 |
-
'version' => '3.9',
|
944 |
),
|
945 |
|
|
|
946 |
'get_all_category_ids' => array(
|
947 |
'alt' => 'get_terms()',
|
948 |
-
'version' => '4.0',
|
949 |
),
|
950 |
'like_escape' => array(
|
951 |
'alt' => 'wpdb::esc_like()',
|
952 |
-
'version' => '4.0',
|
953 |
),
|
954 |
'url_is_accessable_via_ssl' => array(
|
955 |
'alt' => '',
|
956 |
-
'version' => '4.0',
|
957 |
),
|
958 |
|
959 |
-
|
960 |
-
|
961 |
-
'version' => '4.1',
|
962 |
-
),
|
963 |
'add_tab' => array(
|
964 |
'alt' => '',
|
965 |
-
'version' => '4.1',
|
966 |
),
|
967 |
-
|
|
|
968 |
'alt' => '',
|
969 |
-
'version' => '4.1',
|
970 |
),
|
|
|
971 |
'print_tab_image' => array(
|
972 |
'alt' => '',
|
973 |
-
'version' => '4.1',
|
974 |
),
|
975 |
-
|
976 |
-
'
|
977 |
-
'alt' => '
|
978 |
-
'version' => '4.
|
979 |
),
|
|
|
|
|
|
|
980 |
'prepreview_added_sidebars_widgets' => array(
|
981 |
-
'alt' => 'customize_dynamic_setting_args',
|
982 |
-
'version' => '4.2',
|
983 |
),
|
|
|
984 |
'prepreview_added_widget_instance' => array(
|
985 |
-
'alt' => 'customize_dynamic_setting_args',
|
986 |
-
'version' => '4.2',
|
987 |
),
|
|
|
988 |
'remove_prepreview_filters' => array(
|
989 |
-
'alt' => 'customize_dynamic_setting_args
|
990 |
-
'version' => '4.2',
|
|
|
|
|
|
|
|
|
|
|
991 |
),
|
992 |
|
993 |
-
|
|
|
994 |
'alt' => '',
|
995 |
-
'version' => '4.3',
|
996 |
),
|
997 |
'_preview_theme_template_filter' => array(
|
998 |
'alt' => '',
|
999 |
-
'version' => '4.3',
|
1000 |
),
|
1001 |
-
'
|
1002 |
'alt' => '',
|
1003 |
-
'version' => '4.3',
|
1004 |
),
|
1005 |
'preview_theme_ob_filter' => array(
|
1006 |
'alt' => '',
|
1007 |
-
'version' => '4.3',
|
1008 |
),
|
1009 |
'preview_theme_ob_filter_callback' => array(
|
1010 |
'alt' => '',
|
1011 |
-
'version' => '4.3',
|
1012 |
),
|
1013 |
-
'
|
1014 |
'alt' => '',
|
1015 |
-
'version' => '4.3',
|
1016 |
),
|
1017 |
'wp_htmledit_pre' => array(
|
1018 |
-
'alt' => '',
|
1019 |
-
'version' => '4.3',
|
1020 |
),
|
1021 |
-
'
|
1022 |
-
'alt' => '',
|
1023 |
-
'version' => '4.3',
|
1024 |
),
|
1025 |
|
1026 |
-
|
1027 |
-
'alt' => 'get_permalink',
|
1028 |
-
'version' => '4.4',
|
1029 |
-
),
|
1030 |
-
'force_ssl_login' => array(
|
1031 |
-
'alt' => 'force_ssl_admin',
|
1032 |
-
'version' => '4.4',
|
1033 |
-
),
|
1034 |
'create_empty_blog' => array(
|
1035 |
'alt' => '',
|
1036 |
-
'version' => '4.4',
|
|
|
|
|
|
|
|
|
1037 |
),
|
1038 |
'get_admin_users_for_domain' => array(
|
1039 |
'alt' => '',
|
1040 |
-
'version' => '4.4',
|
|
|
|
|
|
|
|
|
1041 |
),
|
1042 |
'wp_get_http' => array(
|
1043 |
-
'alt' => 'WP_Http',
|
1044 |
-
'version' => '4.4',
|
1045 |
),
|
1046 |
// This is a method i.e. WP_Widget_Recent_Comments::flush_widget_cache() See #731.
|
1047 |
'flush_widget_cache' => array(
|
1048 |
'alt' => '',
|
1049 |
-
'version' => '4.4',
|
1050 |
),
|
1051 |
|
1052 |
-
|
1053 |
-
'alt' => '',
|
1054 |
-
'version' => '4.5',
|
1055 |
-
),
|
1056 |
'add_object_page' => array(
|
1057 |
'alt' => 'add_menu_page()',
|
1058 |
-
'version' => '4.5',
|
1059 |
),
|
1060 |
'add_utility_page' => array(
|
1061 |
'alt' => 'add_menu_page()',
|
1062 |
-
'version' => '4.5',
|
1063 |
-
),
|
1064 |
-
'get_comments_popup_template' => array(
|
1065 |
-
'alt' => '',
|
1066 |
-
'version' => '4.5',
|
1067 |
),
|
1068 |
'comments_popup_script' => array(
|
1069 |
'alt' => '',
|
1070 |
-
'version' => '4.5',
|
1071 |
),
|
1072 |
-
'
|
1073 |
'alt' => '',
|
1074 |
-
'version' => '4.5',
|
1075 |
),
|
1076 |
'get_currentuserinfo' => array(
|
1077 |
'alt' => 'wp_get_current_user()',
|
1078 |
-
'version' => '4.5',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1079 |
),
|
1080 |
|
|
|
|
|
|
|
|
|
|
|
1081 |
'wp_embed_handler_googlevideo' => array(
|
1082 |
'alt' => '',
|
1083 |
-
'version' => '4.6',
|
1084 |
),
|
1085 |
'wp_get_sites' => array(
|
1086 |
'alt' => 'get_sites()',
|
1087 |
-
'version' => '4.6',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1088 |
),
|
1089 |
|
1090 |
-
//
|
|
|
|
|
|
|
|
|
1091 |
);
|
1092 |
|
1093 |
/**
|
28 |
* this sniff by setting a property in a custom phpcs.xml ruleset.
|
29 |
*
|
30 |
* Example usage:
|
31 |
+
* <rule ref="WordPress.WP.DeprecatedFunctions">
|
32 |
* <properties>
|
33 |
* <property name="minimum_supported_version" value="4.3"/>
|
34 |
* </properties>
|
36 |
*
|
37 |
* @var string WordPress versions.
|
38 |
*/
|
39 |
+
public $minimum_supported_version = '4.5';
|
40 |
|
41 |
/**
|
42 |
* List of deprecated functions with alternative when available.
|
43 |
*
|
44 |
* To be updated after every major release.
|
45 |
+
* Last updated for WordPress 4.8.
|
46 |
+
*
|
47 |
+
* Version numbers should be fully qualified.
|
48 |
+
* Replacement functions should have parentheses.
|
49 |
+
*
|
50 |
+
* To retrieve a function list for comparison, the following tool is available:
|
51 |
+
* https://github.com/JDGrimes/wp-deprecated-code-scanner
|
52 |
*
|
53 |
* @var array
|
54 |
*/
|
55 |
private $deprecated_functions = array(
|
56 |
+
|
57 |
+
// WP 0.71.
|
|
|
|
|
58 |
'the_category_head' => array(
|
59 |
'alt' => 'get_the_category_by_ID()',
|
60 |
'version' => '0.71',
|
61 |
),
|
62 |
+
'the_category_ID' => array(
|
63 |
+
'alt' => 'get_the_category()',
|
64 |
+
'version' => '0.71',
|
65 |
+
),
|
66 |
|
67 |
+
// WP 1.2.0.
|
68 |
'permalink_link' => array(
|
69 |
'alt' => 'the_permalink()',
|
70 |
+
'version' => '1.2.0',
|
71 |
),
|
72 |
|
73 |
+
// WP 1.5.0.
|
74 |
'start_wp' => array(
|
75 |
+
// Verified correct alternative.
|
76 |
'alt' => 'the Loop',
|
77 |
+
'version' => '1.5.0',
|
78 |
),
|
79 |
+
|
80 |
+
// WP 1.5.1.
|
81 |
'get_postdata' => array(
|
82 |
'alt' => 'get_post()',
|
83 |
'version' => '1.5.1',
|
84 |
),
|
85 |
|
86 |
+
// WP 2.0.0.
|
87 |
+
'create_user' => array(
|
88 |
+
'alt' => 'wp_create_user()',
|
89 |
+
'version' => '2.0.0',
|
90 |
),
|
91 |
'next_post' => array(
|
92 |
'alt' => 'next_post_link()',
|
93 |
+
'version' => '2.0.0',
|
94 |
),
|
95 |
+
'previous_post' => array(
|
96 |
+
'alt' => 'previous_post_link()',
|
97 |
+
'version' => '2.0.0',
|
98 |
),
|
99 |
'user_can_create_draft' => array(
|
100 |
'alt' => 'current_user_can()',
|
101 |
+
'version' => '2.0.0',
|
102 |
),
|
103 |
+
'user_can_create_post' => array(
|
104 |
'alt' => 'current_user_can()',
|
105 |
+
'version' => '2.0.0',
|
106 |
),
|
107 |
'user_can_delete_post' => array(
|
108 |
'alt' => 'current_user_can()',
|
109 |
+
'version' => '2.0.0',
|
110 |
),
|
111 |
+
'user_can_delete_post_comments' => array(
|
112 |
+
'alt' => 'current_user_can()',
|
113 |
+
'version' => '2.0.0',
|
114 |
+
),
|
115 |
+
'user_can_edit_post' => array(
|
116 |
'alt' => 'current_user_can()',
|
117 |
+
'version' => '2.0.0',
|
118 |
),
|
119 |
'user_can_edit_post_comments' => array(
|
120 |
'alt' => 'current_user_can()',
|
121 |
+
'version' => '2.0.0',
|
122 |
),
|
123 |
+
'user_can_edit_post_date' => array(
|
124 |
'alt' => 'current_user_can()',
|
125 |
+
'version' => '2.0.0',
|
126 |
),
|
127 |
'user_can_edit_user' => array(
|
128 |
'alt' => 'current_user_can()',
|
129 |
+
'version' => '2.0.0',
|
130 |
),
|
131 |
+
'user_can_set_post_date' => array(
|
132 |
+
'alt' => 'current_user_can()',
|
133 |
+
'version' => '2.0.0',
|
134 |
),
|
135 |
|
136 |
+
// WP 2.1.0.
|
137 |
+
'dropdown_cats' => array(
|
138 |
+
'alt' => 'wp_dropdown_categories()',
|
139 |
+
'version' => '2.1.0',
|
140 |
),
|
141 |
+
'get_archives' => array(
|
142 |
+
'alt' => 'wp_get_archives()',
|
143 |
+
'version' => '2.1.0',
|
144 |
),
|
145 |
+
'get_author_link' => array(
|
146 |
+
'alt' => 'get_author_posts_url()',
|
147 |
+
'version' => '2.1.0',
|
148 |
+
),
|
149 |
+
'get_autotoggle' => array(
|
150 |
+
'alt' => '',
|
151 |
+
'version' => '2.1.0',
|
152 |
+
),
|
153 |
+
'get_link' => array(
|
154 |
+
'alt' => 'get_bookmark()',
|
155 |
+
'version' => '2.1.0',
|
156 |
+
),
|
157 |
+
'get_linkcatname' => array(
|
158 |
+
'alt' => 'get_category()',
|
159 |
+
'version' => '2.1.0',
|
160 |
),
|
161 |
'get_linkobjects' => array(
|
162 |
'alt' => 'get_bookmarks()',
|
163 |
+
'version' => '2.1.0',
|
164 |
),
|
165 |
+
'get_linkobjectsbyname' => array(
|
166 |
'alt' => 'get_bookmarks()',
|
167 |
+
'version' => '2.1.0',
|
168 |
),
|
169 |
+
'get_linkrating' => array(
|
170 |
+
'alt' => 'sanitize_bookmark_field()',
|
171 |
+
'version' => '2.1.0',
|
172 |
),
|
173 |
+
'get_links' => array(
|
174 |
+
'alt' => 'get_bookmarks()',
|
175 |
+
'version' => '2.1.0',
|
176 |
),
|
177 |
+
'get_links_list' => array(
|
178 |
+
'alt' => 'wp_list_bookmarks()',
|
179 |
+
'version' => '2.1.0',
|
180 |
),
|
181 |
+
'get_links_withrating' => array(
|
182 |
+
'alt' => 'get_bookmarks()',
|
183 |
+
'version' => '2.1.0',
|
184 |
),
|
185 |
+
'get_linksbyname' => array(
|
186 |
+
'alt' => 'get_bookmarks()',
|
187 |
+
'version' => '2.1.0',
|
188 |
),
|
189 |
+
'get_linksbyname_withrating' => array(
|
190 |
+
'alt' => 'get_bookmarks()',
|
191 |
+
'version' => '2.1.0',
|
192 |
),
|
193 |
+
'get_settings' => array(
|
194 |
+
'alt' => 'get_option()',
|
195 |
+
'version' => '2.1.0',
|
196 |
),
|
197 |
+
'link_pages' => array(
|
198 |
+
'alt' => 'wp_link_pages()',
|
199 |
+
'version' => '2.1.0',
|
200 |
),
|
201 |
+
'links_popup_script' => array(
|
202 |
+
'alt' => '',
|
203 |
+
'version' => '2.1.0',
|
204 |
),
|
205 |
+
'list_authors' => array(
|
206 |
+
'alt' => 'wp_list_authors()',
|
207 |
+
'version' => '2.1.0',
|
208 |
),
|
209 |
+
'list_cats' => array(
|
210 |
+
'alt' => 'wp_list_categories()',
|
211 |
+
'version' => '2.1.0',
|
212 |
),
|
213 |
+
'tinymce_include' => array(
|
214 |
+
'alt' => 'wp_editor()',
|
215 |
+
'version' => '2.1.0',
|
216 |
),
|
217 |
'wp_get_links' => array(
|
218 |
'alt' => 'wp_list_bookmarks()',
|
219 |
+
'version' => '2.1.0',
|
|
|
|
|
|
|
|
|
220 |
),
|
221 |
+
'wp_get_linksbyname' => array(
|
222 |
'alt' => 'wp_list_bookmarks()',
|
223 |
+
'version' => '2.1.0',
|
|
|
|
|
|
|
|
|
224 |
),
|
225 |
+
'wp_get_post_cats' => array(
|
226 |
+
'alt' => 'wp_get_post_categories()',
|
227 |
+
'version' => '2.1.0',
|
|
|
|
|
|
|
|
|
228 |
),
|
229 |
+
'wp_list_cats' => array(
|
230 |
+
'alt' => 'wp_list_categories()',
|
231 |
+
'version' => '2.1.0',
|
232 |
),
|
233 |
+
'wp_set_post_cats' => array(
|
234 |
+
'alt' => 'wp_set_post_categories()',
|
235 |
+
'version' => '2.1.0',
|
236 |
),
|
237 |
|
238 |
+
// WP 2.2.0.
|
239 |
'comments_rss' => array(
|
240 |
'alt' => 'get_post_comments_feed_link()',
|
241 |
+
'version' => '2.2.0',
|
242 |
),
|
243 |
|
244 |
+
// WP 2.3.0.
|
245 |
'permalink_single_rss' => array(
|
246 |
+
'alt' => 'the_permalink_rss()',
|
247 |
+
'version' => '2.3.0',
|
248 |
),
|
249 |
|
250 |
+
// WP 2.5.0.
|
251 |
'comments_rss_link' => array(
|
252 |
'alt' => 'post_comments_feed_link()',
|
253 |
+
'version' => '2.5.0',
|
|
|
|
|
|
|
|
|
254 |
),
|
255 |
+
'documentation_link' => array(
|
256 |
+
'alt' => '',
|
257 |
+
'version' => '2.5.0',
|
258 |
),
|
259 |
+
'get_attachment_icon' => array(
|
260 |
+
'alt' => 'wp_get_attachment_image()',
|
261 |
+
'version' => '2.5.0',
|
262 |
),
|
263 |
'get_attachment_icon_src' => array(
|
264 |
'alt' => 'wp_get_attachment_image_src()',
|
265 |
+
'version' => '2.5.0',
|
|
|
|
|
|
|
|
|
266 |
),
|
267 |
'get_attachment_innerHTML' => array(
|
268 |
'alt' => 'wp_get_attachment_image()',
|
269 |
+
'version' => '2.5.0',
|
270 |
),
|
271 |
+
'get_author_rss_link' => array(
|
272 |
+
'alt' => 'get_author_feed_link()',
|
273 |
+
'version' => '2.5.0',
|
274 |
+
),
|
275 |
+
'get_category_rss_link' => array(
|
276 |
+
'alt' => 'get_category_feed_link()',
|
277 |
+
'version' => '2.5.0',
|
278 |
+
),
|
279 |
+
'get_the_attachment_link' => array(
|
280 |
+
'alt' => 'wp_get_attachment_link()',
|
281 |
+
'version' => '2.5.0',
|
282 |
),
|
283 |
'gzip_compression' => array(
|
284 |
'alt' => '',
|
285 |
+
'version' => '2.5.0',
|
286 |
),
|
287 |
+
'wp_clearcookie' => array(
|
288 |
+
'alt' => 'wp_clear_auth_cookie()',
|
289 |
+
'version' => '2.5.0',
|
290 |
),
|
291 |
'wp_get_cookie_login' => array(
|
292 |
'alt' => '',
|
293 |
+
'version' => '2.5.0',
|
294 |
),
|
295 |
'wp_login' => array(
|
296 |
'alt' => 'wp_signon()',
|
297 |
+
'version' => '2.5.0',
|
298 |
+
),
|
299 |
+
'wp_setcookie' => array(
|
300 |
+
'alt' => 'wp_set_auth_cookie()',
|
301 |
+
'version' => '2.5.0',
|
302 |
),
|
303 |
|
304 |
+
// WP 2.6.0.
|
305 |
'dropdown_categories' => array(
|
306 |
'alt' => 'wp_category_checklist()',
|
307 |
+
'version' => '2.6.0',
|
308 |
),
|
309 |
'dropdown_link_categories' => array(
|
310 |
'alt' => 'wp_link_category_checklist()',
|
311 |
+
'version' => '2.6.0',
|
312 |
),
|
313 |
|
314 |
+
// WP 2.7.0.
|
315 |
'get_commentdata' => array(
|
316 |
'alt' => 'get_comment()',
|
317 |
+
'version' => '2.7.0',
|
318 |
),
|
319 |
// This is a method i.e. WP_Filesystem_Base::find_base_dir() See #731.
|
320 |
'find_base_dir' => array(
|
321 |
'alt' => 'WP_Filesystem::abspath()',
|
322 |
+
'version' => '2.7.0',
|
323 |
),
|
324 |
// This is a method i.e. WP_Filesystem_Base::get_base_dir() See #731.
|
325 |
'get_base_dir' => array(
|
326 |
'alt' => 'WP_Filesystem::abspath()',
|
327 |
+
'version' => '2.7.0',
|
328 |
),
|
329 |
|
330 |
+
// WP 2.8.0.
|
331 |
+
'__ngettext' => array(
|
332 |
+
'alt' => '_n()',
|
333 |
+
'version' => '2.8.0',
|
334 |
+
),
|
335 |
+
'__ngettext_noop' => array(
|
336 |
+
'alt' => '_n_noop()',
|
337 |
+
'version' => '2.8.0',
|
338 |
+
),
|
339 |
+
'attribute_escape' => array(
|
340 |
+
'alt' => 'esc_attr()',
|
341 |
+
'version' => '2.8.0',
|
342 |
+
),
|
343 |
+
'get_author_name' => array(
|
344 |
+
'alt' => 'get_the_author_meta(\'display_name\')',
|
345 |
+
'version' => '2.8.0',
|
346 |
+
),
|
347 |
+
'get_category_children' => array(
|
348 |
+
'alt' => 'get_term_children()',
|
349 |
+
'version' => '2.8.0',
|
350 |
+
),
|
351 |
'get_catname' => array(
|
352 |
'alt' => 'get_cat_name()',
|
353 |
+
'version' => '2.8.0',
|
354 |
),
|
355 |
+
'get_the_author_aim' => array(
|
356 |
+
'alt' => 'get_the_author_meta(\'aim\')',
|
357 |
+
'version' => '2.8.0',
|
358 |
),
|
359 |
'get_the_author_description' => array(
|
360 |
+
'alt' => 'get_the_author_meta(\'description\')',
|
361 |
+
'version' => '2.8.0',
|
|
|
|
|
|
|
|
|
362 |
),
|
363 |
+
'get_the_author_email' => array(
|
364 |
+
'alt' => 'get_the_author_meta(\'email\')',
|
365 |
+
'version' => '2.8.0',
|
366 |
),
|
367 |
'get_the_author_firstname' => array(
|
368 |
'alt' => 'get_the_author_meta(\'first_name\')',
|
369 |
+
'version' => '2.8.0',
|
370 |
),
|
371 |
+
'get_the_author_icq' => array(
|
372 |
+
'alt' => 'get_the_author_meta(\'icq\')',
|
373 |
+
'version' => '2.8.0',
|
374 |
+
),
|
375 |
+
'get_the_author_ID' => array(
|
376 |
+
'alt' => 'get_the_author_meta(\'ID\')',
|
377 |
+
'version' => '2.8.0',
|
378 |
),
|
379 |
'get_the_author_lastname' => array(
|
380 |
'alt' => 'get_the_author_meta(\'last_name\')',
|
381 |
+
'version' => '2.8.0',
|
382 |
),
|
383 |
+
'get_the_author_login' => array(
|
384 |
+
'alt' => 'get_the_author_meta(\'login\')',
|
385 |
+
'version' => '2.8.0',
|
386 |
+
),
|
387 |
+
'get_the_author_msn' => array(
|
388 |
+
'alt' => 'get_the_author_meta(\'msn\')',
|
389 |
+
'version' => '2.8.0',
|
390 |
),
|
391 |
'get_the_author_nickname' => array(
|
392 |
'alt' => 'get_the_author_meta(\'nickname\')',
|
393 |
+
'version' => '2.8.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
),
|
395 |
+
'get_the_author_url' => array(
|
396 |
+
'alt' => 'get_the_author_meta(\'url\')',
|
397 |
+
'version' => '2.8.0',
|
398 |
),
|
399 |
'get_the_author_yim' => array(
|
400 |
'alt' => 'get_the_author_meta(\'yim\')',
|
401 |
+
'version' => '2.8.0',
|
402 |
),
|
403 |
+
'js_escape' => array(
|
404 |
+
'alt' => 'esc_js()',
|
405 |
+
'version' => '2.8.0',
|
406 |
),
|
407 |
+
'register_sidebar_widget' => array(
|
408 |
+
'alt' => 'wp_register_sidebar_widget()',
|
409 |
+
'version' => '2.8.0',
|
410 |
),
|
411 |
+
'register_widget_control' => array(
|
412 |
+
'alt' => 'wp_register_widget_control()',
|
413 |
+
'version' => '2.8.0',
|
414 |
),
|
415 |
+
'sanitize_url' => array(
|
416 |
+
'alt' => 'esc_url_raw()',
|
417 |
+
'version' => '2.8.0',
|
418 |
),
|
419 |
'the_author_aim' => array(
|
420 |
'alt' => 'the_author_meta(\'aim\')',
|
421 |
+
'version' => '2.8.0',
|
422 |
),
|
423 |
+
'the_author_description' => array(
|
424 |
+
'alt' => 'the_author_meta(\'description\')',
|
425 |
+
'version' => '2.8.0',
|
426 |
),
|
427 |
+
'the_author_email' => array(
|
428 |
+
'alt' => 'the_author_meta(\'email\')',
|
429 |
+
'version' => '2.8.0',
|
430 |
),
|
431 |
+
'the_author_firstname' => array(
|
432 |
+
'alt' => 'the_author_meta(\'first_name\')',
|
433 |
+
'version' => '2.8.0',
|
434 |
),
|
435 |
+
'the_author_icq' => array(
|
436 |
+
'alt' => 'the_author_meta(\'icq\')',
|
437 |
+
'version' => '2.8.0',
|
438 |
),
|
439 |
'the_author_ID' => array(
|
440 |
'alt' => 'the_author_meta(\'ID\')',
|
441 |
+
'version' => '2.8.0',
|
442 |
),
|
443 |
+
'the_author_lastname' => array(
|
444 |
+
'alt' => 'the_author_meta(\'last_name\')',
|
445 |
+
'version' => '2.8.0',
|
|
|
|
|
|
|
|
|
446 |
),
|
447 |
+
'the_author_login' => array(
|
448 |
+
'alt' => 'the_author_meta(\'login\')',
|
449 |
+
'version' => '2.8.0',
|
450 |
),
|
451 |
+
'the_author_msn' => array(
|
452 |
+
'alt' => 'the_author_meta(\'msn\')',
|
453 |
+
'version' => '2.8.0',
|
454 |
),
|
455 |
+
'the_author_nickname' => array(
|
456 |
+
'alt' => 'the_author_meta(\'nickname\')',
|
457 |
+
'version' => '2.8.0',
|
458 |
),
|
459 |
+
'the_author_url' => array(
|
460 |
+
'alt' => 'the_author_meta(\'url\')',
|
461 |
+
'version' => '2.8.0',
|
462 |
),
|
463 |
+
'the_author_yim' => array(
|
464 |
+
'alt' => 'the_author_meta(\'yim\')',
|
465 |
+
'version' => '2.8.0',
|
466 |
),
|
467 |
'unregister_sidebar_widget' => array(
|
468 |
'alt' => 'wp_unregister_sidebar_widget()',
|
469 |
+
'version' => '2.8.0',
|
|
|
|
|
|
|
|
|
470 |
),
|
471 |
'unregister_widget_control' => array(
|
472 |
'alt' => 'wp_unregister_widget_control()',
|
473 |
+
'version' => '2.8.0',
|
474 |
+
),
|
475 |
+
'wp_specialchars' => array(
|
476 |
+
'alt' => 'esc_html()',
|
477 |
+
'version' => '2.8.0',
|
478 |
),
|
479 |
|
480 |
+
// WP 2.9.0.
|
481 |
+
'_c' => array(
|
482 |
+
'alt' => '_x()',
|
483 |
+
'version' => '2.9.0',
|
484 |
+
),
|
485 |
+
'_nc' => array(
|
486 |
+
'alt' => '_nx()',
|
487 |
+
'version' => '2.9.0',
|
488 |
+
),
|
489 |
+
'get_real_file_to_edit' => array(
|
490 |
+
'alt' => '',
|
491 |
+
'version' => '2.9.0',
|
492 |
),
|
493 |
'make_url_footnote' => array(
|
494 |
'alt' => '',
|
495 |
+
'version' => '2.9.0',
|
496 |
),
|
497 |
+
'the_content_rss' => array(
|
498 |
+
'alt' => 'the_content_feed()',
|
499 |
+
'version' => '2.9.0',
|
500 |
),
|
|
|
501 |
'translate_with_context' => array(
|
502 |
'alt' => '_x()',
|
503 |
+
'version' => '2.9.0',
|
504 |
),
|
505 |
+
|
506 |
+
// WP 3.0.0.
|
507 |
+
'activate_sitewide_plugin' => array(
|
508 |
+
'alt' => 'activate_plugin()',
|
509 |
+
'version' => '3.0.0',
|
510 |
),
|
511 |
+
'add_option_update_handler' => array(
|
512 |
+
'alt' => 'register_setting()',
|
513 |
+
'version' => '3.0.0',
|
514 |
+
),
|
515 |
+
'automatic_feed_links' => array(
|
516 |
+
'alt' => 'add_theme_support( \'automatic-feed-links\' )',
|
517 |
+
'version' => '3.0.0',
|
518 |
),
|
519 |
'clean_url' => array(
|
520 |
'alt' => 'esc_url()',
|
521 |
+
'version' => '3.0.0',
|
522 |
+
),
|
523 |
+
'clear_global_post_cache' => array(
|
524 |
+
'alt' => 'clean_post_cache()',
|
525 |
+
'version' => '3.0.0',
|
526 |
+
),
|
527 |
+
'codepress_footer_js' => array(
|
528 |
+
'alt' => '',
|
529 |
+
'version' => '3.0.0',
|
530 |
+
),
|
531 |
+
'codepress_get_lang' => array(
|
532 |
+
'alt' => '',
|
533 |
+
'version' => '3.0.0',
|
534 |
+
),
|
535 |
+
'deactivate_sitewide_plugin' => array(
|
536 |
+
'alt' => 'deactivate_plugin()',
|
537 |
+
'version' => '3.0.0',
|
538 |
),
|
539 |
'delete_usermeta' => array(
|
540 |
'alt' => 'delete_user_meta()',
|
541 |
+
'version' => '3.0.0',
|
542 |
),
|
543 |
+
'funky_javascript_callback' => array(
|
544 |
+
'alt' => '',
|
545 |
+
'version' => '3.0.0',
|
546 |
),
|
547 |
+
'funky_javascript_fix' => array(
|
548 |
+
'alt' => '',
|
549 |
+
'version' => '3.0.0',
|
550 |
),
|
551 |
+
'generate_random_password' => array(
|
552 |
+
'alt' => 'wp_generate_password()',
|
553 |
+
'version' => '3.0.0',
|
554 |
+
),
|
555 |
+
'get_alloptions' => array(
|
556 |
+
'alt' => 'wp_load_alloptions()',
|
557 |
+
'version' => '3.0.0',
|
558 |
+
),
|
559 |
+
'get_blog_list' => array(
|
560 |
+
'alt' => 'wp_get_sites()',
|
561 |
+
'version' => '3.0.0',
|
562 |
+
),
|
563 |
+
'get_most_active_blogs' => array(
|
564 |
+
'alt' => '',
|
565 |
+
'version' => '3.0.0',
|
566 |
),
|
567 |
'get_profile' => array(
|
568 |
'alt' => 'get_the_author_meta()',
|
569 |
+
'version' => '3.0.0',
|
570 |
+
),
|
571 |
+
'get_user_details' => array(
|
572 |
+
'alt' => 'get_user_by()',
|
573 |
+
'version' => '3.0.0',
|
574 |
+
),
|
575 |
+
'get_usermeta' => array(
|
576 |
+
'alt' => 'get_user_meta()',
|
577 |
+
'version' => '3.0.0',
|
578 |
),
|
579 |
'get_usernumposts' => array(
|
580 |
'alt' => 'count_user_posts()',
|
581 |
+
'version' => '3.0.0',
|
582 |
),
|
583 |
+
'graceful_fail' => array(
|
584 |
+
'alt' => 'wp_die()',
|
585 |
+
'version' => '3.0.0',
|
586 |
),
|
587 |
+
'is_main_blog' => array(
|
588 |
+
'alt' => 'is_main_site()',
|
589 |
+
'version' => '3.0.0',
|
590 |
+
),
|
591 |
+
'is_site_admin' => array(
|
592 |
+
'alt' => 'is_super_admin()',
|
593 |
+
'version' => '3.0.0',
|
594 |
),
|
595 |
'is_taxonomy' => array(
|
596 |
'alt' => 'taxonomy_exists()',
|
597 |
+
'version' => '3.0.0',
|
598 |
),
|
599 |
'is_term' => array(
|
600 |
'alt' => 'term_exists()',
|
601 |
+
'version' => '3.0.0',
|
602 |
),
|
603 |
+
'is_wpmu_sitewide_plugin' => array(
|
604 |
+
'alt' => 'is_network_only_plugin()',
|
605 |
+
'version' => '3.0.0',
|
606 |
),
|
607 |
+
'mu_options' => array(
|
608 |
+
'alt' => '',
|
609 |
+
'version' => '3.0.0',
|
610 |
),
|
611 |
'remove_option_update_handler' => array(
|
612 |
'alt' => 'unregister_setting()',
|
613 |
+
'version' => '3.0.0',
|
614 |
),
|
615 |
+
'set_current_user' => array(
|
616 |
+
'alt' => 'wp_set_current_user()',
|
617 |
+
'version' => '3.0.0',
|
618 |
),
|
619 |
+
'update_usermeta' => array(
|
620 |
+
'alt' => 'update_user_meta()',
|
621 |
+
'version' => '3.0.0',
|
622 |
),
|
623 |
'use_codepress' => array(
|
624 |
'alt' => '',
|
625 |
+
'version' => '3.0.0',
|
626 |
+
),
|
627 |
+
'validate_email' => array(
|
628 |
+
'alt' => 'is_email()',
|
629 |
+
'version' => '3.0.0',
|
630 |
+
),
|
631 |
+
'wp_dropdown_cats' => array(
|
632 |
+
'alt' => 'wp_dropdown_categories()',
|
633 |
+
'version' => '3.0.0',
|
634 |
),
|
635 |
'wp_shrink_dimensions' => array(
|
636 |
'alt' => 'wp_constrain_dimensions()',
|
637 |
+
'version' => '3.0.0',
|
638 |
),
|
639 |
+
'wpmu_checkAvailableSpace' => array(
|
640 |
+
'alt' => 'is_upload_space_available()',
|
641 |
+
'version' => '3.0.0',
|
|
|
642 |
),
|
643 |
+
'wpmu_menu' => array(
|
644 |
'alt' => '',
|
645 |
+
'version' => '3.0.0',
|
646 |
),
|
647 |
+
|
648 |
+
// WP 3.1.0.
|
649 |
+
'get_author_user_ids' => array(
|
650 |
'alt' => 'get_users()',
|
651 |
+
'version' => '3.1.0',
|
652 |
),
|
653 |
+
'get_dashboard_blog' => array(
|
654 |
'alt' => '',
|
655 |
+
'version' => '3.1.0',
|
656 |
),
|
657 |
'get_editable_authors' => array(
|
658 |
+
'alt' => 'get_users()',
|
659 |
+
'version' => '3.1.0',
|
660 |
),
|
661 |
'get_editable_user_ids' => array(
|
662 |
+
'alt' => 'get_users()',
|
663 |
+
'version' => '3.1.0',
|
664 |
),
|
665 |
'get_nonauthor_user_ids' => array(
|
666 |
+
'alt' => 'get_users()',
|
667 |
+
'version' => '3.1.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
),
|
669 |
'get_others_drafts' => array(
|
670 |
'alt' => '',
|
671 |
+
'version' => '3.1.0',
|
672 |
),
|
673 |
'get_others_pending' => array(
|
674 |
'alt' => '',
|
675 |
+
'version' => '3.1.0',
|
676 |
),
|
677 |
+
'get_others_unpublished_posts' => array(
|
|
|
|
|
|
|
|
|
|
|
678 |
'alt' => '',
|
679 |
+
'version' => '3.1.0',
|
680 |
),
|
681 |
+
'get_users_of_blog' => array(
|
682 |
+
'alt' => 'get_users()',
|
683 |
+
'version' => '3.1.0',
|
684 |
),
|
685 |
+
'install_themes_feature_list' => array(
|
686 |
+
'alt' => 'get_theme_feature_list()',
|
687 |
+
'version' => '3.1.0',
|
688 |
),
|
689 |
+
'is_plugin_page' => array(
|
690 |
+
// Verified correct alternative.
|
691 |
+
'alt' => 'global $plugin_page and/or get_plugin_page_hookname() hooks',
|
692 |
+
'version' => '3.1.0',
|
693 |
),
|
694 |
+
'update_category_cache' => array(
|
695 |
+
'alt' => '',
|
696 |
+
'version' => '3.1.0',
|
697 |
),
|
698 |
+
|
699 |
+
// WP 3.2.0.
|
700 |
'favorite_actions' => array(
|
701 |
'alt' => 'WP_Admin_Bar',
|
702 |
+
'version' => '3.2.0',
|
703 |
),
|
704 |
+
'wp_dashboard_quick_press_output' => array(
|
705 |
+
'alt' => 'wp_dashboard_quick_press()',
|
706 |
+
'version' => '3.2.0',
|
|
|
707 |
),
|
708 |
+
'wp_timezone_supported' => array(
|
709 |
'alt' => '',
|
710 |
+
'version' => '3.2.0',
|
711 |
),
|
712 |
+
|
713 |
+
// WP 3.3.0.
|
714 |
+
'add_contextual_help' => array(
|
715 |
+
'alt' => 'get_current_screen()->add_help_tab()',
|
716 |
+
'version' => '3.3.0',
|
717 |
),
|
718 |
'get_boundary_post_rel_link' => array(
|
719 |
'alt' => '',
|
720 |
+
'version' => '3.3.0',
|
|
|
|
|
|
|
|
|
721 |
),
|
722 |
'get_index_rel_link' => array(
|
723 |
'alt' => '',
|
724 |
+
'version' => '3.3.0',
|
|
|
|
|
|
|
|
|
725 |
),
|
726 |
'get_parent_post_rel_link' => array(
|
727 |
'alt' => '',
|
728 |
+
'version' => '3.3.0',
|
729 |
),
|
730 |
+
'get_user_by_email' => array(
|
731 |
+
'alt' => 'get_user_by(\'email\')',
|
732 |
+
'version' => '3.3.0',
|
733 |
+
),
|
734 |
+
'get_user_metavalues' => array(
|
735 |
'alt' => '',
|
736 |
+
'version' => '3.3.0',
|
737 |
),
|
738 |
+
'get_userdatabylogin' => array(
|
739 |
+
'alt' => 'get_user_by(\'login\')',
|
740 |
+
'version' => '3.3.0',
|
741 |
+
),
|
742 |
+
'index_rel_link' => array(
|
743 |
'alt' => '',
|
744 |
+
'version' => '3.3.0',
|
745 |
),
|
746 |
'is_blog_user' => array(
|
747 |
+
'alt' => 'is_user_member_of_blog()',
|
748 |
+
'version' => '3.3.0',
|
749 |
),
|
750 |
+
'media_upload_audio' => array(
|
751 |
+
'alt' => 'wp_media_upload_handler()',
|
752 |
+
'version' => '3.3.0',
|
753 |
),
|
754 |
+
'media_upload_file' => array(
|
755 |
+
'alt' => 'wp_media_upload_handler()',
|
756 |
+
'version' => '3.3.0',
|
757 |
),
|
758 |
+
'media_upload_image' => array(
|
759 |
+
'alt' => 'wp_media_upload_handler()',
|
760 |
+
'version' => '3.3.0',
|
761 |
+
),
|
762 |
+
'media_upload_video' => array(
|
763 |
+
'alt' => 'wp_media_upload_handler()',
|
764 |
+
'version' => '3.3.0',
|
765 |
+
),
|
766 |
+
'parent_post_rel_link' => array(
|
767 |
+
'alt' => '',
|
768 |
+
'version' => '3.3.0',
|
769 |
+
),
|
770 |
+
'sanitize_user_object' => array(
|
771 |
+
'alt' => '',
|
772 |
+
'version' => '3.3.0',
|
773 |
),
|
774 |
'screen_layout' => array(
|
775 |
'alt' => '$current_screen->render_screen_layout()',
|
776 |
+
'version' => '3.3.0',
|
|
|
|
|
|
|
|
|
777 |
),
|
778 |
'screen_meta' => array(
|
779 |
'alt' => '$current_screen->render_screen_meta()',
|
780 |
+
'version' => '3.3.0',
|
781 |
),
|
782 |
+
'screen_options' => array(
|
783 |
+
'alt' => '$current_screen->render_per_page_options()',
|
784 |
+
'version' => '3.3.0',
|
785 |
),
|
786 |
+
'start_post_rel_link' => array(
|
787 |
+
'alt' => '',
|
788 |
+
'version' => '3.3.0',
|
789 |
),
|
790 |
+
'the_editor' => array(
|
791 |
+
'alt' => 'wp_editor()',
|
792 |
+
'version' => '3.3.0',
|
793 |
),
|
794 |
+
'type_url_form_audio' => array(
|
795 |
+
'alt' => 'wp_media_insert_url_form(\'audio\')',
|
796 |
+
'version' => '3.3.0',
|
797 |
),
|
798 |
+
'type_url_form_file' => array(
|
799 |
+
'alt' => 'wp_media_insert_url_form(\'file\')',
|
800 |
+
'version' => '3.3.0',
|
801 |
),
|
802 |
+
'type_url_form_image' => array(
|
803 |
+
'alt' => 'wp_media_insert_url_form(\'image\')',
|
804 |
+
'version' => '3.3.0',
|
805 |
),
|
806 |
'type_url_form_video' => array(
|
807 |
+
'alt' => 'wp_media_insert_url_form(\'video\')',
|
808 |
+
'version' => '3.3.0',
|
809 |
),
|
810 |
+
'wp_admin_bar_dashboard_view_site_menu' => array(
|
811 |
+
'alt' => '',
|
812 |
+
'version' => '3.3.0',
|
813 |
),
|
814 |
+
'wp_preload_dialogs' => array(
|
815 |
+
'alt' => 'wp_editor()',
|
816 |
+
'version' => '3.3.0',
|
817 |
),
|
818 |
+
'wp_print_editor_js' => array(
|
819 |
+
'alt' => 'wp_editor()',
|
820 |
+
'version' => '3.3.0',
|
|
|
821 |
),
|
822 |
+
'wp_quicktags' => array(
|
823 |
+
'alt' => 'wp_editor()',
|
824 |
+
'version' => '3.3.0',
|
825 |
),
|
826 |
+
'wp_tiny_mce' => array(
|
827 |
+
'alt' => 'wp_editor()',
|
828 |
+
'version' => '3.3.0',
|
829 |
),
|
830 |
+
'wpmu_admin_do_redirect' => array(
|
831 |
'alt' => '',
|
832 |
+
'version' => '3.3.0',
|
|
|
|
|
|
|
|
|
833 |
),
|
834 |
+
'wpmu_admin_redirect_add_updated_param' => array(
|
835 |
+
'alt' => '',
|
836 |
+
'version' => '3.3.0',
|
837 |
),
|
838 |
+
|
839 |
+
// WP 3.4.0.
|
840 |
'add_custom_background' => array(
|
841 |
'alt' => 'add_theme_support( \'custom-background\', $args )',
|
842 |
+
'version' => '3.4.0',
|
843 |
),
|
844 |
+
'add_custom_image_header' => array(
|
845 |
+
'alt' => 'add_theme_support( \'custom-header\', $args )',
|
846 |
+
'version' => '3.4.0',
|
847 |
),
|
848 |
+
'clean_page_cache' => array(
|
849 |
+
'alt' => 'clean_post_cache()',
|
850 |
+
'version' => '3.4.0',
|
851 |
+
),
|
852 |
+
'clean_pre' => array(
|
853 |
+
'alt' => '',
|
854 |
+
'version' => '3.4.0',
|
855 |
+
),
|
856 |
+
'current_theme_info' => array(
|
857 |
'alt' => 'wp_get_theme()',
|
858 |
+
'version' => '3.4.0',
|
859 |
),
|
860 |
+
'debug_fclose' => array(
|
861 |
+
'alt' => 'error_log()',
|
862 |
+
'version' => '3.4.0',
|
863 |
),
|
864 |
+
'debug_fopen' => array(
|
865 |
+
'alt' => 'error_log()',
|
866 |
+
'version' => '3.4.0',
|
867 |
+
),
|
868 |
+
'debug_fwrite' => array(
|
869 |
+
'alt' => 'error_log()',
|
870 |
+
'version' => '3.4.0',
|
871 |
+
),
|
872 |
+
'display_theme' => array(
|
873 |
+
'alt' => '',
|
874 |
+
'version' => '3.4.0',
|
875 |
),
|
876 |
'get_allowed_themes' => array(
|
877 |
'alt' => 'wp_get_themes( array( \'allowed\' => true ) )',
|
878 |
+
'version' => '3.4.0',
|
879 |
),
|
880 |
'get_broken_themes' => array(
|
881 |
'alt' => 'wp_get_themes( array( \'errors\' => true )',
|
882 |
+
'version' => '3.4.0',
|
883 |
),
|
884 |
+
'get_current_theme' => array(
|
885 |
+
'alt' => 'wp_get_theme()',
|
886 |
+
'version' => '3.4.0',
|
887 |
+
),
|
888 |
+
'get_site_allowed_themes' => array(
|
889 |
+
'alt' => 'WP_Theme::get_allowed_on_network()',
|
890 |
+
'version' => '3.4.0',
|
891 |
+
),
|
892 |
+
'get_theme' => array(
|
893 |
+
'alt' => 'wp_get_theme( $stylesheet )',
|
894 |
+
'version' => '3.4.0',
|
895 |
+
),
|
896 |
+
'get_theme_data' => array(
|
897 |
'alt' => 'wp_get_theme()',
|
898 |
+
'version' => '3.4.0',
|
899 |
+
),
|
900 |
+
'get_themes' => array(
|
901 |
+
'alt' => 'wp_get_themes()',
|
902 |
+
'version' => '3.4.0',
|
903 |
),
|
904 |
+
'logIO' => array(
|
905 |
+
'alt' => 'error_log()',
|
906 |
+
'version' => '3.4.0',
|
907 |
+
),
|
908 |
+
'remove_custom_background' => array(
|
909 |
+
'alt' => 'remove_theme_support( \'custom-background\' )',
|
910 |
+
'version' => '3.4.0',
|
911 |
+
),
|
912 |
+
'remove_custom_image_header' => array(
|
913 |
+
'alt' => 'remove_theme_support( \'custom-header\' )',
|
914 |
+
'version' => '3.4.0',
|
915 |
+
),
|
916 |
+
'update_page_cache' => array(
|
917 |
+
'alt' => 'update_post_cache()',
|
918 |
+
'version' => '3.4.0',
|
919 |
+
),
|
920 |
+
'wpmu_get_blog_allowedthemes' => array(
|
921 |
+
'alt' => 'WP_Theme::get_allowed_on_site()',
|
922 |
+
'version' => '3.4.0',
|
923 |
+
),
|
924 |
+
|
925 |
+
// WP 3.4.1.
|
926 |
'wp_explain_nonce' => array(
|
927 |
+
'alt' => 'wp_nonce_ays()',
|
928 |
'version' => '3.4.1',
|
929 |
),
|
930 |
|
931 |
+
// WP 3.5.0.
|
932 |
+
'_flip_image_resource' => array(
|
933 |
+
'alt' => 'WP_Image_Editor::flip()',
|
934 |
+
'version' => '3.5.0',
|
935 |
),
|
936 |
'_get_post_ancestors' => array(
|
937 |
'alt' => '',
|
938 |
+
'version' => '3.5.0',
|
|
|
|
|
|
|
|
|
939 |
),
|
940 |
+
'_insert_into_post_button' => array(
|
941 |
+
'alt' => '',
|
942 |
+
'version' => '3.5.0',
|
943 |
),
|
944 |
+
'_media_button' => array(
|
945 |
+
'alt' => '',
|
946 |
+
'version' => '3.5.0',
|
947 |
),
|
948 |
+
'_rotate_image_resource' => array(
|
949 |
+
'alt' => 'WP_Image_Editor::rotate()',
|
950 |
+
'version' => '3.5.0',
|
951 |
),
|
952 |
'_save_post_hook' => array(
|
953 |
'alt' => '',
|
954 |
+
'version' => '3.5.0',
|
955 |
),
|
956 |
'gd_edit_image_support' => array(
|
957 |
+
'alt' => 'wp_image_editor_supports()',
|
958 |
+
'version' => '3.5.0',
|
959 |
),
|
960 |
+
'get_default_page_to_edit' => array(
|
961 |
+
'alt' => 'get_default_post_to_edit( \'page\' )',
|
962 |
+
'version' => '3.5.0',
|
|
|
|
|
|
|
|
|
963 |
),
|
964 |
'get_post_to_edit' => array(
|
965 |
'alt' => 'get_post()',
|
966 |
+
'version' => '3.5.0',
|
967 |
),
|
968 |
+
'get_udims' => array(
|
969 |
+
'alt' => 'wp_constrain_dimensions()',
|
970 |
+
'version' => '3.5.0',
|
971 |
+
),
|
972 |
+
'image_resize' => array(
|
973 |
+
'alt' => 'wp_get_image_editor()',
|
974 |
+
'version' => '3.5.0',
|
975 |
+
),
|
976 |
+
'sticky_class' => array(
|
977 |
+
'alt' => 'post_class()',
|
978 |
+
'version' => '3.5.0',
|
979 |
+
),
|
980 |
+
'user_pass_ok' => array(
|
981 |
+
'alt' => 'wp_authenticate()',
|
982 |
+
'version' => '3.5.0',
|
983 |
+
),
|
984 |
+
'wp_cache_reset' => array(
|
985 |
+
'alt' => '',
|
986 |
+
'version' => '3.5.0',
|
987 |
),
|
988 |
'wp_create_thumbnail' => array(
|
989 |
'alt' => 'image_resize()',
|
990 |
+
'version' => '3.5.0',
|
991 |
+
),
|
992 |
+
'wp_get_single_post' => array(
|
993 |
+
'alt' => 'get_post()',
|
994 |
+
'version' => '3.5.0',
|
995 |
+
),
|
996 |
+
'wp_load_image' => array(
|
997 |
+
'alt' => 'wp_get_image_editor()',
|
998 |
+
'version' => '3.5.0',
|
999 |
),
|
1000 |
|
1001 |
+
// WP 3.6.0.
|
1002 |
'get_user_id_from_string' => array(
|
1003 |
'alt' => 'get_user_by()',
|
1004 |
+
'version' => '3.6.0',
|
1005 |
),
|
1006 |
'wp_convert_bytes_to_hr' => array(
|
1007 |
'alt' => 'size_format()',
|
1008 |
+
'version' => '3.6.0',
|
1009 |
),
|
1010 |
'wp_nav_menu_locations_meta_box' => array(
|
1011 |
'alt' => '',
|
1012 |
+
'version' => '3.6.0',
|
1013 |
),
|
1014 |
|
1015 |
+
// WP 3.7.0.
|
1016 |
+
'_search_terms_tidy' => array(
|
1017 |
+
'alt' => '',
|
1018 |
+
'version' => '3.7.0',
|
1019 |
+
),
|
1020 |
+
'get_blogaddress_by_domain' => array(
|
1021 |
+
'alt' => '',
|
1022 |
+
'version' => '3.7.0',
|
1023 |
+
),
|
1024 |
'the_attachment_links' => array(
|
1025 |
'alt' => '',
|
1026 |
+
'version' => '3.7.0',
|
1027 |
),
|
1028 |
'wp_update_core' => array(
|
1029 |
+
'alt' => 'new Core_Upgrader();',
|
1030 |
+
'version' => '3.7.0',
|
1031 |
),
|
1032 |
'wp_update_plugin' => array(
|
1033 |
+
'alt' => 'new Plugin_Upgrader();',
|
1034 |
+
'version' => '3.7.0',
|
1035 |
),
|
1036 |
'wp_update_theme' => array(
|
1037 |
+
'alt' => 'new Theme_Upgrader();',
|
1038 |
+
'version' => '3.7.0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
),
|
1040 |
|
1041 |
+
// WP 3.8.0.
|
1042 |
'get_screen_icon' => array(
|
1043 |
'alt' => '',
|
1044 |
+
'version' => '3.8.0',
|
1045 |
),
|
1046 |
'screen_icon' => array(
|
1047 |
'alt' => '',
|
1048 |
+
'version' => '3.8.0',
|
1049 |
),
|
1050 |
'wp_dashboard_incoming_links' => array(
|
1051 |
'alt' => '',
|
1052 |
+
'version' => '3.8.0',
|
1053 |
),
|
1054 |
'wp_dashboard_incoming_links_control' => array(
|
1055 |
'alt' => '',
|
1056 |
+
'version' => '3.8.0',
|
1057 |
),
|
1058 |
'wp_dashboard_incoming_links_output' => array(
|
1059 |
'alt' => '',
|
1060 |
+
'version' => '3.8.0',
|
1061 |
),
|
1062 |
'wp_dashboard_plugins' => array(
|
1063 |
'alt' => '',
|
1064 |
+
'version' => '3.8.0',
|
1065 |
),
|
1066 |
'wp_dashboard_primary_control' => array(
|
1067 |
'alt' => '',
|
1068 |
+
'version' => '3.8.0',
|
1069 |
),
|
1070 |
'wp_dashboard_recent_comments_control' => array(
|
1071 |
'alt' => '',
|
1072 |
+
'version' => '3.8.0',
|
1073 |
),
|
1074 |
'wp_dashboard_secondary' => array(
|
1075 |
'alt' => '',
|
1076 |
+
'version' => '3.8.0',
|
1077 |
),
|
1078 |
'wp_dashboard_secondary_control' => array(
|
1079 |
'alt' => '',
|
1080 |
+
'version' => '3.8.0',
|
1081 |
),
|
1082 |
'wp_dashboard_secondary_output' => array(
|
1083 |
'alt' => '',
|
1084 |
+
'version' => '3.8.0',
|
1085 |
),
|
1086 |
|
1087 |
+
// WP 3.9.0.
|
1088 |
+
'_relocate_children' => array(
|
1089 |
'alt' => '',
|
1090 |
+
'version' => '3.9.0',
|
1091 |
),
|
1092 |
'default_topic_count_text' => array(
|
1093 |
'alt' => '',
|
1094 |
+
'version' => '3.9.0',
|
1095 |
),
|
1096 |
'format_to_post' => array(
|
1097 |
'alt' => '',
|
1098 |
+
'version' => '3.9.0',
|
1099 |
),
|
1100 |
'get_current_site_name' => array(
|
1101 |
'alt' => 'get_current_site()',
|
1102 |
+
'version' => '3.9.0',
|
1103 |
),
|
1104 |
+
'rich_edit_exists' => array(
|
1105 |
'alt' => '',
|
1106 |
+
'version' => '3.9.0',
|
1107 |
),
|
1108 |
+
'wpmu_current_site' => array(
|
1109 |
'alt' => '',
|
1110 |
+
'version' => '3.9.0',
|
1111 |
),
|
1112 |
|
1113 |
+
// WP 4.0.0.
|
1114 |
'get_all_category_ids' => array(
|
1115 |
'alt' => 'get_terms()',
|
1116 |
+
'version' => '4.0.0',
|
1117 |
),
|
1118 |
'like_escape' => array(
|
1119 |
'alt' => 'wpdb::esc_like()',
|
1120 |
+
'version' => '4.0.0',
|
1121 |
),
|
1122 |
'url_is_accessable_via_ssl' => array(
|
1123 |
'alt' => '',
|
1124 |
+
'version' => '4.0.0',
|
1125 |
),
|
1126 |
|
1127 |
+
// WP 4.1.0.
|
1128 |
+
// This is a method from the WP_Customize_Image_Control class. See #731.
|
|
|
|
|
1129 |
'add_tab' => array(
|
1130 |
'alt' => '',
|
1131 |
+
'version' => '4.1.0',
|
1132 |
),
|
1133 |
+
// This is a method from the WP_Customize_Image_Control class. See #731.
|
1134 |
+
'prepare_control' => array(
|
1135 |
'alt' => '',
|
1136 |
+
'version' => '4.1.0',
|
1137 |
),
|
1138 |
+
// This is a method from the WP_Customize_Image_Control class. See #731.
|
1139 |
'print_tab_image' => array(
|
1140 |
'alt' => '',
|
1141 |
+
'version' => '4.1.0',
|
1142 |
),
|
1143 |
+
// This is a method from the WP_Customize_Image_Control class. See #731.
|
1144 |
+
'remove_tab' => array(
|
1145 |
+
'alt' => '',
|
1146 |
+
'version' => '4.1.0',
|
1147 |
),
|
1148 |
+
|
1149 |
+
// WP 4.2.0.
|
1150 |
+
// This is a method from the WP_Customize_Widgets class. See #731.
|
1151 |
'prepreview_added_sidebars_widgets' => array(
|
1152 |
+
'alt' => 'the \'customize_dynamic_setting_args\' filter',
|
1153 |
+
'version' => '4.2.0',
|
1154 |
),
|
1155 |
+
// This is a method from the WP_Customize_Widgets class. See #731.
|
1156 |
'prepreview_added_widget_instance' => array(
|
1157 |
+
'alt' => 'the \'customize_dynamic_setting_args\' filter',
|
1158 |
+
'version' => '4.2.0',
|
1159 |
),
|
1160 |
+
// This is a method from the WP_Customize_Widgets class. See #731.
|
1161 |
'remove_prepreview_filters' => array(
|
1162 |
+
'alt' => 'the \'customize_dynamic_setting_args\' filter',
|
1163 |
+
'version' => '4.2.0',
|
1164 |
+
),
|
1165 |
+
// This is a method from the WP_Customize_Widgets class. See #731.
|
1166 |
+
'setup_widget_addition_previews' => array(
|
1167 |
+
'alt' => 'the \'customize_dynamic_setting_args\' filter',
|
1168 |
+
'version' => '4.2.0',
|
1169 |
),
|
1170 |
|
1171 |
+
// WP 4.3.0.
|
1172 |
+
'_preview_theme_stylesheet_filter' => array(
|
1173 |
'alt' => '',
|
1174 |
+
'version' => '4.3.0',
|
1175 |
),
|
1176 |
'_preview_theme_template_filter' => array(
|
1177 |
'alt' => '',
|
1178 |
+
'version' => '4.3.0',
|
1179 |
),
|
1180 |
+
'preview_theme' => array(
|
1181 |
'alt' => '',
|
1182 |
+
'version' => '4.3.0',
|
1183 |
),
|
1184 |
'preview_theme_ob_filter' => array(
|
1185 |
'alt' => '',
|
1186 |
+
'version' => '4.3.0',
|
1187 |
),
|
1188 |
'preview_theme_ob_filter_callback' => array(
|
1189 |
'alt' => '',
|
1190 |
+
'version' => '4.3.0',
|
1191 |
),
|
1192 |
+
'wp_ajax_wp_fullscreen_save_post' => array(
|
1193 |
'alt' => '',
|
1194 |
+
'version' => '4.3.0',
|
1195 |
),
|
1196 |
'wp_htmledit_pre' => array(
|
1197 |
+
'alt' => 'format_for_editor()',
|
1198 |
+
'version' => '4.3.0',
|
1199 |
),
|
1200 |
+
'wp_richedit_pre' => array(
|
1201 |
+
'alt' => 'format_for_editor()',
|
1202 |
+
'version' => '4.3.0',
|
1203 |
),
|
1204 |
|
1205 |
+
// WP 4.4.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1206 |
'create_empty_blog' => array(
|
1207 |
'alt' => '',
|
1208 |
+
'version' => '4.4.0',
|
1209 |
+
),
|
1210 |
+
'force_ssl_login' => array(
|
1211 |
+
'alt' => 'force_ssl_admin()',
|
1212 |
+
'version' => '4.4.0',
|
1213 |
),
|
1214 |
'get_admin_users_for_domain' => array(
|
1215 |
'alt' => '',
|
1216 |
+
'version' => '4.4.0',
|
1217 |
+
),
|
1218 |
+
'post_permalink' => array(
|
1219 |
+
'alt' => 'get_permalink()',
|
1220 |
+
'version' => '4.4.0',
|
1221 |
),
|
1222 |
'wp_get_http' => array(
|
1223 |
+
'alt' => 'the WP_Http class',
|
1224 |
+
'version' => '4.4.0',
|
1225 |
),
|
1226 |
// This is a method i.e. WP_Widget_Recent_Comments::flush_widget_cache() See #731.
|
1227 |
'flush_widget_cache' => array(
|
1228 |
'alt' => '',
|
1229 |
+
'version' => '4.4.0',
|
1230 |
),
|
1231 |
|
1232 |
+
// WP 4.5.0.
|
|
|
|
|
|
|
1233 |
'add_object_page' => array(
|
1234 |
'alt' => 'add_menu_page()',
|
1235 |
+
'version' => '4.5.0',
|
1236 |
),
|
1237 |
'add_utility_page' => array(
|
1238 |
'alt' => 'add_menu_page()',
|
1239 |
+
'version' => '4.5.0',
|
|
|
|
|
|
|
|
|
1240 |
),
|
1241 |
'comments_popup_script' => array(
|
1242 |
'alt' => '',
|
1243 |
+
'version' => '4.5.0',
|
1244 |
),
|
1245 |
+
'get_comments_popup_template' => array(
|
1246 |
'alt' => '',
|
1247 |
+
'version' => '4.5.0',
|
1248 |
),
|
1249 |
'get_currentuserinfo' => array(
|
1250 |
'alt' => 'wp_get_current_user()',
|
1251 |
+
'version' => '4.5.0',
|
1252 |
+
),
|
1253 |
+
'is_comments_popup' => array(
|
1254 |
+
'alt' => '',
|
1255 |
+
'version' => '4.5.0',
|
1256 |
+
),
|
1257 |
+
'popuplinks' => array(
|
1258 |
+
'alt' => '',
|
1259 |
+
'version' => '4.5.0',
|
1260 |
),
|
1261 |
|
1262 |
+
// WP 4.6.0.
|
1263 |
+
'post_form_autocomplete_off' => array(
|
1264 |
+
'alt' => '',
|
1265 |
+
'version' => '4.6.0',
|
1266 |
+
),
|
1267 |
'wp_embed_handler_googlevideo' => array(
|
1268 |
'alt' => '',
|
1269 |
+
'version' => '4.6.0',
|
1270 |
),
|
1271 |
'wp_get_sites' => array(
|
1272 |
'alt' => 'get_sites()',
|
1273 |
+
'version' => '4.6.0',
|
1274 |
+
),
|
1275 |
+
|
1276 |
+
// WP 4.7.0.
|
1277 |
+
'_sort_nav_menu_items' => array(
|
1278 |
+
'alt' => 'wp_list_sort()',
|
1279 |
+
'version' => '4.7.0',
|
1280 |
+
),
|
1281 |
+
'_usort_terms_by_ID' => array(
|
1282 |
+
'alt' => 'wp_list_sort()',
|
1283 |
+
'version' => '4.7.0',
|
1284 |
+
),
|
1285 |
+
'_usort_terms_by_name' => array(
|
1286 |
+
'alt' => 'wp_list_sort()',
|
1287 |
+
'version' => '4.7.0',
|
1288 |
+
),
|
1289 |
+
'get_paged_template' => array(
|
1290 |
+
'alt' => '',
|
1291 |
+
'version' => '4.7.0',
|
1292 |
+
),
|
1293 |
+
'wp_get_network' => array(
|
1294 |
+
'alt' => 'get_network()',
|
1295 |
+
'version' => '4.7.0',
|
1296 |
+
),
|
1297 |
+
'wp_kses_js_entities' => array(
|
1298 |
+
'alt' => '',
|
1299 |
+
'version' => '4.7.0',
|
1300 |
),
|
1301 |
|
1302 |
+
// WP 4.8.0.
|
1303 |
+
'wp_dashboard_plugins_output' => array(
|
1304 |
+
'alt' => '',
|
1305 |
+
'version' => '4.8.0',
|
1306 |
+
),
|
1307 |
);
|
1308 |
|
1309 |
/**
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParametersSniff.php
ADDED
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Check for usage of deprecated parameters in WP functions and suggest alternative based on the parameter passed.
|
12 |
+
*
|
13 |
+
* This sniff will throw an error when usage of deprecated parameters is
|
14 |
+
* detected if the parameter was deprecated before the minimum supported
|
15 |
+
* WP version; a warning otherwise.
|
16 |
+
* By default, it is set to presume that a project will support the current
|
17 |
+
* WP version and up to three releases before.
|
18 |
+
*
|
19 |
+
* @package WPCS\WordPressCodingStandards
|
20 |
+
*
|
21 |
+
* @since 0.12.0
|
22 |
+
*/
|
23 |
+
class WordPress_Sniffs_WP_DeprecatedParametersSniff extends WordPress_AbstractFunctionParameterSniff {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* The group name for this group of functions.
|
27 |
+
*
|
28 |
+
* @since 0.12.0
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $group_name = 'wp_deprecated_parameters';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Minimum WordPress version.
|
36 |
+
*
|
37 |
+
* This variable allows changing the minimum supported WP version used by
|
38 |
+
* this sniff by setting a property in a custom ruleset XML file.
|
39 |
+
*
|
40 |
+
* Example usage:
|
41 |
+
* <rule ref="WordPress.WP.DeprecatedParameters">
|
42 |
+
* <properties>
|
43 |
+
* <property name="minimum_supported_version" value="4.5"/>
|
44 |
+
* </properties>
|
45 |
+
* </rule>
|
46 |
+
*
|
47 |
+
* @since 0.12.0
|
48 |
+
*
|
49 |
+
* @var string WordPress version.
|
50 |
+
*/
|
51 |
+
public $minimum_supported_version = 4.5;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Array of function, argument, and default value for deprecated argument.
|
55 |
+
*
|
56 |
+
* The functions are ordered alphabetically.
|
57 |
+
* Last updated for WordPress 4.8.0.
|
58 |
+
*
|
59 |
+
* @since 0.12.0
|
60 |
+
*
|
61 |
+
* @var array Multidimensional array with parameter details.
|
62 |
+
* $target_functions = array(
|
63 |
+
* (string) Function name. => array(
|
64 |
+
* (int) Target parameter position, 1-based. => array(
|
65 |
+
* 'value' => (mixed) Expected default value for the
|
66 |
+
* deprecated parameter. Currently the default
|
67 |
+
* values: true, false, null, empty arrays and
|
68 |
+
* both empty and non-empty strings can be
|
69 |
+
* handled correctly by the process_parameters()
|
70 |
+
* method. When an additional default value is
|
71 |
+
* added, the relevant code in the
|
72 |
+
* process_parameters() method will need to be
|
73 |
+
* adjusted.
|
74 |
+
* 'version' => (int) The WordPress version when deprecated.
|
75 |
+
* )
|
76 |
+
* )
|
77 |
+
* );
|
78 |
+
*/
|
79 |
+
protected $target_functions = array(
|
80 |
+
|
81 |
+
'add_option' => array(
|
82 |
+
3 => array(
|
83 |
+
'value' => '',
|
84 |
+
'version' => '2.3.0',
|
85 |
+
),
|
86 |
+
),
|
87 |
+
'comments_link' => array(
|
88 |
+
1 => array(
|
89 |
+
'value' => '',
|
90 |
+
'version' => '0.72',
|
91 |
+
),
|
92 |
+
2 => array(
|
93 |
+
'value' => '',
|
94 |
+
'version' => '1.3.0',
|
95 |
+
),
|
96 |
+
),
|
97 |
+
'comments_number' => array(
|
98 |
+
4 => array(
|
99 |
+
'value' => '',
|
100 |
+
'version' => '1.3.0',
|
101 |
+
),
|
102 |
+
),
|
103 |
+
'convert_chars' => array(
|
104 |
+
2 => array(
|
105 |
+
'value' => '',
|
106 |
+
'version' => '0.71',
|
107 |
+
),
|
108 |
+
),
|
109 |
+
'discover_pingback_server_uri' => array(
|
110 |
+
2 => array(
|
111 |
+
'value' => '',
|
112 |
+
'version' => '2.7.0',
|
113 |
+
),
|
114 |
+
),
|
115 |
+
'get_category_parents' => array(
|
116 |
+
5 => array(
|
117 |
+
'value' => array(),
|
118 |
+
'version' => '4.8.0',
|
119 |
+
),
|
120 |
+
),
|
121 |
+
'get_delete_post_link' => array(
|
122 |
+
2 => array(
|
123 |
+
'value' => '',
|
124 |
+
'version' => '3.0.0',
|
125 |
+
),
|
126 |
+
),
|
127 |
+
'get_last_updated' => array(
|
128 |
+
1 => array(
|
129 |
+
'value' => '',
|
130 |
+
'version' => '3.0.0', // Was previously part of MU.
|
131 |
+
),
|
132 |
+
),
|
133 |
+
'get_the_author' => array(
|
134 |
+
1 => array(
|
135 |
+
'value' => '',
|
136 |
+
'version' => '2.1.0',
|
137 |
+
),
|
138 |
+
),
|
139 |
+
'get_user_option' => array(
|
140 |
+
3 => array(
|
141 |
+
'value' => '',
|
142 |
+
'version' => '2.3.0',
|
143 |
+
),
|
144 |
+
),
|
145 |
+
'get_wp_title_rss' => array(
|
146 |
+
1 => array(
|
147 |
+
'value' => '–',
|
148 |
+
'version' => '4.4.0',
|
149 |
+
),
|
150 |
+
),
|
151 |
+
'is_email' => array(
|
152 |
+
2 => array(
|
153 |
+
'value' => false,
|
154 |
+
'version' => '3.0.0',
|
155 |
+
),
|
156 |
+
),
|
157 |
+
'load_plugin_textdomain' => array(
|
158 |
+
2 => array(
|
159 |
+
'value' => false,
|
160 |
+
'version' => '2.7.0',
|
161 |
+
),
|
162 |
+
),
|
163 |
+
'safecss_filter_attr' => array(
|
164 |
+
2 => array(
|
165 |
+
'value' => '',
|
166 |
+
'version' => '2.8.1',
|
167 |
+
),
|
168 |
+
),
|
169 |
+
'the_attachment_link' => array(
|
170 |
+
3 => array(
|
171 |
+
'value' => false,
|
172 |
+
'version' => '2.5.0',
|
173 |
+
),
|
174 |
+
),
|
175 |
+
'the_author' => array(
|
176 |
+
1 => array(
|
177 |
+
'value' => '',
|
178 |
+
'version' => '2.1.0',
|
179 |
+
),
|
180 |
+
2 => array(
|
181 |
+
'value' => true,
|
182 |
+
'version' => '1.5.0',
|
183 |
+
),
|
184 |
+
),
|
185 |
+
'the_author_posts_link' => array(
|
186 |
+
1 => array(
|
187 |
+
'value' => '',
|
188 |
+
'version' => '2.1.0',
|
189 |
+
),
|
190 |
+
),
|
191 |
+
'trackback_rdf' => array(
|
192 |
+
1 => array(
|
193 |
+
'value' => '',
|
194 |
+
'version' => '2.5.0',
|
195 |
+
),
|
196 |
+
),
|
197 |
+
'trackback_url' => array(
|
198 |
+
1 => array(
|
199 |
+
'value' => true,
|
200 |
+
'version' => '2.5.0',
|
201 |
+
),
|
202 |
+
),
|
203 |
+
'update_blog_option' => array(
|
204 |
+
4 => array(
|
205 |
+
'value' => null,
|
206 |
+
'version' => '3.1.0',
|
207 |
+
),
|
208 |
+
),
|
209 |
+
'update_blog_status' => array(
|
210 |
+
4 => array(
|
211 |
+
'value' => null,
|
212 |
+
'version' => '3.1.0',
|
213 |
+
),
|
214 |
+
),
|
215 |
+
'update_user_status' => array(
|
216 |
+
4 => array(
|
217 |
+
'value' => null,
|
218 |
+
'version' => '3.0.2',
|
219 |
+
),
|
220 |
+
),
|
221 |
+
'unregister_setting' => array(
|
222 |
+
4 => array(
|
223 |
+
'value' => '',
|
224 |
+
'version' => '4.7.0',
|
225 |
+
),
|
226 |
+
),
|
227 |
+
'wp_get_http_headers' => array(
|
228 |
+
2 => array(
|
229 |
+
'value' => false,
|
230 |
+
'version' => '2.7.0',
|
231 |
+
),
|
232 |
+
),
|
233 |
+
'wp_get_sidebars_widgets' => array(
|
234 |
+
1 => array(
|
235 |
+
'value' => true,
|
236 |
+
'version' => '2.8.1',
|
237 |
+
),
|
238 |
+
),
|
239 |
+
'wp_install' => array(
|
240 |
+
5 => array(
|
241 |
+
'value' => '',
|
242 |
+
'version' => '2.6.0',
|
243 |
+
),
|
244 |
+
),
|
245 |
+
'wp_new_user_notification' => array(
|
246 |
+
2 => array(
|
247 |
+
'value' => null,
|
248 |
+
'version' => '4.3.1',
|
249 |
+
),
|
250 |
+
),
|
251 |
+
'wp_notify_postauthor' => array(
|
252 |
+
2 => array(
|
253 |
+
'value' => null,
|
254 |
+
'version' => '3.8.0',
|
255 |
+
),
|
256 |
+
),
|
257 |
+
'wp_title_rss' => array(
|
258 |
+
1 => array(
|
259 |
+
'value' => '–',
|
260 |
+
'version' => '4.4.0',
|
261 |
+
),
|
262 |
+
),
|
263 |
+
'wp_upload_bits' => array(
|
264 |
+
2 => array(
|
265 |
+
'value' => '',
|
266 |
+
'version' => '2.0.0',
|
267 |
+
),
|
268 |
+
),
|
269 |
+
'xfn_check' => array(
|
270 |
+
3 => array(
|
271 |
+
'value' => '',
|
272 |
+
'version' => '2.5.0',
|
273 |
+
),
|
274 |
+
),
|
275 |
+
|
276 |
+
); // End $target_functions.
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Process the parameters of a matched function.
|
280 |
+
*
|
281 |
+
* @since 0.12.0
|
282 |
+
*
|
283 |
+
* @param int $stackPtr The position of the current token in the stack.
|
284 |
+
* @param array $group_name The name of the group which was matched.
|
285 |
+
* @param string $matched_content The token content (function name) which was matched.
|
286 |
+
* @param array $parameters Array with information about the parameters.
|
287 |
+
*
|
288 |
+
* @return void
|
289 |
+
*/
|
290 |
+
public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
|
291 |
+
$paramCount = count( $parameters );
|
292 |
+
foreach ( $this->target_functions[ $matched_content ] as $position => $parameter_args ) {
|
293 |
+
|
294 |
+
// Check that number of parameters defined is not less than the position to check.
|
295 |
+
if ( $position > $paramCount ) {
|
296 |
+
break;
|
297 |
+
}
|
298 |
+
|
299 |
+
// The list will need to updated if the default value is not supported.
|
300 |
+
switch ( $parameters[ $position ]['raw'] ) {
|
301 |
+
case 'true':
|
302 |
+
$matched_parameter = true;
|
303 |
+
break;
|
304 |
+
case 'false':
|
305 |
+
$matched_parameter = false;
|
306 |
+
break;
|
307 |
+
case 'null':
|
308 |
+
$matched_parameter = null;
|
309 |
+
break;
|
310 |
+
case 'array()':
|
311 |
+
case '[]':
|
312 |
+
$matched_parameter = array();
|
313 |
+
break;
|
314 |
+
default:
|
315 |
+
$matched_parameter = $this->strip_quotes( $parameters[ $position ]['raw'] );
|
316 |
+
break;
|
317 |
+
}
|
318 |
+
|
319 |
+
if ( $parameter_args['value'] === $matched_parameter ) {
|
320 |
+
continue;
|
321 |
+
}
|
322 |
+
|
323 |
+
$message = 'The parameter "%s" at position #%s of %s() has been deprecated since WordPress version %s.';
|
324 |
+
$is_error = version_compare( $parameter_args['version'], $this->minimum_supported_version, '<' );
|
325 |
+
$code = $this->string_to_errorcode( ucfirst( $matched_content ) . 'Param' . $position . 'Found' );
|
326 |
+
|
327 |
+
$data = array(
|
328 |
+
$parameters[ $position ]['raw'],
|
329 |
+
$position,
|
330 |
+
$matched_content,
|
331 |
+
$parameter_args['version'],
|
332 |
+
);
|
333 |
+
|
334 |
+
if ( isset( $parameter_args['value'] ) && $position < $paramCount ) {
|
335 |
+
$message .= ' Use "%s" instead.';
|
336 |
+
$data[] = (string) $parameter_args['value'];
|
337 |
+
} else {
|
338 |
+
$message .= ' Instead do not pass the parameter.';
|
339 |
+
}
|
340 |
+
|
341 |
+
$this->addMessage( $message, $stackPtr, $is_error, $code, $data, 0 );
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php
CHANGED
@@ -20,11 +20,11 @@ class WordPress_Sniffs_WP_DiscouragedFunctionsSniff extends WordPress_AbstractFu
|
|
20 |
* Groups of functions to restrict.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
20 |
* Groups of functions to restrict.
|
21 |
*
|
22 |
* Example: groups => array(
|
23 |
+
* 'lambda' => array(
|
24 |
+
* 'type' => 'error' | 'warning',
|
25 |
+
* 'message' => 'Use anonymous functions instead please!',
|
26 |
+
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
27 |
+
* )
|
28 |
* )
|
29 |
*
|
30 |
* @return array
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php
CHANGED
@@ -15,8 +15,9 @@
|
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
|
|
18 |
*/
|
19 |
-
class WordPress_Sniffs_WP_EnqueuedResourcesSniff
|
20 |
|
21 |
/**
|
22 |
* Returns an array of tokens this test wants to listen for.
|
@@ -24,33 +25,33 @@ class WordPress_Sniffs_WP_EnqueuedResourcesSniff implements PHP_CodeSniffer_Snif
|
|
24 |
* @return array
|
25 |
*/
|
26 |
public function register() {
|
27 |
-
return
|
28 |
-
T_CONSTANT_ENCAPSED_STRING,
|
29 |
-
T_DOUBLE_QUOTED_STRING,
|
30 |
-
T_INLINE_HTML,
|
31 |
-
);
|
32 |
-
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
* Processes this test, when one of its tokens is encountered.
|
37 |
*
|
38 |
-
* @param
|
39 |
-
* @param int $stackPtr The position of the current token
|
40 |
-
* in the stack passed in $tokens.
|
41 |
*
|
42 |
* @return void
|
43 |
*/
|
44 |
-
public function
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
if ( preg_match( '#<script[^>]*(?<=src=)#', $token['content'] ) > 0 ) {
|
53 |
-
$phpcsFile->addError(
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
} // End process().
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 0.3.0
|
18 |
+
* @since 0.12.0 This class now extends WordPress_Sniff.
|
19 |
*/
|
20 |
+
class WordPress_Sniffs_WP_EnqueuedResourcesSniff extends WordPress_Sniff {
|
21 |
|
22 |
/**
|
23 |
* Returns an array of tokens this test wants to listen for.
|
25 |
* @return array
|
26 |
*/
|
27 |
public function register() {
|
28 |
+
return PHP_CodeSniffer_Tokens::$textStringTokens;
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* Processes this test, when one of its tokens is encountered.
|
33 |
*
|
34 |
+
* @param int $stackPtr The position of the current token in the stack.
|
|
|
|
|
35 |
*
|
36 |
* @return void
|
37 |
*/
|
38 |
+
public function process_token( $stackPtr ) {
|
39 |
+
$token = $this->tokens[ $stackPtr ];
|
40 |
+
|
41 |
+
if ( preg_match( '#rel=\\\\?[\'"]?stylesheet\\\\?[\'"]?#', $token['content'] ) > 0 ) {
|
42 |
+
$this->phpcsFile->addError(
|
43 |
+
'Stylesheets must be registered/enqueued via wp_enqueue_style',
|
44 |
+
$stackPtr,
|
45 |
+
'NonEnqueuedStylesheet'
|
46 |
+
);
|
47 |
}
|
48 |
|
49 |
if ( preg_match( '#<script[^>]*(?<=src=)#', $token['content'] ) > 0 ) {
|
50 |
+
$this->phpcsFile->addError(
|
51 |
+
'Scripts must be registered/enqueued via wp_enqueue_script',
|
52 |
+
$stackPtr,
|
53 |
+
'NonEnqueuedScript'
|
54 |
+
);
|
55 |
}
|
56 |
|
57 |
} // End process().
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php
CHANGED
@@ -173,7 +173,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
173 |
for ( $i = ( $func_open_paren_token + 1 ); $i < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $i++ ) {
|
174 |
$this_token = $this->tokens[ $i ];
|
175 |
$this_token['token_index'] = $i;
|
176 |
-
if (
|
177 |
continue;
|
178 |
}
|
179 |
if ( T_COMMA === $this_token['code'] ) {
|
@@ -183,7 +183,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
183 |
}
|
184 |
|
185 |
// Merge consecutive single or double quoted strings (when they span multiple lines).
|
186 |
-
if (
|
187 |
for ( $j = ( $i + 1 ); $j < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $j++ ) {
|
188 |
if ( $this_token['code'] === $this->tokens[ $j ]['code'] ) {
|
189 |
$this_token['content'] .= $this->tokens[ $j ]['content'];
|
@@ -204,6 +204,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
204 |
$i = $this_token['parenthesis_closer'];
|
205 |
}
|
206 |
}
|
|
|
207 |
if ( ! empty( $argument_tokens ) ) {
|
208 |
$arguments_tokens[] = $argument_tokens;
|
209 |
}
|
@@ -294,7 +295,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
294 |
'arg_name' => 'domain',
|
295 |
'tokens' => array_shift( $arguments_tokens ),
|
296 |
);
|
297 |
-
}
|
298 |
|
299 |
if ( ! empty( $arguments_tokens ) ) {
|
300 |
$this->phpcsFile->addError( 'Too many arguments for function "%s".', $func_open_paren_token, 'TooManyFunctionArgs', array( $translation_function ) );
|
@@ -363,7 +364,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
363 |
}
|
364 |
return true;
|
365 |
}
|
366 |
-
if ( T_DOUBLE_QUOTED_STRING === $tokens[0]['code'] ) {
|
367 |
$interpolated_variables = $this->get_interpolated_variables( $content );
|
368 |
foreach ( $interpolated_variables as $interpolated_variable ) {
|
369 |
$code = $this->string_to_errorcode( 'InterpolatedVariable' . ucfirst( $arg_name ) );
|
@@ -380,7 +381,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
380 |
}
|
381 |
|
382 |
$code = $this->string_to_errorcode( 'NonSingularStringLiteral' . ucfirst( $arg_name ) );
|
383 |
-
$this->addMessage( 'The $%s arg
|
384 |
return false;
|
385 |
}
|
386 |
|
@@ -476,11 +477,9 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
476 |
if ( true === $fix ) {
|
477 |
$fixed_str = preg_replace( $replace_regexes, $replacements, $content, 1 );
|
478 |
|
479 |
-
$this->phpcsFile->fixer->beginChangeset();
|
480 |
$this->phpcsFile->fixer->replaceToken( $stack_ptr, $fixed_str );
|
481 |
-
$this->phpcsFile->fixer->endChangeset();
|
482 |
}
|
483 |
-
}
|
484 |
|
485 |
/*
|
486 |
* NoEmptyStrings.
|
@@ -550,8 +549,8 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
550 |
if ( T_COMMENT === $this->tokens[ $previous_comment ]['code'] ) {
|
551 |
$comment_text = trim( $this->tokens[ $previous_comment ]['content'] );
|
552 |
|
553 |
-
|
554 |
-
|
555 |
for ( $i = ( $previous_comment - 1 ); 0 <= $i; $i-- ) {
|
556 |
if ( T_COMMENT !== $this->tokens[ $i ]['code'] ) {
|
557 |
break;
|
@@ -561,7 +560,7 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
561 |
}
|
562 |
}
|
563 |
|
564 |
-
|
565 |
// Comment is ok.
|
566 |
return;
|
567 |
}
|
@@ -579,8 +578,8 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
579 |
return;
|
580 |
}
|
581 |
}
|
582 |
-
}
|
583 |
-
}
|
584 |
|
585 |
// Found placeholders but no translators comment.
|
586 |
$this->phpcsFile->addWarning(
|
@@ -589,8 +588,8 @@ class WordPress_Sniffs_WP_I18nSniff extends WordPress_Sniff {
|
|
589 |
'MissingTranslatorsComment'
|
590 |
);
|
591 |
return;
|
592 |
-
}
|
593 |
-
}
|
594 |
|
595 |
} // End check_for_translator_comment().
|
596 |
|
173 |
for ( $i = ( $func_open_paren_token + 1 ); $i < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $i++ ) {
|
174 |
$this_token = $this->tokens[ $i ];
|
175 |
$this_token['token_index'] = $i;
|
176 |
+
if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $this_token['code'] ] ) ) {
|
177 |
continue;
|
178 |
}
|
179 |
if ( T_COMMA === $this_token['code'] ) {
|
183 |
}
|
184 |
|
185 |
// Merge consecutive single or double quoted strings (when they span multiple lines).
|
186 |
+
if ( isset( PHP_CodeSniffer_Tokens::$textStringTokens[ $this_token['code'] ] ) ) {
|
187 |
for ( $j = ( $i + 1 ); $j < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $j++ ) {
|
188 |
if ( $this_token['code'] === $this->tokens[ $j ]['code'] ) {
|
189 |
$this_token['content'] .= $this->tokens[ $j ]['content'];
|
204 |
$i = $this_token['parenthesis_closer'];
|
205 |
}
|
206 |
}
|
207 |
+
|
208 |
if ( ! empty( $argument_tokens ) ) {
|
209 |
$arguments_tokens[] = $argument_tokens;
|
210 |
}
|
295 |
'arg_name' => 'domain',
|
296 |
'tokens' => array_shift( $arguments_tokens ),
|
297 |
);
|
298 |
+
}
|
299 |
|
300 |
if ( ! empty( $arguments_tokens ) ) {
|
301 |
$this->phpcsFile->addError( 'Too many arguments for function "%s".', $func_open_paren_token, 'TooManyFunctionArgs', array( $translation_function ) );
|
364 |
}
|
365 |
return true;
|
366 |
}
|
367 |
+
if ( T_DOUBLE_QUOTED_STRING === $tokens[0]['code'] || T_HEREDOC === $tokens[0]['code'] ) {
|
368 |
$interpolated_variables = $this->get_interpolated_variables( $content );
|
369 |
foreach ( $interpolated_variables as $interpolated_variable ) {
|
370 |
$code = $this->string_to_errorcode( 'InterpolatedVariable' . ucfirst( $arg_name ) );
|
381 |
}
|
382 |
|
383 |
$code = $this->string_to_errorcode( 'NonSingularStringLiteral' . ucfirst( $arg_name ) );
|
384 |
+
$this->addMessage( 'The $%s arg must be a single string literal, not "%s".', $stack_ptr, $is_error, $code, array( $arg_name, $content ) );
|
385 |
return false;
|
386 |
}
|
387 |
|
477 |
if ( true === $fix ) {
|
478 |
$fixed_str = preg_replace( $replace_regexes, $replacements, $content, 1 );
|
479 |
|
|
|
480 |
$this->phpcsFile->fixer->replaceToken( $stack_ptr, $fixed_str );
|
|
|
481 |
}
|
482 |
+
}
|
483 |
|
484 |
/*
|
485 |
* NoEmptyStrings.
|
549 |
if ( T_COMMENT === $this->tokens[ $previous_comment ]['code'] ) {
|
550 |
$comment_text = trim( $this->tokens[ $previous_comment ]['content'] );
|
551 |
|
552 |
+
// If it's multi-line /* */ comment, collect all the parts.
|
553 |
+
if ( '*/' === substr( $comment_text, -2 ) && '/*' !== substr( $comment_text, 0, 2 ) ) {
|
554 |
for ( $i = ( $previous_comment - 1 ); 0 <= $i; $i-- ) {
|
555 |
if ( T_COMMENT !== $this->tokens[ $i ]['code'] ) {
|
556 |
break;
|
560 |
}
|
561 |
}
|
562 |
|
563 |
+
if ( true === $this->is_translators_comment( $comment_text ) ) {
|
564 |
// Comment is ok.
|
565 |
return;
|
566 |
}
|
578 |
return;
|
579 |
}
|
580 |
}
|
581 |
+
}
|
582 |
+
}
|
583 |
|
584 |
// Found placeholders but no translators comment.
|
585 |
$this->phpcsFile->addWarning(
|
588 |
'MissingTranslatorsComment'
|
589 |
);
|
590 |
return;
|
591 |
+
}
|
592 |
+
}
|
593 |
|
594 |
} // End check_for_translator_comment().
|
595 |
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/PreparedSQLSniff.php
CHANGED
@@ -55,6 +55,11 @@ class WordPress_Sniffs_WP_PreparedSQLSniff extends WordPress_Sniff {
|
|
55 |
T_CLOSE_SQUARE_BRACKET => true,
|
56 |
T_COMMA => true,
|
57 |
T_LNUMBER => true,
|
|
|
|
|
|
|
|
|
|
|
58 |
);
|
59 |
|
60 |
/**
|
@@ -123,11 +128,13 @@ class WordPress_Sniffs_WP_PreparedSQLSniff extends WordPress_Sniff {
|
|
123 |
continue;
|
124 |
}
|
125 |
|
126 |
-
if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ]['code']
|
|
|
|
|
127 |
|
128 |
$bad_variables = array_filter(
|
129 |
$this->get_interpolated_variables( $this->tokens[ $this->i ]['content'] ),
|
130 |
-
create_function( '$symbol', 'return
|
131 |
);
|
132 |
|
133 |
foreach ( $bad_variables as $bad_variable ) {
|
@@ -181,11 +188,11 @@ class WordPress_Sniffs_WP_PreparedSQLSniff extends WordPress_Sniff {
|
|
181 |
'NotPrepared',
|
182 |
array( $this->tokens[ $this->i ]['content'] )
|
183 |
);
|
184 |
-
}
|
185 |
|
186 |
return $this->end;
|
187 |
|
188 |
-
} // End
|
189 |
|
190 |
/**
|
191 |
* Checks whether this is a call to a $wpdb method that we want to sniff.
|
@@ -205,7 +212,7 @@ class WordPress_Sniffs_WP_PreparedSQLSniff extends WordPress_Sniff {
|
|
205 |
protected function is_wpdb_method_call( $stackPtr ) {
|
206 |
|
207 |
// Check that this is a method call.
|
208 |
-
$is_object_call = $this->phpcsFile->findNext(
|
209 |
if ( false === $is_object_call ) {
|
210 |
return false;
|
211 |
}
|
55 |
T_CLOSE_SQUARE_BRACKET => true,
|
56 |
T_COMMA => true,
|
57 |
T_LNUMBER => true,
|
58 |
+
T_START_HEREDOC => true,
|
59 |
+
T_END_HEREDOC => true,
|
60 |
+
T_START_NOWDOC => true,
|
61 |
+
T_NOWDOC => true,
|
62 |
+
T_END_NOWDOC => true,
|
63 |
);
|
64 |
|
65 |
/**
|
128 |
continue;
|
129 |
}
|
130 |
|
131 |
+
if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ]['code']
|
132 |
+
|| T_HEREDOC === $this->tokens[ $this->i ]['code']
|
133 |
+
) {
|
134 |
|
135 |
$bad_variables = array_filter(
|
136 |
$this->get_interpolated_variables( $this->tokens[ $this->i ]['content'] ),
|
137 |
+
create_function( '$symbol', 'return ( $symbol !== "wpdb" );' ) // Replace this with closure once 5.3 is minimum requirement.
|
138 |
);
|
139 |
|
140 |
foreach ( $bad_variables as $bad_variable ) {
|
188 |
'NotPrepared',
|
189 |
array( $this->tokens[ $this->i ]['content'] )
|
190 |
);
|
191 |
+
}
|
192 |
|
193 |
return $this->end;
|
194 |
|
195 |
+
} // End process_token().
|
196 |
|
197 |
/**
|
198 |
* Checks whether this is a call to a $wpdb method that we want to sniff.
|
212 |
protected function is_wpdb_method_call( $stackPtr ) {
|
213 |
|
214 |
// Check that this is a method call.
|
215 |
+
$is_object_call = $this->phpcsFile->findNext( T_OBJECT_OPERATOR, ( $stackPtr + 1 ), null, false, null, true );
|
216 |
if ( false === $is_object_call ) {
|
217 |
return false;
|
218 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php
CHANGED
@@ -17,8 +17,9 @@
|
|
17 |
* @since 0.3.0
|
18 |
* @since 0.11.0 This sniff now has the ability to fix the issues it flags.
|
19 |
* @since 0.11.0 The error level for all errors thrown by this sniff has been raised from warning to error.
|
|
|
20 |
*/
|
21 |
-
class WordPress_Sniffs_WhiteSpace_CastStructureSpacingSniff
|
22 |
|
23 |
/**
|
24 |
* Returns an array of tokens this test wants to listen for.
|
@@ -32,28 +33,25 @@ class WordPress_Sniffs_WhiteSpace_CastStructureSpacingSniff implements PHP_CodeS
|
|
32 |
/**
|
33 |
* Processes this test, when one of its tokens is encountered.
|
34 |
*
|
35 |
-
* @param
|
36 |
-
* @param int $stackPtr The position of the current token in the
|
37 |
-
* stack passed in $tokens.
|
38 |
*
|
39 |
* @return void
|
40 |
*/
|
41 |
-
public function
|
42 |
-
$tokens = $phpcsFile->getTokens();
|
43 |
|
44 |
-
if ( T_WHITESPACE !== $tokens[ ( $stackPtr - 1 ) ]['code'] ) {
|
45 |
$error = 'No space before opening casting parenthesis is prohibited';
|
46 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBeforeOpenParenthesis' );
|
47 |
if ( true === $fix ) {
|
48 |
-
$phpcsFile->fixer->addContentBefore( $stackPtr, ' ' );
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
if ( T_WHITESPACE !== $tokens[ ( $stackPtr + 1 ) ]['code'] ) {
|
53 |
$error = 'No space after closing casting parenthesis is prohibited';
|
54 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterCloseParenthesis' );
|
55 |
if ( true === $fix ) {
|
56 |
-
$phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
57 |
}
|
58 |
}
|
59 |
}
|
17 |
* @since 0.3.0
|
18 |
* @since 0.11.0 This sniff now has the ability to fix the issues it flags.
|
19 |
* @since 0.11.0 The error level for all errors thrown by this sniff has been raised from warning to error.
|
20 |
+
* @since 0.12.0 This class now extends WordPress_Sniff.
|
21 |
*/
|
22 |
+
class WordPress_Sniffs_WhiteSpace_CastStructureSpacingSniff extends WordPress_Sniff {
|
23 |
|
24 |
/**
|
25 |
* Returns an array of tokens this test wants to listen for.
|
33 |
/**
|
34 |
* Processes this test, when one of its tokens is encountered.
|
35 |
*
|
36 |
+
* @param int $stackPtr The position of the current token in the stack.
|
|
|
|
|
37 |
*
|
38 |
* @return void
|
39 |
*/
|
40 |
+
public function process_token( $stackPtr ) {
|
|
|
41 |
|
42 |
+
if ( T_WHITESPACE !== $this->tokens[ ( $stackPtr - 1 ) ]['code'] ) {
|
43 |
$error = 'No space before opening casting parenthesis is prohibited';
|
44 |
+
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBeforeOpenParenthesis' );
|
45 |
if ( true === $fix ) {
|
46 |
+
$this->phpcsFile->fixer->addContentBefore( $stackPtr, ' ' );
|
47 |
}
|
48 |
}
|
49 |
|
50 |
+
if ( T_WHITESPACE !== $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
|
51 |
$error = 'No space after closing casting parenthesis is prohibited';
|
52 |
+
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterCloseParenthesis' );
|
53 |
if ( true === $fix ) {
|
54 |
+
$this->phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
55 |
}
|
56 |
}
|
57 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
CHANGED
@@ -117,9 +117,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
117 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterStructureOpen' );
|
118 |
|
119 |
if ( true === $fix ) {
|
120 |
-
$this->phpcsFile->fixer->beginChangeset();
|
121 |
$this->phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
122 |
-
$this->phpcsFile->fixer->endChangeset();
|
123 |
}
|
124 |
}
|
125 |
|
@@ -146,9 +144,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
146 |
$fix = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'NoSpaceBetweenStructureColon' );
|
147 |
|
148 |
if ( true === $fix ) {
|
149 |
-
$this->phpcsFile->fixer->beginChangeset();
|
150 |
$this->phpcsFile->fixer->addContentBefore( $scopeOpener, ' ' );
|
151 |
-
$this->phpcsFile->fixer->endChangeset();
|
152 |
}
|
153 |
}
|
154 |
} elseif ( 'forbidden' === $this->space_before_colon ) {
|
@@ -158,13 +154,11 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
158 |
$fix = $this->phpcsFile->addFixableError( $error, ( $scopeOpener - 1 ), 'SpaceBetweenStructureColon' );
|
159 |
|
160 |
if ( true === $fix ) {
|
161 |
-
$this->phpcsFile->fixer->beginChangeset();
|
162 |
$this->phpcsFile->fixer->replaceToken( ( $scopeOpener - 1 ), '' );
|
163 |
-
$this->phpcsFile->fixer->endChangeset();
|
164 |
}
|
165 |
}
|
166 |
}
|
167 |
-
}
|
168 |
|
169 |
$parenthesisOpener = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
170 |
|
@@ -207,9 +201,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
207 |
);
|
208 |
|
209 |
if ( true === $fix ) {
|
210 |
-
$this->phpcsFile->fixer->beginChangeset();
|
211 |
$this->phpcsFile->fixer->replaceToken( ( $function_name_ptr + 1 ), '' );
|
212 |
-
$this->phpcsFile->fixer->endChangeset();
|
213 |
}
|
214 |
}
|
215 |
}
|
@@ -232,7 +224,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
232 |
$scopeOpener = $usePtr;
|
233 |
}
|
234 |
}
|
235 |
-
}
|
236 |
|
237 |
if (
|
238 |
T_COLON !== $this->tokens[ $parenthesisOpener ]['code']
|
@@ -250,9 +242,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
250 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'SpaceBeforeClosureOpenParenthesis' );
|
251 |
|
252 |
if ( true === $fix ) {
|
253 |
-
$this->phpcsFile->fixer->beginChangeset();
|
254 |
$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' );
|
255 |
-
$this->phpcsFile->fixer->endChangeset();
|
256 |
}
|
257 |
}
|
258 |
} elseif (
|
@@ -268,12 +258,10 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
268 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBeforeOpenParenthesis' );
|
269 |
|
270 |
if ( true === $fix ) {
|
271 |
-
$this->phpcsFile->fixer->beginChangeset();
|
272 |
$this->phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
273 |
-
$this->phpcsFile->fixer->endChangeset();
|
274 |
}
|
275 |
}
|
276 |
-
}
|
277 |
|
278 |
if (
|
279 |
T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code']
|
@@ -289,9 +277,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
289 |
);
|
290 |
|
291 |
if ( true === $fix ) {
|
292 |
-
$this->phpcsFile->fixer->beginChangeset();
|
293 |
$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), ' ' );
|
294 |
-
$this->phpcsFile->fixer->endChangeset();
|
295 |
}
|
296 |
}
|
297 |
|
@@ -302,9 +288,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
302 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterOpenParenthesis' );
|
303 |
|
304 |
if ( true === $fix ) {
|
305 |
-
$this->phpcsFile->fixer->beginChangeset();
|
306 |
$this->phpcsFile->fixer->addContent( $parenthesisOpener, ' ' );
|
307 |
-
$this->phpcsFile->fixer->endChangeset();
|
308 |
}
|
309 |
} elseif ( ( ' ' !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
|
310 |
&& "\n" !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
|
@@ -321,9 +305,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
321 |
);
|
322 |
|
323 |
if ( true === $fix ) {
|
324 |
-
$this->phpcsFile->fixer->beginChangeset();
|
325 |
$this->phpcsFile->fixer->replaceToken( ( $parenthesisOpener + 1 ), ' ' );
|
326 |
-
$this->phpcsFile->fixer->endChangeset();
|
327 |
}
|
328 |
}
|
329 |
}
|
@@ -340,9 +322,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
340 |
$fix = $this->phpcsFile->addFixableError( $error, $parenthesisCloser, 'NoSpaceBeforeCloseParenthesis' );
|
341 |
|
342 |
if ( true === $fix ) {
|
343 |
-
$this->phpcsFile->fixer->beginChangeset();
|
344 |
$this->phpcsFile->fixer->addContentBefore( $parenthesisCloser, ' ' );
|
345 |
-
$this->phpcsFile->fixer->endChangeset();
|
346 |
}
|
347 |
} elseif ( ' ' !== $this->tokens[ ( $parenthesisCloser - 1 ) ]['content'] ) {
|
348 |
$prevNonEmpty = $this->phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $parenthesisCloser - 1 ), null, true );
|
@@ -356,9 +336,7 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
356 |
);
|
357 |
|
358 |
if ( true === $fix ) {
|
359 |
-
$this->phpcsFile->fixer->beginChangeset();
|
360 |
$this->phpcsFile->fixer->replaceToken( ( $parenthesisCloser - 1 ), ' ' );
|
361 |
-
$this->phpcsFile->fixer->endChangeset();
|
362 |
}
|
363 |
}
|
364 |
}
|
@@ -371,12 +349,10 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
371 |
$fix = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'NoSpaceAfterCloseParenthesis' );
|
372 |
|
373 |
if ( true === $fix ) {
|
374 |
-
$this->phpcsFile->fixer->beginChangeset();
|
375 |
$this->phpcsFile->fixer->addContentBefore( $scopeOpener, ' ' );
|
376 |
-
$this->phpcsFile->fixer->endChangeset();
|
377 |
}
|
378 |
}
|
379 |
-
}
|
380 |
|
381 |
if ( isset( $this->tokens[ $parenthesisOpener ]['parenthesis_owner'] )
|
382 |
&& ( isset( $scopeOpener )
|
@@ -412,12 +388,10 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
412 |
);
|
413 |
|
414 |
if ( true === $fix ) {
|
415 |
-
$this->phpcsFile->fixer->beginChangeset();
|
416 |
$this->phpcsFile->fixer->replaceToken( ( $parenthesisCloser + 1 ), ' ' );
|
417 |
-
$this->phpcsFile->fixer->endChangeset();
|
418 |
}
|
419 |
-
}
|
420 |
-
}
|
421 |
|
422 |
if ( false !== $this->blank_line_check && isset( $scopeOpener ) ) {
|
423 |
$firstContent = $this->phpcsFile->findNext( T_WHITESPACE, ( $scopeOpener + 1 ), null, true );
|
@@ -485,36 +459,50 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
485 |
$this->phpcsFile->fixer->endChangeset();
|
486 |
}
|
487 |
break;
|
488 |
-
}
|
489 |
-
}
|
490 |
-
}
|
491 |
-
}
|
492 |
unset( $ignore );
|
493 |
-
}
|
494 |
|
495 |
if ( ! isset( $scopeCloser ) || true !== $this->blank_line_after_check ) {
|
496 |
return;
|
497 |
}
|
498 |
|
499 |
-
|
|
|
|
|
500 |
if ( false === $trailingContent ) {
|
501 |
return;
|
502 |
}
|
503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
if ( T_ELSE === $this->tokens[ $trailingContent ]['code'] && T_IF === $this->tokens[ $stackPtr ]['code'] ) {
|
505 |
// IF with ELSE.
|
506 |
return;
|
507 |
}
|
508 |
|
509 |
-
if (
|
510 |
-
//
|
511 |
-
|
512 |
-
if ( isset( $this->tokens[ $trailingContent ]['scope_condition'] ) ) {
|
513 |
-
$condition = $this->tokens[ $trailingContent ]['scope_condition'];
|
514 |
-
if ( T_CASE === $this->tokens[ $condition ]['code'] || T_DEFAULT === $this->tokens[ $condition ]['code'] ) {
|
515 |
-
return;
|
516 |
-
}
|
517 |
-
}
|
518 |
}
|
519 |
|
520 |
if ( T_CLOSE_TAG === $this->tokens[ $trailingContent ]['code'] ) {
|
@@ -522,15 +510,15 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
522 |
return;
|
523 |
}
|
524 |
|
525 |
-
if (
|
|
|
|
|
526 |
// Another control structure's closing brace.
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
return;
|
533 |
-
}
|
534 |
}
|
535 |
|
536 |
if ( ( $this->tokens[ $scopeCloser ]['line'] + 1 ) !== $this->tokens[ $trailingContent ]['line'] ) {
|
@@ -541,17 +529,21 @@ class WordPress_Sniffs_WhiteSpace_ControlStructureSpacingSniff extends WordPress
|
|
541 |
if ( true === $fix ) {
|
542 |
$this->phpcsFile->fixer->beginChangeset();
|
543 |
|
544 |
-
|
|
|
545 |
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
|
|
546 |
}
|
547 |
|
548 |
// TODO: Instead a separate error should be triggered when content comes right after closing brace.
|
549 |
-
$this->
|
|
|
|
|
550 |
$this->phpcsFile->fixer->endChangeset();
|
551 |
}
|
552 |
}
|
553 |
-
}
|
554 |
|
555 |
-
} // End
|
556 |
|
557 |
} // End class.
|
117 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterStructureOpen' );
|
118 |
|
119 |
if ( true === $fix ) {
|
|
|
120 |
$this->phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
|
|
121 |
}
|
122 |
}
|
123 |
|
144 |
$fix = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'NoSpaceBetweenStructureColon' );
|
145 |
|
146 |
if ( true === $fix ) {
|
|
|
147 |
$this->phpcsFile->fixer->addContentBefore( $scopeOpener, ' ' );
|
|
|
148 |
}
|
149 |
}
|
150 |
} elseif ( 'forbidden' === $this->space_before_colon ) {
|
154 |
$fix = $this->phpcsFile->addFixableError( $error, ( $scopeOpener - 1 ), 'SpaceBetweenStructureColon' );
|
155 |
|
156 |
if ( true === $fix ) {
|
|
|
157 |
$this->phpcsFile->fixer->replaceToken( ( $scopeOpener - 1 ), '' );
|
|
|
158 |
}
|
159 |
}
|
160 |
}
|
161 |
+
}
|
162 |
|
163 |
$parenthesisOpener = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
164 |
|
201 |
);
|
202 |
|
203 |
if ( true === $fix ) {
|
|
|
204 |
$this->phpcsFile->fixer->replaceToken( ( $function_name_ptr + 1 ), '' );
|
|
|
205 |
}
|
206 |
}
|
207 |
}
|
224 |
$scopeOpener = $usePtr;
|
225 |
}
|
226 |
}
|
227 |
+
}
|
228 |
|
229 |
if (
|
230 |
T_COLON !== $this->tokens[ $parenthesisOpener ]['code']
|
242 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'SpaceBeforeClosureOpenParenthesis' );
|
243 |
|
244 |
if ( true === $fix ) {
|
|
|
245 |
$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' );
|
|
|
246 |
}
|
247 |
}
|
248 |
} elseif (
|
258 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBeforeOpenParenthesis' );
|
259 |
|
260 |
if ( true === $fix ) {
|
|
|
261 |
$this->phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
|
|
262 |
}
|
263 |
}
|
264 |
+
}
|
265 |
|
266 |
if (
|
267 |
T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code']
|
277 |
);
|
278 |
|
279 |
if ( true === $fix ) {
|
|
|
280 |
$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), ' ' );
|
|
|
281 |
}
|
282 |
}
|
283 |
|
288 |
$fix = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterOpenParenthesis' );
|
289 |
|
290 |
if ( true === $fix ) {
|
|
|
291 |
$this->phpcsFile->fixer->addContent( $parenthesisOpener, ' ' );
|
|
|
292 |
}
|
293 |
} elseif ( ( ' ' !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
|
294 |
&& "\n" !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
|
305 |
);
|
306 |
|
307 |
if ( true === $fix ) {
|
|
|
308 |
$this->phpcsFile->fixer->replaceToken( ( $parenthesisOpener + 1 ), ' ' );
|
|
|
309 |
}
|
310 |
}
|
311 |
}
|
322 |
$fix = $this->phpcsFile->addFixableError( $error, $parenthesisCloser, 'NoSpaceBeforeCloseParenthesis' );
|
323 |
|
324 |
if ( true === $fix ) {
|
|
|
325 |
$this->phpcsFile->fixer->addContentBefore( $parenthesisCloser, ' ' );
|
|
|
326 |
}
|
327 |
} elseif ( ' ' !== $this->tokens[ ( $parenthesisCloser - 1 ) ]['content'] ) {
|
328 |
$prevNonEmpty = $this->phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $parenthesisCloser - 1 ), null, true );
|
336 |
);
|
337 |
|
338 |
if ( true === $fix ) {
|
|
|
339 |
$this->phpcsFile->fixer->replaceToken( ( $parenthesisCloser - 1 ), ' ' );
|
|
|
340 |
}
|
341 |
}
|
342 |
}
|
349 |
$fix = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'NoSpaceAfterCloseParenthesis' );
|
350 |
|
351 |
if ( true === $fix ) {
|
|
|
352 |
$this->phpcsFile->fixer->addContentBefore( $scopeOpener, ' ' );
|
|
|
353 |
}
|
354 |
}
|
355 |
+
}
|
356 |
|
357 |
if ( isset( $this->tokens[ $parenthesisOpener ]['parenthesis_owner'] )
|
358 |
&& ( isset( $scopeOpener )
|
388 |
);
|
389 |
|
390 |
if ( true === $fix ) {
|
|
|
391 |
$this->phpcsFile->fixer->replaceToken( ( $parenthesisCloser + 1 ), ' ' );
|
|
|
392 |
}
|
393 |
+
}
|
394 |
+
}
|
395 |
|
396 |
if ( false !== $this->blank_line_check && isset( $scopeOpener ) ) {
|
397 |
$firstContent = $this->phpcsFile->findNext( T_WHITESPACE, ( $scopeOpener + 1 ), null, true );
|
459 |
$this->phpcsFile->fixer->endChangeset();
|
460 |
}
|
461 |
break;
|
462 |
+
}
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
unset( $ignore );
|
467 |
+
}
|
468 |
|
469 |
if ( ! isset( $scopeCloser ) || true !== $this->blank_line_after_check ) {
|
470 |
return;
|
471 |
}
|
472 |
|
473 |
+
// {@internal This is just for the blank line check. Only whitespace should be considered,
|
474 |
+
// not "other" empty tokens.}}
|
475 |
+
$trailingContent = $this->phpcsFile->findNext( T_WHITESPACE, ( $scopeCloser + 1 ), null, true );
|
476 |
if ( false === $trailingContent ) {
|
477 |
return;
|
478 |
}
|
479 |
|
480 |
+
if ( T_COMMENT === $this->tokens[ $trailingContent ]['code'] ) {
|
481 |
+
// Special exception for code where the comment about
|
482 |
+
// an ELSE or ELSEIF is written between the control structures.
|
483 |
+
$nextCode = $this->phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $scopeCloser + 1 ), null, true );
|
484 |
+
|
485 |
+
if ( T_ELSE === $this->tokens[ $nextCode ]['code'] || T_ELSEIF === $this->tokens[ $nextCode ]['code'] ) {
|
486 |
+
$trailingContent = $nextCode;
|
487 |
+
}
|
488 |
+
|
489 |
+
// Move past end comments.
|
490 |
+
if ( $this->tokens[ $trailingContent ]['line'] === $this->tokens[ $scopeCloser ]['line'] ) {
|
491 |
+
if ( preg_match( '`^//[ ]?end`i', $this->tokens[ $trailingContent ]['content'], $matches ) > 0 ) {
|
492 |
+
$scopeCloser = $trailingContent;
|
493 |
+
$trailingContent = $this->phpcsFile->findNext( T_WHITESPACE, ( $trailingContent + 1 ), null, true );
|
494 |
+
}
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
if ( T_ELSE === $this->tokens[ $trailingContent ]['code'] && T_IF === $this->tokens[ $stackPtr ]['code'] ) {
|
499 |
// IF with ELSE.
|
500 |
return;
|
501 |
}
|
502 |
|
503 |
+
if ( T_WHILE === $this->tokens[ $trailingContent ]['code'] && T_DO === $this->tokens[ $stackPtr ]['code'] ) {
|
504 |
+
// DO with WHILE.
|
505 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
}
|
507 |
|
508 |
if ( T_CLOSE_TAG === $this->tokens[ $trailingContent ]['code'] ) {
|
510 |
return;
|
511 |
}
|
512 |
|
513 |
+
if ( isset( $this->tokens[ $trailingContent ]['scope_condition'] )
|
514 |
+
&& T_CLOSE_CURLY_BRACKET === $this->tokens[ $trailingContent ]['code']
|
515 |
+
) {
|
516 |
// Another control structure's closing brace.
|
517 |
+
$owner = $this->tokens[ $trailingContent ]['scope_condition'];
|
518 |
+
if ( in_array( $this->tokens[ $owner ]['code'], array( T_FUNCTION, T_CLOSURE, T_CLASS, T_ANON_CLASS, T_INTERFACE, T_TRAIT ), true ) ) {
|
519 |
+
// The next content is the closing brace of a function, class, interface or trait
|
520 |
+
// so normal function/class rules apply and we can ignore it.
|
521 |
+
return;
|
|
|
|
|
522 |
}
|
523 |
|
524 |
if ( ( $this->tokens[ $scopeCloser ]['line'] + 1 ) !== $this->tokens[ $trailingContent ]['line'] ) {
|
529 |
if ( true === $fix ) {
|
530 |
$this->phpcsFile->fixer->beginChangeset();
|
531 |
|
532 |
+
$i = ( $scopeCloser + 1 );
|
533 |
+
while ( $this->tokens[ $i ]['line'] !== $this->tokens[ $trailingContent ]['line'] ) {
|
534 |
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
535 |
+
$i++;
|
536 |
}
|
537 |
|
538 |
// TODO: Instead a separate error should be triggered when content comes right after closing brace.
|
539 |
+
if ( T_COMMENT !== $this->tokens[ $scopeCloser ]['code'] ) {
|
540 |
+
$this->phpcsFile->fixer->addNewlineBefore( $trailingContent );
|
541 |
+
}
|
542 |
$this->phpcsFile->fixer->endChangeset();
|
543 |
}
|
544 |
}
|
545 |
+
}
|
546 |
|
547 |
+
} // End process_token().
|
548 |
|
549 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Enforces using spaces for mid-line alignment.
|
12 |
+
*
|
13 |
+
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#indentation
|
14 |
+
*
|
15 |
+
* @package WPCS\WordPressCodingStandards
|
16 |
+
*
|
17 |
+
* @since 0.12.0
|
18 |
+
*/
|
19 |
+
class WordPress_Sniffs_WhiteSpace_DisallowInlineTabsSniff extends WordPress_Sniff {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* The --tab-width CLI value that is being used.
|
23 |
+
*
|
24 |
+
* @var int
|
25 |
+
*/
|
26 |
+
private $tab_width;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns an array of tokens this test wants to listen for.
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function register() {
|
34 |
+
return array(
|
35 |
+
T_OPEN_TAG,
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Processes this test, when one of its tokens is encountered.
|
41 |
+
*
|
42 |
+
* @param int $stackPtr The position of the current token in the stack.
|
43 |
+
*
|
44 |
+
* @return int Integer stack pointer to skip the rest of the file.
|
45 |
+
*/
|
46 |
+
public function process_token( $stackPtr ) {
|
47 |
+
if ( ! isset( $this->tab_width ) ) {
|
48 |
+
$cli_values = $this->phpcsFile->phpcs->cli->getCommandLineValues();
|
49 |
+
if ( ! isset( $cli_values['tabWidth'] ) || 0 === $cli_values['tabWidth'] ) {
|
50 |
+
// We have no idea how wide tabs are, so assume 4 spaces for fixing.
|
51 |
+
$this->tab_width = 4;
|
52 |
+
} else {
|
53 |
+
$this->tab_width = $cli_values['tabWidth'];
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$check_tokens = array(
|
58 |
+
T_WHITESPACE => true,
|
59 |
+
T_DOC_COMMENT_WHITESPACE => true,
|
60 |
+
T_DOC_COMMENT_STRING => true,
|
61 |
+
);
|
62 |
+
|
63 |
+
for ( $i = ( $stackPtr + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
|
64 |
+
// Skip all non-whitespace tokens and skip whitespace at the start of a new line.
|
65 |
+
if ( ! isset( $check_tokens[ $this->tokens[ $i ]['code'] ] ) || 1 === $this->tokens[ $i ]['column'] ) {
|
66 |
+
continue;
|
67 |
+
}
|
68 |
+
|
69 |
+
// If tabs are being converted to spaces by the tokenizer, the
|
70 |
+
// original content should be checked instead of the converted content.
|
71 |
+
if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
|
72 |
+
$content = $this->tokens[ $i ]['orig_content'];
|
73 |
+
} else {
|
74 |
+
$content = $this->tokens[ $i ]['content'];
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( '' === $content || strpos( $content, "\t" ) === false ) {
|
78 |
+
continue;
|
79 |
+
}
|
80 |
+
|
81 |
+
$fix = $this->phpcsFile->addFixableError(
|
82 |
+
'Spaces must be used for mid-line alignment; tabs are not allowed',
|
83 |
+
$i,
|
84 |
+
'NonIndentTabsUsed'
|
85 |
+
);
|
86 |
+
if ( true === $fix ) {
|
87 |
+
if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
|
88 |
+
// Use the replacement that PHPCS has already done.
|
89 |
+
$this->phpcsFile->fixer->replaceToken( $i, $this->tokens[ $i ]['content'] );
|
90 |
+
} else {
|
91 |
+
// Replace tabs with spaces, using an indent of $tab_width.
|
92 |
+
// Other sniffs can then correct the indent if they need to.
|
93 |
+
$spaces = str_repeat( ' ', $this->tab_width );
|
94 |
+
$newContent = str_replace( "\t", $spaces, $this->tokens[ $i ]['content'] );
|
95 |
+
$this->phpcsFile->fixer->replaceToken( $i, $newContent );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
// Ignore the rest of the file.
|
101 |
+
return ( $this->phpcsFile->numTokens + 1 );
|
102 |
+
|
103 |
+
} // End process().
|
104 |
+
|
105 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php
CHANGED
@@ -7,8 +7,12 @@
|
|
7 |
* @license https://opensource.org/licenses/MIT MIT
|
8 |
*/
|
9 |
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
-
* Verify operator spacing,
|
12 |
*
|
13 |
* "Always put spaces after commas, and on both sides of logical, comparison, string and assignment operators."
|
14 |
*
|
@@ -17,22 +21,28 @@
|
|
17 |
* @package WPCS\WordPressCodingStandards
|
18 |
*
|
19 |
* @since 0.1.0
|
20 |
-
* @since 0.3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
*
|
22 |
-
* Last synced with base class
|
23 |
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
|
24 |
*/
|
25 |
-
class WordPress_Sniffs_WhiteSpace_OperatorSpacingSniff
|
26 |
|
27 |
/**
|
28 |
-
*
|
|
|
|
|
29 |
*
|
30 |
-
* @var
|
31 |
*/
|
32 |
-
public $
|
33 |
-
|
34 |
-
'JS',
|
35 |
-
);
|
36 |
|
37 |
/**
|
38 |
* Returns an array of tokens this test wants to listen for.
|
@@ -40,164 +50,12 @@ class WordPress_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffe
|
|
40 |
* @return array
|
41 |
*/
|
42 |
public function register() {
|
43 |
-
$
|
44 |
-
$
|
45 |
-
$
|
46 |
-
|
47 |
-
$tokens = array_unique( array_merge( $comparison, $operators, $assignment ) );
|
48 |
-
$tokens[] = T_BOOLEAN_NOT;
|
49 |
-
|
50 |
-
return $tokens;
|
51 |
|
|
|
|
|
52 |
}
|
53 |
|
54 |
-
/**
|
55 |
-
* Processes this sniff, when one of its tokens is encountered.
|
56 |
-
*
|
57 |
-
* @param PHP_CodeSniffer_File $phpcsFile The current file being checked.
|
58 |
-
* @param int $stackPtr The position of the current token in the
|
59 |
-
* stack passed in $tokens.
|
60 |
-
*
|
61 |
-
* @return void
|
62 |
-
*/
|
63 |
-
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
|
64 |
-
$tokens = $phpcsFile->getTokens();
|
65 |
-
|
66 |
-
if ( T_EQUAL === $tokens[ $stackPtr ]['code'] ) {
|
67 |
-
// Skip for '=&' case.
|
68 |
-
if ( isset( $tokens[ ( $stackPtr + 1 ) ] ) && T_BITWISE_AND === $tokens[ ( $stackPtr + 1 ) ]['code'] ) {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
// Skip default values in function declarations.
|
73 |
-
if ( isset( $tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
|
74 |
-
$bracket = end( $tokens[ $stackPtr ]['nested_parenthesis'] );
|
75 |
-
if ( isset( $tokens[ $bracket ]['parenthesis_owner'] ) ) {
|
76 |
-
$function = $tokens[ $bracket ]['parenthesis_owner'];
|
77 |
-
if ( T_FUNCTION === $tokens[ $function ]['code']
|
78 |
-
|| T_CLOSURE === $tokens[ $function ]['code']
|
79 |
-
) {
|
80 |
-
return;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( T_BITWISE_AND === $tokens[ $stackPtr ]['code'] ) {
|
87 |
-
/*
|
88 |
-
// If it's not a reference, then we expect one space either side of the
|
89 |
-
// bitwise operator.
|
90 |
-
if ( false === $phpcsFile->isReference( $stackPtr ) ) {
|
91 |
-
// @todo Implement or remove ?
|
92 |
-
}
|
93 |
-
*/
|
94 |
-
return;
|
95 |
-
|
96 |
-
} else {
|
97 |
-
if ( T_MINUS === $tokens[ $stackPtr ]['code'] ) {
|
98 |
-
// Check minus spacing, but make sure we aren't just assigning
|
99 |
-
// a minus value or returning one.
|
100 |
-
$prev = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
|
101 |
-
if ( T_RETURN === $tokens[ $prev ]['code'] ) {
|
102 |
-
// Just returning a negative value; eg. return -1.
|
103 |
-
return;
|
104 |
-
}
|
105 |
-
|
106 |
-
if ( in_array( $tokens[ $prev ]['code'], PHP_CodeSniffer_Tokens::$operators, true ) ) {
|
107 |
-
// Just trying to operate on a negative value; eg. ($var * -1).
|
108 |
-
return;
|
109 |
-
}
|
110 |
-
|
111 |
-
if ( in_array( $tokens[ $prev ]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens, true ) ) {
|
112 |
-
// Just trying to compare a negative value; eg. ($var === -1).
|
113 |
-
return;
|
114 |
-
}
|
115 |
-
|
116 |
-
// A list of tokens that indicate that the token is not
|
117 |
-
// part of an arithmetic operation.
|
118 |
-
$invalidTokens = array(
|
119 |
-
T_COMMA,
|
120 |
-
T_OPEN_PARENTHESIS,
|
121 |
-
T_OPEN_SQUARE_BRACKET,
|
122 |
-
);
|
123 |
-
|
124 |
-
if ( in_array( $tokens[ $prev ]['code'], $invalidTokens, true ) ) {
|
125 |
-
// Just trying to use a negative value; eg. myFunction($var, -2).
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
-
$number = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
|
130 |
-
if ( T_LNUMBER === $tokens[ $number ]['code'] ) {
|
131 |
-
$semi = $phpcsFile->findNext( T_WHITESPACE, ( $number + 1 ), null, true );
|
132 |
-
if ( T_SEMICOLON === $tokens[ $semi ]['code'] ) {
|
133 |
-
if ( false !== $prev && in_array( $tokens[ $prev ]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens, true ) ) {
|
134 |
-
// This is a negative assignment.
|
135 |
-
return;
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
139 |
-
} // End if().
|
140 |
-
|
141 |
-
$operator = $tokens[ $stackPtr ]['content'];
|
142 |
-
|
143 |
-
if ( T_WHITESPACE !== $tokens[ ( $stackPtr - 1 ) ]['code'] ) {
|
144 |
-
$error = 'Expected 1 space before "%s"; 0 found';
|
145 |
-
$data = array( $operator );
|
146 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBefore', $data );
|
147 |
-
if ( true === $fix ) {
|
148 |
-
$phpcsFile->fixer->beginChangeset();
|
149 |
-
$phpcsFile->fixer->addContentBefore( $stackPtr, ' ' );
|
150 |
-
$phpcsFile->fixer->endChangeset();
|
151 |
-
}
|
152 |
-
} elseif ( 1 !== strlen( $tokens[ ( $stackPtr - 1 ) ]['content'] ) && 1 !== $tokens[ ( $stackPtr - 1 ) ]['column'] ) {
|
153 |
-
// Don't throw an error for assignments, because other standards allow
|
154 |
-
// multiple spaces there to align multiple assignments.
|
155 |
-
if ( false === in_array( $tokens[ $stackPtr ]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens, true ) ) {
|
156 |
-
$found = strlen( $tokens[ ( $stackPtr - 1 ) ]['content'] );
|
157 |
-
$error = 'Expected 1 space before "%s"; %s found';
|
158 |
-
$data = array(
|
159 |
-
$operator,
|
160 |
-
$found,
|
161 |
-
);
|
162 |
-
|
163 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpacingBefore', $data );
|
164 |
-
if ( true === $fix ) {
|
165 |
-
$phpcsFile->fixer->beginChangeset();
|
166 |
-
$phpcsFile->fixer->replaceToken( ( $stackPtr - 1 ), ' ' );
|
167 |
-
$phpcsFile->fixer->endChangeset();
|
168 |
-
}
|
169 |
-
}
|
170 |
-
} // End if().
|
171 |
-
|
172 |
-
if ( '-' !== $operator ) {
|
173 |
-
if ( T_WHITESPACE !== $tokens[ ( $stackPtr + 1 ) ]['code'] ) {
|
174 |
-
$error = 'Expected 1 space after "%s"; 0 found';
|
175 |
-
$data = array( $operator );
|
176 |
-
|
177 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfter', $data );
|
178 |
-
if ( true === $fix ) {
|
179 |
-
$phpcsFile->fixer->beginChangeset();
|
180 |
-
$phpcsFile->fixer->addContent( $stackPtr, ' ' );
|
181 |
-
$phpcsFile->fixer->endChangeset();
|
182 |
-
}
|
183 |
-
} elseif ( 1 !== strlen( $tokens[ ( $stackPtr + 1 ) ]['content'] ) ) {
|
184 |
-
$found = strlen( $tokens[ ( $stackPtr + 1 ) ]['content'] );
|
185 |
-
$error = 'Expected 1 space after "%s"; %s found';
|
186 |
-
$data = array(
|
187 |
-
$operator,
|
188 |
-
$found,
|
189 |
-
);
|
190 |
-
|
191 |
-
$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpacingAfter', $data );
|
192 |
-
if ( true === $fix ) {
|
193 |
-
$phpcsFile->fixer->beginChangeset();
|
194 |
-
$phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), ' ' );
|
195 |
-
$phpcsFile->fixer->endChangeset();
|
196 |
-
}
|
197 |
-
} // End if().
|
198 |
-
} // End if().
|
199 |
-
} // End if().
|
200 |
-
|
201 |
-
} // End process().
|
202 |
-
|
203 |
} // End class.
|
7 |
* @license https://opensource.org/licenses/MIT MIT
|
8 |
*/
|
9 |
|
10 |
+
if ( ! class_exists( 'Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff', true ) ) {
|
11 |
+
throw new PHP_CodeSniffer_Exception( 'Class Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff not found' );
|
12 |
+
}
|
13 |
+
|
14 |
/**
|
15 |
+
* Verify operator spacing, uses the Squiz sniff, but additionally also sniffs for the `!` (boolean not) operator.
|
16 |
*
|
17 |
* "Always put spaces after commas, and on both sides of logical, comparison, string and assignment operators."
|
18 |
*
|
21 |
* @package WPCS\WordPressCodingStandards
|
22 |
*
|
23 |
* @since 0.1.0
|
24 |
+
* @since 0.3.0 This sniff now has the ability to fix the issues it flags.
|
25 |
+
* @since 0.12.0 This sniff used to be a copy of a very old and outdated version of the
|
26 |
+
* upstream sniff.
|
27 |
+
* Now, the sniff defers completely to the upstream sniff, adding just the
|
28 |
+
* T_BOOLEAN_NOT and the logical operators (`&&` and the like) - via the
|
29 |
+
* registration method and changing the value of the customizable
|
30 |
+
* $ignoreNewlines property.
|
31 |
*
|
32 |
+
* Last synced with base class June 2017 at commit 41127aa4764536f38f504fb3f7b8831f05919c89.
|
33 |
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
|
34 |
*/
|
35 |
+
class WordPress_Sniffs_WhiteSpace_OperatorSpacingSniff extends Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff {
|
36 |
|
37 |
/**
|
38 |
+
* Allow newlines instead of spaces.
|
39 |
+
*
|
40 |
+
* N.B.: The upstream sniff defaults to `false`.
|
41 |
*
|
42 |
+
* @var boolean
|
43 |
*/
|
44 |
+
public $ignoreNewlines = true;
|
45 |
+
|
|
|
|
|
46 |
|
47 |
/**
|
48 |
* Returns an array of tokens this test wants to listen for.
|
50 |
* @return array
|
51 |
*/
|
52 |
public function register() {
|
53 |
+
$tokens = parent::register();
|
54 |
+
$tokens[ T_BOOLEAN_NOT ] = T_BOOLEAN_NOT;
|
55 |
+
$logical_operators = PHP_CodeSniffer_Tokens::$booleanOperators;
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
// Using array union to auto-dedup.
|
58 |
+
return $tokens + $logical_operators;
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/XSS/EscapeOutputSniff.php
CHANGED
@@ -15,9 +15,11 @@
|
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 2013-06-11
|
18 |
-
* @since 0.4.0
|
19 |
-
* @since 0.5.0
|
20 |
-
*
|
|
|
|
|
21 |
*/
|
22 |
class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
23 |
|
@@ -93,10 +95,13 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
93 |
/**
|
94 |
* List of names of the tokens representing PHP magic constants.
|
95 |
*
|
|
|
|
|
96 |
* @var array
|
97 |
*/
|
98 |
private $magic_constant_tokens = array(
|
99 |
'T_CLASS_C' => true, // __CLASS__
|
|
|
100 |
'T_FILE' => true, // __FILE__
|
101 |
'T_FUNC_C' => true, // __FUNCTION__
|
102 |
'T_LINE' => true, // __LINE__
|
@@ -105,19 +110,72 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
105 |
'T_TRAIT_C' => true, // __TRAIT__
|
106 |
);
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
/**
|
109 |
* Returns an array of tokens this test wants to listen for.
|
110 |
*
|
111 |
* @return array
|
112 |
*/
|
113 |
public function register() {
|
114 |
-
|
|
|
115 |
T_ECHO,
|
116 |
T_PRINT,
|
117 |
T_EXIT,
|
118 |
T_STRING,
|
|
|
119 |
);
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
/**
|
@@ -152,6 +210,24 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
152 |
if ( in_array( $function, array( 'trigger_error', 'user_error' ), true ) ) {
|
153 |
$end_of_statement = $this->phpcsFile->findEndOfStatement( $open_paren + 1 );
|
154 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
|
157 |
// Checking for the ignore comment, ex: //xss ok.
|
@@ -160,7 +236,12 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
160 |
}
|
161 |
|
162 |
if ( isset( $end_of_statement, $this->unsafePrintingFunctions[ $function ] ) ) {
|
163 |
-
$error = $this->phpcsFile->addError(
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
// If the error was reported, don't bother checking the function's arguments.
|
166 |
if ( $error ) {
|
@@ -200,7 +281,7 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
200 |
for ( $i = $stackPtr; $i < $end_of_statement; $i++ ) {
|
201 |
|
202 |
// Ignore whitespaces and comments.
|
203 |
-
if (
|
204 |
continue;
|
205 |
}
|
206 |
|
@@ -252,13 +333,13 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
252 |
}
|
253 |
|
254 |
// Wake up on concatenation characters, another part to check.
|
255 |
-
if (
|
256 |
$watch = true;
|
257 |
continue;
|
258 |
}
|
259 |
|
260 |
// Wake up after a ternary else (:).
|
261 |
-
if ( $ternary &&
|
262 |
$watch = true;
|
263 |
continue;
|
264 |
}
|
@@ -276,14 +357,14 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
276 |
|
277 |
// Allow T_CONSTANT_ENCAPSED_STRING eg: echo 'Some String';
|
278 |
// Also T_LNUMBER, e.g.: echo 45; exit -1; and booleans.
|
279 |
-
if (
|
280 |
continue;
|
281 |
}
|
282 |
|
283 |
$watch = false;
|
284 |
|
285 |
// Allow int/double/bool casted variables.
|
286 |
-
if (
|
287 |
$in_cast = true;
|
288 |
continue;
|
289 |
}
|
@@ -293,7 +374,7 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
293 |
|
294 |
$ptr = $i;
|
295 |
$functionName = $this->tokens[ $i ]['content'];
|
296 |
-
$function_opener = $this->phpcsFile->findNext(
|
297 |
$is_formatting_function = isset( $this->formattingFunctions[ $functionName ] );
|
298 |
|
299 |
if ( false !== $function_opener ) {
|
@@ -345,7 +426,7 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
345 |
} else {
|
346 |
$content = $this->tokens[ $i ]['content'];
|
347 |
$ptr = $i;
|
348 |
-
}
|
349 |
|
350 |
$this->phpcsFile->addError(
|
351 |
"Expected next thing to be an escaping function (see Codex for 'Data Validation'), not '%s'",
|
@@ -353,11 +434,11 @@ class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
|
353 |
'OutputNotEscaped',
|
354 |
$content
|
355 |
);
|
356 |
-
}
|
357 |
|
358 |
return $end_of_statement;
|
359 |
|
360 |
-
} // End
|
361 |
|
362 |
/**
|
363 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
15 |
* @package WPCS\WordPressCodingStandards
|
16 |
*
|
17 |
* @since 2013-06-11
|
18 |
+
* @since 0.4.0 This class now extends WordPress_Sniff.
|
19 |
+
* @since 0.5.0 The various function list properties which used to be contained in this class
|
20 |
+
* have been moved to the WordPress_Sniff parent class.
|
21 |
+
* @since 0.12.0 This sniff will now also check for output escaping when using shorthand
|
22 |
+
* echo tags `<?=`.
|
23 |
*/
|
24 |
class WordPress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniff {
|
25 |
|
95 |
/**
|
96 |
* List of names of the tokens representing PHP magic constants.
|
97 |
*
|
98 |
+
* @since 0.10.0
|
99 |
+
*
|
100 |
* @var array
|
101 |
*/
|
102 |
private $magic_constant_tokens = array(
|
103 |
'T_CLASS_C' => true, // __CLASS__
|
104 |
+
'T_DIR' => true, // __DIR__
|
105 |
'T_FILE' => true, // __FILE__
|
106 |
'T_FUNC_C' => true, // __FUNCTION__
|
107 |
'T_LINE' => true, // __LINE__
|
110 |
'T_TRAIT_C' => true, // __TRAIT__
|
111 |
);
|
112 |
|
113 |
+
/**
|
114 |
+
* List of names of the cast tokens which can be considered as a safe escaping method.
|
115 |
+
*
|
116 |
+
* @since 0.12.0
|
117 |
+
*
|
118 |
+
* @var array
|
119 |
+
*/
|
120 |
+
private $safe_cast_tokens = array(
|
121 |
+
'T_INT_CAST' => true, // (int)
|
122 |
+
'T_DOUBLE_CAST' => true, // (float)
|
123 |
+
'T_BOOL_CAST' => true, // (bool)
|
124 |
+
'T_UNSET_CAST' => true, // (unset)
|
125 |
+
);
|
126 |
+
|
127 |
+
/**
|
128 |
+
* List of tokens which can be considered as a safe when directly part of the output.
|
129 |
+
*
|
130 |
+
* @since 0.12.0
|
131 |
+
*
|
132 |
+
* @var array
|
133 |
+
*/
|
134 |
+
private $safe_components = array(
|
135 |
+
'T_CONSTANT_ENCAPSED_STRING' => true,
|
136 |
+
'T_LNUMBER' => true,
|
137 |
+
'T_MINUS' => true,
|
138 |
+
'T_PLUS' => true,
|
139 |
+
'T_MULTIPLY' => true,
|
140 |
+
'T_DIVIDE' => true,
|
141 |
+
'T_MODULUS' => true,
|
142 |
+
'T_TRUE' => true,
|
143 |
+
'T_FALSE' => true,
|
144 |
+
'T_NULL' => true,
|
145 |
+
'T_DNUMBER' => true,
|
146 |
+
'T_START_NOWDOC' => true,
|
147 |
+
'T_NOWDOC' => true,
|
148 |
+
'T_END_NOWDOC' => true,
|
149 |
+
);
|
150 |
+
|
151 |
/**
|
152 |
* Returns an array of tokens this test wants to listen for.
|
153 |
*
|
154 |
* @return array
|
155 |
*/
|
156 |
public function register() {
|
157 |
+
|
158 |
+
$tokens = array(
|
159 |
T_ECHO,
|
160 |
T_PRINT,
|
161 |
T_EXIT,
|
162 |
T_STRING,
|
163 |
+
T_OPEN_TAG_WITH_ECHO,
|
164 |
);
|
165 |
|
166 |
+
/*
|
167 |
+
* Check whether short open echo tags are disabled and if so, register the
|
168 |
+
* T_INLINE_HTML token which is how short open tags are being handled in that case.
|
169 |
+
*
|
170 |
+
* In PHP < 5.4, support for short open echo tags depended on whether the
|
171 |
+
* `short_open_tag` ini directive was set to `true`.
|
172 |
+
* For PHP >= 5.4, the `short_open_tag` no longer affects the short open
|
173 |
+
* echo tags and these are now always enabled.
|
174 |
+
*/
|
175 |
+
if ( PHP_VERSION_ID < 50400 && false === (bool) ini_get( 'short_open_tag' ) ) {
|
176 |
+
$tokens[] = T_INLINE_HTML;
|
177 |
+
}
|
178 |
+
return $tokens;
|
179 |
}
|
180 |
|
181 |
/**
|
210 |
if ( in_array( $function, array( 'trigger_error', 'user_error' ), true ) ) {
|
211 |
$end_of_statement = $this->phpcsFile->findEndOfStatement( $open_paren + 1 );
|
212 |
}
|
213 |
+
} elseif ( T_INLINE_HTML === $this->tokens[ $stackPtr ]['code'] ) {
|
214 |
+
// Skip if no PHP short_open_tag is found in the string.
|
215 |
+
if ( false === strpos( $this->tokens[ $stackPtr ]['content'], '<?=' ) ) {
|
216 |
+
return;
|
217 |
+
}
|
218 |
+
|
219 |
+
// Report on what is very likely a PHP short open echo tag outputting a variable.
|
220 |
+
if ( preg_match( '`\<\?\=[\s]*(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:(?:->\S+|\[[^\]]+\]))*)[\s]*;?[\s]*\?\>`', $this->tokens[ $stackPtr ]['content'], $matches ) > 0 ) {
|
221 |
+
$this->phpcsFile->addError(
|
222 |
+
'Expected next thing to be an escaping function, not %s.',
|
223 |
+
$stackPtr,
|
224 |
+
'OutputNotEscaped',
|
225 |
+
array( $matches[1] )
|
226 |
+
);
|
227 |
+
return;
|
228 |
+
}
|
229 |
+
|
230 |
+
return;
|
231 |
}
|
232 |
|
233 |
// Checking for the ignore comment, ex: //xss ok.
|
236 |
}
|
237 |
|
238 |
if ( isset( $end_of_statement, $this->unsafePrintingFunctions[ $function ] ) ) {
|
239 |
+
$error = $this->phpcsFile->addError(
|
240 |
+
"Expected next thing to be an escaping function (like %s), not '%s'",
|
241 |
+
$stackPtr,
|
242 |
+
'UnsafePrintingFunction',
|
243 |
+
array( $this->unsafePrintingFunctions[ $function ], $function )
|
244 |
+
);
|
245 |
|
246 |
// If the error was reported, don't bother checking the function's arguments.
|
247 |
if ( $error ) {
|
281 |
for ( $i = $stackPtr; $i < $end_of_statement; $i++ ) {
|
282 |
|
283 |
// Ignore whitespaces and comments.
|
284 |
+
if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
285 |
continue;
|
286 |
}
|
287 |
|
333 |
}
|
334 |
|
335 |
// Wake up on concatenation characters, another part to check.
|
336 |
+
if ( T_STRING_CONCAT === $this->tokens[ $i ]['code'] ) {
|
337 |
$watch = true;
|
338 |
continue;
|
339 |
}
|
340 |
|
341 |
// Wake up after a ternary else (:).
|
342 |
+
if ( $ternary && T_INLINE_ELSE === $this->tokens[ $i ]['code'] ) {
|
343 |
$watch = true;
|
344 |
continue;
|
345 |
}
|
357 |
|
358 |
// Allow T_CONSTANT_ENCAPSED_STRING eg: echo 'Some String';
|
359 |
// Also T_LNUMBER, e.g.: echo 45; exit -1; and booleans.
|
360 |
+
if ( isset( $this->safe_components[ $this->tokens[ $i ]['type'] ] ) ) {
|
361 |
continue;
|
362 |
}
|
363 |
|
364 |
$watch = false;
|
365 |
|
366 |
// Allow int/double/bool casted variables.
|
367 |
+
if ( isset( $this->safe_cast_tokens[ $this->tokens[ $i ]['type'] ] ) ) {
|
368 |
$in_cast = true;
|
369 |
continue;
|
370 |
}
|
374 |
|
375 |
$ptr = $i;
|
376 |
$functionName = $this->tokens[ $i ]['content'];
|
377 |
+
$function_opener = $this->phpcsFile->findNext( T_OPEN_PARENTHESIS, ( $i + 1 ), null, false, null, true );
|
378 |
$is_formatting_function = isset( $this->formattingFunctions[ $functionName ] );
|
379 |
|
380 |
if ( false !== $function_opener ) {
|
426 |
} else {
|
427 |
$content = $this->tokens[ $i ]['content'];
|
428 |
$ptr = $i;
|
429 |
+
}
|
430 |
|
431 |
$this->phpcsFile->addError(
|
432 |
"Expected next thing to be an escaping function (see Codex for 'Data Validation'), not '%s'",
|
434 |
'OutputNotEscaped',
|
435 |
$content
|
436 |
);
|
437 |
+
}
|
438 |
|
439 |
return $end_of_statement;
|
440 |
|
441 |
+
} // End process_token().
|
442 |
|
443 |
/**
|
444 |
* Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayAssignmentRestrictionsUnitTest.php
CHANGED
@@ -44,7 +44,7 @@ class WordPress_Tests_Arrays_ArrayAssignmentRestrictionsUnitTest extends Abstrac
|
|
44 |
5 => 1,
|
45 |
7 => 2,
|
46 |
20 => 1,
|
47 |
-
|
48 |
|
49 |
}
|
50 |
|
44 |
5 => 1,
|
45 |
7 => 2,
|
46 |
20 => 1,
|
47 |
+
);
|
48 |
|
49 |
}
|
50 |
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.inc
CHANGED
@@ -19,6 +19,11 @@ $bad = array(
|
|
19 |
[ 'value4', 10 => 'value5' ]
|
20 |
); // Bad.
|
21 |
|
22 |
-
// Test for fixing associative arrays with multiple values &
|
23 |
-
// This needs to be the last test as the scope indent sniff will otherwise screw things up.
|
24 |
$bad = array( 'key1' => 'value1', 'key2' => 'value2', $key3 => 'value3', 'value4', 10 => 'value5' ); // Bad.
|
|
|
|
|
|
|
|
|
|
|
|
19 |
[ 'value4', 10 => 'value5' ]
|
20 |
); // Bad.
|
21 |
|
22 |
+
// Test for fixing associative arrays with multiple values & line indented with whitespace.
|
|
|
23 |
$bad = array( 'key1' => 'value1', 'key2' => 'value2', $key3 => 'value3', 'value4', 10 => 'value5' ); // Bad.
|
24 |
+
|
25 |
+
// Test for fixing associative arrays with comments between values.
|
26 |
+
$bad = array( 'key1' => 'value1', /* comment */ 'key2' => 'value2' ); // Bad.
|
27 |
+
|
28 |
+
// Test for (not) fixing non-associative array with a nested associative array which *will* be fixed.
|
29 |
+
$bad = array( 'value1', 'value2', [ 'sub1' => 1, 'sub2' => 2 ], 'value4' ); // Bad.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.inc.fixed
CHANGED
@@ -8,47 +8,47 @@ $query_vars = array( 'food' ); // Bad, no spaces after opening and before closin
|
|
8 |
$test = array( 1, 2 );
|
9 |
|
10 |
$bad = array(
|
11 |
-
|
12 |
-
); // Bad, each value of an associative array should start on a new line.
|
13 |
|
14 |
// Test for fixing nested associative arrays.
|
15 |
$bad = array(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
'value4',
|
26 |
-
10 => 'value5',
|
27 |
-
],
|
28 |
-
); // Bad.
|
29 |
|
30 |
// Test for fixing mixed single & multi-line nested associative arrays.
|
31 |
$bad = array(
|
32 |
array(
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
),
|
38 |
-
),
|
39 |
$key3 => 'value3',
|
40 |
[
|
41 |
-
|
42 |
-
|
43 |
-
]
|
44 |
); // Bad.
|
45 |
|
46 |
-
// Test for fixing associative arrays with multiple values &
|
47 |
-
// This needs to be the last test as the scope indent sniff will otherwise screw things up.
|
48 |
$bad = array(
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
$test = array( 1, 2 );
|
9 |
|
10 |
$bad = array(
|
11 |
+
'key' => 'value' ); // Bad, each value of an associative array should start on a new line.
|
|
|
12 |
|
13 |
// Test for fixing nested associative arrays.
|
14 |
$bad = array(
|
15 |
+
array(
|
16 |
+
'key1' => 'value1',
|
17 |
+
'key2' => [
|
18 |
+
'sub1' => 1,
|
19 |
+
'sub2' => 2] ),
|
20 |
+
$key3 => 'value3',
|
21 |
+
[
|
22 |
+
'value4',
|
23 |
+
10 => 'value5', ] ); // Bad.
|
|
|
|
|
|
|
|
|
24 |
|
25 |
// Test for fixing mixed single & multi-line nested associative arrays.
|
26 |
$bad = array(
|
27 |
array(
|
28 |
+
'key1' => 'value1',
|
29 |
+
array(
|
30 |
+
'sub1' => 1,
|
31 |
+
'sub2' => 2,)),
|
|
|
|
|
32 |
$key3 => 'value3',
|
33 |
[
|
34 |
+
'value4',
|
35 |
+
10 => 'value5' ]
|
|
|
36 |
); // Bad.
|
37 |
|
38 |
+
// Test for fixing associative arrays with multiple values & line indented with whitespace.
|
|
|
39 |
$bad = array(
|
40 |
+
'key1' => 'value1',
|
41 |
+
'key2' => 'value2',
|
42 |
+
$key3 => 'value3',
|
43 |
+
'value4',
|
44 |
+
10 => 'value5' ); // Bad.
|
45 |
+
|
46 |
+
// Test for fixing associative arrays with comments between values.
|
47 |
+
$bad = array(
|
48 |
+
'key1' => 'value1', /* comment */
|
49 |
+
'key2' => 'value2' ); // Bad.
|
50 |
+
|
51 |
+
// Test for (not) fixing non-associative array with a nested associative array which *will* be fixed.
|
52 |
+
$bad = array( 'value1', 'value2', [
|
53 |
+
'sub1' => 1,
|
54 |
+
'sub2' => 2 ], 'value4' ); // Bad.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php
CHANGED
@@ -25,10 +25,12 @@ class WordPress_Tests_Arrays_ArrayDeclarationSpacingUnitTest extends AbstractSni
|
|
25 |
5 => 2,
|
26 |
8 => 2,
|
27 |
10 => 1,
|
28 |
-
13 =>
|
29 |
-
17 =>
|
30 |
19 => 1,
|
31 |
-
|
|
|
|
|
32 |
);
|
33 |
}
|
34 |
|
25 |
5 => 2,
|
26 |
8 => 2,
|
27 |
10 => 1,
|
28 |
+
13 => 4,
|
29 |
+
17 => 2,
|
30 |
19 => 1,
|
31 |
+
23 => 1,
|
32 |
+
26 => 1,
|
33 |
+
29 => 1,
|
34 |
);
|
35 |
}
|
36 |
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.1.inc
ADDED
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$ok = array(
|
4 |
+
'value',
|
5 |
+
123,
|
6 |
+
);
|
7 |
+
|
8 |
+
$ok_with_keys = [
|
9 |
+
'key1' => 'value',
|
10 |
+
'key2' => 'value', // Comment after item.
|
11 |
+
];
|
12 |
+
|
13 |
+
$ok_nested = array(
|
14 |
+
'key1' => array(
|
15 |
+
'key1' => 'value',
|
16 |
+
'key2' => 'value',
|
17 |
+
),
|
18 |
+
'key2' => 'value',
|
19 |
+
);
|
20 |
+
|
21 |
+
|
22 |
+
$bad_phpcs_style = array(
|
23 |
+
'value',
|
24 |
+
123, // Comment after item.
|
25 |
+
);
|
26 |
+
|
27 |
+
$bad_phpcs_style_with_keys = array(
|
28 |
+
'key1' => 'value',
|
29 |
+
'key2' => 'value',
|
30 |
+
);
|
31 |
+
|
32 |
+
$bad_phpcs_style_nested = array(
|
33 |
+
'key1' => [
|
34 |
+
'key1' => 'value',
|
35 |
+
|
36 |
+
'key2' => 'value',
|
37 |
+
|
38 |
+
],
|
39 |
+
'key2' => 'value',
|
40 |
+
);
|
41 |
+
|
42 |
+
// Arrays with initial indent.
|
43 |
+
$bad_mixed_indent = [
|
44 |
+
'value',
|
45 |
+
123,
|
46 |
+
];
|
47 |
+
|
48 |
+
$bad_mixed_indent_with_keys = array(
|
49 |
+
|
50 |
+
'key1' => 'value',
|
51 |
+
'key2' => 'value',
|
52 |
+
);
|
53 |
+
|
54 |
+
$bad_mixed_indent_nested = [
|
55 |
+
'key1' => array(
|
56 |
+
'key1' => 'value',
|
57 |
+
'key2' => 'value',
|
58 |
+
),
|
59 |
+
|
60 |
+
'key2' => 'value',
|
61 |
+
];
|
62 |
+
|
63 |
+
$empty = [
|
64 |
+
|
65 |
+
|
66 |
+
];
|
67 |
+
|
68 |
+
// Same-line items in mixed arrays should be ignored.
|
69 |
+
$mixed_1 = array('something', 'else', array(
|
70 |
+
'key1' => 'value',
|
71 |
+
'key2' => 'value', // Comment after item.
|
72 |
+
),
|
73 |
+
);
|
74 |
+
|
75 |
+
$mixed_2 = array(
|
76 |
+
array(
|
77 |
+
'key1' => 'value',
|
78 |
+
'key2' => 'value', // Comment after item.
|
79 |
+
),
|
80 |
+
'something', 'else',
|
81 |
+
);
|
82 |
+
|
83 |
+
// Issue 998: don't fix the indentation for the closer if it's not on its own line.
|
84 |
+
$a = array(
|
85 |
+
'foo' => bar(1, 29));
|
86 |
+
|
87 |
+
$a = array(
|
88 |
+
'foo' => bar(1, 29) );
|
89 |
+
|
90 |
+
/*
|
91 |
+
* Issue 973 - multi-line value indentation.
|
92 |
+
*/
|
93 |
+
// OK.
|
94 |
+
get_current_screen()->add_help_tab( array(
|
95 |
+
'id' => 'overview',
|
96 |
+
'content' =>
|
97 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
98 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
99 |
+
) );
|
100 |
+
|
101 |
+
// Too little overall indentation.
|
102 |
+
get_current_screen()->add_help_tab( array(
|
103 |
+
'id' => 'overview',
|
104 |
+
'content' =>
|
105 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
106 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
107 |
+
) );
|
108 |
+
|
109 |
+
// Too much overall indentation.
|
110 |
+
get_current_screen()->add_help_tab( array(
|
111 |
+
'id' => 'overview',
|
112 |
+
'content' =>
|
113 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
114 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
115 |
+
) );
|
116 |
+
|
117 |
+
|
118 |
+
// Too little overall with more than the minimum indentation for some subsequent lines.
|
119 |
+
get_current_screen()->add_help_tab( array(
|
120 |
+
'id' => 'screen-content',
|
121 |
+
'content' => '<p>' . __('You can customize the display of this screen’s contents in a number of ways:') . '</p>' .
|
122 |
+
'<ul>' .
|
123 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
124 |
+
'<li>' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '</li>' .
|
125 |
+
'<li>' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '</li>' .
|
126 |
+
'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
|
127 |
+
'</ul>'
|
128 |
+
) );
|
129 |
+
|
130 |
+
// Too much overall with more than the minimum indentation for some subsequent lines.
|
131 |
+
get_current_screen()->add_help_tab( array(
|
132 |
+
'id' => 'bulk-actions',
|
133 |
+
'content' =>
|
134 |
+
'<p>' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '</p>' .
|
135 |
+
'<p>' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>'
|
136 |
+
) );
|
137 |
+
|
138 |
+
// Too much overall with less than the minimum indentation for some subsequent lines.
|
139 |
+
get_current_screen()->add_help_tab( array(
|
140 |
+
'id' => 'screen-content',
|
141 |
+
'content' =>
|
142 |
+
'<div>' .
|
143 |
+
'<ul>' .
|
144 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
145 |
+
'</ul>' .
|
146 |
+
'</div>'
|
147 |
+
) );
|
148 |
+
|
149 |
+
// Mixed indentation.
|
150 |
+
get_current_screen()->add_help_tab( array(
|
151 |
+
'id' => 'overview',
|
152 |
+
// Here we have a comment.
|
153 |
+
'title' =>
|
154 |
+
__('Overview') .
|
155 |
+
'something',
|
156 |
+
/* Here we have a comment. */
|
157 |
+
'content' => 'value' .
|
158 |
+
'value' .
|
159 |
+
'value' .
|
160 |
+
'value',
|
161 |
+
) );
|
162 |
+
|
163 |
+
// OK: Ignore empty lines when found as subsequent line in an item.
|
164 |
+
get_current_screen()->add_help_tab( array(
|
165 |
+
'id' => 'something' .
|
166 |
+
|
167 |
+
'something else',
|
168 |
+
) );
|
169 |
+
|
170 |
+
/*
|
171 |
+
* Issue: Subsequent lines with Heredoc/Nowdoc syntax should be ignored.
|
172 |
+
*/
|
173 |
+
// Should only report the first line and fix the first line + the comma on the last line.
|
174 |
+
get_current_screen()->add_help_tab( array(
|
175 |
+
'id' => <<<EOD
|
176 |
+
Here comes some text.
|
177 |
+
And some more text.
|
178 |
+
EOD
|
179 |
+
,
|
180 |
+
) );
|
181 |
+
|
182 |
+
// Should report the second line and fix the second line + the comma on the last line.
|
183 |
+
get_current_screen()->add_help_tab( array(
|
184 |
+
'id' =>
|
185 |
+
<<<EOD
|
186 |
+
Here comes some text.
|
187 |
+
And some more text.
|
188 |
+
EOD
|
189 |
+
,
|
190 |
+
) );
|
191 |
+
|
192 |
+
/*
|
193 |
+
* Heredoc/Nowdoc subsequent line fixer: lines before/after the heredoc/nowdoc *should* be fixed.
|
194 |
+
*/
|
195 |
+
// Should report on the 'id' line and the first line after the heredoc and fix 'id' line
|
196 |
+
// and both lines after the heredoc.
|
197 |
+
get_current_screen()->add_help_tab( array(
|
198 |
+
'id' => <<<EOD
|
199 |
+
Here comes some text.
|
200 |
+
And some more text.
|
201 |
+
EOD
|
202 |
+
. '</p>'
|
203 |
+
. '</hr>',
|
204 |
+
) );
|
205 |
+
|
206 |
+
// Should report on the heredoc opener and fix the opener and the line after the heredoc.
|
207 |
+
get_current_screen()->add_help_tab( array(
|
208 |
+
'id' =>
|
209 |
+
<<<EOD
|
210 |
+
Here comes some text.
|
211 |
+
And some more text.
|
212 |
+
EOD
|
213 |
+
. '</p>',
|
214 |
+
) );
|
215 |
+
|
216 |
+
// Should report on the 'id' line and the line after. Should fix both + line after the heredoc.
|
217 |
+
get_current_screen()->add_help_tab( array(
|
218 |
+
'id' =>
|
219 |
+
'<p>' . <<<EOD
|
220 |
+
Here comes some text.
|
221 |
+
And some more text.
|
222 |
+
EOD
|
223 |
+
. '</p>',
|
224 |
+
) );
|
225 |
+
|
226 |
+
// OK. Not pretty, but not handled by this sniff as both first line + line after have acceptable alignment.
|
227 |
+
get_current_screen()->add_help_tab( array(
|
228 |
+
'id' =>
|
229 |
+
'<p>' .
|
230 |
+
<<<EOD
|
231 |
+
Here comes some text.
|
232 |
+
And some more text.
|
233 |
+
EOD
|
234 |
+
. '</p>',
|
235 |
+
) );
|
236 |
+
|
237 |
+
/*
|
238 |
+
* Issue 985 - arrays with comments between items.
|
239 |
+
*/
|
240 |
+
// OK.
|
241 |
+
get_current_screen()->add_help_tab( array(
|
242 |
+
'id' => 'overview',
|
243 |
+
// Here we have a comment.
|
244 |
+
'title' => __('Overview'),
|
245 |
+
/* Here we have a comment. */
|
246 |
+
'content' => 'value',
|
247 |
+
) );
|
248 |
+
|
249 |
+
// Too little overall indentation.
|
250 |
+
get_current_screen()->add_help_tab( array(
|
251 |
+
'id' => 'overview',
|
252 |
+
// Here we have a comment.
|
253 |
+
'title' => __('Overview'),
|
254 |
+
/* Here we have a comment. */
|
255 |
+
'content' => 'value',
|
256 |
+
) );
|
257 |
+
|
258 |
+
// Too much overall indentation.
|
259 |
+
get_current_screen()->add_help_tab( array(
|
260 |
+
'id' => 'overview',
|
261 |
+
// Here we have a comment.
|
262 |
+
'title' => __('Overview'),
|
263 |
+
/* Here we have a comment. */
|
264 |
+
'content' => 'value',
|
265 |
+
) );
|
266 |
+
|
267 |
+
// Mixed indentation.
|
268 |
+
get_current_screen()->add_help_tab( array(
|
269 |
+
'id' => 'overview',
|
270 |
+
// Here we have a comment.
|
271 |
+
'title' =>
|
272 |
+
__('Overview'),
|
273 |
+
/* Here we have a comment. */
|
274 |
+
'content' => 'value',
|
275 |
+
) );
|
276 |
+
|
277 |
+
// Various multi-line comments.
|
278 |
+
$my_array = [
|
279 |
+
/**
|
280 |
+
* Docblock about a filtered value...
|
281 |
+
*/
|
282 |
+
'truthy' => apply_filters( '...', true ),
|
283 |
+
];
|
284 |
+
|
285 |
+
$my_array = [
|
286 |
+
/**
|
287 |
+
* Docblock about a filtered value...
|
288 |
+
*/
|
289 |
+
'truthy' => apply_filters( '...', true ),
|
290 |
+
];
|
291 |
+
|
292 |
+
$my_array = [
|
293 |
+
/*
|
294 |
+
* Multi-line inline comment about something...
|
295 |
+
*/
|
296 |
+
'truthy' => apply_filters( '...', true ),
|
297 |
+
];
|
298 |
+
|
299 |
+
$my_array = [
|
300 |
+
/*
|
301 |
+
* Multi-line inline comment about something...
|
302 |
+
*/
|
303 |
+
'truthy' => apply_filters( '...', true ),
|
304 |
+
];
|
305 |
+
|
306 |
+
$my_array = array(
|
307 |
+
'something' =>
|
308 |
+
/**
|
309 |
+
* Docblock about a filtered value...
|
310 |
+
*/
|
311 |
+
$a = apply_filters( '...', true ),
|
312 |
+
);
|
313 |
+
|
314 |
+
$my_array = [
|
315 |
+
'something' =>
|
316 |
+
/**
|
317 |
+
* Docblock about a filtered value...
|
318 |
+
*/
|
319 |
+
$a = apply_filters( '...', true ),
|
320 |
+
];
|
321 |
+
|
322 |
+
$my_array = [
|
323 |
+
'something' =>
|
324 |
+
/*
|
325 |
+
* Multi-line inline comment about something...
|
326 |
+
*/
|
327 |
+
apply_filters( '...', true ),
|
328 |
+
];
|
329 |
+
|
330 |
+
$my_array = [
|
331 |
+
'something' =>
|
332 |
+
/*
|
333 |
+
* Multi-line inline comment about something...
|
334 |
+
*/
|
335 |
+
apply_filters( '...', true ),
|
336 |
+
];
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.1.inc.fixed
ADDED
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$ok = array(
|
4 |
+
'value',
|
5 |
+
123,
|
6 |
+
);
|
7 |
+
|
8 |
+
$ok_with_keys = [
|
9 |
+
'key1' => 'value',
|
10 |
+
'key2' => 'value', // Comment after item.
|
11 |
+
];
|
12 |
+
|
13 |
+
$ok_nested = array(
|
14 |
+
'key1' => array(
|
15 |
+
'key1' => 'value',
|
16 |
+
'key2' => 'value',
|
17 |
+
),
|
18 |
+
'key2' => 'value',
|
19 |
+
);
|
20 |
+
|
21 |
+
|
22 |
+
$bad_phpcs_style = array(
|
23 |
+
'value',
|
24 |
+
123, // Comment after item.
|
25 |
+
);
|
26 |
+
|
27 |
+
$bad_phpcs_style_with_keys = array(
|
28 |
+
'key1' => 'value',
|
29 |
+
'key2' => 'value',
|
30 |
+
);
|
31 |
+
|
32 |
+
$bad_phpcs_style_nested = array(
|
33 |
+
'key1' => [
|
34 |
+
'key1' => 'value',
|
35 |
+
|
36 |
+
'key2' => 'value',
|
37 |
+
|
38 |
+
],
|
39 |
+
'key2' => 'value',
|
40 |
+
);
|
41 |
+
|
42 |
+
// Arrays with initial indent.
|
43 |
+
$bad_mixed_indent = [
|
44 |
+
'value',
|
45 |
+
123,
|
46 |
+
];
|
47 |
+
|
48 |
+
$bad_mixed_indent_with_keys = array(
|
49 |
+
|
50 |
+
'key1' => 'value',
|
51 |
+
'key2' => 'value',
|
52 |
+
);
|
53 |
+
|
54 |
+
$bad_mixed_indent_nested = [
|
55 |
+
'key1' => array(
|
56 |
+
'key1' => 'value',
|
57 |
+
'key2' => 'value',
|
58 |
+
),
|
59 |
+
|
60 |
+
'key2' => 'value',
|
61 |
+
];
|
62 |
+
|
63 |
+
$empty = [
|
64 |
+
|
65 |
+
|
66 |
+
];
|
67 |
+
|
68 |
+
// Same-line items in mixed arrays should be ignored.
|
69 |
+
$mixed_1 = array('something', 'else', array(
|
70 |
+
'key1' => 'value',
|
71 |
+
'key2' => 'value', // Comment after item.
|
72 |
+
),
|
73 |
+
);
|
74 |
+
|
75 |
+
$mixed_2 = array(
|
76 |
+
array(
|
77 |
+
'key1' => 'value',
|
78 |
+
'key2' => 'value', // Comment after item.
|
79 |
+
),
|
80 |
+
'something', 'else',
|
81 |
+
);
|
82 |
+
|
83 |
+
// Issue 998: don't fix the indentation for the closer if it's not on its own line.
|
84 |
+
$a = array(
|
85 |
+
'foo' => bar(1, 29));
|
86 |
+
|
87 |
+
$a = array(
|
88 |
+
'foo' => bar(1, 29) );
|
89 |
+
|
90 |
+
/*
|
91 |
+
* Issue 973 - multi-line value indentation.
|
92 |
+
*/
|
93 |
+
// OK.
|
94 |
+
get_current_screen()->add_help_tab( array(
|
95 |
+
'id' => 'overview',
|
96 |
+
'content' =>
|
97 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
98 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
99 |
+
) );
|
100 |
+
|
101 |
+
// Too little overall indentation.
|
102 |
+
get_current_screen()->add_help_tab( array(
|
103 |
+
'id' => 'overview',
|
104 |
+
'content' =>
|
105 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
106 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
107 |
+
) );
|
108 |
+
|
109 |
+
// Too much overall indentation.
|
110 |
+
get_current_screen()->add_help_tab( array(
|
111 |
+
'id' => 'overview',
|
112 |
+
'content' =>
|
113 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
114 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
115 |
+
) );
|
116 |
+
|
117 |
+
|
118 |
+
// Too little overall with more than the minimum indentation for some subsequent lines.
|
119 |
+
get_current_screen()->add_help_tab( array(
|
120 |
+
'id' => 'screen-content',
|
121 |
+
'content' => '<p>' . __('You can customize the display of this screen’s contents in a number of ways:') . '</p>' .
|
122 |
+
'<ul>' .
|
123 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
124 |
+
'<li>' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '</li>' .
|
125 |
+
'<li>' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '</li>' .
|
126 |
+
'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
|
127 |
+
'</ul>'
|
128 |
+
) );
|
129 |
+
|
130 |
+
// Too much overall with more than the minimum indentation for some subsequent lines.
|
131 |
+
get_current_screen()->add_help_tab( array(
|
132 |
+
'id' => 'bulk-actions',
|
133 |
+
'content' =>
|
134 |
+
'<p>' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '</p>' .
|
135 |
+
'<p>' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>'
|
136 |
+
) );
|
137 |
+
|
138 |
+
// Too much overall with less than the minimum indentation for some subsequent lines.
|
139 |
+
get_current_screen()->add_help_tab( array(
|
140 |
+
'id' => 'screen-content',
|
141 |
+
'content' =>
|
142 |
+
'<div>' .
|
143 |
+
'<ul>' .
|
144 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
145 |
+
'</ul>' .
|
146 |
+
'</div>'
|
147 |
+
) );
|
148 |
+
|
149 |
+
// Mixed indentation.
|
150 |
+
get_current_screen()->add_help_tab( array(
|
151 |
+
'id' => 'overview',
|
152 |
+
// Here we have a comment.
|
153 |
+
'title' =>
|
154 |
+
__('Overview') .
|
155 |
+
'something',
|
156 |
+
/* Here we have a comment. */
|
157 |
+
'content' => 'value' .
|
158 |
+
'value' .
|
159 |
+
'value' .
|
160 |
+
'value',
|
161 |
+
) );
|
162 |
+
|
163 |
+
// OK: Ignore empty lines when found as subsequent line in an item.
|
164 |
+
get_current_screen()->add_help_tab( array(
|
165 |
+
'id' => 'something' .
|
166 |
+
|
167 |
+
'something else',
|
168 |
+
) );
|
169 |
+
|
170 |
+
/*
|
171 |
+
* Issue: Subsequent lines with Heredoc/Nowdoc syntax should be ignored.
|
172 |
+
*/
|
173 |
+
// Should only report the first line and fix the first line + the comma on the last line.
|
174 |
+
get_current_screen()->add_help_tab( array(
|
175 |
+
'id' => <<<EOD
|
176 |
+
Here comes some text.
|
177 |
+
And some more text.
|
178 |
+
EOD
|
179 |
+
,
|
180 |
+
) );
|
181 |
+
|
182 |
+
// Should report the second line and fix the second line + the comma on the last line.
|
183 |
+
get_current_screen()->add_help_tab( array(
|
184 |
+
'id' =>
|
185 |
+
<<<EOD
|
186 |
+
Here comes some text.
|
187 |
+
And some more text.
|
188 |
+
EOD
|
189 |
+
,
|
190 |
+
) );
|
191 |
+
|
192 |
+
/*
|
193 |
+
* Heredoc/Nowdoc subsequent line fixer: lines before/after the heredoc/nowdoc *should* be fixed.
|
194 |
+
*/
|
195 |
+
// Should report on the 'id' line and the first line after the heredoc and fix 'id' line
|
196 |
+
// and both lines after the heredoc.
|
197 |
+
get_current_screen()->add_help_tab( array(
|
198 |
+
'id' => <<<EOD
|
199 |
+
Here comes some text.
|
200 |
+
And some more text.
|
201 |
+
EOD
|
202 |
+
. '</p>'
|
203 |
+
. '</hr>',
|
204 |
+
) );
|
205 |
+
|
206 |
+
// Should report on the heredoc opener and fix the opener and the line after the heredoc.
|
207 |
+
get_current_screen()->add_help_tab( array(
|
208 |
+
'id' =>
|
209 |
+
<<<EOD
|
210 |
+
Here comes some text.
|
211 |
+
And some more text.
|
212 |
+
EOD
|
213 |
+
. '</p>',
|
214 |
+
) );
|
215 |
+
|
216 |
+
// Should report on the 'id' line and the line after. Should fix both + line after the heredoc.
|
217 |
+
get_current_screen()->add_help_tab( array(
|
218 |
+
'id' =>
|
219 |
+
'<p>' . <<<EOD
|
220 |
+
Here comes some text.
|
221 |
+
And some more text.
|
222 |
+
EOD
|
223 |
+
. '</p>',
|
224 |
+
) );
|
225 |
+
|
226 |
+
// OK. Not pretty, but not handled by this sniff as both first line + line after have acceptable alignment.
|
227 |
+
get_current_screen()->add_help_tab( array(
|
228 |
+
'id' =>
|
229 |
+
'<p>' .
|
230 |
+
<<<EOD
|
231 |
+
Here comes some text.
|
232 |
+
And some more text.
|
233 |
+
EOD
|
234 |
+
. '</p>',
|
235 |
+
) );
|
236 |
+
|
237 |
+
/*
|
238 |
+
* Issue 985 - arrays with comments between items.
|
239 |
+
*/
|
240 |
+
// OK.
|
241 |
+
get_current_screen()->add_help_tab( array(
|
242 |
+
'id' => 'overview',
|
243 |
+
// Here we have a comment.
|
244 |
+
'title' => __('Overview'),
|
245 |
+
/* Here we have a comment. */
|
246 |
+
'content' => 'value',
|
247 |
+
) );
|
248 |
+
|
249 |
+
// Too little overall indentation.
|
250 |
+
get_current_screen()->add_help_tab( array(
|
251 |
+
'id' => 'overview',
|
252 |
+
// Here we have a comment.
|
253 |
+
'title' => __('Overview'),
|
254 |
+
/* Here we have a comment. */
|
255 |
+
'content' => 'value',
|
256 |
+
) );
|
257 |
+
|
258 |
+
// Too much overall indentation.
|
259 |
+
get_current_screen()->add_help_tab( array(
|
260 |
+
'id' => 'overview',
|
261 |
+
// Here we have a comment.
|
262 |
+
'title' => __('Overview'),
|
263 |
+
/* Here we have a comment. */
|
264 |
+
'content' => 'value',
|
265 |
+
) );
|
266 |
+
|
267 |
+
// Mixed indentation.
|
268 |
+
get_current_screen()->add_help_tab( array(
|
269 |
+
'id' => 'overview',
|
270 |
+
// Here we have a comment.
|
271 |
+
'title' =>
|
272 |
+
__('Overview'),
|
273 |
+
/* Here we have a comment. */
|
274 |
+
'content' => 'value',
|
275 |
+
) );
|
276 |
+
|
277 |
+
// Various multi-line comments.
|
278 |
+
$my_array = [
|
279 |
+
/**
|
280 |
+
* Docblock about a filtered value...
|
281 |
+
*/
|
282 |
+
'truthy' => apply_filters( '...', true ),
|
283 |
+
];
|
284 |
+
|
285 |
+
$my_array = [
|
286 |
+
/**
|
287 |
+
* Docblock about a filtered value...
|
288 |
+
*/
|
289 |
+
'truthy' => apply_filters( '...', true ),
|
290 |
+
];
|
291 |
+
|
292 |
+
$my_array = [
|
293 |
+
/*
|
294 |
+
* Multi-line inline comment about something...
|
295 |
+
*/
|
296 |
+
'truthy' => apply_filters( '...', true ),
|
297 |
+
];
|
298 |
+
|
299 |
+
$my_array = [
|
300 |
+
/*
|
301 |
+
* Multi-line inline comment about something...
|
302 |
+
*/
|
303 |
+
'truthy' => apply_filters( '...', true ),
|
304 |
+
];
|
305 |
+
|
306 |
+
$my_array = array(
|
307 |
+
'something' =>
|
308 |
+
/**
|
309 |
+
* Docblock about a filtered value...
|
310 |
+
*/
|
311 |
+
$a = apply_filters( '...', true ),
|
312 |
+
);
|
313 |
+
|
314 |
+
$my_array = [
|
315 |
+
'something' =>
|
316 |
+
/**
|
317 |
+
* Docblock about a filtered value...
|
318 |
+
*/
|
319 |
+
$a = apply_filters( '...', true ),
|
320 |
+
];
|
321 |
+
|
322 |
+
$my_array = [
|
323 |
+
'something' =>
|
324 |
+
/*
|
325 |
+
* Multi-line inline comment about something...
|
326 |
+
*/
|
327 |
+
apply_filters( '...', true ),
|
328 |
+
];
|
329 |
+
|
330 |
+
$my_array = [
|
331 |
+
'something' =>
|
332 |
+
/*
|
333 |
+
* Multi-line inline comment about something...
|
334 |
+
*/
|
335 |
+
apply_filters( '...', true ),
|
336 |
+
];
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.2.inc
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// @codingStandardsChangeSetting WordPress.Arrays.ArrayIndentation tabIndent false
|
3 |
+
$ok = array(
|
4 |
+
'value',
|
5 |
+
123,
|
6 |
+
);
|
7 |
+
|
8 |
+
$ok_with_keys = [
|
9 |
+
'key1' => 'value',
|
10 |
+
'key2' => 'value', // Comment after item.
|
11 |
+
];
|
12 |
+
|
13 |
+
$ok_nested = array(
|
14 |
+
'key1' => array(
|
15 |
+
'key1' => 'value',
|
16 |
+
'key2' => 'value',
|
17 |
+
),
|
18 |
+
'key2' => 'value',
|
19 |
+
);
|
20 |
+
|
21 |
+
|
22 |
+
$bad_phpcs_style = array(
|
23 |
+
'value',
|
24 |
+
123, // Comment after item.
|
25 |
+
);
|
26 |
+
|
27 |
+
$bad_phpcs_style_with_keys = array(
|
28 |
+
'key1' => 'value',
|
29 |
+
'key2' => 'value',
|
30 |
+
);
|
31 |
+
|
32 |
+
$bad_phpcs_style_nested = array(
|
33 |
+
'key1' => [
|
34 |
+
'key1' => 'value',
|
35 |
+
|
36 |
+
'key2' => 'value',
|
37 |
+
|
38 |
+
],
|
39 |
+
'key2' => 'value',
|
40 |
+
);
|
41 |
+
|
42 |
+
// Arrays with initial indent.
|
43 |
+
$bad_mixed_indent = [
|
44 |
+
'value',
|
45 |
+
123,
|
46 |
+
];
|
47 |
+
|
48 |
+
$bad_mixed_indent_with_keys = array(
|
49 |
+
|
50 |
+
'key1' => 'value',
|
51 |
+
'key2' => 'value',
|
52 |
+
);
|
53 |
+
|
54 |
+
$bad_mixed_indent_nested = [
|
55 |
+
'key1' => array(
|
56 |
+
'key1' => 'value',
|
57 |
+
'key2' => 'value',
|
58 |
+
),
|
59 |
+
|
60 |
+
'key2' => 'value',
|
61 |
+
];
|
62 |
+
|
63 |
+
$empty = [
|
64 |
+
|
65 |
+
|
66 |
+
];
|
67 |
+
|
68 |
+
// Same-line items in mixed arrays should be ignored.
|
69 |
+
$mixed_1 = array('something', 'else', array(
|
70 |
+
'key1' => 'value',
|
71 |
+
'key2' => 'value', // Comment after item.
|
72 |
+
),
|
73 |
+
);
|
74 |
+
|
75 |
+
$mixed_2 = array(
|
76 |
+
array(
|
77 |
+
'key1' => 'value',
|
78 |
+
'key2' => 'value', // Comment after item.
|
79 |
+
),
|
80 |
+
'something', 'else',
|
81 |
+
);
|
82 |
+
|
83 |
+
// Issue 998: don't fix the indentation for the closer if it's not on its own line.
|
84 |
+
$a = array(
|
85 |
+
'foo' => bar(1, 29));
|
86 |
+
|
87 |
+
$a = array(
|
88 |
+
'foo' => bar(1, 29) );
|
89 |
+
|
90 |
+
/*
|
91 |
+
* Issue 973 - multi-line value indentation.
|
92 |
+
*/
|
93 |
+
// OK.
|
94 |
+
get_current_screen()->add_help_tab( array(
|
95 |
+
'id' => 'overview',
|
96 |
+
'content' =>
|
97 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
98 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
99 |
+
) );
|
100 |
+
|
101 |
+
// Too little overall indentation.
|
102 |
+
get_current_screen()->add_help_tab( array(
|
103 |
+
'id' => 'overview',
|
104 |
+
'content' =>
|
105 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
106 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
107 |
+
) );
|
108 |
+
|
109 |
+
// Too much overall indentation.
|
110 |
+
get_current_screen()->add_help_tab( array(
|
111 |
+
'id' => 'overview',
|
112 |
+
'content' =>
|
113 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
114 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
115 |
+
) );
|
116 |
+
|
117 |
+
|
118 |
+
// Too little overall with more than the minimum indentation for some subsequent lines.
|
119 |
+
get_current_screen()->add_help_tab( array(
|
120 |
+
'id' => 'screen-content',
|
121 |
+
'content' => '<p>' . __('You can customize the display of this screen’s contents in a number of ways:') . '</p>' .
|
122 |
+
'<ul>' .
|
123 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
124 |
+
'<li>' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '</li>' .
|
125 |
+
'<li>' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '</li>' .
|
126 |
+
'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
|
127 |
+
'</ul>'
|
128 |
+
) );
|
129 |
+
|
130 |
+
// Too much overall with more than the minimum indentation for some subsequent lines.
|
131 |
+
get_current_screen()->add_help_tab( array(
|
132 |
+
'id' => 'bulk-actions',
|
133 |
+
'content' =>
|
134 |
+
'<p>' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '</p>' .
|
135 |
+
'<p>' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>'
|
136 |
+
) );
|
137 |
+
|
138 |
+
// Too much overall with less than the minimum indentation for some subsequent lines.
|
139 |
+
get_current_screen()->add_help_tab( array(
|
140 |
+
'id' => 'screen-content',
|
141 |
+
'content' =>
|
142 |
+
'<div>' .
|
143 |
+
'<ul>' .
|
144 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
145 |
+
'</ul>' .
|
146 |
+
'</div>'
|
147 |
+
) );
|
148 |
+
|
149 |
+
// Mixed indentation.
|
150 |
+
get_current_screen()->add_help_tab( array(
|
151 |
+
'id' => 'overview',
|
152 |
+
// Here we have a comment.
|
153 |
+
'title' =>
|
154 |
+
__('Overview') .
|
155 |
+
'something',
|
156 |
+
/* Here we have a comment. */
|
157 |
+
'content' => 'value' .
|
158 |
+
'value' .
|
159 |
+
'value' .
|
160 |
+
'value',
|
161 |
+
) );
|
162 |
+
|
163 |
+
// OK: Ignore empty lines when found as subsequent line in an item.
|
164 |
+
get_current_screen()->add_help_tab( array(
|
165 |
+
'id' => 'something' .
|
166 |
+
|
167 |
+
'something else',
|
168 |
+
) );
|
169 |
+
|
170 |
+
/*
|
171 |
+
* Issue: Subsequent lines with Heredoc/Nowdoc syntax should be ignored.
|
172 |
+
*/
|
173 |
+
// Should only report the first line and fix the first line + the comma on the last line.
|
174 |
+
get_current_screen()->add_help_tab( array(
|
175 |
+
'id' => <<<EOD
|
176 |
+
Here comes some text.
|
177 |
+
And some more text.
|
178 |
+
EOD
|
179 |
+
,
|
180 |
+
) );
|
181 |
+
|
182 |
+
// Should report the second line and fix the second line + the comma on the last line.
|
183 |
+
get_current_screen()->add_help_tab( array(
|
184 |
+
'id' =>
|
185 |
+
<<<EOD
|
186 |
+
Here comes some text.
|
187 |
+
And some more text.
|
188 |
+
EOD
|
189 |
+
,
|
190 |
+
) );
|
191 |
+
|
192 |
+
/*
|
193 |
+
* Heredoc/Nowdoc subsequent line fixer: lines before/after the heredoc/nowdoc *should* be fixed.
|
194 |
+
*/
|
195 |
+
// Should report on the 'id' line and the first line after the heredoc and fix 'id' line
|
196 |
+
// and both lines after the heredoc.
|
197 |
+
get_current_screen()->add_help_tab( array(
|
198 |
+
'id' => <<<EOD
|
199 |
+
Here comes some text.
|
200 |
+
And some more text.
|
201 |
+
EOD
|
202 |
+
. '</p>'
|
203 |
+
. '</hr>',
|
204 |
+
) );
|
205 |
+
|
206 |
+
// Should report on the heredoc opener and fix the opener and the line after the heredoc.
|
207 |
+
get_current_screen()->add_help_tab( array(
|
208 |
+
'id' =>
|
209 |
+
<<<EOD
|
210 |
+
Here comes some text.
|
211 |
+
And some more text.
|
212 |
+
EOD
|
213 |
+
. '</p>',
|
214 |
+
) );
|
215 |
+
|
216 |
+
// Should report on the 'id' line and the line after. Should fix both + line after the heredoc.
|
217 |
+
get_current_screen()->add_help_tab( array(
|
218 |
+
'id' =>
|
219 |
+
'<p>' . <<<EOD
|
220 |
+
Here comes some text.
|
221 |
+
And some more text.
|
222 |
+
EOD
|
223 |
+
. '</p>',
|
224 |
+
) );
|
225 |
+
|
226 |
+
// OK. Not pretty, but not handled by this sniff as both first line + line after have acceptable alignment.
|
227 |
+
get_current_screen()->add_help_tab( array(
|
228 |
+
'id' =>
|
229 |
+
'<p>' .
|
230 |
+
<<<EOD
|
231 |
+
Here comes some text.
|
232 |
+
And some more text.
|
233 |
+
EOD
|
234 |
+
. '</p>',
|
235 |
+
) );
|
236 |
+
|
237 |
+
/*
|
238 |
+
* Issue 985 - arrays with comments between items.
|
239 |
+
*/
|
240 |
+
// OK.
|
241 |
+
get_current_screen()->add_help_tab( array(
|
242 |
+
'id' => 'overview',
|
243 |
+
// Here we have a comment.
|
244 |
+
'title' => __('Overview'),
|
245 |
+
/* Here we have a comment. */
|
246 |
+
'content' => 'value',
|
247 |
+
) );
|
248 |
+
|
249 |
+
// Too little overall indentation.
|
250 |
+
get_current_screen()->add_help_tab( array(
|
251 |
+
'id' => 'overview',
|
252 |
+
// Here we have a comment.
|
253 |
+
'title' => __('Overview'),
|
254 |
+
/* Here we have a comment. */
|
255 |
+
'content' => 'value',
|
256 |
+
) );
|
257 |
+
|
258 |
+
// Too much overall indentation.
|
259 |
+
get_current_screen()->add_help_tab( array(
|
260 |
+
'id' => 'overview',
|
261 |
+
// Here we have a comment.
|
262 |
+
'title' => __('Overview'),
|
263 |
+
/* Here we have a comment. */
|
264 |
+
'content' => 'value',
|
265 |
+
) );
|
266 |
+
|
267 |
+
// Mixed indentation.
|
268 |
+
get_current_screen()->add_help_tab( array(
|
269 |
+
'id' => 'overview',
|
270 |
+
// Here we have a comment.
|
271 |
+
'title' =>
|
272 |
+
__('Overview'),
|
273 |
+
/* Here we have a comment. */
|
274 |
+
'content' => 'value',
|
275 |
+
) );
|
276 |
+
|
277 |
+
// Various multi-line comments.
|
278 |
+
$my_array = [
|
279 |
+
/**
|
280 |
+
* Docblock about a filtered value...
|
281 |
+
*/
|
282 |
+
'truthy' => apply_filters( '...', true ),
|
283 |
+
];
|
284 |
+
|
285 |
+
$my_array = [
|
286 |
+
/**
|
287 |
+
* Docblock about a filtered value...
|
288 |
+
*/
|
289 |
+
'truthy' => apply_filters( '...', true ),
|
290 |
+
];
|
291 |
+
|
292 |
+
$my_array = [
|
293 |
+
/*
|
294 |
+
* Multi-line inline comment about something...
|
295 |
+
*/
|
296 |
+
'truthy' => apply_filters( '...', true ),
|
297 |
+
];
|
298 |
+
|
299 |
+
$my_array = [
|
300 |
+
/*
|
301 |
+
* Multi-line inline comment about something...
|
302 |
+
*/
|
303 |
+
'truthy' => apply_filters( '...', true ),
|
304 |
+
];
|
305 |
+
|
306 |
+
$my_array = array(
|
307 |
+
'something' =>
|
308 |
+
/**
|
309 |
+
* Docblock about a filtered value...
|
310 |
+
*/
|
311 |
+
$a = apply_filters( '...', true ),
|
312 |
+
);
|
313 |
+
|
314 |
+
$my_array = [
|
315 |
+
'something' =>
|
316 |
+
/**
|
317 |
+
* Docblock about a filtered value...
|
318 |
+
*/
|
319 |
+
$a = apply_filters( '...', true ),
|
320 |
+
];
|
321 |
+
|
322 |
+
$my_array = [
|
323 |
+
'something' =>
|
324 |
+
/*
|
325 |
+
* Multi-line inline comment about something...
|
326 |
+
*/
|
327 |
+
apply_filters( '...', true ),
|
328 |
+
];
|
329 |
+
|
330 |
+
$my_array = [
|
331 |
+
'something' =>
|
332 |
+
/*
|
333 |
+
* Multi-line inline comment about something...
|
334 |
+
*/
|
335 |
+
apply_filters( '...', true ),
|
336 |
+
];
|
337 |
+
|
338 |
+
// @codingStandardsChangeSetting WordPress.Arrays.ArrayIndentation tabIndent true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.2.inc.fixed
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// @codingStandardsChangeSetting WordPress.Arrays.ArrayIndentation tabIndent false
|
3 |
+
$ok = array(
|
4 |
+
'value',
|
5 |
+
123,
|
6 |
+
);
|
7 |
+
|
8 |
+
$ok_with_keys = [
|
9 |
+
'key1' => 'value',
|
10 |
+
'key2' => 'value', // Comment after item.
|
11 |
+
];
|
12 |
+
|
13 |
+
$ok_nested = array(
|
14 |
+
'key1' => array(
|
15 |
+
'key1' => 'value',
|
16 |
+
'key2' => 'value',
|
17 |
+
),
|
18 |
+
'key2' => 'value',
|
19 |
+
);
|
20 |
+
|
21 |
+
|
22 |
+
$bad_phpcs_style = array(
|
23 |
+
'value',
|
24 |
+
123, // Comment after item.
|
25 |
+
);
|
26 |
+
|
27 |
+
$bad_phpcs_style_with_keys = array(
|
28 |
+
'key1' => 'value',
|
29 |
+
'key2' => 'value',
|
30 |
+
);
|
31 |
+
|
32 |
+
$bad_phpcs_style_nested = array(
|
33 |
+
'key1' => [
|
34 |
+
'key1' => 'value',
|
35 |
+
|
36 |
+
'key2' => 'value',
|
37 |
+
|
38 |
+
],
|
39 |
+
'key2' => 'value',
|
40 |
+
);
|
41 |
+
|
42 |
+
// Arrays with initial indent.
|
43 |
+
$bad_mixed_indent = [
|
44 |
+
'value',
|
45 |
+
123,
|
46 |
+
];
|
47 |
+
|
48 |
+
$bad_mixed_indent_with_keys = array(
|
49 |
+
|
50 |
+
'key1' => 'value',
|
51 |
+
'key2' => 'value',
|
52 |
+
);
|
53 |
+
|
54 |
+
$bad_mixed_indent_nested = [
|
55 |
+
'key1' => array(
|
56 |
+
'key1' => 'value',
|
57 |
+
'key2' => 'value',
|
58 |
+
),
|
59 |
+
|
60 |
+
'key2' => 'value',
|
61 |
+
];
|
62 |
+
|
63 |
+
$empty = [
|
64 |
+
|
65 |
+
|
66 |
+
];
|
67 |
+
|
68 |
+
// Same-line items in mixed arrays should be ignored.
|
69 |
+
$mixed_1 = array('something', 'else', array(
|
70 |
+
'key1' => 'value',
|
71 |
+
'key2' => 'value', // Comment after item.
|
72 |
+
),
|
73 |
+
);
|
74 |
+
|
75 |
+
$mixed_2 = array(
|
76 |
+
array(
|
77 |
+
'key1' => 'value',
|
78 |
+
'key2' => 'value', // Comment after item.
|
79 |
+
),
|
80 |
+
'something', 'else',
|
81 |
+
);
|
82 |
+
|
83 |
+
// Issue 998: don't fix the indentation for the closer if it's not on its own line.
|
84 |
+
$a = array(
|
85 |
+
'foo' => bar(1, 29));
|
86 |
+
|
87 |
+
$a = array(
|
88 |
+
'foo' => bar(1, 29) );
|
89 |
+
|
90 |
+
/*
|
91 |
+
* Issue 973 - multi-line value indentation.
|
92 |
+
*/
|
93 |
+
// OK.
|
94 |
+
get_current_screen()->add_help_tab( array(
|
95 |
+
'id' => 'overview',
|
96 |
+
'content' =>
|
97 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
98 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
99 |
+
) );
|
100 |
+
|
101 |
+
// Too little overall indentation.
|
102 |
+
get_current_screen()->add_help_tab( array(
|
103 |
+
'id' => 'overview',
|
104 |
+
'content' =>
|
105 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
106 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
107 |
+
) );
|
108 |
+
|
109 |
+
// Too much overall indentation.
|
110 |
+
get_current_screen()->add_help_tab( array(
|
111 |
+
'id' => 'overview',
|
112 |
+
'content' =>
|
113 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
|
114 |
+
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
|
115 |
+
) );
|
116 |
+
|
117 |
+
|
118 |
+
// Too little overall with more than the minimum indentation for some subsequent lines.
|
119 |
+
get_current_screen()->add_help_tab( array(
|
120 |
+
'id' => 'screen-content',
|
121 |
+
'content' => '<p>' . __('You can customize the display of this screen’s contents in a number of ways:') . '</p>' .
|
122 |
+
'<ul>' .
|
123 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
124 |
+
'<li>' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '</li>' .
|
125 |
+
'<li>' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '</li>' .
|
126 |
+
'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
|
127 |
+
'</ul>'
|
128 |
+
) );
|
129 |
+
|
130 |
+
// Too much overall with more than the minimum indentation for some subsequent lines.
|
131 |
+
get_current_screen()->add_help_tab( array(
|
132 |
+
'id' => 'bulk-actions',
|
133 |
+
'content' =>
|
134 |
+
'<p>' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '</p>' .
|
135 |
+
'<p>' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>'
|
136 |
+
) );
|
137 |
+
|
138 |
+
// Too much overall with less than the minimum indentation for some subsequent lines.
|
139 |
+
get_current_screen()->add_help_tab( array(
|
140 |
+
'id' => 'screen-content',
|
141 |
+
'content' =>
|
142 |
+
'<div>' .
|
143 |
+
'<ul>' .
|
144 |
+
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
145 |
+
'</ul>' .
|
146 |
+
'</div>'
|
147 |
+
) );
|
148 |
+
|
149 |
+
// Mixed indentation.
|
150 |
+
get_current_screen()->add_help_tab( array(
|
151 |
+
'id' => 'overview',
|
152 |
+
// Here we have a comment.
|
153 |
+
'title' =>
|
154 |
+
__('Overview') .
|
155 |
+
'something',
|
156 |
+
/* Here we have a comment. */
|
157 |
+
'content' => 'value' .
|
158 |
+
'value' .
|
159 |
+
'value' .
|
160 |
+
'value',
|
161 |
+
) );
|
162 |
+
|
163 |
+
// OK: Ignore empty lines when found as subsequent line in an item.
|
164 |
+
get_current_screen()->add_help_tab( array(
|
165 |
+
'id' => 'something' .
|
166 |
+
|
167 |
+
'something else',
|
168 |
+
) );
|
169 |
+
|
170 |
+
/*
|
171 |
+
* Issue: Subsequent lines with Heredoc/Nowdoc syntax should be ignored.
|
172 |
+
*/
|
173 |
+
// Should only report the first line and fix the first line + the comma on the last line.
|
174 |
+
get_current_screen()->add_help_tab( array(
|
175 |
+
'id' => <<<EOD
|
176 |
+
Here comes some text.
|
177 |
+
And some more text.
|
178 |
+
EOD
|
179 |
+
,
|
180 |
+
) );
|
181 |
+
|
182 |
+
// Should report the second line and fix the second line + the comma on the last line.
|
183 |
+
get_current_screen()->add_help_tab( array(
|
184 |
+
'id' =>
|
185 |
+
<<<EOD
|
186 |
+
Here comes some text.
|
187 |
+
And some more text.
|
188 |
+
EOD
|
189 |
+
,
|
190 |
+
) );
|
191 |
+
|
192 |
+
/*
|
193 |
+
* Heredoc/Nowdoc subsequent line fixer: lines before/after the heredoc/nowdoc *should* be fixed.
|
194 |
+
*/
|
195 |
+
// Should report on the 'id' line and the first line after the heredoc and fix 'id' line
|
196 |
+
// and both lines after the heredoc.
|
197 |
+
get_current_screen()->add_help_tab( array(
|
198 |
+
'id' => <<<EOD
|
199 |
+
Here comes some text.
|
200 |
+
And some more text.
|
201 |
+
EOD
|
202 |
+
. '</p>'
|
203 |
+
. '</hr>',
|
204 |
+
) );
|
205 |
+
|
206 |
+
// Should report on the heredoc opener and fix the opener and the line after the heredoc.
|
207 |
+
get_current_screen()->add_help_tab( array(
|
208 |
+
'id' =>
|
209 |
+
<<<EOD
|
210 |
+
Here comes some text.
|
211 |
+
And some more text.
|
212 |
+
EOD
|
213 |
+
. '</p>',
|
214 |
+
) );
|
215 |
+
|
216 |
+
// Should report on the 'id' line and the line after. Should fix both + line after the heredoc.
|
217 |
+
get_current_screen()->add_help_tab( array(
|
218 |
+
'id' =>
|
219 |
+
'<p>' . <<<EOD
|
220 |
+
Here comes some text.
|
221 |
+
And some more text.
|
222 |
+
EOD
|
223 |
+
. '</p>',
|
224 |
+
) );
|
225 |
+
|
226 |
+
// OK. Not pretty, but not handled by this sniff as both first line + line after have acceptable alignment.
|
227 |
+
get_current_screen()->add_help_tab( array(
|
228 |
+
'id' =>
|
229 |
+
'<p>' .
|
230 |
+
<<<EOD
|
231 |
+
Here comes some text.
|
232 |
+
And some more text.
|
233 |
+
EOD
|
234 |
+
. '</p>',
|
235 |
+
) );
|
236 |
+
|
237 |
+
/*
|
238 |
+
* Issue 985 - arrays with comments between items.
|
239 |
+
*/
|
240 |
+
// OK.
|
241 |
+
get_current_screen()->add_help_tab( array(
|
242 |
+
'id' => 'overview',
|
243 |
+
// Here we have a comment.
|
244 |
+
'title' => __('Overview'),
|
245 |
+
/* Here we have a comment. */
|
246 |
+
'content' => 'value',
|
247 |
+
) );
|
248 |
+
|
249 |
+
// Too little overall indentation.
|
250 |
+
get_current_screen()->add_help_tab( array(
|
251 |
+
'id' => 'overview',
|
252 |
+
// Here we have a comment.
|
253 |
+
'title' => __('Overview'),
|
254 |
+
/* Here we have a comment. */
|
255 |
+
'content' => 'value',
|
256 |
+
) );
|
257 |
+
|
258 |
+
// Too much overall indentation.
|
259 |
+
get_current_screen()->add_help_tab( array(
|
260 |
+
'id' => 'overview',
|
261 |
+
// Here we have a comment.
|
262 |
+
'title' => __('Overview'),
|
263 |
+
/* Here we have a comment. */
|
264 |
+
'content' => 'value',
|
265 |
+
) );
|
266 |
+
|
267 |
+
// Mixed indentation.
|
268 |
+
get_current_screen()->add_help_tab( array(
|
269 |
+
'id' => 'overview',
|
270 |
+
// Here we have a comment.
|
271 |
+
'title' =>
|
272 |
+
__('Overview'),
|
273 |
+
/* Here we have a comment. */
|
274 |
+
'content' => 'value',
|
275 |
+
) );
|
276 |
+
|
277 |
+
// Various multi-line comments.
|
278 |
+
$my_array = [
|
279 |
+
/**
|
280 |
+
* Docblock about a filtered value...
|
281 |
+
*/
|
282 |
+
'truthy' => apply_filters( '...', true ),
|
283 |
+
];
|
284 |
+
|
285 |
+
$my_array = [
|
286 |
+
/**
|
287 |
+
* Docblock about a filtered value...
|
288 |
+
*/
|
289 |
+
'truthy' => apply_filters( '...', true ),
|
290 |
+
];
|
291 |
+
|
292 |
+
$my_array = [
|
293 |
+
/*
|
294 |
+
* Multi-line inline comment about something...
|
295 |
+
*/
|
296 |
+
'truthy' => apply_filters( '...', true ),
|
297 |
+
];
|
298 |
+
|
299 |
+
$my_array = [
|
300 |
+
/*
|
301 |
+
* Multi-line inline comment about something...
|
302 |
+
*/
|
303 |
+
'truthy' => apply_filters( '...', true ),
|
304 |
+
];
|
305 |
+
|
306 |
+
$my_array = array(
|
307 |
+
'something' =>
|
308 |
+
/**
|
309 |
+
* Docblock about a filtered value...
|
310 |
+
*/
|
311 |
+
$a = apply_filters( '...', true ),
|
312 |
+
);
|
313 |
+
|
314 |
+
$my_array = [
|
315 |
+
'something' =>
|
316 |
+
/**
|
317 |
+
* Docblock about a filtered value...
|
318 |
+
*/
|
319 |
+
$a = apply_filters( '...', true ),
|
320 |
+
];
|
321 |
+
|
322 |
+
$my_array = [
|
323 |
+
'something' =>
|
324 |
+
/*
|
325 |
+
* Multi-line inline comment about something...
|
326 |
+
*/
|
327 |
+
apply_filters( '...', true ),
|
328 |
+
];
|
329 |
+
|
330 |
+
$my_array = [
|
331 |
+
'something' =>
|
332 |
+
/*
|
333 |
+
* Multi-line inline comment about something...
|
334 |
+
*/
|
335 |
+
apply_filters( '...', true ),
|
336 |
+
];
|
337 |
+
|
338 |
+
// @codingStandardsChangeSetting WordPress.Arrays.ArrayIndentation tabIndent true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the ArrayIndentation sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_Arrays_ArrayIndentationUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get a list of CLI values to set before the file is tested.
|
20 |
+
*
|
21 |
+
* @param string $testFile The name of the file being tested.
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function getCliValues( $testFile ) {
|
26 |
+
// Tab width setting is only needed for the tabbed file.
|
27 |
+
if ( 'ArrayIndentationUnitTest.1.inc' === $testFile ) {
|
28 |
+
return array( '--tab-width=4' );
|
29 |
+
}
|
30 |
+
|
31 |
+
return array();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Returns the lines where errors should occur.
|
36 |
+
*
|
37 |
+
* @return array <int line number> => <int number of errors>
|
38 |
+
*/
|
39 |
+
public function getErrorList() {
|
40 |
+
return array(
|
41 |
+
23 => 1,
|
42 |
+
24 => 1,
|
43 |
+
25 => 1,
|
44 |
+
28 => 1,
|
45 |
+
29 => 1,
|
46 |
+
30 => 1,
|
47 |
+
33 => 1,
|
48 |
+
34 => 2,
|
49 |
+
36 => 1,
|
50 |
+
38 => 1,
|
51 |
+
39 => 1,
|
52 |
+
40 => 1,
|
53 |
+
44 => 1,
|
54 |
+
45 => 1,
|
55 |
+
46 => 1,
|
56 |
+
50 => 1,
|
57 |
+
51 => 1,
|
58 |
+
52 => 1,
|
59 |
+
55 => 1,
|
60 |
+
56 => 1,
|
61 |
+
57 => 1,
|
62 |
+
58 => 1,
|
63 |
+
60 => 1,
|
64 |
+
61 => 1,
|
65 |
+
66 => 1,
|
66 |
+
80 => 1,
|
67 |
+
85 => 1,
|
68 |
+
88 => 1,
|
69 |
+
103 => 1,
|
70 |
+
104 => 1,
|
71 |
+
105 => 1,
|
72 |
+
111 => 1,
|
73 |
+
112 => 1,
|
74 |
+
113 => 1,
|
75 |
+
120 => 1,
|
76 |
+
121 => 1,
|
77 |
+
122 => 1,
|
78 |
+
132 => 1,
|
79 |
+
133 => 1,
|
80 |
+
134 => 1,
|
81 |
+
140 => 1,
|
82 |
+
141 => 1,
|
83 |
+
142 => 1,
|
84 |
+
151 => 1,
|
85 |
+
152 => 1,
|
86 |
+
153 => 1,
|
87 |
+
156 => 1,
|
88 |
+
157 => 1,
|
89 |
+
175 => 1,
|
90 |
+
179 => 1,
|
91 |
+
185 => 1,
|
92 |
+
198 => 1,
|
93 |
+
202 => 1,
|
94 |
+
209 => 1,
|
95 |
+
218 => 1,
|
96 |
+
219 => 1,
|
97 |
+
251 => 1,
|
98 |
+
252 => 1,
|
99 |
+
253 => 1,
|
100 |
+
254 => 1,
|
101 |
+
255 => 1,
|
102 |
+
260 => 1,
|
103 |
+
261 => 1,
|
104 |
+
262 => 1,
|
105 |
+
263 => 1,
|
106 |
+
264 => 1,
|
107 |
+
269 => 1,
|
108 |
+
271 => 1,
|
109 |
+
273 => 1,
|
110 |
+
274 => 1,
|
111 |
+
279 => 1,
|
112 |
+
280 => 1,
|
113 |
+
286 => 1,
|
114 |
+
287 => 1,
|
115 |
+
293 => 1,
|
116 |
+
294 => 1,
|
117 |
+
300 => 1,
|
118 |
+
301 => 1,
|
119 |
+
307 => 1,
|
120 |
+
308 => 1,
|
121 |
+
315 => 1,
|
122 |
+
316 => 1,
|
123 |
+
323 => 1,
|
124 |
+
324 => 1,
|
125 |
+
331 => 1,
|
126 |
+
332 => 1,
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Returns the lines where warnings should occur.
|
132 |
+
*
|
133 |
+
* @return array <int line number> => <int number of warnings>
|
134 |
+
*/
|
135 |
+
public function getWarningList() {
|
136 |
+
return array();
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.inc
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Good.
|
5 |
+
*/
|
6 |
+
$good = array();
|
7 |
+
|
8 |
+
$good = array( 1, 2, 3 );
|
9 |
+
$good = [ 'a', 'b', 'c' ];
|
10 |
+
|
11 |
+
$good = array(
|
12 |
+
1,
|
13 |
+
2,
|
14 |
+
3,
|
15 |
+
);
|
16 |
+
$good = [
|
17 |
+
'a',
|
18 |
+
'b',
|
19 |
+
'c',
|
20 |
+
];
|
21 |
+
|
22 |
+
$good = array(
|
23 |
+
1 => 'value',
|
24 |
+
2 => array( 1 ),
|
25 |
+
3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
26 |
+
);
|
27 |
+
$good = [
|
28 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
29 |
+
'b' => array( 1 ),
|
30 |
+
'c' => apply_filters( 'filter', $input, $var ),
|
31 |
+
];
|
32 |
+
|
33 |
+
// OK: that this should be a multi-line array is not the concern of this sniff.
|
34 |
+
$good = array( 1 => 'a', 2 => 'b', 3 => 'c' );
|
35 |
+
$good = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
|
36 |
+
|
37 |
+
$good = array( 1, 2, // OK: that each item should be on its own line or single line array is not the concern of this sniff.
|
38 |
+
3, ); // OK: that the brace should be on another line is not the concern of this sniff.
|
39 |
+
|
40 |
+
/*
|
41 |
+
* Bad.
|
42 |
+
*/
|
43 |
+
// Spacing before comma.
|
44 |
+
$bad = array( 1 , 2 , 3 ); // Bad x2.
|
45 |
+
$bad = [ 'a' , 'b' , 'c' ]; // Bad x2.
|
46 |
+
|
47 |
+
// Spacing after comma.
|
48 |
+
$bad = array( 1,2, 3 ); // Bad x2.
|
49 |
+
$bad = [ 'a','b', 'c' ]; // Bad x2.
|
50 |
+
|
51 |
+
// Comma after last.
|
52 |
+
$bad = array( 1, 2, 3, );
|
53 |
+
$bad = [ 'a', 'b', 'c', ];
|
54 |
+
|
55 |
+
// Spacing before comma.
|
56 |
+
$bad = array(
|
57 |
+
1 => 'value' ,
|
58 |
+
2 => array( 1 ) ,
|
59 |
+
3 => apply_filters( 'filter', $input, $var ) , /* Comment. */
|
60 |
+
);
|
61 |
+
$bad = [
|
62 |
+
'a' => 'value' , // Comment - the extra spacing is fine, might be for alignment with other comments.
|
63 |
+
'b' => array( 1 )
|
64 |
+
|
65 |
+
|
66 |
+
,
|
67 |
+
'c' => apply_filters( 'filter', $input, $var ) ,
|
68 |
+
];
|
69 |
+
|
70 |
+
// NO spacing after comma.
|
71 |
+
$bad = array(
|
72 |
+
3 => apply_filters( 'filter', $input, $var ),/* Comment. */
|
73 |
+
);
|
74 |
+
$bad = [
|
75 |
+
'a' => 'value',// Comment.
|
76 |
+
];
|
77 |
+
|
78 |
+
// NO comma after last.
|
79 |
+
$bad = array(
|
80 |
+
1 => 'value',
|
81 |
+
2 => array( 1 ),
|
82 |
+
3 => apply_filters( 'filter', $input, $var )/* Comment. */
|
83 |
+
);
|
84 |
+
$bad = [
|
85 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
86 |
+
'b' => array( 1 ),
|
87 |
+
'c' => apply_filters( 'filter', $input, $var )
|
88 |
+
];
|
89 |
+
|
90 |
+
$bad = array( 1 => 'a' , 2 => 'b',3 => 'c', );
|
91 |
+
$bad = [ 'a' => 1 , 'b' => 2,'c' => 3, ];
|
92 |
+
|
93 |
+
$bad = array( 1 , 2,
|
94 |
+
3 );
|
95 |
+
|
96 |
+
// Combining a lot of errors in a nested array.
|
97 |
+
$bad = array(
|
98 |
+
1 => 'value' ,
|
99 |
+
2 => [
|
100 |
+
'a' => 'value' ,// Comment - the extra spacing is fine, might be for alignment with other comments.
|
101 |
+
'b' => array(
|
102 |
+
1
|
103 |
+
),
|
104 |
+
'c' => apply_filters( 'filter', $input, $var )
|
105 |
+
],
|
106 |
+
3 => apply_filters( 'filter', $input, $var )/* Comment. */
|
107 |
+
);
|
108 |
+
|
109 |
+
// Alternative array style.
|
110 |
+
$bad = array(
|
111 |
+
1 => 'value'
|
112 |
+
, 2 => array( 1 )
|
113 |
+
, 3 => apply_filters( 'filter', $input, $var )/* Comment. */
|
114 |
+
);
|
115 |
+
$bad = [
|
116 |
+
'a' => 'value' // Comment - the extra spacing is fine, might be for alignment with other comments.
|
117 |
+
, 'b' => array( 1 )
|
118 |
+
, 'c' => apply_filters( 'filter', $input, $var )
|
119 |
+
];
|
120 |
+
$bad = [
|
121 |
+
'a' => 'value' // Comment - the extra spacing is fine, might be for alignment with other comments.
|
122 |
+
,'b' => array( 1 )
|
123 |
+
,'c' => apply_filters( 'filter', $input, $var ),
|
124 |
+
];
|
125 |
+
|
126 |
+
$bad = array(
|
127 |
+
'first',
|
128 |
+
'second'
|
129 |
+
//'third',
|
130 |
+
);
|
131 |
+
|
132 |
+
$bad = array(
|
133 |
+
'key3' => function($bar) {
|
134 |
+
return $bar;
|
135 |
+
}
|
136 |
+
);
|
137 |
+
|
138 |
+
// Issue #998.
|
139 |
+
$a = array(
|
140 |
+
'foo' => bar( 1, 29 ));
|
141 |
+
|
142 |
+
// Issue #986.
|
143 |
+
get_current_screen()->add_help_tab( array(
|
144 |
+
'id' => <<<EOD
|
145 |
+
Here comes some text.
|
146 |
+
EOD
|
147 |
+
,
|
148 |
+
) );
|
149 |
+
|
150 |
+
get_current_screen()->add_help_tab( array(
|
151 |
+
'id' => <<<EOD
|
152 |
+
Here comes some text.
|
153 |
+
EOD
|
154 |
+
. '</hr>',
|
155 |
+
) );
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.inc.fixed
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Good.
|
5 |
+
*/
|
6 |
+
$good = array();
|
7 |
+
|
8 |
+
$good = array( 1, 2, 3 );
|
9 |
+
$good = [ 'a', 'b', 'c' ];
|
10 |
+
|
11 |
+
$good = array(
|
12 |
+
1,
|
13 |
+
2,
|
14 |
+
3,
|
15 |
+
);
|
16 |
+
$good = [
|
17 |
+
'a',
|
18 |
+
'b',
|
19 |
+
'c',
|
20 |
+
];
|
21 |
+
|
22 |
+
$good = array(
|
23 |
+
1 => 'value',
|
24 |
+
2 => array( 1 ),
|
25 |
+
3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
26 |
+
);
|
27 |
+
$good = [
|
28 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
29 |
+
'b' => array( 1 ),
|
30 |
+
'c' => apply_filters( 'filter', $input, $var ),
|
31 |
+
];
|
32 |
+
|
33 |
+
// OK: that this should be a multi-line array is not the concern of this sniff.
|
34 |
+
$good = array( 1 => 'a', 2 => 'b', 3 => 'c' );
|
35 |
+
$good = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
|
36 |
+
|
37 |
+
$good = array( 1, 2, // OK: that each item should be on its own line or single line array is not the concern of this sniff.
|
38 |
+
3, ); // OK: that the brace should be on another line is not the concern of this sniff.
|
39 |
+
|
40 |
+
/*
|
41 |
+
* Bad.
|
42 |
+
*/
|
43 |
+
// Spacing before comma.
|
44 |
+
$bad = array( 1, 2, 3 ); // Bad x2.
|
45 |
+
$bad = [ 'a', 'b', 'c' ]; // Bad x2.
|
46 |
+
|
47 |
+
// Spacing after comma.
|
48 |
+
$bad = array( 1, 2, 3 ); // Bad x2.
|
49 |
+
$bad = [ 'a', 'b', 'c' ]; // Bad x2.
|
50 |
+
|
51 |
+
// Comma after last.
|
52 |
+
$bad = array( 1, 2, 3 );
|
53 |
+
$bad = [ 'a', 'b', 'c' ];
|
54 |
+
|
55 |
+
// Spacing before comma.
|
56 |
+
$bad = array(
|
57 |
+
1 => 'value',
|
58 |
+
2 => array( 1 ),
|
59 |
+
3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
60 |
+
);
|
61 |
+
$bad = [
|
62 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
63 |
+
'b' => array( 1 ),
|
64 |
+
'c' => apply_filters( 'filter', $input, $var ),
|
65 |
+
];
|
66 |
+
|
67 |
+
// NO spacing after comma.
|
68 |
+
$bad = array(
|
69 |
+
3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
70 |
+
);
|
71 |
+
$bad = [
|
72 |
+
'a' => 'value', // Comment.
|
73 |
+
];
|
74 |
+
|
75 |
+
// NO comma after last.
|
76 |
+
$bad = array(
|
77 |
+
1 => 'value',
|
78 |
+
2 => array( 1 ),
|
79 |
+
3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
80 |
+
);
|
81 |
+
$bad = [
|
82 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
83 |
+
'b' => array( 1 ),
|
84 |
+
'c' => apply_filters( 'filter', $input, $var ),
|
85 |
+
];
|
86 |
+
|
87 |
+
$bad = array( 1 => 'a', 2 => 'b', 3 => 'c' );
|
88 |
+
$bad = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
|
89 |
+
|
90 |
+
$bad = array( 1, 2,
|
91 |
+
3, );
|
92 |
+
|
93 |
+
// Combining a lot of errors in a nested array.
|
94 |
+
$bad = array(
|
95 |
+
1 => 'value',
|
96 |
+
2 => [
|
97 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
98 |
+
'b' => array(
|
99 |
+
1,
|
100 |
+
),
|
101 |
+
'c' => apply_filters( 'filter', $input, $var ),
|
102 |
+
],
|
103 |
+
3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
104 |
+
);
|
105 |
+
|
106 |
+
// Alternative array style.
|
107 |
+
$bad = array(
|
108 |
+
1 => 'value', 2 => array( 1 ), 3 => apply_filters( 'filter', $input, $var ), /* Comment. */
|
109 |
+
);
|
110 |
+
$bad = [
|
111 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
112 |
+
'b' => array( 1 ), 'c' => apply_filters( 'filter', $input, $var ),
|
113 |
+
];
|
114 |
+
$bad = [
|
115 |
+
'a' => 'value', // Comment - the extra spacing is fine, might be for alignment with other comments.
|
116 |
+
'b' => array( 1 ), 'c' => apply_filters( 'filter', $input, $var ),
|
117 |
+
];
|
118 |
+
|
119 |
+
$bad = array(
|
120 |
+
'first',
|
121 |
+
'second',
|
122 |
+
//'third',
|
123 |
+
);
|
124 |
+
|
125 |
+
$bad = array(
|
126 |
+
'key3' => function($bar) {
|
127 |
+
return $bar;
|
128 |
+
},
|
129 |
+
);
|
130 |
+
|
131 |
+
// Issue #998.
|
132 |
+
$a = array(
|
133 |
+
'foo' => bar( 1, 29 ), );
|
134 |
+
|
135 |
+
// Issue #986.
|
136 |
+
get_current_screen()->add_help_tab( array(
|
137 |
+
'id' => <<<EOD
|
138 |
+
Here comes some text.
|
139 |
+
EOD
|
140 |
+
,
|
141 |
+
) );
|
142 |
+
|
143 |
+
get_current_screen()->add_help_tab( array(
|
144 |
+
'id' => <<<EOD
|
145 |
+
Here comes some text.
|
146 |
+
EOD
|
147 |
+
. '</hr>',
|
148 |
+
) );
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the Arrays.CommaAfterArrayItem sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_Arrays_CommaAfterArrayItemUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @return array <int line number> => <int number of errors>
|
22 |
+
*/
|
23 |
+
public function getErrorList() {
|
24 |
+
return array(
|
25 |
+
44 => 2,
|
26 |
+
45 => 2,
|
27 |
+
48 => 2,
|
28 |
+
49 => 2,
|
29 |
+
52 => 1,
|
30 |
+
53 => 1,
|
31 |
+
57 => 1,
|
32 |
+
58 => 1,
|
33 |
+
59 => 1,
|
34 |
+
62 => 1,
|
35 |
+
66 => 1,
|
36 |
+
67 => 1,
|
37 |
+
72 => 1,
|
38 |
+
75 => 1,
|
39 |
+
82 => 1,
|
40 |
+
87 => 1,
|
41 |
+
90 => 4,
|
42 |
+
91 => 4,
|
43 |
+
93 => 2,
|
44 |
+
94 => 1,
|
45 |
+
98 => 1,
|
46 |
+
100 => 2,
|
47 |
+
102 => 1,
|
48 |
+
104 => 1,
|
49 |
+
106 => 1,
|
50 |
+
112 => 1,
|
51 |
+
113 => 2,
|
52 |
+
117 => 1,
|
53 |
+
118 => 2,
|
54 |
+
122 => 2,
|
55 |
+
123 => 2,
|
56 |
+
128 => 1,
|
57 |
+
135 => 1,
|
58 |
+
140 => 1,
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns the lines where warnings should occur.
|
64 |
+
*
|
65 |
+
* @return array <int line number> => <int number of warnings>
|
66 |
+
*/
|
67 |
+
public function getWarningList() {
|
68 |
+
return array();
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.1.inc
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* All OK.
|
4 |
+
*/
|
5 |
+
$a = new MyClass();
|
6 |
+
$a = new MyClass( $something );
|
7 |
+
$a = new $varHoldingClassName();
|
8 |
+
$a = new self::$transport[$cap_string]();
|
9 |
+
$renderer = new $this->inline_diff_renderer();
|
10 |
+
$b = ( new MyClass() )->my_function();
|
11 |
+
$b = ( new MyClass() )::$property;
|
12 |
+
|
13 |
+
class ClassA {
|
14 |
+
public static function get_instance() {
|
15 |
+
return new self();
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function get_other_instance() {
|
19 |
+
return new static();
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
class ClassB extends ClassA {
|
24 |
+
public function get_parent_instance() {
|
25 |
+
return new parent();
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
// PHP 7: Anonymous classes.
|
30 |
+
$util->setLogger( new class() {} );
|
31 |
+
$b = new class( 10 ) extends SomeClass implements SomeInterface {};
|
32 |
+
|
33 |
+
|
34 |
+
/*
|
35 |
+
* Bad.
|
36 |
+
*/
|
37 |
+
$a = new MyClass;
|
38 |
+
$a = new $varHoldingClassName;
|
39 |
+
$a = new self::$transport[$cap_string];
|
40 |
+
$renderer = new $this->inline_diff_renderer;
|
41 |
+
$b = ( new MyClass )->my_function();
|
42 |
+
$b = ( new MyClass )::$property;
|
43 |
+
|
44 |
+
class ClassA {
|
45 |
+
public static function get_instance() {
|
46 |
+
return new self;
|
47 |
+
}
|
48 |
+
|
49 |
+
public static function get_other_instance() {
|
50 |
+
return new static;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
class ClassB extends ClassA {
|
55 |
+
public function get_parent_instance() {
|
56 |
+
return new parent;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
// PHP 7: Anonymous classes.
|
61 |
+
$util->setLogger( new class {} );
|
62 |
+
$b = new class extends SomeClass implements SomeInterface {};
|
63 |
+
|
64 |
+
|
65 |
+
// Test some non-typical spacing.
|
66 |
+
$renderer = new $this->
|
67 |
+
inline_diff_renderer ();
|
68 |
+
$renderer = new $this-> // There can be a comment here.
|
69 |
+
inline_diff_renderer ();
|
70 |
+
$renderer = new $this->
|
71 |
+
inline_diff_renderer /* or here */ ();
|
72 |
+
$a = new self :: $transport [ $cap_string ] ();
|
73 |
+
|
74 |
+
$renderer = new $this->
|
75 |
+
inline_diff_renderer;
|
76 |
+
$renderer = new $this-> // There can be a comment here.
|
77 |
+
inline_diff_renderer;
|
78 |
+
$renderer = new $this->
|
79 |
+
inline_diff_renderer /* or here */ ;
|
80 |
+
$a = new self :: $transport [ $cap_string ];
|
81 |
+
|
82 |
+
|
83 |
+
// Assigning new by reference.
|
84 |
+
$b = &new Foobar();
|
85 |
+
$b = & new Foobar();
|
86 |
+
|
87 |
+
|
88 |
+
// Currently not accounted for by the sniff, i.e. false negatives.
|
89 |
+
$a = new $$varHoldingClassName;
|
90 |
+
$a = new ${$varHoldingClassName};
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.1.inc.fixed
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* All OK.
|
4 |
+
*/
|
5 |
+
$a = new MyClass();
|
6 |
+
$a = new MyClass( $something );
|
7 |
+
$a = new $varHoldingClassName();
|
8 |
+
$a = new self::$transport[$cap_string]();
|
9 |
+
$renderer = new $this->inline_diff_renderer();
|
10 |
+
$b = ( new MyClass() )->my_function();
|
11 |
+
$b = ( new MyClass() )::$property;
|
12 |
+
|
13 |
+
class ClassA {
|
14 |
+
public static function get_instance() {
|
15 |
+
return new self();
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function get_other_instance() {
|
19 |
+
return new static();
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
class ClassB extends ClassA {
|
24 |
+
public function get_parent_instance() {
|
25 |
+
return new parent();
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
// PHP 7: Anonymous classes.
|
30 |
+
$util->setLogger( new class() {} );
|
31 |
+
$b = new class( 10 ) extends SomeClass implements SomeInterface {};
|
32 |
+
|
33 |
+
|
34 |
+
/*
|
35 |
+
* Bad.
|
36 |
+
*/
|
37 |
+
$a = new MyClass();
|
38 |
+
$a = new $varHoldingClassName();
|
39 |
+
$a = new self::$transport[$cap_string]();
|
40 |
+
$renderer = new $this->inline_diff_renderer();
|
41 |
+
$b = ( new MyClass() )->my_function();
|
42 |
+
$b = ( new MyClass() )::$property;
|
43 |
+
|
44 |
+
class ClassA {
|
45 |
+
public static function get_instance() {
|
46 |
+
return new self();
|
47 |
+
}
|
48 |
+
|
49 |
+
public static function get_other_instance() {
|
50 |
+
return new static();
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
class ClassB extends ClassA {
|
55 |
+
public function get_parent_instance() {
|
56 |
+
return new parent();
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
// PHP 7: Anonymous classes.
|
61 |
+
$util->setLogger( new class() {} );
|
62 |
+
$b = new class() extends SomeClass implements SomeInterface {};
|
63 |
+
|
64 |
+
|
65 |
+
// Test some non-typical spacing.
|
66 |
+
$renderer = new $this->
|
67 |
+
inline_diff_renderer();
|
68 |
+
$renderer = new $this-> // There can be a comment here.
|
69 |
+
inline_diff_renderer();
|
70 |
+
$renderer = new $this->
|
71 |
+
inline_diff_renderer /* or here */ ();
|
72 |
+
$a = new self :: $transport [ $cap_string ]();
|
73 |
+
|
74 |
+
$renderer = new $this->
|
75 |
+
inline_diff_renderer();
|
76 |
+
$renderer = new $this-> // There can be a comment here.
|
77 |
+
inline_diff_renderer();
|
78 |
+
$renderer = new $this->
|
79 |
+
inline_diff_renderer() /* or here */ ;
|
80 |
+
$a = new self :: $transport [ $cap_string ]();
|
81 |
+
|
82 |
+
|
83 |
+
// Assigning new by reference.
|
84 |
+
$b = &new Foobar();
|
85 |
+
$b = & new Foobar();
|
86 |
+
|
87 |
+
|
88 |
+
// Currently not accounted for by the sniff, i.e. false negatives.
|
89 |
+
$a = new $$varHoldingClassName;
|
90 |
+
$a = new ${$varHoldingClassName};
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.2.inc
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Test cases which can't be tested on PHP 5.2.
|
4 |
+
*/
|
5 |
+
|
6 |
+
/*
|
7 |
+
* All OK.
|
8 |
+
*/
|
9 |
+
$a = new \MyClass();
|
10 |
+
$a = new \MyNamespace\MyClass();
|
11 |
+
|
12 |
+
|
13 |
+
/*
|
14 |
+
* Bad.
|
15 |
+
*/
|
16 |
+
$a = new \MyClass;
|
17 |
+
$a = new \MyNamespace\MyClass;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.2.inc.fixed
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Test cases which can't be tested on PHP 5.2.
|
4 |
+
*/
|
5 |
+
|
6 |
+
/*
|
7 |
+
* All OK.
|
8 |
+
*/
|
9 |
+
$a = new \MyClass();
|
10 |
+
$a = new \MyNamespace\MyClass();
|
11 |
+
|
12 |
+
|
13 |
+
/*
|
14 |
+
* Bad.
|
15 |
+
*/
|
16 |
+
$a = new \MyClass();
|
17 |
+
$a = new \MyNamespace\MyClass();
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
var firstBook = new Book(); // OK.
|
2 |
+
var secondBook = new Book; // Bad.
|
3 |
+
var thirdBook = new Book (); // Bad.
|
4 |
+
var fourthBook = new Book ( 'title' ); // Bad.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.js.fixed
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
var firstBook = new Book(); // OK.
|
2 |
+
var secondBook = new Book(); // Bad.
|
3 |
+
var thirdBook = new Book(); // Bad.
|
4 |
+
var fourthBook = new Book( 'title' ); // Bad.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Classes/ClassInstantiationUnitTest.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the ClassInstantiation sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_Classes_ClassInstantiationUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get a list of all test files to check.
|
20 |
+
*
|
21 |
+
* @param string $testFileBase The base path that the unit tests files will have.
|
22 |
+
*
|
23 |
+
* @return string[]
|
24 |
+
*/
|
25 |
+
protected function getTestFiles( $testFileBase ) {
|
26 |
+
$testFiles = parent::getTestFiles( $testFileBase );
|
27 |
+
|
28 |
+
if ( PHP_VERSION_ID < 50300 ) {
|
29 |
+
$testFiles = array_diff( $testFiles, array( $testFileBase . '2.inc' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
return $testFiles;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Returns the lines where errors should occur.
|
37 |
+
*
|
38 |
+
* @param string $testFile The name of the file being tested.
|
39 |
+
* @return array <int line number> => <int number of errors>
|
40 |
+
*/
|
41 |
+
public function getErrorList( $testFile = '' ) {
|
42 |
+
|
43 |
+
switch ( $testFile ) {
|
44 |
+
case 'ClassInstantiationUnitTest.1.inc':
|
45 |
+
return array(
|
46 |
+
37 => 1,
|
47 |
+
38 => 1,
|
48 |
+
39 => 1,
|
49 |
+
40 => 1,
|
50 |
+
41 => 1,
|
51 |
+
42 => 1,
|
52 |
+
46 => 1,
|
53 |
+
50 => 1,
|
54 |
+
56 => 1,
|
55 |
+
61 => 1,
|
56 |
+
62 => 1,
|
57 |
+
67 => 1,
|
58 |
+
69 => 1,
|
59 |
+
71 => 1,
|
60 |
+
72 => 1,
|
61 |
+
75 => 1,
|
62 |
+
77 => 1,
|
63 |
+
79 => 1,
|
64 |
+
80 => 1,
|
65 |
+
84 => 1,
|
66 |
+
85 => 1,
|
67 |
+
);
|
68 |
+
|
69 |
+
case 'ClassInstantiationUnitTest.2.inc':
|
70 |
+
return array(
|
71 |
+
16 => 1,
|
72 |
+
17 => 1,
|
73 |
+
);
|
74 |
+
|
75 |
+
case 'ClassInstantiationUnitTest.js':
|
76 |
+
return array(
|
77 |
+
2 => 1,
|
78 |
+
3 => 1,
|
79 |
+
4 => 1,
|
80 |
+
);
|
81 |
+
|
82 |
+
default:
|
83 |
+
return array();
|
84 |
+
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns the lines where warnings should occur.
|
90 |
+
*
|
91 |
+
* @return array <int line number> => <int number of warnings>
|
92 |
+
*/
|
93 |
+
public function getWarningList() {
|
94 |
+
return array();
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.inc
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Test empty statement: two consecutive semicolons without executable code between them.
|
5 |
+
*/
|
6 |
+
function_call(); // OK.
|
7 |
+
|
8 |
+
// The below examples are all bad.
|
9 |
+
function_call();;
|
10 |
+
|
11 |
+
function_call();
|
12 |
+
;
|
13 |
+
|
14 |
+
function_call();
|
15 |
+
/* some comment */;
|
16 |
+
|
17 |
+
function_call();
|
18 |
+
/* some comment */ ;
|
19 |
+
|
20 |
+
?>
|
21 |
+
<input name="<?php ; something_else(); ?>" />
|
22 |
+
<input name="<?php something_else(); ; ?>" />
|
23 |
+
|
24 |
+
/*
|
25 |
+
* Test empty statement: no code between PHP open and close tag.
|
26 |
+
*/
|
27 |
+
<input name="<?php something_else() ?>" /> <!-- OK. -->
|
28 |
+
<input name="<?php something_else(); ?>" /> <!-- OK. -->
|
29 |
+
<input name="<?php /* comment */ ?>" /> <!-- OK. -->
|
30 |
+
|
31 |
+
<input name="<?php ?>" /> <!-- Bad. -->
|
32 |
+
|
33 |
+
<input name="<?php
|
34 |
+
|
35 |
+
|
36 |
+
?>" /> <!-- Bad. -->
|
37 |
+
|
38 |
+
<!--
|
39 |
+
/*
|
40 |
+
* Test detecting & fixing a combination of the two above checks.
|
41 |
+
*/
|
42 |
+
-->
|
43 |
+
<?php ; ?>
|
44 |
+
|
45 |
+
<input name="<?php ; ?>" />
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.inc.fixed
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Test empty statement: two consecutive semicolons without executable code between them.
|
5 |
+
*/
|
6 |
+
function_call(); // OK.
|
7 |
+
|
8 |
+
// The below examples are all bad.
|
9 |
+
function_call();
|
10 |
+
|
11 |
+
function_call();
|
12 |
+
|
13 |
+
function_call();
|
14 |
+
/* some comment */
|
15 |
+
|
16 |
+
function_call();
|
17 |
+
/* some comment */
|
18 |
+
|
19 |
+
?>
|
20 |
+
<input name="<?php something_else(); ?>" />
|
21 |
+
<input name="<?php something_else(); ?>" />
|
22 |
+
|
23 |
+
/*
|
24 |
+
* Test empty statement: no code between PHP open and close tag.
|
25 |
+
*/
|
26 |
+
<input name="<?php something_else() ?>" /> <!-- OK. -->
|
27 |
+
<input name="<?php something_else(); ?>" /> <!-- OK. -->
|
28 |
+
<input name="<?php /* comment */ ?>" /> <!-- OK. -->
|
29 |
+
|
30 |
+
<input name="" /> <!-- Bad. -->
|
31 |
+
|
32 |
+
<input name="" /> <!-- Bad. -->
|
33 |
+
|
34 |
+
<!--
|
35 |
+
/*
|
36 |
+
* Test detecting & fixing a combination of the two above checks.
|
37 |
+
*/
|
38 |
+
-->
|
39 |
+
|
40 |
+
<input name="" />
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/CodeAnalysis/EmptyStatementUnitTest.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the EmptyStatement sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_CodeAnalysis_EmptyStatementUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @return array <int line number> => <int number of errors>
|
22 |
+
*/
|
23 |
+
public function getErrorList() {
|
24 |
+
return array();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Returns the lines where warnings should occur.
|
29 |
+
*
|
30 |
+
* @return array <int line number> => <int number of warnings>
|
31 |
+
*/
|
32 |
+
public function getWarningList() {
|
33 |
+
return array(
|
34 |
+
9 => 1,
|
35 |
+
12 => 1,
|
36 |
+
15 => 1,
|
37 |
+
18 => 1,
|
38 |
+
21 => 1,
|
39 |
+
22 => 1,
|
40 |
+
31 => 1,
|
41 |
+
33 => 1,
|
42 |
+
43 => 1,
|
43 |
+
45 => 1,
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTest.php
CHANGED
@@ -48,6 +48,14 @@ class WordPress_Tests_Files_FileNameUnitTest extends AbstractSniffUnitTest {
|
|
48 |
// Non-strict class names still have to comply with lowercase hyphenated.
|
49 |
'ClassNonStrictClass.inc' => 1,
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/*
|
52 |
* In /FileNameUnitTests/ThemeExceptions.
|
53 |
*/
|
@@ -80,8 +88,13 @@ class WordPress_Tests_Files_FileNameUnitTest extends AbstractSniffUnitTest {
|
|
80 |
* @return string[]
|
81 |
*/
|
82 |
protected function getTestFiles( $testFileBase ) {
|
83 |
-
$sep
|
84 |
-
$test_files
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
if ( ! empty( $test_files ) ) {
|
87 |
return $test_files;
|
48 |
// Non-strict class names still have to comply with lowercase hyphenated.
|
49 |
'ClassNonStrictClass.inc' => 1,
|
50 |
|
51 |
+
/*
|
52 |
+
* In /FileNameUnitTests/TestFiles.
|
53 |
+
*/
|
54 |
+
'test-sample-phpunit.inc' => 0,
|
55 |
+
'test-sample-phpunit6.inc' => 0,
|
56 |
+
'test-sample-wpunit.inc' => 0,
|
57 |
+
'test-sample-custom-unit.inc' => 0,
|
58 |
+
|
59 |
/*
|
60 |
* In /FileNameUnitTests/ThemeExceptions.
|
61 |
*/
|
88 |
* @return string[]
|
89 |
*/
|
90 |
protected function getTestFiles( $testFileBase ) {
|
91 |
+
$sep = DIRECTORY_SEPARATOR;
|
92 |
+
$test_files = glob( dirname( $testFileBase ) . $sep . 'FileNameUnitTests{' . $sep . ',' . $sep . '*' . $sep . '}*.inc', GLOB_BRACE );
|
93 |
+
|
94 |
+
// Adjust the expected results array for PHP 5.2 as PHP 5.2 does not recognize namespaces.
|
95 |
+
if ( PHP_VERSION_ID < 50300 ) {
|
96 |
+
$this->expected_results['test-sample-phpunit6.inc'] = 1;
|
97 |
+
}
|
98 |
|
99 |
if ( ! empty( $test_files ) ) {
|
100 |
return $test_files;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/NonStrictClassNames/ClassNonStrictClass.inc
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
@codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names false
|
|
|
2 |
<?php
|
3 |
|
4 |
class Non_Strict_Class {}
|
5 |
-
|
|
1 |
@codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names false
|
2 |
+
|
3 |
<?php
|
4 |
|
5 |
class Non_Strict_Class {}
|
6 |
+
|
7 |
+
// @codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/NonStrictClassNames/non-strict-class.inc
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
@codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names false
|
|
|
2 |
<?php
|
3 |
|
4 |
class Non_Strict_Class {}
|
5 |
-
|
|
1 |
@codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names false
|
2 |
+
|
3 |
<?php
|
4 |
|
5 |
class Non_Strict_Class {}
|
6 |
+
|
7 |
+
// @codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/NonStrictClassNames/unrelated-filename.inc
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
@codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names false
|
|
|
2 |
<?php
|
3 |
|
4 |
class My_Class {}
|
5 |
-
|
|
1 |
@codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names false
|
2 |
+
|
3 |
<?php
|
4 |
|
5 |
class My_Class {}
|
6 |
+
|
7 |
+
// @codingStandardsChangeSetting WordPress.Files.FileName strict_class_file_names true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-custom-unit.inc
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName custom_test_class_whitelist My_TestClass
|
2 |
+
<?php
|
3 |
+
|
4 |
+
class TestSample extends My_TestClass {}
|
5 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName custom_test_class_whitelist false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-phpunit.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class TestSample extends PHPUnit_Framework_TestCase {}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-phpunit6.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class TestSample extends PHPUnit\Framework\TestCase {}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/TestFiles/test-sample-wpunit.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class TestSample extends WP_UnitTestCase {}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/category-another_slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/category-slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/content-another_slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/content-slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/page-slug_slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/tag-another_slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Files/FileNameUnitTests/ThemeExceptions/tag-slug.inc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
@codingStandardsChangeSetting WordPress.Files.FileName is_theme true
|
2 |
+
<?php
|
3 |
+
/* @codingStandardsChangeSetting WordPress.Files.FileName is_theme false */
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Functions/FunctionCallSignatureNoParamsUnitTest.inc
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
ms_cookie_constants(); // OK.
|
4 |
+
ms_cookie_constants( ); // Bad.
|
5 |
+
ms_cookie_constants( ); // Bad.
|
6 |
+
|
7 |
+
// These should be ignored as these are handled by the PEAR.Functions.FunctionCallSignature sniff.
|
8 |
+
ms_cookie_constants($something);
|
9 |
+
ms_cookie_constants( $something );
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Functions/FunctionCallSignatureNoParamsUnitTest.inc.fixed
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
ms_cookie_constants(); // OK.
|
4 |
+
ms_cookie_constants(); // Bad.
|
5 |
+
ms_cookie_constants(); // Bad.
|
6 |
+
|
7 |
+
// These should be ignored as these are handled by the PEAR.Functions.FunctionCallSignature sniff.
|
8 |
+
ms_cookie_constants($something);
|
9 |
+
ms_cookie_constants( $something );
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Functions/FunctionCallSignatureNoParamsUnitTest.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the FunctionCallSignatureNoParams sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_Functions_FunctionCallSignatureNoParamsUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @return array <int line number> => <int number of errors>
|
22 |
+
*/
|
23 |
+
public function getErrorList() {
|
24 |
+
return array(
|
25 |
+
4 => 1,
|
26 |
+
5 => 1,
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Returns the lines where warnings should occur.
|
32 |
+
*
|
33 |
+
* @return array <int line number> => <int number of warnings>
|
34 |
+
*/
|
35 |
+
public function getWarningList() {
|
36 |
+
return array();
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes acronym,tgmpa
|
3 |
+
|
4 |
+
/*
|
5 |
+
* OK - not in the global namespace.
|
6 |
+
*/
|
7 |
+
namespace Acronym;
|
8 |
+
|
9 |
+
function do_something() {}
|
10 |
+
|
11 |
+
const SOME_CONSTANT = 'value';
|
12 |
+
|
13 |
+
class Example {}
|
14 |
+
interface I_Example {}
|
15 |
+
trait T_Example {}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.inc
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Bad: invalid prefix passed
|
5 |
+
*/
|
6 |
+
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes wp
|
7 |
+
function wp_do_something() {}
|
8 |
+
|
9 |
+
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes ^%&
|
10 |
+
function ^%&_do_something() {}
|
11 |
+
|
12 |
+
// Now let's set the real prefixes we want to test for.
|
13 |
+
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes acronym,tgmpa
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Bad - not prefixed.
|
17 |
+
*/
|
18 |
+
function do_something() {
|
19 |
+
global $something, $else;
|
20 |
+
|
21 |
+
$something = 'value';
|
22 |
+
$GLOBALS['something'] = 'value';
|
23 |
+
$GLOBALS[ 'something' . $else ] = 'value';
|
24 |
+
$GLOBALS[ "something_{$else}" ] = 'value';
|
25 |
+
$GLOBALS[ "something$else" ] = 'value';
|
26 |
+
}
|
27 |
+
|
28 |
+
$var = 'abc';
|
29 |
+
|
30 |
+
define( 'SOME_CONSTANT', 'value' );
|
31 |
+
const SOME_CONSTANT = 'value';
|
32 |
+
|
33 |
+
class Example {}
|
34 |
+
interface Example_Interface {}
|
35 |
+
trait Example_Trait {}
|
36 |
+
|
37 |
+
do_action( 'plugin_action' );
|
38 |
+
apply_filters( 'theme_filter', $var );
|
39 |
+
do_action( "plugin_action_{$acronym_filter_var}" );
|
40 |
+
apply_filters( 'theme_filter_' . $acronym_filter_var );
|
41 |
+
|
42 |
+
|
43 |
+
/*
|
44 |
+
* OK - prefixed.
|
45 |
+
*/
|
46 |
+
function acronym_do_something() {
|
47 |
+
global $acronym_something, $else;
|
48 |
+
|
49 |
+
$acronym_something = 'value';
|
50 |
+
$GLOBALS['acronym_something'] = 'value';
|
51 |
+
$GLOBALS[ 'acronym_' . $else ] = 'value';
|
52 |
+
$GLOBALS[ "acronym_something_{$else}" ] = 'value';
|
53 |
+
}
|
54 |
+
|
55 |
+
$acronym_var = 'abc';
|
56 |
+
|
57 |
+
define( 'ACRONYM_SOME_CONSTANT', 'value' );
|
58 |
+
const ACRONYM_SOME_CONSTANT = 'value';
|
59 |
+
|
60 |
+
class Acronym_Example {}
|
61 |
+
interface Acronym_Example_Interface {}
|
62 |
+
trait Acronym_Example_Trait {}
|
63 |
+
|
64 |
+
do_action( 'acronym_plugin_action' );
|
65 |
+
apply_filters( 'acronym_theme_filter', $var );
|
66 |
+
do_action( "acronym_plugin_action_{$acronym_filter_var}" );
|
67 |
+
apply_filters( 'acronym_theme_filter_' . $acronym_filter_var );
|
68 |
+
|
69 |
+
|
70 |
+
/*
|
71 |
+
* OK - test secondary prefix.
|
72 |
+
*/
|
73 |
+
function tgmpa_do_something() {}
|
74 |
+
|
75 |
+
$tgmpa_var = 'abc';
|
76 |
+
|
77 |
+
define( 'TGMPA_SOME_CONSTANT', 'value' );
|
78 |
+
const TGMPA_SOME_CONSTANT = 'value';
|
79 |
+
|
80 |
+
class TGMPA_Example {}
|
81 |
+
|
82 |
+
do_action( 'tgmpa_plugin_action' );
|
83 |
+
apply_filters( 'tgmpa_theme_filter', $var );
|
84 |
+
do_action( "tgmpa_plugin_action_{$acronym_filter_var}" );
|
85 |
+
|
86 |
+
|
87 |
+
/*
|
88 |
+
* Bad: prefix not correctly used.
|
89 |
+
*/
|
90 |
+
function abtgmpa_do_something() {} // Bad.
|
91 |
+
function tgmpacd_do_something() {} // Bad.
|
92 |
+
|
93 |
+
|
94 |
+
/*
|
95 |
+
* OK - allow for function/var/constant/class etc names to be just and only the prefix.
|
96 |
+
*/
|
97 |
+
function acronym() {
|
98 |
+
global $acronym;
|
99 |
+
|
100 |
+
$acronym = 'value';
|
101 |
+
$GLOBALS['acronym'] = 'value';
|
102 |
+
$GLOBALS[ 'acronym' . $else ] = 'value'; // Presume the '_' is part of the $else.
|
103 |
+
$GLOBALS[ "acronym{$else}" ] = 'value'; // Presume the '_' is part of the $else.
|
104 |
+
$GLOBALS[ "acronym$else" ] = 'value'; // Presume the '_' is part of the $else.
|
105 |
+
}
|
106 |
+
|
107 |
+
$acronym = 'abc';
|
108 |
+
|
109 |
+
define( 'ACRONYM', 'value' );
|
110 |
+
const ACRONYM = 'value';
|
111 |
+
|
112 |
+
class Acronym {}
|
113 |
+
interface Acronym {}
|
114 |
+
trait Acronym {}
|
115 |
+
|
116 |
+
do_action( 'acronym' );
|
117 |
+
apply_filters( 'acronym', $var );
|
118 |
+
|
119 |
+
|
120 |
+
/*
|
121 |
+
* OK - not in the global namespace.
|
122 |
+
*/
|
123 |
+
function acronym_do_something( $param = 'default' ) {
|
124 |
+
$var = 'abc';
|
125 |
+
${$something} = 'value';
|
126 |
+
}
|
127 |
+
|
128 |
+
function ( $param ) {
|
129 |
+
$var = 'abc';
|
130 |
+
}
|
131 |
+
|
132 |
+
class Acronym_Example {
|
133 |
+
const SOME_CONSTANT = 'value';
|
134 |
+
|
135 |
+
public $var = 'abc';
|
136 |
+
|
137 |
+
function do_something( $param = 'default' ) {}
|
138 |
+
}
|
139 |
+
|
140 |
+
$acronym_class = new class {
|
141 |
+
const SOME_CONSTANT = 'value';
|
142 |
+
|
143 |
+
public $var = 'abc';
|
144 |
+
|
145 |
+
function do_something( $param = 'default' ) {}
|
146 |
+
}
|
147 |
+
|
148 |
+
namespace Acronym {
|
149 |
+
function do_something( $param = 'default' ) {}
|
150 |
+
|
151 |
+
const SOME_CONSTANT = 'value';
|
152 |
+
|
153 |
+
class Example {}
|
154 |
+
interface I_Example {}
|
155 |
+
trait T_Example {}
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/*
|
160 |
+
* OK - exceptions whitelisted by default.
|
161 |
+
*/
|
162 |
+
$_POST['something'] = 'value';
|
163 |
+
|
164 |
+
do_action_deprecated( 'set_current_user' ); // Deprecated hook, ignored.
|
165 |
+
|
166 |
+
// WP global variables, override warning is handled by another sniff.
|
167 |
+
function acronym_do_something() {
|
168 |
+
global $post;
|
169 |
+
$post = 'value';
|
170 |
+
$GLOBALS['post'] = 'value';
|
171 |
+
}
|
172 |
+
|
173 |
+
/*
|
174 |
+
* OK - test class - skips forward.
|
175 |
+
*/
|
176 |
+
class Example extends WP_UnitTestCase {
|
177 |
+
const SOME_CONSTANT = 'value';
|
178 |
+
|
179 |
+
public $var = 'abc';
|
180 |
+
|
181 |
+
function do_something() {}
|
182 |
+
}
|
183 |
+
|
184 |
+
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals custom_test_class_whitelist My_TestClass
|
185 |
+
class Test_Class_D extends My_TestClass {
|
186 |
+
|
187 |
+
const SOME_CONSTANT = 'value';
|
188 |
+
|
189 |
+
public $var = 'abc';
|
190 |
+
|
191 |
+
function do_something() {}
|
192 |
+
}
|
193 |
+
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals custom_test_class_whitelist false
|
194 |
+
|
195 |
+
|
196 |
+
/*
|
197 |
+
* OK - whitelisted via whitelist comment.
|
198 |
+
*/
|
199 |
+
if ( ! function_exists( 'intdiv' ) ) {
|
200 |
+
// Fill in for a PHP function which is not available in low PHP versions.
|
201 |
+
function intdiv() { // WPCS: prefix ok.
|
202 |
+
// Some code.
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
if ( ! defined( 'PHP_VERSION_ID' ) ) {
|
207 |
+
$acronym_version = explode('.', PHP_VERSION);
|
208 |
+
define('PHP_VERSION_ID', (int) (($acronym_version[0] * 10000) + ($acronym_version[1] * 100) + $acronym_version[2])); // WPCS: prefix ok.
|
209 |
+
unset($acronym_version);
|
210 |
+
}
|
211 |
+
|
212 |
+
$something = 'abc'; // WPCS: prefix ok.
|
213 |
+
|
214 |
+
// Executing a WP core action or filter is sometimes ok.
|
215 |
+
do_action( 'set_current_user' ); // WPCS: prefix ok.
|
216 |
+
apply_filters( 'excerpt_edit_pre', $var ); // WPCS: prefix ok.
|
217 |
+
|
218 |
+
|
219 |
+
/*
|
220 |
+
* Issue 915: OK/Bad - backfilled PHP functions will be recognized depending on the PHP version PHPCS runs on
|
221 |
+
* and the extensions loaded in that version.
|
222 |
+
*/
|
223 |
+
if ( ! function_exists( 'mb_strpos' ) ) {
|
224 |
+
// Fill in for a PHP function which is not always available (extension needs to be loaded).
|
225 |
+
function mb_strpos() {}
|
226 |
+
}
|
227 |
+
|
228 |
+
if ( ! function_exists( 'array_column' ) ) {
|
229 |
+
// Fill in for a PHP function which is not always available - introduced in PHP 5.5.
|
230 |
+
function array_column() {}
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( ! defined( 'E_DEPRECATED' ) ) {
|
234 |
+
define( 'E_DEPRECATED', true ); // Introduced in PHP 5.3.0.
|
235 |
+
}
|
236 |
+
|
237 |
+
if ( ! class_exists( 'IntlTimeZone' ) ) {
|
238 |
+
class IntlTimeZone {} // Introduced in PHP 5.5.0.
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
/*
|
243 |
+
* Issue 915: dynamic names. Names starting with a dynamic part or
|
244 |
+
* which are completely dynamic, will receive a warning.
|
245 |
+
*/
|
246 |
+
function acronym_something() {
|
247 |
+
global $something;
|
248 |
+
|
249 |
+
$GLOBALS[ $something ] = 'value'; // Warning.
|
250 |
+
$GLOBALS[ "{$something}_something" ] = 'value'; // Warning.
|
251 |
+
}
|
252 |
+
|
253 |
+
$$something = 'value'; // Warning.
|
254 |
+
${$something} = 'value'; // Warning.
|
255 |
+
$$$${$something} = 'value'; // Warning.
|
256 |
+
${$something}['foo'] = 'value'; // Warning.
|
257 |
+
${$something}['foo']['bar'] = 'value'; // Warning.
|
258 |
+
${$something['foo']} = 'value'; // Warning.
|
259 |
+
$GLOBALS[ $something ] = 'value'; // Warning.
|
260 |
+
$GLOBALS[ "{$something}_something" ] = 'value'; // Warning.
|
261 |
+
$GLOBALS[ ${$something} ] = 'value'; // Warning.
|
262 |
+
|
263 |
+
define( ${$something}, 'value' ); // Warning.
|
264 |
+
define( $something, 'value' ); // Warning.
|
265 |
+
define( $something . '_CONSTANT', 'value' ); // Warning.
|
266 |
+
define( "{$something}_CONSTANT", 'value' ); // Warning.
|
267 |
+
define( $something . '_CONSTANT', 'value' ); // Warning.
|
268 |
+
|
269 |
+
do_action( "{$acronym_filter_var}_hook_name" ); // Warning.
|
270 |
+
do_action( "{$acronym_filter_var}hook_name" ); // Warning.
|
271 |
+
do_action( $acronym_filter_var ); // Warning.
|
272 |
+
do_action( $GLOBALS['something'] ); // Warning.
|
273 |
+
do_action( ${$acronym_filter_var} ); // Warning.
|
274 |
+
do_action( $GLOBALS[ ${$something} ] ); // Warning.
|
275 |
+
apply_filters( $_REQUEST['else'] ); // Warning.
|
276 |
+
|
277 |
+
class Acronym_Dynamic_Hooks {
|
278 |
+
const FILTER = 'acronym';
|
279 |
+
const FILTER_WITH_UNDERSCORE = 'acronym_';
|
280 |
+
|
281 |
+
protected $filter = 'acronym';
|
282 |
+
protected $filter_with_underscore = 'acronym_';
|
283 |
+
|
284 |
+
public function test() {
|
285 |
+
global $acronym_filter_var;
|
286 |
+
${$this->name} = 'value'; // Warning.
|
287 |
+
apply_filters( "{$acronym_filter_var}_hook" ); // Warning.
|
288 |
+
do_action( $acronym_filter_var ); // Warning.
|
289 |
+
|
290 |
+
do_action( $this->filter ); // Warning.
|
291 |
+
apply_filters( $this->filter_array['key'] ); // Warning.
|
292 |
+
do_action( "{$this->filter}_hook_name" ); // Warning.
|
293 |
+
do_action( "{$this->filter_with_underscore}hook_name" ); // Warning.
|
294 |
+
|
295 |
+
apply_filters( self::FILTER ); // Warning.
|
296 |
+
apply_filters( self::FILTER_WITH_UNDERSCORE . 'hook_name' ); // Warning.
|
297 |
+
apply_filters( self::FILTER_ARRAY['key'] ); // Warning.
|
298 |
+
|
299 |
+
do_action( $this->parent_property ); // Warning.
|
300 |
+
}
|
301 |
+
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the PrefixAllGlobals sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_NamingConventions_PrefixAllGlobalsUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @param string $testFile The name of the file being tested.
|
22 |
+
* @return array <int line number> => <int number of errors>
|
23 |
+
*/
|
24 |
+
public function getErrorList( $testFile = 'PrefixAllGlobalsUnitTest.inc' ) {
|
25 |
+
|
26 |
+
switch ( $testFile ) {
|
27 |
+
case 'PrefixAllGlobalsUnitTest.inc':
|
28 |
+
return array(
|
29 |
+
1 => 2, // 2 x error for incorrect prefix passed.
|
30 |
+
10 => 1,
|
31 |
+
18 => 1,
|
32 |
+
21 => 1,
|
33 |
+
22 => 1,
|
34 |
+
23 => 1,
|
35 |
+
24 => 1,
|
36 |
+
25 => 1,
|
37 |
+
28 => 1,
|
38 |
+
30 => 1,
|
39 |
+
31 => 1,
|
40 |
+
33 => 1,
|
41 |
+
34 => 1,
|
42 |
+
35 => 1,
|
43 |
+
37 => 1,
|
44 |
+
38 => 1,
|
45 |
+
39 => 1,
|
46 |
+
40 => 1,
|
47 |
+
90 => 1,
|
48 |
+
91 => 1,
|
49 |
+
// Scoped.
|
50 |
+
149 => ( PHP_VERSION_ID >= 50300 ) ? 0 : 1, // PHPCS on PHP 5.2 does not recognize namespaces.
|
51 |
+
151 => ( PHP_VERSION_ID >= 50300 ) ? 0 : 1, // PHPCS on PHP 5.2 does not recognize namespaces.
|
52 |
+
153 => ( PHP_VERSION_ID >= 50300 ) ? 0 : 1, // PHPCS on PHP 5.2 does not recognize namespaces.
|
53 |
+
154 => ( PHP_VERSION_ID >= 50300 ) ? 0 : 1, // PHPCS on PHP 5.2 does not recognize namespaces.
|
54 |
+
155 => ( PHP_VERSION_ID >= 50300 ) ? 0 : 1, // PHPCS on PHP 5.2 does not recognize namespaces.
|
55 |
+
// Backfills.
|
56 |
+
225 => ( function_exists( 'mb_strpos' ) ) ? 0 : 1,
|
57 |
+
230 => ( function_exists( 'array_column' ) ) ? 0 : 1,
|
58 |
+
234 => ( defined( 'E_DEPRECATED' ) ) ? 0 : 1,
|
59 |
+
238 => ( class_exists( 'IntlTimeZone' ) ) ? 0 : 1,
|
60 |
+
);
|
61 |
+
|
62 |
+
case 'PrefixAllGlobalsUnitTest.1.inc':
|
63 |
+
// Namespaced - all OK.
|
64 |
+
if ( PHP_VERSION_ID >= 50300 ) {
|
65 |
+
return array();
|
66 |
+
}
|
67 |
+
|
68 |
+
// PHPCS on PHP 5.2 does not recognize namespaces.
|
69 |
+
return array(
|
70 |
+
9 => 1,
|
71 |
+
11 => 1,
|
72 |
+
13 => 1,
|
73 |
+
14 => 1,
|
74 |
+
15 => 1,
|
75 |
+
);
|
76 |
+
|
77 |
+
default:
|
78 |
+
return array();
|
79 |
+
|
80 |
+
} // End switch().
|
81 |
+
|
82 |
+
} // end getErrorList()
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Returns the lines where warnings should occur.
|
86 |
+
*
|
87 |
+
* @param string $testFile The name of the file being tested.
|
88 |
+
* @return array <int line number> => <int number of warnings>
|
89 |
+
*/
|
90 |
+
public function getWarningList( $testFile = 'PrefixAllGlobalsUnitTest.inc' ) {
|
91 |
+
|
92 |
+
switch ( $testFile ) {
|
93 |
+
case 'PrefixAllGlobalsUnitTest.inc':
|
94 |
+
return array(
|
95 |
+
249 => 1,
|
96 |
+
250 => 1,
|
97 |
+
253 => 1,
|
98 |
+
254 => 1,
|
99 |
+
255 => 1,
|
100 |
+
256 => 1,
|
101 |
+
257 => 1,
|
102 |
+
258 => 1,
|
103 |
+
259 => 1,
|
104 |
+
260 => 1,
|
105 |
+
261 => 1,
|
106 |
+
263 => 1,
|
107 |
+
264 => 1,
|
108 |
+
265 => 1,
|
109 |
+
266 => 1,
|
110 |
+
267 => 1,
|
111 |
+
269 => 1,
|
112 |
+
270 => 1,
|
113 |
+
271 => 1,
|
114 |
+
272 => 1,
|
115 |
+
273 => 1,
|
116 |
+
274 => 1,
|
117 |
+
275 => 1,
|
118 |
+
286 => 1,
|
119 |
+
287 => 1,
|
120 |
+
288 => 1,
|
121 |
+
290 => 1,
|
122 |
+
291 => 1,
|
123 |
+
292 => 1,
|
124 |
+
293 => 1,
|
125 |
+
295 => 1,
|
126 |
+
296 => 1,
|
127 |
+
297 => 1,
|
128 |
+
299 => 1,
|
129 |
+
);
|
130 |
+
|
131 |
+
default:
|
132 |
+
return array();
|
133 |
+
|
134 |
+
} // End switch().
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/StrictComparisonsUnitTest.inc
CHANGED
@@ -18,4 +18,14 @@ if ( true != $true ) { // Bad.
|
|
18 |
// Test for whitelisting.
|
19 |
if ( true == $true ) { // Loose comparison, OK.
|
20 |
echo 'True';
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
// Test for whitelisting.
|
19 |
if ( true == $true ) { // Loose comparison, OK.
|
20 |
echo 'True';
|
21 |
+
}
|
22 |
+
|
23 |
+
// Test that whitelisting is not too eager.
|
24 |
+
if ( true == $true ) {
|
25 |
+
// The line above has a loose comparison, but no whitelist comment.
|
26 |
+
echo 'True';
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( true == $true ) { // Loose comparisons FTW!
|
30 |
+
echo 'True';
|
31 |
+
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/StrictComparisonsUnitTest.php
CHANGED
@@ -32,9 +32,11 @@ class WordPress_Tests_PHP_StrictComparisonsUnitTest extends AbstractSniffUnitTes
|
|
32 |
*/
|
33 |
public function getWarningList() {
|
34 |
return array(
|
35 |
-
3
|
36 |
10 => 1,
|
37 |
12 => 1,
|
|
|
|
|
38 |
);
|
39 |
|
40 |
}
|
32 |
*/
|
33 |
public function getWarningList() {
|
34 |
return array(
|
35 |
+
3 => 1,
|
36 |
10 => 1,
|
37 |
12 => 1,
|
38 |
+
24 => 1,
|
39 |
+
29 => 1,
|
40 |
);
|
41 |
|
42 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/YodaConditionsUnitTest.inc
CHANGED
@@ -90,3 +90,39 @@ if ( $GLOBALS['wpdb']->num_rows === 0 ) {} // Bad.
|
|
90 |
if ( $true == strtolower( $check ) ) {} // Bad.
|
91 |
|
92 |
$update = 'yes' === strtolower( $this->from_post( 'update' ) ); // Ok.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
if ( $true == strtolower( $check ) ) {} // Bad.
|
91 |
|
92 |
$update = 'yes' === strtolower( $this->from_post( 'update' ) ); // Ok.
|
93 |
+
$sample = false !== strpos( $link, '%pagename%' ); // Ok.
|
94 |
+
$sample = true !== strpos( $link, '%pagename%' ); // Ok.
|
95 |
+
$sample = null !== strpos( $link, '%pagename%' ); // Ok.
|
96 |
+
$sample = SOME_CONSTANT !== strpos( $link, '%pagename%' ); // Ok.
|
97 |
+
$sample = foo() !== strpos( $link, '%pagename%' ); // Ok.
|
98 |
+
$sample = foo( $var ) !== strpos( $link, '%pagename%' ); // Ok.
|
99 |
+
|
100 |
+
if ( $sample = false !== strpos( $link, '%pagename%' ) ) {} // Ok.
|
101 |
+
if ( $sample = ( false !== strpos( $link, '%pagename%' ) ) ) {} // Ok.
|
102 |
+
if ( ( $sample = false ) !== strpos( $link, '%pagename%' ) ) {} // Ok.
|
103 |
+
|
104 |
+
switch ( true ) {
|
105 |
+
case $sample === 'something': // Bad.
|
106 |
+
// Do something.
|
107 |
+
break;
|
108 |
+
|
109 |
+
case 'something' === $sample: // OK.
|
110 |
+
// Do something.
|
111 |
+
break;
|
112 |
+
}
|
113 |
+
|
114 |
+
for ( $i = 0; $i !== 100; $i++ ) {} // Bad.
|
115 |
+
for ( $i = 0; 100 != $i; $i++ ) {} // OK.
|
116 |
+
|
117 |
+
do {
|
118 |
+
// Something.
|
119 |
+
} while ( $sample === false ); // Bad.
|
120 |
+
|
121 |
+
do {
|
122 |
+
// Something.
|
123 |
+
} while ( CONSTANT_A === $sample ); // OK.
|
124 |
+
|
125 |
+
while ( $sample === false ) {} // Bad.
|
126 |
+
while ( false != $sample ) {} // OK.
|
127 |
+
|
128 |
+
$a = ( $sample ) === 'yes'; // OK.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/PHP/YodaConditionsUnitTest.php
CHANGED
@@ -35,6 +35,10 @@ class WordPress_Tests_PHP_YodaConditionsUnitTest extends AbstractSniffUnitTest {
|
|
35 |
84 => 1,
|
36 |
88 => 1,
|
37 |
90 => 1,
|
|
|
|
|
|
|
|
|
38 |
);
|
39 |
|
40 |
}
|
35 |
84 => 1,
|
36 |
88 => 1,
|
37 |
90 => 1,
|
38 |
+
105 => 1,
|
39 |
+
114 => 1,
|
40 |
+
119 => 1,
|
41 |
+
125 => 1,
|
42 |
);
|
43 |
|
44 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/DirectDatabaseQueryUnitTest.inc
CHANGED
@@ -242,3 +242,60 @@ function custom_modify_term_relationship() {
|
|
242 |
$wpdb->update( $wpdb->term_relationships, array( 'term_order' => 1 ), array( 'object_id' => 1 ) ); // DB call ok; OK.
|
243 |
clean_object_term_cache( 1 );
|
244 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
$wpdb->update( $wpdb->term_relationships, array( 'term_order' => 1 ), array( 'object_id' => 1 ) ); // DB call ok; OK.
|
243 |
clean_object_term_cache( 1 );
|
244 |
}
|
245 |
+
|
246 |
+
// Test Nowdocs and Heredocs
|
247 |
+
function foo() {
|
248 |
+
global $wpdb;
|
249 |
+
|
250 |
+
$listofthings = $wpdb->get_col( <<<'EOD'
|
251 |
+
SELECT something
|
252 |
+
FROM somewhere
|
253 |
+
WHERE someotherthing = 1
|
254 |
+
EOD
|
255 |
+
); // Error + Warning.
|
256 |
+
|
257 |
+
$listofthings = $wpdb->get_col( <<<EOD
|
258 |
+
SELECT something
|
259 |
+
FROM somewhere
|
260 |
+
WHERE someotherthing = 1
|
261 |
+
EOD
|
262 |
+
); // DB call okay ( No Warning, but Error for not caching! ).
|
263 |
+
|
264 |
+
return $listofthings;
|
265 |
+
}
|
266 |
+
|
267 |
+
function baz() {
|
268 |
+
global $wpdb;
|
269 |
+
|
270 |
+
$baz = wp_cache_get( 'baz' );
|
271 |
+
if ( false !== $baz ) {
|
272 |
+
|
273 |
+
$wpdb->query( <<<'EOD'
|
274 |
+
ALTER TABLE TO ADD SOME FIELDS
|
275 |
+
EOD
|
276 |
+
); // DB call okay (but not really because ALTER TABLE!).
|
277 |
+
wp_cache_set( 'baz', $baz );
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
function cache_add_instead_of_set() {
|
282 |
+
global $wpdb;
|
283 |
+
|
284 |
+
$baz = wp_cache_get( 'baz' );
|
285 |
+
|
286 |
+
if ( false !== $baz ) {
|
287 |
+
|
288 |
+
$data = $where = array();
|
289 |
+
|
290 |
+
$wpdb->query( <<<EOD
|
291 |
+
SELECT X FROM Y
|
292 |
+
EOD
|
293 |
+
); // DB call ok; OK.
|
294 |
+
$wpdb->get_row( <<<'EOD'
|
295 |
+
SELECT X FROM Y
|
296 |
+
EOD
|
297 |
+
); // DB call ok; OK.
|
298 |
+
|
299 |
+
wp_cache_add( 'baz', $baz );
|
300 |
+
}
|
301 |
+
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/DirectDatabaseQueryUnitTest.php
CHANGED
@@ -33,6 +33,9 @@ class WordPress_Tests_VIP_DirectDatabaseQueryUnitTest extends AbstractSniffUnitT
|
|
33 |
170 => 1,
|
34 |
178 => 1,
|
35 |
190 => 1,
|
|
|
|
|
|
|
36 |
);
|
37 |
|
38 |
}
|
@@ -49,6 +52,7 @@ class WordPress_Tests_VIP_DirectDatabaseQueryUnitTest extends AbstractSniffUnitT
|
|
49 |
38 => 1,
|
50 |
50 => 1,
|
51 |
112 => 1,
|
|
|
52 |
);
|
53 |
|
54 |
}
|
33 |
170 => 1,
|
34 |
178 => 1,
|
35 |
190 => 1,
|
36 |
+
250 => 1,
|
37 |
+
257 => 1,
|
38 |
+
274 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 does not recognize T_NOWDOC.
|
39 |
);
|
40 |
|
41 |
}
|
52 |
38 => 1,
|
53 |
50 => 1,
|
54 |
112 => 1,
|
55 |
+
250 => 1,
|
56 |
);
|
57 |
|
58 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedFunctionsUnitTest.inc
CHANGED
@@ -55,10 +55,10 @@ get_posts(); // Warning.
|
|
55 |
wp_get_recent_posts(); // Warning.
|
56 |
|
57 |
get_children(); // Warning.
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
term_exists(); // Error.
|
63 |
count_user_posts(); // Error.
|
64 |
wp_old_slug_redirect(); // Error.
|
55 |
wp_get_recent_posts(); // Warning.
|
56 |
|
57 |
get_children(); // Warning.
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
term_exists(); // Error.
|
63 |
count_user_posts(); // Error.
|
64 |
wp_old_slug_redirect(); // Error.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedFunctionsUnitTest.php
CHANGED
@@ -37,10 +37,6 @@ class WordPress_Tests_VIP_RestrictedFunctionsUnitTest extends AbstractSniffUnitT
|
|
37 |
50 => 1,
|
38 |
51 => 1,
|
39 |
52 => 1,
|
40 |
-
58 => 1,
|
41 |
-
59 => 1,
|
42 |
-
60 => 1,
|
43 |
-
61 => 1,
|
44 |
62 => 1,
|
45 |
63 => 1,
|
46 |
64 => 1,
|
37 |
50 => 1,
|
38 |
51 => 1,
|
39 |
52 => 1,
|
|
|
|
|
|
|
|
|
40 |
62 => 1,
|
41 |
63 => 1,
|
42 |
64 => 1,
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedVariablesUnitTest.inc
CHANGED
@@ -17,3 +17,13 @@ if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // Warning.
|
|
17 |
$x = $_COOKIE['bar']; // Warning.
|
18 |
|
19 |
$y = $_SERVER['REQUEST_URI']; // Ok.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
$x = $_COOKIE['bar']; // Warning.
|
18 |
|
19 |
$y = $_SERVER['REQUEST_URI']; // Ok.
|
20 |
+
|
21 |
+
// Error.
|
22 |
+
$query = <<<EOD
|
23 |
+
SELECT * FROM $wpdb->usermeta
|
24 |
+
EOD;
|
25 |
+
|
26 |
+
// Warning
|
27 |
+
$phrase = <<<EOD
|
28 |
+
Your user-agent is {$_SERVER['HTTP_USER_AGENT']}
|
29 |
+
EOD;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/RestrictedVariablesUnitTest.php
CHANGED
@@ -22,10 +22,11 @@ class WordPress_Tests_VIP_RestrictedVariablesUnitTest extends AbstractSniffUnitT
|
|
22 |
*/
|
23 |
public function getErrorList() {
|
24 |
return array(
|
25 |
-
3
|
26 |
-
5
|
27 |
-
7
|
28 |
-
9
|
|
|
29 |
);
|
30 |
|
31 |
}
|
@@ -40,6 +41,7 @@ class WordPress_Tests_VIP_RestrictedVariablesUnitTest extends AbstractSniffUnitT
|
|
40 |
13 => 1,
|
41 |
14 => 1,
|
42 |
17 => 1,
|
|
|
43 |
);
|
44 |
|
45 |
}
|
22 |
*/
|
23 |
public function getErrorList() {
|
24 |
return array(
|
25 |
+
3 => 1,
|
26 |
+
5 => 1,
|
27 |
+
7 => 1,
|
28 |
+
9 => 1,
|
29 |
+
23 => 1,
|
30 |
);
|
31 |
|
32 |
}
|
41 |
13 => 1,
|
42 |
14 => 1,
|
43 |
17 => 1,
|
44 |
+
28 => 1,
|
45 |
);
|
46 |
|
47 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/SlowDBQueryUnitTest.inc
CHANGED
@@ -28,10 +28,11 @@ $test = array(
|
|
28 |
|
29 |
// Single-line statements.
|
30 |
'tax_query' => array(), // Bad.
|
|
|
31 |
'tax_query' => array(), // WPCS: tax_query ok.
|
32 |
|
33 |
// Multi-line statement.
|
34 |
-
'tax_query' => array( // WPCS:
|
35 |
array(
|
36 |
'taxonomy' => 'foo',
|
37 |
),
|
28 |
|
29 |
// Single-line statements.
|
30 |
'tax_query' => array(), // Bad.
|
31 |
+
'tax_query' => array(), // WPCS: slow query ok.
|
32 |
'tax_query' => array(), // WPCS: tax_query ok.
|
33 |
|
34 |
// Multi-line statement.
|
35 |
+
'tax_query' => array( // WPCS: slow query ok.
|
36 |
array(
|
37 |
'taxonomy' => 'foo',
|
38 |
),
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/SlowDBQueryUnitTest.php
CHANGED
@@ -38,6 +38,7 @@ class WordPress_Tests_VIP_SlowDBQueryUnitTest extends AbstractSniffUnitTest {
|
|
38 |
16 => 1,
|
39 |
19 => 2,
|
40 |
30 => 1,
|
|
|
41 |
);
|
42 |
|
43 |
}
|
38 |
16 => 1,
|
39 |
19 => 2,
|
40 |
30 => 1,
|
41 |
+
32 => 1, // Warning about deprecated whitelist comment.
|
42 |
);
|
43 |
|
44 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/ValidatedSanitizedInputUnitTest.inc
CHANGED
@@ -149,3 +149,17 @@ function test_this() {
|
|
149 |
|
150 |
$abc = sanitize_twitter_handle( $_POST['abc_field'] ); // Bad x2, sanitize + unslash.
|
151 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
$abc = sanitize_twitter_handle( $_POST['abc_field'] ); // Bad x2, sanitize + unslash.
|
151 |
}
|
152 |
+
|
153 |
+
// Variables in heredocs.
|
154 |
+
output( <<<EOD
|
155 |
+
some string \$_POST[some_var]
|
156 |
+
EOD
|
157 |
+
); // Ok.
|
158 |
+
|
159 |
+
output( <<<EOD
|
160 |
+
some string {$_POST[some_var]} {$_GET['evil']}
|
161 |
+
EOD
|
162 |
+
); // Bad x2.
|
163 |
+
|
164 |
+
if ( ( $_POST['foo'] ?? 'post' ) === 'post' ) {} // OK.
|
165 |
+
if ( ( $_POST['foo'] <=> 'post' ) === 0 ) {} // OK.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/VIP/ValidatedSanitizedInputUnitTest.php
CHANGED
@@ -46,6 +46,7 @@ class WordPress_Tests_VIP_ValidatedSanitizedInputUnitTest extends AbstractSniffU
|
|
46 |
137 => 1,
|
47 |
138 => 1,
|
48 |
150 => 2,
|
|
|
49 |
);
|
50 |
|
51 |
}
|
46 |
137 => 1,
|
47 |
138 => 1,
|
48 |
150 => 2,
|
49 |
+
160 => 2,
|
50 |
);
|
51 |
|
52 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Variables/GlobalVariablesUnitTest.inc
CHANGED
@@ -129,3 +129,5 @@ add_filter( 'comments_open', new class {
|
|
129 |
return 'page' === $page->post_type;
|
130 |
}
|
131 |
}, 10, 2 );
|
|
|
|
129 |
return 'page' === $page->post_type;
|
130 |
}
|
131 |
}, 10, 2 );
|
132 |
+
|
133 |
+
$GLOBALS['totals'] ??= 10; // Bad.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/Variables/GlobalVariablesUnitTest.php
CHANGED
@@ -33,6 +33,7 @@ class WordPress_Tests_Variables_GlobalVariablesUnitTest extends AbstractSniffUni
|
|
33 |
54 => 1,
|
34 |
95 => 1,
|
35 |
128 => 1,
|
|
|
36 |
);
|
37 |
|
38 |
}
|
33 |
54 => 1,
|
34 |
95 => 1,
|
35 |
128 => 1,
|
36 |
+
133 => 1,
|
37 |
);
|
38 |
|
39 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.1.inc
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Test Nowdoc separately as the fixer breaks on this in PHP 5.2.
|
5 |
+
*/
|
6 |
+
|
7 |
+
// Bad.
|
8 |
+
$text = <<<'EOD'
|
9 |
+
This is an explanation about word-press.
|
10 |
+
EOD;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.inc
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Bad: This is a comment with WORDPRESS spelled incorrectly.
|
4 |
+
|
5 |
+
/* Bad: This is a comment with wordpress spelled incorrectly. */
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Bad: This is a comment with Wordpress spelled incorrectly.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Function comment
|
13 |
+
*
|
14 |
+
* @param string $wordpress OK: Here the incorrect spelling is OK to comply with the variable name rules.
|
15 |
+
*/
|
16 |
+
function something( $wordpress ) {} // OK.
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Function comment
|
20 |
+
*
|
21 |
+
* @param string $my_wordpress_test OK: Here the incorrect spelling is OK to comply with the variable name rules.
|
22 |
+
*/
|
23 |
+
function something( $my_wordpress_test ) {} // OK.
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Bad: In this comment wordPresss should be fixed.
|
27 |
+
*
|
28 |
+
* @param string $test Bad: In this comment word press should be fixed.
|
29 |
+
*/
|
30 |
+
function something( $test ) {} // OK.
|
31 |
+
|
32 |
+
function wordpress_function() {} // OK - comply with the function name rules.
|
33 |
+
|
34 |
+
class Wordpress_Something {} // Bad.
|
35 |
+
class Something_Word_press_Something {} // Bad.
|
36 |
+
class Something_wordpressss {} // Bad.
|
37 |
+
class WordPress_Something {} // OK.
|
38 |
+
class Something_WordPress {} // OK.
|
39 |
+
|
40 |
+
echo 'This is an explanation about wordpress.'; // Bad.
|
41 |
+
echo "This is an {$explanation} about wordpress."; // Bad.
|
42 |
+
|
43 |
+
// Bad.
|
44 |
+
echo <<<EOD
|
45 |
+
This is an {$explanation} about wordpress.
|
46 |
+
EOD;
|
47 |
+
|
48 |
+
echo 'http://wordpress.org/something'; // OK - part of a URL.
|
49 |
+
?>
|
50 |
+
|
51 |
+
<div class="copyright"><?php printf( wp_kses_post( __( 'Powered by <a href="%s">WordPress</a>', 'theme-slug' ) ), 'https://wordpress.org/' ); ?></div><!-- OK. -->
|
52 |
+
|
53 |
+
<p>Here we have an inline HTML tag with wordpress spelled incorrectly.</p><!-- Bad. -->
|
54 |
+
<p>Here we have an inline HTML tag with WordPress spelled correctly.</p><!-- OK. -->
|
55 |
+
|
56 |
+
<p>Here we have an inline HTML tag with a URL, of course this should be coded differently, but even when it isn't, it should be ignored, so here goes: http://wordpress.org/ spelled incorrectly.</p><!-- OK. -->
|
57 |
+
|
58 |
+
<p>Here we have an inline HTML tag with wordpressers spelled incorrectly.</p><!-- OK, part of another word. -->
|
59 |
+
|
60 |
+
<p>Here we have an inline HTML tag with word press spelled incorrectly.</p><!-- Bad. -->
|
61 |
+
<p>Here we have an inline HTML tag with word-press spelled incorrectly.</p><!-- Bad. -->
|
62 |
+
<p>Here we have an inline HTML tag with word - presssss spelled incorrectly.</p><!-- Bad. -->
|
63 |
+
|
64 |
+
<p class="fa-wordpress">In this case it's a CSS class name and we should leave well alone.</p><!-- OK. -->
|
65 |
+
<p class="wordpress-class">CSS class, but also wordPres spelled incorrectly in the text.</p><!-- Bad. -->
|
66 |
+
<p class="wordpress-class">Same again, this time with same spelling in both the class as well as in the text wordpress.</p><!-- Bad. -->
|
67 |
+
|
68 |
+
<p>And lets have another test with wordpress spelled incorrectly more than once. Wordpress, wordPress, word pres.</p><!-- Bad. -->
|
69 |
+
|
70 |
+
<?php
|
71 |
+
/*
|
72 |
+
* Some additional examples found in WP core.
|
73 |
+
*/
|
74 |
+
$first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example'; // OK.
|
75 |
+
|
76 |
+
$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); // OK.
|
77 |
+
|
78 |
+
// If we don't have an email from the input headers default to wordpress@$sitename <= OK.
|
79 |
+
$from_email = 'wordpress@' . $sitename; // OK.
|
80 |
+
|
81 |
+
if ( $counts['wordpress'] ) { // OK.
|
82 |
+
/* translators: 1: Number of updates available to WordPress */
|
83 |
+
$titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] ); // OK.
|
84 |
+
}
|
85 |
+
|
86 |
+
?>
|
87 |
+
<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td><!-- OK. -->
|
88 |
+
|
89 |
+
<ol id="authors"><form action="?import=wordpress&step=2&id=" method="post"><input type="hidden" name="_wpnonce" value="855ae98911" /><!-- OK. -->
|
90 |
+
|
91 |
+
<?php
|
92 |
+
/*
|
93 |
+
* More examples found in themes which should be accounted for.
|
94 |
+
* Based on a run of this sniff against 180 recently updated themes (7500+ files).
|
95 |
+
*/
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @wordpress-plugin <= OK.
|
99 |
+
* Plugin Name: TGM Plugin Activation
|
100 |
+
*
|
101 |
+
* @package Wordpress <= Bad.
|
102 |
+
*
|
103 |
+
* @link OK: http://justintadlock.com/archives/2011/07/01/captions-in-wordpress
|
104 |
+
*/
|
105 |
+
|
106 |
+
if ( file_exists( ABSPATH . 'wp-content/plugins/wordpress-importer/wordpress-importer.php' ) ) { // OK.
|
107 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
108 |
+
|
109 |
+
return is_plugin_active( 'wordpress-importer/wordpress-importer.php' ); // OK.
|
110 |
+
}
|
111 |
+
|
112 |
+
$check = array(
|
113 |
+
'wordpress-importer' => array( 'installed' => false, 'active' => false ), // OK.
|
114 |
+
'widget-importer-exporter' => array( 'installed' => false, 'active' => false )
|
115 |
+
);
|
116 |
+
|
117 |
+
$default_editor_settings = [
|
118 |
+
'textarea_name' => $textarea_name,
|
119 |
+
'media_buttons' => false,
|
120 |
+
'tinymce' => [ 'plugins' => 'wordpress' ] // OK.
|
121 |
+
];
|
122 |
+
|
123 |
+
$wp_customize->add_control(
|
124 |
+
new Arouse_Custom_Content(
|
125 |
+
$wp_customize,
|
126 |
+
'arouse_documentation_link',
|
127 |
+
array(
|
128 |
+
'section' => 'arouse_theme_info',
|
129 |
+
'label' => __( 'Arouse Documentation', 'arouse' ),
|
130 |
+
'content' => __( '<a class="button" href="http://themezhut.com/arouse-wordpress-theme-documentation/" target="_blank">Read the documentation.</a>', 'arouse' ), // OK.
|
131 |
+
)
|
132 |
+
)
|
133 |
+
);
|
134 |
+
|
135 |
+
?>
|
136 |
+
|
137 |
+
<a href="https://wordpress.org/support/theme/{{ data.theme_slug }}/reviews/#new-post" class="button button-primary activello-wordpress"><span class="dashicons dashicons-wordpress"></span>Review this theme on w.org</a><!-- OK. -->
|
138 |
+
|
139 |
+
<p><?php _e( 'This page will help you get up and running quickly with <strong>Adamos</strong>. Please use the <a href="https://wordpress.org/support/theme/adamos">Wordpress Support Forums</a> if you have experience issues with this theme.', 'adamos' ); ?></p><!-- Bad. -->
|
140 |
+
|
141 |
+
<a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/alhena-free-responsive-corporate-wordpress-theme/?ref=2&campaign=alhena-notice' ); ?>" class="button"><?php _e( 'Upgrade to Alhena Premium', 'alhena-lite' ); ?></a><!-- OK. -->
|
142 |
+
|
143 |
+
<?php
|
144 |
+
comment_form( array(
|
145 |
+
'fields' => apply_filters( 'comment_form_default_fields', $fields ),
|
146 |
+
/* translators: %s: wordpress login url */ // Bad, but false negative as within an array.
|
147 |
+
'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' , 'annina' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
|
148 |
+
));
|
149 |
+
|
150 |
+
$wl_theme_options['service_3_icons']="fa fa-wordpress"; // OK.
|
151 |
+
|
152 |
+
if ( get_theme_mod('header_icon', 'fa-wordpress') ) echo '<i class="fa ' .esc_attr(get_theme_mod('header_icon' , 'fa-wordpress')) . '"></i>'; // OK.
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Bootstrap styled Caption shortcode.
|
156 |
+
* Hat tip: http://justintadlock.com/archives/2011/07/01/captions-in-wordpress <= OK.
|
157 |
+
*/
|
158 |
+
|
159 |
+
$render = '<div class="redux-field-locked"><div class="redux-locked-inner' . (empty($message) ? ' empty' : '') . '"><a target="_blank" href="' . $t4p_url . 'evolve-multipurpose-wordpress-theme/" class="el el-lock"> </a>' . $message . '</div></div>' . $render; // OK.
|
160 |
+
|
161 |
+
$installed = self::check_plugin_is_installed( 'wordpress-importer' ); // OK.
|
162 |
+
|
163 |
+
|
164 |
+
/*
|
165 |
+
* Test whitelisting
|
166 |
+
*/
|
167 |
+
echo 'This is an explanation about wordpress.'; // WPCS: spelling ok.
|
168 |
+
|
169 |
+
/*
|
170 |
+
* Test fixer with an ignored and a fixable misspelling in the same line.
|
171 |
+
*/
|
172 |
+
?>
|
173 |
+
<p class="wordpress" href="http://x.org/?something=wordpress">The first two should be ignored for the purpose of replacing, this wordpress however should be fixed and this wordpress too.</p><!-- Bad. -->
|
174 |
+
|
175 |
+
<?php // POT filename should be ignored. ?>
|
176 |
+
wordpress.pot
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Bad: This is a comment with WordPress spelled incorrectly.
|
4 |
+
|
5 |
+
/* Bad: This is a comment with WordPress spelled incorrectly. */
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Bad: This is a comment with WordPress spelled incorrectly.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Function comment
|
13 |
+
*
|
14 |
+
* @param string $wordpress OK: Here the incorrect spelling is OK to comply with the variable name rules.
|
15 |
+
*/
|
16 |
+
function something( $wordpress ) {} // OK.
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Function comment
|
20 |
+
*
|
21 |
+
* @param string $my_wordpress_test OK: Here the incorrect spelling is OK to comply with the variable name rules.
|
22 |
+
*/
|
23 |
+
function something( $my_wordpress_test ) {} // OK.
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Bad: In this comment WordPress should be fixed.
|
27 |
+
*
|
28 |
+
* @param string $test Bad: In this comment WordPress should be fixed.
|
29 |
+
*/
|
30 |
+
function something( $test ) {} // OK.
|
31 |
+
|
32 |
+
function wordpress_function() {} // OK - comply with the function name rules.
|
33 |
+
|
34 |
+
class Wordpress_Something {} // Bad.
|
35 |
+
class Something_Word_press_Something {} // Bad.
|
36 |
+
class Something_wordpressss {} // Bad.
|
37 |
+
class WordPress_Something {} // OK.
|
38 |
+
class Something_WordPress {} // OK.
|
39 |
+
|
40 |
+
echo 'This is an explanation about WordPress.'; // Bad.
|
41 |
+
echo "This is an {$explanation} about WordPress."; // Bad.
|
42 |
+
|
43 |
+
// Bad.
|
44 |
+
echo <<<EOD
|
45 |
+
This is an {$explanation} about WordPress.
|
46 |
+
EOD;
|
47 |
+
|
48 |
+
echo 'http://wordpress.org/something'; // OK - part of a URL.
|
49 |
+
?>
|
50 |
+
|
51 |
+
<div class="copyright"><?php printf( wp_kses_post( __( 'Powered by <a href="%s">WordPress</a>', 'theme-slug' ) ), 'https://wordpress.org/' ); ?></div><!-- OK. -->
|
52 |
+
|
53 |
+
<p>Here we have an inline HTML tag with WordPress spelled incorrectly.</p><!-- Bad. -->
|
54 |
+
<p>Here we have an inline HTML tag with WordPress spelled correctly.</p><!-- OK. -->
|
55 |
+
|
56 |
+
<p>Here we have an inline HTML tag with a URL, of course this should be coded differently, but even when it isn't, it should be ignored, so here goes: http://wordpress.org/ spelled incorrectly.</p><!-- OK. -->
|
57 |
+
|
58 |
+
<p>Here we have an inline HTML tag with wordpressers spelled incorrectly.</p><!-- OK, part of another word. -->
|
59 |
+
|
60 |
+
<p>Here we have an inline HTML tag with WordPress spelled incorrectly.</p><!-- Bad. -->
|
61 |
+
<p>Here we have an inline HTML tag with WordPress spelled incorrectly.</p><!-- Bad. -->
|
62 |
+
<p>Here we have an inline HTML tag with WordPress spelled incorrectly.</p><!-- Bad. -->
|
63 |
+
|
64 |
+
<p class="fa-wordpress">In this case it's a CSS class name and we should leave well alone.</p><!-- OK. -->
|
65 |
+
<p class="wordpress-class">CSS class, but also WordPress spelled incorrectly in the text.</p><!-- Bad. -->
|
66 |
+
<p class="wordpress-class">Same again, this time with same spelling in both the class as well as in the text WordPress.</p><!-- Bad. -->
|
67 |
+
|
68 |
+
<p>And lets have another test with WordPress spelled incorrectly more than once. WordPress, WordPress, WordPress.</p><!-- Bad. -->
|
69 |
+
|
70 |
+
<?php
|
71 |
+
/*
|
72 |
+
* Some additional examples found in WP core.
|
73 |
+
*/
|
74 |
+
$first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example'; // OK.
|
75 |
+
|
76 |
+
$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); // OK.
|
77 |
+
|
78 |
+
// If we don't have an email from the input headers default to wordpress@$sitename <= OK.
|
79 |
+
$from_email = 'wordpress@' . $sitename; // OK.
|
80 |
+
|
81 |
+
if ( $counts['wordpress'] ) { // OK.
|
82 |
+
/* translators: 1: Number of updates available to WordPress */
|
83 |
+
$titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] ); // OK.
|
84 |
+
}
|
85 |
+
|
86 |
+
?>
|
87 |
+
<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td><!-- OK. -->
|
88 |
+
|
89 |
+
<ol id="authors"><form action="?import=wordpress&step=2&id=" method="post"><input type="hidden" name="_wpnonce" value="855ae98911" /><!-- OK. -->
|
90 |
+
|
91 |
+
<?php
|
92 |
+
/*
|
93 |
+
* More examples found in themes which should be accounted for.
|
94 |
+
* Based on a run of this sniff against 180 recently updated themes (7500+ files).
|
95 |
+
*/
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @wordpress-plugin <= OK.
|
99 |
+
* Plugin Name: TGM Plugin Activation
|
100 |
+
*
|
101 |
+
* @package WordPress <= Bad.
|
102 |
+
*
|
103 |
+
* @link OK: http://justintadlock.com/archives/2011/07/01/captions-in-wordpress
|
104 |
+
*/
|
105 |
+
|
106 |
+
if ( file_exists( ABSPATH . 'wp-content/plugins/wordpress-importer/wordpress-importer.php' ) ) { // OK.
|
107 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
108 |
+
|
109 |
+
return is_plugin_active( 'wordpress-importer/wordpress-importer.php' ); // OK.
|
110 |
+
}
|
111 |
+
|
112 |
+
$check = array(
|
113 |
+
'wordpress-importer' => array( 'installed' => false, 'active' => false ), // OK.
|
114 |
+
'widget-importer-exporter' => array( 'installed' => false, 'active' => false )
|
115 |
+
);
|
116 |
+
|
117 |
+
$default_editor_settings = [
|
118 |
+
'textarea_name' => $textarea_name,
|
119 |
+
'media_buttons' => false,
|
120 |
+
'tinymce' => [ 'plugins' => 'wordpress' ] // OK.
|
121 |
+
];
|
122 |
+
|
123 |
+
$wp_customize->add_control(
|
124 |
+
new Arouse_Custom_Content(
|
125 |
+
$wp_customize,
|
126 |
+
'arouse_documentation_link',
|
127 |
+
array(
|
128 |
+
'section' => 'arouse_theme_info',
|
129 |
+
'label' => __( 'Arouse Documentation', 'arouse' ),
|
130 |
+
'content' => __( '<a class="button" href="http://themezhut.com/arouse-wordpress-theme-documentation/" target="_blank">Read the documentation.</a>', 'arouse' ), // OK.
|
131 |
+
)
|
132 |
+
)
|
133 |
+
);
|
134 |
+
|
135 |
+
?>
|
136 |
+
|
137 |
+
<a href="https://wordpress.org/support/theme/{{ data.theme_slug }}/reviews/#new-post" class="button button-primary activello-wordpress"><span class="dashicons dashicons-wordpress"></span>Review this theme on w.org</a><!-- OK. -->
|
138 |
+
|
139 |
+
<p><?php _e( 'This page will help you get up and running quickly with <strong>Adamos</strong>. Please use the <a href="https://wordpress.org/support/theme/adamos">WordPress Support Forums</a> if you have experience issues with this theme.', 'adamos' ); ?></p><!-- Bad. -->
|
140 |
+
|
141 |
+
<a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/alhena-free-responsive-corporate-wordpress-theme/?ref=2&campaign=alhena-notice' ); ?>" class="button"><?php _e( 'Upgrade to Alhena Premium', 'alhena-lite' ); ?></a><!-- OK. -->
|
142 |
+
|
143 |
+
<?php
|
144 |
+
comment_form( array(
|
145 |
+
'fields' => apply_filters( 'comment_form_default_fields', $fields ),
|
146 |
+
/* translators: %s: wordpress login url */ // Bad, but false negative as within an array.
|
147 |
+
'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' , 'annina' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
|
148 |
+
));
|
149 |
+
|
150 |
+
$wl_theme_options['service_3_icons']="fa fa-wordpress"; // OK.
|
151 |
+
|
152 |
+
if ( get_theme_mod('header_icon', 'fa-wordpress') ) echo '<i class="fa ' .esc_attr(get_theme_mod('header_icon' , 'fa-wordpress')) . '"></i>'; // OK.
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Bootstrap styled Caption shortcode.
|
156 |
+
* Hat tip: http://justintadlock.com/archives/2011/07/01/captions-in-wordpress <= OK.
|
157 |
+
*/
|
158 |
+
|
159 |
+
$render = '<div class="redux-field-locked"><div class="redux-locked-inner' . (empty($message) ? ' empty' : '') . '"><a target="_blank" href="' . $t4p_url . 'evolve-multipurpose-wordpress-theme/" class="el el-lock"> </a>' . $message . '</div></div>' . $render; // OK.
|
160 |
+
|
161 |
+
$installed = self::check_plugin_is_installed( 'wordpress-importer' ); // OK.
|
162 |
+
|
163 |
+
|
164 |
+
/*
|
165 |
+
* Test whitelisting
|
166 |
+
*/
|
167 |
+
echo 'This is an explanation about wordpress.'; // WPCS: spelling ok.
|
168 |
+
|
169 |
+
/*
|
170 |
+
* Test fixer with an ignored and a fixable misspelling in the same line.
|
171 |
+
*/
|
172 |
+
?>
|
173 |
+
<p class="wordpress" href="http://x.org/?something=wordpress">The first two should be ignored for the purpose of replacing, this WordPress however should be fixed and this WordPress too.</p><!-- Bad. -->
|
174 |
+
|
175 |
+
<?php // POT filename should be ignored. ?>
|
176 |
+
wordpress.pot
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/CapitalPDangitUnitTest.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the CapitalPDangit sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_WP_CapitalPDangitUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @return array <int line number> => <int number of errors>
|
22 |
+
*/
|
23 |
+
public function getErrorList() {
|
24 |
+
return array();
|
25 |
+
|
26 |
+
} // end getErrorList()
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns the lines where warnings should occur.
|
30 |
+
*
|
31 |
+
* @param string $testFile The name of the file being tested.
|
32 |
+
* @return array <int line number> => <int number of warnings>
|
33 |
+
*/
|
34 |
+
public function getWarningList( $testFile = 'CapitalPDangitUnitTest.inc' ) {
|
35 |
+
|
36 |
+
switch ( $testFile ) {
|
37 |
+
case 'CapitalPDangitUnitTest.inc':
|
38 |
+
return array(
|
39 |
+
3 => 1,
|
40 |
+
5 => 1,
|
41 |
+
8 => 1,
|
42 |
+
26 => 1,
|
43 |
+
28 => 1,
|
44 |
+
34 => 1,
|
45 |
+
35 => 1,
|
46 |
+
36 => 1,
|
47 |
+
40 => 1,
|
48 |
+
41 => 1,
|
49 |
+
45 => 1,
|
50 |
+
53 => 1,
|
51 |
+
60 => 1,
|
52 |
+
61 => 1,
|
53 |
+
62 => 1,
|
54 |
+
65 => 1,
|
55 |
+
66 => 1,
|
56 |
+
68 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 2, // PHPCS on PHP 5.2 apparently breaks the token up into two tokens.
|
57 |
+
101 => 1,
|
58 |
+
139 => 1,
|
59 |
+
146 => 0, // False negative.
|
60 |
+
173 => 1,
|
61 |
+
);
|
62 |
+
|
63 |
+
case 'CapitalPDangitUnitTest.1.inc':
|
64 |
+
return array(
|
65 |
+
9 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 does not recognize nowdocs.
|
66 |
+
);
|
67 |
+
|
68 |
+
default:
|
69 |
+
return array();
|
70 |
+
|
71 |
+
} // End switch().
|
72 |
+
}
|
73 |
+
|
74 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedClassesUnitTest.inc
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// DEPRECATED WORDPRESS CLASSES.
|
4 |
+
|
5 |
+
/*
|
6 |
+
* Error.
|
7 |
+
*/
|
8 |
+
/* ============ WP 3.1 ============ */
|
9 |
+
$a = new WP_User_Search;
|
10 |
+
$a = new \WP_User_Search();
|
11 |
+
echo WP_User_Search::$users_per_page;
|
12 |
+
echo \WP_User_Search::prepare_query();
|
13 |
+
class My_User_Search extends WP_User_Search {}
|
14 |
+
class Our_User_Search implements WP_User_Search {}
|
15 |
+
$a = new WP_User_Search->query();
|
16 |
+
|
17 |
+
/*
|
18 |
+
* Warning.
|
19 |
+
*/
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedClassesUnitTest.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the WP_DeprecatedClasses sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_WP_DeprecatedClassesUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @return array <int line number> => <int number of errors>
|
22 |
+
*/
|
23 |
+
public function getErrorList() {
|
24 |
+
return array_fill( 9, 7, 1 );
|
25 |
+
|
26 |
+
} // End getErrorList().
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns the lines where warnings should occur.
|
30 |
+
*
|
31 |
+
* @return array <int line number> => <int number of warnings>
|
32 |
+
*/
|
33 |
+
public function getWarningList() {
|
34 |
+
return array();
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc
CHANGED
@@ -1,211 +1,265 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
// DEPRECATED WORDPRESS FUNCTIONS.
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
get_base_dir(); // WP_Filesystem_Base::get_base_dir() use WP_Filesystem::abspath instead.
|
10 |
-
the_category_id();
|
11 |
the_category_head();
|
|
|
|
|
12 |
permalink_link();
|
|
|
13 |
start_wp();
|
|
|
14 |
get_postdata();
|
15 |
-
|
|
|
16 |
next_post();
|
17 |
-
|
18 |
user_can_create_draft();
|
19 |
-
|
20 |
user_can_delete_post();
|
21 |
-
user_can_set_post_date();
|
22 |
-
user_can_edit_post_comments();
|
23 |
user_can_delete_post_comments();
|
|
|
|
|
|
|
24 |
user_can_edit_user();
|
25 |
-
|
26 |
-
|
27 |
-
wp_get_linksbyname();
|
28 |
-
get_linkobjectsbyname();
|
29 |
-
get_linkobjects();
|
30 |
-
get_linksbyname_withrating();
|
31 |
-
get_links_withrating();
|
32 |
-
get_autotoggle();
|
33 |
-
list_cats();
|
34 |
-
wp_list_cats();
|
35 |
dropdown_cats();
|
36 |
-
list_authors();
|
37 |
-
wp_get_post_cats();
|
38 |
-
wp_set_post_cats();
|
39 |
get_archives();
|
40 |
get_author_link();
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
44 |
get_links();
|
45 |
get_links_list();
|
|
|
|
|
|
|
|
|
|
|
46 |
links_popup_script();
|
47 |
-
|
48 |
-
|
49 |
-
get_link();
|
50 |
tinymce_include();
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
comments_rss();
|
|
|
52 |
permalink_single_rss();
|
|
|
53 |
comments_rss_link();
|
54 |
-
|
55 |
-
get_author_rss_link();
|
56 |
-
get_the_attachment_link();
|
57 |
-
get_attachment_icon_src();
|
58 |
get_attachment_icon();
|
|
|
59 |
get_attachment_innerHTML();
|
60 |
-
|
|
|
|
|
61 |
gzip_compression();
|
62 |
-
|
63 |
wp_get_cookie_login();
|
64 |
wp_login();
|
|
|
|
|
65 |
dropdown_categories();
|
66 |
dropdown_link_categories();
|
|
|
67 |
get_commentdata();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
get_catname();
|
69 |
get_category_children();
|
|
|
70 |
get_the_author_description();
|
71 |
-
|
72 |
-
get_the_author_login();
|
73 |
get_the_author_firstname();
|
74 |
-
|
|
|
75 |
get_the_author_lastname();
|
76 |
-
|
|
|
77 |
get_the_author_nickname();
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
the_author_email();
|
81 |
-
|
82 |
the_author_icq();
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
the_author_msn();
|
87 |
-
|
88 |
-
the_author_aim();
|
89 |
-
get_author_name();
|
90 |
-
get_the_author_url();
|
91 |
the_author_url();
|
92 |
-
|
93 |
-
the_author_ID();
|
94 |
-
__ngettext();
|
95 |
-
__ngettext_noop();
|
96 |
-
sanitize_url();
|
97 |
-
js_escape();
|
98 |
-
wp_specialchars();
|
99 |
-
attribute_escape();
|
100 |
-
register_sidebar_widget();
|
101 |
unregister_sidebar_widget();
|
102 |
-
register_widget_control();
|
103 |
unregister_widget_control();
|
104 |
-
|
105 |
-
|
106 |
_c();
|
|
|
|
|
|
|
|
|
107 |
translate_with_context();
|
108 |
-
|
109 |
-
|
|
|
|
|
110 |
clean_url();
|
|
|
|
|
|
|
|
|
111 |
delete_usermeta();
|
112 |
-
get_usermeta();
|
113 |
-
update_usermeta();
|
114 |
-
automatic_feed_links();
|
115 |
-
get_profile();
|
116 |
-
get_usernumposts();
|
117 |
funky_javascript_callback();
|
118 |
funky_javascript_fix();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
is_taxonomy();
|
120 |
is_term();
|
121 |
-
|
122 |
-
|
123 |
remove_option_update_handler();
|
124 |
-
|
125 |
-
|
126 |
use_codepress();
|
|
|
|
|
127 |
wp_shrink_dimensions();
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
get_author_user_ids();
|
|
|
132 |
get_editable_authors();
|
133 |
get_editable_user_ids();
|
134 |
get_nonauthor_user_ids();
|
135 |
-
WP_User_Search();
|
136 |
-
get_others_unpublished_posts();
|
137 |
get_others_drafts();
|
138 |
get_others_pending();
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
favorite_actions();
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
149 |
get_boundary_post_rel_link();
|
150 |
-
start_post_rel_link();
|
151 |
get_index_rel_link();
|
152 |
-
index_rel_link();
|
153 |
get_parent_post_rel_link();
|
154 |
-
|
155 |
-
|
|
|
|
|
156 |
is_blog_user();
|
157 |
-
debug_fopen();
|
158 |
-
debug_fwrite();
|
159 |
-
debug_fclose();
|
160 |
-
screen_layout();
|
161 |
-
screen_options();
|
162 |
-
screen_meta();
|
163 |
-
media_upload_image();
|
164 |
media_upload_audio();
|
165 |
-
media_upload_video();
|
166 |
media_upload_file();
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
type_url_form_audio();
|
169 |
-
type_url_form_video();
|
170 |
type_url_form_file();
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
178 |
add_custom_background();
|
179 |
-
|
180 |
-
get_theme_data();
|
181 |
-
update_page_cache();
|
182 |
clean_page_cache();
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
get_allowed_themes();
|
184 |
get_broken_themes();
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
wp_explain_nonce();
|
187 |
-
|
|
|
|
|
188 |
_get_post_ancestors();
|
189 |
-
wp_load_image();
|
190 |
-
image_resize();
|
191 |
-
wp_get_single_post();
|
192 |
-
user_pass_ok();
|
193 |
-
_save_post_hook();
|
194 |
-
gd_edit_image_support();
|
195 |
_insert_into_post_button();
|
196 |
_media_button();
|
197 |
-
|
|
|
|
|
|
|
198 |
get_default_page_to_edit();
|
|
|
|
|
|
|
|
|
|
|
199 |
wp_create_thumbnail();
|
|
|
|
|
|
|
200 |
get_user_id_from_string();
|
201 |
wp_convert_bytes_to_hr();
|
202 |
wp_nav_menu_locations_meta_box();
|
|
|
|
|
|
|
203 |
the_attachment_links();
|
204 |
wp_update_core();
|
205 |
wp_update_plugin();
|
206 |
wp_update_theme();
|
207 |
-
|
208 |
-
get_blogaddress_by_domain();
|
209 |
get_screen_icon();
|
210 |
screen_icon();
|
211 |
wp_dashboard_incoming_links();
|
@@ -217,44 +271,64 @@ wp_dashboard_recent_comments_control();
|
|
217 |
wp_dashboard_secondary();
|
218 |
wp_dashboard_secondary_control();
|
219 |
wp_dashboard_secondary_output();
|
220 |
-
|
|
|
221 |
default_topic_count_text();
|
222 |
format_to_post();
|
223 |
get_current_site_name();
|
|
|
224 |
wpmu_current_site();
|
225 |
-
|
226 |
get_all_category_ids();
|
227 |
like_escape();
|
228 |
url_is_accessable_via_ssl();
|
229 |
-
|
230 |
-
add_tab();
|
231 |
-
|
232 |
-
print_tab_image();
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
239 |
_preview_theme_stylesheet_filter();
|
|
|
|
|
240 |
preview_theme_ob_filter();
|
241 |
preview_theme_ob_filter_callback();
|
242 |
-
wp_richedit_pre();
|
243 |
wp_ajax_wp_fullscreen_save_post();
|
244 |
-
|
245 |
-
|
246 |
-
flush_widget_cache(); // WP_Widget_Recent_Comments::flush_widget_cache()
|
247 |
-
post_permalink();
|
248 |
-
force_ssl_login();
|
249 |
create_empty_blog();
|
|
|
250 |
get_admin_users_for_domain();
|
|
|
251 |
wp_get_http();
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
253 |
add_object_page();
|
254 |
add_utility_page();
|
255 |
-
get_comments_popup_template();
|
256 |
comments_popup_script();
|
257 |
-
|
258 |
get_currentuserinfo();
|
|
|
|
|
|
|
|
|
259 |
wp_embed_handler_googlevideo();
|
260 |
wp_get_sites();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
|
|
2 |
// DEPRECATED WORDPRESS FUNCTIONS.
|
3 |
|
4 |
+
/*
|
5 |
+
* Error.
|
6 |
+
*/
|
7 |
+
/* ============ WP 0.71 ============ */
|
|
|
|
|
8 |
the_category_head();
|
9 |
+
the_category_ID();
|
10 |
+
/* ============ WP 1.2 ============ */
|
11 |
permalink_link();
|
12 |
+
/* ============ WP 1.5 ============ */
|
13 |
start_wp();
|
14 |
+
/* ============ WP 1.5.1 ============ */
|
15 |
get_postdata();
|
16 |
+
/* ============ WP 2.0 ============ */
|
17 |
+
create_user();
|
18 |
next_post();
|
19 |
+
previous_post();
|
20 |
user_can_create_draft();
|
21 |
+
user_can_create_post();
|
22 |
user_can_delete_post();
|
|
|
|
|
23 |
user_can_delete_post_comments();
|
24 |
+
user_can_edit_post();
|
25 |
+
user_can_edit_post_comments();
|
26 |
+
user_can_edit_post_date();
|
27 |
user_can_edit_user();
|
28 |
+
user_can_set_post_date();
|
29 |
+
/* ============ WP 2.1 ============ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
dropdown_cats();
|
|
|
|
|
|
|
31 |
get_archives();
|
32 |
get_author_link();
|
33 |
+
get_autotoggle();
|
34 |
+
get_link();
|
35 |
+
get_linkcatname();
|
36 |
+
get_linkobjectsbyname();
|
37 |
+
get_linkobjects();
|
38 |
+
get_linkrating();
|
39 |
get_links();
|
40 |
get_links_list();
|
41 |
+
get_links_withrating();
|
42 |
+
get_linksbyname();
|
43 |
+
get_linksbyname_withrating();
|
44 |
+
get_settings();
|
45 |
+
link_pages();
|
46 |
links_popup_script();
|
47 |
+
list_authors();
|
48 |
+
list_cats();
|
|
|
49 |
tinymce_include();
|
50 |
+
wp_get_links();
|
51 |
+
wp_get_linksbyname();
|
52 |
+
wp_get_post_cats();
|
53 |
+
wp_list_cats();
|
54 |
+
wp_set_post_cats();
|
55 |
+
/* ============ WP 2.2 ============ */
|
56 |
comments_rss();
|
57 |
+
/* ============ WP 2.3 ============ */
|
58 |
permalink_single_rss();
|
59 |
+
/* ============ WP 2.5 ============ */
|
60 |
comments_rss_link();
|
61 |
+
documentation_link();
|
|
|
|
|
|
|
62 |
get_attachment_icon();
|
63 |
+
get_attachment_icon_src();
|
64 |
get_attachment_innerHTML();
|
65 |
+
get_author_rss_link();
|
66 |
+
get_category_rss_link();
|
67 |
+
get_the_attachment_link();
|
68 |
gzip_compression();
|
69 |
+
wp_clearcookie();
|
70 |
wp_get_cookie_login();
|
71 |
wp_login();
|
72 |
+
wp_setcookie();
|
73 |
+
/* ============ WP 2.6 ============ */
|
74 |
dropdown_categories();
|
75 |
dropdown_link_categories();
|
76 |
+
/* ============ WP 2.7 ============ */
|
77 |
get_commentdata();
|
78 |
+
find_base_dir(); // Issue #731 - method WP_Filesystem_Base::find_base_dir() use WP_Filesystem::abspath instead.
|
79 |
+
get_base_dir(); // Issue #731 - method WP_Filesystem_Base::get_base_dir() use WP_Filesystem::abspath instead.
|
80 |
+
/* ============ WP 2.8 ============ */
|
81 |
+
__ngettext();
|
82 |
+
__ngettext_noop();
|
83 |
+
attribute_escape();
|
84 |
+
get_author_name();
|
85 |
get_catname();
|
86 |
get_category_children();
|
87 |
+
get_the_author_aim();
|
88 |
get_the_author_description();
|
89 |
+
get_the_author_email();
|
|
|
90 |
get_the_author_firstname();
|
91 |
+
get_the_author_icq();
|
92 |
+
get_the_author_ID();
|
93 |
get_the_author_lastname();
|
94 |
+
get_the_author_login();
|
95 |
+
get_the_author_msn();
|
96 |
get_the_author_nickname();
|
97 |
+
get_the_author_url();
|
98 |
+
get_the_author_yim();
|
99 |
+
js_escape();
|
100 |
+
register_sidebar_widget();
|
101 |
+
register_widget_control();
|
102 |
+
sanitize_url();
|
103 |
+
the_author_aim();
|
104 |
+
the_author_description();
|
105 |
the_author_email();
|
106 |
+
the_author_firstname();
|
107 |
the_author_icq();
|
108 |
+
the_author_ID();
|
109 |
+
the_author_lastname();
|
110 |
+
the_author_login();
|
111 |
the_author_msn();
|
112 |
+
the_author_nickname();
|
|
|
|
|
|
|
113 |
the_author_url();
|
114 |
+
the_author_yim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
unregister_sidebar_widget();
|
|
|
116 |
unregister_widget_control();
|
117 |
+
wp_specialchars();
|
118 |
+
/* ============ WP 2.9 ============ */
|
119 |
_c();
|
120 |
+
_nc();
|
121 |
+
get_real_file_to_edit();
|
122 |
+
make_url_footnote();
|
123 |
+
the_content_rss();
|
124 |
translate_with_context();
|
125 |
+
/* ============ WP 3.0 ============ */
|
126 |
+
activate_sitewide_plugin();
|
127 |
+
add_option_update_handler();
|
128 |
+
automatic_feed_links();
|
129 |
clean_url();
|
130 |
+
clear_global_post_cache();
|
131 |
+
codepress_footer_js();
|
132 |
+
codepress_get_lang();
|
133 |
+
deactivate_sitewide_plugin();
|
134 |
delete_usermeta();
|
|
|
|
|
|
|
|
|
|
|
135 |
funky_javascript_callback();
|
136 |
funky_javascript_fix();
|
137 |
+
generate_random_password();
|
138 |
+
get_alloptions();
|
139 |
+
get_blog_list();
|
140 |
+
get_most_active_blogs();
|
141 |
+
get_profile();
|
142 |
+
get_user_details();
|
143 |
+
get_usermeta();
|
144 |
+
get_usernumposts();
|
145 |
+
graceful_fail();
|
146 |
+
is_main_blog();
|
147 |
+
is_site_admin();
|
148 |
is_taxonomy();
|
149 |
is_term();
|
150 |
+
is_wpmu_sitewide_plugin();
|
151 |
+
mu_options();
|
152 |
remove_option_update_handler();
|
153 |
+
set_current_user();
|
154 |
+
update_usermeta();
|
155 |
use_codepress();
|
156 |
+
validate_email();
|
157 |
+
wp_dropdown_cats();
|
158 |
wp_shrink_dimensions();
|
159 |
+
wpmu_checkAvailableSpace();
|
160 |
+
wpmu_menu();
|
161 |
+
/* ============ WP 3.1 ============ */
|
162 |
get_author_user_ids();
|
163 |
+
get_dashboard_blog();
|
164 |
get_editable_authors();
|
165 |
get_editable_user_ids();
|
166 |
get_nonauthor_user_ids();
|
|
|
|
|
167 |
get_others_drafts();
|
168 |
get_others_pending();
|
169 |
+
get_others_unpublished_posts();
|
170 |
+
get_users_of_blog();
|
171 |
+
install_themes_feature_list();
|
172 |
+
is_plugin_page();
|
173 |
+
update_category_cache();
|
174 |
+
/* ============ WP 3.2 ============ */
|
175 |
favorite_actions();
|
176 |
+
wp_dashboard_quick_press_output();
|
177 |
+
wp_timezone_supported();
|
178 |
+
/* ============ WP 3.3 ============ */
|
179 |
+
add_contextual_help();
|
180 |
get_boundary_post_rel_link();
|
|
|
181 |
get_index_rel_link();
|
|
|
182 |
get_parent_post_rel_link();
|
183 |
+
get_user_by_email();
|
184 |
+
get_user_metavalues();
|
185 |
+
get_userdatabylogin();
|
186 |
+
index_rel_link();
|
187 |
is_blog_user();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
media_upload_audio();
|
|
|
189 |
media_upload_file();
|
190 |
+
media_upload_image();
|
191 |
+
media_upload_video();
|
192 |
+
parent_post_rel_link();
|
193 |
+
sanitize_user_object();
|
194 |
+
screen_layout();
|
195 |
+
screen_meta();
|
196 |
+
screen_options();
|
197 |
+
start_post_rel_link();
|
198 |
+
the_editor();
|
199 |
type_url_form_audio();
|
|
|
200 |
type_url_form_file();
|
201 |
+
type_url_form_image();
|
202 |
+
type_url_form_video();
|
203 |
+
wp_admin_bar_dashboard_view_site_menu();
|
204 |
+
wp_preload_dialogs();
|
205 |
+
wp_print_editor_js();
|
206 |
+
wp_quicktags();
|
207 |
+
wp_tiny_mce();
|
208 |
+
wpmu_admin_do_redirect();
|
209 |
+
wpmu_admin_redirect_add_updated_param();
|
210 |
+
/* ============ WP 3.4 ============ */
|
211 |
add_custom_background();
|
212 |
+
add_custom_image_header();
|
|
|
|
|
213 |
clean_page_cache();
|
214 |
+
clean_pre();
|
215 |
+
current_theme_info();
|
216 |
+
debug_fclose();
|
217 |
+
debug_fopen();
|
218 |
+
debug_fwrite();
|
219 |
+
display_theme();
|
220 |
get_allowed_themes();
|
221 |
get_broken_themes();
|
222 |
+
get_current_theme();
|
223 |
+
get_site_allowed_themes();
|
224 |
+
get_theme();
|
225 |
+
get_theme_data();
|
226 |
+
get_themes();
|
227 |
+
logIO();
|
228 |
+
remove_custom_background();
|
229 |
+
remove_custom_image_header();
|
230 |
+
update_page_cache();
|
231 |
wp_explain_nonce();
|
232 |
+
wpmu_get_blog_allowedthemes();
|
233 |
+
/* ============ WP 3.5 ============ */
|
234 |
+
_flip_image_resource();
|
235 |
_get_post_ancestors();
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
_insert_into_post_button();
|
237 |
_media_button();
|
238 |
+
_rotate_image_resource();
|
239 |
+
_save_post_hook();
|
240 |
+
image_resize();
|
241 |
+
gd_edit_image_support();
|
242 |
get_default_page_to_edit();
|
243 |
+
get_post_to_edit();
|
244 |
+
get_udims();
|
245 |
+
sticky_class();
|
246 |
+
user_pass_ok();
|
247 |
+
wp_cache_reset();
|
248 |
wp_create_thumbnail();
|
249 |
+
wp_get_single_post();
|
250 |
+
wp_load_image();
|
251 |
+
/* ============ WP 3.6 ============ */
|
252 |
get_user_id_from_string();
|
253 |
wp_convert_bytes_to_hr();
|
254 |
wp_nav_menu_locations_meta_box();
|
255 |
+
/* ============ WP 3.7 ============ */
|
256 |
+
_search_terms_tidy();
|
257 |
+
get_blogaddress_by_domain();
|
258 |
the_attachment_links();
|
259 |
wp_update_core();
|
260 |
wp_update_plugin();
|
261 |
wp_update_theme();
|
262 |
+
/* ============ WP 3.8 ============ */
|
|
|
263 |
get_screen_icon();
|
264 |
screen_icon();
|
265 |
wp_dashboard_incoming_links();
|
271 |
wp_dashboard_secondary();
|
272 |
wp_dashboard_secondary_control();
|
273 |
wp_dashboard_secondary_output();
|
274 |
+
/* ============ WP 3.9 ============ */
|
275 |
+
_relocate_children();
|
276 |
default_topic_count_text();
|
277 |
format_to_post();
|
278 |
get_current_site_name();
|
279 |
+
rich_edit_exists();
|
280 |
wpmu_current_site();
|
281 |
+
/* ============ WP 4.0 ============ */
|
282 |
get_all_category_ids();
|
283 |
like_escape();
|
284 |
url_is_accessable_via_ssl();
|
285 |
+
/* ============ WP 4.1 ============ */
|
286 |
+
add_tab(); // Issue #731 - method, not function.
|
287 |
+
prepare_control(); // Issue #731 - method, not function.
|
288 |
+
print_tab_image(); // Issue #731 - method, not function.
|
289 |
+
remove_tab(); // Issue #731 - method, not function.
|
290 |
+
/* ============ WP 4.2 ============ */
|
291 |
+
prepreview_added_sidebars_widgets(); // Issue #731 - method, not function.
|
292 |
+
prepreview_added_widget_instance(); // Issue #731 - method, not function.
|
293 |
+
remove_prepreview_filters(); // Issue #731 - method, not function.
|
294 |
+
setup_widget_addition_previews(); // Issue #731 - method, not function.
|
295 |
+
/* ============ WP 4.3 ============ */
|
296 |
_preview_theme_stylesheet_filter();
|
297 |
+
_preview_theme_template_filter();
|
298 |
+
preview_theme();
|
299 |
preview_theme_ob_filter();
|
300 |
preview_theme_ob_filter_callback();
|
|
|
301 |
wp_ajax_wp_fullscreen_save_post();
|
302 |
+
wp_richedit_pre();
|
303 |
+
/* ============ WP 4.4 ============ */
|
|
|
|
|
|
|
304 |
create_empty_blog();
|
305 |
+
force_ssl_login();
|
306 |
get_admin_users_for_domain();
|
307 |
+
post_permalink();
|
308 |
wp_get_http();
|
309 |
+
flush_widget_cache(); // Issue #731 - method WP_Widget_Recent_Comments::flush_widget_cache()
|
310 |
+
|
311 |
+
/*
|
312 |
+
* Warning.
|
313 |
+
*/
|
314 |
+
/* ============ WP 4.5 ============ */
|
315 |
add_object_page();
|
316 |
add_utility_page();
|
|
|
317 |
comments_popup_script();
|
318 |
+
get_comments_popup_template();
|
319 |
get_currentuserinfo();
|
320 |
+
is_comments_popup();
|
321 |
+
popuplinks();
|
322 |
+
/* ============ WP 4.6 ============ */
|
323 |
+
post_form_autocomplete_off();
|
324 |
wp_embed_handler_googlevideo();
|
325 |
wp_get_sites();
|
326 |
+
/* ============ WP 4.7 ============ */
|
327 |
+
_sort_nav_menu_items();
|
328 |
+
_usort_terms_by_ID();
|
329 |
+
_usort_terms_by_name();
|
330 |
+
get_paged_template();
|
331 |
+
wp_get_network();
|
332 |
+
wp_kses_js_entities();
|
333 |
+
/* ============ WP 4.8 ============ */
|
334 |
+
wp_dashboard_plugins_output();
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php
CHANGED
@@ -22,8 +22,20 @@ class WordPress_Tests_WP_DeprecatedFunctionsUnitTest extends AbstractSniffUnitTe
|
|
22 |
* @return array <int line number> => <int number of errors>
|
23 |
*/
|
24 |
public function getErrorList() {
|
25 |
-
return array_fill( 8, 236, 1 );
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
@@ -32,8 +44,15 @@ class WordPress_Tests_WP_DeprecatedFunctionsUnitTest extends AbstractSniffUnitTe
|
|
32 |
* @return array <int line number> => <int number of warnings>
|
33 |
*/
|
34 |
public function getWarningList() {
|
35 |
-
return array_fill( 246, 15, 1 );
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
} // End class.
|
22 |
* @return array <int line number> => <int number of errors>
|
23 |
*/
|
24 |
public function getErrorList() {
|
|
|
25 |
|
26 |
+
$errors = array_fill( 8, 302, 1 );
|
27 |
+
|
28 |
+
// Unset the lines related to version comments.
|
29 |
+
unset(
|
30 |
+
$errors[10], $errors[12], $errors[14], $errors[16], $errors[29],
|
31 |
+
$errors[55], $errors[57], $errors[59], $errors[73], $errors[76],
|
32 |
+
$errors[80], $errors[118], $errors[125], $errors[161], $errors[174],
|
33 |
+
$errors[178], $errors[210], $errors[233], $errors[251], $errors[255],
|
34 |
+
$errors[262], $errors[274], $errors[281], $errors[285], $errors[290],
|
35 |
+
$errors[295], $errors[303]
|
36 |
+
);
|
37 |
+
|
38 |
+
return $errors;
|
39 |
}
|
40 |
|
41 |
/**
|
44 |
* @return array <int line number> => <int number of warnings>
|
45 |
*/
|
46 |
public function getWarningList() {
|
|
|
47 |
|
48 |
+
$warnings = array_fill( 315, 20, 1 );
|
49 |
+
|
50 |
+
// Unset the lines related to version comments.
|
51 |
+
unset(
|
52 |
+
$warnings[322], $warnings[326], $warnings[333]
|
53 |
+
);
|
54 |
+
|
55 |
+
return $warnings;
|
56 |
}
|
57 |
|
58 |
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedParametersUnitTest.inc
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// All will be OK as the default value is used.
|
4 |
+
|
5 |
+
wp_title_rss( '–' ); // 1st.
|
6 |
+
wp_get_sidebars_widgets( true ); // 1st.
|
7 |
+
wp_new_user_notification( '', null, '' ); // 2nd.
|
8 |
+
the_attachment_link( '', false, false, false ); // 3rd.
|
9 |
+
update_blog_option( '', '', '', null ); // 4th.
|
10 |
+
wp_install( '', '', '', '', '' ); // 5th.
|
11 |
+
get_category_parents( '', '', '', '', array() ); // 5th.
|
12 |
+
get_category_parents( '', '', '', '', [] ); // 5th.
|
13 |
+
|
14 |
+
// Method names within a class should be fine.
|
15 |
+
|
16 |
+
Theme_Object::wp_title_rss( 'home' ); // Ok.
|
17 |
+
$this->wp_title_rss( 'siteurl' ); // Ok.
|
18 |
+
$theme_object->wp_title_rss( 'text_direction' ); // Ok.
|
19 |
+
|
20 |
+
// All will give an Error even though they have a dynamic variable.
|
21 |
+
|
22 |
+
wp_new_user_notification( '', $variable );
|
23 |
+
wp_new_user_notification( '', function_name() );
|
24 |
+
wp_new_user_notification( '', $this->method_name() );
|
25 |
+
|
26 |
+
// All will give an ERROR. The functions are ordered alphabetically.
|
27 |
+
|
28 |
+
add_option( '', '', [] );
|
29 |
+
add_option( '', '', 1.23 );
|
30 |
+
add_option( '', '', 10 );
|
31 |
+
add_option( '', '', false );
|
32 |
+
add_option( '', '', 'deprecated' );
|
33 |
+
comments_link( 'deprecated', 'deprecated' );
|
34 |
+
comments_number( '', '', '', 'deprecated' );
|
35 |
+
convert_chars( '', 'deprecated' );
|
36 |
+
discover_pingback_server_uri( '', 'deprecated' );
|
37 |
+
get_delete_post_link( '', 'deprecated' );
|
38 |
+
get_last_updated( 'deprecated' );
|
39 |
+
get_the_author( 'deprecated' );
|
40 |
+
get_user_option( '', '', 'deprecated' );
|
41 |
+
get_wp_title_rss( 'deprecated' );
|
42 |
+
is_email( '', 'deprecated' );
|
43 |
+
is_email( '', 'false' ); // False as a string not bool.
|
44 |
+
load_plugin_textdomain( '', 'deprecated' );
|
45 |
+
safecss_filter_attr( '', 'deprecated' );
|
46 |
+
the_attachment_link( '', '', 'deprecated' );
|
47 |
+
the_author( 'deprecated', 'deprecated' );
|
48 |
+
the_author_posts_link( 'deprecated' );
|
49 |
+
trackback_rdf( 'deprecated' );
|
50 |
+
trackback_url( 'deprecated' );
|
51 |
+
update_blog_option( '', '', '', 'deprecated' );
|
52 |
+
update_user_status( '', '', '', 'deprecated' );
|
53 |
+
wp_get_http_headers( '', 'deprecated' );
|
54 |
+
wp_get_sidebars_widgets( 'deprecated' );
|
55 |
+
wp_install( '', '', '', '', 'deprecated' );
|
56 |
+
wp_new_user_notification( '', 'deprecated' );
|
57 |
+
wp_notify_postauthor( '', 'deprecated' );
|
58 |
+
wp_notify_postauthor( '', 'null' ); // Null as a string not null.
|
59 |
+
wp_title_rss( 'deprecated' );
|
60 |
+
wp_upload_bits( '', 'deprecated' );
|
61 |
+
xfn_check( '', '', 'deprecated' );
|
62 |
+
|
63 |
+
// All will give an WARNING as they have been deprecated after WP 4.5.
|
64 |
+
|
65 |
+
get_category_parents( '', '', '', '', array( 'deprecated') );
|
66 |
+
unregister_setting( '', '', '', 'deprecated' );
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/DeprecatedParametersUnitTest.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the DeprecatedParameters sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_WP_DeprecatedParametersUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns the lines where errors should occur.
|
20 |
+
*
|
21 |
+
* @return array <int line number> => <int number of errors>
|
22 |
+
*/
|
23 |
+
public function getErrorList() {
|
24 |
+
$errors = array_fill( 28, 34, 1 );
|
25 |
+
|
26 |
+
$errors[22] = 1;
|
27 |
+
$errors[23] = 1;
|
28 |
+
$errors[24] = 1;
|
29 |
+
|
30 |
+
// Override number of errors.
|
31 |
+
$errors[33] = 2;
|
32 |
+
$errors[47] = 2;
|
33 |
+
|
34 |
+
return $errors;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns the lines where warnings should occur.
|
39 |
+
*
|
40 |
+
* @return array <int line number> => <int number of warnings>
|
41 |
+
*/
|
42 |
+
public function getWarningList() {
|
43 |
+
return array(
|
44 |
+
65 => 1,
|
45 |
+
66 => 1,
|
46 |
+
);
|
47 |
+
}
|
48 |
+
|
49 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/EnqueuedResourcesUnitTest.inc
CHANGED
@@ -8,4 +8,25 @@
|
|
8 |
|
9 |
|
10 |
echo '<script src="' . SOMESCRIPT . '">';
|
11 |
-
echo '<link rel="stylesheet" src="' . SOMESCRIPT . '">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
echo '<script src="' . SOMESCRIPT . '">';
|
11 |
+
echo '<link rel="stylesheet" src="' . SOMESCRIPT . '">';
|
12 |
+
|
13 |
+
$double_quoted = "<link rel=\"stylesheet\" href=\"{$stylesheet}\">
|
14 |
+
<script src=\"{$script}\"></script>";
|
15 |
+
|
16 |
+
$double_quoted = "<link rel='stylesheet' href='{$stylesheet}' />
|
17 |
+
<script src='{$script}'></script>";
|
18 |
+
|
19 |
+
$head = <<<EOT
|
20 |
+
<link rel="stylesheet" href="http://someurl/somefile.css">
|
21 |
+
<script src="http://someurl/somefile.js"></script>
|
22 |
+
EOT;
|
23 |
+
|
24 |
+
$head = <<<"EOT"
|
25 |
+
<link rel="stylesheet" href="http://someurl/somefile.css">
|
26 |
+
<script src="http://someurl/somefile.js"></script>
|
27 |
+
EOT;
|
28 |
+
|
29 |
+
$head = <<<'EOD'
|
30 |
+
<link rel="stylesheet" href="http://someurl/somefile.css">
|
31 |
+
<script src="http://someurl/somefile.js"></script>
|
32 |
+
EOD;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php
CHANGED
@@ -15,17 +15,6 @@
|
|
15 |
*/
|
16 |
class WordPress_Tests_WP_EnqueuedResourcesUnitTest extends AbstractSniffUnitTest {
|
17 |
|
18 |
-
/**
|
19 |
-
* Skip this test on PHP 5.2.
|
20 |
-
*
|
21 |
-
* @since 0.9.0
|
22 |
-
*
|
23 |
-
* @return bool Whether to skip this test.
|
24 |
-
*/
|
25 |
-
protected function shouldSkipTest() {
|
26 |
-
return ( PHP_VERSION_ID < 50300 );
|
27 |
-
}
|
28 |
-
|
29 |
/**
|
30 |
* Returns the lines where errors should occur.
|
31 |
*
|
@@ -34,11 +23,21 @@ class WordPress_Tests_WP_EnqueuedResourcesUnitTest extends AbstractSniffUnitTest
|
|
34 |
public function getErrorList() {
|
35 |
return array(
|
36 |
1 => 1,
|
37 |
-
2 => 1,
|
38 |
6 => 1,
|
39 |
-
7 => 1,
|
40 |
10 => 1,
|
41 |
11 => 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
);
|
43 |
|
44 |
}
|
15 |
*/
|
16 |
class WordPress_Tests_WP_EnqueuedResourcesUnitTest extends AbstractSniffUnitTest {
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* Returns the lines where errors should occur.
|
20 |
*
|
23 |
public function getErrorList() {
|
24 |
return array(
|
25 |
1 => 1,
|
26 |
+
2 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 has a bug tokenizing inline HTML / `<s`.
|
27 |
6 => 1,
|
28 |
+
7 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 has a bug tokenizing inline HTML / `<s`.
|
29 |
10 => 1,
|
30 |
11 => 1,
|
31 |
+
13 => 1,
|
32 |
+
14 => 1,
|
33 |
+
16 => 1,
|
34 |
+
17 => 1,
|
35 |
+
20 => 1,
|
36 |
+
21 => 1,
|
37 |
+
25 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 does not recognize double quoted T_HEREDOC.
|
38 |
+
26 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 does not recognize double quoted T_HEREDOC.
|
39 |
+
30 => 1, // PHPCS on PHP 5.2 does not recognize T_NOWDOC, but sees this as a literal string anyway.
|
40 |
+
31 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 does not recognize T_NOWDOC.
|
41 |
);
|
42 |
|
43 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/I18nUnitTest.inc
CHANGED
@@ -128,5 +128,28 @@ __( "%04d for %'.9d item", 'my-slug' ); // Bad - Placeholder with other specifie
|
|
128 |
__( '%1$d for %d item', 'my-slug' ); // Bad.
|
129 |
__( '%1$d for %d and %d item', 'my-slug' ); // Bad.
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
// @codingStandardsChangeSetting WordPress.WP.I18n check_translator_comments true
|
128 |
__( '%1$d for %d item', 'my-slug' ); // Bad.
|
129 |
__( '%1$d for %d and %d item', 'my-slug' ); // Bad.
|
130 |
|
131 |
+
// Nowdoc syntax.
|
132 |
+
__( <<<'EOD'
|
133 |
+
%1$d for %d item
|
134 |
+
EOD
|
135 |
+
, 'my-slug' ); // Bad.
|
136 |
+
|
137 |
+
// Multi-line heredoc syntax.
|
138 |
+
_nx( <<<'EOD'
|
139 |
+
I have
|
140 |
+
%d cat and %d
|
141 |
+
dog.
|
142 |
+
EOD
|
143 |
+
, <<<'EOD'
|
144 |
+
I have
|
145 |
+
%d cats and %d
|
146 |
+
dogs.
|
147 |
+
EOD
|
148 |
+
, $number, <<<'EOD'
|
149 |
+
Not
|
150 |
+
really.
|
151 |
+
EOD
|
152 |
+
, 'my-slug' ); // OK.
|
153 |
+
|
154 |
|
155 |
// @codingStandardsChangeSetting WordPress.WP.I18n check_translator_comments true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/I18nUnitTest.inc.fixed
CHANGED
@@ -128,5 +128,28 @@ __( "%1\$04d for %2\$'.9d item", 'my-slug' ); // Bad - Placeholder with other sp
|
|
128 |
__( '%1$d for %d item', 'my-slug' ); // Bad.
|
129 |
__( '%1$d for %d and %d item', 'my-slug' ); // Bad.
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
// @codingStandardsChangeSetting WordPress.WP.I18n check_translator_comments true
|
128 |
__( '%1$d for %d item', 'my-slug' ); // Bad.
|
129 |
__( '%1$d for %d and %d item', 'my-slug' ); // Bad.
|
130 |
|
131 |
+
// Nowdoc syntax.
|
132 |
+
__( <<<'EOD'
|
133 |
+
%1$d for %d item
|
134 |
+
EOD
|
135 |
+
, 'my-slug' ); // Bad.
|
136 |
+
|
137 |
+
// Multi-line heredoc syntax.
|
138 |
+
_nx( <<<'EOD'
|
139 |
+
I have
|
140 |
+
%d cat and %d
|
141 |
+
dog.
|
142 |
+
EOD
|
143 |
+
, <<<'EOD'
|
144 |
+
I have
|
145 |
+
%d cats and %d
|
146 |
+
dogs.
|
147 |
+
EOD
|
148 |
+
, $number, <<<'EOD'
|
149 |
+
Not
|
150 |
+
really.
|
151 |
+
EOD
|
152 |
+
, 'my-slug' ); // OK.
|
153 |
+
|
154 |
|
155 |
// @codingStandardsChangeSetting WordPress.WP.I18n check_translator_comments true
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/I18nUnitTest.php
CHANGED
@@ -91,6 +91,10 @@ class WordPress_Tests_WP_I18nUnitTest extends AbstractSniffUnitTest {
|
|
91 |
125 => 1,
|
92 |
128 => 1,
|
93 |
129 => 1,
|
|
|
|
|
|
|
|
|
94 |
);
|
95 |
|
96 |
case 'I18nUnitTest.1.inc':
|
91 |
125 => 1,
|
92 |
128 => 1,
|
93 |
129 => 1,
|
94 |
+
132 => ( PHP_VERSION_ID >= 50300 ) ? 1 : 2, // PHPCS on PHP 5.2 does not recognize T_NOWDOC.
|
95 |
+
138 => 1,
|
96 |
+
143 => 1,
|
97 |
+
148 => 1,
|
98 |
);
|
99 |
|
100 |
case 'I18nUnitTest.1.inc':
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/PreparedSQLUnitTest.inc
CHANGED
@@ -31,3 +31,53 @@ $all_post_meta = $wpdb->get_results( $wpdb->prepare( sprintf(
|
|
31 |
|
32 |
$wpdb->query( "SELECT * FROM $wpdb->posts WHERE post_title LIKE '" . esc_sql( $foo ) . "';" ); // Ok.
|
33 |
$wpdb->query( "SELECT * FROM $wpdb->posts WHERE ID = " . absint( $foo ) . ";" ); // Ok.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
$wpdb->query( "SELECT * FROM $wpdb->posts WHERE post_title LIKE '" . esc_sql( $foo ) . "';" ); // Ok.
|
33 |
$wpdb->query( "SELECT * FROM $wpdb->posts WHERE ID = " . absint( $foo ) . ";" ); // Ok.
|
34 |
+
|
35 |
+
// Test multi-line strings.
|
36 |
+
$all_post_meta = $wpdb->get_results( $wpdb->prepare( sprintf(
|
37 |
+
'SELECT `post_id`, `meta_value`
|
38 |
+
FROM `%s`
|
39 |
+
WHERE `meta_key` = "sort_order"
|
40 |
+
AND `post_id` IN (%s)',
|
41 |
+
$wpdb->postmeta,
|
42 |
+
implode( ',', array_fill( 0, count( $post_ids ), '%d' ) )
|
43 |
+
), $post_ids ) ); // Ok.
|
44 |
+
|
45 |
+
$wpdb->query( "
|
46 |
+
SELECT *
|
47 |
+
FROM $wpdb->posts
|
48 |
+
WHERE post_title LIKE '" . esc_sql( $foo ) . "';"
|
49 |
+
); // Ok.
|
50 |
+
|
51 |
+
$wpdb->query( $wpdb->prepare( "
|
52 |
+
SELECT *
|
53 |
+
FROM $wpdb->posts
|
54 |
+
WHERE post_title = 'The \\$_GET[foo]// var is evil again.'
|
55 |
+
AND ID = %s",
|
56 |
+
array( 123 )
|
57 |
+
) ); // Bad.
|
58 |
+
|
59 |
+
|
60 |
+
// Test heredoc & nowdoc for query.
|
61 |
+
$wpdb->query( <<<EOT
|
62 |
+
SELECT *
|
63 |
+
FROM {$wpdb->posts}
|
64 |
+
WHERE ID = {$foo};
|
65 |
+
EOT
|
66 |
+
); // Bad.
|
67 |
+
|
68 |
+
$wpdb->query( <<<"HD"
|
69 |
+
SELECT *
|
70 |
+
FROM {$wpdb->posts}
|
71 |
+
WHERE post_title LIKE '{$var}';
|
72 |
+
HD
|
73 |
+
); // Bad.
|
74 |
+
|
75 |
+
$all_post_meta = $wpdb->get_results( $wpdb->prepare( sprintf( <<<'ND'
|
76 |
+
SELECT `post_id`, `meta_value`
|
77 |
+
FROM `%s`
|
78 |
+
WHERE `meta_key` = "sort_order"
|
79 |
+
AND `post_id` IN (%s)
|
80 |
+
ND
|
81 |
+
, $wpdb->postmeta,
|
82 |
+
implode( ',', array_fill( 0, count( $post_ids ), '%d' ) )
|
83 |
+
), $post_ids ) ); // OK.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WP/PreparedSQLUnitTest.php
CHANGED
@@ -23,7 +23,7 @@ class WordPress_Tests_WP_PreparedSQLUnitTest extends AbstractSniffUnitTest {
|
|
23 |
* @return array <int line number> => <int number of errors>
|
24 |
*/
|
25 |
public function getErrorList() {
|
26 |
-
|
27 |
3 => 1,
|
28 |
4 => 1,
|
29 |
5 => 1,
|
@@ -34,7 +34,27 @@ class WordPress_Tests_WP_PreparedSQLUnitTest extends AbstractSniffUnitTest {
|
|
34 |
18 => 1,
|
35 |
20 => 1,
|
36 |
21 => 1,
|
|
|
|
|
|
|
37 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
/**
|
23 |
* @return array <int line number> => <int number of errors>
|
24 |
*/
|
25 |
public function getErrorList() {
|
26 |
+
$errors = array(
|
27 |
3 => 1,
|
28 |
4 => 1,
|
29 |
5 => 1,
|
34 |
18 => 1,
|
35 |
20 => 1,
|
36 |
21 => 1,
|
37 |
+
54 => 1,
|
38 |
+
64 => 1,
|
39 |
+
71 => 1,
|
40 |
);
|
41 |
+
|
42 |
+
// Deal with PHP 5.2 not recognizing quoted heredoc openers, nor nowdoc syntax.
|
43 |
+
// These are all false positives!
|
44 |
+
if ( PHP_VERSION_ID < 50300 ) {
|
45 |
+
$errors[68] = 2;
|
46 |
+
$errors[69] = 2;
|
47 |
+
$errors[70] = 2;
|
48 |
+
$errors[71] = 4;
|
49 |
+
$errors[75] = 2;
|
50 |
+
$errors[76] = 7;
|
51 |
+
$errors[77] = 4;
|
52 |
+
$errors[78] = 5;
|
53 |
+
$errors[79] = 7;
|
54 |
+
$errors[80] = 1;
|
55 |
+
}
|
56 |
+
|
57 |
+
return $errors;
|
58 |
}
|
59 |
|
60 |
/**
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php
CHANGED
@@ -22,13 +22,13 @@ class WordPress_Tests_WhiteSpace_CastStructureSpacingUnitTest extends AbstractSn
|
|
22 |
*/
|
23 |
public function getErrorList() {
|
24 |
return array(
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
);
|
33 |
|
34 |
}
|
22 |
*/
|
23 |
public function getErrorList() {
|
24 |
return array(
|
25 |
+
3 => 2,
|
26 |
+
6 => 2,
|
27 |
+
9 => 2,
|
28 |
+
12 => 2,
|
29 |
+
15 => 2,
|
30 |
+
18 => 2,
|
31 |
+
21 => 2,
|
32 |
);
|
33 |
|
34 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc
CHANGED
@@ -211,3 +211,60 @@ if (
|
|
211 |
) { // Ok.
|
212 |
echo 'bye';
|
213 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
) { // Ok.
|
212 |
echo 'bye';
|
213 |
}
|
214 |
+
|
215 |
+
// Bug #976 - the case of the disappearing comment.
|
216 |
+
if ( isset( $submenu_file ) ) {
|
217 |
+
if ( $submenu_file == $sub_item[2] ) {
|
218 |
+
$class[] = 'current';
|
219 |
+
}
|
220 |
+
// If plugin_page is set the parent must either match the current page or not physically exist.
|
221 |
+
// This allows plugin pages with the same hook to exist under different parents.
|
222 |
+
} else {
|
223 |
+
$class[] = 'current';
|
224 |
+
}
|
225 |
+
|
226 |
+
// Test finding & fixing blank line after control structure.
|
227 |
+
if ( $one ) {
|
228 |
+
}
|
229 |
+
elseif ( $two ) {
|
230 |
+
}
|
231 |
+
// else if something
|
232 |
+
else if ( $three ) {
|
233 |
+
} // else do something
|
234 |
+
else {
|
235 |
+
}
|
236 |
+
|
237 |
+
do {
|
238 |
+
}
|
239 |
+
// Comment
|
240 |
+
while ( $a === $b );
|
241 |
+
|
242 |
+
if ( $foo ) {
|
243 |
+
try {
|
244 |
+
// Something
|
245 |
+
} catch ( Exception $e ) {
|
246 |
+
// Something
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
if ( $foo ) {
|
253 |
+
try {
|
254 |
+
// Something
|
255 |
+
} catch ( Exception $e ) {
|
256 |
+
// Something
|
257 |
+
}//end try/catch <- Bad: "blank line after".
|
258 |
+
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
if ( $foo ) {
|
263 |
+
try { // Bad.
|
264 |
+
// Something
|
265 |
+
} catch ( Exception $e ) {
|
266 |
+
// Something
|
267 |
+
} // End try/catch <- Bad: "blank line after".
|
268 |
+
|
269 |
+
|
270 |
+
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc.fixed
CHANGED
@@ -206,3 +206,54 @@ if (
|
|
206 |
) { // Ok.
|
207 |
echo 'bye';
|
208 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
) { // Ok.
|
207 |
echo 'bye';
|
208 |
}
|
209 |
+
|
210 |
+
// Bug #976 - the case of the disappearing comment.
|
211 |
+
if ( isset( $submenu_file ) ) {
|
212 |
+
if ( $submenu_file == $sub_item[2] ) {
|
213 |
+
$class[] = 'current';
|
214 |
+
}
|
215 |
+
// If plugin_page is set the parent must either match the current page or not physically exist.
|
216 |
+
// This allows plugin pages with the same hook to exist under different parents.
|
217 |
+
} else {
|
218 |
+
$class[] = 'current';
|
219 |
+
}
|
220 |
+
|
221 |
+
// Test finding & fixing blank line after control structure.
|
222 |
+
if ( $one ) {
|
223 |
+
}
|
224 |
+
elseif ( $two ) {
|
225 |
+
}
|
226 |
+
// else if something
|
227 |
+
else if ( $three ) {
|
228 |
+
} // else do something
|
229 |
+
else {
|
230 |
+
}
|
231 |
+
|
232 |
+
do {
|
233 |
+
}
|
234 |
+
// Comment
|
235 |
+
while ( $a === $b );
|
236 |
+
|
237 |
+
if ( $foo ) {
|
238 |
+
try {
|
239 |
+
// Something
|
240 |
+
} catch ( Exception $e ) {
|
241 |
+
// Something
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( $foo ) {
|
246 |
+
try {
|
247 |
+
// Something
|
248 |
+
} catch ( Exception $e ) {
|
249 |
+
// Something
|
250 |
+
}//end try/catch <- Bad: "blank line after".
|
251 |
+
}
|
252 |
+
|
253 |
+
if ( $foo ) {
|
254 |
+
try { // Bad.
|
255 |
+
// Something
|
256 |
+
} catch ( Exception $e ) {
|
257 |
+
// Something
|
258 |
+
} // End try/catch <- Bad: "blank line after".
|
259 |
+
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php
CHANGED
@@ -67,6 +67,9 @@ class WordPress_Tests_WhiteSpace_ControlStructureSpacingUnitTest extends Abstrac
|
|
67 |
192 => 1,
|
68 |
196 => 2,
|
69 |
200 => 2,
|
|
|
|
|
|
|
70 |
);
|
71 |
|
72 |
/*
|
67 |
192 => 1,
|
68 |
196 => 2,
|
69 |
200 => 2,
|
70 |
+
247 => 1,
|
71 |
+
257 => 1,
|
72 |
+
267 => 1,
|
73 |
);
|
74 |
|
75 |
/*
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.inc
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @param int $var Description.
|
5 |
+
* @param string $string Another description.
|
6 |
+
*/
|
7 |
+
|
8 |
+
$expected = ( $column - 1 );
|
9 |
+
$found = ( $this->tokens[ $closer ]['column'] - 1 );
|
10 |
+
$error = 'Array closer not aligned correctly; expected %s space(s) but found %s';
|
11 |
+
$data = array(
|
12 |
+
$expected_value => 'data',
|
13 |
+
$found => 'more_data',
|
14 |
+
);
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param int $var Description - Bad: alignment using tabs.
|
18 |
+
* @param string $string Another description.
|
19 |
+
*/
|
20 |
+
|
21 |
+
$expected = ( $column - 1 );
|
22 |
+
$found = ( $this->tokens[ $closer ]['column'] - 1 ); // Bad.
|
23 |
+
$error = 'Array closer not aligned correctly; expected %s space(s) but found %s'; // Bad.
|
24 |
+
$data = array( // Bad.
|
25 |
+
$expected_value => 'data',
|
26 |
+
$found => 'more_data', // Bad.
|
27 |
+
);
|
28 |
+
|
29 |
+
/*
|
30 |
+
* Test that the tab replacements do not negatively influence the existing mid-line alignments.
|
31 |
+
*/
|
32 |
+
$a = true;
|
33 |
+
$aa = true;
|
34 |
+
$aaa = true;
|
35 |
+
$aaaa = true;
|
36 |
+
$aaaaa = true;
|
37 |
+
$aaaaaa = true;
|
38 |
+
$aaaaaaa = true;
|
39 |
+
$aaaaaaaa = true;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.inc.fixed
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @param int $var Description.
|
5 |
+
* @param string $string Another description.
|
6 |
+
*/
|
7 |
+
|
8 |
+
$expected = ( $column - 1 );
|
9 |
+
$found = ( $this->tokens[ $closer ]['column'] - 1 );
|
10 |
+
$error = 'Array closer not aligned correctly; expected %s space(s) but found %s';
|
11 |
+
$data = array(
|
12 |
+
$expected_value => 'data',
|
13 |
+
$found => 'more_data',
|
14 |
+
);
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param int $var Description - Bad: alignment using tabs.
|
18 |
+
* @param string $string Another description.
|
19 |
+
*/
|
20 |
+
|
21 |
+
$expected = ( $column - 1 );
|
22 |
+
$found = ( $this->tokens[ $closer ]['column'] - 1 ); // Bad.
|
23 |
+
$error = 'Array closer not aligned correctly; expected %s space(s) but found %s'; // Bad.
|
24 |
+
$data = array( // Bad.
|
25 |
+
$expected_value => 'data',
|
26 |
+
$found => 'more_data', // Bad.
|
27 |
+
);
|
28 |
+
|
29 |
+
/*
|
30 |
+
* Test that the tab replacements do not negatively influence the existing mid-line alignments.
|
31 |
+
*/
|
32 |
+
$a = true;
|
33 |
+
$aa = true;
|
34 |
+
$aaa = true;
|
35 |
+
$aaaa = true;
|
36 |
+
$aaaaa = true;
|
37 |
+
$aaaaaa = true;
|
38 |
+
$aaaaaaa = true;
|
39 |
+
$aaaaaaaa = true;
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Unit test class for WordPress Coding Standard.
|
4 |
+
*
|
5 |
+
* @package WPCS\WordPressCodingStandards
|
6 |
+
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
7 |
+
* @license https://opensource.org/licenses/MIT MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Unit test class for the DisallowInlineTabs sniff.
|
12 |
+
*
|
13 |
+
* @package WPCS\WordPressCodingStandards
|
14 |
+
* @since 0.12.0
|
15 |
+
*/
|
16 |
+
class WordPress_Tests_WhiteSpace_DisallowInlineTabsUnitTest extends AbstractSniffUnitTest {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get a list of CLI values to set before the file is tested.
|
20 |
+
*
|
21 |
+
* @param string $testFile The name of the file being tested.
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function getCliValues( $testFile ) {
|
26 |
+
return array( '--tab-width=4' );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns the lines where errors should occur.
|
31 |
+
*
|
32 |
+
* @return array <int line number> => <int number of errors>
|
33 |
+
*/
|
34 |
+
public function getErrorList() {
|
35 |
+
return array(
|
36 |
+
17 => 1,
|
37 |
+
22 => 1,
|
38 |
+
23 => 1,
|
39 |
+
24 => 1,
|
40 |
+
26 => 1,
|
41 |
+
32 => 1,
|
42 |
+
33 => 1,
|
43 |
+
34 => 1,
|
44 |
+
35 => 1,
|
45 |
+
36 => 1,
|
46 |
+
37 => 1,
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Returns the lines where warnings should occur.
|
52 |
+
*
|
53 |
+
* @return array <int line number> => <int number of warnings>
|
54 |
+
*/
|
55 |
+
public function getWarningList() {
|
56 |
+
return array();
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
} // End class.
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc
CHANGED
@@ -1,55 +1,66 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
// Bad, no operator spacing.
|
5 |
-
for ( $i=0; $i<sizeof( $posts ); $i++ ) {
|
6 |
-
// ...
|
7 |
-
}
|
8 |
-
|
9 |
-
// Good.
|
10 |
-
for ( $i = 0; $i < sizeof( $posts ); $i++ ) {
|
11 |
-
// ...
|
12 |
-
}
|
13 |
-
// Good.
|
14 |
-
if ( ! $var ) {
|
15 |
-
// ...
|
16 |
-
}
|
17 |
-
// Bad.
|
18 |
-
if ( !$var ) {
|
19 |
-
// ...
|
20 |
-
}
|
21 |
-
|
22 |
-
while ( have_posts() ) {
|
23 |
-
$ok = (
|
24 |
-
! is_author()
|
25 |
-
||
|
26 |
-
is_front_page()
|
27 |
-
);
|
28 |
-
}
|
29 |
-
|
30 |
-
// All OK.
|
31 |
if ( 'bb' !== 'bb' ) {
|
32 |
if (
|
33 |
-
empty($_GET['refid']) &&
|
34 |
-
empty($_GET['nolinks']) &&
|
35 |
-
! is_page_template('page_strategy-center.php') &&
|
36 |
-
! is_page_template('page_confirmation.php') &&
|
37 |
-
! is_page_template('page_debartolo.php') &&
|
38 |
-
! is_singular('offer')
|
39 |
) {
|
40 |
hello();
|
41 |
}
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
44 |
// Bad.
|
45 |
-
|
46 |
// ...
|
47 |
}
|
|
|
48 |
// Bad.
|
49 |
-
if ( !
|
50 |
// ...
|
51 |
}
|
52 |
|
53 |
-
//
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
// Boolean not operator: All OK.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
if ( 'bb' !== 'bb' ) {
|
5 |
if (
|
6 |
+
empty( $_GET['refid'] ) &&
|
7 |
+
empty( $_GET['nolinks'] ) &&
|
8 |
+
! is_page_template( 'page_strategy-center.php' ) &&
|
9 |
+
! is_page_template( 'page_confirmation.php' ) &&
|
10 |
+
! is_page_template( 'page_debartolo.php' ) &&
|
11 |
+
! is_singular( 'offer' )
|
12 |
) {
|
13 |
hello();
|
14 |
}
|
15 |
}
|
16 |
|
17 |
+
// Good.
|
18 |
+
if ( ! $var ) {
|
19 |
+
// ...
|
20 |
+
}
|
21 |
+
|
22 |
// Bad.
|
23 |
+
if (!$var ) {
|
24 |
// ...
|
25 |
}
|
26 |
+
|
27 |
// Bad.
|
28 |
+
if ( ! $var ) {
|
29 |
// ...
|
30 |
}
|
31 |
|
32 |
+
// Logical operators: Ok.
|
33 |
+
if ( $a === $b && $b === $c ) {}
|
34 |
+
if ( $a === $b || $b === $c ) {}
|
35 |
+
if ( $a === $b and $b === $c ) {}
|
36 |
+
if ( $a === $b or $b === $c ) {}
|
37 |
+
if ( $a === $b xor $b === $c ) {}
|
38 |
+
|
39 |
+
// Logical operators: Too little space.
|
40 |
+
if ( $a === $b&&$b === $c ) {}
|
41 |
+
if ( $a === $b||$b === $c ) {}
|
42 |
+
if ( $a === {$b}and$b === $c ) {}
|
43 |
+
if ( $a === {$b}or$b === $c ) {}
|
44 |
+
if ( $a === {$b}xor$b === $c ) {}
|
45 |
+
|
46 |
+
// Logical operators: Too much space.
|
47 |
+
if ( $a === $b && $b === $c ) {}
|
48 |
+
if ( $a === $b || $b === $c ) {}
|
49 |
+
if ( $a === $b and $b === $c ) {}
|
50 |
+
if ( $a === $b or $b === $c ) {}
|
51 |
+
if ( $a === $b xor $b === $c ) {}
|
52 |
+
|
53 |
+
// Logical operators: Multi-line, OK.
|
54 |
+
if ( $a === $b
|
55 |
+
&& $b === $c
|
56 |
+
) {}
|
57 |
+
if (
|
58 |
+
$a === $b
|
59 |
+
||
|
60 |
+
$b === $c
|
61 |
+
) {}
|
62 |
+
if ( $a === $b
|
63 |
+
and $b === $c ) {}
|
64 |
+
|
65 |
+
if ( $a === $b or
|
66 |
+
$b === $c ) {}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed
CHANGED
@@ -1,55 +1,66 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
|
9 |
-
// Good.
|
10 |
-
for ( $i = 0; $i < sizeof( $posts ); $i++ ) {
|
11 |
-
// ...
|
12 |
-
}
|
13 |
// Good.
|
14 |
if ( ! $var ) {
|
15 |
// ...
|
16 |
}
|
|
|
17 |
// Bad.
|
18 |
if ( ! $var ) {
|
19 |
// ...
|
20 |
}
|
21 |
|
22 |
-
while ( have_posts() ) {
|
23 |
-
$ok = (
|
24 |
-
! is_author()
|
25 |
-
||
|
26 |
-
is_front_page()
|
27 |
-
);
|
28 |
-
}
|
29 |
-
|
30 |
-
// All OK.
|
31 |
-
if ( 'bb' !== 'bb' ) {
|
32 |
-
if (
|
33 |
-
empty($_GET['refid']) &&
|
34 |
-
empty($_GET['nolinks']) &&
|
35 |
-
! is_page_template('page_strategy-center.php') &&
|
36 |
-
! is_page_template('page_confirmation.php') &&
|
37 |
-
! is_page_template('page_debartolo.php') &&
|
38 |
-
! is_singular('offer')
|
39 |
-
) {
|
40 |
-
hello();
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
// Bad.
|
45 |
-
for ( $i = 0; $i < sizeof( $posts ); $i++ ) {
|
46 |
-
// ...
|
47 |
-
}
|
48 |
// Bad.
|
49 |
if ( ! $var ) {
|
50 |
// ...
|
51 |
}
|
52 |
|
53 |
-
//
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
// Boolean not operator: All OK.
|
4 |
+
if ( 'bb' !== 'bb' ) {
|
5 |
+
if (
|
6 |
+
empty( $_GET['refid'] ) &&
|
7 |
+
empty( $_GET['nolinks'] ) &&
|
8 |
+
! is_page_template( 'page_strategy-center.php' ) &&
|
9 |
+
! is_page_template( 'page_confirmation.php' ) &&
|
10 |
+
! is_page_template( 'page_debartolo.php' ) &&
|
11 |
+
! is_singular( 'offer' )
|
12 |
+
) {
|
13 |
+
hello();
|
14 |
+
}
|
15 |
}
|
16 |
|
|
|
|
|
|
|
|
|
17 |
// Good.
|
18 |
if ( ! $var ) {
|
19 |
// ...
|
20 |
}
|
21 |
+
|
22 |
// Bad.
|
23 |
if ( ! $var ) {
|
24 |
// ...
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
// Bad.
|
28 |
if ( ! $var ) {
|
29 |
// ...
|
30 |
}
|
31 |
|
32 |
+
// Logical operators: Ok.
|
33 |
+
if ( $a === $b && $b === $c ) {}
|
34 |
+
if ( $a === $b || $b === $c ) {}
|
35 |
+
if ( $a === $b and $b === $c ) {}
|
36 |
+
if ( $a === $b or $b === $c ) {}
|
37 |
+
if ( $a === $b xor $b === $c ) {}
|
38 |
+
|
39 |
+
// Logical operators: Too little space.
|
40 |
+
if ( $a === $b && $b === $c ) {}
|
41 |
+
if ( $a === $b || $b === $c ) {}
|
42 |
+
if ( $a === {$b} and $b === $c ) {}
|
43 |
+
if ( $a === {$b} or $b === $c ) {}
|
44 |
+
if ( $a === {$b} xor $b === $c ) {}
|
45 |
+
|
46 |
+
// Logical operators: Too much space.
|
47 |
+
if ( $a === $b && $b === $c ) {}
|
48 |
+
if ( $a === $b || $b === $c ) {}
|
49 |
+
if ( $a === $b and $b === $c ) {}
|
50 |
+
if ( $a === $b or $b === $c ) {}
|
51 |
+
if ( $a === $b xor $b === $c ) {}
|
52 |
+
|
53 |
+
// Logical operators: Multi-line, OK.
|
54 |
+
if ( $a === $b
|
55 |
+
&& $b === $c
|
56 |
+
) {}
|
57 |
+
if (
|
58 |
+
$a === $b
|
59 |
+
||
|
60 |
+
$b === $c
|
61 |
+
) {}
|
62 |
+
if ( $a === $b
|
63 |
+
and $b === $c ) {}
|
64 |
+
|
65 |
+
if ( $a === $b or
|
66 |
+
$b === $c ) {}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php
CHANGED
@@ -12,6 +12,8 @@
|
|
12 |
*
|
13 |
* @package WPCS\WordPressCodingStandards
|
14 |
* @since 2013-06-11
|
|
|
|
|
15 |
*/
|
16 |
class WordPress_Tests_WhiteSpace_OperatorSpacingUnitTest extends AbstractSniffUnitTest {
|
17 |
|
@@ -22,10 +24,18 @@ class WordPress_Tests_WhiteSpace_OperatorSpacingUnitTest extends AbstractSniffUn
|
|
22 |
*/
|
23 |
public function getErrorList() {
|
24 |
return array(
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
);
|
30 |
|
31 |
}
|
12 |
*
|
13 |
* @package WPCS\WordPressCodingStandards
|
14 |
* @since 2013-06-11
|
15 |
+
* @since 0.12.0 Now only tests the WPCS specific addition of T_BOOLEAN_NOT.
|
16 |
+
* The rest of the sniff is unit tested upstream.
|
17 |
*/
|
18 |
class WordPress_Tests_WhiteSpace_OperatorSpacingUnitTest extends AbstractSniffUnitTest {
|
19 |
|
24 |
*/
|
25 |
public function getErrorList() {
|
26 |
return array(
|
27 |
+
23 => 2,
|
28 |
+
28 => 2,
|
29 |
+
40 => 2,
|
30 |
+
41 => 2,
|
31 |
+
42 => 2,
|
32 |
+
43 => 2,
|
33 |
+
44 => 2,
|
34 |
+
47 => 2,
|
35 |
+
48 => 2,
|
36 |
+
49 => 2,
|
37 |
+
50 => 2,
|
38 |
+
51 => 2,
|
39 |
);
|
40 |
|
41 |
}
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/XSS/EscapeOutputUnitTest.inc
CHANGED
@@ -205,3 +205,23 @@ to_screen( esc_form_field( $var1), esc_attr( $var2 ) ); // Ok.
|
|
205 |
echo esc_form_field( $var ); // Bad.
|
206 |
echo post_info( $post_id, 'field' ); // Bad.
|
207 |
echo cpt_info( $post_type, 'query' ); // Bad.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
echo esc_form_field( $var ); // Bad.
|
206 |
echo post_info( $post_id, 'field' ); // Bad.
|
207 |
echo cpt_info( $post_type, 'query' ); // Bad.
|
208 |
+
|
209 |
+
echo (unset) $var; // Ok.
|
210 |
+
|
211 |
+
// Nowdocs are OK.
|
212 |
+
echo <<<'EOD'
|
213 |
+
Some Raw String
|
214 |
+
EOD;
|
215 |
+
|
216 |
+
echo 1.234; // Ok.
|
217 |
+
|
218 |
+
echo ( 1.234 + 10 + 2.5 ); // Ok.
|
219 |
+
echo 10 % 2; // Ok.
|
220 |
+
echo 8 * 1.2; // Ok.
|
221 |
+
|
222 |
+
?>
|
223 |
+
<?= $var ?><!-- Bad. -->
|
224 |
+
<?= esc_html( $var ); ?><!-- Ok. -->
|
225 |
+
<?= $var['foo']; ?><!-- Bad. -->
|
226 |
+
<?= $var->foo ?><!-- Bad. -->
|
227 |
+
<?php
|
vendor/wp-coding-standards/wpcs/WordPress/Tests/XSS/EscapeOutputUnitTest.php
CHANGED
@@ -63,6 +63,10 @@ class WordPress_Tests_XSS_EscapeOutputUnitTest extends AbstractSniffUnitTest {
|
|
63 |
205 => 1,
|
64 |
206 => 1,
|
65 |
207 => 1,
|
|
|
|
|
|
|
|
|
66 |
);
|
67 |
|
68 |
} // end getErrorList()
|
63 |
205 => 1,
|
64 |
206 => 1,
|
65 |
207 => 1,
|
66 |
+
212 => ( PHP_VERSION_ID < 50300 ) ? 1 : 0, // PHPCS on PHP 5.2 does not recognize T_NOWDOC.
|
67 |
+
223 => 1,
|
68 |
+
225 => 1,
|
69 |
+
226 => 1,
|
70 |
);
|
71 |
|
72 |
} // end getErrorList()
|
vendor/wp-coding-standards/wpcs/WordPress/ruleset.xml
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
<!-- From "Extra": The create_function group is excluded as WP core still supports PHP 5.2 and 5.2 does not support anonymous functions. -->
|
12 |
<!-- From "VIP": The obfuscation group is excluded as there are plenty of legitimate uses for the base64 functions. -->
|
13 |
<properties>
|
14 |
-
<property name="exclude" value="create_function,obfuscation"
|
15 |
</properties>
|
16 |
</rule>
|
17 |
</ruleset>
|
11 |
<!-- From "Extra": The create_function group is excluded as WP core still supports PHP 5.2 and 5.2 does not support anonymous functions. -->
|
12 |
<!-- From "VIP": The obfuscation group is excluded as there are plenty of legitimate uses for the base64 functions. -->
|
13 |
<properties>
|
14 |
+
<property name="exclude" value="create_function,obfuscation"/>
|
15 |
</properties>
|
16 |
</rule>
|
17 |
</ruleset>
|
vendor/wp-coding-standards/wpcs/composer.json
CHANGED
@@ -11,12 +11,18 @@
|
|
11 |
}
|
12 |
],
|
13 |
"require" : {
|
14 |
-
"squizlabs/php_codesniffer": "^2.
|
|
|
|
|
|
|
15 |
},
|
16 |
"minimum-stability" : "RC",
|
17 |
"support" : {
|
18 |
-
"issues": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues"
|
|
|
|
|
19 |
},
|
|
|
20 |
"scripts" : {
|
21 |
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths ../../..",
|
22 |
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths ../../.."
|
11 |
}
|
12 |
],
|
13 |
"require" : {
|
14 |
+
"squizlabs/php_codesniffer": "^2.9.0"
|
15 |
+
},
|
16 |
+
"suggest" : {
|
17 |
+
"dealerdirect/phpcodesniffer-composer-installer": "*"
|
18 |
},
|
19 |
"minimum-stability" : "RC",
|
20 |
"support" : {
|
21 |
+
"issues": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues",
|
22 |
+
"wiki" : "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki",
|
23 |
+
"source": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards"
|
24 |
},
|
25 |
+
"type" : "phpcodesniffer-standard",
|
26 |
"scripts" : {
|
27 |
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths ../../..",
|
28 |
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths ../../.."
|
vendor/wp-coding-standards/wpcs/phpcs.xml.dist.sample
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Example Project">
|
3 |
+
<description>A custom set of rules to check for a WPized WordPress project</description>
|
4 |
+
|
5 |
+
<!-- Exclude WP Core folders and files from being checked. -->
|
6 |
+
<exclude-pattern>/docroot/wp-admin/*</exclude-pattern>
|
7 |
+
<exclude-pattern>/docroot/wp-includes/*</exclude-pattern>
|
8 |
+
<exclude-pattern>/docroot/wp-*.php</exclude-pattern>
|
9 |
+
<exclude-pattern>/docroot/index.php</exclude-pattern>
|
10 |
+
<exclude-pattern>/docroot/xmlrpc.php</exclude-pattern>
|
11 |
+
<exclude-pattern>/docroot/wp-content/plugins/*</exclude-pattern>
|
12 |
+
|
13 |
+
<!-- Exclude the Composer Vendor directory. -->
|
14 |
+
<exclude-pattern>/vendor/*</exclude-pattern>
|
15 |
+
|
16 |
+
<!-- Exclude the Node Modules directory. -->
|
17 |
+
<exclude-pattern>/node_modules/*</exclude-pattern>
|
18 |
+
|
19 |
+
<!-- Exclude minified Javascript files. -->
|
20 |
+
<exclude-pattern>*.min.js</exclude-pattern>
|
21 |
+
|
22 |
+
<!-- Include the WordPress-Extra standard. -->
|
23 |
+
<rule ref="WordPress-Extra">
|
24 |
+
<!--
|
25 |
+
We may want a middle ground though. The best way to do this is add the
|
26 |
+
entire ruleset, then rule by rule, remove ones that don't suit a project.
|
27 |
+
We can do this by running `phpcs` with the '-s' flag, which allows us to
|
28 |
+
see the names of the sniffs reporting errors.
|
29 |
+
Once we know the sniff names, we can opt to exclude sniffs which don't
|
30 |
+
suit our project like so.
|
31 |
+
-->
|
32 |
+
|
33 |
+
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing"/>
|
34 |
+
<exclude name="WordPress.XSS.EscapeOutput"/>
|
35 |
+
</rule>
|
36 |
+
|
37 |
+
<!-- Let's also check that everything is properly documented. -->
|
38 |
+
<rule ref="WordPress-Docs"/>
|
39 |
+
|
40 |
+
<!-- Add in some extra rules from other standards. -->
|
41 |
+
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
42 |
+
<rule ref="Generic.Commenting.Todo"/>
|
43 |
+
|
44 |
+
<!-- Check for PHP cross-version compatibility. -->
|
45 |
+
<!--
|
46 |
+
To enable this, the PHPCompatibility standard needs
|
47 |
+
to be installed.
|
48 |
+
See the readme for installation instructions:
|
49 |
+
https://github.com/wimg/PHPCompatibility
|
50 |
+
-->
|
51 |
+
<!--
|
52 |
+
<config name="testVersion" value="5.2-99.0"/>
|
53 |
+
<rule ref="PHPCompatibility"/>
|
54 |
+
-->
|
55 |
+
|
56 |
+
<!--
|
57 |
+
To get the optimal benefits of using WPCS, we should add a couple of
|
58 |
+
custom properties.
|
59 |
+
Adjust the values of these properties to fit our needs.
|
60 |
+
|
61 |
+
For information on additional custom properties available, check out
|
62 |
+
the wiki:
|
63 |
+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
|
64 |
+
-->
|
65 |
+
<rule ref="WordPress.WP.I18n">
|
66 |
+
<properties>
|
67 |
+
<property name="text_domain" type="array" value="my-textdomain,library-textdomain"/>
|
68 |
+
</properties>
|
69 |
+
</rule>
|
70 |
+
|
71 |
+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
|
72 |
+
<properties>
|
73 |
+
<property name="prefixes" type="array" value="my_prefix"/>
|
74 |
+
</properties>
|
75 |
+
</rule>
|
76 |
+
|
77 |
+
<rule ref="WordPress.WP.DeprecatedClasses">
|
78 |
+
<properties>
|
79 |
+
<property name="minimum_supported_version" value="4.5"/>
|
80 |
+
</properties>
|
81 |
+
</rule>
|
82 |
+
|
83 |
+
<rule ref="WordPress.WP.DeprecatedFunctions">
|
84 |
+
<properties>
|
85 |
+
<property name="minimum_supported_version" value="4.5"/>
|
86 |
+
</properties>
|
87 |
+
</rule>
|
88 |
+
|
89 |
+
<rule ref="WordPress.WP.DeprecatedParameters">
|
90 |
+
<properties>
|
91 |
+
<property name="minimum_supported_version" value="4.5"/>
|
92 |
+
</properties>
|
93 |
+
</rule>
|
94 |
+
|
95 |
+
</ruleset>
|