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
package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php
DELETED
|
@@ -1,761 +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\DB;
|
|
11
|
-
|
|
12
|
-
use PHP_CodeSniffer\Util\Tokens;
|
|
13
|
-
use PHPCSUtils\Tokens\Collections;
|
|
14
|
-
use PHPCSUtils\Utils\Arrays;
|
|
15
|
-
use PHPCSUtils\Utils\PassedParameters;
|
|
16
|
-
use PHPCSUtils\Utils\TextStrings;
|
|
17
|
-
use WordPressCS\WordPress\Helpers\MinimumWPVersionTrait;
|
|
18
|
-
use WordPressCS\WordPress\Helpers\WPDBTrait;
|
|
19
|
-
use WordPressCS\WordPress\Sniff;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Checks for incorrect use of the $wpdb->prepare method.
|
|
23
|
-
*
|
|
24
|
-
* Checks the following issues:
|
|
25
|
-
* - The only placeholders supported are: %d, %f (%F), %s, %i, and their variations.
|
|
26
|
-
* - Literal % signs need to be properly escaped as `%%`.
|
|
27
|
-
* - Simple placeholders (%d, %f, %F, %s, %i) should be left unquoted in the query string.
|
|
28
|
-
* - Complex placeholders - numbered and formatted variants - will not be quoted
|
|
29
|
-
* automagically by $wpdb->prepare(), so if used for values, should be quoted in
|
|
30
|
-
* the query string.
|
|
31
|
-
* The only exception to this is complex placeholders for %i. In that case, the
|
|
32
|
-
* replacement *will* still be backtick-quoted.
|
|
33
|
-
* - Either an array of replacements should be passed matching the number of
|
|
34
|
-
* placeholders found or individual parameters for each placeholder should
|
|
35
|
-
* be passed.
|
|
36
|
-
* - Wildcards for LIKE compare values should be passed in via a replacement parameter.
|
|
37
|
-
*
|
|
38
|
-
* The sniff allows for a specific pattern with a variable number of placeholders
|
|
39
|
-
* created using code along the lines of:
|
|
40
|
-
* `sprintf( 'query .... IN (%s) ...', implode( ',', array_fill( 0, count( $something ), '%s' ) ) )`.
|
|
41
|
-
*
|
|
42
|
-
* @link https://developer.wordpress.org/reference/classes/wpdb/prepare/
|
|
43
|
-
* @link https://core.trac.wordpress.org/changeset/41496
|
|
44
|
-
* @link https://core.trac.wordpress.org/changeset/41471
|
|
45
|
-
* @link https://core.trac.wordpress.org/changeset/55151
|
|
46
|
-
*
|
|
47
|
-
* @since 0.14.0
|
|
48
|
-
* @since 3.0.0 Support for the %i placeholder has been added
|
|
49
|
-
*
|
|
50
|
-
* @uses \WordPressCS\WordPress\Helpers\MinimumWPVersionTrait::$minimum_wp_version
|
|
51
|
-
*/
|
|
52
|
-
final class PreparedSQLPlaceholdersSniff extends Sniff {
|
|
53
|
-
|
|
54
|
-
use MinimumWPVersionTrait;
|
|
55
|
-
use WPDBTrait;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* These regexes were originally copied from https://www.php.net/function.sprintf#93552
|
|
59
|
-
* and adjusted for limitations in `$wpdb->prepare()`.
|
|
60
|
-
*
|
|
61
|
-
* Near duplicate of the one used in the WP.I18n sniff, but with fewer types allowed.
|
|
62
|
-
*
|
|
63
|
-
* Note: The regex delimiters and modifiers are not included to allow this regex to be
|
|
64
|
-
* concatenated together with other regex partials.
|
|
65
|
-
*
|
|
66
|
-
* @since 0.14.0
|
|
67
|
-
*
|
|
68
|
-
* @var string
|
|
69
|
-
*/
|
|
70
|
-
const PREPARE_PLACEHOLDER_REGEX = '(?:
|
|
71
|
-
(?<![^%]%) # Don\'t match a literal % (%%), including when it could overlap with a placeholder.
|
|
72
|
-
(?:
|
|
73
|
-
% # Start of placeholder.
|
|
74
|
-
(?:[0-9]+\\\\?\$)? # Optional ordering of the placeholders.
|
|
75
|
-
[+-]? # Optional sign specifier.
|
|
76
|
-
(?:
|
|
77
|
-
(?:0|\'.)? # Optional padding specifier - excluding the space.
|
|
78
|
-
-? # Optional alignment specifier.
|
|
79
|
-
[0-9]* # Optional width specifier.
|
|
80
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
|
|
81
|
-
| # Only recognize the space as padding in combination with a width specifier.
|
|
82
|
-
(?:[ ])? # Optional space padding specifier.
|
|
83
|
-
-? # Optional alignment specifier.
|
|
84
|
-
[0-9]+ # Width specifier.
|
|
85
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
|
|
86
|
-
)
|
|
87
|
-
[dfFsi] # Type specifier.
|
|
88
|
-
)
|
|
89
|
-
)';
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Similar to above, but for the placeholder types *not* supported.
|
|
93
|
-
*
|
|
94
|
-
* Note: all optional parts are forced to be greedy to allow for the negative look ahead
|
|
95
|
-
* at the end to work.
|
|
96
|
-
*
|
|
97
|
-
* @since 0.14.0
|
|
98
|
-
*
|
|
99
|
-
* @var string
|
|
100
|
-
*/
|
|
101
|
-
const UNSUPPORTED_PLACEHOLDER_REGEX = '`(?:
|
|
102
|
-
(?<!%) # Don\'t match a literal % (%%).
|
|
103
|
-
(
|
|
104
|
-
% # Start of placeholder.
|
|
105
|
-
(?! # Negative look ahead.
|
|
106
|
-
%[^%] # Not a correct literal % (%%).
|
|
107
|
-
|
|
|
108
|
-
%%[dfFsi] # Nor a correct literal % (%%), followed by a simple placeholder.
|
|
109
|
-
)
|
|
110
|
-
(?:[0-9]+\\\\??\$)?+ # Optional ordering of the placeholders.
|
|
111
|
-
[+-]?+ # Optional sign specifier.
|
|
112
|
-
(?:
|
|
113
|
-
(?:0|\'.)?+ # Optional padding specifier - excluding the space.
|
|
114
|
-
-?+ # Optional alignment specifier.
|
|
115
|
-
[0-9]*+ # Optional width specifier.
|
|
116
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)?+ # Optional precision specifier with optional padding character.
|
|
117
|
-
| # Only recognize the space as padding in combination with a width specifier.
|
|
118
|
-
(?:[ ])?+ # Optional space padding specifier.
|
|
119
|
-
-?+ # Optional alignment specifier.
|
|
120
|
-
[0-9]++ # Width specifier.
|
|
121
|
-
(?:\.(?:[ 0]|\'.)?[0-9]+)?+ # Optional precision specifier with optional padding character.
|
|
122
|
-
)
|
|
123
|
-
(?![dfFsi]) # Negative look ahead: not one of the supported placeholders.
|
|
124
|
-
(?:[^ \'"]*|$) # but something else instead.
|
|
125
|
-
)
|
|
126
|
-
)`x';
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* List of $wpdb methods we are interested in.
|
|
130
|
-
*
|
|
131
|
-
* @since 0.14.0
|
|
132
|
-
*
|
|
133
|
-
* @var array
|
|
134
|
-
*/
|
|
135
|
-
protected $target_methods = array(
|
|
136
|
-
'prepare' => true,
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Storage for the stack pointer to the method call token.
|
|
141
|
-
*
|
|
142
|
-
* @since 0.14.0
|
|
143
|
-
*
|
|
144
|
-
* @var int
|
|
145
|
-
*/
|
|
146
|
-
protected $methodPtr;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Simple regex snippet to recognize and remember quotes.
|
|
150
|
-
*
|
|
151
|
-
* @since 0.14.0
|
|
152
|
-
*
|
|
153
|
-
* @var string
|
|
154
|
-
*/
|
|
155
|
-
private $regex_quote = '["\']';
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Returns an array of tokens this test wants to listen for.
|
|
159
|
-
*
|
|
160
|
-
* @since 0.14.0
|
|
161
|
-
*
|
|
162
|
-
* @return array
|
|
163
|
-
*/
|
|
164
|
-
public function register() {
|
|
165
|
-
return array(
|
|
166
|
-
\T_VARIABLE,
|
|
167
|
-
\T_STRING,
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Processes this test, when one of its tokens is encountered.
|
|
173
|
-
*
|
|
174
|
-
* @since 0.14.0
|
|
175
|
-
*
|
|
176
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
177
|
-
*
|
|
178
|
-
* @return void
|
|
179
|
-
*/
|
|
180
|
-
public function process_token( $stackPtr ) {
|
|
181
|
-
|
|
182
|
-
$this->set_minimum_wp_version();
|
|
183
|
-
|
|
184
|
-
if ( ! $this->is_wpdb_method_call( $this->phpcsFile, $stackPtr, $this->target_methods ) ) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
$parameters = PassedParameters::getParameters( $this->phpcsFile, $this->methodPtr );
|
|
189
|
-
if ( empty( $parameters ) ) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
$query = PassedParameters::getParameterFromStack( $parameters, 1, 'query' );
|
|
194
|
-
if ( false === $query ) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
$text_string_tokens_found = false;
|
|
199
|
-
$variable_found = false;
|
|
200
|
-
$sql_wildcard_found = false;
|
|
201
|
-
$total_placeholders = 0;
|
|
202
|
-
$total_parameters = \count( $parameters );
|
|
203
|
-
$valid_in_clauses = array(
|
|
204
|
-
'uses_in' => 0,
|
|
205
|
-
'implode_fill' => 0,
|
|
206
|
-
'adjustment_count' => 0,
|
|
207
|
-
);
|
|
208
|
-
$skip_from = null;
|
|
209
|
-
$skip_to = null;
|
|
210
|
-
|
|
211
|
-
for ( $i = $query['start']; $i <= $query['end']; $i++ ) {
|
|
212
|
-
// Skip over groups of tokens if they are part of an inline function call.
|
|
213
|
-
if ( isset( $skip_from, $skip_to ) && $i >= $skip_from && $i <= $skip_to ) {
|
|
214
|
-
$i = $skip_to;
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
|
219
|
-
if ( \T_VARIABLE === $this->tokens[ $i ]['code'] ) {
|
|
220
|
-
if ( '$wpdb' !== $this->tokens[ $i ]['content'] ) {
|
|
221
|
-
$variable_found = true;
|
|
222
|
-
}
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Detect a specific pattern for variable replacements in combination with `IN`.
|
|
227
|
-
if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
|
|
228
|
-
|
|
229
|
-
if ( 'sprintf' === strtolower( $this->tokens[ $i ]['content'] ) ) {
|
|
230
|
-
$sprintf_parameters = PassedParameters::getParameters( $this->phpcsFile, $i );
|
|
231
|
-
|
|
232
|
-
if ( ! empty( $sprintf_parameters ) ) {
|
|
233
|
-
/*
|
|
234
|
-
* Check for named params. sprintf() does not support this due to its variadic nature,
|
|
235
|
-
* and we cannot analyse the code correctly if it is used, so skip the whole sprintf()
|
|
236
|
-
* in that case.
|
|
237
|
-
*/
|
|
238
|
-
$valid_sprintf = true;
|
|
239
|
-
foreach ( $sprintf_parameters as $param ) {
|
|
240
|
-
if ( isset( $param['name'] ) ) {
|
|
241
|
-
$valid_sprintf = false;
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if ( false === $valid_sprintf ) {
|
|
247
|
-
$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
|
|
248
|
-
if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
|
|
249
|
-
&& isset( $this->tokens[ $next ]['parenthesis_closer'] )
|
|
250
|
-
) {
|
|
251
|
-
$skip_from = ( $i + 1 );
|
|
252
|
-
$skip_to = $this->tokens[ $next ]['parenthesis_closer'];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// We know for sure this sprintf() uses positional parameters, so this will be fine.
|
|
259
|
-
$skip_from = ( $sprintf_parameters[1]['end'] + 1 );
|
|
260
|
-
$last_param = end( $sprintf_parameters );
|
|
261
|
-
$skip_to = ( $last_param['end'] + 1 );
|
|
262
|
-
|
|
263
|
-
$valid_in_clauses['implode_fill'] += $this->analyse_sprintf( $sprintf_parameters );
|
|
264
|
-
$valid_in_clauses['adjustment_count'] += ( \count( $sprintf_parameters ) - 1 );
|
|
265
|
-
}
|
|
266
|
-
unset( $sprintf_parameters, $valid_sprintf, $last_param );
|
|
267
|
-
|
|
268
|
-
} elseif ( 'implode' === strtolower( $this->tokens[ $i ]['content'] ) ) {
|
|
269
|
-
$prev = $this->phpcsFile->findPrevious(
|
|
270
|
-
Tokens::$emptyTokens + array( \T_STRING_CONCAT => \T_STRING_CONCAT ),
|
|
271
|
-
( $i - 1 ),
|
|
272
|
-
$query['start'],
|
|
273
|
-
true
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
if ( isset( Tokens::$textStringTokens[ $this->tokens[ $prev ]['code'] ] ) ) {
|
|
277
|
-
$prev_content = TextStrings::stripQuotes( $this->tokens[ $prev ]['content'] );
|
|
278
|
-
$regex_quote = $this->get_regex_quote_snippet( $prev_content, $this->tokens[ $prev ]['content'] );
|
|
279
|
-
|
|
280
|
-
// Only examine the implode if preceded by an ` IN (`.
|
|
281
|
-
if ( preg_match( '`\s+IN\s*\(\s*(' . $regex_quote . ')?$`i', $prev_content, $match ) > 0 ) {
|
|
282
|
-
|
|
283
|
-
if ( isset( $match[1] ) && $regex_quote !== $this->regex_quote ) {
|
|
284
|
-
$this->phpcsFile->addError(
|
|
285
|
-
'Dynamic placeholder generation should not have surrounding quotes.',
|
|
286
|
-
$prev,
|
|
287
|
-
'QuotedDynamicPlaceholderGeneration'
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if ( $this->analyse_implode( $i ) === true ) {
|
|
292
|
-
++$valid_in_clauses['uses_in'];
|
|
293
|
-
++$valid_in_clauses['implode_fill'];
|
|
294
|
-
|
|
295
|
-
$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
|
|
296
|
-
if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
|
|
297
|
-
&& isset( $this->tokens[ $next ]['parenthesis_closer'] )
|
|
298
|
-
) {
|
|
299
|
-
$skip_from = ( $i + 1 );
|
|
300
|
-
$skip_to = $this->tokens[ $next ]['parenthesis_closer'];
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
unset( $next, $prev_content, $regex_quote, $match );
|
|
305
|
-
}
|
|
306
|
-
unset( $prev );
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
$text_string_tokens_found = true;
|
|
314
|
-
$content = $this->tokens[ $i ]['content'];
|
|
315
|
-
|
|
316
|
-
$regex_quote = $this->regex_quote;
|
|
317
|
-
if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
|
318
|
-
$content = TextStrings::stripQuotes( $content );
|
|
319
|
-
$regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ]['content'] );
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code']
|
|
323
|
-
|| \T_HEREDOC === $this->tokens[ $i ]['code']
|
|
324
|
-
) {
|
|
325
|
-
// Only interested in actual query text, so strip out variables.
|
|
326
|
-
$stripped_content = TextStrings::stripEmbeds( $content );
|
|
327
|
-
if ( $stripped_content !== $content ) {
|
|
328
|
-
$vars_without_wpdb = array_filter(
|
|
329
|
-
TextStrings::getEmbeds( $content ),
|
|
330
|
-
static function ( $symbol ) {
|
|
331
|
-
return preg_match( '`^\{?\$\{?wpdb\??->`', $symbol ) !== 1;
|
|
332
|
-
}
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
$content = $stripped_content;
|
|
336
|
-
|
|
337
|
-
if ( ! empty( $vars_without_wpdb ) ) {
|
|
338
|
-
$variable_found = true;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
unset( $stripped_content, $vars_without_wpdb );
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
$placeholders = preg_match_all( '`' . self::PREPARE_PLACEHOLDER_REGEX . '`x', $content, $matches );
|
|
345
|
-
if ( $placeholders > 0 ) {
|
|
346
|
-
$total_placeholders += $placeholders;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/*
|
|
350
|
-
* Analyse the query for incorrect LIKE queries.
|
|
351
|
-
*
|
|
352
|
-
* - `LIKE %s` is the only correct one.
|
|
353
|
-
* - `LIKE '%s'` or `LIKE "%s"` will not be reported here, but in the quote check.
|
|
354
|
-
* - Any other `LIKE` statement should be reported, either for using `LIKE` without
|
|
355
|
-
* SQL wildcards or for not passing the SQL wildcards via the replacement.
|
|
356
|
-
*/
|
|
357
|
-
$regex = '`\s+LIKE\s*(?:(' . $regex_quote . ')(?!%s(?:\1|$))(?P<content>.*?)(?:\1|$)|(?:concat\((?![^\)]*%s[^\)]*\))(?P<concat>[^\)]*))\))`i';
|
|
358
|
-
if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
|
|
359
|
-
$walk = array();
|
|
360
|
-
if ( ! empty( $matches['content'] ) ) {
|
|
361
|
-
$matches['content'] = array_filter( $matches['content'] );
|
|
362
|
-
if ( ! empty( $matches['content'] ) ) {
|
|
363
|
-
$walk[] = 'content';
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if ( ! empty( $matches['concat'] ) ) {
|
|
367
|
-
$matches['concat'] = array_filter( $matches['concat'] );
|
|
368
|
-
if ( ! empty( $matches['concat'] ) ) {
|
|
369
|
-
$walk[] = 'concat';
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if ( ! empty( $walk ) ) {
|
|
374
|
-
foreach ( $walk as $match_key ) {
|
|
375
|
-
foreach ( $matches[ $match_key ] as $index => $match ) {
|
|
376
|
-
$data = array( $matches[0][ $index ] );
|
|
377
|
-
|
|
378
|
-
// Both a `%` as well as a `_` are wildcards in SQL.
|
|
379
|
-
if ( strpos( $match, '%' ) === false && strpos( $match, '_' ) === false ) {
|
|
380
|
-
$this->phpcsFile->addWarning(
|
|
381
|
-
'Unless you are using SQL wildcards, using LIKE is inefficient. Use a straight compare instead. Found: %s.',
|
|
382
|
-
$i,
|
|
383
|
-
'LikeWithoutWildcards',
|
|
384
|
-
$data
|
|
385
|
-
);
|
|
386
|
-
} else {
|
|
387
|
-
$sql_wildcard_found = true;
|
|
388
|
-
|
|
389
|
-
if ( strpos( $match, '%s' ) === false ) {
|
|
390
|
-
$this->phpcsFile->addError(
|
|
391
|
-
'SQL wildcards for a LIKE query should be passed in through a replacement parameter. Found: %s.',
|
|
392
|
-
$i,
|
|
393
|
-
'LikeWildcardsInQuery',
|
|
394
|
-
$data
|
|
395
|
-
);
|
|
396
|
-
} else {
|
|
397
|
-
$this->phpcsFile->addError(
|
|
398
|
-
'SQL wildcards for a LIKE query should be passed in through a replacement parameter and the variable part of the replacement should be escaped using "esc_like()". Found: %s.',
|
|
399
|
-
$i,
|
|
400
|
-
'LikeWildcardsInQueryWithPlaceholder',
|
|
401
|
-
$data
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/*
|
|
407
|
-
* Don't throw `UnescapedLiteral`, `UnsupportedPlaceholder` or `QuotedPlaceholder`
|
|
408
|
-
* for this part of the SQL query.
|
|
409
|
-
*/
|
|
410
|
-
$content = preg_replace( '`' . preg_quote( $match, '`' ) . '`', '', $content, 1 );
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
unset( $matches, $index, $match, $data );
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if ( strpos( $content, '%' ) === false ) {
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/*
|
|
422
|
-
* Analyse the query for unsupported placeholders.
|
|
423
|
-
*/
|
|
424
|
-
if ( preg_match_all( self::UNSUPPORTED_PLACEHOLDER_REGEX, $content, $matches ) > 0 ) {
|
|
425
|
-
if ( ! empty( $matches[0] ) ) {
|
|
426
|
-
foreach ( $matches[0] as $match ) {
|
|
427
|
-
if ( '%' === $match ) {
|
|
428
|
-
$this->phpcsFile->addError(
|
|
429
|
-
'Found unescaped literal "%%" character.',
|
|
430
|
-
$i,
|
|
431
|
-
'UnescapedLiteral',
|
|
432
|
-
array( $match )
|
|
433
|
-
);
|
|
434
|
-
} else {
|
|
435
|
-
$this->phpcsFile->addError(
|
|
436
|
-
'Unsupported placeholder used in $wpdb->prepare(). Found: "%s".',
|
|
437
|
-
$i,
|
|
438
|
-
'UnsupportedPlaceholder',
|
|
439
|
-
array( $match )
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
unset( $match, $matches );
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if ( $this->wp_version_compare( $this->minimum_wp_version, '6.2', '<' ) ) {
|
|
448
|
-
if ( preg_match_all( '`' . self::PREPARE_PLACEHOLDER_REGEX . '`x', $content, $matches ) > 0 ) {
|
|
449
|
-
if ( ! empty( $matches[0] ) ) {
|
|
450
|
-
foreach ( $matches[0] as $match ) {
|
|
451
|
-
if ( 'i' === substr( $match, -1 ) ) {
|
|
452
|
-
$this->phpcsFile->addError(
|
|
453
|
-
'The %%i modifier is only supported in WP 6.2 or higher. Found: "%s".',
|
|
454
|
-
$i,
|
|
455
|
-
'UnsupportedIdentifierPlaceholder',
|
|
456
|
-
array( $match )
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
unset( $match, $matches );
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/*
|
|
466
|
-
* Analyse the query for single/double quoted simple value placeholders
|
|
467
|
-
* Identifiers are checked separately.
|
|
468
|
-
*/
|
|
469
|
-
$regex = '`(' . $regex_quote . ')%[dfFs]\1`';
|
|
470
|
-
if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
|
|
471
|
-
if ( ! empty( $matches[0] ) ) {
|
|
472
|
-
foreach ( $matches[0] as $match ) {
|
|
473
|
-
$this->phpcsFile->addError(
|
|
474
|
-
'Simple placeholders should not be quoted in the query string in $wpdb->prepare(). Found: %s.',
|
|
475
|
-
$i,
|
|
476
|
-
'QuotedSimplePlaceholder',
|
|
477
|
-
array( $match )
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
unset( $match, $matches );
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/*
|
|
485
|
-
* Analyse the query for quoted identifier placeholders.
|
|
486
|
-
*/
|
|
487
|
-
$regex = '/(' . $regex_quote . '|`)(?<placeholder>' . self::PREPARE_PLACEHOLDER_REGEX . ')\1/x';
|
|
488
|
-
if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
|
|
489
|
-
if ( ! empty( $matches ) ) {
|
|
490
|
-
foreach ( $matches['placeholder'] as $index => $match ) {
|
|
491
|
-
if ( 'i' === substr( $match, -1 ) ) {
|
|
492
|
-
$this->phpcsFile->addError(
|
|
493
|
-
'Placeholders used for identifiers (%%i) in the query string in $wpdb->prepare() are always quoted automagically. Please remove the surrounding quotes. Found: %s',
|
|
494
|
-
$i,
|
|
495
|
-
'QuotedIdentifierPlaceholder',
|
|
496
|
-
array( $matches[0][ $index ] )
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
unset( $index, $match, $matches );
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/*
|
|
505
|
-
* Analyse the query for unquoted complex placeholders.
|
|
506
|
-
*/
|
|
507
|
-
$regex = '`(?<!' . $regex_quote . ')' . self::PREPARE_PLACEHOLDER_REGEX . '(?!' . $regex_quote . ')`x';
|
|
508
|
-
if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
|
|
509
|
-
if ( ! empty( $matches[0] ) ) {
|
|
510
|
-
foreach ( $matches[0] as $match ) {
|
|
511
|
-
if ( substr( $match, -1 ) !== 'i' && preg_match( '`^%[dfFsi]$`', $match ) !== 1 ) { // Identifiers must always be unquoted.
|
|
512
|
-
$this->phpcsFile->addWarning(
|
|
513
|
-
'Complex placeholders used for values in the query string in $wpdb->prepare() will NOT be quoted automagically. Found: %s.',
|
|
514
|
-
$i,
|
|
515
|
-
'UnquotedComplexPlaceholder',
|
|
516
|
-
array( $match )
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
unset( $match, $matches );
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/*
|
|
525
|
-
* Check for an ` IN (%s)` clause.
|
|
526
|
-
*/
|
|
527
|
-
$found_in = preg_match_all( '`\s+IN\s*\(\s*%s\s*\)`i', $content, $matches );
|
|
528
|
-
if ( $found_in > 0 ) {
|
|
529
|
-
$valid_in_clauses['uses_in'] += $found_in;
|
|
530
|
-
}
|
|
531
|
-
unset( $found_in );
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if ( false === $text_string_tokens_found ) {
|
|
535
|
-
// Query string passed in as a variable or function call, nothing to examine.
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if ( 0 === $total_placeholders ) {
|
|
540
|
-
if ( 1 === $total_parameters ) {
|
|
541
|
-
if ( false === $variable_found && false === $sql_wildcard_found ) {
|
|
542
|
-
/*
|
|
543
|
-
* Only throw this warning if the PreparedSQL sniff won't throw one about
|
|
544
|
-
* variables being found.
|
|
545
|
-
* Also don't throw it if we just advised to use a replacement variable to pass a
|
|
546
|
-
* string containing an SQL wildcard.
|
|
547
|
-
*/
|
|
548
|
-
$this->phpcsFile->addWarning(
|
|
549
|
-
'It is not necessary to prepare a query which doesn\'t use variable replacement.',
|
|
550
|
-
$i,
|
|
551
|
-
'UnnecessaryPrepare'
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
} elseif ( 0 === $valid_in_clauses['uses_in'] ) {
|
|
555
|
-
$this->phpcsFile->addWarning(
|
|
556
|
-
'Replacement variables found, but no valid placeholders found in the query.',
|
|
557
|
-
$i,
|
|
558
|
-
'UnfinishedPrepare'
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
if ( 1 === $total_parameters ) {
|
|
566
|
-
$this->phpcsFile->addError(
|
|
567
|
-
'Placeholders found in the query passed to $wpdb->prepare(), but no replacements found. Expected %d replacement(s) parameters.',
|
|
568
|
-
$stackPtr,
|
|
569
|
-
'MissingReplacements',
|
|
570
|
-
array( $total_placeholders )
|
|
571
|
-
);
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
$replacements = $parameters;
|
|
576
|
-
unset( $replacements['query'], $replacements[1] ); // Remove the query param, whether passed positionally or named.
|
|
577
|
-
|
|
578
|
-
// The parameters may have been passed as an array in the variadic $args parameter.
|
|
579
|
-
$args_param = PassedParameters::getParameterFromStack( $parameters, 2, 'args' );
|
|
580
|
-
if ( false !== $args_param && 2 === $total_parameters ) {
|
|
581
|
-
$next = $this->phpcsFile->findNext(
|
|
582
|
-
Tokens::$emptyTokens,
|
|
583
|
-
$args_param['start'],
|
|
584
|
-
( $args_param['end'] + 1 ),
|
|
585
|
-
true
|
|
586
|
-
);
|
|
587
|
-
|
|
588
|
-
if ( false !== $next
|
|
589
|
-
&& ( \T_ARRAY === $this->tokens[ $next ]['code']
|
|
590
|
-
|| ( isset( Collections::shortArrayListOpenTokensBC()[ $this->tokens[ $next ]['code'] ] )
|
|
591
|
-
&& Arrays::isShortArray( $this->phpcsFile, $next ) === true ) )
|
|
592
|
-
) {
|
|
593
|
-
$replacements = PassedParameters::getParameters( $this->phpcsFile, $next );
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
$total_replacements = \count( $replacements );
|
|
598
|
-
$total_placeholders -= $valid_in_clauses['adjustment_count'];
|
|
599
|
-
|
|
600
|
-
// Bow out when `IN` clauses have been used which appear to be correct.
|
|
601
|
-
if ( $valid_in_clauses['uses_in'] > 0
|
|
602
|
-
&& $valid_in_clauses['uses_in'] === $valid_in_clauses['implode_fill']
|
|
603
|
-
&& 1 === $total_replacements
|
|
604
|
-
) {
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/*
|
|
609
|
-
* Verify that the correct amount of replacements have been passed.
|
|
610
|
-
*/
|
|
611
|
-
if ( $total_replacements !== $total_placeholders ) {
|
|
612
|
-
$this->phpcsFile->addWarning(
|
|
613
|
-
'Incorrect number of replacements passed to $wpdb->prepare(). Found %d replacement parameters, expected %d.',
|
|
614
|
-
$stackPtr,
|
|
615
|
-
'ReplacementsWrongNumber',
|
|
616
|
-
array( $total_replacements, $total_placeholders )
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Retrieve a regex snippet to recognize and remember quotes based on the quote style
|
|
623
|
-
* used in the original string (if any).
|
|
624
|
-
*
|
|
625
|
-
* This allows for recognizing `"` and `\'` in single quoted strings,
|
|
626
|
-
* recognizing `'` and `\"` in double quotes strings and `'` and `"`when the quote
|
|
627
|
-
* style is unknown or it is a non-quoted string (heredoc/nowdoc and such).
|
|
628
|
-
*
|
|
629
|
-
* @since 0.14.0
|
|
630
|
-
*
|
|
631
|
-
* @param string $stripped_content Text string content without surrounding quotes.
|
|
632
|
-
* @param string $original_content Original content for the same text string.
|
|
633
|
-
*
|
|
634
|
-
* @return string
|
|
635
|
-
*/
|
|
636
|
-
protected function get_regex_quote_snippet( $stripped_content, $original_content ) {
|
|
637
|
-
$regex_quote = $this->regex_quote;
|
|
638
|
-
|
|
639
|
-
if ( $original_content !== $stripped_content ) {
|
|
640
|
-
$quote_style = $original_content[0];
|
|
641
|
-
|
|
642
|
-
if ( '"' === $quote_style ) {
|
|
643
|
-
$regex_quote = '\\\\"|\'';
|
|
644
|
-
} elseif ( "'" === $quote_style ) {
|
|
645
|
-
$regex_quote = '"|\\\\\'';
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
return $regex_quote;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Analyse a sprintf() query wrapper to see if it contains a specific code pattern
|
|
654
|
-
* to deal correctly with `IN` queries.
|
|
655
|
-
*
|
|
656
|
-
* The pattern we are searching for is:
|
|
657
|
-
* `sprintf( 'query ....', implode( ',', array_fill( 0, count( $something ), '%s' ) ) )`
|
|
658
|
-
*
|
|
659
|
-
* @since 0.14.0
|
|
660
|
-
*
|
|
661
|
-
* @param array $sprintf_params Parameters details for the sprintf call.
|
|
662
|
-
*
|
|
663
|
-
* @return int The number of times the pattern was found in the replacements.
|
|
664
|
-
*/
|
|
665
|
-
protected function analyse_sprintf( $sprintf_params ) {
|
|
666
|
-
$found = 0;
|
|
667
|
-
|
|
668
|
-
unset( $sprintf_params[1] ); // Remove the positionally passed $format param.
|
|
669
|
-
|
|
670
|
-
foreach ( $sprintf_params as $sprintf_param ) {
|
|
671
|
-
$implode = $this->phpcsFile->findNext(
|
|
672
|
-
Tokens::$emptyTokens + array( \T_NS_SEPARATOR => \T_NS_SEPARATOR ),
|
|
673
|
-
$sprintf_param['start'],
|
|
674
|
-
$sprintf_param['end'],
|
|
675
|
-
true
|
|
676
|
-
);
|
|
677
|
-
if ( \T_STRING === $this->tokens[ $implode ]['code']
|
|
678
|
-
&& 'implode' === strtolower( $this->tokens[ $implode ]['content'] )
|
|
679
|
-
) {
|
|
680
|
-
if ( $this->analyse_implode( $implode ) === true ) {
|
|
681
|
-
++$found;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
return $found;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Analyse an implode() function call to see if it contains a specific code pattern
|
|
691
|
-
* to dynamically create placeholders.
|
|
692
|
-
*
|
|
693
|
-
* The pattern we are searching for is:
|
|
694
|
-
* `implode( ',', array_fill( 0, count( $something ), '%s' ) )`
|
|
695
|
-
*
|
|
696
|
-
* This pattern presumes unquoted placeholders!
|
|
697
|
-
*
|
|
698
|
-
* Identifiers (%i) are not supported, as this function is designed to work
|
|
699
|
-
* with `IN()`, which contains a list of values. In the future, it should
|
|
700
|
-
* be possible to simplify code using the implode/array_fill pattern to
|
|
701
|
-
* use a variable number of identifiers, e.g. `CONCAT(%...i)`,
|
|
702
|
-
* https://core.trac.wordpress.org/ticket/54042
|
|
703
|
-
*
|
|
704
|
-
* @since 0.14.0
|
|
705
|
-
*
|
|
706
|
-
* @param int $implode_token The stackPtr to the implode function call.
|
|
707
|
-
*
|
|
708
|
-
* @return bool True if the pattern is found, false otherwise.
|
|
709
|
-
*/
|
|
710
|
-
protected function analyse_implode( $implode_token ) {
|
|
711
|
-
$implode_params = PassedParameters::getParameters( $this->phpcsFile, $implode_token );
|
|
712
|
-
if ( empty( $implode_params ) || \count( $implode_params ) !== 2 ) {
|
|
713
|
-
return false;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
$implode_separator_param = PassedParameters::getParameterFromStack( $implode_params, 1, 'separator' );
|
|
717
|
-
if ( false === $implode_separator_param
|
|
718
|
-
|| preg_match( '`^(["\']), ?\1$`', $implode_separator_param['clean'] ) !== 1
|
|
719
|
-
) {
|
|
720
|
-
return false;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
$implode_array_param = PassedParameters::getParameterFromStack( $implode_params, 2, 'array' );
|
|
724
|
-
if ( false === $implode_array_param ) {
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
$array_fill = $this->phpcsFile->findNext(
|
|
729
|
-
Tokens::$emptyTokens + array( \T_NS_SEPARATOR => \T_NS_SEPARATOR ),
|
|
730
|
-
$implode_array_param['start'],
|
|
731
|
-
$implode_array_param['end'],
|
|
732
|
-
true
|
|
733
|
-
);
|
|
734
|
-
|
|
735
|
-
if ( \T_STRING !== $this->tokens[ $array_fill ]['code']
|
|
736
|
-
|| 'array_fill' !== strtolower( $this->tokens[ $array_fill ]['content'] )
|
|
737
|
-
) {
|
|
738
|
-
return false;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
$array_fill_value_param = PassedParameters::getParameter( $this->phpcsFile, $array_fill, 3, 'value' );
|
|
742
|
-
if ( false === $array_fill_value_param ) {
|
|
743
|
-
return false;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
if ( "'%i'" === $array_fill_value_param['clean']
|
|
747
|
-
|| '"%i"' === $array_fill_value_param['clean']
|
|
748
|
-
) {
|
|
749
|
-
$firstNonEmpty = $this->phpcsFile->findNext( Tokens::$emptyTokens, $array_fill_value_param['start'], $array_fill_value_param['end'], true );
|
|
750
|
-
|
|
751
|
-
$this->phpcsFile->addError(
|
|
752
|
-
'The %i placeholder cannot be used within SQL `IN()` clauses.',
|
|
753
|
-
$firstNonEmpty,
|
|
754
|
-
'IdentifierWithinIN'
|
|
755
|
-
);
|
|
756
|
-
return false;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
return (bool) preg_match( '`^(["\'])%[dfFs]\1$`', $array_fill_value_param['clean'] );
|
|
760
|
-
}
|
|
761
|
-
}
|