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,862 +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\Utils;
|
|
11
|
-
|
|
12
|
-
use PHP_CodeSniffer\Util\Tokens;
|
|
13
|
-
use PHPCSUtils\BackCompat\Helper;
|
|
14
|
-
use PHPCSUtils\Utils\GetTokensAsString;
|
|
15
|
-
use PHPCSUtils\Utils\PassedParameters;
|
|
16
|
-
use PHPCSUtils\Utils\TextStrings;
|
|
17
|
-
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
|
|
18
|
-
use WordPressCS\WordPress\Helpers\RulesetPropertyHelper;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Comprehensive I18n text domain fixer tool.
|
|
22
|
-
*
|
|
23
|
-
* This sniff can:
|
|
24
|
-
* - Add missing text domains.
|
|
25
|
-
* - Replace text domains based on an array of `old` values to a `new` value.
|
|
26
|
-
*
|
|
27
|
-
* Note: Without a user-defined configuration in a custom ruleset, this sniff will be ignored.
|
|
28
|
-
*
|
|
29
|
-
* @since 1.2.0
|
|
30
|
-
*/
|
|
31
|
-
final class I18nTextDomainFixerSniff extends AbstractFunctionParameterSniff {
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A list of tokenizers this sniff supports.
|
|
35
|
-
*
|
|
36
|
-
* @since 1.2.0
|
|
37
|
-
*
|
|
38
|
-
* @var array
|
|
39
|
-
*/
|
|
40
|
-
public $supportedTokenizers = array(
|
|
41
|
-
'PHP',
|
|
42
|
-
'CSS',
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Old text domain(s) to replace.
|
|
47
|
-
*
|
|
48
|
-
* @since 1.2.0
|
|
49
|
-
*
|
|
50
|
-
* @var string[]
|
|
51
|
-
*/
|
|
52
|
-
public $old_text_domain;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* New text domain.
|
|
56
|
-
*
|
|
57
|
-
* @since 1.2.0
|
|
58
|
-
*
|
|
59
|
-
* @var string
|
|
60
|
-
*/
|
|
61
|
-
public $new_text_domain = '';
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The group name for this group of functions.
|
|
65
|
-
*
|
|
66
|
-
* @since 1.2.0
|
|
67
|
-
*
|
|
68
|
-
* @var string
|
|
69
|
-
*/
|
|
70
|
-
protected $group_name = 'i18nfixer';
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The WP Internationalization related functions to target for the replacements.
|
|
74
|
-
*
|
|
75
|
-
* @since 1.2.0
|
|
76
|
-
* @since 3.0.0 The format of the value has changed from a numerically indexed
|
|
77
|
-
* array containing parameter positions to an array with the parameter
|
|
78
|
-
* position as the index and the parameter name as value.
|
|
79
|
-
*
|
|
80
|
-
* @var array<string, array<string, int|string>> Function name as key, array with target
|
|
81
|
-
* parameter and name as value.
|
|
82
|
-
*/
|
|
83
|
-
protected $target_functions = array(
|
|
84
|
-
'load_textdomain' => array(
|
|
85
|
-
'position' => 1,
|
|
86
|
-
'name' => 'domain',
|
|
87
|
-
),
|
|
88
|
-
'load_plugin_textdomain' => array(
|
|
89
|
-
'position' => 1,
|
|
90
|
-
'name' => 'domain',
|
|
91
|
-
),
|
|
92
|
-
'load_muplugin_textdomain' => array(
|
|
93
|
-
'position' => 1,
|
|
94
|
-
'name' => 'domain',
|
|
95
|
-
),
|
|
96
|
-
'load_theme_textdomain' => array(
|
|
97
|
-
'position' => 1,
|
|
98
|
-
'name' => 'domain',
|
|
99
|
-
),
|
|
100
|
-
'load_child_theme_textdomain' => array(
|
|
101
|
-
'position' => 1,
|
|
102
|
-
'name' => 'domain',
|
|
103
|
-
),
|
|
104
|
-
'load_script_textdomain' => array(
|
|
105
|
-
'position' => 2,
|
|
106
|
-
'name' => 'domain',
|
|
107
|
-
),
|
|
108
|
-
'unload_textdomain' => array(
|
|
109
|
-
'position' => 1,
|
|
110
|
-
'name' => 'domain',
|
|
111
|
-
),
|
|
112
|
-
|
|
113
|
-
'__' => array(
|
|
114
|
-
'position' => 2,
|
|
115
|
-
'name' => 'domain',
|
|
116
|
-
),
|
|
117
|
-
'_e' => array(
|
|
118
|
-
'position' => 2,
|
|
119
|
-
'name' => 'domain',
|
|
120
|
-
),
|
|
121
|
-
'_x' => array(
|
|
122
|
-
'position' => 3,
|
|
123
|
-
'name' => 'domain',
|
|
124
|
-
),
|
|
125
|
-
'_ex' => array(
|
|
126
|
-
'position' => 3,
|
|
127
|
-
'name' => 'domain',
|
|
128
|
-
),
|
|
129
|
-
'_n' => array(
|
|
130
|
-
'position' => 4,
|
|
131
|
-
'name' => 'domain',
|
|
132
|
-
),
|
|
133
|
-
'_nx' => array(
|
|
134
|
-
'position' => 5,
|
|
135
|
-
'name' => 'domain',
|
|
136
|
-
),
|
|
137
|
-
'_n_noop' => array(
|
|
138
|
-
'position' => 3,
|
|
139
|
-
'name' => 'domain',
|
|
140
|
-
),
|
|
141
|
-
'_nx_noop' => array(
|
|
142
|
-
'position' => 4,
|
|
143
|
-
'name' => 'domain',
|
|
144
|
-
),
|
|
145
|
-
'translate_nooped_plural' => array(
|
|
146
|
-
'position' => 3,
|
|
147
|
-
'name' => 'domain',
|
|
148
|
-
),
|
|
149
|
-
|
|
150
|
-
'esc_html__' => array(
|
|
151
|
-
'position' => 2,
|
|
152
|
-
'name' => 'domain',
|
|
153
|
-
),
|
|
154
|
-
'esc_html_e' => array(
|
|
155
|
-
'position' => 2,
|
|
156
|
-
'name' => 'domain',
|
|
157
|
-
),
|
|
158
|
-
'esc_html_x' => array(
|
|
159
|
-
'position' => 3,
|
|
160
|
-
'name' => 'domain',
|
|
161
|
-
),
|
|
162
|
-
'esc_attr__' => array(
|
|
163
|
-
'position' => 2,
|
|
164
|
-
'name' => 'domain',
|
|
165
|
-
),
|
|
166
|
-
'esc_attr_e' => array(
|
|
167
|
-
'position' => 2,
|
|
168
|
-
'name' => 'domain',
|
|
169
|
-
),
|
|
170
|
-
'esc_attr_x' => array(
|
|
171
|
-
'position' => 3,
|
|
172
|
-
'name' => 'domain',
|
|
173
|
-
),
|
|
174
|
-
|
|
175
|
-
'is_textdomain_loaded' => array(
|
|
176
|
-
'position' => 1,
|
|
177
|
-
'name' => 'domain',
|
|
178
|
-
),
|
|
179
|
-
'get_translations_for_domain' => array(
|
|
180
|
-
'position' => 1,
|
|
181
|
-
'name' => 'domain',
|
|
182
|
-
),
|
|
183
|
-
|
|
184
|
-
// Deprecated functions.
|
|
185
|
-
'_c' => array(
|
|
186
|
-
'position' => 2,
|
|
187
|
-
'name' => 'domain',
|
|
188
|
-
),
|
|
189
|
-
'_nc' => array(
|
|
190
|
-
'position' => 4,
|
|
191
|
-
'name' => 'domain',
|
|
192
|
-
),
|
|
193
|
-
'__ngettext' => array(
|
|
194
|
-
'position' => 4,
|
|
195
|
-
'name' => 'domain',
|
|
196
|
-
),
|
|
197
|
-
'__ngettext_noop' => array(
|
|
198
|
-
'position' => 3,
|
|
199
|
-
'name' => 'domain',
|
|
200
|
-
),
|
|
201
|
-
'translate_with_context' => array(
|
|
202
|
-
'position' => 2,
|
|
203
|
-
'name' => 'domain',
|
|
204
|
-
),
|
|
205
|
-
|
|
206
|
-
// Shouldn't be used by plugins/themes.
|
|
207
|
-
'translate' => array(
|
|
208
|
-
'position' => 2,
|
|
209
|
-
'name' => 'domain',
|
|
210
|
-
),
|
|
211
|
-
'translate_with_gettext_context' => array(
|
|
212
|
-
'position' => 3,
|
|
213
|
-
'name' => 'domain',
|
|
214
|
-
),
|
|
215
|
-
|
|
216
|
-
// WP private functions. Shouldn't be used by plugins/themes.
|
|
217
|
-
'_load_textdomain_just_in_time' => array(
|
|
218
|
-
'position' => 1,
|
|
219
|
-
'name' => 'domain',
|
|
220
|
-
),
|
|
221
|
-
'_get_path_to_translation_from_lang_dir' => array(
|
|
222
|
-
'position' => 1,
|
|
223
|
-
'name' => 'domain',
|
|
224
|
-
),
|
|
225
|
-
'_get_path_to_translation' => array(
|
|
226
|
-
'position' => 1,
|
|
227
|
-
'name' => 'domain',
|
|
228
|
-
),
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Whether a valid new text domain was found.
|
|
233
|
-
*
|
|
234
|
-
* @since 1.2.0
|
|
235
|
-
*
|
|
236
|
-
* @var bool
|
|
237
|
-
*/
|
|
238
|
-
private $is_valid = false;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* The new text domain as validated.
|
|
242
|
-
*
|
|
243
|
-
* @since 1.2.0
|
|
244
|
-
*
|
|
245
|
-
* @var string
|
|
246
|
-
*/
|
|
247
|
-
private $validated_textdomain = '';
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Whether the plugin/theme header has been seen and fixed yet.
|
|
251
|
-
*
|
|
252
|
-
* @since 1.2.0
|
|
253
|
-
*
|
|
254
|
-
* @var bool
|
|
255
|
-
*/
|
|
256
|
-
private $header_found = false;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Possible headers for a theme.
|
|
260
|
-
*
|
|
261
|
-
* @link https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/
|
|
262
|
-
*
|
|
263
|
-
* @since 1.2.0
|
|
264
|
-
*
|
|
265
|
-
* @var array<string, bool> Array key is the header name, the value indicated whether it is a
|
|
266
|
-
* required (true) or optional (false) header.
|
|
267
|
-
*/
|
|
268
|
-
private $theme_headers = array(
|
|
269
|
-
'Theme Name' => true,
|
|
270
|
-
'Theme URI' => false,
|
|
271
|
-
'Author' => true,
|
|
272
|
-
'Author URI' => false,
|
|
273
|
-
'Description' => true,
|
|
274
|
-
'Version' => true,
|
|
275
|
-
'Requires at least' => true,
|
|
276
|
-
'Tested up to' => true,
|
|
277
|
-
'Requires PHP' => true,
|
|
278
|
-
'License' => true,
|
|
279
|
-
'License URI' => true,
|
|
280
|
-
'Text Domain' => true,
|
|
281
|
-
'Tags' => false,
|
|
282
|
-
'Domain Path' => false,
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Possible headers for a plugin.
|
|
287
|
-
*
|
|
288
|
-
* @link https://developer.wordpress.org/plugins/plugin-basics/header-requirements/
|
|
289
|
-
*
|
|
290
|
-
* @since 1.2.0
|
|
291
|
-
*
|
|
292
|
-
* @var array<string, bool> Array key is the header name, the value indicated whether it is a
|
|
293
|
-
* required (true) or optional (false) header.
|
|
294
|
-
*/
|
|
295
|
-
private $plugin_headers = array(
|
|
296
|
-
'Plugin Name' => true,
|
|
297
|
-
'Plugin URI' => false,
|
|
298
|
-
'Description' => false,
|
|
299
|
-
'Version' => false,
|
|
300
|
-
'Requires at least' => false,
|
|
301
|
-
'Requires PHP' => false,
|
|
302
|
-
'Author' => false,
|
|
303
|
-
'Author URI' => false,
|
|
304
|
-
'License' => false,
|
|
305
|
-
'License URI' => false,
|
|
306
|
-
'Text Domain' => false,
|
|
307
|
-
'Domain Path' => false,
|
|
308
|
-
'Network' => false,
|
|
309
|
-
'Update URI' => false,
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Regex template to match theme/plugin headers.
|
|
314
|
-
*
|
|
315
|
-
* @since 1.2.0
|
|
316
|
-
*
|
|
317
|
-
* @var string
|
|
318
|
-
*/
|
|
319
|
-
private $header_regex_template = '`^(?:\s*(?:(?:\*|//)\s*)?)?(%s)\s*:\s*([^\r\n]+)`';
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Regex to match theme headers.
|
|
323
|
-
*
|
|
324
|
-
* Set from within the register() method.
|
|
325
|
-
*
|
|
326
|
-
* @since 1.2.0
|
|
327
|
-
*
|
|
328
|
-
* @var string
|
|
329
|
-
*/
|
|
330
|
-
private $theme_header_regex;
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Regex to match plugin headers.
|
|
334
|
-
*
|
|
335
|
-
* Set from within the register() method.
|
|
336
|
-
*
|
|
337
|
-
* @since 1.2.0
|
|
338
|
-
*
|
|
339
|
-
* @var string
|
|
340
|
-
*/
|
|
341
|
-
private $plugin_header_regex;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* The --tab-width CLI value that is being used.
|
|
345
|
-
*
|
|
346
|
-
* @since 1.2.0
|
|
347
|
-
*
|
|
348
|
-
* @var int
|
|
349
|
-
*/
|
|
350
|
-
private $tab_width = null;
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Returns an array of tokens this test wants to listen for.
|
|
354
|
-
*
|
|
355
|
-
* @since 1.2.0
|
|
356
|
-
*
|
|
357
|
-
* @return array
|
|
358
|
-
*/
|
|
359
|
-
public function register() {
|
|
360
|
-
$headers = array_map(
|
|
361
|
-
'preg_quote',
|
|
362
|
-
array_keys( $this->theme_headers ),
|
|
363
|
-
array_fill( 0, \count( $this->theme_headers ), '`' )
|
|
364
|
-
);
|
|
365
|
-
$this->theme_header_regex = sprintf( $this->header_regex_template, implode( '|', $headers ) );
|
|
366
|
-
|
|
367
|
-
$headers = array_map(
|
|
368
|
-
'preg_quote',
|
|
369
|
-
array_keys( $this->plugin_headers ),
|
|
370
|
-
array_fill( 0, \count( $this->plugin_headers ), '`' )
|
|
371
|
-
);
|
|
372
|
-
$this->plugin_header_regex = sprintf( $this->header_regex_template, implode( '|', $headers ) );
|
|
373
|
-
|
|
374
|
-
$targets = parent::register();
|
|
375
|
-
|
|
376
|
-
$targets[] = \T_DOC_COMMENT_OPEN_TAG;
|
|
377
|
-
$targets[] = \T_COMMENT;
|
|
378
|
-
|
|
379
|
-
return $targets;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Processes this test, when one of its tokens is encountered.
|
|
384
|
-
*
|
|
385
|
-
* @since 1.2.0
|
|
386
|
-
*
|
|
387
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
388
|
-
*
|
|
389
|
-
* @return int|void Integer stack pointer to skip forward or void to continue
|
|
390
|
-
* normal file processing.
|
|
391
|
-
*/
|
|
392
|
-
public function process_token( $stackPtr ) {
|
|
393
|
-
// Check if the old/new properties are correctly set. If not, bow out.
|
|
394
|
-
if ( ! is_string( $this->new_text_domain )
|
|
395
|
-
|| '' === $this->new_text_domain
|
|
396
|
-
) {
|
|
397
|
-
return ( $this->phpcsFile->numTokens + 1 );
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if ( isset( $this->old_text_domain ) ) {
|
|
401
|
-
$this->old_text_domain = RulesetPropertyHelper::merge_custom_array( $this->old_text_domain, array(), false );
|
|
402
|
-
|
|
403
|
-
if ( ! is_array( $this->old_text_domain )
|
|
404
|
-
|| array() === $this->old_text_domain
|
|
405
|
-
) {
|
|
406
|
-
return ( $this->phpcsFile->numTokens + 1 );
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Only validate and throw warning about the text domain once.
|
|
411
|
-
if ( $this->new_text_domain !== $this->validated_textdomain ) {
|
|
412
|
-
$this->is_valid = false;
|
|
413
|
-
$this->validated_textdomain = $this->new_text_domain;
|
|
414
|
-
$this->header_found = false;
|
|
415
|
-
|
|
416
|
-
if ( 'default' === $this->new_text_domain ) {
|
|
417
|
-
$this->phpcsFile->addWarning(
|
|
418
|
-
'The "default" text domain is reserved for WordPress core use and should not be used by plugins or themes',
|
|
419
|
-
0,
|
|
420
|
-
'ReservedNewDomain',
|
|
421
|
-
array( $this->new_text_domain )
|
|
422
|
-
);
|
|
423
|
-
|
|
424
|
-
return ( $this->phpcsFile->numTokens + 1 );
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
if ( preg_match( '`^[a-z0-9-]+$`', $this->new_text_domain ) !== 1 ) {
|
|
428
|
-
$this->phpcsFile->addWarning(
|
|
429
|
-
'The text domain should be a simple lowercase text string with words separated by dashes. "%s" appears invalid',
|
|
430
|
-
0,
|
|
431
|
-
'InvalidNewDomain',
|
|
432
|
-
array( $this->new_text_domain )
|
|
433
|
-
);
|
|
434
|
-
|
|
435
|
-
return ( $this->phpcsFile->numTokens + 1 );
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// If the text domain passed both validations, it should be considered valid.
|
|
439
|
-
$this->is_valid = true;
|
|
440
|
-
|
|
441
|
-
} elseif ( false === $this->is_valid ) {
|
|
442
|
-
return ( $this->phpcsFile->numTokens + 1 );
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if ( isset( $this->tab_width ) === false ) {
|
|
446
|
-
$this->tab_width = Helper::getTabWidth( $this->phpcsFile );
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ]['code']
|
|
450
|
-
|| \T_COMMENT === $this->tokens[ $stackPtr ]['code']
|
|
451
|
-
) {
|
|
452
|
-
// Examine for plugin/theme file header.
|
|
453
|
-
return $this->process_comments( $stackPtr );
|
|
454
|
-
|
|
455
|
-
} elseif ( isset( $this->phpcsFile->tokenizerType ) === false || 'CSS' !== $this->phpcsFile->tokenizerType ) {
|
|
456
|
-
// Examine a T_STRING token in a PHP file as a function call.
|
|
457
|
-
return parent::process_token( $stackPtr );
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Process the parameters of a matched function.
|
|
464
|
-
*
|
|
465
|
-
* @since 1.2.0
|
|
466
|
-
*
|
|
467
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
468
|
-
* @param string $group_name The name of the group which was matched.
|
|
469
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
470
|
-
* in lowercase.
|
|
471
|
-
* @param array $parameters Array with information about the parameters.
|
|
472
|
-
*
|
|
473
|
-
* @return void
|
|
474
|
-
*/
|
|
475
|
-
public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
|
|
476
|
-
$target_param_specs = $this->target_functions[ $matched_content ];
|
|
477
|
-
$found_param = PassedParameters::getParameterFromStack( $parameters, $target_param_specs['position'], $target_param_specs['name'] );
|
|
478
|
-
|
|
479
|
-
if ( false === $found_param && 1 !== $target_param_specs['position'] ) {
|
|
480
|
-
$error_msg = 'Missing $domain arg';
|
|
481
|
-
$error_code = 'MissingArgDomain';
|
|
482
|
-
|
|
483
|
-
$has_named_params = false;
|
|
484
|
-
foreach ( $parameters as $param ) {
|
|
485
|
-
if ( isset( $param['name'] ) ) {
|
|
486
|
-
$has_named_params = true;
|
|
487
|
-
break;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
if ( false === $has_named_params && isset( $parameters[ ( $target_param_specs['position'] - 1 ) ] ) ) {
|
|
492
|
-
$fix = $this->phpcsFile->addFixableError( $error_msg, $stackPtr, $error_code );
|
|
493
|
-
|
|
494
|
-
if ( true === $fix ) {
|
|
495
|
-
$start_previous = $parameters[ ( $target_param_specs['position'] - 1 ) ]['start'];
|
|
496
|
-
$end_previous = $parameters[ ( $target_param_specs['position'] - 1 ) ]['end'];
|
|
497
|
-
if ( \T_WHITESPACE === $this->tokens[ $start_previous ]['code']
|
|
498
|
-
&& $this->tokens[ $start_previous ]['content'] === $this->phpcsFile->eolChar
|
|
499
|
-
) {
|
|
500
|
-
// Replicate the new line + indentation of the previous item.
|
|
501
|
-
$replacement = ',';
|
|
502
|
-
for ( $i = $start_previous; $i <= $end_previous; $i++ ) {
|
|
503
|
-
if ( \T_WHITESPACE !== $this->tokens[ $i ]['code'] ) {
|
|
504
|
-
break;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
|
|
508
|
-
$replacement .= $this->tokens[ $i ]['orig_content'];
|
|
509
|
-
} else {
|
|
510
|
-
$replacement .= $this->tokens[ $i ]['content'];
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
$replacement .= "'{$this->new_text_domain}'";
|
|
515
|
-
} else {
|
|
516
|
-
$replacement = ", '{$this->new_text_domain}'";
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
if ( \T_WHITESPACE === $this->tokens[ $end_previous ]['code'] ) {
|
|
520
|
-
$this->phpcsFile->fixer->addContentBefore( $end_previous, $replacement );
|
|
521
|
-
} else {
|
|
522
|
-
$this->phpcsFile->fixer->addContent( $end_previous, $replacement );
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
} elseif ( true === $has_named_params ) {
|
|
526
|
-
/*
|
|
527
|
-
* Function call using named arguments. For now, we will not auto-fix this.
|
|
528
|
-
*
|
|
529
|
-
* {@internal If we don't bother with indentation and such, this can be made
|
|
530
|
-
* auto-fixable by getting the 'end' of the last seen parameter and adding the
|
|
531
|
-
* domain parameter, with the 'domain: ' parameter label, after the last
|
|
532
|
-
* seen parameter.}
|
|
533
|
-
*/
|
|
534
|
-
$this->phpcsFile->addError( $error_msg, $stackPtr, $error_code );
|
|
535
|
-
} else {
|
|
536
|
-
$error_msg .= ' and preceding argument(s)';
|
|
537
|
-
$error_code = 'MissingArgs';
|
|
538
|
-
|
|
539
|
-
// Expected preceeding param also missing, just throw the warning.
|
|
540
|
-
$this->phpcsFile->addWarning( $error_msg, $stackPtr, $error_code );
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// Target parameter found. Let's examine it.
|
|
547
|
-
$domain_param_start = $found_param['start'];
|
|
548
|
-
$domain_param_end = $found_param['end'];
|
|
549
|
-
$domain_token = null;
|
|
550
|
-
|
|
551
|
-
for ( $i = $domain_param_start; $i <= $domain_param_end; $i++ ) {
|
|
552
|
-
if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
|
553
|
-
continue;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
if ( \T_CONSTANT_ENCAPSED_STRING !== $this->tokens[ $i ]['code'] ) {
|
|
557
|
-
// Unexpected token found, not our concern. This is handled by the I18n sniff.
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
if ( isset( $domain_token ) ) {
|
|
562
|
-
// More than one T_CONSTANT_ENCAPSED_STRING found, not our concern. This is handled by the I18n sniff.
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
$domain_token = $i;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// If we're still here, this means only one T_CONSTANT_ENCAPSED_STRING was found.
|
|
570
|
-
$old_domain = TextStrings::stripQuotes( $this->tokens[ $domain_token ]['content'] );
|
|
571
|
-
|
|
572
|
-
if ( ! \in_array( $old_domain, $this->old_text_domain, true ) ) {
|
|
573
|
-
// Not a text domain targetted for replacement, ignore.
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
$fix = $this->phpcsFile->addFixableError(
|
|
578
|
-
'Mismatched text domain. Expected \'%s\' but found \'%s\'',
|
|
579
|
-
$domain_token,
|
|
580
|
-
'TextDomainMismatch',
|
|
581
|
-
array( $this->new_text_domain, $old_domain )
|
|
582
|
-
);
|
|
583
|
-
|
|
584
|
-
if ( true === $fix ) {
|
|
585
|
-
$replacement = str_replace( $old_domain, $this->new_text_domain, $this->tokens[ $domain_token ]['content'] );
|
|
586
|
-
$this->phpcsFile->fixer->replaceToken( $domain_token, $replacement );
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* Process the function if no parameters were found.
|
|
592
|
-
*
|
|
593
|
-
* @since 1.2.0
|
|
594
|
-
*
|
|
595
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
596
|
-
* @param string $group_name The name of the group which was matched.
|
|
597
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
598
|
-
* in lowercase.
|
|
599
|
-
*
|
|
600
|
-
* @return void
|
|
601
|
-
*/
|
|
602
|
-
public function process_no_parameters( $stackPtr, $group_name, $matched_content ) {
|
|
603
|
-
$target_param = $this->target_functions[ $matched_content ];
|
|
604
|
-
|
|
605
|
-
if ( 1 !== $target_param['position'] ) {
|
|
606
|
-
// Only process the no param case as fixable if the text domain is expected to be the first parameter.
|
|
607
|
-
$this->phpcsFile->addWarning( 'Missing $domain arg and preceding argument(s)', $stackPtr, 'MissingArgs' );
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
$opener = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
|
|
612
|
-
if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $opener ]['code']
|
|
613
|
-
|| isset( $this->tokens[ $opener ]['parenthesis_closer'] ) === false
|
|
614
|
-
) {
|
|
615
|
-
// Parse error or live coding.
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
$fix = $this->phpcsFile->addFixableError( 'Missing $domain arg', $stackPtr, 'MissingArgDomain' );
|
|
620
|
-
if ( true === $fix ) {
|
|
621
|
-
$closer = $this->tokens[ $opener ]['parenthesis_closer'];
|
|
622
|
-
$replacement = " '{$this->new_text_domain}' ";
|
|
623
|
-
|
|
624
|
-
if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) {
|
|
625
|
-
$replacement = trim( $replacement );
|
|
626
|
-
$addBefore = ( $closer - 1 );
|
|
627
|
-
if ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
|
|
628
|
-
&& $this->tokens[ $closer - 1 ]['line'] === $this->tokens[ $closer ]['line']
|
|
629
|
-
) {
|
|
630
|
-
if ( isset( $this->tokens[ ( $closer - 1 ) ]['orig_content'] ) ) {
|
|
631
|
-
$replacement = $this->tokens[ ( $closer - 1 ) ]['orig_content']
|
|
632
|
-
. "\t"
|
|
633
|
-
. $replacement;
|
|
634
|
-
} else {
|
|
635
|
-
$replacement = $this->tokens[ ( $closer - 1 ) ]['content']
|
|
636
|
-
. str_repeat( ' ', $this->tab_width )
|
|
637
|
-
. $replacement;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
--$addBefore;
|
|
641
|
-
} else {
|
|
642
|
-
// We don't know whether the code uses tabs or spaces, so presume WPCS, i.e. tabs.
|
|
643
|
-
$replacement = "\t" . $replacement;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
$replacement = $this->phpcsFile->eolChar . $replacement;
|
|
647
|
-
|
|
648
|
-
$this->phpcsFile->fixer->addContentBefore( $addBefore, $replacement );
|
|
649
|
-
|
|
650
|
-
} elseif ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code'] ) {
|
|
651
|
-
$this->phpcsFile->fixer->replaceToken( ( $closer - 1 ), $replacement );
|
|
652
|
-
} else {
|
|
653
|
-
$this->phpcsFile->fixer->addContentBefore( $closer, $replacement );
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Process comments to find the plugin/theme headers.
|
|
661
|
-
*
|
|
662
|
-
* @since 1.2.0
|
|
663
|
-
*
|
|
664
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
665
|
-
*
|
|
666
|
-
* @return int|void Integer stack pointer to skip forward or void to continue
|
|
667
|
-
* normal file processing.
|
|
668
|
-
*/
|
|
669
|
-
public function process_comments( $stackPtr ) {
|
|
670
|
-
if ( true === $this->header_found && ! defined( 'PHP_CODESNIFFER_IN_TESTS' ) ) {
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
$regex = $this->plugin_header_regex;
|
|
675
|
-
$headers = $this->plugin_headers;
|
|
676
|
-
$type = 'plugin';
|
|
677
|
-
$skip_to = $stackPtr;
|
|
678
|
-
|
|
679
|
-
$file = TextStrings::stripQuotes( $this->phpcsFile->getFileName() );
|
|
680
|
-
if ( 'STDIN' === $file ) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
$file_name = basename( $file );
|
|
685
|
-
if ( isset( $this->phpcsFile->tokenizerType ) && 'CSS' === $this->phpcsFile->tokenizerType ) {
|
|
686
|
-
if ( 'style.css' !== $file_name && ! defined( 'PHP_CODESNIFFER_IN_TESTS' ) ) {
|
|
687
|
-
// CSS files only need to be examined for the file header.
|
|
688
|
-
return ( $this->phpcsFile->numTokens + 1 );
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
$regex = $this->theme_header_regex;
|
|
692
|
-
$headers = $this->theme_headers;
|
|
693
|
-
$type = 'theme';
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
$comment_details = array(
|
|
697
|
-
'required_header_found' => false,
|
|
698
|
-
'headers_found' => 0,
|
|
699
|
-
'text_domain_ptr' => false,
|
|
700
|
-
'text_domain_found' => '',
|
|
701
|
-
'last_header_ptr' => false,
|
|
702
|
-
'last_header_matches' => array(),
|
|
703
|
-
);
|
|
704
|
-
|
|
705
|
-
if ( \T_COMMENT === $this->tokens[ $stackPtr ]['code'] ) {
|
|
706
|
-
$block_comment = false;
|
|
707
|
-
if ( substr( $this->tokens[ $stackPtr ]['content'], 0, 2 ) === '/*' ) {
|
|
708
|
-
$block_comment = true;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
$current = $stackPtr;
|
|
712
|
-
do {
|
|
713
|
-
if ( false === $comment_details['text_domain_ptr']
|
|
714
|
-
|| false === $comment_details['required_header_found']
|
|
715
|
-
|| $comment_details['headers_found'] < 3
|
|
716
|
-
) {
|
|
717
|
-
$comment_details = $this->examine_comment_line( $current, $regex, $headers, $comment_details );
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
if ( true === $block_comment && substr( $this->tokens[ $current ]['content'], -2 ) === '*/' ) {
|
|
721
|
-
++$current;
|
|
722
|
-
break;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
++$current;
|
|
726
|
-
} while ( isset( $this->tokens[ $current ] ) && \T_COMMENT === $this->tokens[ $current ]['code'] );
|
|
727
|
-
|
|
728
|
-
$skip_to = $current;
|
|
729
|
-
|
|
730
|
-
} else {
|
|
731
|
-
if ( ! isset( $this->tokens[ $stackPtr ]['comment_closer'] ) ) {
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
$closer = $this->tokens[ $stackPtr ]['comment_closer'];
|
|
736
|
-
$current = $stackPtr;
|
|
737
|
-
|
|
738
|
-
while ( ( $current = $this->phpcsFile->findNext( \T_DOC_COMMENT_STRING, ( $current + 1 ), $closer ) ) !== false ) {
|
|
739
|
-
$comment_details = $this->examine_comment_line( $current, $regex, $headers, $comment_details );
|
|
740
|
-
|
|
741
|
-
if ( false !== $comment_details['text_domain_ptr']
|
|
742
|
-
&& true === $comment_details['required_header_found']
|
|
743
|
-
&& $comment_details['headers_found'] >= 3
|
|
744
|
-
) {
|
|
745
|
-
// No need to look at the rest of the docblock.
|
|
746
|
-
break;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
$skip_to = $closer;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
// So, was this the plugin/theme header ?
|
|
754
|
-
if ( true === $comment_details['required_header_found']
|
|
755
|
-
&& $comment_details['headers_found'] >= 3
|
|
756
|
-
) {
|
|
757
|
-
$this->header_found = true;
|
|
758
|
-
|
|
759
|
-
$text_domain_ptr = $comment_details['text_domain_ptr'];
|
|
760
|
-
$text_domain_found = $comment_details['text_domain_found'];
|
|
761
|
-
|
|
762
|
-
if ( false !== $text_domain_ptr ) {
|
|
763
|
-
if ( $this->new_text_domain !== $text_domain_found
|
|
764
|
-
&& ( \in_array( $text_domain_found, $this->old_text_domain, true ) )
|
|
765
|
-
) {
|
|
766
|
-
$fix = $this->phpcsFile->addFixableError(
|
|
767
|
-
'Mismatched text domain in %s header. Expected \'%s\' but found \'%s\'',
|
|
768
|
-
$text_domain_ptr,
|
|
769
|
-
'TextDomainHeaderMismatch',
|
|
770
|
-
array(
|
|
771
|
-
$type,
|
|
772
|
-
$this->new_text_domain,
|
|
773
|
-
$text_domain_found,
|
|
774
|
-
)
|
|
775
|
-
);
|
|
776
|
-
|
|
777
|
-
if ( true === $fix ) {
|
|
778
|
-
if ( isset( $this->tokens[ $text_domain_ptr ]['orig_content'] ) ) {
|
|
779
|
-
$replacement = $this->tokens[ $text_domain_ptr ]['orig_content'];
|
|
780
|
-
} else {
|
|
781
|
-
$replacement = $this->tokens[ $text_domain_ptr ]['content'];
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
$replacement = str_replace( $text_domain_found, $this->new_text_domain, $replacement );
|
|
785
|
-
|
|
786
|
-
$this->phpcsFile->fixer->replaceToken( $text_domain_ptr, $replacement );
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
} else {
|
|
790
|
-
$last_header_ptr = $comment_details['last_header_ptr'];
|
|
791
|
-
$last_header_matches = $comment_details['last_header_matches'];
|
|
792
|
-
|
|
793
|
-
$fix = $this->phpcsFile->addFixableError(
|
|
794
|
-
'Missing "Text Domain" in %s header',
|
|
795
|
-
$last_header_ptr,
|
|
796
|
-
'MissingTextDomainHeader',
|
|
797
|
-
array( $type )
|
|
798
|
-
);
|
|
799
|
-
|
|
800
|
-
if ( true === $fix ) {
|
|
801
|
-
if ( isset( $this->tokens[ $last_header_ptr ]['orig_content'] ) ) {
|
|
802
|
-
$replacement = $this->tokens[ $last_header_ptr ]['orig_content'];
|
|
803
|
-
} else {
|
|
804
|
-
$replacement = $this->tokens[ $last_header_ptr ]['content'];
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
$replacement = str_replace( $last_header_matches[1], 'Text Domain', $replacement );
|
|
808
|
-
$replacement = str_replace( $last_header_matches[2], $this->new_text_domain, $replacement );
|
|
809
|
-
|
|
810
|
-
if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ]['code'] ) {
|
|
811
|
-
for ( $i = ( $last_header_ptr - 1 ); ; $i-- ) {
|
|
812
|
-
if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $last_header_ptr ]['line'] ) {
|
|
813
|
-
++$i;
|
|
814
|
-
break;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
$replacement = $this->phpcsFile->eolChar
|
|
819
|
-
. GetTokensAsString::origContent( $this->phpcsFile, $i, ( $last_header_ptr - 1 ) )
|
|
820
|
-
. $replacement;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
$this->phpcsFile->fixer->addContent( $comment_details['last_header_ptr'], $replacement );
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
return $skip_to;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Examine an individual token in a larger comment for plugin/theme headers.
|
|
833
|
-
*
|
|
834
|
-
* @since 1.2.0
|
|
835
|
-
*
|
|
836
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
837
|
-
* @param string $regex The regex to use to examine the comment line.
|
|
838
|
-
* @param array $headers Valid headers for a plugin or theme.
|
|
839
|
-
* @param array $comment_details The information collected so far.
|
|
840
|
-
*
|
|
841
|
-
* @return array Adjusted $comment_details array
|
|
842
|
-
*/
|
|
843
|
-
protected function examine_comment_line( $stackPtr, $regex, $headers, $comment_details ) {
|
|
844
|
-
if ( preg_match( $regex, $this->tokens[ $stackPtr ]['content'], $matches ) === 1 ) {
|
|
845
|
-
++$comment_details['headers_found'];
|
|
846
|
-
|
|
847
|
-
if ( true === $headers[ $matches[1] ] ) {
|
|
848
|
-
$comment_details['required_header_found'] = true;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
if ( 'Text Domain' === $matches[1] ) {
|
|
852
|
-
$comment_details['text_domain_ptr'] = $stackPtr;
|
|
853
|
-
$comment_details['text_domain_found'] = trim( $matches[2] );
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
$comment_details['last_header_ptr'] = $stackPtr;
|
|
857
|
-
$comment_details['last_header_matches'] = $matches;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
return $comment_details;
|
|
861
|
-
}
|
|
862
|
-
}
|