sdc-build-wp 4.1.0 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composer.json +2 -3
- package/composer.lock +3 -313
- package/index.js +38 -21
- package/lib/blocks.js +8 -6
- package/lib/style.js +17 -0
- package/package.json +1 -1
- package/vendor/composer/autoload_classmap.php +0 -37
- package/vendor/composer/autoload_psr4.php +0 -1
- package/vendor/composer/autoload_real.php +2 -0
- package/vendor/composer/autoload_static.php +0 -53
- package/vendor/composer/installed.json +1 -329
- package/vendor/composer/installed.php +3 -39
- package/vendor/composer/platform_check.php +26 -0
- package/lib/bustCache.js +0 -14
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md +0 -22
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md +0 -285
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/composer.json +0 -71
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php +0 -637
- package/vendor/phpcsstandards/phpcsextra/CHANGELOG.md +0 -590
- package/vendor/phpcsstandards/phpcsextra/LICENSE +0 -165
- package/vendor/phpcsstandards/phpcsextra/Modernize/Docs/FunctionCalls/DirnameStandard.xml +0 -40
- package/vendor/phpcsstandards/phpcsextra/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +0 -382
- package/vendor/phpcsstandards/phpcsextra/Modernize/ruleset.xml +0 -5
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Docs/Arrays/ArrayBraceSpacingStandard.xml +0 -94
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Docs/Arrays/CommaAfterLastStandard.xml +0 -43
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php +0 -305
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php +0 -226
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/ruleset.xml +0 -5
- package/vendor/phpcsstandards/phpcsextra/README.md +0 -573
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/DisallowShortArraySyntaxStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/DuplicateArrayKeyStandard.xml +0 -44
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/MixedArrayKeyTypesStandard.xml +0 -40
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/MixedKeyedUnkeyedArrayStandard.xml +0 -31
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/DisallowAnonClassParenthesesStandard.xml +0 -24
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/DisallowFinalClassStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/ModifierKeywordOrderStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/RequireAnonClassParenthesesStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/RequireFinalClassStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/ConstructorDestructorReturnStandard.xml +0 -64
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/ForeachUniqueAssignmentStandard.xml +0 -26
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoDoubleNegativeStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoEchoSprintfStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml +0 -43
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/LowercaseClassResolutionKeywordStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/ModifierKeywordOrderStandard.xml +0 -30
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/UppercaseMagicConstantsStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/DisallowAlternativeSyntaxStandard.xml +0 -35
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/DisallowLonelyIfStandard.xml +0 -49
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/IfElseDeclarationStandard.xml +0 -37
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Files/SeparateFunctionsFromOOStandard.xml +0 -45
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml +0 -42
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml +0 -33
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Lists/DisallowLongListSyntaxStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Lists/DisallowShortListSyntaxStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/DisallowCurlyBraceSyntaxStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/DisallowDeclarationWithoutNameStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/EnforceCurlyBraceSyntaxStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/OneDeclarationPerFileStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/NamingConventions/NoReservedKeywordParameterNamesStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/OOStructures/AlphabeticExtendsImplementsStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/ConcatPositionStandard.xml +0 -31
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowLogicalAndOrStandard.xml +0 -30
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowShortTernaryStandard.xml +0 -26
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowStandalonePostIncrementDecrementStandard.xml +0 -44
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/StrictComparisonsStandard.xml +0 -29
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/TypeSeparatorSpacingStandard.xml +0 -33
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/PHP/LowercasePHPTagStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/PHP/OneStatementInShortEchoTagStandard.xml +0 -41
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml +0 -39
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseClassStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseConstStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseFunctionStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml +0 -29
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/LowercaseFunctionConstStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoLeadingBackslashStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml +0 -30
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/AnonClassKeywordSpacingStandard.xml +0 -31
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml +0 -94
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/DisallowInlineTabsStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/PrecisionAlignmentStandard.xml +0 -29
- package/vendor/phpcsstandards/phpcsextra/Universal/Helpers/DummyTokenizer.php +0 -60
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +0 -89
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php +0 -297
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php +0 -174
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php +0 -134
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php +0 -112
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/DisallowFinalClassSniff.php +0 -116
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php +0 -188
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php +0 -81
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/RequireFinalClassSniff.php +0 -102
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php +0 -153
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoDoubleNegativeSniff.php +0 -269
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php +0 -131
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php +0 -216
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php +0 -106
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php +0 -199
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php +0 -89
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php +0 -216
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php +0 -348
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php +0 -164
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php +0 -190
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php +0 -233
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php +0 -120
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php +0 -71
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php +0 -86
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php +0 -81
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php +0 -80
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php +0 -81
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php +0 -96
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php +0 -190
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php +0 -275
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/ConcatPositionSniff.php +0 -204
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php +0 -112
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowShortTernarySniff.php +0 -76
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php +0 -197
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/StrictComparisonsSniff.php +0 -116
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php +0 -85
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/PHP/LowercasePHPTagSniff.php +0 -87
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php +0 -101
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php +0 -248
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php +0 -207
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php +0 -156
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php +0 -170
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php +0 -155
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php +0 -79
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php +0 -408
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +0 -173
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +0 -445
- package/vendor/phpcsstandards/phpcsextra/Universal/ruleset.xml +0 -5
- package/vendor/phpcsstandards/phpcsextra/composer.json +0 -69
- package/vendor/phpcsstandards/phpcsutils/.phpdoc.xml.dist +0 -36
- package/vendor/phpcsstandards/phpcsutils/CHANGELOG.md +0 -1106
- package/vendor/phpcsstandards/phpcsutils/LICENSE +0 -165
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php +0 -551
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php +0 -781
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php +0 -123
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php +0 -202
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/InvalidTokenArray.php +0 -44
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestFileNotFound.php +0 -47
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestMarkerNotFound.php +0 -43
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestTargetNotFound.php +0 -50
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Fixers/SpacesFixer.php +0 -246
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/Cache.php +0 -218
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php +0 -687
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php +0 -269
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/NoFileCache.php +0 -164
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/StableCollections.php +0 -75
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php +0 -459
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php +0 -837
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/TokenHelper.php +0 -55
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Arrays.php +0 -227
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Conditions.php +0 -156
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php +0 -232
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php +0 -276
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php +0 -828
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/GetTokensAsString.php +0 -262
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Lists.php +0 -359
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/MessageHelper.php +0 -145
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Namespaces.php +0 -389
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php +0 -116
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Numbers.php +0 -322
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php +0 -359
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Operators.php +0 -252
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Orthography.php +0 -120
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Parentheses.php +0 -419
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php +0 -510
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Scopes.php +0 -143
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/TextStrings.php +0 -331
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php +0 -432
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Variables.php +0 -333
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/ruleset.xml +0 -4
- package/vendor/phpcsstandards/phpcsutils/README.md +0 -297
- package/vendor/phpcsstandards/phpcsutils/composer.json +0 -92
- package/vendor/phpcsstandards/phpcsutils/phpcsutils-autoload.php +0 -68
- package/vendor/wp-coding-standards/wpcs/CHANGELOG.md +0 -1654
- package/vendor/wp-coding-standards/wpcs/LICENSE +0 -21
- package/vendor/wp-coding-standards/wpcs/README.md +0 -261
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +0 -261
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php +0 -257
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionParameterSniff.php +0 -111
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php +0 -358
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/ArrayIndentationStandard.xml +0 -116
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml +0 -31
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml +0 -50
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/CodeAnalysis/EscapedNotTranslatedStandard.xml +0 -24
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml +0 -35
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/DateTime/RestrictedFunctionsStandard.xml +0 -54
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/PrefixAllGlobalsStandard.xml +0 -119
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/ValidHookNameStandard.xml +0 -35
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/ValidPostTypeSlugStandard.xml +0 -121
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/IniSetStandard.xml +0 -40
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/StrictInArrayStandard.xml +0 -53
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/YodaConditionsStandard.xml +0 -27
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Security/SafeRedirectStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CapabilitiesStandard.xml +0 -69
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CapitalPDangitStandard.xml +0 -43
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/ClassNameCaseStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CronIntervalStandard.xml +0 -45
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedClassesStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedParametersStandard.xml +0 -40
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/EnqueuedResourceParametersStandard.xml +0 -92
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/EnqueuedResourcesStandard.xml +0 -57
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/PostsPerPageStandard.xml +0 -73
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml +0 -27
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/ControlStructureSpacingStandard.xml +0 -150
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/ObjectOperatorSpacingStandard.xml +0 -19
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/OperatorSpacingStandard.xml +0 -61
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ArrayWalkingFunctionsHelper.php +0 -108
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ConstantsHelper.php +0 -135
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ContextHelper.php +0 -394
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/DeprecationHelper.php +0 -84
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/EscapingFunctionsTrait.php +0 -256
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/FormattingFunctionsHelper.php +0 -60
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/IsUnitTestTrait.php +0 -238
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ListHelper.php +0 -101
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/MinimumWPVersionTrait.php +0 -159
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/PrintingFunctionsTrait.php +0 -122
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/RulesetPropertyHelper.php +0 -73
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/SanitizationHelperTrait.php +0 -418
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/SnakeCaseHelper.php +0 -60
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/UnslashingFunctionsHelper.php +0 -59
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ValidationHelper.php +0 -349
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/VariableHelper.php +0 -262
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPDBTrait.php +0 -115
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPGlobalVariablesHelper.php +0 -312
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPHookHelper.php +0 -113
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniff.php +0 -72
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +0 -252
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +0 -550
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +0 -174
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +0 -583
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInTernaryConditionSniff.php +0 -173
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EscapedNotTranslatedSniff.php +0 -89
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php +0 -301
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +0 -761
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php +0 -242
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php +0 -57
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php +0 -63
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/SlowDBQuerySniff.php +0 -58
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php +0 -168
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php +0 -59
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php +0 -313
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +0 -1297
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +0 -188
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +0 -277
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php +0 -230
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +0 -289
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php +0 -63
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php +0 -100
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DontExtractSniff.php +0 -52
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/IniSetSniff.php +0 -193
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php +0 -245
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php +0 -73
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php +0 -70
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php +0 -45
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/StrictInArraySniff.php +0 -122
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/TypeCastsSniff.php +0 -90
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/YodaConditionsSniff.php +0 -124
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/EscapeOutputSniff.php +0 -903
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/NonceVerificationSniff.php +0 -422
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/PluginMenuSlugSniff.php +0 -126
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/SafeRedirectSniff.php +0 -45
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php +0 -244
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php +0 -862
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php +0 -371
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapabilitiesSniff.php +0 -478
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php +0 -315
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/ClassNameCaseSniff.php +0 -897
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CronIntervalSniff.php +0 -321
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +0 -152
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +0 -1708
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php +0 -291
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +0 -509
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +0 -160
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php +0 -54
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php +0 -241
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +0 -108
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php +0 -436
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php +0 -977
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/PostsPerPageSniff.php +0 -102
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +0 -59
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +0 -486
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +0 -63
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php +0 -60
- package/vendor/wp-coding-standards/wpcs/WordPress/ruleset.xml +0 -13
- package/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml +0 -948
- package/vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml +0 -109
- package/vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml +0 -199
- package/vendor/wp-coding-standards/wpcs/composer.json +0 -88
- package/vendor/wp-coding-standards/wpcs/phpcs.xml.dist.sample +0 -153
|
@@ -1,977 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* WordPress Coding Standard.
|
|
4
|
-
*
|
|
5
|
-
* @package WPCS\WordPressCodingStandards
|
|
6
|
-
* @link https://github.com/WordPress/WordPress-Coding-Standards
|
|
7
|
-
* @license https://opensource.org/licenses/MIT MIT
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
namespace WordPressCS\WordPress\Sniffs\WP;
|
|
11
|
-
|
|
12
|
-
use PHP_CodeSniffer\Util\Tokens;
|
|
13
|
-
use PHPCSUtils\BackCompat\Helper;
|
|
14
|
-
use PHPCSUtils\Utils\MessageHelper;
|
|
15
|
-
use PHPCSUtils\Utils\PassedParameters;
|
|
16
|
-
use PHPCSUtils\Utils\TextStrings;
|
|
17
|
-
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
|
|
18
|
-
use WordPressCS\WordPress\Helpers\RulesetPropertyHelper;
|
|
19
|
-
use XMLReader;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Makes sure WP internationalization functions are used properly.
|
|
23
|
-
*
|
|
24
|
-
* @link https://make.wordpress.org/core/handbook/best-practices/internationalization/
|
|
25
|
-
* @link https://developer.wordpress.org/plugins/internationalization/
|
|
26
|
-
*
|
|
27
|
-
* @since 0.10.0
|
|
28
|
-
* @since 0.11.0 - Now also checks for translators comments.
|
|
29
|
-
* - Now has the ability to handle text domain set via the command-line
|
|
30
|
-
* as a comma-delimited list.
|
|
31
|
-
* `phpcs --runtime-set text_domain my-slug,default`
|
|
32
|
-
* @since 0.13.0 Class name changed: this class is now namespaced.
|
|
33
|
-
* @since 1.0.0 This class now extends the WordPressCS native
|
|
34
|
-
* `AbstractFunctionRestrictionSniff` class.
|
|
35
|
-
* The parent `exclude` property is, however, disabled as it
|
|
36
|
-
* would disable the whole sniff.
|
|
37
|
-
* @since 3.0.0 This class now extends the WordPressCS native
|
|
38
|
-
* `AbstractFunctionParameterSniff` class.
|
|
39
|
-
* The parent `exclude` property is still disabled.
|
|
40
|
-
*/
|
|
41
|
-
final class I18nSniff extends AbstractFunctionParameterSniff {
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* These Regexes were originally copied from https://www.php.net/function.sprintf#93552
|
|
45
|
-
* and adjusted for better precision and updated specs.
|
|
46
|
-
*/
|
|
47
|
-
const SPRINTF_PLACEHOLDER_REGEX = '/(?:
|
|
48
|
-
(?<!%) # Don\'t match a literal % (%%).
|
|
49
|
-
(
|
|
50
|
-
% # Start of placeholder.
|
|
51
|
-
(?:[0-9]+\$)? # Optional ordering of the placeholders.
|
|
52
|
-
[+-]? # Optional sign specifier.
|
|
53
|
-
(?:
|
|
54
|
-
(?:0|\'.)? # Optional padding specifier - excluding the space.
|
|
55
|
-
-? # Optional alignment specifier.
|
|
56
|
-
[0-9]* # Optional width specifier.
|
|
57
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
|
|
58
|
-
| # Only recognize the space as padding in combination with a width specifier.
|
|
59
|
-
(?:[ ])? # Optional space padding specifier.
|
|
60
|
-
-? # Optional alignment specifier.
|
|
61
|
-
[0-9]+ # Width specifier.
|
|
62
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
|
|
63
|
-
)
|
|
64
|
-
[bcdeEfFgGhHosuxX] # Type specifier.
|
|
65
|
-
)
|
|
66
|
-
)/x';
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* "Unordered" means there's no position specifier: '%s', not '%2$s'.
|
|
70
|
-
*/
|
|
71
|
-
const UNORDERED_SPRINTF_PLACEHOLDER_REGEX = '/(?:
|
|
72
|
-
(?<!%) # Don\'t match a literal % (%%).
|
|
73
|
-
% # Start of placeholder.
|
|
74
|
-
[+-]? # Optional sign specifier.
|
|
75
|
-
(?:
|
|
76
|
-
(?:0|\'.)? # Optional padding specifier - excluding the space.
|
|
77
|
-
-? # Optional alignment specifier.
|
|
78
|
-
[0-9]* # Optional width specifier.
|
|
79
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
|
|
80
|
-
| # Only recognize the space as padding in combination with a width specifier.
|
|
81
|
-
(?:[ ])? # Optional space padding specifier.
|
|
82
|
-
-? # Optional alignment specifier.
|
|
83
|
-
[0-9]+ # Width specifier.
|
|
84
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
|
|
85
|
-
)
|
|
86
|
-
[bcdeEfFgGhHosuxX] # Type specifier.
|
|
87
|
-
)/x';
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Text domain.
|
|
91
|
-
*
|
|
92
|
-
* @var string[]
|
|
93
|
-
*/
|
|
94
|
-
public $text_domain;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The I18N functions in use in WP.
|
|
98
|
-
*
|
|
99
|
-
* @since 0.10.0
|
|
100
|
-
* @since 0.11.0 Changed visibility from public to protected.
|
|
101
|
-
*
|
|
102
|
-
* @var array<string, string> Key is function name, value is the function type.
|
|
103
|
-
*/
|
|
104
|
-
protected $i18n_functions = array(
|
|
105
|
-
'translate' => 'simple',
|
|
106
|
-
'__' => 'simple',
|
|
107
|
-
'esc_attr__' => 'simple',
|
|
108
|
-
'esc_html__' => 'simple',
|
|
109
|
-
'_e' => 'simple',
|
|
110
|
-
'esc_attr_e' => 'simple',
|
|
111
|
-
'esc_html_e' => 'simple',
|
|
112
|
-
'translate_with_gettext_context' => 'context',
|
|
113
|
-
'_x' => 'context',
|
|
114
|
-
'_ex' => 'context',
|
|
115
|
-
'esc_attr_x' => 'context',
|
|
116
|
-
'esc_html_x' => 'context',
|
|
117
|
-
'_n' => 'number',
|
|
118
|
-
'_nx' => 'number_context',
|
|
119
|
-
'_n_noop' => 'noopnumber',
|
|
120
|
-
'_nx_noop' => 'noopnumber_context',
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Whether or not the `default` text domain is one of the allowed text domains.
|
|
125
|
-
*
|
|
126
|
-
* @since 0.14.0
|
|
127
|
-
*
|
|
128
|
-
* @var bool
|
|
129
|
-
*/
|
|
130
|
-
private $text_domain_contains_default = false;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Whether or not the `default` text domain is the only allowed text domain.
|
|
134
|
-
*
|
|
135
|
-
* @since 0.14.0
|
|
136
|
-
*
|
|
137
|
-
* @var bool
|
|
138
|
-
*/
|
|
139
|
-
private $text_domain_is_default = false;
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Parameter specifications for the functions in each group.
|
|
143
|
-
*
|
|
144
|
-
* {@internal Even when not all parameters will be examined, the parameter list should still
|
|
145
|
-
* be complete in the below array to allow for a correct "total parameters" calculation.}
|
|
146
|
-
*
|
|
147
|
-
* @since 3.0.0
|
|
148
|
-
*
|
|
149
|
-
* @var array<string, array> Array of the parameter positions and names.
|
|
150
|
-
*/
|
|
151
|
-
private $parameter_specs = array(
|
|
152
|
-
'simple' => array(
|
|
153
|
-
1 => 'text',
|
|
154
|
-
2 => 'domain',
|
|
155
|
-
),
|
|
156
|
-
'context' => array(
|
|
157
|
-
1 => 'text',
|
|
158
|
-
2 => 'context',
|
|
159
|
-
3 => 'domain',
|
|
160
|
-
),
|
|
161
|
-
'number' => array(
|
|
162
|
-
1 => 'single',
|
|
163
|
-
2 => 'plural',
|
|
164
|
-
3 => 'number',
|
|
165
|
-
4 => 'domain',
|
|
166
|
-
),
|
|
167
|
-
'number_context' => array(
|
|
168
|
-
1 => 'single',
|
|
169
|
-
2 => 'plural',
|
|
170
|
-
3 => 'number',
|
|
171
|
-
4 => 'context',
|
|
172
|
-
5 => 'domain',
|
|
173
|
-
),
|
|
174
|
-
'noopnumber' => array(
|
|
175
|
-
1 => 'singular',
|
|
176
|
-
2 => 'plural',
|
|
177
|
-
3 => 'domain',
|
|
178
|
-
),
|
|
179
|
-
'noopnumber_context' => array(
|
|
180
|
-
1 => 'singular',
|
|
181
|
-
2 => 'plural',
|
|
182
|
-
3 => 'context',
|
|
183
|
-
4 => 'domain',
|
|
184
|
-
),
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Groups of functions to restrict.
|
|
189
|
-
*
|
|
190
|
-
* Example: groups => array(
|
|
191
|
-
* 'lambda' => array(
|
|
192
|
-
* 'type' => 'error' | 'warning',
|
|
193
|
-
* 'message' => 'Use anonymous functions instead please!',
|
|
194
|
-
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
|
195
|
-
* )
|
|
196
|
-
* )
|
|
197
|
-
*
|
|
198
|
-
* @return array
|
|
199
|
-
*/
|
|
200
|
-
public function getGroups() {
|
|
201
|
-
return array(
|
|
202
|
-
'i18n' => array(
|
|
203
|
-
'functions' => array_keys( $this->i18n_functions ),
|
|
204
|
-
),
|
|
205
|
-
'typos' => array(
|
|
206
|
-
'functions' => array(
|
|
207
|
-
'_',
|
|
208
|
-
),
|
|
209
|
-
),
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Processes this test, when one of its tokens is encountered.
|
|
215
|
-
*
|
|
216
|
-
* @since 1.0.0 Defers to the abstractFunctionRestriction sniff for determining
|
|
217
|
-
* whether something is a function call. The logic after that has
|
|
218
|
-
* been split off to the `process_matched_token()` method.
|
|
219
|
-
*
|
|
220
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
221
|
-
*
|
|
222
|
-
* @return void
|
|
223
|
-
*/
|
|
224
|
-
public function process_token( $stackPtr ) {
|
|
225
|
-
|
|
226
|
-
// Reset defaults.
|
|
227
|
-
$this->text_domain_contains_default = false;
|
|
228
|
-
$this->text_domain_is_default = false;
|
|
229
|
-
|
|
230
|
-
// Allow overruling the text_domain set in a ruleset via the command line.
|
|
231
|
-
$cl_text_domain = Helper::getConfigData( 'text_domain' );
|
|
232
|
-
if ( ! empty( $cl_text_domain ) ) {
|
|
233
|
-
$cl_text_domain = trim( $cl_text_domain );
|
|
234
|
-
if ( '' !== $cl_text_domain ) {
|
|
235
|
-
$this->text_domain = array_filter( array_map( 'trim', explode( ',', $cl_text_domain ) ) );
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
$this->text_domain = RulesetPropertyHelper::merge_custom_array( $this->text_domain, array(), false );
|
|
240
|
-
|
|
241
|
-
if ( ! empty( $this->text_domain ) ) {
|
|
242
|
-
if ( \in_array( 'default', $this->text_domain, true ) ) {
|
|
243
|
-
$this->text_domain_contains_default = true;
|
|
244
|
-
if ( \count( $this->text_domain ) === 1 ) {
|
|
245
|
-
$this->text_domain_is_default = true;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Prevent exclusion of the i18n group.
|
|
251
|
-
$this->exclude = array();
|
|
252
|
-
|
|
253
|
-
parent::process_token( $stackPtr );
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Process a matched token.
|
|
258
|
-
*
|
|
259
|
-
* @since 1.0.0 Logic split off from the `process_token()` method.
|
|
260
|
-
*
|
|
261
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
262
|
-
* @param string $group_name The name of the group which was matched.
|
|
263
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
264
|
-
* in lowercase.
|
|
265
|
-
*
|
|
266
|
-
* @return void
|
|
267
|
-
*/
|
|
268
|
-
public function process_matched_token( $stackPtr, $group_name, $matched_content ) {
|
|
269
|
-
|
|
270
|
-
$func_open_paren_token = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
|
271
|
-
if ( ! isset( $this->tokens[ $func_open_paren_token ]['parenthesis_closer'] ) ) {
|
|
272
|
-
// Live coding, parse error or not a function call.
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if ( 'typos' === $group_name && '_' === $matched_content ) {
|
|
277
|
-
$this->phpcsFile->addError(
|
|
278
|
-
'Found single-underscore "_()" function when double-underscore expected.',
|
|
279
|
-
$stackPtr,
|
|
280
|
-
'SingleUnderscoreGetTextFunction'
|
|
281
|
-
);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if ( 'translate' === $matched_content || 'translate_with_gettext_context' === $matched_content ) {
|
|
286
|
-
$this->phpcsFile->addWarning(
|
|
287
|
-
'Use of the "%s()" function is reserved for low-level API usage.',
|
|
288
|
-
$stackPtr,
|
|
289
|
-
'LowLevelTranslationFunction',
|
|
290
|
-
array( $matched_content )
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
parent::process_matched_token( $stackPtr, $group_name, $matched_content );
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Process the function if no parameters were found.
|
|
299
|
-
*
|
|
300
|
-
* @since 3.0.0
|
|
301
|
-
*
|
|
302
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
303
|
-
* @param string $group_name The name of the group which was matched.
|
|
304
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
305
|
-
* in lowercase.
|
|
306
|
-
*
|
|
307
|
-
* @return void
|
|
308
|
-
*/
|
|
309
|
-
public function process_no_parameters( $stackPtr, $group_name, $matched_content ) {
|
|
310
|
-
$function_param_specs = $this->parameter_specs[ $this->i18n_functions[ $matched_content ] ];
|
|
311
|
-
|
|
312
|
-
foreach ( $function_param_specs as $param_name ) {
|
|
313
|
-
$error_code = MessageHelper::stringToErrorcode( 'MissingArg' . ucfirst( $param_name ) );
|
|
314
|
-
$this->phpcsFile->addError(
|
|
315
|
-
'Missing $%s parameter in function call to %s().',
|
|
316
|
-
$stackPtr,
|
|
317
|
-
$error_code,
|
|
318
|
-
array( $param_name, $matched_content )
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Process the parameters of a matched function.
|
|
325
|
-
*
|
|
326
|
-
* @since 3.0.0
|
|
327
|
-
*
|
|
328
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
329
|
-
* @param string $group_name The name of the group which was matched.
|
|
330
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
331
|
-
* in lowercase.
|
|
332
|
-
* @param array $parameters Array with information about the parameters.
|
|
333
|
-
*
|
|
334
|
-
* @return void
|
|
335
|
-
*/
|
|
336
|
-
public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
|
|
337
|
-
/*
|
|
338
|
-
* Retrieve the individual parameters from the array in a way that we know which is which.
|
|
339
|
-
*/
|
|
340
|
-
$parameter_details = array();
|
|
341
|
-
|
|
342
|
-
$function_param_specs = $this->parameter_specs[ $this->i18n_functions[ $matched_content ] ];
|
|
343
|
-
$expected_args = count( $function_param_specs );
|
|
344
|
-
|
|
345
|
-
foreach ( $function_param_specs as $position => $name ) {
|
|
346
|
-
if ( 'number' === $name ) {
|
|
347
|
-
// This sniff does not examine the $number parameter.
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
$parameter_details[ $name ] = PassedParameters::getParameterFromStack( $parameters, $position, $name );
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/*
|
|
355
|
-
* Examine the individual parameters.
|
|
356
|
-
*/
|
|
357
|
-
$this->check_argument_count( $stackPtr, $matched_content, $parameters, $expected_args );
|
|
358
|
-
|
|
359
|
-
foreach ( $parameter_details as $param_name => $param_info ) {
|
|
360
|
-
$is_string_literal = $this->check_argument_is_string_literal( $stackPtr, $matched_content, $param_name, $param_info );
|
|
361
|
-
|
|
362
|
-
/*
|
|
363
|
-
* If the parameter exists, remember whether the argument was a valid string literal.
|
|
364
|
-
* This is used in a few places to determine whether the checks which examine a text string should run.
|
|
365
|
-
*/
|
|
366
|
-
if ( false !== $param_info ) {
|
|
367
|
-
$parameter_details[ $param_name ]['is_string_literal'] = $is_string_literal;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if ( false === $is_string_literal ) {
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if ( 'domain' === $param_name ) {
|
|
375
|
-
$this->check_textdomain_matches( $matched_content, $param_name, $param_info );
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if ( \in_array( $param_name, array( 'text', 'single', 'singular', 'plural' ), true ) ) {
|
|
379
|
-
$this->check_placeholders_in_string( $matched_content, $param_name, $param_info );
|
|
380
|
-
$has_content = $this->check_string_has_translatable_content( $matched_content, $param_name, $param_info );
|
|
381
|
-
if ( true === $has_content ) {
|
|
382
|
-
$this->check_string_has_no_html_wrapper( $matched_content, $param_name, $param_info );
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/*
|
|
388
|
-
* For _n*() calls, compare the singular and plural strings.
|
|
389
|
-
*
|
|
390
|
-
* If either of the arguments is missing, empty or has more than 1 token, skip out.
|
|
391
|
-
* An error for that will already have been reported via the `check_argument_is_string_literal()` method.
|
|
392
|
-
*/
|
|
393
|
-
$single_details = null;
|
|
394
|
-
if ( isset( $parameter_details['single'] ) ) {
|
|
395
|
-
$single_details = $parameter_details['single'];
|
|
396
|
-
} elseif ( isset( $parameter_details['singular'] ) ) {
|
|
397
|
-
$single_details = $parameter_details['singular'];
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if ( isset( $single_details, $parameter_details['plural'] )
|
|
401
|
-
&& false !== $single_details
|
|
402
|
-
&& false !== $parameter_details['plural']
|
|
403
|
-
&& true === $single_details['is_string_literal']
|
|
404
|
-
&& true === $parameter_details['plural']['is_string_literal']
|
|
405
|
-
) {
|
|
406
|
-
$this->compare_single_and_plural_arguments( $stackPtr, $single_details, $parameter_details['plural'] );
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/*
|
|
410
|
-
* Check if a translators comments is necessary and if so, if it exists.
|
|
411
|
-
*/
|
|
412
|
-
$this->check_for_translator_comment( $stackPtr, $matched_content, $parameter_details );
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Verify that there are no superfluous function arguments.
|
|
417
|
-
*
|
|
418
|
-
* @since 3.0.0 Check moved from the `process_matched_token()` method to this method.
|
|
419
|
-
*
|
|
420
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
421
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
422
|
-
* in lowercase.
|
|
423
|
-
* @param array $parameters The parameters array.
|
|
424
|
-
* @param int $expected_count The expected number of passed arguments.
|
|
425
|
-
*
|
|
426
|
-
* @return void
|
|
427
|
-
*/
|
|
428
|
-
private function check_argument_count( $stackPtr, $matched_content, $parameters, $expected_count ) {
|
|
429
|
-
$actual_count = count( $parameters );
|
|
430
|
-
if ( $actual_count > $expected_count ) {
|
|
431
|
-
$this->phpcsFile->addError(
|
|
432
|
-
'Too many parameters passed to function "%s()". Expected: %s parameters, received: %s',
|
|
433
|
-
$stackPtr,
|
|
434
|
-
'TooManyFunctionArgs',
|
|
435
|
-
array( $matched_content, $expected_count, $actual_count )
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Check if an arbitrary function call parameter is a text string literal suitable for use in the translation functions.
|
|
442
|
-
*
|
|
443
|
-
* Will also check and warn about missing parameters.
|
|
444
|
-
*
|
|
445
|
-
* @since 3.0.0 Most of the logic in this method used to be contained in the, now removed, `check_argument_tokens()` method.
|
|
446
|
-
*
|
|
447
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
448
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
449
|
-
* in lowercase.
|
|
450
|
-
* @param string $param_name The name of the parameter being examined.
|
|
451
|
-
* @param array|false $param_info Parameter info array for an individual parameter,
|
|
452
|
-
* as received from the PassedParemeters class.
|
|
453
|
-
*
|
|
454
|
-
* @return bool Whether or not the argument is a string literal.
|
|
455
|
-
*/
|
|
456
|
-
private function check_argument_is_string_literal( $stackPtr, $matched_content, $param_name, $param_info ) {
|
|
457
|
-
/*
|
|
458
|
-
* Check if the parameter was supplied.
|
|
459
|
-
*/
|
|
460
|
-
if ( false === $param_info || '' === $param_info['clean'] ) {
|
|
461
|
-
$error_code = MessageHelper::stringToErrorcode( 'MissingArg' . ucfirst( $param_name ) );
|
|
462
|
-
|
|
463
|
-
/*
|
|
464
|
-
* Special case the text domain parameter, which is allowed to be "missing"
|
|
465
|
-
* when set to `default` (= WP Core translation).
|
|
466
|
-
*/
|
|
467
|
-
if ( 'domain' === $param_name ) {
|
|
468
|
-
if ( empty( $this->text_domain ) ) {
|
|
469
|
-
// If no text domain is passed, presume WP Core.
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
if ( true === $this->text_domain_is_default ) {
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if ( true === $this->text_domain_contains_default ) {
|
|
478
|
-
$this->phpcsFile->addWarning(
|
|
479
|
-
'Missing $%s parameter in function call to %s(). If this text string is supposed to use a WP Core translation, use the "default" text domain.',
|
|
480
|
-
$stackPtr,
|
|
481
|
-
$error_code . 'Default',
|
|
482
|
-
array( $param_name, $matched_content )
|
|
483
|
-
);
|
|
484
|
-
return false;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
$this->phpcsFile->addError(
|
|
489
|
-
'Missing $%s parameter in function call to %s().',
|
|
490
|
-
$stackPtr,
|
|
491
|
-
$error_code,
|
|
492
|
-
array( $param_name, $matched_content )
|
|
493
|
-
);
|
|
494
|
-
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/*
|
|
499
|
-
* Check if the parameter consists of one singular text string literal.
|
|
500
|
-
* Heredoc/nowdocs not allowed. Multi-line single/double quoted strings are allowed.
|
|
501
|
-
*/
|
|
502
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
503
|
-
for ( $i = $first_non_empty; $i <= $param_info['end']; $i++ ) {
|
|
504
|
-
if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) === false ) {
|
|
509
|
-
$error_code = MessageHelper::stringToErrorcode( 'NonSingularStringLiteral' . ucfirst( $param_name ) );
|
|
510
|
-
$this->phpcsFile->addError(
|
|
511
|
-
'The $%s parameter must be a single text string literal. Found: %s',
|
|
512
|
-
$first_non_empty,
|
|
513
|
-
$error_code,
|
|
514
|
-
array( $param_name, $param_info['clean'] )
|
|
515
|
-
);
|
|
516
|
-
return false;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/*
|
|
521
|
-
* Make sure the text string does not contain any interpolated variable.
|
|
522
|
-
*/
|
|
523
|
-
if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
|
|
524
|
-
$error_code = MessageHelper::stringToErrorcode( 'InterpolatedVariable' . ucfirst( $param_name ) );
|
|
525
|
-
|
|
526
|
-
$interpolated_variables = TextStrings::getEmbeds( $param_info['clean'] );
|
|
527
|
-
foreach ( $interpolated_variables as $interpolated_variable ) {
|
|
528
|
-
$this->phpcsFile->addError(
|
|
529
|
-
'The $%s parameter must not contain interpolated variables or expressions. Found: %s',
|
|
530
|
-
$first_non_empty,
|
|
531
|
-
$error_code,
|
|
532
|
-
array( $param_name, $interpolated_variable )
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
if ( ! empty( $interpolated_variables ) ) {
|
|
537
|
-
return false;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
return true;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Check the correct text domain is being used.
|
|
546
|
-
*
|
|
547
|
-
* @since 3.0.0 The logic in this method used to be contained in the, now removed, `check_argument_tokens()` method.
|
|
548
|
-
*
|
|
549
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
550
|
-
* in lowercase.
|
|
551
|
-
* @param string $param_name The name of the parameter being examined.
|
|
552
|
-
* @param array|false $param_info Parameter info array for an individual parameter,
|
|
553
|
-
* as received from the PassedParemeters class.
|
|
554
|
-
*
|
|
555
|
-
* @return void
|
|
556
|
-
*/
|
|
557
|
-
private function check_textdomain_matches( $matched_content, $param_name, $param_info ) {
|
|
558
|
-
$stripped_content = TextStrings::stripQuotes( $param_info['clean'] );
|
|
559
|
-
|
|
560
|
-
if ( empty( $this->text_domain ) && '' === $stripped_content ) {
|
|
561
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
562
|
-
|
|
563
|
-
$this->phpcsFile->addError(
|
|
564
|
-
'The passed $domain should never be an empty string. Either pass a text domain or remove the parameter.',
|
|
565
|
-
$first_non_empty,
|
|
566
|
-
'EmptyTextDomain'
|
|
567
|
-
);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if ( empty( $this->text_domain ) ) {
|
|
571
|
-
// Nothing more to do, the other checks all depend on a text domain being known.
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if ( ! \in_array( $stripped_content, $this->text_domain, true ) ) {
|
|
576
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
577
|
-
|
|
578
|
-
$this->phpcsFile->addError(
|
|
579
|
-
'Mismatched text domain. Expected \'%s\' but got %s.',
|
|
580
|
-
$first_non_empty,
|
|
581
|
-
'TextDomainMismatch',
|
|
582
|
-
array( implode( "' or '", $this->text_domain ), $param_info['clean'] )
|
|
583
|
-
);
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
if ( true === $this->text_domain_is_default && 'default' === $stripped_content ) {
|
|
588
|
-
$fixable = false;
|
|
589
|
-
$error = 'No need to supply the text domain in function call to %s() when the only accepted text domain is "default".';
|
|
590
|
-
$error_code = 'SuperfluousDefaultTextDomain';
|
|
591
|
-
$data = array( $matched_content );
|
|
592
|
-
|
|
593
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
594
|
-
|
|
595
|
-
// Prevent removing comments when auto-fixing.
|
|
596
|
-
$remove_from = ( $param_info['start'] - 1 );
|
|
597
|
-
$remove_to = $first_non_empty;
|
|
598
|
-
|
|
599
|
-
if ( isset( $param_info['name_token'] ) ) {
|
|
600
|
-
$remove_from = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $param_info['name_token'] - 1 ), null, true );
|
|
601
|
-
if ( \T_OPEN_PARENTHESIS === $this->tokens[ $remove_from ]['code'] ) {
|
|
602
|
-
++$remove_from; // Don't remove the open parenthesis.
|
|
603
|
-
|
|
604
|
-
/*
|
|
605
|
-
* Named param as first param in the function call, if we fix this, we need to
|
|
606
|
-
* remove the comma _after_ the parameter as well to prevent creating a parse error.
|
|
607
|
-
*/
|
|
608
|
-
$remove_to = $param_info['end'];
|
|
609
|
-
if ( \T_COMMA === $this->tokens[ ( $param_info['end'] + 1 ) ]['code'] ) {
|
|
610
|
-
++$remove_to; // Include the comma.
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// Now, make sure there are no comments in the tokens we want to remove.
|
|
616
|
-
if ( $this->phpcsFile->findNext( Tokens::$commentTokens, $remove_from, ( $remove_to + 1 ) ) === false ) {
|
|
617
|
-
$fixable = true;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if ( false === $fixable ) {
|
|
621
|
-
$this->phpcsFile->addWarning( $error, $first_non_empty, $error_code, $data );
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
$fix = $this->phpcsFile->addFixableWarning( $error, $first_non_empty, $error_code, $data );
|
|
626
|
-
if ( true === $fix ) {
|
|
627
|
-
$this->phpcsFile->fixer->beginChangeset();
|
|
628
|
-
for ( $i = $remove_from; $i <= $remove_to; $i++ ) {
|
|
629
|
-
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
|
630
|
-
}
|
|
631
|
-
$this->phpcsFile->fixer->endChangeset();
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Check the placeholders used in translatable text for common problems.
|
|
638
|
-
*
|
|
639
|
-
* @since 3.0.0 The logic in this method used to be contained in the, now removed, `check_text()` method.
|
|
640
|
-
*
|
|
641
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
642
|
-
* in lowercase.
|
|
643
|
-
* @param string $param_name The name of the parameter being examined.
|
|
644
|
-
* @param array|false $param_info Parameter info array for an individual parameter,
|
|
645
|
-
* as received from the PassedParemeters class.
|
|
646
|
-
*
|
|
647
|
-
* @return void
|
|
648
|
-
*/
|
|
649
|
-
private function check_placeholders_in_string( $matched_content, $param_name, $param_info ) {
|
|
650
|
-
$content = $param_info['clean'];
|
|
651
|
-
|
|
652
|
-
// UnorderedPlaceholders: Check for multiple unordered placeholders.
|
|
653
|
-
$unordered_matches_count = preg_match_all( self::UNORDERED_SPRINTF_PLACEHOLDER_REGEX, $content, $unordered_matches );
|
|
654
|
-
$unordered_matches = $unordered_matches[0];
|
|
655
|
-
$all_matches_count = preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $content, $all_matches );
|
|
656
|
-
|
|
657
|
-
if ( $unordered_matches_count > 0
|
|
658
|
-
&& $unordered_matches_count !== $all_matches_count
|
|
659
|
-
&& $all_matches_count > 1
|
|
660
|
-
) {
|
|
661
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
662
|
-
$error_code = MessageHelper::stringToErrorcode( 'MixedOrderedPlaceholders' . ucfirst( $param_name ) );
|
|
663
|
-
|
|
664
|
-
$this->phpcsFile->addError(
|
|
665
|
-
'Multiple placeholders in translatable strings should be ordered. Mix of ordered and non-ordered placeholders found. Found: "%s" in %s.',
|
|
666
|
-
$first_non_empty,
|
|
667
|
-
$error_code,
|
|
668
|
-
array( implode( ', ', $all_matches[0] ), $param_info['clean'] )
|
|
669
|
-
);
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
if ( $unordered_matches_count >= 2 ) {
|
|
674
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
675
|
-
$error_code = MessageHelper::stringToErrorcode( 'UnorderedPlaceholders' . ucfirst( $param_name ) );
|
|
676
|
-
|
|
677
|
-
$suggestions = array();
|
|
678
|
-
$replace_regexes = array();
|
|
679
|
-
$replacements = array();
|
|
680
|
-
for ( $i = 0; $i < $unordered_matches_count; $i++ ) {
|
|
681
|
-
$to_insert = ( $i + 1 );
|
|
682
|
-
$to_insert .= ( '"' !== $content[0] ) ? '$' : '\$';
|
|
683
|
-
$suggestions[ $i ] = substr_replace( $unordered_matches[ $i ], $to_insert, 1, 0 );
|
|
684
|
-
|
|
685
|
-
// Prepare the strings for use in a regex.
|
|
686
|
-
$replace_regexes[ $i ] = '`\Q' . $unordered_matches[ $i ] . '\E`';
|
|
687
|
-
// Note: the initial \\ is a literal \, the four \ in the replacement translate also to a literal \.
|
|
688
|
-
$replacements[ $i ] = str_replace( '\\', '\\\\', $suggestions[ $i ] );
|
|
689
|
-
// Note: the $ needs escaping to prevent numeric sequences after the $ being interpreted as match replacements.
|
|
690
|
-
$replacements[ $i ] = str_replace( '$', '\\$', $replacements[ $i ] );
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
$fix = $this->phpcsFile->addFixableError(
|
|
694
|
-
'Multiple placeholders in translatable strings should be ordered. Expected "%s", but got "%s" in %s.',
|
|
695
|
-
$first_non_empty,
|
|
696
|
-
$error_code,
|
|
697
|
-
array( implode( ', ', $suggestions ), implode( ', ', $unordered_matches ), $param_info['clean'] )
|
|
698
|
-
);
|
|
699
|
-
|
|
700
|
-
if ( true === $fix ) {
|
|
701
|
-
$this->phpcsFile->fixer->beginChangeset();
|
|
702
|
-
|
|
703
|
-
$fixed_str = preg_replace( $replace_regexes, $replacements, $content, 1 );
|
|
704
|
-
|
|
705
|
-
$this->phpcsFile->fixer->replaceToken( $first_non_empty, $fixed_str );
|
|
706
|
-
|
|
707
|
-
$i = ( $first_non_empty + 1 );
|
|
708
|
-
while ( $i <= $param_info['end'] && isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
|
709
|
-
$this->phpcsFile->fixer->replaceToken( $i, '' );
|
|
710
|
-
++$i;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
$this->phpcsFile->fixer->endChangeset();
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* Check if a parameter which is supposed to hold translatable text actually has translatable text.
|
|
720
|
-
*
|
|
721
|
-
* @since 3.0.0 The logic in this method used to be contained in the, now removed, `check_text()` method.
|
|
722
|
-
*
|
|
723
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
724
|
-
* in lowercase.
|
|
725
|
-
* @param string $param_name The name of the parameter being examined.
|
|
726
|
-
* @param array|false $param_info Parameter info array for an individual parameter,
|
|
727
|
-
* as received from the PassedParemeters class.
|
|
728
|
-
*
|
|
729
|
-
* @return bool Whether or not the text string has translatable content.
|
|
730
|
-
*/
|
|
731
|
-
private function check_string_has_translatable_content( $matched_content, $param_name, $param_info ) {
|
|
732
|
-
// Strip placeholders and surrounding quotes.
|
|
733
|
-
$content_without_quotes = trim( TextStrings::stripQuotes( $param_info['clean'] ) );
|
|
734
|
-
$non_placeholder_content = preg_replace( self::SPRINTF_PLACEHOLDER_REGEX, '', $content_without_quotes );
|
|
735
|
-
|
|
736
|
-
if ( '' === $non_placeholder_content ) {
|
|
737
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
738
|
-
|
|
739
|
-
$this->phpcsFile->addError(
|
|
740
|
-
'The $%s text string should have translatable content. Found: %s',
|
|
741
|
-
$first_non_empty,
|
|
742
|
-
'NoEmptyStrings',
|
|
743
|
-
array( $param_name, $param_info['clean'] )
|
|
744
|
-
);
|
|
745
|
-
return false;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
return true;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
* Ensure that a translatable text string is not wrapped in HTML code.
|
|
753
|
-
*
|
|
754
|
-
* If the text is wrapped in HTML, the HTML should be moved out of the translatable text string.
|
|
755
|
-
*
|
|
756
|
-
* @since 3.0.0 The logic in this method used to be contained in the, now removed, `check_text()` method.
|
|
757
|
-
*
|
|
758
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
759
|
-
* in lowercase.
|
|
760
|
-
* @param string $param_name The name of the parameter being examined.
|
|
761
|
-
* @param array|false $param_info Parameter info array for an individual parameter,
|
|
762
|
-
* as received from the PassedParemeters class.
|
|
763
|
-
*
|
|
764
|
-
* @return void
|
|
765
|
-
*/
|
|
766
|
-
private function check_string_has_no_html_wrapper( $matched_content, $param_name, $param_info ) {
|
|
767
|
-
// Strip surrounding quotes.
|
|
768
|
-
$content_without_quotes = trim( TextStrings::stripQuotes( $param_info['clean'] ) );
|
|
769
|
-
|
|
770
|
-
$reader = new XMLReader();
|
|
771
|
-
$reader->XML( $content_without_quotes, 'UTF-8', \LIBXML_NOERROR | \LIBXML_ERR_NONE | \LIBXML_NOWARNING );
|
|
772
|
-
|
|
773
|
-
// Is the first node an HTML element?
|
|
774
|
-
if ( ! $reader->read() || XMLReader::ELEMENT !== $reader->nodeType ) {
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
// If the opening HTML element includes placeholders in its attributes, we don't warn.
|
|
779
|
-
// E.g. '<option id="%1$s" value="%2$s">Translatable option name</option>'.
|
|
780
|
-
$i = 0;
|
|
781
|
-
while ( $attr = $reader->getAttributeNo( $i ) ) {
|
|
782
|
-
if ( preg_match( self::SPRINTF_PLACEHOLDER_REGEX, $attr ) === 1 ) {
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
++$i;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
// We don't flag strings wrapped in `<a href="...">...</a>`, as the link target might actually need localization.
|
|
790
|
-
if ( 'a' === $reader->name && $reader->getAttribute( 'href' ) ) {
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
// Does the entire string only consist of this HTML node?
|
|
795
|
-
if ( $reader->readOuterXml() === $content_without_quotes ) {
|
|
796
|
-
$first_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info['start'], ( $param_info['end'] + 1 ), true );
|
|
797
|
-
|
|
798
|
-
$this->phpcsFile->addWarning(
|
|
799
|
-
'Translatable string should not be wrapped in HTML. Found: %s',
|
|
800
|
-
$first_non_empty,
|
|
801
|
-
'NoHtmlWrappedStrings',
|
|
802
|
-
array( $param_info['clean'] )
|
|
803
|
-
);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Check for inconsistencies in the placeholders between single and plural form of the translatable text string.
|
|
809
|
-
*
|
|
810
|
-
* @since 3.0.0 - The parameter names and expected format for the $param_info_single
|
|
811
|
-
* and the $param_info_plural parameters has changed.
|
|
812
|
-
* - The method visibility has been changed from `protected` to `private`.
|
|
813
|
-
*
|
|
814
|
-
* @param int $stackPtr The position of the function call token in the stack.
|
|
815
|
-
* @param array $param_info_single Parameter info array for the `$single` parameter,
|
|
816
|
-
* as received from the PassedParemeters class.
|
|
817
|
-
* @param array $param_info_plural Parameter info array for the `$plural` parameter,
|
|
818
|
-
* as received from the PassedParemeters class.
|
|
819
|
-
*
|
|
820
|
-
* @return void
|
|
821
|
-
*/
|
|
822
|
-
private function compare_single_and_plural_arguments( $stackPtr, $param_info_single, $param_info_plural ) {
|
|
823
|
-
$single_content = $param_info_single['clean'];
|
|
824
|
-
$plural_content = $param_info_plural['clean'];
|
|
825
|
-
|
|
826
|
-
preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $single_content, $single_placeholders );
|
|
827
|
-
$single_placeholders = $single_placeholders[0];
|
|
828
|
-
|
|
829
|
-
preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $plural_content, $plural_placeholders );
|
|
830
|
-
$plural_placeholders = $plural_placeholders[0];
|
|
831
|
-
|
|
832
|
-
// English conflates "singular" with "only one", described in the codex:
|
|
833
|
-
// https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals .
|
|
834
|
-
if ( \count( $single_placeholders ) < \count( $plural_placeholders ) ) {
|
|
835
|
-
$error_string = 'Missing singular placeholder, needed for some languages. See https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals';
|
|
836
|
-
$first_non_empty_single = $this->phpcsFile->findNext( Tokens::$emptyTokens, $param_info_single['start'], ( $param_info_single['end'] + 1 ), true );
|
|
837
|
-
|
|
838
|
-
$this->phpcsFile->addError( $error_string, $first_non_empty_single, 'MissingSingularPlaceholder' );
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// Reordering is fine, but mismatched placeholders is probably wrong.
|
|
843
|
-
sort( $single_placeholders, \SORT_NATURAL );
|
|
844
|
-
sort( $plural_placeholders, \SORT_NATURAL );
|
|
845
|
-
|
|
846
|
-
if ( $single_placeholders !== $plural_placeholders ) {
|
|
847
|
-
$this->phpcsFile->addWarning( 'Mismatched placeholders is probably an error', $stackPtr, 'MismatchedPlaceholders' );
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* Check for the presence of a translators comment if one of the text strings contains a placeholder.
|
|
853
|
-
*
|
|
854
|
-
* @since 3.0.0 - The parameter names and expected format for the $parameters parameter has changed.
|
|
855
|
-
* - The method visibility has been changed from `protected` to `private`.
|
|
856
|
-
*
|
|
857
|
-
* @param int $stackPtr The position of the gettext call token in the stack.
|
|
858
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
859
|
-
* in lowercase.
|
|
860
|
-
* @param array $parameters Array with information about the parameters.
|
|
861
|
-
*
|
|
862
|
-
* @return void
|
|
863
|
-
*/
|
|
864
|
-
private function check_for_translator_comment( $stackPtr, $matched_content, $parameters ) {
|
|
865
|
-
$needs_translators_comment = false;
|
|
866
|
-
|
|
867
|
-
foreach ( $parameters as $param_name => $param_info ) {
|
|
868
|
-
if ( false === \in_array( $param_name, array( 'text', 'single', 'singular', 'plural' ), true ) ) {
|
|
869
|
-
continue;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
if ( false === $param_info || false === $param_info['is_string_literal'] ) {
|
|
873
|
-
continue;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
if ( preg_match( self::SPRINTF_PLACEHOLDER_REGEX, $param_info['clean'], $placeholders ) === 1 ) {
|
|
877
|
-
$needs_translators_comment = true;
|
|
878
|
-
break;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
if ( false === $needs_translators_comment ) {
|
|
883
|
-
// No text string with placeholders found, no translation comment needed.
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
$previous_comment = $this->phpcsFile->findPrevious( Tokens::$commentTokens, ( $stackPtr - 1 ) );
|
|
888
|
-
|
|
889
|
-
if ( false !== $previous_comment ) {
|
|
890
|
-
/*
|
|
891
|
-
* Check that the comment is either on the line before the gettext call or
|
|
892
|
-
* if it's not, that there is only whitespace between.
|
|
893
|
-
*/
|
|
894
|
-
$correctly_placed = false;
|
|
895
|
-
|
|
896
|
-
if ( ( $this->tokens[ $previous_comment ]['line'] + 1 ) === $this->tokens[ $stackPtr ]['line'] ) {
|
|
897
|
-
$correctly_placed = true;
|
|
898
|
-
} else {
|
|
899
|
-
$next_non_whitespace = $this->phpcsFile->findNext( \T_WHITESPACE, ( $previous_comment + 1 ), $stackPtr, true );
|
|
900
|
-
if ( false === $next_non_whitespace || $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $stackPtr ]['line'] ) {
|
|
901
|
-
// No non-whitespace found or next non-whitespace is on same line as gettext call.
|
|
902
|
-
$correctly_placed = true;
|
|
903
|
-
}
|
|
904
|
-
unset( $next_non_whitespace );
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
/*
|
|
908
|
-
* Check that the comment starts with 'translators:'.
|
|
909
|
-
*/
|
|
910
|
-
if ( true === $correctly_placed ) {
|
|
911
|
-
if ( \T_COMMENT === $this->tokens[ $previous_comment ]['code'] ) {
|
|
912
|
-
$comment_text = trim( $this->tokens[ $previous_comment ]['content'] );
|
|
913
|
-
|
|
914
|
-
// If it's multi-line /* */ comment, collect all the parts.
|
|
915
|
-
if ( '*/' === substr( $comment_text, -2 ) && '/*' !== substr( $comment_text, 0, 2 ) ) {
|
|
916
|
-
for ( $i = ( $previous_comment - 1 ); 0 <= $i; $i-- ) {
|
|
917
|
-
if ( \T_COMMENT !== $this->tokens[ $i ]['code'] ) {
|
|
918
|
-
break;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
$comment_text = trim( $this->tokens[ $i ]['content'] ) . $comment_text;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
if ( true === $this->is_translators_comment( $comment_text ) ) {
|
|
926
|
-
// Comment is ok.
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
if ( \T_DOC_COMMENT_CLOSE_TAG === $this->tokens[ $previous_comment ]['code'] ) {
|
|
932
|
-
// If it's docblock comment (wrong style) make sure that it's a translators comment.
|
|
933
|
-
if ( isset( $this->tokens[ $previous_comment ]['comment_opener'] ) ) {
|
|
934
|
-
$db_start = $this->tokens[ $previous_comment ]['comment_opener'];
|
|
935
|
-
} else {
|
|
936
|
-
$db_start = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_OPEN_TAG, ( $previous_comment - 1 ) );
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
$db_first_text = $this->phpcsFile->findNext( \T_DOC_COMMENT_STRING, ( $db_start + 1 ), $previous_comment );
|
|
940
|
-
|
|
941
|
-
if ( true === $this->is_translators_comment( $this->tokens[ $db_first_text ]['content'] ) ) {
|
|
942
|
-
$this->phpcsFile->addWarning(
|
|
943
|
-
'A "translators:" comment must be a "/* */" style comment. Docblock comments will not be picked up by the tools to generate a ".pot" file.',
|
|
944
|
-
$stackPtr,
|
|
945
|
-
'TranslatorsCommentWrongStyle'
|
|
946
|
-
);
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
// Found placeholders but no translators comment.
|
|
954
|
-
$this->phpcsFile->addWarning(
|
|
955
|
-
'A function call to %s() with texts containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.',
|
|
956
|
-
$stackPtr,
|
|
957
|
-
'MissingTranslatorsComment',
|
|
958
|
-
array( $matched_content )
|
|
959
|
-
);
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
/**
|
|
963
|
-
* Check if a (collated) comment string starts with 'translators:'.
|
|
964
|
-
*
|
|
965
|
-
* @since 0.11.0
|
|
966
|
-
*
|
|
967
|
-
* @param string $content Comment string content.
|
|
968
|
-
*
|
|
969
|
-
* @return bool
|
|
970
|
-
*/
|
|
971
|
-
private function is_translators_comment( $content ) {
|
|
972
|
-
if ( preg_match( '`^(?:(?://|/\*{1,2}) )?translators:`i', $content, $matches ) === 1 ) {
|
|
973
|
-
return true;
|
|
974
|
-
}
|
|
975
|
-
return false;
|
|
976
|
-
}
|
|
977
|
-
}
|