Version Description
- Added support for PHP 7.3 compatibility checks
Download this release
Release Info
Developer | stevenkword |
Plugin | PHP Compatibility Checker |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.7 to 1.5.0
- php52/composer.lock +9 -8
- php52/vendor/autoload.php +1 -1
- php52/vendor/autoload_52.php +1 -1
- php52/vendor/composer/ClassLoader.php +2 -2
- php52/vendor/composer/autoload_real.php +4 -4
- php52/vendor/composer/autoload_real_52.php +3 -3
- php52/vendor/composer/autoload_static.php +5 -5
- php52/vendor/composer/installed.json +6 -6
- readme.txt +17 -9
- src/wpcli.php +21 -17
- vendor/autoload.php +1 -1
- vendor/composer/ClassLoader.php +2 -2
- vendor/composer/autoload_psr4.php +0 -1
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +4 -12
- vendor/composer/installed.json +88 -27
- vendor/phpcompatibility/php-compatibility/.gitattributes +0 -28
- vendor/phpcompatibility/php-compatibility/.gitignore +0 -7
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/ForbiddenAbstractPrivateMethodsSniff.php +90 -0
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes}/NewAnonymousClassesSniff.php +14 -15
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Classes}/NewClassesSniff.php +85 -56
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Classes}/NewConstVisibilitySniff.php +12 -13
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewLateStaticBindingSniff.php} +13 -15
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php +125 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedOrphanedParentSniff.php +115 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Constants}/NewConstantsSniff.php +656 -12
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Constants}/NewMagicClassConstantSniff.php +9 -7
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants}/RemovedConstantsSniff.php +215 -11
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/DiscouragedSwitchContinueSniff.php +9 -21
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures}/ForbiddenBreakContinueOutsideLoopSniff.php +17 -19
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/ForbiddenBreakContinueVariableArgumentsSniff.php +14 -15
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures}/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +10 -11
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/NewExecutionDirectivesSniff.php +26 -28
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewForeachExpressionReferencingSniff.php +96 -0
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewMagicClassConstantSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewListInForeachSniff.php} +20 -14
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/NewMultiCatchSniff.php +10 -12
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Extensions}/RemovedExtensionsSniff.php +33 -28
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ParameterShadowSuperGlobalsSniff.php → FunctionDeclarations/ForbiddenParameterShadowSuperGlobalsSniff.php} +10 -9
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ForbiddenFunctionParametersWithSameNameSniff.php → FunctionDeclarations/ForbiddenParametersWithSameNameSniff.php} +13 -15
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenToStringParametersSniff.php +97 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ForbiddenClosureUseVariableNamesSniff.php → FunctionDeclarations/ForbiddenVariableNamesInClosureUseSniff.php} +17 -18
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NewClosureSniff.php +20 -21
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewExceptionsFromToStringSniff.php +100 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NewNullableTypesSniff.php +26 -27
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewScalarTypeDeclarationsSniff.php → FunctionDeclarations/NewParamTypeDeclarationsSniff.php} +11 -12
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NewReturnTypeDeclarationsSniff.php +15 -16
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NonStaticMagicMethodsSniff.php +14 -22
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionNameRestrictions}/NewMagicMethodsSniff.php +9 -12
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedMagicAutoloadSniff.php → FunctionNameRestrictions/RemovedMagicAutoloadSniff.php} +11 -11
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedNamespacedAssertSniff.php +92 -0
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedPHP4StyleConstructorsSniff.php} +30 -11
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionNameRestrictions}/ReservedFunctionNamesSniff.php +32 -29
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php +439 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/ArgumentFunctionsUsageSniff.php +20 -19
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/NewFunctionParametersSniff.php +115 -20
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/NewFunctionsSniff.php +167 -19
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/OptionalRequiredFunctionParametersSniff.php → FunctionUse/OptionalToRequiredFunctionParametersSniff.php} +11 -14
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/RemovedFunctionParametersSniff.php +23 -18
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedFunctionsSniff.php → FunctionUse/RemovedFunctionsSniff.php} +335 -201
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/RequiredOptionalFunctionParametersSniff.php → FunctionUse/RequiredToOptionalFunctionParametersSniff.php} +106 -25
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Generators}/NewGeneratorReturnSniff.php +58 -29
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → IniDirectives}/NewIniDirectivesSniff.php +54 -18
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedIniDirectivesSniff.php → IniDirectives/RemovedIniDirectivesSniff.php} +80 -20
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ConstantArraysUsingConstSniff.php → InitialValue/NewConstantArraysUsingConstSniff.php} +12 -11
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ConstantArraysUsingDefineSniff.php → InitialValue/NewConstantArraysUsingDefineSniff.php} +16 -15
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → InitialValue}/NewConstantScalarExpressionsSniff.php +75 -106
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewHeredocInitializeSniff.php → InitialValue/NewHeredocSniff.php} +11 -9
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Interfaces}/InternalInterfacesSniff.php +13 -16
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Interfaces}/NewInterfacesSniff.php +32 -27
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords}/CaseSensitiveKeywordsSniff.php +8 -7
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Keywords}/ForbiddenNamesAsDeclaredSniff.php +28 -33
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords}/ForbiddenNamesAsInvokedFunctionsSniff.php +37 -42
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Keywords}/ForbiddenNamesSniff.php +37 -59
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Keywords}/NewKeywordsSniff.php +21 -27
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/LanguageConstructs/NewEmptyNonVariableSniff.php +84 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/LanguageConstructs/NewLanguageConstructsSniff.php +140 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/AssignmentOrderSniff.php +183 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Lists}/ForbiddenEmptyListAssignmentSniff.php +14 -16
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/NewKeyedListSniff.php +211 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/NewListReferenceAssignmentSniff.php +67 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/NewShortListSniff.php +80 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/MethodUse/ForbiddenToStringParametersSniff.php +102 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/MethodUse/NewDirectCallsToCloneSniff.php +97 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Miscellaneous}/RemovedAlternativePHPTagsSniff.php +19 -22
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Miscellaneous}/ValidIntegersSniff.php +18 -20
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/ChangedConcatOperatorPrecedenceSniff.php +199 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Operators}/ForbiddenNegativeBitshiftSniff.php +19 -20
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewLanguageConstructsSniff.php → Operators/NewOperatorsSniff.php} +42 -54
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/TernaryOperatorsSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/NewShortTernarySniff.php} +15 -18
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/RemovedTernaryAssociativitySniff.php +156 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/CaseSensitiveKeywordsSniff.php +0 -72
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php +0 -116
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php +0 -164
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php +0 -111
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php +0 -122
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php +0 -189
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +0 -80
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php +0 -81
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php +0 -88
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php +0 -104
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/NewUseConstFunctionSniff.php +0 -101
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/RemovedConstantsSniff.php +0 -343
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/TernaryOperatorsSniff.php +0 -72
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/ForbiddenGetClassNullSniff.php +80 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewArrayReduceInitialTypeSniff.php +106 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewFopenModesSniff.php +112 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ParameterValues}/NewHashAlgorithmsSniff.php +10 -13
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewNegativeStringOffsetSniff.php +126 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/PCRENewModifiersSniff.php → ParameterValues/NewPCREModifiersSniff.php} +8 -8
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewPackFormatSniff.php +123 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ParameterValues}/RemovedHashAlgorithmsSniff.php +10 -13
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedIconvEncodingSniff.php +80 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/MbstringReplaceEModifierSniff.php → ParameterValues/RemovedMbstringModifiersSniff.php} +13 -9
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedNonCryptoHashSniff.php +114 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/PregReplaceEModifierSniff.php → ParameterValues/RemovedPCREModifiersSniff.php} +17 -16
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedSetlocaleStringSniff.php +99 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/ForbiddenCallTimePassByReferenceSniff.php +48 -28
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/NewArrayStringDereferencingSniff.php +16 -16
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewArrayUnpackingSniff.php +137 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/NewClassMemberAccessSniff.php +16 -24
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DynamicAccessToStaticSniff.php → Syntax/NewDynamicAccessToStaticSniff.php} +12 -11
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewFlexibleHeredocNowdocSniff.php +247 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/NewFunctionArrayDereferencingSniff.php +22 -21
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewTrailingCommaSniff.php → Syntax/NewFunctionCallTrailingCommaSniff.php} +24 -32
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ShortArraySniff.php → Syntax/NewShortArraySniff.php} +11 -12
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedNewReferenceSniff.php → Syntax/RemovedNewReferenceSniff.php} +12 -13
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → TypeCasts}/NewTypeCastsSniff.php +18 -14
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedTypeCastsSniff.php → TypeCasts/RemovedTypeCastsSniff.php} +9 -11
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/UseDeclarations}/NewGroupUseDeclarationsSniff.php +21 -20
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/UseDeclarations}/NewUseConstFunctionSniff.php +10 -9
- vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables}/ForbiddenGlobalVariableVariableSniff.php +16 -14
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php +424 -0
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/VariableVariablesSniff.php → Variables/NewUniformVariableSyntaxSniff.php} +22 -24
- vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/RemovedGlobalVariablesSniff.php → Variables/RemovedPredefinedGlobalVariablesSniff.php} +26 -38
- vendor/phpcompatibility/php-compatibility/phpunit-bootstrap.php +79 -0
- vendor/{wimg/php-compatibility → phpcompatibility/phpcompatibility-paragonie}/LICENSE +0 -0
- vendor/phpcompatibility/phpcompatibility-paragonie/PHPCompatibilityParagonieRandomCompat/ruleset.xml +40 -0
- vendor/phpcompatibility/phpcompatibility-paragonie/PHPCompatibilityParagonieSodiumCompat/ruleset.xml +148 -0
- vendor/phpcompatibility/phpcompatibility-paragonie/README.md +109 -0
- vendor/phpcompatibility/phpcompatibility-paragonie/composer.json +31 -0
- vendor/simplyadmire/composer-plugins/Configuration/Settings.yaml +0 -5
- vendor/simplyadmire/composer-plugins/LICENSE +0 -56
- vendor/simplyadmire/composer-plugins/README.md +0 -62
- vendor/simplyadmire/composer-plugins/SimplyAdmire/ComposerPlugins/Installers/PhpCodesnifferStandardInstaller.php +0 -49
- vendor/simplyadmire/composer-plugins/SimplyAdmire/ComposerPlugins/PhpCodesnifferStandardInstallerPlugin.php +0 -20
- vendor/squizlabs/php_codesniffer/CodeSniffer.conf +1 -1
- vendor/wimg/php-compatibility/CHANGELOG.md +0 -899
- vendor/wimg/php-compatibility/PHPCSAliases.php +0 -67
- vendor/wimg/php-compatibility/PHPCompatibility/AbstractComplexVersionSniff.php +0 -132
- vendor/wimg/php-compatibility/PHPCompatibility/AbstractNewFeatureSniff.php +0 -108
- vendor/wimg/php-compatibility/PHPCompatibility/AbstractRemovedFeatureSniff.php +0 -148
- vendor/wimg/php-compatibility/PHPCompatibility/ComplexVersionInterface.php +0 -77
- vendor/wimg/php-compatibility/PHPCompatibility/PHPCSHelper.php +0 -89
- vendor/wimg/php-compatibility/PHPCompatibility/Sniff.php +0 -1696
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingConstSniff.php +0 -70
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php +0 -96
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php +0 -904
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php +0 -338
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedMagicAutoloadSniff.php +0 -80
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php +0 -78
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedTypeCastsSniff.php +0 -133
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DynamicAccessToStaticSniff.php +0 -84
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php +0 -161
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php +0 -102
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php +0 -233
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenClosureUseVariableNamesSniff.php +0 -118
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php +0 -97
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php +0 -87
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php +0 -252
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php +0 -411
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php +0 -74
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php +0 -93
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php +0 -122
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewArrayStringDereferencingSniff.php +0 -108
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php +0 -569
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php +0 -187
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php +0 -79
- vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewConstantsSniff.php +0 -1217
php52/composer.lock
CHANGED
@@ -1,23 +1,24 @@
|
|
1 |
{
|
2 |
"_readme": [
|
3 |
"This file locks the dependencies of your project to a known state",
|
4 |
-
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#
|
5 |
"This file is @generated automatically"
|
6 |
],
|
|
|
7 |
"content-hash": "937367a108bb97c748a6156b5d542002",
|
8 |
"packages": [
|
9 |
{
|
10 |
"name": "squizlabs/php_codesniffer",
|
11 |
-
"version": "2.9.
|
12 |
"source": {
|
13 |
"type": "git",
|
14 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
15 |
-
"reference": "
|
16 |
},
|
17 |
"dist": {
|
18 |
"type": "zip",
|
19 |
-
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/
|
20 |
-
"reference": "
|
21 |
"shasum": ""
|
22 |
},
|
23 |
"require": {
|
@@ -82,7 +83,7 @@
|
|
82 |
"phpcs",
|
83 |
"standards"
|
84 |
],
|
85 |
-
"time": "
|
86 |
},
|
87 |
{
|
88 |
"name": "wimg/php-compatibility",
|
@@ -126,7 +127,7 @@
|
|
126 |
"phpcs",
|
127 |
"standards"
|
128 |
],
|
129 |
-
"time": "2017-07-
|
130 |
},
|
131 |
{
|
132 |
"name": "xrstf/composer-php52",
|
@@ -157,7 +158,7 @@
|
|
157 |
"license": [
|
158 |
"MIT"
|
159 |
],
|
160 |
-
"time": "2016-04-
|
161 |
}
|
162 |
],
|
163 |
"packages-dev": [],
|
1 |
{
|
2 |
"_readme": [
|
3 |
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
+
"hash": "7c46dfad96b04e3adea69f7f0c3f9cdd",
|
8 |
"content-hash": "937367a108bb97c748a6156b5d542002",
|
9 |
"packages": [
|
10 |
{
|
11 |
"name": "squizlabs/php_codesniffer",
|
12 |
+
"version": "2.9.2",
|
13 |
"source": {
|
14 |
"type": "git",
|
15 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
16 |
+
"reference": "2acf168de78487db620ab4bc524135a13cfe6745"
|
17 |
},
|
18 |
"dist": {
|
19 |
"type": "zip",
|
20 |
+
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745",
|
21 |
+
"reference": "2acf168de78487db620ab4bc524135a13cfe6745",
|
22 |
"shasum": ""
|
23 |
},
|
24 |
"require": {
|
83 |
"phpcs",
|
84 |
"standards"
|
85 |
],
|
86 |
+
"time": "2018-11-07 22:31:41"
|
87 |
},
|
88 |
{
|
89 |
"name": "wimg/php-compatibility",
|
127 |
"phpcs",
|
128 |
"standards"
|
129 |
],
|
130 |
+
"time": "2017-07-15 23:03:53"
|
131 |
},
|
132 |
{
|
133 |
"name": "xrstf/composer-php52",
|
158 |
"license": [
|
159 |
"MIT"
|
160 |
],
|
161 |
+
"time": "2016-04-16 21:52:24"
|
162 |
}
|
163 |
],
|
164 |
"packages-dev": [],
|
php52/vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitc4301fae20add97d611a17b9b129eb65::getLoader();
|
php52/vendor/autoload_52.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit524612e2811943051abd61e25bc05ed8::getLoader();
|
php52/vendor/composer/ClassLoader.php
CHANGED
@@ -279,7 +279,7 @@ class ClassLoader
|
|
279 |
*/
|
280 |
public function setApcuPrefix($apcuPrefix)
|
281 |
{
|
282 |
-
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
283 |
}
|
284 |
|
285 |
/**
|
@@ -377,7 +377,7 @@ class ClassLoader
|
|
377 |
$subPath = $class;
|
378 |
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
379 |
$subPath = substr($subPath, 0, $lastPos);
|
380 |
-
$search = $subPath.'\\';
|
381 |
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
383 |
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
279 |
*/
|
280 |
public function setApcuPrefix($apcuPrefix)
|
281 |
{
|
282 |
+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
283 |
}
|
284 |
|
285 |
/**
|
377 |
$subPath = $class;
|
378 |
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
379 |
$subPath = substr($subPath, 0, $lastPos);
|
380 |
+
$search = $subPath . '\\';
|
381 |
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
383 |
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
php52/vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit86b8ad330e39a59baeaf1244fe586115
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitc4301fae20add97d611a17b9b129eb65
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitc4301fae20add97d611a17b9b129eb65', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitc4301fae20add97d611a17b9b129eb65', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitc4301fae20add97d611a17b9b129eb65::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
php52/vendor/composer/autoload_real_52.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real_52.php generated by xrstf/composer-php52
|
4 |
|
5 |
-
class
|
6 |
private static $loader;
|
7 |
|
8 |
public static function loadClassLoader($class) {
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit9682a282f546102ba01ce755bc036ffe {
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new xrstf_Composer52_ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$vendorDir = dirname(dirname(__FILE__));
|
27 |
$baseDir = dirname($vendorDir);
|
2 |
|
3 |
// autoload_real_52.php generated by xrstf/composer-php52
|
4 |
|
5 |
+
class ComposerAutoloaderInit524612e2811943051abd61e25bc05ed8 {
|
6 |
private static $loader;
|
7 |
|
8 |
public static function loadClassLoader($class) {
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit524612e2811943051abd61e25bc05ed8', 'loadClassLoader'), true /*, true */);
|
23 |
self::$loader = $loader = new xrstf_Composer52_ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit524612e2811943051abd61e25bc05ed8', 'loadClassLoader'));
|
25 |
|
26 |
$vendorDir = dirname(dirname(__FILE__));
|
27 |
$baseDir = dirname($vendorDir);
|
php52/vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'P' =>
|
@@ -288,10 +288,10 @@ class ComposerStaticInit86b8ad330e39a59baeaf1244fe586115
|
|
288 |
public static function getInitializer(ClassLoader $loader)
|
289 |
{
|
290 |
return \Closure::bind(function () use ($loader) {
|
291 |
-
$loader->prefixLengthsPsr4 =
|
292 |
-
$loader->prefixDirsPsr4 =
|
293 |
-
$loader->prefixesPsr0 =
|
294 |
-
$loader->classMap =
|
295 |
|
296 |
}, null, ClassLoader::class);
|
297 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitc4301fae20add97d611a17b9b129eb65
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'P' =>
|
288 |
public static function getInitializer(ClassLoader $loader)
|
289 |
{
|
290 |
return \Closure::bind(function () use ($loader) {
|
291 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitc4301fae20add97d611a17b9b129eb65::$prefixLengthsPsr4;
|
292 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitc4301fae20add97d611a17b9b129eb65::$prefixDirsPsr4;
|
293 |
+
$loader->prefixesPsr0 = ComposerStaticInitc4301fae20add97d611a17b9b129eb65::$prefixesPsr0;
|
294 |
+
$loader->classMap = ComposerStaticInitc4301fae20add97d611a17b9b129eb65::$classMap;
|
295 |
|
296 |
}, null, ClassLoader::class);
|
297 |
}
|
php52/vendor/composer/installed.json
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
[
|
2 |
{
|
3 |
"name": "squizlabs/php_codesniffer",
|
4 |
-
"version": "2.9.
|
5 |
-
"version_normalized": "2.9.
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
@@ -23,7 +23,7 @@
|
|
23 |
"require-dev": {
|
24 |
"phpunit/phpunit": "~4.0"
|
25 |
},
|
26 |
-
"time": "
|
27 |
"bin": [
|
28 |
"scripts/phpcs",
|
29 |
"scripts/phpcbf"
|
1 |
[
|
2 |
{
|
3 |
"name": "squizlabs/php_codesniffer",
|
4 |
+
"version": "2.9.2",
|
5 |
+
"version_normalized": "2.9.2.0",
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
9 |
+
"reference": "2acf168de78487db620ab4bc524135a13cfe6745"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745",
|
14 |
+
"reference": "2acf168de78487db620ab4bc524135a13cfe6745",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
23 |
"require-dev": {
|
24 |
"phpunit/phpunit": "~4.0"
|
25 |
},
|
26 |
+
"time": "2018-11-07T22:31:41+00:00",
|
27 |
"bin": [
|
28 |
"scripts/phpcs",
|
29 |
"scripts/phpcbf"
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: wpengine, octalmage, stevenkword, Taylor4484, pross, jcross
|
3 |
Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
|
4 |
Requires at least: 3.5
|
5 |
-
Tested up to:
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -21,11 +21,11 @@ This plugin will lint theme and plugin code inside your WordPress file system an
|
|
21 |
|
22 |
**This plugin relies on WP-Cron to scan files in the background. The scan will get stuck if the site's WP-Cron isn't running correctly. Please see the [FAQ](https://wordpress.org/plugins/php-compatibility-checker/faq/) for more information.**
|
23 |
|
24 |
-
= Update to PHP 7.
|
25 |
-
* Use this plugin to check your site for compatibility up to PHP 7.
|
26 |
-
* As of [
|
27 |
-
* These versions of PHP have been deprecated and unsupported for over
|
28 |
-
* Only
|
29 |
|
30 |
|
31 |
= Disclaimer =
|
@@ -113,6 +113,14 @@ To disclose security issues for this plugin please email WordPress@wpengine.com
|
|
113 |
2. Compatibility results screen
|
114 |
|
115 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
= 1.4.6 =
|
118 |
- Switched to new PHPCompatibilityWP library to help prevent false positives.
|
@@ -204,5 +212,5 @@ To disclose security issues for this plugin please email WordPress@wpengine.com
|
|
204 |
|
205 |
== Upgrade Notice ==
|
206 |
|
207 |
-
= 1.4.
|
208 |
-
-
|
2 |
Contributors: wpengine, octalmage, stevenkword, Taylor4484, pross, jcross
|
3 |
Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
|
4 |
Requires at least: 3.5
|
5 |
+
Tested up to: 5.2.2
|
6 |
+
Stable tag: 1.5.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
21 |
|
22 |
**This plugin relies on WP-Cron to scan files in the background. The scan will get stuck if the site's WP-Cron isn't running correctly. Please see the [FAQ](https://wordpress.org/plugins/php-compatibility-checker/faq/) for more information.**
|
23 |
|
24 |
+
= Update to PHP 7.3 =
|
25 |
+
* Use this plugin to check your site for compatibility up to PHP 7.3!
|
26 |
+
* As of [July 2019](https://wordpress.org/about/stats/), 20.1% of WordPress websites run a PHP version older than PHP 5.6.
|
27 |
+
* These versions of PHP have been [deprecated and unsupported](https://secure.php.net/supported-versions.php) for over 2 years.
|
28 |
+
* Only 54.1% of WordPress websites run PHP 7, the current main version of PHP.
|
29 |
|
30 |
|
31 |
= Disclaimer =
|
113 |
2. Compatibility results screen
|
114 |
|
115 |
== Changelog ==
|
116 |
+
= 1.5.0 =
|
117 |
+
- Added support for PHP 7.3 compatibility checks
|
118 |
+
|
119 |
+
= 1.4.8 =
|
120 |
+
- Update dependencies.
|
121 |
+
|
122 |
+
= 1.4.7 =
|
123 |
+
- Better translation support.
|
124 |
|
125 |
= 1.4.6 =
|
126 |
- Switched to new PHPCompatibilityWP library to help prevent false positives.
|
212 |
|
213 |
== Upgrade Notice ==
|
214 |
|
215 |
+
= 1.4.8 =
|
216 |
+
- Update dependencies.
|
src/wpcli.php
CHANGED
@@ -65,21 +65,25 @@ class PHPCompat_Command extends WP_CLI_Command {
|
|
65 |
* Using this for now since there are issues with the PHPDoc syntax.
|
66 |
* TODO: Use PHPDoc syntax.
|
67 |
*/
|
68 |
-
WP_CLI::add_command(
|
69 |
-
'
|
70 |
-
'
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
),
|
77 |
-
|
78 |
-
|
79 |
-
'name' => 'scan',
|
80 |
-
'optional' => true,
|
81 |
-
'default' => 'active',
|
82 |
-
'options' => array( 'active', 'all' ),
|
83 |
-
),
|
84 |
-
),
|
85 |
-
));
|
65 |
* Using this for now since there are issues with the PHPDoc syntax.
|
66 |
* TODO: Use PHPDoc syntax.
|
67 |
*/
|
68 |
+
WP_CLI::add_command(
|
69 |
+
'phpcompat',
|
70 |
+
'PHPCompat_Command',
|
71 |
+
array(
|
72 |
+
'shortdesc' => 'Test compatibility with different PHP versions.',
|
73 |
+
'synopsis' => array(
|
74 |
+
array(
|
75 |
+
'type' => 'positional',
|
76 |
+
'name' => 'version',
|
77 |
+
'optional' => false,
|
78 |
+
'multiple' => false,
|
79 |
+
),
|
80 |
+
array(
|
81 |
+
'type' => 'assoc',
|
82 |
+
'name' => 'scan',
|
83 |
+
'optional' => true,
|
84 |
+
'default' => 'active',
|
85 |
+
'options' => array( 'active', 'all' ),
|
86 |
+
),
|
87 |
),
|
88 |
+
)
|
89 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit286b3d04f78898a763ebc0336108fffb::getLoader();
|
vendor/composer/ClassLoader.php
CHANGED
@@ -279,7 +279,7 @@ class ClassLoader
|
|
279 |
*/
|
280 |
public function setApcuPrefix($apcuPrefix)
|
281 |
{
|
282 |
-
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
283 |
}
|
284 |
|
285 |
/**
|
@@ -377,7 +377,7 @@ class ClassLoader
|
|
377 |
$subPath = $class;
|
378 |
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
379 |
$subPath = substr($subPath, 0, $lastPos);
|
380 |
-
$search = $subPath.'\\';
|
381 |
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
383 |
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
279 |
*/
|
280 |
public function setApcuPrefix($apcuPrefix)
|
281 |
{
|
282 |
+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
283 |
}
|
284 |
|
285 |
/**
|
377 |
$subPath = $class;
|
378 |
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
379 |
$subPath = substr($subPath, 0, $lastPos);
|
380 |
+
$search = $subPath . '\\';
|
381 |
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
383 |
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -6,6 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
-
'PHPCompatibility\\' => array($vendorDir . '/phpcompatibility/php-compatibility/PHPCompatibility'),
|
10 |
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => array($vendorDir . '/dealerdirect/phpcodesniffer-composer-installer/src'),
|
11 |
);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
|
|
9 |
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => array($vendorDir . '/dealerdirect/phpcodesniffer-composer-installer/src'),
|
10 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit57cc78f2f1c527f7b3892d3c7f254998
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit286b3d04f78898a763ebc0336108fffb
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit286b3d04f78898a763ebc0336108fffb', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit286b3d04f78898a763ebc0336108fffb', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit286b3d04f78898a763ebc0336108fffb::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,13 +4,9 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
-
'P' =>
|
11 |
-
array (
|
12 |
-
'PHPCompatibility\\' => 17,
|
13 |
-
),
|
14 |
'D' =>
|
15 |
array (
|
16 |
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => 55,
|
@@ -18,10 +14,6 @@ class ComposerStaticInit57cc78f2f1c527f7b3892d3c7f254998
|
|
18 |
);
|
19 |
|
20 |
public static $prefixDirsPsr4 = array (
|
21 |
-
'PHPCompatibility\\' =>
|
22 |
-
array (
|
23 |
-
0 => __DIR__ . '/..' . '/phpcompatibility/php-compatibility/PHPCompatibility',
|
24 |
-
),
|
25 |
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' =>
|
26 |
array (
|
27 |
0 => __DIR__ . '/..' . '/dealerdirect/phpcodesniffer-composer-installer/src',
|
@@ -286,9 +278,9 @@ class ComposerStaticInit57cc78f2f1c527f7b3892d3c7f254998
|
|
286 |
public static function getInitializer(ClassLoader $loader)
|
287 |
{
|
288 |
return \Closure::bind(function () use ($loader) {
|
289 |
-
$loader->prefixLengthsPsr4 =
|
290 |
-
$loader->prefixDirsPsr4 =
|
291 |
-
$loader->classMap =
|
292 |
|
293 |
}, null, ClassLoader::class);
|
294 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit286b3d04f78898a763ebc0336108fffb
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
|
|
|
|
|
|
|
|
10 |
'D' =>
|
11 |
array (
|
12 |
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => 55,
|
14 |
);
|
15 |
|
16 |
public static $prefixDirsPsr4 = array (
|
|
|
|
|
|
|
|
|
17 |
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' =>
|
18 |
array (
|
19 |
0 => __DIR__ . '/..' . '/dealerdirect/phpcodesniffer-composer-installer/src',
|
278 |
public static function getInitializer(ClassLoader $loader)
|
279 |
{
|
280 |
return \Closure::bind(function () use ($loader) {
|
281 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit286b3d04f78898a763ebc0336108fffb::$prefixLengthsPsr4;
|
282 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit286b3d04f78898a763ebc0336108fffb::$prefixDirsPsr4;
|
283 |
+
$loader->classMap = ComposerStaticInit286b3d04f78898a763ebc0336108fffb::$classMap;
|
284 |
|
285 |
}, null, ClassLoader::class);
|
286 |
}
|
vendor/composer/installed.json
CHANGED
@@ -71,17 +71,17 @@
|
|
71 |
},
|
72 |
{
|
73 |
"name": "phpcompatibility/php-compatibility",
|
74 |
-
"version": "
|
75 |
-
"version_normalized": "
|
76 |
"source": {
|
77 |
"type": "git",
|
78 |
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
|
79 |
-
"reference": "
|
80 |
},
|
81 |
"dist": {
|
82 |
"type": "zip",
|
83 |
-
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/
|
84 |
-
"reference": "
|
85 |
"shasum": ""
|
86 |
},
|
87 |
"require": {
|
@@ -95,17 +95,68 @@
|
|
95 |
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
|
96 |
},
|
97 |
"suggest": {
|
98 |
-
"dealerdirect/phpcodesniffer-composer-installer": "^0.
|
99 |
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
100 |
},
|
101 |
-
"time": "
|
102 |
"type": "phpcodesniffer-standard",
|
103 |
"installation-source": "dist",
|
104 |
-
"
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
},
|
|
|
|
|
|
|
109 |
"notification-url": "https://packagist.org/downloads/",
|
110 |
"license": [
|
111 |
"LGPL-3.0-or-later"
|
@@ -114,39 +165,49 @@
|
|
114 |
{
|
115 |
"name": "Wim Godden",
|
116 |
"role": "lead"
|
|
|
|
|
|
|
|
|
117 |
}
|
118 |
],
|
119 |
-
"description": "A set of
|
120 |
-
"homepage": "http://
|
121 |
"keywords": [
|
122 |
"compatibility",
|
|
|
123 |
"phpcs",
|
|
|
124 |
"standards"
|
125 |
]
|
126 |
},
|
127 |
{
|
128 |
"name": "phpcompatibility/phpcompatibility-wp",
|
129 |
-
"version": "
|
130 |
-
"version_normalized": "
|
131 |
"source": {
|
132 |
"type": "git",
|
133 |
"url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git",
|
134 |
-
"reference": "
|
135 |
},
|
136 |
"dist": {
|
137 |
"type": "zip",
|
138 |
-
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/
|
139 |
-
"reference": "
|
140 |
"shasum": ""
|
141 |
},
|
142 |
"require": {
|
143 |
-
"phpcompatibility/php-compatibility": "^
|
|
|
|
|
|
|
|
|
144 |
},
|
145 |
"suggest": {
|
146 |
-
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the
|
147 |
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
148 |
},
|
149 |
-
"time": "2018-
|
150 |
"type": "phpcodesniffer-standard",
|
151 |
"installation-source": "dist",
|
152 |
"notification-url": "https://packagist.org/downloads/",
|
@@ -163,7 +224,7 @@
|
|
163 |
"role": "lead"
|
164 |
}
|
165 |
],
|
166 |
-
"description": "A
|
167 |
"homepage": "http://phpcompatibility.com/",
|
168 |
"keywords": [
|
169 |
"compatibility",
|
@@ -174,17 +235,17 @@
|
|
174 |
},
|
175 |
{
|
176 |
"name": "squizlabs/php_codesniffer",
|
177 |
-
"version": "2.9.
|
178 |
-
"version_normalized": "2.9.
|
179 |
"source": {
|
180 |
"type": "git",
|
181 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
182 |
-
"reference": "
|
183 |
},
|
184 |
"dist": {
|
185 |
"type": "zip",
|
186 |
-
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/
|
187 |
-
"reference": "
|
188 |
"shasum": ""
|
189 |
},
|
190 |
"require": {
|
@@ -196,7 +257,7 @@
|
|
196 |
"require-dev": {
|
197 |
"phpunit/phpunit": "~4.0"
|
198 |
},
|
199 |
-
"time": "
|
200 |
"bin": [
|
201 |
"scripts/phpcs",
|
202 |
"scripts/phpcbf"
|
71 |
},
|
72 |
{
|
73 |
"name": "phpcompatibility/php-compatibility",
|
74 |
+
"version": "9.2.0",
|
75 |
+
"version_normalized": "9.2.0.0",
|
76 |
"source": {
|
77 |
"type": "git",
|
78 |
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
|
79 |
+
"reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e"
|
80 |
},
|
81 |
"dist": {
|
82 |
"type": "zip",
|
83 |
+
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/3db1bf1e28123fd574a4ae2e9a84072826d51b5e",
|
84 |
+
"reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e",
|
85 |
"shasum": ""
|
86 |
},
|
87 |
"require": {
|
95 |
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
|
96 |
},
|
97 |
"suggest": {
|
98 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
|
99 |
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
100 |
},
|
101 |
+
"time": "2019-06-27T19:58:56+00:00",
|
102 |
"type": "phpcodesniffer-standard",
|
103 |
"installation-source": "dist",
|
104 |
+
"notification-url": "https://packagist.org/downloads/",
|
105 |
+
"license": [
|
106 |
+
"LGPL-3.0-or-later"
|
107 |
+
],
|
108 |
+
"authors": [
|
109 |
+
{
|
110 |
+
"name": "Contributors",
|
111 |
+
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"name": "Wim Godden",
|
115 |
+
"homepage": "https://github.com/wimg",
|
116 |
+
"role": "lead"
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"name": "Juliette Reinders Folmer",
|
120 |
+
"homepage": "https://github.com/jrfnl",
|
121 |
+
"role": "lead"
|
122 |
}
|
123 |
+
],
|
124 |
+
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
|
125 |
+
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
|
126 |
+
"keywords": [
|
127 |
+
"compatibility",
|
128 |
+
"phpcs",
|
129 |
+
"standards"
|
130 |
+
]
|
131 |
+
},
|
132 |
+
{
|
133 |
+
"name": "phpcompatibility/phpcompatibility-paragonie",
|
134 |
+
"version": "1.0.1",
|
135 |
+
"version_normalized": "1.0.1.0",
|
136 |
+
"source": {
|
137 |
+
"type": "git",
|
138 |
+
"url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git",
|
139 |
+
"reference": "9160de79fcd683b5c99e9c4133728d91529753ea"
|
140 |
+
},
|
141 |
+
"dist": {
|
142 |
+
"type": "zip",
|
143 |
+
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/9160de79fcd683b5c99e9c4133728d91529753ea",
|
144 |
+
"reference": "9160de79fcd683b5c99e9c4133728d91529753ea",
|
145 |
+
"shasum": ""
|
146 |
+
},
|
147 |
+
"require": {
|
148 |
+
"phpcompatibility/php-compatibility": "^9.0"
|
149 |
+
},
|
150 |
+
"require-dev": {
|
151 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4"
|
152 |
+
},
|
153 |
+
"suggest": {
|
154 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
|
155 |
+
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
156 |
},
|
157 |
+
"time": "2018-12-16T19:10:44+00:00",
|
158 |
+
"type": "phpcodesniffer-standard",
|
159 |
+
"installation-source": "dist",
|
160 |
"notification-url": "https://packagist.org/downloads/",
|
161 |
"license": [
|
162 |
"LGPL-3.0-or-later"
|
165 |
{
|
166 |
"name": "Wim Godden",
|
167 |
"role": "lead"
|
168 |
+
},
|
169 |
+
{
|
170 |
+
"name": "Juliette Reinders Folmer",
|
171 |
+
"role": "lead"
|
172 |
}
|
173 |
],
|
174 |
+
"description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.",
|
175 |
+
"homepage": "http://phpcompatibility.com/",
|
176 |
"keywords": [
|
177 |
"compatibility",
|
178 |
+
"paragonie",
|
179 |
"phpcs",
|
180 |
+
"polyfill",
|
181 |
"standards"
|
182 |
]
|
183 |
},
|
184 |
{
|
185 |
"name": "phpcompatibility/phpcompatibility-wp",
|
186 |
+
"version": "2.0.0",
|
187 |
+
"version_normalized": "2.0.0.0",
|
188 |
"source": {
|
189 |
"type": "git",
|
190 |
"url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git",
|
191 |
+
"reference": "cb303f0067cd5b366a41d4fb0e254fb40ff02efd"
|
192 |
},
|
193 |
"dist": {
|
194 |
"type": "zip",
|
195 |
+
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/cb303f0067cd5b366a41d4fb0e254fb40ff02efd",
|
196 |
+
"reference": "cb303f0067cd5b366a41d4fb0e254fb40ff02efd",
|
197 |
"shasum": ""
|
198 |
},
|
199 |
"require": {
|
200 |
+
"phpcompatibility/php-compatibility": "^9.0",
|
201 |
+
"phpcompatibility/phpcompatibility-paragonie": "^1.0"
|
202 |
+
},
|
203 |
+
"require-dev": {
|
204 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
|
205 |
},
|
206 |
"suggest": {
|
207 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
|
208 |
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
209 |
},
|
210 |
+
"time": "2018-10-07T18:31:37+00:00",
|
211 |
"type": "phpcodesniffer-standard",
|
212 |
"installation-source": "dist",
|
213 |
"notification-url": "https://packagist.org/downloads/",
|
224 |
"role": "lead"
|
225 |
}
|
226 |
],
|
227 |
+
"description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.",
|
228 |
"homepage": "http://phpcompatibility.com/",
|
229 |
"keywords": [
|
230 |
"compatibility",
|
235 |
},
|
236 |
{
|
237 |
"name": "squizlabs/php_codesniffer",
|
238 |
+
"version": "2.9.2",
|
239 |
+
"version_normalized": "2.9.2.0",
|
240 |
"source": {
|
241 |
"type": "git",
|
242 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
243 |
+
"reference": "2acf168de78487db620ab4bc524135a13cfe6745"
|
244 |
},
|
245 |
"dist": {
|
246 |
"type": "zip",
|
247 |
+
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745",
|
248 |
+
"reference": "2acf168de78487db620ab4bc524135a13cfe6745",
|
249 |
"shasum": ""
|
250 |
},
|
251 |
"require": {
|
257 |
"require-dev": {
|
258 |
"phpunit/phpunit": "~4.0"
|
259 |
},
|
260 |
+
"time": "2018-11-07T22:31:41+00:00",
|
261 |
"bin": [
|
262 |
"scripts/phpcs",
|
263 |
"scripts/phpcbf"
|
vendor/phpcompatibility/php-compatibility/.gitattributes
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
#
|
2 |
-
# Exclude these files from release archives.
|
3 |
-
# This will also make them unavailable when using Composer with `--prefer-dist`.
|
4 |
-
# If you develop for PHPCompatibility using Composer, use `--prefer-source`.
|
5 |
-
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
|
6 |
-
# https://blog.madewithlove.be/post/gitattributes/
|
7 |
-
#
|
8 |
-
/.coveralls.yml export-ignore
|
9 |
-
/.scrutinizer.yml export-ignore
|
10 |
-
/.travis.yml export-ignore
|
11 |
-
/phpcs.xml.dist export-ignore
|
12 |
-
/phpunit.xml.dist export-ignore
|
13 |
-
/phpunit-travis.xml export-ignore
|
14 |
-
/.github export-ignore
|
15 |
-
/bin export-ignore
|
16 |
-
/PHPCompatibility/Tests export-ignore
|
17 |
-
|
18 |
-
#
|
19 |
-
# Auto detect text files and perform LF normalization
|
20 |
-
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
|
21 |
-
#
|
22 |
-
* text=auto
|
23 |
-
|
24 |
-
#
|
25 |
-
# The above will handle all files NOT found below
|
26 |
-
#
|
27 |
-
*.md text
|
28 |
-
*.php text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/.gitignore
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
.idea/*
|
2 |
-
/vendor/
|
3 |
-
composer.phar
|
4 |
-
composer.lock
|
5 |
-
phpcs.xml
|
6 |
-
phpunit.xml
|
7 |
-
*~
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/ForbiddenAbstractPrivateMethodsSniff.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Abstract private methods are not allowed since PHP 5.1.
|
18 |
+
*
|
19 |
+
* Abstract private methods were supported between PHP 5.0.0 and PHP 5.0.4, but
|
20 |
+
* were then disallowed on the grounds that the behaviours of private and abstract
|
21 |
+
* are mutually exclusive.
|
22 |
+
*
|
23 |
+
* @link https://www.php.net/manual/en/migration51.oop.php#migration51.oop-methods
|
24 |
+
*
|
25 |
+
* PHP version 5.1
|
26 |
+
*
|
27 |
+
* @since 9.2.0
|
28 |
+
*/
|
29 |
+
class ForbiddenAbstractPrivateMethodsSniff extends Sniff
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Valid scopes to check for abstract private methods.
|
34 |
+
*
|
35 |
+
* @since 9.2.0
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
public $ooScopeTokens = array(
|
40 |
+
'T_CLASS' => true,
|
41 |
+
'T_TRAIT' => true,
|
42 |
+
'T_ANON_CLASS' => true,
|
43 |
+
);
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Returns an array of tokens this test wants to listen for.
|
47 |
+
*
|
48 |
+
* @since 9.2.0
|
49 |
+
*
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function register()
|
53 |
+
{
|
54 |
+
return array(\T_FUNCTION);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Processes this test, when one of its tokens is encountered.
|
59 |
+
*
|
60 |
+
* @since 9.2.0
|
61 |
+
*
|
62 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
63 |
+
* @param int $stackPtr The position of the current token
|
64 |
+
* in the stack passed in $tokens.
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function process(File $phpcsFile, $stackPtr)
|
69 |
+
{
|
70 |
+
if ($this->supportsAbove('5.1') === false) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
|
75 |
+
// Function, not method.
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
$properties = $phpcsFile->getMethodProperties($stackPtr);
|
80 |
+
if ($properties['scope'] !== 'private' || $properties['is_abstract'] !== true) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
$phpcsFile->addError(
|
85 |
+
'Abstract methods cannot be declared as private since PHP 5.1',
|
86 |
+
$stackPtr,
|
87 |
+
'Found'
|
88 |
+
);
|
89 |
+
}
|
90 |
+
}
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes}/NewAnonymousClassesSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Anonymous classes are supported in PHP 7.0
|
20 |
*
|
@@ -36,7 +38,7 @@ class NewAnonymousClassesSniff extends Sniff
|
|
36 |
* @var array
|
37 |
*/
|
38 |
private $indicators = array(
|
39 |
-
T_CLASS => T_CLASS,
|
40 |
);
|
41 |
|
42 |
/**
|
@@ -46,12 +48,12 @@ class NewAnonymousClassesSniff extends Sniff
|
|
46 |
*/
|
47 |
public function register()
|
48 |
{
|
49 |
-
if (defined('T_ANON_CLASS')) {
|
50 |
-
$this->indicators[T_ANON_CLASS] = T_ANON_CLASS;
|
51 |
}
|
52 |
|
53 |
-
return array(T_NEW);
|
54 |
-
}
|
55 |
|
56 |
|
57 |
/**
|
@@ -63,14 +65,14 @@ class NewAnonymousClassesSniff extends Sniff
|
|
63 |
*
|
64 |
* @return void
|
65 |
*/
|
66 |
-
public function process(
|
67 |
{
|
68 |
if ($this->supportsBelow('5.6') === false) {
|
69 |
return;
|
70 |
}
|
71 |
|
72 |
$tokens = $phpcsFile->getTokens();
|
73 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
74 |
if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
|
75 |
return;
|
76 |
}
|
@@ -81,8 +83,5 @@ class NewAnonymousClassesSniff extends Sniff
|
|
81 |
$stackPtr,
|
82 |
'Found'
|
83 |
);
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Classes\NewAnonymousClasses.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Classes\NewAnonymousClasses.
|
20 |
*
|
21 |
* Anonymous classes are supported in PHP 7.0
|
22 |
*
|
38 |
* @var array
|
39 |
*/
|
40 |
private $indicators = array(
|
41 |
+
\T_CLASS => \T_CLASS,
|
42 |
);
|
43 |
|
44 |
/**
|
48 |
*/
|
49 |
public function register()
|
50 |
{
|
51 |
+
if (\defined('T_ANON_CLASS')) {
|
52 |
+
$this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
|
53 |
}
|
54 |
|
55 |
+
return array(\T_NEW);
|
56 |
+
}
|
57 |
|
58 |
|
59 |
/**
|
65 |
*
|
66 |
* @return void
|
67 |
*/
|
68 |
+
public function process(File $phpcsFile, $stackPtr)
|
69 |
{
|
70 |
if ($this->supportsBelow('5.6') === false) {
|
71 |
return;
|
72 |
}
|
73 |
|
74 |
$tokens = $phpcsFile->getTokens();
|
75 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
76 |
if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
|
77 |
return;
|
78 |
}
|
83 |
$stackPtr,
|
84 |
'Found'
|
85 |
);
|
86 |
+
}
|
87 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Classes}/NewClassesSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,12 +8,13 @@
|
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
@@ -397,15 +398,38 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
397 |
* This list is automatically added to the $newClasses property
|
398 |
* in the `register()` method.}}
|
399 |
*
|
|
|
|
|
400 |
* @var array(string => array(string => bool))
|
401 |
*/
|
402 |
protected $newExceptions = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
'Exception' => array(
|
404 |
// According to the docs introduced in PHP 5.1, but this appears to be.
|
405 |
// an error. Class was introduced with try/catch keywords in PHP 5.0.
|
406 |
'4.4' => false,
|
407 |
'5.0' => true,
|
408 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
'ErrorException' => array(
|
410 |
'5.0' => false,
|
411 |
'5.1' => true,
|
@@ -434,6 +458,10 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
434 |
'5.0' => false,
|
435 |
'5.1' => true,
|
436 |
),
|
|
|
|
|
|
|
|
|
437 |
'OutOfBoundsException' => array(
|
438 |
'5.0' => false,
|
439 |
'5.1' => true,
|
@@ -446,6 +474,10 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
446 |
'5.0' => false,
|
447 |
'5.1' => true,
|
448 |
),
|
|
|
|
|
|
|
|
|
449 |
'RangeException' => array(
|
450 |
'5.0' => false,
|
451 |
'5.1' => true,
|
@@ -462,26 +494,6 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
462 |
'5.0' => false,
|
463 |
'5.1' => true,
|
464 |
),
|
465 |
-
'DOMException' => array(
|
466 |
-
'4.4' => false,
|
467 |
-
'5.0' => true,
|
468 |
-
),
|
469 |
-
'mysqli_sql_exception' => array(
|
470 |
-
'4.4' => false,
|
471 |
-
'5.0' => true,
|
472 |
-
),
|
473 |
-
'PDOException' => array(
|
474 |
-
'5.0' => false,
|
475 |
-
'5.1' => true,
|
476 |
-
),
|
477 |
-
'ReflectionException' => array(
|
478 |
-
'4.4' => false,
|
479 |
-
'5.0' => true,
|
480 |
-
),
|
481 |
-
'SoapFault' => array(
|
482 |
-
'4.4' => false,
|
483 |
-
'5.0' => true,
|
484 |
-
),
|
485 |
|
486 |
'PharException' => array(
|
487 |
'5.2' => false,
|
@@ -494,8 +506,8 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
494 |
),
|
495 |
|
496 |
'IntlException' => array(
|
497 |
-
'5.
|
498 |
-
'5.5
|
499 |
),
|
500 |
|
501 |
'Error' => array(
|
@@ -522,6 +534,10 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
522 |
'5.6' => false,
|
523 |
'7.0' => true,
|
524 |
),
|
|
|
|
|
|
|
|
|
525 |
'UI\Exception\InvalidArgumentException' => array(
|
526 |
'5.6' => false,
|
527 |
'7.0' => true,
|
@@ -535,6 +551,25 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
535 |
'7.0' => false,
|
536 |
'7.1' => true,
|
537 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
);
|
539 |
|
540 |
|
@@ -553,26 +588,24 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
553 |
$this->newClasses = array_merge($this->newClasses, $this->newExceptions);
|
554 |
|
555 |
$targets = array(
|
556 |
-
T_NEW,
|
557 |
-
T_CLASS,
|
558 |
-
T_DOUBLE_COLON,
|
559 |
-
T_FUNCTION,
|
560 |
-
T_CLOSURE,
|
561 |
-
T_CATCH,
|
562 |
);
|
563 |
|
564 |
-
if (defined('T_ANON_CLASS')) {
|
565 |
-
|
566 |
-
$targets[] = T_ANON_CLASS;
|
567 |
}
|
568 |
|
569 |
-
if (defined('T_RETURN_TYPE')) {
|
570 |
-
$targets[] = T_RETURN_TYPE;
|
571 |
}
|
572 |
|
573 |
return $targets;
|
574 |
-
|
575 |
-
}//end register()
|
576 |
|
577 |
|
578 |
/**
|
@@ -584,7 +617,7 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
584 |
*
|
585 |
* @return void
|
586 |
*/
|
587 |
-
public function process(
|
588 |
{
|
589 |
$tokens = $phpcsFile->getTokens();
|
590 |
|
@@ -613,8 +646,7 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
613 |
$this->processSingularToken($phpcsFile, $stackPtr);
|
614 |
break;
|
615 |
}
|
616 |
-
|
617 |
-
}//end process()
|
618 |
|
619 |
|
620 |
/**
|
@@ -626,7 +658,7 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
626 |
*
|
627 |
* @return void
|
628 |
*/
|
629 |
-
private function processSingularToken(
|
630 |
{
|
631 |
$tokens = $phpcsFile->getTokens();
|
632 |
$FQClassName = '';
|
@@ -657,8 +689,7 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
657 |
'nameLc' => $classNameLc,
|
658 |
);
|
659 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
660 |
-
|
661 |
-
}//end processSingularToken()
|
662 |
|
663 |
|
664 |
/**
|
@@ -672,11 +703,11 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
672 |
*
|
673 |
* @return void
|
674 |
*/
|
675 |
-
private function processFunctionToken(
|
676 |
{
|
677 |
// Retrieve typehints stripped of global NS indicator and/or nullable indicator.
|
678 |
$typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
|
679 |
-
if (empty($typeHints) || is_array($typeHints) === false) {
|
680 |
return;
|
681 |
}
|
682 |
|
@@ -706,7 +737,7 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
706 |
*
|
707 |
* @return void
|
708 |
*/
|
709 |
-
private function processCatchToken(
|
710 |
{
|
711 |
$tokens = $phpcsFile->getTokens();
|
712 |
|
@@ -720,12 +751,12 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
720 |
$name = '';
|
721 |
$listen = array(
|
722 |
// Parts of a (namespaced) class name.
|
723 |
-
T_STRING => true,
|
724 |
-
T_NS_SEPARATOR => true,
|
725 |
// End/split tokens.
|
726 |
-
T_VARIABLE => false,
|
727 |
-
T_BITWISE_OR => false,
|
728 |
-
T_CLOSE_CURLY_BRACKET => false, // Shouldn't be needed as we expect a var before this.
|
729 |
);
|
730 |
|
731 |
for ($i = ($opener + 1); $i < $closer; $i++) {
|
@@ -772,7 +803,7 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
772 |
*
|
773 |
* @return void
|
774 |
*/
|
775 |
-
private function processReturnTypeToken(
|
776 |
{
|
777 |
$returnTypeHint = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
|
778 |
$returnTypeHint = ltrim($returnTypeHint, '\\');
|
@@ -813,6 +844,4 @@ class NewClassesSniff extends AbstractNewFeatureSniff
|
|
813 |
{
|
814 |
return 'The built-in class ' . parent::getErrorMsgTemplate();
|
815 |
}
|
816 |
-
|
817 |
-
|
818 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Classes\NewClassesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\Classes\NewClassesSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
398 |
* This list is automatically added to the $newClasses property
|
399 |
* in the `register()` method.}}
|
400 |
*
|
401 |
+
* {@internal Helper to update this list: https://3v4l.org/MhlUp}}
|
402 |
+
*
|
403 |
* @var array(string => array(string => bool))
|
404 |
*/
|
405 |
protected $newExceptions = array(
|
406 |
+
'com_exception' => array(
|
407 |
+
'4.4' => false,
|
408 |
+
'5.0' => true,
|
409 |
+
),
|
410 |
+
'DOMException' => array(
|
411 |
+
'4.4' => false,
|
412 |
+
'5.0' => true,
|
413 |
+
),
|
414 |
'Exception' => array(
|
415 |
// According to the docs introduced in PHP 5.1, but this appears to be.
|
416 |
// an error. Class was introduced with try/catch keywords in PHP 5.0.
|
417 |
'4.4' => false,
|
418 |
'5.0' => true,
|
419 |
),
|
420 |
+
'ReflectionException' => array(
|
421 |
+
'4.4' => false,
|
422 |
+
'5.0' => true,
|
423 |
+
),
|
424 |
+
'SoapFault' => array(
|
425 |
+
'4.4' => false,
|
426 |
+
'5.0' => true,
|
427 |
+
),
|
428 |
+
'SQLiteException' => array(
|
429 |
+
'4.4' => false,
|
430 |
+
'5.0' => true,
|
431 |
+
),
|
432 |
+
|
433 |
'ErrorException' => array(
|
434 |
'5.0' => false,
|
435 |
'5.1' => true,
|
458 |
'5.0' => false,
|
459 |
'5.1' => true,
|
460 |
),
|
461 |
+
'mysqli_sql_exception' => array(
|
462 |
+
'5.0' => false,
|
463 |
+
'5.1' => true,
|
464 |
+
),
|
465 |
'OutOfBoundsException' => array(
|
466 |
'5.0' => false,
|
467 |
'5.1' => true,
|
474 |
'5.0' => false,
|
475 |
'5.1' => true,
|
476 |
),
|
477 |
+
'PDOException' => array(
|
478 |
+
'5.0' => false,
|
479 |
+
'5.1' => true,
|
480 |
+
),
|
481 |
'RangeException' => array(
|
482 |
'5.0' => false,
|
483 |
'5.1' => true,
|
494 |
'5.0' => false,
|
495 |
'5.1' => true,
|
496 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
|
498 |
'PharException' => array(
|
499 |
'5.2' => false,
|
506 |
),
|
507 |
|
508 |
'IntlException' => array(
|
509 |
+
'5.4' => false,
|
510 |
+
'5.5' => true,
|
511 |
),
|
512 |
|
513 |
'Error' => array(
|
534 |
'5.6' => false,
|
535 |
'7.0' => true,
|
536 |
),
|
537 |
+
'ClosedGeneratorException' => array(
|
538 |
+
'5.6' => false,
|
539 |
+
'7.0' => true,
|
540 |
+
),
|
541 |
'UI\Exception\InvalidArgumentException' => array(
|
542 |
'5.6' => false,
|
543 |
'7.0' => true,
|
551 |
'7.0' => false,
|
552 |
'7.1' => true,
|
553 |
),
|
554 |
+
|
555 |
+
'SodiumException' => array(
|
556 |
+
'7.1' => false,
|
557 |
+
'7.2' => true,
|
558 |
+
),
|
559 |
+
|
560 |
+
'CompileError' => array(
|
561 |
+
'7.2' => false,
|
562 |
+
'7.3' => true,
|
563 |
+
),
|
564 |
+
'JsonException' => array(
|
565 |
+
'7.2' => false,
|
566 |
+
'7.3' => true,
|
567 |
+
),
|
568 |
+
|
569 |
+
'ReflectionReference' => array(
|
570 |
+
'7.3' => false,
|
571 |
+
'7.4' => true,
|
572 |
+
),
|
573 |
);
|
574 |
|
575 |
|
588 |
$this->newClasses = array_merge($this->newClasses, $this->newExceptions);
|
589 |
|
590 |
$targets = array(
|
591 |
+
\T_NEW,
|
592 |
+
\T_CLASS,
|
593 |
+
\T_DOUBLE_COLON,
|
594 |
+
\T_FUNCTION,
|
595 |
+
\T_CLOSURE,
|
596 |
+
\T_CATCH,
|
597 |
);
|
598 |
|
599 |
+
if (\defined('T_ANON_CLASS')) {
|
600 |
+
$targets[] = \T_ANON_CLASS;
|
|
|
601 |
}
|
602 |
|
603 |
+
if (\defined('T_RETURN_TYPE')) {
|
604 |
+
$targets[] = \T_RETURN_TYPE;
|
605 |
}
|
606 |
|
607 |
return $targets;
|
608 |
+
}
|
|
|
609 |
|
610 |
|
611 |
/**
|
617 |
*
|
618 |
* @return void
|
619 |
*/
|
620 |
+
public function process(File $phpcsFile, $stackPtr)
|
621 |
{
|
622 |
$tokens = $phpcsFile->getTokens();
|
623 |
|
646 |
$this->processSingularToken($phpcsFile, $stackPtr);
|
647 |
break;
|
648 |
}
|
649 |
+
}
|
|
|
650 |
|
651 |
|
652 |
/**
|
658 |
*
|
659 |
* @return void
|
660 |
*/
|
661 |
+
private function processSingularToken(File $phpcsFile, $stackPtr)
|
662 |
{
|
663 |
$tokens = $phpcsFile->getTokens();
|
664 |
$FQClassName = '';
|
689 |
'nameLc' => $classNameLc,
|
690 |
);
|
691 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
692 |
+
}
|
|
|
693 |
|
694 |
|
695 |
/**
|
703 |
*
|
704 |
* @return void
|
705 |
*/
|
706 |
+
private function processFunctionToken(File $phpcsFile, $stackPtr)
|
707 |
{
|
708 |
// Retrieve typehints stripped of global NS indicator and/or nullable indicator.
|
709 |
$typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
|
710 |
+
if (empty($typeHints) || \is_array($typeHints) === false) {
|
711 |
return;
|
712 |
}
|
713 |
|
737 |
*
|
738 |
* @return void
|
739 |
*/
|
740 |
+
private function processCatchToken(File $phpcsFile, $stackPtr)
|
741 |
{
|
742 |
$tokens = $phpcsFile->getTokens();
|
743 |
|
751 |
$name = '';
|
752 |
$listen = array(
|
753 |
// Parts of a (namespaced) class name.
|
754 |
+
\T_STRING => true,
|
755 |
+
\T_NS_SEPARATOR => true,
|
756 |
// End/split tokens.
|
757 |
+
\T_VARIABLE => false,
|
758 |
+
\T_BITWISE_OR => false,
|
759 |
+
\T_CLOSE_CURLY_BRACKET => false, // Shouldn't be needed as we expect a var before this.
|
760 |
);
|
761 |
|
762 |
for ($i = ($opener + 1); $i < $closer; $i++) {
|
803 |
*
|
804 |
* @return void
|
805 |
*/
|
806 |
+
private function processReturnTypeToken(File $phpcsFile, $stackPtr)
|
807 |
{
|
808 |
$returnTypeHint = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
|
809 |
$returnTypeHint = ltrim($returnTypeHint, '\\');
|
844 |
{
|
845 |
return 'The built-in class ' . parent::getErrorMsgTemplate();
|
846 |
}
|
847 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Classes}/NewConstVisibilitySniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Visibility for class constants is available since PHP 7.1.
|
20 |
*
|
@@ -33,9 +35,8 @@ class NewConstVisibilitySniff extends Sniff
|
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
-
return array(T_CONST);
|
37 |
-
|
38 |
-
}//end register()
|
39 |
|
40 |
/**
|
41 |
* Processes this test, when one of its tokens is encountered.
|
@@ -46,17 +47,17 @@ class NewConstVisibilitySniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsBelow('7.0') === false) {
|
52 |
return;
|
53 |
}
|
54 |
|
55 |
$tokens = $phpcsFile->getTokens();
|
56 |
-
$prevToken = $phpcsFile->findPrevious(
|
57 |
|
58 |
// Is the previous token a visibility indicator ?
|
59 |
-
if ($prevToken === false ||
|
60 |
return;
|
61 |
}
|
62 |
|
@@ -73,7 +74,5 @@ class NewConstVisibilitySniff extends Sniff
|
|
73 |
'Found',
|
74 |
array($tokens[$prevToken]['content'])
|
75 |
);
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Classes\NewConstVisibility.
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Classes\NewConstVisibility.
|
20 |
*
|
21 |
* Visibility for class constants is available since PHP 7.1.
|
22 |
*
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
+
return array(\T_CONST);
|
39 |
+
}
|
|
|
40 |
|
41 |
/**
|
42 |
* Processes this test, when one of its tokens is encountered.
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
+
public function process(File $phpcsFile, $stackPtr)
|
51 |
{
|
52 |
if ($this->supportsBelow('7.0') === false) {
|
53 |
return;
|
54 |
}
|
55 |
|
56 |
$tokens = $phpcsFile->getTokens();
|
57 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
58 |
|
59 |
// Is the previous token a visibility indicator ?
|
60 |
+
if ($prevToken === false || isset(Tokens::$scopeModifiers[$tokens[$prevToken]['code']]) === false) {
|
61 |
return;
|
62 |
}
|
63 |
|
74 |
'Found',
|
75 |
array($tokens[$prevToken]['content'])
|
76 |
);
|
77 |
+
}
|
78 |
+
}
|
|
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewLateStaticBindingSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 5.3
|
20 |
*
|
@@ -22,7 +24,7 @@ use PHPCompatibility\Sniff;
|
|
22 |
* @package PHPCompatibility
|
23 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
/**
|
28 |
* Returns an array of tokens this test wants to listen for.
|
@@ -31,9 +33,8 @@ class LateStaticBindingSniff extends Sniff
|
|
31 |
*/
|
32 |
public function register()
|
33 |
{
|
34 |
-
return array(T_STATIC);
|
35 |
-
|
36 |
-
}//end register()
|
37 |
|
38 |
|
39 |
/**
|
@@ -45,15 +46,15 @@ class LateStaticBindingSniff extends Sniff
|
|
45 |
*
|
46 |
* @return void
|
47 |
*/
|
48 |
-
public function process(
|
49 |
{
|
50 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
51 |
if ($nextNonEmpty === false) {
|
52 |
return;
|
53 |
}
|
54 |
|
55 |
$tokens = $phpcsFile->getTokens();
|
56 |
-
if ($tokens[$nextNonEmpty]['code'] !== T_DOUBLE_COLON) {
|
57 |
return;
|
58 |
}
|
59 |
|
@@ -74,8 +75,5 @@ class LateStaticBindingSniff extends Sniff
|
|
74 |
'OutsideClassScope'
|
75 |
);
|
76 |
}
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Classes\NewLateStaticBindingSniff.
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Classes\NewLateStaticBindingSniff.
|
20 |
*
|
21 |
* PHP version 5.3
|
22 |
*
|
24 |
* @package PHPCompatibility
|
25 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
*/
|
27 |
+
class NewLateStaticBindingSniff extends Sniff
|
28 |
{
|
29 |
/**
|
30 |
* Returns an array of tokens this test wants to listen for.
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
+
return array(\T_STATIC);
|
37 |
+
}
|
|
|
38 |
|
39 |
|
40 |
/**
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
+
public function process(File $phpcsFile, $stackPtr)
|
50 |
{
|
51 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
52 |
if ($nextNonEmpty === false) {
|
53 |
return;
|
54 |
}
|
55 |
|
56 |
$tokens = $phpcsFile->getTokens();
|
57 |
+
if ($tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
|
58 |
return;
|
59 |
}
|
60 |
|
75 |
'OutsideClassScope'
|
76 |
);
|
77 |
}
|
78 |
+
}
|
79 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Typed properties are available since PHP 7.4.
|
19 |
+
*
|
20 |
+
* PHP version 7.4
|
21 |
+
*
|
22 |
+
* @link https://wiki.php.net/rfc/typed_properties_v2
|
23 |
+
*
|
24 |
+
* @since 9.2.0
|
25 |
+
*/
|
26 |
+
class NewTypedPropertiesSniff extends Sniff
|
27 |
+
{
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Valid property modifier keywords.
|
31 |
+
*
|
32 |
+
* @var array
|
33 |
+
*/
|
34 |
+
private $modifierKeywords = array(
|
35 |
+
\T_PRIVATE => \T_PRIVATE,
|
36 |
+
\T_PROTECTED => \T_PROTECTED,
|
37 |
+
\T_PUBLIC => \T_PUBLIC,
|
38 |
+
\T_STATIC => \T_STATIC,
|
39 |
+
\T_VAR => \T_VAR,
|
40 |
+
);
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns an array of tokens this test wants to listen for.
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function register()
|
49 |
+
{
|
50 |
+
return array(\T_VARIABLE);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Processes this test, when one of its tokens is encountered.
|
55 |
+
*
|
56 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
57 |
+
* @param int $stackPtr The position of the current token in the
|
58 |
+
* stack passed in $tokens.
|
59 |
+
*
|
60 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
61 |
+
* normal file processing.
|
62 |
+
*/
|
63 |
+
public function process(File $phpcsFile, $stackPtr)
|
64 |
+
{
|
65 |
+
if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
|
69 |
+
$find = $this->modifierKeywords;
|
70 |
+
$find += array(
|
71 |
+
\T_SEMICOLON => \T_SEMICOLON,
|
72 |
+
\T_OPEN_CURLY_BRACKET => \T_OPEN_CURLY_BRACKET,
|
73 |
+
);
|
74 |
+
|
75 |
+
$tokens = $phpcsFile->getTokens();
|
76 |
+
$modifier = $phpcsFile->findPrevious($find, ($stackPtr - 1));
|
77 |
+
if ($modifier === false
|
78 |
+
|| $tokens[$modifier]['code'] === \T_SEMICOLON
|
79 |
+
|| $tokens[$modifier]['code'] === \T_OPEN_CURLY_BRACKET
|
80 |
+
) {
|
81 |
+
// Parse error. Ignore.
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$type = $phpcsFile->findNext(Tokens::$emptyTokens, ($modifier + 1), null, true);
|
86 |
+
if ($tokens[$type]['code'] === \T_VARIABLE) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
// Still here ? In that case, this will be a typed property.
|
91 |
+
if ($this->supportsBelow('7.3') === true) {
|
92 |
+
$phpcsFile->addError(
|
93 |
+
'Typed properties are not supported in PHP 7.3 or earlier',
|
94 |
+
$type,
|
95 |
+
'Found'
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
if ($this->supportsAbove('7.4') === true) {
|
100 |
+
// Examine the type to verify it's valid.
|
101 |
+
if ($tokens[$type]['type'] === 'T_NULLABLE'
|
102 |
+
// Needed to support PHPCS < 3.5.0 which doesn't correct to the nullable token type yet.
|
103 |
+
|| $tokens[$type]['code'] === \T_INLINE_THEN
|
104 |
+
) {
|
105 |
+
$type = $phpcsFile->findNext(Tokens::$emptyTokens, ($type + 1), null, true);
|
106 |
+
}
|
107 |
+
|
108 |
+
$content = $tokens[$type]['content'];
|
109 |
+
if ($content === 'void' || $content === 'callable') {
|
110 |
+
$phpcsFile->addError(
|
111 |
+
'%s is not supported as a type declaration for properties',
|
112 |
+
$type,
|
113 |
+
'InvalidType',
|
114 |
+
array($content)
|
115 |
+
);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
$endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1));
|
120 |
+
if ($endOfStatement !== false) {
|
121 |
+
// Don't throw the same error multiple times for multi-property declarations.
|
122 |
+
return ($endOfStatement + 1);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedOrphanedParentSniff.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Classes;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Using "parent" inside a class without parent is deprecated since PHP 7.4.
|
18 |
+
*
|
19 |
+
* This will throw a compile-time error in the future. Currently an error will only
|
20 |
+
* be generated if/when the parent is accessed at run-time.
|
21 |
+
*
|
22 |
+
* @link https://github.com/php/php-src/blob/42cc58ff7b2fee1c17a00dc77a4873552ffb577f/UPGRADING#L303
|
23 |
+
*
|
24 |
+
* PHP version 7.4
|
25 |
+
*
|
26 |
+
* @since 9.2.0
|
27 |
+
*/
|
28 |
+
class RemovedOrphanedParentSniff extends Sniff
|
29 |
+
{
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Class scopes to check the class declaration.
|
33 |
+
*
|
34 |
+
* @since 9.2.0
|
35 |
+
*
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
public $classScopeTokens = array(
|
39 |
+
'T_CLASS' => true,
|
40 |
+
'T_ANON_CLASS' => true,
|
41 |
+
);
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns an array of tokens this test wants to listen for.
|
45 |
+
*
|
46 |
+
* @since 9.2.0
|
47 |
+
*
|
48 |
+
* @return array
|
49 |
+
*/
|
50 |
+
public function register()
|
51 |
+
{
|
52 |
+
return array(\T_PARENT);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Processes this test, when one of its tokens is encountered.
|
57 |
+
*
|
58 |
+
* @since 9.2.0
|
59 |
+
*
|
60 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
61 |
+
* @param int $stackPtr The position of the current token
|
62 |
+
* in the stack passed in $tokens.
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
public function process(File $phpcsFile, $stackPtr)
|
67 |
+
{
|
68 |
+
if ($this->supportsAbove('7.4') === false) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
$tokens = $phpcsFile->getTokens();
|
73 |
+
|
74 |
+
if (empty($tokens[$stackPtr]['conditions']) === true) {
|
75 |
+
// Use within the global namespace. Not our concern.
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* Find the class within which this parent keyword is used.
|
81 |
+
*/
|
82 |
+
$conditions = $tokens[$stackPtr]['conditions'];
|
83 |
+
$conditions = array_reverse($conditions, true);
|
84 |
+
$classPtr = false;
|
85 |
+
|
86 |
+
foreach ($conditions as $ptr => $type) {
|
87 |
+
if (isset($this->classScopeTokens[$tokens[$ptr]['type']])) {
|
88 |
+
$classPtr = $ptr;
|
89 |
+
break;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($classPtr === false) {
|
94 |
+
// Use outside of a class scope. Not our concern.
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
if (isset($tokens[$classPtr]['scope_opener']) === false) {
|
99 |
+
// No scope opener known. Probably a parse error.
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
$extends = $phpcsFile->findNext(\T_EXTENDS, ($classPtr + 1), $tokens[$classPtr]['scope_opener']);
|
104 |
+
if ($extends !== false) {
|
105 |
+
// Class has a parent.
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
$phpcsFile->addError(
|
110 |
+
'Using "parent" inside a class without parent is deprecated since PHP 7.4',
|
111 |
+
$stackPtr,
|
112 |
+
'Deprecated'
|
113 |
+
);
|
114 |
+
}
|
115 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Constants}/NewConstantsSniff.php
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -2148,10 +2149,19 @@ class NewConstantsSniff extends AbstractNewFeatureSniff
|
|
2148 |
'7.0' => true,
|
2149 |
),
|
2150 |
// Tokenizer:
|
|
|
|
|
|
|
|
|
2151 |
'T_SPACESHIP' => array(
|
2152 |
'5.6' => false,
|
2153 |
'7.0' => true,
|
2154 |
),
|
|
|
|
|
|
|
|
|
|
|
2155 |
// Zlib:
|
2156 |
// The first three are in the PHP 5.4 changelog, but the Extension constant page says 7.0.
|
2157 |
'ZLIB_ENCODING_RAW' => array(
|
@@ -2941,6 +2951,644 @@ class NewConstantsSniff extends AbstractNewFeatureSniff
|
|
2941 |
'7.1' => false,
|
2942 |
'7.2' => true,
|
2943 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2944 |
);
|
2945 |
|
2946 |
|
@@ -2951,9 +3599,8 @@ class NewConstantsSniff extends AbstractNewFeatureSniff
|
|
2951 |
*/
|
2952 |
public function register()
|
2953 |
{
|
2954 |
-
return array(T_STRING);
|
2955 |
-
|
2956 |
-
}//end register()
|
2957 |
|
2958 |
/**
|
2959 |
* Processes this test, when one of its tokens is encountered.
|
@@ -2964,7 +3611,7 @@ class NewConstantsSniff extends AbstractNewFeatureSniff
|
|
2964 |
*
|
2965 |
* @return void
|
2966 |
*/
|
2967 |
-
public function process(
|
2968 |
{
|
2969 |
$tokens = $phpcsFile->getTokens();
|
2970 |
$constantName = $tokens[$stackPtr]['content'];
|
@@ -2981,8 +3628,7 @@ class NewConstantsSniff extends AbstractNewFeatureSniff
|
|
2981 |
'name' => $constantName,
|
2982 |
);
|
2983 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
2984 |
-
|
2985 |
-
}//end process()
|
2986 |
|
2987 |
|
2988 |
/**
|
@@ -3007,6 +3653,4 @@ class NewConstantsSniff extends AbstractNewFeatureSniff
|
|
3007 |
{
|
3008 |
return 'The constant "%s" is not present in PHP version %s or earlier';
|
3009 |
}
|
3010 |
-
|
3011 |
-
|
3012 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Constants\NewConstantsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\Constants;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\Constants\NewConstantsSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
2149 |
'7.0' => true,
|
2150 |
),
|
2151 |
// Tokenizer:
|
2152 |
+
'T_COALESCE' => array(
|
2153 |
+
'5.6' => false,
|
2154 |
+
'7.0' => true,
|
2155 |
+
),
|
2156 |
'T_SPACESHIP' => array(
|
2157 |
'5.6' => false,
|
2158 |
'7.0' => true,
|
2159 |
),
|
2160 |
+
'T_YIELD_FROM' => array(
|
2161 |
+
'5.6' => false,
|
2162 |
+
'7.0' => true,
|
2163 |
+
),
|
2164 |
+
|
2165 |
// Zlib:
|
2166 |
// The first three are in the PHP 5.4 changelog, but the Extension constant page says 7.0.
|
2167 |
'ZLIB_ENCODING_RAW' => array(
|
2951 |
'7.1' => false,
|
2952 |
'7.2' => true,
|
2953 |
),
|
2954 |
+
|
2955 |
+
'CURLAUTH_BEARER' => array(
|
2956 |
+
'7.2' => false,
|
2957 |
+
'7.3' => true,
|
2958 |
+
),
|
2959 |
+
'CURLAUTH_GSSAPI' => array(
|
2960 |
+
'7.2' => false,
|
2961 |
+
'7.3' => true,
|
2962 |
+
),
|
2963 |
+
'CURLE_WEIRD_SERVER_REPLY' => array(
|
2964 |
+
'7.2' => false,
|
2965 |
+
'7.3' => true,
|
2966 |
+
),
|
2967 |
+
'CURLINFO_APPCONNECT_TIME_T' => array(
|
2968 |
+
'7.2' => false,
|
2969 |
+
'7.3' => true,
|
2970 |
+
),
|
2971 |
+
'CURLINFO_CONNECT_TIME_T' => array(
|
2972 |
+
'7.2' => false,
|
2973 |
+
'7.3' => true,
|
2974 |
+
),
|
2975 |
+
'CURLINFO_CONTENT_LENGTH_DOWNLOAD_T' => array(
|
2976 |
+
'7.2' => false,
|
2977 |
+
'7.3' => true,
|
2978 |
+
),
|
2979 |
+
'CURLINFO_CONTENT_LENGTH_UPLOAD_T' => array(
|
2980 |
+
'7.2' => false,
|
2981 |
+
'7.3' => true,
|
2982 |
+
),
|
2983 |
+
'CURLINFO_FILETIME_T' => array(
|
2984 |
+
'7.2' => false,
|
2985 |
+
'7.3' => true,
|
2986 |
+
),
|
2987 |
+
'CURLINFO_HTTP_VERSION' => array(
|
2988 |
+
'7.2' => false,
|
2989 |
+
'7.3' => true,
|
2990 |
+
),
|
2991 |
+
'CURLINFO_NAMELOOKUP_TIME_T' => array(
|
2992 |
+
'7.2' => false,
|
2993 |
+
'7.3' => true,
|
2994 |
+
),
|
2995 |
+
'CURLINFO_PRETRANSFER_TIME_T' => array(
|
2996 |
+
'7.2' => false,
|
2997 |
+
'7.3' => true,
|
2998 |
+
),
|
2999 |
+
'CURLINFO_PROTOCOL' => array(
|
3000 |
+
'7.2' => false,
|
3001 |
+
'7.3' => true,
|
3002 |
+
),
|
3003 |
+
'CURLINFO_PROXY_SSL_VERIFYRESULT' => array(
|
3004 |
+
'7.2' => false,
|
3005 |
+
'7.3' => true,
|
3006 |
+
),
|
3007 |
+
'CURLINFO_REDIRECT_TIME_T' => array(
|
3008 |
+
'7.2' => false,
|
3009 |
+
'7.3' => true,
|
3010 |
+
),
|
3011 |
+
'CURLINFO_SCHEME' => array(
|
3012 |
+
'7.2' => false,
|
3013 |
+
'7.3' => true,
|
3014 |
+
),
|
3015 |
+
'CURLINFO_SIZE_DOWNLOAD_T' => array(
|
3016 |
+
'7.2' => false,
|
3017 |
+
'7.3' => true,
|
3018 |
+
),
|
3019 |
+
'CURLINFO_SIZE_UPLOAD_T' => array(
|
3020 |
+
'7.2' => false,
|
3021 |
+
'7.3' => true,
|
3022 |
+
),
|
3023 |
+
'CURLINFO_SPEED_DOWNLOAD_T' => array(
|
3024 |
+
'7.2' => false,
|
3025 |
+
'7.3' => true,
|
3026 |
+
),
|
3027 |
+
'CURLINFO_SPEED_UPLOAD_T' => array(
|
3028 |
+
'7.2' => false,
|
3029 |
+
'7.3' => true,
|
3030 |
+
),
|
3031 |
+
'CURLINFO_STARTTRANSFER_TIME_T' => array(
|
3032 |
+
'7.2' => false,
|
3033 |
+
'7.3' => true,
|
3034 |
+
),
|
3035 |
+
'CURLINFO_TOTAL_TIME_T' => array(
|
3036 |
+
'7.2' => false,
|
3037 |
+
'7.3' => true,
|
3038 |
+
),
|
3039 |
+
'CURL_LOCK_DATA_CONNECT' => array(
|
3040 |
+
'7.2' => false,
|
3041 |
+
'7.3' => true,
|
3042 |
+
),
|
3043 |
+
'CURL_LOCK_DATA_PSL' => array(
|
3044 |
+
'7.2' => false,
|
3045 |
+
'7.3' => true,
|
3046 |
+
),
|
3047 |
+
'CURL_MAX_READ_SIZE' => array(
|
3048 |
+
'7.2' => false,
|
3049 |
+
'7.3' => true,
|
3050 |
+
),
|
3051 |
+
'CURLOPT_ABSTRACT_UNIX_SOCKET' => array(
|
3052 |
+
'7.2' => false,
|
3053 |
+
'7.3' => true,
|
3054 |
+
),
|
3055 |
+
'CURLOPT_DISALLOW_USERNAME_IN_URL' => array(
|
3056 |
+
'7.2' => false,
|
3057 |
+
'7.3' => true,
|
3058 |
+
),
|
3059 |
+
'CURLOPT_DNS_SHUFFLE_ADDRESSES' => array(
|
3060 |
+
'7.2' => false,
|
3061 |
+
'7.3' => true,
|
3062 |
+
),
|
3063 |
+
'CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS' => array(
|
3064 |
+
'7.2' => false,
|
3065 |
+
'7.3' => true,
|
3066 |
+
),
|
3067 |
+
'CURLOPT_HAPROXYPROTOCOL' => array(
|
3068 |
+
'7.2' => false,
|
3069 |
+
'7.3' => true,
|
3070 |
+
),
|
3071 |
+
'CURLOPT_KEEP_SENDING_ON_ERROR' => array(
|
3072 |
+
'7.2' => false,
|
3073 |
+
'7.3' => true,
|
3074 |
+
),
|
3075 |
+
'CURLOPT_PRE_PROXY' => array(
|
3076 |
+
'7.2' => false,
|
3077 |
+
'7.3' => true,
|
3078 |
+
),
|
3079 |
+
'CURLOPT_PROXY_CAINFO' => array(
|
3080 |
+
'7.2' => false,
|
3081 |
+
'7.3' => true,
|
3082 |
+
),
|
3083 |
+
'CURLOPT_PROXY_CAPATH' => array(
|
3084 |
+
'7.2' => false,
|
3085 |
+
'7.3' => true,
|
3086 |
+
),
|
3087 |
+
'CURLOPT_PROXY_CRLFILE' => array(
|
3088 |
+
'7.2' => false,
|
3089 |
+
'7.3' => true,
|
3090 |
+
),
|
3091 |
+
'CURLOPT_PROXY_KEYPASSWD' => array(
|
3092 |
+
'7.2' => false,
|
3093 |
+
'7.3' => true,
|
3094 |
+
),
|
3095 |
+
'CURLOPT_PROXY_PINNEDPUBLICKEY' => array(
|
3096 |
+
'7.2' => false,
|
3097 |
+
'7.3' => true,
|
3098 |
+
),
|
3099 |
+
'CURLOPT_PROXY_SSLCERT' => array(
|
3100 |
+
'7.2' => false,
|
3101 |
+
'7.3' => true,
|
3102 |
+
),
|
3103 |
+
'CURLOPT_PROXY_SSLCERTTYPE' => array(
|
3104 |
+
'7.2' => false,
|
3105 |
+
'7.3' => true,
|
3106 |
+
),
|
3107 |
+
'CURLOPT_PROXY_SSL_CIPHER_LIST' => array(
|
3108 |
+
'7.2' => false,
|
3109 |
+
'7.3' => true,
|
3110 |
+
),
|
3111 |
+
'CURLOPT_PROXY_SSLKEY' => array(
|
3112 |
+
'7.2' => false,
|
3113 |
+
'7.3' => true,
|
3114 |
+
),
|
3115 |
+
'CURLOPT_PROXY_SSLKEYTYPE' => array(
|
3116 |
+
'7.2' => false,
|
3117 |
+
'7.3' => true,
|
3118 |
+
),
|
3119 |
+
'CURLOPT_PROXY_SSL_OPTIONS' => array(
|
3120 |
+
'7.2' => false,
|
3121 |
+
'7.3' => true,
|
3122 |
+
),
|
3123 |
+
'CURLOPT_PROXY_SSL_VERIFYHOST' => array(
|
3124 |
+
'7.2' => false,
|
3125 |
+
'7.3' => true,
|
3126 |
+
),
|
3127 |
+
'CURLOPT_PROXY_SSL_VERIFYPEER' => array(
|
3128 |
+
'7.2' => false,
|
3129 |
+
'7.3' => true,
|
3130 |
+
),
|
3131 |
+
'CURLOPT_PROXY_SSLVERSION' => array(
|
3132 |
+
'7.2' => false,
|
3133 |
+
'7.3' => true,
|
3134 |
+
),
|
3135 |
+
'CURLOPT_PROXY_TLS13_CIPHERS' => array(
|
3136 |
+
'7.2' => false,
|
3137 |
+
'7.3' => true,
|
3138 |
+
),
|
3139 |
+
'CURLOPT_PROXY_TLSAUTH_PASSWORD' => array(
|
3140 |
+
'7.2' => false,
|
3141 |
+
'7.3' => true,
|
3142 |
+
),
|
3143 |
+
'CURLOPT_PROXY_TLSAUTH_TYPE' => array(
|
3144 |
+
'7.2' => false,
|
3145 |
+
'7.3' => true,
|
3146 |
+
),
|
3147 |
+
'CURLOPT_PROXY_TLSAUTH_USERNAME' => array(
|
3148 |
+
'7.2' => false,
|
3149 |
+
'7.3' => true,
|
3150 |
+
),
|
3151 |
+
'CURLOPT_REQUEST_TARGET' => array(
|
3152 |
+
'7.2' => false,
|
3153 |
+
'7.3' => true,
|
3154 |
+
),
|
3155 |
+
'CURLOPT_SOCKS5_AUTH' => array(
|
3156 |
+
'7.2' => false,
|
3157 |
+
'7.3' => true,
|
3158 |
+
),
|
3159 |
+
'CURLOPT_SSH_COMPRESSION' => array(
|
3160 |
+
'7.2' => false,
|
3161 |
+
'7.3' => true,
|
3162 |
+
),
|
3163 |
+
'CURLOPT_SUPPRESS_CONNECT_HEADERS' => array(
|
3164 |
+
'7.2' => false,
|
3165 |
+
'7.3' => true,
|
3166 |
+
),
|
3167 |
+
'CURLOPT_TIMEVALUE_LARGE' => array(
|
3168 |
+
'7.2' => false,
|
3169 |
+
'7.3' => true,
|
3170 |
+
),
|
3171 |
+
'CURLOPT_TLS13_CIPHERS' => array(
|
3172 |
+
'7.2' => false,
|
3173 |
+
'7.3' => true,
|
3174 |
+
),
|
3175 |
+
'CURLPROXY_HTTPS' => array(
|
3176 |
+
'7.2' => false,
|
3177 |
+
'7.3' => true,
|
3178 |
+
),
|
3179 |
+
'CURLSSH_AUTH_GSSAPI' => array(
|
3180 |
+
'7.2' => false,
|
3181 |
+
'7.3' => true,
|
3182 |
+
),
|
3183 |
+
'CURL_SSLVERSION_MAX_DEFAULT' => array(
|
3184 |
+
'7.2' => false,
|
3185 |
+
'7.3' => true,
|
3186 |
+
),
|
3187 |
+
'CURL_SSLVERSION_MAX_NONE' => array(
|
3188 |
+
'7.2' => false,
|
3189 |
+
'7.3' => true,
|
3190 |
+
),
|
3191 |
+
'CURL_SSLVERSION_MAX_TLSv1_0' => array(
|
3192 |
+
'7.2' => false,
|
3193 |
+
'7.3' => true,
|
3194 |
+
),
|
3195 |
+
'CURL_SSLVERSION_MAX_TLSv1_1' => array(
|
3196 |
+
'7.2' => false,
|
3197 |
+
'7.3' => true,
|
3198 |
+
),
|
3199 |
+
'CURL_SSLVERSION_MAX_TLSv1_2' => array(
|
3200 |
+
'7.2' => false,
|
3201 |
+
'7.3' => true,
|
3202 |
+
),
|
3203 |
+
'CURL_SSLVERSION_MAX_TLSv1_3' => array(
|
3204 |
+
'7.2' => false,
|
3205 |
+
'7.3' => true,
|
3206 |
+
),
|
3207 |
+
'CURL_SSLVERSION_TLSv1_3' => array(
|
3208 |
+
'7.2' => false,
|
3209 |
+
'7.3' => true,
|
3210 |
+
),
|
3211 |
+
'CURL_VERSION_ASYNCHDNS' => array(
|
3212 |
+
'7.2' => false,
|
3213 |
+
'7.3' => true,
|
3214 |
+
),
|
3215 |
+
'CURL_VERSION_BROTLI' => array(
|
3216 |
+
'7.2' => false,
|
3217 |
+
'7.3' => true,
|
3218 |
+
),
|
3219 |
+
'CURL_VERSION_CONV' => array(
|
3220 |
+
'7.2' => false,
|
3221 |
+
'7.3' => true,
|
3222 |
+
),
|
3223 |
+
'CURL_VERSION_DEBUG' => array(
|
3224 |
+
'7.2' => false,
|
3225 |
+
'7.3' => true,
|
3226 |
+
),
|
3227 |
+
'CURL_VERSION_GSSAPI' => array(
|
3228 |
+
'7.2' => false,
|
3229 |
+
'7.3' => true,
|
3230 |
+
),
|
3231 |
+
'CURL_VERSION_GSSNEGOTIATE' => array(
|
3232 |
+
'7.2' => false,
|
3233 |
+
'7.3' => true,
|
3234 |
+
),
|
3235 |
+
'CURL_VERSION_HTTPS_PROXY' => array(
|
3236 |
+
'7.2' => false,
|
3237 |
+
'7.3' => true,
|
3238 |
+
),
|
3239 |
+
'CURL_VERSION_IDN' => array(
|
3240 |
+
'7.2' => false,
|
3241 |
+
'7.3' => true,
|
3242 |
+
),
|
3243 |
+
'CURL_VERSION_LARGEFILE' => array(
|
3244 |
+
'7.2' => false,
|
3245 |
+
'7.3' => true,
|
3246 |
+
),
|
3247 |
+
'CURL_VERSION_MULTI_SSL' => array(
|
3248 |
+
'7.2' => false,
|
3249 |
+
'7.3' => true,
|
3250 |
+
),
|
3251 |
+
'CURL_VERSION_NTLM' => array(
|
3252 |
+
'7.2' => false,
|
3253 |
+
'7.3' => true,
|
3254 |
+
),
|
3255 |
+
'CURL_VERSION_NTLM_WB' => array(
|
3256 |
+
'7.2' => false,
|
3257 |
+
'7.3' => true,
|
3258 |
+
),
|
3259 |
+
'CURL_VERSION_SPNEGO' => array(
|
3260 |
+
'7.2' => false,
|
3261 |
+
'7.3' => true,
|
3262 |
+
),
|
3263 |
+
'CURL_VERSION_SSPI' => array(
|
3264 |
+
'7.2' => false,
|
3265 |
+
'7.3' => true,
|
3266 |
+
),
|
3267 |
+
'CURL_VERSION_TLSAUTH_SRP' => array(
|
3268 |
+
'7.2' => false,
|
3269 |
+
'7.3' => true,
|
3270 |
+
),
|
3271 |
+
'FILTER_SANITIZE_ADD_SLASHES' => array(
|
3272 |
+
'7.2' => false,
|
3273 |
+
'7.3' => true,
|
3274 |
+
),
|
3275 |
+
'JSON_THROW_ON_ERROR' => array(
|
3276 |
+
'7.2' => false,
|
3277 |
+
'7.3' => true,
|
3278 |
+
),
|
3279 |
+
'LDAP_CONTROL_MANAGEDSAIT' => array(
|
3280 |
+
'7.2' => false,
|
3281 |
+
'7.3' => true,
|
3282 |
+
),
|
3283 |
+
'LDAP_CONTROL_PROXY_AUTHZ' => array(
|
3284 |
+
'7.2' => false,
|
3285 |
+
'7.3' => true,
|
3286 |
+
),
|
3287 |
+
'LDAP_CONTROL_SUBENTRIES' => array(
|
3288 |
+
'7.2' => false,
|
3289 |
+
'7.3' => true,
|
3290 |
+
),
|
3291 |
+
'LDAP_CONTROL_VALUESRETURNFILTER' => array(
|
3292 |
+
'7.2' => false,
|
3293 |
+
'7.3' => true,
|
3294 |
+
),
|
3295 |
+
'LDAP_CONTROL_ASSERT' => array(
|
3296 |
+
'7.2' => false,
|
3297 |
+
'7.3' => true,
|
3298 |
+
),
|
3299 |
+
'LDAP_CONTROL_PRE_READ' => array(
|
3300 |
+
'7.2' => false,
|
3301 |
+
'7.3' => true,
|
3302 |
+
),
|
3303 |
+
'LDAP_CONTROL_POST_READ' => array(
|
3304 |
+
'7.2' => false,
|
3305 |
+
'7.3' => true,
|
3306 |
+
),
|
3307 |
+
'LDAP_CONTROL_SORTREQUEST' => array(
|
3308 |
+
'7.2' => false,
|
3309 |
+
'7.3' => true,
|
3310 |
+
),
|
3311 |
+
'LDAP_CONTROL_SORTRESPONSE' => array(
|
3312 |
+
'7.2' => false,
|
3313 |
+
'7.3' => true,
|
3314 |
+
),
|
3315 |
+
'LDAP_CONTROL_PAGEDRESULTS' => array(
|
3316 |
+
'7.2' => false,
|
3317 |
+
'7.3' => true,
|
3318 |
+
),
|
3319 |
+
'LDAP_CONTROL_AUTHZID_REQUEST' => array(
|
3320 |
+
'7.2' => false,
|
3321 |
+
'7.3' => true,
|
3322 |
+
),
|
3323 |
+
'LDAP_CONTROL_AUTHZID_RESPONSE' => array(
|
3324 |
+
'7.2' => false,
|
3325 |
+
'7.3' => true,
|
3326 |
+
),
|
3327 |
+
'LDAP_CONTROL_SYNC' => array(
|
3328 |
+
'7.2' => false,
|
3329 |
+
'7.3' => true,
|
3330 |
+
),
|
3331 |
+
'LDAP_CONTROL_SYNC_STATE' => array(
|
3332 |
+
'7.2' => false,
|
3333 |
+
'7.3' => true,
|
3334 |
+
),
|
3335 |
+
'LDAP_CONTROL_SYNC_DONE' => array(
|
3336 |
+
'7.2' => false,
|
3337 |
+
'7.3' => true,
|
3338 |
+
),
|
3339 |
+
'LDAP_CONTROL_DONTUSECOPY' => array(
|
3340 |
+
'7.2' => false,
|
3341 |
+
'7.3' => true,
|
3342 |
+
),
|
3343 |
+
'LDAP_CONTROL_PASSWORDPOLICYREQUEST' => array(
|
3344 |
+
'7.2' => false,
|
3345 |
+
'7.3' => true,
|
3346 |
+
),
|
3347 |
+
'LDAP_CONTROL_PASSWORDPOLICYRESPONSE' => array(
|
3348 |
+
'7.2' => false,
|
3349 |
+
'7.3' => true,
|
3350 |
+
),
|
3351 |
+
'LDAP_CONTROL_X_INCREMENTAL_VALUES' => array(
|
3352 |
+
'7.2' => false,
|
3353 |
+
'7.3' => true,
|
3354 |
+
),
|
3355 |
+
'LDAP_CONTROL_X_DOMAIN_SCOPE' => array(
|
3356 |
+
'7.2' => false,
|
3357 |
+
'7.3' => true,
|
3358 |
+
),
|
3359 |
+
'LDAP_CONTROL_X_PERMISSIVE_MODIFY' => array(
|
3360 |
+
'7.2' => false,
|
3361 |
+
'7.3' => true,
|
3362 |
+
),
|
3363 |
+
'LDAP_CONTROL_X_SEARCH_OPTIONS' => array(
|
3364 |
+
'7.2' => false,
|
3365 |
+
'7.3' => true,
|
3366 |
+
),
|
3367 |
+
'LDAP_CONTROL_X_TREE_DELETE' => array(
|
3368 |
+
'7.2' => false,
|
3369 |
+
'7.3' => true,
|
3370 |
+
),
|
3371 |
+
'LDAP_CONTROL_X_EXTENDED_DN' => array(
|
3372 |
+
'7.2' => false,
|
3373 |
+
'7.3' => true,
|
3374 |
+
),
|
3375 |
+
'LDAP_CONTROL_VLVREQUEST' => array(
|
3376 |
+
'7.2' => false,
|
3377 |
+
'7.3' => true,
|
3378 |
+
),
|
3379 |
+
'LDAP_CONTROL_VLVRESPONSE' => array(
|
3380 |
+
'7.2' => false,
|
3381 |
+
'7.3' => true,
|
3382 |
+
),
|
3383 |
+
'MB_CASE_FOLD' => array(
|
3384 |
+
'7.2' => false,
|
3385 |
+
'7.3' => true,
|
3386 |
+
),
|
3387 |
+
'MB_CASE_UPPER_SIMPLE' => array(
|
3388 |
+
'7.2' => false,
|
3389 |
+
'7.3' => true,
|
3390 |
+
),
|
3391 |
+
'MB_CASE_LOWER_SIMPLE' => array(
|
3392 |
+
'7.2' => false,
|
3393 |
+
'7.3' => true,
|
3394 |
+
),
|
3395 |
+
'MB_CASE_TITLE_SIMPLE' => array(
|
3396 |
+
'7.2' => false,
|
3397 |
+
'7.3' => true,
|
3398 |
+
),
|
3399 |
+
'MB_CASE_FOLD_SIMPLE' => array(
|
3400 |
+
'7.2' => false,
|
3401 |
+
'7.3' => true,
|
3402 |
+
),
|
3403 |
+
'PGSQL_DIAG_SCHEMA_NAME' => array(
|
3404 |
+
'7.2' => false,
|
3405 |
+
'7.3' => true,
|
3406 |
+
),
|
3407 |
+
'PGSQL_DIAG_TABLE_NAME' => array(
|
3408 |
+
'7.2' => false,
|
3409 |
+
'7.3' => true,
|
3410 |
+
),
|
3411 |
+
'PGSQL_DIAG_COLUMN_NAME' => array(
|
3412 |
+
'7.2' => false,
|
3413 |
+
'7.3' => true,
|
3414 |
+
),
|
3415 |
+
'PGSQL_DIAG_DATATYPE_NAME' => array(
|
3416 |
+
'7.2' => false,
|
3417 |
+
'7.3' => true,
|
3418 |
+
),
|
3419 |
+
'PGSQL_DIAG_CONSTRAINT_NAME' => array(
|
3420 |
+
'7.2' => false,
|
3421 |
+
'7.3' => true,
|
3422 |
+
),
|
3423 |
+
'PGSQL_DIAG_SEVERITY_NONLOCALIZED' => array(
|
3424 |
+
'7.2' => false,
|
3425 |
+
'7.3' => true,
|
3426 |
+
),
|
3427 |
+
'PASSWORD_ARGON2ID' => array(
|
3428 |
+
'7.2' => false,
|
3429 |
+
'7.3' => true,
|
3430 |
+
),
|
3431 |
+
'STREAM_CRYPTO_PROTO_SSLv3' => array(
|
3432 |
+
'7.2' => false,
|
3433 |
+
'7.3' => true,
|
3434 |
+
),
|
3435 |
+
'STREAM_CRYPTO_PROTO_TLSv1_0' => array(
|
3436 |
+
'7.2' => false,
|
3437 |
+
'7.3' => true,
|
3438 |
+
),
|
3439 |
+
'STREAM_CRYPTO_PROTO_TLSv1_1' => array(
|
3440 |
+
'7.2' => false,
|
3441 |
+
'7.3' => true,
|
3442 |
+
),
|
3443 |
+
'STREAM_CRYPTO_PROTO_TLSv1_2' => array(
|
3444 |
+
'7.2' => false,
|
3445 |
+
'7.3' => true,
|
3446 |
+
),
|
3447 |
+
|
3448 |
+
'MB_ONIGURUMA_VERSION' => array(
|
3449 |
+
'7.3' => false,
|
3450 |
+
'7.4' => true,
|
3451 |
+
),
|
3452 |
+
'SO_LABEL' => array(
|
3453 |
+
'7.3' => false,
|
3454 |
+
'7.4' => true,
|
3455 |
+
),
|
3456 |
+
'SO_PEERLABEL' => array(
|
3457 |
+
'7.3' => false,
|
3458 |
+
'7.4' => true,
|
3459 |
+
),
|
3460 |
+
'SO_LISTENQLIMIT' => array(
|
3461 |
+
'7.3' => false,
|
3462 |
+
'7.4' => true,
|
3463 |
+
),
|
3464 |
+
'SO_LISTENQLEN' => array(
|
3465 |
+
'7.3' => false,
|
3466 |
+
'7.4' => true,
|
3467 |
+
),
|
3468 |
+
'SO_USER_COOKIE' => array(
|
3469 |
+
'7.3' => false,
|
3470 |
+
'7.4' => true,
|
3471 |
+
),
|
3472 |
+
'PHP_WINDOWS_EVENT_CTRL_C' => array(
|
3473 |
+
'7.3' => false,
|
3474 |
+
'7.4' => true,
|
3475 |
+
),
|
3476 |
+
'PHP_WINDOWS_EVENT_CTRL_BREAK' => array(
|
3477 |
+
'7.3' => false,
|
3478 |
+
'7.4' => true,
|
3479 |
+
),
|
3480 |
+
'TIDY_TAG_ARTICLE' => array(
|
3481 |
+
'7.3' => false,
|
3482 |
+
'7.4' => true,
|
3483 |
+
),
|
3484 |
+
'TIDY_TAG_ASIDE' => array(
|
3485 |
+
'7.3' => false,
|
3486 |
+
'7.4' => true,
|
3487 |
+
),
|
3488 |
+
'TIDY_TAG_AUDIO' => array(
|
3489 |
+
'7.3' => false,
|
3490 |
+
'7.4' => true,
|
3491 |
+
),
|
3492 |
+
'TIDY_TAG_BDI' => array(
|
3493 |
+
'7.3' => false,
|
3494 |
+
'7.4' => true,
|
3495 |
+
),
|
3496 |
+
'TIDY_TAG_CANVAS' => array(
|
3497 |
+
'7.3' => false,
|
3498 |
+
'7.4' => true,
|
3499 |
+
),
|
3500 |
+
'TIDY_TAG_COMMAND' => array(
|
3501 |
+
'7.3' => false,
|
3502 |
+
'7.4' => true,
|
3503 |
+
),
|
3504 |
+
'TIDY_TAG_DATALIST' => array(
|
3505 |
+
'7.3' => false,
|
3506 |
+
'7.4' => true,
|
3507 |
+
),
|
3508 |
+
'TIDY_TAG_DETAILS' => array(
|
3509 |
+
'7.3' => false,
|
3510 |
+
'7.4' => true,
|
3511 |
+
),
|
3512 |
+
'TIDY_TAG_DIALOG' => array(
|
3513 |
+
'7.3' => false,
|
3514 |
+
'7.4' => true,
|
3515 |
+
),
|
3516 |
+
'TIDY_TAG_FIGCAPTION' => array(
|
3517 |
+
'7.3' => false,
|
3518 |
+
'7.4' => true,
|
3519 |
+
),
|
3520 |
+
'TIDY_TAG_FIGURE' => array(
|
3521 |
+
'7.3' => false,
|
3522 |
+
'7.4' => true,
|
3523 |
+
),
|
3524 |
+
'TIDY_TAG_FOOTER' => array(
|
3525 |
+
'7.3' => false,
|
3526 |
+
'7.4' => true,
|
3527 |
+
),
|
3528 |
+
'TIDY_TAG_HEADER' => array(
|
3529 |
+
'7.3' => false,
|
3530 |
+
'7.4' => true,
|
3531 |
+
),
|
3532 |
+
'TIDY_TAG_HGROUP' => array(
|
3533 |
+
'7.3' => false,
|
3534 |
+
'7.4' => true,
|
3535 |
+
),
|
3536 |
+
'TIDY_TAG_MAIN' => array(
|
3537 |
+
'7.3' => false,
|
3538 |
+
'7.4' => true,
|
3539 |
+
),
|
3540 |
+
'TIDY_TAG_MARK' => array(
|
3541 |
+
'7.3' => false,
|
3542 |
+
'7.4' => true,
|
3543 |
+
),
|
3544 |
+
'TIDY_TAG_MENUITEM' => array(
|
3545 |
+
'7.3' => false,
|
3546 |
+
'7.4' => true,
|
3547 |
+
),
|
3548 |
+
'TIDY_TAG_METER' => array(
|
3549 |
+
'7.3' => false,
|
3550 |
+
'7.4' => true,
|
3551 |
+
),
|
3552 |
+
'TIDY_TAG_NAV' => array(
|
3553 |
+
'7.3' => false,
|
3554 |
+
'7.4' => true,
|
3555 |
+
),
|
3556 |
+
'TIDY_TAG_OUTPUT' => array(
|
3557 |
+
'7.3' => false,
|
3558 |
+
'7.4' => true,
|
3559 |
+
),
|
3560 |
+
'TIDY_TAG_PROGRESS' => array(
|
3561 |
+
'7.3' => false,
|
3562 |
+
'7.4' => true,
|
3563 |
+
),
|
3564 |
+
'TIDY_TAG_SECTION' => array(
|
3565 |
+
'7.3' => false,
|
3566 |
+
'7.4' => true,
|
3567 |
+
),
|
3568 |
+
'TIDY_TAG_SOURCE' => array(
|
3569 |
+
'7.3' => false,
|
3570 |
+
'7.4' => true,
|
3571 |
+
),
|
3572 |
+
'TIDY_TAG_SUMMARY' => array(
|
3573 |
+
'7.3' => false,
|
3574 |
+
'7.4' => true,
|
3575 |
+
),
|
3576 |
+
'TIDY_TAG_TEMPLATE' => array(
|
3577 |
+
'7.3' => false,
|
3578 |
+
'7.4' => true,
|
3579 |
+
),
|
3580 |
+
'TIDY_TAG_TIME' => array(
|
3581 |
+
'7.3' => false,
|
3582 |
+
'7.4' => true,
|
3583 |
+
),
|
3584 |
+
'TIDY_TAG_TRACK' => array(
|
3585 |
+
'7.3' => false,
|
3586 |
+
'7.4' => true,
|
3587 |
+
),
|
3588 |
+
'TIDY_TAG_VIDEO' => array(
|
3589 |
+
'7.3' => false,
|
3590 |
+
'7.4' => true,
|
3591 |
+
),
|
3592 |
);
|
3593 |
|
3594 |
|
3599 |
*/
|
3600 |
public function register()
|
3601 |
{
|
3602 |
+
return array(\T_STRING);
|
3603 |
+
}
|
|
|
3604 |
|
3605 |
/**
|
3606 |
* Processes this test, when one of its tokens is encountered.
|
3611 |
*
|
3612 |
* @return void
|
3613 |
*/
|
3614 |
+
public function process(File $phpcsFile, $stackPtr)
|
3615 |
{
|
3616 |
$tokens = $phpcsFile->getTokens();
|
3617 |
$constantName = $tokens[$stackPtr]['content'];
|
3628 |
'name' => $constantName,
|
3629 |
);
|
3630 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
3631 |
+
}
|
|
|
3632 |
|
3633 |
|
3634 |
/**
|
3653 |
{
|
3654 |
return 'The constant "%s" is not present in PHP version %s or earlier';
|
3655 |
}
|
3656 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Constants}/NewMagicClassConstantSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* The special ClassName::class constant is available as of PHP 5.5.0, and allows for
|
20 |
* fully qualified class name resolution at compile.
|
@@ -35,7 +37,7 @@ class NewMagicClassConstantSniff extends Sniff
|
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
-
return array(T_STRING);
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -47,7 +49,7 @@ class NewMagicClassConstantSniff extends Sniff
|
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
-
public function process(
|
51 |
{
|
52 |
if ($this->supportsBelow('5.4') === false) {
|
53 |
return;
|
@@ -59,8 +61,8 @@ class NewMagicClassConstantSniff extends Sniff
|
|
59 |
return;
|
60 |
}
|
61 |
|
62 |
-
$prevToken = $phpcsFile->findPrevious(
|
63 |
-
if ($prevToken === false || $tokens[$prevToken]['code'] !== T_DOUBLE_COLON) {
|
64 |
return;
|
65 |
}
|
66 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Constants\NewMagicClassConstantSniff.
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Constants;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Constants\NewMagicClassConstantSniff.
|
20 |
*
|
21 |
* The special ClassName::class constant is available as of PHP 5.5.0, and allows for
|
22 |
* fully qualified class name resolution at compile.
|
37 |
*/
|
38 |
public function register()
|
39 |
{
|
40 |
+
return array(\T_STRING);
|
41 |
}
|
42 |
|
43 |
/**
|
49 |
*
|
50 |
* @return void
|
51 |
*/
|
52 |
+
public function process(File $phpcsFile, $stackPtr)
|
53 |
{
|
54 |
if ($this->supportsBelow('5.4') === false) {
|
55 |
return;
|
61 |
return;
|
62 |
}
|
63 |
|
64 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
65 |
+
if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_DOUBLE_COLON) {
|
66 |
return;
|
67 |
}
|
68 |
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants}/RemovedConstantsSniff.php
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -272,6 +273,212 @@ class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
|
|
272 |
'7.1' => false,
|
273 |
'7.2' => true,
|
274 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
);
|
276 |
|
277 |
|
@@ -282,9 +489,8 @@ class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
|
|
282 |
*/
|
283 |
public function register()
|
284 |
{
|
285 |
-
return array(T_STRING);
|
286 |
-
|
287 |
-
}//end register()
|
288 |
|
289 |
|
290 |
/**
|
@@ -296,7 +502,7 @@ class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
|
|
296 |
*
|
297 |
* @return void
|
298 |
*/
|
299 |
-
public function process(
|
300 |
{
|
301 |
$tokens = $phpcsFile->getTokens();
|
302 |
$constantName = $tokens[$stackPtr]['content'];
|
@@ -313,8 +519,7 @@ class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
|
|
313 |
'name' => $constantName,
|
314 |
);
|
315 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
316 |
-
|
317 |
-
}//end process()
|
318 |
|
319 |
|
320 |
/**
|
@@ -339,5 +544,4 @@ class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
|
|
339 |
{
|
340 |
return 'The constant "%s" is ';
|
341 |
}
|
342 |
-
|
343 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Constants\RemovedConstantsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\Constants;
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\Constants\RemovedConstantsSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
273 |
'7.1' => false,
|
274 |
'7.2' => true,
|
275 |
),
|
276 |
+
|
277 |
+
'PHPDBG_FILE' => array(
|
278 |
+
'7.3' => true,
|
279 |
+
),
|
280 |
+
'PHPDBG_METHOD' => array(
|
281 |
+
'7.3' => true,
|
282 |
+
),
|
283 |
+
'PHPDBG_LINENO' => array(
|
284 |
+
'7.3' => true,
|
285 |
+
),
|
286 |
+
'PHPDBG_FUNC' => array(
|
287 |
+
'7.3' => true,
|
288 |
+
),
|
289 |
+
'FILTER_FLAG_SCHEME_REQUIRED' => array(
|
290 |
+
'7.3' => false,
|
291 |
+
),
|
292 |
+
'FILTER_FLAG_HOST_REQUIRED' => array(
|
293 |
+
'7.3' => false,
|
294 |
+
),
|
295 |
+
|
296 |
+
'IBASE_BKP_CONVERT' => array(
|
297 |
+
'7.4' => true,
|
298 |
+
),
|
299 |
+
'IBASE_BKP_IGNORE_CHECKSUMS' => array(
|
300 |
+
'7.4' => true,
|
301 |
+
),
|
302 |
+
'IBASE_BKP_IGNORE_LIMBO' => array(
|
303 |
+
'7.4' => true,
|
304 |
+
),
|
305 |
+
'IBASE_BKP_METADATA_ONLY' => array(
|
306 |
+
'7.4' => true,
|
307 |
+
),
|
308 |
+
'IBASE_BKP_NO_GARBAGE_COLLECT' => array(
|
309 |
+
'7.4' => true,
|
310 |
+
),
|
311 |
+
'IBASE_BKP_NON_TRANSPORTABLE' => array(
|
312 |
+
'7.4' => true,
|
313 |
+
),
|
314 |
+
'IBASE_BKP_OLD_DESCRIPTIONS' => array(
|
315 |
+
'7.4' => true,
|
316 |
+
),
|
317 |
+
'IBASE_COMMITTED' => array(
|
318 |
+
'7.4' => true,
|
319 |
+
),
|
320 |
+
'IBASE_CONCURRENCY' => array(
|
321 |
+
'7.4' => true,
|
322 |
+
),
|
323 |
+
'IBASE_CONSISTENCY' => array(
|
324 |
+
'7.4' => true,
|
325 |
+
),
|
326 |
+
'IBASE_DEFAULT' => array(
|
327 |
+
'7.4' => true,
|
328 |
+
),
|
329 |
+
'IBASE_FETCH_ARRAYS' => array(
|
330 |
+
'7.4' => true,
|
331 |
+
),
|
332 |
+
'IBASE_FETCH_BLOBS' => array(
|
333 |
+
'7.4' => true,
|
334 |
+
),
|
335 |
+
'IBASE_NOWAIT' => array(
|
336 |
+
'7.4' => true,
|
337 |
+
),
|
338 |
+
'IBASE_PRP_ACCESS_MODE' => array(
|
339 |
+
'7.4' => true,
|
340 |
+
),
|
341 |
+
'IBASE_PRP_ACTIVATE' => array(
|
342 |
+
'7.4' => true,
|
343 |
+
),
|
344 |
+
'IBASE_PRP_AM_READONLY' => array(
|
345 |
+
'7.4' => true,
|
346 |
+
),
|
347 |
+
'IBASE_PRP_AM_READWRITE' => array(
|
348 |
+
'7.4' => true,
|
349 |
+
),
|
350 |
+
'IBASE_PRP_DENY_NEW_ATTACHMENTS' => array(
|
351 |
+
'7.4' => true,
|
352 |
+
),
|
353 |
+
'IBASE_PRP_DENY_NEW_TRANSACTIONS' => array(
|
354 |
+
'7.4' => true,
|
355 |
+
),
|
356 |
+
'IBASE_PRP_DB_ONLINE' => array(
|
357 |
+
'7.4' => true,
|
358 |
+
),
|
359 |
+
'IBASE_PRP_PAGE_BUFFERS' => array(
|
360 |
+
'7.4' => true,
|
361 |
+
),
|
362 |
+
'IBASE_PRP_RES' => array(
|
363 |
+
'7.4' => true,
|
364 |
+
),
|
365 |
+
'IBASE_PRP_RES_USE_FULL' => array(
|
366 |
+
'7.4' => true,
|
367 |
+
),
|
368 |
+
'IBASE_PRP_RESERVE_SPACE' => array(
|
369 |
+
'7.4' => true,
|
370 |
+
),
|
371 |
+
'IBASE_PRP_SET_SQL_DIALECT' => array(
|
372 |
+
'7.4' => true,
|
373 |
+
),
|
374 |
+
'IBASE_PRP_SHUTDOWN_DB' => array(
|
375 |
+
'7.4' => true,
|
376 |
+
),
|
377 |
+
'IBASE_PRP_SWEEP_INTERVAL' => array(
|
378 |
+
'7.4' => true,
|
379 |
+
),
|
380 |
+
'IBASE_PRP_WM_ASYNC' => array(
|
381 |
+
'7.4' => true,
|
382 |
+
),
|
383 |
+
'IBASE_PRP_WM_SYNC' => array(
|
384 |
+
'7.4' => true,
|
385 |
+
),
|
386 |
+
'IBASE_PRP_WRITE_MODE' => array(
|
387 |
+
'7.4' => true,
|
388 |
+
),
|
389 |
+
'IBASE_READ' => array(
|
390 |
+
'7.4' => true,
|
391 |
+
),
|
392 |
+
'IBASE_RES_CREATE' => array(
|
393 |
+
'7.4' => true,
|
394 |
+
),
|
395 |
+
'IBASE_RES_DEACTIVATE_IDX' => array(
|
396 |
+
'7.4' => true,
|
397 |
+
),
|
398 |
+
'IBASE_RES_NO_SHADOW' => array(
|
399 |
+
'7.4' => true,
|
400 |
+
),
|
401 |
+
'IBASE_RES_NO_VALIDITY' => array(
|
402 |
+
'7.4' => true,
|
403 |
+
),
|
404 |
+
'IBASE_RES_ONE_AT_A_TIME' => array(
|
405 |
+
'7.4' => true,
|
406 |
+
),
|
407 |
+
'IBASE_RES_REPLACE' => array(
|
408 |
+
'7.4' => true,
|
409 |
+
),
|
410 |
+
'IBASE_RES_USE_ALL_SPACE' => array(
|
411 |
+
'7.4' => true,
|
412 |
+
),
|
413 |
+
'IBASE_RPR_CHECK_DB' => array(
|
414 |
+
'7.4' => true,
|
415 |
+
),
|
416 |
+
'IBASE_RPR_FULL' => array(
|
417 |
+
'7.4' => true,
|
418 |
+
),
|
419 |
+
'IBASE_RPR_IGNORE_CHECKSUM' => array(
|
420 |
+
'7.4' => true,
|
421 |
+
),
|
422 |
+
'IBASE_RPR_KILL_SHADOWS' => array(
|
423 |
+
'7.4' => true,
|
424 |
+
),
|
425 |
+
'IBASE_RPR_MEND_DB' => array(
|
426 |
+
'7.4' => true,
|
427 |
+
),
|
428 |
+
'IBASE_RPR_SWEEP_DB' => array(
|
429 |
+
'7.4' => true,
|
430 |
+
),
|
431 |
+
'IBASE_RPR_VALIDATE_DB' => array(
|
432 |
+
'7.4' => true,
|
433 |
+
),
|
434 |
+
'IBASE_STS_DATA_PAGES' => array(
|
435 |
+
'7.4' => true,
|
436 |
+
),
|
437 |
+
'IBASE_STS_DB_LOG' => array(
|
438 |
+
'7.4' => true,
|
439 |
+
),
|
440 |
+
'IBASE_STS_HDR_PAGES' => array(
|
441 |
+
'7.4' => true,
|
442 |
+
),
|
443 |
+
'IBASE_STS_IDX_PAGES' => array(
|
444 |
+
'7.4' => true,
|
445 |
+
),
|
446 |
+
'IBASE_STS_SYS_RELATIONS' => array(
|
447 |
+
'7.4' => true,
|
448 |
+
),
|
449 |
+
'IBASE_SVC_GET_ENV' => array(
|
450 |
+
'7.4' => true,
|
451 |
+
),
|
452 |
+
'IBASE_SVC_GET_ENV_LOCK' => array(
|
453 |
+
'7.4' => true,
|
454 |
+
),
|
455 |
+
'IBASE_SVC_GET_ENV_MSG' => array(
|
456 |
+
'7.4' => true,
|
457 |
+
),
|
458 |
+
'IBASE_SVC_GET_USERS' => array(
|
459 |
+
'7.4' => true,
|
460 |
+
),
|
461 |
+
'IBASE_SVC_IMPLEMENTATION' => array(
|
462 |
+
'7.4' => true,
|
463 |
+
),
|
464 |
+
'IBASE_SVC_SERVER_VERSION' => array(
|
465 |
+
'7.4' => true,
|
466 |
+
),
|
467 |
+
'IBASE_SVC_SVR_DB_INFO' => array(
|
468 |
+
'7.4' => true,
|
469 |
+
),
|
470 |
+
'IBASE_SVC_USER_DBPATH' => array(
|
471 |
+
'7.4' => true,
|
472 |
+
),
|
473 |
+
'IBASE_UNIXTIME' => array(
|
474 |
+
'7.4' => true,
|
475 |
+
),
|
476 |
+
'IBASE_WAIT' => array(
|
477 |
+
'7.4' => true,
|
478 |
+
),
|
479 |
+
'IBASE_WRITE' => array(
|
480 |
+
'7.4' => true,
|
481 |
+
),
|
482 |
);
|
483 |
|
484 |
|
489 |
*/
|
490 |
public function register()
|
491 |
{
|
492 |
+
return array(\T_STRING);
|
493 |
+
}
|
|
|
494 |
|
495 |
|
496 |
/**
|
502 |
*
|
503 |
* @return void
|
504 |
*/
|
505 |
+
public function process(File $phpcsFile, $stackPtr)
|
506 |
{
|
507 |
$tokens = $phpcsFile->getTokens();
|
508 |
$constantName = $tokens[$stackPtr]['content'];
|
519 |
'name' => $constantName,
|
520 |
);
|
521 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
522 |
+
}
|
|
|
523 |
|
524 |
|
525 |
/**
|
544 |
{
|
545 |
return 'The constant "%s" is ';
|
546 |
}
|
547 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/DiscouragedSwitchContinueSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.3
|
6 |
*
|
@@ -9,13 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
-
use
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* PHP 7.3 will throw a warning when continue is used to target a switch control structure.
|
21 |
*
|
@@ -64,12 +65,6 @@ class DiscouragedSwitchContinueSniff extends Sniff
|
|
64 |
\T_CLOSE_PARENTHESIS => \T_CLOSE_PARENTHESIS,
|
65 |
);
|
66 |
|
67 |
-
/**
|
68 |
-
* PHPCS cross-version compatible version of the Tokens::$emptyTokens array.
|
69 |
-
*
|
70 |
-
* @var array
|
71 |
-
*/
|
72 |
-
private $emptyTokens = array();
|
73 |
|
74 |
/**
|
75 |
* Returns an array of tokens this test wants to listen for.
|
@@ -78,14 +73,8 @@ class DiscouragedSwitchContinueSniff extends Sniff
|
|
78 |
*/
|
79 |
public function register()
|
80 |
{
|
81 |
-
$
|
82 |
-
$this->
|
83 |
-
if (version_compare(PHPCSHelper::getVersion(), '2.0', '<')) {
|
84 |
-
$arithmeticTokens = array_combine($arithmeticTokens, $arithmeticTokens);
|
85 |
-
$this->emptyTokens = array_combine($this->emptyTokens, $this->emptyTokens);
|
86 |
-
}
|
87 |
-
|
88 |
-
$this->acceptedLevelTokens = $this->acceptedLevelTokens + $arithmeticTokens + $this->emptyTokens;
|
89 |
|
90 |
return array(\T_SWITCH);
|
91 |
}
|
@@ -99,7 +88,7 @@ class DiscouragedSwitchContinueSniff extends Sniff
|
|
99 |
*
|
100 |
* @return void
|
101 |
*/
|
102 |
-
public function process(
|
103 |
{
|
104 |
if ($this->supportsAbove('7.3') === false) {
|
105 |
return;
|
@@ -178,7 +167,7 @@ class DiscouragedSwitchContinueSniff extends Sniff
|
|
178 |
continue 2;
|
179 |
}
|
180 |
|
181 |
-
if (isset(
|
182 |
continue;
|
183 |
}
|
184 |
|
@@ -231,5 +220,4 @@ class DiscouragedSwitchContinueSniff extends Sniff
|
|
231 |
|
232 |
} while ($caseDefault < $switchCloser);
|
233 |
}
|
234 |
-
|
235 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\DiscouragedSwitchContinue.
|
4 |
*
|
5 |
* PHP version 7.3
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\ControlStructures\DiscouragedSwitchContinue.
|
20 |
*
|
21 |
* PHP 7.3 will throw a warning when continue is used to target a switch control structure.
|
22 |
*
|
65 |
\T_CLOSE_PARENTHESIS => \T_CLOSE_PARENTHESIS,
|
66 |
);
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
/**
|
70 |
* Returns an array of tokens this test wants to listen for.
|
73 |
*/
|
74 |
public function register()
|
75 |
{
|
76 |
+
$this->acceptedLevelTokens += Tokens::$arithmeticTokens;
|
77 |
+
$this->acceptedLevelTokens += Tokens::$emptyTokens;
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
return array(\T_SWITCH);
|
80 |
}
|
88 |
*
|
89 |
* @return void
|
90 |
*/
|
91 |
+
public function process(File $phpcsFile, $stackPtr)
|
92 |
{
|
93 |
if ($this->supportsAbove('7.3') === false) {
|
94 |
return;
|
167 |
continue 2;
|
168 |
}
|
169 |
|
170 |
+
if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
|
171 |
continue;
|
172 |
}
|
173 |
|
220 |
|
221 |
} while ($caseDefault < $switchCloser);
|
222 |
}
|
|
|
223 |
}
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures}/ForbiddenBreakContinueOutsideLoopSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Forbids use of break or continue statements outside of looping structures.
|
20 |
*
|
@@ -33,11 +34,11 @@ class ForbiddenBreakContinueOutsideLoopSniff extends Sniff
|
|
33 |
* @var array
|
34 |
*/
|
35 |
protected $validLoopStructures = array(
|
36 |
-
T_FOR => true,
|
37 |
-
T_FOREACH => true,
|
38 |
-
T_WHILE => true,
|
39 |
-
T_DO => true,
|
40 |
-
T_SWITCH => true,
|
41 |
);
|
42 |
|
43 |
/**
|
@@ -46,8 +47,8 @@ class ForbiddenBreakContinueOutsideLoopSniff extends Sniff
|
|
46 |
* @var array
|
47 |
*/
|
48 |
protected $backCompat = array(
|
49 |
-
T_CASE => true,
|
50 |
-
T_DEFAULT => true,
|
51 |
);
|
52 |
|
53 |
/**
|
@@ -58,11 +59,10 @@ class ForbiddenBreakContinueOutsideLoopSniff extends Sniff
|
|
58 |
public function register()
|
59 |
{
|
60 |
return array(
|
61 |
-
T_BREAK,
|
62 |
-
T_CONTINUE,
|
63 |
);
|
64 |
-
|
65 |
-
}//end register()
|
66 |
|
67 |
/**
|
68 |
* Processes this test, when one of its tokens is encountered.
|
@@ -73,7 +73,7 @@ class ForbiddenBreakContinueOutsideLoopSniff extends Sniff
|
|
73 |
*
|
74 |
* @return void
|
75 |
*/
|
76 |
-
public function process(
|
77 |
{
|
78 |
$tokens = $phpcsFile->getTokens();
|
79 |
$token = $tokens[$stackPtr];
|
@@ -105,7 +105,5 @@ class ForbiddenBreakContinueOutsideLoopSniff extends Sniff
|
|
105 |
}
|
106 |
|
107 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\ForbiddenBreakContinueOutsideLoop.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ControlStructures\ForbiddenBreakContinueOutsideLoop.
|
19 |
*
|
20 |
* Forbids use of break or continue statements outside of looping structures.
|
21 |
*
|
34 |
* @var array
|
35 |
*/
|
36 |
protected $validLoopStructures = array(
|
37 |
+
\T_FOR => true,
|
38 |
+
\T_FOREACH => true,
|
39 |
+
\T_WHILE => true,
|
40 |
+
\T_DO => true,
|
41 |
+
\T_SWITCH => true,
|
42 |
);
|
43 |
|
44 |
/**
|
47 |
* @var array
|
48 |
*/
|
49 |
protected $backCompat = array(
|
50 |
+
\T_CASE => true,
|
51 |
+
\T_DEFAULT => true,
|
52 |
);
|
53 |
|
54 |
/**
|
59 |
public function register()
|
60 |
{
|
61 |
return array(
|
62 |
+
\T_BREAK,
|
63 |
+
\T_CONTINUE,
|
64 |
);
|
65 |
+
}
|
|
|
66 |
|
67 |
/**
|
68 |
* Processes this test, when one of its tokens is encountered.
|
73 |
*
|
74 |
* @return void
|
75 |
*/
|
76 |
+
public function process(File $phpcsFile, $stackPtr)
|
77 |
{
|
78 |
$tokens = $phpcsFile->getTokens();
|
79 |
$token = $tokens[$stackPtr];
|
105 |
}
|
106 |
|
107 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
108 |
+
}
|
109 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/ForbiddenBreakContinueVariableArgumentsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -10,12 +10,14 @@
|
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Forbids variable arguments on break or continue statements.
|
21 |
*
|
@@ -47,9 +49,8 @@ class ForbiddenBreakContinueVariableArgumentsSniff extends Sniff
|
|
47 |
*/
|
48 |
public function register()
|
49 |
{
|
50 |
-
return array(T_BREAK, T_CONTINUE);
|
51 |
-
|
52 |
-
}//end register()
|
53 |
|
54 |
/**
|
55 |
* Processes this test, when one of its tokens is encountered.
|
@@ -60,26 +61,26 @@ class ForbiddenBreakContinueVariableArgumentsSniff extends Sniff
|
|
60 |
*
|
61 |
* @return void
|
62 |
*/
|
63 |
-
public function process(
|
64 |
{
|
65 |
if ($this->supportsAbove('5.4') === false) {
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
$tokens = $phpcsFile->getTokens();
|
70 |
-
$nextSemicolonToken = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr), null, false);
|
71 |
$errorType = '';
|
72 |
for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
|
73 |
if ($tokens[$curToken]['type'] === 'T_STRING') {
|
74 |
// If the next non-whitespace token after the string
|
75 |
// is an opening parenthesis then it's a function call.
|
76 |
-
$openBracket = $phpcsFile->findNext(
|
77 |
-
if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS) {
|
78 |
$errorType = 'variableArgument';
|
79 |
break;
|
80 |
}
|
81 |
|
82 |
-
} elseif (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
|
83 |
$errorType = 'variableArgument';
|
84 |
break;
|
85 |
|
@@ -96,7 +97,5 @@ class ForbiddenBreakContinueVariableArgumentsSniff extends Sniff
|
|
96 |
|
97 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
98 |
}
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\ForbiddenBreakContinueVariableArguments.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\ControlStructures\ForbiddenBreakContinueVariableArguments.
|
21 |
*
|
22 |
* Forbids variable arguments on break or continue statements.
|
23 |
*
|
49 |
*/
|
50 |
public function register()
|
51 |
{
|
52 |
+
return array(\T_BREAK, \T_CONTINUE);
|
53 |
+
}
|
|
|
54 |
|
55 |
/**
|
56 |
* Processes this test, when one of its tokens is encountered.
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
+
public function process(File $phpcsFile, $stackPtr)
|
65 |
{
|
66 |
if ($this->supportsAbove('5.4') === false) {
|
67 |
return;
|
68 |
}
|
69 |
|
70 |
$tokens = $phpcsFile->getTokens();
|
71 |
+
$nextSemicolonToken = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr), null, false);
|
72 |
$errorType = '';
|
73 |
for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
|
74 |
if ($tokens[$curToken]['type'] === 'T_STRING') {
|
75 |
// If the next non-whitespace token after the string
|
76 |
// is an opening parenthesis then it's a function call.
|
77 |
+
$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, $curToken + 1, null, true);
|
78 |
+
if ($tokens[$openBracket]['code'] === \T_OPEN_PARENTHESIS) {
|
79 |
$errorType = 'variableArgument';
|
80 |
break;
|
81 |
}
|
82 |
|
83 |
+
} elseif (\in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
|
84 |
$errorType = 'variableArgument';
|
85 |
break;
|
86 |
|
97 |
|
98 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
99 |
}
|
100 |
+
}
|
101 |
+
}
|
|
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures}/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Switch statements can not have multiple default blocks since PHP 7.0
|
20 |
*
|
@@ -34,9 +35,8 @@ class ForbiddenSwitchWithMultipleDefaultBlocksSniff extends Sniff
|
|
34 |
*/
|
35 |
public function register()
|
36 |
{
|
37 |
-
return array(T_SWITCH);
|
38 |
-
|
39 |
-
}//end register()
|
40 |
|
41 |
/**
|
42 |
* Processes this test, when one of its tokens is encountered.
|
@@ -47,7 +47,7 @@ class ForbiddenSwitchWithMultipleDefaultBlocksSniff extends Sniff
|
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
-
public function process(
|
51 |
{
|
52 |
if ($this->supportsAbove('7.0') === false) {
|
53 |
return;
|
@@ -61,7 +61,7 @@ class ForbiddenSwitchWithMultipleDefaultBlocksSniff extends Sniff
|
|
61 |
$defaultToken = $stackPtr;
|
62 |
$defaultCount = 0;
|
63 |
$targetLevel = $tokens[$stackPtr]['level'] + 1;
|
64 |
-
while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) {
|
65 |
// Same level or one below (= two default cases after each other).
|
66 |
if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
|
67 |
$defaultCount++;
|
@@ -75,6 +75,5 @@ class ForbiddenSwitchWithMultipleDefaultBlocksSniff extends Sniff
|
|
75 |
'Found'
|
76 |
);
|
77 |
}
|
78 |
-
}
|
79 |
-
|
80 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\ForbiddenSwitchWithMultipleDefaultBlocksSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ControlStructures\ForbiddenSwitchWithMultipleDefaultBlocksSniff.
|
19 |
*
|
20 |
* Switch statements can not have multiple default blocks since PHP 7.0
|
21 |
*
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
+
return array(\T_SWITCH);
|
39 |
+
}
|
|
|
40 |
|
41 |
/**
|
42 |
* Processes this test, when one of its tokens is encountered.
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
+
public function process(File $phpcsFile, $stackPtr)
|
51 |
{
|
52 |
if ($this->supportsAbove('7.0') === false) {
|
53 |
return;
|
61 |
$defaultToken = $stackPtr;
|
62 |
$defaultCount = 0;
|
63 |
$targetLevel = $tokens[$stackPtr]['level'] + 1;
|
64 |
+
while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(\T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) {
|
65 |
// Same level or one below (= two default cases after each other).
|
66 |
if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
|
67 |
$defaultCount++;
|
75 |
'Found'
|
76 |
);
|
77 |
}
|
78 |
+
}
|
79 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/NewExecutionDirectivesSniff.php
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
|
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
@@ -66,11 +68,11 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
66 |
*/
|
67 |
public function register()
|
68 |
{
|
69 |
-
$this->ignoreTokens
|
70 |
-
$this->ignoreTokens[T_EQUAL] = T_EQUAL;
|
71 |
|
72 |
-
return array(T_DECLARE);
|
73 |
-
}
|
74 |
|
75 |
|
76 |
/**
|
@@ -82,7 +84,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
82 |
*
|
83 |
* @return void
|
84 |
*/
|
85 |
-
public function process(
|
86 |
{
|
87 |
$tokens = $phpcsFile->getTokens();
|
88 |
|
@@ -94,15 +96,15 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
94 |
return;
|
95 |
}
|
96 |
|
97 |
-
// Deal with PHPCS
|
98 |
-
$openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true);
|
99 |
if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
|
100 |
return;
|
101 |
}
|
102 |
$closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
|
103 |
}
|
104 |
|
105 |
-
$directivePtr = $phpcsFile->findNext(T_STRING, ($openParenthesis + 1), $closeParenthesis, false);
|
106 |
if ($directivePtr === false) {
|
107 |
return;
|
108 |
}
|
@@ -133,8 +135,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
133 |
|
134 |
$this->addWarningOnInvalidValue($phpcsFile, $valuePtr, $directiveContent);
|
135 |
}
|
136 |
-
|
137 |
-
}//end process()
|
138 |
|
139 |
|
140 |
/**
|
@@ -187,7 +188,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
187 |
*/
|
188 |
public function getErrorInfo(array $itemArray, array $itemInfo)
|
189 |
{
|
190 |
-
$errorInfo
|
191 |
$errorInfo['conditional_version'] = '';
|
192 |
$errorInfo['condition'] = '';
|
193 |
|
@@ -195,7 +196,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
195 |
|
196 |
if (empty($versionArray) === false) {
|
197 |
foreach ($versionArray as $version => $present) {
|
198 |
-
if (is_string($present) === true && $this->supportsBelow($version) === true) {
|
199 |
// We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
|
200 |
$errorInfo['conditional_version'] = $version;
|
201 |
$errorInfo['condition'] = $present;
|
@@ -230,7 +231,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
230 |
*
|
231 |
* @return void
|
232 |
*/
|
233 |
-
public function addError(
|
234 |
{
|
235 |
if ($errorInfo['not_in_version'] !== '') {
|
236 |
parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
|
@@ -245,8 +246,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
245 |
|
246 |
$phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
|
247 |
}
|
248 |
-
|
249 |
-
}//end addError()
|
250 |
|
251 |
|
252 |
/**
|
@@ -259,22 +259,22 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
259 |
*
|
260 |
* @return void
|
261 |
*/
|
262 |
-
protected function addWarningOnInvalidValue(
|
263 |
{
|
264 |
$tokens = $phpcsFile->getTokens();
|
265 |
|
266 |
$value = $tokens[$stackPtr]['content'];
|
267 |
-
if (
|
268 |
$value = $this->stripQuotes($value);
|
269 |
}
|
270 |
|
271 |
$isError = false;
|
272 |
if (isset($this->newDirectives[$directive]['valid_values'])) {
|
273 |
-
if (in_array($value, $this->newDirectives[$directive]['valid_values']) === false) {
|
274 |
$isError = true;
|
275 |
}
|
276 |
} elseif (isset($this->newDirectives[$directive]['valid_value_callback'])) {
|
277 |
-
$valid = call_user_func(array($this, $this->newDirectives[$directive]['valid_value_callback']), $value);
|
278 |
if ($valid === false) {
|
279 |
$isError = true;
|
280 |
}
|
@@ -290,7 +290,7 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
290 |
|
291 |
$phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
|
292 |
}
|
293 |
-
}
|
294 |
|
295 |
|
296 |
/**
|
@@ -324,13 +324,11 @@ class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
|
|
324 |
$encodings = mb_list_encodings();
|
325 |
}
|
326 |
|
327 |
-
if (empty($encodings) || is_array($encodings) === false) {
|
328 |
// If we can't test the encoding, let it pass through.
|
329 |
return true;
|
330 |
}
|
331 |
|
332 |
-
return in_array($value, $encodings, true);
|
333 |
}
|
334 |
-
|
335 |
-
|
336 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\NewExecutionDirectivesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ControlStructures\NewExecutionDirectivesSniff.
|
19 |
*
|
20 |
* @category PHP
|
21 |
* @package PHPCompatibility
|
68 |
*/
|
69 |
public function register()
|
70 |
{
|
71 |
+
$this->ignoreTokens = Tokens::$emptyTokens;
|
72 |
+
$this->ignoreTokens[\T_EQUAL] = \T_EQUAL;
|
73 |
|
74 |
+
return array(\T_DECLARE);
|
75 |
+
}
|
76 |
|
77 |
|
78 |
/**
|
84 |
*
|
85 |
* @return void
|
86 |
*/
|
87 |
+
public function process(File $phpcsFile, $stackPtr)
|
88 |
{
|
89 |
$tokens = $phpcsFile->getTokens();
|
90 |
|
96 |
return;
|
97 |
}
|
98 |
|
99 |
+
// Deal with PHPCS 2.3.0-2.3.3 which do not yet set the parenthesis properly for declare statements.
|
100 |
+
$openParenthesis = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true);
|
101 |
if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
|
102 |
return;
|
103 |
}
|
104 |
$closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
|
105 |
}
|
106 |
|
107 |
+
$directivePtr = $phpcsFile->findNext(\T_STRING, ($openParenthesis + 1), $closeParenthesis, false);
|
108 |
if ($directivePtr === false) {
|
109 |
return;
|
110 |
}
|
135 |
|
136 |
$this->addWarningOnInvalidValue($phpcsFile, $valuePtr, $directiveContent);
|
137 |
}
|
138 |
+
}
|
|
|
139 |
|
140 |
|
141 |
/**
|
188 |
*/
|
189 |
public function getErrorInfo(array $itemArray, array $itemInfo)
|
190 |
{
|
191 |
+
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
|
192 |
$errorInfo['conditional_version'] = '';
|
193 |
$errorInfo['condition'] = '';
|
194 |
|
196 |
|
197 |
if (empty($versionArray) === false) {
|
198 |
foreach ($versionArray as $version => $present) {
|
199 |
+
if (\is_string($present) === true && $this->supportsBelow($version) === true) {
|
200 |
// We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
|
201 |
$errorInfo['conditional_version'] = $version;
|
202 |
$errorInfo['condition'] = $present;
|
231 |
*
|
232 |
* @return void
|
233 |
*/
|
234 |
+
public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
|
235 |
{
|
236 |
if ($errorInfo['not_in_version'] !== '') {
|
237 |
parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
|
246 |
|
247 |
$phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
|
248 |
}
|
249 |
+
}
|
|
|
250 |
|
251 |
|
252 |
/**
|
259 |
*
|
260 |
* @return void
|
261 |
*/
|
262 |
+
protected function addWarningOnInvalidValue(File $phpcsFile, $stackPtr, $directive)
|
263 |
{
|
264 |
$tokens = $phpcsFile->getTokens();
|
265 |
|
266 |
$value = $tokens[$stackPtr]['content'];
|
267 |
+
if (isset(Tokens::$stringTokens[$tokens[$stackPtr]['code']]) === true) {
|
268 |
$value = $this->stripQuotes($value);
|
269 |
}
|
270 |
|
271 |
$isError = false;
|
272 |
if (isset($this->newDirectives[$directive]['valid_values'])) {
|
273 |
+
if (\in_array($value, $this->newDirectives[$directive]['valid_values']) === false) {
|
274 |
$isError = true;
|
275 |
}
|
276 |
} elseif (isset($this->newDirectives[$directive]['valid_value_callback'])) {
|
277 |
+
$valid = \call_user_func(array($this, $this->newDirectives[$directive]['valid_value_callback']), $value);
|
278 |
if ($valid === false) {
|
279 |
$isError = true;
|
280 |
}
|
290 |
|
291 |
$phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
|
292 |
}
|
293 |
+
}
|
294 |
|
295 |
|
296 |
/**
|
324 |
$encodings = mb_list_encodings();
|
325 |
}
|
326 |
|
327 |
+
if (empty($encodings) || \is_array($encodings) === false) {
|
328 |
// If we can't test the encoding, let it pass through.
|
329 |
return true;
|
330 |
}
|
331 |
|
332 |
+
return \in_array($value, $encodings, true);
|
333 |
}
|
334 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewForeachExpressionReferencingSniff.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\NewForeachExpressionReferencingSniff.
|
4 |
+
*
|
5 |
+
* PHP version 5.5
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* New `foreach` Expression Referencing.
|
19 |
+
*
|
20 |
+
* Before PHP 5.5.0, referencing $value is only possible if the iterated array
|
21 |
+
* can be referenced (i.e. if it is a variable).
|
22 |
+
*
|
23 |
+
* PHP version 5.5
|
24 |
+
*
|
25 |
+
* @category PHP
|
26 |
+
* @package PHPCompatibility
|
27 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
+
*/
|
29 |
+
class NewForeachExpressionReferencingSniff extends Sniff
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns an array of tokens this test wants to listen for.
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function register()
|
38 |
+
{
|
39 |
+
return array(\T_FOREACH);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Processes this test, when one of its tokens is encountered.
|
44 |
+
*
|
45 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
46 |
+
* @param int $stackPtr The position of the current token in the
|
47 |
+
* stack passed in $tokens.
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function process(File $phpcsFile, $stackPtr)
|
52 |
+
{
|
53 |
+
if ($this->supportsBelow('5.4') === false) {
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$tokens = $phpcsFile->getTokens();
|
58 |
+
|
59 |
+
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
$opener = $tokens[$stackPtr]['parenthesis_opener'];
|
64 |
+
$closer = $tokens[$stackPtr]['parenthesis_closer'];
|
65 |
+
|
66 |
+
$asToken = $phpcsFile->findNext(\T_AS, ($opener + 1), $closer);
|
67 |
+
if ($asToken === false) {
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
|
71 |
+
/*
|
72 |
+
* Note: referencing $key is not allowed in any version, so this should only find referenced $values.
|
73 |
+
* If it does find a referenced key, it would be a parse error anyway.
|
74 |
+
*/
|
75 |
+
$hasReference = $phpcsFile->findNext(\T_BITWISE_AND, ($asToken + 1), $closer);
|
76 |
+
if ($hasReference === false) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
$nestingLevel = 0;
|
81 |
+
if ($asToken !== ($opener + 1) && isset($tokens[$opener + 1]['nested_parenthesis'])) {
|
82 |
+
$nestingLevel = \count($tokens[$opener + 1]['nested_parenthesis']);
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($this->isVariable($phpcsFile, ($opener + 1), $asToken, $nestingLevel) === true) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
// Non-variable detected before the `as` keyword.
|
90 |
+
$phpcsFile->addError(
|
91 |
+
'Referencing $value is only possible if the iterated array is a variable in PHP 5.4 or earlier.',
|
92 |
+
$hasReference,
|
93 |
+
'Found'
|
94 |
+
);
|
95 |
+
}
|
96 |
+
}
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewMagicClassConstantSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewListInForeachSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
@@ -9,15 +9,13 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
*
|
19 |
-
* The special ClassName::class constant is available as of PHP 5.5.0, and allows for
|
20 |
-
* fully qualified class name resolution at compile.
|
21 |
*
|
22 |
* PHP version 5.5
|
23 |
*
|
@@ -25,7 +23,7 @@ use PHPCompatibility\Sniff;
|
|
25 |
* @package PHPCompatibility
|
26 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
|
31 |
/**
|
@@ -35,7 +33,7 @@ class NewMagicClassConstantSniff extends Sniff
|
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
-
return array(
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -47,7 +45,7 @@ class NewMagicClassConstantSniff extends Sniff
|
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
-
public function process(
|
51 |
{
|
52 |
if ($this->supportsBelow('5.4') === false) {
|
53 |
return;
|
@@ -55,18 +53,26 @@ class NewMagicClassConstantSniff extends Sniff
|
|
55 |
|
56 |
$tokens = $phpcsFile->getTokens();
|
57 |
|
58 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
return;
|
60 |
}
|
61 |
|
62 |
-
$
|
63 |
-
if ($
|
64 |
return;
|
65 |
}
|
66 |
|
67 |
$phpcsFile->addError(
|
68 |
-
'
|
69 |
-
$
|
70 |
'Found'
|
71 |
);
|
72 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\NewListInForeachSniff.
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* Detect unpacking nested arrays with list() in a foreach().
|
|
|
|
|
|
|
19 |
*
|
20 |
* PHP version 5.5
|
21 |
*
|
23 |
* @package PHPCompatibility
|
24 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
25 |
*/
|
26 |
+
class NewListInForeachSniff extends Sniff
|
27 |
{
|
28 |
|
29 |
/**
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
+
return array(\T_FOREACH);
|
37 |
}
|
38 |
|
39 |
/**
|
45 |
*
|
46 |
* @return void
|
47 |
*/
|
48 |
+
public function process(File $phpcsFile, $stackPtr)
|
49 |
{
|
50 |
if ($this->supportsBelow('5.4') === false) {
|
51 |
return;
|
53 |
|
54 |
$tokens = $phpcsFile->getTokens();
|
55 |
|
56 |
+
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
+
$opener = $tokens[$stackPtr]['parenthesis_opener'];
|
61 |
+
$closer = $tokens[$stackPtr]['parenthesis_closer'];
|
62 |
+
|
63 |
+
$asToken = $phpcsFile->findNext(\T_AS, ($opener + 1), $closer);
|
64 |
+
if ($asToken === false) {
|
65 |
return;
|
66 |
}
|
67 |
|
68 |
+
$hasList = $phpcsFile->findNext(array(\T_LIST, \T_OPEN_SHORT_ARRAY), ($asToken + 1), $closer);
|
69 |
+
if ($hasList === false) {
|
70 |
return;
|
71 |
}
|
72 |
|
73 |
$phpcsFile->addError(
|
74 |
+
'Unpacking nested arrays with list() in a foreach is not supported in PHP 5.4 or earlier.',
|
75 |
+
$hasList,
|
76 |
'Found'
|
77 |
);
|
78 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ControlStructures}/NewMultiCatchSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Catching multiple exception types in one statement is available since PHP 7.1.
|
20 |
*
|
@@ -33,9 +34,8 @@ class NewMultiCatchSniff extends Sniff
|
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
-
return array(T_CATCH);
|
37 |
-
|
38 |
-
}//end register()
|
39 |
|
40 |
/**
|
41 |
* Processes this test, when one of its tokens is encountered.
|
@@ -46,7 +46,7 @@ class NewMultiCatchSniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsBelow('7.0') === false) {
|
52 |
return;
|
@@ -60,7 +60,7 @@ class NewMultiCatchSniff extends Sniff
|
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
-
$hasBitwiseOr = $phpcsFile->findNext(T_BITWISE_OR, $token['parenthesis_opener'], $token['parenthesis_closer']);
|
64 |
|
65 |
if ($hasBitwiseOr === false) {
|
66 |
return;
|
@@ -71,7 +71,5 @@ class NewMultiCatchSniff extends Sniff
|
|
71 |
$hasBitwiseOr,
|
72 |
'Found'
|
73 |
);
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ControlStructures\NewMultiCatch.
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\ControlStructures;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ControlStructures\NewMultiCatch.
|
19 |
*
|
20 |
* Catching multiple exception types in one statement is available since PHP 7.1.
|
21 |
*
|
34 |
*/
|
35 |
public function register()
|
36 |
{
|
37 |
+
return array(\T_CATCH);
|
38 |
+
}
|
|
|
39 |
|
40 |
/**
|
41 |
* Processes this test, when one of its tokens is encountered.
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
+
public function process(File $phpcsFile, $stackPtr)
|
50 |
{
|
51 |
if ($this->supportsBelow('7.0') === false) {
|
52 |
return;
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
+
$hasBitwiseOr = $phpcsFile->findNext(\T_BITWISE_OR, $token['parenthesis_opener'], $token['parenthesis_closer']);
|
64 |
|
65 |
if ($hasBitwiseOr === false) {
|
66 |
return;
|
71 |
$hasBitwiseOr,
|
72 |
'Found'
|
73 |
);
|
74 |
+
}
|
75 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Extensions}/RemovedExtensionsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,12 +8,14 @@
|
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* Discourages the use of removed extensions. Suggests alternative extensions if available
|
19 |
*
|
@@ -31,7 +33,7 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
31 |
* prefix as one of the removed extensions.
|
32 |
*
|
33 |
* This property can be set from the ruleset, like so:
|
34 |
-
* <rule ref="PHPCompatibility.
|
35 |
* <properties>
|
36 |
* <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
|
37 |
* </properties>
|
@@ -95,6 +97,10 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
95 |
'5.2' => true,
|
96 |
'alternative' => null,
|
97 |
),
|
|
|
|
|
|
|
|
|
98 |
'ingres' => array(
|
99 |
'5.1' => true,
|
100 |
'alternative' => 'pecl/ingres',
|
@@ -110,7 +116,7 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
110 |
),
|
111 |
'mcve' => array(
|
112 |
'5.1' => true,
|
113 |
-
'alternative' => 'pecl/
|
114 |
),
|
115 |
'ming' => array(
|
116 |
'5.3' => true,
|
@@ -145,8 +151,8 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
145 |
'5.1' => true,
|
146 |
'alternative' => null,
|
147 |
),
|
148 |
-
'
|
149 |
-
'5.
|
150 |
'alternative' => null,
|
151 |
),
|
152 |
'sqlite' => array(
|
@@ -166,6 +172,10 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
166 |
'5.1' => true,
|
167 |
'alternative' => 'pecl/ffi',
|
168 |
),
|
|
|
|
|
|
|
|
|
169 |
'yp' => array(
|
170 |
'5.1' => true,
|
171 |
'alternative' => null,
|
@@ -182,9 +192,8 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
182 |
// Handle case-insensitivity of function names.
|
183 |
$this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
|
184 |
|
185 |
-
return array(T_STRING);
|
186 |
-
|
187 |
-
}//end register()
|
188 |
|
189 |
/**
|
190 |
* Processes this test, when one of its tokens is encountered.
|
@@ -195,14 +204,14 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
195 |
*
|
196 |
* @return void
|
197 |
*/
|
198 |
-
public function process(
|
199 |
{
|
200 |
$tokens = $phpcsFile->getTokens();
|
201 |
|
202 |
// Find the next non-empty token.
|
203 |
-
$openBracket = $phpcsFile->findNext(
|
204 |
|
205 |
-
if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
|
206 |
// Not a function call.
|
207 |
return;
|
208 |
}
|
@@ -213,20 +222,20 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
213 |
}
|
214 |
|
215 |
// Find the previous non-empty token.
|
216 |
-
$search =
|
217 |
-
$search[] = T_BITWISE_AND;
|
218 |
$previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
|
219 |
-
if ($tokens[$previous]['code'] === T_FUNCTION) {
|
220 |
// It's a function definition, not a function call.
|
221 |
return;
|
222 |
}
|
223 |
|
224 |
-
if ($tokens[$previous]['code'] === T_NEW) {
|
225 |
// We are creating an object, not calling a function.
|
226 |
return;
|
227 |
}
|
228 |
|
229 |
-
if ($tokens[$previous]['code'] === T_OBJECT_OPERATOR) {
|
230 |
// We are calling a method of an object.
|
231 |
return;
|
232 |
}
|
@@ -248,8 +257,7 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
248 |
break;
|
249 |
}
|
250 |
}
|
251 |
-
|
252 |
-
}//end process()
|
253 |
|
254 |
|
255 |
/**
|
@@ -267,7 +275,7 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
267 |
return false;
|
268 |
}
|
269 |
|
270 |
-
if (is_string($this->functionWhitelist) === true) {
|
271 |
if (strpos($this->functionWhitelist, ',') !== false) {
|
272 |
$this->functionWhitelist = explode(',', $this->functionWhitelist);
|
273 |
} else {
|
@@ -275,14 +283,13 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
275 |
}
|
276 |
}
|
277 |
|
278 |
-
if (is_array($this->functionWhitelist) === true) {
|
279 |
$this->functionWhitelist = array_map('strtolower', $this->functionWhitelist);
|
280 |
-
return in_array($content, $this->functionWhitelist, true);
|
281 |
}
|
282 |
|
283 |
return false;
|
284 |
-
|
285 |
-
}//end isWhiteListed()
|
286 |
|
287 |
|
288 |
/**
|
@@ -307,6 +314,4 @@ class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
|
|
307 |
{
|
308 |
return "Extension '%s' is ";
|
309 |
}
|
310 |
-
|
311 |
-
|
312 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Extensions\RemovedExtensionsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\Extensions;
|
12 |
|
13 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Extensions\RemovedExtensionsSniff.
|
19 |
*
|
20 |
* Discourages the use of removed extensions. Suggests alternative extensions if available
|
21 |
*
|
33 |
* prefix as one of the removed extensions.
|
34 |
*
|
35 |
* This property can be set from the ruleset, like so:
|
36 |
+
* <rule ref="PHPCompatibility.Extensions.RemovedExtensions">
|
37 |
* <properties>
|
38 |
* <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
|
39 |
* </properties>
|
97 |
'5.2' => true,
|
98 |
'alternative' => null,
|
99 |
),
|
100 |
+
'ibase' => array(
|
101 |
+
'7.4' => true,
|
102 |
+
'alternative' => 'pecl/ibase',
|
103 |
+
),
|
104 |
'ingres' => array(
|
105 |
'5.1' => true,
|
106 |
'alternative' => 'pecl/ingres',
|
116 |
),
|
117 |
'mcve' => array(
|
118 |
'5.1' => true,
|
119 |
+
'alternative' => 'pecl/mcve',
|
120 |
),
|
121 |
'ming' => array(
|
122 |
'5.3' => true,
|
151 |
'5.1' => true,
|
152 |
'alternative' => null,
|
153 |
),
|
154 |
+
'pfpro_' => array(
|
155 |
+
'5.1' => true,
|
156 |
'alternative' => null,
|
157 |
),
|
158 |
'sqlite' => array(
|
172 |
'5.1' => true,
|
173 |
'alternative' => 'pecl/ffi',
|
174 |
),
|
175 |
+
'wddx' => array(
|
176 |
+
'7.4' => true,
|
177 |
+
'alternative' => 'pecl/wddx',
|
178 |
+
),
|
179 |
'yp' => array(
|
180 |
'5.1' => true,
|
181 |
'alternative' => null,
|
192 |
// Handle case-insensitivity of function names.
|
193 |
$this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
|
194 |
|
195 |
+
return array(\T_STRING);
|
196 |
+
}
|
|
|
197 |
|
198 |
/**
|
199 |
* Processes this test, when one of its tokens is encountered.
|
204 |
*
|
205 |
* @return void
|
206 |
*/
|
207 |
+
public function process(File $phpcsFile, $stackPtr)
|
208 |
{
|
209 |
$tokens = $phpcsFile->getTokens();
|
210 |
|
211 |
// Find the next non-empty token.
|
212 |
+
$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
213 |
|
214 |
+
if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
|
215 |
// Not a function call.
|
216 |
return;
|
217 |
}
|
222 |
}
|
223 |
|
224 |
// Find the previous non-empty token.
|
225 |
+
$search = Tokens::$emptyTokens;
|
226 |
+
$search[] = \T_BITWISE_AND;
|
227 |
$previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
|
228 |
+
if ($tokens[$previous]['code'] === \T_FUNCTION) {
|
229 |
// It's a function definition, not a function call.
|
230 |
return;
|
231 |
}
|
232 |
|
233 |
+
if ($tokens[$previous]['code'] === \T_NEW) {
|
234 |
// We are creating an object, not calling a function.
|
235 |
return;
|
236 |
}
|
237 |
|
238 |
+
if ($tokens[$previous]['code'] === \T_OBJECT_OPERATOR) {
|
239 |
// We are calling a method of an object.
|
240 |
return;
|
241 |
}
|
257 |
break;
|
258 |
}
|
259 |
}
|
260 |
+
}
|
|
|
261 |
|
262 |
|
263 |
/**
|
275 |
return false;
|
276 |
}
|
277 |
|
278 |
+
if (\is_string($this->functionWhitelist) === true) {
|
279 |
if (strpos($this->functionWhitelist, ',') !== false) {
|
280 |
$this->functionWhitelist = explode(',', $this->functionWhitelist);
|
281 |
} else {
|
283 |
}
|
284 |
}
|
285 |
|
286 |
+
if (\is_array($this->functionWhitelist) === true) {
|
287 |
$this->functionWhitelist = array_map('strtolower', $this->functionWhitelist);
|
288 |
+
return \in_array($content, $this->functionWhitelist, true);
|
289 |
}
|
290 |
|
291 |
return false;
|
292 |
+
}
|
|
|
293 |
|
294 |
|
295 |
/**
|
314 |
{
|
315 |
return "Extension '%s' is ";
|
316 |
}
|
317 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ParameterShadowSuperGlobalsSniff.php → FunctionDeclarations/ForbiddenParameterShadowSuperGlobalsSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -10,13 +10,14 @@
|
|
10 |
* @copyright 2015 Declan Kelly
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
use PHPCompatibility\PHPCSHelper;
|
|
|
17 |
|
18 |
/**
|
19 |
-
* \PHPCompatibility\Sniffs\
|
20 |
*
|
21 |
* Discourages use of superglobals as parameters for functions.
|
22 |
*
|
@@ -29,7 +30,7 @@ use PHPCompatibility\PHPCSHelper;
|
|
29 |
* @author Declan Kelly <declankelly90@gmail.com>
|
30 |
* @copyright 2015 Declan Kelly
|
31 |
*/
|
32 |
-
class
|
33 |
{
|
34 |
|
35 |
/**
|
@@ -40,8 +41,8 @@ class ParameterShadowSuperGlobalsSniff extends Sniff
|
|
40 |
public function register()
|
41 |
{
|
42 |
return array(
|
43 |
-
T_FUNCTION,
|
44 |
-
T_CLOSURE,
|
45 |
);
|
46 |
}
|
47 |
|
@@ -53,7 +54,7 @@ class ParameterShadowSuperGlobalsSniff extends Sniff
|
|
53 |
*
|
54 |
* @return void
|
55 |
*/
|
56 |
-
public function process(
|
57 |
{
|
58 |
if ($this->supportsAbove('5.4') === false) {
|
59 |
return;
|
@@ -61,12 +62,12 @@ class ParameterShadowSuperGlobalsSniff extends Sniff
|
|
61 |
|
62 |
// Get all parameters from function signature.
|
63 |
$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
64 |
-
if (empty($parameters) || is_array($parameters) === false) {
|
65 |
return;
|
66 |
}
|
67 |
|
68 |
foreach ($parameters as $param) {
|
69 |
-
if (
|
70 |
$error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
|
71 |
$errorCode = $this->stringToErrorCode(substr($param['name'], 1)) . 'Found';
|
72 |
$data = array($param['name']);
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\ForbiddenParameterShadowSuperGlobalsSniff
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
10 |
* @copyright 2015 Declan Kelly
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
use PHPCompatibility\PHPCSHelper;
|
17 |
+
use PHP_CodeSniffer_File as File;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\ForbiddenParameterShadowSuperGlobalsSniff
|
21 |
*
|
22 |
* Discourages use of superglobals as parameters for functions.
|
23 |
*
|
30 |
* @author Declan Kelly <declankelly90@gmail.com>
|
31 |
* @copyright 2015 Declan Kelly
|
32 |
*/
|
33 |
+
class ForbiddenParameterShadowSuperGlobalsSniff extends Sniff
|
34 |
{
|
35 |
|
36 |
/**
|
41 |
public function register()
|
42 |
{
|
43 |
return array(
|
44 |
+
\T_FUNCTION,
|
45 |
+
\T_CLOSURE,
|
46 |
);
|
47 |
}
|
48 |
|
54 |
*
|
55 |
* @return void
|
56 |
*/
|
57 |
+
public function process(File $phpcsFile, $stackPtr)
|
58 |
{
|
59 |
if ($this->supportsAbove('5.4') === false) {
|
60 |
return;
|
62 |
|
63 |
// Get all parameters from function signature.
|
64 |
$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
65 |
+
if (empty($parameters) || \is_array($parameters) === false) {
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
foreach ($parameters as $param) {
|
70 |
+
if (isset($this->superglobals[$param['name']]) === true) {
|
71 |
$error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
|
72 |
$errorCode = $this->stringToErrorCode(substr($param['name'], 1)) . 'Found';
|
73 |
$data = array($param['name']);
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ForbiddenFunctionParametersWithSameNameSniff.php → FunctionDeclarations/ForbiddenParametersWithSameNameSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,13 +9,14 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Functions can not have multiple parameters with the same name since PHP 7.0
|
21 |
*
|
@@ -25,7 +26,7 @@ use PHPCompatibility\PHPCSHelper;
|
|
25 |
* @package PHPCompatibility
|
26 |
* @author Wim Godden <wim@cu.be>
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
|
31 |
/**
|
@@ -36,11 +37,10 @@ class ForbiddenFunctionParametersWithSameNameSniff extends Sniff
|
|
36 |
public function register()
|
37 |
{
|
38 |
return array(
|
39 |
-
T_FUNCTION,
|
40 |
-
T_CLOSURE,
|
41 |
);
|
42 |
-
|
43 |
-
}//end register()
|
44 |
|
45 |
/**
|
46 |
* Processes this test, when one of its tokens is encountered.
|
@@ -51,7 +51,7 @@ class ForbiddenFunctionParametersWithSameNameSniff extends Sniff
|
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
-
public function process(
|
55 |
{
|
56 |
if ($this->supportsAbove('7.0') === false) {
|
57 |
return;
|
@@ -66,7 +66,7 @@ class ForbiddenFunctionParametersWithSameNameSniff extends Sniff
|
|
66 |
|
67 |
// Get all parameters from method signature.
|
68 |
$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
69 |
-
if (empty($parameters) || is_array($parameters) === false) {
|
70 |
return;
|
71 |
}
|
72 |
|
@@ -75,14 +75,12 @@ class ForbiddenFunctionParametersWithSameNameSniff extends Sniff
|
|
75 |
$paramNames[] = strtolower($param['name']);
|
76 |
}
|
77 |
|
78 |
-
if (count($paramNames) !== count(array_unique($paramNames))) {
|
79 |
$phpcsFile->addError(
|
80 |
'Functions can not have multiple parameters with the same name since PHP 7.0',
|
81 |
$stackPtr,
|
82 |
'Found'
|
83 |
);
|
84 |
}
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\ForbiddenParametersWithSameName.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\ForbiddenParametersWithSameName.
|
20 |
*
|
21 |
* Functions can not have multiple parameters with the same name since PHP 7.0
|
22 |
*
|
26 |
* @package PHPCompatibility
|
27 |
* @author Wim Godden <wim@cu.be>
|
28 |
*/
|
29 |
+
class ForbiddenParametersWithSameNameSniff extends Sniff
|
30 |
{
|
31 |
|
32 |
/**
|
37 |
public function register()
|
38 |
{
|
39 |
return array(
|
40 |
+
\T_FUNCTION,
|
41 |
+
\T_CLOSURE,
|
42 |
);
|
43 |
+
}
|
|
|
44 |
|
45 |
/**
|
46 |
* Processes this test, when one of its tokens is encountered.
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
+
public function process(File $phpcsFile, $stackPtr)
|
55 |
{
|
56 |
if ($this->supportsAbove('7.0') === false) {
|
57 |
return;
|
66 |
|
67 |
// Get all parameters from method signature.
|
68 |
$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
69 |
+
if (empty($parameters) || \is_array($parameters) === false) {
|
70 |
return;
|
71 |
}
|
72 |
|
75 |
$paramNames[] = strtolower($param['name']);
|
76 |
}
|
77 |
|
78 |
+
if (\count($paramNames) !== \count(array_unique($paramNames))) {
|
79 |
$phpcsFile->addError(
|
80 |
'Functions can not have multiple parameters with the same name since PHP 7.0',
|
81 |
$stackPtr,
|
82 |
'Found'
|
83 |
);
|
84 |
}
|
85 |
+
}
|
86 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenToStringParametersSniff.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHPCompatibility\PHPCSHelper;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* As of PHP 5.3, the __toString() magic method can no longer accept arguments.
|
19 |
+
*
|
20 |
+
* Sister-sniff to PHPCompatibility.MethodUse.ForbiddenToStringParameters.
|
21 |
+
*
|
22 |
+
* @link https://www.php.net/manual/en/migration53.incompatible.php
|
23 |
+
*
|
24 |
+
* PHP version 5.3
|
25 |
+
*
|
26 |
+
* @since 9.2.0
|
27 |
+
*/
|
28 |
+
class ForbiddenToStringParametersSniff extends Sniff
|
29 |
+
{
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Valid scopes for the __toString() method to live in.
|
33 |
+
*
|
34 |
+
* @since 9.2.0
|
35 |
+
*
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
public $ooScopeTokens = array(
|
39 |
+
'T_CLASS' => true,
|
40 |
+
'T_INTERFACE' => true,
|
41 |
+
'T_TRAIT' => true,
|
42 |
+
'T_ANON_CLASS' => true,
|
43 |
+
);
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Returns an array of tokens this test wants to listen for.
|
47 |
+
*
|
48 |
+
* @since 9.2.0
|
49 |
+
*
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function register()
|
53 |
+
{
|
54 |
+
return array(\T_FUNCTION);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Processes this test, when one of its tokens is encountered.
|
59 |
+
*
|
60 |
+
* @since 9.2.0
|
61 |
+
*
|
62 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
63 |
+
* @param int $stackPtr The position of the current token
|
64 |
+
* in the stack passed in $tokens.
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function process(File $phpcsFile, $stackPtr)
|
69 |
+
{
|
70 |
+
if ($this->supportsAbove('5.3') === false) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
$functionName = $phpcsFile->getDeclarationName($stackPtr);
|
75 |
+
if (strtolower($functionName) !== '__tostring') {
|
76 |
+
// Not the right function.
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
|
81 |
+
// Function, not method.
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
86 |
+
if (empty($params)) {
|
87 |
+
// Function declared without parameters.
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
|
91 |
+
$phpcsFile->addError(
|
92 |
+
'The __toString() magic method can no longer accept arguments since PHP 5.3',
|
93 |
+
$stackPtr,
|
94 |
+
'Declared'
|
95 |
+
);
|
96 |
+
}
|
97 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ForbiddenClosureUseVariableNamesSniff.php → FunctionDeclarations/ForbiddenVariableNamesInClosureUseSniff.php}
RENAMED
@@ -9,10 +9,12 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
* PHP 7.1 Forbidden variable names in closure use statements.
|
@@ -26,7 +28,7 @@ use PHPCompatibility\PHPCSHelper;
|
|
26 |
* @package PHPCompatibility
|
27 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
*/
|
29 |
-
class
|
30 |
{
|
31 |
|
32 |
/**
|
@@ -36,9 +38,8 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
36 |
*/
|
37 |
public function register()
|
38 |
{
|
39 |
-
return array(T_USE);
|
40 |
-
|
41 |
-
}//end register()
|
42 |
|
43 |
/**
|
44 |
* Processes this test, when one of its tokens is encountered.
|
@@ -49,7 +50,7 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
49 |
*
|
50 |
* @return void
|
51 |
*/
|
52 |
-
public function process(
|
53 |
{
|
54 |
if ($this->supportsAbove('7.1') === false) {
|
55 |
return;
|
@@ -58,16 +59,16 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
58 |
$tokens = $phpcsFile->getTokens();
|
59 |
|
60 |
// Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
|
61 |
-
$previousNonEmpty = $phpcsFile->findPrevious(
|
62 |
-
if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== T_CLOSE_PARENTHESIS
|
63 |
|| isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
|
64 |
) {
|
65 |
return;
|
66 |
}
|
67 |
|
68 |
// ... and (a variable within) parenthesis after it.
|
69 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
70 |
-
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) {
|
71 |
return;
|
72 |
}
|
73 |
|
@@ -76,8 +77,8 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
76 |
return;
|
77 |
}
|
78 |
|
79 |
-
$closurePtr = $phpcsFile->findPrevious(
|
80 |
-
if ($closurePtr === false || $tokens[$closurePtr]['code'] !== T_CLOSURE) {
|
81 |
return;
|
82 |
}
|
83 |
|
@@ -87,7 +88,7 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
87 |
$errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s';
|
88 |
|
89 |
for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
|
90 |
-
if ($tokens[$i]['code'] !== T_VARIABLE) {
|
91 |
continue;
|
92 |
}
|
93 |
|
@@ -98,7 +99,7 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
98 |
continue;
|
99 |
}
|
100 |
|
101 |
-
if (
|
102 |
$phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
|
103 |
continue;
|
104 |
}
|
@@ -113,7 +114,5 @@ class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
|
113 |
}
|
114 |
}
|
115 |
}
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
}//end class
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
* PHP 7.1 Forbidden variable names in closure use statements.
|
28 |
* @package PHPCompatibility
|
29 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
30 |
*/
|
31 |
+
class ForbiddenVariableNamesInClosureUseSniff extends Sniff
|
32 |
{
|
33 |
|
34 |
/**
|
38 |
*/
|
39 |
public function register()
|
40 |
{
|
41 |
+
return array(\T_USE);
|
42 |
+
}
|
|
|
43 |
|
44 |
/**
|
45 |
* Processes this test, when one of its tokens is encountered.
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
53 |
+
public function process(File $phpcsFile, $stackPtr)
|
54 |
{
|
55 |
if ($this->supportsAbove('7.1') === false) {
|
56 |
return;
|
59 |
$tokens = $phpcsFile->getTokens();
|
60 |
|
61 |
// Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
|
62 |
+
$previousNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
63 |
+
if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== \T_CLOSE_PARENTHESIS
|
64 |
|| isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
|
65 |
) {
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
// ... and (a variable within) parenthesis after it.
|
70 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
71 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
|
72 |
return;
|
73 |
}
|
74 |
|
77 |
return;
|
78 |
}
|
79 |
|
80 |
+
$closurePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true);
|
81 |
+
if ($closurePtr === false || $tokens[$closurePtr]['code'] !== \T_CLOSURE) {
|
82 |
return;
|
83 |
}
|
84 |
|
88 |
$errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s';
|
89 |
|
90 |
for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
|
91 |
+
if ($tokens[$i]['code'] !== \T_VARIABLE) {
|
92 |
continue;
|
93 |
}
|
94 |
|
99 |
continue;
|
100 |
}
|
101 |
|
102 |
+
if (isset($this->superglobals[$variableName]) === true) {
|
103 |
$phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
|
104 |
continue;
|
105 |
}
|
114 |
}
|
115 |
}
|
116 |
}
|
117 |
+
}
|
118 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NewClosureSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Closures are available since PHP 5.3
|
20 |
*
|
@@ -33,9 +35,8 @@ class NewClosureSniff extends Sniff
|
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
-
return array(T_CLOSURE);
|
37 |
-
|
38 |
-
}//end register()
|
39 |
|
40 |
/**
|
41 |
* Processes this test, when one of its tokens is encountered.
|
@@ -46,7 +47,7 @@ class NewClosureSniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsBelow('5.2')) {
|
52 |
$phpcsFile->addError(
|
@@ -154,8 +155,7 @@ class NewClosureSniff extends Sniff
|
|
154 |
|
155 |
// Prevent double reporting for nested closures.
|
156 |
return $scopeEnd;
|
157 |
-
|
158 |
-
}//end process()
|
159 |
|
160 |
|
161 |
/**
|
@@ -167,12 +167,12 @@ class NewClosureSniff extends Sniff
|
|
167 |
*
|
168 |
* @return bool
|
169 |
*/
|
170 |
-
protected function isClosureStatic(
|
171 |
{
|
172 |
$tokens = $phpcsFile->getTokens();
|
173 |
-
$prevToken = $phpcsFile->findPrevious(
|
174 |
|
175 |
-
return ($prevToken !== false && $tokens[$prevToken]['code'] === T_STATIC);
|
176 |
}
|
177 |
|
178 |
|
@@ -186,7 +186,7 @@ class NewClosureSniff extends Sniff
|
|
186 |
* @return int|false The stackPtr to the first $this usage if found or false if
|
187 |
* $this is not used.
|
188 |
*/
|
189 |
-
protected function findThisUsageInClosure(
|
190 |
{
|
191 |
// Make sure the $startToken is valid.
|
192 |
if ($startToken >= $endToken) {
|
@@ -194,7 +194,7 @@ class NewClosureSniff extends Sniff
|
|
194 |
}
|
195 |
|
196 |
return $phpcsFile->findNext(
|
197 |
-
T_VARIABLE,
|
198 |
$startToken,
|
199 |
$endToken,
|
200 |
false,
|
@@ -212,7 +212,7 @@ class NewClosureSniff extends Sniff
|
|
212 |
* @return int|false The stackPtr to the first classRef usage if found or false if
|
213 |
* they are not used.
|
214 |
*/
|
215 |
-
protected function findClassRefUsageInClosure(
|
216 |
{
|
217 |
// Make sure the $startToken is valid.
|
218 |
if ($startToken >= $endToken) {
|
@@ -220,19 +220,18 @@ class NewClosureSniff extends Sniff
|
|
220 |
}
|
221 |
|
222 |
$tokens = $phpcsFile->getTokens();
|
223 |
-
$classRef = $phpcsFile->findNext(array(T_SELF, T_PARENT, T_STATIC), $startToken, $endToken);
|
224 |
|
225 |
-
if ($classRef === false || $tokens[$classRef]['code'] !== T_STATIC) {
|
226 |
return $classRef;
|
227 |
}
|
228 |
|
229 |
// T_STATIC, make sure it is used as a class reference.
|
230 |
-
$next = $phpcsFile->findNext(
|
231 |
-
if ($next === false || $tokens[$next]['code'] !== T_DOUBLE_COLON) {
|
232 |
return false;
|
233 |
}
|
234 |
|
235 |
return $classRef;
|
236 |
}
|
237 |
-
|
238 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewClosure.
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewClosure.
|
20 |
*
|
21 |
* Closures are available since PHP 5.3
|
22 |
*
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
+
return array(\T_CLOSURE);
|
39 |
+
}
|
|
|
40 |
|
41 |
/**
|
42 |
* Processes this test, when one of its tokens is encountered.
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
+
public function process(File $phpcsFile, $stackPtr)
|
51 |
{
|
52 |
if ($this->supportsBelow('5.2')) {
|
53 |
$phpcsFile->addError(
|
155 |
|
156 |
// Prevent double reporting for nested closures.
|
157 |
return $scopeEnd;
|
158 |
+
}
|
|
|
159 |
|
160 |
|
161 |
/**
|
167 |
*
|
168 |
* @return bool
|
169 |
*/
|
170 |
+
protected function isClosureStatic(File $phpcsFile, $stackPtr)
|
171 |
{
|
172 |
$tokens = $phpcsFile->getTokens();
|
173 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
174 |
|
175 |
+
return ($prevToken !== false && $tokens[$prevToken]['code'] === \T_STATIC);
|
176 |
}
|
177 |
|
178 |
|
186 |
* @return int|false The stackPtr to the first $this usage if found or false if
|
187 |
* $this is not used.
|
188 |
*/
|
189 |
+
protected function findThisUsageInClosure(File $phpcsFile, $startToken, $endToken)
|
190 |
{
|
191 |
// Make sure the $startToken is valid.
|
192 |
if ($startToken >= $endToken) {
|
194 |
}
|
195 |
|
196 |
return $phpcsFile->findNext(
|
197 |
+
\T_VARIABLE,
|
198 |
$startToken,
|
199 |
$endToken,
|
200 |
false,
|
212 |
* @return int|false The stackPtr to the first classRef usage if found or false if
|
213 |
* they are not used.
|
214 |
*/
|
215 |
+
protected function findClassRefUsageInClosure(File $phpcsFile, $startToken, $endToken)
|
216 |
{
|
217 |
// Make sure the $startToken is valid.
|
218 |
if ($startToken >= $endToken) {
|
220 |
}
|
221 |
|
222 |
$tokens = $phpcsFile->getTokens();
|
223 |
+
$classRef = $phpcsFile->findNext(array(\T_SELF, \T_PARENT, \T_STATIC), $startToken, $endToken);
|
224 |
|
225 |
+
if ($classRef === false || $tokens[$classRef]['code'] !== \T_STATIC) {
|
226 |
return $classRef;
|
227 |
}
|
228 |
|
229 |
// T_STATIC, make sure it is used as a class reference.
|
230 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($classRef + 1), $endToken, true);
|
231 |
+
if ($next === false || $tokens[$next]['code'] !== \T_DOUBLE_COLON) {
|
232 |
return false;
|
233 |
}
|
234 |
|
235 |
return $classRef;
|
236 |
}
|
237 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewExceptionsFromToStringSniff.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* As of PHP 7.4, throwing exceptions from a __toString() method is allowed.
|
18 |
+
*
|
19 |
+
* @link https://wiki.php.net/rfc/tostring_exceptions
|
20 |
+
*
|
21 |
+
* PHP version 7.4
|
22 |
+
*
|
23 |
+
* @since 9.2.0
|
24 |
+
*/
|
25 |
+
class NewExceptionsFromToStringSniff extends Sniff
|
26 |
+
{
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Valid scopes for the __toString() method to live in.
|
30 |
+
*
|
31 |
+
* @since 9.2.0
|
32 |
+
*
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
public $ooScopeTokens = array(
|
36 |
+
'T_CLASS' => true,
|
37 |
+
'T_TRAIT' => true,
|
38 |
+
'T_ANON_CLASS' => true,
|
39 |
+
);
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns an array of tokens this test wants to listen for.
|
43 |
+
*
|
44 |
+
* @since 9.2.0
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function register()
|
49 |
+
{
|
50 |
+
return array(\T_FUNCTION);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Processes this test, when one of its tokens is encountered.
|
55 |
+
*
|
56 |
+
* @since 9.2.0
|
57 |
+
*
|
58 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
59 |
+
* @param int $stackPtr The position of the current token
|
60 |
+
* in the stack passed in $tokens.
|
61 |
+
*
|
62 |
+
* @return void
|
63 |
+
*/
|
64 |
+
public function process(File $phpcsFile, $stackPtr)
|
65 |
+
{
|
66 |
+
if ($this->supportsBelow('7.3') === false) {
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
$tokens = $phpcsFile->getTokens();
|
71 |
+
if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
|
72 |
+
// Abstract function, interface function, live coding or parse error.
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$functionName = $phpcsFile->getDeclarationName($stackPtr);
|
77 |
+
if (strtolower($functionName) !== '__tostring') {
|
78 |
+
// Not the right function.
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
|
83 |
+
// Function, not method.
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
|
87 |
+
$hasThrow = $phpcsFile->findNext(\T_THROW, ($tokens[$stackPtr]['scope_opener'] + 1), $tokens[$stackPtr]['scope_closer']);
|
88 |
+
|
89 |
+
if ($hasThrow === false) {
|
90 |
+
// No exception is being thrown.
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
|
94 |
+
$phpcsFile->addError(
|
95 |
+
'Throwing exceptions from __toString() was not allowed prior to PHP 7.4',
|
96 |
+
$hasThrow,
|
97 |
+
'Found'
|
98 |
+
);
|
99 |
+
}
|
100 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NewNullableTypesSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
@@ -9,13 +9,15 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Nullable type hints and return types are available since PHP 7.1.
|
21 |
*
|
@@ -39,17 +41,16 @@ class NewNullableTypesSniff extends Sniff
|
|
39 |
public function register()
|
40 |
{
|
41 |
$tokens = array(
|
42 |
-
T_FUNCTION,
|
43 |
-
T_CLOSURE,
|
44 |
);
|
45 |
|
46 |
-
if (defined('T_RETURN_TYPE')) {
|
47 |
-
$tokens[] = T_RETURN_TYPE;
|
48 |
}
|
49 |
|
50 |
return $tokens;
|
51 |
-
|
52 |
-
}//end register()
|
53 |
|
54 |
|
55 |
/**
|
@@ -61,7 +62,7 @@ class NewNullableTypesSniff extends Sniff
|
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
-
public function process(
|
65 |
{
|
66 |
if ($this->supportsBelow('7.0') === false) {
|
67 |
return;
|
@@ -70,7 +71,7 @@ class NewNullableTypesSniff extends Sniff
|
|
70 |
$tokens = $phpcsFile->getTokens();
|
71 |
$tokenCode = $tokens[$stackPtr]['code'];
|
72 |
|
73 |
-
if ($tokenCode === T_FUNCTION || $tokenCode === T_CLOSURE) {
|
74 |
$this->processFunctionDeclaration($phpcsFile, $stackPtr);
|
75 |
|
76 |
// Deal with older PHPCS version which don't recognize return type hints
|
@@ -82,8 +83,7 @@ class NewNullableTypesSniff extends Sniff
|
|
82 |
} else {
|
83 |
$this->processReturnType($phpcsFile, $stackPtr);
|
84 |
}
|
85 |
-
|
86 |
-
}//end process()
|
87 |
|
88 |
|
89 |
/**
|
@@ -95,11 +95,11 @@ class NewNullableTypesSniff extends Sniff
|
|
95 |
*
|
96 |
* @return void
|
97 |
*/
|
98 |
-
protected function processFunctionDeclaration(
|
99 |
{
|
100 |
$params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
101 |
|
102 |
-
if (empty($params) === false && is_array($params)) {
|
103 |
foreach ($params as $param) {
|
104 |
if ($param['nullable_type'] === true) {
|
105 |
$phpcsFile->addError(
|
@@ -123,7 +123,7 @@ class NewNullableTypesSniff extends Sniff
|
|
123 |
*
|
124 |
* @return void
|
125 |
*/
|
126 |
-
protected function processReturnType(
|
127 |
{
|
128 |
$tokens = $phpcsFile->getTokens();
|
129 |
|
@@ -131,26 +131,26 @@ class NewNullableTypesSniff extends Sniff
|
|
131 |
return;
|
132 |
}
|
133 |
|
134 |
-
$previous = $phpcsFile->findPrevious(
|
135 |
|
136 |
// Deal with namespaced class names.
|
137 |
-
if ($tokens[$previous]['code'] === T_NS_SEPARATOR) {
|
138 |
-
$validTokens
|
139 |
-
$validTokens[]
|
140 |
-
$validTokens[] =
|
141 |
|
142 |
$stackPtr--;
|
143 |
|
144 |
-
while (
|
145 |
$stackPtr--;
|
146 |
}
|
147 |
|
148 |
-
$previous = $phpcsFile->findPrevious(
|
149 |
}
|
150 |
|
151 |
// T_NULLABLE token was introduced in PHPCS 2.7.2. Before that it identified as T_INLINE_THEN.
|
152 |
-
if ((defined('T_NULLABLE') === true && $tokens[$previous]['type'] === 'T_NULLABLE')
|
153 |
-
|| (defined('T_NULLABLE') === false && $tokens[$previous]['code'] === T_INLINE_THEN)
|
154 |
) {
|
155 |
$phpcsFile->addError(
|
156 |
'Nullable return types are not supported in PHP 7.0 or earlier.',
|
@@ -159,5 +159,4 @@ class NewNullableTypesSniff extends Sniff
|
|
159 |
);
|
160 |
}
|
161 |
}
|
162 |
-
|
163 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewNullableTypes.
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewNullableTypes.
|
21 |
*
|
22 |
* Nullable type hints and return types are available since PHP 7.1.
|
23 |
*
|
41 |
public function register()
|
42 |
{
|
43 |
$tokens = array(
|
44 |
+
\T_FUNCTION,
|
45 |
+
\T_CLOSURE,
|
46 |
);
|
47 |
|
48 |
+
if (\defined('T_RETURN_TYPE')) {
|
49 |
+
$tokens[] = \T_RETURN_TYPE;
|
50 |
}
|
51 |
|
52 |
return $tokens;
|
53 |
+
}
|
|
|
54 |
|
55 |
|
56 |
/**
|
62 |
*
|
63 |
* @return void
|
64 |
*/
|
65 |
+
public function process(File $phpcsFile, $stackPtr)
|
66 |
{
|
67 |
if ($this->supportsBelow('7.0') === false) {
|
68 |
return;
|
71 |
$tokens = $phpcsFile->getTokens();
|
72 |
$tokenCode = $tokens[$stackPtr]['code'];
|
73 |
|
74 |
+
if ($tokenCode === \T_FUNCTION || $tokenCode === \T_CLOSURE) {
|
75 |
$this->processFunctionDeclaration($phpcsFile, $stackPtr);
|
76 |
|
77 |
// Deal with older PHPCS version which don't recognize return type hints
|
83 |
} else {
|
84 |
$this->processReturnType($phpcsFile, $stackPtr);
|
85 |
}
|
86 |
+
}
|
|
|
87 |
|
88 |
|
89 |
/**
|
95 |
*
|
96 |
* @return void
|
97 |
*/
|
98 |
+
protected function processFunctionDeclaration(File $phpcsFile, $stackPtr)
|
99 |
{
|
100 |
$params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
101 |
|
102 |
+
if (empty($params) === false && \is_array($params)) {
|
103 |
foreach ($params as $param) {
|
104 |
if ($param['nullable_type'] === true) {
|
105 |
$phpcsFile->addError(
|
123 |
*
|
124 |
* @return void
|
125 |
*/
|
126 |
+
protected function processReturnType(File $phpcsFile, $stackPtr)
|
127 |
{
|
128 |
$tokens = $phpcsFile->getTokens();
|
129 |
|
131 |
return;
|
132 |
}
|
133 |
|
134 |
+
$previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
135 |
|
136 |
// Deal with namespaced class names.
|
137 |
+
if ($tokens[$previous]['code'] === \T_NS_SEPARATOR) {
|
138 |
+
$validTokens = Tokens::$emptyTokens;
|
139 |
+
$validTokens[\T_STRING] = true;
|
140 |
+
$validTokens[\T_NS_SEPARATOR] = true;
|
141 |
|
142 |
$stackPtr--;
|
143 |
|
144 |
+
while (isset($validTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
|
145 |
$stackPtr--;
|
146 |
}
|
147 |
|
148 |
+
$previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
149 |
}
|
150 |
|
151 |
// T_NULLABLE token was introduced in PHPCS 2.7.2. Before that it identified as T_INLINE_THEN.
|
152 |
+
if ((\defined('T_NULLABLE') === true && $tokens[$previous]['type'] === 'T_NULLABLE')
|
153 |
+
|| (\defined('T_NULLABLE') === false && $tokens[$previous]['code'] === \T_INLINE_THEN)
|
154 |
) {
|
155 |
$phpcsFile->addError(
|
156 |
'Nullable return types are not supported in PHP 7.0 or earlier.',
|
159 |
);
|
160 |
}
|
161 |
}
|
162 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewScalarTypeDeclarationsSniff.php → FunctionDeclarations/NewParamTypeDeclarationsSniff.php}
RENAMED
@@ -1,25 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
20 |
* @author Wim Godden <wim.godden@cu.be>
|
21 |
*/
|
22 |
-
class
|
23 |
{
|
24 |
|
25 |
/**
|
@@ -96,10 +97,10 @@ class NewScalarTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
96 |
public function register()
|
97 |
{
|
98 |
return array(
|
99 |
-
T_FUNCTION,
|
100 |
-
T_CLOSURE,
|
101 |
);
|
102 |
-
}
|
103 |
|
104 |
|
105 |
/**
|
@@ -111,7 +112,7 @@ class NewScalarTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
111 |
*
|
112 |
* @return void
|
113 |
*/
|
114 |
-
public function process(
|
115 |
{
|
116 |
// Get all parameters from method signature.
|
117 |
$paramNames = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
@@ -166,7 +167,7 @@ class NewScalarTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
166 |
$phpcsFile->addError($error, $param['token'], 'InvalidTypeHintFound', $data);
|
167 |
}
|
168 |
}
|
169 |
-
}
|
170 |
|
171 |
|
172 |
/**
|
@@ -191,6 +192,4 @@ class NewScalarTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
191 |
{
|
192 |
return "'%s' type declaration is not present in PHP version %s or earlier";
|
193 |
}
|
194 |
-
|
195 |
-
|
196 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewParamTypeDeclarationsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewParamTypeDeclarationsSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
21 |
* @author Wim Godden <wim.godden@cu.be>
|
22 |
*/
|
23 |
+
class NewParamTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
24 |
{
|
25 |
|
26 |
/**
|
97 |
public function register()
|
98 |
{
|
99 |
return array(
|
100 |
+
\T_FUNCTION,
|
101 |
+
\T_CLOSURE,
|
102 |
);
|
103 |
+
}
|
104 |
|
105 |
|
106 |
/**
|
112 |
*
|
113 |
* @return void
|
114 |
*/
|
115 |
+
public function process(File $phpcsFile, $stackPtr)
|
116 |
{
|
117 |
// Get all parameters from method signature.
|
118 |
$paramNames = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
167 |
$phpcsFile->addError($error, $param['token'], 'InvalidTypeHintFound', $data);
|
168 |
}
|
169 |
}
|
170 |
+
}
|
171 |
|
172 |
|
173 |
/**
|
192 |
{
|
193 |
return "'%s' type declaration is not present in PHP version %s or earlier";
|
194 |
}
|
195 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NewReturnTypeDeclarationsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 7.0
|
20 |
*
|
@@ -95,16 +96,16 @@ class NewReturnTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
95 |
public function register()
|
96 |
{
|
97 |
$tokens = array(
|
98 |
-
T_FUNCTION,
|
99 |
-
T_CLOSURE,
|
100 |
);
|
101 |
|
102 |
-
if (defined('T_RETURN_TYPE')) {
|
103 |
-
$tokens[] = T_RETURN_TYPE;
|
104 |
}
|
105 |
|
106 |
return $tokens;
|
107 |
-
}
|
108 |
|
109 |
|
110 |
/**
|
@@ -116,13 +117,13 @@ class NewReturnTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
116 |
*
|
117 |
* @return void
|
118 |
*/
|
119 |
-
public function process(
|
120 |
{
|
121 |
$tokens = $phpcsFile->getTokens();
|
122 |
|
123 |
// Deal with older PHPCS version which don't recognize return type hints
|
124 |
// as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
|
125 |
-
if ($tokens[$stackPtr]['code'] === T_FUNCTION || $tokens[$stackPtr]['code'] === T_CLOSURE) {
|
126 |
$returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
|
127 |
if ($returnTypeHint !== false) {
|
128 |
$stackPtr = $returnTypeHint;
|
@@ -136,15 +137,15 @@ class NewReturnTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
136 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
137 |
}
|
138 |
// Handle class name based return types.
|
139 |
-
elseif ($tokens[$stackPtr]['code'] === T_STRING
|
140 |
-
|| (defined('T_RETURN_TYPE') && $tokens[$stackPtr]['code'] === T_RETURN_TYPE)
|
141 |
) {
|
142 |
$itemInfo = array(
|
143 |
'name' => 'Class name',
|
144 |
);
|
145 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
146 |
}
|
147 |
-
}
|
148 |
|
149 |
|
150 |
/**
|
@@ -169,6 +170,4 @@ class NewReturnTypeDeclarationsSniff extends AbstractNewFeatureSniff
|
|
169 |
{
|
170 |
return '%s return type is not present in PHP version %s or earlier';
|
171 |
}
|
172 |
-
|
173 |
-
|
174 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewReturnTypeDeclarationsSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
13 |
|
14 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NewReturnTypeDeclarationsSniff.
|
19 |
*
|
20 |
* PHP version 7.0
|
21 |
*
|
96 |
public function register()
|
97 |
{
|
98 |
$tokens = array(
|
99 |
+
\T_FUNCTION,
|
100 |
+
\T_CLOSURE,
|
101 |
);
|
102 |
|
103 |
+
if (\defined('T_RETURN_TYPE')) {
|
104 |
+
$tokens[] = \T_RETURN_TYPE;
|
105 |
}
|
106 |
|
107 |
return $tokens;
|
108 |
+
}
|
109 |
|
110 |
|
111 |
/**
|
117 |
*
|
118 |
* @return void
|
119 |
*/
|
120 |
+
public function process(File $phpcsFile, $stackPtr)
|
121 |
{
|
122 |
$tokens = $phpcsFile->getTokens();
|
123 |
|
124 |
// Deal with older PHPCS version which don't recognize return type hints
|
125 |
// as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
|
126 |
+
if ($tokens[$stackPtr]['code'] === \T_FUNCTION || $tokens[$stackPtr]['code'] === \T_CLOSURE) {
|
127 |
$returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
|
128 |
if ($returnTypeHint !== false) {
|
129 |
$stackPtr = $returnTypeHint;
|
137 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
138 |
}
|
139 |
// Handle class name based return types.
|
140 |
+
elseif ($tokens[$stackPtr]['code'] === \T_STRING
|
141 |
+
|| (\defined('T_RETURN_TYPE') && $tokens[$stackPtr]['code'] === \T_RETURN_TYPE)
|
142 |
) {
|
143 |
$itemInfo = array(
|
144 |
'name' => 'Class name',
|
145 |
);
|
146 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
147 |
}
|
148 |
+
}
|
149 |
|
150 |
|
151 |
/**
|
170 |
{
|
171 |
return '%s return type is not present in PHP version %s or earlier';
|
172 |
}
|
173 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionDeclarations}/NonStaticMagicMethodsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -10,12 +10,13 @@
|
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Verifies the use of the correct visibility and static properties of magic methods.
|
21 |
*
|
@@ -83,23 +84,17 @@ class NonStaticMagicMethodsSniff extends Sniff
|
|
83 |
public function register()
|
84 |
{
|
85 |
$targets = array(
|
86 |
-
T_CLASS,
|
87 |
-
T_INTERFACE,
|
|
|
88 |
);
|
89 |
|
90 |
-
if (defined('
|
91 |
-
|
92 |
-
$targets[] = T_TRAIT;
|
93 |
-
}
|
94 |
-
|
95 |
-
if (defined('T_ANON_CLASS')) {
|
96 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_anon_classFound
|
97 |
-
$targets[] = T_ANON_CLASS;
|
98 |
}
|
99 |
|
100 |
return $targets;
|
101 |
-
|
102 |
-
}//end register()
|
103 |
|
104 |
|
105 |
/**
|
@@ -111,7 +106,7 @@ class NonStaticMagicMethodsSniff extends Sniff
|
|
111 |
*
|
112 |
* @return void
|
113 |
*/
|
114 |
-
public function process(
|
115 |
{
|
116 |
// Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
|
117 |
if ($this->supportsAbove('5.3') === false) {
|
@@ -128,7 +123,7 @@ class NonStaticMagicMethodsSniff extends Sniff
|
|
128 |
$functionPtr = $stackPtr;
|
129 |
|
130 |
// Find all the functions in this class or interface.
|
131 |
-
while (($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) {
|
132 |
/*
|
133 |
* Get the scope closer for this function in order to know how
|
134 |
* to advance to the next function.
|
@@ -179,8 +174,5 @@ class NonStaticMagicMethodsSniff extends Sniff
|
|
179 |
// Advance to next function.
|
180 |
$functionPtr = $scopeCloser;
|
181 |
}
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NonStaticMagicMethodsSniff.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\FunctionDeclarations;
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\FunctionDeclarations\NonStaticMagicMethodsSniff.
|
20 |
*
|
21 |
* Verifies the use of the correct visibility and static properties of magic methods.
|
22 |
*
|
84 |
public function register()
|
85 |
{
|
86 |
$targets = array(
|
87 |
+
\T_CLASS,
|
88 |
+
\T_INTERFACE,
|
89 |
+
\T_TRAIT,
|
90 |
);
|
91 |
|
92 |
+
if (\defined('T_ANON_CLASS')) {
|
93 |
+
$targets[] = \T_ANON_CLASS;
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
return $targets;
|
97 |
+
}
|
|
|
98 |
|
99 |
|
100 |
/**
|
106 |
*
|
107 |
* @return void
|
108 |
*/
|
109 |
+
public function process(File $phpcsFile, $stackPtr)
|
110 |
{
|
111 |
// Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
|
112 |
if ($this->supportsAbove('5.3') === false) {
|
123 |
$functionPtr = $stackPtr;
|
124 |
|
125 |
// Find all the functions in this class or interface.
|
126 |
+
while (($functionToken = $phpcsFile->findNext(\T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) {
|
127 |
/*
|
128 |
* Get the scope closer for this function in order to know how
|
129 |
* to advance to the next function.
|
174 |
// Advance to next function.
|
175 |
$functionPtr = $scopeCloser;
|
176 |
}
|
177 |
+
}
|
178 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionNameRestrictions}/NewMagicMethodsSniff.php
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* Warns for non-magic behaviour of magic methods prior to becoming magic.
|
18 |
*
|
@@ -82,9 +83,8 @@ class NewMagicMethodsSniff extends AbstractNewFeatureSniff
|
|
82 |
*/
|
83 |
public function register()
|
84 |
{
|
85 |
-
return array(T_FUNCTION);
|
86 |
-
|
87 |
-
}//end register()
|
88 |
|
89 |
|
90 |
/**
|
@@ -96,7 +96,7 @@ class NewMagicMethodsSniff extends AbstractNewFeatureSniff
|
|
96 |
*
|
97 |
* @return void
|
98 |
*/
|
99 |
-
public function process(
|
100 |
{
|
101 |
$functionName = $phpcsFile->getDeclarationName($stackPtr);
|
102 |
$functionNameLc = strtolower($functionName);
|
@@ -114,8 +114,7 @@ class NewMagicMethodsSniff extends AbstractNewFeatureSniff
|
|
114 |
'nameLc' => $functionNameLc,
|
115 |
);
|
116 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
117 |
-
|
118 |
-
}//end process()
|
119 |
|
120 |
|
121 |
/**
|
@@ -192,6 +191,4 @@ class NewMagicMethodsSniff extends AbstractNewFeatureSniff
|
|
192 |
|
193 |
return $error;
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\NewMagicMethodsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionNameRestrictions;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\NewMagicMethodsSniff.
|
17 |
*
|
18 |
* Warns for non-magic behaviour of magic methods prior to becoming magic.
|
19 |
*
|
83 |
*/
|
84 |
public function register()
|
85 |
{
|
86 |
+
return array(\T_FUNCTION);
|
87 |
+
}
|
|
|
88 |
|
89 |
|
90 |
/**
|
96 |
*
|
97 |
* @return void
|
98 |
*/
|
99 |
+
public function process(File $phpcsFile, $stackPtr)
|
100 |
{
|
101 |
$functionName = $phpcsFile->getDeclarationName($stackPtr);
|
102 |
$functionNameLc = strtolower($functionName);
|
114 |
'nameLc' => $functionNameLc,
|
115 |
);
|
116 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
117 |
+
}
|
|
|
118 |
|
119 |
|
120 |
/**
|
191 |
|
192 |
return $error;
|
193 |
}
|
194 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedMagicAutoloadSniff.php → FunctionNameRestrictions/RemovedMagicAutoloadSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.2
|
6 |
*
|
@@ -9,18 +9,19 @@
|
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
21 |
* @author Wim Godden <wim.godden@cu.be>
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
/**
|
26 |
* Scopes to look for when testing using validDirectScope
|
@@ -42,8 +43,8 @@ class DeprecatedMagicAutoloadSniff extends Sniff
|
|
42 |
*/
|
43 |
public function register()
|
44 |
{
|
45 |
-
return array(T_FUNCTION);
|
46 |
-
}
|
47 |
|
48 |
/**
|
49 |
* Processes this test, when one of its tokens is encountered.
|
@@ -54,7 +55,7 @@ class DeprecatedMagicAutoloadSniff extends Sniff
|
|
54 |
*
|
55 |
* @return void
|
56 |
*/
|
57 |
-
public function process(
|
58 |
{
|
59 |
if ($this->supportsAbove('7.2') === false) {
|
60 |
return;
|
@@ -66,7 +67,7 @@ class DeprecatedMagicAutoloadSniff extends Sniff
|
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
-
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes)
|
70 |
return;
|
71 |
}
|
72 |
|
@@ -75,6 +76,5 @@ class DeprecatedMagicAutoloadSniff extends Sniff
|
|
75 |
}
|
76 |
|
77 |
$phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
|
78 |
-
}
|
79 |
-
|
80 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\RemovedMagicAutoloadSniff.
|
4 |
*
|
5 |
* PHP version 7.2
|
6 |
*
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionNameRestrictions;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\RemovedMagicAutoloadSniff.
|
19 |
*
|
20 |
* @category PHP
|
21 |
* @package PHPCompatibility
|
22 |
* @author Wim Godden <wim.godden@cu.be>
|
23 |
*/
|
24 |
+
class RemovedMagicAutoloadSniff extends Sniff
|
25 |
{
|
26 |
/**
|
27 |
* Scopes to look for when testing using validDirectScope
|
43 |
*/
|
44 |
public function register()
|
45 |
{
|
46 |
+
return array(\T_FUNCTION);
|
47 |
+
}
|
48 |
|
49 |
/**
|
50 |
* Processes this test, when one of its tokens is encountered.
|
55 |
*
|
56 |
* @return void
|
57 |
*/
|
58 |
+
public function process(File $phpcsFile, $stackPtr)
|
59 |
{
|
60 |
if ($this->supportsAbove('7.2') === false) {
|
61 |
return;
|
67 |
return;
|
68 |
}
|
69 |
|
70 |
+
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) !== false) {
|
71 |
return;
|
72 |
}
|
73 |
|
76 |
}
|
77 |
|
78 |
$phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
|
79 |
+
}
|
80 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedNamespacedAssertSniff.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\RemovedNamespacedAssertSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.3
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionNameRestrictions;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Removed Namespaced Assert.
|
19 |
+
*
|
20 |
+
* As of PHP 7.3, a compile-time deprecation warning will be thrown when a function
|
21 |
+
* called `assert()` is declared. In PHP 8 this will become a compile-error.
|
22 |
+
*
|
23 |
+
* Methods are unaffected.
|
24 |
+
* Global, non-namespaced, assert() function declarations were always a fatal
|
25 |
+
* "function already declared" error, so not the concern of this sniff.
|
26 |
+
*
|
27 |
+
* @category PHP
|
28 |
+
* @package PHPCompatibility
|
29 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
30 |
+
*/
|
31 |
+
class RemovedNamespacedAssertSniff extends Sniff
|
32 |
+
{
|
33 |
+
/**
|
34 |
+
* Scopes in which an `assert` function can be declared without issue.
|
35 |
+
*
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
private $scopes = array(
|
39 |
+
\T_CLASS,
|
40 |
+
\T_INTERFACE,
|
41 |
+
\T_TRAIT,
|
42 |
+
\T_CLOSURE,
|
43 |
+
);
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Returns an array of tokens this test wants to listen for.
|
47 |
+
*
|
48 |
+
* @return array
|
49 |
+
*/
|
50 |
+
public function register()
|
51 |
+
{
|
52 |
+
// Enrich the scopes list.
|
53 |
+
if (\defined('T_ANON_CLASS')) {
|
54 |
+
$this->scopes[] = \T_ANON_CLASS;
|
55 |
+
}
|
56 |
+
|
57 |
+
return array(\T_FUNCTION);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Processes this test, when one of its tokens is encountered.
|
62 |
+
*
|
63 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
64 |
+
* @param int $stackPtr The position of the current token in the
|
65 |
+
* stack passed in $tokens.
|
66 |
+
*
|
67 |
+
* @return void
|
68 |
+
*/
|
69 |
+
public function process(File $phpcsFile, $stackPtr)
|
70 |
+
{
|
71 |
+
if ($this->supportsAbove('7.3') === false) {
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
$funcName = $phpcsFile->getDeclarationName($stackPtr);
|
76 |
+
|
77 |
+
if (strtolower($funcName) !== 'assert') {
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
+
if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) {
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($this->determineNamespace($phpcsFile, $stackPtr) === '') {
|
86 |
+
// Not a namespaced function declaration. Parse error, but not our concern.
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
$phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found');
|
91 |
+
}
|
92 |
+
}
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedPHP4StyleConstructorsSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Koen Eelen <koen.eelen@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 7.0
|
20 |
*
|
@@ -22,7 +24,7 @@ use PHPCompatibility\Sniff;
|
|
22 |
* @package PHPCompatibility
|
23 |
* @author Koen Eelen <koen.eelen@cu.be>
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
|
28 |
/**
|
@@ -32,8 +34,10 @@ class DeprecatedPHP4StyleConstructorsSniff extends Sniff
|
|
32 |
*/
|
33 |
public function register()
|
34 |
{
|
35 |
-
return array(
|
36 |
-
|
|
|
|
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -45,7 +49,7 @@ class DeprecatedPHP4StyleConstructorsSniff extends Sniff
|
|
45 |
*
|
46 |
* @return void
|
47 |
*/
|
48 |
-
public function process(
|
49 |
{
|
50 |
if ($this->supportsAbove('7.0') === false) {
|
51 |
return;
|
@@ -70,10 +74,16 @@ class DeprecatedPHP4StyleConstructorsSniff extends Sniff
|
|
70 |
return;
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
$scopeCloser = $class['scope_closer'];
|
74 |
-
$className = $
|
75 |
|
76 |
-
if (empty($className) || is_string($className) === false) {
|
77 |
return;
|
78 |
}
|
79 |
|
@@ -82,9 +92,16 @@ class DeprecatedPHP4StyleConstructorsSniff extends Sniff
|
|
82 |
$newConstructorFound = false;
|
83 |
$oldConstructorFound = false;
|
84 |
$oldConstructorPos = -1;
|
85 |
-
while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
$funcName = $phpcsFile->getDeclarationName($nextFunc);
|
87 |
-
if (empty($funcName) || is_string($funcName) === false) {
|
|
|
88 |
continue;
|
89 |
}
|
90 |
|
@@ -103,6 +120,8 @@ class DeprecatedPHP4StyleConstructorsSniff extends Sniff
|
|
103 |
if ($newConstructorFound === true && $oldConstructorFound === true) {
|
104 |
break;
|
105 |
}
|
|
|
|
|
106 |
}
|
107 |
|
108 |
if ($newConstructorFound === false && $oldConstructorFound === true) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\RemovedPHP4StyleConstructorsSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Koen Eelen <koen.eelen@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionNameRestrictions;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\RemovedPHP4StyleConstructorsSniff.
|
20 |
*
|
21 |
* PHP version 7.0
|
22 |
*
|
24 |
* @package PHPCompatibility
|
25 |
* @author Koen Eelen <koen.eelen@cu.be>
|
26 |
*/
|
27 |
+
class RemovedPHP4StyleConstructorsSniff extends Sniff
|
28 |
{
|
29 |
|
30 |
/**
|
34 |
*/
|
35 |
public function register()
|
36 |
{
|
37 |
+
return array(
|
38 |
+
\T_CLASS,
|
39 |
+
\T_INTERFACE,
|
40 |
+
);
|
41 |
}
|
42 |
|
43 |
/**
|
49 |
*
|
50 |
* @return void
|
51 |
*/
|
52 |
+
public function process(File $phpcsFile, $stackPtr)
|
53 |
{
|
54 |
if ($this->supportsAbove('7.0') === false) {
|
55 |
return;
|
74 |
return;
|
75 |
}
|
76 |
|
77 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
78 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
|
79 |
+
// Anonymous class in combination with PHPCS 2.3.x.
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
$scopeCloser = $class['scope_closer'];
|
84 |
+
$className = $tokens[$nextNonEmpty]['content'];
|
85 |
|
86 |
+
if (empty($className) || \is_string($className) === false) {
|
87 |
return;
|
88 |
}
|
89 |
|
92 |
$newConstructorFound = false;
|
93 |
$oldConstructorFound = false;
|
94 |
$oldConstructorPos = -1;
|
95 |
+
while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
|
96 |
+
$functionScopeCloser = $nextFunc;
|
97 |
+
if (isset($tokens[$nextFunc]['scope_closer'])) {
|
98 |
+
// Normal (non-interface, non-abstract) method.
|
99 |
+
$functionScopeCloser = $tokens[$nextFunc]['scope_closer'];
|
100 |
+
}
|
101 |
+
|
102 |
$funcName = $phpcsFile->getDeclarationName($nextFunc);
|
103 |
+
if (empty($funcName) || \is_string($funcName) === false) {
|
104 |
+
$nextFunc = $functionScopeCloser;
|
105 |
continue;
|
106 |
}
|
107 |
|
120 |
if ($newConstructorFound === true && $oldConstructorFound === true) {
|
121 |
break;
|
122 |
}
|
123 |
+
|
124 |
+
$nextFunc = $functionScopeCloser;
|
125 |
}
|
126 |
|
127 |
if ($newConstructorFound === false && $oldConstructorFound === true) {
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionNameRestrictions}/ReservedFunctionNamesSniff.php
RENAMED
@@ -1,18 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
-
use
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* All function and method names starting with double underscore are reserved by PHP.
|
18 |
*
|
@@ -31,7 +34,7 @@ use PHPCompatibility\PHPCSHelper;
|
|
31 |
* @package PHPCompatibility
|
32 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
33 |
*/
|
34 |
-
class ReservedFunctionNamesSniff extends
|
35 |
{
|
36 |
|
37 |
/**
|
@@ -39,26 +42,13 @@ class ReservedFunctionNamesSniff extends \Generic_Sniffs_NamingConventions_Camel
|
|
39 |
*/
|
40 |
public function __construct()
|
41 |
{
|
42 |
-
$scopeTokens = array(T_CLASS, T_INTERFACE);
|
43 |
-
if (defined('
|
44 |
-
|
45 |
-
$scopeTokens[] = T_TRAIT;
|
46 |
-
}
|
47 |
-
if (defined('T_ANON_CLASS')) {
|
48 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_anon_classFound
|
49 |
-
$scopeTokens[] = T_ANON_CLASS;
|
50 |
}
|
51 |
|
52 |
// Call the grand-parent constructor directly.
|
53 |
-
|
54 |
-
|
55 |
-
$phpcsVersion = PHPCSHelper::getVersion();
|
56 |
-
|
57 |
-
if (version_compare($phpcsVersion, '2.0.0', '<') === true) {
|
58 |
-
$this->magicMethods = array_flip($this->magicMethods);
|
59 |
-
$this->methodsDoubleUnderscore = array_flip($this->methodsDoubleUnderscore);
|
60 |
-
$this->magicFunctions = array_flip($this->magicFunctions);
|
61 |
-
}
|
62 |
|
63 |
// Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1.
|
64 |
$this->magicMethods['debuginfo'] = true;
|
@@ -75,10 +65,23 @@ class ReservedFunctionNamesSniff extends \Generic_Sniffs_NamingConventions_Camel
|
|
75 |
*
|
76 |
* @return void
|
77 |
*/
|
78 |
-
protected function processTokenWithinScope(
|
79 |
{
|
80 |
$tokens = $phpcsFile->getTokens();
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
$methodName = $phpcsFile->getDeclarationName($stackPtr);
|
83 |
if ($methodName === null) {
|
84 |
// Ignore closures.
|
@@ -91,9 +94,10 @@ class ReservedFunctionNamesSniff extends \Generic_Sniffs_NamingConventions_Camel
|
|
91 |
if (isset($this->magicMethods[$magicPart]) === false
|
92 |
&& isset($this->methodsDoubleUnderscore[$magicPart]) === false
|
93 |
) {
|
94 |
-
$className
|
95 |
-
|
96 |
-
|
|
|
97 |
}
|
98 |
|
99 |
$phpcsFile->addWarning(
|
@@ -116,7 +120,7 @@ class ReservedFunctionNamesSniff extends \Generic_Sniffs_NamingConventions_Camel
|
|
116 |
*
|
117 |
* @return void
|
118 |
*/
|
119 |
-
protected function processTokenOutsideScope(
|
120 |
{
|
121 |
$functionName = $phpcsFile->getDeclarationName($stackPtr);
|
122 |
if ($functionName === null) {
|
@@ -137,5 +141,4 @@ class ReservedFunctionNamesSniff extends \Generic_Sniffs_NamingConventions_Camel
|
|
137 |
}
|
138 |
}
|
139 |
}
|
140 |
-
|
141 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\ReservedFunctionNamesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionNameRestrictions;
|
11 |
|
12 |
+
use Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff as PHPCS_CamelCapsFunctionNameSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
use PHP_CodeSniffer_Standards_AbstractScopeSniff as PHPCS_AbstractScopeSniff;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\FunctionNameRestrictions\ReservedFunctionNamesSniff.
|
19 |
*
|
20 |
* All function and method names starting with double underscore are reserved by PHP.
|
21 |
*
|
34 |
* @package PHPCompatibility
|
35 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
36 |
*/
|
37 |
+
class ReservedFunctionNamesSniff extends PHPCS_CamelCapsFunctionNameSniff
|
38 |
{
|
39 |
|
40 |
/**
|
42 |
*/
|
43 |
public function __construct()
|
44 |
{
|
45 |
+
$scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT);
|
46 |
+
if (\defined('T_ANON_CLASS')) {
|
47 |
+
$scopeTokens[] = \T_ANON_CLASS;
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
|
50 |
// Call the grand-parent constructor directly.
|
51 |
+
PHPCS_AbstractScopeSniff::__construct($scopeTokens, array(\T_FUNCTION), true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
// Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1.
|
54 |
$this->magicMethods['debuginfo'] = true;
|
65 |
*
|
66 |
* @return void
|
67 |
*/
|
68 |
+
protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
|
69 |
{
|
70 |
$tokens = $phpcsFile->getTokens();
|
71 |
|
72 |
+
/*
|
73 |
+
* Determine if this is a function which needs to be examined.
|
74 |
+
* The `processTokenWithinScope()` is called for each valid scope a method is in,
|
75 |
+
* so for nested classes, we need to make sure we only examine the token for
|
76 |
+
* the lowest level valid scope.
|
77 |
+
*/
|
78 |
+
$conditions = $tokens[$stackPtr]['conditions'];
|
79 |
+
end($conditions);
|
80 |
+
$deepestScope = key($conditions);
|
81 |
+
if ($deepestScope !== $currScope) {
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
$methodName = $phpcsFile->getDeclarationName($stackPtr);
|
86 |
if ($methodName === null) {
|
87 |
// Ignore closures.
|
94 |
if (isset($this->magicMethods[$magicPart]) === false
|
95 |
&& isset($this->methodsDoubleUnderscore[$magicPart]) === false
|
96 |
) {
|
97 |
+
$className = '[anonymous class]';
|
98 |
+
$scopeNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($currScope + 1), null, true);
|
99 |
+
if ($scopeNextNonEmpty !== false && $tokens[$scopeNextNonEmpty]['code'] === \T_STRING) {
|
100 |
+
$className = $tokens[$scopeNextNonEmpty]['content'];
|
101 |
}
|
102 |
|
103 |
$phpcsFile->addWarning(
|
120 |
*
|
121 |
* @return void
|
122 |
*/
|
123 |
+
protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
|
124 |
{
|
125 |
$functionName = $phpcsFile->getDeclarationName($stackPtr);
|
126 |
if ($functionName === null) {
|
141 |
}
|
142 |
}
|
143 |
}
|
144 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php
ADDED
@@ -0,0 +1,439 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2018 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHPCompatibility\PHPCSHelper;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Functions inspecting function arguments report the current parameter value
|
20 |
+
* instead of the original since PHP 7.0.
|
21 |
+
*
|
22 |
+
* `func_get_arg()`, `func_get_args()`, `debug_backtrace()` and exception backtraces
|
23 |
+
* will no longer report the original value that was passed to a parameter, but will
|
24 |
+
* instead provide the current value (which might have been modified).
|
25 |
+
*
|
26 |
+
* PHP version 7.0
|
27 |
+
*
|
28 |
+
* @since 9.1.0
|
29 |
+
*/
|
30 |
+
class ArgumentFunctionsReportCurrentValueSniff extends Sniff
|
31 |
+
{
|
32 |
+
|
33 |
+
/**
|
34 |
+
* A list of functions that, when called, can behave differently in PHP 7
|
35 |
+
* when dealing with parameters of the function they're called in.
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
protected $changedFunctions = array(
|
40 |
+
'func_get_arg' => true,
|
41 |
+
'func_get_args' => true,
|
42 |
+
'debug_backtrace' => true,
|
43 |
+
'debug_print_backtrace' => true,
|
44 |
+
);
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Tokens to look out for to allow us to skip past nested scoped structures.
|
48 |
+
*
|
49 |
+
* @var array
|
50 |
+
*/
|
51 |
+
private $skipPastNested = array(
|
52 |
+
'T_CLASS' => true,
|
53 |
+
'T_ANON_CLASS' => true,
|
54 |
+
'T_INTERFACE' => true,
|
55 |
+
'T_TRAIT' => true,
|
56 |
+
'T_FUNCTION' => true,
|
57 |
+
'T_CLOSURE' => true,
|
58 |
+
);
|
59 |
+
|
60 |
+
/**
|
61 |
+
* List of tokens which when they preceed a T_STRING *within a function* indicate
|
62 |
+
* this is not a call to a PHP native function.
|
63 |
+
*
|
64 |
+
* This list already takes into account that nested scoped structures are being
|
65 |
+
* skipped over, so doesn't check for those again.
|
66 |
+
* Similarly, as constants won't have parentheses, those don't need to be checked
|
67 |
+
* for either.
|
68 |
+
*
|
69 |
+
* @var array
|
70 |
+
*/
|
71 |
+
private $noneFunctionCallIndicators = array(
|
72 |
+
\T_DOUBLE_COLON => true,
|
73 |
+
\T_OBJECT_OPERATOR => true,
|
74 |
+
);
|
75 |
+
|
76 |
+
/**
|
77 |
+
* The tokens for variable incrementing/decrementing.
|
78 |
+
*
|
79 |
+
* @var array
|
80 |
+
*/
|
81 |
+
private $plusPlusMinusMinus = array(
|
82 |
+
\T_DEC => true,
|
83 |
+
\T_INC => true,
|
84 |
+
);
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Tokens to ignore when determining the start of a statement.
|
88 |
+
*
|
89 |
+
* @var array
|
90 |
+
*/
|
91 |
+
private $ignoreForStartOfStatement = array(
|
92 |
+
\T_COMMA,
|
93 |
+
\T_DOUBLE_ARROW,
|
94 |
+
\T_OPEN_SQUARE_BRACKET,
|
95 |
+
\T_OPEN_PARENTHESIS,
|
96 |
+
);
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Returns an array of tokens this test wants to listen for.
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
public function register()
|
104 |
+
{
|
105 |
+
return array(
|
106 |
+
\T_FUNCTION,
|
107 |
+
\T_CLOSURE,
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Processes this test, when one of its tokens is encountered.
|
113 |
+
*
|
114 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
115 |
+
* @param int $stackPtr The position of the current token
|
116 |
+
* in the stack passed in $tokens.
|
117 |
+
*
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function process(File $phpcsFile, $stackPtr)
|
121 |
+
{
|
122 |
+
if ($this->supportsAbove('7.0') === false) {
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
$tokens = $phpcsFile->getTokens();
|
127 |
+
|
128 |
+
if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
|
129 |
+
// Abstract function, interface function, live coding or parse error.
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
|
133 |
+
$scopeOpener = $tokens[$stackPtr]['scope_opener'];
|
134 |
+
$scopeCloser = $tokens[$stackPtr]['scope_closer'];
|
135 |
+
|
136 |
+
// Does the function declaration have parameters ?
|
137 |
+
$params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
138 |
+
if (empty($params)) {
|
139 |
+
// No named arguments found, so no risk of them being changed.
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
$paramNames = array();
|
144 |
+
foreach ($params as $param) {
|
145 |
+
$paramNames[] = $param['name'];
|
146 |
+
}
|
147 |
+
|
148 |
+
for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) {
|
149 |
+
if (isset($this->skipPastNested[$tokens[$i]['type']]) && isset($tokens[$i]['scope_closer'])) {
|
150 |
+
// Skip past nested structures.
|
151 |
+
$i = $tokens[$i]['scope_closer'];
|
152 |
+
continue;
|
153 |
+
}
|
154 |
+
|
155 |
+
if ($tokens[$i]['code'] !== \T_STRING) {
|
156 |
+
continue;
|
157 |
+
}
|
158 |
+
|
159 |
+
$foundFunctionName = strtolower($tokens[$i]['content']);
|
160 |
+
|
161 |
+
if (isset($this->changedFunctions[$foundFunctionName]) === false) {
|
162 |
+
// Not one of the target functions.
|
163 |
+
continue;
|
164 |
+
}
|
165 |
+
|
166 |
+
/*
|
167 |
+
* Ok, so is this really a function call to one of the PHP native functions ?
|
168 |
+
*/
|
169 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
|
170 |
+
if ($next === false || $tokens[$next]['code'] !== \T_OPEN_PARENTHESIS) {
|
171 |
+
// Live coding, parse error or not a function call.
|
172 |
+
continue;
|
173 |
+
}
|
174 |
+
|
175 |
+
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
|
176 |
+
if ($prev !== false) {
|
177 |
+
if (isset($this->noneFunctionCallIndicators[$tokens[$prev]['code']])) {
|
178 |
+
continue;
|
179 |
+
}
|
180 |
+
|
181 |
+
// Check for namespaced functions, ie: \foo\bar() not \bar().
|
182 |
+
if ($tokens[ $prev ]['code'] === \T_NS_SEPARATOR) {
|
183 |
+
$pprev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
|
184 |
+
if ($pprev !== false && $tokens[ $pprev ]['code'] === \T_STRING) {
|
185 |
+
continue;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/*
|
191 |
+
* Address some special cases.
|
192 |
+
*/
|
193 |
+
if ($foundFunctionName !== 'func_get_args') {
|
194 |
+
$paramOne = $this->getFunctionCallParameter($phpcsFile, $i, 1);
|
195 |
+
if ($paramOne !== false) {
|
196 |
+
switch ($foundFunctionName) {
|
197 |
+
/*
|
198 |
+
* Check if `debug_(print_)backtrace()` is called with the
|
199 |
+
* `DEBUG_BACKTRACE_IGNORE_ARGS` option.
|
200 |
+
*/
|
201 |
+
case 'debug_backtrace':
|
202 |
+
case 'debug_print_backtrace':
|
203 |
+
$hasIgnoreArgs = $phpcsFile->findNext(
|
204 |
+
\T_STRING,
|
205 |
+
$paramOne['start'],
|
206 |
+
($paramOne['end'] + 1),
|
207 |
+
false,
|
208 |
+
'DEBUG_BACKTRACE_IGNORE_ARGS'
|
209 |
+
);
|
210 |
+
|
211 |
+
if ($hasIgnoreArgs !== false) {
|
212 |
+
// Debug_backtrace() called with ignore args option.
|
213 |
+
continue 2;
|
214 |
+
}
|
215 |
+
break;
|
216 |
+
|
217 |
+
/*
|
218 |
+
* Collect the necessary information to only throw a notice if the argument
|
219 |
+
* touched/changed is in line with the passed $arg_num.
|
220 |
+
*
|
221 |
+
* Also, we can ignore `func_get_arg()` if the argument offset passed is
|
222 |
+
* higher than the number of named parameters.
|
223 |
+
*
|
224 |
+
* {@internal Note: This does not take calculations into account!
|
225 |
+
* Should be exceptionally rare and can - if needs be - be addressed at a later stage.}}
|
226 |
+
*/
|
227 |
+
case 'func_get_arg':
|
228 |
+
$number = $phpcsFile->findNext(\T_LNUMBER, $paramOne['start'], ($paramOne['end'] + 1));
|
229 |
+
if ($number !== false) {
|
230 |
+
$argNumber = $tokens[$number]['content'];
|
231 |
+
|
232 |
+
if (isset($paramNames[$argNumber]) === false) {
|
233 |
+
// Requesting a non-named additional parameter. Ignore.
|
234 |
+
continue 2;
|
235 |
+
}
|
236 |
+
}
|
237 |
+
break;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
} else {
|
241 |
+
/*
|
242 |
+
* Check if the call to func_get_args() happens to be in an array_slice() or
|
243 |
+
* array_splice() with an $offset higher than the number of named parameters.
|
244 |
+
* In that case, we can ignore it.
|
245 |
+
*
|
246 |
+
* {@internal Note: This does not take offset calculations into account!
|
247 |
+
* Should be exceptionally rare and can - if needs be - be addressed at a later stage.}}
|
248 |
+
*/
|
249 |
+
if ($prev !== false && $tokens[$prev]['code'] === \T_OPEN_PARENTHESIS) {
|
250 |
+
|
251 |
+
$maybeFunctionCall = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
|
252 |
+
if ($maybeFunctionCall !== false
|
253 |
+
&& $tokens[$maybeFunctionCall]['code'] === \T_STRING
|
254 |
+
&& ($tokens[$maybeFunctionCall]['content'] === 'array_slice'
|
255 |
+
|| $tokens[$maybeFunctionCall]['content'] === 'array_splice')
|
256 |
+
) {
|
257 |
+
$parentFuncParamTwo = $this->getFunctionCallParameter($phpcsFile, $maybeFunctionCall, 2);
|
258 |
+
$number = $phpcsFile->findNext(
|
259 |
+
\T_LNUMBER,
|
260 |
+
$parentFuncParamTwo['start'],
|
261 |
+
($parentFuncParamTwo['end'] + 1)
|
262 |
+
);
|
263 |
+
|
264 |
+
if ($number !== false && isset($paramNames[$tokens[$number]['content']]) === false) {
|
265 |
+
// Requesting non-named additional parameters. Ignore.
|
266 |
+
continue ;
|
267 |
+
}
|
268 |
+
|
269 |
+
// Slice starts at a named argument, but we know which params are being accessed.
|
270 |
+
$paramNamesSubset = \array_slice($paramNames, $tokens[$number]['content']);
|
271 |
+
}
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
/*
|
276 |
+
* For debug_backtrace(), check if the result is being dereferenced and if so,
|
277 |
+
* whether the `args` index is used.
|
278 |
+
* I.e. whether `$index` in `debug_backtrace()[$stackFrame][$index]` is a string
|
279 |
+
* with the content `args`.
|
280 |
+
*
|
281 |
+
* Note: We already know that $next is the open parenthesis of the function call.
|
282 |
+
*/
|
283 |
+
if ($foundFunctionName === 'debug_backtrace' && isset($tokens[$next]['parenthesis_closer'])) {
|
284 |
+
$afterParenthesis = $phpcsFile->findNext(
|
285 |
+
Tokens::$emptyTokens,
|
286 |
+
($tokens[$next]['parenthesis_closer'] + 1),
|
287 |
+
null,
|
288 |
+
true
|
289 |
+
);
|
290 |
+
|
291 |
+
if ($tokens[$afterParenthesis]['code'] === \T_OPEN_SQUARE_BRACKET
|
292 |
+
&& isset($tokens[$afterParenthesis]['bracket_closer'])
|
293 |
+
) {
|
294 |
+
$afterStackFrame = $phpcsFile->findNext(
|
295 |
+
Tokens::$emptyTokens,
|
296 |
+
($tokens[$afterParenthesis]['bracket_closer'] + 1),
|
297 |
+
null,
|
298 |
+
true
|
299 |
+
);
|
300 |
+
|
301 |
+
if ($tokens[$afterStackFrame]['code'] === \T_OPEN_SQUARE_BRACKET
|
302 |
+
&& isset($tokens[$afterStackFrame]['bracket_closer'])
|
303 |
+
) {
|
304 |
+
$arrayIndex = $phpcsFile->findNext(
|
305 |
+
\T_CONSTANT_ENCAPSED_STRING,
|
306 |
+
($afterStackFrame + 1),
|
307 |
+
$tokens[$afterStackFrame]['bracket_closer']
|
308 |
+
);
|
309 |
+
|
310 |
+
if ($arrayIndex !== false && $this->stripQuotes($tokens[$arrayIndex]['content']) !== 'args') {
|
311 |
+
continue;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
/*
|
318 |
+
* Only check for variables before the start of the statement to
|
319 |
+
* prevent false positives on the return value of the function call
|
320 |
+
* being assigned to one of the parameters, i.e.:
|
321 |
+
* `$param = func_get_args();`.
|
322 |
+
*/
|
323 |
+
$startOfStatement = PHPCSHelper::findStartOfStatement($phpcsFile, $i, $this->ignoreForStartOfStatement);
|
324 |
+
|
325 |
+
/*
|
326 |
+
* Ok, so we've found one of the target functions in the right scope.
|
327 |
+
* Now, let's check if any of the passed parameters were touched.
|
328 |
+
*/
|
329 |
+
$scanResult = 'clean';
|
330 |
+
for ($j = ($scopeOpener + 1); $j < $startOfStatement; $j++) {
|
331 |
+
if (isset($this->skipPastNested[$tokens[$j]['type']])
|
332 |
+
&& isset($tokens[$j]['scope_closer'])
|
333 |
+
) {
|
334 |
+
// Skip past nested structures.
|
335 |
+
$j = $tokens[$j]['scope_closer'];
|
336 |
+
continue;
|
337 |
+
}
|
338 |
+
|
339 |
+
if ($tokens[$j]['code'] !== \T_VARIABLE) {
|
340 |
+
continue;
|
341 |
+
}
|
342 |
+
|
343 |
+
if ($foundFunctionName === 'func_get_arg' && isset($argNumber)) {
|
344 |
+
if (isset($paramNames[$argNumber])
|
345 |
+
&& $tokens[$j]['content'] !== $paramNames[$argNumber]
|
346 |
+
) {
|
347 |
+
// Different param than the one requested by func_get_arg().
|
348 |
+
continue;
|
349 |
+
}
|
350 |
+
} elseif ($foundFunctionName === 'func_get_args' && isset($paramNamesSubset)) {
|
351 |
+
if (\in_array($tokens[$j]['content'], $paramNamesSubset, true) === false) {
|
352 |
+
// Different param than the ones requested by func_get_args().
|
353 |
+
continue;
|
354 |
+
}
|
355 |
+
} elseif (\in_array($tokens[$j]['content'], $paramNames, true) === false) {
|
356 |
+
// Variable is not one of the function parameters.
|
357 |
+
continue;
|
358 |
+
}
|
359 |
+
|
360 |
+
/*
|
361 |
+
* Ok, so we've found a variable which was passed as one of the parameters.
|
362 |
+
* Now, is this variable being changed, i.e. incremented, decremented or
|
363 |
+
* assigned something ?
|
364 |
+
*/
|
365 |
+
$scanResult = 'warning';
|
366 |
+
if (isset($variableToken) === false) {
|
367 |
+
$variableToken = $j;
|
368 |
+
}
|
369 |
+
|
370 |
+
$beforeVar = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($j - 1), null, true);
|
371 |
+
if ($beforeVar !== false && isset($this->plusPlusMinusMinus[$tokens[$beforeVar]['code']])) {
|
372 |
+
// Variable is being (pre-)incremented/decremented.
|
373 |
+
$scanResult = 'error';
|
374 |
+
$variableToken = $j;
|
375 |
+
break;
|
376 |
+
}
|
377 |
+
|
378 |
+
$afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($j + 1), null, true);
|
379 |
+
if ($afterVar === false) {
|
380 |
+
// Shouldn't be possible, but just in case.
|
381 |
+
continue;
|
382 |
+
}
|
383 |
+
|
384 |
+
if (isset($this->plusPlusMinusMinus[$tokens[$afterVar]['code']])) {
|
385 |
+
// Variable is being (post-)incremented/decremented.
|
386 |
+
$scanResult = 'error';
|
387 |
+
$variableToken = $j;
|
388 |
+
break;
|
389 |
+
}
|
390 |
+
|
391 |
+
if ($tokens[$afterVar]['code'] === \T_OPEN_SQUARE_BRACKET
|
392 |
+
&& isset($tokens[$afterVar]['bracket_closer'])
|
393 |
+
) {
|
394 |
+
// Skip past array access on the variable.
|
395 |
+
while (($afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($tokens[$afterVar]['bracket_closer'] + 1), null, true)) !== false) {
|
396 |
+
if ($tokens[$afterVar]['code'] !== \T_OPEN_SQUARE_BRACKET
|
397 |
+
|| isset($tokens[$afterVar]['bracket_closer']) === false
|
398 |
+
) {
|
399 |
+
break;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
if ($afterVar !== false
|
405 |
+
&& isset(Tokens::$assignmentTokens[$tokens[$afterVar]['code']])
|
406 |
+
) {
|
407 |
+
// Variable is being assigned something.
|
408 |
+
$scanResult = 'error';
|
409 |
+
$variableToken = $j;
|
410 |
+
break;
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
unset($argNumber, $paramNamesSubset);
|
415 |
+
|
416 |
+
if ($scanResult === 'clean') {
|
417 |
+
continue;
|
418 |
+
}
|
419 |
+
|
420 |
+
$error = 'Since PHP 7.0, functions inspecting arguments, like %1$s(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "%2$s" was %4$s on line %3$s.';
|
421 |
+
$data = array(
|
422 |
+
$foundFunctionName,
|
423 |
+
$tokens[$variableToken]['content'],
|
424 |
+
$tokens[$variableToken]['line'],
|
425 |
+
);
|
426 |
+
|
427 |
+
if ($scanResult === 'error') {
|
428 |
+
$data[] = 'changed';
|
429 |
+
$phpcsFile->addError($error, $i, 'Changed', $data);
|
430 |
+
|
431 |
+
} elseif ($scanResult === 'warning') {
|
432 |
+
$data[] = 'used, and possibly changed (by reference),';
|
433 |
+
$phpcsFile->addWarning($error, $i, 'NeedsInspection', $data);
|
434 |
+
}
|
435 |
+
|
436 |
+
unset($variableToken);
|
437 |
+
}
|
438 |
+
}
|
439 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/ArgumentFunctionsUsageSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* - Prior to PHP 5.3, these functions could not be used as a function call parameter.
|
20 |
*
|
@@ -52,7 +54,7 @@ class ArgumentFunctionsUsageSniff extends Sniff
|
|
52 |
*/
|
53 |
public function register()
|
54 |
{
|
55 |
-
return array(T_STRING);
|
56 |
}
|
57 |
|
58 |
|
@@ -65,7 +67,7 @@ class ArgumentFunctionsUsageSniff extends Sniff
|
|
65 |
*
|
66 |
* @return void
|
67 |
*/
|
68 |
-
public function process(
|
69 |
{
|
70 |
$tokens = $phpcsFile->getTokens();
|
71 |
$functionLc = strtolower($tokens[$stackPtr]['content']);
|
@@ -74,23 +76,23 @@ class ArgumentFunctionsUsageSniff extends Sniff
|
|
74 |
}
|
75 |
|
76 |
// Next non-empty token should be the open parenthesis.
|
77 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
78 |
-
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) {
|
79 |
return;
|
80 |
}
|
81 |
|
82 |
$ignore = array(
|
83 |
-
T_DOUBLE_COLON => true,
|
84 |
-
T_OBJECT_OPERATOR => true,
|
85 |
-
T_FUNCTION => true,
|
86 |
-
T_NEW => true,
|
87 |
);
|
88 |
|
89 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
90 |
if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) {
|
91 |
// Not a call to a PHP function.
|
92 |
return;
|
93 |
-
} elseif ($tokens[$prevNonEmpty]['code'] === T_NS_SEPARATOR && $tokens[$prevNonEmpty - 1]['code'] === T_STRING) {
|
94 |
// Namespaced function.
|
95 |
return;
|
96 |
}
|
@@ -103,7 +105,7 @@ class ArgumentFunctionsUsageSniff extends Sniff
|
|
103 |
* As PHPCS can not determine whether a file is included from within a function in
|
104 |
* another file, so always throw a warning/error.
|
105 |
*/
|
106 |
-
if ($phpcsFile->hasCondition($stackPtr, array(T_FUNCTION, T_CLOSURE)) === false) {
|
107 |
$isError = false;
|
108 |
$message = 'Use of %s() outside of a user-defined function is only supported if the file is included from within a user-defined function in another file prior to PHP 5.3.';
|
109 |
|
@@ -135,13 +137,13 @@ class ArgumentFunctionsUsageSniff extends Sniff
|
|
135 |
$throwError = true;
|
136 |
} else {
|
137 |
$opener = key($tokens[$stackPtr]['nested_parenthesis']);
|
138 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
139 |
-
if ($tokens[$prevNonEmpty]['code'] !== T_STRING) {
|
140 |
return;
|
141 |
}
|
142 |
|
143 |
-
$prevPrevNonEmpty = $phpcsFile->findPrevious(
|
144 |
-
if ($tokens[$prevPrevNonEmpty]['code'] === T_FUNCTION) {
|
145 |
return;
|
146 |
}
|
147 |
|
@@ -159,5 +161,4 @@ class ArgumentFunctionsUsageSniff extends Sniff
|
|
159 |
$data
|
160 |
);
|
161 |
}
|
162 |
-
|
163 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\ArgumentFunctionsUsageSniff.
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\FunctionUse\ArgumentFunctionsUsageSniff.
|
20 |
*
|
21 |
* - Prior to PHP 5.3, these functions could not be used as a function call parameter.
|
22 |
*
|
54 |
*/
|
55 |
public function register()
|
56 |
{
|
57 |
+
return array(\T_STRING);
|
58 |
}
|
59 |
|
60 |
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
+
public function process(File $phpcsFile, $stackPtr)
|
71 |
{
|
72 |
$tokens = $phpcsFile->getTokens();
|
73 |
$functionLc = strtolower($tokens[$stackPtr]['content']);
|
76 |
}
|
77 |
|
78 |
// Next non-empty token should be the open parenthesis.
|
79 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
80 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
|
81 |
return;
|
82 |
}
|
83 |
|
84 |
$ignore = array(
|
85 |
+
\T_DOUBLE_COLON => true,
|
86 |
+
\T_OBJECT_OPERATOR => true,
|
87 |
+
\T_FUNCTION => true,
|
88 |
+
\T_NEW => true,
|
89 |
);
|
90 |
|
91 |
+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
92 |
if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) {
|
93 |
// Not a call to a PHP function.
|
94 |
return;
|
95 |
+
} elseif ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING) {
|
96 |
// Namespaced function.
|
97 |
return;
|
98 |
}
|
105 |
* As PHPCS can not determine whether a file is included from within a function in
|
106 |
* another file, so always throw a warning/error.
|
107 |
*/
|
108 |
+
if ($phpcsFile->hasCondition($stackPtr, array(\T_FUNCTION, \T_CLOSURE)) === false) {
|
109 |
$isError = false;
|
110 |
$message = 'Use of %s() outside of a user-defined function is only supported if the file is included from within a user-defined function in another file prior to PHP 5.3.';
|
111 |
|
137 |
$throwError = true;
|
138 |
} else {
|
139 |
$opener = key($tokens[$stackPtr]['nested_parenthesis']);
|
140 |
+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
|
141 |
+
if ($tokens[$prevNonEmpty]['code'] !== \T_STRING) {
|
142 |
return;
|
143 |
}
|
144 |
|
145 |
+
$prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
|
146 |
+
if ($tokens[$prevPrevNonEmpty]['code'] === \T_FUNCTION) {
|
147 |
return;
|
148 |
}
|
149 |
|
161 |
$data
|
162 |
);
|
163 |
}
|
|
|
164 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/NewFunctionParametersSniff.php
RENAMED
@@ -1,18 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -400,6 +402,90 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
400 |
'5.5' => true,
|
401 |
),
|
402 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
'memory_get_peak_usage' => array(
|
404 |
0 => array(
|
405 |
'name' => 'real_usage',
|
@@ -606,8 +692,8 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
606 |
'php_uname' => array(
|
607 |
0 => array(
|
608 |
'name' => 'mode',
|
609 |
-
'
|
610 |
-
'
|
611 |
),
|
612 |
),
|
613 |
'preg_replace' => array(
|
@@ -623,6 +709,18 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
623 |
'5.0' => false,
|
624 |
'5.1' => true,
|
625 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
),
|
627 |
'round' => array(
|
628 |
2 => array(
|
@@ -846,8 +944,8 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
846 |
// Handle case-insensitivity of function names.
|
847 |
$this->newFunctionParameters = $this->arrayKeysToLowercase($this->newFunctionParameters);
|
848 |
|
849 |
-
return array(T_STRING);
|
850 |
-
}
|
851 |
|
852 |
/**
|
853 |
* Processes this test, when one of its tokens is encountered.
|
@@ -858,19 +956,19 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
858 |
*
|
859 |
* @return void
|
860 |
*/
|
861 |
-
public function process(
|
862 |
{
|
863 |
$tokens = $phpcsFile->getTokens();
|
864 |
|
865 |
$ignore = array(
|
866 |
-
T_DOUBLE_COLON,
|
867 |
-
T_OBJECT_OPERATOR,
|
868 |
-
T_FUNCTION,
|
869 |
-
T_CONST,
|
870 |
);
|
871 |
|
872 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
873 |
-
if (
|
874 |
// Not a call to a PHP function.
|
875 |
return;
|
876 |
}
|
@@ -888,7 +986,7 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
888 |
}
|
889 |
|
890 |
// If the parameter count returned > 0, we know there will be valid open parenthesis.
|
891 |
-
$openParenthesis = $phpcsFile->findNext(
|
892 |
$parameterOffsetFound = $parameterCount - 1;
|
893 |
|
894 |
foreach ($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
|
@@ -901,8 +999,7 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
901 |
$this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
|
902 |
}
|
903 |
}
|
904 |
-
|
905 |
-
}//end process()
|
906 |
|
907 |
|
908 |
/**
|
@@ -986,6 +1083,4 @@ class NewFunctionParametersSniff extends AbstractNewFeatureSniff
|
|
986 |
array_unshift($data, $itemInfo['name'], $errorInfo['paramName']);
|
987 |
return $data;
|
988 |
}
|
989 |
-
|
990 |
-
|
991 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\NewFunctionParametersSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\FunctionUse\newFunctionParametersSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
402 |
'5.5' => true,
|
403 |
),
|
404 |
),
|
405 |
+
'ldap_add' => array(
|
406 |
+
3 => array(
|
407 |
+
'name' => 'serverctrls',
|
408 |
+
'7.2' => false,
|
409 |
+
'7.3' => true,
|
410 |
+
),
|
411 |
+
),
|
412 |
+
'ldap_compare' => array(
|
413 |
+
4 => array(
|
414 |
+
'name' => 'serverctrls',
|
415 |
+
'7.2' => false,
|
416 |
+
'7.3' => true,
|
417 |
+
),
|
418 |
+
),
|
419 |
+
'ldap_delete' => array(
|
420 |
+
2 => array(
|
421 |
+
'name' => 'serverctrls',
|
422 |
+
'7.2' => false,
|
423 |
+
'7.3' => true,
|
424 |
+
),
|
425 |
+
),
|
426 |
+
'ldap_list' => array(
|
427 |
+
8 => array(
|
428 |
+
'name' => 'serverctrls',
|
429 |
+
'7.2' => false,
|
430 |
+
'7.3' => true,
|
431 |
+
),
|
432 |
+
),
|
433 |
+
'ldap_mod_add' => array(
|
434 |
+
3 => array(
|
435 |
+
'name' => 'serverctrls',
|
436 |
+
'7.2' => false,
|
437 |
+
'7.3' => true,
|
438 |
+
),
|
439 |
+
),
|
440 |
+
'ldap_mod_del' => array(
|
441 |
+
3 => array(
|
442 |
+
'name' => 'serverctrls',
|
443 |
+
'7.2' => false,
|
444 |
+
'7.3' => true,
|
445 |
+
),
|
446 |
+
),
|
447 |
+
'ldap_mod_replace' => array(
|
448 |
+
3 => array(
|
449 |
+
'name' => 'serverctrls',
|
450 |
+
'7.2' => false,
|
451 |
+
'7.3' => true,
|
452 |
+
),
|
453 |
+
),
|
454 |
+
'ldap_modify_batch' => array(
|
455 |
+
3 => array(
|
456 |
+
'name' => 'serverctrls',
|
457 |
+
'7.2' => false,
|
458 |
+
'7.3' => true,
|
459 |
+
),
|
460 |
+
),
|
461 |
+
'ldap_parse_result' => array(
|
462 |
+
6 => array(
|
463 |
+
'name' => 'serverctrls',
|
464 |
+
'7.2' => false,
|
465 |
+
'7.3' => true,
|
466 |
+
),
|
467 |
+
),
|
468 |
+
'ldap_read' => array(
|
469 |
+
8 => array(
|
470 |
+
'name' => 'serverctrls',
|
471 |
+
'7.2' => false,
|
472 |
+
'7.3' => true,
|
473 |
+
),
|
474 |
+
),
|
475 |
+
'ldap_rename' => array(
|
476 |
+
5 => array(
|
477 |
+
'name' => 'serverctrls',
|
478 |
+
'7.2' => false,
|
479 |
+
'7.3' => true,
|
480 |
+
),
|
481 |
+
),
|
482 |
+
'ldap_search' => array(
|
483 |
+
8 => array(
|
484 |
+
'name' => 'serverctrls',
|
485 |
+
'7.2' => false,
|
486 |
+
'7.3' => true,
|
487 |
+
),
|
488 |
+
),
|
489 |
'memory_get_peak_usage' => array(
|
490 |
0 => array(
|
491 |
'name' => 'real_usage',
|
692 |
'php_uname' => array(
|
693 |
0 => array(
|
694 |
'name' => 'mode',
|
695 |
+
'4.2' => false,
|
696 |
+
'4.3' => true,
|
697 |
),
|
698 |
),
|
699 |
'preg_replace' => array(
|
709 |
'5.0' => false,
|
710 |
'5.1' => true,
|
711 |
),
|
712 |
+
5 => array(
|
713 |
+
'name' => 'flags',
|
714 |
+
'7.3' => false,
|
715 |
+
'7.4' => true,
|
716 |
+
),
|
717 |
+
),
|
718 |
+
'preg_replace_callback_array' => array(
|
719 |
+
4 => array(
|
720 |
+
'name' => 'flags',
|
721 |
+
'7.3' => false,
|
722 |
+
'7.4' => true,
|
723 |
+
),
|
724 |
),
|
725 |
'round' => array(
|
726 |
2 => array(
|
944 |
// Handle case-insensitivity of function names.
|
945 |
$this->newFunctionParameters = $this->arrayKeysToLowercase($this->newFunctionParameters);
|
946 |
|
947 |
+
return array(\T_STRING);
|
948 |
+
}
|
949 |
|
950 |
/**
|
951 |
* Processes this test, when one of its tokens is encountered.
|
956 |
*
|
957 |
* @return void
|
958 |
*/
|
959 |
+
public function process(File $phpcsFile, $stackPtr)
|
960 |
{
|
961 |
$tokens = $phpcsFile->getTokens();
|
962 |
|
963 |
$ignore = array(
|
964 |
+
\T_DOUBLE_COLON => true,
|
965 |
+
\T_OBJECT_OPERATOR => true,
|
966 |
+
\T_FUNCTION => true,
|
967 |
+
\T_CONST => true,
|
968 |
);
|
969 |
|
970 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
971 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
972 |
// Not a call to a PHP function.
|
973 |
return;
|
974 |
}
|
986 |
}
|
987 |
|
988 |
// If the parameter count returned > 0, we know there will be valid open parenthesis.
|
989 |
+
$openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
990 |
$parameterOffsetFound = $parameterCount - 1;
|
991 |
|
992 |
foreach ($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
|
999 |
$this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
|
1000 |
}
|
1001 |
}
|
1002 |
+
}
|
|
|
1003 |
|
1004 |
|
1005 |
/**
|
1083 |
array_unshift($data, $itemInfo['name'], $errorInfo['paramName']);
|
1084 |
return $data;
|
1085 |
}
|
1086 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/NewFunctionsSniff.php
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -1275,6 +1276,10 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1275 |
'7.0' => false,
|
1276 |
'7.1' => true,
|
1277 |
),
|
|
|
|
|
|
|
|
|
1278 |
'session_create_id' => array(
|
1279 |
'7.0' => false,
|
1280 |
'7.1' => true,
|
@@ -1283,7 +1288,27 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1283 |
'7.0' => false,
|
1284 |
'7.1' => true,
|
1285 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1286 |
|
|
|
|
|
|
|
|
|
1287 |
'oci_register_taf_callback' => array(
|
1288 |
'7.1.6' => false,
|
1289 |
'7.1.7' => true,
|
@@ -1721,11 +1746,138 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1721 |
'7.1' => false,
|
1722 |
'7.2' => true,
|
1723 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1724 |
|
|
|
|
|
|
|
|
|
1725 |
'is_countable' => array(
|
1726 |
'7.2' => false,
|
1727 |
'7.3' => true,
|
1728 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1729 |
);
|
1730 |
|
1731 |
|
@@ -1739,9 +1891,8 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1739 |
// Handle case-insensitivity of function names.
|
1740 |
$this->newFunctions = $this->arrayKeysToLowercase($this->newFunctions);
|
1741 |
|
1742 |
-
return array(T_STRING);
|
1743 |
-
|
1744 |
-
}//end register()
|
1745 |
|
1746 |
/**
|
1747 |
* Processes this test, when one of its tokens is encountered.
|
@@ -1752,23 +1903,23 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1752 |
*
|
1753 |
* @return void
|
1754 |
*/
|
1755 |
-
public function process(
|
1756 |
{
|
1757 |
$tokens = $phpcsFile->getTokens();
|
1758 |
|
1759 |
$ignore = array(
|
1760 |
-
T_DOUBLE_COLON,
|
1761 |
-
T_OBJECT_OPERATOR,
|
1762 |
-
T_FUNCTION,
|
1763 |
-
T_CONST,
|
1764 |
);
|
1765 |
|
1766 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
1767 |
-
if (
|
1768 |
// Not a call to a PHP function.
|
1769 |
return;
|
1770 |
|
1771 |
-
} elseif ($tokens[$prevToken]['code'] === T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === T_STRING) {
|
1772 |
// Namespaced function.
|
1773 |
return;
|
1774 |
}
|
@@ -1785,8 +1936,7 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1785 |
'nameLc' => $functionLc,
|
1786 |
);
|
1787 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
1788 |
-
|
1789 |
-
}//end process()
|
1790 |
|
1791 |
|
1792 |
/**
|
@@ -1811,6 +1961,4 @@ class NewFunctionsSniff extends AbstractNewFeatureSniff
|
|
1811 |
{
|
1812 |
return 'The function %s() is not present in PHP version %s or earlier';
|
1813 |
}
|
1814 |
-
|
1815 |
-
|
1816 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\NewFunctionsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\FunctionUse\newFunctionsSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
1276 |
'7.0' => false,
|
1277 |
'7.1' => true,
|
1278 |
),
|
1279 |
+
'pcntl_signal_get_handler' => array(
|
1280 |
+
'7.0' => false,
|
1281 |
+
'7.1' => true,
|
1282 |
+
),
|
1283 |
'session_create_id' => array(
|
1284 |
'7.0' => false,
|
1285 |
'7.1' => true,
|
1288 |
'7.0' => false,
|
1289 |
'7.1' => true,
|
1290 |
),
|
1291 |
+
'sapi_windows_cp_set' => array(
|
1292 |
+
'7.0' => false,
|
1293 |
+
'7.1' => true,
|
1294 |
+
),
|
1295 |
+
'sapi_windows_cp_get' => array(
|
1296 |
+
'7.0' => false,
|
1297 |
+
'7.1' => true,
|
1298 |
+
),
|
1299 |
+
'sapi_windows_cp_is_utf8' => array(
|
1300 |
+
'7.0' => false,
|
1301 |
+
'7.1' => true,
|
1302 |
+
),
|
1303 |
+
'sapi_windows_cp_conv' => array(
|
1304 |
+
'7.0' => false,
|
1305 |
+
'7.1' => true,
|
1306 |
+
),
|
1307 |
|
1308 |
+
'hash_hkdf' => array(
|
1309 |
+
'7.1.1' => false,
|
1310 |
+
'7.1.2' => true,
|
1311 |
+
),
|
1312 |
'oci_register_taf_callback' => array(
|
1313 |
'7.1.6' => false,
|
1314 |
'7.1.7' => true,
|
1746 |
'7.1' => false,
|
1747 |
'7.2' => true,
|
1748 |
),
|
1749 |
+
// Introduced in 7.2.14 and 7.3.1 similtanously.
|
1750 |
+
'oci_set_call_timeout' => array(
|
1751 |
+
'7.2.13' => false,
|
1752 |
+
'7.2.14' => true,
|
1753 |
+
),
|
1754 |
+
// Introduced in 7.2.14 and 7.3.1 similtanously.
|
1755 |
+
'oci_set_db_operation' => array(
|
1756 |
+
'7.2.13' => false,
|
1757 |
+
'7.2.14' => true,
|
1758 |
+
),
|
1759 |
|
1760 |
+
'hrtime' => array(
|
1761 |
+
'7.2' => false,
|
1762 |
+
'7.3' => true,
|
1763 |
+
),
|
1764 |
'is_countable' => array(
|
1765 |
'7.2' => false,
|
1766 |
'7.3' => true,
|
1767 |
),
|
1768 |
+
'array_key_first' => array(
|
1769 |
+
'7.2' => false,
|
1770 |
+
'7.3' => true,
|
1771 |
+
),
|
1772 |
+
'array_key_last' => array(
|
1773 |
+
'7.2' => false,
|
1774 |
+
'7.3' => true,
|
1775 |
+
),
|
1776 |
+
'fpm_get_status' => array(
|
1777 |
+
'7.2' => false,
|
1778 |
+
'7.3' => true,
|
1779 |
+
),
|
1780 |
+
'net_get_interfaces' => array(
|
1781 |
+
'7.2' => false,
|
1782 |
+
'7.3' => true,
|
1783 |
+
),
|
1784 |
+
'gmp_binomial' => array(
|
1785 |
+
'7.2' => false,
|
1786 |
+
'7.3' => true,
|
1787 |
+
),
|
1788 |
+
'gmp_lcm' => array(
|
1789 |
+
'7.2' => false,
|
1790 |
+
'7.3' => true,
|
1791 |
+
),
|
1792 |
+
'gmp_perfect_power' => array(
|
1793 |
+
'7.2' => false,
|
1794 |
+
'7.3' => true,
|
1795 |
+
),
|
1796 |
+
'gmp_kronecker' => array(
|
1797 |
+
'7.2' => false,
|
1798 |
+
'7.3' => true,
|
1799 |
+
),
|
1800 |
+
'ldap_add_ext' => array(
|
1801 |
+
'7.2' => false,
|
1802 |
+
'7.3' => true,
|
1803 |
+
),
|
1804 |
+
'ldap_bind_ext' => array(
|
1805 |
+
'7.2' => false,
|
1806 |
+
'7.3' => true,
|
1807 |
+
),
|
1808 |
+
'ldap_delete_ext' => array(
|
1809 |
+
'7.2' => false,
|
1810 |
+
'7.3' => true,
|
1811 |
+
),
|
1812 |
+
'ldap_exop_refresh' => array(
|
1813 |
+
'7.2' => false,
|
1814 |
+
'7.3' => true,
|
1815 |
+
),
|
1816 |
+
'ldap_mod_add_ext' => array(
|
1817 |
+
'7.2' => false,
|
1818 |
+
'7.3' => true,
|
1819 |
+
),
|
1820 |
+
'ldap_mod_replace_ext' => array(
|
1821 |
+
'7.2' => false,
|
1822 |
+
'7.3' => true,
|
1823 |
+
),
|
1824 |
+
'ldap_mod_del_ext' => array(
|
1825 |
+
'7.2' => false,
|
1826 |
+
'7.3' => true,
|
1827 |
+
),
|
1828 |
+
'ldap_rename_ext' => array(
|
1829 |
+
'7.2' => false,
|
1830 |
+
'7.3' => true,
|
1831 |
+
),
|
1832 |
+
'normalizer_get_raw_decomposition' => array(
|
1833 |
+
'7.2' => false,
|
1834 |
+
'7.3' => true,
|
1835 |
+
),
|
1836 |
+
'openssl_pkey_derive' => array(
|
1837 |
+
'7.2' => false,
|
1838 |
+
'7.3' => true,
|
1839 |
+
),
|
1840 |
+
'socket_wsaprotocol_info_export' => array(
|
1841 |
+
'7.2' => false,
|
1842 |
+
'7.3' => true,
|
1843 |
+
),
|
1844 |
+
'socket_wsaprotocol_info_import' => array(
|
1845 |
+
'7.2' => false,
|
1846 |
+
'7.3' => true,
|
1847 |
+
),
|
1848 |
+
'socket_wsaprotocol_info_release' => array(
|
1849 |
+
'7.2' => false,
|
1850 |
+
'7.3' => true,
|
1851 |
+
),
|
1852 |
+
|
1853 |
+
'get_mangled_object_vars' => array(
|
1854 |
+
'7.3' => false,
|
1855 |
+
'7.4' => true,
|
1856 |
+
),
|
1857 |
+
'mb_str_split' => array(
|
1858 |
+
'7.3' => false,
|
1859 |
+
'7.4' => true,
|
1860 |
+
),
|
1861 |
+
'openssl_x509_verify' => array(
|
1862 |
+
'7.3' => false,
|
1863 |
+
'7.4' => true,
|
1864 |
+
),
|
1865 |
+
'password_algos' => array(
|
1866 |
+
'7.3' => false,
|
1867 |
+
'7.4' => true,
|
1868 |
+
),
|
1869 |
+
'pcntl_unshare' => array(
|
1870 |
+
'7.3' => false,
|
1871 |
+
'7.4' => true,
|
1872 |
+
),
|
1873 |
+
'sapi_windows_set_ctrl_handler' => array(
|
1874 |
+
'7.3' => false,
|
1875 |
+
'7.4' => true,
|
1876 |
+
),
|
1877 |
+
'sapi_windows_generate_ctrl_event' => array(
|
1878 |
+
'7.3' => false,
|
1879 |
+
'7.4' => true,
|
1880 |
+
),
|
1881 |
);
|
1882 |
|
1883 |
|
1891 |
// Handle case-insensitivity of function names.
|
1892 |
$this->newFunctions = $this->arrayKeysToLowercase($this->newFunctions);
|
1893 |
|
1894 |
+
return array(\T_STRING);
|
1895 |
+
}
|
|
|
1896 |
|
1897 |
/**
|
1898 |
* Processes this test, when one of its tokens is encountered.
|
1903 |
*
|
1904 |
* @return void
|
1905 |
*/
|
1906 |
+
public function process(File $phpcsFile, $stackPtr)
|
1907 |
{
|
1908 |
$tokens = $phpcsFile->getTokens();
|
1909 |
|
1910 |
$ignore = array(
|
1911 |
+
\T_DOUBLE_COLON => true,
|
1912 |
+
\T_OBJECT_OPERATOR => true,
|
1913 |
+
\T_FUNCTION => true,
|
1914 |
+
\T_CONST => true,
|
1915 |
);
|
1916 |
|
1917 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
1918 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
1919 |
// Not a call to a PHP function.
|
1920 |
return;
|
1921 |
|
1922 |
+
} elseif ($tokens[$prevToken]['code'] === \T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === \T_STRING) {
|
1923 |
// Namespaced function.
|
1924 |
return;
|
1925 |
}
|
1936 |
'nameLc' => $functionLc,
|
1937 |
);
|
1938 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
1939 |
+
}
|
|
|
1940 |
|
1941 |
|
1942 |
/**
|
1961 |
{
|
1962 |
return 'The function %s() is not present in PHP version %s or earlier';
|
1963 |
}
|
1964 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/OptionalRequiredFunctionParametersSniff.php → FunctionUse/OptionalToRequiredFunctionParametersSniff.php}
RENAMED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
-
use PHPCompatibility\Sniffs\
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
19 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
|
24 |
/**
|
@@ -102,8 +103,7 @@ class OptionalRequiredFunctionParametersSniff extends RequiredOptionalFunctionPa
|
|
102 |
$errorInfo['paramName'] = $itemArray['name'];
|
103 |
|
104 |
return $errorInfo;
|
105 |
-
|
106 |
-
}//end getErrorInfo()
|
107 |
|
108 |
|
109 |
/**
|
@@ -118,7 +118,7 @@ class OptionalRequiredFunctionParametersSniff extends RequiredOptionalFunctionPa
|
|
118 |
*
|
119 |
* @return void
|
120 |
*/
|
121 |
-
public function addError(
|
122 |
{
|
123 |
$error = 'The "%s" parameter for function %s() is missing. Passing this parameter is ';
|
124 |
if ($errorInfo['optionalRecommended'] === '') {
|
@@ -151,12 +151,9 @@ class OptionalRequiredFunctionParametersSniff extends RequiredOptionalFunctionPa
|
|
151 |
}
|
152 |
|
153 |
// Remove the last 'and' from the message.
|
154 |
-
$error = substr($error, 0, (strlen($error) - 5));
|
155 |
}
|
156 |
|
157 |
$this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\OptionalToRequiredFunctionParametersSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
11 |
|
12 |
+
use PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\FunctionUse\OptionalToRequiredFunctionParametersSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
20 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
21 |
*/
|
22 |
+
class OptionalToRequiredFunctionParametersSniff extends RequiredToOptionalFunctionParametersSniff
|
23 |
{
|
24 |
|
25 |
/**
|
103 |
$errorInfo['paramName'] = $itemArray['name'];
|
104 |
|
105 |
return $errorInfo;
|
106 |
+
}
|
|
|
107 |
|
108 |
|
109 |
/**
|
118 |
*
|
119 |
* @return void
|
120 |
*/
|
121 |
+
public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
|
122 |
{
|
123 |
$error = 'The "%s" parameter for function %s() is missing. Passing this parameter is ';
|
124 |
if ($errorInfo['optionalRecommended'] === '') {
|
151 |
}
|
152 |
|
153 |
// Remove the last 'and' from the message.
|
154 |
+
$error = substr($error, 0, (\strlen($error) - 5));
|
155 |
}
|
156 |
|
157 |
$this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
|
158 |
+
}
|
159 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → FunctionUse}/RemovedFunctionParametersSniff.php
RENAMED
@@ -1,18 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -30,6 +32,12 @@ class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
|
|
30 |
* @var array
|
31 |
*/
|
32 |
protected $removedFunctionParameters = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
'gmmktime' => array(
|
34 |
6 => array(
|
35 |
'name' => 'is_dst',
|
@@ -69,8 +77,8 @@ class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
|
|
69 |
// Handle case-insensitivity of function names.
|
70 |
$this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters);
|
71 |
|
72 |
-
return array(T_STRING);
|
73 |
-
}
|
74 |
|
75 |
/**
|
76 |
* Processes this test, when one of its tokens is encountered.
|
@@ -81,19 +89,19 @@ class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
|
|
81 |
*
|
82 |
* @return void
|
83 |
*/
|
84 |
-
public function process(
|
85 |
{
|
86 |
$tokens = $phpcsFile->getTokens();
|
87 |
|
88 |
$ignore = array(
|
89 |
-
T_DOUBLE_COLON,
|
90 |
-
T_OBJECT_OPERATOR,
|
91 |
-
T_FUNCTION,
|
92 |
-
T_CONST,
|
93 |
);
|
94 |
|
95 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
96 |
-
if (
|
97 |
// Not a call to a PHP function.
|
98 |
return;
|
99 |
}
|
@@ -111,7 +119,7 @@ class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
|
|
111 |
}
|
112 |
|
113 |
// If the parameter count returned > 0, we know there will be valid open parenthesis.
|
114 |
-
$openParenthesis = $phpcsFile->findNext(
|
115 |
$parameterOffsetFound = $parameterCount - 1;
|
116 |
|
117 |
foreach ($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) {
|
@@ -124,8 +132,7 @@ class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
|
|
124 |
$this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
|
125 |
}
|
126 |
}
|
127 |
-
|
128 |
-
}//end process()
|
129 |
|
130 |
|
131 |
/**
|
@@ -209,6 +216,4 @@ class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
|
|
209 |
array_unshift($data, $errorInfo['paramName'], $itemInfo['name']);
|
210 |
return $data;
|
211 |
}
|
212 |
-
|
213 |
-
|
214 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\RemovedFunctionParametersSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\FunctionUse\RemovedFunctionParametersSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
32 |
* @var array
|
33 |
*/
|
34 |
protected $removedFunctionParameters = array(
|
35 |
+
'define' => array(
|
36 |
+
2 => array(
|
37 |
+
'name' => 'case_insensitive',
|
38 |
+
'7.3' => false, // Slated for removal in PHP 8.0.0.
|
39 |
+
),
|
40 |
+
),
|
41 |
'gmmktime' => array(
|
42 |
6 => array(
|
43 |
'name' => 'is_dst',
|
77 |
// Handle case-insensitivity of function names.
|
78 |
$this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters);
|
79 |
|
80 |
+
return array(\T_STRING);
|
81 |
+
}
|
82 |
|
83 |
/**
|
84 |
* Processes this test, when one of its tokens is encountered.
|
89 |
*
|
90 |
* @return void
|
91 |
*/
|
92 |
+
public function process(File $phpcsFile, $stackPtr)
|
93 |
{
|
94 |
$tokens = $phpcsFile->getTokens();
|
95 |
|
96 |
$ignore = array(
|
97 |
+
\T_DOUBLE_COLON => true,
|
98 |
+
\T_OBJECT_OPERATOR => true,
|
99 |
+
\T_FUNCTION => true,
|
100 |
+
\T_CONST => true,
|
101 |
);
|
102 |
|
103 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
104 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
105 |
// Not a call to a PHP function.
|
106 |
return;
|
107 |
}
|
119 |
}
|
120 |
|
121 |
// If the parameter count returned > 0, we know there will be valid open parenthesis.
|
122 |
+
$openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
123 |
$parameterOffsetFound = $parameterCount - 1;
|
124 |
|
125 |
foreach ($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) {
|
132 |
$this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
|
133 |
}
|
134 |
}
|
135 |
+
}
|
|
|
136 |
|
137 |
|
138 |
/**
|
216 |
array_unshift($data, $errorInfo['paramName'], $itemInfo['name']);
|
217 |
return $data;
|
218 |
}
|
219 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedFunctionsSniff.php → FunctionUse/RemovedFunctionsSniff.php}
RENAMED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
19 |
* @author Wim Godden <wim.godden@cu.be>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
/**
|
24 |
* A list of deprecated and removed functions with their alternatives.
|
@@ -33,65 +34,64 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
33 |
'5.0.5' => true,
|
34 |
'alternative' => null,
|
35 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
'call_user_method' => array(
|
37 |
'5.3' => false,
|
38 |
-
'5.4' => false,
|
39 |
-
'5.5' => false,
|
40 |
-
'5.6' => false,
|
41 |
'7.0' => true,
|
42 |
'alternative' => 'call_user_func()',
|
43 |
),
|
44 |
'call_user_method_array' => array(
|
45 |
'5.3' => false,
|
46 |
-
'5.4' => false,
|
47 |
-
'5.5' => false,
|
48 |
-
'5.6' => false,
|
49 |
'7.0' => true,
|
50 |
'alternative' => 'call_user_func_array()',
|
51 |
),
|
52 |
'define_syslog_variables' => array(
|
53 |
'5.3' => false,
|
54 |
'5.4' => true,
|
55 |
-
'5.5' => true,
|
56 |
-
'5.6' => true,
|
57 |
'alternative' => null,
|
58 |
),
|
59 |
'dl' => array(
|
60 |
'5.3' => false,
|
61 |
-
'5.4' => false,
|
62 |
-
'5.5' => false,
|
63 |
-
'5.6' => false,
|
64 |
'alternative' => null,
|
65 |
),
|
66 |
'ereg' => array(
|
67 |
'5.3' => false,
|
68 |
-
'5.4' => false,
|
69 |
-
'5.5' => false,
|
70 |
-
'5.6' => false,
|
71 |
'7.0' => true,
|
72 |
'alternative' => 'preg_match()',
|
73 |
),
|
74 |
'ereg_replace' => array(
|
75 |
'5.3' => false,
|
76 |
-
'5.4' => false,
|
77 |
-
'5.5' => false,
|
78 |
-
'5.6' => false,
|
79 |
'7.0' => true,
|
80 |
'alternative' => 'preg_replace()',
|
81 |
),
|
82 |
'eregi' => array(
|
83 |
'5.3' => false,
|
84 |
-
'5.4' => false,
|
85 |
-
'5.5' => false,
|
86 |
-
'5.6' => false,
|
87 |
'7.0' => true,
|
88 |
'alternative' => 'preg_match()',
|
89 |
),
|
90 |
'eregi_replace' => array(
|
91 |
'5.3' => false,
|
92 |
-
'5.4' => false,
|
93 |
-
'5.5' => false,
|
94 |
-
'5.6' => false,
|
95 |
'7.0' => true,
|
96 |
'alternative' => 'preg_replace()',
|
97 |
),
|
@@ -134,495 +134,339 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
134 |
),
|
135 |
'mcrypt_generic_end' => array(
|
136 |
'5.3' => false,
|
137 |
-
'5.4' => false,
|
138 |
-
'5.5' => false,
|
139 |
-
'5.6' => false,
|
140 |
'7.0' => true,
|
141 |
'alternative' => 'mcrypt_generic_deinit()',
|
142 |
),
|
143 |
'mysql_db_query' => array(
|
144 |
'5.3' => false,
|
145 |
-
'5.4' => false,
|
146 |
-
'5.5' => false,
|
147 |
-
'5.6' => false,
|
148 |
'7.0' => true,
|
149 |
'alternative' => 'mysqli::select_db() and mysqli::query()',
|
150 |
),
|
151 |
'mysql_escape_string' => array(
|
152 |
'5.3' => false,
|
153 |
-
'5.4' => false,
|
154 |
-
'5.5' => false,
|
155 |
-
'5.6' => false,
|
156 |
'7.0' => true,
|
157 |
'alternative' => 'mysqli::real_escape_string()',
|
158 |
),
|
159 |
'mysql_list_dbs' => array(
|
160 |
'5.4' => false,
|
161 |
-
'5.5' => false,
|
162 |
-
'5.6' => false,
|
163 |
'7.0' => true,
|
164 |
'alternative' => null,
|
165 |
),
|
166 |
'mysqli_bind_param' => array(
|
167 |
'5.3' => false,
|
168 |
'5.4' => true,
|
169 |
-
'5.5' => true,
|
170 |
-
'5.6' => true,
|
171 |
'alternative' => 'mysqli_stmt::bind_param()',
|
172 |
),
|
173 |
'mysqli_bind_result' => array(
|
174 |
'5.3' => false,
|
175 |
'5.4' => true,
|
176 |
-
'5.5' => true,
|
177 |
-
'5.6' => true,
|
178 |
'alternative' => 'mysqli_stmt::bind_result()',
|
179 |
),
|
180 |
'mysqli_client_encoding' => array(
|
181 |
'5.3' => false,
|
182 |
'5.4' => true,
|
183 |
-
'5.5' => true,
|
184 |
-
'5.6' => true,
|
185 |
'alternative' => 'mysqli::character_set_name()',
|
186 |
),
|
187 |
'mysqli_fetch' => array(
|
188 |
'5.3' => false,
|
189 |
'5.4' => true,
|
190 |
-
'5.5' => true,
|
191 |
-
'5.6' => true,
|
192 |
'alternative' => 'mysqli_stmt::fetch()',
|
193 |
),
|
194 |
'mysqli_param_count' => array(
|
195 |
'5.3' => false,
|
196 |
'5.4' => true,
|
197 |
-
'5.5' => true,
|
198 |
-
'5.6' => true,
|
199 |
'alternative' => 'mysqli_stmt_param_count()',
|
200 |
),
|
201 |
'mysqli_get_metadata' => array(
|
202 |
'5.3' => false,
|
203 |
'5.4' => true,
|
204 |
-
'5.5' => true,
|
205 |
-
'5.6' => true,
|
206 |
'alternative' => 'mysqli_stmt::result_metadata()',
|
207 |
),
|
208 |
'mysqli_send_long_data' => array(
|
209 |
'5.3' => false,
|
210 |
'5.4' => true,
|
211 |
-
'5.5' => true,
|
212 |
-
'5.6' => true,
|
213 |
'alternative' => 'mysqli_stmt::send_long_data()',
|
214 |
),
|
215 |
'magic_quotes_runtime' => array(
|
216 |
'5.3' => false,
|
217 |
-
'5.4' => false,
|
218 |
-
'5.5' => false,
|
219 |
-
'5.6' => false,
|
220 |
'7.0' => true,
|
221 |
'alternative' => null,
|
222 |
),
|
223 |
'session_register' => array(
|
224 |
'5.3' => false,
|
225 |
'5.4' => true,
|
226 |
-
'5.5' => true,
|
227 |
-
'5.6' => true,
|
228 |
'alternative' => '$_SESSION',
|
229 |
),
|
230 |
'session_unregister' => array(
|
231 |
'5.3' => false,
|
232 |
'5.4' => true,
|
233 |
-
'5.5' => true,
|
234 |
-
'5.6' => true,
|
235 |
'alternative' => '$_SESSION',
|
236 |
),
|
237 |
'session_is_registered' => array(
|
238 |
'5.3' => false,
|
239 |
'5.4' => true,
|
240 |
-
'5.5' => true,
|
241 |
-
'5.6' => true,
|
242 |
'alternative' => '$_SESSION',
|
243 |
),
|
244 |
'set_magic_quotes_runtime' => array(
|
245 |
'5.3' => false,
|
246 |
-
'5.4' => false,
|
247 |
-
'5.5' => false,
|
248 |
-
'5.6' => false,
|
249 |
'7.0' => true,
|
250 |
'alternative' => null,
|
251 |
),
|
252 |
'set_socket_blocking' => array(
|
253 |
'5.3' => false,
|
254 |
-
'5.4' => false,
|
255 |
-
'5.5' => false,
|
256 |
-
'5.6' => false,
|
257 |
'7.0' => true,
|
258 |
'alternative' => 'stream_set_blocking()',
|
259 |
),
|
260 |
'split' => array(
|
261 |
'5.3' => false,
|
262 |
-
'5.4' => false,
|
263 |
-
'5.5' => false,
|
264 |
-
'5.6' => false,
|
265 |
'7.0' => true,
|
266 |
'alternative' => 'preg_split()',
|
267 |
),
|
268 |
'spliti' => array(
|
269 |
'5.3' => false,
|
270 |
-
'5.4' => false,
|
271 |
-
'5.5' => false,
|
272 |
-
'5.6' => false,
|
273 |
'7.0' => true,
|
274 |
'alternative' => 'preg_split()',
|
275 |
),
|
276 |
'sql_regcase' => array(
|
277 |
'5.3' => false,
|
278 |
-
'5.4' => false,
|
279 |
-
'5.5' => false,
|
280 |
-
'5.6' => false,
|
281 |
'7.0' => true,
|
282 |
'alternative' => null,
|
283 |
),
|
284 |
'php_logo_guid' => array(
|
285 |
'5.5' => true,
|
286 |
-
'5.6' => true,
|
287 |
'alternative' => null,
|
288 |
),
|
289 |
'php_egg_logo_guid' => array(
|
290 |
'5.5' => true,
|
291 |
-
'5.6' => true,
|
292 |
'alternative' => null,
|
293 |
),
|
294 |
'php_real_logo_guid' => array(
|
295 |
'5.5' => true,
|
296 |
-
'5.6' => true,
|
297 |
'alternative' => null,
|
298 |
),
|
299 |
'zend_logo_guid' => array(
|
300 |
'5.5' => true,
|
301 |
-
'5.6' => true,
|
302 |
'alternative' => null,
|
303 |
),
|
304 |
'datefmt_set_timezone_id' => array(
|
305 |
'5.5' => false,
|
306 |
-
'5.6' => false,
|
307 |
'7.0' => true,
|
308 |
'alternative' => 'IntlDateFormatter::setTimeZone()',
|
309 |
),
|
310 |
'mcrypt_ecb' => array(
|
311 |
'5.5' => false,
|
312 |
-
'5.6' => false,
|
313 |
'7.0' => true,
|
314 |
'alternative' => null,
|
315 |
),
|
316 |
'mcrypt_cbc' => array(
|
317 |
'5.5' => false,
|
318 |
-
'5.6' => false,
|
319 |
'7.0' => true,
|
320 |
'alternative' => null,
|
321 |
),
|
322 |
'mcrypt_cfb' => array(
|
323 |
'5.5' => false,
|
324 |
-
'5.6' => false,
|
325 |
'7.0' => true,
|
326 |
'alternative' => null,
|
327 |
),
|
328 |
'mcrypt_ofb' => array(
|
329 |
'5.5' => false,
|
330 |
-
'5.6' => false,
|
331 |
'7.0' => true,
|
332 |
'alternative' => null,
|
333 |
),
|
334 |
'ocibindbyname' => array(
|
335 |
'5.4' => false,
|
336 |
-
'5.5' => false,
|
337 |
-
'5.6' => false,
|
338 |
'alternative' => 'oci_bind_by_name()',
|
339 |
),
|
340 |
'ocicancel' => array(
|
341 |
'5.4' => false,
|
342 |
-
'5.5' => false,
|
343 |
-
'5.6' => false,
|
344 |
'alternative' => 'oci_cancel()',
|
345 |
),
|
346 |
'ocicloselob' => array(
|
347 |
'5.4' => false,
|
348 |
-
'5.5' => false,
|
349 |
-
'5.6' => false,
|
350 |
'alternative' => 'OCI-Lob::close()',
|
351 |
),
|
352 |
'ocicollappend' => array(
|
353 |
'5.4' => false,
|
354 |
-
'5.5' => false,
|
355 |
-
'5.6' => false,
|
356 |
'alternative' => 'OCI-Collection::append()',
|
357 |
),
|
358 |
'ocicollassign' => array(
|
359 |
'5.4' => false,
|
360 |
-
'5.5' => false,
|
361 |
-
'5.6' => false,
|
362 |
'alternative' => 'OCI-Collection::assign()',
|
363 |
),
|
364 |
'ocicollassignelem' => array(
|
365 |
'5.4' => false,
|
366 |
-
'5.5' => false,
|
367 |
-
'5.6' => false,
|
368 |
'alternative' => 'OCI-Collection::assignElem()',
|
369 |
),
|
370 |
'ocicollgetelem' => array(
|
371 |
'5.4' => false,
|
372 |
-
'5.5' => false,
|
373 |
-
'5.6' => false,
|
374 |
'alternative' => 'OCI-Collection::getElem()',
|
375 |
),
|
376 |
'ocicollmax' => array(
|
377 |
'5.4' => false,
|
378 |
-
'5.5' => false,
|
379 |
-
'5.6' => false,
|
380 |
'alternative' => 'OCI-Collection::max()',
|
381 |
),
|
382 |
'ocicollsize' => array(
|
383 |
'5.4' => false,
|
384 |
-
'5.5' => false,
|
385 |
-
'5.6' => false,
|
386 |
'alternative' => 'OCI-Collection::size()',
|
387 |
),
|
388 |
'ocicolltrim' => array(
|
389 |
'5.4' => false,
|
390 |
-
'5.5' => false,
|
391 |
-
'5.6' => false,
|
392 |
'alternative' => 'OCI-Collection::trim()',
|
393 |
),
|
394 |
'ocicolumnisnull' => array(
|
395 |
'5.4' => false,
|
396 |
-
'5.5' => false,
|
397 |
-
'5.6' => false,
|
398 |
'alternative' => 'oci_field_is_null()',
|
399 |
),
|
400 |
'ocicolumnname' => array(
|
401 |
'5.4' => false,
|
402 |
-
'5.5' => false,
|
403 |
-
'5.6' => false,
|
404 |
'alternative' => 'oci_field_name()',
|
405 |
),
|
406 |
'ocicolumnprecision' => array(
|
407 |
'5.4' => false,
|
408 |
-
'5.5' => false,
|
409 |
-
'5.6' => false,
|
410 |
'alternative' => 'oci_field_precision()',
|
411 |
),
|
412 |
'ocicolumnscale' => array(
|
413 |
'5.4' => false,
|
414 |
-
'5.5' => false,
|
415 |
-
'5.6' => false,
|
416 |
'alternative' => 'oci_field_scale()',
|
417 |
),
|
418 |
'ocicolumnsize' => array(
|
419 |
'5.4' => false,
|
420 |
-
'5.5' => false,
|
421 |
-
'5.6' => false,
|
422 |
'alternative' => 'oci_field_size()',
|
423 |
),
|
424 |
'ocicolumntype' => array(
|
425 |
'5.4' => false,
|
426 |
-
'5.5' => false,
|
427 |
-
'5.6' => false,
|
428 |
'alternative' => 'oci_field_type()',
|
429 |
),
|
430 |
'ocicolumntyperaw' => array(
|
431 |
'5.4' => false,
|
432 |
-
'5.5' => false,
|
433 |
-
'5.6' => false,
|
434 |
'alternative' => 'oci_field_type_raw()',
|
435 |
),
|
436 |
'ocicommit' => array(
|
437 |
'5.4' => false,
|
438 |
-
'5.5' => false,
|
439 |
-
'5.6' => false,
|
440 |
'alternative' => 'oci_commit()',
|
441 |
),
|
442 |
'ocidefinebyname' => array(
|
443 |
'5.4' => false,
|
444 |
-
'5.5' => false,
|
445 |
-
'5.6' => false,
|
446 |
'alternative' => 'oci_define_by_name()',
|
447 |
),
|
448 |
'ocierror' => array(
|
449 |
'5.4' => false,
|
450 |
-
'5.5' => false,
|
451 |
-
'5.6' => false,
|
452 |
'alternative' => 'oci_error()',
|
453 |
),
|
454 |
'ociexecute' => array(
|
455 |
'5.4' => false,
|
456 |
-
'5.5' => false,
|
457 |
-
'5.6' => false,
|
458 |
'alternative' => 'oci_execute()',
|
459 |
),
|
460 |
'ocifetch' => array(
|
461 |
'5.4' => false,
|
462 |
-
'5.5' => false,
|
463 |
-
'5.6' => false,
|
464 |
'alternative' => 'oci_fetch()',
|
465 |
),
|
466 |
'ocifetchinto' => array(
|
467 |
'5.4' => false,
|
468 |
-
'5.5' => false,
|
469 |
-
'5.6' => false,
|
470 |
'alternative' => null,
|
471 |
),
|
472 |
'ocifetchstatement' => array(
|
473 |
'5.4' => false,
|
474 |
-
'5.5' => false,
|
475 |
-
'5.6' => false,
|
476 |
'alternative' => 'oci_fetch_all()',
|
477 |
),
|
478 |
'ocifreecollection' => array(
|
479 |
'5.4' => false,
|
480 |
-
'5.5' => false,
|
481 |
-
'5.6' => false,
|
482 |
'alternative' => 'OCI-Collection::free()',
|
483 |
),
|
484 |
'ocifreecursor' => array(
|
485 |
'5.4' => false,
|
486 |
-
'5.5' => false,
|
487 |
-
'5.6' => false,
|
488 |
'alternative' => 'oci_free_statement()',
|
489 |
),
|
490 |
'ocifreedesc' => array(
|
491 |
'5.4' => false,
|
492 |
-
'5.5' => false,
|
493 |
-
'5.6' => false,
|
494 |
'alternative' => 'OCI-Lob::free()',
|
495 |
),
|
496 |
'ocifreestatement' => array(
|
497 |
'5.4' => false,
|
498 |
-
'5.5' => false,
|
499 |
-
'5.6' => false,
|
500 |
'alternative' => 'oci_free_statement()',
|
501 |
),
|
502 |
'ociinternaldebug' => array(
|
503 |
'5.4' => false,
|
504 |
-
'5.5' => false,
|
505 |
-
'5.6' => false,
|
506 |
'alternative' => 'oci_internal_debug()',
|
507 |
),
|
508 |
'ociloadlob' => array(
|
509 |
'5.4' => false,
|
510 |
-
'5.5' => false,
|
511 |
-
'5.6' => false,
|
512 |
'alternative' => 'OCI-Lob::load()',
|
513 |
),
|
514 |
'ocilogoff' => array(
|
515 |
'5.4' => false,
|
516 |
-
'5.5' => false,
|
517 |
-
'5.6' => false,
|
518 |
'alternative' => 'oci_close()',
|
519 |
),
|
520 |
'ocilogon' => array(
|
521 |
'5.4' => false,
|
522 |
-
'5.5' => false,
|
523 |
-
'5.6' => false,
|
524 |
'alternative' => 'oci_connect()',
|
525 |
),
|
526 |
'ocinewcollection' => array(
|
527 |
'5.4' => false,
|
528 |
-
'5.5' => false,
|
529 |
-
'5.6' => false,
|
530 |
'alternative' => 'oci_new_collection()',
|
531 |
),
|
532 |
'ocinewcursor' => array(
|
533 |
'5.4' => false,
|
534 |
-
'5.5' => false,
|
535 |
-
'5.6' => false,
|
536 |
'alternative' => 'oci_new_cursor()',
|
537 |
),
|
538 |
'ocinewdescriptor' => array(
|
539 |
'5.4' => false,
|
540 |
-
'5.5' => false,
|
541 |
-
'5.6' => false,
|
542 |
'alternative' => 'oci_new_descriptor()',
|
543 |
),
|
544 |
'ocinlogon' => array(
|
545 |
'5.4' => false,
|
546 |
-
'5.5' => false,
|
547 |
-
'5.6' => false,
|
548 |
'alternative' => 'oci_new_connect()',
|
549 |
),
|
550 |
'ocinumcols' => array(
|
551 |
'5.4' => false,
|
552 |
-
'5.5' => false,
|
553 |
-
'5.6' => false,
|
554 |
'alternative' => 'oci_num_fields()',
|
555 |
),
|
556 |
'ociparse' => array(
|
557 |
'5.4' => false,
|
558 |
-
'5.5' => false,
|
559 |
-
'5.6' => false,
|
560 |
'alternative' => 'oci_parse()',
|
561 |
),
|
562 |
'ociplogon' => array(
|
563 |
'5.4' => false,
|
564 |
-
'5.5' => false,
|
565 |
-
'5.6' => false,
|
566 |
'alternative' => 'oci_pconnect()',
|
567 |
),
|
568 |
'ociresult' => array(
|
569 |
'5.4' => false,
|
570 |
-
'5.5' => false,
|
571 |
-
'5.6' => false,
|
572 |
'alternative' => 'oci_result()',
|
573 |
),
|
574 |
'ocirollback' => array(
|
575 |
'5.4' => false,
|
576 |
-
'5.5' => false,
|
577 |
-
'5.6' => false,
|
578 |
'alternative' => 'oci_rollback()',
|
579 |
),
|
580 |
'ocirowcount' => array(
|
581 |
'5.4' => false,
|
582 |
-
'5.5' => false,
|
583 |
-
'5.6' => false,
|
584 |
'alternative' => 'oci_num_rows()',
|
585 |
),
|
586 |
'ocisavelob' => array(
|
587 |
'5.4' => false,
|
588 |
-
'5.5' => false,
|
589 |
-
'5.6' => false,
|
590 |
'alternative' => 'OCI-Lob::save()',
|
591 |
),
|
592 |
'ocisavelobfile' => array(
|
593 |
'5.4' => false,
|
594 |
-
'5.5' => false,
|
595 |
-
'5.6' => false,
|
596 |
'alternative' => 'OCI-Lob::import()',
|
597 |
),
|
598 |
'ociserverversion' => array(
|
599 |
'5.4' => false,
|
600 |
-
'5.5' => false,
|
601 |
-
'5.6' => false,
|
602 |
'alternative' => 'oci_server_version()',
|
603 |
),
|
604 |
'ocisetprefetch' => array(
|
605 |
'5.4' => false,
|
606 |
-
'5.5' => false,
|
607 |
-
'5.6' => false,
|
608 |
'alternative' => 'oci_set_prefetch()',
|
609 |
),
|
610 |
'ocistatementtype' => array(
|
611 |
'5.4' => false,
|
612 |
-
'5.5' => false,
|
613 |
-
'5.6' => false,
|
614 |
'alternative' => 'oci_statement_type()',
|
615 |
),
|
616 |
'ociwritelobtofile' => array(
|
617 |
'5.4' => false,
|
618 |
-
'5.5' => false,
|
619 |
-
'5.6' => false,
|
620 |
'alternative' => 'OCI-Lob::export()',
|
621 |
),
|
622 |
'ociwritetemporarylob' => array(
|
623 |
'5.4' => false,
|
624 |
-
'5.5' => false,
|
625 |
-
'5.6' => false,
|
626 |
'alternative' => 'OCI-Lob::writeTemporary()',
|
627 |
),
|
628 |
'mysqli_get_cache_stats' => array(
|
@@ -814,6 +658,300 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
814 |
'7.2' => false,
|
815 |
'alternative' => 'exif_read_data()',
|
816 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
817 |
);
|
818 |
|
819 |
|
@@ -827,9 +965,8 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
827 |
// Handle case-insensitivity of function names.
|
828 |
$this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions);
|
829 |
|
830 |
-
return array(T_STRING);
|
831 |
-
|
832 |
-
}//end register()
|
833 |
|
834 |
|
835 |
/**
|
@@ -841,22 +978,22 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
841 |
*
|
842 |
* @return void
|
843 |
*/
|
844 |
-
public function process(
|
845 |
{
|
846 |
$tokens = $phpcsFile->getTokens();
|
847 |
|
848 |
$ignore = array(
|
849 |
-
T_DOUBLE_COLON,
|
850 |
-
T_OBJECT_OPERATOR,
|
851 |
-
T_FUNCTION,
|
852 |
-
T_CLASS,
|
853 |
-
T_CONST,
|
854 |
-
T_USE,
|
855 |
-
T_NS_SEPARATOR,
|
856 |
);
|
857 |
|
858 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
859 |
-
if (
|
860 |
// Not a call to a PHP function.
|
861 |
return;
|
862 |
}
|
@@ -873,8 +1010,7 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
873 |
'nameLc' => $functionLc,
|
874 |
);
|
875 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
876 |
-
|
877 |
-
}//end process()
|
878 |
|
879 |
|
880 |
/**
|
@@ -899,6 +1035,4 @@ class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
|
899 |
{
|
900 |
return 'Function %s() is ';
|
901 |
}
|
902 |
-
|
903 |
-
|
904 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\RemovedFunctionsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\FunctionUse\RemovedFunctionsSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
20 |
* @author Wim Godden <wim.godden@cu.be>
|
21 |
*/
|
22 |
+
class RemovedFunctionsSniff extends AbstractRemovedFeatureSniff
|
23 |
{
|
24 |
/**
|
25 |
* A list of deprecated and removed functions with their alternatives.
|
34 |
'5.0.5' => true,
|
35 |
'alternative' => null,
|
36 |
),
|
37 |
+
|
38 |
+
'pfpro_cleanup' => array(
|
39 |
+
'5.1' => true,
|
40 |
+
'alternative' => null,
|
41 |
+
),
|
42 |
+
'pfpro_init' => array(
|
43 |
+
'5.1' => true,
|
44 |
+
'alternative' => null,
|
45 |
+
),
|
46 |
+
'pfpro_process_raw' => array(
|
47 |
+
'5.1' => true,
|
48 |
+
'alternative' => null,
|
49 |
+
),
|
50 |
+
'pfpro_process' => array(
|
51 |
+
'5.1' => true,
|
52 |
+
'alternative' => null,
|
53 |
+
),
|
54 |
+
'pfpro_version' => array(
|
55 |
+
'5.1' => true,
|
56 |
+
'alternative' => null,
|
57 |
+
),
|
58 |
+
|
59 |
'call_user_method' => array(
|
60 |
'5.3' => false,
|
|
|
|
|
|
|
61 |
'7.0' => true,
|
62 |
'alternative' => 'call_user_func()',
|
63 |
),
|
64 |
'call_user_method_array' => array(
|
65 |
'5.3' => false,
|
|
|
|
|
|
|
66 |
'7.0' => true,
|
67 |
'alternative' => 'call_user_func_array()',
|
68 |
),
|
69 |
'define_syslog_variables' => array(
|
70 |
'5.3' => false,
|
71 |
'5.4' => true,
|
|
|
|
|
72 |
'alternative' => null,
|
73 |
),
|
74 |
'dl' => array(
|
75 |
'5.3' => false,
|
|
|
|
|
|
|
76 |
'alternative' => null,
|
77 |
),
|
78 |
'ereg' => array(
|
79 |
'5.3' => false,
|
|
|
|
|
|
|
80 |
'7.0' => true,
|
81 |
'alternative' => 'preg_match()',
|
82 |
),
|
83 |
'ereg_replace' => array(
|
84 |
'5.3' => false,
|
|
|
|
|
|
|
85 |
'7.0' => true,
|
86 |
'alternative' => 'preg_replace()',
|
87 |
),
|
88 |
'eregi' => array(
|
89 |
'5.3' => false,
|
|
|
|
|
|
|
90 |
'7.0' => true,
|
91 |
'alternative' => 'preg_match()',
|
92 |
),
|
93 |
'eregi_replace' => array(
|
94 |
'5.3' => false,
|
|
|
|
|
|
|
95 |
'7.0' => true,
|
96 |
'alternative' => 'preg_replace()',
|
97 |
),
|
134 |
),
|
135 |
'mcrypt_generic_end' => array(
|
136 |
'5.3' => false,
|
|
|
|
|
|
|
137 |
'7.0' => true,
|
138 |
'alternative' => 'mcrypt_generic_deinit()',
|
139 |
),
|
140 |
'mysql_db_query' => array(
|
141 |
'5.3' => false,
|
|
|
|
|
|
|
142 |
'7.0' => true,
|
143 |
'alternative' => 'mysqli::select_db() and mysqli::query()',
|
144 |
),
|
145 |
'mysql_escape_string' => array(
|
146 |
'5.3' => false,
|
|
|
|
|
|
|
147 |
'7.0' => true,
|
148 |
'alternative' => 'mysqli::real_escape_string()',
|
149 |
),
|
150 |
'mysql_list_dbs' => array(
|
151 |
'5.4' => false,
|
|
|
|
|
152 |
'7.0' => true,
|
153 |
'alternative' => null,
|
154 |
),
|
155 |
'mysqli_bind_param' => array(
|
156 |
'5.3' => false,
|
157 |
'5.4' => true,
|
|
|
|
|
158 |
'alternative' => 'mysqli_stmt::bind_param()',
|
159 |
),
|
160 |
'mysqli_bind_result' => array(
|
161 |
'5.3' => false,
|
162 |
'5.4' => true,
|
|
|
|
|
163 |
'alternative' => 'mysqli_stmt::bind_result()',
|
164 |
),
|
165 |
'mysqli_client_encoding' => array(
|
166 |
'5.3' => false,
|
167 |
'5.4' => true,
|
|
|
|
|
168 |
'alternative' => 'mysqli::character_set_name()',
|
169 |
),
|
170 |
'mysqli_fetch' => array(
|
171 |
'5.3' => false,
|
172 |
'5.4' => true,
|
|
|
|
|
173 |
'alternative' => 'mysqli_stmt::fetch()',
|
174 |
),
|
175 |
'mysqli_param_count' => array(
|
176 |
'5.3' => false,
|
177 |
'5.4' => true,
|
|
|
|
|
178 |
'alternative' => 'mysqli_stmt_param_count()',
|
179 |
),
|
180 |
'mysqli_get_metadata' => array(
|
181 |
'5.3' => false,
|
182 |
'5.4' => true,
|
|
|
|
|
183 |
'alternative' => 'mysqli_stmt::result_metadata()',
|
184 |
),
|
185 |
'mysqli_send_long_data' => array(
|
186 |
'5.3' => false,
|
187 |
'5.4' => true,
|
|
|
|
|
188 |
'alternative' => 'mysqli_stmt::send_long_data()',
|
189 |
),
|
190 |
'magic_quotes_runtime' => array(
|
191 |
'5.3' => false,
|
|
|
|
|
|
|
192 |
'7.0' => true,
|
193 |
'alternative' => null,
|
194 |
),
|
195 |
'session_register' => array(
|
196 |
'5.3' => false,
|
197 |
'5.4' => true,
|
|
|
|
|
198 |
'alternative' => '$_SESSION',
|
199 |
),
|
200 |
'session_unregister' => array(
|
201 |
'5.3' => false,
|
202 |
'5.4' => true,
|
|
|
|
|
203 |
'alternative' => '$_SESSION',
|
204 |
),
|
205 |
'session_is_registered' => array(
|
206 |
'5.3' => false,
|
207 |
'5.4' => true,
|
|
|
|
|
208 |
'alternative' => '$_SESSION',
|
209 |
),
|
210 |
'set_magic_quotes_runtime' => array(
|
211 |
'5.3' => false,
|
|
|
|
|
|
|
212 |
'7.0' => true,
|
213 |
'alternative' => null,
|
214 |
),
|
215 |
'set_socket_blocking' => array(
|
216 |
'5.3' => false,
|
|
|
|
|
|
|
217 |
'7.0' => true,
|
218 |
'alternative' => 'stream_set_blocking()',
|
219 |
),
|
220 |
'split' => array(
|
221 |
'5.3' => false,
|
|
|
|
|
|
|
222 |
'7.0' => true,
|
223 |
'alternative' => 'preg_split()',
|
224 |
),
|
225 |
'spliti' => array(
|
226 |
'5.3' => false,
|
|
|
|
|
|
|
227 |
'7.0' => true,
|
228 |
'alternative' => 'preg_split()',
|
229 |
),
|
230 |
'sql_regcase' => array(
|
231 |
'5.3' => false,
|
|
|
|
|
|
|
232 |
'7.0' => true,
|
233 |
'alternative' => null,
|
234 |
),
|
235 |
'php_logo_guid' => array(
|
236 |
'5.5' => true,
|
|
|
237 |
'alternative' => null,
|
238 |
),
|
239 |
'php_egg_logo_guid' => array(
|
240 |
'5.5' => true,
|
|
|
241 |
'alternative' => null,
|
242 |
),
|
243 |
'php_real_logo_guid' => array(
|
244 |
'5.5' => true,
|
|
|
245 |
'alternative' => null,
|
246 |
),
|
247 |
'zend_logo_guid' => array(
|
248 |
'5.5' => true,
|
|
|
249 |
'alternative' => null,
|
250 |
),
|
251 |
'datefmt_set_timezone_id' => array(
|
252 |
'5.5' => false,
|
|
|
253 |
'7.0' => true,
|
254 |
'alternative' => 'IntlDateFormatter::setTimeZone()',
|
255 |
),
|
256 |
'mcrypt_ecb' => array(
|
257 |
'5.5' => false,
|
|
|
258 |
'7.0' => true,
|
259 |
'alternative' => null,
|
260 |
),
|
261 |
'mcrypt_cbc' => array(
|
262 |
'5.5' => false,
|
|
|
263 |
'7.0' => true,
|
264 |
'alternative' => null,
|
265 |
),
|
266 |
'mcrypt_cfb' => array(
|
267 |
'5.5' => false,
|
|
|
268 |
'7.0' => true,
|
269 |
'alternative' => null,
|
270 |
),
|
271 |
'mcrypt_ofb' => array(
|
272 |
'5.5' => false,
|
|
|
273 |
'7.0' => true,
|
274 |
'alternative' => null,
|
275 |
),
|
276 |
'ocibindbyname' => array(
|
277 |
'5.4' => false,
|
|
|
|
|
278 |
'alternative' => 'oci_bind_by_name()',
|
279 |
),
|
280 |
'ocicancel' => array(
|
281 |
'5.4' => false,
|
|
|
|
|
282 |
'alternative' => 'oci_cancel()',
|
283 |
),
|
284 |
'ocicloselob' => array(
|
285 |
'5.4' => false,
|
|
|
|
|
286 |
'alternative' => 'OCI-Lob::close()',
|
287 |
),
|
288 |
'ocicollappend' => array(
|
289 |
'5.4' => false,
|
|
|
|
|
290 |
'alternative' => 'OCI-Collection::append()',
|
291 |
),
|
292 |
'ocicollassign' => array(
|
293 |
'5.4' => false,
|
|
|
|
|
294 |
'alternative' => 'OCI-Collection::assign()',
|
295 |
),
|
296 |
'ocicollassignelem' => array(
|
297 |
'5.4' => false,
|
|
|
|
|
298 |
'alternative' => 'OCI-Collection::assignElem()',
|
299 |
),
|
300 |
'ocicollgetelem' => array(
|
301 |
'5.4' => false,
|
|
|
|
|
302 |
'alternative' => 'OCI-Collection::getElem()',
|
303 |
),
|
304 |
'ocicollmax' => array(
|
305 |
'5.4' => false,
|
|
|
|
|
306 |
'alternative' => 'OCI-Collection::max()',
|
307 |
),
|
308 |
'ocicollsize' => array(
|
309 |
'5.4' => false,
|
|
|
|
|
310 |
'alternative' => 'OCI-Collection::size()',
|
311 |
),
|
312 |
'ocicolltrim' => array(
|
313 |
'5.4' => false,
|
|
|
|
|
314 |
'alternative' => 'OCI-Collection::trim()',
|
315 |
),
|
316 |
'ocicolumnisnull' => array(
|
317 |
'5.4' => false,
|
|
|
|
|
318 |
'alternative' => 'oci_field_is_null()',
|
319 |
),
|
320 |
'ocicolumnname' => array(
|
321 |
'5.4' => false,
|
|
|
|
|
322 |
'alternative' => 'oci_field_name()',
|
323 |
),
|
324 |
'ocicolumnprecision' => array(
|
325 |
'5.4' => false,
|
|
|
|
|
326 |
'alternative' => 'oci_field_precision()',
|
327 |
),
|
328 |
'ocicolumnscale' => array(
|
329 |
'5.4' => false,
|
|
|
|
|
330 |
'alternative' => 'oci_field_scale()',
|
331 |
),
|
332 |
'ocicolumnsize' => array(
|
333 |
'5.4' => false,
|
|
|
|
|
334 |
'alternative' => 'oci_field_size()',
|
335 |
),
|
336 |
'ocicolumntype' => array(
|
337 |
'5.4' => false,
|
|
|
|
|
338 |
'alternative' => 'oci_field_type()',
|
339 |
),
|
340 |
'ocicolumntyperaw' => array(
|
341 |
'5.4' => false,
|
|
|
|
|
342 |
'alternative' => 'oci_field_type_raw()',
|
343 |
),
|
344 |
'ocicommit' => array(
|
345 |
'5.4' => false,
|
|
|
|
|
346 |
'alternative' => 'oci_commit()',
|
347 |
),
|
348 |
'ocidefinebyname' => array(
|
349 |
'5.4' => false,
|
|
|
|
|
350 |
'alternative' => 'oci_define_by_name()',
|
351 |
),
|
352 |
'ocierror' => array(
|
353 |
'5.4' => false,
|
|
|
|
|
354 |
'alternative' => 'oci_error()',
|
355 |
),
|
356 |
'ociexecute' => array(
|
357 |
'5.4' => false,
|
|
|
|
|
358 |
'alternative' => 'oci_execute()',
|
359 |
),
|
360 |
'ocifetch' => array(
|
361 |
'5.4' => false,
|
|
|
|
|
362 |
'alternative' => 'oci_fetch()',
|
363 |
),
|
364 |
'ocifetchinto' => array(
|
365 |
'5.4' => false,
|
|
|
|
|
366 |
'alternative' => null,
|
367 |
),
|
368 |
'ocifetchstatement' => array(
|
369 |
'5.4' => false,
|
|
|
|
|
370 |
'alternative' => 'oci_fetch_all()',
|
371 |
),
|
372 |
'ocifreecollection' => array(
|
373 |
'5.4' => false,
|
|
|
|
|
374 |
'alternative' => 'OCI-Collection::free()',
|
375 |
),
|
376 |
'ocifreecursor' => array(
|
377 |
'5.4' => false,
|
|
|
|
|
378 |
'alternative' => 'oci_free_statement()',
|
379 |
),
|
380 |
'ocifreedesc' => array(
|
381 |
'5.4' => false,
|
|
|
|
|
382 |
'alternative' => 'OCI-Lob::free()',
|
383 |
),
|
384 |
'ocifreestatement' => array(
|
385 |
'5.4' => false,
|
|
|
|
|
386 |
'alternative' => 'oci_free_statement()',
|
387 |
),
|
388 |
'ociinternaldebug' => array(
|
389 |
'5.4' => false,
|
|
|
|
|
390 |
'alternative' => 'oci_internal_debug()',
|
391 |
),
|
392 |
'ociloadlob' => array(
|
393 |
'5.4' => false,
|
|
|
|
|
394 |
'alternative' => 'OCI-Lob::load()',
|
395 |
),
|
396 |
'ocilogoff' => array(
|
397 |
'5.4' => false,
|
|
|
|
|
398 |
'alternative' => 'oci_close()',
|
399 |
),
|
400 |
'ocilogon' => array(
|
401 |
'5.4' => false,
|
|
|
|
|
402 |
'alternative' => 'oci_connect()',
|
403 |
),
|
404 |
'ocinewcollection' => array(
|
405 |
'5.4' => false,
|
|
|
|
|
406 |
'alternative' => 'oci_new_collection()',
|
407 |
),
|
408 |
'ocinewcursor' => array(
|
409 |
'5.4' => false,
|
|
|
|
|
410 |
'alternative' => 'oci_new_cursor()',
|
411 |
),
|
412 |
'ocinewdescriptor' => array(
|
413 |
'5.4' => false,
|
|
|
|
|
414 |
'alternative' => 'oci_new_descriptor()',
|
415 |
),
|
416 |
'ocinlogon' => array(
|
417 |
'5.4' => false,
|
|
|
|
|
418 |
'alternative' => 'oci_new_connect()',
|
419 |
),
|
420 |
'ocinumcols' => array(
|
421 |
'5.4' => false,
|
|
|
|
|
422 |
'alternative' => 'oci_num_fields()',
|
423 |
),
|
424 |
'ociparse' => array(
|
425 |
'5.4' => false,
|
|
|
|
|
426 |
'alternative' => 'oci_parse()',
|
427 |
),
|
428 |
'ociplogon' => array(
|
429 |
'5.4' => false,
|
|
|
|
|
430 |
'alternative' => 'oci_pconnect()',
|
431 |
),
|
432 |
'ociresult' => array(
|
433 |
'5.4' => false,
|
|
|
|
|
434 |
'alternative' => 'oci_result()',
|
435 |
),
|
436 |
'ocirollback' => array(
|
437 |
'5.4' => false,
|
|
|
|
|
438 |
'alternative' => 'oci_rollback()',
|
439 |
),
|
440 |
'ocirowcount' => array(
|
441 |
'5.4' => false,
|
|
|
|
|
442 |
'alternative' => 'oci_num_rows()',
|
443 |
),
|
444 |
'ocisavelob' => array(
|
445 |
'5.4' => false,
|
|
|
|
|
446 |
'alternative' => 'OCI-Lob::save()',
|
447 |
),
|
448 |
'ocisavelobfile' => array(
|
449 |
'5.4' => false,
|
|
|
|
|
450 |
'alternative' => 'OCI-Lob::import()',
|
451 |
),
|
452 |
'ociserverversion' => array(
|
453 |
'5.4' => false,
|
|
|
|
|
454 |
'alternative' => 'oci_server_version()',
|
455 |
),
|
456 |
'ocisetprefetch' => array(
|
457 |
'5.4' => false,
|
|
|
|
|
458 |
'alternative' => 'oci_set_prefetch()',
|
459 |
),
|
460 |
'ocistatementtype' => array(
|
461 |
'5.4' => false,
|
|
|
|
|
462 |
'alternative' => 'oci_statement_type()',
|
463 |
),
|
464 |
'ociwritelobtofile' => array(
|
465 |
'5.4' => false,
|
|
|
|
|
466 |
'alternative' => 'OCI-Lob::export()',
|
467 |
),
|
468 |
'ociwritetemporarylob' => array(
|
469 |
'5.4' => false,
|
|
|
|
|
470 |
'alternative' => 'OCI-Lob::writeTemporary()',
|
471 |
),
|
472 |
'mysqli_get_cache_stats' => array(
|
658 |
'7.2' => false,
|
659 |
'alternative' => 'exif_read_data()',
|
660 |
),
|
661 |
+
|
662 |
+
'image2wbmp' => array(
|
663 |
+
'7.3' => false,
|
664 |
+
'alternative' => 'imagewbmp()',
|
665 |
+
),
|
666 |
+
'mbregex_encoding' => array(
|
667 |
+
'7.3' => false,
|
668 |
+
'alternative' => 'mb_regex_encoding()',
|
669 |
+
),
|
670 |
+
'mbereg' => array(
|
671 |
+
'7.3' => false,
|
672 |
+
'alternative' => 'mb_ereg()',
|
673 |
+
),
|
674 |
+
'mberegi' => array(
|
675 |
+
'7.3' => false,
|
676 |
+
'alternative' => 'mb_eregi()',
|
677 |
+
),
|
678 |
+
'mbereg_replace' => array(
|
679 |
+
'7.3' => false,
|
680 |
+
'alternative' => 'mb_ereg_replace()',
|
681 |
+
),
|
682 |
+
'mberegi_replace' => array(
|
683 |
+
'7.3' => false,
|
684 |
+
'alternative' => 'mb_eregi_replace()',
|
685 |
+
),
|
686 |
+
'mbsplit' => array(
|
687 |
+
'7.3' => false,
|
688 |
+
'alternative' => 'mb_split()',
|
689 |
+
),
|
690 |
+
'mbereg_match' => array(
|
691 |
+
'7.3' => false,
|
692 |
+
'alternative' => 'mb_ereg_match()',
|
693 |
+
),
|
694 |
+
'mbereg_search' => array(
|
695 |
+
'7.3' => false,
|
696 |
+
'alternative' => 'mb_ereg_search()',
|
697 |
+
),
|
698 |
+
'mbereg_search_pos' => array(
|
699 |
+
'7.3' => false,
|
700 |
+
'alternative' => 'mb_ereg_search_pos()',
|
701 |
+
),
|
702 |
+
'mbereg_search_regs' => array(
|
703 |
+
'7.3' => false,
|
704 |
+
'alternative' => 'mb_ereg_search_regs()',
|
705 |
+
),
|
706 |
+
'mbereg_search_init' => array(
|
707 |
+
'7.3' => false,
|
708 |
+
'alternative' => 'mb_ereg_search_init()',
|
709 |
+
),
|
710 |
+
'mbereg_search_getregs' => array(
|
711 |
+
'7.3' => false,
|
712 |
+
'alternative' => 'mb_ereg_search_getregs()',
|
713 |
+
),
|
714 |
+
'mbereg_search_getpos' => array(
|
715 |
+
'7.3' => false,
|
716 |
+
'alternative' => 'mb_ereg_search_getpos()',
|
717 |
+
),
|
718 |
+
'mbereg_search_setpos' => array(
|
719 |
+
'7.3' => false,
|
720 |
+
'alternative' => 'mb_ereg_search_setpos()',
|
721 |
+
),
|
722 |
+
'fgetss' => array(
|
723 |
+
'7.3' => false,
|
724 |
+
'alternative' => null,
|
725 |
+
),
|
726 |
+
'gzgetss' => array(
|
727 |
+
'7.3' => false,
|
728 |
+
'alternative' => null,
|
729 |
+
),
|
730 |
+
|
731 |
+
'ibase_add_user' => array(
|
732 |
+
'7.4' => true,
|
733 |
+
'alternative' => null,
|
734 |
+
),
|
735 |
+
'ibase_affected_rows' => array(
|
736 |
+
'7.4' => true,
|
737 |
+
'alternative' => null,
|
738 |
+
),
|
739 |
+
'ibase_backup' => array(
|
740 |
+
'7.4' => true,
|
741 |
+
'alternative' => null,
|
742 |
+
),
|
743 |
+
'ibase_blob_add' => array(
|
744 |
+
'7.4' => true,
|
745 |
+
'alternative' => null,
|
746 |
+
),
|
747 |
+
'ibase_blob_cancel' => array(
|
748 |
+
'7.4' => true,
|
749 |
+
'alternative' => null,
|
750 |
+
),
|
751 |
+
'ibase_blob_close' => array(
|
752 |
+
'7.4' => true,
|
753 |
+
'alternative' => null,
|
754 |
+
),
|
755 |
+
'ibase_blob_create' => array(
|
756 |
+
'7.4' => true,
|
757 |
+
'alternative' => null,
|
758 |
+
),
|
759 |
+
'ibase_blob_echo' => array(
|
760 |
+
'7.4' => true,
|
761 |
+
'alternative' => null,
|
762 |
+
),
|
763 |
+
'ibase_blob_get' => array(
|
764 |
+
'7.4' => true,
|
765 |
+
'alternative' => null,
|
766 |
+
),
|
767 |
+
'ibase_blob_import' => array(
|
768 |
+
'7.4' => true,
|
769 |
+
'alternative' => null,
|
770 |
+
),
|
771 |
+
'ibase_blob_info' => array(
|
772 |
+
'7.4' => true,
|
773 |
+
'alternative' => null,
|
774 |
+
),
|
775 |
+
'ibase_blob_open' => array(
|
776 |
+
'7.4' => true,
|
777 |
+
'alternative' => null,
|
778 |
+
),
|
779 |
+
'ibase_close' => array(
|
780 |
+
'7.4' => true,
|
781 |
+
'alternative' => null,
|
782 |
+
),
|
783 |
+
'ibase_commit_ret' => array(
|
784 |
+
'7.4' => true,
|
785 |
+
'alternative' => null,
|
786 |
+
),
|
787 |
+
'ibase_commit' => array(
|
788 |
+
'7.4' => true,
|
789 |
+
'alternative' => null,
|
790 |
+
),
|
791 |
+
'ibase_connect' => array(
|
792 |
+
'7.4' => true,
|
793 |
+
'alternative' => null,
|
794 |
+
),
|
795 |
+
'ibase_db_info' => array(
|
796 |
+
'7.4' => true,
|
797 |
+
'alternative' => null,
|
798 |
+
),
|
799 |
+
'ibase_delete_user' => array(
|
800 |
+
'7.4' => true,
|
801 |
+
'alternative' => null,
|
802 |
+
),
|
803 |
+
'ibase_drop_db' => array(
|
804 |
+
'7.4' => true,
|
805 |
+
'alternative' => null,
|
806 |
+
),
|
807 |
+
'ibase_errcode' => array(
|
808 |
+
'7.4' => true,
|
809 |
+
'alternative' => null,
|
810 |
+
),
|
811 |
+
'ibase_errmsg' => array(
|
812 |
+
'7.4' => true,
|
813 |
+
'alternative' => null,
|
814 |
+
),
|
815 |
+
'ibase_execute' => array(
|
816 |
+
'7.4' => true,
|
817 |
+
'alternative' => null,
|
818 |
+
),
|
819 |
+
'ibase_fetch_assoc' => array(
|
820 |
+
'7.4' => true,
|
821 |
+
'alternative' => null,
|
822 |
+
),
|
823 |
+
'ibase_fetch_object' => array(
|
824 |
+
'7.4' => true,
|
825 |
+
'alternative' => null,
|
826 |
+
),
|
827 |
+
'ibase_fetch_row' => array(
|
828 |
+
'7.4' => true,
|
829 |
+
'alternative' => null,
|
830 |
+
),
|
831 |
+
'ibase_field_info' => array(
|
832 |
+
'7.4' => true,
|
833 |
+
'alternative' => null,
|
834 |
+
),
|
835 |
+
'ibase_free_event_handler' => array(
|
836 |
+
'7.4' => true,
|
837 |
+
'alternative' => null,
|
838 |
+
),
|
839 |
+
'ibase_free_query' => array(
|
840 |
+
'7.4' => true,
|
841 |
+
'alternative' => null,
|
842 |
+
),
|
843 |
+
'ibase_free_result' => array(
|
844 |
+
'7.4' => true,
|
845 |
+
'alternative' => null,
|
846 |
+
),
|
847 |
+
'ibase_gen_id' => array(
|
848 |
+
'7.4' => true,
|
849 |
+
'alternative' => null,
|
850 |
+
),
|
851 |
+
'ibase_maintain_db' => array(
|
852 |
+
'7.4' => true,
|
853 |
+
'alternative' => null,
|
854 |
+
),
|
855 |
+
'ibase_modify_user' => array(
|
856 |
+
'7.4' => true,
|
857 |
+
'alternative' => null,
|
858 |
+
),
|
859 |
+
'ibase_name_result' => array(
|
860 |
+
'7.4' => true,
|
861 |
+
'alternative' => null,
|
862 |
+
),
|
863 |
+
'ibase_num_fields' => array(
|
864 |
+
'7.4' => true,
|
865 |
+
'alternative' => null,
|
866 |
+
),
|
867 |
+
'ibase_num_params' => array(
|
868 |
+
'7.4' => true,
|
869 |
+
'alternative' => null,
|
870 |
+
),
|
871 |
+
'ibase_param_info' => array(
|
872 |
+
'7.4' => true,
|
873 |
+
'alternative' => null,
|
874 |
+
),
|
875 |
+
'ibase_pconnect' => array(
|
876 |
+
'7.4' => true,
|
877 |
+
'alternative' => null,
|
878 |
+
),
|
879 |
+
'ibase_prepare' => array(
|
880 |
+
'7.4' => true,
|
881 |
+
'alternative' => null,
|
882 |
+
),
|
883 |
+
'ibase_query' => array(
|
884 |
+
'7.4' => true,
|
885 |
+
'alternative' => null,
|
886 |
+
),
|
887 |
+
'ibase_restore' => array(
|
888 |
+
'7.4' => true,
|
889 |
+
'alternative' => null,
|
890 |
+
),
|
891 |
+
'ibase_rollback_ret' => array(
|
892 |
+
'7.4' => true,
|
893 |
+
'alternative' => null,
|
894 |
+
),
|
895 |
+
'ibase_rollback' => array(
|
896 |
+
'7.4' => true,
|
897 |
+
'alternative' => null,
|
898 |
+
),
|
899 |
+
'ibase_server_info' => array(
|
900 |
+
'7.4' => true,
|
901 |
+
'alternative' => null,
|
902 |
+
),
|
903 |
+
'ibase_service_attach' => array(
|
904 |
+
'7.4' => true,
|
905 |
+
'alternative' => null,
|
906 |
+
),
|
907 |
+
'ibase_service_detach' => array(
|
908 |
+
'7.4' => true,
|
909 |
+
'alternative' => null,
|
910 |
+
),
|
911 |
+
'ibase_set_event_handler' => array(
|
912 |
+
'7.4' => true,
|
913 |
+
'alternative' => null,
|
914 |
+
),
|
915 |
+
'ibase_trans' => array(
|
916 |
+
'7.4' => true,
|
917 |
+
'alternative' => null,
|
918 |
+
),
|
919 |
+
'ibase_wait_event' => array(
|
920 |
+
'7.4' => true,
|
921 |
+
'alternative' => null,
|
922 |
+
),
|
923 |
+
'ldap_control_paged_result_response' => array(
|
924 |
+
'7.4' => false,
|
925 |
+
'alternative' => 'ldap_search()',
|
926 |
+
),
|
927 |
+
'ldap_control_paged_result' => array(
|
928 |
+
'7.4' => false,
|
929 |
+
'alternative' => 'ldap_search()',
|
930 |
+
),
|
931 |
+
'wddx_add_vars' => array(
|
932 |
+
'7.4' => true,
|
933 |
+
'alternative' => null,
|
934 |
+
),
|
935 |
+
'wddx_deserialize' => array(
|
936 |
+
'7.4' => true,
|
937 |
+
'alternative' => null,
|
938 |
+
),
|
939 |
+
'wddx_packet_end' => array(
|
940 |
+
'7.4' => true,
|
941 |
+
'alternative' => null,
|
942 |
+
),
|
943 |
+
'wddx_packet_start' => array(
|
944 |
+
'7.4' => true,
|
945 |
+
'alternative' => null,
|
946 |
+
),
|
947 |
+
'wddx_serialize_value' => array(
|
948 |
+
'7.4' => true,
|
949 |
+
'alternative' => null,
|
950 |
+
),
|
951 |
+
'wddx_serialize_vars' => array(
|
952 |
+
'7.4' => true,
|
953 |
+
'alternative' => null,
|
954 |
+
),
|
955 |
);
|
956 |
|
957 |
|
965 |
// Handle case-insensitivity of function names.
|
966 |
$this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions);
|
967 |
|
968 |
+
return array(\T_STRING);
|
969 |
+
}
|
|
|
970 |
|
971 |
|
972 |
/**
|
978 |
*
|
979 |
* @return void
|
980 |
*/
|
981 |
+
public function process(File $phpcsFile, $stackPtr)
|
982 |
{
|
983 |
$tokens = $phpcsFile->getTokens();
|
984 |
|
985 |
$ignore = array(
|
986 |
+
\T_DOUBLE_COLON => true,
|
987 |
+
\T_OBJECT_OPERATOR => true,
|
988 |
+
\T_FUNCTION => true,
|
989 |
+
\T_CLASS => true,
|
990 |
+
\T_CONST => true,
|
991 |
+
\T_USE => true,
|
992 |
+
\T_NS_SEPARATOR => true,
|
993 |
);
|
994 |
|
995 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
996 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
997 |
// Not a call to a PHP function.
|
998 |
return;
|
999 |
}
|
1010 |
'nameLc' => $functionLc,
|
1011 |
);
|
1012 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
1013 |
+
}
|
|
|
1014 |
|
1015 |
|
1016 |
/**
|
1035 |
{
|
1036 |
return 'Function %s() is ';
|
1037 |
}
|
1038 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/RequiredOptionalFunctionParametersSniff.php → FunctionUse/RequiredToOptionalFunctionParametersSniff.php}
RENAMED
@@ -1,24 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractComplexVersionSniff;
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
19 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
|
24 |
/**
|
@@ -32,6 +34,34 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
32 |
* @var array
|
33 |
*/
|
34 |
protected $functionParameters = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
'bcscale' => array(
|
36 |
0 => array(
|
37 |
'name' => 'scale',
|
@@ -39,6 +69,62 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
39 |
'7.3' => false,
|
40 |
),
|
41 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
'getenv' => array(
|
43 |
0 => array(
|
44 |
'name' => 'varname',
|
@@ -73,8 +159,8 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
73 |
// Handle case-insensitivity of function names.
|
74 |
$this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters);
|
75 |
|
76 |
-
return array(T_STRING);
|
77 |
-
}
|
78 |
|
79 |
/**
|
80 |
* Processes this test, when one of its tokens is encountered.
|
@@ -85,19 +171,19 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
85 |
*
|
86 |
* @return void
|
87 |
*/
|
88 |
-
public function process(
|
89 |
{
|
90 |
$tokens = $phpcsFile->getTokens();
|
91 |
|
92 |
$ignore = array(
|
93 |
-
T_DOUBLE_COLON,
|
94 |
-
T_OBJECT_OPERATOR,
|
95 |
-
T_FUNCTION,
|
96 |
-
T_CONST,
|
97 |
);
|
98 |
|
99 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
100 |
-
if (
|
101 |
// Not a call to a PHP function.
|
102 |
return;
|
103 |
}
|
@@ -110,10 +196,10 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
110 |
}
|
111 |
|
112 |
$parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
|
113 |
-
$openParenthesis = $phpcsFile->findNext(
|
114 |
|
115 |
// If the parameter count returned > 0, we know there will be valid open parenthesis.
|
116 |
-
if ($parameterCount === 0 && $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) {
|
117 |
return;
|
118 |
}
|
119 |
|
@@ -129,8 +215,7 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
129 |
$this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
|
130 |
}
|
131 |
}
|
132 |
-
|
133 |
-
}//end process()
|
134 |
|
135 |
|
136 |
/**
|
@@ -198,8 +283,7 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
198 |
$errorInfo['paramName'] = $itemArray['name'];
|
199 |
|
200 |
return $errorInfo;
|
201 |
-
|
202 |
-
}//end getErrorInfo()
|
203 |
|
204 |
|
205 |
/**
|
@@ -225,7 +309,7 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
225 |
*
|
226 |
* @return void
|
227 |
*/
|
228 |
-
public function addError(
|
229 |
{
|
230 |
$error = $this->getErrorMsgTemplate();
|
231 |
$errorCode = $this->stringToErrorCode($itemInfo['name'] . '_' . $errorInfo['paramName']) . 'Missing';
|
@@ -236,8 +320,5 @@ class RequiredOptionalFunctionParametersSniff extends AbstractComplexVersionSnif
|
|
236 |
);
|
237 |
|
238 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\FunctionUse;
|
11 |
|
12 |
use PHPCompatibility\AbstractComplexVersionSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
21 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
22 |
*/
|
23 |
+
class RequiredToOptionalFunctionParametersSniff extends AbstractComplexVersionSniff
|
24 |
{
|
25 |
|
26 |
/**
|
34 |
* @var array
|
35 |
*/
|
36 |
protected $functionParameters = array(
|
37 |
+
'array_merge' => array(
|
38 |
+
0 => array(
|
39 |
+
'name' => 'array(s) to merge',
|
40 |
+
'7.3' => true,
|
41 |
+
'7.4' => false,
|
42 |
+
),
|
43 |
+
),
|
44 |
+
'array_merge_recursive' => array(
|
45 |
+
0 => array(
|
46 |
+
'name' => 'array(s) to merge',
|
47 |
+
'7.3' => true,
|
48 |
+
'7.4' => false,
|
49 |
+
),
|
50 |
+
),
|
51 |
+
'array_push' => array(
|
52 |
+
1 => array(
|
53 |
+
'name' => 'element to push',
|
54 |
+
'7.2' => true,
|
55 |
+
'7.3' => false,
|
56 |
+
),
|
57 |
+
),
|
58 |
+
'array_unshift' => array(
|
59 |
+
1 => array(
|
60 |
+
'name' => 'element to prepend',
|
61 |
+
'7.2' => true,
|
62 |
+
'7.3' => false,
|
63 |
+
),
|
64 |
+
),
|
65 |
'bcscale' => array(
|
66 |
0 => array(
|
67 |
'name' => 'scale',
|
69 |
'7.3' => false,
|
70 |
),
|
71 |
),
|
72 |
+
'ftp_fget' => array(
|
73 |
+
3 => array(
|
74 |
+
'name' => 'mode',
|
75 |
+
'7.2' => true,
|
76 |
+
'7.3' => false,
|
77 |
+
),
|
78 |
+
),
|
79 |
+
'ftp_fput' => array(
|
80 |
+
3 => array(
|
81 |
+
'name' => 'mode',
|
82 |
+
'7.2' => true,
|
83 |
+
'7.3' => false,
|
84 |
+
),
|
85 |
+
),
|
86 |
+
'ftp_get' => array(
|
87 |
+
3 => array(
|
88 |
+
'name' => 'mode',
|
89 |
+
'7.2' => true,
|
90 |
+
'7.3' => false,
|
91 |
+
),
|
92 |
+
),
|
93 |
+
'ftp_nb_fget' => array(
|
94 |
+
3 => array(
|
95 |
+
'name' => 'mode',
|
96 |
+
'7.2' => true,
|
97 |
+
'7.3' => false,
|
98 |
+
),
|
99 |
+
),
|
100 |
+
'ftp_nb_fput' => array(
|
101 |
+
3 => array(
|
102 |
+
'name' => 'mode',
|
103 |
+
'7.2' => true,
|
104 |
+
'7.3' => false,
|
105 |
+
),
|
106 |
+
),
|
107 |
+
'ftp_nb_get' => array(
|
108 |
+
3 => array(
|
109 |
+
'name' => 'mode',
|
110 |
+
'7.2' => true,
|
111 |
+
'7.3' => false,
|
112 |
+
),
|
113 |
+
),
|
114 |
+
'ftp_nb_put' => array(
|
115 |
+
3 => array(
|
116 |
+
'name' => 'mode',
|
117 |
+
'7.2' => true,
|
118 |
+
'7.3' => false,
|
119 |
+
),
|
120 |
+
),
|
121 |
+
'ftp_put' => array(
|
122 |
+
3 => array(
|
123 |
+
'name' => 'mode',
|
124 |
+
'7.2' => true,
|
125 |
+
'7.3' => false,
|
126 |
+
),
|
127 |
+
),
|
128 |
'getenv' => array(
|
129 |
0 => array(
|
130 |
'name' => 'varname',
|
159 |
// Handle case-insensitivity of function names.
|
160 |
$this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters);
|
161 |
|
162 |
+
return array(\T_STRING);
|
163 |
+
}
|
164 |
|
165 |
/**
|
166 |
* Processes this test, when one of its tokens is encountered.
|
171 |
*
|
172 |
* @return void
|
173 |
*/
|
174 |
+
public function process(File $phpcsFile, $stackPtr)
|
175 |
{
|
176 |
$tokens = $phpcsFile->getTokens();
|
177 |
|
178 |
$ignore = array(
|
179 |
+
\T_DOUBLE_COLON => true,
|
180 |
+
\T_OBJECT_OPERATOR => true,
|
181 |
+
\T_FUNCTION => true,
|
182 |
+
\T_CONST => true,
|
183 |
);
|
184 |
|
185 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
186 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
187 |
// Not a call to a PHP function.
|
188 |
return;
|
189 |
}
|
196 |
}
|
197 |
|
198 |
$parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
|
199 |
+
$openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
200 |
|
201 |
// If the parameter count returned > 0, we know there will be valid open parenthesis.
|
202 |
+
if ($parameterCount === 0 && $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS) {
|
203 |
return;
|
204 |
}
|
205 |
|
215 |
$this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
|
216 |
}
|
217 |
}
|
218 |
+
}
|
|
|
219 |
|
220 |
|
221 |
/**
|
283 |
$errorInfo['paramName'] = $itemArray['name'];
|
284 |
|
285 |
return $errorInfo;
|
286 |
+
}
|
|
|
287 |
|
288 |
|
289 |
/**
|
309 |
*
|
310 |
* @return void
|
311 |
*/
|
312 |
+
public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
|
313 |
{
|
314 |
$error = $this->getErrorMsgTemplate();
|
315 |
$errorCode = $this->stringToErrorCode($itemInfo['name'] . '_' . $errorInfo['paramName']) . 'Missing';
|
320 |
);
|
321 |
|
322 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
323 |
+
}
|
324 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Generators}/NewGeneratorReturnSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,13 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* As of PHP 7.0, a return statement can be used within a generator for a final expression to be returned.
|
21 |
*
|
@@ -27,6 +28,16 @@ use PHPCompatibility\PHPCSHelper;
|
|
27 |
*/
|
28 |
class NewGeneratorReturnSniff extends Sniff
|
29 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
/**
|
32 |
* Returns an array of tokens this test wants to listen for.
|
@@ -35,14 +46,16 @@ class NewGeneratorReturnSniff extends Sniff
|
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
-
$targets = array(
|
|
|
|
|
39 |
|
40 |
/*
|
41 |
* The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.
|
42 |
* The `yield from` keyword was introduced in PHP 7.0 and tokenizes as
|
43 |
* "T_YIELD T_WHITESPACE T_STRING".
|
44 |
*
|
45 |
-
* Pre-PHPCS 3.1.0, the T_YIELD token was not back-filled for PHP < 5.5.
|
46 |
* Also, as of PHPCS 3.1.0, the PHPCS tokenizer adds a new T_YIELD_FROM
|
47 |
* token.
|
48 |
*
|
@@ -50,19 +63,14 @@ class NewGeneratorReturnSniff extends Sniff
|
|
50 |
* For PHP 5.5+ we need to look for T_YIELD.
|
51 |
* For PHPCS 3.1.0+, we also need to look for T_YIELD_FROM.
|
52 |
*/
|
53 |
-
if (version_compare(PHP_VERSION_ID, '50500', '<') === true
|
54 |
&& version_compare(PHPCSHelper::getVersion(), '3.1.0', '<') === true
|
55 |
) {
|
56 |
-
$targets[] = T_STRING;
|
57 |
-
}
|
58 |
-
|
59 |
-
if (defined('T_YIELD')) {
|
60 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_yieldFound
|
61 |
-
$targets[] = T_YIELD;
|
62 |
}
|
63 |
|
64 |
-
if (defined('T_YIELD_FROM')) {
|
65 |
-
$targets[] = T_YIELD_FROM;
|
66 |
}
|
67 |
|
68 |
return $targets;
|
@@ -77,7 +85,7 @@ class NewGeneratorReturnSniff extends Sniff
|
|
77 |
*
|
78 |
* @return void|int Void or a stack pointer to skip forward.
|
79 |
*/
|
80 |
-
public function process(
|
81 |
{
|
82 |
if ($this->supportsBelow('5.6') !== true) {
|
83 |
return;
|
@@ -85,19 +93,26 @@ class NewGeneratorReturnSniff extends Sniff
|
|
85 |
|
86 |
$tokens = $phpcsFile->getTokens();
|
87 |
|
88 |
-
if ($tokens[$stackPtr]['code'] === T_STRING
|
89 |
&& $tokens[$stackPtr]['content'] !== 'yield'
|
90 |
) {
|
91 |
return;
|
92 |
}
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
-
if ($function === false) {
|
101 |
// Yield outside function scope, fatal error, but not our concern.
|
102 |
return;
|
103 |
}
|
@@ -107,16 +122,30 @@ class NewGeneratorReturnSniff extends Sniff
|
|
107 |
return;
|
108 |
}
|
109 |
|
110 |
-
$
|
111 |
-
if (
|
112 |
-
|
113 |
}
|
114 |
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
'
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
// Don't examine this function again.
|
122 |
return $tokens[$function]['scope_closer'];
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Generators\NewGeneratorReturnSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Generators;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Generators\NewGeneratorReturnSniff.
|
20 |
*
|
21 |
* As of PHP 7.0, a return statement can be used within a generator for a final expression to be returned.
|
22 |
*
|
28 |
*/
|
29 |
class NewGeneratorReturnSniff extends Sniff
|
30 |
{
|
31 |
+
/**
|
32 |
+
* Scope conditions within which a yield can exist.
|
33 |
+
*
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
private $validConditions = array(
|
37 |
+
\T_FUNCTION => \T_FUNCTION,
|
38 |
+
\T_CLOSURE => \T_CLOSURE,
|
39 |
+
);
|
40 |
+
|
41 |
|
42 |
/**
|
43 |
* Returns an array of tokens this test wants to listen for.
|
46 |
*/
|
47 |
public function register()
|
48 |
{
|
49 |
+
$targets = array(
|
50 |
+
\T_YIELD,
|
51 |
+
);
|
52 |
|
53 |
/*
|
54 |
* The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.
|
55 |
* The `yield from` keyword was introduced in PHP 7.0 and tokenizes as
|
56 |
* "T_YIELD T_WHITESPACE T_STRING".
|
57 |
*
|
58 |
+
* Pre-PHPCS 3.1.0, the T_YIELD token was not correctly back-filled for PHP < 5.5.
|
59 |
* Also, as of PHPCS 3.1.0, the PHPCS tokenizer adds a new T_YIELD_FROM
|
60 |
* token.
|
61 |
*
|
63 |
* For PHP 5.5+ we need to look for T_YIELD.
|
64 |
* For PHPCS 3.1.0+, we also need to look for T_YIELD_FROM.
|
65 |
*/
|
66 |
+
if (version_compare(\PHP_VERSION_ID, '50500', '<') === true
|
67 |
&& version_compare(PHPCSHelper::getVersion(), '3.1.0', '<') === true
|
68 |
) {
|
69 |
+
$targets[] = \T_STRING;
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
+
if (\defined('T_YIELD_FROM')) {
|
73 |
+
$targets[] = \T_YIELD_FROM;
|
74 |
}
|
75 |
|
76 |
return $targets;
|
85 |
*
|
86 |
* @return void|int Void or a stack pointer to skip forward.
|
87 |
*/
|
88 |
+
public function process(File $phpcsFile, $stackPtr)
|
89 |
{
|
90 |
if ($this->supportsBelow('5.6') !== true) {
|
91 |
return;
|
93 |
|
94 |
$tokens = $phpcsFile->getTokens();
|
95 |
|
96 |
+
if ($tokens[$stackPtr]['code'] === \T_STRING
|
97 |
&& $tokens[$stackPtr]['content'] !== 'yield'
|
98 |
) {
|
99 |
return;
|
100 |
}
|
101 |
|
102 |
+
if (empty($tokens[$stackPtr]['conditions']) === true) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
// Walk the condition from inner to outer to see if we can find a valid function/closure scope.
|
107 |
+
$conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
|
108 |
+
foreach ($conditions as $ptr => $type) {
|
109 |
+
if (isset($this->validConditions[$type]) === true) {
|
110 |
+
$function = $ptr;
|
111 |
+
break;
|
112 |
+
}
|
113 |
}
|
114 |
|
115 |
+
if (isset($function) === false) {
|
116 |
// Yield outside function scope, fatal error, but not our concern.
|
117 |
return;
|
118 |
}
|
122 |
return;
|
123 |
}
|
124 |
|
125 |
+
$targets = array(\T_RETURN, \T_CLOSURE, \T_FUNCTION, \T_CLASS);
|
126 |
+
if (\defined('T_ANON_CLASS')) {
|
127 |
+
$targets[] = \T_ANON_CLASS;
|
128 |
}
|
129 |
|
130 |
+
$current = $tokens[$function]['scope_opener'];
|
131 |
+
|
132 |
+
while (($current = $phpcsFile->findNext($targets, ($current + 1), $tokens[$function]['scope_closer'])) !== false) {
|
133 |
+
if ($tokens[$current]['code'] === \T_RETURN) {
|
134 |
+
$phpcsFile->addError(
|
135 |
+
'Returning a final expression from a generator was not supported in PHP 5.6 or earlier',
|
136 |
+
$current,
|
137 |
+
'ReturnFound'
|
138 |
+
);
|
139 |
+
|
140 |
+
return $tokens[$function]['scope_closer'];
|
141 |
+
}
|
142 |
+
|
143 |
+
// Found a nested scope in which return can exist without problems.
|
144 |
+
if (isset($tokens[$current]['scope_closer'])) {
|
145 |
+
// Skip past the nested scope.
|
146 |
+
$current = $tokens[$current]['scope_closer'];
|
147 |
+
}
|
148 |
+
}
|
149 |
|
150 |
// Don't examine this function again.
|
151 |
return $tokens[$function]['scope_closer'];
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → IniDirectives}/NewIniDirectivesSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,12 +8,13 @@
|
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* Discourages the use of new INI directives through ini_set() or ini_get().
|
19 |
*
|
@@ -454,6 +455,10 @@ class NewIniDirectivesSniff extends AbstractNewFeatureSniff
|
|
454 |
'7.0' => true,
|
455 |
),
|
456 |
|
|
|
|
|
|
|
|
|
457 |
'session.sid_length' => array(
|
458 |
'7.0' => false,
|
459 |
'7.1' => true,
|
@@ -462,6 +467,41 @@ class NewIniDirectivesSniff extends AbstractNewFeatureSniff
|
|
462 |
'7.0' => false,
|
463 |
'7.1' => true,
|
464 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
);
|
466 |
|
467 |
/**
|
@@ -471,9 +511,8 @@ class NewIniDirectivesSniff extends AbstractNewFeatureSniff
|
|
471 |
*/
|
472 |
public function register()
|
473 |
{
|
474 |
-
return array(T_STRING);
|
475 |
-
|
476 |
-
}//end register()
|
477 |
|
478 |
/**
|
479 |
* Processes this test, when one of its tokens is encountered.
|
@@ -484,19 +523,19 @@ class NewIniDirectivesSniff extends AbstractNewFeatureSniff
|
|
484 |
*
|
485 |
* @return void
|
486 |
*/
|
487 |
-
public function process(
|
488 |
{
|
489 |
$tokens = $phpcsFile->getTokens();
|
490 |
|
491 |
$ignore = array(
|
492 |
-
T_DOUBLE_COLON,
|
493 |
-
T_OBJECT_OPERATOR,
|
494 |
-
T_FUNCTION,
|
495 |
-
T_CONST,
|
496 |
);
|
497 |
|
498 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
499 |
-
if (
|
500 |
// Not a call to a PHP function.
|
501 |
return;
|
502 |
}
|
@@ -521,8 +560,7 @@ class NewIniDirectivesSniff extends AbstractNewFeatureSniff
|
|
521 |
'functionLc' => $functionLc,
|
522 |
);
|
523 |
$this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
|
524 |
-
|
525 |
-
}//end process()
|
526 |
|
527 |
|
528 |
/**
|
@@ -622,6 +660,4 @@ class NewIniDirectivesSniff extends AbstractNewFeatureSniff
|
|
622 |
|
623 |
return $data;
|
624 |
}
|
625 |
-
|
626 |
-
|
627 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\IniDirectives\NewIniDirectivesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\IniDirectives;
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\IniDirectives\NewIniDirectivesSniff.
|
18 |
*
|
19 |
* Discourages the use of new INI directives through ini_set() or ini_get().
|
20 |
*
|
455 |
'7.0' => true,
|
456 |
),
|
457 |
|
458 |
+
'hard_timeout' => array(
|
459 |
+
'7.0' => false,
|
460 |
+
'7.1' => true,
|
461 |
+
),
|
462 |
'session.sid_length' => array(
|
463 |
'7.0' => false,
|
464 |
'7.1' => true,
|
467 |
'7.0' => false,
|
468 |
'7.1' => true,
|
469 |
),
|
470 |
+
'session.trans_sid_hosts' => array(
|
471 |
+
'7.0' => false,
|
472 |
+
'7.1' => true,
|
473 |
+
),
|
474 |
+
'session.trans_sid_tags' => array(
|
475 |
+
'7.0' => false,
|
476 |
+
'7.1' => true,
|
477 |
+
),
|
478 |
+
'url_rewriter.hosts' => array(
|
479 |
+
'7.0' => false,
|
480 |
+
'7.1' => true,
|
481 |
+
),
|
482 |
+
|
483 |
+
// Introduced in PHP 7.1.25, 7.2.13, 7.3.0.
|
484 |
+
'imap.enable_insecure_rsh' => array(
|
485 |
+
'7.1.24' => false,
|
486 |
+
'7.1.25' => true,
|
487 |
+
),
|
488 |
+
|
489 |
+
'syslog.facility' => array(
|
490 |
+
'7.2' => false,
|
491 |
+
'7.3' => true,
|
492 |
+
),
|
493 |
+
'syslog.filter' => array(
|
494 |
+
'7.2' => false,
|
495 |
+
'7.3' => true,
|
496 |
+
),
|
497 |
+
'syslog.ident' => array(
|
498 |
+
'7.2' => false,
|
499 |
+
'7.3' => true,
|
500 |
+
),
|
501 |
+
'session.cookie_samesite' => array(
|
502 |
+
'7.2' => false,
|
503 |
+
'7.3' => true,
|
504 |
+
),
|
505 |
);
|
506 |
|
507 |
/**
|
511 |
*/
|
512 |
public function register()
|
513 |
{
|
514 |
+
return array(\T_STRING);
|
515 |
+
}
|
|
|
516 |
|
517 |
/**
|
518 |
* Processes this test, when one of its tokens is encountered.
|
523 |
*
|
524 |
* @return void
|
525 |
*/
|
526 |
+
public function process(File $phpcsFile, $stackPtr)
|
527 |
{
|
528 |
$tokens = $phpcsFile->getTokens();
|
529 |
|
530 |
$ignore = array(
|
531 |
+
\T_DOUBLE_COLON => true,
|
532 |
+
\T_OBJECT_OPERATOR => true,
|
533 |
+
\T_FUNCTION => true,
|
534 |
+
\T_CONST => true,
|
535 |
);
|
536 |
|
537 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
538 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
539 |
// Not a call to a PHP function.
|
540 |
return;
|
541 |
}
|
560 |
'functionLc' => $functionLc,
|
561 |
);
|
562 |
$this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
|
563 |
+
}
|
|
|
564 |
|
565 |
|
566 |
/**
|
660 |
|
661 |
return $data;
|
662 |
}
|
663 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedIniDirectivesSniff.php → IniDirectives/RemovedIniDirectivesSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,21 +8,22 @@
|
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
-
* Discourages the use of deprecated INI directives through ini_set() or ini_get().
|
19 |
*
|
20 |
* @category PHP
|
21 |
* @package PHPCompatibility
|
22 |
* @author Wim Godden <wim.godden@cu.be>
|
23 |
* @copyright 2012 Cu.be Solutions bvba
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
/**
|
28 |
* A list of deprecated INI directives.
|
@@ -37,6 +38,27 @@ class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
|
37 |
'5.1' => true,
|
38 |
'alternative' => 'fbsql.batchsize',
|
39 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
'ifx.allow_persistent' => array(
|
42 |
'5.2.1' => true,
|
@@ -216,6 +238,48 @@ class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
|
216 |
'opcache.fast_shutdown' => array(
|
217 |
'7.2' => true,
|
218 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
);
|
220 |
|
221 |
/**
|
@@ -225,9 +289,8 @@ class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
|
225 |
*/
|
226 |
public function register()
|
227 |
{
|
228 |
-
return array(T_STRING);
|
229 |
-
|
230 |
-
}//end register()
|
231 |
|
232 |
/**
|
233 |
* Processes this test, when one of its tokens is encountered.
|
@@ -238,19 +301,19 @@ class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
|
238 |
*
|
239 |
* @return void
|
240 |
*/
|
241 |
-
public function process(
|
242 |
{
|
243 |
$tokens = $phpcsFile->getTokens();
|
244 |
|
245 |
$ignore = array(
|
246 |
-
T_DOUBLE_COLON,
|
247 |
-
T_OBJECT_OPERATOR,
|
248 |
-
T_FUNCTION,
|
249 |
-
T_CONST,
|
250 |
);
|
251 |
|
252 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
253 |
-
if (
|
254 |
// Not a call to a PHP function.
|
255 |
return;
|
256 |
}
|
@@ -275,8 +338,7 @@ class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
|
275 |
'functionLc' => $functionLc,
|
276 |
);
|
277 |
$this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
|
278 |
-
|
279 |
-
}//end process()
|
280 |
|
281 |
|
282 |
/**
|
@@ -333,6 +395,4 @@ class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
|
333 |
{
|
334 |
return str_replace("%s", "'%s'", parent::getAlternativeOptionTemplate());
|
335 |
}
|
336 |
-
|
337 |
-
|
338 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\IniDirectives\RemovedIniDirectivesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\IniDirectives;
|
12 |
|
13 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\IniDirectives\RemovedIniDirectivesSniff.
|
18 |
*
|
19 |
+
* Discourages the use of deprecated and removed INI directives through ini_set() or ini_get().
|
20 |
*
|
21 |
* @category PHP
|
22 |
* @package PHPCompatibility
|
23 |
* @author Wim Godden <wim.godden@cu.be>
|
24 |
* @copyright 2012 Cu.be Solutions bvba
|
25 |
*/
|
26 |
+
class RemovedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
27 |
{
|
28 |
/**
|
29 |
* A list of deprecated INI directives.
|
38 |
'5.1' => true,
|
39 |
'alternative' => 'fbsql.batchsize',
|
40 |
),
|
41 |
+
'pfpro.defaulthost' => array(
|
42 |
+
'5.1' => true,
|
43 |
+
),
|
44 |
+
'pfpro.defaultport' => array(
|
45 |
+
'5.1' => true,
|
46 |
+
),
|
47 |
+
'pfpro.defaulttimeout' => array(
|
48 |
+
'5.1' => true,
|
49 |
+
),
|
50 |
+
'pfpro.proxyaddress' => array(
|
51 |
+
'5.1' => true,
|
52 |
+
),
|
53 |
+
'pfpro.proxyport' => array(
|
54 |
+
'5.1' => true,
|
55 |
+
),
|
56 |
+
'pfpro.proxylogon' => array(
|
57 |
+
'5.1' => true,
|
58 |
+
),
|
59 |
+
'pfpro.proxypassword' => array(
|
60 |
+
'5.1' => true,
|
61 |
+
),
|
62 |
|
63 |
'ifx.allow_persistent' => array(
|
64 |
'5.2.1' => true,
|
238 |
'opcache.fast_shutdown' => array(
|
239 |
'7.2' => true,
|
240 |
),
|
241 |
+
|
242 |
+
'birdstep.max_links' => array(
|
243 |
+
'7.3' => true,
|
244 |
+
),
|
245 |
+
'opcache.inherited_hack' => array(
|
246 |
+
'5.3' => false, // Soft deprecated, i.e. ignored.
|
247 |
+
'7.3' => true,
|
248 |
+
),
|
249 |
+
'pdo_odbc.db2_instance_name' => array(
|
250 |
+
'7.3' => false, // Has been marked as deprecated in the manual from before this time. Now hard-deprecated.
|
251 |
+
),
|
252 |
+
|
253 |
+
'ibase.allow_persistent' => array(
|
254 |
+
'7.4' => true,
|
255 |
+
),
|
256 |
+
'ibase.max_persistent' => array(
|
257 |
+
'7.4' => true,
|
258 |
+
),
|
259 |
+
'ibase.max_links' => array(
|
260 |
+
'7.4' => true,
|
261 |
+
),
|
262 |
+
'ibase.default_db' => array(
|
263 |
+
'7.4' => true,
|
264 |
+
),
|
265 |
+
'ibase.default_user' => array(
|
266 |
+
'7.4' => true,
|
267 |
+
),
|
268 |
+
'ibase.default_password' => array(
|
269 |
+
'7.4' => true,
|
270 |
+
),
|
271 |
+
'ibase.default_charset' => array(
|
272 |
+
'7.4' => true,
|
273 |
+
),
|
274 |
+
'ibase.timestampformat' => array(
|
275 |
+
'7.4' => true,
|
276 |
+
),
|
277 |
+
'ibase.dateformat' => array(
|
278 |
+
'7.4' => true,
|
279 |
+
),
|
280 |
+
'ibase.timeformat' => array(
|
281 |
+
'7.4' => true,
|
282 |
+
),
|
283 |
);
|
284 |
|
285 |
/**
|
289 |
*/
|
290 |
public function register()
|
291 |
{
|
292 |
+
return array(\T_STRING);
|
293 |
+
}
|
|
|
294 |
|
295 |
/**
|
296 |
* Processes this test, when one of its tokens is encountered.
|
301 |
*
|
302 |
* @return void
|
303 |
*/
|
304 |
+
public function process(File $phpcsFile, $stackPtr)
|
305 |
{
|
306 |
$tokens = $phpcsFile->getTokens();
|
307 |
|
308 |
$ignore = array(
|
309 |
+
\T_DOUBLE_COLON => true,
|
310 |
+
\T_OBJECT_OPERATOR => true,
|
311 |
+
\T_FUNCTION => true,
|
312 |
+
\T_CONST => true,
|
313 |
);
|
314 |
|
315 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
316 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
317 |
// Not a call to a PHP function.
|
318 |
return;
|
319 |
}
|
338 |
'functionLc' => $functionLc,
|
339 |
);
|
340 |
$this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
|
341 |
+
}
|
|
|
342 |
|
343 |
|
344 |
/**
|
395 |
{
|
396 |
return str_replace("%s", "'%s'", parent::getAlternativeOptionTemplate());
|
397 |
}
|
398 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ConstantArraysUsingConstSniff.php → InitialValue/NewConstantArraysUsingConstSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.6
|
6 |
*
|
@@ -9,14 +9,15 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
-
* Constant arrays using the
|
20 |
*
|
21 |
* PHP version 5.6
|
22 |
*
|
@@ -24,7 +25,7 @@ use PHPCompatibility\Sniff;
|
|
24 |
* @package PHPCompatibility
|
25 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
*/
|
27 |
-
class
|
28 |
{
|
29 |
|
30 |
/**
|
@@ -34,7 +35,7 @@ class ConstantArraysUsingConstSniff extends Sniff
|
|
34 |
*/
|
35 |
public function register()
|
36 |
{
|
37 |
-
return array(T_CONST);
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -46,7 +47,7 @@ class ConstantArraysUsingConstSniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsBelow('5.5') !== true) {
|
52 |
return;
|
@@ -54,8 +55,8 @@ class ConstantArraysUsingConstSniff extends Sniff
|
|
54 |
|
55 |
$tokens = $phpcsFile->getTokens();
|
56 |
$find = array(
|
57 |
-
T_ARRAY
|
58 |
-
T_OPEN_SHORT_ARRAY
|
59 |
);
|
60 |
|
61 |
while (($hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true)) !== false) {
|
@@ -67,9 +68,9 @@ class ConstantArraysUsingConstSniff extends Sniff
|
|
67 |
|
68 |
// Skip past the content of the array.
|
69 |
$stackPtr = $hasArray;
|
70 |
-
if ($tokens[$hasArray]['code'] === T_OPEN_SHORT_ARRAY && isset($tokens[$hasArray]['bracket_closer'])) {
|
71 |
$stackPtr = $tokens[$hasArray]['bracket_closer'];
|
72 |
-
} elseif ($tokens[$hasArray]['code'] === T_ARRAY && isset($tokens[$hasArray]['parenthesis_closer'])) {
|
73 |
$stackPtr = $tokens[$hasArray]['parenthesis_closer'];
|
74 |
}
|
75 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewConstantArraysUsingConstSniff.
|
4 |
*
|
5 |
* PHP version 5.6
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\InitialValue;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewConstantArraysUsingConstSniff.
|
19 |
*
|
20 |
+
* Constant arrays using the const keyword in PHP 5.6
|
21 |
*
|
22 |
* PHP version 5.6
|
23 |
*
|
25 |
* @package PHPCompatibility
|
26 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
27 |
*/
|
28 |
+
class NewConstantArraysUsingConstSniff extends Sniff
|
29 |
{
|
30 |
|
31 |
/**
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
+
return array(\T_CONST);
|
39 |
}
|
40 |
|
41 |
/**
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
+
public function process(File $phpcsFile, $stackPtr)
|
51 |
{
|
52 |
if ($this->supportsBelow('5.5') !== true) {
|
53 |
return;
|
55 |
|
56 |
$tokens = $phpcsFile->getTokens();
|
57 |
$find = array(
|
58 |
+
\T_ARRAY => \T_ARRAY,
|
59 |
+
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
|
60 |
);
|
61 |
|
62 |
while (($hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true)) !== false) {
|
68 |
|
69 |
// Skip past the content of the array.
|
70 |
$stackPtr = $hasArray;
|
71 |
+
if ($tokens[$hasArray]['code'] === \T_OPEN_SHORT_ARRAY && isset($tokens[$hasArray]['bracket_closer'])) {
|
72 |
$stackPtr = $tokens[$hasArray]['bracket_closer'];
|
73 |
+
} elseif ($tokens[$hasArray]['code'] === \T_ARRAY && isset($tokens[$hasArray]['parenthesis_closer'])) {
|
74 |
$stackPtr = $tokens[$hasArray]['parenthesis_closer'];
|
75 |
}
|
76 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ConstantArraysUsingDefineSniff.php → InitialValue/NewConstantArraysUsingDefineSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Constant arrays using define in PHP 7.0
|
20 |
*
|
@@ -24,7 +25,7 @@ use PHPCompatibility\Sniff;
|
|
24 |
* @package PHPCompatibility
|
25 |
* @author Wim Godden <wim@cu.be>
|
26 |
*/
|
27 |
-
class
|
28 |
{
|
29 |
|
30 |
/**
|
@@ -34,7 +35,7 @@ class ConstantArraysUsingDefineSniff extends Sniff
|
|
34 |
*/
|
35 |
public function register()
|
36 |
{
|
37 |
-
return array(T_STRING);
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -46,7 +47,7 @@ class ConstantArraysUsingDefineSniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsBelow('5.6') !== true) {
|
52 |
return;
|
@@ -55,14 +56,14 @@ class ConstantArraysUsingDefineSniff extends Sniff
|
|
55 |
$tokens = $phpcsFile->getTokens();
|
56 |
|
57 |
$ignore = array(
|
58 |
-
T_DOUBLE_COLON,
|
59 |
-
T_OBJECT_OPERATOR,
|
60 |
-
T_FUNCTION,
|
61 |
-
T_CONST,
|
62 |
);
|
63 |
|
64 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
65 |
-
if (
|
66 |
// Not a call to a PHP function.
|
67 |
return;
|
68 |
}
|
@@ -79,12 +80,12 @@ class ConstantArraysUsingDefineSniff extends Sniff
|
|
79 |
|
80 |
$targetNestingLevel = 0;
|
81 |
if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
|
82 |
-
$targetNestingLevel = count($tokens[$secondParam['start']]['nested_parenthesis']);
|
83 |
}
|
84 |
|
85 |
-
$array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
|
86 |
if ($array !== false) {
|
87 |
-
if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
|
88 |
$phpcsFile->addError(
|
89 |
'Constant arrays using define are not allowed in PHP 5.6 or earlier',
|
90 |
$array,
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewConstantArraysUsingDefineSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\InitialValue;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewConstantArraysUsingDefineSniff.
|
19 |
*
|
20 |
* Constant arrays using define in PHP 7.0
|
21 |
*
|
25 |
* @package PHPCompatibility
|
26 |
* @author Wim Godden <wim@cu.be>
|
27 |
*/
|
28 |
+
class NewConstantArraysUsingDefineSniff extends Sniff
|
29 |
{
|
30 |
|
31 |
/**
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
+
return array(\T_STRING);
|
39 |
}
|
40 |
|
41 |
/**
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
+
public function process(File $phpcsFile, $stackPtr)
|
51 |
{
|
52 |
if ($this->supportsBelow('5.6') !== true) {
|
53 |
return;
|
56 |
$tokens = $phpcsFile->getTokens();
|
57 |
|
58 |
$ignore = array(
|
59 |
+
\T_DOUBLE_COLON => true,
|
60 |
+
\T_OBJECT_OPERATOR => true,
|
61 |
+
\T_FUNCTION => true,
|
62 |
+
\T_CONST => true,
|
63 |
);
|
64 |
|
65 |
+
$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
|
66 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
67 |
// Not a call to a PHP function.
|
68 |
return;
|
69 |
}
|
80 |
|
81 |
$targetNestingLevel = 0;
|
82 |
if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
|
83 |
+
$targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);
|
84 |
}
|
85 |
|
86 |
+
$array = $phpcsFile->findNext(array(\T_ARRAY, \T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
|
87 |
if ($array !== false) {
|
88 |
+
if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
|
89 |
$phpcsFile->addError(
|
90 |
'Constant arrays using define are not allowed in PHP 5.6 or earlier',
|
91 |
$array,
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → InitialValue}/NewConstantScalarExpressionsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.6
|
6 |
*
|
@@ -9,13 +9,15 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Since PHP 5.6, it is now possible to provide a scalar expression involving
|
21 |
* numeric and string literals and/or constants in contexts where PHP previously
|
@@ -58,28 +60,29 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
58 |
* @var array
|
59 |
*/
|
60 |
protected $safeOperands = array(
|
61 |
-
T_LNUMBER => T_LNUMBER,
|
62 |
-
T_DNUMBER => T_DNUMBER,
|
63 |
-
T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
|
64 |
-
T_TRUE => T_TRUE,
|
65 |
-
T_FALSE => T_FALSE,
|
66 |
-
T_NULL => T_NULL,
|
67 |
-
|
68 |
-
T_LINE => T_LINE,
|
69 |
-
T_FILE => T_FILE,
|
70 |
-
T_DIR => T_DIR,
|
71 |
-
T_FUNC_C => T_FUNC_C,
|
72 |
-
T_CLASS_C => T_CLASS_C,
|
73 |
-
|
74 |
-
|
|
|
75 |
|
76 |
// Special cases:
|
77 |
-
T_NS_SEPARATOR => T_NS_SEPARATOR,
|
78 |
/*
|
79 |
* This can be neigh anything, but for any usage except constants,
|
80 |
* the T_STRING will be combined with non-allowed tokens, so we should be good.
|
81 |
*/
|
82 |
-
T_STRING => T_STRING,
|
83 |
);
|
84 |
|
85 |
|
@@ -94,11 +97,11 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
94 |
$this->setProperties();
|
95 |
|
96 |
return array(
|
97 |
-
T_CONST,
|
98 |
-
T_VARIABLE,
|
99 |
-
T_FUNCTION,
|
100 |
-
T_CLOSURE,
|
101 |
-
T_STATIC,
|
102 |
);
|
103 |
}
|
104 |
|
@@ -110,25 +113,8 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
110 |
*/
|
111 |
public function setProperties()
|
112 |
{
|
113 |
-
|
114 |
-
|
115 |
-
* Not a problem for recognition as when the token is not available
|
116 |
-
* __TRAIT__ will be tokenized as T_STRING which will pass.
|
117 |
-
*/
|
118 |
-
if (defined('T_TRAIT_C') === true) {
|
119 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_trait_cFound
|
120 |
-
$this->safeOperands[T_TRAIT_C] = T_TRAIT_C;
|
121 |
-
}
|
122 |
-
|
123 |
-
$emptyTokens = \PHP_CodeSniffer_Tokens::$emptyTokens;
|
124 |
-
$heredocTokens = \PHP_CodeSniffer_Tokens::$heredocTokens;
|
125 |
-
if (version_compare(PHPCSHelper::getVersion(), '2.0', '<')) {
|
126 |
-
// PHPCS 1.x compat.
|
127 |
-
$emptyTokens = array_combine($emptyTokens, $emptyTokens);
|
128 |
-
$heredocTokens = array_combine($heredocTokens, $heredocTokens);
|
129 |
-
}
|
130 |
-
|
131 |
-
$this->safeOperands = $this->safeOperands + $heredocTokens + $emptyTokens;
|
132 |
}
|
133 |
|
134 |
|
@@ -152,7 +138,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
152 |
*
|
153 |
* @return void|int Null or integer stack pointer to skip forward.
|
154 |
*/
|
155 |
-
public function process(
|
156 |
{
|
157 |
if ($this->bowOutEarly() === true) {
|
158 |
return;
|
@@ -185,7 +171,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
185 |
// Which nesting level is the one we are interested in ?
|
186 |
$nestedParenthesisCount = 1;
|
187 |
if (isset($tokens[$opener]['nested_parenthesis'])) {
|
188 |
-
$nestedParenthesisCount += count($tokens[$opener]['nested_parenthesis']);
|
189 |
}
|
190 |
|
191 |
foreach ($params as $param) {
|
@@ -194,7 +180,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
194 |
}
|
195 |
|
196 |
$end = $param['token'];
|
197 |
-
while (($end = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), ($end + 1), ($closer + 1))) !== false) {
|
198 |
$maybeSkipTo = $this->isRealEndOfDeclaration($tokens, $end, $nestedParenthesisCount);
|
199 |
if ($maybeSkipTo !== true) {
|
200 |
$end = $maybeSkipTo;
|
@@ -202,7 +188,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
202 |
}
|
203 |
|
204 |
// Ignore closing parenthesis/bracket if not 'ours'.
|
205 |
-
if ($tokens[$end]['code'] === T_CLOSE_PARENTHESIS && $end !== $closer) {
|
206 |
continue;
|
207 |
}
|
208 |
|
@@ -227,7 +213,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
227 |
$type = 'const';
|
228 |
|
229 |
// Filter out non-property declarations.
|
230 |
-
if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
|
231 |
if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
|
232 |
return;
|
233 |
}
|
@@ -239,16 +225,9 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
239 |
}
|
240 |
|
241 |
// Filter out late static binding and class properties.
|
242 |
-
if ($tokens[$stackPtr]['code'] === T_STATIC) {
|
243 |
-
$next = $phpcsFile->findNext(
|
244 |
-
|
245 |
-
($stackPtr + 1),
|
246 |
-
null,
|
247 |
-
true,
|
248 |
-
null,
|
249 |
-
true
|
250 |
-
);
|
251 |
-
if ($next === false || $tokens[$next]['code'] !== T_VARIABLE) {
|
252 |
// Late static binding.
|
253 |
return;
|
254 |
}
|
@@ -262,7 +241,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
262 |
$type = 'staticvar';
|
263 |
}
|
264 |
|
265 |
-
$endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr + 1));
|
266 |
if ($endOfStatement === false) {
|
267 |
// No semi-colon - live coding.
|
268 |
return;
|
@@ -270,13 +249,13 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
270 |
|
271 |
$targetNestingLevel = 0;
|
272 |
if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
|
273 |
-
$targetNestingLevel = count($tokens[$stackPtr]['nested_parenthesis']);
|
274 |
}
|
275 |
|
276 |
// Examine each variable/constant in multi-declarations.
|
277 |
$start = $stackPtr;
|
278 |
$end = $stackPtr;
|
279 |
-
while (($end = $phpcsFile->findNext(array(T_COMMA, T_SEMICOLON, T_OPEN_SHORT_ARRAY, T_CLOSE_TAG), ($end + 1), ($endOfStatement + 1))) !== false) {
|
280 |
|
281 |
$maybeSkipTo = $this->isRealEndOfDeclaration($tokens, $end, $targetNestingLevel);
|
282 |
if ($maybeSkipTo !== true) {
|
@@ -284,10 +263,10 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
284 |
continue;
|
285 |
}
|
286 |
|
287 |
-
$start = $phpcsFile->findNext(
|
288 |
if ($start === false
|
289 |
-
|| ($tokens[$stackPtr]['code'] === T_CONST && $tokens[$start]['code'] !== T_STRING)
|
290 |
-
|| ($tokens[$stackPtr]['code'] !== T_CONST && $tokens[$start]['code'] !== T_VARIABLE)
|
291 |
) {
|
292 |
// Shouldn't be possible.
|
293 |
continue;
|
@@ -325,11 +304,11 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
325 |
*
|
326 |
* @return bool
|
327 |
*/
|
328 |
-
protected function isValidAssignment(
|
329 |
{
|
330 |
$tokens = $phpcsFile->getTokens();
|
331 |
-
$next = $phpcsFile->findNext(
|
332 |
-
if ($next === false || $tokens[$next]['code'] !== T_EQUAL) {
|
333 |
// No value assigned.
|
334 |
return true;
|
335 |
}
|
@@ -352,7 +331,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
352 |
*
|
353 |
* @return bool
|
354 |
*/
|
355 |
-
protected function isStaticValue(
|
356 |
{
|
357 |
$nextNonSimple = $phpcsFile->findNext($this->safeOperands, $start, ($end + 1), true);
|
358 |
if ($nextNonSimple === false) {
|
@@ -363,8 +342,8 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
363 |
* OK, so we have at least one token which needs extra examination.
|
364 |
*/
|
365 |
switch ($tokens[$nextNonSimple]['code']) {
|
366 |
-
case T_MINUS:
|
367 |
-
case T_PLUS:
|
368 |
if ($this->isNumber($phpcsFile, $start, $end, true) !== false) {
|
369 |
// Int or float with sign.
|
370 |
return true;
|
@@ -372,39 +351,34 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
372 |
|
373 |
return false;
|
374 |
|
375 |
-
case T_NAMESPACE:
|
376 |
-
case T_PARENT:
|
377 |
-
case T_SELF:
|
378 |
-
case T_DOUBLE_COLON:
|
379 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
380 |
-
|
381 |
-
|
382 |
-
($end + 1),
|
383 |
-
true
|
384 |
-
);
|
385 |
-
|
386 |
-
if ($tokens[$nextNonSimple]['code'] === T_NAMESPACE) {
|
387 |
// Allow only `namespace\...`.
|
388 |
-
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_NS_SEPARATOR) {
|
389 |
return false;
|
390 |
}
|
391 |
-
} elseif ($tokens[$nextNonSimple]['code'] === T_PARENT
|
392 |
-
|| $tokens[$nextNonSimple]['code'] === T_SELF
|
393 |
) {
|
394 |
// Allow only `parent::` and `self::`.
|
395 |
-
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_DOUBLE_COLON) {
|
396 |
return false;
|
397 |
}
|
398 |
-
} elseif ($tokens[$nextNonSimple]['code'] === T_DOUBLE_COLON) {
|
399 |
// Allow only `T_STRING::T_STRING`.
|
400 |
-
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_STRING) {
|
401 |
return false;
|
402 |
}
|
403 |
|
404 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
405 |
// No need to worry about parent/self, that's handled above and
|
406 |
// the double colon is skipped over in that case.
|
407 |
-
if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['code'] !== T_STRING) {
|
408 |
return false;
|
409 |
}
|
410 |
}
|
@@ -412,8 +386,8 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
412 |
// Examine what comes after the namespace/parent/self/double colon, if anything.
|
413 |
return $this->isStaticValue($phpcsFile, $tokens, ($nextNonEmpty + 1), $end, $nestedArrays);
|
414 |
|
415 |
-
case T_ARRAY:
|
416 |
-
case T_OPEN_SHORT_ARRAY:
|
417 |
++$nestedArrays;
|
418 |
|
419 |
$arrayItems = $this->getFunctionCallParameters($phpcsFile, $nextNonSimple);
|
@@ -423,11 +397,11 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
423 |
$doubleArrow = false;
|
424 |
|
425 |
$maybeDoubleArrow = $phpcsFile->findNext(
|
426 |
-
array(T_DOUBLE_ARROW, T_ARRAY, T_OPEN_SHORT_ARRAY),
|
427 |
$item['start'],
|
428 |
($item['end'] + 1)
|
429 |
);
|
430 |
-
if ($maybeDoubleArrow !== false && $tokens[$maybeDoubleArrow]['code'] === T_DOUBLE_ARROW) {
|
431 |
// Double arrow is for this nesting level.
|
432 |
$doubleArrow = $maybeDoubleArrow;
|
433 |
}
|
@@ -459,18 +433,13 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
459 |
* able to get the array items.
|
460 |
*/
|
461 |
$closer = ($nextNonSimple + 1);
|
462 |
-
if ($tokens[$nextNonSimple]['code'] === T_OPEN_SHORT_ARRAY
|
463 |
&& isset($tokens[$nextNonSimple]['bracket_closer']) === true
|
464 |
) {
|
465 |
$closer = $tokens[$nextNonSimple]['bracket_closer'];
|
466 |
} else {
|
467 |
-
$maybeOpener = $phpcsFile->findNext(
|
468 |
-
|
469 |
-
($nextNonSimple + 1),
|
470 |
-
($end + 1),
|
471 |
-
true
|
472 |
-
);
|
473 |
-
if ($tokens[$maybeOpener]['code'] === T_OPEN_PARENTHESIS) {
|
474 |
$opener = $maybeOpener;
|
475 |
if (isset($tokens[$opener]['parenthesis_closer']) === true) {
|
476 |
$closer = $tokens[$opener]['parenthesis_closer'];
|
@@ -502,7 +471,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
502 |
*
|
503 |
* @return void
|
504 |
*/
|
505 |
-
protected function throwError(
|
506 |
{
|
507 |
$error = static::ERROR_PHRASE;
|
508 |
$phrase = '';
|
@@ -539,7 +508,7 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
539 |
private function isRealEndOfDeclaration($tokens, $endPtr, $targetLevel)
|
540 |
{
|
541 |
// Ignore anything within short array definition brackets for now.
|
542 |
-
if ($tokens[$endPtr]['code'] === T_OPEN_SHORT_ARRAY
|
543 |
&& (isset($tokens[$endPtr]['bracket_opener'])
|
544 |
&& $tokens[$endPtr]['bracket_opener'] === $endPtr)
|
545 |
&& isset($tokens[$endPtr]['bracket_closer'])
|
@@ -549,11 +518,11 @@ class NewConstantScalarExpressionsSniff extends Sniff
|
|
549 |
}
|
550 |
|
551 |
// Skip past comma's at a lower nesting level.
|
552 |
-
if ($tokens[$endPtr]['code'] === T_COMMA) {
|
553 |
// Check if a comma is at the nesting level we're targetting.
|
554 |
$nestingLevel = 0;
|
555 |
if (isset($tokens[$endPtr]['nested_parenthesis']) === true) {
|
556 |
-
$nestingLevel = count($tokens[$endPtr]['nested_parenthesis']);
|
557 |
}
|
558 |
if ($nestingLevel > $targetLevel) {
|
559 |
return $endPtr;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewConstantScalarExpressionsSniff.
|
4 |
*
|
5 |
* PHP version 5.6
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\InitialValue;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewConstantScalarExpressionsSniff.
|
21 |
*
|
22 |
* Since PHP 5.6, it is now possible to provide a scalar expression involving
|
23 |
* numeric and string literals and/or constants in contexts where PHP previously
|
60 |
* @var array
|
61 |
*/
|
62 |
protected $safeOperands = array(
|
63 |
+
\T_LNUMBER => \T_LNUMBER,
|
64 |
+
\T_DNUMBER => \T_DNUMBER,
|
65 |
+
\T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING,
|
66 |
+
\T_TRUE => \T_TRUE,
|
67 |
+
\T_FALSE => \T_FALSE,
|
68 |
+
\T_NULL => \T_NULL,
|
69 |
+
|
70 |
+
\T_LINE => \T_LINE,
|
71 |
+
\T_FILE => \T_FILE,
|
72 |
+
\T_DIR => \T_DIR,
|
73 |
+
\T_FUNC_C => \T_FUNC_C,
|
74 |
+
\T_CLASS_C => \T_CLASS_C,
|
75 |
+
\T_TRAIT_C => \T_TRAIT_C,
|
76 |
+
\T_METHOD_C => \T_METHOD_C,
|
77 |
+
\T_NS_C => \T_NS_C,
|
78 |
|
79 |
// Special cases:
|
80 |
+
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
|
81 |
/*
|
82 |
* This can be neigh anything, but for any usage except constants,
|
83 |
* the T_STRING will be combined with non-allowed tokens, so we should be good.
|
84 |
*/
|
85 |
+
\T_STRING => \T_STRING,
|
86 |
);
|
87 |
|
88 |
|
97 |
$this->setProperties();
|
98 |
|
99 |
return array(
|
100 |
+
\T_CONST,
|
101 |
+
\T_VARIABLE,
|
102 |
+
\T_FUNCTION,
|
103 |
+
\T_CLOSURE,
|
104 |
+
\T_STATIC,
|
105 |
);
|
106 |
}
|
107 |
|
113 |
*/
|
114 |
public function setProperties()
|
115 |
{
|
116 |
+
$this->safeOperands += Tokens::$heredocTokens;
|
117 |
+
$this->safeOperands += Tokens::$emptyTokens;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
|
138 |
*
|
139 |
* @return void|int Null or integer stack pointer to skip forward.
|
140 |
*/
|
141 |
+
public function process(File $phpcsFile, $stackPtr)
|
142 |
{
|
143 |
if ($this->bowOutEarly() === true) {
|
144 |
return;
|
171 |
// Which nesting level is the one we are interested in ?
|
172 |
$nestedParenthesisCount = 1;
|
173 |
if (isset($tokens[$opener]['nested_parenthesis'])) {
|
174 |
+
$nestedParenthesisCount += \count($tokens[$opener]['nested_parenthesis']);
|
175 |
}
|
176 |
|
177 |
foreach ($params as $param) {
|
180 |
}
|
181 |
|
182 |
$end = $param['token'];
|
183 |
+
while (($end = $phpcsFile->findNext(array(\T_COMMA, \T_CLOSE_PARENTHESIS), ($end + 1), ($closer + 1))) !== false) {
|
184 |
$maybeSkipTo = $this->isRealEndOfDeclaration($tokens, $end, $nestedParenthesisCount);
|
185 |
if ($maybeSkipTo !== true) {
|
186 |
$end = $maybeSkipTo;
|
188 |
}
|
189 |
|
190 |
// Ignore closing parenthesis/bracket if not 'ours'.
|
191 |
+
if ($tokens[$end]['code'] === \T_CLOSE_PARENTHESIS && $end !== $closer) {
|
192 |
continue;
|
193 |
}
|
194 |
|
213 |
$type = 'const';
|
214 |
|
215 |
// Filter out non-property declarations.
|
216 |
+
if ($tokens[$stackPtr]['code'] === \T_VARIABLE) {
|
217 |
if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
|
218 |
return;
|
219 |
}
|
225 |
}
|
226 |
|
227 |
// Filter out late static binding and class properties.
|
228 |
+
if ($tokens[$stackPtr]['code'] === \T_STATIC) {
|
229 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
230 |
+
if ($next === false || $tokens[$next]['code'] !== \T_VARIABLE) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
// Late static binding.
|
232 |
return;
|
233 |
}
|
241 |
$type = 'staticvar';
|
242 |
}
|
243 |
|
244 |
+
$endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1));
|
245 |
if ($endOfStatement === false) {
|
246 |
// No semi-colon - live coding.
|
247 |
return;
|
249 |
|
250 |
$targetNestingLevel = 0;
|
251 |
if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
|
252 |
+
$targetNestingLevel = \count($tokens[$stackPtr]['nested_parenthesis']);
|
253 |
}
|
254 |
|
255 |
// Examine each variable/constant in multi-declarations.
|
256 |
$start = $stackPtr;
|
257 |
$end = $stackPtr;
|
258 |
+
while (($end = $phpcsFile->findNext(array(\T_COMMA, \T_SEMICOLON, \T_OPEN_SHORT_ARRAY, \T_CLOSE_TAG), ($end + 1), ($endOfStatement + 1))) !== false) {
|
259 |
|
260 |
$maybeSkipTo = $this->isRealEndOfDeclaration($tokens, $end, $targetNestingLevel);
|
261 |
if ($maybeSkipTo !== true) {
|
263 |
continue;
|
264 |
}
|
265 |
|
266 |
+
$start = $phpcsFile->findNext(Tokens::$emptyTokens, ($start + 1), $end, true);
|
267 |
if ($start === false
|
268 |
+
|| ($tokens[$stackPtr]['code'] === \T_CONST && $tokens[$start]['code'] !== \T_STRING)
|
269 |
+
|| ($tokens[$stackPtr]['code'] !== \T_CONST && $tokens[$start]['code'] !== \T_VARIABLE)
|
270 |
) {
|
271 |
// Shouldn't be possible.
|
272 |
continue;
|
304 |
*
|
305 |
* @return bool
|
306 |
*/
|
307 |
+
protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
|
308 |
{
|
309 |
$tokens = $phpcsFile->getTokens();
|
310 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
|
311 |
+
if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
|
312 |
// No value assigned.
|
313 |
return true;
|
314 |
}
|
331 |
*
|
332 |
* @return bool
|
333 |
*/
|
334 |
+
protected function isStaticValue(File $phpcsFile, $tokens, $start, $end, $nestedArrays = 0)
|
335 |
{
|
336 |
$nextNonSimple = $phpcsFile->findNext($this->safeOperands, $start, ($end + 1), true);
|
337 |
if ($nextNonSimple === false) {
|
342 |
* OK, so we have at least one token which needs extra examination.
|
343 |
*/
|
344 |
switch ($tokens[$nextNonSimple]['code']) {
|
345 |
+
case \T_MINUS:
|
346 |
+
case \T_PLUS:
|
347 |
if ($this->isNumber($phpcsFile, $start, $end, true) !== false) {
|
348 |
// Int or float with sign.
|
349 |
return true;
|
351 |
|
352 |
return false;
|
353 |
|
354 |
+
case \T_NAMESPACE:
|
355 |
+
case \T_PARENT:
|
356 |
+
case \T_SELF:
|
357 |
+
case \T_DOUBLE_COLON:
|
358 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonSimple + 1), ($end + 1), true);
|
359 |
+
|
360 |
+
if ($tokens[$nextNonSimple]['code'] === \T_NAMESPACE) {
|
|
|
|
|
|
|
|
|
|
|
361 |
// Allow only `namespace\...`.
|
362 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_NS_SEPARATOR) {
|
363 |
return false;
|
364 |
}
|
365 |
+
} elseif ($tokens[$nextNonSimple]['code'] === \T_PARENT
|
366 |
+
|| $tokens[$nextNonSimple]['code'] === \T_SELF
|
367 |
) {
|
368 |
// Allow only `parent::` and `self::`.
|
369 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
|
370 |
return false;
|
371 |
}
|
372 |
+
} elseif ($tokens[$nextNonSimple]['code'] === \T_DOUBLE_COLON) {
|
373 |
// Allow only `T_STRING::T_STRING`.
|
374 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
|
375 |
return false;
|
376 |
}
|
377 |
|
378 |
+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextNonSimple - 1), null, true);
|
379 |
// No need to worry about parent/self, that's handled above and
|
380 |
// the double colon is skipped over in that case.
|
381 |
+
if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['code'] !== \T_STRING) {
|
382 |
return false;
|
383 |
}
|
384 |
}
|
386 |
// Examine what comes after the namespace/parent/self/double colon, if anything.
|
387 |
return $this->isStaticValue($phpcsFile, $tokens, ($nextNonEmpty + 1), $end, $nestedArrays);
|
388 |
|
389 |
+
case \T_ARRAY:
|
390 |
+
case \T_OPEN_SHORT_ARRAY:
|
391 |
++$nestedArrays;
|
392 |
|
393 |
$arrayItems = $this->getFunctionCallParameters($phpcsFile, $nextNonSimple);
|
397 |
$doubleArrow = false;
|
398 |
|
399 |
$maybeDoubleArrow = $phpcsFile->findNext(
|
400 |
+
array(\T_DOUBLE_ARROW, \T_ARRAY, \T_OPEN_SHORT_ARRAY),
|
401 |
$item['start'],
|
402 |
($item['end'] + 1)
|
403 |
);
|
404 |
+
if ($maybeDoubleArrow !== false && $tokens[$maybeDoubleArrow]['code'] === \T_DOUBLE_ARROW) {
|
405 |
// Double arrow is for this nesting level.
|
406 |
$doubleArrow = $maybeDoubleArrow;
|
407 |
}
|
433 |
* able to get the array items.
|
434 |
*/
|
435 |
$closer = ($nextNonSimple + 1);
|
436 |
+
if ($tokens[$nextNonSimple]['code'] === \T_OPEN_SHORT_ARRAY
|
437 |
&& isset($tokens[$nextNonSimple]['bracket_closer']) === true
|
438 |
) {
|
439 |
$closer = $tokens[$nextNonSimple]['bracket_closer'];
|
440 |
} else {
|
441 |
+
$maybeOpener = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonSimple + 1), ($end + 1), true);
|
442 |
+
if ($tokens[$maybeOpener]['code'] === \T_OPEN_PARENTHESIS) {
|
|
|
|
|
|
|
|
|
|
|
443 |
$opener = $maybeOpener;
|
444 |
if (isset($tokens[$opener]['parenthesis_closer']) === true) {
|
445 |
$closer = $tokens[$opener]['parenthesis_closer'];
|
471 |
*
|
472 |
* @return void
|
473 |
*/
|
474 |
+
protected function throwError(File $phpcsFile, $stackPtr, $type, $content = '')
|
475 |
{
|
476 |
$error = static::ERROR_PHRASE;
|
477 |
$phrase = '';
|
508 |
private function isRealEndOfDeclaration($tokens, $endPtr, $targetLevel)
|
509 |
{
|
510 |
// Ignore anything within short array definition brackets for now.
|
511 |
+
if ($tokens[$endPtr]['code'] === \T_OPEN_SHORT_ARRAY
|
512 |
&& (isset($tokens[$endPtr]['bracket_opener'])
|
513 |
&& $tokens[$endPtr]['bracket_opener'] === $endPtr)
|
514 |
&& isset($tokens[$endPtr]['bracket_closer'])
|
518 |
}
|
519 |
|
520 |
// Skip past comma's at a lower nesting level.
|
521 |
+
if ($tokens[$endPtr]['code'] === \T_COMMA) {
|
522 |
// Check if a comma is at the nesting level we're targetting.
|
523 |
$nestingLevel = 0;
|
524 |
if (isset($tokens[$endPtr]['nested_parenthesis']) === true) {
|
525 |
+
$nestingLevel = \count($tokens[$endPtr]['nested_parenthesis']);
|
526 |
}
|
527 |
if ($nestingLevel > $targetLevel) {
|
528 |
return $endPtr;
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewHeredocInitializeSniff.php → InitialValue/NewHeredocSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
-
use PHPCompatibility\Sniffs\
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* As of PHP 5.3.0, it's possible to initialize static variables, class properties
|
20 |
* and constants declared using the `const` keyword, using the Heredoc syntax.
|
@@ -30,7 +32,7 @@ use PHPCompatibility\Sniffs\PHP\NewConstantScalarExpressionsSniff;
|
|
30 |
* @package PHPCompatibility
|
31 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
32 |
*/
|
33 |
-
class
|
34 |
{
|
35 |
|
36 |
/**
|
@@ -74,15 +76,15 @@ class NewHeredocInitializeSniff extends NewConstantScalarExpressionsSniff
|
|
74 |
*
|
75 |
* @return bool True if no heredoc (or assignment) is found, false otherwise.
|
76 |
*/
|
77 |
-
protected function isValidAssignment(
|
78 |
{
|
79 |
$tokens = $phpcsFile->getTokens();
|
80 |
-
$next = $phpcsFile->findNext(
|
81 |
-
if ($next === false || $tokens[$next]['code'] !== T_EQUAL) {
|
82 |
// No value assigned.
|
83 |
return true;
|
84 |
}
|
85 |
|
86 |
-
return ($phpcsFile->findNext(T_START_HEREDOC, ($next + 1), $end, false, null, true) === false);
|
87 |
}
|
88 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewHeredocSniff.
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\InitialValue;
|
13 |
|
14 |
+
use PHPCompatibility\Sniffs\InitialValue\NewConstantScalarExpressionsSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\InitialValue\NewHeredocSniff.
|
20 |
*
|
21 |
* As of PHP 5.3.0, it's possible to initialize static variables, class properties
|
22 |
* and constants declared using the `const` keyword, using the Heredoc syntax.
|
32 |
* @package PHPCompatibility
|
33 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
34 |
*/
|
35 |
+
class NewHeredocSniff extends NewConstantScalarExpressionsSniff
|
36 |
{
|
37 |
|
38 |
/**
|
76 |
*
|
77 |
* @return bool True if no heredoc (or assignment) is found, false otherwise.
|
78 |
*/
|
79 |
+
protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
|
80 |
{
|
81 |
$tokens = $phpcsFile->getTokens();
|
82 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
|
83 |
+
if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
|
84 |
// No value assigned.
|
85 |
return true;
|
86 |
}
|
87 |
|
88 |
+
return ($phpcsFile->findNext(\T_START_HEREDOC, ($next + 1), $end, false, null, true) === false);
|
89 |
}
|
90 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Interfaces}/InternalInterfacesSniff.php
RENAMED
@@ -1,19 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\Sniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
@@ -46,16 +47,14 @@ class InternalInterfacesSniff extends Sniff
|
|
46 |
// Handle case-insensitivity of interface names.
|
47 |
$this->internalInterfaces = $this->arrayKeysToLowercase($this->internalInterfaces);
|
48 |
|
49 |
-
$targets = array(T_CLASS);
|
50 |
|
51 |
-
if (defined('T_ANON_CLASS')) {
|
52 |
-
|
53 |
-
$targets[] = T_ANON_CLASS;
|
54 |
}
|
55 |
|
56 |
return $targets;
|
57 |
-
|
58 |
-
}//end register()
|
59 |
|
60 |
|
61 |
/**
|
@@ -67,15 +66,16 @@ class InternalInterfacesSniff extends Sniff
|
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
-
public function process(
|
71 |
{
|
72 |
$interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);
|
73 |
|
74 |
-
if (is_array($interfaces) === false || $interfaces === array()) {
|
75 |
return;
|
76 |
}
|
77 |
|
78 |
foreach ($interfaces as $interface) {
|
|
|
79 |
$interfaceLc = strtolower($interface);
|
80 |
if (isset($this->internalInterfaces[$interfaceLc]) === true) {
|
81 |
$error = 'The interface %s %s';
|
@@ -88,8 +88,5 @@ class InternalInterfacesSniff extends Sniff
|
|
88 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
89 |
}
|
90 |
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Interfaces\InternalInterfacesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\Interfaces;
|
11 |
|
12 |
use PHPCompatibility\Sniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\Interfaces\InternalInterfacesSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
47 |
// Handle case-insensitivity of interface names.
|
48 |
$this->internalInterfaces = $this->arrayKeysToLowercase($this->internalInterfaces);
|
49 |
|
50 |
+
$targets = array(\T_CLASS);
|
51 |
|
52 |
+
if (\defined('T_ANON_CLASS')) {
|
53 |
+
$targets[] = \T_ANON_CLASS;
|
|
|
54 |
}
|
55 |
|
56 |
return $targets;
|
57 |
+
}
|
|
|
58 |
|
59 |
|
60 |
/**
|
66 |
*
|
67 |
* @return void
|
68 |
*/
|
69 |
+
public function process(File $phpcsFile, $stackPtr)
|
70 |
{
|
71 |
$interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);
|
72 |
|
73 |
+
if (\is_array($interfaces) === false || $interfaces === array()) {
|
74 |
return;
|
75 |
}
|
76 |
|
77 |
foreach ($interfaces as $interface) {
|
78 |
+
$interface = ltrim($interface, '\\');
|
79 |
$interfaceLc = strtolower($interface);
|
80 |
if (isset($this->internalInterfaces[$interfaceLc]) === true) {
|
81 |
$error = 'The interface %s %s';
|
88 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
89 |
}
|
90 |
}
|
91 |
+
}
|
92 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Interfaces}/NewInterfacesSniff.php
RENAMED
@@ -1,19 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
@@ -83,11 +84,19 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
83 |
'5.5' => true,
|
84 |
),
|
85 |
|
|
|
|
|
|
|
|
|
|
|
86 |
'Throwable' => array(
|
87 |
'5.6' => false,
|
88 |
'7.0' => true,
|
89 |
),
|
90 |
-
|
|
|
|
|
|
|
91 |
);
|
92 |
|
93 |
/**
|
@@ -114,23 +123,21 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
114 |
$this->unsupportedMethods = $this->arrayKeysToLowercase($this->unsupportedMethods);
|
115 |
|
116 |
$targets = array(
|
117 |
-
T_CLASS,
|
118 |
-
T_FUNCTION,
|
119 |
-
T_CLOSURE,
|
120 |
);
|
121 |
|
122 |
-
if (defined('T_ANON_CLASS')) {
|
123 |
-
|
124 |
-
$targets[] = T_ANON_CLASS;
|
125 |
}
|
126 |
|
127 |
-
if (defined('T_RETURN_TYPE')) {
|
128 |
-
$targets[] = T_RETURN_TYPE;
|
129 |
}
|
130 |
|
131 |
return $targets;
|
132 |
-
|
133 |
-
}//end register()
|
134 |
|
135 |
|
136 |
/**
|
@@ -142,7 +149,7 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
142 |
*
|
143 |
* @return void
|
144 |
*/
|
145 |
-
public function process(
|
146 |
{
|
147 |
$tokens = $phpcsFile->getTokens();
|
148 |
|
@@ -172,8 +179,7 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
172 |
// Deliberately left empty.
|
173 |
break;
|
174 |
}
|
175 |
-
|
176 |
-
}//end process()
|
177 |
|
178 |
|
179 |
/**
|
@@ -188,11 +194,11 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
188 |
*
|
189 |
* @return void
|
190 |
*/
|
191 |
-
private function processClassToken(
|
192 |
{
|
193 |
$interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);
|
194 |
|
195 |
-
if (is_array($interfaces) === false || $interfaces === array()) {
|
196 |
return;
|
197 |
}
|
198 |
|
@@ -205,6 +211,7 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
205 |
}
|
206 |
|
207 |
foreach ($interfaces as $interface) {
|
|
|
208 |
$interfaceLc = strtolower($interface);
|
209 |
|
210 |
if (isset($this->newInterfaces[$interfaceLc]) === true) {
|
@@ -217,7 +224,7 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
217 |
|
218 |
if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
|
219 |
$nextFunc = $stackPtr;
|
220 |
-
while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
|
221 |
$funcName = $phpcsFile->getDeclarationName($nextFunc);
|
222 |
$funcNameLc = strtolower($funcName);
|
223 |
if ($funcNameLc === '') {
|
@@ -238,7 +245,7 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
238 |
}
|
239 |
}
|
240 |
}
|
241 |
-
}
|
242 |
|
243 |
|
244 |
/**
|
@@ -252,10 +259,10 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
252 |
*
|
253 |
* @return void
|
254 |
*/
|
255 |
-
private function processFunctionToken(
|
256 |
{
|
257 |
$typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
|
258 |
-
if (empty($typeHints) || is_array($typeHints) === false) {
|
259 |
return;
|
260 |
}
|
261 |
|
@@ -285,7 +292,7 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
285 |
*
|
286 |
* @return void
|
287 |
*/
|
288 |
-
private function processReturnTypeToken(
|
289 |
{
|
290 |
$returnTypeHint = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
|
291 |
$returnTypeHint = ltrim($returnTypeHint, '\\');
|
@@ -326,6 +333,4 @@ class NewInterfacesSniff extends AbstractNewFeatureSniff
|
|
326 |
{
|
327 |
return 'The built-in interface ' . parent::getErrorMsgTemplate();
|
328 |
}
|
329 |
-
|
330 |
-
|
331 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Interfaces\NewInterfacesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\Interfaces;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\Interfaces\NewInterfacesSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
84 |
'5.5' => true,
|
85 |
),
|
86 |
|
87 |
+
'SessionIdInterface' => array(
|
88 |
+
'5.5.0' => false,
|
89 |
+
'5.5.1' => true,
|
90 |
+
),
|
91 |
+
|
92 |
'Throwable' => array(
|
93 |
'5.6' => false,
|
94 |
'7.0' => true,
|
95 |
),
|
96 |
+
'SessionUpdateTimestampHandlerInterface' => array(
|
97 |
+
'5.6' => false,
|
98 |
+
'7.0' => true,
|
99 |
+
),
|
100 |
);
|
101 |
|
102 |
/**
|
123 |
$this->unsupportedMethods = $this->arrayKeysToLowercase($this->unsupportedMethods);
|
124 |
|
125 |
$targets = array(
|
126 |
+
\T_CLASS,
|
127 |
+
\T_FUNCTION,
|
128 |
+
\T_CLOSURE,
|
129 |
);
|
130 |
|
131 |
+
if (\defined('T_ANON_CLASS')) {
|
132 |
+
$targets[] = \T_ANON_CLASS;
|
|
|
133 |
}
|
134 |
|
135 |
+
if (\defined('T_RETURN_TYPE')) {
|
136 |
+
$targets[] = \T_RETURN_TYPE;
|
137 |
}
|
138 |
|
139 |
return $targets;
|
140 |
+
}
|
|
|
141 |
|
142 |
|
143 |
/**
|
149 |
*
|
150 |
* @return void
|
151 |
*/
|
152 |
+
public function process(File $phpcsFile, $stackPtr)
|
153 |
{
|
154 |
$tokens = $phpcsFile->getTokens();
|
155 |
|
179 |
// Deliberately left empty.
|
180 |
break;
|
181 |
}
|
182 |
+
}
|
|
|
183 |
|
184 |
|
185 |
/**
|
194 |
*
|
195 |
* @return void
|
196 |
*/
|
197 |
+
private function processClassToken(File $phpcsFile, $stackPtr)
|
198 |
{
|
199 |
$interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);
|
200 |
|
201 |
+
if (\is_array($interfaces) === false || $interfaces === array()) {
|
202 |
return;
|
203 |
}
|
204 |
|
211 |
}
|
212 |
|
213 |
foreach ($interfaces as $interface) {
|
214 |
+
$interface = ltrim($interface, '\\');
|
215 |
$interfaceLc = strtolower($interface);
|
216 |
|
217 |
if (isset($this->newInterfaces[$interfaceLc]) === true) {
|
224 |
|
225 |
if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
|
226 |
$nextFunc = $stackPtr;
|
227 |
+
while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
|
228 |
$funcName = $phpcsFile->getDeclarationName($nextFunc);
|
229 |
$funcNameLc = strtolower($funcName);
|
230 |
if ($funcNameLc === '') {
|
245 |
}
|
246 |
}
|
247 |
}
|
248 |
+
}
|
249 |
|
250 |
|
251 |
/**
|
259 |
*
|
260 |
* @return void
|
261 |
*/
|
262 |
+
private function processFunctionToken(File $phpcsFile, $stackPtr)
|
263 |
{
|
264 |
$typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
|
265 |
+
if (empty($typeHints) || \is_array($typeHints) === false) {
|
266 |
return;
|
267 |
}
|
268 |
|
292 |
*
|
293 |
* @return void
|
294 |
*/
|
295 |
+
private function processReturnTypeToken(File $phpcsFile, $stackPtr)
|
296 |
{
|
297 |
$returnTypeHint = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
|
298 |
$returnTypeHint = ltrim($returnTypeHint, '\\');
|
333 |
{
|
334 |
return 'The built-in interface ' . parent::getErrorMsgTemplate();
|
335 |
}
|
336 |
+
}
|
|
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords}/CaseSensitiveKeywordsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Prior to PHP 5.5, cases existed where the self, parent, and static keywords
|
20 |
* were treated in a case sensitive fashion.
|
@@ -36,9 +37,9 @@ class CaseSensitiveKeywordsSniff extends Sniff
|
|
36 |
public function register()
|
37 |
{
|
38 |
return array(
|
39 |
-
T_SELF,
|
40 |
-
T_STATIC,
|
41 |
-
T_PARENT,
|
42 |
);
|
43 |
}
|
44 |
|
@@ -51,7 +52,7 @@ class CaseSensitiveKeywordsSniff extends Sniff
|
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
-
public function process(
|
55 |
{
|
56 |
if ($this->supportsBelow('5.4') === false) {
|
57 |
return;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Keywords\CaseSensitiveKeywordsSniff.
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Keywords;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Keywords\CaseSensitiveKeywordsSniff.
|
19 |
*
|
20 |
* Prior to PHP 5.5, cases existed where the self, parent, and static keywords
|
21 |
* were treated in a case sensitive fashion.
|
37 |
public function register()
|
38 |
{
|
39 |
return array(
|
40 |
+
\T_SELF,
|
41 |
+
\T_STATIC,
|
42 |
+
\T_PARENT,
|
43 |
);
|
44 |
}
|
45 |
|
52 |
*
|
53 |
* @return void
|
54 |
*/
|
55 |
+
public function process(File $phpcsFile, $stackPtr)
|
56 |
{
|
57 |
if ($this->supportsBelow('5.4') === false) {
|
58 |
return;
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Keywords}/ForbiddenNamesAsDeclaredSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0+
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Prohibits the use of some reserved keywords to name a class, interface, trait or namespace.
|
20 |
* Emits errors for reserved words and warnings for soft-reserved words.
|
@@ -36,9 +38,9 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
36 |
* @var array
|
37 |
*/
|
38 |
protected $forbiddenTokens = array(
|
39 |
-
T_NULL => '7.0',
|
40 |
-
T_TRUE => '7.0',
|
41 |
-
T_FALSE => '7.0',
|
42 |
);
|
43 |
|
44 |
/**
|
@@ -97,20 +99,15 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
97 |
$this->allForbiddenNames = array_merge($this->forbiddenNames, $this->softReservedNames);
|
98 |
|
99 |
$targets = array(
|
100 |
-
T_CLASS,
|
101 |
-
T_INTERFACE,
|
102 |
-
|
103 |
-
|
|
|
104 |
);
|
105 |
|
106 |
-
if (defined('T_TRAIT')) {
|
107 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_traitFound
|
108 |
-
$targets[] = T_TRAIT;
|
109 |
-
}
|
110 |
-
|
111 |
return $targets;
|
112 |
-
|
113 |
-
}//end register()
|
114 |
|
115 |
|
116 |
/**
|
@@ -122,7 +119,7 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
122 |
*
|
123 |
* @return void
|
124 |
*/
|
125 |
-
public function process(
|
126 |
{
|
127 |
if ($this->supportsAbove('7.0') === false) {
|
128 |
return;
|
@@ -136,13 +133,13 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
136 |
// For string tokens we only care about 'trait' as that is the only one
|
137 |
// which may not be correctly recognized as it's own token.
|
138 |
// This only happens in older versions of PHP where the token doesn't exist yet as a keyword.
|
139 |
-
if ($tokenCode === T_STRING && $tokenContentLc !== 'trait') {
|
140 |
return;
|
141 |
}
|
142 |
|
143 |
-
if (in_array($tokenType, array('T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
|
144 |
// Check for the declared name being a name which is not tokenized as T_STRING.
|
145 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
146 |
if ($nextNonEmpty !== false && isset($this->forbiddenTokens[$tokens[$nextNonEmpty]['code']]) === true) {
|
147 |
$name = $tokens[$nextNonEmpty]['content'];
|
148 |
} else {
|
@@ -151,7 +148,7 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
151 |
}
|
152 |
unset($nextNonEmpty);
|
153 |
|
154 |
-
if (isset($name) === false || is_string($name) === false || $name === '') {
|
155 |
return;
|
156 |
}
|
157 |
|
@@ -160,7 +157,7 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
160 |
return;
|
161 |
}
|
162 |
|
163 |
-
} elseif ($tokenCode === T_NAMESPACE) {
|
164 |
$namespaceName = $this->getDeclaredNamespaceName($phpcsFile, $stackPtr);
|
165 |
|
166 |
if ($namespaceName === false || $namespaceName === '') {
|
@@ -176,20 +173,20 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
176 |
break;
|
177 |
}
|
178 |
}
|
179 |
-
} elseif ($tokenCode === T_STRING) {
|
180 |
// Traits which are not yet tokenized as T_TRAIT.
|
181 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
182 |
if ($nextNonEmpty === false) {
|
183 |
return;
|
184 |
}
|
185 |
|
186 |
$nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
|
187 |
|
188 |
-
if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
|
189 |
$name = $tokens[$nextNonEmpty]['content'];
|
190 |
$nameLc = strtolower($tokens[$nextNonEmpty]['content']);
|
191 |
-
} elseif ($nextNonEmptyCode === T_STRING) {
|
192 |
-
$endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
|
193 |
if ($endOfStatement === false) {
|
194 |
return;
|
195 |
}
|
@@ -203,7 +200,7 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
203 |
break;
|
204 |
}
|
205 |
|
206 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
207 |
} while ($nextNonEmpty !== false);
|
208 |
}
|
209 |
unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
|
@@ -247,7 +244,5 @@ class ForbiddenNamesAsDeclaredSniff extends Sniff
|
|
247 |
|
248 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
249 |
}
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Keywords\ForbiddenNamesAsDeclaredClassSniff.
|
4 |
*
|
5 |
* PHP version 7.0+
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Keywords;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Keywords\ForbiddenNamesAsDeclaredClassSniff.
|
20 |
*
|
21 |
* Prohibits the use of some reserved keywords to name a class, interface, trait or namespace.
|
22 |
* Emits errors for reserved words and warnings for soft-reserved words.
|
38 |
* @var array
|
39 |
*/
|
40 |
protected $forbiddenTokens = array(
|
41 |
+
\T_NULL => '7.0',
|
42 |
+
\T_TRUE => '7.0',
|
43 |
+
\T_FALSE => '7.0',
|
44 |
);
|
45 |
|
46 |
/**
|
99 |
$this->allForbiddenNames = array_merge($this->forbiddenNames, $this->softReservedNames);
|
100 |
|
101 |
$targets = array(
|
102 |
+
\T_CLASS,
|
103 |
+
\T_INTERFACE,
|
104 |
+
\T_TRAIT,
|
105 |
+
\T_NAMESPACE,
|
106 |
+
\T_STRING, // Compat for PHPCS < 2.4.0 and PHP < 5.3.
|
107 |
);
|
108 |
|
|
|
|
|
|
|
|
|
|
|
109 |
return $targets;
|
110 |
+
}
|
|
|
111 |
|
112 |
|
113 |
/**
|
119 |
*
|
120 |
* @return void
|
121 |
*/
|
122 |
+
public function process(File $phpcsFile, $stackPtr)
|
123 |
{
|
124 |
if ($this->supportsAbove('7.0') === false) {
|
125 |
return;
|
133 |
// For string tokens we only care about 'trait' as that is the only one
|
134 |
// which may not be correctly recognized as it's own token.
|
135 |
// This only happens in older versions of PHP where the token doesn't exist yet as a keyword.
|
136 |
+
if ($tokenCode === \T_STRING && $tokenContentLc !== 'trait') {
|
137 |
return;
|
138 |
}
|
139 |
|
140 |
+
if (\in_array($tokenType, array('T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
|
141 |
// Check for the declared name being a name which is not tokenized as T_STRING.
|
142 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
143 |
if ($nextNonEmpty !== false && isset($this->forbiddenTokens[$tokens[$nextNonEmpty]['code']]) === true) {
|
144 |
$name = $tokens[$nextNonEmpty]['content'];
|
145 |
} else {
|
148 |
}
|
149 |
unset($nextNonEmpty);
|
150 |
|
151 |
+
if (isset($name) === false || \is_string($name) === false || $name === '') {
|
152 |
return;
|
153 |
}
|
154 |
|
157 |
return;
|
158 |
}
|
159 |
|
160 |
+
} elseif ($tokenCode === \T_NAMESPACE) {
|
161 |
$namespaceName = $this->getDeclaredNamespaceName($phpcsFile, $stackPtr);
|
162 |
|
163 |
if ($namespaceName === false || $namespaceName === '') {
|
173 |
break;
|
174 |
}
|
175 |
}
|
176 |
+
} elseif ($tokenCode === \T_STRING) {
|
177 |
// Traits which are not yet tokenized as T_TRAIT.
|
178 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
179 |
if ($nextNonEmpty === false) {
|
180 |
return;
|
181 |
}
|
182 |
|
183 |
$nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
|
184 |
|
185 |
+
if ($nextNonEmptyCode !== \T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
|
186 |
$name = $tokens[$nextNonEmpty]['content'];
|
187 |
$nameLc = strtolower($tokens[$nextNonEmpty]['content']);
|
188 |
+
} elseif ($nextNonEmptyCode === \T_STRING) {
|
189 |
+
$endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
|
190 |
if ($endOfStatement === false) {
|
191 |
return;
|
192 |
}
|
200 |
break;
|
201 |
}
|
202 |
|
203 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
|
204 |
} while ($nextNonEmpty !== false);
|
205 |
}
|
206 |
unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
|
244 |
|
245 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
246 |
}
|
247 |
+
}
|
248 |
+
}
|
|
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords}/ForbiddenNamesAsInvokedFunctionsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,12 +8,14 @@
|
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\Sniff;
|
|
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* Prohibits the use of reserved keywords invoked as functions.
|
19 |
*
|
@@ -31,19 +33,23 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
31 |
* @var array
|
32 |
*/
|
33 |
protected $targetedTokens = array(
|
34 |
-
T_ABSTRACT
|
35 |
-
T_CALLABLE
|
36 |
-
T_CATCH
|
37 |
-
T_FINAL
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
);
|
48 |
|
49 |
/**
|
@@ -81,21 +87,11 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
81 |
*/
|
82 |
public function register()
|
83 |
{
|
84 |
-
if (defined('T_FINALLY')) {
|
85 |
-
$this->targetedTokens[T_FINALLY] = '5.5';
|
86 |
-
}
|
87 |
-
if (defined('T_INSTEADOF')) {
|
88 |
-
$this->targetedTokens[T_INSTEADOF] = '5.4';
|
89 |
-
}
|
90 |
-
if (defined('T_TRAIT')) {
|
91 |
-
$this->targetedTokens[T_TRAIT] = '5.4';
|
92 |
-
}
|
93 |
-
|
94 |
$tokens = array_keys($this->targetedTokens);
|
95 |
-
$tokens[] = T_STRING;
|
96 |
|
97 |
return $tokens;
|
98 |
-
}
|
99 |
|
100 |
/**
|
101 |
* Processes this test, when one of its tokens is encountered.
|
@@ -106,7 +102,7 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
106 |
*
|
107 |
* @return void
|
108 |
*/
|
109 |
-
public function process(
|
110 |
{
|
111 |
$tokens = $phpcsFile->getTokens();
|
112 |
$tokenCode = $tokens[$stackPtr]['code'];
|
@@ -119,26 +115,26 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
119 |
* token doesn't exist yet for that keyword or in later versions when the
|
120 |
* token is used in a method invocation.
|
121 |
*/
|
122 |
-
if ($tokenCode === T_STRING
|
123 |
&& (isset($this->targetedStringTokens[$tokenContentLc]) === false)
|
124 |
) {
|
125 |
return;
|
126 |
}
|
127 |
|
128 |
-
if ($tokenCode === T_STRING) {
|
129 |
$isString = true;
|
130 |
}
|
131 |
|
132 |
// Make sure this is a function call.
|
133 |
-
$next = $phpcsFile->findNext(
|
134 |
-
if ($next === false || $tokens[$next]['code'] !== T_OPEN_PARENTHESIS) {
|
135 |
// Not a function call.
|
136 |
return;
|
137 |
}
|
138 |
|
139 |
// This sniff isn't concerned about function declarations.
|
140 |
-
$prev = $phpcsFile->findPrevious(
|
141 |
-
if ($prev !== false && $tokens[$prev]['code'] === T_FUNCTION) {
|
142 |
return;
|
143 |
}
|
144 |
|
@@ -149,7 +145,7 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
149 |
*
|
150 |
* Only needed for those keywords which we sniff out via T_STRING.
|
151 |
*/
|
152 |
-
if (($tokens[$prev]['code'] === T_OBJECT_OPERATOR || $tokens[$prev]['code'] === T_DOUBLE_COLON)
|
153 |
&& $this->supportsBelow('5.6') === false
|
154 |
) {
|
155 |
return;
|
@@ -157,8 +153,8 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
157 |
|
158 |
// For the word catch, it is valid to have an open parenthesis
|
159 |
// after it, but only if it is preceded by a right curly brace.
|
160 |
-
if ($tokenCode === T_CATCH) {
|
161 |
-
if ($prev !== false && $tokens[$prev]['code'] === T_CLOSE_CURLY_BRACKET) {
|
162 |
// Ok, it's fine.
|
163 |
return;
|
164 |
}
|
@@ -172,7 +168,7 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
172 |
|
173 |
if ($this->supportsAbove($version)) {
|
174 |
$error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
|
175 |
-
$errorCode = $this->stringToErrorCode($tokenContentLc).'Found';
|
176 |
$data = array(
|
177 |
$tokenContentLc,
|
178 |
$version,
|
@@ -181,6 +177,5 @@ class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
|
181 |
|
182 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
183 |
}
|
184 |
-
}
|
185 |
-
|
186 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Keywords\ForbiddenNamesAsInvokedFunctionsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\Keywords;
|
12 |
|
13 |
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Keywords\ForbiddenNamesAsInvokedFunctionsSniff.
|
19 |
*
|
20 |
* Prohibits the use of reserved keywords invoked as functions.
|
21 |
*
|
33 |
* @var array
|
34 |
*/
|
35 |
protected $targetedTokens = array(
|
36 |
+
\T_ABSTRACT => '5.0',
|
37 |
+
\T_CALLABLE => '5.4',
|
38 |
+
\T_CATCH => '5.0',
|
39 |
+
\T_FINAL => '5.0',
|
40 |
+
\T_FINALLY => '5.5',
|
41 |
+
\T_GOTO => '5.3',
|
42 |
+
\T_IMPLEMENTS => '5.0',
|
43 |
+
\T_INTERFACE => '5.0',
|
44 |
+
\T_INSTANCEOF => '5.0',
|
45 |
+
\T_INSTEADOF => '5.4',
|
46 |
+
\T_NAMESPACE => '5.3',
|
47 |
+
\T_PRIVATE => '5.0',
|
48 |
+
\T_PROTECTED => '5.0',
|
49 |
+
\T_PUBLIC => '5.0',
|
50 |
+
\T_TRAIT => '5.4',
|
51 |
+
\T_TRY => '5.0',
|
52 |
+
|
53 |
);
|
54 |
|
55 |
/**
|
87 |
*/
|
88 |
public function register()
|
89 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
$tokens = array_keys($this->targetedTokens);
|
91 |
+
$tokens[] = \T_STRING;
|
92 |
|
93 |
return $tokens;
|
94 |
+
}
|
95 |
|
96 |
/**
|
97 |
* Processes this test, when one of its tokens is encountered.
|
102 |
*
|
103 |
* @return void
|
104 |
*/
|
105 |
+
public function process(File $phpcsFile, $stackPtr)
|
106 |
{
|
107 |
$tokens = $phpcsFile->getTokens();
|
108 |
$tokenCode = $tokens[$stackPtr]['code'];
|
115 |
* token doesn't exist yet for that keyword or in later versions when the
|
116 |
* token is used in a method invocation.
|
117 |
*/
|
118 |
+
if ($tokenCode === \T_STRING
|
119 |
&& (isset($this->targetedStringTokens[$tokenContentLc]) === false)
|
120 |
) {
|
121 |
return;
|
122 |
}
|
123 |
|
124 |
+
if ($tokenCode === \T_STRING) {
|
125 |
$isString = true;
|
126 |
}
|
127 |
|
128 |
// Make sure this is a function call.
|
129 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
130 |
+
if ($next === false || $tokens[$next]['code'] !== \T_OPEN_PARENTHESIS) {
|
131 |
// Not a function call.
|
132 |
return;
|
133 |
}
|
134 |
|
135 |
// This sniff isn't concerned about function declarations.
|
136 |
+
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
137 |
+
if ($prev !== false && $tokens[$prev]['code'] === \T_FUNCTION) {
|
138 |
return;
|
139 |
}
|
140 |
|
145 |
*
|
146 |
* Only needed for those keywords which we sniff out via T_STRING.
|
147 |
*/
|
148 |
+
if (($tokens[$prev]['code'] === \T_OBJECT_OPERATOR || $tokens[$prev]['code'] === \T_DOUBLE_COLON)
|
149 |
&& $this->supportsBelow('5.6') === false
|
150 |
) {
|
151 |
return;
|
153 |
|
154 |
// For the word catch, it is valid to have an open parenthesis
|
155 |
// after it, but only if it is preceded by a right curly brace.
|
156 |
+
if ($tokenCode === \T_CATCH) {
|
157 |
+
if ($prev !== false && $tokens[$prev]['code'] === \T_CLOSE_CURLY_BRACKET) {
|
158 |
// Ok, it's fine.
|
159 |
return;
|
160 |
}
|
168 |
|
169 |
if ($this->supportsAbove($version)) {
|
170 |
$error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
|
171 |
+
$errorCode = $this->stringToErrorCode($tokenContentLc) . 'Found';
|
172 |
$data = array(
|
173 |
$tokenContentLc,
|
174 |
$version,
|
177 |
|
178 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
179 |
}
|
180 |
+
}
|
181 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Keywords}/ForbiddenNamesSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,13 +8,14 @@
|
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\Sniff;
|
14 |
-
use
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Prohibits the use of reserved keywords as class, function, namespace or constant names.
|
20 |
*
|
@@ -102,13 +103,6 @@ class ForbiddenNamesSniff extends Sniff
|
|
102 |
'function' => true,
|
103 |
);
|
104 |
|
105 |
-
/**
|
106 |
-
* Whether PHPCS 1.x is used or not.
|
107 |
-
*
|
108 |
-
* @var bool
|
109 |
-
*/
|
110 |
-
protected $isLowPHPCS = false;
|
111 |
-
|
112 |
/**
|
113 |
* Scope modifiers and other keywords allowed in trait use statements.
|
114 |
*
|
@@ -122,15 +116,16 @@ class ForbiddenNamesSniff extends Sniff
|
|
122 |
* @var array
|
123 |
*/
|
124 |
protected $targetedTokens = array(
|
125 |
-
T_CLASS,
|
126 |
-
T_FUNCTION,
|
127 |
-
T_NAMESPACE,
|
128 |
-
T_STRING,
|
129 |
-
T_CONST,
|
130 |
-
T_USE,
|
131 |
-
T_AS,
|
132 |
-
T_EXTENDS,
|
133 |
-
T_INTERFACE,
|
|
|
134 |
);
|
135 |
|
136 |
/**
|
@@ -140,28 +135,17 @@ class ForbiddenNamesSniff extends Sniff
|
|
140 |
*/
|
141 |
public function register()
|
142 |
{
|
143 |
-
$this->
|
144 |
-
|
145 |
-
$this->allowedModifiers = array_combine(
|
146 |
-
\PHP_CodeSniffer_Tokens::$scopeModifiers,
|
147 |
-
\PHP_CodeSniffer_Tokens::$scopeModifiers
|
148 |
-
);
|
149 |
-
$this->allowedModifiers[T_FINAL] = T_FINAL;
|
150 |
|
151 |
$tokens = $this->targetedTokens;
|
152 |
|
153 |
-
if (defined('
|
154 |
-
|
155 |
-
$tokens[] = T_TRAIT;
|
156 |
-
}
|
157 |
-
|
158 |
-
if (defined('T_ANON_CLASS')) {
|
159 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_anon_classFound
|
160 |
-
$tokens[] = T_ANON_CLASS;
|
161 |
}
|
162 |
|
163 |
return $tokens;
|
164 |
-
}
|
165 |
|
166 |
/**
|
167 |
* Processes this test, when one of its tokens is encountered.
|
@@ -172,7 +156,7 @@ class ForbiddenNamesSniff extends Sniff
|
|
172 |
*
|
173 |
* @return void
|
174 |
*/
|
175 |
-
public function process(
|
176 |
{
|
177 |
$tokens = $phpcsFile->getTokens();
|
178 |
|
@@ -197,9 +181,9 @@ class ForbiddenNamesSniff extends Sniff
|
|
197 |
*
|
198 |
* @return void
|
199 |
*/
|
200 |
-
public function processNonString(
|
201 |
{
|
202 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
203 |
if ($nextNonEmpty === false) {
|
204 |
return;
|
205 |
}
|
@@ -210,7 +194,7 @@ class ForbiddenNamesSniff extends Sniff
|
|
210 |
* In PHPCS < 2.3.4 these were tokenized as T_CLASS no matter what.
|
211 |
*/
|
212 |
if ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS') {
|
213 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
214 |
if ($prevNonEmpty !== false && $tokens[$prevNonEmpty]['type'] === 'T_NEW') {
|
215 |
return;
|
216 |
}
|
@@ -224,12 +208,8 @@ class ForbiddenNamesSniff extends Sniff
|
|
224 |
elseif ($tokens[$stackPtr]['type'] === 'T_USE'
|
225 |
&& isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === true
|
226 |
) {
|
227 |
-
$maybeUseNext = $phpcsFile->findNext(
|
228 |
if ($maybeUseNext !== false && $this->isEndOfUseStatement($tokens[$maybeUseNext]) === false) {
|
229 |
-
// Prevent duplicate messages: `const` is T_CONST in PHPCS 1.x and T_STRING in PHPCS 2.x.
|
230 |
-
if ($this->isLowPHPCS === true) {
|
231 |
-
return;
|
232 |
-
}
|
233 |
$nextNonEmpty = $maybeUseNext;
|
234 |
}
|
235 |
}
|
@@ -241,9 +221,9 @@ class ForbiddenNamesSniff extends Sniff
|
|
241 |
*/
|
242 |
elseif ($tokens[$stackPtr]['type'] === 'T_AS'
|
243 |
&& isset($this->allowedModifiers[$tokens[$nextNonEmpty]['code']]) === true
|
244 |
-
&& $
|
245 |
) {
|
246 |
-
$maybeUseNext = $phpcsFile->findNext(
|
247 |
if ($maybeUseNext === false || $this->isEndOfUseStatement($tokens[$maybeUseNext]) === true) {
|
248 |
return;
|
249 |
}
|
@@ -257,7 +237,7 @@ class ForbiddenNamesSniff extends Sniff
|
|
257 |
elseif ($tokens[$stackPtr]['type'] === 'T_FUNCTION'
|
258 |
&& $tokens[$nextNonEmpty]['type'] === 'T_BITWISE_AND'
|
259 |
) {
|
260 |
-
$maybeUseNext = $phpcsFile->findNext(
|
261 |
if ($maybeUseNext === false) {
|
262 |
// Live coding.
|
263 |
return;
|
@@ -270,12 +250,12 @@ class ForbiddenNamesSniff extends Sniff
|
|
270 |
* Deal with nested namespaces.
|
271 |
*/
|
272 |
elseif ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') {
|
273 |
-
if ($tokens[$stackPtr + 1]['code'] === T_NS_SEPARATOR) {
|
274 |
// Not a namespace declaration, but use of, i.e. namespace\someFunction();
|
275 |
return;
|
276 |
}
|
277 |
|
278 |
-
$endToken = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1), null, false, null, true);
|
279 |
$namespaceName = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($endToken - $stackPtr - 1)));
|
280 |
if (empty($namespaceName) === true) {
|
281 |
return;
|
@@ -326,8 +306,7 @@ class ForbiddenNamesSniff extends Sniff
|
|
326 |
);
|
327 |
$this->addError($phpcsFile, $stackPtr, $tokens[$nextNonEmpty]['content'], $data);
|
328 |
}
|
329 |
-
|
330 |
-
}//end processNonString()
|
331 |
|
332 |
/**
|
333 |
* Processes this test, when one of its tokens is encountered.
|
@@ -340,17 +319,16 @@ class ForbiddenNamesSniff extends Sniff
|
|
340 |
*
|
341 |
* @return void
|
342 |
*/
|
343 |
-
public function processString(
|
344 |
{
|
345 |
$tokenContentLc = strtolower($tokens[$stackPtr]['content']);
|
346 |
|
347 |
/*
|
348 |
* Special case for PHP versions where the target is not yet identified as
|
349 |
* its own token, but presents as T_STRING.
|
350 |
-
* - namespace keyword in PHP < 5.3
|
351 |
* - trait keyword in PHP < 5.4
|
352 |
*/
|
353 |
-
if (version_compare(PHP_VERSION_ID, '50400', '<') && $tokenContentLc === 'trait') {
|
354 |
$this->processNonString($phpcsFile, $stackPtr, $tokens);
|
355 |
return;
|
356 |
}
|
@@ -376,7 +354,7 @@ class ForbiddenNamesSniff extends Sniff
|
|
376 |
);
|
377 |
$this->addError($phpcsFile, $stackPtr, $defineNameLc, $data);
|
378 |
}
|
379 |
-
}
|
380 |
|
381 |
|
382 |
/**
|
@@ -390,7 +368,7 @@ class ForbiddenNamesSniff extends Sniff
|
|
390 |
*
|
391 |
* @return void
|
392 |
*/
|
393 |
-
protected function addError($phpcsFile, $stackPtr, $content, $data)
|
394 |
{
|
395 |
$error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
|
396 |
$errorCode = $this->stringToErrorCode($content) . 'Found';
|
@@ -408,6 +386,6 @@ class ForbiddenNamesSniff extends Sniff
|
|
408 |
*/
|
409 |
protected function isEndOfUseStatement($token)
|
410 |
{
|
411 |
-
return in_array($token['code'], array(T_CLOSE_CURLY_BRACKET, T_SEMICOLON, T_COMMA), true);
|
412 |
}
|
413 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Keywords\ForbiddenNamesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2012 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\Keywords;
|
12 |
|
13 |
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Keywords\ForbiddenNamesSniff.
|
19 |
*
|
20 |
* Prohibits the use of reserved keywords as class, function, namespace or constant names.
|
21 |
*
|
103 |
'function' => true,
|
104 |
);
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
/**
|
107 |
* Scope modifiers and other keywords allowed in trait use statements.
|
108 |
*
|
116 |
* @var array
|
117 |
*/
|
118 |
protected $targetedTokens = array(
|
119 |
+
\T_CLASS,
|
120 |
+
\T_FUNCTION,
|
121 |
+
\T_NAMESPACE,
|
122 |
+
\T_STRING,
|
123 |
+
\T_CONST,
|
124 |
+
\T_USE,
|
125 |
+
\T_AS,
|
126 |
+
\T_EXTENDS,
|
127 |
+
\T_INTERFACE,
|
128 |
+
\T_TRAIT,
|
129 |
);
|
130 |
|
131 |
/**
|
135 |
*/
|
136 |
public function register()
|
137 |
{
|
138 |
+
$this->allowedModifiers = Tokens::$scopeModifiers;
|
139 |
+
$this->allowedModifiers[\T_FINAL] = \T_FINAL;
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
$tokens = $this->targetedTokens;
|
142 |
|
143 |
+
if (\defined('T_ANON_CLASS')) {
|
144 |
+
$tokens[] = \T_ANON_CLASS;
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
|
147 |
return $tokens;
|
148 |
+
}
|
149 |
|
150 |
/**
|
151 |
* Processes this test, when one of its tokens is encountered.
|
156 |
*
|
157 |
* @return void
|
158 |
*/
|
159 |
+
public function process(File $phpcsFile, $stackPtr)
|
160 |
{
|
161 |
$tokens = $phpcsFile->getTokens();
|
162 |
|
181 |
*
|
182 |
* @return void
|
183 |
*/
|
184 |
+
public function processNonString(File $phpcsFile, $stackPtr, $tokens)
|
185 |
{
|
186 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
187 |
if ($nextNonEmpty === false) {
|
188 |
return;
|
189 |
}
|
194 |
* In PHPCS < 2.3.4 these were tokenized as T_CLASS no matter what.
|
195 |
*/
|
196 |
if ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS') {
|
197 |
+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
198 |
if ($prevNonEmpty !== false && $tokens[$prevNonEmpty]['type'] === 'T_NEW') {
|
199 |
return;
|
200 |
}
|
208 |
elseif ($tokens[$stackPtr]['type'] === 'T_USE'
|
209 |
&& isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === true
|
210 |
) {
|
211 |
+
$maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
|
212 |
if ($maybeUseNext !== false && $this->isEndOfUseStatement($tokens[$maybeUseNext]) === false) {
|
|
|
|
|
|
|
|
|
213 |
$nextNonEmpty = $maybeUseNext;
|
214 |
}
|
215 |
}
|
221 |
*/
|
222 |
elseif ($tokens[$stackPtr]['type'] === 'T_AS'
|
223 |
&& isset($this->allowedModifiers[$tokens[$nextNonEmpty]['code']]) === true
|
224 |
+
&& $phpcsFile->hasCondition($stackPtr, \T_USE) === true
|
225 |
) {
|
226 |
+
$maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
|
227 |
if ($maybeUseNext === false || $this->isEndOfUseStatement($tokens[$maybeUseNext]) === true) {
|
228 |
return;
|
229 |
}
|
237 |
elseif ($tokens[$stackPtr]['type'] === 'T_FUNCTION'
|
238 |
&& $tokens[$nextNonEmpty]['type'] === 'T_BITWISE_AND'
|
239 |
) {
|
240 |
+
$maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
|
241 |
if ($maybeUseNext === false) {
|
242 |
// Live coding.
|
243 |
return;
|
250 |
* Deal with nested namespaces.
|
251 |
*/
|
252 |
elseif ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') {
|
253 |
+
if ($tokens[$stackPtr + 1]['code'] === \T_NS_SEPARATOR) {
|
254 |
// Not a namespace declaration, but use of, i.e. namespace\someFunction();
|
255 |
return;
|
256 |
}
|
257 |
|
258 |
+
$endToken = $phpcsFile->findNext(array(\T_SEMICOLON, \T_OPEN_CURLY_BRACKET), ($stackPtr + 1), null, false, null, true);
|
259 |
$namespaceName = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($endToken - $stackPtr - 1)));
|
260 |
if (empty($namespaceName) === true) {
|
261 |
return;
|
306 |
);
|
307 |
$this->addError($phpcsFile, $stackPtr, $tokens[$nextNonEmpty]['content'], $data);
|
308 |
}
|
309 |
+
}
|
|
|
310 |
|
311 |
/**
|
312 |
* Processes this test, when one of its tokens is encountered.
|
319 |
*
|
320 |
* @return void
|
321 |
*/
|
322 |
+
public function processString(File $phpcsFile, $stackPtr, $tokens)
|
323 |
{
|
324 |
$tokenContentLc = strtolower($tokens[$stackPtr]['content']);
|
325 |
|
326 |
/*
|
327 |
* Special case for PHP versions where the target is not yet identified as
|
328 |
* its own token, but presents as T_STRING.
|
|
|
329 |
* - trait keyword in PHP < 5.4
|
330 |
*/
|
331 |
+
if (version_compare(\PHP_VERSION_ID, '50400', '<') && $tokenContentLc === 'trait') {
|
332 |
$this->processNonString($phpcsFile, $stackPtr, $tokens);
|
333 |
return;
|
334 |
}
|
354 |
);
|
355 |
$this->addError($phpcsFile, $stackPtr, $defineNameLc, $data);
|
356 |
}
|
357 |
+
}
|
358 |
|
359 |
|
360 |
/**
|
368 |
*
|
369 |
* @return void
|
370 |
*/
|
371 |
+
protected function addError(File $phpcsFile, $stackPtr, $content, $data)
|
372 |
{
|
373 |
$error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
|
374 |
$errorCode = $this->stringToErrorCode($content) . 'Found';
|
386 |
*/
|
387 |
protected function isEndOfUseStatement($token)
|
388 |
{
|
389 |
+
return \in_array($token['code'], array(\T_CLOSE_CURLY_BRACKET, \T_SEMICOLON, \T_COMMA), true);
|
390 |
}
|
391 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Keywords}/NewKeywordsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,12 +8,14 @@
|
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
@@ -162,11 +164,11 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
162 |
$tokens = array();
|
163 |
$translate = array();
|
164 |
foreach ($this->newKeywords as $token => $versions) {
|
165 |
-
if (defined($token)) {
|
166 |
$tokens[] = constant($token);
|
167 |
}
|
168 |
if (isset($versions['content'])) {
|
169 |
-
$translate[$versions['content']] = $token;
|
170 |
}
|
171 |
}
|
172 |
|
@@ -176,12 +178,11 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
176 |
*/
|
177 |
if (empty($translate) === false) {
|
178 |
$this->translateContentToToken = $translate;
|
179 |
-
$tokens[]
|
180 |
}
|
181 |
|
182 |
return $tokens;
|
183 |
-
|
184 |
-
}//end register()
|
185 |
|
186 |
|
187 |
/**
|
@@ -193,7 +194,7 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
193 |
*
|
194 |
* @return void
|
195 |
*/
|
196 |
-
public function process(
|
197 |
{
|
198 |
$tokens = $phpcsFile->getTokens();
|
199 |
$tokenType = $tokens[$stackPtr]['type'];
|
@@ -203,10 +204,7 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
203 |
|
204 |
// Translate T_STRING token if necessary.
|
205 |
if ($tokens[$stackPtr]['type'] === 'T_STRING') {
|
206 |
-
$content = $tokens[$stackPtr]['content'];
|
207 |
-
if (strpos($content, '__') !== 0) {
|
208 |
-
$content = strtolower($tokens[$stackPtr]['content']);
|
209 |
-
}
|
210 |
|
211 |
if (isset($this->translateContentToToken[$content]) === false) {
|
212 |
// Not one of the tokens we're looking for.
|
@@ -230,8 +228,8 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
230 |
* a multi-line "yield from" is tokenized as two tokens.
|
231 |
*/
|
232 |
if ($tokenType === 'T_YIELD') {
|
233 |
-
$nextToken = $phpcsFile->findNext(T_WHITESPACE, ($end + 1), null, true);
|
234 |
-
if ($tokens[$nextToken]['code'] === T_STRING
|
235 |
&& $tokens[$nextToken]['content'] === 'from'
|
236 |
) {
|
237 |
$tokenType = 'T_YIELD_FROM';
|
@@ -249,12 +247,12 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
249 |
return;
|
250 |
}
|
251 |
|
252 |
-
$nextToken = $phpcsFile->findNext(
|
253 |
-
$prevToken = $phpcsFile->findPrevious(
|
254 |
|
255 |
if ($prevToken !== false
|
256 |
-
&& ($tokens[$prevToken]['code'] === T_DOUBLE_COLON
|
257 |
-
|| $tokens[$prevToken]['code'] === T_OBJECT_OPERATOR)
|
258 |
) {
|
259 |
// Class property of the same name as one of the keywords. Ignore.
|
260 |
return;
|
@@ -274,7 +272,7 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
274 |
) {
|
275 |
// Skip based on token scope condition.
|
276 |
if (isset($this->newKeywords[$tokenType]['condition'])
|
277 |
-
&& call_user_func(array($this, $this->newKeywords[$tokenType]['condition']), $phpcsFile, $stackPtr) === true
|
278 |
) {
|
279 |
return;
|
280 |
}
|
@@ -284,8 +282,7 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
284 |
);
|
285 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
286 |
}
|
287 |
-
|
288 |
-
}//end process()
|
289 |
|
290 |
|
291 |
/**
|
@@ -330,7 +327,6 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
330 |
$errorInfo['description'] = $itemArray['description'];
|
331 |
|
332 |
return $errorInfo;
|
333 |
-
|
334 |
}
|
335 |
|
336 |
|
@@ -362,11 +358,9 @@ class NewKeywordsSniff extends AbstractNewFeatureSniff
|
|
362 |
*
|
363 |
* @return bool
|
364 |
*/
|
365 |
-
public function isNotQuoted(
|
366 |
{
|
367 |
$tokens = $phpcsFile->getTokens();
|
368 |
return ($tokens[$stackPtr]['content'][3] !== '"');
|
369 |
}
|
370 |
-
|
371 |
-
|
372 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Keywords\NewKeywordsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\Keywords;
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Keywords\NewKeywordsSniff.
|
19 |
*
|
20 |
* @category PHP
|
21 |
* @package PHPCompatibility
|
164 |
$tokens = array();
|
165 |
$translate = array();
|
166 |
foreach ($this->newKeywords as $token => $versions) {
|
167 |
+
if (\defined($token)) {
|
168 |
$tokens[] = constant($token);
|
169 |
}
|
170 |
if (isset($versions['content'])) {
|
171 |
+
$translate[strtolower($versions['content'])] = $token;
|
172 |
}
|
173 |
}
|
174 |
|
178 |
*/
|
179 |
if (empty($translate) === false) {
|
180 |
$this->translateContentToToken = $translate;
|
181 |
+
$tokens[] = \T_STRING;
|
182 |
}
|
183 |
|
184 |
return $tokens;
|
185 |
+
}
|
|
|
186 |
|
187 |
|
188 |
/**
|
194 |
*
|
195 |
* @return void
|
196 |
*/
|
197 |
+
public function process(File $phpcsFile, $stackPtr)
|
198 |
{
|
199 |
$tokens = $phpcsFile->getTokens();
|
200 |
$tokenType = $tokens[$stackPtr]['type'];
|
204 |
|
205 |
// Translate T_STRING token if necessary.
|
206 |
if ($tokens[$stackPtr]['type'] === 'T_STRING') {
|
207 |
+
$content = strtolower($tokens[$stackPtr]['content']);
|
|
|
|
|
|
|
208 |
|
209 |
if (isset($this->translateContentToToken[$content]) === false) {
|
210 |
// Not one of the tokens we're looking for.
|
228 |
* a multi-line "yield from" is tokenized as two tokens.
|
229 |
*/
|
230 |
if ($tokenType === 'T_YIELD') {
|
231 |
+
$nextToken = $phpcsFile->findNext(\T_WHITESPACE, ($end + 1), null, true);
|
232 |
+
if ($tokens[$nextToken]['code'] === \T_STRING
|
233 |
&& $tokens[$nextToken]['content'] === 'from'
|
234 |
) {
|
235 |
$tokenType = 'T_YIELD_FROM';
|
247 |
return;
|
248 |
}
|
249 |
|
250 |
+
$nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true);
|
251 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
252 |
|
253 |
if ($prevToken !== false
|
254 |
+
&& ($tokens[$prevToken]['code'] === \T_DOUBLE_COLON
|
255 |
+
|| $tokens[$prevToken]['code'] === \T_OBJECT_OPERATOR)
|
256 |
) {
|
257 |
// Class property of the same name as one of the keywords. Ignore.
|
258 |
return;
|
272 |
) {
|
273 |
// Skip based on token scope condition.
|
274 |
if (isset($this->newKeywords[$tokenType]['condition'])
|
275 |
+
&& \call_user_func(array($this, $this->newKeywords[$tokenType]['condition']), $phpcsFile, $stackPtr) === true
|
276 |
) {
|
277 |
return;
|
278 |
}
|
282 |
);
|
283 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
284 |
}
|
285 |
+
}
|
|
|
286 |
|
287 |
|
288 |
/**
|
327 |
$errorInfo['description'] = $itemArray['description'];
|
328 |
|
329 |
return $errorInfo;
|
|
|
330 |
}
|
331 |
|
332 |
|
358 |
*
|
359 |
* @return bool
|
360 |
*/
|
361 |
+
public function isNotQuoted(File $phpcsFile, $stackPtr)
|
362 |
{
|
363 |
$tokens = $phpcsFile->getTokens();
|
364 |
return ($tokens[$stackPtr]['content'][3] !== '"');
|
365 |
}
|
366 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/LanguageConstructs/NewEmptyNonVariableSniff.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\LanguageConstructs\NewEmptyNonVariableSniff.
|
4 |
+
*
|
5 |
+
* PHP version 5.5
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\LanguageConstructs;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* \PHPCompatibility\Sniffs\LanguageConstructs\NewEmptyNonVariableSniff.
|
20 |
+
*
|
21 |
+
* Verify that nothing but variables are passed to empty().
|
22 |
+
*
|
23 |
+
* PHP version 5.5
|
24 |
+
*
|
25 |
+
* @category PHP
|
26 |
+
* @package PHPCompatibility
|
27 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
+
*/
|
29 |
+
class NewEmptyNonVariableSniff extends Sniff
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns an array of tokens this test wants to listen for.
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function register()
|
38 |
+
{
|
39 |
+
return array(\T_EMPTY);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Processes this test, when one of its tokens is encountered.
|
44 |
+
*
|
45 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
46 |
+
* @param int $stackPtr The position of the current token in the
|
47 |
+
* stack passed in $tokens.
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function process(File $phpcsFile, $stackPtr)
|
52 |
+
{
|
53 |
+
if ($this->supportsBelow('5.4') === false) {
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$tokens = $phpcsFile->getTokens();
|
58 |
+
|
59 |
+
$open = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
60 |
+
if ($open === false
|
61 |
+
|| $tokens[$open]['code'] !== \T_OPEN_PARENTHESIS
|
62 |
+
|| isset($tokens[$open]['parenthesis_closer']) === false
|
63 |
+
) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
$close = $tokens[$open]['parenthesis_closer'];
|
68 |
+
|
69 |
+
$nestingLevel = 0;
|
70 |
+
if ($close !== ($open + 1) && isset($tokens[$open + 1]['nested_parenthesis'])) {
|
71 |
+
$nestingLevel = \count($tokens[$open + 1]['nested_parenthesis']);
|
72 |
+
}
|
73 |
+
|
74 |
+
if ($this->isVariable($phpcsFile, ($open + 1), $close, $nestingLevel) === true) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
$phpcsFile->addError(
|
79 |
+
'Only variables can be passed to empty() prior to PHP 5.5.',
|
80 |
+
$stackPtr,
|
81 |
+
'Found'
|
82 |
+
);
|
83 |
+
}
|
84 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/LanguageConstructs/NewLanguageConstructsSniff.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\LanguageConstructs\NewLanguageConstructsSniff.
|
4 |
+
*
|
5 |
+
* @category PHP
|
6 |
+
* @package PHPCompatibility
|
7 |
+
* @author Wim Godden <wim.godden@cu.be>
|
8 |
+
* @copyright 2013 Cu.be Solutions bvba
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\LanguageConstructs;
|
12 |
+
|
13 |
+
use PHPCompatibility\AbstractNewFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* \PHPCompatibility\Sniffs\LanguageConstructs\NewLanguageConstructsSniff.
|
18 |
+
*
|
19 |
+
* @category PHP
|
20 |
+
* @package PHPCompatibility
|
21 |
+
* @author Wim Godden <wim.godden@cu.be>
|
22 |
+
* @copyright 2013 Cu.be Solutions bvba
|
23 |
+
*/
|
24 |
+
class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* A list of new language constructs, not present in older versions.
|
29 |
+
*
|
30 |
+
* The array lists : version number with false (not present) or true (present).
|
31 |
+
* If's sufficient to list the first version where the keyword appears.
|
32 |
+
*
|
33 |
+
* @var array(string => array(string => int|string|null))
|
34 |
+
*/
|
35 |
+
protected $newConstructs = array(
|
36 |
+
'T_NS_SEPARATOR' => array(
|
37 |
+
'5.2' => false,
|
38 |
+
'5.3' => true,
|
39 |
+
'description' => 'the \ operator (for namespaces)',
|
40 |
+
),
|
41 |
+
'T_ELLIPSIS' => array(
|
42 |
+
'5.5' => false,
|
43 |
+
'5.6' => true,
|
44 |
+
'description' => 'the ... spread operator',
|
45 |
+
),
|
46 |
+
);
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Returns an array of tokens this test wants to listen for.
|
51 |
+
*
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
public function register()
|
55 |
+
{
|
56 |
+
$tokens = array();
|
57 |
+
foreach ($this->newConstructs as $token => $versions) {
|
58 |
+
$tokens[] = constant($token);
|
59 |
+
}
|
60 |
+
return $tokens;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Processes this test, when one of its tokens is encountered.
|
66 |
+
*
|
67 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
68 |
+
* @param int $stackPtr The position of the current token in
|
69 |
+
* the stack passed in $tokens.
|
70 |
+
*
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
public function process(File $phpcsFile, $stackPtr)
|
74 |
+
{
|
75 |
+
$tokens = $phpcsFile->getTokens();
|
76 |
+
$tokenType = $tokens[$stackPtr]['type'];
|
77 |
+
|
78 |
+
$itemInfo = array(
|
79 |
+
'name' => $tokenType,
|
80 |
+
);
|
81 |
+
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
87 |
+
*
|
88 |
+
* @param array $itemInfo Base information about the item.
|
89 |
+
*
|
90 |
+
* @return array Version and other information about the item.
|
91 |
+
*/
|
92 |
+
public function getItemArray(array $itemInfo)
|
93 |
+
{
|
94 |
+
return $this->newConstructs[$itemInfo['name']];
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get an array of the non-PHP-version array keys used in a sub-array.
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
protected function getNonVersionArrayKeys()
|
104 |
+
{
|
105 |
+
return array('description');
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Retrieve the relevant detail (version) information for use in an error message.
|
111 |
+
*
|
112 |
+
* @param array $itemArray Version and other information about the item.
|
113 |
+
* @param array $itemInfo Base information about the item.
|
114 |
+
*
|
115 |
+
* @return array
|
116 |
+
*/
|
117 |
+
public function getErrorInfo(array $itemArray, array $itemInfo)
|
118 |
+
{
|
119 |
+
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
|
120 |
+
$errorInfo['description'] = $itemArray['description'];
|
121 |
+
|
122 |
+
return $errorInfo;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Allow for concrete child classes to filter the error data before it's passed to PHPCS.
|
128 |
+
*
|
129 |
+
* @param array $data The error data array which was created.
|
130 |
+
* @param array $itemInfo Base information about the item this error message applies to.
|
131 |
+
* @param array $errorInfo Detail information about an item this error message applies to.
|
132 |
+
*
|
133 |
+
* @return array
|
134 |
+
*/
|
135 |
+
protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
|
136 |
+
{
|
137 |
+
$data[0] = $errorInfo['description'];
|
138 |
+
return $data;
|
139 |
+
}
|
140 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/AssignmentOrderSniff.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Lists\AssignmentOrderSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.0
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\Lists;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* List assignment order.
|
20 |
+
*
|
21 |
+
* The list() construct no longer assigns variables in reverse order.
|
22 |
+
* This affects all list constructs where non-unique variables are used.
|
23 |
+
*
|
24 |
+
* PHP version 7.0
|
25 |
+
*
|
26 |
+
* @category PHP
|
27 |
+
* @package PHPCompatibility
|
28 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
29 |
+
*/
|
30 |
+
class AssignmentOrderSniff extends Sniff
|
31 |
+
{
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns an array of tokens this test wants to listen for.
|
35 |
+
*
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function register()
|
39 |
+
{
|
40 |
+
return array(
|
41 |
+
\T_LIST,
|
42 |
+
\T_OPEN_SHORT_ARRAY,
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Processes this test, when one of its tokens is encountered.
|
49 |
+
*
|
50 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
51 |
+
* @param int $stackPtr The position of the current token in the
|
52 |
+
* stack passed in $tokens.
|
53 |
+
*
|
54 |
+
* @return void|int Void if not a valid list. If a list construct has been
|
55 |
+
* examined, the stack pointer to the list closer to skip
|
56 |
+
* passed any nested lists which don't need to be examined again.
|
57 |
+
*/
|
58 |
+
public function process(File $phpcsFile, $stackPtr)
|
59 |
+
{
|
60 |
+
if ($this->supportsAbove('7.0') === false) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
$tokens = $phpcsFile->getTokens();
|
65 |
+
|
66 |
+
if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
|
67 |
+
&& $this->isShortList($phpcsFile, $stackPtr) === false
|
68 |
+
) {
|
69 |
+
// Short array, not short list.
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
if ($tokens[$stackPtr]['code'] === \T_LIST) {
|
74 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
75 |
+
if ($nextNonEmpty === false
|
76 |
+
|| $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
|
77 |
+
|| isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
|
78 |
+
) {
|
79 |
+
// Parse error or live coding.
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
$opener = $nextNonEmpty;
|
84 |
+
$closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
|
85 |
+
} else {
|
86 |
+
// Short list syntax.
|
87 |
+
$opener = $stackPtr;
|
88 |
+
|
89 |
+
if (isset($tokens[$stackPtr]['bracket_closer'])) {
|
90 |
+
$closer = $tokens[$stackPtr]['bracket_closer'];
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
if (isset($opener, $closer) === false) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
/*
|
99 |
+
* OK, so we have the opener & closer, now we need to check all the variables in the
|
100 |
+
* list() to see if there are duplicates as that's the problem.
|
101 |
+
*/
|
102 |
+
$hasVars = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($opener + 1), $closer);
|
103 |
+
if ($hasVars === false) {
|
104 |
+
// Empty list, not our concern.
|
105 |
+
return ($closer + 1);
|
106 |
+
}
|
107 |
+
|
108 |
+
// Set the variable delimiters based on the list type being examined.
|
109 |
+
$stopPoints = array(\T_COMMA);
|
110 |
+
if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
|
111 |
+
$stopPoints[] = \T_CLOSE_SHORT_ARRAY;
|
112 |
+
} else {
|
113 |
+
$stopPoints[] = \T_CLOSE_PARENTHESIS;
|
114 |
+
}
|
115 |
+
|
116 |
+
$listVars = array();
|
117 |
+
$lastStopPoint = $opener;
|
118 |
+
|
119 |
+
/*
|
120 |
+
* Create a list of all variables used within the `list()` construct.
|
121 |
+
* We're not concerned with whether these are nested or not, as any duplicate
|
122 |
+
* variable name used will be problematic, independent of nesting.
|
123 |
+
*/
|
124 |
+
do {
|
125 |
+
$nextStopPoint = $phpcsFile->findNext($stopPoints, ($lastStopPoint + 1), $closer);
|
126 |
+
if ($nextStopPoint === false) {
|
127 |
+
$nextStopPoint = $closer;
|
128 |
+
}
|
129 |
+
|
130 |
+
// Also detect this in PHP 7.1 keyed lists.
|
131 |
+
$hasDoubleArrow = $phpcsFile->findNext(\T_DOUBLE_ARROW, ($lastStopPoint + 1), $nextStopPoint);
|
132 |
+
if ($hasDoubleArrow !== false) {
|
133 |
+
$lastStopPoint = $hasDoubleArrow;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Find the start of the variable, allowing for variable variables.
|
137 |
+
$nextStartPoint = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($lastStopPoint + 1), $nextStopPoint);
|
138 |
+
if ($nextStartPoint === false) {
|
139 |
+
// Skip past empty bits in the list, i.e. `list( $a, , ,)`.
|
140 |
+
$lastStopPoint = $nextStopPoint;
|
141 |
+
continue;
|
142 |
+
}
|
143 |
+
|
144 |
+
/*
|
145 |
+
* Gather the content of all non-empty tokens to determine the "variable name".
|
146 |
+
* Variable name in this context includes array or object property syntaxes, such
|
147 |
+
* as `$a['name']` and `$b->property`.
|
148 |
+
*/
|
149 |
+
$varContent = '';
|
150 |
+
|
151 |
+
for ($i = $nextStartPoint; $i < $nextStopPoint; $i++) {
|
152 |
+
if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
|
153 |
+
continue;
|
154 |
+
}
|
155 |
+
|
156 |
+
$varContent .= $tokens[$i]['content'];
|
157 |
+
}
|
158 |
+
|
159 |
+
if ($varContent !== '') {
|
160 |
+
$listVars[] = $varContent;
|
161 |
+
}
|
162 |
+
|
163 |
+
$lastStopPoint = $nextStopPoint;
|
164 |
+
|
165 |
+
} while ($lastStopPoint < $closer);
|
166 |
+
|
167 |
+
if (empty($listVars)) {
|
168 |
+
// Shouldn't be possible, but just in case.
|
169 |
+
return ($closer + 1);
|
170 |
+
}
|
171 |
+
|
172 |
+
// Verify that all variables used in the list() construct are unique.
|
173 |
+
if (\count($listVars) !== \count(array_unique($listVars))) {
|
174 |
+
$phpcsFile->addError(
|
175 |
+
'list() will assign variable from left-to-right since PHP 7.0. Ensure all variables in list() are unique to prevent unexpected results.',
|
176 |
+
$stackPtr,
|
177 |
+
'Affected'
|
178 |
+
);
|
179 |
+
}
|
180 |
+
|
181 |
+
return ($closer + 1);
|
182 |
+
}
|
183 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Lists}/ForbiddenEmptyListAssignmentSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,13 +9,14 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
-
use
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Empty list() assignments have been removed in PHP 7.0
|
21 |
*
|
@@ -44,17 +45,14 @@ class ForbiddenEmptyListAssignmentSniff extends Sniff
|
|
44 |
{
|
45 |
// Set up a list of tokens to disregard when determining whether the list() is empty.
|
46 |
// Only needs to be set up once.
|
47 |
-
$this->ignoreTokens
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
$this->ignoreTokens[T_COMMA] = T_COMMA;
|
52 |
-
$this->ignoreTokens[T_OPEN_PARENTHESIS] = T_OPEN_PARENTHESIS;
|
53 |
-
$this->ignoreTokens[T_CLOSE_PARENTHESIS] = T_CLOSE_PARENTHESIS;
|
54 |
|
55 |
return array(
|
56 |
-
T_LIST,
|
57 |
-
T_OPEN_SHORT_ARRAY,
|
58 |
);
|
59 |
}
|
60 |
|
@@ -67,7 +65,7 @@ class ForbiddenEmptyListAssignmentSniff extends Sniff
|
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
-
public function process(
|
71 |
{
|
72 |
if ($this->supportsAbove('7.0') === false) {
|
73 |
return;
|
@@ -75,7 +73,7 @@ class ForbiddenEmptyListAssignmentSniff extends Sniff
|
|
75 |
|
76 |
$tokens = $phpcsFile->getTokens();
|
77 |
|
78 |
-
if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
|
79 |
if ($this->isShortList($phpcsFile, $stackPtr) === false) {
|
80 |
return;
|
81 |
}
|
@@ -84,7 +82,7 @@ class ForbiddenEmptyListAssignmentSniff extends Sniff
|
|
84 |
$close = $tokens[$stackPtr]['bracket_closer'];
|
85 |
} else {
|
86 |
// T_LIST.
|
87 |
-
$open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
|
88 |
if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
|
89 |
return;
|
90 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Lists\ForbiddenEmptyListAssignmentSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Lists;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Lists\ForbiddenEmptyListAssignmentSniff.
|
20 |
*
|
21 |
* Empty list() assignments have been removed in PHP 7.0
|
22 |
*
|
45 |
{
|
46 |
// Set up a list of tokens to disregard when determining whether the list() is empty.
|
47 |
// Only needs to be set up once.
|
48 |
+
$this->ignoreTokens = Tokens::$emptyTokens;
|
49 |
+
$this->ignoreTokens[\T_COMMA] = \T_COMMA;
|
50 |
+
$this->ignoreTokens[\T_OPEN_PARENTHESIS] = \T_OPEN_PARENTHESIS;
|
51 |
+
$this->ignoreTokens[\T_CLOSE_PARENTHESIS] = \T_CLOSE_PARENTHESIS;
|
|
|
|
|
|
|
52 |
|
53 |
return array(
|
54 |
+
\T_LIST,
|
55 |
+
\T_OPEN_SHORT_ARRAY,
|
56 |
);
|
57 |
}
|
58 |
|
65 |
*
|
66 |
* @return void
|
67 |
*/
|
68 |
+
public function process(File $phpcsFile, $stackPtr)
|
69 |
{
|
70 |
if ($this->supportsAbove('7.0') === false) {
|
71 |
return;
|
73 |
|
74 |
$tokens = $phpcsFile->getTokens();
|
75 |
|
76 |
+
if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
|
77 |
if ($this->isShortList($phpcsFile, $stackPtr) === false) {
|
78 |
return;
|
79 |
}
|
82 |
$close = $tokens[$stackPtr]['bracket_closer'];
|
83 |
} else {
|
84 |
// T_LIST.
|
85 |
+
$open = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
|
86 |
if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
|
87 |
return;
|
88 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/NewKeyedListSniff.php
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Lists\NewKeyedListSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.1
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\Lists;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Lists\NewKeyedListSniff.
|
20 |
+
*
|
21 |
+
* "You can now specify keys in list(), or its new shorthand [] syntax. "
|
22 |
+
*
|
23 |
+
* PHP version 7.1
|
24 |
+
*
|
25 |
+
* @category PHP
|
26 |
+
* @package PHPCompatibility
|
27 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
+
*/
|
29 |
+
class NewKeyedListSniff extends Sniff
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* Tokens which represent the start of a list construct.
|
33 |
+
*
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
protected $sniffTargets = array(
|
37 |
+
\T_LIST => \T_LIST,
|
38 |
+
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
|
39 |
+
);
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The token(s) within the list construct which is being targeted.
|
43 |
+
*
|
44 |
+
* @var array
|
45 |
+
*/
|
46 |
+
protected $targetsInList = array(
|
47 |
+
\T_DOUBLE_ARROW => \T_DOUBLE_ARROW,
|
48 |
+
);
|
49 |
+
|
50 |
+
/**
|
51 |
+
* All tokens needed to walk through the list construct and
|
52 |
+
* determine whether the target token is contained within.
|
53 |
+
*
|
54 |
+
* Set by the setUpAllTargets() method which is called from within register().
|
55 |
+
*
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
protected $allTargets;
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Returns an array of tokens this test wants to listen for.
|
63 |
+
*
|
64 |
+
* @return array
|
65 |
+
*/
|
66 |
+
public function register()
|
67 |
+
{
|
68 |
+
$this->setUpAllTargets();
|
69 |
+
|
70 |
+
return $this->sniffTargets;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Prepare the $allTargets array only once.
|
75 |
+
*
|
76 |
+
* @return array
|
77 |
+
*/
|
78 |
+
public function setUpAllTargets()
|
79 |
+
{
|
80 |
+
$this->allTargets = $this->sniffTargets + $this->targetsInList;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Do a version check to determine if this sniff needs to run at all.
|
85 |
+
*
|
86 |
+
* @return bool
|
87 |
+
*/
|
88 |
+
protected function bowOutEarly()
|
89 |
+
{
|
90 |
+
return ($this->supportsBelow('7.0') === false);
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Processes this test, when one of its tokens is encountered.
|
95 |
+
*
|
96 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
97 |
+
* @param int $stackPtr The position of the current token in the
|
98 |
+
* stack passed in $tokens.
|
99 |
+
*
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
public function process(File $phpcsFile, $stackPtr)
|
103 |
+
{
|
104 |
+
if ($this->bowOutEarly() === true) {
|
105 |
+
return;
|
106 |
+
}
|
107 |
+
|
108 |
+
$tokens = $phpcsFile->getTokens();
|
109 |
+
|
110 |
+
if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
|
111 |
+
&& $this->isShortList($phpcsFile, $stackPtr) === false
|
112 |
+
) {
|
113 |
+
// Short array, not short list.
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
if ($tokens[$stackPtr]['code'] === \T_LIST) {
|
118 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
119 |
+
if ($nextNonEmpty === false
|
120 |
+
|| $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
|
121 |
+
|| isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
|
122 |
+
) {
|
123 |
+
// Parse error or live coding.
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
|
127 |
+
$opener = $nextNonEmpty;
|
128 |
+
$closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
|
129 |
+
} else {
|
130 |
+
// Short list syntax.
|
131 |
+
$opener = $stackPtr;
|
132 |
+
|
133 |
+
if (isset($tokens[$stackPtr]['bracket_closer'])) {
|
134 |
+
$closer = $tokens[$stackPtr]['bracket_closer'];
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
if (isset($opener, $closer) === false) {
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->examineList($phpcsFile, $opener, $closer);
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Examine the contents of a list construct to determine whether an error needs to be thrown.
|
148 |
+
*
|
149 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
150 |
+
* @param int $opener The position of the list open token.
|
151 |
+
* @param int $closer The position of the list close token.
|
152 |
+
*
|
153 |
+
* @return void
|
154 |
+
*/
|
155 |
+
protected function examineList(File $phpcsFile, $opener, $closer)
|
156 |
+
{
|
157 |
+
$start = $opener;
|
158 |
+
while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
|
159 |
+
$phpcsFile->addError(
|
160 |
+
'Specifying keys in list constructs is not supported in PHP 7.0 or earlier.',
|
161 |
+
$start,
|
162 |
+
'Found'
|
163 |
+
);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Check whether a certain target token exists within a list construct.
|
170 |
+
*
|
171 |
+
* Skips past nested list constructs, so these can be examined based on their own token.
|
172 |
+
*
|
173 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
174 |
+
* @param int $start The position of the list open token or a token
|
175 |
+
* within the list to start (resume) the examination from.
|
176 |
+
* @param int $closer The position of the list close token.
|
177 |
+
*
|
178 |
+
* @return int|bool Stack pointer to the target token if encountered. False otherwise.
|
179 |
+
*/
|
180 |
+
protected function hasTargetInList(File $phpcsFile, $start, $closer)
|
181 |
+
{
|
182 |
+
$tokens = $phpcsFile->getTokens();
|
183 |
+
|
184 |
+
for ($i = ($start + 1); $i < $closer; $i++) {
|
185 |
+
if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
|
186 |
+
continue;
|
187 |
+
}
|
188 |
+
|
189 |
+
if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
|
190 |
+
return $i;
|
191 |
+
}
|
192 |
+
|
193 |
+
// Skip past nested list constructs.
|
194 |
+
if ($tokens[$i]['code'] === \T_LIST) {
|
195 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
|
196 |
+
if ($nextNonEmpty !== false
|
197 |
+
&& $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
|
198 |
+
&& isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
|
199 |
+
) {
|
200 |
+
$i = $tokens[$nextNonEmpty]['parenthesis_closer'];
|
201 |
+
}
|
202 |
+
} elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
|
203 |
+
&& isset($tokens[$i]['bracket_closer'])
|
204 |
+
) {
|
205 |
+
$i = $tokens[$i]['bracket_closer'];
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
return false;
|
210 |
+
}
|
211 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/NewListReferenceAssignmentSniff.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Lists\NewListReferenceAssignmentSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.3
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\Lists;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniffs\Lists\NewKeyedListSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Detect reference assignments in array destructuring using (short) list.
|
19 |
+
*
|
20 |
+
* PHP version 7.3
|
21 |
+
*
|
22 |
+
* @category PHP
|
23 |
+
* @package PHPCompatibility
|
24 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
25 |
+
*/
|
26 |
+
class NewListReferenceAssignmentSniff extends NewKeyedListSniff
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* The token(s) within the list construct which is being targeted.
|
30 |
+
*
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
protected $targetsInList = array(
|
34 |
+
\T_BITWISE_AND => \T_BITWISE_AND,
|
35 |
+
);
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Do a version check to determine if this sniff needs to run at all.
|
39 |
+
*
|
40 |
+
* @return bool
|
41 |
+
*/
|
42 |
+
protected function bowOutEarly()
|
43 |
+
{
|
44 |
+
return ($this->supportsBelow('7.2') === false);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Examine the contents of a list construct to determine whether an error needs to be thrown.
|
49 |
+
*
|
50 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
51 |
+
* @param int $opener The position of the list open token.
|
52 |
+
* @param int $closer The position of the list close token.
|
53 |
+
*
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
protected function examineList(File $phpcsFile, $opener, $closer)
|
57 |
+
{
|
58 |
+
$start = $opener;
|
59 |
+
while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
|
60 |
+
$phpcsFile->addError(
|
61 |
+
'Reference assignments within list constructs are not supported in PHP 7.2 or earlier.',
|
62 |
+
$start,
|
63 |
+
'Found'
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Lists/NewShortListSniff.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Lists\NewShortListSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.1
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\Lists;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Lists\NewShortListSniff.
|
19 |
+
*
|
20 |
+
* "The shorthand array syntax ([]) may now be used to destructure arrays for
|
21 |
+
* assignments (including within foreach), as an alternative to the existing
|
22 |
+
* list() syntax, which is still supported."
|
23 |
+
*
|
24 |
+
* PHP version 7.1
|
25 |
+
*
|
26 |
+
* @category PHP
|
27 |
+
* @package PHPCompatibility
|
28 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
29 |
+
*/
|
30 |
+
class NewShortListSniff extends Sniff
|
31 |
+
{
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns an array of tokens this test wants to listen for.
|
35 |
+
*
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function register()
|
39 |
+
{
|
40 |
+
return array(\T_OPEN_SHORT_ARRAY);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Processes this test, when one of its tokens is encountered.
|
45 |
+
*
|
46 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
47 |
+
* @param int $stackPtr The position of the current token in the
|
48 |
+
* stack passed in $tokens.
|
49 |
+
*
|
50 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
51 |
+
* normal file processing.
|
52 |
+
*/
|
53 |
+
public function process(File $phpcsFile, $stackPtr)
|
54 |
+
{
|
55 |
+
if ($this->supportsBelow('7.0') === false) {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($this->isShortList($phpcsFile, $stackPtr) === false) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
$tokens = $phpcsFile->getTokens();
|
64 |
+
$closer = $tokens[$stackPtr]['bracket_closer'];
|
65 |
+
|
66 |
+
$hasVariable = $phpcsFile->findNext(\T_VARIABLE, ($stackPtr + 1), $closer);
|
67 |
+
if ($hasVariable === false) {
|
68 |
+
// List syntax is only valid if there are variables in it.
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
$phpcsFile->addError(
|
73 |
+
'The shorthand list syntax "[]" to destructure arrays is not available in PHP 7.0 or earlier.',
|
74 |
+
$stackPtr,
|
75 |
+
'Found'
|
76 |
+
);
|
77 |
+
|
78 |
+
return ($closer + 1);
|
79 |
+
}
|
80 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/MethodUse/ForbiddenToStringParametersSniff.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\MethodUse;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* As of PHP 5.3, the __toString() magic method can no longer be passed arguments.
|
19 |
+
*
|
20 |
+
* Sister-sniff to PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameters.
|
21 |
+
*
|
22 |
+
* @link https://www.php.net/manual/en/migration53.incompatible.php
|
23 |
+
*
|
24 |
+
* PHP version 5.3
|
25 |
+
*
|
26 |
+
* @since 9.2.0
|
27 |
+
*/
|
28 |
+
class ForbiddenToStringParametersSniff extends Sniff
|
29 |
+
{
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns an array of tokens this test wants to listen for.
|
33 |
+
*
|
34 |
+
* @since 9.2.0
|
35 |
+
*
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function register()
|
39 |
+
{
|
40 |
+
return array(
|
41 |
+
\T_DOUBLE_COLON,
|
42 |
+
\T_OBJECT_OPERATOR,
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Processes this test, when one of its tokens is encountered.
|
48 |
+
*
|
49 |
+
* @since 9.2.0
|
50 |
+
*
|
51 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
52 |
+
* @param int $stackPtr The position of the current token
|
53 |
+
* in the stack passed in $tokens.
|
54 |
+
*
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
public function process(File $phpcsFile, $stackPtr)
|
58 |
+
{
|
59 |
+
if ($this->supportsAbove('5.3') === false) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
$tokens = $phpcsFile->getTokens();
|
64 |
+
|
65 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
66 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
|
67 |
+
/*
|
68 |
+
* Not a method call.
|
69 |
+
*
|
70 |
+
* Note: This disregards method calls with the method name in a variable, like:
|
71 |
+
* $method = '__toString';
|
72 |
+
* $obj->$method();
|
73 |
+
* However, that would be very hard to examine reliably anyway.
|
74 |
+
*/
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
if (strtolower($tokens[$nextNonEmpty]['content']) !== '__tostring') {
|
79 |
+
// Not a call to the __clone() method.
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
$openParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
|
84 |
+
if ($openParens === false || $tokens[$openParens]['code'] !== \T_OPEN_PARENTHESIS) {
|
85 |
+
// Not a method call.
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
$closeParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($openParens + 1), null, true);
|
90 |
+
if ($closeParens === false || $tokens[$closeParens]['code'] === \T_CLOSE_PARENTHESIS) {
|
91 |
+
// Not a method call.
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
|
95 |
+
// If we're still here, then this is a call to the __toString() magic method passing parameters.
|
96 |
+
$phpcsFile->addError(
|
97 |
+
'The __toString() magic method will no longer accept passed arguments since PHP 5.3',
|
98 |
+
$stackPtr,
|
99 |
+
'Passed'
|
100 |
+
);
|
101 |
+
}
|
102 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/MethodUse/NewDirectCallsToCloneSniff.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2018 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\MethodUse;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Detect direct calls to the __clone() magic method which is allowed since PHP 7.0.
|
19 |
+
*
|
20 |
+
* "Doing calls like $obj->__clone() is now allowed. This was the only magic method
|
21 |
+
* that had a compile-time check preventing some calls to it, which doesn't make sense.
|
22 |
+
* If we allow all other magic methods to be called, there's no reason to forbid this one."
|
23 |
+
*
|
24 |
+
* PHP version 7.0
|
25 |
+
*
|
26 |
+
* @link https://wiki.php.net/rfc/abstract_syntax_tree#directly_calling_clone_is_allowed
|
27 |
+
*
|
28 |
+
* @since 9.1.0
|
29 |
+
*/
|
30 |
+
class NewDirectCallsToCloneSniff extends Sniff
|
31 |
+
{
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns an array of tokens this test wants to listen for.
|
35 |
+
*
|
36 |
+
* @since 9.1.0
|
37 |
+
*
|
38 |
+
* @return array
|
39 |
+
*/
|
40 |
+
public function register()
|
41 |
+
{
|
42 |
+
return array(
|
43 |
+
\T_DOUBLE_COLON,
|
44 |
+
\T_OBJECT_OPERATOR,
|
45 |
+
);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Processes this test, when one of its tokens is encountered.
|
50 |
+
*
|
51 |
+
* @since 9.1.0
|
52 |
+
*
|
53 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
54 |
+
* @param int $stackPtr The position of the current token in
|
55 |
+
* the stack passed in $tokens.
|
56 |
+
*
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
public function process(File $phpcsFile, $stackPtr)
|
60 |
+
{
|
61 |
+
if ($this->supportsBelow('5.6') === false) {
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
|
65 |
+
$tokens = $phpcsFile->getTokens();
|
66 |
+
|
67 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
68 |
+
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
|
69 |
+
/*
|
70 |
+
* Not a method call.
|
71 |
+
*
|
72 |
+
* Note: This disregards method calls with the method name in a variable, like:
|
73 |
+
* $method = '__clone';
|
74 |
+
* $obj->$method();
|
75 |
+
* However, that would be very hard to examine reliably anyway.
|
76 |
+
*/
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
if (strtolower($tokens[$nextNonEmpty]['content']) !== '__clone') {
|
81 |
+
// Not a call to the __clone() method.
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$nextNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
|
86 |
+
if ($nextNextNonEmpty === false || $tokens[$nextNextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
|
87 |
+
// Not a method call.
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
|
91 |
+
$phpcsFile->addError(
|
92 |
+
'Direct calls to the __clone() magic method are not allowed in PHP 5.6 or earlier.',
|
93 |
+
$nextNonEmpty,
|
94 |
+
'Found'
|
95 |
+
);
|
96 |
+
}
|
97 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Miscellaneous}/RemovedAlternativePHPTagsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Check for usage of alternative PHP tags - removed in PHP 7.0.
|
20 |
*
|
@@ -44,18 +45,17 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
44 |
*/
|
45 |
public function register()
|
46 |
{
|
47 |
-
if (version_compare(PHP_VERSION_ID, '70000', '<') === true) {
|
48 |
-
// phpcs:ignore PHPCompatibility.
|
49 |
$this->aspTags = (bool) ini_get('asp_tags');
|
50 |
}
|
51 |
|
52 |
return array(
|
53 |
-
T_OPEN_TAG,
|
54 |
-
T_OPEN_TAG_WITH_ECHO,
|
55 |
-
T_INLINE_HTML,
|
56 |
);
|
57 |
-
|
58 |
-
}//end register()
|
59 |
|
60 |
|
61 |
/**
|
@@ -67,7 +67,7 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
-
public function process(
|
71 |
{
|
72 |
if ($this->supportsAbove('7.0') === false) {
|
73 |
return;
|
@@ -81,7 +81,7 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
81 |
return;
|
82 |
}
|
83 |
|
84 |
-
if ($openTag['code'] === T_OPEN_TAG || $openTag['code'] === T_OPEN_TAG_WITH_ECHO) {
|
85 |
|
86 |
if ($content === '<%' || $content === '<%=') {
|
87 |
$data = array(
|
@@ -102,7 +102,7 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
102 |
}
|
103 |
// Account for incorrect script open tags.
|
104 |
// The "(?:<s)?" in the regex is to work-around a bug in the tokenizer in PHP 5.2.
|
105 |
-
elseif ($openTag['code'] === T_INLINE_HTML
|
106 |
&& preg_match('`((?:<s)?cript (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
|
107 |
) {
|
108 |
$found = $match[1];
|
@@ -124,7 +124,7 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
124 |
}
|
125 |
|
126 |
// If we're still here, we can't be sure if what we find was really intended as ASP open tags.
|
127 |
-
if ($openTag['code'] === T_INLINE_HTML && $this->aspTags === false) {
|
128 |
if (strpos($content, '<%') !== false) {
|
129 |
$error = 'Possible use of ASP style opening tags detected. ASP style opening tags have been removed in PHP 7.0. Found: %s';
|
130 |
$snippet = $this->getSnippet($content, '<%');
|
@@ -133,8 +133,7 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
133 |
$phpcsFile->addWarning($error, $stackPtr, 'MaybeASPOpenTagFound', $data);
|
134 |
}
|
135 |
}
|
136 |
-
|
137 |
-
}//end process()
|
138 |
|
139 |
|
140 |
/**
|
@@ -153,17 +152,15 @@ class RemovedAlternativePHPTagsSniff extends Sniff
|
|
153 |
if ($startAt !== '') {
|
154 |
$startPos = strpos($content, $startAt);
|
155 |
if ($startPos !== false) {
|
156 |
-
$startPos += strlen($startAt);
|
157 |
}
|
158 |
}
|
159 |
|
160 |
$snippet = substr($content, $startPos, $length);
|
161 |
-
if ((strlen($content) - $startPos) > $length) {
|
162 |
$snippet .= '...';
|
163 |
}
|
164 |
|
165 |
return $snippet;
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Miscellaneous\RemovedAlternativePHPTags.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Miscellaneous;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Miscellaneous\RemovedAlternativePHPTags.
|
19 |
*
|
20 |
* Check for usage of alternative PHP tags - removed in PHP 7.0.
|
21 |
*
|
45 |
*/
|
46 |
public function register()
|
47 |
{
|
48 |
+
if (version_compare(\PHP_VERSION_ID, '70000', '<') === true) {
|
49 |
+
// phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.asp_tagsRemoved
|
50 |
$this->aspTags = (bool) ini_get('asp_tags');
|
51 |
}
|
52 |
|
53 |
return array(
|
54 |
+
\T_OPEN_TAG,
|
55 |
+
\T_OPEN_TAG_WITH_ECHO,
|
56 |
+
\T_INLINE_HTML,
|
57 |
);
|
58 |
+
}
|
|
|
59 |
|
60 |
|
61 |
/**
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
+
public function process(File $phpcsFile, $stackPtr)
|
71 |
{
|
72 |
if ($this->supportsAbove('7.0') === false) {
|
73 |
return;
|
81 |
return;
|
82 |
}
|
83 |
|
84 |
+
if ($openTag['code'] === \T_OPEN_TAG || $openTag['code'] === \T_OPEN_TAG_WITH_ECHO) {
|
85 |
|
86 |
if ($content === '<%' || $content === '<%=') {
|
87 |
$data = array(
|
102 |
}
|
103 |
// Account for incorrect script open tags.
|
104 |
// The "(?:<s)?" in the regex is to work-around a bug in the tokenizer in PHP 5.2.
|
105 |
+
elseif ($openTag['code'] === \T_INLINE_HTML
|
106 |
&& preg_match('`((?:<s)?cript (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
|
107 |
) {
|
108 |
$found = $match[1];
|
124 |
}
|
125 |
|
126 |
// If we're still here, we can't be sure if what we find was really intended as ASP open tags.
|
127 |
+
if ($openTag['code'] === \T_INLINE_HTML && $this->aspTags === false) {
|
128 |
if (strpos($content, '<%') !== false) {
|
129 |
$error = 'Possible use of ASP style opening tags detected. ASP style opening tags have been removed in PHP 7.0. Found: %s';
|
130 |
$snippet = $this->getSnippet($content, '<%');
|
133 |
$phpcsFile->addWarning($error, $stackPtr, 'MaybeASPOpenTagFound', $data);
|
134 |
}
|
135 |
}
|
136 |
+
}
|
|
|
137 |
|
138 |
|
139 |
/**
|
152 |
if ($startAt !== '') {
|
153 |
$startPos = strpos($content, $startAt);
|
154 |
if ($startPos !== false) {
|
155 |
+
$startPos += \strlen($startAt);
|
156 |
}
|
157 |
}
|
158 |
|
159 |
$snippet = substr($content, $startPos, $length);
|
160 |
+
if ((\strlen($content) - $startPos) > $length) {
|
161 |
$snippet .= '...';
|
162 |
}
|
163 |
|
164 |
return $snippet;
|
165 |
+
}
|
166 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Miscellaneous}/ValidIntegersSniff.php
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\Sniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -35,14 +36,13 @@ class ValidIntegersSniff extends Sniff
|
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
-
$this->isLowPHPVersion = version_compare(PHP_VERSION_ID, '50400', '<');
|
39 |
|
40 |
return array(
|
41 |
-
T_LNUMBER, // Binary, octal integers.
|
42 |
-
T_CONSTANT_ENCAPSED_STRING, // Hex numeric string.
|
43 |
);
|
44 |
-
|
45 |
-
}//end register()
|
46 |
|
47 |
|
48 |
/**
|
@@ -54,7 +54,7 @@ class ValidIntegersSniff extends Sniff
|
|
54 |
*
|
55 |
* @return void
|
56 |
*/
|
57 |
-
public function process(
|
58 |
{
|
59 |
$tokens = $phpcsFile->getTokens();
|
60 |
$token = $tokens[$stackPtr];
|
@@ -104,8 +104,7 @@ class ValidIntegersSniff extends Sniff
|
|
104 |
);
|
105 |
return;
|
106 |
}
|
107 |
-
|
108 |
-
}//end process()
|
109 |
|
110 |
|
111 |
/**
|
@@ -120,7 +119,7 @@ class ValidIntegersSniff extends Sniff
|
|
120 |
{
|
121 |
$token = $tokens[$stackPtr];
|
122 |
|
123 |
-
if ($token['code'] !== T_LNUMBER) {
|
124 |
return false;
|
125 |
}
|
126 |
|
@@ -130,7 +129,7 @@ class ValidIntegersSniff extends Sniff
|
|
130 |
// Pre-5.4, binary strings are tokenized as T_LNUMBER (0) + T_STRING ("b01010101").
|
131 |
// At this point, we don't yet care whether it's a valid binary int, that's a separate check.
|
132 |
else {
|
133 |
-
return($token['content'] === '0' && $tokens[$stackPtr + 1]['code'] === T_STRING && preg_match('`^b[0-9]+$`D', $tokens[$stackPtr + 1]['content']) === 1);
|
134 |
}
|
135 |
}
|
136 |
|
@@ -150,7 +149,7 @@ class ValidIntegersSniff extends Sniff
|
|
150 |
|
151 |
if ($this->isLowPHPVersion === false) {
|
152 |
// If it's an invalid binary int, the token will be split into two T_LNUMBER tokens.
|
153 |
-
return ($tokens[$stackPtr + 1]['code'] === T_LNUMBER);
|
154 |
} else {
|
155 |
return (preg_match('`^b[0-1]+$`D', $tokens[$stackPtr + 1]['content']) === 0);
|
156 |
}
|
@@ -166,13 +165,13 @@ class ValidIntegersSniff extends Sniff
|
|
166 |
*
|
167 |
* @return string
|
168 |
*/
|
169 |
-
private function getBinaryInteger(
|
170 |
{
|
171 |
$length = 2; // PHP < 5.4 T_LNUMBER + T_STRING.
|
172 |
|
173 |
if ($this->isLowPHPVersion === false) {
|
174 |
$i = $stackPtr;
|
175 |
-
while ($tokens[$i]['code'] === T_LNUMBER) {
|
176 |
$i++;
|
177 |
}
|
178 |
$length = ($i - $stackPtr);
|
@@ -193,7 +192,7 @@ class ValidIntegersSniff extends Sniff
|
|
193 |
{
|
194 |
$token = $tokens[$stackPtr];
|
195 |
|
196 |
-
if ($token['code'] === T_LNUMBER && preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $token['content']) === 1) {
|
197 |
return true;
|
198 |
}
|
199 |
|
@@ -212,11 +211,10 @@ class ValidIntegersSniff extends Sniff
|
|
212 |
{
|
213 |
$token = $tokens[$stackPtr];
|
214 |
|
215 |
-
if ($token['code'] === T_CONSTANT_ENCAPSED_STRING && preg_match('`^0x[a-f0-9]+$`iD', $this->stripQuotes($token['content'])) === 1) {
|
216 |
return true;
|
217 |
}
|
218 |
|
219 |
return false;
|
220 |
}
|
221 |
-
|
222 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Miscellaneous\ValidIntegersSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\Miscellaneous;
|
11 |
|
12 |
use PHPCompatibility\Sniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\Miscellaneous\ValidIntegersSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
36 |
*/
|
37 |
public function register()
|
38 |
{
|
39 |
+
$this->isLowPHPVersion = version_compare(\PHP_VERSION_ID, '50400', '<');
|
40 |
|
41 |
return array(
|
42 |
+
\T_LNUMBER, // Binary, octal integers.
|
43 |
+
\T_CONSTANT_ENCAPSED_STRING, // Hex numeric string.
|
44 |
);
|
45 |
+
}
|
|
|
46 |
|
47 |
|
48 |
/**
|
54 |
*
|
55 |
* @return void
|
56 |
*/
|
57 |
+
public function process(File $phpcsFile, $stackPtr)
|
58 |
{
|
59 |
$tokens = $phpcsFile->getTokens();
|
60 |
$token = $tokens[$stackPtr];
|
104 |
);
|
105 |
return;
|
106 |
}
|
107 |
+
}
|
|
|
108 |
|
109 |
|
110 |
/**
|
119 |
{
|
120 |
$token = $tokens[$stackPtr];
|
121 |
|
122 |
+
if ($token['code'] !== \T_LNUMBER) {
|
123 |
return false;
|
124 |
}
|
125 |
|
129 |
// Pre-5.4, binary strings are tokenized as T_LNUMBER (0) + T_STRING ("b01010101").
|
130 |
// At this point, we don't yet care whether it's a valid binary int, that's a separate check.
|
131 |
else {
|
132 |
+
return($token['content'] === '0' && $tokens[$stackPtr + 1]['code'] === \T_STRING && preg_match('`^b[0-9]+$`D', $tokens[$stackPtr + 1]['content']) === 1);
|
133 |
}
|
134 |
}
|
135 |
|
149 |
|
150 |
if ($this->isLowPHPVersion === false) {
|
151 |
// If it's an invalid binary int, the token will be split into two T_LNUMBER tokens.
|
152 |
+
return ($tokens[$stackPtr + 1]['code'] === \T_LNUMBER);
|
153 |
} else {
|
154 |
return (preg_match('`^b[0-1]+$`D', $tokens[$stackPtr + 1]['content']) === 0);
|
155 |
}
|
165 |
*
|
166 |
* @return string
|
167 |
*/
|
168 |
+
private function getBinaryInteger(File $phpcsFile, $tokens, $stackPtr)
|
169 |
{
|
170 |
$length = 2; // PHP < 5.4 T_LNUMBER + T_STRING.
|
171 |
|
172 |
if ($this->isLowPHPVersion === false) {
|
173 |
$i = $stackPtr;
|
174 |
+
while ($tokens[$i]['code'] === \T_LNUMBER) {
|
175 |
$i++;
|
176 |
}
|
177 |
$length = ($i - $stackPtr);
|
192 |
{
|
193 |
$token = $tokens[$stackPtr];
|
194 |
|
195 |
+
if ($token['code'] === \T_LNUMBER && preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $token['content']) === 1) {
|
196 |
return true;
|
197 |
}
|
198 |
|
211 |
{
|
212 |
$token = $tokens[$stackPtr];
|
213 |
|
214 |
+
if ($token['code'] === \T_CONSTANT_ENCAPSED_STRING && preg_match('`^0x[a-f0-9]+$`iD', $this->stripQuotes($token['content'])) === 1) {
|
215 |
return true;
|
216 |
}
|
217 |
|
218 |
return false;
|
219 |
}
|
220 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/ChangedConcatOperatorPrecedenceSniff.php
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Operators;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The operator precedence of concatenation will be lowered in PHP 8.0.
|
19 |
+
*
|
20 |
+
* In PHP < 8.0 the operator precedence of `.`, `+` and `-` are the same.
|
21 |
+
* As of PHP 8.0, the operator precedence of the concatenation operator will be
|
22 |
+
* lowered to be right below the '«' and '»' operators.
|
23 |
+
*
|
24 |
+
* As of PHP 7.4, a deprecation warning will be thrown upon encountering an
|
25 |
+
* unparenthesized expression containing an '.' before a '+' or '-'.
|
26 |
+
*
|
27 |
+
* PHP version 7.4
|
28 |
+
* PHP version 8.0
|
29 |
+
*
|
30 |
+
* @link https://wiki.php.net/rfc/concatenation_precedence
|
31 |
+
* @link https://www.php.net/manual/en/language.operators.precedence.php
|
32 |
+
*
|
33 |
+
* @since 9.2.0
|
34 |
+
*/
|
35 |
+
class ChangedConcatOperatorPrecedenceSniff extends Sniff
|
36 |
+
{
|
37 |
+
|
38 |
+
/**
|
39 |
+
* List of tokens with a lower operator precedence than concatenation in PHP >= 8.0.
|
40 |
+
*
|
41 |
+
* @since 9.2.0
|
42 |
+
*
|
43 |
+
* @var array
|
44 |
+
*/
|
45 |
+
private $tokensWithLowerPrecedence = array(
|
46 |
+
'T_BITWISE_AND' => true,
|
47 |
+
'T_BITWISE_XOR' => true,
|
48 |
+
'T_BITWISE_OR' => true,
|
49 |
+
'T_COALESCE' => true,
|
50 |
+
'T_INLINE_THEN' => true,
|
51 |
+
'T_INLINE_ELSE' => true,
|
52 |
+
'T_YIELD_FROM' => true,
|
53 |
+
'T_YIELD' => true,
|
54 |
+
);
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Returns an array of tokens this test wants to listen for.
|
59 |
+
*
|
60 |
+
* @since 9.2.0
|
61 |
+
*
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
public function register()
|
65 |
+
{
|
66 |
+
return array(
|
67 |
+
\T_PLUS,
|
68 |
+
\T_MINUS,
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Processes this test, when one of its tokens is encountered.
|
74 |
+
*
|
75 |
+
* @since 9.2.0
|
76 |
+
*
|
77 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
78 |
+
* @param int $stackPtr The position of the current token in the
|
79 |
+
* stack passed in $tokens.
|
80 |
+
*
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
public function process(File $phpcsFile, $stackPtr)
|
84 |
+
{
|
85 |
+
if ($this->supportsAbove('7.4') === false) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($this->isUnaryPlusMinus($phpcsFile, $stackPtr) === true) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
$tokens = $phpcsFile->getTokens();
|
94 |
+
|
95 |
+
for ($i = ($stackPtr - 1); $stackPtr >= 0; $i--) {
|
96 |
+
if ($tokens[$i]['code'] === \T_STRING_CONCAT) {
|
97 |
+
// Found one.
|
98 |
+
break;
|
99 |
+
}
|
100 |
+
|
101 |
+
if ($tokens[$i]['code'] === \T_SEMICOLON
|
102 |
+
|| $tokens[$i]['code'] === \T_OPEN_CURLY_BRACKET
|
103 |
+
|| $tokens[$i]['code'] === \T_OPEN_TAG
|
104 |
+
|| $tokens[$i]['code'] === \T_OPEN_TAG_WITH_ECHO
|
105 |
+
|| $tokens[$i]['code'] === \T_COMMA
|
106 |
+
|| $tokens[$i]['code'] === \T_COLON
|
107 |
+
|| $tokens[$i]['code'] === \T_CASE
|
108 |
+
) {
|
109 |
+
// If we reached any of the above tokens, we've reached the end of
|
110 |
+
// the statement without encountering a concatenation operator.
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
|
114 |
+
if ($tokens[$i]['code'] === \T_OPEN_CURLY_BRACKET
|
115 |
+
&& isset($tokens[$i]['bracket_closer'])
|
116 |
+
&& $tokens[$i]['bracket_closer'] > $stackPtr
|
117 |
+
) {
|
118 |
+
// No need to look any further, this is plus/minus within curly braces
|
119 |
+
// and we've reached the open curly.
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
|
123 |
+
if ($tokens[$i]['code'] === \T_OPEN_PARENTHESIS
|
124 |
+
&& isset($tokens[$i]['parenthesis_closer'])
|
125 |
+
&& $tokens[$i]['parenthesis_closer'] > $stackPtr
|
126 |
+
) {
|
127 |
+
// No need to look any further, this is plus/minus within parenthesis
|
128 |
+
// and we've reached the open parenthesis.
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
|
132 |
+
if (($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
|
133 |
+
|| $tokens[$i]['code'] === \T_OPEN_SQUARE_BRACKET)
|
134 |
+
&& isset($tokens[$i]['bracket_closer'])
|
135 |
+
&& $tokens[$i]['bracket_closer'] > $stackPtr
|
136 |
+
) {
|
137 |
+
// No need to look any further, this is plus/minus within a short array
|
138 |
+
// or array key square brackets and we've reached the opener.
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
if ($tokens[$i]['code'] === \T_CLOSE_CURLY_BRACKET) {
|
143 |
+
if (isset($tokens[$i]['scope_owner'])) {
|
144 |
+
// Different scope, we've passed the start of the statement.
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
if (isset($tokens[$i]['bracket_opener'])) {
|
149 |
+
$i = $tokens[$i]['bracket_opener'];
|
150 |
+
}
|
151 |
+
|
152 |
+
continue;
|
153 |
+
}
|
154 |
+
|
155 |
+
if ($tokens[$i]['code'] === \T_CLOSE_PARENTHESIS
|
156 |
+
&& isset($tokens[$i]['parenthesis_opener'])
|
157 |
+
) {
|
158 |
+
// Skip over statements in parenthesis, including long arrays.
|
159 |
+
$i = $tokens[$i]['parenthesis_opener'];
|
160 |
+
continue;
|
161 |
+
}
|
162 |
+
|
163 |
+
if (($tokens[$i]['code'] === \T_CLOSE_SQUARE_BRACKET
|
164 |
+
|| $tokens[$i]['code'] === \T_CLOSE_SHORT_ARRAY)
|
165 |
+
&& isset($tokens[$i]['bracket_opener'])
|
166 |
+
) {
|
167 |
+
// Skip over array keys and short arrays.
|
168 |
+
$i = $tokens[$i]['bracket_opener'];
|
169 |
+
continue;
|
170 |
+
}
|
171 |
+
|
172 |
+
// Check for chain being broken by a token with a lower precedence.
|
173 |
+
if (isset(Tokens::$booleanOperators[$tokens[$i]['code']]) === true
|
174 |
+
|| isset(Tokens::$assignmentTokens[$tokens[$i]['code']]) === true
|
175 |
+
) {
|
176 |
+
return;
|
177 |
+
}
|
178 |
+
|
179 |
+
if (isset($this->tokensWithLowerPrecedence[$tokens[$i]['type']]) === true) {
|
180 |
+
if ($tokens[$i]['code'] === \T_BITWISE_AND
|
181 |
+
&& $phpcsFile->isReference($i) === true
|
182 |
+
) {
|
183 |
+
continue;
|
184 |
+
}
|
185 |
+
|
186 |
+
return;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
$message = 'Using an unparenthesized expression containing a "." before a "+" or "-" has been deprecated in PHP 7.4';
|
191 |
+
$isError = false;
|
192 |
+
if ($this->supportsAbove('8.0') === true) {
|
193 |
+
$message .= ' and removed in PHP 8.0';
|
194 |
+
$isError = true;
|
195 |
+
}
|
196 |
+
|
197 |
+
$this->addMessage($phpcsFile, $message, $i, $isError);
|
198 |
+
}
|
199 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Operators}/ForbiddenNegativeBitshiftSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,13 +9,15 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0.
|
21 |
*
|
@@ -37,10 +39,10 @@ class ForbiddenNegativeBitshiftSniff extends Sniff
|
|
37 |
* @var array
|
38 |
*/
|
39 |
private $inclusiveStopPoints = array(
|
40 |
-
T_COLON => true,
|
41 |
-
T_COMMA => true,
|
42 |
-
T_DOUBLE_ARROW => true,
|
43 |
-
T_SEMICOLON => true,
|
44 |
);
|
45 |
|
46 |
/**
|
@@ -51,13 +53,12 @@ class ForbiddenNegativeBitshiftSniff extends Sniff
|
|
51 |
public function register()
|
52 |
{
|
53 |
return array(
|
54 |
-
T_SL,
|
55 |
-
T_SL_EQUAL,
|
56 |
-
T_SR,
|
57 |
-
T_SR_EQUAL,
|
58 |
);
|
59 |
-
|
60 |
-
}//end register()
|
61 |
|
62 |
/**
|
63 |
* Processes this test, when one of its tokens is encountered.
|
@@ -68,7 +69,7 @@ class ForbiddenNegativeBitshiftSniff extends Sniff
|
|
68 |
*
|
69 |
* @return void
|
70 |
*/
|
71 |
-
public function process(
|
72 |
{
|
73 |
if ($this->supportsAbove('7.0') === false) {
|
74 |
return;
|
@@ -78,8 +79,8 @@ class ForbiddenNegativeBitshiftSniff extends Sniff
|
|
78 |
|
79 |
// Determine the start and end of the part of the statement we need to examine.
|
80 |
$start = ($stackPtr + 1);
|
81 |
-
$next = $phpcsFile->findNext(
|
82 |
-
if ($next !== false && $tokens[$next]['code'] === T_OPEN_PARENTHESIS) {
|
83 |
$start = ($next + 1);
|
84 |
}
|
85 |
|
@@ -99,7 +100,5 @@ class ForbiddenNegativeBitshiftSniff extends Sniff
|
|
99 |
'Found',
|
100 |
array($phpcsFile->getTokensAsString($start, ($end - $start + 1)))
|
101 |
);
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Operators\ForbiddenNegativeBitshift.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Operators;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\Operators\ForbiddenNegativeBitshift.
|
21 |
*
|
22 |
* Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0.
|
23 |
*
|
39 |
* @var array
|
40 |
*/
|
41 |
private $inclusiveStopPoints = array(
|
42 |
+
\T_COLON => true,
|
43 |
+
\T_COMMA => true,
|
44 |
+
\T_DOUBLE_ARROW => true,
|
45 |
+
\T_SEMICOLON => true,
|
46 |
);
|
47 |
|
48 |
/**
|
53 |
public function register()
|
54 |
{
|
55 |
return array(
|
56 |
+
\T_SL,
|
57 |
+
\T_SL_EQUAL,
|
58 |
+
\T_SR,
|
59 |
+
\T_SR_EQUAL,
|
60 |
);
|
61 |
+
}
|
|
|
62 |
|
63 |
/**
|
64 |
* Processes this test, when one of its tokens is encountered.
|
69 |
*
|
70 |
* @return void
|
71 |
*/
|
72 |
+
public function process(File $phpcsFile, $stackPtr)
|
73 |
{
|
74 |
if ($this->supportsAbove('7.0') === false) {
|
75 |
return;
|
79 |
|
80 |
// Determine the start and end of the part of the statement we need to examine.
|
81 |
$start = ($stackPtr + 1);
|
82 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, $start, null, true);
|
83 |
+
if ($next !== false && $tokens[$next]['code'] === \T_OPEN_PARENTHESIS) {
|
84 |
$start = ($next + 1);
|
85 |
}
|
86 |
|
100 |
'Found',
|
101 |
array($phpcsFile->getTokensAsString($start, ($end - $start + 1)))
|
102 |
);
|
103 |
+
}
|
104 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewLanguageConstructsSniff.php → Operators/NewOperatorsSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
@@ -8,93 +8,84 @@
|
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
-
namespace PHPCompatibility\Sniffs\
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
20 |
* @author Wim Godden <wim.godden@cu.be>
|
21 |
* @copyright 2013 Cu.be Solutions bvba
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
|
26 |
/**
|
27 |
-
* A list of new
|
28 |
*
|
29 |
* The array lists : version number with false (not present) or true (present).
|
30 |
* If's sufficient to list the first version where the keyword appears.
|
31 |
*
|
32 |
* @var array(string => array(string => int|string|null))
|
33 |
*/
|
34 |
-
protected $
|
35 |
-
'T_NS_SEPARATOR' => array(
|
36 |
-
'5.2' => false,
|
37 |
-
'5.3' => true,
|
38 |
-
'description' => 'the \ operator (for namespaces)',
|
39 |
-
),
|
40 |
'T_POW' => array(
|
41 |
'5.5' => false,
|
42 |
'5.6' => true,
|
43 |
'description' => 'power operator (**)',
|
44 |
-
), // Identified in PHPCS
|
45 |
'T_POW_EQUAL' => array(
|
46 |
'5.5' => false,
|
47 |
'5.6' => true,
|
48 |
'description' => 'power assignment operator (**=)',
|
49 |
-
), // Identified in PHPCS
|
50 |
-
'T_ELLIPSIS' => array(
|
51 |
-
'5.5' => false,
|
52 |
-
'5.6' => true,
|
53 |
-
'description' => 'variadic functions using ...',
|
54 |
-
),
|
55 |
'T_SPACESHIP' => array(
|
56 |
'5.6' => false,
|
57 |
'7.0' => true,
|
58 |
'description' => 'spaceship operator (<=>)',
|
59 |
-
), // Identified in PHPCS
|
60 |
'T_COALESCE' => array(
|
61 |
'5.6' => false,
|
62 |
'7.0' => true,
|
63 |
'description' => 'null coalescing operator (??)',
|
64 |
-
), // Identified in PHPCS
|
65 |
/*
|
66 |
* Was slated for 7.2, but still not implemented. PHPCS however does already tokenize it.
|
67 |
* @link https://wiki.php.net/rfc/null_coalesce_equal_operator
|
68 |
*/
|
69 |
'T_COALESCE_EQUAL' => array(
|
70 |
-
'7.
|
71 |
-
'7.
|
72 |
'description' => 'null coalesce equal operator (??=)',
|
73 |
-
), // Identified in PHPCS
|
74 |
);
|
75 |
|
76 |
|
77 |
/**
|
78 |
-
* A list of new
|
79 |
*
|
80 |
* The array lists an alternative token to listen for.
|
81 |
*
|
82 |
* @var array(string => int)
|
83 |
*/
|
84 |
-
protected $
|
85 |
-
'T_POW' => T_MULTIPLY,
|
86 |
-
'T_POW_EQUAL' => T_MUL_EQUAL,
|
87 |
-
'T_SPACESHIP' => T_GREATER_THAN,
|
88 |
-
'T_COALESCE' => T_INLINE_THEN,
|
89 |
-
'T_COALESCE_EQUAL' => T_EQUAL,
|
90 |
);
|
91 |
|
92 |
/**
|
93 |
-
*
|
94 |
*
|
95 |
* The 'before' index lists the token which would have to be directly before the
|
96 |
-
* token found for it to be one of the new
|
97 |
-
* The 'real_token' index indicates which
|
98 |
*
|
99 |
* If the token combination has multi-layer complexity, such as is the case
|
100 |
* with T_COALESCE(_EQUAL), a 'callback' index is added instead pointing to a
|
@@ -137,15 +128,15 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
137 |
public function register()
|
138 |
{
|
139 |
$tokens = array();
|
140 |
-
foreach ($this->
|
141 |
-
if (defined($token)) {
|
142 |
$tokens[] = constant($token);
|
143 |
-
} elseif (isset($this->
|
144 |
-
$tokens[] = $this->
|
145 |
}
|
146 |
}
|
147 |
return $tokens;
|
148 |
-
}
|
149 |
|
150 |
|
151 |
/**
|
@@ -157,31 +148,31 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
157 |
*
|
158 |
* @return void
|
159 |
*/
|
160 |
-
public function process(
|
161 |
{
|
162 |
$tokens = $phpcsFile->getTokens();
|
163 |
$tokenType = $tokens[$stackPtr]['type'];
|
164 |
|
165 |
-
// Translate older PHPCS token combis for new
|
166 |
-
if (isset($this->
|
167 |
if (isset($this->PHPCSCompatTranslate[$tokenType])
|
168 |
&& ((isset($this->PHPCSCompatTranslate[$tokenType]['before'], $tokens[$stackPtr - 1]) === true
|
169 |
&& $tokens[$stackPtr - 1]['type'] === $this->PHPCSCompatTranslate[$tokenType]['before'])
|
170 |
|| (isset($this->PHPCSCompatTranslate[$tokenType]['callback']) === true
|
171 |
-
&& call_user_func(array($this, $this->PHPCSCompatTranslate[$tokenType]['callback']), $tokens, $stackPtr) === true))
|
172 |
) {
|
173 |
$tokenType = $this->PHPCSCompatTranslate[$tokenType]['real_token'];
|
174 |
}
|
175 |
} elseif ($tokenType === 'T_COALESCE') {
|
176 |
// Make sure that T_COALESCE is not confused with T_COALESCE_EQUAL.
|
177 |
-
if (isset($tokens[($stackPtr + 1)]) !== false && $tokens[($stackPtr + 1)]['code'] === T_EQUAL) {
|
178 |
// Ignore as will be dealt with via the T_EQUAL token.
|
179 |
return;
|
180 |
}
|
181 |
}
|
182 |
|
183 |
// If the translation did not yield one of the tokens we are looking for, bow out.
|
184 |
-
if (isset($this->
|
185 |
return;
|
186 |
}
|
187 |
|
@@ -189,8 +180,7 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
189 |
'name' => $tokenType,
|
190 |
);
|
191 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
192 |
-
|
193 |
-
}//end process()
|
194 |
|
195 |
|
196 |
/**
|
@@ -202,7 +192,7 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
202 |
*/
|
203 |
public function getItemArray(array $itemInfo)
|
204 |
{
|
205 |
-
return $this->
|
206 |
}
|
207 |
|
208 |
|
@@ -231,7 +221,6 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
231 |
$errorInfo['description'] = $itemArray['description'];
|
232 |
|
233 |
return $errorInfo;
|
234 |
-
|
235 |
}
|
236 |
|
237 |
|
@@ -261,7 +250,7 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
261 |
*/
|
262 |
private function isTCoalesceEqual($tokens, $stackPtr)
|
263 |
{
|
264 |
-
if ($tokens[$stackPtr]['code'] !== T_EQUAL || isset($tokens[($stackPtr - 1)]) === false) {
|
265 |
// Function called for wrong token or token has no predecesor.
|
266 |
return false;
|
267 |
}
|
@@ -288,19 +277,18 @@ class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
|
|
288 |
*/
|
289 |
private function isTCoalesce($tokens, $stackPtr)
|
290 |
{
|
291 |
-
if ($tokens[$stackPtr]['code'] !== T_INLINE_THEN || isset($tokens[($stackPtr - 1)]) === false) {
|
292 |
// Function called for wrong token or token has no predecesor.
|
293 |
return false;
|
294 |
}
|
295 |
|
296 |
-
if ($tokens[($stackPtr - 1)]['code'] === T_INLINE_THEN) {
|
297 |
// Make sure not to confuse it with the T_COALESCE_EQUAL token.
|
298 |
-
if (isset($tokens[($stackPtr + 1)]) === false || $tokens[($stackPtr + 1)]['code'] !== T_EQUAL) {
|
299 |
return true;
|
300 |
}
|
301 |
}
|
302 |
|
303 |
return false;
|
304 |
}
|
305 |
-
|
306 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Operators\NewOperatorsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
8 |
* @copyright 2013 Cu.be Solutions bvba
|
9 |
*/
|
10 |
|
11 |
+
namespace PHPCompatibility\Sniffs\Operators;
|
12 |
|
13 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\Operators\NewOperatorsSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
21 |
* @author Wim Godden <wim.godden@cu.be>
|
22 |
* @copyright 2013 Cu.be Solutions bvba
|
23 |
*/
|
24 |
+
class NewOperatorsSniff extends AbstractNewFeatureSniff
|
25 |
{
|
26 |
|
27 |
/**
|
28 |
+
* A list of new operators, not present in older versions.
|
29 |
*
|
30 |
* The array lists : version number with false (not present) or true (present).
|
31 |
* If's sufficient to list the first version where the keyword appears.
|
32 |
*
|
33 |
* @var array(string => array(string => int|string|null))
|
34 |
*/
|
35 |
+
protected $newOperators = array(
|
|
|
|
|
|
|
|
|
|
|
36 |
'T_POW' => array(
|
37 |
'5.5' => false,
|
38 |
'5.6' => true,
|
39 |
'description' => 'power operator (**)',
|
40 |
+
), // Identified in PHP < 5.6 icw PHPCS < 2.4.0 as T_MULTIPLY + T_MULTIPLY.
|
41 |
'T_POW_EQUAL' => array(
|
42 |
'5.5' => false,
|
43 |
'5.6' => true,
|
44 |
'description' => 'power assignment operator (**=)',
|
45 |
+
), // Identified in PHP < 5.6 icw PHPCS < 2.6.0 as T_MULTIPLY + T_MUL_EQUAL.
|
|
|
|
|
|
|
|
|
|
|
46 |
'T_SPACESHIP' => array(
|
47 |
'5.6' => false,
|
48 |
'7.0' => true,
|
49 |
'description' => 'spaceship operator (<=>)',
|
50 |
+
), // Identified in PHP < 7.0 icw PHPCS < 2.5.1 as T_IS_SMALLER_OR_EQUAL + T_GREATER_THAN.
|
51 |
'T_COALESCE' => array(
|
52 |
'5.6' => false,
|
53 |
'7.0' => true,
|
54 |
'description' => 'null coalescing operator (??)',
|
55 |
+
), // Identified in PHP < 7.0 icw PHPCS < 2.6.2 as T_INLINE_THEN + T_INLINE_THEN.
|
56 |
/*
|
57 |
* Was slated for 7.2, but still not implemented. PHPCS however does already tokenize it.
|
58 |
* @link https://wiki.php.net/rfc/null_coalesce_equal_operator
|
59 |
*/
|
60 |
'T_COALESCE_EQUAL' => array(
|
61 |
+
'7.3' => false,
|
62 |
+
'7.4' => true,
|
63 |
'description' => 'null coalesce equal operator (??=)',
|
64 |
+
), // Identified in PHP < 7.0 icw PHPCS < 2.6.2 as T_INLINE_THEN + T_INLINE_THEN + T_EQUAL and between PHPCS 2.6.2 and PHPCS 2.8.1 as T_COALESCE + T_EQUAL.
|
65 |
);
|
66 |
|
67 |
|
68 |
/**
|
69 |
+
* A list of new operators which are not recognized in older PHPCS versions.
|
70 |
*
|
71 |
* The array lists an alternative token to listen for.
|
72 |
*
|
73 |
* @var array(string => int)
|
74 |
*/
|
75 |
+
protected $newOperatorsPHPCSCompat = array(
|
76 |
+
'T_POW' => \T_MULTIPLY,
|
77 |
+
'T_POW_EQUAL' => \T_MUL_EQUAL,
|
78 |
+
'T_SPACESHIP' => \T_GREATER_THAN,
|
79 |
+
'T_COALESCE' => \T_INLINE_THEN,
|
80 |
+
'T_COALESCE_EQUAL' => \T_EQUAL,
|
81 |
);
|
82 |
|
83 |
/**
|
84 |
+
* Token translation table for older PHPCS versions.
|
85 |
*
|
86 |
* The 'before' index lists the token which would have to be directly before the
|
87 |
+
* token found for it to be one of the new operators.
|
88 |
+
* The 'real_token' index indicates which operator was found in that case.
|
89 |
*
|
90 |
* If the token combination has multi-layer complexity, such as is the case
|
91 |
* with T_COALESCE(_EQUAL), a 'callback' index is added instead pointing to a
|
128 |
public function register()
|
129 |
{
|
130 |
$tokens = array();
|
131 |
+
foreach ($this->newOperators as $token => $versions) {
|
132 |
+
if (\defined($token)) {
|
133 |
$tokens[] = constant($token);
|
134 |
+
} elseif (isset($this->newOperatorsPHPCSCompat[$token])) {
|
135 |
+
$tokens[] = $this->newOperatorsPHPCSCompat[$token];
|
136 |
}
|
137 |
}
|
138 |
return $tokens;
|
139 |
+
}
|
140 |
|
141 |
|
142 |
/**
|
148 |
*
|
149 |
* @return void
|
150 |
*/
|
151 |
+
public function process(File $phpcsFile, $stackPtr)
|
152 |
{
|
153 |
$tokens = $phpcsFile->getTokens();
|
154 |
$tokenType = $tokens[$stackPtr]['type'];
|
155 |
|
156 |
+
// Translate older PHPCS token combis for new operators to the actual operator.
|
157 |
+
if (isset($this->newOperators[$tokenType]) === false) {
|
158 |
if (isset($this->PHPCSCompatTranslate[$tokenType])
|
159 |
&& ((isset($this->PHPCSCompatTranslate[$tokenType]['before'], $tokens[$stackPtr - 1]) === true
|
160 |
&& $tokens[$stackPtr - 1]['type'] === $this->PHPCSCompatTranslate[$tokenType]['before'])
|
161 |
|| (isset($this->PHPCSCompatTranslate[$tokenType]['callback']) === true
|
162 |
+
&& \call_user_func(array($this, $this->PHPCSCompatTranslate[$tokenType]['callback']), $tokens, $stackPtr) === true))
|
163 |
) {
|
164 |
$tokenType = $this->PHPCSCompatTranslate[$tokenType]['real_token'];
|
165 |
}
|
166 |
} elseif ($tokenType === 'T_COALESCE') {
|
167 |
// Make sure that T_COALESCE is not confused with T_COALESCE_EQUAL.
|
168 |
+
if (isset($tokens[($stackPtr + 1)]) !== false && $tokens[($stackPtr + 1)]['code'] === \T_EQUAL) {
|
169 |
// Ignore as will be dealt with via the T_EQUAL token.
|
170 |
return;
|
171 |
}
|
172 |
}
|
173 |
|
174 |
// If the translation did not yield one of the tokens we are looking for, bow out.
|
175 |
+
if (isset($this->newOperators[$tokenType]) === false) {
|
176 |
return;
|
177 |
}
|
178 |
|
180 |
'name' => $tokenType,
|
181 |
);
|
182 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
183 |
+
}
|
|
|
184 |
|
185 |
|
186 |
/**
|
192 |
*/
|
193 |
public function getItemArray(array $itemInfo)
|
194 |
{
|
195 |
+
return $this->newOperators[$itemInfo['name']];
|
196 |
}
|
197 |
|
198 |
|
221 |
$errorInfo['description'] = $itemArray['description'];
|
222 |
|
223 |
return $errorInfo;
|
|
|
224 |
}
|
225 |
|
226 |
|
250 |
*/
|
251 |
private function isTCoalesceEqual($tokens, $stackPtr)
|
252 |
{
|
253 |
+
if ($tokens[$stackPtr]['code'] !== \T_EQUAL || isset($tokens[($stackPtr - 1)]) === false) {
|
254 |
// Function called for wrong token or token has no predecesor.
|
255 |
return false;
|
256 |
}
|
277 |
*/
|
278 |
private function isTCoalesce($tokens, $stackPtr)
|
279 |
{
|
280 |
+
if ($tokens[$stackPtr]['code'] !== \T_INLINE_THEN || isset($tokens[($stackPtr - 1)]) === false) {
|
281 |
// Function called for wrong token or token has no predecesor.
|
282 |
return false;
|
283 |
}
|
284 |
|
285 |
+
if ($tokens[($stackPtr - 1)]['code'] === \T_INLINE_THEN) {
|
286 |
// Make sure not to confuse it with the T_COALESCE_EQUAL token.
|
287 |
+
if (isset($tokens[($stackPtr + 1)]) === false || $tokens[($stackPtr + 1)]['code'] !== \T_EQUAL) {
|
288 |
return true;
|
289 |
}
|
290 |
}
|
291 |
|
292 |
return false;
|
293 |
}
|
294 |
+
}
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/TernaryOperatorsSniff.php → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/NewShortTernarySniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
@@ -10,12 +10,13 @@
|
|
10 |
* @copyright 2012 Ben Selby
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Performs checks on ternary operators, specifically that the middle expression
|
21 |
* is not omitted for versions that don't support this.
|
@@ -27,7 +28,7 @@ use PHPCompatibility\Sniff;
|
|
27 |
* @author Ben Selby <bselby@plus.net>
|
28 |
* @copyright 2012 Ben Selby
|
29 |
*/
|
30 |
-
class
|
31 |
{
|
32 |
|
33 |
/**
|
@@ -37,7 +38,7 @@ class TernaryOperatorsSniff extends Sniff
|
|
37 |
*/
|
38 |
public function register()
|
39 |
{
|
40 |
-
return array(T_INLINE_THEN);
|
41 |
}
|
42 |
|
43 |
/**
|
@@ -49,24 +50,20 @@ class TernaryOperatorsSniff extends Sniff
|
|
49 |
*
|
50 |
* @return void
|
51 |
*/
|
52 |
-
public function process(
|
53 |
{
|
54 |
if ($this->supportsBelow('5.2') === false) {
|
55 |
return;
|
56 |
}
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
// Get next non-whitespace token, and check it isn't the related inline else
|
61 |
-
// symbol, which is not allowed prior to PHP 5.3.
|
62 |
-
$next = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
63 |
-
|
64 |
-
if ($next !== false && $tokens[$next]['code'] === T_INLINE_ELSE) {
|
65 |
-
$phpcsFile->addError(
|
66 |
-
'Middle may not be omitted from ternary operators in PHP < 5.3',
|
67 |
-
$stackPtr,
|
68 |
-
'MiddleMissing'
|
69 |
-
);
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Operators\NewShortTernarySniff.
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
10 |
* @copyright 2012 Ben Selby
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\Operators;
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Operators\NewShortTernarySniff.
|
20 |
*
|
21 |
* Performs checks on ternary operators, specifically that the middle expression
|
22 |
* is not omitted for versions that don't support this.
|
28 |
* @author Ben Selby <bselby@plus.net>
|
29 |
* @copyright 2012 Ben Selby
|
30 |
*/
|
31 |
+
class NewShortTernarySniff extends Sniff
|
32 |
{
|
33 |
|
34 |
/**
|
38 |
*/
|
39 |
public function register()
|
40 |
{
|
41 |
+
return array(\T_INLINE_THEN);
|
42 |
}
|
43 |
|
44 |
/**
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
53 |
+
public function process(File $phpcsFile, $stackPtr)
|
54 |
{
|
55 |
if ($this->supportsBelow('5.2') === false) {
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
+
if ($this->isShortTernary($phpcsFile, $stackPtr) === false) {
|
60 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
+
|
63 |
+
$phpcsFile->addError(
|
64 |
+
'Middle may not be omitted from ternary operators in PHP < 5.3',
|
65 |
+
$stackPtr,
|
66 |
+
'MiddleMissing'
|
67 |
+
);
|
68 |
}
|
69 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/RemovedTernaryAssociativitySniff.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Operators;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHPCompatibility\PHPCSHelper;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* The left-associativity of the ternary operator is deprecated in PHP 7.4 and
|
20 |
+
* removed in PHP 8.0.
|
21 |
+
*
|
22 |
+
* @link https://wiki.php.net/rfc/ternary_associativity
|
23 |
+
* @link https://github.com/php/php-src/pull/4017
|
24 |
+
*
|
25 |
+
* PHP version 7.4
|
26 |
+
* PHP version 8.0
|
27 |
+
*
|
28 |
+
* @since 9.2.0
|
29 |
+
*/
|
30 |
+
class RemovedTernaryAssociativitySniff extends Sniff
|
31 |
+
{
|
32 |
+
|
33 |
+
/**
|
34 |
+
* List of tokens with a lower operator precedence than ternary.
|
35 |
+
*
|
36 |
+
* @since 9.2.0
|
37 |
+
*
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
private $tokensWithLowerPrecedence = array(
|
41 |
+
'T_YIELD_FROM' => true,
|
42 |
+
'T_YIELD' => true,
|
43 |
+
'T_LOGICAL_AND' => true,
|
44 |
+
'T_LOGICAL_OR' => true,
|
45 |
+
'T_LOGICAL_XOR' => true,
|
46 |
+
);
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Returns an array of tokens this test wants to listen for.
|
51 |
+
*
|
52 |
+
* @since 9.2.0
|
53 |
+
*
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function register()
|
57 |
+
{
|
58 |
+
return array(\T_INLINE_THEN);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Processes this test, when one of its tokens is encountered.
|
63 |
+
*
|
64 |
+
* @since 9.2.0
|
65 |
+
*
|
66 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
67 |
+
* @param int $stackPtr The position of the current token
|
68 |
+
* in the stack passed in $tokens.
|
69 |
+
*
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
public function process(File $phpcsFile, $stackPtr)
|
73 |
+
{
|
74 |
+
if ($this->supportsAbove('7.4') === false) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
$tokens = $phpcsFile->getTokens();
|
79 |
+
$endOfStatement = PHPCSHelper::findEndOfStatement($phpcsFile, $stackPtr);
|
80 |
+
if ($tokens[$endOfStatement]['code'] !== \T_SEMICOLON
|
81 |
+
&& $tokens[$endOfStatement]['code'] !== \T_COLON
|
82 |
+
&& $tokens[$endOfStatement]['code'] !== \T_COMMA
|
83 |
+
&& $tokens[$endOfStatement]['code'] !== \T_DOUBLE_ARROW
|
84 |
+
&& $tokens[$endOfStatement]['code'] !== \T_OPEN_TAG
|
85 |
+
&& $tokens[$endOfStatement]['code'] !== \T_CLOSE_TAG
|
86 |
+
) {
|
87 |
+
// End of statement is last non-empty before close brace, so make sure we examine that token too.
|
88 |
+
++$endOfStatement;
|
89 |
+
}
|
90 |
+
|
91 |
+
$ternaryCount = 0;
|
92 |
+
$elseCount = 0;
|
93 |
+
$shortTernaryCount = 0;
|
94 |
+
|
95 |
+
// Start at $stackPtr so we don't need duplicate code for short ternary determination.
|
96 |
+
for ($i = $stackPtr; $i < $endOfStatement; $i++) {
|
97 |
+
if (($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
|
98 |
+
|| $tokens[$i]['code'] === \T_OPEN_SQUARE_BRACKET
|
99 |
+
|| $tokens[$i]['code'] === \T_OPEN_CURLY_BRACKET)
|
100 |
+
&& isset($tokens[$i]['bracket_closer'])
|
101 |
+
) {
|
102 |
+
// Skip over short arrays, array access keys and curlies.
|
103 |
+
$i = $tokens[$i]['bracket_closer'];
|
104 |
+
continue;
|
105 |
+
}
|
106 |
+
|
107 |
+
if ($tokens[$i]['code'] === \T_OPEN_PARENTHESIS
|
108 |
+
&& isset($tokens[$i]['parenthesis_closer'])
|
109 |
+
) {
|
110 |
+
// Skip over anything between parentheses.
|
111 |
+
$i = $tokens[$i]['parenthesis_closer'];
|
112 |
+
continue;
|
113 |
+
}
|
114 |
+
|
115 |
+
// Check for operators with lower operator precedence.
|
116 |
+
if (isset(Tokens::$assignmentTokens[$tokens[$i]['code']])
|
117 |
+
|| isset($this->tokensWithLowerPrecedence[$tokens[$i]['code']])
|
118 |
+
) {
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($tokens[$i]['code'] === \T_INLINE_THEN) {
|
123 |
+
++$ternaryCount;
|
124 |
+
|
125 |
+
if ($this->isShortTernary($phpcsFile, $i) === true) {
|
126 |
+
++$shortTernaryCount;
|
127 |
+
}
|
128 |
+
|
129 |
+
continue;
|
130 |
+
}
|
131 |
+
|
132 |
+
if ($tokens[$i]['code'] === \T_INLINE_ELSE) {
|
133 |
+
if (($ternaryCount - $elseCount) >= 2) {
|
134 |
+
// This is the `else` for a ternary in the middle part of a previous ternary.
|
135 |
+
--$ternaryCount;
|
136 |
+
} else {
|
137 |
+
++$elseCount;
|
138 |
+
}
|
139 |
+
continue;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if ($ternaryCount > 1 && $ternaryCount === $elseCount && $ternaryCount > $shortTernaryCount) {
|
144 |
+
$message = 'The left-associativity of the ternary operator has been deprecated in PHP 7.4';
|
145 |
+
$isError = false;
|
146 |
+
if ($this->supportsAbove('8.0') === true) {
|
147 |
+
$message .= ' and removed in PHP 8.0';
|
148 |
+
$isError = true;
|
149 |
+
}
|
150 |
+
|
151 |
+
$message .= '. Multiple consecutive ternaries detected. Use parenthesis to clarify the order in which the operations should be executed';
|
152 |
+
|
153 |
+
$this->addMessage($phpcsFile, $message, $stackPtr, $isError);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/CaseSensitiveKeywordsSniff.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\CaseSensitiveKeywordsSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.5
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\CaseSensitiveKeywordsSniff.
|
18 |
-
*
|
19 |
-
* Prior to PHP 5.5, cases existed where the self, parent, and static keywords
|
20 |
-
* were treated in a case sensitive fashion.
|
21 |
-
*
|
22 |
-
* PHP version 5.5
|
23 |
-
*
|
24 |
-
* @category PHP
|
25 |
-
* @package PHPCompatibility
|
26 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
27 |
-
*/
|
28 |
-
class CaseSensitiveKeywordsSniff extends Sniff
|
29 |
-
{
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Returns an array of tokens this test wants to listen for.
|
33 |
-
*
|
34 |
-
* @return array
|
35 |
-
*/
|
36 |
-
public function register()
|
37 |
-
{
|
38 |
-
return array(
|
39 |
-
T_SELF,
|
40 |
-
T_STATIC,
|
41 |
-
T_PARENT,
|
42 |
-
);
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Processes this test, when one of its tokens is encountered.
|
47 |
-
*
|
48 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
49 |
-
* @param int $stackPtr The position of the current token in the
|
50 |
-
* stack passed in $tokens.
|
51 |
-
*
|
52 |
-
* @return void
|
53 |
-
*/
|
54 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
55 |
-
{
|
56 |
-
if ($this->supportsBelow('5.4') === false) {
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
$tokens = $phpcsFile->getTokens();
|
61 |
-
$tokenContentLC = strtolower($tokens[$stackPtr]['content']);
|
62 |
-
|
63 |
-
if ($tokenContentLC !== $tokens[$stackPtr]['content']) {
|
64 |
-
$phpcsFile->addError(
|
65 |
-
'The keyword \'%s\' was treated in a case-sensitive fashion in certain cases in PHP 5.4 or earlier. Use the lowercase version for consistent support.',
|
66 |
-
$stackPtr,
|
67 |
-
'NonLowercaseFound',
|
68 |
-
array($tokenContentLC)
|
69 |
-
);
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedPHP4StyleConstructorsSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Koen Eelen <koen.eelen@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedPHP4StyleConstructorsSniff.
|
18 |
-
*
|
19 |
-
* PHP version 7.0
|
20 |
-
*
|
21 |
-
* @category PHP
|
22 |
-
* @package PHPCompatibility
|
23 |
-
* @author Koen Eelen <koen.eelen@cu.be>
|
24 |
-
*/
|
25 |
-
class DeprecatedPHP4StyleConstructorsSniff extends Sniff
|
26 |
-
{
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Returns an array of tokens this test wants to listen for.
|
30 |
-
*
|
31 |
-
* @return array
|
32 |
-
*/
|
33 |
-
public function register()
|
34 |
-
{
|
35 |
-
return array(T_CLASS);
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Processes this test, when one of its tokens is encountered.
|
41 |
-
*
|
42 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
43 |
-
* @param int $stackPtr The position of the current token in the
|
44 |
-
* stack passed in $tokens.
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
49 |
-
{
|
50 |
-
if ($this->supportsAbove('7.0') === false) {
|
51 |
-
return;
|
52 |
-
}
|
53 |
-
|
54 |
-
if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
|
55 |
-
/*
|
56 |
-
* Namespaced methods with the same name as the class are treated as
|
57 |
-
* regular methods, so we can bow out if we're in a namespace.
|
58 |
-
*
|
59 |
-
* Note: the exception to this is PHP 5.3.0-5.3.2. This is currently
|
60 |
-
* not dealt with.
|
61 |
-
*/
|
62 |
-
return;
|
63 |
-
}
|
64 |
-
|
65 |
-
$tokens = $phpcsFile->getTokens();
|
66 |
-
|
67 |
-
$class = $tokens[$stackPtr];
|
68 |
-
|
69 |
-
if (isset($class['scope_closer']) === false) {
|
70 |
-
return;
|
71 |
-
}
|
72 |
-
|
73 |
-
$scopeCloser = $class['scope_closer'];
|
74 |
-
$className = $phpcsFile->getDeclarationName($stackPtr);
|
75 |
-
|
76 |
-
if (empty($className) || is_string($className) === false) {
|
77 |
-
return;
|
78 |
-
}
|
79 |
-
|
80 |
-
$nextFunc = $stackPtr;
|
81 |
-
$classNameLc = strtolower($className);
|
82 |
-
$newConstructorFound = false;
|
83 |
-
$oldConstructorFound = false;
|
84 |
-
$oldConstructorPos = -1;
|
85 |
-
while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
|
86 |
-
$funcName = $phpcsFile->getDeclarationName($nextFunc);
|
87 |
-
if (empty($funcName) || is_string($funcName) === false) {
|
88 |
-
continue;
|
89 |
-
}
|
90 |
-
|
91 |
-
$funcNameLc = strtolower($funcName);
|
92 |
-
|
93 |
-
if ($funcNameLc === '__construct') {
|
94 |
-
$newConstructorFound = true;
|
95 |
-
}
|
96 |
-
|
97 |
-
if ($funcNameLc === $classNameLc) {
|
98 |
-
$oldConstructorFound = true;
|
99 |
-
$oldConstructorPos = $nextFunc;
|
100 |
-
}
|
101 |
-
|
102 |
-
// If both have been found, no need to continue looping through the functions.
|
103 |
-
if ($newConstructorFound === true && $oldConstructorFound === true) {
|
104 |
-
break;
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
if ($newConstructorFound === false && $oldConstructorFound === true) {
|
109 |
-
$phpcsFile->addWarning(
|
110 |
-
'Use of deprecated PHP4 style class constructor is not supported since PHP 7.',
|
111 |
-
$oldConstructorPos,
|
112 |
-
'Found'
|
113 |
-
);
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\EmptyNonVariableSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.5
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\EmptyNonVariableSniff.
|
18 |
-
*
|
19 |
-
* Verify that nothing but variables are passed to empty().
|
20 |
-
*
|
21 |
-
* PHP version 5.5
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
-
*/
|
27 |
-
class EmptyNonVariableSniff extends Sniff
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* List of tokens to check against.
|
31 |
-
*
|
32 |
-
* @var array
|
33 |
-
*/
|
34 |
-
protected $tokenBlackList = array();
|
35 |
-
|
36 |
-
/**
|
37 |
-
* List of brackets which can be part of a variable variable.
|
38 |
-
*
|
39 |
-
* Key is the open bracket token, value the close bracket token.
|
40 |
-
*
|
41 |
-
* @var array
|
42 |
-
*/
|
43 |
-
protected $bracketTokens = array(
|
44 |
-
T_OPEN_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
|
45 |
-
T_OPEN_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET,
|
46 |
-
);
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Returns an array of tokens this test wants to listen for.
|
51 |
-
*
|
52 |
-
* @return array
|
53 |
-
*/
|
54 |
-
public function register()
|
55 |
-
{
|
56 |
-
// Set the token blacklist only once.
|
57 |
-
$tokenBlackList = array_unique(
|
58 |
-
array_merge(
|
59 |
-
\PHP_CodeSniffer_Tokens::$assignmentTokens,
|
60 |
-
\PHP_CodeSniffer_Tokens::$equalityTokens,
|
61 |
-
\PHP_CodeSniffer_Tokens::$comparisonTokens,
|
62 |
-
\PHP_CodeSniffer_Tokens::$operators,
|
63 |
-
\PHP_CodeSniffer_Tokens::$booleanOperators,
|
64 |
-
\PHP_CodeSniffer_Tokens::$castTokens,
|
65 |
-
array(T_OPEN_PARENTHESIS, T_STRING_CONCAT)
|
66 |
-
)
|
67 |
-
);
|
68 |
-
|
69 |
-
$this->tokenBlackList = array_combine($tokenBlackList, $tokenBlackList);
|
70 |
-
|
71 |
-
return array(T_EMPTY);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Processes this test, when one of its tokens is encountered.
|
76 |
-
*
|
77 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
78 |
-
* @param int $stackPtr The position of the current token in the
|
79 |
-
* stack passed in $tokens.
|
80 |
-
*
|
81 |
-
* @return void
|
82 |
-
*/
|
83 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
84 |
-
{
|
85 |
-
if ($this->supportsBelow('5.4') === false) {
|
86 |
-
return;
|
87 |
-
}
|
88 |
-
|
89 |
-
$tokens = $phpcsFile->getTokens();
|
90 |
-
|
91 |
-
$open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
|
92 |
-
if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
|
93 |
-
return;
|
94 |
-
}
|
95 |
-
|
96 |
-
$close = $tokens[$open]['parenthesis_closer'];
|
97 |
-
|
98 |
-
// If no variable at all was found, then it's definitely a no-no.
|
99 |
-
$hasVariable = $phpcsFile->findNext(T_VARIABLE, $open + 1, $close);
|
100 |
-
if ($hasVariable === false) {
|
101 |
-
$this->addError($phpcsFile, $stackPtr);
|
102 |
-
return;
|
103 |
-
}
|
104 |
-
|
105 |
-
// Check if the variable found is at the right level. Deeper levels are always an error.
|
106 |
-
if (isset($tokens[$open + 1]['nested_parenthesis'], $tokens[$hasVariable]['nested_parenthesis'])) {
|
107 |
-
$nestingLevel = count($tokens[$open + 1]['nested_parenthesis']);
|
108 |
-
if (count($tokens[$hasVariable]['nested_parenthesis']) !== $nestingLevel) {
|
109 |
-
$this->addError($phpcsFile, $stackPtr);
|
110 |
-
return;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
// Ok, so the first variable is at the right level, now are there any
|
115 |
-
// blacklisted tokens within the empty() ?
|
116 |
-
$hasBadToken = $phpcsFile->findNext($this->tokenBlackList, $open + 1, $close);
|
117 |
-
if ($hasBadToken === false) {
|
118 |
-
return;
|
119 |
-
}
|
120 |
-
|
121 |
-
// If there are also bracket tokens, the blacklisted token might be part of a variable
|
122 |
-
// variable, but if there are no bracket tokens, we know we have an error.
|
123 |
-
$hasBrackets = $phpcsFile->findNext($this->bracketTokens, $open + 1, $close);
|
124 |
-
if ($hasBrackets === false) {
|
125 |
-
$this->addError($phpcsFile, $stackPtr);
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
-
// Ok, we have both a blacklisted token as well as brackets, so we need to walk
|
130 |
-
// the tokens of the variable variable.
|
131 |
-
for ($i = ($open + 1); $i < $close; $i++) {
|
132 |
-
// If this is a bracket token, skip to the end of the bracketed expression.
|
133 |
-
if (isset($this->bracketTokens[$tokens[$i]['code']], $tokens[$i]['bracket_closer'])) {
|
134 |
-
$i = $tokens[$i]['bracket_closer'];
|
135 |
-
continue;
|
136 |
-
}
|
137 |
-
|
138 |
-
// If it's a blacklisted token, not within brackets, we have an error.
|
139 |
-
if (isset($this->tokenBlackList[$tokens[$i]['code']])) {
|
140 |
-
$this->addError($phpcsFile, $stackPtr);
|
141 |
-
return;
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Add the error message.
|
149 |
-
*
|
150 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
151 |
-
* @param int $stackPtr The position of the current token in the
|
152 |
-
* stack passed in $tokens.
|
153 |
-
*
|
154 |
-
* @return void
|
155 |
-
*/
|
156 |
-
protected function addError(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
157 |
-
{
|
158 |
-
$phpcsFile->addError(
|
159 |
-
'Only variables can be passed to empty() prior to PHP 5.5.',
|
160 |
-
$stackPtr,
|
161 |
-
'Found'
|
162 |
-
);
|
163 |
-
}
|
164 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenBreakContinueOutsideLoop.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenBreakContinueOutsideLoop.
|
18 |
-
*
|
19 |
-
* Forbids use of break or continue statements outside of looping structures.
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
-
*/
|
27 |
-
class ForbiddenBreakContinueOutsideLoopSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Token codes of control structure in which usage of break/continue is valid.
|
32 |
-
*
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
protected $validLoopStructures = array(
|
36 |
-
T_FOR => true,
|
37 |
-
T_FOREACH => true,
|
38 |
-
T_WHILE => true,
|
39 |
-
T_DO => true,
|
40 |
-
T_SWITCH => true,
|
41 |
-
);
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Token codes which did not correctly get a condition assigned in older PHPCS versions.
|
45 |
-
*
|
46 |
-
* @var array
|
47 |
-
*/
|
48 |
-
protected $backCompat = array(
|
49 |
-
T_CASE => true,
|
50 |
-
T_DEFAULT => true,
|
51 |
-
);
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Returns an array of tokens this test wants to listen for.
|
55 |
-
*
|
56 |
-
* @return array
|
57 |
-
*/
|
58 |
-
public function register()
|
59 |
-
{
|
60 |
-
return array(
|
61 |
-
T_BREAK,
|
62 |
-
T_CONTINUE,
|
63 |
-
);
|
64 |
-
|
65 |
-
}//end register()
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Processes this test, when one of its tokens is encountered.
|
69 |
-
*
|
70 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
71 |
-
* @param int $stackPtr The position of the current token in the
|
72 |
-
* stack passed in $tokens.
|
73 |
-
*
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
77 |
-
{
|
78 |
-
$tokens = $phpcsFile->getTokens();
|
79 |
-
$token = $tokens[$stackPtr];
|
80 |
-
|
81 |
-
// Check if the break/continue is within a valid loop structure.
|
82 |
-
if (empty($token['conditions']) === false) {
|
83 |
-
foreach ($token['conditions'] as $tokenCode) {
|
84 |
-
if (isset($this->validLoopStructures[$tokenCode]) === true) {
|
85 |
-
return;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
} else {
|
89 |
-
// Deal with older PHPCS versions.
|
90 |
-
if (isset($token['scope_condition']) === true && isset($this->backCompat[$tokens[$token['scope_condition']]['code']]) === true) {
|
91 |
-
return;
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
// If we're still here, no valid loop structure container has been found, so throw an error.
|
96 |
-
$error = "Using '%s' outside of a loop or switch structure is invalid";
|
97 |
-
$isError = false;
|
98 |
-
$errorCode = 'Found';
|
99 |
-
$data = array($token['content']);
|
100 |
-
|
101 |
-
if ($this->supportsAbove('7.0')) {
|
102 |
-
$error .= ' and will throw a fatal error since PHP 7.0';
|
103 |
-
$isError = true;
|
104 |
-
$errorCode = 'FatalError';
|
105 |
-
}
|
106 |
-
|
107 |
-
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
108 |
-
|
109 |
-
}//end process()
|
110 |
-
|
111 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php
DELETED
@@ -1,122 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenGlobalVariableVariableSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenGlobalVariableVariableSniff.
|
18 |
-
*
|
19 |
-
* Variable variables are forbidden with global
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim@cu.be>
|
26 |
-
*/
|
27 |
-
class ForbiddenGlobalVariableVariableSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Returns an array of tokens this test wants to listen for.
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function register()
|
36 |
-
{
|
37 |
-
return array(T_GLOBAL);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes this test, when one of its tokens is encountered.
|
42 |
-
*
|
43 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
44 |
-
* @param int $stackPtr The position of the current token in the
|
45 |
-
* stack passed in $tokens.
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
50 |
-
{
|
51 |
-
if ($this->supportsAbove('7.0') === false) {
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
$tokens = $phpcsFile->getTokens();
|
56 |
-
$endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr + 1));
|
57 |
-
if ($endOfStatement === false) {
|
58 |
-
// No semi-colon - live coding.
|
59 |
-
return;
|
60 |
-
}
|
61 |
-
|
62 |
-
for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) {
|
63 |
-
$errorThrown = false;
|
64 |
-
$nextComma = $phpcsFile->findNext(T_COMMA, $ptr, $endOfStatement, false, null, true);
|
65 |
-
$varEnd = ($nextComma === false) ? $endOfStatement : $nextComma;
|
66 |
-
$variable = $phpcsFile->findNext(T_VARIABLE, $ptr, $varEnd);
|
67 |
-
$varString = trim($phpcsFile->getTokensAsString($ptr, ($varEnd - $ptr)));
|
68 |
-
$data = array($varString);
|
69 |
-
|
70 |
-
if ($variable !== false) {
|
71 |
-
|
72 |
-
$prev = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($variable - 1), $ptr, true);
|
73 |
-
|
74 |
-
if ($prev !== false && $tokens[$prev]['type'] === 'T_DOLLAR') {
|
75 |
-
|
76 |
-
$next = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($variable + 1), $varEnd, true);
|
77 |
-
|
78 |
-
if ($next !== false
|
79 |
-
&& in_array($tokens[$next]['code'], array(T_OPEN_SQUARE_BRACKET, T_OBJECT_OPERATOR, T_DOUBLE_COLON), true) === true
|
80 |
-
) {
|
81 |
-
$phpcsFile->addError(
|
82 |
-
'Global with variable variables is not allowed since PHP 7.0. Found %s',
|
83 |
-
$variable,
|
84 |
-
'Found',
|
85 |
-
$data
|
86 |
-
);
|
87 |
-
$errorThrown = true;
|
88 |
-
} else {
|
89 |
-
$phpcsFile->addWarning(
|
90 |
-
'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s',
|
91 |
-
$variable,
|
92 |
-
'NonBareVariableFound',
|
93 |
-
$data
|
94 |
-
);
|
95 |
-
$errorThrown = true;
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
if ($errorThrown === false) {
|
101 |
-
$dollar = $phpcsFile->findNext(T_DOLLAR, $ptr, $varEnd);
|
102 |
-
if ($dollar !== false) {
|
103 |
-
$next = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($dollar + 1), $varEnd, true);
|
104 |
-
if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) {
|
105 |
-
$phpcsFile->addWarning(
|
106 |
-
'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s',
|
107 |
-
$dollar,
|
108 |
-
'NonBareVariableFound',
|
109 |
-
$data
|
110 |
-
);
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
// Move the stack pointer forward to the next variable for multi-variable statements.
|
116 |
-
if ($nextComma === false) {
|
117 |
-
break;
|
118 |
-
}
|
119 |
-
$ptr = $nextComma;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNamesAsInvokedFunctionsSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Jansen Price <jansen.price@gmail.com>
|
8 |
-
* @copyright 2012 Cu.be Solutions bvba
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
12 |
-
|
13 |
-
use PHPCompatibility\Sniff;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNamesAsInvokedFunctionsSniff.
|
17 |
-
*
|
18 |
-
* Prohibits the use of reserved keywords invoked as functions.
|
19 |
-
*
|
20 |
-
* @category PHP
|
21 |
-
* @package PHPCompatibility
|
22 |
-
* @author Jansen Price <jansen.price@gmail.com>
|
23 |
-
* @copyright 2012 Cu.be Solutions bvba
|
24 |
-
*/
|
25 |
-
class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
|
26 |
-
{
|
27 |
-
|
28 |
-
/**
|
29 |
-
* List of tokens to register.
|
30 |
-
*
|
31 |
-
* @var array
|
32 |
-
*/
|
33 |
-
protected $targetedTokens = array(
|
34 |
-
T_ABSTRACT => '5.0',
|
35 |
-
T_CALLABLE => '5.4',
|
36 |
-
T_CATCH => '5.0',
|
37 |
-
T_FINAL => '5.0',
|
38 |
-
T_GOTO => '5.3',
|
39 |
-
T_IMPLEMENTS => '5.0',
|
40 |
-
T_INTERFACE => '5.0',
|
41 |
-
T_INSTANCEOF => '5.0',
|
42 |
-
T_NAMESPACE => '5.3',
|
43 |
-
T_PRIVATE => '5.0',
|
44 |
-
T_PROTECTED => '5.0',
|
45 |
-
T_PUBLIC => '5.0',
|
46 |
-
T_TRY => '5.0',
|
47 |
-
);
|
48 |
-
|
49 |
-
/**
|
50 |
-
* T_STRING keywords to recognize as targetted tokens.
|
51 |
-
*
|
52 |
-
* Compatibility for PHP versions where the keyword is not yet recognized
|
53 |
-
* as its own token and for PHPCS versions which change the token to
|
54 |
-
* T_STRING when used in a method call.
|
55 |
-
*
|
56 |
-
* @var array
|
57 |
-
*/
|
58 |
-
protected $targetedStringTokens = array(
|
59 |
-
'abstract' => '5.0',
|
60 |
-
'callable' => '5.4',
|
61 |
-
'catch' => '5.0',
|
62 |
-
'final' => '5.0',
|
63 |
-
'finally' => '5.5',
|
64 |
-
'goto' => '5.3',
|
65 |
-
'implements' => '5.0',
|
66 |
-
'interface' => '5.0',
|
67 |
-
'instanceof' => '5.0',
|
68 |
-
'insteadof' => '5.4',
|
69 |
-
'namespace' => '5.3',
|
70 |
-
'private' => '5.0',
|
71 |
-
'protected' => '5.0',
|
72 |
-
'public' => '5.0',
|
73 |
-
'trait' => '5.4',
|
74 |
-
'try' => '5.0',
|
75 |
-
);
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Returns an array of tokens this test wants to listen for.
|
79 |
-
*
|
80 |
-
* @return array
|
81 |
-
*/
|
82 |
-
public function register()
|
83 |
-
{
|
84 |
-
if (defined('T_FINALLY')) {
|
85 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_finallyFound
|
86 |
-
$this->targetedTokens[T_FINALLY] = '5.5';
|
87 |
-
}
|
88 |
-
if (defined('T_INSTEADOF')) {
|
89 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_insteadofFound
|
90 |
-
$this->targetedTokens[T_INSTEADOF] = '5.4';
|
91 |
-
}
|
92 |
-
if (defined('T_TRAIT')) {
|
93 |
-
// phpcs:ignore PHPCompatibility.PHP.NewConstants.t_traitFound
|
94 |
-
$this->targetedTokens[T_TRAIT] = '5.4';
|
95 |
-
}
|
96 |
-
|
97 |
-
$tokens = array_keys($this->targetedTokens);
|
98 |
-
$tokens[] = T_STRING;
|
99 |
-
|
100 |
-
return $tokens;
|
101 |
-
}//end register()
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Processes this test, when one of its tokens is encountered.
|
105 |
-
*
|
106 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
107 |
-
* @param int $stackPtr The position of the current token in the
|
108 |
-
* stack passed in $tokens.
|
109 |
-
*
|
110 |
-
* @return void
|
111 |
-
*/
|
112 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
113 |
-
{
|
114 |
-
$tokens = $phpcsFile->getTokens();
|
115 |
-
$tokenCode = $tokens[$stackPtr]['code'];
|
116 |
-
$tokenContentLc = strtolower($tokens[$stackPtr]['content']);
|
117 |
-
$isString = false;
|
118 |
-
|
119 |
-
/*
|
120 |
-
* For string tokens we only care if the string is a reserved word used
|
121 |
-
* as a function. This only happens in older versions of PHP where the
|
122 |
-
* token doesn't exist yet for that keyword or in later versions when the
|
123 |
-
* token is used in a method invocation.
|
124 |
-
*/
|
125 |
-
if ($tokenCode === T_STRING
|
126 |
-
&& (isset($this->targetedStringTokens[$tokenContentLc]) === false)
|
127 |
-
) {
|
128 |
-
return;
|
129 |
-
}
|
130 |
-
|
131 |
-
if ($tokenCode === T_STRING) {
|
132 |
-
$isString = true;
|
133 |
-
}
|
134 |
-
|
135 |
-
// Make sure this is a function call.
|
136 |
-
$next = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
137 |
-
if ($next === false || $tokens[$next]['code'] !== T_OPEN_PARENTHESIS) {
|
138 |
-
// Not a function call.
|
139 |
-
return;
|
140 |
-
}
|
141 |
-
|
142 |
-
// This sniff isn't concerned about function declarations.
|
143 |
-
$prev = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
144 |
-
if ($prev !== false && $tokens[$prev]['code'] === T_FUNCTION) {
|
145 |
-
return;
|
146 |
-
}
|
147 |
-
|
148 |
-
/*
|
149 |
-
* Deal with PHP 7 relaxing the rules.
|
150 |
-
* "As of PHP 7.0.0 these keywords are allowed as property, constant, and method names
|
151 |
-
* of classes, interfaces and traits...", i.e. they can be invoked as a method call.
|
152 |
-
*
|
153 |
-
* Only needed for those keywords which we sniff out via T_STRING.
|
154 |
-
*/
|
155 |
-
if (($tokens[$prev]['code'] === T_OBJECT_OPERATOR || $tokens[$prev]['code'] === T_DOUBLE_COLON)
|
156 |
-
&& $this->supportsBelow('5.6') === false
|
157 |
-
) {
|
158 |
-
return;
|
159 |
-
}
|
160 |
-
|
161 |
-
// For the word catch, it is valid to have an open parenthesis
|
162 |
-
// after it, but only if it is preceded by a right curly brace.
|
163 |
-
if ($tokenCode === T_CATCH) {
|
164 |
-
if ($prev !== false && $tokens[$prev]['code'] === T_CLOSE_CURLY_BRACKET) {
|
165 |
-
// Ok, it's fine.
|
166 |
-
return;
|
167 |
-
}
|
168 |
-
}
|
169 |
-
|
170 |
-
if ($isString === true) {
|
171 |
-
$version = $this->targetedStringTokens[$tokenContentLc];
|
172 |
-
} else {
|
173 |
-
$version = $this->targetedTokens[$tokenCode];
|
174 |
-
}
|
175 |
-
|
176 |
-
if ($this->supportsAbove($version)) {
|
177 |
-
$error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
|
178 |
-
$errorCode = $this->stringToErrorCode($tokenContentLc) . 'Found';
|
179 |
-
$data = array(
|
180 |
-
$tokenContentLc,
|
181 |
-
$version,
|
182 |
-
$tokens[$stackPtr]['type'],
|
183 |
-
);
|
184 |
-
|
185 |
-
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
186 |
-
}
|
187 |
-
}//end process()
|
188 |
-
|
189 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenSwitchWithMultipleDefaultBlocksSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenSwitchWithMultipleDefaultBlocksSniff.
|
18 |
-
*
|
19 |
-
* Switch statements can not have multiple default blocks since PHP 7.0
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim@cu.be>
|
26 |
-
*/
|
27 |
-
class ForbiddenSwitchWithMultipleDefaultBlocksSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Returns an array of tokens this test wants to listen for.
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function register()
|
36 |
-
{
|
37 |
-
return array(T_SWITCH);
|
38 |
-
|
39 |
-
}//end register()
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Processes this test, when one of its tokens is encountered.
|
43 |
-
*
|
44 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
45 |
-
* @param int $stackPtr The position of the current token
|
46 |
-
* in the stack passed in $tokens.
|
47 |
-
*
|
48 |
-
* @return void
|
49 |
-
*/
|
50 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
51 |
-
{
|
52 |
-
if ($this->supportsAbove('7.0') === false) {
|
53 |
-
return;
|
54 |
-
}
|
55 |
-
|
56 |
-
$tokens = $phpcsFile->getTokens();
|
57 |
-
if (isset($tokens[$stackPtr]['scope_closer']) === false) {
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
|
61 |
-
$defaultToken = $stackPtr;
|
62 |
-
$defaultCount = 0;
|
63 |
-
$targetLevel = $tokens[$stackPtr]['level'] + 1;
|
64 |
-
while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) {
|
65 |
-
// Same level or one below (= two default cases after each other).
|
66 |
-
if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
|
67 |
-
$defaultCount++;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
if ($defaultCount > 1) {
|
72 |
-
$phpcsFile->addError(
|
73 |
-
'Switch statements can not have multiple default blocks since PHP 7.0',
|
74 |
-
$stackPtr,
|
75 |
-
'Found'
|
76 |
-
);
|
77 |
-
}
|
78 |
-
}//end process()
|
79 |
-
|
80 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\LateStaticBindingSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.3
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\LateStaticBindingSniff.
|
18 |
-
*
|
19 |
-
* PHP version 5.3
|
20 |
-
*
|
21 |
-
* @category PHP
|
22 |
-
* @package PHPCompatibility
|
23 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
24 |
-
*/
|
25 |
-
class LateStaticBindingSniff extends Sniff
|
26 |
-
{
|
27 |
-
/**
|
28 |
-
* Returns an array of tokens this test wants to listen for.
|
29 |
-
*
|
30 |
-
* @return array
|
31 |
-
*/
|
32 |
-
public function register()
|
33 |
-
{
|
34 |
-
return array(T_STATIC);
|
35 |
-
|
36 |
-
}//end register()
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Processes this test, when one of its tokens is encountered.
|
41 |
-
*
|
42 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
43 |
-
* @param int $stackPtr The position of the current token in the
|
44 |
-
* stack passed in $tokens.
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
49 |
-
{
|
50 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
51 |
-
if ($nextNonEmpty === false) {
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
$tokens = $phpcsFile->getTokens();
|
56 |
-
if ($tokens[$nextNonEmpty]['code'] !== T_DOUBLE_COLON) {
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
$inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
|
61 |
-
|
62 |
-
if ($inClass === true && $this->supportsBelow('5.2') === true) {
|
63 |
-
$phpcsFile->addError(
|
64 |
-
'Late static binding is not supported in PHP 5.2 or earlier.',
|
65 |
-
$stackPtr,
|
66 |
-
'Found'
|
67 |
-
);
|
68 |
-
}
|
69 |
-
|
70 |
-
if ($inClass === false) {
|
71 |
-
$phpcsFile->addError(
|
72 |
-
'Late static binding is not supported outside of class scope.',
|
73 |
-
$stackPtr,
|
74 |
-
'OutsideClassScope'
|
75 |
-
);
|
76 |
-
}
|
77 |
-
|
78 |
-
}//end process()
|
79 |
-
|
80 |
-
|
81 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewAnonymousClasses.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim.godden@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\NewAnonymousClasses.
|
18 |
-
*
|
19 |
-
* Anonymous classes are supported in PHP 7.0
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim.godden@cu.be>
|
26 |
-
*/
|
27 |
-
class NewAnonymousClassesSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Tokens which in various PHP versions indicate the `class` keyword.
|
32 |
-
*
|
33 |
-
* The dedicated anonymous class token is added from the `register()`
|
34 |
-
* method if the token is available.
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
private $indicators = array(
|
39 |
-
T_CLASS => T_CLASS,
|
40 |
-
);
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Returns an array of tokens this test wants to listen for.
|
44 |
-
*
|
45 |
-
* @return array
|
46 |
-
*/
|
47 |
-
public function register()
|
48 |
-
{
|
49 |
-
if (defined('T_ANON_CLASS')) {
|
50 |
-
$this->indicators[T_ANON_CLASS] = T_ANON_CLASS;
|
51 |
-
}
|
52 |
-
|
53 |
-
return array(T_NEW);
|
54 |
-
}//end register()
|
55 |
-
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Processes this test, when one of its tokens is encountered.
|
59 |
-
*
|
60 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
61 |
-
* @param int $stackPtr The position of the current token in the
|
62 |
-
* stack passed in $tokens.
|
63 |
-
*
|
64 |
-
* @return void
|
65 |
-
*/
|
66 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
67 |
-
{
|
68 |
-
if ($this->supportsBelow('5.6') === false) {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
$tokens = $phpcsFile->getTokens();
|
73 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
74 |
-
if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
|
75 |
-
return;
|
76 |
-
}
|
77 |
-
|
78 |
-
// Still here ? In that case, it is an anonymous class.
|
79 |
-
$phpcsFile->addError(
|
80 |
-
'Anonymous classes are not supported in PHP 5.6 or earlier',
|
81 |
-
$stackPtr,
|
82 |
-
'Found'
|
83 |
-
);
|
84 |
-
|
85 |
-
}//end process()
|
86 |
-
|
87 |
-
|
88 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewGroupUseDeclarationsSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim.godden@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\NewGroupUseDeclarationsSniff.
|
18 |
-
*
|
19 |
-
* PHP version 7.0
|
20 |
-
*
|
21 |
-
* @category PHP
|
22 |
-
* @package PHPCompatibility
|
23 |
-
* @author Wim Godden <wim.godden@cu.be>
|
24 |
-
*/
|
25 |
-
class NewGroupUseDeclarationsSniff extends Sniff
|
26 |
-
{
|
27 |
-
/**
|
28 |
-
* Returns an array of tokens this test wants to listen for.
|
29 |
-
*
|
30 |
-
* @return array
|
31 |
-
*/
|
32 |
-
public function register()
|
33 |
-
{
|
34 |
-
if (defined('T_OPEN_USE_GROUP')) {
|
35 |
-
return array(T_OPEN_USE_GROUP);
|
36 |
-
} else {
|
37 |
-
return array(T_USE);
|
38 |
-
}
|
39 |
-
}//end register()
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Processes this test, when one of its tokens is encountered.
|
44 |
-
*
|
45 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
46 |
-
* @param int $stackPtr The position of the current token in
|
47 |
-
* the stack passed in $tokens.
|
48 |
-
*
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
52 |
-
{
|
53 |
-
if ($this->supportsBelow('7.1') === false) {
|
54 |
-
return;
|
55 |
-
}
|
56 |
-
|
57 |
-
$tokens = $phpcsFile->getTokens();
|
58 |
-
$token = $tokens[$stackPtr];
|
59 |
-
|
60 |
-
// Deal with PHPCS pre-2.6.0.
|
61 |
-
if ($token['code'] === T_USE) {
|
62 |
-
$hasCurlyBrace = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
|
63 |
-
if ($hasCurlyBrace === false) {
|
64 |
-
return;
|
65 |
-
}
|
66 |
-
|
67 |
-
$prevToken = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
|
68 |
-
if ($prevToken === false || $tokens[$prevToken]['code'] !== T_NS_SEPARATOR) {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
$stackPtr = $hasCurlyBrace;
|
73 |
-
}
|
74 |
-
|
75 |
-
// Still here ? In that case, it is a group use statement.
|
76 |
-
if ($this->supportsBelow('5.6') === true) {
|
77 |
-
$phpcsFile->addError(
|
78 |
-
'Group use declarations are not allowed in PHP 5.6 or earlier',
|
79 |
-
$stackPtr,
|
80 |
-
'Found'
|
81 |
-
);
|
82 |
-
}
|
83 |
-
|
84 |
-
$closers = array(T_CLOSE_CURLY_BRACKET);
|
85 |
-
if (defined('T_CLOSE_USE_GROUP')) {
|
86 |
-
$closers[] = T_CLOSE_USE_GROUP;
|
87 |
-
}
|
88 |
-
|
89 |
-
$closeCurly = $phpcsFile->findNext($closers, ($stackPtr + 1), null, false, null, true);
|
90 |
-
if ($closeCurly === false) {
|
91 |
-
return;
|
92 |
-
}
|
93 |
-
|
94 |
-
$prevToken = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($closeCurly - 1), null, true);
|
95 |
-
if ($tokens[$prevToken]['code'] === T_COMMA) {
|
96 |
-
$phpcsFile->addError(
|
97 |
-
'Trailing comma\'s are not allowed in group use statements in PHP 7.1 or earlier',
|
98 |
-
$prevToken,
|
99 |
-
'TrailingCommaFound'
|
100 |
-
);
|
101 |
-
}
|
102 |
-
}//end process()
|
103 |
-
|
104 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/NewUseConstFunctionSniff.php
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewUseConstFunctionSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.6
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\NewUseConstFunctionSniff.
|
18 |
-
*
|
19 |
-
* The use operator has been extended to support importing functions and
|
20 |
-
* constants in addition to classes. This is achieved via the use function
|
21 |
-
* and use const constructs, respectively.
|
22 |
-
*
|
23 |
-
* PHP version 5.6
|
24 |
-
*
|
25 |
-
* @category PHP
|
26 |
-
* @package PHPCompatibility
|
27 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
-
*/
|
29 |
-
class NewUseConstFunctionSniff extends Sniff
|
30 |
-
{
|
31 |
-
|
32 |
-
/**
|
33 |
-
* A list of keywords that can follow use statements.
|
34 |
-
*
|
35 |
-
* @var array(string => string)
|
36 |
-
*/
|
37 |
-
protected $validUseNames = array(
|
38 |
-
'const' => true,
|
39 |
-
'function' => true,
|
40 |
-
);
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Returns an array of tokens this test wants to listen for.
|
44 |
-
*
|
45 |
-
* @return array
|
46 |
-
*/
|
47 |
-
public function register()
|
48 |
-
{
|
49 |
-
return array(T_USE);
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Processes this test, when one of its tokens is encountered.
|
55 |
-
*
|
56 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
57 |
-
* @param int $stackPtr The position of the current token in the
|
58 |
-
* stack passed in $tokens.
|
59 |
-
*
|
60 |
-
* @return void
|
61 |
-
*/
|
62 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
63 |
-
{
|
64 |
-
if ($this->supportsBelow('5.5') !== true) {
|
65 |
-
return;
|
66 |
-
}
|
67 |
-
|
68 |
-
$tokens = $phpcsFile->getTokens();
|
69 |
-
|
70 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
71 |
-
if ($nextNonEmpty === false) {
|
72 |
-
// Live coding.
|
73 |
-
return;
|
74 |
-
}
|
75 |
-
|
76 |
-
if (isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === false) {
|
77 |
-
// Not a `use const` or `use function` statement.
|
78 |
-
return;
|
79 |
-
}
|
80 |
-
|
81 |
-
// `use const` and `use function` have to be followed by the function/constant name.
|
82 |
-
$functionOrConstName = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
|
83 |
-
if ($functionOrConstName === false
|
84 |
-
// Identifies as T_AS or T_STRING, this covers both.
|
85 |
-
|| ($tokens[$functionOrConstName]['content'] === 'as'
|
86 |
-
|| $tokens[$functionOrConstName]['code'] === T_COMMA)
|
87 |
-
) {
|
88 |
-
// Live coding or incorrect use of reserved keyword, but that is
|
89 |
-
// covered by the ForbiddenNames sniff.
|
90 |
-
return;
|
91 |
-
}
|
92 |
-
|
93 |
-
// Still here ? In that case we have encountered a `use const` or `use function` statement.
|
94 |
-
$phpcsFile->addError(
|
95 |
-
'Importing functions and constants through a "use" statement is not supported in PHP 5.5 or lower.',
|
96 |
-
$nextNonEmpty,
|
97 |
-
'Found'
|
98 |
-
);
|
99 |
-
}
|
100 |
-
|
101 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/RemovedConstantsSniff.php
DELETED
@@ -1,343 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\RemovedConstantsSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
11 |
-
|
12 |
-
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* \PHPCompatibility\Sniffs\PHP\RemovedConstantsSniff.
|
16 |
-
*
|
17 |
-
* @category PHP
|
18 |
-
* @package PHPCompatibility
|
19 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
-
*/
|
21 |
-
class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
|
22 |
-
{
|
23 |
-
|
24 |
-
/**
|
25 |
-
* A list of removed PHP Constants.
|
26 |
-
*
|
27 |
-
* The array lists : version number with false (deprecated) or true (removed).
|
28 |
-
* If's sufficient to list the first version where the constant was deprecated/removed.
|
29 |
-
*
|
30 |
-
* Note: PHP Constants are case-sensitive!
|
31 |
-
*
|
32 |
-
* @var array(string => array(string => bool|string|null))
|
33 |
-
*/
|
34 |
-
protected $removedConstants = array(
|
35 |
-
// Disabled since PHP 5.3.0 due to thread safety issues.
|
36 |
-
'FILEINFO_COMPRESS' => array(
|
37 |
-
'5.3' => true,
|
38 |
-
),
|
39 |
-
|
40 |
-
'CURLOPT_CLOSEPOLICY' => array(
|
41 |
-
'5.6' => true,
|
42 |
-
),
|
43 |
-
'CURLCLOSEPOLICY_LEAST_RECENTLY_USED' => array(
|
44 |
-
'5.6' => true,
|
45 |
-
),
|
46 |
-
'CURLCLOSEPOLICY_LEAST_TRAFFIC' => array(
|
47 |
-
'5.6' => true,
|
48 |
-
),
|
49 |
-
'CURLCLOSEPOLICY_SLOWEST' => array(
|
50 |
-
'5.6' => true,
|
51 |
-
),
|
52 |
-
'CURLCLOSEPOLICY_CALLBACK' => array(
|
53 |
-
'5.6' => true,
|
54 |
-
),
|
55 |
-
'CURLCLOSEPOLICY_OLDEST' => array(
|
56 |
-
'5.6' => true,
|
57 |
-
),
|
58 |
-
|
59 |
-
'PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT' => array(
|
60 |
-
'7.0' => true,
|
61 |
-
),
|
62 |
-
|
63 |
-
'INTL_IDNA_VARIANT_2003' => array(
|
64 |
-
'7.2' => false,
|
65 |
-
),
|
66 |
-
|
67 |
-
'MCRYPT_MODE_ECB' => array(
|
68 |
-
'7.1' => false,
|
69 |
-
'7.2' => true,
|
70 |
-
),
|
71 |
-
'MCRYPT_MODE_CBC' => array(
|
72 |
-
'7.1' => false,
|
73 |
-
'7.2' => true,
|
74 |
-
),
|
75 |
-
'MCRYPT_MODE_CFB' => array(
|
76 |
-
'7.1' => false,
|
77 |
-
'7.2' => true,
|
78 |
-
),
|
79 |
-
'MCRYPT_MODE_OFB' => array(
|
80 |
-
'7.1' => false,
|
81 |
-
'7.2' => true,
|
82 |
-
),
|
83 |
-
'MCRYPT_MODE_NOFB' => array(
|
84 |
-
'7.1' => false,
|
85 |
-
'7.2' => true,
|
86 |
-
),
|
87 |
-
'MCRYPT_MODE_STREAM' => array(
|
88 |
-
'7.1' => false,
|
89 |
-
'7.2' => true,
|
90 |
-
),
|
91 |
-
'MCRYPT_ENCRYPT' => array(
|
92 |
-
'7.1' => false,
|
93 |
-
'7.2' => true,
|
94 |
-
),
|
95 |
-
'MCRYPT_DECRYPT' => array(
|
96 |
-
'7.1' => false,
|
97 |
-
'7.2' => true,
|
98 |
-
),
|
99 |
-
'MCRYPT_DEV_RANDOM' => array(
|
100 |
-
'7.1' => false,
|
101 |
-
'7.2' => true,
|
102 |
-
),
|
103 |
-
'MCRYPT_DEV_URANDOM' => array(
|
104 |
-
'7.1' => false,
|
105 |
-
'7.2' => true,
|
106 |
-
),
|
107 |
-
'MCRYPT_RAND' => array(
|
108 |
-
'7.1' => false,
|
109 |
-
'7.2' => true,
|
110 |
-
),
|
111 |
-
'MCRYPT_3DES' => array(
|
112 |
-
'7.1' => false,
|
113 |
-
'7.2' => true,
|
114 |
-
),
|
115 |
-
'MCRYPT_ARCFOUR_IV' => array(
|
116 |
-
'7.1' => false,
|
117 |
-
'7.2' => true,
|
118 |
-
),
|
119 |
-
'MCRYPT_ARCFOUR' => array(
|
120 |
-
'7.1' => false,
|
121 |
-
'7.2' => true,
|
122 |
-
),
|
123 |
-
'MCRYPT_BLOWFISH' => array(
|
124 |
-
'7.1' => false,
|
125 |
-
'7.2' => true,
|
126 |
-
),
|
127 |
-
'MCRYPT_CAST_128' => array(
|
128 |
-
'7.1' => false,
|
129 |
-
'7.2' => true,
|
130 |
-
),
|
131 |
-
'MCRYPT_CAST_256' => array(
|
132 |
-
'7.1' => false,
|
133 |
-
'7.2' => true,
|
134 |
-
),
|
135 |
-
'MCRYPT_CRYPT' => array(
|
136 |
-
'7.1' => false,
|
137 |
-
'7.2' => true,
|
138 |
-
),
|
139 |
-
'MCRYPT_DES' => array(
|
140 |
-
'7.1' => false,
|
141 |
-
'7.2' => true,
|
142 |
-
),
|
143 |
-
'MCRYPT_DES_COMPAT' => array(
|
144 |
-
'7.1' => false,
|
145 |
-
'7.2' => true,
|
146 |
-
),
|
147 |
-
'MCRYPT_ENIGMA' => array(
|
148 |
-
'7.1' => false,
|
149 |
-
'7.2' => true,
|
150 |
-
),
|
151 |
-
'MCRYPT_GOST' => array(
|
152 |
-
'7.1' => false,
|
153 |
-
'7.2' => true,
|
154 |
-
),
|
155 |
-
'MCRYPT_IDEA' => array(
|
156 |
-
'7.1' => false,
|
157 |
-
'7.2' => true,
|
158 |
-
),
|
159 |
-
'MCRYPT_LOKI97' => array(
|
160 |
-
'7.1' => false,
|
161 |
-
'7.2' => true,
|
162 |
-
),
|
163 |
-
'MCRYPT_MARS' => array(
|
164 |
-
'7.1' => false,
|
165 |
-
'7.2' => true,
|
166 |
-
),
|
167 |
-
'MCRYPT_PANAMA' => array(
|
168 |
-
'7.1' => false,
|
169 |
-
'7.2' => true,
|
170 |
-
),
|
171 |
-
'MCRYPT_RIJNDAEL_128' => array(
|
172 |
-
'7.1' => false,
|
173 |
-
'7.2' => true,
|
174 |
-
),
|
175 |
-
'MCRYPT_RIJNDAEL_192' => array(
|
176 |
-
'7.1' => false,
|
177 |
-
'7.2' => true,
|
178 |
-
),
|
179 |
-
'MCRYPT_RIJNDAEL_256' => array(
|
180 |
-
'7.1' => false,
|
181 |
-
'7.2' => true,
|
182 |
-
),
|
183 |
-
'MCRYPT_RC2' => array(
|
184 |
-
'7.1' => false,
|
185 |
-
'7.2' => true,
|
186 |
-
),
|
187 |
-
'MCRYPT_RC4' => array(
|
188 |
-
'7.1' => false,
|
189 |
-
'7.2' => true,
|
190 |
-
),
|
191 |
-
'MCRYPT_RC6' => array(
|
192 |
-
'7.1' => false,
|
193 |
-
'7.2' => true,
|
194 |
-
),
|
195 |
-
'MCRYPT_RC6_128' => array(
|
196 |
-
'7.1' => false,
|
197 |
-
'7.2' => true,
|
198 |
-
),
|
199 |
-
'MCRYPT_RC6_192' => array(
|
200 |
-
'7.1' => false,
|
201 |
-
'7.2' => true,
|
202 |
-
),
|
203 |
-
'MCRYPT_RC6_256' => array(
|
204 |
-
'7.1' => false,
|
205 |
-
'7.2' => true,
|
206 |
-
),
|
207 |
-
'MCRYPT_SAFER64' => array(
|
208 |
-
'7.1' => false,
|
209 |
-
'7.2' => true,
|
210 |
-
),
|
211 |
-
'MCRYPT_SAFER128' => array(
|
212 |
-
'7.1' => false,
|
213 |
-
'7.2' => true,
|
214 |
-
),
|
215 |
-
'MCRYPT_SAFERPLUS' => array(
|
216 |
-
'7.1' => false,
|
217 |
-
'7.2' => true,
|
218 |
-
),
|
219 |
-
'MCRYPT_SERPENT' => array(
|
220 |
-
'7.1' => false,
|
221 |
-
'7.2' => true,
|
222 |
-
),
|
223 |
-
'MCRYPT_SERPENT_128' => array(
|
224 |
-
'7.1' => false,
|
225 |
-
'7.2' => true,
|
226 |
-
),
|
227 |
-
'MCRYPT_SERPENT_192' => array(
|
228 |
-
'7.1' => false,
|
229 |
-
'7.2' => true,
|
230 |
-
),
|
231 |
-
'MCRYPT_SERPENT_256' => array(
|
232 |
-
'7.1' => false,
|
233 |
-
'7.2' => true,
|
234 |
-
),
|
235 |
-
'MCRYPT_SKIPJACK' => array(
|
236 |
-
'7.1' => false,
|
237 |
-
'7.2' => true,
|
238 |
-
),
|
239 |
-
'MCRYPT_TEAN' => array(
|
240 |
-
'7.1' => false,
|
241 |
-
'7.2' => true,
|
242 |
-
),
|
243 |
-
'MCRYPT_THREEWAY' => array(
|
244 |
-
'7.1' => false,
|
245 |
-
'7.2' => true,
|
246 |
-
),
|
247 |
-
'MCRYPT_TRIPLEDES' => array(
|
248 |
-
'7.1' => false,
|
249 |
-
'7.2' => true,
|
250 |
-
),
|
251 |
-
'MCRYPT_TWOFISH' => array(
|
252 |
-
'7.1' => false,
|
253 |
-
'7.2' => true,
|
254 |
-
),
|
255 |
-
'MCRYPT_TWOFISH128' => array(
|
256 |
-
'7.1' => false,
|
257 |
-
'7.2' => true,
|
258 |
-
),
|
259 |
-
'MCRYPT_TWOFISH192' => array(
|
260 |
-
'7.1' => false,
|
261 |
-
'7.2' => true,
|
262 |
-
),
|
263 |
-
'MCRYPT_TWOFISH256' => array(
|
264 |
-
'7.1' => false,
|
265 |
-
'7.2' => true,
|
266 |
-
),
|
267 |
-
'MCRYPT_WAKE' => array(
|
268 |
-
'7.1' => false,
|
269 |
-
'7.2' => true,
|
270 |
-
),
|
271 |
-
'MCRYPT_XTEA' => array(
|
272 |
-
'7.1' => false,
|
273 |
-
'7.2' => true,
|
274 |
-
),
|
275 |
-
);
|
276 |
-
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Returns an array of tokens this test wants to listen for.
|
280 |
-
*
|
281 |
-
* @return array
|
282 |
-
*/
|
283 |
-
public function register()
|
284 |
-
{
|
285 |
-
return array(T_STRING);
|
286 |
-
|
287 |
-
}//end register()
|
288 |
-
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Processes this test, when one of its tokens is encountered.
|
292 |
-
*
|
293 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
294 |
-
* @param int $stackPtr The position of the current token in
|
295 |
-
* the stack passed in $tokens.
|
296 |
-
*
|
297 |
-
* @return void
|
298 |
-
*/
|
299 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
300 |
-
{
|
301 |
-
$tokens = $phpcsFile->getTokens();
|
302 |
-
$constantName = $tokens[$stackPtr]['content'];
|
303 |
-
|
304 |
-
if (isset($this->removedConstants[$constantName]) === false) {
|
305 |
-
return;
|
306 |
-
}
|
307 |
-
|
308 |
-
if ($this->isUseOfGlobalConstant($phpcsFile, $stackPtr) === false) {
|
309 |
-
return;
|
310 |
-
}
|
311 |
-
|
312 |
-
$itemInfo = array(
|
313 |
-
'name' => $constantName,
|
314 |
-
);
|
315 |
-
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
316 |
-
|
317 |
-
}//end process()
|
318 |
-
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
322 |
-
*
|
323 |
-
* @param array $itemInfo Base information about the item.
|
324 |
-
*
|
325 |
-
* @return array Version and other information about the item.
|
326 |
-
*/
|
327 |
-
public function getItemArray(array $itemInfo)
|
328 |
-
{
|
329 |
-
return $this->removedConstants[$itemInfo['name']];
|
330 |
-
}
|
331 |
-
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Get the error message template for this sniff.
|
335 |
-
*
|
336 |
-
* @return string
|
337 |
-
*/
|
338 |
-
protected function getErrorMsgTemplate()
|
339 |
-
{
|
340 |
-
return 'The constant "%s" is ';
|
341 |
-
}
|
342 |
-
|
343 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/PHP/TernaryOperatorsSniff.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\TernaryOperatorsSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.3
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Ben Selby <bselby@plus.net>
|
10 |
-
* @copyright 2012 Ben Selby
|
11 |
-
*/
|
12 |
-
|
13 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
14 |
-
|
15 |
-
use PHPCompatibility\Sniff;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* \PHPCompatibility\Sniffs\PHP\TernaryOperatorsSniff.
|
19 |
-
*
|
20 |
-
* Performs checks on ternary operators, specifically that the middle expression
|
21 |
-
* is not omitted for versions that don't support this.
|
22 |
-
*
|
23 |
-
* PHP version 5.3
|
24 |
-
*
|
25 |
-
* @category PHP
|
26 |
-
* @package PHPCompatibility
|
27 |
-
* @author Ben Selby <bselby@plus.net>
|
28 |
-
* @copyright 2012 Ben Selby
|
29 |
-
*/
|
30 |
-
class TernaryOperatorsSniff extends Sniff
|
31 |
-
{
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Returns an array of tokens this test wants to listen for.
|
35 |
-
*
|
36 |
-
* @return array
|
37 |
-
*/
|
38 |
-
public function register()
|
39 |
-
{
|
40 |
-
return array(T_INLINE_THEN);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Processes this test, when one of its tokens is encountered.
|
45 |
-
*
|
46 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
47 |
-
* @param int $stackPtr The position of the current token in the
|
48 |
-
* stack passed in $tokens.
|
49 |
-
*
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
53 |
-
{
|
54 |
-
if ($this->supportsBelow('5.2') === false) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
|
58 |
-
$tokens = $phpcsFile->getTokens();
|
59 |
-
|
60 |
-
// Get next non-whitespace token, and check it isn't the related inline else
|
61 |
-
// symbol, which is not allowed prior to PHP 5.3.
|
62 |
-
$next = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
63 |
-
|
64 |
-
if ($next !== false && $tokens[$next]['code'] === T_INLINE_ELSE) {
|
65 |
-
$phpcsFile->addError(
|
66 |
-
'Middle may not be omitted from ternary operators in PHP < 5.3',
|
67 |
-
$stackPtr,
|
68 |
-
'MiddleMissing'
|
69 |
-
);
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/ForbiddenGetClassNullSniff.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\ForbiddenGetClassNullSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.2
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
13 |
+
|
14 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ParameterValues\ForbiddenGetClassNullSniff.
|
19 |
+
*
|
20 |
+
* Detect: Passing `null` to get_class() is no longer allowed as of PHP 7.2.
|
21 |
+
* This will now result in an E_WARNING being thrown.
|
22 |
+
*
|
23 |
+
* PHP version 7.2
|
24 |
+
*
|
25 |
+
* @category PHP
|
26 |
+
* @package PHPCompatibility
|
27 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
+
*/
|
29 |
+
class ForbiddenGetClassNullSniff extends AbstractFunctionCallParameterSniff
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Functions to check for.
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
protected $targetFunctions = array(
|
38 |
+
'get_class' => true,
|
39 |
+
);
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Do a version check to determine if this sniff needs to run at all.
|
44 |
+
*
|
45 |
+
* @return bool
|
46 |
+
*/
|
47 |
+
protected function bowOutEarly()
|
48 |
+
{
|
49 |
+
return ($this->supportsAbove('7.2') === false);
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Process the parameters of a matched function.
|
55 |
+
*
|
56 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
57 |
+
* @param int $stackPtr The position of the current token in the stack.
|
58 |
+
* @param string $functionName The token content (function name) which was matched.
|
59 |
+
* @param array $parameters Array with information about the parameters.
|
60 |
+
*
|
61 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
62 |
+
* normal file processing.
|
63 |
+
*/
|
64 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
65 |
+
{
|
66 |
+
if (isset($parameters[1]) === false) {
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
if ($parameters[1]['raw'] !== 'null') {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
$phpcsFile->addError(
|
75 |
+
'Passing "null" as the $object to get_class() is not allowed since PHP 7.2.',
|
76 |
+
$parameters[1]['start'],
|
77 |
+
'Found'
|
78 |
+
);
|
79 |
+
}
|
80 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewArrayReduceInitialTypeSniff.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewArrayReduceInitialTypeSniff.
|
4 |
+
*
|
5 |
+
* @category PHP
|
6 |
+
* @package PHPCompatibility
|
7 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
11 |
+
|
12 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewArrayReduceInitialTypeSniff.
|
17 |
+
*
|
18 |
+
* Detect: In PHP 5.2 and lower, the $initial parameter had to be an integer.
|
19 |
+
*
|
20 |
+
* @category PHP
|
21 |
+
* @package PHPCompatibility
|
22 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
23 |
+
*/
|
24 |
+
class NewArrayReduceInitialTypeSniff extends AbstractFunctionCallParameterSniff
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Functions to check for.
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
protected $targetFunctions = array(
|
33 |
+
'array_reduce' => true,
|
34 |
+
);
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Tokens which, for the purposes of this sniff, indicate that there is
|
38 |
+
* a variable element to the value passed.
|
39 |
+
*
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
private $variableValueTokens = array(
|
43 |
+
\T_VARIABLE,
|
44 |
+
\T_STRING,
|
45 |
+
\T_SELF,
|
46 |
+
\T_PARENT,
|
47 |
+
\T_STATIC,
|
48 |
+
\T_DOUBLE_QUOTED_STRING,
|
49 |
+
);
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Do a version check to determine if this sniff needs to run at all.
|
54 |
+
*
|
55 |
+
* @return bool
|
56 |
+
*/
|
57 |
+
protected function bowOutEarly()
|
58 |
+
{
|
59 |
+
return ($this->supportsBelow('5.2') === false);
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Process the parameters of a matched function.
|
65 |
+
*
|
66 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
67 |
+
* @param int $stackPtr The position of the current token in the stack.
|
68 |
+
* @param string $functionName The token content (function name) which was matched.
|
69 |
+
* @param array $parameters Array with information about the parameters.
|
70 |
+
*
|
71 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
72 |
+
* normal file processing.
|
73 |
+
*/
|
74 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
75 |
+
{
|
76 |
+
if (isset($parameters[3]) === false) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
$targetParam = $parameters[3];
|
81 |
+
if ($this->isNumber($phpcsFile, $targetParam['start'], $targetParam['end'], true) !== false) {
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($this->isNumericCalculation($phpcsFile, $targetParam['start'], $targetParam['end']) === true) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
$error = 'Passing a non-integer as the value for $initial to array_reduce() is not supported in PHP 5.2 or lower.';
|
90 |
+
if ($phpcsFile->findNext($this->variableValueTokens, $targetParam['start'], ($targetParam['end'] + 1)) === false) {
|
91 |
+
$phpcsFile->addError(
|
92 |
+
$error . ' Found %s',
|
93 |
+
$targetParam['start'],
|
94 |
+
'InvalidTypeFound',
|
95 |
+
array($targetParam['raw'])
|
96 |
+
);
|
97 |
+
} else {
|
98 |
+
$phpcsFile->addWarning(
|
99 |
+
$error . ' Variable value found. Found %s',
|
100 |
+
$targetParam['start'],
|
101 |
+
'VariableFound',
|
102 |
+
array($targetParam['raw'])
|
103 |
+
);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewFopenModesSniff.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewFopenModesSniff.
|
4 |
+
*
|
5 |
+
* @category PHP
|
6 |
+
* @package PHPCompatibility
|
7 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
11 |
+
|
12 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewFopenModesSniff.
|
17 |
+
*
|
18 |
+
* Detect: Changes in allowed values for the fopen() $mode parameter.
|
19 |
+
*
|
20 |
+
* @category PHP
|
21 |
+
* @package PHPCompatibility
|
22 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
23 |
+
*/
|
24 |
+
class NewFopenModesSniff extends AbstractFunctionCallParameterSniff
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Functions to check for.
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
protected $targetFunctions = array(
|
33 |
+
'fopen' => true,
|
34 |
+
);
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Do a version check to determine if this sniff needs to run at all.
|
39 |
+
*
|
40 |
+
* @return bool
|
41 |
+
*/
|
42 |
+
protected function bowOutEarly()
|
43 |
+
{
|
44 |
+
// Version used here should be (above) the highest version from the `newModes` control,
|
45 |
+
// structure below, i.e. the last PHP version in which a new mode was introduced.
|
46 |
+
return ($this->supportsBelow('7.1') === false);
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Process the parameters of a matched function.
|
52 |
+
*
|
53 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
54 |
+
* @param int $stackPtr The position of the current token in the stack.
|
55 |
+
* @param string $functionName The token content (function name) which was matched.
|
56 |
+
* @param array $parameters Array with information about the parameters.
|
57 |
+
*
|
58 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
59 |
+
* normal file processing.
|
60 |
+
*/
|
61 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
62 |
+
{
|
63 |
+
if (isset($parameters[2]) === false) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
$tokens = $phpcsFile->getTokens();
|
68 |
+
$targetParam = $parameters[2];
|
69 |
+
$errors = array();
|
70 |
+
|
71 |
+
for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
|
72 |
+
if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING) {
|
73 |
+
continue;
|
74 |
+
}
|
75 |
+
|
76 |
+
if (strpos($tokens[$i]['content'], 'c+') !== false && $this->supportsBelow('5.2.5')) {
|
77 |
+
$errors['cplusFound'] = array(
|
78 |
+
'c+',
|
79 |
+
'5.2.5',
|
80 |
+
$targetParam['raw'],
|
81 |
+
);
|
82 |
+
} elseif (strpos($tokens[$i]['content'], 'c') !== false && $this->supportsBelow('5.2.5')) {
|
83 |
+
$errors['cFound'] = array(
|
84 |
+
'c',
|
85 |
+
'5.2.5',
|
86 |
+
$targetParam['raw'],
|
87 |
+
);
|
88 |
+
}
|
89 |
+
|
90 |
+
if (strpos($tokens[$i]['content'], 'e') !== false && $this->supportsBelow('7.0.15')) {
|
91 |
+
$errors['eFound'] = array(
|
92 |
+
'e',
|
93 |
+
'7.0.15',
|
94 |
+
$targetParam['raw'],
|
95 |
+
);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
if (empty($errors) === true) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
foreach ($errors as $errorCode => $errorData) {
|
104 |
+
$phpcsFile->addError(
|
105 |
+
'Passing "%s" as the $mode to fopen() is not supported in PHP %s or lower. Found %s',
|
106 |
+
$targetParam['start'],
|
107 |
+
$errorCode,
|
108 |
+
$errorData
|
109 |
+
);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ParameterValues}/NewHashAlgorithmsSniff.php
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -108,9 +109,8 @@ class NewHashAlgorithmsSniff extends AbstractNewFeatureSniff
|
|
108 |
*/
|
109 |
public function register()
|
110 |
{
|
111 |
-
return array(T_STRING);
|
112 |
-
|
113 |
-
}//end register()
|
114 |
|
115 |
|
116 |
/**
|
@@ -122,10 +122,10 @@ class NewHashAlgorithmsSniff extends AbstractNewFeatureSniff
|
|
122 |
*
|
123 |
* @return void
|
124 |
*/
|
125 |
-
public function process(
|
126 |
{
|
127 |
$algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
|
128 |
-
if (empty($algo) || is_string($algo) === false) {
|
129 |
return;
|
130 |
}
|
131 |
|
@@ -139,8 +139,7 @@ class NewHashAlgorithmsSniff extends AbstractNewFeatureSniff
|
|
139 |
'name' => $algo,
|
140 |
);
|
141 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
142 |
-
|
143 |
-
}//end process()
|
144 |
|
145 |
|
146 |
/**
|
@@ -165,6 +164,4 @@ class NewHashAlgorithmsSniff extends AbstractNewFeatureSniff
|
|
165 |
{
|
166 |
return 'The %s hash algorithm is not present in PHP version %s or earlier';
|
167 |
}
|
168 |
-
|
169 |
-
|
170 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewHashAlgorithmsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewHashAlgorithmsSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
109 |
*/
|
110 |
public function register()
|
111 |
{
|
112 |
+
return array(\T_STRING);
|
113 |
+
}
|
|
|
114 |
|
115 |
|
116 |
/**
|
122 |
*
|
123 |
* @return void
|
124 |
*/
|
125 |
+
public function process(File $phpcsFile, $stackPtr)
|
126 |
{
|
127 |
$algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
|
128 |
+
if (empty($algo) || \is_string($algo) === false) {
|
129 |
return;
|
130 |
}
|
131 |
|
139 |
'name' => $algo,
|
140 |
);
|
141 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
142 |
+
}
|
|
|
143 |
|
144 |
|
145 |
/**
|
164 |
{
|
165 |
return 'The %s hash algorithm is not present in PHP version %s or earlier';
|
166 |
}
|
167 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewNegativeStringOffsetSniff.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewNegativeStringOffsetSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.1
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
13 |
+
|
14 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewNegativeStringOffsetSniff.
|
19 |
+
*
|
20 |
+
* Detect: negative string offsets as parameters passed to functions where this
|
21 |
+
* was not allowed prior to PHP 7.1.
|
22 |
+
*
|
23 |
+
* PHP version 7.1
|
24 |
+
*
|
25 |
+
* @category PHP
|
26 |
+
* @package PHPCompatibility
|
27 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
+
*/
|
29 |
+
class NewNegativeStringOffsetSniff extends AbstractFunctionCallParameterSniff
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Functions to check for.
|
34 |
+
*
|
35 |
+
* @var array Function name => 1-based parameter offset of the affected parameters => parameter name.
|
36 |
+
*/
|
37 |
+
protected $targetFunctions = array(
|
38 |
+
'file_get_contents' => array(
|
39 |
+
4 => 'offset',
|
40 |
+
),
|
41 |
+
'grapheme_extract' => array(
|
42 |
+
4 => 'start',
|
43 |
+
),
|
44 |
+
'grapheme_stripos' => array(
|
45 |
+
3 => 'offset',
|
46 |
+
),
|
47 |
+
'grapheme_strpos' => array(
|
48 |
+
3 => 'offset',
|
49 |
+
),
|
50 |
+
'iconv_strpos' => array(
|
51 |
+
3 => 'offset',
|
52 |
+
),
|
53 |
+
'mb_ereg_search_setpos' => array(
|
54 |
+
1 => 'position',
|
55 |
+
),
|
56 |
+
'mb_strimwidth' => array(
|
57 |
+
2 => 'start',
|
58 |
+
3 => 'width',
|
59 |
+
),
|
60 |
+
'mb_stripos' => array(
|
61 |
+
3 => 'offset',
|
62 |
+
),
|
63 |
+
'mb_strpos' => array(
|
64 |
+
3 => 'offset',
|
65 |
+
),
|
66 |
+
'stripos' => array(
|
67 |
+
3 => 'offset',
|
68 |
+
),
|
69 |
+
'strpos' => array(
|
70 |
+
3 => 'offset',
|
71 |
+
),
|
72 |
+
'substr_count' => array(
|
73 |
+
3 => 'offset',
|
74 |
+
4 => 'length',
|
75 |
+
),
|
76 |
+
);
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Do a version check to determine if this sniff needs to run at all.
|
81 |
+
*
|
82 |
+
* @return bool
|
83 |
+
*/
|
84 |
+
protected function bowOutEarly()
|
85 |
+
{
|
86 |
+
return ($this->supportsBelow('7.0') === false);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Process the parameters of a matched function.
|
91 |
+
*
|
92 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
93 |
+
* @param int $stackPtr The position of the current token in the stack.
|
94 |
+
* @param string $functionName The token content (function name) which was matched.
|
95 |
+
* @param array $parameters Array with information about the parameters.
|
96 |
+
*
|
97 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
98 |
+
* normal file processing.
|
99 |
+
*/
|
100 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
101 |
+
{
|
102 |
+
$functionLC = strtolower($functionName);
|
103 |
+
foreach ($this->targetFunctions[$functionLC] as $pos => $name) {
|
104 |
+
if (isset($parameters[$pos]) === false) {
|
105 |
+
continue;
|
106 |
+
}
|
107 |
+
|
108 |
+
$targetParam = $parameters[$pos];
|
109 |
+
|
110 |
+
if ($this->isNegativeNumber($phpcsFile, $targetParam['start'], $targetParam['end']) === false) {
|
111 |
+
continue;
|
112 |
+
}
|
113 |
+
|
114 |
+
$phpcsFile->addError(
|
115 |
+
'Negative string offsets were not supported for the $%s parameter in %s() in PHP 7.0 or lower. Found %s',
|
116 |
+
$targetParam['start'],
|
117 |
+
'Found',
|
118 |
+
array(
|
119 |
+
$name,
|
120 |
+
$functionName,
|
121 |
+
$targetParam['raw'],
|
122 |
+
)
|
123 |
+
);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/PCRENewModifiersSniff.php → ParameterValues/NewPCREModifiersSniff.php}
RENAMED
@@ -1,18 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
-
use PHPCompatibility\Sniffs\
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* Check for usage of newly added regex modifiers for PCRE functions.
|
18 |
*
|
@@ -20,7 +21,7 @@ use PHPCompatibility\Sniffs\PHP\PregReplaceEModifierSniff;
|
|
20 |
* @package PHPCompatibility
|
21 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
|
26 |
/**
|
@@ -80,7 +81,7 @@ class PCRENewModifiersSniff extends PregReplaceEModifierSniff
|
|
80 |
*
|
81 |
* @return void
|
82 |
*/
|
83 |
-
protected function examineModifiers(
|
84 |
{
|
85 |
$error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier';
|
86 |
|
@@ -111,5 +112,4 @@ class PCRENewModifiersSniff extends PregReplaceEModifierSniff
|
|
111 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
112 |
}
|
113 |
}
|
114 |
-
|
115 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewPCREModifiers.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
11 |
|
12 |
+
use PHPCompatibility\Sniffs\ParameterValues\RemovedPCREModifiersSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewPCREModifiers.
|
17 |
*
|
18 |
* Check for usage of newly added regex modifiers for PCRE functions.
|
19 |
*
|
21 |
* @package PHPCompatibility
|
22 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
23 |
*/
|
24 |
+
class NewPCREModifiersSniff extends RemovedPCREModifiersSniff
|
25 |
{
|
26 |
|
27 |
/**
|
81 |
*
|
82 |
* @return void
|
83 |
*/
|
84 |
+
protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
|
85 |
{
|
86 |
$error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier';
|
87 |
|
112 |
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
113 |
}
|
114 |
}
|
115 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewPackFormatSniff.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewPackFormatSniff.
|
4 |
+
*
|
5 |
+
* @category PHP
|
6 |
+
* @package PHPCompatibility
|
7 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
11 |
+
|
12 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* \PHPCompatibility\Sniffs\ParameterValues\NewPackFormatSniff.
|
17 |
+
*
|
18 |
+
* Detect: Changes in the allowed values for $format passed to pack().
|
19 |
+
*
|
20 |
+
* @category PHP
|
21 |
+
* @package PHPCompatibility
|
22 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
23 |
+
*/
|
24 |
+
class NewPackFormatSniff extends AbstractFunctionCallParameterSniff
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Functions to check for.
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
protected $targetFunctions = array(
|
33 |
+
'pack' => true,
|
34 |
+
);
|
35 |
+
|
36 |
+
/**
|
37 |
+
* List of new format character codes added to pack().
|
38 |
+
*
|
39 |
+
* @var array Regex pattern => Version array.
|
40 |
+
*/
|
41 |
+
protected $newFormats = array(
|
42 |
+
'`([Z])`' => array(
|
43 |
+
'5.4' => false,
|
44 |
+
'5.5' => true,
|
45 |
+
),
|
46 |
+
'`([qQJP])`' => array(
|
47 |
+
'5.6.2' => false,
|
48 |
+
'5.6.3' => true,
|
49 |
+
),
|
50 |
+
'`([eEgG])`' => array(
|
51 |
+
'7.0.14' => false,
|
52 |
+
'7.0.15' => true, // And 7.1.1.
|
53 |
+
),
|
54 |
+
);
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Do a version check to determine if this sniff needs to run at all.
|
59 |
+
*
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
protected function bowOutEarly()
|
63 |
+
{
|
64 |
+
return ($this->supportsBelow('7.1') === false);
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Process the parameters of a matched function.
|
70 |
+
*
|
71 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
72 |
+
* @param int $stackPtr The position of the current token in the stack.
|
73 |
+
* @param string $functionName The token content (function name) which was matched.
|
74 |
+
* @param array $parameters Array with information about the parameters.
|
75 |
+
*
|
76 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
77 |
+
* normal file processing.
|
78 |
+
*/
|
79 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
80 |
+
{
|
81 |
+
if (isset($parameters[1]) === false) {
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$tokens = $phpcsFile->getTokens();
|
86 |
+
$targetParam = $parameters[1];
|
87 |
+
|
88 |
+
for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
|
89 |
+
if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
|
90 |
+
&& $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
|
91 |
+
) {
|
92 |
+
continue;
|
93 |
+
}
|
94 |
+
|
95 |
+
$content = $tokens[$i]['content'];
|
96 |
+
if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
|
97 |
+
$content = $this->stripVariables($content);
|
98 |
+
}
|
99 |
+
|
100 |
+
foreach ($this->newFormats as $pattern => $versionArray) {
|
101 |
+
if (preg_match($pattern, $content, $matches) !== 1) {
|
102 |
+
continue;
|
103 |
+
}
|
104 |
+
|
105 |
+
foreach ($versionArray as $version => $present) {
|
106 |
+
if ($present === false && $this->supportsBelow($version) === true) {
|
107 |
+
$phpcsFile->addError(
|
108 |
+
'Passing the $format(s) "%s" to pack() is not supported in PHP %s or lower. Found %s',
|
109 |
+
$targetParam['start'],
|
110 |
+
'NewFormatFound',
|
111 |
+
array(
|
112 |
+
$matches[1],
|
113 |
+
$version,
|
114 |
+
$targetParam['raw'],
|
115 |
+
)
|
116 |
+
);
|
117 |
+
continue 2;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → ParameterValues}/RemovedHashAlgorithmsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -10,12 +10,13 @@
|
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Discourages the use of deprecated and removed hash algorithms.
|
21 |
*
|
@@ -53,9 +54,8 @@ class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff
|
|
53 |
*/
|
54 |
public function register()
|
55 |
{
|
56 |
-
return array(T_STRING);
|
57 |
-
|
58 |
-
}//end register()
|
59 |
|
60 |
|
61 |
/**
|
@@ -67,10 +67,10 @@ class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff
|
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
-
public function process(
|
71 |
{
|
72 |
$algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
|
73 |
-
if (empty($algo) || is_string($algo) === false) {
|
74 |
return;
|
75 |
}
|
76 |
|
@@ -83,8 +83,7 @@ class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff
|
|
83 |
'name' => $algo,
|
84 |
);
|
85 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
86 |
-
|
87 |
-
}//end process()
|
88 |
|
89 |
|
90 |
/**
|
@@ -109,6 +108,4 @@ class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff
|
|
109 |
{
|
110 |
return 'The %s hash algorithm is ';
|
111 |
}
|
112 |
-
|
113 |
-
|
114 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedHashAlgorithmsSniff.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
14 |
|
15 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedHashAlgorithmsSniff.
|
20 |
*
|
21 |
* Discourages the use of deprecated and removed hash algorithms.
|
22 |
*
|
54 |
*/
|
55 |
public function register()
|
56 |
{
|
57 |
+
return array(\T_STRING);
|
58 |
+
}
|
|
|
59 |
|
60 |
|
61 |
/**
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
+
public function process(File $phpcsFile, $stackPtr)
|
71 |
{
|
72 |
$algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
|
73 |
+
if (empty($algo) || \is_string($algo) === false) {
|
74 |
return;
|
75 |
}
|
76 |
|
83 |
'name' => $algo,
|
84 |
);
|
85 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
86 |
+
}
|
|
|
87 |
|
88 |
|
89 |
/**
|
108 |
{
|
109 |
return 'The %s hash algorithm is ';
|
110 |
}
|
111 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedIconvEncodingSniff.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedIconvEncodingSniff.
|
4 |
+
*
|
5 |
+
* PHP version 5.6
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
13 |
+
|
14 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedIconvEncodingSniff.
|
19 |
+
*
|
20 |
+
* Detect: "The iconv and mbstring configuration options related to encoding
|
21 |
+
* have been deprecated in favour of default_charset."
|
22 |
+
*
|
23 |
+
* {@internal It is unclear which mbstring functions should be targetted, so for now,
|
24 |
+
* only the iconv function is handled.}}
|
25 |
+
*
|
26 |
+
* PHP version 5.6
|
27 |
+
*
|
28 |
+
* @category PHP
|
29 |
+
* @package PHPCompatibility
|
30 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
31 |
+
*/
|
32 |
+
class RemovedIconvEncodingSniff extends AbstractFunctionCallParameterSniff
|
33 |
+
{
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Functions to check for.
|
37 |
+
*
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
protected $targetFunctions = array(
|
41 |
+
'iconv_set_encoding' => true,
|
42 |
+
);
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Do a version check to determine if this sniff needs to run at all.
|
47 |
+
*
|
48 |
+
* @return bool
|
49 |
+
*/
|
50 |
+
protected function bowOutEarly()
|
51 |
+
{
|
52 |
+
return ($this->supportsAbove('5.6') === false);
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Process the parameters of a matched function.
|
58 |
+
*
|
59 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
60 |
+
* @param int $stackPtr The position of the current token in the stack.
|
61 |
+
* @param string $functionName The token content (function name) which was matched.
|
62 |
+
* @param array $parameters Array with information about the parameters.
|
63 |
+
*
|
64 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
65 |
+
* normal file processing.
|
66 |
+
*/
|
67 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
68 |
+
{
|
69 |
+
if (isset($parameters[1]) === false) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
$phpcsFile->addWarning(
|
74 |
+
'All previously accepted values for the $type parameter of iconv_set_encoding() have been deprecated since PHP 5.6. Found %s',
|
75 |
+
$parameters[1]['start'],
|
76 |
+
'DeprecatedValueFound',
|
77 |
+
$parameters[1]['raw']
|
78 |
+
);
|
79 |
+
}
|
80 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/MbstringReplaceEModifierSniff.php → ParameterValues/RemovedMbstringModifiersSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 7.1
|
20 |
*
|
@@ -22,7 +24,7 @@ use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
|
22 |
* @package PHPCompatibility
|
23 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
|
28 |
/**
|
@@ -36,6 +38,8 @@ class MbstringReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
36 |
'mb_ereg_replace' => 4,
|
37 |
'mb_eregi_replace' => 4,
|
38 |
'mb_regex_set_options' => 1,
|
|
|
|
|
39 |
);
|
40 |
|
41 |
|
@@ -65,7 +69,7 @@ class MbstringReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
65 |
* @return int|void Integer stack pointer to skip forward or void to continue
|
66 |
* normal file processing.
|
67 |
*/
|
68 |
-
public function processParameters(
|
69 |
{
|
70 |
$tokens = $phpcsFile->getTokens();
|
71 |
$functionNameLc = strtolower($functionName);
|
@@ -77,7 +81,7 @@ class MbstringReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
77 |
|
78 |
$optionsParam = $parameters[$this->targetFunctions[$functionNameLc]];
|
79 |
|
80 |
-
$stringToken = $phpcsFile->findNext(
|
81 |
if ($stringToken === false) {
|
82 |
// No string token found in the options parameter, so skip it (e.g. variable passed in).
|
83 |
return;
|
@@ -89,12 +93,12 @@ class MbstringReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
89 |
* Get the content of any string tokens in the options parameter and remove the quotes and variables.
|
90 |
*/
|
91 |
for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
|
92 |
-
if (
|
93 |
continue;
|
94 |
}
|
95 |
|
96 |
$content = $this->stripQuotes($tokens[$i]['content']);
|
97 |
-
if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
|
98 |
$content = $this->stripVariables($content);
|
99 |
}
|
100 |
$content = trim($content);
|
@@ -115,4 +119,4 @@ class MbstringReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
115 |
$phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
|
116 |
}
|
117 |
}
|
118 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedMbstringModifiersSniff.
|
4 |
*
|
5 |
* PHP version 7.1
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
13 |
|
14 |
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedMbstringModifiersSniff.
|
20 |
*
|
21 |
* PHP version 7.1
|
22 |
*
|
24 |
* @package PHPCompatibility
|
25 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
*/
|
27 |
+
class RemovedMbstringModifiersSniff extends AbstractFunctionCallParameterSniff
|
28 |
{
|
29 |
|
30 |
/**
|
38 |
'mb_ereg_replace' => 4,
|
39 |
'mb_eregi_replace' => 4,
|
40 |
'mb_regex_set_options' => 1,
|
41 |
+
'mbereg_replace' => 4, // Undocumented, but valid function alias.
|
42 |
+
'mberegi_replace' => 4, // Undocumented, but valid function alias.
|
43 |
);
|
44 |
|
45 |
|
69 |
* @return int|void Integer stack pointer to skip forward or void to continue
|
70 |
* normal file processing.
|
71 |
*/
|
72 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
73 |
{
|
74 |
$tokens = $phpcsFile->getTokens();
|
75 |
$functionNameLc = strtolower($functionName);
|
81 |
|
82 |
$optionsParam = $parameters[$this->targetFunctions[$functionNameLc]];
|
83 |
|
84 |
+
$stringToken = $phpcsFile->findNext(Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
|
85 |
if ($stringToken === false) {
|
86 |
// No string token found in the options parameter, so skip it (e.g. variable passed in).
|
87 |
return;
|
93 |
* Get the content of any string tokens in the options parameter and remove the quotes and variables.
|
94 |
*/
|
95 |
for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
|
96 |
+
if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === false) {
|
97 |
continue;
|
98 |
}
|
99 |
|
100 |
$content = $this->stripQuotes($tokens[$i]['content']);
|
101 |
+
if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
|
102 |
$content = $this->stripVariables($content);
|
103 |
}
|
104 |
$content = trim($content);
|
119 |
$phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
|
120 |
}
|
121 |
}
|
122 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedNonCryptoHashSniff.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedNonCryptoHashSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.2
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
13 |
+
|
14 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedNonCryptoHashSniff.
|
19 |
+
*
|
20 |
+
* Detect: "The hash_hmac(), hash_hmac_file(), hash_pbkdf2(), and hash_init()
|
21 |
+
* (with HASH_HMAC) functions no longer accept non-cryptographic hashes."
|
22 |
+
*
|
23 |
+
* PHP version 7.2
|
24 |
+
*
|
25 |
+
* @category PHP
|
26 |
+
* @package PHPCompatibility
|
27 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
+
*/
|
29 |
+
class RemovedNonCryptoHashSniff extends AbstractFunctionCallParameterSniff
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Functions to check for.
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
protected $targetFunctions = array(
|
38 |
+
'hash_hmac' => true,
|
39 |
+
'hash_hmac_file' => true,
|
40 |
+
'hash_init' => true,
|
41 |
+
'hash_pbkdf2' => true,
|
42 |
+
);
|
43 |
+
|
44 |
+
/**
|
45 |
+
* List of the non-cryptographic hashes.
|
46 |
+
*
|
47 |
+
* @var array
|
48 |
+
*/
|
49 |
+
protected $disabledCryptos = array(
|
50 |
+
'adler32' => true,
|
51 |
+
'crc32' => true,
|
52 |
+
'crc32b' => true,
|
53 |
+
'fnv132' => true,
|
54 |
+
'fnv1a32' => true,
|
55 |
+
'fnv164' => true,
|
56 |
+
'fnv1a64' => true,
|
57 |
+
'joaat' => true,
|
58 |
+
);
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Do a version check to determine if this sniff needs to run at all.
|
63 |
+
*
|
64 |
+
* @return bool
|
65 |
+
*/
|
66 |
+
protected function bowOutEarly()
|
67 |
+
{
|
68 |
+
return ($this->supportsAbove('7.2') === false);
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Process the parameters of a matched function.
|
74 |
+
*
|
75 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
76 |
+
* @param int $stackPtr The position of the current token in the stack.
|
77 |
+
* @param string $functionName The token content (function name) which was matched.
|
78 |
+
* @param array $parameters Array with information about the parameters.
|
79 |
+
*
|
80 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
81 |
+
* normal file processing.
|
82 |
+
*/
|
83 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
84 |
+
{
|
85 |
+
if (isset($parameters[1]) === false) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
$targetParam = $parameters[1];
|
90 |
+
|
91 |
+
if (isset($this->disabledCryptos[$this->stripQuotes($targetParam['raw'])]) === false) {
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
|
95 |
+
if (strtolower($functionName) === 'hash_init'
|
96 |
+
&& (isset($parameters[2]) === false
|
97 |
+
|| ($parameters[2]['raw'] !== 'HASH_HMAC'
|
98 |
+
&& $parameters[2]['raw'] !== (string) \HASH_HMAC))
|
99 |
+
) {
|
100 |
+
// For hash_init(), these hashes are only disabled with HASH_HMAC set.
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
$phpcsFile->addError(
|
105 |
+
'Non-cryptographic hashes are no longer accepted by function %s() since PHP 7.2. Found: %s',
|
106 |
+
$targetParam['start'],
|
107 |
+
$this->stringToErrorCode($functionName),
|
108 |
+
array(
|
109 |
+
$functionName,
|
110 |
+
$targetParam['raw'],
|
111 |
+
)
|
112 |
+
);
|
113 |
+
}
|
114 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/PregReplaceEModifierSniff.php → ParameterValues/RemovedPCREModifiersSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
@@ -10,12 +10,14 @@
|
|
10 |
* @copyright 2014 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Check for usage of the `e` modifier with PCRE functions which is deprecated since PHP 5.5
|
21 |
* and removed as of PHP 7.0.
|
@@ -27,7 +29,7 @@ use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
|
27 |
* @author Wim Godden <wim.godden@cu.be>
|
28 |
* @copyright 2014 Cu.be Solutions bvba
|
29 |
*/
|
30 |
-
class
|
31 |
{
|
32 |
|
33 |
/**
|
@@ -64,7 +66,7 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
64 |
* @return int|void Integer stack pointer to skip forward or void to continue
|
65 |
* normal file processing.
|
66 |
*/
|
67 |
-
public function processParameters(
|
68 |
{
|
69 |
// Check the first parameter in the function call as that should contain the regex(es).
|
70 |
if (isset($parameters[1]) === false) {
|
@@ -76,13 +78,13 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
76 |
$firstParam = $parameters[1];
|
77 |
|
78 |
// Differentiate between an array of patterns passed and a single pattern.
|
79 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
80 |
-
if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === T_ARRAY || $tokens[$nextNonEmpty]['code'] === T_OPEN_SHORT_ARRAY)) {
|
81 |
$arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
|
82 |
if ($functionNameLc === 'preg_replace_callback_array') {
|
83 |
// For preg_replace_callback_array(), the patterns will be in the array keys.
|
84 |
foreach ($arrayValues as $value) {
|
85 |
-
$hasKey = $phpcsFile->findNext(T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
|
86 |
if ($hasKey === false) {
|
87 |
continue;
|
88 |
}
|
@@ -95,7 +97,7 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
95 |
} else {
|
96 |
// Otherwise, the patterns will be in the array values.
|
97 |
foreach ($arrayValues as $value) {
|
98 |
-
$hasKey = $phpcsFile->findNext(T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
|
99 |
if ($hasKey !== false) {
|
100 |
$value['start'] = ($hasKey + 1);
|
101 |
$value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
|
@@ -135,7 +137,7 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
135 |
*
|
136 |
* @return void
|
137 |
*/
|
138 |
-
protected function processRegexPattern($pattern,
|
139 |
{
|
140 |
$tokens = $phpcsFile->getTokens();
|
141 |
|
@@ -145,9 +147,9 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
145 |
*/
|
146 |
$regex = '';
|
147 |
for ($i = $pattern['start']; $i <= $pattern['end']; $i++) {
|
148 |
-
if (
|
149 |
$content = $this->stripQuotes($tokens[$i]['content']);
|
150 |
-
if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
|
151 |
$content = $this->stripVariables($content);
|
152 |
}
|
153 |
|
@@ -183,7 +185,7 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
183 |
$modifiers = substr($regex, $regexEndPos + 1);
|
184 |
$this->examineModifiers($phpcsFile, $stackPtr, $functionName, $modifiers);
|
185 |
}
|
186 |
-
}
|
187 |
|
188 |
|
189 |
/**
|
@@ -197,7 +199,7 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
197 |
*
|
198 |
* @return void
|
199 |
*/
|
200 |
-
protected function examineModifiers(
|
201 |
{
|
202 |
if (strpos($modifiers, 'e') !== false) {
|
203 |
$error = '%s() - /e modifier is deprecated since PHP 5.5';
|
@@ -214,5 +216,4 @@ class PregReplaceEModifierSniff extends AbstractFunctionCallParameterSniff
|
|
214 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
215 |
}
|
216 |
}
|
217 |
-
|
218 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedPCREModifiersSniff.
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
10 |
* @copyright 2014 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
14 |
|
15 |
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedPCREModifiersSniff.
|
21 |
*
|
22 |
* Check for usage of the `e` modifier with PCRE functions which is deprecated since PHP 5.5
|
23 |
* and removed as of PHP 7.0.
|
29 |
* @author Wim Godden <wim.godden@cu.be>
|
30 |
* @copyright 2014 Cu.be Solutions bvba
|
31 |
*/
|
32 |
+
class RemovedPCREModifiersSniff extends AbstractFunctionCallParameterSniff
|
33 |
{
|
34 |
|
35 |
/**
|
66 |
* @return int|void Integer stack pointer to skip forward or void to continue
|
67 |
* normal file processing.
|
68 |
*/
|
69 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
70 |
{
|
71 |
// Check the first parameter in the function call as that should contain the regex(es).
|
72 |
if (isset($parameters[1]) === false) {
|
78 |
$firstParam = $parameters[1];
|
79 |
|
80 |
// Differentiate between an array of patterns passed and a single pattern.
|
81 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $firstParam['start'], ($firstParam['end'] + 1), true);
|
82 |
+
if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === \T_ARRAY || $tokens[$nextNonEmpty]['code'] === \T_OPEN_SHORT_ARRAY)) {
|
83 |
$arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
|
84 |
if ($functionNameLc === 'preg_replace_callback_array') {
|
85 |
// For preg_replace_callback_array(), the patterns will be in the array keys.
|
86 |
foreach ($arrayValues as $value) {
|
87 |
+
$hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
|
88 |
if ($hasKey === false) {
|
89 |
continue;
|
90 |
}
|
97 |
} else {
|
98 |
// Otherwise, the patterns will be in the array values.
|
99 |
foreach ($arrayValues as $value) {
|
100 |
+
$hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
|
101 |
if ($hasKey !== false) {
|
102 |
$value['start'] = ($hasKey + 1);
|
103 |
$value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
|
137 |
*
|
138 |
* @return void
|
139 |
*/
|
140 |
+
protected function processRegexPattern($pattern, File $phpcsFile, $stackPtr, $functionName)
|
141 |
{
|
142 |
$tokens = $phpcsFile->getTokens();
|
143 |
|
147 |
*/
|
148 |
$regex = '';
|
149 |
for ($i = $pattern['start']; $i <= $pattern['end']; $i++) {
|
150 |
+
if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
|
151 |
$content = $this->stripQuotes($tokens[$i]['content']);
|
152 |
+
if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
|
153 |
$content = $this->stripVariables($content);
|
154 |
}
|
155 |
|
185 |
$modifiers = substr($regex, $regexEndPos + 1);
|
186 |
$this->examineModifiers($phpcsFile, $stackPtr, $functionName, $modifiers);
|
187 |
}
|
188 |
+
}
|
189 |
|
190 |
|
191 |
/**
|
199 |
*
|
200 |
* @return void
|
201 |
*/
|
202 |
+
protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
|
203 |
{
|
204 |
if (strpos($modifiers, 'e') !== false) {
|
205 |
$error = '%s() - /e modifier is deprecated since PHP 5.5';
|
216 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
217 |
}
|
218 |
}
|
219 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedSetlocaleStringSniff.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedSetlocaleStringSniff.
|
4 |
+
*
|
5 |
+
* PHP version 4.2
|
6 |
+
* PHP version 7.0
|
7 |
+
*
|
8 |
+
* @category PHP
|
9 |
+
* @package PHPCompatibility
|
10 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace PHPCompatibility\Sniffs\ParameterValues;
|
14 |
+
|
15 |
+
use PHPCompatibility\AbstractFunctionCallParameterSniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* \PHPCompatibility\Sniffs\ParameterValues\RemovedSetlocaleStringSniff.
|
20 |
+
*
|
21 |
+
* Detect: Support for the category parameter passed as a string has been removed.
|
22 |
+
* Only LC_* constants can be used as of this version [7.0.0].
|
23 |
+
*
|
24 |
+
* PHP version 4.2
|
25 |
+
* PHP version 7.0
|
26 |
+
*
|
27 |
+
* @category PHP
|
28 |
+
* @package PHPCompatibility
|
29 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
30 |
+
*/
|
31 |
+
class RemovedSetlocaleStringSniff extends AbstractFunctionCallParameterSniff
|
32 |
+
{
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Functions to check for.
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
protected $targetFunctions = array(
|
40 |
+
'setlocale' => true,
|
41 |
+
);
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Do a version check to determine if this sniff needs to run at all.
|
46 |
+
*
|
47 |
+
* @return bool
|
48 |
+
*/
|
49 |
+
protected function bowOutEarly()
|
50 |
+
{
|
51 |
+
return ($this->supportsAbove('4.2') === false);
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Process the parameters of a matched function.
|
57 |
+
*
|
58 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
59 |
+
* @param int $stackPtr The position of the current token in the stack.
|
60 |
+
* @param string $functionName The token content (function name) which was matched.
|
61 |
+
* @param array $parameters Array with information about the parameters.
|
62 |
+
*
|
63 |
+
* @return int|void Integer stack pointer to skip forward or void to continue
|
64 |
+
* normal file processing.
|
65 |
+
*/
|
66 |
+
public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
|
67 |
+
{
|
68 |
+
if (isset($parameters[1]) === false) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
$tokens = $phpcsFile->getTokens();
|
73 |
+
$targetParam = $parameters[1];
|
74 |
+
|
75 |
+
for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
|
76 |
+
if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
|
77 |
+
&& $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
|
78 |
+
) {
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
|
82 |
+
$message = 'Passing the $category as a string to setlocale() has been deprecated since PHP 4.2';
|
83 |
+
$isError = false;
|
84 |
+
$errorCode = 'Deprecated';
|
85 |
+
$data = array($targetParam['raw']);
|
86 |
+
|
87 |
+
if ($this->supportsAbove('7.0') === true) {
|
88 |
+
$message .= ' and is removed since PHP 7.0';
|
89 |
+
$isError = true;
|
90 |
+
$errorCode = 'Removed';
|
91 |
+
}
|
92 |
+
|
93 |
+
$message .= '; Pass one of the LC_* constants instead. Found: %s';
|
94 |
+
|
95 |
+
$this->addMessage($phpcsFile, $message, $i, $isError, $errorCode, $data);
|
96 |
+
break;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/ForbiddenCallTimePassByReferenceSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -11,12 +11,14 @@
|
|
11 |
* @copyright 2009 Florian Grandel
|
12 |
*/
|
13 |
|
14 |
-
namespace PHPCompatibility\Sniffs\
|
15 |
|
16 |
use PHPCompatibility\Sniff;
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
-
* \PHPCompatibility\Sniffs\
|
20 |
*
|
21 |
* Discourages the use of call time pass by references
|
22 |
*
|
@@ -74,9 +76,11 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
74 |
*/
|
75 |
public function register()
|
76 |
{
|
77 |
-
return array(
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
|
81 |
/**
|
82 |
* Processes this test, when one of its tokens is encountered.
|
@@ -87,7 +91,7 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
87 |
*
|
88 |
* @return void
|
89 |
*/
|
90 |
-
public function process(
|
91 |
{
|
92 |
if ($this->supportsAbove('5.3') === false) {
|
93 |
return;
|
@@ -99,8 +103,8 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
99 |
// within their definitions. For example: function myFunction...
|
100 |
// "myFunction" is T_STRING but we should skip because it is not a
|
101 |
// function or method *call*.
|
102 |
-
$findTokens =
|
103 |
-
$findTokens[] = T_BITWISE_AND;
|
104 |
|
105 |
$prevNonEmpty = $phpcsFile->findPrevious(
|
106 |
$findTokens,
|
@@ -109,20 +113,15 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
109 |
true
|
110 |
);
|
111 |
|
112 |
-
if ($prevNonEmpty !== false && in_array($tokens[$prevNonEmpty]['type'], array('T_FUNCTION', 'T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
|
113 |
return;
|
114 |
}
|
115 |
|
116 |
// If the next non-whitespace token after the function or method call
|
117 |
// is not an opening parenthesis then it can't really be a *call*.
|
118 |
-
$openBracket = $phpcsFile->findNext(
|
119 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
120 |
-
($stackPtr + 1),
|
121 |
-
null,
|
122 |
-
true
|
123 |
-
);
|
124 |
|
125 |
-
if ($openBracket === false || $tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS
|
126 |
|| isset($tokens[$openBracket]['parenthesis_closer']) === false
|
127 |
) {
|
128 |
return;
|
@@ -130,14 +129,14 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
130 |
|
131 |
// Get the function call parameters.
|
132 |
$parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
|
133 |
-
if (count($parameters) === 0) {
|
134 |
return;
|
135 |
}
|
136 |
|
137 |
// Which nesting level is the one we are interested in ?
|
138 |
$nestedParenthesisCount = 1;
|
139 |
if (isset($tokens[$openBracket]['nested_parenthesis'])) {
|
140 |
-
$nestedParenthesisCount = count($tokens[$openBracket]['nested_parenthesis']) + 1;
|
141 |
}
|
142 |
|
143 |
foreach ($parameters as $parameter) {
|
@@ -156,7 +155,7 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
156 |
$this->addMessage($phpcsFile, $error, $parameter['start'], $isError, $errorCode);
|
157 |
}
|
158 |
}
|
159 |
-
}
|
160 |
|
161 |
|
162 |
/**
|
@@ -169,7 +168,7 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
169 |
*
|
170 |
* @return bool
|
171 |
*/
|
172 |
-
protected function isCallTimePassByReferenceParam(
|
173 |
{
|
174 |
$tokens = $phpcsFile->getTokens();
|
175 |
|
@@ -177,28 +176,50 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
177 |
$searchEndToken = $parameter['end'] + 1;
|
178 |
$nextVariable = $searchStartToken;
|
179 |
do {
|
180 |
-
$nextVariable = $phpcsFile->findNext(T_VARIABLE, ($nextVariable + 1), $searchEndToken);
|
181 |
if ($nextVariable === false) {
|
182 |
return false;
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
// Make sure the variable belongs directly to this function call
|
186 |
// and is not inside a nested function call or array.
|
187 |
if (isset($tokens[$nextVariable]['nested_parenthesis']) === false
|
188 |
-
|| (count($tokens[$nextVariable]['nested_parenthesis']) !== $nestingLevel)
|
189 |
) {
|
190 |
continue;
|
191 |
}
|
192 |
|
193 |
// Checking this: $value = my_function(...[*]$arg...).
|
194 |
$tokenBefore = $phpcsFile->findPrevious(
|
195 |
-
|
196 |
($nextVariable - 1),
|
197 |
$searchStartToken,
|
198 |
true
|
199 |
);
|
200 |
|
201 |
-
if ($tokenBefore === false || $tokens[$tokenBefore]['code'] !== T_BITWISE_AND) {
|
202 |
// Nothing before the token or no &.
|
203 |
continue;
|
204 |
}
|
@@ -209,7 +230,7 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
209 |
|
210 |
// Checking this: $value = my_function(...[*]&$arg...).
|
211 |
$tokenBefore = $phpcsFile->findPrevious(
|
212 |
-
|
213 |
($tokenBefore - 1),
|
214 |
$searchStartToken,
|
215 |
true
|
@@ -229,5 +250,4 @@ class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
|
229 |
// This code should never be reached, but here in case of weird bugs.
|
230 |
return false;
|
231 |
}
|
232 |
-
|
233 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\ForbiddenCallTimePassByReference.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
11 |
* @copyright 2009 Florian Grandel
|
12 |
*/
|
13 |
|
14 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
15 |
|
16 |
use PHPCompatibility\Sniff;
|
17 |
+
use PHP_CodeSniffer_File as File;
|
18 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
19 |
|
20 |
/**
|
21 |
+
* \PHPCompatibility\Sniffs\Syntax\ForbiddenCallTimePassByReference.
|
22 |
*
|
23 |
* Discourages the use of call time pass by references
|
24 |
*
|
76 |
*/
|
77 |
public function register()
|
78 |
{
|
79 |
+
return array(
|
80 |
+
\T_STRING,
|
81 |
+
\T_VARIABLE,
|
82 |
+
);
|
83 |
+
}
|
84 |
|
85 |
/**
|
86 |
* Processes this test, when one of its tokens is encountered.
|
91 |
*
|
92 |
* @return void
|
93 |
*/
|
94 |
+
public function process(File $phpcsFile, $stackPtr)
|
95 |
{
|
96 |
if ($this->supportsAbove('5.3') === false) {
|
97 |
return;
|
103 |
// within their definitions. For example: function myFunction...
|
104 |
// "myFunction" is T_STRING but we should skip because it is not a
|
105 |
// function or method *call*.
|
106 |
+
$findTokens = Tokens::$emptyTokens;
|
107 |
+
$findTokens[] = \T_BITWISE_AND;
|
108 |
|
109 |
$prevNonEmpty = $phpcsFile->findPrevious(
|
110 |
$findTokens,
|
113 |
true
|
114 |
);
|
115 |
|
116 |
+
if ($prevNonEmpty !== false && \in_array($tokens[$prevNonEmpty]['type'], array('T_FUNCTION', 'T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
|
117 |
return;
|
118 |
}
|
119 |
|
120 |
// If the next non-whitespace token after the function or method call
|
121 |
// is not an opening parenthesis then it can't really be a *call*.
|
122 |
+
$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
+
if ($openBracket === false || $tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS
|
125 |
|| isset($tokens[$openBracket]['parenthesis_closer']) === false
|
126 |
) {
|
127 |
return;
|
129 |
|
130 |
// Get the function call parameters.
|
131 |
$parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
|
132 |
+
if (\count($parameters) === 0) {
|
133 |
return;
|
134 |
}
|
135 |
|
136 |
// Which nesting level is the one we are interested in ?
|
137 |
$nestedParenthesisCount = 1;
|
138 |
if (isset($tokens[$openBracket]['nested_parenthesis'])) {
|
139 |
+
$nestedParenthesisCount = \count($tokens[$openBracket]['nested_parenthesis']) + 1;
|
140 |
}
|
141 |
|
142 |
foreach ($parameters as $parameter) {
|
155 |
$this->addMessage($phpcsFile, $error, $parameter['start'], $isError, $errorCode);
|
156 |
}
|
157 |
}
|
158 |
+
}
|
159 |
|
160 |
|
161 |
/**
|
168 |
*
|
169 |
* @return bool
|
170 |
*/
|
171 |
+
protected function isCallTimePassByReferenceParam(File $phpcsFile, $parameter, $nestingLevel)
|
172 |
{
|
173 |
$tokens = $phpcsFile->getTokens();
|
174 |
|
176 |
$searchEndToken = $parameter['end'] + 1;
|
177 |
$nextVariable = $searchStartToken;
|
178 |
do {
|
179 |
+
$nextVariable = $phpcsFile->findNext(array(\T_VARIABLE, \T_OPEN_SHORT_ARRAY, \T_CLOSURE), ($nextVariable + 1), $searchEndToken);
|
180 |
if ($nextVariable === false) {
|
181 |
return false;
|
182 |
}
|
183 |
|
184 |
+
// Ignore anything within short array definition brackets.
|
185 |
+
if ($tokens[$nextVariable]['type'] === 'T_OPEN_SHORT_ARRAY'
|
186 |
+
&& (isset($tokens[$nextVariable]['bracket_opener'])
|
187 |
+
&& $tokens[$nextVariable]['bracket_opener'] === $nextVariable)
|
188 |
+
&& isset($tokens[$nextVariable]['bracket_closer'])
|
189 |
+
) {
|
190 |
+
// Skip forward to the end of the short array definition.
|
191 |
+
$nextVariable = $tokens[$nextVariable]['bracket_closer'];
|
192 |
+
continue;
|
193 |
+
}
|
194 |
+
|
195 |
+
// Skip past closures passed as function parameters.
|
196 |
+
if ($tokens[$nextVariable]['type'] === 'T_CLOSURE'
|
197 |
+
&& (isset($tokens[$nextVariable]['scope_condition'])
|
198 |
+
&& $tokens[$nextVariable]['scope_condition'] === $nextVariable)
|
199 |
+
&& isset($tokens[$nextVariable]['scope_closer'])
|
200 |
+
) {
|
201 |
+
// Skip forward to the end of the closure declaration.
|
202 |
+
$nextVariable = $tokens[$nextVariable]['scope_closer'];
|
203 |
+
continue;
|
204 |
+
}
|
205 |
+
|
206 |
// Make sure the variable belongs directly to this function call
|
207 |
// and is not inside a nested function call or array.
|
208 |
if (isset($tokens[$nextVariable]['nested_parenthesis']) === false
|
209 |
+
|| (\count($tokens[$nextVariable]['nested_parenthesis']) !== $nestingLevel)
|
210 |
) {
|
211 |
continue;
|
212 |
}
|
213 |
|
214 |
// Checking this: $value = my_function(...[*]$arg...).
|
215 |
$tokenBefore = $phpcsFile->findPrevious(
|
216 |
+
Tokens::$emptyTokens,
|
217 |
($nextVariable - 1),
|
218 |
$searchStartToken,
|
219 |
true
|
220 |
);
|
221 |
|
222 |
+
if ($tokenBefore === false || $tokens[$tokenBefore]['code'] !== \T_BITWISE_AND) {
|
223 |
// Nothing before the token or no &.
|
224 |
continue;
|
225 |
}
|
230 |
|
231 |
// Checking this: $value = my_function(...[*]&$arg...).
|
232 |
$tokenBefore = $phpcsFile->findPrevious(
|
233 |
+
Tokens::$emptyTokens,
|
234 |
($tokenBefore - 1),
|
235 |
$searchStartToken,
|
236 |
true
|
250 |
// This code should never be reached, but here in case of weird bugs.
|
251 |
return false;
|
252 |
}
|
253 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/NewArrayStringDereferencingSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Array and string literals can now be dereferenced directly to access individual elements and characters.
|
20 |
*
|
@@ -34,11 +36,11 @@ class NewArrayStringDereferencingSniff extends Sniff
|
|
34 |
public function register()
|
35 |
{
|
36 |
return array(
|
37 |
-
T_ARRAY,
|
38 |
-
T_OPEN_SHORT_ARRAY,
|
39 |
-
T_CONSTANT_ENCAPSED_STRING,
|
40 |
);
|
41 |
-
}
|
42 |
|
43 |
/**
|
44 |
* Processes this test, when one of its tokens is encountered.
|
@@ -49,7 +51,7 @@ class NewArrayStringDereferencingSniff extends Sniff
|
|
49 |
*
|
50 |
* @return void
|
51 |
*/
|
52 |
-
public function process(
|
53 |
{
|
54 |
if ($this->supportsBelow('5.4') === false) {
|
55 |
return;
|
@@ -58,12 +60,12 @@ class NewArrayStringDereferencingSniff extends Sniff
|
|
58 |
$tokens = $phpcsFile->getTokens();
|
59 |
|
60 |
switch ($tokens[$stackPtr]['code']) {
|
61 |
-
case T_CONSTANT_ENCAPSED_STRING:
|
62 |
$type = 'string literals';
|
63 |
$end = $stackPtr;
|
64 |
break;
|
65 |
|
66 |
-
case T_ARRAY:
|
67 |
if (isset($tokens[$stackPtr]['parenthesis_closer']) === false) {
|
68 |
// Live coding.
|
69 |
return;
|
@@ -73,7 +75,7 @@ class NewArrayStringDereferencingSniff extends Sniff
|
|
73 |
}
|
74 |
break;
|
75 |
|
76 |
-
case T_OPEN_SHORT_ARRAY:
|
77 |
if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
|
78 |
// Live coding.
|
79 |
return;
|
@@ -89,7 +91,7 @@ class NewArrayStringDereferencingSniff extends Sniff
|
|
89 |
return;
|
90 |
}
|
91 |
|
92 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
93 |
|
94 |
if ($nextNonEmpty !== false
|
95 |
&& ($tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET'
|
@@ -102,7 +104,5 @@ class NewArrayStringDereferencingSniff extends Sniff
|
|
102 |
array($type)
|
103 |
);
|
104 |
}
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewArrayStringDereferencingSniff.
|
4 |
*
|
5 |
* PHP version 5.5
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Syntax\NewArrayStringDereferencingSniff.
|
20 |
*
|
21 |
* Array and string literals can now be dereferenced directly to access individual elements and characters.
|
22 |
*
|
36 |
public function register()
|
37 |
{
|
38 |
return array(
|
39 |
+
\T_ARRAY,
|
40 |
+
\T_OPEN_SHORT_ARRAY,
|
41 |
+
\T_CONSTANT_ENCAPSED_STRING,
|
42 |
);
|
43 |
+
}
|
44 |
|
45 |
/**
|
46 |
* Processes this test, when one of its tokens is encountered.
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
+
public function process(File $phpcsFile, $stackPtr)
|
55 |
{
|
56 |
if ($this->supportsBelow('5.4') === false) {
|
57 |
return;
|
60 |
$tokens = $phpcsFile->getTokens();
|
61 |
|
62 |
switch ($tokens[$stackPtr]['code']) {
|
63 |
+
case \T_CONSTANT_ENCAPSED_STRING:
|
64 |
$type = 'string literals';
|
65 |
$end = $stackPtr;
|
66 |
break;
|
67 |
|
68 |
+
case \T_ARRAY:
|
69 |
if (isset($tokens[$stackPtr]['parenthesis_closer']) === false) {
|
70 |
// Live coding.
|
71 |
return;
|
75 |
}
|
76 |
break;
|
77 |
|
78 |
+
case \T_OPEN_SHORT_ARRAY:
|
79 |
if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
|
80 |
// Live coding.
|
81 |
return;
|
91 |
return;
|
92 |
}
|
93 |
|
94 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true, null, true);
|
95 |
|
96 |
if ($nextNonEmpty !== false
|
97 |
&& ($tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET'
|
104 |
array($type)
|
105 |
);
|
106 |
}
|
107 |
+
}
|
108 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewArrayUnpackingSniff.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2019 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Using the spread operator for unpacking arrays in array expressions is available since PHP 7.4.
|
19 |
+
*
|
20 |
+
* PHP version 7.4
|
21 |
+
*
|
22 |
+
* @link https://wiki.php.net/rfc/spread_operator_for_array
|
23 |
+
*
|
24 |
+
* @since 9.2.0
|
25 |
+
*/
|
26 |
+
class NewArrayUnpackingSniff extends Sniff
|
27 |
+
{
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns an array of tokens this test wants to listen for.
|
31 |
+
*
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public function register()
|
35 |
+
{
|
36 |
+
return array(
|
37 |
+
\T_ARRAY,
|
38 |
+
\T_OPEN_SHORT_ARRAY,
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Processes this test, when one of its tokens is encountered.
|
44 |
+
*
|
45 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
46 |
+
* @param int $stackPtr The position of the current token in the
|
47 |
+
* stack passed in $tokens.
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function process(File $phpcsFile, $stackPtr)
|
52 |
+
{
|
53 |
+
if ($this->supportsBelow('7.3') === false) {
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$tokens = $phpcsFile->getTokens();
|
58 |
+
|
59 |
+
/*
|
60 |
+
* Determine the array opener & closer.
|
61 |
+
*/
|
62 |
+
$closer = $phpcsFile->numTokens;
|
63 |
+
if ($tokens[$stackPtr]['code'] === \T_ARRAY) {
|
64 |
+
if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
$opener = $tokens[$stackPtr]['parenthesis_opener'];
|
69 |
+
|
70 |
+
if (isset($tokens[$opener]['parenthesis_closer'])) {
|
71 |
+
$closer = $tokens[$opener]['parenthesis_closer'];
|
72 |
+
}
|
73 |
+
} else {
|
74 |
+
// Short array syntax.
|
75 |
+
$opener = $stackPtr;
|
76 |
+
|
77 |
+
if (isset($tokens[$stackPtr]['bracket_closer'])) {
|
78 |
+
$closer = $tokens[$stackPtr]['bracket_closer'];
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
$nestingLevel = 0;
|
83 |
+
if (isset($tokens[($opener + 1)]['nested_parenthesis'])) {
|
84 |
+
$nestingLevel = count($tokens[($opener + 1)]['nested_parenthesis']);
|
85 |
+
}
|
86 |
+
|
87 |
+
for ($i = $opener; $i < $closer;) {
|
88 |
+
$i = $phpcsFile->findNext(array(\T_ELLIPSIS, \T_OPEN_SHORT_ARRAY, \T_ARRAY), ($i + 1), $closer);
|
89 |
+
if ($i === false) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY) {
|
94 |
+
if (isset($tokens[$i]['bracket_closer']) === false) {
|
95 |
+
// Live coding, unfinished nested array, handle this when the array opener
|
96 |
+
// of the nested array is passed.
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
// Skip over nested short arrays. These will be handled when the array opener
|
101 |
+
// of the nested array is passed.
|
102 |
+
$i = $tokens[$i]['bracket_closer'];
|
103 |
+
continue;
|
104 |
+
}
|
105 |
+
|
106 |
+
if ($tokens[$i]['code'] === \T_ARRAY) {
|
107 |
+
if (isset($tokens[$i]['parenthesis_closer']) === false) {
|
108 |
+
// Live coding, unfinished nested array, handle this when the array opener
|
109 |
+
// of the nested array is passed.
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
// Skip over nested long arrays. These will be handled when the array opener
|
114 |
+
// of the nested array is passed.
|
115 |
+
$i = $tokens[$i]['parenthesis_closer'];
|
116 |
+
continue;
|
117 |
+
}
|
118 |
+
|
119 |
+
// Ensure this is not function call variable unpacking.
|
120 |
+
if (isset($tokens[$i]['nested_parenthesis'])
|
121 |
+
&& count($tokens[$i]['nested_parenthesis']) > $nestingLevel
|
122 |
+
) {
|
123 |
+
continue;
|
124 |
+
}
|
125 |
+
|
126 |
+
// Ok, found one.
|
127 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
|
128 |
+
$snippet = trim($phpcsFile->getTokensAsString($i, (($nextNonEmpty - $i) + 1)));
|
129 |
+
$phpcsFile->addError(
|
130 |
+
'Array unpacking within array declarations using the spread operator is not supported in PHP 7.3 or earlier. Found: %s',
|
131 |
+
$i,
|
132 |
+
'Found',
|
133 |
+
array($snippet)
|
134 |
+
);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/NewClassMemberAccessSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
* PHP version 7.0
|
@@ -10,12 +10,14 @@
|
|
10 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* PHP 5.4: Class member access on instantiation has been added, e.g. (new Foo)->bar().
|
21 |
* PHP 7.0: Class member access on cloning has been added, e.g. (clone $foo)->bar().
|
@@ -38,8 +40,8 @@ class NewClassMemberAccessSniff extends Sniff
|
|
38 |
public function register()
|
39 |
{
|
40 |
return array(
|
41 |
-
T_NEW,
|
42 |
-
T_CLONE,
|
43 |
);
|
44 |
}
|
45 |
|
@@ -52,13 +54,13 @@ class NewClassMemberAccessSniff extends Sniff
|
|
52 |
*
|
53 |
* @return void
|
54 |
*/
|
55 |
-
public function process(
|
56 |
{
|
57 |
$tokens = $phpcsFile->getTokens();
|
58 |
|
59 |
-
if ($tokens[$stackPtr]['code'] === T_NEW && $this->supportsBelow('5.3') !== true) {
|
60 |
return;
|
61 |
-
} elseif ($tokens[$stackPtr]['code'] === T_CLONE && $this->supportsBelow('5.6') !== true) {
|
62 |
return;
|
63 |
}
|
64 |
|
@@ -75,30 +77,20 @@ class NewClassMemberAccessSniff extends Sniff
|
|
75 |
return;
|
76 |
}
|
77 |
|
78 |
-
$prevBeforeParenthesis = $phpcsFile->findPrevious(
|
79 |
-
|
80 |
-
($parenthesisOpener - 1),
|
81 |
-
null,
|
82 |
-
true
|
83 |
-
);
|
84 |
-
if ($prevBeforeParenthesis !== false && $tokens[$prevBeforeParenthesis]['code'] === T_STRING) {
|
85 |
// This is most likely a function call with the new/cloned object as a parameter.
|
86 |
return;
|
87 |
}
|
88 |
|
89 |
-
$nextAfterParenthesis = $phpcsFile->findNext(
|
90 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
91 |
-
($parenthesisCloser + 1),
|
92 |
-
null,
|
93 |
-
true
|
94 |
-
);
|
95 |
if ($nextAfterParenthesis === false) {
|
96 |
// Live coding.
|
97 |
return;
|
98 |
}
|
99 |
|
100 |
-
if ($tokens[$nextAfterParenthesis]['code'] !== T_OBJECT_OPERATOR
|
101 |
-
&& $tokens[$nextAfterParenthesis]['code'] !== T_OPEN_SQUARE_BRACKET
|
102 |
) {
|
103 |
return;
|
104 |
}
|
@@ -106,7 +98,7 @@ class NewClassMemberAccessSniff extends Sniff
|
|
106 |
$data = array('instantiation', '5.3');
|
107 |
$errorCode = 'OnNewFound';
|
108 |
|
109 |
-
if ($tokens[$stackPtr]['code'] === T_CLONE) {
|
110 |
$data = array('cloning', '5.6');
|
111 |
$errorCode = 'OnCloneFound';
|
112 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewClassMemberAccessSniff.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
* PHP version 7.0
|
10 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\Syntax\NewClassMemberAccessSniff.
|
21 |
*
|
22 |
* PHP 5.4: Class member access on instantiation has been added, e.g. (new Foo)->bar().
|
23 |
* PHP 7.0: Class member access on cloning has been added, e.g. (clone $foo)->bar().
|
40 |
public function register()
|
41 |
{
|
42 |
return array(
|
43 |
+
\T_NEW,
|
44 |
+
\T_CLONE,
|
45 |
);
|
46 |
}
|
47 |
|
54 |
*
|
55 |
* @return void
|
56 |
*/
|
57 |
+
public function process(File $phpcsFile, $stackPtr)
|
58 |
{
|
59 |
$tokens = $phpcsFile->getTokens();
|
60 |
|
61 |
+
if ($tokens[$stackPtr]['code'] === \T_NEW && $this->supportsBelow('5.3') !== true) {
|
62 |
return;
|
63 |
+
} elseif ($tokens[$stackPtr]['code'] === \T_CLONE && $this->supportsBelow('5.6') !== true) {
|
64 |
return;
|
65 |
}
|
66 |
|
77 |
return;
|
78 |
}
|
79 |
|
80 |
+
$prevBeforeParenthesis = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($parenthesisOpener - 1), null, true);
|
81 |
+
if ($prevBeforeParenthesis !== false && $tokens[$prevBeforeParenthesis]['code'] === \T_STRING) {
|
|
|
|
|
|
|
|
|
|
|
82 |
// This is most likely a function call with the new/cloned object as a parameter.
|
83 |
return;
|
84 |
}
|
85 |
|
86 |
+
$nextAfterParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, ($parenthesisCloser + 1), null, true);
|
|
|
|
|
|
|
|
|
|
|
87 |
if ($nextAfterParenthesis === false) {
|
88 |
// Live coding.
|
89 |
return;
|
90 |
}
|
91 |
|
92 |
+
if ($tokens[$nextAfterParenthesis]['code'] !== \T_OBJECT_OPERATOR
|
93 |
+
&& $tokens[$nextAfterParenthesis]['code'] !== \T_OPEN_SQUARE_BRACKET
|
94 |
) {
|
95 |
return;
|
96 |
}
|
98 |
$data = array('instantiation', '5.3');
|
99 |
$errorCode = 'OnNewFound';
|
100 |
|
101 |
+
if ($tokens[$stackPtr]['code'] === \T_CLONE) {
|
102 |
$data = array('cloning', '5.6');
|
103 |
$errorCode = 'OnCloneFound';
|
104 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DynamicAccessToStaticSniff.php → Syntax/NewDynamicAccessToStaticSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
@@ -9,13 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* As of PHP 5.3, static properties and methods as well as class constants
|
21 |
* can be accessed using a dynamic (variable) class name.
|
@@ -26,7 +27,7 @@ use PHP_CodeSniffer_Tokens as Tokens;
|
|
26 |
* @package PHPCompatibility
|
27 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
*/
|
29 |
-
class
|
30 |
{
|
31 |
|
32 |
/**
|
@@ -37,7 +38,7 @@ class DynamicAccessToStaticSniff extends Sniff
|
|
37 |
public function register()
|
38 |
{
|
39 |
return array(
|
40 |
-
T_DOUBLE_COLON,
|
41 |
);
|
42 |
}
|
43 |
|
@@ -50,7 +51,7 @@ class DynamicAccessToStaticSniff extends Sniff
|
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
53 |
-
public function process(
|
54 |
{
|
55 |
if ($this->supportsBelow('5.2') === false) {
|
56 |
return;
|
@@ -60,17 +61,17 @@ class DynamicAccessToStaticSniff extends Sniff
|
|
60 |
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
61 |
|
62 |
// Disregard `static::` as well. Late static binding is reported by another sniff.
|
63 |
-
if ($tokens[$prevNonEmpty]['code'] === T_SELF
|
64 |
-
|| $tokens[$prevNonEmpty]['code'] === T_PARENT
|
65 |
-
|| $tokens[$prevNonEmpty]['code'] === T_STATIC
|
66 |
) {
|
67 |
return;
|
68 |
}
|
69 |
|
70 |
-
if ($tokens[$prevNonEmpty]['code'] === T_STRING) {
|
71 |
$prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
|
72 |
|
73 |
-
if ($tokens[$prevPrevNonEmpty]['code'] !== T_OBJECT_OPERATOR) {
|
74 |
return;
|
75 |
}
|
76 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewDynamicAccessToStaticSniff.
|
4 |
*
|
5 |
* PHP version 5.3
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Syntax\NewDynamicAccessToStaticSniff.
|
20 |
*
|
21 |
* As of PHP 5.3, static properties and methods as well as class constants
|
22 |
* can be accessed using a dynamic (variable) class name.
|
27 |
* @package PHPCompatibility
|
28 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
29 |
*/
|
30 |
+
class NewDynamicAccessToStaticSniff extends Sniff
|
31 |
{
|
32 |
|
33 |
/**
|
38 |
public function register()
|
39 |
{
|
40 |
return array(
|
41 |
+
\T_DOUBLE_COLON,
|
42 |
);
|
43 |
}
|
44 |
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
+
public function process(File $phpcsFile, $stackPtr)
|
55 |
{
|
56 |
if ($this->supportsBelow('5.2') === false) {
|
57 |
return;
|
61 |
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
62 |
|
63 |
// Disregard `static::` as well. Late static binding is reported by another sniff.
|
64 |
+
if ($tokens[$prevNonEmpty]['code'] === \T_SELF
|
65 |
+
|| $tokens[$prevNonEmpty]['code'] === \T_PARENT
|
66 |
+
|| $tokens[$prevNonEmpty]['code'] === \T_STATIC
|
67 |
) {
|
68 |
return;
|
69 |
}
|
70 |
|
71 |
+
if ($tokens[$prevNonEmpty]['code'] === \T_STRING) {
|
72 |
$prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
|
73 |
|
74 |
+
if ($tokens[$prevPrevNonEmpty]['code'] !== \T_OBJECT_OPERATOR) {
|
75 |
return;
|
76 |
}
|
77 |
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewFlexibleHeredocNowdocSniff.php
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewFlexibleHeredocNowdocSniff.
|
4 |
+
*
|
5 |
+
* PHP version 7.3
|
6 |
+
*
|
7 |
+
* @category PHP
|
8 |
+
* @package PHPCompatibility
|
9 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
13 |
+
|
14 |
+
use PHPCompatibility\Sniff;
|
15 |
+
use PHPCompatibility\PHPCSHelper;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* New Flexible Heredoc Nowdoc.
|
20 |
+
*
|
21 |
+
* As of PHP 7.3:
|
22 |
+
* - The body and the closing marker of a Heredoc/nowdoc can be indented;
|
23 |
+
* - The closing marker no longer needs to be on a line by itself;
|
24 |
+
* - The heredoc/nowdoc body may no longer contain the closing marker at the
|
25 |
+
* start of any of its lines.
|
26 |
+
*
|
27 |
+
* PHP version 7.3
|
28 |
+
*
|
29 |
+
* @category PHP
|
30 |
+
* @package PHPCompatibility
|
31 |
+
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
32 |
+
*/
|
33 |
+
class NewFlexibleHeredocNowdocSniff extends Sniff
|
34 |
+
{
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Returns an array of tokens this test wants to listen for.
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function register()
|
42 |
+
{
|
43 |
+
$targets = array(
|
44 |
+
\T_END_HEREDOC,
|
45 |
+
\T_END_NOWDOC,
|
46 |
+
);
|
47 |
+
|
48 |
+
if (version_compare(\PHP_VERSION_ID, '70299', '>') === false) {
|
49 |
+
// Start identifier of a PHP 7.3 flexible heredoc/nowdoc.
|
50 |
+
$targets[] = \T_STRING;
|
51 |
+
}
|
52 |
+
|
53 |
+
return $targets;
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Processes this test, when one of its tokens is encountered.
|
59 |
+
*
|
60 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
61 |
+
* @param int $stackPtr The position of the current token in the
|
62 |
+
* stack passed in $tokens.
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
public function process(File $phpcsFile, $stackPtr)
|
67 |
+
{
|
68 |
+
/*
|
69 |
+
* Due to a tokenizer bug which gets hit when the PHP 7.3 heredoc/nowdoc syntax
|
70 |
+
* is used, this part of the sniff cannot possibly work on PHPCS < 2.6.0.
|
71 |
+
* See upstream issue #928.
|
72 |
+
*/
|
73 |
+
if ($this->supportsBelow('7.2') === true && version_compare(PHPCSHelper::getVersion(), '2.6.0', '>=')) {
|
74 |
+
$this->detectIndentedNonStandAloneClosingMarker($phpcsFile, $stackPtr);
|
75 |
+
}
|
76 |
+
|
77 |
+
$tokens = $phpcsFile->getTokens();
|
78 |
+
if ($this->supportsAbove('7.3') === true && $tokens[$stackPtr]['code'] !== \T_STRING) {
|
79 |
+
$this->detectClosingMarkerInBody($phpcsFile, $stackPtr);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Detect indented and/or non-stand alone closing markers.
|
86 |
+
*
|
87 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
88 |
+
* @param int $stackPtr The position of the current token in the
|
89 |
+
* stack passed in $tokens.
|
90 |
+
*
|
91 |
+
* @return void
|
92 |
+
*/
|
93 |
+
protected function detectIndentedNonStandAloneClosingMarker(File $phpcsFile, $stackPtr)
|
94 |
+
{
|
95 |
+
$tokens = $phpcsFile->getTokens();
|
96 |
+
$indentError = 'Heredoc/nowdoc with an indented closing marker is not supported in PHP 7.2 or earlier.';
|
97 |
+
$indentErrorCode = 'IndentedClosingMarker';
|
98 |
+
$trailingError = 'Having code - other than a semi-colon or new line - after the closing marker of a heredoc/nowdoc is not supported in PHP 7.2 or earlier.';
|
99 |
+
$trailingErrorCode = 'ClosingMarkerNoNewLine';
|
100 |
+
|
101 |
+
if (version_compare(\PHP_VERSION_ID, '70299', '>') === true) {
|
102 |
+
|
103 |
+
/*
|
104 |
+
* Check for indented closing marker.
|
105 |
+
*/
|
106 |
+
if (ltrim($tokens[$stackPtr]['content']) !== $tokens[$stackPtr]['content']) {
|
107 |
+
$phpcsFile->addError($indentError, $stackPtr, $indentErrorCode);
|
108 |
+
}
|
109 |
+
|
110 |
+
/*
|
111 |
+
* Check for tokens after the closing marker.
|
112 |
+
*/
|
113 |
+
$nextNonWhitespace = $phpcsFile->findNext(array(\T_WHITESPACE, \T_SEMICOLON), ($stackPtr + 1), null, true);
|
114 |
+
if ($tokens[$stackPtr]['line'] === $tokens[$nextNonWhitespace]['line']) {
|
115 |
+
$phpcsFile->addError($trailingError, $stackPtr, $trailingErrorCode);
|
116 |
+
}
|
117 |
+
} else {
|
118 |
+
// For PHP < 7.3, we're only interested in T_STRING tokens.
|
119 |
+
if ($tokens[$stackPtr]['code'] !== \T_STRING) {
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
|
123 |
+
if (preg_match('`^<<<([\'"]?)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\1[\r\n]+`', $tokens[$stackPtr]['content'], $matches) !== 1) {
|
124 |
+
// Not the start of a PHP 7.3 flexible heredoc/nowdoc.
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
|
128 |
+
$identifier = $matches[2];
|
129 |
+
|
130 |
+
for ($i = ($stackPtr + 1); $i <= $phpcsFile->numTokens; $i++) {
|
131 |
+
if ($tokens[$i]['code'] !== \T_ENCAPSED_AND_WHITESPACE) {
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
|
135 |
+
$trimmed = ltrim($tokens[$i]['content']);
|
136 |
+
|
137 |
+
if (strpos($trimmed, $identifier) !== 0) {
|
138 |
+
continue;
|
139 |
+
}
|
140 |
+
|
141 |
+
// OK, we've found the PHP 7.3 flexible heredoc/nowdoc closing marker.
|
142 |
+
|
143 |
+
/*
|
144 |
+
* Check for indented closing marker.
|
145 |
+
*/
|
146 |
+
if ($trimmed !== $tokens[$i]['content']) {
|
147 |
+
// Indent found before closing marker.
|
148 |
+
$phpcsFile->addError($indentError, $i, $indentErrorCode);
|
149 |
+
}
|
150 |
+
|
151 |
+
/*
|
152 |
+
* Check for tokens after the closing marker.
|
153 |
+
*/
|
154 |
+
// Remove the identifier.
|
155 |
+
$afterMarker = substr($trimmed, \strlen($identifier));
|
156 |
+
// Remove a potential semi-colon at the beginning of what's left of the string.
|
157 |
+
$afterMarker = ltrim($afterMarker, ';');
|
158 |
+
// Remove new line characters at the end of the string.
|
159 |
+
$afterMarker = rtrim($afterMarker, "\r\n");
|
160 |
+
|
161 |
+
if ($afterMarker !== '') {
|
162 |
+
$phpcsFile->addError($trailingError, $i, $trailingErrorCode);
|
163 |
+
}
|
164 |
+
|
165 |
+
break;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Detect heredoc/nowdoc identifiers at the start of lines in the heredoc/nowdoc body.
|
173 |
+
*
|
174 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
175 |
+
* @param int $stackPtr The position of the current token in the
|
176 |
+
* stack passed in $tokens.
|
177 |
+
*
|
178 |
+
* @return void
|
179 |
+
*/
|
180 |
+
protected function detectClosingMarkerInBody(File $phpcsFile, $stackPtr)
|
181 |
+
{
|
182 |
+
$tokens = $phpcsFile->getTokens();
|
183 |
+
$error = 'The body of a heredoc/nowdoc can not contain the heredoc/nowdoc closing marker as text at the start of a line since PHP 7.3.';
|
184 |
+
$errorCode = 'ClosingMarkerNoNewLine';
|
185 |
+
|
186 |
+
if (version_compare(\PHP_VERSION_ID, '70299', '>') === true) {
|
187 |
+
$nextNonWhitespace = $phpcsFile->findNext(\T_WHITESPACE, ($stackPtr + 1), null, true, null, true);
|
188 |
+
if ($nextNonWhitespace === false
|
189 |
+
|| $tokens[$nextNonWhitespace]['code'] === \T_SEMICOLON
|
190 |
+
|| (($tokens[$nextNonWhitespace]['code'] === \T_COMMA
|
191 |
+
|| $tokens[$nextNonWhitespace]['code'] === \T_STRING_CONCAT)
|
192 |
+
&& $tokens[$nextNonWhitespace]['line'] !== $tokens[$stackPtr]['line'])
|
193 |
+
) {
|
194 |
+
// This is most likely a correctly identified closing marker.
|
195 |
+
return;
|
196 |
+
}
|
197 |
+
|
198 |
+
// The real closing tag has to be before the next heredoc/nowdoc.
|
199 |
+
$nextHereNowDoc = $phpcsFile->findNext(array(\T_START_HEREDOC, \T_START_NOWDOC), ($stackPtr + 1));
|
200 |
+
if ($nextHereNowDoc === false) {
|
201 |
+
$nextHereNowDoc = null;
|
202 |
+
}
|
203 |
+
|
204 |
+
$identifier = trim($tokens[$stackPtr]['content']);
|
205 |
+
$realClosingMarker = $stackPtr;
|
206 |
+
|
207 |
+
while (($realClosingMarker = $phpcsFile->findNext(\T_STRING, ($realClosingMarker + 1), $nextHereNowDoc, false, $identifier)) !== false) {
|
208 |
+
|
209 |
+
$prevNonWhitespace = $phpcsFile->findPrevious(\T_WHITESPACE, ($realClosingMarker - 1), null, true);
|
210 |
+
if ($prevNonWhitespace === false
|
211 |
+
|| $tokens[$prevNonWhitespace]['line'] === $tokens[$realClosingMarker]['line']
|
212 |
+
) {
|
213 |
+
// Marker text found, but not at the start of the line.
|
214 |
+
continue;
|
215 |
+
}
|
216 |
+
|
217 |
+
// The original T_END_HEREDOC/T_END_NOWDOC was most likely incorrect as we've found
|
218 |
+
// a possible alternative closing marker.
|
219 |
+
$phpcsFile->addError($error, $stackPtr, $errorCode);
|
220 |
+
|
221 |
+
break;
|
222 |
+
}
|
223 |
+
|
224 |
+
} else {
|
225 |
+
if (isset($tokens[$stackPtr]['scope_closer'], $tokens[$stackPtr]['scope_opener']) === true
|
226 |
+
&& $tokens[$stackPtr]['scope_closer'] === $stackPtr
|
227 |
+
) {
|
228 |
+
$opener = $tokens[$stackPtr]['scope_opener'];
|
229 |
+
} else {
|
230 |
+
// PHPCS < 3.0.2 did not add scope_* values for Nowdocs.
|
231 |
+
$opener = $phpcsFile->findPrevious(\T_START_NOWDOC, ($stackPtr - 1));
|
232 |
+
if ($opener === false) {
|
233 |
+
return;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
$quotedIdentifier = preg_quote($tokens[$stackPtr]['content'], '`');
|
238 |
+
|
239 |
+
// Throw an error for each line in the body which starts with the identifier.
|
240 |
+
for ($i = ($opener + 1); $i < $stackPtr; $i++) {
|
241 |
+
if (preg_match('`^[ \t]*' . $quotedIdentifier . '\b`', $tokens[$i]['content']) === 1) {
|
242 |
+
$phpcsFile->addError($error, $i, $errorCode);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → Syntax}/NewFunctionArrayDereferencingSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 5.4
|
20 |
*
|
@@ -31,8 +33,8 @@ class NewFunctionArrayDereferencingSniff extends Sniff
|
|
31 |
*/
|
32 |
public function register()
|
33 |
{
|
34 |
-
return array(T_STRING);
|
35 |
-
}
|
36 |
|
37 |
/**
|
38 |
* Processes this test, when one of its tokens is encountered.
|
@@ -43,7 +45,7 @@ class NewFunctionArrayDereferencingSniff extends Sniff
|
|
43 |
*
|
44 |
* @return void
|
45 |
*/
|
46 |
-
public function process(
|
47 |
{
|
48 |
if ($this->supportsBelow('5.3') === false) {
|
49 |
return;
|
@@ -52,8 +54,8 @@ class NewFunctionArrayDereferencingSniff extends Sniff
|
|
52 |
$tokens = $phpcsFile->getTokens();
|
53 |
|
54 |
// Next non-empty token should be the open parenthesis.
|
55 |
-
$openParenthesis = $phpcsFile->findNext(
|
56 |
-
if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) {
|
57 |
return;
|
58 |
}
|
59 |
|
@@ -63,25 +65,25 @@ class NewFunctionArrayDereferencingSniff extends Sniff
|
|
63 |
}
|
64 |
|
65 |
// Is this T_STRING really a function or method call ?
|
66 |
-
$prevToken = $phpcsFile->findPrevious(
|
67 |
-
if ($prevToken !== false && in_array($tokens[$prevToken]['code'], array(T_DOUBLE_COLON, T_OBJECT_OPERATOR), true) === false) {
|
68 |
$ignore = array(
|
69 |
-
T_FUNCTION,
|
70 |
-
T_CONST,
|
71 |
-
T_USE,
|
72 |
-
T_NEW,
|
73 |
-
T_CLASS,
|
74 |
-
T_INTERFACE,
|
75 |
);
|
76 |
|
77 |
-
if (
|
78 |
// Not a call to a PHP function or method.
|
79 |
return;
|
80 |
}
|
81 |
}
|
82 |
|
83 |
$closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
|
84 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
85 |
if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') {
|
86 |
$phpcsFile->addError(
|
87 |
'Function array dereferencing is not present in PHP version 5.3 or earlier',
|
@@ -89,6 +91,5 @@ class NewFunctionArrayDereferencingSniff extends Sniff
|
|
89 |
'Found'
|
90 |
);
|
91 |
}
|
92 |
-
|
93 |
-
|
94 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewFunctionArrayDereferencingSniff.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Syntax\NewFunctionArrayDereferencingSniff.
|
20 |
*
|
21 |
* PHP version 5.4
|
22 |
*
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
+
return array(\T_STRING);
|
37 |
+
}
|
38 |
|
39 |
/**
|
40 |
* Processes this test, when one of its tokens is encountered.
|
45 |
*
|
46 |
* @return void
|
47 |
*/
|
48 |
+
public function process(File $phpcsFile, $stackPtr)
|
49 |
{
|
50 |
if ($this->supportsBelow('5.3') === false) {
|
51 |
return;
|
54 |
$tokens = $phpcsFile->getTokens();
|
55 |
|
56 |
// Next non-empty token should be the open parenthesis.
|
57 |
+
$openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
58 |
+
if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS) {
|
59 |
return;
|
60 |
}
|
61 |
|
65 |
}
|
66 |
|
67 |
// Is this T_STRING really a function or method call ?
|
68 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
69 |
+
if ($prevToken !== false && \in_array($tokens[$prevToken]['code'], array(\T_DOUBLE_COLON, \T_OBJECT_OPERATOR), true) === false) {
|
70 |
$ignore = array(
|
71 |
+
\T_FUNCTION => true,
|
72 |
+
\T_CONST => true,
|
73 |
+
\T_USE => true,
|
74 |
+
\T_NEW => true,
|
75 |
+
\T_CLASS => true,
|
76 |
+
\T_INTERFACE => true,
|
77 |
);
|
78 |
|
79 |
+
if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
|
80 |
// Not a call to a PHP function or method.
|
81 |
return;
|
82 |
}
|
83 |
}
|
84 |
|
85 |
$closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
|
86 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($closeParenthesis + 1), null, true, null, true);
|
87 |
if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') {
|
88 |
$phpcsFile->addError(
|
89 |
'Function array dereferencing is not present in PHP version 5.3 or earlier',
|
91 |
'Found'
|
92 |
);
|
93 |
}
|
94 |
+
}
|
95 |
+
}
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/NewTrailingCommaSniff.php → Syntax/NewFunctionCallTrailingCommaSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.3
|
6 |
*
|
@@ -9,23 +9,22 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 7.3
|
20 |
*
|
21 |
-
* Note: trailing comma's in group use statements as introduced in PHP 7.2 is covered
|
22 |
-
* by the `NewGroupUseDeclaration` sniff.
|
23 |
-
*
|
24 |
* @category PHP
|
25 |
* @package PHPCompatibility
|
26 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
/**
|
31 |
* Returns an array of tokens this test wants to listen for.
|
@@ -35,10 +34,10 @@ class NewTrailingCommaSniff extends Sniff
|
|
35 |
public function register()
|
36 |
{
|
37 |
return array(
|
38 |
-
T_STRING,
|
39 |
-
T_VARIABLE,
|
40 |
-
T_ISSET,
|
41 |
-
T_UNSET,
|
42 |
);
|
43 |
}
|
44 |
|
@@ -52,7 +51,7 @@ class NewTrailingCommaSniff extends Sniff
|
|
52 |
*
|
53 |
* @return void
|
54 |
*/
|
55 |
-
public function process(
|
56 |
{
|
57 |
if ($this->supportsBelow('7.2') === false) {
|
58 |
return;
|
@@ -60,21 +59,21 @@ class NewTrailingCommaSniff extends Sniff
|
|
60 |
|
61 |
$tokens = $phpcsFile->getTokens();
|
62 |
|
63 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
64 |
-
if ($tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS
|
65 |
|| isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
|
66 |
) {
|
67 |
return;
|
68 |
}
|
69 |
|
70 |
-
if ($tokens[$stackPtr]['code'] === T_STRING) {
|
71 |
$ignore = array(
|
72 |
-
T_FUNCTION => true,
|
73 |
-
T_CONST => true,
|
74 |
-
T_USE => true,
|
75 |
);
|
76 |
|
77 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
78 |
if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) {
|
79 |
// Not a function call.
|
80 |
return;
|
@@ -82,25 +81,20 @@ class NewTrailingCommaSniff extends Sniff
|
|
82 |
}
|
83 |
|
84 |
$closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
|
85 |
-
$lastInParenthesis = $phpcsFile->findPrevious(
|
86 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
87 |
-
($closer - 1),
|
88 |
-
$nextNonEmpty,
|
89 |
-
true
|
90 |
-
);
|
91 |
|
92 |
-
if ($tokens[$lastInParenthesis]['code'] !== T_COMMA) {
|
93 |
return;
|
94 |
}
|
95 |
|
96 |
$data = array();
|
97 |
switch ($tokens[$stackPtr]['code']) {
|
98 |
-
case T_ISSET:
|
99 |
$data[] = 'calls to isset()';
|
100 |
$errorCode = 'FoundInIsset';
|
101 |
break;
|
102 |
|
103 |
-
case T_UNSET:
|
104 |
$data[] = 'calls to unset()';
|
105 |
$errorCode = 'FoundInUnset';
|
106 |
break;
|
@@ -117,7 +111,5 @@ class NewTrailingCommaSniff extends Sniff
|
|
117 |
$errorCode,
|
118 |
$data
|
119 |
);
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewFunctionCallTrailingCommaSniff.
|
4 |
*
|
5 |
* PHP version 7.3
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Syntax\NewFunctionCallTrailingCommaSniff.
|
20 |
*
|
21 |
* PHP version 7.3
|
22 |
*
|
|
|
|
|
|
|
23 |
* @category PHP
|
24 |
* @package PHPCompatibility
|
25 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
*/
|
27 |
+
class NewFunctionCallTrailingCommaSniff extends Sniff
|
28 |
{
|
29 |
/**
|
30 |
* Returns an array of tokens this test wants to listen for.
|
34 |
public function register()
|
35 |
{
|
36 |
return array(
|
37 |
+
\T_STRING,
|
38 |
+
\T_VARIABLE,
|
39 |
+
\T_ISSET,
|
40 |
+
\T_UNSET,
|
41 |
);
|
42 |
}
|
43 |
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
+
public function process(File $phpcsFile, $stackPtr)
|
55 |
{
|
56 |
if ($this->supportsBelow('7.2') === false) {
|
57 |
return;
|
59 |
|
60 |
$tokens = $phpcsFile->getTokens();
|
61 |
|
62 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
63 |
+
if ($tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
|
64 |
|| isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
|
65 |
) {
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
+
if ($tokens[$stackPtr]['code'] === \T_STRING) {
|
70 |
$ignore = array(
|
71 |
+
\T_FUNCTION => true,
|
72 |
+
\T_CONST => true,
|
73 |
+
\T_USE => true,
|
74 |
);
|
75 |
|
76 |
+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
77 |
if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) {
|
78 |
// Not a function call.
|
79 |
return;
|
81 |
}
|
82 |
|
83 |
$closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
|
84 |
+
$lastInParenthesis = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($closer - 1), $nextNonEmpty, true);
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
+
if ($tokens[$lastInParenthesis]['code'] !== \T_COMMA) {
|
87 |
return;
|
88 |
}
|
89 |
|
90 |
$data = array();
|
91 |
switch ($tokens[$stackPtr]['code']) {
|
92 |
+
case \T_ISSET:
|
93 |
$data[] = 'calls to isset()';
|
94 |
$errorCode = 'FoundInIsset';
|
95 |
break;
|
96 |
|
97 |
+
case \T_UNSET:
|
98 |
$data[] = 'calls to unset()';
|
99 |
$errorCode = 'FoundInUnset';
|
100 |
break;
|
111 |
$errorCode,
|
112 |
$data
|
113 |
);
|
114 |
+
}
|
115 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/ShortArraySniff.php → Syntax/NewShortArraySniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -9,12 +9,13 @@
|
|
9 |
* @author Alex Miroshnikov <unknown@example.com>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Short array syntax is available since PHP 5.4
|
20 |
*
|
@@ -24,7 +25,7 @@ use PHPCompatibility\Sniff;
|
|
24 |
* @package PHPCompatibility
|
25 |
* @author Alex Miroshnikov <unknown@example.com>
|
26 |
*/
|
27 |
-
class
|
28 |
{
|
29 |
|
30 |
/**
|
@@ -35,10 +36,10 @@ class ShortArraySniff extends Sniff
|
|
35 |
public function register()
|
36 |
{
|
37 |
return array(
|
38 |
-
T_OPEN_SHORT_ARRAY,
|
39 |
-
T_CLOSE_SHORT_ARRAY,
|
40 |
);
|
41 |
-
}
|
42 |
|
43 |
|
44 |
/**
|
@@ -50,7 +51,7 @@ class ShortArraySniff extends Sniff
|
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
53 |
-
public function process(
|
54 |
{
|
55 |
if ($this->supportsBelow('5.3') === false) {
|
56 |
return;
|
@@ -69,7 +70,5 @@ class ShortArraySniff extends Sniff
|
|
69 |
}
|
70 |
|
71 |
$phpcsFile->addError($error, $stackPtr, 'Found', $data);
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\NewShortArray.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
9 |
* @author Alex Miroshnikov <unknown@example.com>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Syntax\NewShortArray.
|
19 |
*
|
20 |
* Short array syntax is available since PHP 5.4
|
21 |
*
|
25 |
* @package PHPCompatibility
|
26 |
* @author Alex Miroshnikov <unknown@example.com>
|
27 |
*/
|
28 |
+
class NewShortArraySniff extends Sniff
|
29 |
{
|
30 |
|
31 |
/**
|
36 |
public function register()
|
37 |
{
|
38 |
return array(
|
39 |
+
\T_OPEN_SHORT_ARRAY,
|
40 |
+
\T_CLOSE_SHORT_ARRAY,
|
41 |
);
|
42 |
+
}
|
43 |
|
44 |
|
45 |
/**
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
+
public function process(File $phpcsFile, $stackPtr)
|
55 |
{
|
56 |
if ($this->supportsBelow('5.3') === false) {
|
57 |
return;
|
70 |
}
|
71 |
|
72 |
$phpcsFile->addError($error, $stackPtr, 'Found', $data);
|
73 |
+
}
|
74 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedNewReferenceSniff.php → Syntax/RemovedNewReferenceSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
@@ -10,12 +10,14 @@
|
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
-
namespace PHPCompatibility\Sniffs\
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
-
* \PHPCompatibility\Sniffs\
|
19 |
*
|
20 |
* Discourages the use of assigning the return value of new by reference
|
21 |
*
|
@@ -26,7 +28,7 @@ use PHPCompatibility\Sniff;
|
|
26 |
* @author Wim Godden <wim.godden@cu.be>
|
27 |
* @copyright 2012 Cu.be Solutions bvba
|
28 |
*/
|
29 |
-
class
|
30 |
{
|
31 |
|
32 |
/**
|
@@ -36,9 +38,8 @@ class DeprecatedNewReferenceSniff extends Sniff
|
|
36 |
*/
|
37 |
public function register()
|
38 |
{
|
39 |
-
return array(T_NEW);
|
40 |
-
|
41 |
-
}//end register()
|
42 |
|
43 |
/**
|
44 |
* Processes this test, when one of its tokens is encountered.
|
@@ -49,14 +50,14 @@ class DeprecatedNewReferenceSniff extends Sniff
|
|
49 |
*
|
50 |
* @return void
|
51 |
*/
|
52 |
-
public function process(
|
53 |
{
|
54 |
if ($this->supportsAbove('5.3') === false) {
|
55 |
return;
|
56 |
}
|
57 |
|
58 |
$tokens = $phpcsFile->getTokens();
|
59 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
60 |
if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['type'] !== 'T_BITWISE_AND') {
|
61 |
return;
|
62 |
}
|
@@ -72,7 +73,5 @@ class DeprecatedNewReferenceSniff extends Sniff
|
|
72 |
}
|
73 |
|
74 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode);
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Syntax\RemovedNewReferenceSniff.
|
4 |
*
|
5 |
* PHP version 5.4
|
6 |
*
|
10 |
* @copyright 2012 Cu.be Solutions bvba
|
11 |
*/
|
12 |
|
13 |
+
namespace PHPCompatibility\Sniffs\Syntax;
|
14 |
|
15 |
use PHPCompatibility\Sniff;
|
16 |
+
use PHP_CodeSniffer_File as File;
|
17 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
18 |
|
19 |
/**
|
20 |
+
* \PHPCompatibility\Sniffs\Syntax\RemovedNewReferenceSniff.
|
21 |
*
|
22 |
* Discourages the use of assigning the return value of new by reference
|
23 |
*
|
28 |
* @author Wim Godden <wim.godden@cu.be>
|
29 |
* @copyright 2012 Cu.be Solutions bvba
|
30 |
*/
|
31 |
+
class RemovedNewReferenceSniff extends Sniff
|
32 |
{
|
33 |
|
34 |
/**
|
38 |
*/
|
39 |
public function register()
|
40 |
{
|
41 |
+
return array(\T_NEW);
|
42 |
+
}
|
|
|
43 |
|
44 |
/**
|
45 |
* Processes this test, when one of its tokens is encountered.
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
53 |
+
public function process(File $phpcsFile, $stackPtr)
|
54 |
{
|
55 |
if ($this->supportsAbove('5.3') === false) {
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
$tokens = $phpcsFile->getTokens();
|
60 |
+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
61 |
if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['type'] !== 'T_BITWISE_AND') {
|
62 |
return;
|
63 |
}
|
73 |
}
|
74 |
|
75 |
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode);
|
76 |
+
}
|
77 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP → TypeCasts}/NewTypeCastsSniff.php
RENAMED
@@ -1,18 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
@@ -52,7 +54,7 @@ class NewTypeCastsSniff extends AbstractNewFeatureSniff
|
|
52 |
{
|
53 |
$tokens = array();
|
54 |
foreach ($this->newTypeCasts as $token => $versions) {
|
55 |
-
if (defined($token)) {
|
56 |
$tokens[] = constant($token);
|
57 |
}
|
58 |
}
|
@@ -62,14 +64,17 @@ class NewTypeCastsSniff extends AbstractNewFeatureSniff
|
|
62 |
*
|
63 |
* - (binary) cast is incorrectly tokenized as T_STRING_CAST by PHP and PHPCS.
|
64 |
* - b"something" binary cast is incorrectly tokenized as T_CONSTANT_ENCAPSED_STRING by PHP and PHPCS.
|
|
|
65 |
*
|
66 |
* @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1574
|
67 |
*/
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
|
71 |
return $tokens;
|
72 |
-
}
|
73 |
|
74 |
|
75 |
/**
|
@@ -81,7 +86,7 @@ class NewTypeCastsSniff extends AbstractNewFeatureSniff
|
|
81 |
*
|
82 |
* @return void
|
83 |
*/
|
84 |
-
public function process(
|
85 |
{
|
86 |
$tokens = $phpcsFile->getTokens();
|
87 |
$tokenType = $tokens[$stackPtr]['type'];
|
@@ -99,7 +104,9 @@ class NewTypeCastsSniff extends AbstractNewFeatureSniff
|
|
99 |
break;
|
100 |
|
101 |
case 'T_CONSTANT_ENCAPSED_STRING':
|
102 |
-
if (strpos($tokenContent, 'b"') === 0 && substr($tokenContent, -1) === '"')
|
|
|
|
|
103 |
$tokenType = 'T_BINARY_CAST';
|
104 |
} else {
|
105 |
return;
|
@@ -119,8 +126,7 @@ class NewTypeCastsSniff extends AbstractNewFeatureSniff
|
|
119 |
'content' => $tokens[$stackPtr]['content'],
|
120 |
);
|
121 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
122 |
-
|
123 |
-
}//end process()
|
124 |
|
125 |
|
126 |
/**
|
@@ -194,6 +200,4 @@ class NewTypeCastsSniff extends AbstractNewFeatureSniff
|
|
194 |
$data[] = $itemInfo['content'];
|
195 |
return $data;
|
196 |
}
|
197 |
-
|
198 |
-
|
199 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\TypeCasts\NewTypeCastsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\TypeCasts;
|
11 |
|
12 |
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
+
use PHPCompatibility\PHPCSHelper;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
|
16 |
/**
|
17 |
+
* \PHPCompatibility\Sniffs\TypeCasts\NewTypeCastsSniff.
|
18 |
*
|
19 |
* @category PHP
|
20 |
* @package PHPCompatibility
|
54 |
{
|
55 |
$tokens = array();
|
56 |
foreach ($this->newTypeCasts as $token => $versions) {
|
57 |
+
if (\defined($token)) {
|
58 |
$tokens[] = constant($token);
|
59 |
}
|
60 |
}
|
64 |
*
|
65 |
* - (binary) cast is incorrectly tokenized as T_STRING_CAST by PHP and PHPCS.
|
66 |
* - b"something" binary cast is incorrectly tokenized as T_CONSTANT_ENCAPSED_STRING by PHP and PHPCS.
|
67 |
+
* - Since PHPCS 3.4.0, PHPCS *will* tokenize these correctly.
|
68 |
*
|
69 |
* @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1574
|
70 |
*/
|
71 |
+
if (version_compare(PHPCSHelper::getVersion(), '3.4.0', '<') === true) {
|
72 |
+
$tokens[] = \T_STRING_CAST;
|
73 |
+
$tokens[] = \T_CONSTANT_ENCAPSED_STRING;
|
74 |
+
}
|
75 |
|
76 |
return $tokens;
|
77 |
+
}
|
78 |
|
79 |
|
80 |
/**
|
86 |
*
|
87 |
* @return void
|
88 |
*/
|
89 |
+
public function process(File $phpcsFile, $stackPtr)
|
90 |
{
|
91 |
$tokens = $phpcsFile->getTokens();
|
92 |
$tokenType = $tokens[$stackPtr]['type'];
|
104 |
break;
|
105 |
|
106 |
case 'T_CONSTANT_ENCAPSED_STRING':
|
107 |
+
if ((strpos($tokenContent, 'b"') === 0 && substr($tokenContent, -1) === '"')
|
108 |
+
|| (strpos($tokenContent, "b'") === 0 && substr($tokenContent, -1) === "'")
|
109 |
+
) {
|
110 |
$tokenType = 'T_BINARY_CAST';
|
111 |
} else {
|
112 |
return;
|
126 |
'content' => $tokens[$stackPtr]['content'],
|
127 |
);
|
128 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
129 |
+
}
|
|
|
130 |
|
131 |
|
132 |
/**
|
200 |
$data[] = $itemInfo['content'];
|
201 |
return $data;
|
202 |
}
|
203 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/DeprecatedTypeCastsSniff.php → TypeCasts/RemovedTypeCastsSniff.php}
RENAMED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
|
|
13 |
|
14 |
/**
|
15 |
-
* \PHPCompatibility\Sniffs\
|
16 |
*
|
17 |
* @category PHP
|
18 |
* @package PHPCompatibility
|
19 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
/**
|
24 |
* A list of deprecated and removed type casts with their alternatives.
|
@@ -50,8 +51,7 @@ class DeprecatedTypeCastsSniff extends AbstractRemovedFeatureSniff
|
|
50 |
}
|
51 |
|
52 |
return $tokens;
|
53 |
-
|
54 |
-
}//end register()
|
55 |
|
56 |
|
57 |
/**
|
@@ -63,7 +63,7 @@ class DeprecatedTypeCastsSniff extends AbstractRemovedFeatureSniff
|
|
63 |
*
|
64 |
* @return void
|
65 |
*/
|
66 |
-
public function process(
|
67 |
{
|
68 |
$tokens = $phpcsFile->getTokens();
|
69 |
$tokenType = $tokens[$stackPtr]['type'];
|
@@ -73,8 +73,7 @@ class DeprecatedTypeCastsSniff extends AbstractRemovedFeatureSniff
|
|
73 |
'description' => $this->deprecatedTypeCasts[$tokenType]['description'],
|
74 |
);
|
75 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
76 |
-
|
77 |
-
}//end process()
|
78 |
|
79 |
|
80 |
/**
|
@@ -125,5 +124,4 @@ class DeprecatedTypeCastsSniff extends AbstractRemovedFeatureSniff
|
|
125 |
$data[0] = $itemInfo['description'];
|
126 |
return $data;
|
127 |
}
|
128 |
-
|
129 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\TypeCasts\RemovedTypeCastsSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\TypeCasts;
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
+
use PHP_CodeSniffer_File as File;
|
14 |
|
15 |
/**
|
16 |
+
* \PHPCompatibility\Sniffs\TypeCasts\RemovedTypeCastsSniff.
|
17 |
*
|
18 |
* @category PHP
|
19 |
* @package PHPCompatibility
|
20 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
21 |
*/
|
22 |
+
class RemovedTypeCastsSniff extends AbstractRemovedFeatureSniff
|
23 |
{
|
24 |
/**
|
25 |
* A list of deprecated and removed type casts with their alternatives.
|
51 |
}
|
52 |
|
53 |
return $tokens;
|
54 |
+
}
|
|
|
55 |
|
56 |
|
57 |
/**
|
63 |
*
|
64 |
* @return void
|
65 |
*/
|
66 |
+
public function process(File $phpcsFile, $stackPtr)
|
67 |
{
|
68 |
$tokens = $phpcsFile->getTokens();
|
69 |
$tokenType = $tokens[$stackPtr]['type'];
|
73 |
'description' => $this->deprecatedTypeCasts[$tokenType]['description'],
|
74 |
);
|
75 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
76 |
+
}
|
|
|
77 |
|
78 |
|
79 |
/**
|
124 |
$data[0] = $itemInfo['description'];
|
125 |
return $data;
|
126 |
}
|
127 |
+
}
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/UseDeclarations}/NewGroupUseDeclarationsSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* PHP version 7.0
|
20 |
*
|
@@ -31,12 +33,12 @@ class NewGroupUseDeclarationsSniff extends Sniff
|
|
31 |
*/
|
32 |
public function register()
|
33 |
{
|
34 |
-
if (defined('T_OPEN_USE_GROUP')) {
|
35 |
-
return array(T_OPEN_USE_GROUP);
|
36 |
} else {
|
37 |
-
return array(T_USE);
|
38 |
}
|
39 |
-
}
|
40 |
|
41 |
|
42 |
/**
|
@@ -48,7 +50,7 @@ class NewGroupUseDeclarationsSniff extends Sniff
|
|
48 |
*
|
49 |
* @return void
|
50 |
*/
|
51 |
-
public function process(
|
52 |
{
|
53 |
if ($this->supportsBelow('7.1') === false) {
|
54 |
return;
|
@@ -58,14 +60,14 @@ class NewGroupUseDeclarationsSniff extends Sniff
|
|
58 |
$token = $tokens[$stackPtr];
|
59 |
|
60 |
// Deal with PHPCS pre-2.6.0.
|
61 |
-
if ($token['code'] === T_USE) {
|
62 |
-
$hasCurlyBrace = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
|
63 |
if ($hasCurlyBrace === false) {
|
64 |
return;
|
65 |
}
|
66 |
|
67 |
-
$prevToken = $phpcsFile->findPrevious(
|
68 |
-
if ($prevToken === false || $tokens[$prevToken]['code'] !== T_NS_SEPARATOR) {
|
69 |
return;
|
70 |
}
|
71 |
|
@@ -81,9 +83,9 @@ class NewGroupUseDeclarationsSniff extends Sniff
|
|
81 |
);
|
82 |
}
|
83 |
|
84 |
-
$closers = array(T_CLOSE_CURLY_BRACKET);
|
85 |
-
if (defined('T_CLOSE_USE_GROUP')) {
|
86 |
-
$closers[] = T_CLOSE_USE_GROUP;
|
87 |
}
|
88 |
|
89 |
$closeCurly = $phpcsFile->findNext($closers, ($stackPtr + 1), null, false, null, true);
|
@@ -91,14 +93,13 @@ class NewGroupUseDeclarationsSniff extends Sniff
|
|
91 |
return;
|
92 |
}
|
93 |
|
94 |
-
$prevToken = $phpcsFile->findPrevious(
|
95 |
-
if ($tokens[$prevToken]['code'] === T_COMMA) {
|
96 |
$phpcsFile->addError(
|
97 |
'Trailing comma\'s are not allowed in group use statements in PHP 7.1 or earlier',
|
98 |
$prevToken,
|
99 |
'TrailingCommaFound'
|
100 |
);
|
101 |
}
|
102 |
-
}
|
103 |
-
|
104 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\UseDeclarations\NewGroupUseDeclarationsSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim.godden@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\UseDeclarations;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\UseDeclarations\NewGroupUseDeclarationsSniff.
|
20 |
*
|
21 |
* PHP version 7.0
|
22 |
*
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
+
if (\defined('T_OPEN_USE_GROUP')) {
|
37 |
+
return array(\T_OPEN_USE_GROUP);
|
38 |
} else {
|
39 |
+
return array(\T_USE);
|
40 |
}
|
41 |
+
}
|
42 |
|
43 |
|
44 |
/**
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
53 |
+
public function process(File $phpcsFile, $stackPtr)
|
54 |
{
|
55 |
if ($this->supportsBelow('7.1') === false) {
|
56 |
return;
|
60 |
$token = $tokens[$stackPtr];
|
61 |
|
62 |
// Deal with PHPCS pre-2.6.0.
|
63 |
+
if ($token['code'] === \T_USE) {
|
64 |
+
$hasCurlyBrace = $phpcsFile->findNext(\T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
|
65 |
if ($hasCurlyBrace === false) {
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
|
70 |
+
if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_NS_SEPARATOR) {
|
71 |
return;
|
72 |
}
|
73 |
|
83 |
);
|
84 |
}
|
85 |
|
86 |
+
$closers = array(\T_CLOSE_CURLY_BRACKET);
|
87 |
+
if (\defined('T_CLOSE_USE_GROUP')) {
|
88 |
+
$closers[] = \T_CLOSE_USE_GROUP;
|
89 |
}
|
90 |
|
91 |
$closeCurly = $phpcsFile->findNext($closers, ($stackPtr + 1), null, false, null, true);
|
93 |
return;
|
94 |
}
|
95 |
|
96 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($closeCurly - 1), null, true);
|
97 |
+
if ($tokens[$prevToken]['code'] === \T_COMMA) {
|
98 |
$phpcsFile->addError(
|
99 |
'Trailing comma\'s are not allowed in group use statements in PHP 7.1 or earlier',
|
100 |
$prevToken,
|
101 |
'TrailingCommaFound'
|
102 |
);
|
103 |
}
|
104 |
+
}
|
105 |
+
}
|
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/UseDeclarations}/NewUseConstFunctionSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 5.6
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* The use operator has been extended to support importing functions and
|
20 |
* constants in addition to classes. This is achieved via the use function
|
@@ -46,7 +48,7 @@ class NewUseConstFunctionSniff extends Sniff
|
|
46 |
*/
|
47 |
public function register()
|
48 |
{
|
49 |
-
return array(T_USE);
|
50 |
}
|
51 |
|
52 |
|
@@ -59,7 +61,7 @@ class NewUseConstFunctionSniff extends Sniff
|
|
59 |
*
|
60 |
* @return void
|
61 |
*/
|
62 |
-
public function process(
|
63 |
{
|
64 |
if ($this->supportsBelow('5.5') !== true) {
|
65 |
return;
|
@@ -67,7 +69,7 @@ class NewUseConstFunctionSniff extends Sniff
|
|
67 |
|
68 |
$tokens = $phpcsFile->getTokens();
|
69 |
|
70 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
71 |
if ($nextNonEmpty === false) {
|
72 |
// Live coding.
|
73 |
return;
|
@@ -79,11 +81,11 @@ class NewUseConstFunctionSniff extends Sniff
|
|
79 |
}
|
80 |
|
81 |
// `use const` and `use function` have to be followed by the function/constant name.
|
82 |
-
$functionOrConstName = $phpcsFile->findNext(
|
83 |
if ($functionOrConstName === false
|
84 |
// Identifies as T_AS or T_STRING, this covers both.
|
85 |
|| ($tokens[$functionOrConstName]['content'] === 'as'
|
86 |
-
|| $tokens[$functionOrConstName]['code'] === T_COMMA)
|
87 |
) {
|
88 |
// Live coding or incorrect use of reserved keyword, but that is
|
89 |
// covered by the ForbiddenNames sniff.
|
@@ -97,5 +99,4 @@ class NewUseConstFunctionSniff extends Sniff
|
|
97 |
'Found'
|
98 |
);
|
99 |
}
|
100 |
-
|
101 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\UseDeclarations\NewUseConstFunctionSniff.
|
4 |
*
|
5 |
* PHP version 5.6
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\UseDeclarations;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\UseDeclarations\NewUseConstFunctionSniff.
|
20 |
*
|
21 |
* The use operator has been extended to support importing functions and
|
22 |
* constants in addition to classes. This is achieved via the use function
|
48 |
*/
|
49 |
public function register()
|
50 |
{
|
51 |
+
return array(\T_USE);
|
52 |
}
|
53 |
|
54 |
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
+
public function process(File $phpcsFile, $stackPtr)
|
65 |
{
|
66 |
if ($this->supportsBelow('5.5') !== true) {
|
67 |
return;
|
69 |
|
70 |
$tokens = $phpcsFile->getTokens();
|
71 |
|
72 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
73 |
if ($nextNonEmpty === false) {
|
74 |
// Live coding.
|
75 |
return;
|
81 |
}
|
82 |
|
83 |
// `use const` and `use function` have to be followed by the function/constant name.
|
84 |
+
$functionOrConstName = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
|
85 |
if ($functionOrConstName === false
|
86 |
// Identifies as T_AS or T_STRING, this covers both.
|
87 |
|| ($tokens[$functionOrConstName]['content'] === 'as'
|
88 |
+
|| $tokens[$functionOrConstName]['code'] === \T_COMMA)
|
89 |
) {
|
90 |
// Live coding or incorrect use of reserved keyword, but that is
|
91 |
// covered by the ForbiddenNames sniff.
|
99 |
'Found'
|
100 |
);
|
101 |
}
|
|
|
102 |
}
|
vendor/{wimg/php-compatibility/PHPCompatibility/Sniffs/PHP → phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables}/ForbiddenGlobalVariableVariableSniff.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* Variable variables are forbidden with global
|
20 |
*
|
@@ -34,7 +36,7 @@ class ForbiddenGlobalVariableVariableSniff extends Sniff
|
|
34 |
*/
|
35 |
public function register()
|
36 |
{
|
37 |
-
return array(T_GLOBAL);
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -46,14 +48,14 @@ class ForbiddenGlobalVariableVariableSniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsAbove('7.0') === false) {
|
52 |
return;
|
53 |
}
|
54 |
|
55 |
$tokens = $phpcsFile->getTokens();
|
56 |
-
$endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr + 1));
|
57 |
if ($endOfStatement === false) {
|
58 |
// No semi-colon - live coding.
|
59 |
return;
|
@@ -61,22 +63,22 @@ class ForbiddenGlobalVariableVariableSniff extends Sniff
|
|
61 |
|
62 |
for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) {
|
63 |
$errorThrown = false;
|
64 |
-
$nextComma = $phpcsFile->findNext(T_COMMA, $ptr, $endOfStatement, false, null, true);
|
65 |
$varEnd = ($nextComma === false) ? $endOfStatement : $nextComma;
|
66 |
-
$variable = $phpcsFile->findNext(T_VARIABLE, $ptr, $varEnd);
|
67 |
$varString = trim($phpcsFile->getTokensAsString($ptr, ($varEnd - $ptr)));
|
68 |
$data = array($varString);
|
69 |
|
70 |
if ($variable !== false) {
|
71 |
|
72 |
-
$prev = $phpcsFile->findPrevious(
|
73 |
|
74 |
if ($prev !== false && $tokens[$prev]['type'] === 'T_DOLLAR') {
|
75 |
|
76 |
-
$next = $phpcsFile->findNext(
|
77 |
|
78 |
if ($next !== false
|
79 |
-
&& in_array($tokens[$next]['code'], array(T_OPEN_SQUARE_BRACKET, T_OBJECT_OPERATOR, T_DOUBLE_COLON), true) === true
|
80 |
) {
|
81 |
$phpcsFile->addError(
|
82 |
'Global with variable variables is not allowed since PHP 7.0. Found %s',
|
@@ -98,10 +100,10 @@ class ForbiddenGlobalVariableVariableSniff extends Sniff
|
|
98 |
}
|
99 |
|
100 |
if ($errorThrown === false) {
|
101 |
-
$dollar = $phpcsFile->findNext(T_DOLLAR, $ptr, $varEnd);
|
102 |
if ($dollar !== false) {
|
103 |
-
$next = $phpcsFile->findNext(
|
104 |
-
if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) {
|
105 |
$phpcsFile->addWarning(
|
106 |
'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s',
|
107 |
$dollar,
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Variables\ForbiddenGlobalVariableVariableSniff.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Wim Godden <wim@cu.be>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Variables;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Variables\ForbiddenGlobalVariableVariableSniff.
|
20 |
*
|
21 |
* Variable variables are forbidden with global
|
22 |
*
|
36 |
*/
|
37 |
public function register()
|
38 |
{
|
39 |
+
return array(\T_GLOBAL);
|
40 |
}
|
41 |
|
42 |
/**
|
48 |
*
|
49 |
* @return void
|
50 |
*/
|
51 |
+
public function process(File $phpcsFile, $stackPtr)
|
52 |
{
|
53 |
if ($this->supportsAbove('7.0') === false) {
|
54 |
return;
|
55 |
}
|
56 |
|
57 |
$tokens = $phpcsFile->getTokens();
|
58 |
+
$endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1));
|
59 |
if ($endOfStatement === false) {
|
60 |
// No semi-colon - live coding.
|
61 |
return;
|
63 |
|
64 |
for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) {
|
65 |
$errorThrown = false;
|
66 |
+
$nextComma = $phpcsFile->findNext(\T_COMMA, $ptr, $endOfStatement, false, null, true);
|
67 |
$varEnd = ($nextComma === false) ? $endOfStatement : $nextComma;
|
68 |
+
$variable = $phpcsFile->findNext(\T_VARIABLE, $ptr, $varEnd);
|
69 |
$varString = trim($phpcsFile->getTokensAsString($ptr, ($varEnd - $ptr)));
|
70 |
$data = array($varString);
|
71 |
|
72 |
if ($variable !== false) {
|
73 |
|
74 |
+
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($variable - 1), $ptr, true);
|
75 |
|
76 |
if ($prev !== false && $tokens[$prev]['type'] === 'T_DOLLAR') {
|
77 |
|
78 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($variable + 1), $varEnd, true);
|
79 |
|
80 |
if ($next !== false
|
81 |
+
&& \in_array($tokens[$next]['code'], array(\T_OPEN_SQUARE_BRACKET, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === true
|
82 |
) {
|
83 |
$phpcsFile->addError(
|
84 |
'Global with variable variables is not allowed since PHP 7.0. Found %s',
|
100 |
}
|
101 |
|
102 |
if ($errorThrown === false) {
|
103 |
+
$dollar = $phpcsFile->findNext(\T_DOLLAR, $ptr, $varEnd);
|
104 |
if ($dollar !== false) {
|
105 |
+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($dollar + 1), $varEnd, true);
|
106 |
+
if ($tokens[$next]['code'] === \T_OPEN_CURLY_BRACKET) {
|
107 |
$phpcsFile->addWarning(
|
108 |
'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s',
|
109 |
$dollar,
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php
ADDED
@@ -0,0 +1,424 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPCompatibility, an external standard for PHP_CodeSniffer.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
* @copyright 2012-2018 PHPCompatibility Contributors
|
7 |
+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
|
8 |
+
* @link https://github.com/PHPCompatibility/PHPCompatibility
|
9 |
+
*/
|
10 |
+
|
11 |
+
namespace PHPCompatibility\Sniffs\Variables;
|
12 |
+
|
13 |
+
use PHPCompatibility\Sniff;
|
14 |
+
use PHPCompatibility\PHPCSHelper;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Detect using $this in incompatible contexts.
|
20 |
+
*
|
21 |
+
* "Whilst $this is considered a special variable in PHP, it lacked proper checks
|
22 |
+
* to ensure it wasn't used as a variable name or reassigned. This has now been
|
23 |
+
* rectified to ensure that $this cannot be a user-defined variable, reassigned
|
24 |
+
* to a different value, or be globalised."
|
25 |
+
*
|
26 |
+
* This sniff only addresses those situations which did *not* throw an error prior
|
27 |
+
* to PHP 7.1, either at all or only in PHP 7.0.
|
28 |
+
* In other words, the following situation, while mentioned in the RFC, will NOT
|
29 |
+
* be sniffed for:
|
30 |
+
* - Using $this as static variable. (error _message_ change only).
|
31 |
+
*
|
32 |
+
* Also, the changes with relation to assigning $this dynamically can not be
|
33 |
+
* sniffed for reliably, so are not covered by this sniff.
|
34 |
+
* - Disable ability to re-assign $this indirectly through $$.
|
35 |
+
* - Disable ability to re-assign $this indirectly through reference.
|
36 |
+
* - Disable ability to re-assign $this indirectly through extract() and parse_str().
|
37 |
+
*
|
38 |
+
* Other changes not (yet) covered:
|
39 |
+
* - get_defined_vars() always doesn't show value of variable $this.
|
40 |
+
* - Always show true $this value in magic method __call().
|
41 |
+
* {@internal This could possibly be covered. Similar logic as "outside object context",
|
42 |
+
* but with function name check and supportsBelow('7.0').}}
|
43 |
+
*
|
44 |
+
* PHP version 7.1
|
45 |
+
*
|
46 |
+
* @link https://wiki.php.net/rfc/this_var
|
47 |
+
*
|
48 |
+
* @since 9.1.0
|
49 |
+
*/
|
50 |
+
class ForbiddenThisUseContextsSniff extends Sniff
|
51 |
+
{
|
52 |
+
|
53 |
+
/**
|
54 |
+
* OO scope tokens.
|
55 |
+
*
|
56 |
+
* Duplicate of Tokens::$ooScopeTokens array in PHPCS which was added in 3.1.0.
|
57 |
+
*
|
58 |
+
* @since 9.1.0
|
59 |
+
*
|
60 |
+
* @var array
|
61 |
+
*/
|
62 |
+
private $ooScopeTokens = array(
|
63 |
+
'T_CLASS' => \T_CLASS,
|
64 |
+
'T_INTERFACE' => \T_INTERFACE,
|
65 |
+
'T_TRAIT' => \T_TRAIT,
|
66 |
+
);
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Scopes to skip over when examining the contents of functions.
|
70 |
+
*
|
71 |
+
* @since 9.1.0
|
72 |
+
*
|
73 |
+
* @var array
|
74 |
+
*/
|
75 |
+
private $skipOverScopes = array(
|
76 |
+
'T_FUNCTION' => true,
|
77 |
+
'T_CLOSURE' => true,
|
78 |
+
);
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Valid uses of $this in plain functions or methods outside object context.
|
82 |
+
*
|
83 |
+
* @since 9.1.0
|
84 |
+
*
|
85 |
+
* @var array
|
86 |
+
*/
|
87 |
+
private $validUseOutsideObject = array(
|
88 |
+
\T_ISSET => true,
|
89 |
+
\T_EMPTY => true,
|
90 |
+
);
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Returns an array of tokens this test wants to listen for.
|
94 |
+
*
|
95 |
+
* @since 9.1.0
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
*/
|
99 |
+
public function register()
|
100 |
+
{
|
101 |
+
if (\defined('T_ANON_CLASS')) {
|
102 |
+
$this->ooScopeTokens['T_ANON_CLASS'] = \T_ANON_CLASS;
|
103 |
+
}
|
104 |
+
|
105 |
+
$this->skipOverScopes += $this->ooScopeTokens;
|
106 |
+
|
107 |
+
return array(
|
108 |
+
\T_FUNCTION,
|
109 |
+
\T_CLOSURE,
|
110 |
+
\T_GLOBAL,
|
111 |
+
\T_CATCH,
|
112 |
+
\T_FOREACH,
|
113 |
+
\T_UNSET,
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Processes this test, when one of its tokens is encountered.
|
119 |
+
*
|
120 |
+
* @since 9.1.0
|
121 |
+
*
|
122 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
123 |
+
* @param int $stackPtr The position of the current token in
|
124 |
+
* the stack passed in $tokens.
|
125 |
+
*
|
126 |
+
* @return void
|
127 |
+
*/
|
128 |
+
public function process(File $phpcsFile, $stackPtr)
|
129 |
+
{
|
130 |
+
if ($this->supportsAbove('7.1') === false) {
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
$tokens = $phpcsFile->getTokens();
|
135 |
+
|
136 |
+
switch ($tokens[$stackPtr]['code']) {
|
137 |
+
case \T_FUNCTION:
|
138 |
+
$this->isThisUsedAsParameter($phpcsFile, $stackPtr);
|
139 |
+
$this->isThisUsedOutsideObjectContext($phpcsFile, $stackPtr);
|
140 |
+
break;
|
141 |
+
|
142 |
+
case \T_CLOSURE:
|
143 |
+
$this->isThisUsedAsParameter($phpcsFile, $stackPtr);
|
144 |
+
break;
|
145 |
+
|
146 |
+
case \T_GLOBAL:
|
147 |
+
/*
|
148 |
+
* $this can no longer be imported using the `global` keyword.
|
149 |
+
* This worked in PHP 7.0, though in PHP 5.x, it would throw a
|
150 |
+
* fatal "Cannot re-assign $this" error.
|
151 |
+
*/
|
152 |
+
$endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1));
|
153 |
+
if ($endOfStatement === false) {
|
154 |
+
// No semi-colon - live coding.
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
for ($i = ($stackPtr + 1); $i < $endOfStatement; $i++) {
|
159 |
+
if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') {
|
160 |
+
continue;
|
161 |
+
}
|
162 |
+
|
163 |
+
$phpcsFile->addError(
|
164 |
+
'"$this" can no longer be used with the "global" keyword since PHP 7.1.',
|
165 |
+
$i,
|
166 |
+
'Global'
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
break;
|
171 |
+
|
172 |
+
case \T_CATCH:
|
173 |
+
/*
|
174 |
+
* $this can no longer be used as a catch variable.
|
175 |
+
*/
|
176 |
+
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
|
177 |
+
return;
|
178 |
+
}
|
179 |
+
|
180 |
+
$varPtr = $phpcsFile->findNext(
|
181 |
+
\T_VARIABLE,
|
182 |
+
($tokens[$stackPtr]['parenthesis_opener'] + 1),
|
183 |
+
$tokens[$stackPtr]['parenthesis_closer']
|
184 |
+
);
|
185 |
+
|
186 |
+
if ($varPtr === false || $tokens[$varPtr]['content'] !== '$this') {
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
|
190 |
+
$phpcsFile->addError(
|
191 |
+
'"$this" can no longer be used as a catch variable since PHP 7.1.',
|
192 |
+
$varPtr,
|
193 |
+
'Catch'
|
194 |
+
);
|
195 |
+
|
196 |
+
break;
|
197 |
+
|
198 |
+
case \T_FOREACH:
|
199 |
+
/*
|
200 |
+
* $this can no longer be used as a foreach *value* variable.
|
201 |
+
* This worked in PHP 7.0, though in PHP 5.x, it would throw a
|
202 |
+
* fatal "Cannot re-assign $this" error.
|
203 |
+
*/
|
204 |
+
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
|
205 |
+
return;
|
206 |
+
}
|
207 |
+
|
208 |
+
$stopPtr = $phpcsFile->findPrevious(
|
209 |
+
array(\T_AS, \T_DOUBLE_ARROW),
|
210 |
+
($tokens[$stackPtr]['parenthesis_closer'] - 1),
|
211 |
+
$tokens[$stackPtr]['parenthesis_opener']
|
212 |
+
);
|
213 |
+
if ($stopPtr === false) {
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
|
217 |
+
$valueVarPtr = $phpcsFile->findNext(
|
218 |
+
\T_VARIABLE,
|
219 |
+
($stopPtr + 1),
|
220 |
+
$tokens[$stackPtr]['parenthesis_closer']
|
221 |
+
);
|
222 |
+
if ($valueVarPtr === false || $tokens[$valueVarPtr]['content'] !== '$this') {
|
223 |
+
return;
|
224 |
+
}
|
225 |
+
|
226 |
+
$afterThis = $phpcsFile->findNext(
|
227 |
+
Tokens::$emptyTokens,
|
228 |
+
($valueVarPtr + 1),
|
229 |
+
$tokens[$stackPtr]['parenthesis_closer'],
|
230 |
+
true
|
231 |
+
);
|
232 |
+
|
233 |
+
if ($afterThis !== false
|
234 |
+
&& ($tokens[$afterThis]['code'] === \T_OBJECT_OPERATOR
|
235 |
+
|| $tokens[$afterThis]['code'] === \T_DOUBLE_COLON)
|
236 |
+
) {
|
237 |
+
return;
|
238 |
+
}
|
239 |
+
|
240 |
+
$phpcsFile->addError(
|
241 |
+
'"$this" can no longer be used as value variable in a foreach control structure since PHP 7.1.',
|
242 |
+
$valueVarPtr,
|
243 |
+
'ForeachValueVar'
|
244 |
+
);
|
245 |
+
|
246 |
+
break;
|
247 |
+
|
248 |
+
case \T_UNSET:
|
249 |
+
/*
|
250 |
+
* $this can no longer be unset.
|
251 |
+
*/
|
252 |
+
$openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
253 |
+
if ($openParenthesis === false
|
254 |
+
|| $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS
|
255 |
+
|| isset($tokens[$openParenthesis]['parenthesis_closer']) === false
|
256 |
+
) {
|
257 |
+
return;
|
258 |
+
}
|
259 |
+
|
260 |
+
for ($i = ($openParenthesis + 1); $i < $tokens[$openParenthesis]['parenthesis_closer']; $i++) {
|
261 |
+
if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') {
|
262 |
+
continue;
|
263 |
+
}
|
264 |
+
|
265 |
+
$afterThis = $phpcsFile->findNext(
|
266 |
+
Tokens::$emptyTokens,
|
267 |
+
($i + 1),
|
268 |
+
$tokens[$openParenthesis]['parenthesis_closer'],
|
269 |
+
true
|
270 |
+
);
|
271 |
+
|
272 |
+
if ($afterThis !== false
|
273 |
+
&& ($tokens[$afterThis]['code'] === \T_OBJECT_OPERATOR
|
274 |
+
|| $tokens[$afterThis]['code'] === \T_DOUBLE_COLON
|
275 |
+
|| $tokens[$afterThis]['code'] === \T_OPEN_SQUARE_BRACKET)
|
276 |
+
) {
|
277 |
+
$i = $afterThis;
|
278 |
+
continue;
|
279 |
+
}
|
280 |
+
|
281 |
+
$phpcsFile->addError(
|
282 |
+
'"$this" can no longer be unset since PHP 7.1.',
|
283 |
+
$i,
|
284 |
+
'Unset'
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
break;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Check if $this is used as a parameter in a function declaration.
|
294 |
+
*
|
295 |
+
* $this can no longer be used as a parameter in a *global* function.
|
296 |
+
* Use as a parameter in a method was already an error prior to PHP 7.1.
|
297 |
+
*
|
298 |
+
* @since 9.1.0
|
299 |
+
*
|
300 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
301 |
+
* @param int $stackPtr The position of the current token in
|
302 |
+
* the stack passed in $tokens.
|
303 |
+
*
|
304 |
+
* @return void
|
305 |
+
*/
|
306 |
+
protected function isThisUsedAsParameter(File $phpcsFile, $stackPtr)
|
307 |
+
{
|
308 |
+
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) !== false) {
|
309 |
+
return;
|
310 |
+
}
|
311 |
+
|
312 |
+
$params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
|
313 |
+
if (empty($params)) {
|
314 |
+
return;
|
315 |
+
}
|
316 |
+
|
317 |
+
$tokens = $phpcsFile->getTokens();
|
318 |
+
|
319 |
+
foreach ($params as $param) {
|
320 |
+
if ($param['name'] !== '$this') {
|
321 |
+
continue;
|
322 |
+
}
|
323 |
+
|
324 |
+
if ($tokens[$stackPtr]['code'] === \T_FUNCTION) {
|
325 |
+
$phpcsFile->addError(
|
326 |
+
'"$this" can no longer be used as a parameter since PHP 7.1.',
|
327 |
+
$param['token'],
|
328 |
+
'FunctionParam'
|
329 |
+
);
|
330 |
+
} else {
|
331 |
+
$phpcsFile->addError(
|
332 |
+
'"$this" can no longer be used as a closure parameter since PHP 7.0.7.',
|
333 |
+
$param['token'],
|
334 |
+
'ClosureParam'
|
335 |
+
);
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Check if $this is used in a plain function or method.
|
342 |
+
*
|
343 |
+
* Prior to PHP 7.1, this would result in an "undefined variable" notice
|
344 |
+
* and execution would continue with $this regarded as `null`.
|
345 |
+
* As of PHP 7.1, this throws an exception.
|
346 |
+
*
|
347 |
+
* Note: use within isset() and empty() to check object context is still allowed.
|
348 |
+
* Note: $this can still be used within a closure.
|
349 |
+
*
|
350 |
+
* @since 9.1.0
|
351 |
+
*
|
352 |
+
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
353 |
+
* @param int $stackPtr The position of the current token in
|
354 |
+
* the stack passed in $tokens.
|
355 |
+
*
|
356 |
+
* @return void
|
357 |
+
*/
|
358 |
+
protected function isThisUsedOutsideObjectContext(File $phpcsFile, $stackPtr)
|
359 |
+
{
|
360 |
+
$tokens = $phpcsFile->getTokens();
|
361 |
+
|
362 |
+
if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
|
363 |
+
return;
|
364 |
+
}
|
365 |
+
|
366 |
+
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) !== false) {
|
367 |
+
$methodProps = $phpcsFile->getMethodProperties($stackPtr);
|
368 |
+
if ($methodProps['is_static'] === false) {
|
369 |
+
return;
|
370 |
+
} else {
|
371 |
+
$methodName = $phpcsFile->getDeclarationName($stackPtr);
|
372 |
+
if ($methodName === '__call') {
|
373 |
+
/*
|
374 |
+
* This is an exception.
|
375 |
+
* @link https://wiki.php.net/rfc/this_var#always_show_true_this_value_in_magic_method_call
|
376 |
+
*/
|
377 |
+
return;
|
378 |
+
}
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) {
|
383 |
+
if (isset($this->skipOverScopes[$tokens[$i]['type']])) {
|
384 |
+
if (isset($tokens[$i]['scope_closer']) === false) {
|
385 |
+
// Live coding or parse error, will only lead to inaccurate results.
|
386 |
+
return;
|
387 |
+
}
|
388 |
+
|
389 |
+
// Skip over nested structures.
|
390 |
+
$i = $tokens[$i]['scope_closer'];
|
391 |
+
continue;
|
392 |
+
}
|
393 |
+
|
394 |
+
if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') {
|
395 |
+
continue;
|
396 |
+
}
|
397 |
+
|
398 |
+
if (isset($tokens[$i]['nested_parenthesis']) === true) {
|
399 |
+
$nestedParenthesis = $tokens[$i]['nested_parenthesis'];
|
400 |
+
$nestedOpenParenthesis = array_keys($nestedParenthesis);
|
401 |
+
$lastOpenParenthesis = array_pop($nestedOpenParenthesis);
|
402 |
+
|
403 |
+
$previousNonEmpty = $phpcsFile->findPrevious(
|
404 |
+
Tokens::$emptyTokens,
|
405 |
+
($lastOpenParenthesis - 1),
|
406 |
+
null,
|
407 |
+
true,
|
408 |
+
null,
|
409 |
+
true
|
410 |
+
);
|
411 |
+
|
412 |
+
if (isset($this->validUseOutsideObject[$tokens[$previousNonEmpty]['code']])) {
|
413 |
+
continue;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
$phpcsFile->addError(
|
418 |
+
'"$this" can no longer be used in a plain function or method since PHP 7.1.',
|
419 |
+
$i,
|
420 |
+
'OutsideObjectContext'
|
421 |
+
);
|
422 |
+
}
|
423 |
+
}
|
424 |
+
}
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/VariableVariablesSniff.php → Variables/NewUniformVariableSyntaxSniff.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
@@ -9,12 +9,14 @@
|
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
-
namespace PHPCompatibility\Sniffs\
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
* \PHPCompatibility\Sniffs\
|
18 |
*
|
19 |
* The interpretation of variable variables has changed in PHP 7.0.
|
20 |
*
|
@@ -24,7 +26,7 @@ use PHPCompatibility\Sniff;
|
|
24 |
* @package PHPCompatibility
|
25 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
*/
|
27 |
-
class
|
28 |
{
|
29 |
/**
|
30 |
* Returns an array of tokens this test wants to listen for.
|
@@ -33,9 +35,8 @@ class VariableVariablesSniff extends Sniff
|
|
33 |
*/
|
34 |
public function register()
|
35 |
{
|
36 |
-
return array(T_VARIABLE);
|
37 |
-
|
38 |
-
}//end register()
|
39 |
|
40 |
/**
|
41 |
* Processes this test, when one of its tokens is encountered.
|
@@ -46,7 +47,7 @@ class VariableVariablesSniff extends Sniff
|
|
46 |
*
|
47 |
* @return void
|
48 |
*/
|
49 |
-
public function process(
|
50 |
{
|
51 |
if ($this->supportsAbove('7.0') === false) {
|
52 |
return;
|
@@ -55,23 +56,23 @@ class VariableVariablesSniff extends Sniff
|
|
55 |
$tokens = $phpcsFile->getTokens();
|
56 |
|
57 |
// Verify that the next token is a square open bracket. If not, bow out.
|
58 |
-
$nextToken = $phpcsFile->findNext(
|
59 |
|
60 |
-
if ($nextToken === false || $tokens[$nextToken]['code'] !== T_OPEN_SQUARE_BRACKET || isset($tokens[$nextToken]['bracket_closer']) === false) {
|
61 |
return;
|
62 |
}
|
63 |
|
64 |
// The previous non-empty token has to be a $, -> or ::.
|
65 |
-
$prevToken = $phpcsFile->findPrevious(
|
66 |
-
if ($prevToken === false || in_array($tokens[$prevToken]['code'], array(T_DOLLAR, T_OBJECT_OPERATOR, T_DOUBLE_COLON), true) === false) {
|
67 |
return;
|
68 |
}
|
69 |
|
70 |
// For static object calls, it only applies when this is a function call.
|
71 |
-
if ($tokens[$prevToken]['code'] === T_DOUBLE_COLON) {
|
72 |
$hasBrackets = $tokens[$nextToken]['bracket_closer'];
|
73 |
-
while (($hasBrackets = $phpcsFile->findNext(
|
74 |
-
if ($tokens[$hasBrackets]['code'] === T_OPEN_SQUARE_BRACKET) {
|
75 |
if (isset($tokens[$hasBrackets]['bracket_closer'])) {
|
76 |
$hasBrackets = $tokens[$hasBrackets]['bracket_closer'];
|
77 |
continue;
|
@@ -80,7 +81,7 @@ class VariableVariablesSniff extends Sniff
|
|
80 |
return;
|
81 |
}
|
82 |
|
83 |
-
} elseif ($tokens[$hasBrackets]['code'] === T_OPEN_PARENTHESIS) {
|
84 |
// Caught!
|
85 |
break;
|
86 |
|
@@ -91,11 +92,11 @@ class VariableVariablesSniff extends Sniff
|
|
91 |
}
|
92 |
|
93 |
// Now let's also prevent false positives when used with self and static which still work fine.
|
94 |
-
$classToken = $phpcsFile->findPrevious(
|
95 |
if ($classToken !== false) {
|
96 |
-
if ($tokens[$classToken]['code'] === T_STATIC || $tokens[$classToken]['code'] === T_SELF) {
|
97 |
return;
|
98 |
-
} elseif ($tokens[$classToken]['code'] === T_STRING && $tokens[$classToken]['content'] === 'self') {
|
99 |
return;
|
100 |
}
|
101 |
}
|
@@ -106,8 +107,5 @@ class VariableVariablesSniff extends Sniff
|
|
106 |
$stackPtr,
|
107 |
'Found'
|
108 |
);
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Variables\NewUniformVariableSyntax.
|
4 |
*
|
5 |
* PHP version 7.0
|
6 |
*
|
9 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
*/
|
11 |
|
12 |
+
namespace PHPCompatibility\Sniffs\Variables;
|
13 |
|
14 |
use PHPCompatibility\Sniff;
|
15 |
+
use PHP_CodeSniffer_File as File;
|
16 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
17 |
|
18 |
/**
|
19 |
+
* \PHPCompatibility\Sniffs\Variables\NewUniformVariableSyntax.
|
20 |
*
|
21 |
* The interpretation of variable variables has changed in PHP 7.0.
|
22 |
*
|
26 |
* @package PHPCompatibility
|
27 |
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
*/
|
29 |
+
class NewUniformVariableSyntaxSniff extends Sniff
|
30 |
{
|
31 |
/**
|
32 |
* Returns an array of tokens this test wants to listen for.
|
35 |
*/
|
36 |
public function register()
|
37 |
{
|
38 |
+
return array(\T_VARIABLE);
|
39 |
+
}
|
|
|
40 |
|
41 |
/**
|
42 |
* Processes this test, when one of its tokens is encountered.
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
+
public function process(File $phpcsFile, $stackPtr)
|
51 |
{
|
52 |
if ($this->supportsAbove('7.0') === false) {
|
53 |
return;
|
56 |
$tokens = $phpcsFile->getTokens();
|
57 |
|
58 |
// Verify that the next token is a square open bracket. If not, bow out.
|
59 |
+
$nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
60 |
|
61 |
+
if ($nextToken === false || $tokens[$nextToken]['code'] !== \T_OPEN_SQUARE_BRACKET || isset($tokens[$nextToken]['bracket_closer']) === false) {
|
62 |
return;
|
63 |
}
|
64 |
|
65 |
// The previous non-empty token has to be a $, -> or ::.
|
66 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
67 |
+
if ($prevToken === false || \in_array($tokens[$prevToken]['code'], array(\T_DOLLAR, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === false) {
|
68 |
return;
|
69 |
}
|
70 |
|
71 |
// For static object calls, it only applies when this is a function call.
|
72 |
+
if ($tokens[$prevToken]['code'] === \T_DOUBLE_COLON) {
|
73 |
$hasBrackets = $tokens[$nextToken]['bracket_closer'];
|
74 |
+
while (($hasBrackets = $phpcsFile->findNext(Tokens::$emptyTokens, ($hasBrackets + 1), null, true, null, true)) !== false) {
|
75 |
+
if ($tokens[$hasBrackets]['code'] === \T_OPEN_SQUARE_BRACKET) {
|
76 |
if (isset($tokens[$hasBrackets]['bracket_closer'])) {
|
77 |
$hasBrackets = $tokens[$hasBrackets]['bracket_closer'];
|
78 |
continue;
|
81 |
return;
|
82 |
}
|
83 |
|
84 |
+
} elseif ($tokens[$hasBrackets]['code'] === \T_OPEN_PARENTHESIS) {
|
85 |
// Caught!
|
86 |
break;
|
87 |
|
92 |
}
|
93 |
|
94 |
// Now let's also prevent false positives when used with self and static which still work fine.
|
95 |
+
$classToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevToken - 1), null, true, null, true);
|
96 |
if ($classToken !== false) {
|
97 |
+
if ($tokens[$classToken]['code'] === \T_STATIC || $tokens[$classToken]['code'] === \T_SELF) {
|
98 |
return;
|
99 |
+
} elseif ($tokens[$classToken]['code'] === \T_STRING && $tokens[$classToken]['content'] === 'self') {
|
100 |
return;
|
101 |
}
|
102 |
}
|
107 |
$stackPtr,
|
108 |
'Found'
|
109 |
);
|
110 |
+
}
|
111 |
+
}
|
|
|
|
|
|
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/{PHP/RemovedGlobalVariablesSniff.php → Variables/RemovedPredefinedGlobalVariablesSniff.php}
RENAMED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* \PHPCompatibility\Sniffs\
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
-
namespace PHPCompatibility\Sniffs\
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
|
|
|
|
14 |
|
15 |
/**
|
16 |
-
* \PHPCompatibility\Sniffs\
|
17 |
*
|
18 |
* Discourages the use of removed global variables. Suggests alternative extensions if available
|
19 |
*
|
@@ -21,7 +23,7 @@ use PHPCompatibility\PHPCSHelper;
|
|
21 |
* @package PHPCompatibility
|
22 |
* @author Wim Godden <wim.godden@cu.be>
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
|
27 |
/**
|
@@ -89,9 +91,8 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
89 |
*/
|
90 |
public function register()
|
91 |
{
|
92 |
-
return array(T_VARIABLE);
|
93 |
-
|
94 |
-
}//end register()
|
95 |
|
96 |
|
97 |
/**
|
@@ -103,7 +104,7 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
103 |
*
|
104 |
* @return void
|
105 |
*/
|
106 |
-
public function process(
|
107 |
{
|
108 |
if ($this->supportsAbove('5.3') === false) {
|
109 |
return;
|
@@ -123,8 +124,8 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
123 |
|
124 |
// Check for static usage of class properties shadowing the removed global variables.
|
125 |
if ($this->inClassScope($phpcsFile, $stackPtr, false) === true) {
|
126 |
-
$prevToken = $phpcsFile->findPrevious(
|
127 |
-
if ($prevToken !== false && $tokens[$prevToken]['code'] === T_DOUBLE_COLON) {
|
128 |
return;
|
129 |
}
|
130 |
}
|
@@ -141,8 +142,7 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
141 |
'name' => $varName,
|
142 |
);
|
143 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
144 |
-
|
145 |
-
}//end process()
|
146 |
|
147 |
|
148 |
/**
|
@@ -196,16 +196,16 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
196 |
*
|
197 |
* @return bool
|
198 |
*/
|
199 |
-
private function isTargetPHPErrormsgVar(
|
200 |
{
|
201 |
$scopeStart = 0;
|
202 |
|
203 |
/*
|
204 |
* If the variable is detected within the scope of a function/closure, limit the checking.
|
205 |
*/
|
206 |
-
$function = $phpcsFile->getCondition($stackPtr, T_CLOSURE);
|
207 |
if ($function === false) {
|
208 |
-
$function = $phpcsFile->getCondition($stackPtr, T_FUNCTION);
|
209 |
}
|
210 |
|
211 |
// It could also be a function param, which is not in the function scope.
|
@@ -213,8 +213,8 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
213 |
$nestedParentheses = $tokens[$stackPtr]['nested_parenthesis'];
|
214 |
$parenthesisCloser = end($nestedParentheses);
|
215 |
if (isset($tokens[$parenthesisCloser]['parenthesis_owner'])
|
216 |
-
&& ($tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === T_FUNCTION
|
217 |
-
|| $tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === T_CLOSURE)
|
218 |
) {
|
219 |
$function = $tokens[$parenthesisCloser]['parenthesis_owner'];
|
220 |
}
|
@@ -227,15 +227,10 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
227 |
/*
|
228 |
* Now, let's do some additional checks.
|
229 |
*/
|
230 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
231 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
232 |
-
($stackPtr + 1),
|
233 |
-
null,
|
234 |
-
true
|
235 |
-
);
|
236 |
|
237 |
// Is the variable being used as an array ?
|
238 |
-
if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === T_OPEN_SQUARE_BRACKET) {
|
239 |
// The PHP native variable is a string, so this is probably not it
|
240 |
// (except for array access to string, but why would you in this case ?).
|
241 |
return false;
|
@@ -243,7 +238,7 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
243 |
|
244 |
// Is this a variable assignment ?
|
245 |
if ($nextNonEmpty !== false
|
246 |
-
&&
|
247 |
) {
|
248 |
return false;
|
249 |
}
|
@@ -251,7 +246,7 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
251 |
// Is this a function param shadowing the PHP native one ?
|
252 |
if ($function !== false) {
|
253 |
$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $function);
|
254 |
-
if (is_array($parameters) === true && empty($parameters) === false) {
|
255 |
foreach ($parameters as $param) {
|
256 |
if ($param['name'] === '$php_errormsg') {
|
257 |
return false;
|
@@ -271,7 +266,7 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
271 |
|
272 |
// Walk back and see if there is an assignment to the variable within the same scope.
|
273 |
for ($i = ($stackPtr - 1); $i >= $scopeStart; $i--) {
|
274 |
-
if ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET
|
275 |
&& isset($tokens[$i]['scope_condition'])
|
276 |
&& isset($skipPast[$tokens[$tokens[$i]['scope_condition']]['type']])
|
277 |
) {
|
@@ -280,19 +275,14 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
280 |
continue;
|
281 |
}
|
282 |
|
283 |
-
if ($tokens[$i]['code'] !== T_VARIABLE || $tokens[$i]['content'] !== '$php_errormsg') {
|
284 |
continue;
|
285 |
}
|
286 |
|
287 |
-
$nextNonEmpty = $phpcsFile->findNext(
|
288 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
289 |
-
($i + 1),
|
290 |
-
null,
|
291 |
-
true
|
292 |
-
);
|
293 |
|
294 |
if ($nextNonEmpty !== false
|
295 |
-
&&
|
296 |
) {
|
297 |
return false;
|
298 |
}
|
@@ -300,6 +290,4 @@ class RemovedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
|
300 |
|
301 |
return true;
|
302 |
}
|
303 |
-
|
304 |
-
|
305 |
-
}//end class
|
1 |
<?php
|
2 |
/**
|
3 |
+
* \PHPCompatibility\Sniffs\Variables\RemovedPredefinedGlobalVariablesSniff.
|
4 |
*
|
5 |
* @category PHP
|
6 |
* @package PHPCompatibility
|
7 |
* @author Wim Godden <wim.godden@cu.be>
|
8 |
*/
|
9 |
|
10 |
+
namespace PHPCompatibility\Sniffs\Variables;
|
11 |
|
12 |
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
use PHPCompatibility\PHPCSHelper;
|
14 |
+
use PHP_CodeSniffer_File as File;
|
15 |
+
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
|
17 |
/**
|
18 |
+
* \PHPCompatibility\Sniffs\Variables\RemovedPredefinedGlobalVariablesSniff.
|
19 |
*
|
20 |
* Discourages the use of removed global variables. Suggests alternative extensions if available
|
21 |
*
|
23 |
* @package PHPCompatibility
|
24 |
* @author Wim Godden <wim.godden@cu.be>
|
25 |
*/
|
26 |
+
class RemovedPredefinedGlobalVariablesSniff extends AbstractRemovedFeatureSniff
|
27 |
{
|
28 |
|
29 |
/**
|
91 |
*/
|
92 |
public function register()
|
93 |
{
|
94 |
+
return array(\T_VARIABLE);
|
95 |
+
}
|
|
|
96 |
|
97 |
|
98 |
/**
|
104 |
*
|
105 |
* @return void
|
106 |
*/
|
107 |
+
public function process(File $phpcsFile, $stackPtr)
|
108 |
{
|
109 |
if ($this->supportsAbove('5.3') === false) {
|
110 |
return;
|
124 |
|
125 |
// Check for static usage of class properties shadowing the removed global variables.
|
126 |
if ($this->inClassScope($phpcsFile, $stackPtr, false) === true) {
|
127 |
+
$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
128 |
+
if ($prevToken !== false && $tokens[$prevToken]['code'] === \T_DOUBLE_COLON) {
|
129 |
return;
|
130 |
}
|
131 |
}
|
142 |
'name' => $varName,
|
143 |
);
|
144 |
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
145 |
+
}
|
|
|
146 |
|
147 |
|
148 |
/**
|
196 |
*
|
197 |
* @return bool
|
198 |
*/
|
199 |
+
private function isTargetPHPErrormsgVar(File $phpcsFile, $stackPtr, array $tokens)
|
200 |
{
|
201 |
$scopeStart = 0;
|
202 |
|
203 |
/*
|
204 |
* If the variable is detected within the scope of a function/closure, limit the checking.
|
205 |
*/
|
206 |
+
$function = $phpcsFile->getCondition($stackPtr, \T_CLOSURE);
|
207 |
if ($function === false) {
|
208 |
+
$function = $phpcsFile->getCondition($stackPtr, \T_FUNCTION);
|
209 |
}
|
210 |
|
211 |
// It could also be a function param, which is not in the function scope.
|
213 |
$nestedParentheses = $tokens[$stackPtr]['nested_parenthesis'];
|
214 |
$parenthesisCloser = end($nestedParentheses);
|
215 |
if (isset($tokens[$parenthesisCloser]['parenthesis_owner'])
|
216 |
+
&& ($tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === \T_FUNCTION
|
217 |
+
|| $tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === \T_CLOSURE)
|
218 |
) {
|
219 |
$function = $tokens[$parenthesisCloser]['parenthesis_owner'];
|
220 |
}
|
227 |
/*
|
228 |
* Now, let's do some additional checks.
|
229 |
*/
|
230 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
// Is the variable being used as an array ?
|
233 |
+
if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === \T_OPEN_SQUARE_BRACKET) {
|
234 |
// The PHP native variable is a string, so this is probably not it
|
235 |
// (except for array access to string, but why would you in this case ?).
|
236 |
return false;
|
238 |
|
239 |
// Is this a variable assignment ?
|
240 |
if ($nextNonEmpty !== false
|
241 |
+
&& isset(Tokens::$assignmentTokens[$tokens[$nextNonEmpty]['code']]) === true
|
242 |
) {
|
243 |
return false;
|
244 |
}
|
246 |
// Is this a function param shadowing the PHP native one ?
|
247 |
if ($function !== false) {
|
248 |
$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $function);
|
249 |
+
if (\is_array($parameters) === true && empty($parameters) === false) {
|
250 |
foreach ($parameters as $param) {
|
251 |
if ($param['name'] === '$php_errormsg') {
|
252 |
return false;
|
266 |
|
267 |
// Walk back and see if there is an assignment to the variable within the same scope.
|
268 |
for ($i = ($stackPtr - 1); $i >= $scopeStart; $i--) {
|
269 |
+
if ($tokens[$i]['code'] === \T_CLOSE_CURLY_BRACKET
|
270 |
&& isset($tokens[$i]['scope_condition'])
|
271 |
&& isset($skipPast[$tokens[$tokens[$i]['scope_condition']]['type']])
|
272 |
) {
|
275 |
continue;
|
276 |
}
|
277 |
|
278 |
+
if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$php_errormsg') {
|
279 |
continue;
|
280 |
}
|
281 |
|
282 |
+
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
|
|
|
|
|
|
|
|
|
|
|
283 |
|
284 |
if ($nextNonEmpty !== false
|
285 |
+
&& isset(Tokens::$assignmentTokens[$tokens[$nextNonEmpty]['code']]) === true
|
286 |
) {
|
287 |
return false;
|
288 |
}
|
290 |
|
291 |
return true;
|
292 |
}
|
293 |
+
}
|
|
|
|
vendor/phpcompatibility/php-compatibility/phpunit-bootstrap.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Bootstrap file for tests.
|
4 |
+
*
|
5 |
+
* @package PHPCompatibility
|
6 |
+
*/
|
7 |
+
|
8 |
+
if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
|
9 |
+
define('PHP_CODESNIFFER_IN_TESTS', true);
|
10 |
+
}
|
11 |
+
|
12 |
+
// The below two defines are needed for PHPCS 3.x.
|
13 |
+
if (defined('PHP_CODESNIFFER_CBF') === false) {
|
14 |
+
define('PHP_CODESNIFFER_CBF', false);
|
15 |
+
}
|
16 |
+
|
17 |
+
if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
|
18 |
+
define('PHP_CODESNIFFER_VERBOSITY', 0);
|
19 |
+
}
|
20 |
+
|
21 |
+
$ds = DIRECTORY_SEPARATOR;
|
22 |
+
|
23 |
+
// Get the PHPCS dir from an environment variable.
|
24 |
+
$phpcsDir = getenv('PHPCS_DIR');
|
25 |
+
|
26 |
+
// This may be a Composer install.
|
27 |
+
if ($phpcsDir === false && is_dir(__DIR__ . $ds . 'vendor' . $ds . 'squizlabs' . $ds . 'php_codesniffer')) {
|
28 |
+
$vendorDir = __DIR__ . $ds . 'vendor';
|
29 |
+
$phpcsDir = $vendorDir . $ds . 'squizlabs' . $ds . 'php_codesniffer';
|
30 |
+
} elseif ($phpcsDir !== false) {
|
31 |
+
$phpcsDir = realpath($phpcsDir);
|
32 |
+
}
|
33 |
+
|
34 |
+
// Try and load the PHPCS autoloader.
|
35 |
+
if ($phpcsDir !== false && file_exists($phpcsDir . $ds . 'autoload.php')) {
|
36 |
+
// PHPCS 3.x.
|
37 |
+
require_once $phpcsDir . $ds . 'autoload.php';
|
38 |
+
|
39 |
+
/*
|
40 |
+
* Alias the PHPCS 3.x classes to their PHPCS 2.x equivalent if necessary.
|
41 |
+
* Also provide a custom autoloader for our abstract base classes as the PHPCS native autoloader
|
42 |
+
* has trouble with them in combination with the PHPCompatibility custom unit test suite.
|
43 |
+
*/
|
44 |
+
require_once __DIR__ . $ds . 'PHPCSAliases.php';
|
45 |
+
|
46 |
+
} elseif ($phpcsDir !== false && file_exists($phpcsDir . $ds . 'CodeSniffer.php')) {
|
47 |
+
// PHPCS 2.x.
|
48 |
+
require_once $phpcsDir . $ds . 'CodeSniffer.php';
|
49 |
+
|
50 |
+
if (isset($vendorDir) && file_exists($vendorDir . $ds . 'autoload.php')) {
|
51 |
+
require_once $vendorDir . $ds . 'autoload.php';
|
52 |
+
}
|
53 |
+
|
54 |
+
} else {
|
55 |
+
echo 'Uh oh... can\'t find PHPCS.
|
56 |
+
|
57 |
+
If you use Composer, please run `composer install --prefer-source`.
|
58 |
+
Otherwise, make sure you set a `PHPCS_DIR` environment variable in your phpunit.xml file
|
59 |
+
pointing to the PHPCS directory.
|
60 |
+
|
61 |
+
Please read the contributors guidelines for more information:
|
62 |
+
https://is.gd/PHPCompatibilityContrib
|
63 |
+
';
|
64 |
+
|
65 |
+
die(1);
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
// PHPUnit cross version compatibility.
|
70 |
+
if (class_exists('PHPUnit\Runner\Version')
|
71 |
+
&& version_compare(PHPUnit\Runner\Version::id(), '6.0', '>=')
|
72 |
+
&& class_exists('PHPUnit_Framework_TestCase') === false
|
73 |
+
) {
|
74 |
+
class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
|
75 |
+
}
|
76 |
+
|
77 |
+
require_once __DIR__ . $ds . 'PHPCompatibility' . $ds . 'Tests' . $ds . 'BaseSniffTest.php';
|
78 |
+
require_once __DIR__ . $ds . 'PHPCompatibility' . $ds . 'Util' . $ds . 'Tests' . $ds . 'CoreMethodTestFrame.php';
|
79 |
+
unset($ds, $phpcsDir, $vendorDir);
|
vendor/{wimg/php-compatibility → phpcompatibility/phpcompatibility-paragonie}/LICENSE
RENAMED
File without changes
|
vendor/phpcompatibility/phpcompatibility-paragonie/PHPCompatibilityParagonieRandomCompat/ruleset.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="PHPCompatibilityParagonieRandomCompat">
|
3 |
+
<description>PHPCompatibility ruleset for PHP_CodeSniffer which accounts for polyfills provided by the Paragonie random_compat library.</description>
|
4 |
+
|
5 |
+
<rule ref="PHPCompatibility">
|
6 |
+
<!-- https://github.com/paragonie/random_compat/blob/master/lib/random.php -->
|
7 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.php_version_idFound"/>
|
8 |
+
|
9 |
+
<!-- https://github.com/paragonie/random_compat/blob/master/lib/random_bytes_*.php -->
|
10 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_bytesFound"/>
|
11 |
+
|
12 |
+
<!-- https://github.com/paragonie/random_compat/blob/master/lib/random_int.php -->
|
13 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_intFound"/>
|
14 |
+
|
15 |
+
<!-- https://github.com/paragonie/random_compat/blob/master/lib/error_polyfill.php -->
|
16 |
+
<exclude name="PHPCompatibility.Classes.NewClasses.errorFound"/>
|
17 |
+
<exclude name="PHPCompatibility.Classes.NewClasses.typeerrorFound"/>
|
18 |
+
</rule>
|
19 |
+
|
20 |
+
<!-- Prevent false positives being thrown when run over the code of random_compat itself. -->
|
21 |
+
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated">
|
22 |
+
<exclude-pattern>/random_compat/lib/byte_safe_strings\.php$</exclude-pattern>
|
23 |
+
</rule>
|
24 |
+
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.stream_set_chunk_sizeFound">
|
25 |
+
<exclude-pattern>/random_compat/lib/random_bytes_dev_urandom\.php$</exclude-pattern>
|
26 |
+
</rule>
|
27 |
+
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_dev_urandomDeprecatedRemoved">
|
28 |
+
<exclude-pattern>/random_compat/lib/random_bytes_mcrypt\.php$</exclude-pattern>
|
29 |
+
</rule>
|
30 |
+
<rule ref="PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved">
|
31 |
+
<exclude-pattern>/random_compat/lib/random_bytes_mcrypt\.php$</exclude-pattern>
|
32 |
+
</rule>
|
33 |
+
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved">
|
34 |
+
<exclude-pattern>/random_compat/lib/random_bytes_mcrypt\.php$</exclude-pattern>
|
35 |
+
</rule>
|
36 |
+
<rule ref="PHPCompatibility.LanguageConstructs.NewLanguageConstructs.t_ns_separatorFound">
|
37 |
+
<exclude-pattern>/random_compat/lib/random_bytes_libsodium\.php$</exclude-pattern>
|
38 |
+
</rule>
|
39 |
+
|
40 |
+
</ruleset>
|
vendor/phpcompatibility/phpcompatibility-paragonie/PHPCompatibilityParagonieSodiumCompat/ruleset.xml
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="PHPCompatibilityParagonieSodiumCompat">
|
3 |
+
<description>PHPCompatibility ruleset for PHP_CodeSniffer which accounts for polyfills provided by the Paragonie sodium_compat library.</description>
|
4 |
+
|
5 |
+
<!--
|
6 |
+
Note: this ruleset does **not** contain excludes for the `sodium_pwhash()` and
|
7 |
+
the sodium_memzero() functions as, while those functions do exist in the polyfill,
|
8 |
+
they do not work and are explicitly excluded features.
|
9 |
+
See: https://github.com/paragonie/sodium_compat#features-excluded-from-this-polyfill
|
10 |
+
|
11 |
+
With that in mind, these functions should not be used in code which intends to be
|
12 |
+
PHP cross-version compatible.
|
13 |
+
-->
|
14 |
+
|
15 |
+
<!-- https://github.com/paragonie/sodium_compat/blob/master/composer.json -->
|
16 |
+
<rule ref="PHPCompatibilityParagonieRandomCompat"/>
|
17 |
+
|
18 |
+
<rule ref="PHPCompatibility">
|
19 |
+
<!-- https://github.com/paragonie/sodium_compat/blob/master/src/SodiumException.php -->
|
20 |
+
<exclude name="PHPCompatibility.Classes.NewClasses.sodiumexceptionFound"/>
|
21 |
+
|
22 |
+
<!-- https://github.com/paragonie/sodium_compat/blob/master/lib/php72compat.php -->
|
23 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_keybytesFound"/>
|
24 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_nsecbytesFound"/>
|
25 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_npubbytesFound"/>
|
26 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_abytesFound"/>
|
27 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_keybytesFound"/>
|
28 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_nsecbytesFound"/>
|
29 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_npubbytesFound"/>
|
30 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_abytesFound"/>
|
31 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_keybytesFound"/>
|
32 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_nsecbytesFound"/>
|
33 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_npubbytesFound"/>
|
34 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_abytesFound"/>
|
35 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_auth_bytesFound"/>
|
36 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_auth_keybytesFound"/>
|
37 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_sealbytesFound"/>
|
38 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_secretkeybytesFound"/>
|
39 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_publickeybytesFound"/>
|
40 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_keypairbytesFound"/>
|
41 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_macbytesFound"/>
|
42 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_noncebytesFound"/>
|
43 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_seedbytesFound"/>
|
44 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_bytesFound"/>
|
45 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_publickeybytesFound"/>
|
46 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_secretkeybytesFound"/>
|
47 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_seedbytesFound"/>
|
48 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_bytesFound"/>
|
49 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_bytes_minFound"/>
|
50 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_bytes_maxFound"/>
|
51 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_keybytesFound"/>
|
52 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_keybytes_minFound"/>
|
53 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_keybytes_maxFound"/>
|
54 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_saltbytesFound"/>
|
55 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_strprefixFound"/>
|
56 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_alg_argon2i13Found"/>
|
57 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_alg_argon2id13Found"/>
|
58 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_memlimit_interactiveFound"/>
|
59 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_opslimit_interactiveFound"/>
|
60 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_memlimit_moderateFound"/>
|
61 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_opslimit_moderateFound"/>
|
62 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_memlimit_sensitiveFound"/>
|
63 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_opslimit_sensitiveFound"/>
|
64 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_scalarmult_bytesFound"/>
|
65 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_scalarmult_scalarbytesFound"/>
|
66 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_shorthash_bytesFound"/>
|
67 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_shorthash_keybytesFound"/>
|
68 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_keybytesFound"/>
|
69 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_macbytesFound"/>
|
70 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_noncebytesFound"/>
|
71 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_sign_bytesFound"/>
|
72 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_sign_seedbytesFound"/>
|
73 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_sign_publickeybytesFound"/>
|
74 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_sign_secretkeybytesFound"/>
|
75 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_sign_keypairbytesFound"/>
|
76 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_stream_keybytesFound"/>
|
77 |
+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_stream_noncebytesFound"/>
|
78 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_bin2hexFound"/>
|
79 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_compareFound"/>
|
80 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_aes256gcm_decryptFound"/>
|
81 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_aes256gcm_encryptFound"/>
|
82 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_aes256gcm_is_availableFound"/>
|
83 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_chacha20poly1305_decryptFound"/>
|
84 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_chacha20poly1305_encryptFound"/>
|
85 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_chacha20poly1305_keygenFound"/>
|
86 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_chacha20poly1305_ietf_decryptFound"/>
|
87 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_chacha20poly1305_ietf_encryptFound"/>
|
88 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_chacha20poly1305_ietf_keygenFound"/>
|
89 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_xchacha20poly1305_ietf_decryptFound"/>
|
90 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_xchacha20poly1305_ietf_encryptFound"/>
|
91 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_aead_xchacha20poly1305_ietf_keygenFound"/>
|
92 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_authFound"/>
|
93 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_auth_keygenFound"/>
|
94 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_auth_verifyFound"/>
|
95 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_boxFound"/>
|
96 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_keypairFound"/>
|
97 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_keypair_from_secretkey_and_publickeyFound"/>
|
98 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_openFound"/>
|
99 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_publickeyFound"/>
|
100 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_publickey_from_secretkeyFound"/>
|
101 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_sealFound"/>
|
102 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_seal_openFound"/>
|
103 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_secretkeyFound"/>
|
104 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_box_seed_keypairFound"/>
|
105 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_generichashFound"/>
|
106 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_generichash_finalFound"/>
|
107 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_generichash_initFound"/>
|
108 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_generichash_keygenFound"/>
|
109 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_generichash_updateFound"/>
|
110 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_kxFound"/>
|
111 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_pwhash_strFound"/>
|
112 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_pwhash_str_verifyFound"/>
|
113 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_pwhash_scryptsalsa208sha256Found"/>
|
114 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_pwhash_scryptsalsa208sha256_strFound"/>
|
115 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_pwhash_scryptsalsa208sha256_str_verifyFound"/>
|
116 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_scalarmultFound"/>
|
117 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_scalarmult_baseFound"/>
|
118 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretboxFound"/>
|
119 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretbox_keygenFound"/>
|
120 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretbox_openFound"/>
|
121 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_shorthashFound"/>
|
122 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_shorthash_keygenFound"/>
|
123 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_signFound"/>
|
124 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_detachedFound"/>
|
125 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_keypairFound"/>
|
126 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_openFound"/>
|
127 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_publickeyFound"/>
|
128 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_publickey_from_secretkeyFound"/>
|
129 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_secretkeyFound"/>
|
130 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_seed_keypairFound"/>
|
131 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_verify_detachedFound"/>
|
132 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_ed25519_pk_to_curve25519Found"/>
|
133 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_ed25519_sk_to_curve25519Found"/>
|
134 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_streamFound"/>
|
135 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_stream_keygenFound"/>
|
136 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_stream_xorFound"/>
|
137 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_hex2binFound"/>
|
138 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_incrementFound"/>
|
139 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_library_version_majorFound"/>
|
140 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_library_version_minorFound"/>
|
141 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_version_stringFound"/>
|
142 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_memcmpFound"/>
|
143 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_randombytes_bufFound"/>
|
144 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_randombytes_uniformFound"/>
|
145 |
+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_randombytes_random16Found"/>
|
146 |
+
</rule>
|
147 |
+
|
148 |
+
</ruleset>
|
vendor/phpcompatibility/phpcompatibility-paragonie/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[![Latest Stable Version](https://poser.pugx.org/phpcompatibility/phpcompatibility-paragonie/v/stable.png)](https://packagist.org/packages/phpcompatibility/phpcompatibility-paragonie)
|
2 |
+
[![Latest Unstable Version](https://poser.pugx.org/phpcompatibility/phpcompatibility-paragonie/v/unstable.png)](https://packagist.org/packages/phpcompatibility/phpcompatibility-paragonie)
|
3 |
+
[![License](https://poser.pugx.org/phpcompatibility/phpcompatibility-paragonie/license.png)](https://github.com/PHPCompatibility/PHPCompatibilityParagonie/blob/master/LICENSE)
|
4 |
+
[![Build Status](https://travis-ci.org/PHPCompatibility/PHPCompatibilityParagonie.svg?branch=master)](https://travis-ci.org/PHPCompatibility/PHPCompatibilityParagonie)
|
5 |
+
|
6 |
+
# PHPCompatibilityParagonie
|
7 |
+
|
8 |
+
Using PHPCompatibilityParagonie, you can analyse the codebase of a project using either of the Paragonie polyfills, for PHP cross-version compatibility.
|
9 |
+
|
10 |
+
|
11 |
+
## What's in this repo ?
|
12 |
+
|
13 |
+
Two rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.
|
14 |
+
|
15 |
+
These rulesets prevent false positives from the [PHPCompatibility standard](https://github.com/PHPCompatibility/PHPCompatibility) by excluding back-fills and poly-fills which are provided by those libraries.
|
16 |
+
|
17 |
+
Paragonie Polyfill Library | Corresponding PHPCompatibility Ruleset | Includes
|
18 |
+
--- | --- | ---
|
19 |
+
[`random_compat`](https://github.com/paragonie/random_compat) | `PHPCompatibilityParagonieRandomCompat`
|
20 |
+
[`sodium_compat`](https://github.com/paragonie/sodium_compat) | `PHPCompatibilityParagonieSodiumCompat` | `PHPCompatibilityParagonieRandomCompat`
|
21 |
+
|
22 |
+
> Note:
|
23 |
+
> As the `sodium_compat` library has `random_compat` [as a dependency](https://github.com/paragonie/sodium_compat/blob/master/composer.json), the `PHPCompatibilityParagonieSodiumCompat` ruleset includes the `PHPCompatibilityParagonieRandomCompat` ruleset.
|
24 |
+
>
|
25 |
+
> In practice, this means that if your project uses both libraries, you just need to use the `PHPCompatibilityParagonieSodiumCompat` ruleset to prevent false positives from both.
|
26 |
+
|
27 |
+
|
28 |
+
## Requirements
|
29 |
+
|
30 |
+
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
|
31 |
+
* PHP 5.3+ for use with [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) 2.3.0+.
|
32 |
+
* PHP 5.4+ for use with [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) 3.0.2+.
|
33 |
+
|
34 |
+
Use the latest stable release of PHP_CodeSniffer for the best results.
|
35 |
+
The minimum _recommended_ version of PHP_CodeSniffer is version 2.6.0.
|
36 |
+
* [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) 9.0.0+.
|
37 |
+
|
38 |
+
|
39 |
+
## Installation instructions
|
40 |
+
|
41 |
+
The only supported installation method is via [Composer](https://getcomposer.org/).
|
42 |
+
|
43 |
+
If you don't have a Composer plugin installed to manage the `installed_paths` setting for PHP_CodeSniffer, run the following from the command-line:
|
44 |
+
```bash
|
45 |
+
composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.4.4 phpcompatibility/phpcompatibility-paragonie:*
|
46 |
+
composer install
|
47 |
+
```
|
48 |
+
|
49 |
+
If you already have a Composer PHP_CodeSniffer plugin installed, run:
|
50 |
+
```bash
|
51 |
+
composer require --dev phpcompatibility/phpcompatibility-paragonie:*
|
52 |
+
composer install
|
53 |
+
```
|
54 |
+
|
55 |
+
Next, run:
|
56 |
+
```bash
|
57 |
+
vendor/bin/phpcs -i
|
58 |
+
```
|
59 |
+
If all went well, you will now see that the `PHPCompatibility`, `PHPCompatibilityParagonieRandomCompat` and `PHPCompatibilityParagonieSodiumCompat` standards are installed for PHP_CodeSniffer.
|
60 |
+
|
61 |
+
|
62 |
+
## How to use
|
63 |
+
|
64 |
+
Now you can use the following commands to inspect the code in your project for PHP cross-version compatibility:
|
65 |
+
```bash
|
66 |
+
./vendor/bin/phpcs -p . --standard=PHPCompatibilityParagonieRandomCompat
|
67 |
+
|
68 |
+
./vendor/bin/phpcs -p . --standard=PHPCompatibilityParagonieSodiumCompat
|
69 |
+
```
|
70 |
+
|
71 |
+
By default, you will only receive notifications about deprecated and/or removed PHP features.
|
72 |
+
|
73 |
+
To get the most out of the PHPCompatibilityParagonie rulesets, you should specify a `testVersion` to check against. That will enable the checks for both deprecated/removed PHP features as well as the detection of code using new PHP features.
|
74 |
+
|
75 |
+
For example:
|
76 |
+
```bash
|
77 |
+
# For a project which should be compatible with PHP 5.3 up to and including PHP 7.0:
|
78 |
+
./vendor/bin/phpcs -p . --standard=PHPCompatibilityParagonieRandomCompat --runtime-set testVersion 5.3-7.0
|
79 |
+
|
80 |
+
# For a project which should be compatible with PHP 5.4 and higher:
|
81 |
+
./vendor/bin/phpcs -p . --standard=PHPCompatibilityParagonieSodiumCompat --runtime-set testVersion 5.4-
|
82 |
+
```
|
83 |
+
|
84 |
+
For more detailed information about setting the `testVersion`, see the README of the generic [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions) standard.
|
85 |
+
|
86 |
+
|
87 |
+
### Testing PHP files only
|
88 |
+
|
89 |
+
By default PHP_CodeSniffer will analyse PHP, JavaScript and CSS files. As the PHPCompatibility sniffs only target PHP code, you can make the run slightly faster by telling PHP_CodeSniffer to only check PHP files, like so:
|
90 |
+
```bash
|
91 |
+
./vendor/bin/phpcs -p . --standard=PHPCompatibilityParagonieRandomCompat --extensions=php --runtime-set testVersion 5.3-
|
92 |
+
```
|
93 |
+
|
94 |
+
## License
|
95 |
+
|
96 |
+
All code within the PHPCompatibility organisation is released under the GNU Lesser General Public License (LGPL). For more information, visit https://www.gnu.org/copyleft/lesser.html
|
97 |
+
|
98 |
+
|
99 |
+
## Changelog
|
100 |
+
|
101 |
+
### 1.0.1 - 2018-12-16
|
102 |
+
|
103 |
+
* Prevent false positives when the ruleset is run over the code of the `RandomCompat` polyfill itself.
|
104 |
+
* The rulesets are now also tested against PHP 7.3.
|
105 |
+
Note: full PHP 7.3 support is only available in combination with PHP_CodeSniffer 2.9.2 or 3.3.1+ due to an incompatibility within PHP_CodeSniffer itself.
|
106 |
+
|
107 |
+
### 1.0.0 - 2018-10-07
|
108 |
+
|
109 |
+
Initial release of PHPCompatibilityParagonie containing rulesets covering the `random_compat` and `sodium_compat` polyfill libraries.
|
vendor/phpcompatibility/phpcompatibility-paragonie/composer.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name" : "phpcompatibility/phpcompatibility-paragonie",
|
3 |
+
"description" : "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.",
|
4 |
+
"type" : "phpcodesniffer-standard",
|
5 |
+
"keywords" : [ "compatibility", "phpcs", "standards", "paragonie", "polyfill" ],
|
6 |
+
"homepage" : "http://phpcompatibility.com/",
|
7 |
+
"license" : "LGPL-3.0-or-later",
|
8 |
+
"authors" : [ {
|
9 |
+
"name" : "Wim Godden",
|
10 |
+
"role" : "lead"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"name" : "Juliette Reinders Folmer",
|
14 |
+
"role" : "lead"
|
15 |
+
} ],
|
16 |
+
"support" : {
|
17 |
+
"issues" : "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues",
|
18 |
+
"source" : "https://github.com/PHPCompatibility/PHPCompatibilityParagonie"
|
19 |
+
},
|
20 |
+
"require" : {
|
21 |
+
"phpcompatibility/php-compatibility" : "^9.0"
|
22 |
+
},
|
23 |
+
"require-dev" : {
|
24 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4"
|
25 |
+
},
|
26 |
+
"suggest" : {
|
27 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
|
28 |
+
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
|
29 |
+
},
|
30 |
+
"prefer-stable" : true
|
31 |
+
}
|
vendor/simplyadmire/composer-plugins/Configuration/Settings.yaml
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
TYPO3:
|
2 |
-
Flow:
|
3 |
-
object:
|
4 |
-
excludeClasses:
|
5 |
-
'simplyadmire.composerplugins': ['.*']
|
|
|
|
|
|
|
|
|
|
vendor/simplyadmire/composer-plugins/LICENSE
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
GNU LESSER GENERAL PUBLIC LICENSE
|
2 |
-
Version 3, 29 June 2007
|
3 |
-
|
4 |
-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
-
|
6 |
-
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
7 |
-
|
8 |
-
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
9 |
-
|
10 |
-
0. Additional Definitions.
|
11 |
-
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
12 |
-
|
13 |
-
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
14 |
-
|
15 |
-
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
16 |
-
|
17 |
-
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
18 |
-
|
19 |
-
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
20 |
-
|
21 |
-
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
22 |
-
|
23 |
-
1. Exception to Section 3 of the GNU GPL.
|
24 |
-
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
25 |
-
|
26 |
-
2. Conveying Modified Versions.
|
27 |
-
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
28 |
-
|
29 |
-
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
30 |
-
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
31 |
-
3. Object Code Incorporating Material from Library Header Files.
|
32 |
-
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
33 |
-
|
34 |
-
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
35 |
-
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
36 |
-
4. Combined Works.
|
37 |
-
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
38 |
-
|
39 |
-
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
40 |
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
41 |
-
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
42 |
-
d) Do one of the following:
|
43 |
-
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
44 |
-
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
45 |
-
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
46 |
-
5. Combined Libraries.
|
47 |
-
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
48 |
-
|
49 |
-
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
50 |
-
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
51 |
-
6. Revised Versions of the GNU Lesser General Public License.
|
52 |
-
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
53 |
-
|
54 |
-
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
55 |
-
|
56 |
-
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/simplyadmire/composer-plugins/README.md
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
Composer Plugins
|
2 |
-
================
|
3 |
-
|
4 |
-
A collection of composer plugins for specific installation instruction
|
5 |
-
for composer packages.
|
6 |
-
|
7 |
-
Important: if you are running on Flow 3+ and have the typo3/ci-flow package installed
|
8 |
-
using your main distributions composer.json you should remove it there and install
|
9 |
-
the codesniffer in a separate folder, like for example: https://git.typo3.org/Neos/Distributions/Base.git/tree/refs/heads/master:/Build/PhpCodesniffer
|
10 |
-
|
11 |
-
PHP Codesniffer Standard installer
|
12 |
-
----------------------------------
|
13 |
-
|
14 |
-
The PHP Codesniffer Standard installer is able to install phpcs codesniffer
|
15 |
-
standards into the `<vendor>/squizlabs/php_codesniffer/CodeSniffer/Standards/`
|
16 |
-
folder. By doing so the standard will be usable by calling `bin/phpcs --standard <standard>`.
|
17 |
-
|
18 |
-
### How To Use
|
19 |
-
|
20 |
-
* Find the package containing the codesniffs you want to use. This package should be
|
21 |
-
a normal Codesniffing package containing a `ruleset.xml` and a `composer.json`.
|
22 |
-
* The composer package type has to be `phpcodesniffer-standard`
|
23 |
-
* The name of the package has to reflect the name of the standard (explained below)
|
24 |
-
* It's best if the package has a requirement to `simplyadmire/composer-plugins`. This
|
25 |
-
is the only way to be sure the installer is available before the package is installed.
|
26 |
-
* Now add the package as a development dependency to your project
|
27 |
-
* Run `bin/phpcs -i` and see your standard listed
|
28 |
-
|
29 |
-
### Naming Rules
|
30 |
-
|
31 |
-
The name of the standard is derived from the composer packagekey. The part after the `/`
|
32 |
-
is taken as standard name. The first character is made uppercase, and all characters after
|
33 |
-
a `-` will be uppercased. So:
|
34 |
-
|
35 |
-
* `vendor/mysniffs` becomes `Mysniffs`
|
36 |
-
* `vendor/some-more-words` becomes `SomeMoreWords`
|
37 |
-
|
38 |
-
TYPO3 Specific
|
39 |
-
--------------
|
40 |
-
|
41 |
-
The TYPO3 community already has packages available on packagist, and as renaming packagenames
|
42 |
-
would be a bad practice we added 3 hardcoded standard names. Also the vendor name `TYPO3` will
|
43 |
-
always be enforced to be uppercase.
|
44 |
-
|
45 |
-
To include the TYPO3 CGL to your project you can use one of the following commands (depending
|
46 |
-
on the CGL you want to use, TYPO3 Flow or TYPO3 CMS):
|
47 |
-
|
48 |
-
TYPO3 Flow:
|
49 |
-
```
|
50 |
-
composer require --dev typo3-ci/typo3flow=dev-master
|
51 |
-
```
|
52 |
-
|
53 |
-
TYPO3 CMS:
|
54 |
-
```
|
55 |
-
composer require --dev typo3-ci/typo3cms=dev-master
|
56 |
-
```
|
57 |
-
|
58 |
-
Now you can sniff your packages with for example:
|
59 |
-
|
60 |
-
```
|
61 |
-
bin/phpcs --extensions=php --standard=TYPO3Flow Packages/Application/My.Package
|
62 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/simplyadmire/composer-plugins/SimplyAdmire/ComposerPlugins/Installers/PhpCodesnifferStandardInstaller.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace SimplyAdmire\ComposerPlugins\Installers;
|
3 |
-
|
4 |
-
use Composer\Package\PackageInterface;
|
5 |
-
use Composer\Installer\LibraryInstaller;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* This installer installs code sniffing standards in the Standards/ folder
|
9 |
-
* of the squizlabs/php_codesniffer package
|
10 |
-
*/
|
11 |
-
class PhpCodesnifferStandardInstaller extends LibraryInstaller {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @param PackageInterface $package
|
15 |
-
* @return string
|
16 |
-
*/
|
17 |
-
protected function getPackageBasePath(PackageInterface $package) {
|
18 |
-
$this->initializeVendorDir();
|
19 |
-
|
20 |
-
$targetPath = $this->vendorDir ? $this->vendorDir . '/' : '';
|
21 |
-
|
22 |
-
$codeSnifferStandardsPathParts = array('squizlabs', 'php_codesniffer', 'CodeSniffer', 'Standards');
|
23 |
-
$targetPath .= implode(DIRECTORY_SEPARATOR, $codeSnifferStandardsPathParts) . DIRECTORY_SEPARATOR;
|
24 |
-
|
25 |
-
$packageKeyParts = explode('/', $package->getPrettyName(), 2);
|
26 |
-
|
27 |
-
$codeStandardName = str_replace('Typo3', 'TYPO3', ucfirst($packageKeyParts[1]));
|
28 |
-
$codeStandardName = preg_replace_callback('/-([a-z]{1})/', function($matches) { return strtoupper($matches[1]); }, $codeStandardName);
|
29 |
-
|
30 |
-
// Fixed mapping for TYPO3 codesniffers
|
31 |
-
$codeStandardName = str_replace('TYPO3sniffpool', 'TYPO3SniffPool', $codeStandardName);
|
32 |
-
$codeStandardName = str_replace('TYPO3cms', 'TYPO3CMS', $codeStandardName);
|
33 |
-
$codeStandardName = str_replace('TYPO3flow', 'TYPO3Flow', $codeStandardName);
|
34 |
-
|
35 |
-
// Fixed mapping for PrestaShop coding standard
|
36 |
-
$codeStandardName = str_replace('PrestashopCodingstandard', 'Prestashop', $codeStandardName);
|
37 |
-
|
38 |
-
return $targetPath . $codeStandardName;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param string $packageType
|
43 |
-
* @return boolean
|
44 |
-
*/
|
45 |
-
public function supports($packageType) {
|
46 |
-
return $packageType === 'phpcodesniffer-standard';
|
47 |
-
}
|
48 |
-
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/simplyadmire/composer-plugins/SimplyAdmire/ComposerPlugins/PhpCodesnifferStandardInstallerPlugin.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace SimplyAdmire\ComposerPlugins;
|
3 |
-
|
4 |
-
use Composer\Composer;
|
5 |
-
use Composer\IO\IOInterface;
|
6 |
-
use Composer\Plugin\PluginInterface;
|
7 |
-
use SimplyAdmire\ComposerPlugins\Installers\PhpCodesnifferStandardInstaller;
|
8 |
-
|
9 |
-
class PhpCodesnifferStandardInstallerPlugin implements PluginInterface {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @param Composer $composer
|
13 |
-
* @param IOInterface $io
|
14 |
-
* @return void
|
15 |
-
*/
|
16 |
-
public function activate(Composer $composer, IOInterface $io) {
|
17 |
-
$installer = new PhpCodesnifferStandardInstaller($io, $composer);
|
18 |
-
$composer->getInstallationManager()->addInstaller($installer);
|
19 |
-
}
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/squizlabs/php_codesniffer/CodeSniffer.conf
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
$phpCodeSnifferConfig = array (
|
3 |
-
'installed_paths' => '../../phpcompatibility/php-compatibility/,../../phpcompatibility/phpcompatibility-wp/',
|
4 |
)
|
5 |
?>
|
1 |
<?php
|
2 |
$phpCodeSnifferConfig = array (
|
3 |
+
'installed_paths' => '../../phpcompatibility/php-compatibility/,../../phpcompatibility/phpcompatibility-wp/,../../phpcompatibility/phpcompatibility-paragonie/',
|
4 |
)
|
5 |
?>
|
vendor/wimg/php-compatibility/CHANGELOG.md
DELETED
@@ -1,899 +0,0 @@
|
|
1 |
-
# Change Log for the PHPCompatibility standard for PHP Codesniffer
|
2 |
-
|
3 |
-
All notable changes to this project will be documented in this file.
|
4 |
-
|
5 |
-
This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
6 |
-
|
7 |
-
Up to version 8.0.0, the `major.minor` version numbers were based on the PHP version for which compatibility check support was added, with `patch` version numbers being specific to this library.
|
8 |
-
From version 8.0.0 onwards, [Semantic Versioning](http://semver.org/) is used.
|
9 |
-
|
10 |
-
**IMPORTANT**: The 8.0.0 release contains a **breaking change**. Please read the v [8.0.0 changelog](CHANGELOG.md#800---2017-08-03) carefully before upgrading.
|
11 |
-
|
12 |
-
|
13 |
-
## [Unreleased]
|
14 |
-
|
15 |
-
_Nothing yet._
|
16 |
-
|
17 |
-
|
18 |
-
## [8.1.0] - 2017-12-27
|
19 |
-
|
20 |
-
See all related issues and PRs in the [8.1.0 milestone].
|
21 |
-
|
22 |
-
### Added
|
23 |
-
- :star2: New `NewConstants` and `RemovedConstants` sniffs to detect usage of new/removed PHP constants for all PHP versions from PHP 5 up. [#526](https://github.com/wimg/PHPCompatibility/pull/525), [#551](https://github.com/wimg/PHPCompatibility/pull/551), [#566](https://github.com/wimg/PHPCompatibility/pull/566). Fixes [#263](https://github.com/wimg/PHPCompatibility/issues/263).
|
24 |
-
- :star2: New `MagicAutoloadDeprecation` sniff to detect deprecated `__autoload()` functions as deprecated in PHP 7.2. [#540](https://github.com/wimg/PHPCompatibility/pull/540)
|
25 |
-
- :star2: New `OptionalRequiredFunctionParameter` sniff to check for missing function call parameters which were required and only became optional in a later PHP version. [#524](https://github.com/wimg/PHPCompatibility/pull/524)
|
26 |
-
- :star2: New `DynamicAccessToStatic` sniff to detect dynamic access to static methods and properties, as well as class constants, prior to PHP 5.3. [#535](https://github.com/wimg/PHPCompatibility/pull/535). Fixes [#534](https://github.com/wimg/PHPCompatibility/issues/534).
|
27 |
-
- :star: `DeprecatedFunctions` sniff: recognize yet more PHP 7.2 deprecated functions. [#561](https://github.com/wimg/PHPCompatibility/pull/561), [#566](https://github.com/wimg/PHPCompatibility/pull/566)
|
28 |
-
- :star: `DeprecatedIniDirectives` sniff: recognize the last of the PHP 7.2 deprecated ini directives. [#566](https://github.com/wimg/PHPCompatibility/pull/566), [#567](https://github.com/wimg/PHPCompatibility/pull/567)
|
29 |
-
- :star: `NewFunctions` : detection of all new PHP 7.2 functions added. [#522](https://github.com/wimg/PHPCompatibility/pull/522), [#545](https://github.com/wimg/PHPCompatibility/pull/545), [#551](https://github.com/wimg/PHPCompatibility/pull/551), [#565](https://github.com/wimg/PHPCompatibility/pull/565)
|
30 |
-
- :star: `RemovedExtensions` : report on usage of the `mcrypt` extension which has been removed in PHP 7.2. [#566](https://github.com/wimg/PHPCompatibility/pull/566)
|
31 |
-
- :star: `RemovedGlobalVariables` : detection of the use of `$php_errormsg` with `track_errors` which has been deprecated in PHP 7.2. [#528](https://github.com/wimg/PHPCompatibility/pull/528)
|
32 |
-
- :books: Documentation : added reporting usage instructions. [#533](https://github.com/wimg/PHPCompatibility/pull/533), [#552](https://github.com/wimg/PHPCompatibility/pull/552)
|
33 |
-
|
34 |
-
### Changed
|
35 |
-
- :pushpin: `NewClosures` : downgraded "$this found in closure outside class" to warning. [#536](https://github.com/wimg/PHPCompatibility/pull/535). Fixes [#527](https://github.com/wimg/PHPCompatibility/issues/527).
|
36 |
-
- :pushpin: `ForbiddenGlobalVariableVariable` : the sniff will now throw an error for each variable in a `global` statement which is no longer supported and show the variable found to make it easier to fix this. Previously only one error would be thrown per `global` statement. [#564](https://github.com/wimg/PHPCompatibility/pull/564)
|
37 |
-
- :pushpin: `ForbiddenGlobalVariableVariable` : the sniff will now throw `warning`s for non-bare variables used in a `global` statement as those are discouraged since PHP 7.0. [#564](https://github.com/wimg/PHPCompatibility/pull/564)
|
38 |
-
- :rewind: `NewLanguageConstructs` : updated the version number for `T_COALESCE_EQUAL`. [#523](https://github.com/wimg/PHPCompatibility/pull/523)
|
39 |
-
- :pencil2: `Sniff::getTestVersion()` : simplified regex logic. [#520](https://github.com/wimg/PHPCompatibility/pull/520)
|
40 |
-
- :green_heart: Travis : build tests are now being run against PHP 7.2 as well. [#511](https://github.com/wimg/PHPCompatibility/pull/511)
|
41 |
-
- :wrench: Improved check for superfluous whitespaces in files. [#542](https://github.com/wimg/PHPCompatibility/pull/542)
|
42 |
-
- :wrench: Build/PHPCS : stabilized the exclude patterns. [#529](https://github.com/wimg/PHPCompatibility/pull/529)
|
43 |
-
- :wrench: Build/PHPCS : added array indentation check. [#538](https://github.com/wimg/PHPCompatibility/pull/538)
|
44 |
-
- :white_check_mark: PHPCS cross-version compatibility : sync `FindExtendedClassname()` method with upstream. [#507](https://github.com/wimg/PHPCompatibility/pull/507)
|
45 |
-
- :wrench: The minimum version for the recommended `DealerDirect/phpcodesniffer-composer-installer` Composer plugin has been upped to `0.4.3`. [#548](https://github.com/wimg/PHPCompatibility/pull/548)
|
46 |
-
|
47 |
-
### Fixed
|
48 |
-
- :bug: `ForbiddenCallTimePassByReference` : a false positive was being thrown when a global constant was followed by a _bitwise and_. [#562](https://github.com/wimg/PHPCompatibility/pull/562). Fixes [#39](https://github.com/wimg/PHPCompatibility/issues/39).
|
49 |
-
- :bug: `ForbiddenGlobalVariableVariable` : the sniff was overzealous and would also report on `global` in combination with variable variables which are still supported. [#564](https://github.com/wimg/PHPCompatibility/pull/564). Fixes [#537](https://github.com/wimg/PHPCompatibility/issues/537).
|
50 |
-
- :bug: `ForbiddenGlobalVariableVariable` : variables interspersed with whitespace and/or comments were not being reported. [#564](https://github.com/wimg/PHPCompatibility/pull/564)
|
51 |
-
- :rewind: `ForbiddenNamesAsInvokedFunctions` : improved recognition of function invocations using forbidden words and prevent warnings for keywords which are no longer forbidden as method names in PHP 7.0+. [#516](https://github.com/wimg/PHPCompatibility/pull/516). Fixes [#515](https://github.com/wimg/PHPCompatibility/issues/515)
|
52 |
-
- :bug: `VariableVariables` : variables interspersed with whitespace and/or comments were not being reported. [#563](https://github.com/wimg/PHPCompatibility/pull/563)
|
53 |
-
- :umbrella: Fixed some unintentional syntax errors in test files. [#539](https://github.com/wimg/PHPCompatibility/pull/539)
|
54 |
-
- :umbrella: Tests : fixed case numbering error. [#525](https://github.com/wimg/PHPCompatibility/pull/525)
|
55 |
-
- :books: Tests : added missing test skip explanation. [#521](https://github.com/wimg/PHPCompatibility/pull/521)
|
56 |
-
- :wrench: Fixed PHPCS whitespaces. [#543](https://github.com/wimg/PHPCompatibility/pull/543)
|
57 |
-
- :wrench: Fixed code test coverage verification. [#550](https://github.com/wimg/PHPCompatibility/pull/550). Fixes [#549](https://github.com/wimg/PHPCompatibility/issues/549).
|
58 |
-
|
59 |
-
### Credits
|
60 |
-
Thanks go out to [Juliette Reinders Folmer] and [Jonathan Van Belle] for their contributions to this version. :clap:
|
61 |
-
|
62 |
-
|
63 |
-
## [8.0.1] - 2017-08-07
|
64 |
-
|
65 |
-
See all related issues and PRs in the [8.0.1 milestone].
|
66 |
-
|
67 |
-
### Added
|
68 |
-
- :star2: New `DeprecatedTypeCasts` sniff to detect deprecated and removed type casts, such as the `(unset)` type cast as deprecated in PHP 7.2. [#498](https://github.com/wimg/PHPCompatibility/pull/498)
|
69 |
-
- :star2: New `NewTypeCasts` sniff to detect type casts not present in older PHP versions such as the `(binary)` type cast as added in PHP 5.2.1. [#497](https://github.com/wimg/PHPCompatibility/pull/497)
|
70 |
-
- :star: `NewGroupUseDeclaration`: Detection of PHP 7.2 trailing comma's in group use statements. [#504](https://github.com/wimg/PHPCompatibility/pull/504)
|
71 |
-
- :star: `DeprecatedFunctions` sniff: recognize some more PHP 7.2 deprecated functions. [#501](https://github.com/wimg/PHPCompatibility/pull/501)
|
72 |
-
- :star: `DeprecatedIniDirectives` sniff: recognize more PHP 7.2 deprecated ini directives. [#500](https://github.com/wimg/PHPCompatibility/pull/500)
|
73 |
-
- :star: `ForbiddenNames` sniff: recognize `object` as a forbidden keyword since PHP 7.2. [#499](https://github.com/wimg/PHPCompatibility/pull/499)
|
74 |
-
- :star: `NewReturnTypeDeclarations` sniff: recognize generic `parent`, PHP 7.1 `iterable` and PHP 7.2 `object` return type declarations. [#505](https://github.com/wimg/PHPCompatibility/pull/505), [#499](https://github.com/wimg/PHPCompatibility/pull/499)
|
75 |
-
- :star: `NewScalarTypeDeclarations` sniff: recognize PHP 7.2 `object` type declarion. [#499](https://github.com/wimg/PHPCompatibility/pull/499)
|
76 |
-
|
77 |
-
### Changed
|
78 |
-
:pencil2: Improved clarity of the deprecated functions alternative in the error message. [#502](https://github.com/wimg/PHPCompatibility/pull/502)
|
79 |
-
|
80 |
-
### Fixed
|
81 |
-
:fire_engine: Temporary hotfix for installed_paths (pending [upstream fix](https://github.com/squizlabs/PHP_CodeSniffer/issues/1591).) [#503](https://github.com/wimg/PHPCompatibility/pull/503)
|
82 |
-
|
83 |
-
### Credits
|
84 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
## [8.0.0] - 2017-08-03
|
89 |
-
|
90 |
-
**IMPORTANT**: This release contains a **breaking change**. Please read the below information carefully before upgrading!
|
91 |
-
|
92 |
-
The directory layout of the PHPCompatibility standard has been changed for improved compatibility with Composer.
|
93 |
-
This means that the PHPCompatibility standard no longer extends from the root directory of the repository, but now lives in its own subdirectory `/PHPCompatibility`.
|
94 |
-
|
95 |
-
This release also bring compatibility with PHPCS 3.x to the PHPCompatibility standard.
|
96 |
-
|
97 |
-
There are two things you will need to be aware of:
|
98 |
-
* The path to the PHPCompatibility standard has changed.
|
99 |
-
* If you intend to upgrade to PHPCS 3.x, the path to the `phpcs` script has changed (upstream change).
|
100 |
-
|
101 |
-
Please follow the below upgrade instructions carefully. This should be a one-time only action.
|
102 |
-
|
103 |
-
### Upgrade instructions
|
104 |
-
|
105 |
-
### Before upgrading
|
106 |
-
|
107 |
-
If you had previously made accommodations for the old directory layout, you should remove any such _"hacks"_ (meant in the kindest of ways) now.
|
108 |
-
|
109 |
-
By this we mean: symlinks for the PHPCompatibility install to the `PHP_CodeSniffer/CodeSniffer/Standards` directory, scripts to move the sniffs files to the PHPCS directory, scripts which made symlinks etc.
|
110 |
-
|
111 |
-
So, please remove those first.
|
112 |
-
|
113 |
-
> **Side-note**:
|
114 |
-
>
|
115 |
-
> If you had previously forked this repository to solve this issue, please consider reverting your fork to the official version or removing it all together.
|
116 |
-
|
117 |
-
### Upgrading: re-registering PHPCompatibility with PHP CodeSniffer
|
118 |
-
|
119 |
-
External PHP CodeSniffer standards need to be registered with PHP CodeSniffer. You have probably done this the first time you used PHPCompatibility or have a script or Composer plugin in place to do this for you.
|
120 |
-
|
121 |
-
As the directory layout of PHPCompatibility has changed, the path previously registered with PHP CodeSniffer will no longer work and running `phpcs -i` will **_not_** list PHPCompatibility as one of the registered standards.
|
122 |
-
|
123 |
-
#### Using a Composer plugin
|
124 |
-
|
125 |
-
If you use Composer, we recommend you use a Composer plugin to sort this out. In previous install instructions we recommended the SimplyAdmin plugin for this. This plugin has since been abandoned. We now recommend the DealerDirect plugin.
|
126 |
-
```bash
|
127 |
-
composer remove --dev simplyadmire/composer-plugins
|
128 |
-
composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.4.3
|
129 |
-
composer install
|
130 |
-
composer update wimg/php-compatibility squizlabs/php_codesniffer
|
131 |
-
vendor/bin/phpcs -i
|
132 |
-
```
|
133 |
-
If all went well, you should now see PHPCompatibility listed again in the list of installed standards.
|
134 |
-
|
135 |
-
#### Manually re-registering PHPCompatibility
|
136 |
-
|
137 |
-
1. First run `phpcs --config-show` to check which path(s) are currently registered with PHP CodeSniffer for external standards.
|
138 |
-
2. Check in the below table what the new path for PHPCompatibility will be - the path should point to the root directory of your PHPCompatibility install (not to the sub-directory of the same name):
|
139 |
-
|
140 |
-
Install type | Old path | New path
|
141 |
-
------------ | -------- | ---------
|
142 |
-
Composer | `vendor/wimg` | `vendor/wimg/php-compatibility`
|
143 |
-
Unzipped release to arbitrary directory | `path/to/dir/abovePHPCompatibility` | `path/to/dir/abovePHPCompatibility/PHPCompatibility`
|
144 |
-
Git checkout | `path/to/dir/abovePHPCompatibility` | `path/to/dir/abovePHPCompatibility/PHPCompatibility`
|
145 |
-
PEAR | If the old install instruction has been followed, not registered. | `path/to/PHPCompatibility`
|
146 |
-
|
147 |
-
> **Side-note**:
|
148 |
-
>
|
149 |
-
> If you used the old install instructions for a PEAR install, i.e. checking out the latest release to the `PHP/CodeSniffer/Standards/PHPCompatibility` directory, and you intend to upgrade to PHP CodeSniffer 3.x, it is recommended you move the PHPCompatibility folder out of the PEAR directory now, as the layout of the PHPCS directory has changed with PHPCS 3.x and you may otherwise lose your PHPCompatibility install when you upgrade PHP CodeSniffer via PEAR.
|
150 |
-
|
151 |
-
3. There are two ways in which you can register the new `installed_paths` value with PHP CodeSniffer. Choose your preferred method:
|
152 |
-
* Run `phpcs --config-set installed_paths ...` and include all previously installed paths including the _adjusted_ path for the PHPCompatibility standard.
|
153 |
-
|
154 |
-
For example, if the previous value of `installed_paths` was
|
155 |
-
|
156 |
-
`/path/to/MyStandard,/path/to/dir/abovePHPCompatibility`
|
157 |
-
|
158 |
-
you should now set it using
|
159 |
-
|
160 |
-
`phpcs --config-set installed_paths /path/to/MyStandard,/path/to/PHPCompatibility`
|
161 |
-
|
162 |
-
* If you use a custom ruleset in combination with PHPCS 2.6.0 or higher, you can pass the value to PHPCS from your custom ruleset:
|
163 |
-
```xml
|
164 |
-
<config name="installed_paths" value="vendor/wimg/php-compatibility" />
|
165 |
-
```
|
166 |
-
4. Run `phpcs -i` to verify that the PHPCompatibility standard is now listed again in the list of installed standards.
|
167 |
-
|
168 |
-
|
169 |
-
### Upgrading to PHPCS 3.x
|
170 |
-
|
171 |
-
The path to the `phpcs` script has changed in PHPCS 3.x which will impact how you call PHPCS.
|
172 |
-
|
173 |
-
Version | PHPCS 2.x | PHPCS 3.x
|
174 |
-
------- | --------- | ---------
|
175 |
-
Generic `phpcs` Command | `path/to/PHP_CodeSniffer/scripts/phpcs ....` | `path/to/PHP_CodeSniffer/bin/phpcs ....`
|
176 |
-
Composer command | `vendor/bin/phpcs ...` | `vendor/bin/phpcs ...`
|
177 |
-
|
178 |
-
So, for Composer users, nothing changes. For everyone else, you may want to add the `path/to/PHP_CodeSniffer/bin/phpcs` path to your PATH environment variable or adjust any scripts - like build scripts - which call PHPCS.
|
179 |
-
|
180 |
-
|
181 |
-
### Upgrading a Travis build script
|
182 |
-
|
183 |
-
If you run PHPCompatibility against your code as part of your Travis build:
|
184 |
-
* If you use Composer to install PHP CodeSniffer and PHPCompatibility on the travis image and you've made the above mentioned changes, your build should pass again.
|
185 |
-
* If you use `git clone` to install PHP CodeSniffer and PHPCompatibility on the travis image, your build will fail until you make the following changes:
|
186 |
-
1. Check which branch of PHPCS is being checked out. If you previously fixed this to a pre-PHPCS 3.x branch or tag, you can now change this (back) to `master` or a PHPCS 3 tag.
|
187 |
-
2. Check to which path PHPCompatibility is being cloned and adjust the path if necessary.
|
188 |
-
3. Adjust the `phpcs --config-set installed_paths` command as described above to point to the root of the cloned PHPCompatibility repo.
|
189 |
-
4. If you switched to using PHPCS 3.x, adjust the call to PHPCS.
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
### Changelog for version 8.0.0
|
194 |
-
|
195 |
-
See all related issues and PRs in the [8.0.0 milestone].
|
196 |
-
|
197 |
-
### Added
|
198 |
-
- :two_hearts: Support for PHP CodeSniffer 3.x. [#482](https://github.com/wimg/PHPCompatibility/pull/482), [#481](https://github.com/wimg/PHPCompatibility/pull/481), [#480](https://github.com/wimg/PHPCompatibility/pull/480), [#488](https://github.com/wimg/PHPCompatibility/pull/488), [#489](https://github.com/wimg/PHPCompatibility/pull/489), [#495](https://github.com/wimg/PHPCompatibility/pull/495)
|
199 |
-
|
200 |
-
### Changed
|
201 |
-
- :gift: As of this version PHPCompatibility will use semantic versioning.
|
202 |
-
- :fire: The directory structure of the repository has changed for better compatibility with installation via Composer. [#446](https://github.com/wimg/PHPCompatibility/pull/446). Fixes [#102](https://github.com/wimg/PHPCompatibility/issues/102), [#107](https://github.com/wimg/PHPCompatibility/issues/107)
|
203 |
-
- :pencil2: The custom `functionWhitelist` property for the `PHPCompatibility.PHP.RemovedExtensions` sniff is now only supported in combination with PHP CodeSniffer 2.6.0 or higher (due to an upstream bug which was fixed in PHPCS 2.6.0). [#482](https://github.com/wimg/PHPCompatibility/pull/482)
|
204 |
-
- :wrench: Improved the information provided to Composer from the `composer.json` file. [#446](https://github.com/wimg/PHPCompatibility/pull/446), [#482](https://github.com/wimg/PHPCompatibility/pull/482), [#486](https://github.com/wimg/PHPCompatibility/pull/486)
|
205 |
-
- :wrench: Release archives will no longer contain the unit tests and other typical development files. You can still get these by using Composer with `--prefer-source` or by checking out a git clone of the repository. [#494](https://github.com/wimg/PHPCompatibility/pull/494)
|
206 |
-
- :wrench: A variety of minor improvements to the build process. [#485](https://github.com/wimg/PHPCompatibility/pull/485), [#486](https://github.com/wimg/PHPCompatibility/pull/486), [#487](https://github.com/wimg/PHPCompatibility/pull/487)
|
207 |
-
- :wrench: Some files for use by contributors have been renamed to use `.dist` extensions or moved for easier access. [#478](https://github.com/wimg/PHPCompatibility/pull/478), [#479](https://github.com/wimg/PHPCompatibility/pull/479), [#483](https://github.com/wimg/PHPCompatibility/pull/483), [#493](https://github.com/wimg/PHPCompatibility/pull/493)
|
208 |
-
- :books: The installation instructions in the Readme. [#496](https://github.com/wimg/PHPCompatibility/pull/496)
|
209 |
-
- :books: The unit test instructions in the Contributing file. [#496](https://github.com/wimg/PHPCompatibility/pull/496)
|
210 |
-
- :books: Improved the example code in the Readme. [#490](https://github.com/wimg/PHPCompatibility/pull/490)
|
211 |
-
|
212 |
-
### Removed
|
213 |
-
- :no_entry_sign: Support for PHP 5.1 and 5.2.
|
214 |
-
|
215 |
-
The sniffs can now only be run on PHP 5.3 or higher in combination with PHPCS 1.5.6 or 2.x and on PHP 5.4 or higher in combination with PHPCS 3.x. [#484](https://github.com/wimg/PHPCompatibility/pull/484), [#482](https://github.com/wimg/PHPCompatibility/pull/482)
|
216 |
-
|
217 |
-
### Credits
|
218 |
-
Thanks go out to [Gary Jones] and [Juliette Reinders Folmer] for their contributions to this version. :clap:
|
219 |
-
|
220 |
-
|
221 |
-
## [7.1.5] - 2017-07-17
|
222 |
-
|
223 |
-
See all related issues and PRs in the [7.1.5 milestone].
|
224 |
-
|
225 |
-
### Added
|
226 |
-
- :star: The `NewKeywords` sniff will now also sniff for `yield from` which was introduced in PHP 7.0. [#477](https://github.com/wimg/PHPCompatibility/pull/477). Fixes [#476](https://github.com/wimg/PHPCompatibility/issues/476)
|
227 |
-
- :books: The LGPL-3.0 license. [#447](https://github.com/wimg/PHPCompatibility/pull/447)
|
228 |
-
|
229 |
-
### Changed
|
230 |
-
- :rewind: The `NewExecutionDirectives` sniff will now also report on execution directives when used in combination with PHPCS 2.0.0-2.3.3. [#451](https://github.com/wimg/PHPCompatibility/pull/451)
|
231 |
-
- :rewind: The `getMethodParameters()` utility method will no longer break when used with PHPCS 1.5.x < 1.5.6. This affected a number of sniffs. [#452](https://github.com/wimg/PHPCompatibility/pull/452)
|
232 |
-
- :rewind: The `inUseScope()` utility method will no longer break when used with PHPCS 2.0.0 - 2.2.0. This affected a number of sniffs. [#454](https://github.com/wimg/PHPCompatibility/pull/454)
|
233 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#443](https://github.com/wimg/PHPCompatibility/pull/443), [#474](https://github.com/wimg/PHPCompatibility/pull/474)
|
234 |
-
- :pencil2: Renamed a test file for consistency. [#453](https://github.com/wimg/PHPCompatibility/pull/453)
|
235 |
-
- :wrench: Code style clean up. [#429](https://github.com/wimg/PHPCompatibility/pull/429)
|
236 |
-
- :wrench: Prevent Composer installing PHPCS 3.x. **_PHPCS 3.x is not (yet) supported by the PHPCompatibility standard, but will be in the near future._** [#444](https://github.com/wimg/PHPCompatibility/pull/444)
|
237 |
-
- :green_heart: The code base will now be checked for consistent code style during build testing. [#429](https://github.com/wimg/PHPCompatibility/pull/429)
|
238 |
-
- :green_heart: The sniffs are now also tested against HHVM for consistent results. _Note: the sniffs do not contain any HHVM specific checks nor is there any intention to add them at this time._ [#450](https://github.com/wimg/PHPCompatibility/pull/450)
|
239 |
-
- :books: Made it explicit that - at this moment - PHPCS 3.x is not (yet) supported. [#444](https://github.com/wimg/PHPCompatibility/pull/444)
|
240 |
-
- :books: Minor improvements to the Readme. [#448](https://github.com/wimg/PHPCompatibility/pull/448), [#449](https://github.com/wimg/PHPCompatibility/pull/449), [#468](https://github.com/wimg/PHPCompatibility/pull/468)
|
241 |
-
- :books: Minor improvements to the Contributing guidelines. [#467](https://github.com/wimg/PHPCompatibility/pull/467)
|
242 |
-
|
243 |
-
### Removed
|
244 |
-
- :no_entry_sign: The `DefaultTimeZoneRequired` sniff. This sniff was checking server settings rather than code. [#458](https://github.com/wimg/PHPCompatibility/pull/458). Fixes [#457](https://github.com/wimg/PHPCompatibility/issues/457)
|
245 |
-
- :no_entry_sign: The `NewMagicClassConstant` sniff as introduced in v 7.1.4 contained two additional checks for not strictly compatibility related issues. One of these was plainly wrong, the other opinionated. Both have been removed. [#442](https://github.com/wimg/PHPCompatibility/pull/442). Fixes [#436](https://github.com/wimg/PHPCompatibility/issues/436)
|
246 |
-
|
247 |
-
### Fixed
|
248 |
-
- :bug: `NewClass` sniff: was reporting an incorrect introduction version number for a few of the Exception classes. [#441](https://github.com/wimg/PHPCompatibility/pull/441). Fixes [#440](https://github.com/wimg/PHPCompatibility/issues/440).
|
249 |
-
- :bug: `ForbiddenBreakContinueVariableArguments` sniff: was incorrectly reporting an error if the `break` or `continue` was followed by a PHP closing tag (breaking out of PHP). [#462](https://github.com/wimg/PHPCompatibility/pull/462). Fixes [#460](https://github.com/wimg/PHPCompatibility/issues/460)
|
250 |
-
- :bug: `ForbiddenGlobalVariableVariable` sniff: was incorrectly reporting an error if the `global` statement was followed by a PHP closing tag (breaking out of PHP). [#463](https://github.com/wimg/PHPCompatibility/pull/463).
|
251 |
-
- :bug: `DeprecatedFunctions` sniff: was reporting false positives for classes using the same name as a deprecated function. [#465](https://github.com/wimg/PHPCompatibility/pull/465). Fixes [#464](https://github.com/wimg/PHPCompatibility/issues/464)
|
252 |
-
|
253 |
-
### Credits
|
254 |
-
Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
|
255 |
-
|
256 |
-
|
257 |
-
## [7.1.4] - 2017-05-06
|
258 |
-
|
259 |
-
See all related issues and PRs in the [7.1.4 milestone].
|
260 |
-
|
261 |
-
### Added
|
262 |
-
- :star2: New `CaseSensitiveKeywords` sniff to detect use of non-lowercase `self`, `static` and `parent` keywords which could cause compatibility issues pre-PHP 5.5. [#382](https://github.com/wimg/PHPCompatibility/pull/382)
|
263 |
-
- :star2: New `ConstantArraysUsingConst` sniff to detect constants defined using the `const` keyword being assigned an array value which was not supported prior to PHP 5.6. [#397](https://github.com/wimg/PHPCompatibility/pull/397)
|
264 |
-
- :star2: New `ForbiddenClosureUseVariableNames` sniff to detect PHP 7.1 forbidden variable names in closure use statements. [#386](https://github.com/wimg/PHPCompatibility/pull/386). Fixes [#374](https://github.com/wimg/PHPCompatibility/issues/374)
|
265 |
-
- :star2: New `NewArrayStringDereferencing` sniff to detect array and string literal dereferencing as introduced in PHP 5.5. [#388](https://github.com/wimg/PHPCompatibility/pull/388)
|
266 |
-
- :star2: New `NewHeredocInitialize` sniff to detect initialization of static variables and class properties/constants using the heredoc syntax which is supported since PHP 5.3. [#391](https://github.com/wimg/PHPCompatibility/pull/391). Fixes [#51](https://github.com/wimg/PHPCompatibility/issues/51)
|
267 |
-
- :star2: New `NewMagicClassConstant` sniff to detect use of the magic `::class` constant as introduced in PHP 5.5. [#403](https://github.com/wimg/PHPCompatibility/pull/403). Fixes [#364](https://github.com/wimg/PHPCompatibility/issues/364).
|
268 |
-
- :star2: New `NewUseConstFunction` sniff to detect use statements importing constants and functions as introduced in PHP 5.6. [#401](https://github.com/wimg/PHPCompatibility/pull/401)
|
269 |
-
- :star: `DeprecatedFunctions` sniff: recognize PHP 7.2 deprecated GD functions. [#392](https://github.com/wimg/PHPCompatibility/pull/392)
|
270 |
-
- :star: `DeprecatedIniDirectives` sniff: recognize PHP 7.2 deprecated `mbstring.func_overload` directive. [#377](https://github.com/wimg/PHPCompatibility/pull/377)
|
271 |
-
- :star: `NewClasses` sniff: check for the PHP 5.1 `libXMLError` class. [#412](https://github.com/wimg/PHPCompatibility/pull/412)
|
272 |
-
- :star: `NewClasses` sniff: recognize all native PHP Exception classes. [#418](https://github.com/wimg/PHPCompatibility/pull/418)
|
273 |
-
- :star: `NewClosures` sniff: check for closures being declared as static and closures using `$this`. Both of which was not supported pre-PHP 5.4. [#389](https://github.com/wimg/PHPCompatibility/pull/389). Fixes [#24](https://github.com/wimg/PHPCompatibility/issues/24).
|
274 |
-
- :star: `NewFunctionParameters` sniff: recognize new `exclude_disabled` parameter for the `get_defined_functions()` function as introduced in PHP 7.0.15. [#375](https://github.com/wimg/PHPCompatibility/pull/375)
|
275 |
-
- :star: `NewFunctions` sniff: recognize new PHP 7.2 socket related functions. [#376](https://github.com/wimg/PHPCompatibility/pull/376)
|
276 |
-
- :star: `NewInterfaces` sniff: check for some more PHP native interfaces. [#411](https://github.com/wimg/PHPCompatibility/pull/411)
|
277 |
-
- :star: New `isClassProperty()`, `isClassConstant()` and `validDirectScope()` utility methods to the `PHPCompatibility_Sniff` class. [#393](https://github.com/wimg/PHPCompatibility/pull/393), [#391](https://github.com/wimg/PHPCompatibility/pull/391).
|
278 |
-
- :star: New `getTypeHintsFromFunctionDeclaration()` utility method to the `PHPCompatibility_Sniff` class. [#414](https://github.com/wimg/PHPCompatibility/pull/414).
|
279 |
-
- :umbrella: Unit tests against false positives for the `NewMagicMethods` sniff. [#381](https://github.com/wimg/PHPCompatibility/pull/381)
|
280 |
-
- :umbrella: More unit tests for the `getTestVersion()` utility method. [#405](https://github.com/wimg/PHPCompatibility/pull/405), [#430](https://github.com/wimg/PHPCompatibility/pull/430)
|
281 |
-
- :green_heart: The XML of the ruleset will now be validated and checked for consistent code style during the build testing by Travis. [#433](https://github.com/wimg/PHPCompatibility/pull/433)
|
282 |
-
- :books: Readme: information about setting `installed_paths` via a custom ruleset. [#407](https://github.com/wimg/PHPCompatibility/pull/407)
|
283 |
-
- :books: `Changelog.md` file containing a record of notable changes since the first tagged release. [#421](https://github.com/wimg/PHPCompatibility/pull/421)
|
284 |
-
|
285 |
-
### Changed
|
286 |
-
- :pushpin: The `ForbiddenNamesAsDeclared` sniff will now emit `warning`s for soft reserved keywords. [#406](https://github.com/wimg/PHPCompatibility/pull/406), [#370](https://github.com/wimg/PHPCompatibility/pull/370).
|
287 |
-
- :pushpin: The `ForbiddenNames` sniff will now allow for the more liberal rules for usage of reserved keywords as of PHP 7.0. [#417](https://github.com/wimg/PHPCompatibility/pull/417)
|
288 |
-
- :pushpin: The `InternalInterfaces`, `NewClasses`, `NewConstVisibility`, `NewInterfaces`, `NewMagicMethods`, `NonStaticMagicMethods` and `RemovedGlobalVariables` sniffs will now also sniff for and correctly report violations in combination with anonymous classes. [#378](https://github.com/wimg/PHPCompatibility/pull/378), [#383](https://github.com/wimg/PHPCompatibility/pull/383), [#393](https://github.com/wimg/PHPCompatibility/pull/393), [#394](https://github.com/wimg/PHPCompatibility/pull/394), [#395](https://github.com/wimg/PHPCompatibility/pull/395), [#396](https://github.com/wimg/PHPCompatibility/pull/396). Fixes [#351](https://github.com/wimg/PHPCompatibility/issues/351) and [#333](https://github.com/wimg/PHPCompatibility/issues/333).
|
289 |
-
- :pushpin: The `NewClasses` and `NewInterfaces` sniffs will now also report on new classes/interfaces when used as type hints. [#414](https://github.com/wimg/PHPCompatibility/pull/414), [#416](https://github.com/wimg/PHPCompatibility/pull/416). Fixes [#352](https://github.com/wimg/PHPCompatibility/issues/352)
|
290 |
-
- :pushpin: The `NewClasses` sniff will now also report on Exception classes when used in (multi-)`catch` statements. [#418](https://github.com/wimg/PHPCompatibility/pull/418). Fixes [#373](https://github.com/wimg/PHPCompatibility/issues/373).
|
291 |
-
- :pushpin: The `NewScalarTypeDeclarations` sniff will now report on new type hints even when the type hint is nullable. [#379](https://github.com/wimg/PHPCompatibility/pull/379)
|
292 |
-
- :twisted_rightwards_arrows: The `NewNowdoc` sniff has been renamed to `NewNowdocQuotedHeredoc` and will now also check for double quoted heredoc identifiers as introduced in PHP 5.3. [#390](https://github.com/wimg/PHPCompatibility/pull/390)
|
293 |
-
- :rewind: The `NewClasses` sniff will now also report anonymous classes which `extend` a new sniff when used in combination with PHPCS 2.4.0-2.8.0. [#432](https://github.com/wimg/PHPCompatibility/pull/432). Fixes [#334](https://github.com/wimg/PHPCompatibility/issues/334).
|
294 |
-
- :pencil2: `NewFunctionParameter` sniff: version number precision for two parameters. [#384](https://github.com/wimg/PHPCompatibility/pull/384), [#428](https://github.com/wimg/PHPCompatibility/pull/428)
|
295 |
-
- :umbrella: Skipping two unit tests for the `ForbiddenClosureUseVariable` sniff when run on PHPCS 2.5.1 as these cause an infinite loop due to an upstream bug. [#408](https://github.com/wimg/PHPCompatibility/pull/408)
|
296 |
-
- :umbrella: Skipping unit tests involving `trait`s in combination with PHP < 5.4 and PHPCS < 2.4.0 as `trait`s are not recognized in those circumstances. [#431](https://github.com/wimg/PHPCompatibility/pull/431)
|
297 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#385](https://github.com/wimg/PHPCompatibility/pull/385), [#387](https://github.com/wimg/PHPCompatibility/pull/387), [#415](https://github.com/wimg/PHPCompatibility/pull/415), [#423](https://github.com/wimg/PHPCompatibility/pull/423), [#424](https://github.com/wimg/PHPCompatibility/pull/424)
|
298 |
-
- :recycle: Minor simplification of the PHPUnit 6 compatibility layer and other test code. [#426](https://github.com/wimg/PHPCompatibility/pull/426), [#425](https://github.com/wimg/PHPCompatibility/pull/425)
|
299 |
-
- General housekeeping. [#398](https://github.com/wimg/PHPCompatibility/pull/398), [#400](https://github.com/wimg/PHPCompatibility/pull/400)
|
300 |
-
- :wrench: Minor tweaks to the Travis build script. [#409](https://github.com/wimg/PHPCompatibility/pull/409)
|
301 |
-
- :green_heart: The sniffs are now also tested against PHP nightly for consistent results. [#380](https://github.com/wimg/PHPCompatibility/pull/380)
|
302 |
-
|
303 |
-
### Fixed
|
304 |
-
- :fire: Using unbounded ranges in `testVersion` resulted in unreported errors when used with sniffs using the `supportsBelow()` method. This affected the results of approximately half the sniffs. [#430](https://github.com/wimg/PHPCompatibility/pull/430)
|
305 |
-
- :bug: The `ForbiddenNames` sniff would throw false positives for `use` statements with the `final` modifier in traits. [#402](https://github.com/wimg/PHPCompatibility/pull/402).
|
306 |
-
- :bug: The `ForbiddenNames` sniff would fail to report on functions declared to return by reference using a reserved keyword as the function name. [#413](https://github.com/wimg/PHPCompatibility/pull/413)
|
307 |
-
- :bug: The `ForbiddenNames` sniff would only examine the first part of a namespace and not report on reserved keywords used in subsequent parts of a nested namespace. [#419](https://github.com/wimg/PHPCompatibility/pull/419)
|
308 |
-
- :bug: The `ForbiddenNames` sniff would not always correctly report on use statements importing constants or functions using reserved keywords. [#420](https://github.com/wimg/PHPCompatibility/pull/420)
|
309 |
-
- :bug: The `NewKeywords` sniff would sometimes fail to report on the `const` keyword when used in a class, but not for a class constant. [#424](https://github.com/wimg/PHPCompatibility/pull/424)
|
310 |
-
- :green_heart: PHPCS has released version 3.0 and updated the `master` branch to reflect this. This was causing the builds to fail. [#422](https://github.com/wimg/PHPCompatibility/pull/422)
|
311 |
-
|
312 |
-
### Credits
|
313 |
-
Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
|
314 |
-
|
315 |
-
|
316 |
-
## [7.1.3] - 2017-04-02
|
317 |
-
|
318 |
-
See all related issues and PRs in the [7.1.3 milestone].
|
319 |
-
|
320 |
-
### Added
|
321 |
-
- :zap: The `testVersion` config parameter now allows for specifying unbounded ranges.
|
322 |
-
For example: specifying `-5.6` means: check for compatibility with all PHP versions up to and including PHP 5.6;
|
323 |
-
Specifying `7.0-` means: check for compatibility with all PHP versions from PHP 7.0 upwards.
|
324 |
-
For more information about setting the `testVersion`, see [Using the compatibility sniffs](https://github.com/wimg/PHPCompatibility#using-the-compatibility-sniffs) in the readme.
|
325 |
-
- :umbrella: Unit test for multi-line short arrays for the `ShortArray` sniff. [#347](https://github.com/wimg/PHPCompatibility/pull/347)
|
326 |
-
- :umbrella: Various additional unit tests against false positives. [#345](https://github.com/wimg/PHPCompatibility/pull/345), [#369](https://github.com/wimg/PHPCompatibility/pull/369)
|
327 |
-
- :umbrella: Unit tests for the `supportsBelow()`, `supportsAbove()` and `getTestVersion()` utility methods. [#363](https://github.com/wimg/PHPCompatibility/pull/363)
|
328 |
-
- :books: Readme: information about installation of the standard using git check-out. [#349](https://github.com/wimg/PHPCompatibility/pull/349)
|
329 |
-
- :books: `Contributing.md` file with information about reporting bugs, requesting features, making pull requests and running the unit tests. [#350](https://github.com/wimg/PHPCompatibility/pull/350)
|
330 |
-
|
331 |
-
### Changed
|
332 |
-
- :pushpin: The `ForbiddenFunctionParametersWithSameName`, `NewScalarTypeDeclarations`, `ParameterShadowSuperGlobals` sniff will now also sniff for and report violations in closures. [#331](https://github.com/wimg/PHPCompatibility/pull/331)
|
333 |
-
- :twisted_rightwards_arrows: :rewind: The check for the PHP 5.3 `nowdoc` structure has been moved from the `NewKeywords` sniff to a new stand-alone `NewNowdoc` sniff which will now also recognize this structure when the sniffs are run on PHP 5.2. [#335](https://github.com/wimg/PHPCompatibility/pull/335)
|
334 |
-
- :rewind: The `ForbiddenNames` sniff will now also correctly recognize reserved keywords used in a declared namespace when run on PHP 5.2. [#362](https://github.com/wimg/PHPCompatibility/pull/362)
|
335 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#360](https://github.com/wimg/PHPCompatibility/pull/360)
|
336 |
-
- :recycle: The unit tests would previously run each test case file against all PHPCompatibility sniffs. Now, they will only be tested against the sniff which the test case file is intended to test. This allows for more test cases to be tested, more precise testing in combination with `testVersion` settings and makes the unit tests run ~6 x faster.
|
337 |
-
Relevant additional unit tests have been added and others adjusted. [#369](https://github.com/wimg/PHPCompatibility/pull/369)
|
338 |
-
- :recycle: Refactoring/tidying up of some unit test code. [#343](https://github.com/wimg/PHPCompatibility/pull/343), [#345](https://github.com/wimg/PHPCompatibility/pull/345), [#356](https://github.com/wimg/PHPCompatibility/pull/356), [#355](https://github.com/wimg/PHPCompatibility/pull/355), [#359](https://github.com/wimg/PHPCompatibility/pull/359)
|
339 |
-
- General housekeeping. [#346](https://github.com/wimg/PHPCompatibility/pull/346)
|
340 |
-
- :books: Readme: Clarify minimum requirements and influence on the results. [#348](https://github.com/wimg/PHPCompatibility/pull/348)
|
341 |
-
|
342 |
-
### Removed
|
343 |
-
- :twisted_rightwards_arrows: Removed the `LongArrays` sniff. The checks it contained have been moved into the `RemovedGlobalVariables` sniff. Both sniffs essentially did the same thing, just for different PHP native superglobals. [#354](https://github.com/wimg/PHPCompatibility/pull/354)
|
344 |
-
|
345 |
-
### Fixed
|
346 |
-
- :bug: The `PregReplaceEModifier` sniff would throw a false positive if a quote character was used as the regex delimiter. [#357](https://github.com/wimg/PHPCompatibility/pull/357)
|
347 |
-
- :bug: `RemovedGlobalVariables` sniff would report false positives for class properties shadowing the removed `$HTTP_RAW_POST_DATA` variables. [#354](https://github.com/wimg/PHPCompatibility/pull/354).
|
348 |
-
- :bug: The `getFQClassNameFromNewToken()` utility function could go into an infinite loop causing PHP to run out of memory when examining unfinished code (examination during live coding). [#338](https://github.com/wimg/PHPCompatibility/pull/338), [#342](https://github.com/wimg/PHPCompatibility/pull/342)
|
349 |
-
- :bug: The `determineNamespace()` utility method would in certain cases not break out a loop. [#358](https://github.com/wimg/PHPCompatibility/pull/358)
|
350 |
-
- :wrench: Travis script: Minor tweak for PHP 5.2 compatibility. [#341](https://github.com/wimg/PHPCompatibility/pull/341)
|
351 |
-
- :wrench: The unit test suite is now also compatible with PHPUnit 6. [#365](https://github.com/wimg/PHPCompatibility/pull/365)
|
352 |
-
- :books: Readme: Typo in the composer instructions. [#344](https://github.com/wimg/PHPCompatibility/pull/344)
|
353 |
-
|
354 |
-
### Credits
|
355 |
-
Thanks go out to [Arthur Edamov], [Juliette Reinders Folmer], [Mark Clements] and [Tadas Juozapaitis] for their contributions to this version. :clap:
|
356 |
-
|
357 |
-
|
358 |
-
## [7.1.2] - 2017-02-17
|
359 |
-
|
360 |
-
See all related issues and PRs in the [7.1.2 milestone].
|
361 |
-
|
362 |
-
### Added
|
363 |
-
- :star2: New `VariableVariables` sniff to detect variables variables for which the behaviour has changed in PHP 7.0. [#310](https://github.com/wimg/PHPCompatibility/pull/310) Fixes [#309](https://github.com/wimg/PHPCompatibility/issues/309).
|
364 |
-
- :star: The `NewReturnTypeDeclarations` sniff will now also sniff for non-scalar return type declarations, i.e. `array`, `callable`, `self` or a class name. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
365 |
-
- :star: The `NewLanguageConstructs` sniff will now also sniff for the null coalesce equal operator `??=`. This operator is slated to be introduced in PHP 7.2 and PHPCS already accounts for it. [#340](https://github.com/wimg/PHPCompatibility/pull/340)
|
366 |
-
- :star: New `getReturnTypeHintToken()` utility method to the `PHPCompatibility_Sniff` class to retrieve return type hints from function declarations in a cross-PHPCS-version compatible way. [#323](https://github.com/wimg/PHPCompatibility/pull/323).
|
367 |
-
- :star: New `stripVariables()` utility method to the `PHPCompatibility_Sniff` class to strip variables from interpolated text strings. [#341](https://github.com/wimg/PHPCompatibility/pull/314).
|
368 |
-
- :umbrella: Additional unit tests covering previously uncovered code. [#308](https://github.com/wimg/PHPCompatibility/pull/308)
|
369 |
-
|
370 |
-
### Changed
|
371 |
-
- :pushpin: The `MbstringReplaceEModifier`, `PregReplaceEModifier` and `NewExecutionDirectives` sniffs will now also correctly interpret double quoted text strings with interpolated variables. [#341](https://github.com/wimg/PHPCompatibility/pull/314), [#324](https://github.com/wimg/PHPCompatibility/pull/324).
|
372 |
-
- :pushpin: The `NewNullableTypes` sniff will now also report on nullable (return) type hints when used with closures. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
373 |
-
- :pushpin: The `NewReturnTypeDeclarations` sniff will now also report on return type hints when used with closures. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
374 |
-
- :pushpin: Allow for anonymous classes in the `inClassScope()` utility method. [#315](https://github.com/wimg/PHPCompatibility/pull/315)
|
375 |
-
- :pushpin: The function call parameter related utility functions can now also be used to get the individual items from an array declaration. [#300](https://github.com/wimg/PHPCompatibility/pull/300)
|
376 |
-
- :twisted_rightwards_arrows: The `NewScalarReturnTypeDeclarations` sniff has been renamed to `NewReturnTypeDeclarations`. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
377 |
-
- :rewind: The `ForbiddenNames` sniff will now also correctly ignore anonymous classes when used in combination with PHPCS < 2.3.4. [#319](https://github.com/wimg/PHPCompatibility/pull/319)
|
378 |
-
- :rewind: The `NewAnonymousClasses` sniff will now correctly recognize and report on anonymous classes when used in combination with PHPCS < 2.5.2. [#325](https://github.com/wimg/PHPCompatibility/pull/325)
|
379 |
-
- :rewind: The `NewGroupUseDeclarations` sniff will now correctly recognize and report on group use statements when used in combination with PHPCS < 2.6.0. [#320](https://github.com/wimg/PHPCompatibility/pull/320)
|
380 |
-
- :rewind: The `NewNullableTypes` sniff will now correctly recognize and report on nullable return types when used in combination with PHPCS < 2.6.0. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
381 |
-
- :rewind: The `NewReturnTypeDeclarations` sniff will now correctly recognize and report on new return types when used in combination with PHPCS < 2.6.0. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
382 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#317](https://github.com/wimg/PHPCompatibility/pull/317)
|
383 |
-
- :recycle: Defer to upstream `hasCondition()` utility method where appropriate. [#315](https://github.com/wimg/PHPCompatibility/pull/315)
|
384 |
-
- :recycle: Minor refactoring of some unit test code. [#304](https://github.com/wimg/PHPCompatibility/pull/304), [#303](https://github.com/wimg/PHPCompatibility/pull/303), [#318](https://github.com/wimg/PHPCompatibility/pull/318)
|
385 |
-
- :wrench: All unit tests now have appropriate `@group` annotations allowing for quicker/easier testing of a select group of tests/sniffs. [#305](https://github.com/wimg/PHPCompatibility/pull/305)
|
386 |
-
- :wrench: All unit tests now have appropriate `@covers` annotations to improve code coverage reporting and remove bleed through of accidental coverage. [#307](https://github.com/wimg/PHPCompatibility/pull/307)
|
387 |
-
- :wrench: Minor tweaks to the travis script. [#322](https://github.com/wimg/PHPCompatibility/pull/322)
|
388 |
-
- :green_heart: The PHPCompatibility code base itself will now be checked for cross-version compatibility during build testing. [#322](https://github.com/wimg/PHPCompatibility/pull/322)
|
389 |
-
|
390 |
-
### Fixed
|
391 |
-
- :bug: The `ConstantArraysUsingDefine` sniff would throw false positives if the value of the `define()` was retrieved via a function call and an array parameter was passed. [#327](https://github.com/wimg/PHPCompatibility/pull/327)
|
392 |
-
- :bug: The `ForbiddenCallTimePassByReference` sniff would throw false positives on assign by reference within function calls or conditions. [#302](https://github.com/wimg/PHPCompatibility/pull/302) Fixes the last two cases reported in [#68](https://github.com/wimg/PHPCompatibility/issues/68#issuecomment-231366445)
|
393 |
-
- :bug: The `ForbiddenGlobalVariableVariableSniff` sniff would only examine the first variable in a `global ...` statement causing unreported issues if subsequent variables were variable variables. [#316](https://github.com/wimg/PHPCompatibility/pull/316)
|
394 |
-
- :bug: The `NewKeywords` sniff would throw a false positive for the `const` keyword when encountered in an interface. [#312](https://github.com/wimg/PHPCompatibility/pull/312)
|
395 |
-
- :bug: The `NewNullableTypes` sniff would not report on nullable return types for namespaced classnames used as a type hint. [#323](https://github.com/wimg/PHPCompatibility/pull/323)
|
396 |
-
- :bug: The `PregReplaceEModifier` sniff would always consider the first parameter passed as a single regex, while it could also be an array of regexes. This led to false positives and potentially unreported use of the `e` modifier when an array of regexes was passed. [#300](https://github.com/wimg/PHPCompatibility/pull/300)
|
397 |
-
- :bug: The `PregReplaceEModifier` sniff could misidentify the regex delimiter when the regex to be examined was concatenated together from various text strings taken from a compound parameter leading to false positives. [#300](https://github.com/wimg/PHPCompatibility/pull/300)
|
398 |
-
- :white_check_mark: Compatibility with PHPCS 2.7.x. Deal with changed behaviour of the upstream PHP tokenizer and utility function(s). [#313](https://github.com/wimg/PHPCompatibility/pull/313), [#323](https://github.com/wimg/PHPCompatibility/pull/323), [#326](https://github.com/wimg/PHPCompatibility/pull/326), [#340](https://github.com/wimg/PHPCompatibility/pull/340)
|
399 |
-
|
400 |
-
### Credits
|
401 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
402 |
-
|
403 |
-
|
404 |
-
## [7.1.1] - 2016-12-14
|
405 |
-
|
406 |
-
See all related issues and PRs in the [7.1.1 milestone].
|
407 |
-
|
408 |
-
### Added
|
409 |
-
- :star: `ForbiddenNamesAsDeclared` sniff: detection of the PHP 7.1 `iterable` and `void` reserved keywords when used to name classes, interfaces or traits. [#298](https://github.com/wimg/PHPCompatibility/pull/298)
|
410 |
-
|
411 |
-
### Fixed
|
412 |
-
- :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would incorrectly throw an error if the `clone` keyword was used with parenthesis. [#299](https://github.com/wimg/PHPCompatibility/pull/299). Fixes [#284](https://github.com/wimg/PHPCompatibility/issues/284)
|
413 |
-
|
414 |
-
### Credits
|
415 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
416 |
-
|
417 |
-
|
418 |
-
## [7.1.0] - 2016-12-14
|
419 |
-
|
420 |
-
See all related issues and PRs in the [7.1.0 milestone].
|
421 |
-
|
422 |
-
### Added
|
423 |
-
- :star: New `stringToErrorCode()`, `arrayKeysToLowercase()` and `addMessage()` utility methods to the `PHPCompatibility_Sniff` class. [#291](https://github.com/wimg/PHPCompatibility/pull/291).
|
424 |
-
|
425 |
-
### Changed
|
426 |
-
- :pushpin: All sniff error messages now have modular error codes allowing for selectively disabling individual checks - and even selectively disabling individual sniff for specific files - without disabling the complete sniff. [#291](https://github.com/wimg/PHPCompatibility/pull/291)
|
427 |
-
- :pencil2: Minor changes to some of the error message texts for consistency across sniffs. [#291](https://github.com/wimg/PHPCompatibility/pull/291)
|
428 |
-
- :recycle: Refactored the complex version sniffs to reduce code duplication. [#291](https://github.com/wimg/PHPCompatibility/pull/291)
|
429 |
-
- :recycle: Miscellaneous other refactoring for improved performance and sniff accuracy. [#291](https://github.com/wimg/PHPCompatibility/pull/291)
|
430 |
-
- :umbrella: The unit tests for the `RemovedExtensions` sniff now verify that the correct alternative extension is being suggested. [#291](https://github.com/wimg/PHPCompatibility/pull/291)
|
431 |
-
|
432 |
-
### Credits
|
433 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
434 |
-
|
435 |
-
|
436 |
-
## [7.0.8] - 2016-10-31 - :ghost: Spooky! :jack_o_lantern:
|
437 |
-
|
438 |
-
See all related issues and PRs in the [7.0.8 milestone].
|
439 |
-
|
440 |
-
### Added
|
441 |
-
- :star2: New `ForbiddenNamesAsDeclared` sniff: detection of the [other reserved keywords](http://php.net/manual/en/reserved.other-reserved-words.php) which are reserved as of PHP 7.0 (or higher). [#287](https://github.com/wimg/PHPCompatibility/pull/287). Fixes [#115](https://github.com/wimg/PHPCompatibility/issues/115).
|
442 |
-
These were previously sniffed for by the `ForbiddenNames` and `ForbiddenNamesAsInvokedFunctions` sniffs causing false positives as the rules for their reservation are different from the rules for "normal" [reserved keywords](http://php.net/manual/en/reserved.keywords.php).
|
443 |
-
- :star: New `inUseScope()` utility method to the `PHPCompatibility_Sniff` class which handles PHPCS cross-version compatibility when determining the scope of a `use` statement. [#271](https://github.com/wimg/PHPCompatibility/pull/271).
|
444 |
-
- :umbrella: More unit tests for the `ForbiddenNames` sniff. [#271](https://github.com/wimg/PHPCompatibility/pull/271).
|
445 |
-
|
446 |
-
### Changed
|
447 |
-
- :pushpin: _Deprecated_ functionality should throw a `warning`. _Removed_ or otherwise unavailable functionality should throw an `error`. This distinction was previously not consistently applied everywhere. [#286](https://github.com/wimg/PHPCompatibility/pull/286)
|
448 |
-
This change affects the following sniffs:
|
449 |
-
* `DeprecatedPHP4StyleConstructors` will now throw a `warning` instead of an `error` for deprecated PHP4 style class constructors.
|
450 |
-
* `ForbiddenCallTimePassByReference` will now throw a `warning` if the `testVersion` is `5.3` and an `error` if the `testVersion` if `5.4` or higher.
|
451 |
-
* `MbstringReplaceEModifier` will now throw a `warning` instead of an `error` for usage of the deprecated `e` modifier.
|
452 |
-
* `PregReplaceEModifier` will now throw a `warning` if the `testVersion` is `5.5` or `5.6` and an `error` if the `testVersion` if `7.0` or higher. Fixes [#290](https://github.com/wimg/PHPCompatibility/issues/290).
|
453 |
-
* `TernaryOperators` will now throw an `error` when the `testVersion` < `5.3` and the middle part has been omitted.
|
454 |
-
* `ValidIntegers` will now throw a `warning` when an invalid binary integer is detected.
|
455 |
-
- :pencil2: `DeprecatedFunctions` and `DeprecatedIniDirectives` sniffs: minor change in the sniff error message text. Use _"removed"_ rather than the ominous _"forbidden"_. [#285](https://github.com/wimg/PHPCompatibility/pull/285)
|
456 |
-
Also updated relevant internal variable names and documentation to match.
|
457 |
-
|
458 |
-
### Fixed
|
459 |
-
- :bug: `ForbiddenNames` sniff would throw false positives for `use` statements which changed the visibility of methods in traits. [#271](https://github.com/wimg/PHPCompatibility/pull/271).
|
460 |
-
- :bug: `ForbiddenNames` sniff would not report reserved keywords when used in combination with `use function` or `use const`. [#271](https://github.com/wimg/PHPCompatibility/pull/271).
|
461 |
-
- :bug: `ForbiddenNames` sniff would potentially - unintentionally - skip over tokens, thereby - potentially - not reporting all errors. [#271](https://github.com/wimg/PHPCompatibility/pull/271).
|
462 |
-
- :wrench: Composer config: `prefer-stable` should be a root element of the json file. Fixes [#277](https://github.com/wimg/PHPCompatibility/issues/277).
|
463 |
-
|
464 |
-
### Credits
|
465 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
466 |
-
|
467 |
-
|
468 |
-
## [7.0.7] - 2016-10-20
|
469 |
-
|
470 |
-
See all related issues and PRs in the [7.0.7 milestone].
|
471 |
-
|
472 |
-
### Added
|
473 |
-
- :star2: New `ForbiddenBreakContinueOutsideLoop` sniff: verify that `break`/`continue` is not used outside of a loop structure. This will cause fatal errors since PHP 7.0. [#278](https://github.com/wimg/PHPCompatibility/pull/278). Fixes [#275](https://github.com/wimg/PHPCompatibility/issues/275)
|
474 |
-
- :star2: New `NewConstVisibility` sniff: detect visibility indicators for `class` and `interface` constants as introduced in PHP 7.1. [#280](https://github.com/wimg/PHPCompatibility/pull/280). Fixes [#249](https://github.com/wimg/PHPCompatibility/issues/249)
|
475 |
-
- :star2: New `NewHashAlgorithms` sniff to check used hash algorithms against the PHP version in which they were introduced. [#242](https://github.com/wimg/PHPCompatibility/pull/242)
|
476 |
-
- :star2: New `NewMultiCatch` sniff: detect catch statements catching multiple Exceptions as introduced in PHP 7.1. [#281](https://github.com/wimg/PHPCompatibility/pull/281). Fixes [#251](https://github.com/wimg/PHPCompatibility/issues/251)
|
477 |
-
- :star2: New `NewNullableTypes` sniff: detect nullable parameter and return type hints (only supported in PHPCS >= 2.3.4) as introduced in PHP 7.1. [#282](https://github.com/wimg/PHPCompatibility/pull/282). Fixes [#247](https://github.com/wimg/PHPCompatibility/issues/247)
|
478 |
-
- :star: `DeprecatedIniDirectives` sniff: recognize PHP 7.1 removed `session` ini directives. [#256](https://github.com/wimg/PHPCompatibility/pull/256)
|
479 |
-
- :star: `NewFunctions` sniff: recognize new `socket_export_stream()` function as introduced in PHP 7.0.7. [#264](https://github.com/wimg/PHPCompatibility/pull/264)
|
480 |
-
- :star: `NewFunctions` sniff: recognize new `curl_...()`, `is_iterable()`, `pcntl_async_signals()`, `session_create_id()`, `session_gc()` functions as introduced in PHP 7.1. [#273](https://github.com/wimg/PHPCompatibility/pull/273)
|
481 |
-
- :star: `NewFunctionParameters` sniff: recognize new OpenSSL function parameters as introduced in PHP 7.1. [#258](https://github.com/wimg/PHPCompatibility/pull/258)
|
482 |
-
- :star: `NewIniDirectives` sniff: recognize new `session` ini directives as introduced in PHP 7.1. [#259](https://github.com/wimg/PHPCompatibility/pull/259)
|
483 |
-
- :star: `NewScalarReturnTypeDeclarations` sniff: recognize PHP 7.1 `void` return type hint. [#250](https://github.com/wimg/PHPCompatibility/pull/250)
|
484 |
-
- :star: `NewScalarTypeDeclarations` sniff: recognize PHP 7.1 `iterable` type hint. [#255](https://github.com/wimg/PHPCompatibility/pull/255)
|
485 |
-
- :star: Recognize the PHP 7.1 deprecated `mcrypt` functionality in the `RemovedExtensions`, `DeprecatedFunctions` and `DeprecatedIniDirectives` sniffs. [#257](https://github.com/wimg/PHPCompatibility/pull/257)
|
486 |
-
|
487 |
-
### Changed
|
488 |
-
- :pushpin: `LongArrays` sniff used to only throw `warning`s. It will now throw `error`s for PHP versions in which the long superglobals have been removed. [#270](https://github.com/wimg/PHPCompatibility/pull/270)
|
489 |
-
- :pushpin: The `NewIniDirectives` sniff used to always throw an `warning`. Now it will throw an `error` when a new ini directive is used in combination with `ini_set()`. [#246](https://github.com/wimg/PHPCompatibility/pull/246).
|
490 |
-
- :pushpin: `RemovedHashAlgorithms` sniff: also recognize removed algorithms when used with the PHP 5.5+ `hash_pbkdf2()` function. [#240](https://github.com/wimg/PHPCompatibility/pull/240)
|
491 |
-
- :pushpin: Properly recognize nullable type hints in the `getMethodParameters()` utility method. [#282](https://github.com/wimg/PHPCompatibility/pull/282)
|
492 |
-
- :pencil2: `DeprecatedPHP4StyleConstructors` sniff: minor error message text fix. [#236](https://github.com/wimg/PHPCompatibility/pull/236)
|
493 |
-
- :pencil2: `NewIniDirectives` sniff: improved precision for the introduction version numbers being reported. [#246](https://github.com/wimg/PHPCompatibility/pull/246)
|
494 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#238](https://github.com/wimg/PHPCompatibility/pull/238), [#244](https://github.com/wimg/PHPCompatibility/pull/244), [#240](https://github.com/wimg/PHPCompatibility/pull/240), [#276](https://github.com/wimg/PHPCompatibility/pull/276)
|
495 |
-
- :umbrella: Re-activate the unit tests for the `NewScalarReturnTypeDeclarations` sniff. [#250](https://github.com/wimg/PHPCompatibility/pull/250)
|
496 |
-
|
497 |
-
### Fixed
|
498 |
-
- :bug: The `DeprecatedPHP4StyleConstructors` sniff would not report errors when the case of the class name and the PHP4 constructor function name did not match. [#236](https://github.com/wimg/PHPCompatibility/pull/236)
|
499 |
-
- :bug: `LongArrays` sniff would report false positives for class properties shadowing removed PHP superglobals. [#270](https://github.com/wimg/PHPCompatibility/pull/270). Fixes [#268](https://github.com/wimg/PHPCompatibility/issues/268).
|
500 |
-
- :bug: The `NewClasses` sniff would not report errors when the case of the class name used and "official" class name did not match. [#237](https://github.com/wimg/PHPCompatibility/pull/237)
|
501 |
-
- :bug: The `NewIniDirectives` sniff would report violations against the PHP version in which the ini directive was introduced. This should be the version below it. [#246](https://github.com/wimg/PHPCompatibility/pull/246)
|
502 |
-
- :bug: `PregReplaceEModifier` sniff would report false positives for compound regex parameters with different quote types. [#266](https://github.com/wimg/PHPCompatibility/pull/266). Fixes [#265](https://github.com/wimg/PHPCompatibility/issues/265).
|
503 |
-
- :bug: `RemovedGlobalVariables` sniff would report false positives for lowercase/mixed cased variables shadowing superglobals. [#245](https://github.com/wimg/PHPCompatibility/pull/245).
|
504 |
-
- :bug: The `RemovedHashAlgorithms` sniff would not report errors when the case of the hash function name used and "official" class name did not match. [#240](https://github.com/wimg/PHPCompatibility/pull/240)
|
505 |
-
- :bug: The `ShortArray` sniff would report all violations on the line of the PHP open tag, not on the lines of the short array open/close tags. [#238](https://github.com/wimg/PHPCompatibility/pull/238)
|
506 |
-
|
507 |
-
### Credits
|
508 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
509 |
-
|
510 |
-
|
511 |
-
## [7.0.6] - 2016-09-23
|
512 |
-
|
513 |
-
See all related issues and PRs in the [7.0.6 milestone].
|
514 |
-
|
515 |
-
### Added
|
516 |
-
- :star: New `stripQuotes()` utility method in the `PHPCompatibility_Sniff` base class to strip quotes which surround text strings in a consistent manner. [#224](https://github.com/wimg/PHPCompatibility/pull/224)
|
517 |
-
- :books: Readme: Add _PHP Version Support_ section. [#225](https://github.com/wimg/PHPCompatibility/pull/225)
|
518 |
-
|
519 |
-
### Changed
|
520 |
-
- :pushpin: The `ForbiddenCallTimePassByReference` sniff will now also report the deprecation as of PHP 5.3, not just its removal as of PHP 5.4. [#203](https://github.com/wimg/PHPCompatibility/pull/203)
|
521 |
-
- :pushpin: The `NewFunctionArrayDereferencing` sniff will now also check _method_ calls for array dereferencing, not just function calls. [#229](https://github.com/wimg/PHPCompatibility/pull/229). Fixes [#227](https://github.com/wimg/PHPCompatibility/issues/227).
|
522 |
-
- :pencil2: The `NewExecutionDirectives` sniff will now throw `warning`s instead of `error`s for invalid values encountered in execution directives. [#223](https://github.com/wimg/PHPCompatibility/pull/223)
|
523 |
-
- :pencil2: Minor miscellaneous fixes. [#231](https://github.com/wimg/PHPCompatibility/pull/231)
|
524 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#219](https://github.com/wimg/PHPCompatibility/pull/219), [#203](https://github.com/wimg/PHPCompatibility/pull/203)
|
525 |
-
- :recycle: Defer to upstream `findImplementedInterfaceNames()` utility method when it exists. [#222](https://github.com/wimg/PHPCompatibility/pull/222)
|
526 |
-
- :wrench: Exclude the test files from analysis by Scrutinizer CI. [#230](https://github.com/wimg/PHPCompatibility/pull/230)
|
527 |
-
|
528 |
-
### Removed
|
529 |
-
- :no_entry_sign: Some redundant code. [#232](https://github.com/wimg/PHPCompatibility/pull/232)
|
530 |
-
|
531 |
-
### Fixed
|
532 |
-
- :bug: The `EmptyNonVariable` sniff would throw false positives for variable variables and for array access with a (partially) variable array index. [#212](https://github.com/wimg/PHPCompatibility/pull/212). Fixes [#210](https://github.com/wimg/PHPCompatibility/issues/210).
|
533 |
-
- :bug: The `NewFunctionArrayDereferencing` sniff would throw false positives for lines of code containing both a function call as well as square brackets, even when they were unrelated. [#228](https://github.com/wimg/PHPCompatibility/pull/228). Fixes [#226](https://github.com/wimg/PHPCompatibility/issues/226).
|
534 |
-
- :bug: `ParameterShadowSuperGlobals` sniff would report false positives for lowercase/mixed cased variables shadowing superglobals. [#218](https://github.com/wimg/PHPCompatibility/pull/218). Fixes [#214](https://github.com/wimg/PHPCompatibility/issues/214).
|
535 |
-
- :bug: The `determineNamespace()` utility method now accounts properly for namespaces within scoped `declare()` statements. [#221](https://github.com/wimg/PHPCompatibility/pull/221)
|
536 |
-
- :books: Readme: Logo alignment in the Credits section. [#233](https://github.com/wimg/PHPCompatibility/pull/233)
|
537 |
-
|
538 |
-
### Credits
|
539 |
-
Thanks go out to [Jason Stallings], [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
|
540 |
-
|
541 |
-
|
542 |
-
## [7.0.5] - 2016-09-08
|
543 |
-
|
544 |
-
See all related issues and PRs in the [7.0.5 milestone].
|
545 |
-
|
546 |
-
### Added
|
547 |
-
- :star2: New `MbstringReplaceEModifier` sniff to detect the use of the PHP 7.1 deprecated `e` modifier in Mbstring regex functions. [#202](https://github.com/wimg/PHPCompatibility/pull/202)
|
548 |
-
- :star: The `ForbiddenBreakContinueVariableArguments` sniff will now also report on `break 0`/`continue 0` which is not allowed since PHP 5.4. [#209](https://github.com/wimg/PHPCompatibility/pull/209)
|
549 |
-
- :star: New `getFunctionCallParameters()`, `getFunctionCallParameter()` utility methods in the `PHPCompatibility_Sniff` base class. [#170](https://github.com/wimg/PHPCompatibility/pull/170)
|
550 |
-
- :star: New `tokenHasScope()` utility method in the `PHPCompatibility_Sniff` base class. [#189](https://github.com/wimg/PHPCompatibility/pull/189)
|
551 |
-
- :umbrella: Unit test for `goto` and `callable` detection and some other miscellanous extra unit tests for the `NewKeywords` sniff. [#189](https://github.com/wimg/PHPCompatibility/pull/189)
|
552 |
-
- :books: Readme: Information for sniff developers about running unit tests for _other_ sniff libraries using the PHPCS native test framework without running into conflicts with the PHPCompatibility specific unit test framework. [#217](https://github.com/wimg/PHPCompatibility/pull/217)
|
553 |
-
|
554 |
-
### Changed
|
555 |
-
- :pushpin: The `ForbiddenNames` sniff will now also check interface declarations for usage of reserved keywords. [#200](https://github.com/wimg/PHPCompatibility/pull/200)
|
556 |
-
- :pushpin: `PregReplaceEModifier` sniff: improved handling of regexes build up of a combination of variables, function calls and/or text strings. [#201](https://github.com/wimg/PHPCompatibility/pull/201)
|
557 |
-
- :rewind: The `NewKeywords` sniff will now also correctly recognize new keywords when used in combination with older PHPCS versions and/or run on older PHP versions. [#189](https://github.com/wimg/PHPCompatibility/pull/189)
|
558 |
-
- :pencil2: `PregReplaceEModifier` sniff: minor improvement to the error message text. [#201](https://github.com/wimg/PHPCompatibility/pull/201)
|
559 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#170](https://github.com/wimg/PHPCompatibility/pull/170), [#188](https://github.com/wimg/PHPCompatibility/pull/188), [#189](https://github.com/wimg/PHPCompatibility/pull/189), [#199](https://github.com/wimg/PHPCompatibility/pull/199), [#200](https://github.com/wimg/PHPCompatibility/pull/200), [#201](https://github.com/wimg/PHPCompatibility/pull/201), [#208](https://github.com/wimg/PHPCompatibility/pull/208)
|
560 |
-
- :wrench: The unit tests for the utility methods have been moved to their own subdirectory within `Tests`. [#215](https://github.com/wimg/PHPCompatibility/pull/215)
|
561 |
-
- :green_heart: The sniffs are now also tested against PHP 7.1 for consistent results. [#216](https://github.com/wimg/PHPCompatibility/pull/216)
|
562 |
-
|
563 |
-
### Removed
|
564 |
-
- :no_entry_sign: Some redundant code. [26d0b6](https://github.com/wimg/PHPCompatibility/commit/26d0b6cf0921f75d93a4faaf09c390f386dde9ff) and [841616](https://github.com/wimg/PHPCompatibility/commit/8416162ea81f4067226324f5948f4a50f7958a9b)
|
565 |
-
|
566 |
-
### Fixed
|
567 |
-
- :bug: `ConstantArraysUsingDefine` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#199](https://github.com/wimg/PHPCompatibility/pull/199)
|
568 |
-
- :bug: The `DeprecatedIniDirectives` and `NewIniDirectives` sniffs could potentially trigger on the ini value instead of the ini directive name. [#170](https://github.com/wimg/PHPCompatibility/pull/170)
|
569 |
-
- :bug: `ForbiddenNames` sniff: Reserved keywords when used as the name of a constant declared using `define()` would always be reported independently of the `testVersion` set. [#200](https://github.com/wimg/PHPCompatibility/pull/200)
|
570 |
-
- :bug: `PregReplaceEModifier` sniff would not report errors when the function name used was not in lowercase. [#201](https://github.com/wimg/PHPCompatibility/pull/201)
|
571 |
-
- :bug: `TernaryOperators` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#188](https://github.com/wimg/PHPCompatibility/pull/188)
|
572 |
-
- :bug: The `getFQClassNameFromNewToken()` and `getFQClassNameFromDoubleColonToken()` utility methods would get confused when the class name was a variable instead of being hard-coded, resulting in a PHP warning being thown. [#206](https://github.com/wimg/PHPCompatibility/pull/206). Fixes [#205](https://github.com/wimg/PHPCompatibility/issues/205).
|
573 |
-
- :bug: The `getFunctionCallParameters()` utility method would incorrectly identify an extra parameter if the last parameter passed to a function would have an - unnecessary - comma after it. The `getFunctionCallParameters()` utility method also did not handle parameters passed as short arrays correctly. [#213](https://github.com/wimg/PHPCompatibility/pull/213). Fixes [#211](https://github.com/wimg/PHPCompatibility/issues/211).
|
574 |
-
- :umbrella: Unit tests for the `NewFunctionArrayDereferencing` sniff were not being run due to a naming error. [#208](https://github.com/wimg/PHPCompatibility/pull/208)
|
575 |
-
- :books: Readme: Information about setting the `testVersion` from a custom ruleset was incorrect. [#204](https://github.com/wimg/PHPCompatibility/pull/204)
|
576 |
-
- :wrench: Path to PHPCS in the unit tests breaking for non-Composer installs. [#198](https://github.com/wimg/PHPCompatibility/pull/198)
|
577 |
-
|
578 |
-
### Credits
|
579 |
-
Thanks go out to [Juliette Reinders Folmer] and [Yoshiaki Yoshida] for their contributions to this version. :clap:
|
580 |
-
|
581 |
-
|
582 |
-
## [7.0.4] - 2016-08-20
|
583 |
-
|
584 |
-
See all related issues and PRs in the [7.0.4 milestone].
|
585 |
-
|
586 |
-
### Added
|
587 |
-
- :star2: New `EmptyNonVariable` sniff: detection of empty being used on non-variables for PHP < 5.5. [#187](https://github.com/wimg/PHPCompatibility/pull/187)
|
588 |
-
- :star2: New `NewMagicMethods` sniff: detection of declaration of magic methods before the method became "magic". Includes a check for the changed behaviour for the `__toString()` magic method in PHP 5.2. [#176](https://github.com/wimg/PHPCompatibility/pull/176). Fixes [#64](https://github.com/wimg/PHPCompatibility/issues/64).
|
589 |
-
- :star2: New `RemovedAlternativePHPTags` sniff: detection of ASP and script open tags for which support was removed in PHP 7.0. [#184](https://github.com/wimg/PHPCompatibility/pull/184), [#193](https://github.com/wimg/PHPCompatibility/pull/193). Fixes [#127](https://github.com/wimg/PHPCompatibility/issues/127).
|
590 |
-
- :star: `NonStaticMagicMethods` sniff: detection of the `__callStatic()`, `__sleep()`, `__toString()` and `__set_state()` magic methods.
|
591 |
-
- :green_heart: Lint all non-test case files for syntax errors during the build testing by Travis. [#192](https://github.com/wimg/PHPCompatibility/pull/192)
|
592 |
-
|
593 |
-
### Changed
|
594 |
-
- :pushpin: `NonStaticMagicMethods` sniff: will now also sniff `trait`s for magic methods. [#174](https://github.com/wimg/PHPCompatibility/pull/174)
|
595 |
-
- :pushpin: `NonStaticMagicMethods` sniff: will now also check for magic methods which should be declared as `static`. [#174](https://github.com/wimg/PHPCompatibility/pull/174)
|
596 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#178](https://github.com/wimg/PHPCompatibility/pull/178), [#179](https://github.com/wimg/PHPCompatibility/pull/179), [#174](https://github.com/wimg/PHPCompatibility/pull/174), [#171](https://github.com/wimg/PHPCompatibility/pull/171)
|
597 |
-
- :recycle: The unit test suite now internally caches PHPCS run results in combination with a set `testVersion` to speed up the running of the unit tests. These are now ~3 x faster. [#148](https://github.com/wimg/PHPCompatibility/pull/148)
|
598 |
-
- :books: Readme: Minor clarification of the minimum requirements.
|
599 |
-
- :books: Readme: Advise to use the latest stable version of this repository.
|
600 |
-
- :wrench: The unit tests can now be run with PHPCS installed in an arbitrary location by passing the location through an environment option. [#191](https://github.com/wimg/PHPCompatibility/pull/191).
|
601 |
-
- :wrench: Improved coveralls configuration and compatibility. [#194](https://github.com/wimg/PHPCompatibility/pull/194)
|
602 |
-
- :green_heart: The sniffs are now also tested against PHP 5.2 for consistent results. Except for namespace, trait and group use related errors, most sniffs work as intended on PHP 5.2. [#196](https://github.com/wimg/PHPCompatibility/pull/196)
|
603 |
-
|
604 |
-
### Fixed
|
605 |
-
- :bug: The `ForbiddenBreakContinueVariableArguments` sniff would not report on `break`/`continue` with a closure as an argument. [#171](https://github.com/wimg/PHPCompatibility/pull/171)
|
606 |
-
- :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would not report on reserved keywords which were not lowercase. [#186](https://github.com/wimg/PHPCompatibility/pull/186)
|
607 |
-
- :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would not report on the `goto` and `namespace` keywords when run on PHP 5.2. [#193](https://github.com/wimg/PHPCompatibility/pull/193)
|
608 |
-
- :bug: `NewAnonymousClasses` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#195](https://github.com/wimg/PHPCompatibility/pull/195).
|
609 |
-
- :bug: `NewGroupUseDeclarations` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#190](https://github.com/wimg/PHPCompatibility/pull/190).
|
610 |
-
- :bug: The `NonStaticMagicMethods` sniff would not report on magic methods when the function name as declared was not in the same case as used in the PHP manual. [#174](https://github.com/wimg/PHPCompatibility/pull/174)
|
611 |
-
- :wrench: The unit tests would exit with `0` if PHPCS could not be found. [#191](https://github.com/wimg/PHPCompatibility/pull/191)
|
612 |
-
- :green_heart: The PHPCompatibility library itself was not fully compatible with PHP 5.2. [#193](https://github.com/wimg/PHPCompatibility/pull/193)
|
613 |
-
|
614 |
-
### Credits
|
615 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
616 |
-
|
617 |
-
|
618 |
-
## [7.0.3] - 2016-08-18
|
619 |
-
|
620 |
-
See all related issues and PRs in the [7.0.3 milestone].
|
621 |
-
|
622 |
-
### Added
|
623 |
-
- :star2: New `InternalInterfaces` sniff: detection of internal PHP interfaces being which should not be implemented by user land classes. [#144](https://github.com/wimg/PHPCompatibility/pull/144)
|
624 |
-
- :star2: New `LateStaticBinding` sniff: detection of PHP 5.3 late static binding. [#177](https://github.com/wimg/PHPCompatibility/pull/177)
|
625 |
-
- :star2: New `NewExecutionDirectives` sniff: verify execution directives set with `declare()`. [#169](https://github.com/wimg/PHPCompatibility/pull/169)
|
626 |
-
- :star2: New `NewInterfaces` sniff: detection of the use of newly introduced PHP native interfaces. This sniff will also detect unsupported methods when a class implements the `Serializable` interface. [#144](https://github.com/wimg/PHPCompatibility/pull/144)
|
627 |
-
- :star2: New `RequiredOptionalFunctionParameters` sniff: detection of missing function parameters which were required in earlier PHP versions only to become optional in later versions. [#165](https://github.com/wimg/PHPCompatibility/pull/165)
|
628 |
-
- :star2: New `ValidIntegers` sniff: detection of binary integers for PHP < 5.4, detection of hexademical numeric strings for which recognition as hex integers was removed in PHP 7.0, detection of invalid binary and octal integers. [#160](https://github.com/wimg/PHPCompatibility/pull/160). Fixes [#55](https://github.com/wimg/PHPCompatibility/issues/55).
|
629 |
-
- :star: `DeprecatedExtensions` sniff: detect removal of the `ereg` extension in PHP 7. [#149](https://github.com/wimg/PHPCompatibility/pull/149)
|
630 |
-
- :star: `DeprecatedFunctions` sniff: detection of the PHP 5.0.5 deprecated `php_check_syntax()` and PHP 5.4 deprecated `mysqli_get_cache_stats()` functions. [#155](https://github.com/wimg/PHPCompatibility/pull/155).
|
631 |
-
- :star: `DeprecatedFunctions` sniff: detect deprecation of a number of the `mysqli` functions in PHP 5.3. [#149](https://github.com/wimg/PHPCompatibility/pull/149)
|
632 |
-
- :star: `DeprecatedFunctions` sniff: detect removal of the `call_user_method()`, `ldap_sort()`, `ereg_*()` and `mysql_*()` functions in PHP 7.0. [#149](https://github.com/wimg/PHPCompatibility/pull/149)
|
633 |
-
- :star: `DeprecatedIniDirectives` sniff: detection of a _lot_ more deprecated/removed ini directives. [#146](https://github.com/wimg/PHPCompatibility/pull/146)
|
634 |
-
- :star: `NewFunctionParameters` sniff: detection of a _lot_ more new function parameters. [#164](https://github.com/wimg/PHPCompatibility/pull/164)
|
635 |
-
- :star: `NewFunctions` sniff: detection of numerous extra new functions. [#161](https://github.com/wimg/PHPCompatibility/pull/161)
|
636 |
-
- :star: `NewIniDirectives` sniff: detection of a _lot_ more new ini directives. [#146](https://github.com/wimg/PHPCompatibility/pull/146)
|
637 |
-
- :star: `NewLanguageConstructs` sniff: detection of the PHP 5.6 ellipsis `...` construct. [#175](https://github.com/wimg/PHPCompatibility/pull/175)
|
638 |
-
- :star: `NewScalarTypeDeclarations` sniff: detection of PHP 5.1 `array` and PHP 5.4 `callable` type hints. [#168](https://github.com/wimg/PHPCompatibility/pull/168)
|
639 |
-
- :star: `RemovedFunctionParameters` sniff: detection of a few extra removed function parameters. [#163](https://github.com/wimg/PHPCompatibility/pull/163)
|
640 |
-
- :star: Detection of functions and methods with a double underscore prefix as these are reserved by PHP for future use. The existing upstream `Generic.NamingConventions.CamelCapsFunctionName` sniff is re-used for this with some customization. [#173](https://github.com/wimg/PHPCompatibility/pull/173)
|
641 |
-
- :star: New `getFQClassNameFromNewToken()`, `getFQExtendedClassName()`, `getFQClassNameFromDoubleColonToken()`, `getFQName()`, `isNamespaced()`, `determineNamespace()` and `getDeclaredNamespaceName()` utility methods in the `PHPCompatibility_Sniff` base class for namespace determination. [#162](https://github.com/wimg/PHPCompatibility/pull/162)
|
642 |
-
- :recycle: New `inClassScope()` utility method in the `PHPCompatibility_Sniff` base class. [#168](https://github.com/wimg/PHPCompatibility/pull/168)
|
643 |
-
- :recycle: New `doesFunctionCallHaveParameters()` and `getFunctionCallParameterCount()` utility methods in the `PHPCompatibility_Sniff` base class. [#153](https://github.com/wimg/PHPCompatibility/pull/153)
|
644 |
-
- :umbrella: Unit test for `__halt_compiler()` detection by the `NewKeywords` sniff.
|
645 |
-
- :umbrella: Unit tests for the `NewFunctions` sniff. [#161](https://github.com/wimg/PHPCompatibility/pull/161)
|
646 |
-
- :umbrella: Unit tests for the `ParameterShadowSuperGlobals` sniff. [#180](https://github.com/wimg/PHPCompatibility/pull/180)
|
647 |
-
- :wrench: Minimal config for Scrutinizer CI. [#145](https://github.com/wimg/PHPCompatibility/pull/145).
|
648 |
-
|
649 |
-
### Changed
|
650 |
-
- :pushpin: The `DeprecatedIniDirectives` and the `NewIniDirectives` sniffs will now indicate an alternative ini directive in case the directive has been renamed. [#146](https://github.com/wimg/PHPCompatibility/pull/146)
|
651 |
-
- :pushpin: The `NewClasses` sniff will now also report on new classes being extended by child classes. [#140](https://github.com/wimg/PHPCompatibility/pull/140).
|
652 |
-
- :pushpin: The `NewClasses` sniff will now also report on static use of new classes. [#162](https://github.com/wimg/PHPCompatibility/pull/162).
|
653 |
-
- :pushpin: The `NewScalarTypeDeclarations` sniff will now throw an error on use of type hints pre-PHP 5.0. [#168](https://github.com/wimg/PHPCompatibility/pull/168)
|
654 |
-
- :pushpin: The `NewScalarTypeDeclarations` sniff will now verify type hints used against typical mistakes. [#168](https://github.com/wimg/PHPCompatibility/pull/168)
|
655 |
-
- :pushpin: The `ParameterShadowSuperGlobals` sniff will now do a case-insensitive variable name compare. [#180](https://github.com/wimg/PHPCompatibility/pull/180)
|
656 |
-
- :pushpin: The `RemovedFunctionParameters` sniff will now also report `warning`s on deprecation of function parameters. [#163](https://github.com/wimg/PHPCompatibility/pull/163)
|
657 |
-
- :twisted_rightwards_arrows: The check for `JsonSerializable` has been moved from the `NewClasses` sniff to the `NewInterfaces` sniff. [#162](https://github.com/wimg/PHPCompatibility/pull/162)
|
658 |
-
- :rewind: The `NewLanguageConstructs` sniff will now also recognize new language constructs when used in combination with PHPCS 1.5.x. [#175](https://github.com/wimg/PHPCompatibility/pull/175)
|
659 |
-
- :pencil2: `NewFunctionParameters` sniff: use correct name for the new parameter for the `dirname()` function. [#164](https://github.com/wimg/PHPCompatibility/pull/164)
|
660 |
-
- :pencil2: `NewScalarTypeDeclarations` sniff: minor change in the sniff error message text. [#168](https://github.com/wimg/PHPCompatibility/pull/168)
|
661 |
-
- :pencil2: `RemovedFunctionParameters` sniff: minor change in the sniff error message text. [#163](https://github.com/wimg/PHPCompatibility/pull/163)
|
662 |
-
- :pencil2: The `ParameterShadowSuperGlobals` sniff now extends the `PHPCompatibility_Sniff` class. [#180](https://github.com/wimg/PHPCompatibility/pull/180)
|
663 |
-
- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#181](https://github.com/wimg/PHPCompatibility/pull/181), [#182](https://github.com/wimg/PHPCompatibility/pull/182), [#166](https://github.com/wimg/PHPCompatibility/pull/166), [#167](https://github.com/wimg/PHPCompatibility/pull/167), [#172](https://github.com/wimg/PHPCompatibility/pull/172), [#180](https://github.com/wimg/PHPCompatibility/pull/180), [#146](https://github.com/wimg/PHPCompatibility/pull/146), [#138](https://github.com/wimg/PHPCompatibility/pull/138)
|
664 |
-
- :recycle: Various refactoring to remove code duplication in the unit tests and add proper test skip notifications where relevant. [#139](https://github.com/wimg/PHPCompatibility/pull/139), [#149](https://github.com/wimg/PHPCompatibility/pull/149)
|
665 |
-
|
666 |
-
### Fixed
|
667 |
-
- :bug: The `DeprecatedFunctions` sniff was reporting an incorrect deprecation/removal version number for a few functions. [#149](https://github.com/wimg/PHPCompatibility/pull/149)
|
668 |
-
- :bug: The `DeprecatedIniDirectives` sniff was in select cases reporting deprecation of an ini directive prior to removal, while the ini directive was never deprecated prior to its removal. [#146](https://github.com/wimg/PHPCompatibility/pull/146)
|
669 |
-
- :bug: The `DeprecatedPHP4StyleConstructors` sniff would cause false positives for methods with the same name as the class in namespaced classes. [#167](https://github.com/wimg/PHPCompatibility/pull/167)
|
670 |
-
- :bug: The `ForbiddenEmptyListAssignment` sniff did not report errors when there were only comments or parentheses between the list parentheses. [#166](https://github.com/wimg/PHPCompatibility/pull/166)
|
671 |
-
- :bug: The `ForbiddenEmptyListAssignment` sniff will no longer cause false positives during live coding. [#166](https://github.com/wimg/PHPCompatibility/pull/166)
|
672 |
-
- :bug: The `NewClasses` sniff would potentially misidentify namespaced classes as PHP native classes. [#161](https://github.com/wimg/PHPCompatibility/pull/162)
|
673 |
-
- :bug: The `NewFunctions` sniff would fail to identify called functions when the function call was not lowercase. [#161](https://github.com/wimg/PHPCompatibility/pull/161)
|
674 |
-
- :bug: The `NewFunctions` sniff would potentially misidentify namespaced userland functions as new functions. [#161](https://github.com/wimg/PHPCompatibility/pull/161)
|
675 |
-
- :bug: The `NewIniDirectives` sniff was reporting an incorrect introduction version number for a few ini directives. [#146](https://github.com/wimg/PHPCompatibility/pull/146)
|
676 |
-
- :bug: `NewKeywords` sniff: the use of the `const` keyword should only be reported when used outside of a class for PHP < 5.3. [#147](https://github.com/wimg/PHPCompatibility/pull/147). Fixes [#129](https://github.com/wimg/PHPCompatibility/issues/129).
|
677 |
-
- :bug: The `RemovedExtensions` sniff was incorrectly reporting a number of extensions as being removed in PHP 5.3 while they were actually removed in PHP 5.1. [#156](https://github.com/wimg/PHPCompatibility/pull/156)
|
678 |
-
- :bug: :recycle: The `NewFunctionParameters` and `RemovedFunctionParameters` now use the new `doesFunctionCallHaveParameters()` and `getFunctionCallParameterCount()` utility methods for improved accuracy in identifying function parameters. This fixes several false positives. [#153](https://github.com/wimg/PHPCompatibility/pull/153) Fixes [#120](https://github.com/wimg/PHPCompatibility/issues/120), [#151](https://github.com/wimg/PHPCompatibility/issues/151), [#152](https://github.com/wimg/PHPCompatibility/issues/152).
|
679 |
-
- :bug: A number of sniffs would return `false` if the examined construct was not found. This could potentially cause race conditions/infinite sniff loops. [#138](https://github.com/wimg/PHPCompatibility/pull/138)
|
680 |
-
- :wrench: The unit tests would fail to run when used in combination with a PEAR install of PHPCS. [#157](https://github.com/wimg/PHPCompatibility/pull/157).
|
681 |
-
- :green_heart: Unit tests failing against PHPCS 2.6.1. [#158](https://github.com/wimg/PHPCompatibility/pull/158)
|
682 |
-
The unit tests *will* still fail against PHPCS 2.6.2 due to a bug in PHPCS itself. This bug does not affect the running of the sniffs outside of a unit test context.
|
683 |
-
|
684 |
-
### Credits
|
685 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
686 |
-
|
687 |
-
|
688 |
-
## [7.0.2] - 2016-08-03
|
689 |
-
|
690 |
-
See all related issues and PRs in the [7.0.2 milestone].
|
691 |
-
|
692 |
-
### Added
|
693 |
-
- :star: `RemovedExtensions` sniff: ability to whitelist userland functions for which the function prefix overlaps with a prefix of a deprecated/removed extension. [#130](https://github.com/wimg/PHPCompatibility/pull/130). Fixes [#123](https://github.com/wimg/PHPCompatibility/issues/123).
|
694 |
-
To use this feature, add the `functionWhitelist` property in your custom ruleset. For more information, see the [README](https://github.com/wimg/PHPCompatibility#phpcompatibility-specific-options).
|
695 |
-
|
696 |
-
### Changed
|
697 |
-
- :pencil2: A number of sniffs contained `public` class properties. Within PHPCS, `public` properties can be overruled via a custom ruleset. This was not the intention, so the visibility of these properties has been changed to `protected`. [#135](https://github.com/wimg/PHPCompatibility/pull/135)
|
698 |
-
- :wrench: Composer config: Stable packages are preferred over unstable/dev.
|
699 |
-
- :pencil2: Ruleset name. [#134](https://github.com/wimg/PHPCompatibility/pull/134)
|
700 |
-
|
701 |
-
### Credits
|
702 |
-
Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
|
703 |
-
|
704 |
-
|
705 |
-
## [7.0.1] - 2016-08-02
|
706 |
-
|
707 |
-
See all related issues and PRs in the [7.0.1 milestone].
|
708 |
-
|
709 |
-
### Changed
|
710 |
-
- :pushpin: The `DeprecatedIniDirectives` sniff used to throw an `error` when a deprecated ini directive was used in combination with `ini_get()`. It will now throw a `warning` instead. [#122](https://github.com/wimg/PHPCompatibility/pull/122) Fixes [#119](https://github.com/wimg/PHPCompatibility/issues/119).
|
711 |
-
Usage of deprecated ini directives in combination with `ini_set()` will still throw an `error`.
|
712 |
-
- :pushpin: The `PregReplaceEModifier` sniff now also detects the `e` modifier when used with the `preg_filter()` function. While this is undocumented, the `e` modifier was supported by the `preg_filter()` function as well. [#128](https://github.com/wimg/PHPCompatibility/pull/128)
|
713 |
-
- :pencil2: The `RemovedExtensions` sniff contained superfluous deprecation information in the error message. [#131](https://github.com/wimg/PHPCompatibility/pull/131)
|
714 |
-
|
715 |
-
### Removed
|
716 |
-
- :wrench: Duplicate builds from the Travis CI build matrix. [#132](https://github.com/wimg/PHPCompatibility/pull/132)
|
717 |
-
|
718 |
-
### Fixed
|
719 |
-
- :bug: The `ForbiddenNames` sniff did not allow for the PHP 5.6 `use function ...` and `use const ...` syntax. [#126](https://github.com/wimg/PHPCompatibility/pull/126) Fixes [#124](https://github.com/wimg/PHPCompatibility/issues/124).
|
720 |
-
- :bug: The `NewClasses` sniff failed to detect new classes when the class was instantiated without parenthesis, i.e. `new NewClass;`. [#121](https://github.com/wimg/PHPCompatibility/pull/121)
|
721 |
-
- :bug: The `PregReplaceEModifier` sniff failed to detect the `e` modifier when using bracket delimiters for the regex other than the `{}` brackets. [#128](https://github.com/wimg/PHPCompatibility/pull/128)
|
722 |
-
- :green_heart: Unit tests failing against PHPCS 2.6.1.
|
723 |
-
|
724 |
-
### Credits
|
725 |
-
Thanks go out to [Jason Stallings], [Juliette Reinders Folmer] and [Ryan Neufeld] for their contributions to this version. :clap:
|
726 |
-
|
727 |
-
|
728 |
-
## [7.0] - 2016-07-02
|
729 |
-
|
730 |
-
See all related issues and PRs in the [7.0 milestone].
|
731 |
-
|
732 |
-
### Added
|
733 |
-
- :zap: Ability to specify a range of PHP versions against which to test your code base for compatibility, i.e. `--runtime-set testVersion 5.0-5.4` will now test your code for compatibility with PHP 5.0 up to PHP 5.4. [#99](https://github.com/wimg/PHPCompatibility/pull/99)
|
734 |
-
- :star2: New `NewFunctionArrayDereferencing` sniff to detect function array dereferencing as introduced in PHP 5.4. Fixes [#52](https://github.com/wimg/PHPCompatibility/issues/52).
|
735 |
-
- :star2: New `ShortArray` sniff to detect short array syntax as introduced in PHP 5.4. [#97](https://github.com/wimg/PHPCompatibility/pull/97). Fixes [#47](https://github.com/wimg/PHPCompatibility/issues/47).
|
736 |
-
- :star2: New `TernaryOperators` sniff to detect ternaries without the middle part (`elvis` operator) as introduced in PHP 5.3. [#101](https://github.com/wimg/PHPCompatibility/pull/101), [#103](https://github.com/wimg/PHPCompatibility/pull/103). Fixes [#49](https://github.com/wimg/PHPCompatibility/issues/49).
|
737 |
-
- :star2: New `ConstantArraysUsingDefine` sniff to detect constants declared using `define()` being assigned an `array` value which was not allowed prior to PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
738 |
-
- :star2: New `DeprecatedPHP4StyleConstructors` sniff to detect PHP 4 style class constructor methods which are deprecated as of PHP 7. [#109](https://github.com/wimg/PHPCompatibility/pull/109).
|
739 |
-
- :star2: New `ForbiddenEmptyListAssignment` sniff to detect empty list() assignments which have been removed in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
740 |
-
- :star2: New `ForbiddenFunctionParametersWithSameName` sniff to detect functions declared with multiple same-named parameters which is no longer accepted since PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
741 |
-
- :star2: New `ForbiddenGlobalVariableVariable` sniff to detect variable variables being made `global` which is not allowed since PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
742 |
-
- :star2: New `ForbiddenNegativeBitshift` sniff to detect bitwise shifts by negative number which will throw an ArithmeticError in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
743 |
-
- :star2: New `ForbiddenSwitchWithMultipleDefaultBlocks` sniff to detect switch statements with multiple default blocks which is not allowed since PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
744 |
-
- :star2: New `NewAnonymousClasses` sniff to detect anonymous classes as introduced in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
745 |
-
- :star2: New `NewFunctionParameters` sniff to detect use of new parameters in build-in PHP functions. Initially only sniffing for the new PHP 7.0 function parameters and the new PHP 5.3+ `before_needle` parameter for the `strstr()` function. [#110](https://github.com/wimg/PHPCompatibility/pull/110), [#112](https://github.com/wimg/PHPCompatibility/pull/112). Fixes [#27](https://github.com/wimg/PHPCompatibility/issues/27).
|
746 |
-
- :star2: New `NewGroupUseDeclarations` sniff to detect group use declarations as introduced in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
747 |
-
- :star2: New `NewScalarReturnTypeDeclarations` sniff to detect scalar return type hints as introduced in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
748 |
-
- :star2: New `NewScalarTypeDeclarations` sniff to detect scalar function parameter type hints as introduced in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
749 |
-
- :star2: New `RemovedFunctionParameters` sniff to detect use of removed parameters in build-in PHP functions. Initially only sniffing for the function parameters removed in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
750 |
-
- :star2: New `RemovedGlobalVariables` sniff to detect the PHP 7.0 removed `$HTTP_RAW_POST_DATA` superglobal. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
751 |
-
- :star: `DeprecatedFunctions` sniff: detection of the PHP 5.4 deprecated OCI8 functions. [#93](https://github.com/wimg/PHPCompatibility/pull/93)
|
752 |
-
- :star: `ForbiddenNamesAsInvokedFunctions` sniff: recognize PHP 5.5 `finally` as a reserved keywords when invoked as a function. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
753 |
-
- :star: `NewKeywords` sniff: detection of the use of the PHP 5.1+ `__halt_compiler` keyword. Fixes [#50](https://github.com/wimg/PHPCompatibility/issues/50).
|
754 |
-
- :star: `NewKeywords` sniff: detection of the PHP 5.3+ `nowdoc` syntax. Fixes [#48](https://github.com/wimg/PHPCompatibility/issues/48).
|
755 |
-
- :star: `NewKeywords` sniff: detection of the use of the `const` keyword outside of a class for PHP < 5.3. Fixes [#50](https://github.com/wimg/PHPCompatibility/issues/50).
|
756 |
-
- :star: `DeprecatedFunctions` sniff: recognize PHP 7.0 deprecated and removed functions. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
757 |
-
- :star: `DeprecatedIniDirectives` sniff: recognize PHP 7.0 removed ini directives. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
758 |
-
- :star: `ForbiddenNamesAsInvokedFunctions` sniff: recognize new PHP 7.0 reserved keywords when invoked as functions. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
759 |
-
- :star: `ForbiddenNames` sniff: recognize new PHP 7.0 reserved keywords. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
760 |
-
- :star: `NewFunctions` sniff: recognize new functions as introduced in PHP 7.0. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
761 |
-
- :star: `NewLanguageConstructs` sniff: recognize new PHP 7.0 `<=>` "spaceship" and `??` null coalescing operators. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
762 |
-
- :star: `RemovedExtensions` sniff: recognize PHP 7.0 removed `ereg`, `mssql`, `mysql` and `sybase_ct` extensions. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
763 |
-
- :umbrella: Additional unit tests for the `NewLanguageConstructs` sniff. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
764 |
-
- :books: Readme: New section containing information about the use of the `testVersion` config variable.
|
765 |
-
- :books: Readme: Sponsor credits.
|
766 |
-
|
767 |
-
### Changed
|
768 |
-
- :pushpin: The `DeprecatedIniDirectives` sniff used to always throw an `warning`. Now it will throw an `error` when a removed ini directive is used. [#110](https://github.com/wimg/PHPCompatibility/pull/110).
|
769 |
-
- :pushpin: The `DeprecatedNewReference` sniff will now throw an error when the `testVersion` includes PHP 7.0 or higher. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
770 |
-
- :pushpin: The `ForbiddenNames` sniff now supports detection of reserved keywords when used in combination with PHP 7 anonymous classes. [#108](https://github.com/wimg/PHPCompatibility/pull/108), [#110](https://github.com/wimg/PHPCompatibility/pull/110).
|
771 |
-
- :pushpin: The `PregReplaceEModifier` sniff will now throw an error when the `testVersion` includes PHP 7.0 or higher. [#110](https://github.com/wimg/PHPCompatibility/pull/110)
|
772 |
-
- :pencil2: `NewKeywords` sniff: clarified the error message text for the `use` keyword. Fixes [#46](https://github.com/wimg/PHPCompatibility/issues/46).
|
773 |
-
- :recycle: Minor refactor of the `testVersion` related utility functions. [#98](https://github.com/wimg/PHPCompatibility/pull/98)
|
774 |
-
- :wrench: Add autoload to the `composer.json` file. [#96](https://github.com/wimg/PHPCompatibility/pull/96) Fixes [#67](https://github.com/wimg/PHPCompatibility/issues/67).
|
775 |
-
- :wrench: Minor other updates to the `composer.json` file. [#75](https://github.com/wimg/PHPCompatibility/pull/75)
|
776 |
-
- :wrench: Improved creation of the code coverage reports needed by coveralls via Travis.
|
777 |
-
- :green_heart: The sniffs are now also tested against PHP 7.0 for consistent results.
|
778 |
-
|
779 |
-
### Fixed
|
780 |
-
- :bug: The `ForbiddenCallTimePassByReference` sniff was throwing `Undefined index` notices when used in combination with PHPCS 2.2.0. [#100](https://github.com/wimg/PHPCompatibility/pull/100). Fixes [#42](https://github.com/wimg/PHPCompatibility/issues/42).
|
781 |
-
- :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would incorrectly throw an error if the `throw` keyword was used with parenthesis. Fixes [#118](https://github.com/wimg/PHPCompatibility/issues/118).
|
782 |
-
- :bug: The `PregReplaceEModifier` sniff incorrectly identified `e`'s in the pattern as the `e` modifier when using `{}` bracket delimiters for the regex. [#94](https://github.com/wimg/PHPCompatibility/pull/94)
|
783 |
-
- :bug: The `RemovedExtensions` sniff was throwing an `error` instead of a `warning` for deprecated, but not (yet) removed extensions. Fixes [#62](https://github.com/wimg/PHPCompatibility/issues/62).
|
784 |
-
|
785 |
-
### Credits
|
786 |
-
Thanks go out to AlexMiroshnikov, [Chris Abernethy], [dgudgeon], [djaenecke], [Eugene Maslovich], [Ken Guest], Koen Eelen, [Komarov Alexey], [Mark Clements] and [Remko van Bezooijen] for their contributions to this version. :clap:
|
787 |
-
|
788 |
-
|
789 |
-
## [5.6] - 2015-09-14
|
790 |
-
|
791 |
-
See all related issues and PRs in the [5.6 milestone].
|
792 |
-
|
793 |
-
### Added
|
794 |
-
- :star2: New: `NewLanguageConstructs` sniff. The initial version of this sniff checks for the PHP 5.6 `**` power operator and the `**=` power assignment operator. [#87](https://github.com/wimg/PHPCompatibility/pull/87). Fixes [#60](https://github.com/wimg/PHPCompatibility/issues/60).
|
795 |
-
- :star2: New: `ParameterShadowSuperGlobals` sniff which covers the PHP 5.4 change _Parameter names that shadow super globals now cause a fatal error.`_. [#74](https://github.com/wimg/PHPCompatibility/pull/74)
|
796 |
-
- :star2: New: `PregReplaceEModifier` sniff which detects usage of the `e` modifier in literal regular expressions used with `preg_replace()`. The `e` modifier will not (yet) be detected when the regex passed is a variable or constant. [#81](https://github.com/wimg/PHPCompatibility/pull/81), [#84](https://github.com/wimg/PHPCompatibility/pull/84). Fixes [#71](https://github.com/wimg/PHPCompatibility/issues/71), [#83](https://github.com/wimg/PHPCompatibility/issues/83).
|
797 |
-
- :star: `DeprecatedIniDirectives` sniff: PHP 5.6 deprecated ini directives.
|
798 |
-
- :star: `NewKeywords` sniff: detection of the `goto` keyword introduced in PHP 5.3 and the `callable` keyword introduced in PHP 5.4. [#57](https://github.com/wimg/PHPCompatibility/pull/57)
|
799 |
-
- :recycle: `PHPCompatibility_Sniff` base class initially containing the `supportsAbove()` and `supportsBelow()` utility methods. (Nearly) All sniffs now extend this base class and use these methods to determine whether or not violations should be reported for a set `testVersion`. [#77](https://github.com/wimg/PHPCompatibility/pull/77)
|
800 |
-
- :books: Readme: Composer installation instructions. [#32](https://github.com/wimg/PHPCompatibility/pull/32), [#61](https://github.com/wimg/PHPCompatibility/pull/61)
|
801 |
-
- :wrench: `.gitignore` to ignore vendor and IDE related directories. [#78](https://github.com/wimg/PHPCompatibility/pull/78)
|
802 |
-
- :green_heart: Code coverage checking via coveralls.
|
803 |
-
|
804 |
-
### Changed
|
805 |
-
- :twisted_rightwards_arrows: The check for the `\` namespace separator has been moved from the `NewKeywords` sniff to the `NewLanguageConstructs` sniff. [#88](https://github.com/wimg/PHPCompatibility/pull/88)
|
806 |
-
- :pencil2: `DeprecatedIniDirectives` sniff: minor change in the sniff error message text.
|
807 |
-
- :pencil2: `DeprecatedFunctions` sniff: minor change in the sniff error message text.
|
808 |
-
- :wrench: Minor updates to the `composer.json` file. [#31](https://github.com/wimg/PHPCompatibility/pull/31), [34](https://github.com/wimg/PHPCompatibility/pull/34), [#70](https://github.com/wimg/PHPCompatibility/pull/70)
|
809 |
-
- :wrench: Tests: The unit tests can now be run without configuration.
|
810 |
-
- :wrench: Tests: Skipped unit tests will now be annotated as such. [#85](https://github.com/wimg/PHPCompatibility/pull/85)
|
811 |
-
- :green_heart: The sniffs are now also tested against PHP 5.6 for consistent results.
|
812 |
-
- :green_heart: The sniffs are now also tested against PHPCS 2.0+.
|
813 |
-
- :green_heart: The sniffs are now tested using the new container-based infrastructure in Travis CI. [#37](https://github.com/wimg/PHPCompatibility/pull/37)
|
814 |
-
|
815 |
-
### Fixed
|
816 |
-
- :bug: The `ForbiddenCallTimePassByReference` sniff was throwing false positives when a bitwise and `&` was used in combination with class constants and class properties within function calls. [#44](https://github.com/wimg/PHPCompatibility/pull/44). Fixes [#39](https://github.com/wimg/PHPCompatibility/issues/39).
|
817 |
-
- :bug: The `ForbiddenNamesAsInvokedFunctions` sniff was throwing false positives in certain cases when a comment separated a `try` from the `catch` block. [#29](https://github.com/wimg/PHPCompatibility/pull/29)
|
818 |
-
- :bug: The `ForbiddenNamesAsInvokedFunctions` sniff was incorrectly reporting `instanceof` as being introduced in PHP 5.4 while it has been around since PHP 5.0. [#80](https://github.com/wimg/PHPCompatibility/pull/80)
|
819 |
-
- :white_check_mark: Compatibility with PHPCS 2.0 - 2.3. [#63](https://github.com/wimg/PHPCompatibility/pull/63), [#65](https://github.com/wimg/PHPCompatibility/pull/65)
|
820 |
-
|
821 |
-
### Credits
|
822 |
-
Thanks go out to Daniel Jänecke, [Declan Kelly], [Dominic], [Jaap van Otterdijk], [Marin Crnkovic], [Mark Clements], [Nick Pack], [Oliver Klee], [Rowan Collins] and [Sam Van der Borght] for their contributions to this version. :clap:
|
823 |
-
|
824 |
-
|
825 |
-
## 5.5 - 2014-04-04
|
826 |
-
|
827 |
-
First tagged release.
|
828 |
-
|
829 |
-
See all related issues and PRs in the [5.5 milestone].
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
[Unreleased]: https://github.com/wimg/PHPCompatibility/compare/8.1.0...HEAD
|
834 |
-
[8.1.0]: https://github.com/wimg/PHPCompatibility/compare/8.0.1...8.1.0
|
835 |
-
[8.0.1]: https://github.com/wimg/PHPCompatibility/compare/8.0.0...8.0.1
|
836 |
-
[8.0.0]: https://github.com/wimg/PHPCompatibility/compare/7.1.5...8.0.0
|
837 |
-
[7.1.5]: https://github.com/wimg/PHPCompatibility/compare/7.1.4...7.1.5
|
838 |
-
[7.1.4]: https://github.com/wimg/PHPCompatibility/compare/7.1.3...7.1.4
|
839 |
-
[7.1.3]: https://github.com/wimg/PHPCompatibility/compare/7.1.2...7.1.3
|
840 |
-
[7.1.2]: https://github.com/wimg/PHPCompatibility/compare/7.1.1...7.1.2
|
841 |
-
[7.1.1]: https://github.com/wimg/PHPCompatibility/compare/7.1.0...7.1.1
|
842 |
-
[7.1.0]: https://github.com/wimg/PHPCompatibility/compare/7.0.8...7.1.0
|
843 |
-
[7.0.8]: https://github.com/wimg/PHPCompatibility/compare/7.0.7...7.0.8
|
844 |
-
[7.0.7]: https://github.com/wimg/PHPCompatibility/compare/7.0.6...7.0.7
|
845 |
-
[7.0.6]: https://github.com/wimg/PHPCompatibility/compare/7.0.5...7.0.6
|
846 |
-
[7.0.5]: https://github.com/wimg/PHPCompatibility/compare/7.0.4...7.0.5
|
847 |
-
[7.0.4]: https://github.com/wimg/PHPCompatibility/compare/7.0.3...7.0.4
|
848 |
-
[7.0.3]: https://github.com/wimg/PHPCompatibility/compare/7.0.2...7.0.3
|
849 |
-
[7.0.2]: https://github.com/wimg/PHPCompatibility/compare/7.0.1...7.0.2
|
850 |
-
[7.0.1]: https://github.com/wimg/PHPCompatibility/compare/7.0...7.0.1
|
851 |
-
[7.0]: https://github.com/wimg/PHPCompatibility/compare/5.6...7.0
|
852 |
-
[5.6]: https://github.com/wimg/PHPCompatibility/compare/5.5...5.6
|
853 |
-
|
854 |
-
[8.1.0 milestone]: https://github.com/wimg/PHPCompatibility/milestone/21
|
855 |
-
[8.0.1 milestone]: https://github.com/wimg/PHPCompatibility/milestone/20
|
856 |
-
[8.0.0 milestone]: https://github.com/wimg/PHPCompatibility/milestone/19
|
857 |
-
[7.1.5 milestone]: https://github.com/wimg/PHPCompatibility/milestone/17
|
858 |
-
[7.1.4 milestone]: https://github.com/wimg/PHPCompatibility/milestone/15
|
859 |
-
[7.1.3 milestone]: https://github.com/wimg/PHPCompatibility/milestone/14
|
860 |
-
[7.1.2 milestone]: https://github.com/wimg/PHPCompatibility/milestone/13
|
861 |
-
[7.1.1 milestone]: https://github.com/wimg/PHPCompatibility/milestone/12
|
862 |
-
[7.1.0 milestone]: https://github.com/wimg/PHPCompatibility/milestone/11
|
863 |
-
[7.0.8 milestone]: https://github.com/wimg/PHPCompatibility/milestone/10
|
864 |
-
[7.0.7 milestone]: https://github.com/wimg/PHPCompatibility/milestone/9
|
865 |
-
[7.0.6 milestone]: https://github.com/wimg/PHPCompatibility/milestone/8
|
866 |
-
[7.0.5 milestone]: https://github.com/wimg/PHPCompatibility/milestone/7
|
867 |
-
[7.0.4 milestone]: https://github.com/wimg/PHPCompatibility/milestone/6
|
868 |
-
[7.0.3 milestone]: https://github.com/wimg/PHPCompatibility/milestone/5
|
869 |
-
[7.0.2 milestone]: https://github.com/wimg/PHPCompatibility/milestone/4
|
870 |
-
[7.0.1 milestone]: https://github.com/wimg/PHPCompatibility/milestone/3
|
871 |
-
[7.0 milestone]: https://github.com/wimg/PHPCompatibility/milestone/2
|
872 |
-
[5.6 milestone]: https://github.com/wimg/PHPCompatibility/milestone/1
|
873 |
-
[5.5 milestone]: https://github.com/wimg/PHPCompatibility/milestone/16
|
874 |
-
|
875 |
-
[Arthur Edamov]: https://github.com/edamov
|
876 |
-
[Chris Abernethy]: https://github.com/cabernet-zerve
|
877 |
-
[Declan Kelly]: https://github.com/declank
|
878 |
-
[dgudgeon]: https://github.com/dgudgeon
|
879 |
-
[djaenecke]: https://github.com/djaenecke
|
880 |
-
[Dominic]: https://github.com/dol
|
881 |
-
[Eugene Maslovich]: https://github.com/ehpc
|
882 |
-
[Gary Jones]: https://github.com/GaryJones
|
883 |
-
[Jaap van Otterdijk]: https://github.com/jaapio
|
884 |
-
[Jason Stallings]: https://github.com/octalmage
|
885 |
-
[Jonathan Van Belle]: https://github.com/Grummfy
|
886 |
-
[Juliette Reinders Folmer]: https://github.com/jrfnl
|
887 |
-
[Ken Guest]: https://github.com/kenguest
|
888 |
-
[Komarov Alexey]: https://github.com/erdraug
|
889 |
-
[Marin Crnkovic]: https://github.com/anorgan
|
890 |
-
[Mark Clements]: https://github.com/MarkMaldaba
|
891 |
-
[Nick Pack]: https://github.com/nickpack
|
892 |
-
[Oliver Klee]: https://github.com/oliverklee
|
893 |
-
[Remko van Bezooijen]: https://github.com/emkookmer
|
894 |
-
[Rowan Collins]: https://github.com/IMSoP
|
895 |
-
[Ryan Neufeld]: https://github.com/ryanneufeld
|
896 |
-
[Sam Van der Borght]: https://github.com/samvdb
|
897 |
-
[Tadas Juozapaitis]: https://github.com/kasp3r
|
898 |
-
[Yoshiaki Yoshida]: https://github.com/kakakakakku
|
899 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCSAliases.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHPCS cross-version compatibility helper.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
/*
|
12 |
-
* Alias a number of PHPCS 3.x classes to their PHPCS 2.x equivalents.
|
13 |
-
*
|
14 |
-
* This file is auto-loaded by PHPCS 3.x before any sniffs are loaded
|
15 |
-
* through the PHPCS 3.x `<autoload>` ruleset directive.
|
16 |
-
*
|
17 |
-
* {@internal The PHPCS file have been reorganized in PHPCS 3.x, quite
|
18 |
-
* a few "old" classes have been split and spread out over several "new"
|
19 |
-
* classes. In other words, this will only work for a limited number
|
20 |
-
* of classes.}}
|
21 |
-
*
|
22 |
-
* {@internal The `class_exists` wrappers are needed to play nice with other
|
23 |
-
* external PHPCS standards creating cross-version compatibility in the same
|
24 |
-
* manner.}}
|
25 |
-
*/
|
26 |
-
if (defined('PHPCOMPATIBILITY_PHPCS_ALIASES_SET') === false) {
|
27 |
-
if (interface_exists('\PHP_CodeSniffer_Sniff') === false) {
|
28 |
-
class_alias('PHP_CodeSniffer\Sniffs\Sniff', '\PHP_CodeSniffer_Sniff');
|
29 |
-
}
|
30 |
-
if (class_exists('\PHP_CodeSniffer_File') === false) {
|
31 |
-
class_alias('PHP_CodeSniffer\Files\File', '\PHP_CodeSniffer_File');
|
32 |
-
}
|
33 |
-
if (class_exists('\PHP_CodeSniffer_Tokens') === false) {
|
34 |
-
class_alias('PHP_CodeSniffer\Util\Tokens', '\PHP_CodeSniffer_Tokens');
|
35 |
-
}
|
36 |
-
if (class_exists('\PHP_CodeSniffer_Exception') === false) {
|
37 |
-
class_alias('PHP_CodeSniffer\Exceptions\RuntimeException', '\PHP_CodeSniffer_Exception');
|
38 |
-
}
|
39 |
-
|
40 |
-
define('PHPCOMPATIBILITY_PHPCS_ALIASES_SET', true);
|
41 |
-
|
42 |
-
/*
|
43 |
-
* Register an autoloader.
|
44 |
-
*
|
45 |
-
* {@internal This autoloader is not needed for running the sniffs, however, it *is*
|
46 |
-
* needed for running the unit tests as the PHPCS native autoloader runs into trouble there.
|
47 |
-
* This issue will be fixed in PHPCS 3.1, so the below code can be removed once the
|
48 |
-
* minimum PHPCS 3.x requirement for PHPCompatibility has gone up to 3.1.
|
49 |
-
* Upstream issue: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1564} }}
|
50 |
-
*
|
51 |
-
* {@internal Update: when `installed_paths` is set via the ruleset, this autoloader
|
52 |
-
* **is** needed to run the sniffs.
|
53 |
-
* Upstream issue: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1591} }}
|
54 |
-
*/
|
55 |
-
spl_autoload_register(function ($class) {
|
56 |
-
// Only try & load our own classes.
|
57 |
-
if (stripos($class, 'PHPCompatibility') !== 0) {
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
|
61 |
-
$file = realpath(__DIR__) . DIRECTORY_SEPARATOR . strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
|
62 |
-
|
63 |
-
if (file_exists($file)) {
|
64 |
-
include_once($file);
|
65 |
-
}
|
66 |
-
});
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/AbstractComplexVersionSniff.php
DELETED
@@ -1,132 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\AbstractComplexVersionSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* \PHPCompatibility\AbstractComplexVersionSniff.
|
14 |
-
*
|
15 |
-
* @category PHP
|
16 |
-
* @package PHPCompatibility
|
17 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
18 |
-
*/
|
19 |
-
abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface
|
20 |
-
{
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Handle the retrieval of relevant information and - if necessary - throwing of an
|
25 |
-
* error/warning for an item.
|
26 |
-
*
|
27 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
28 |
-
* @param int $stackPtr The position of the relevant token in
|
29 |
-
* the stack.
|
30 |
-
* @param array $itemInfo Base information about the item.
|
31 |
-
*
|
32 |
-
* @return void
|
33 |
-
*/
|
34 |
-
public function handleFeature(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo)
|
35 |
-
{
|
36 |
-
$itemArray = $this->getItemArray($itemInfo);
|
37 |
-
$errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
|
38 |
-
|
39 |
-
if ($this->shouldThrowError($errorInfo) === true) {
|
40 |
-
$this->addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Determine whether an error/warning should be thrown for an item based on collected information.
|
47 |
-
*
|
48 |
-
* @param array $errorInfo Detail information about an item.
|
49 |
-
*
|
50 |
-
* @return bool
|
51 |
-
*/
|
52 |
-
abstract protected function shouldThrowError(array $errorInfo);
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Get an array of the non-PHP-version array keys used in a sub-array.
|
57 |
-
*
|
58 |
-
* @return array
|
59 |
-
*/
|
60 |
-
protected function getNonVersionArrayKeys()
|
61 |
-
{
|
62 |
-
return array();
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Retrieve a subset of an item array containing only the array keys which
|
68 |
-
* contain PHP version information.
|
69 |
-
*
|
70 |
-
* @param array $itemArray Version and other information about an item.
|
71 |
-
*
|
72 |
-
* @return array Array with only the version information.
|
73 |
-
*/
|
74 |
-
protected function getVersionArray(array $itemArray)
|
75 |
-
{
|
76 |
-
return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys()));
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Get the item name to be used for the creation of the error code and in the error message.
|
82 |
-
*
|
83 |
-
* @param array $itemInfo Base information about the item.
|
84 |
-
* @param array $errorInfo Detail information about an item.
|
85 |
-
*
|
86 |
-
* @return string
|
87 |
-
*/
|
88 |
-
protected function getItemName(array $itemInfo, array $errorInfo)
|
89 |
-
{
|
90 |
-
return $itemInfo['name'];
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get the error message template for a specific sniff.
|
96 |
-
*
|
97 |
-
* @return string
|
98 |
-
*/
|
99 |
-
abstract protected function getErrorMsgTemplate();
|
100 |
-
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Allow for concrete child classes to filter the error message before it's passed to PHPCS.
|
104 |
-
*
|
105 |
-
* @param string $error The error message which was created.
|
106 |
-
* @param array $itemInfo Base information about the item this error message applied to.
|
107 |
-
* @param array $errorInfo Detail information about an item this error message applied to.
|
108 |
-
*
|
109 |
-
* @return string
|
110 |
-
*/
|
111 |
-
protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
|
112 |
-
{
|
113 |
-
return $error;
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Allow for concrete child classes to filter the error data before it's passed to PHPCS.
|
119 |
-
*
|
120 |
-
* @param array $data The error data array which was created.
|
121 |
-
* @param array $itemInfo Base information about the item this error message applied to.
|
122 |
-
* @param array $errorInfo Detail information about an item this error message applied to.
|
123 |
-
*
|
124 |
-
* @return array
|
125 |
-
*/
|
126 |
-
protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
|
127 |
-
{
|
128 |
-
return $data;
|
129 |
-
}
|
130 |
-
|
131 |
-
|
132 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/AbstractNewFeatureSniff.php
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\AbstractNewFeatureSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* \PHPCompatibility\AbstractNewFeatureSniff.
|
14 |
-
*
|
15 |
-
* @category PHP
|
16 |
-
* @package PHPCompatibility
|
17 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
18 |
-
*/
|
19 |
-
abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff
|
20 |
-
{
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Determine whether an error/warning should be thrown for an item based on collected information.
|
25 |
-
*
|
26 |
-
* @param array $errorInfo Detail information about an item.
|
27 |
-
*
|
28 |
-
* @return bool
|
29 |
-
*/
|
30 |
-
protected function shouldThrowError(array $errorInfo)
|
31 |
-
{
|
32 |
-
return ($errorInfo['not_in_version'] !== '');
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Retrieve the relevant detail (version) information for use in an error message.
|
38 |
-
*
|
39 |
-
* @param array $itemArray Version and other information about the item.
|
40 |
-
* @param array $itemInfo Base information about the item.
|
41 |
-
*
|
42 |
-
* @return array
|
43 |
-
*/
|
44 |
-
public function getErrorInfo(array $itemArray, array $itemInfo)
|
45 |
-
{
|
46 |
-
$errorInfo = array(
|
47 |
-
'not_in_version' => '',
|
48 |
-
'error' => true,
|
49 |
-
);
|
50 |
-
|
51 |
-
$versionArray = $this->getVersionArray($itemArray);
|
52 |
-
|
53 |
-
if (empty($versionArray) === false) {
|
54 |
-
foreach ($versionArray as $version => $present) {
|
55 |
-
if ($errorInfo['not_in_version'] === '' && $present === false
|
56 |
-
&& $this->supportsBelow($version) === true
|
57 |
-
) {
|
58 |
-
$errorInfo['not_in_version'] = $version;
|
59 |
-
}
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
return $errorInfo;
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Get the error message template for this sniff.
|
69 |
-
*
|
70 |
-
* @return string
|
71 |
-
*/
|
72 |
-
protected function getErrorMsgTemplate()
|
73 |
-
{
|
74 |
-
return '%s is not present in PHP version %s or earlier';
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Generates the error or warning for this item.
|
80 |
-
*
|
81 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
82 |
-
* @param int $stackPtr The position of the relevant token in
|
83 |
-
* the stack.
|
84 |
-
* @param array $itemInfo Base information about the item.
|
85 |
-
* @param array $errorInfo Array with detail (version) information
|
86 |
-
* relevant to the item.
|
87 |
-
*
|
88 |
-
* @return void
|
89 |
-
*/
|
90 |
-
public function addError(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
|
91 |
-
{
|
92 |
-
$itemName = $this->getItemName($itemInfo, $errorInfo);
|
93 |
-
$error = $this->getErrorMsgTemplate();
|
94 |
-
|
95 |
-
$errorCode = $this->stringToErrorCode($itemName).'Found';
|
96 |
-
$data = array(
|
97 |
-
$itemName,
|
98 |
-
$errorInfo['not_in_version'],
|
99 |
-
);
|
100 |
-
|
101 |
-
$error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
|
102 |
-
$data = $this->filterErrorData($data, $itemInfo, $errorInfo);
|
103 |
-
|
104 |
-
$this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/AbstractRemovedFeatureSniff.php
DELETED
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\AbstractRemovedFeatureSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* \PHPCompatibility\AbstractRemovedFeatureSniff.
|
14 |
-
*
|
15 |
-
* @category PHP
|
16 |
-
* @package PHPCompatibility
|
17 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
18 |
-
*/
|
19 |
-
abstract class AbstractRemovedFeatureSniff extends AbstractComplexVersionSniff
|
20 |
-
{
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Determine whether an error/warning should be thrown for an item based on collected information.
|
25 |
-
*
|
26 |
-
* @param array $errorInfo Detail information about an item.
|
27 |
-
*
|
28 |
-
* @return bool
|
29 |
-
*/
|
30 |
-
protected function shouldThrowError(array $errorInfo)
|
31 |
-
{
|
32 |
-
return ($errorInfo['deprecated'] !== '' || $errorInfo['removed'] !== '');
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Get an array of the non-PHP-version array keys used in a sub-array.
|
38 |
-
*
|
39 |
-
* By default, removed feature version arrays, contain an additional 'alternative' array key.
|
40 |
-
*
|
41 |
-
* @return array
|
42 |
-
*/
|
43 |
-
protected function getNonVersionArrayKeys()
|
44 |
-
{
|
45 |
-
return array('alternative');
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Retrieve the relevant detail (version) information for use in an error message.
|
51 |
-
*
|
52 |
-
* @param array $itemArray Version and other information about the item.
|
53 |
-
* @param array $itemInfo Base information about the item.
|
54 |
-
*
|
55 |
-
* @return array
|
56 |
-
*/
|
57 |
-
public function getErrorInfo(array $itemArray, array $itemInfo)
|
58 |
-
{
|
59 |
-
$errorInfo = array(
|
60 |
-
'deprecated' => '',
|
61 |
-
'removed' => '',
|
62 |
-
'alternative' => '',
|
63 |
-
'error' => false,
|
64 |
-
);
|
65 |
-
|
66 |
-
$versionArray = $this->getVersionArray($itemArray);
|
67 |
-
|
68 |
-
if (empty($versionArray) === false) {
|
69 |
-
foreach ($versionArray as $version => $removed) {
|
70 |
-
if ($this->supportsAbove($version) === true) {
|
71 |
-
if ($removed === true && $errorInfo['removed'] === '') {
|
72 |
-
$errorInfo['removed'] = $version;
|
73 |
-
$errorInfo['error'] = true;
|
74 |
-
} elseif ($errorInfo['deprecated'] === '') {
|
75 |
-
$errorInfo['deprecated'] = $version;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
if (isset($itemArray['alternative']) === true) {
|
82 |
-
$errorInfo['alternative'] = $itemArray['alternative'];
|
83 |
-
}
|
84 |
-
|
85 |
-
return $errorInfo;
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Get the error message template for suggesting an alternative for a specific sniff.
|
91 |
-
*
|
92 |
-
* @return string
|
93 |
-
*/
|
94 |
-
protected function getAlternativeOptionTemplate()
|
95 |
-
{
|
96 |
-
return '; Use %s instead';
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Generates the error or warning for this item.
|
102 |
-
*
|
103 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
104 |
-
* @param int $stackPtr The position of the relevant token in
|
105 |
-
* the stack.
|
106 |
-
* @param array $itemInfo Base information about the item.
|
107 |
-
* @param array $errorInfo Array with detail (version) information
|
108 |
-
* relevant to the item.
|
109 |
-
*
|
110 |
-
* @return void
|
111 |
-
*/
|
112 |
-
public function addError(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
|
113 |
-
{
|
114 |
-
$itemName = $this->getItemName($itemInfo, $errorInfo);
|
115 |
-
$error = $this->getErrorMsgTemplate();
|
116 |
-
|
117 |
-
$errorCode = $this->stringToErrorCode($itemName);
|
118 |
-
$data = array($itemName);
|
119 |
-
|
120 |
-
if ($errorInfo['deprecated'] !== '') {
|
121 |
-
$error .= 'deprecated since PHP %s and ';
|
122 |
-
$errorCode .= 'Deprecated';
|
123 |
-
$data[] = $errorInfo['deprecated'];
|
124 |
-
}
|
125 |
-
|
126 |
-
if ($errorInfo['removed'] !== '') {
|
127 |
-
$error .= 'removed since PHP %s and ';
|
128 |
-
$errorCode .= 'Removed';
|
129 |
-
$data[] = $errorInfo['removed'];
|
130 |
-
}
|
131 |
-
|
132 |
-
// Remove the last 'and' from the message.
|
133 |
-
$error = substr($error, 0, (strlen($error) - 5));
|
134 |
-
|
135 |
-
if ($errorInfo['alternative'] !== '') {
|
136 |
-
$error .= $this->getAlternativeOptionTemplate();
|
137 |
-
$data[] = $errorInfo['alternative'];
|
138 |
-
}
|
139 |
-
|
140 |
-
$error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
|
141 |
-
$data = $this->filterErrorData($data, $itemInfo, $errorInfo);
|
142 |
-
|
143 |
-
$this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
|
144 |
-
|
145 |
-
}//end addError()
|
146 |
-
|
147 |
-
|
148 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/ComplexVersionInterface.php
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\ComplexVersionInterface.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* \PHPCompatibility\ComplexVersionInterface.
|
14 |
-
*
|
15 |
-
* Interface to be implemented by sniffs using a multi-dimensional array of
|
16 |
-
* PHP features (functions, classes etc) being sniffed for with version
|
17 |
-
* information in sub-arrays.
|
18 |
-
*
|
19 |
-
* @category PHP
|
20 |
-
* @package PHPCompatibility
|
21 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
22 |
-
*/
|
23 |
-
interface ComplexVersionInterface
|
24 |
-
{
|
25 |
-
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Handle the retrieval of relevant information and - if necessary - throwing of an
|
29 |
-
* error/warning for an item.
|
30 |
-
*
|
31 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
32 |
-
* @param int $stackPtr The position of the relevant token in
|
33 |
-
* the stack.
|
34 |
-
* @param array $itemInfo Base information about the item.
|
35 |
-
*
|
36 |
-
* @return void
|
37 |
-
*/
|
38 |
-
public function handleFeature(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo);
|
39 |
-
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
43 |
-
*
|
44 |
-
* @param array $itemInfo Base information about the item.
|
45 |
-
*
|
46 |
-
* @return array Version and other information about the item.
|
47 |
-
*/
|
48 |
-
public function getItemArray(array $itemInfo);
|
49 |
-
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Retrieve the relevant detail (version) information for use in an error message.
|
53 |
-
*
|
54 |
-
* @param array $itemArray Version and other information about the item.
|
55 |
-
* @param array $itemInfo Base information about the item.
|
56 |
-
*
|
57 |
-
* @return array
|
58 |
-
*/
|
59 |
-
public function getErrorInfo(array $itemArray, array $itemInfo);
|
60 |
-
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Generates the error or warning for this item.
|
64 |
-
*
|
65 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
66 |
-
* @param int $stackPtr The position of the relevant token in
|
67 |
-
* the stack.
|
68 |
-
* @param array $itemInfo Base information about the item.
|
69 |
-
* @param array $errorInfo Array with detail (version) information
|
70 |
-
* relevant to the item.
|
71 |
-
*
|
72 |
-
* @return void
|
73 |
-
*/
|
74 |
-
public function addError(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo);
|
75 |
-
|
76 |
-
|
77 |
-
}//end interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/PHPCSHelper.php
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHPCS cross-version compatibility helper class.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* \PHPCompatibility\PHPCSHelper
|
14 |
-
*
|
15 |
-
* PHPCS cross-version compatibility helper class.
|
16 |
-
*
|
17 |
-
* A number of PHPCS classes were split up into several classes in PHPCS 3.x
|
18 |
-
* Those classes cannot be aliased as they don't represent the same object.
|
19 |
-
* This class provides helper methods for functions which were contained in
|
20 |
-
* one of these classes and which are used within the PHPCompatibility library.
|
21 |
-
*
|
22 |
-
* @category PHP
|
23 |
-
* @package PHPCompatibility
|
24 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
25 |
-
*/
|
26 |
-
class PHPCSHelper
|
27 |
-
{
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Get the PHPCS version number.
|
31 |
-
*
|
32 |
-
* @return string
|
33 |
-
*/
|
34 |
-
public static function getVersion()
|
35 |
-
{
|
36 |
-
if (defined('\PHP_CodeSniffer\Config::VERSION')) {
|
37 |
-
// PHPCS 3.x.
|
38 |
-
return \PHP_CodeSniffer\Config::VERSION;
|
39 |
-
} else {
|
40 |
-
// PHPCS 1.x & 2.x.
|
41 |
-
return \PHP_CodeSniffer::VERSION;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Pass config data to PHPCS.
|
48 |
-
*
|
49 |
-
* PHPCS cross-version compatibility helper.
|
50 |
-
*
|
51 |
-
* @param string $key The name of the config value.
|
52 |
-
* @param string|null $value The value to set. If null, the config entry
|
53 |
-
* is deleted, reverting it to the default value.
|
54 |
-
* @param boolean $temp Set this config data temporarily for this script run.
|
55 |
-
* This will not write the config data to the config file.
|
56 |
-
*
|
57 |
-
* @return void
|
58 |
-
*/
|
59 |
-
public static function setConfigData($key, $value, $temp = false)
|
60 |
-
{
|
61 |
-
if (method_exists('\PHP_CodeSniffer\Config', 'setConfigData')) {
|
62 |
-
// PHPCS 3.x.
|
63 |
-
\PHP_CodeSniffer\Config::setConfigData($key, $value, $temp);
|
64 |
-
} else {
|
65 |
-
// PHPCS 1.x & 2.x.
|
66 |
-
\PHP_CodeSniffer::setConfigData($key, $value, $temp);
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Get the value of a single PHPCS config key.
|
73 |
-
*
|
74 |
-
* @param string $key The name of the config value.
|
75 |
-
*
|
76 |
-
* @return string|null
|
77 |
-
*/
|
78 |
-
public static function getConfigData($key)
|
79 |
-
{
|
80 |
-
if (method_exists('\PHP_CodeSniffer\Config', 'getConfigData')) {
|
81 |
-
// PHPCS 3.x.
|
82 |
-
return \PHP_CodeSniffer\Config::getConfigData($key);
|
83 |
-
} else {
|
84 |
-
// PHPCS 1.x & 2.x.
|
85 |
-
return \PHP_CodeSniffer::getConfigData($key);
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniff.php
DELETED
@@ -1,1696 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Wim Godden <wim.godden@cu.be>
|
8 |
-
* @copyright 2014 Cu.be Solutions bvba
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace PHPCompatibility;
|
12 |
-
|
13 |
-
use PHPCompatibility\PHPCSHelper;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* \PHPCompatibility\Sniff.
|
17 |
-
*
|
18 |
-
* @category PHP
|
19 |
-
* @package PHPCompatibility
|
20 |
-
* @author Wim Godden <wim.godden@cu.be>
|
21 |
-
* @copyright 2014 Cu.be Solutions bvba
|
22 |
-
*/
|
23 |
-
abstract class Sniff implements \PHP_CodeSniffer_Sniff
|
24 |
-
{
|
25 |
-
|
26 |
-
const REGEX_COMPLEX_VARS = '`(?:(\{)?(?<!\\\\)\$)?(\{)?(?<!\\\\)\$(\{)?(?P<varname>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?:->\$?(?P>varname)|\[[^\]]+\]|::\$?(?P>varname)|\([^\)]*\))*(?(3)\}|)(?(2)\}|)(?(1)\}|)`';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* List of superglobals as an array of strings.
|
30 |
-
*
|
31 |
-
* Used by the ParameterShadowSuperGlobals and ForbiddenClosureUseVariableNames sniffs.
|
32 |
-
*
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
protected $superglobals = array(
|
36 |
-
'$GLOBALS',
|
37 |
-
'$_SERVER',
|
38 |
-
'$_GET',
|
39 |
-
'$_POST',
|
40 |
-
'$_FILES',
|
41 |
-
'$_COOKIE',
|
42 |
-
'$_SESSION',
|
43 |
-
'$_REQUEST',
|
44 |
-
'$_ENV',
|
45 |
-
);
|
46 |
-
|
47 |
-
/**
|
48 |
-
* List of functions using hash algorithm as parameter (always the first parameter).
|
49 |
-
*
|
50 |
-
* Used by the new/removed hash algorithm sniffs.
|
51 |
-
* Key is the function name, value is the 1-based parameter position in the function call.
|
52 |
-
*
|
53 |
-
* @var array
|
54 |
-
*/
|
55 |
-
protected $hashAlgoFunctions = array(
|
56 |
-
'hash_file' => 1,
|
57 |
-
'hash_hmac_file' => 1,
|
58 |
-
'hash_hmac' => 1,
|
59 |
-
'hash_init' => 1,
|
60 |
-
'hash_pbkdf2' => 1,
|
61 |
-
'hash' => 1,
|
62 |
-
);
|
63 |
-
|
64 |
-
|
65 |
-
/**
|
66 |
-
* List of functions which take an ini directive as parameter (always the first parameter).
|
67 |
-
*
|
68 |
-
* Used by the new/removed ini directives sniffs.
|
69 |
-
* Key is the function name, value is the 1-based parameter position in the function call.
|
70 |
-
*
|
71 |
-
* @var array
|
72 |
-
*/
|
73 |
-
protected $iniFunctions = array(
|
74 |
-
'ini_get' => 1,
|
75 |
-
'ini_set' => 1,
|
76 |
-
);
|
77 |
-
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Get the testVersion configuration variable.
|
81 |
-
*
|
82 |
-
* The testVersion configuration variable may be in any of the following formats:
|
83 |
-
* 1) Omitted/empty, in which case no version is specified. This effectively
|
84 |
-
* disables all the checks for new PHP features provided by this standard.
|
85 |
-
* 2) A single PHP version number, e.g. "5.4" in which case the standard checks that
|
86 |
-
* the code will run on that version of PHP (no deprecated features or newer
|
87 |
-
* features being used).
|
88 |
-
* 3) A range, e.g. "5.0-5.5", in which case the standard checks the code will run
|
89 |
-
* on all PHP versions in that range, and that it doesn't use any features that
|
90 |
-
* were deprecated by the final version in the list, or which were not available
|
91 |
-
* for the first version in the list.
|
92 |
-
* We accept ranges where one of the components is missing, e.g. "-5.6" means
|
93 |
-
* all versions up to PHP 5.6, and "7.0-" means all versions above PHP 7.0.
|
94 |
-
* PHP version numbers should always be in Major.Minor format. Both "5", "5.3.2"
|
95 |
-
* would be treated as invalid, and ignored.
|
96 |
-
*
|
97 |
-
* @return array $arrTestVersions will hold an array containing min/max version
|
98 |
-
* of PHP that we are checking against (see above). If only a
|
99 |
-
* single version number is specified, then this is used as
|
100 |
-
* both the min and max.
|
101 |
-
*
|
102 |
-
* @throws \PHP_CodeSniffer_Exception If testVersion is invalid.
|
103 |
-
*/
|
104 |
-
private function getTestVersion()
|
105 |
-
{
|
106 |
-
static $arrTestVersions = array();
|
107 |
-
|
108 |
-
$default = array(null, null);
|
109 |
-
$testVersion = trim(PHPCSHelper::getConfigData('testVersion'));
|
110 |
-
|
111 |
-
if (empty($testVersion) === false && isset($arrTestVersions[$testVersion]) === false) {
|
112 |
-
|
113 |
-
$arrTestVersions[$testVersion] = $default;
|
114 |
-
|
115 |
-
if (preg_match('`^\d+\.\d+$`', $testVersion)) {
|
116 |
-
$arrTestVersions[$testVersion] = array($testVersion, $testVersion);
|
117 |
-
return $arrTestVersions[$testVersion];
|
118 |
-
}
|
119 |
-
|
120 |
-
if (preg_match('`^(\d+\.\d+)?\s*-\s*(\d+\.\d+)?$`', $testVersion, $matches)) {
|
121 |
-
if (empty($matches[1]) === false || empty($matches[2]) === false) {
|
122 |
-
// If no lower-limit is set, we set the min version to 4.0.
|
123 |
-
// Whilst development focuses on PHP 5 and above, we also accept
|
124 |
-
// sniffs for PHP 4, so we include that as the minimum.
|
125 |
-
// (It makes no sense to support PHP 3 as this was effectively a
|
126 |
-
// different language).
|
127 |
-
$min = empty($matches[1]) ? '4.0' : $matches[1];
|
128 |
-
|
129 |
-
// If no upper-limit is set, we set the max version to 99.9.
|
130 |
-
$max = empty($matches[2]) ? '99.9' : $matches[2];
|
131 |
-
|
132 |
-
if (version_compare($min, $max, '>')) {
|
133 |
-
trigger_error(
|
134 |
-
"Invalid range in testVersion setting: '" . $testVersion . "'",
|
135 |
-
E_USER_WARNING
|
136 |
-
);
|
137 |
-
return $default;
|
138 |
-
}
|
139 |
-
else {
|
140 |
-
$arrTestVersions[$testVersion] = array($min, $max);
|
141 |
-
return $arrTestVersions[$testVersion];
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
trigger_error(
|
147 |
-
"Invalid testVersion setting: '" . $testVersion . "'",
|
148 |
-
E_USER_WARNING
|
149 |
-
);
|
150 |
-
return $default;
|
151 |
-
}
|
152 |
-
|
153 |
-
if (isset($arrTestVersions[$testVersion])) {
|
154 |
-
return $arrTestVersions[$testVersion];
|
155 |
-
}
|
156 |
-
|
157 |
-
return $default;
|
158 |
-
}
|
159 |
-
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Check whether a specific PHP version is equal to or higher than the maximum
|
163 |
-
* supported PHP version as provided by the user in `testVersion`.
|
164 |
-
*
|
165 |
-
* Should be used when sniffing for *old* PHP features (deprecated/removed).
|
166 |
-
*
|
167 |
-
* @param string $phpVersion A PHP version number in 'major.minor' format.
|
168 |
-
*
|
169 |
-
* @return bool True if testVersion has not been provided or if the PHP version
|
170 |
-
* is equal to or higher than the highest supported PHP version
|
171 |
-
* in testVersion. False otherwise.
|
172 |
-
*/
|
173 |
-
public function supportsAbove($phpVersion)
|
174 |
-
{
|
175 |
-
$testVersion = $this->getTestVersion();
|
176 |
-
$testVersion = $testVersion[1];
|
177 |
-
|
178 |
-
if (is_null($testVersion)
|
179 |
-
|| version_compare($testVersion, $phpVersion) >= 0
|
180 |
-
) {
|
181 |
-
return true;
|
182 |
-
} else {
|
183 |
-
return false;
|
184 |
-
}
|
185 |
-
}//end supportsAbove()
|
186 |
-
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Check whether a specific PHP version is equal to or lower than the minimum
|
190 |
-
* supported PHP version as provided by the user in `testVersion`.
|
191 |
-
*
|
192 |
-
* Should be used when sniffing for *new* PHP features.
|
193 |
-
*
|
194 |
-
* @param string $phpVersion A PHP version number in 'major.minor' format.
|
195 |
-
*
|
196 |
-
* @return bool True if the PHP version is equal to or lower than the lowest
|
197 |
-
* supported PHP version in testVersion.
|
198 |
-
* False otherwise or if no testVersion is provided.
|
199 |
-
*/
|
200 |
-
public function supportsBelow($phpVersion)
|
201 |
-
{
|
202 |
-
$testVersion = $this->getTestVersion();
|
203 |
-
$testVersion = $testVersion[0];
|
204 |
-
|
205 |
-
if (is_null($testVersion) === false
|
206 |
-
&& version_compare($testVersion, $phpVersion) <= 0
|
207 |
-
) {
|
208 |
-
return true;
|
209 |
-
} else {
|
210 |
-
return false;
|
211 |
-
}
|
212 |
-
}//end supportsBelow()
|
213 |
-
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Add a PHPCS message to the output stack as either a warning or an error.
|
217 |
-
*
|
218 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file the message applies to.
|
219 |
-
* @param string $message The message.
|
220 |
-
* @param int $stackPtr The position of the token
|
221 |
-
* the message relates to.
|
222 |
-
* @param bool $isError Whether to report the message as an
|
223 |
-
* 'error' or 'warning'.
|
224 |
-
* Defaults to true (error).
|
225 |
-
* @param string $code The error code for the message.
|
226 |
-
* Defaults to 'Found'.
|
227 |
-
* @param array $data Optional input for the data replacements.
|
228 |
-
*
|
229 |
-
* @return void
|
230 |
-
*/
|
231 |
-
public function addMessage(\PHP_CodeSniffer_File $phpcsFile, $message, $stackPtr, $isError, $code = 'Found', $data = array())
|
232 |
-
{
|
233 |
-
if ($isError === true) {
|
234 |
-
$phpcsFile->addError($message, $stackPtr, $code, $data);
|
235 |
-
} else {
|
236 |
-
$phpcsFile->addWarning($message, $stackPtr, $code, $data);
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Convert an arbitrary string to an alphanumeric string with underscores.
|
243 |
-
*
|
244 |
-
* Pre-empt issues with arbitrary strings being used as error codes in XML and PHP.
|
245 |
-
*
|
246 |
-
* @param string $baseString Arbitrary string.
|
247 |
-
*
|
248 |
-
* @return string
|
249 |
-
*/
|
250 |
-
public function stringToErrorCode($baseString)
|
251 |
-
{
|
252 |
-
return preg_replace('`[^a-z0-9_]`i', '_', strtolower($baseString));
|
253 |
-
}
|
254 |
-
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Strip quotes surrounding an arbitrary string.
|
258 |
-
*
|
259 |
-
* Intended for use with the content of a T_CONSTANT_ENCAPSED_STRING / T_DOUBLE_QUOTED_STRING.
|
260 |
-
*
|
261 |
-
* @param string $string The raw string.
|
262 |
-
*
|
263 |
-
* @return string String without quotes around it.
|
264 |
-
*/
|
265 |
-
public function stripQuotes($string)
|
266 |
-
{
|
267 |
-
return preg_replace('`^([\'"])(.*)\1$`Ds', '$2', $string);
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Strip variables from an arbitrary double quoted string.
|
273 |
-
*
|
274 |
-
* Intended for use with the content of a T_DOUBLE_QUOTED_STRING.
|
275 |
-
*
|
276 |
-
* @param string $string The raw string.
|
277 |
-
*
|
278 |
-
* @return string String without variables in it.
|
279 |
-
*/
|
280 |
-
public function stripVariables($string)
|
281 |
-
{
|
282 |
-
if (strpos($string, '$') === false) {
|
283 |
-
return $string;
|
284 |
-
}
|
285 |
-
|
286 |
-
return preg_replace(self::REGEX_COMPLEX_VARS, '', $string);
|
287 |
-
}
|
288 |
-
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Make all top level array keys in an array lowercase.
|
292 |
-
*
|
293 |
-
* @param array $array Initial array.
|
294 |
-
*
|
295 |
-
* @return array Same array, but with all lowercase top level keys.
|
296 |
-
*/
|
297 |
-
public function arrayKeysToLowercase($array)
|
298 |
-
{
|
299 |
-
$keys = array_keys($array);
|
300 |
-
$keys = array_map('strtolower', $keys);
|
301 |
-
return array_combine($keys, $array);
|
302 |
-
}
|
303 |
-
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Returns the name(s) of the interface(s) that the specified class implements.
|
307 |
-
*
|
308 |
-
* Returns FALSE on error or if there are no implemented interface names.
|
309 |
-
*
|
310 |
-
* {@internal Duplicate of same method as introduced in PHPCS 2.7.
|
311 |
-
* This method also includes an improvement we use which was only introduced
|
312 |
-
* in PHPCS 2.8.0, so only defer to upstream for higher versions.
|
313 |
-
* Once the minimum supported PHPCS version for this sniff library goes beyond
|
314 |
-
* that, this method can be removed and calls to it replaced with
|
315 |
-
* `$phpcsFile->findImplementedInterfaceNames($stackPtr)` calls.}}
|
316 |
-
*
|
317 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
318 |
-
* @param int $stackPtr The position of the class token.
|
319 |
-
*
|
320 |
-
* @return array|false
|
321 |
-
*/
|
322 |
-
public function findImplementedInterfaceNames(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
323 |
-
{
|
324 |
-
if (version_compare(PHPCSHelper::getVersion(), '2.7.1', '>') === true) {
|
325 |
-
return $phpcsFile->findImplementedInterfaceNames($stackPtr);
|
326 |
-
}
|
327 |
-
|
328 |
-
$tokens = $phpcsFile->getTokens();
|
329 |
-
|
330 |
-
// Check for the existence of the token.
|
331 |
-
if (isset($tokens[$stackPtr]) === false) {
|
332 |
-
return false;
|
333 |
-
}
|
334 |
-
|
335 |
-
if ($tokens[$stackPtr]['code'] !== T_CLASS
|
336 |
-
&& $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS'
|
337 |
-
) {
|
338 |
-
return false;
|
339 |
-
}
|
340 |
-
|
341 |
-
if (isset($tokens[$stackPtr]['scope_closer']) === false) {
|
342 |
-
return false;
|
343 |
-
}
|
344 |
-
|
345 |
-
$classOpenerIndex = $tokens[$stackPtr]['scope_opener'];
|
346 |
-
$implementsIndex = $phpcsFile->findNext(T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
|
347 |
-
if ($implementsIndex === false) {
|
348 |
-
return false;
|
349 |
-
}
|
350 |
-
|
351 |
-
$find = array(
|
352 |
-
T_NS_SEPARATOR,
|
353 |
-
T_STRING,
|
354 |
-
T_WHITESPACE,
|
355 |
-
T_COMMA,
|
356 |
-
);
|
357 |
-
|
358 |
-
$end = $phpcsFile->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true);
|
359 |
-
$name = $phpcsFile->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1));
|
360 |
-
$name = trim($name);
|
361 |
-
|
362 |
-
if ($name === '') {
|
363 |
-
return false;
|
364 |
-
} else {
|
365 |
-
$names = explode(',', $name);
|
366 |
-
$names = array_map('trim', $names);
|
367 |
-
return $names;
|
368 |
-
}
|
369 |
-
|
370 |
-
}//end findImplementedInterfaceNames()
|
371 |
-
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Checks if a function call has parameters.
|
375 |
-
*
|
376 |
-
* Expects to be passed the T_STRING stack pointer for the function call.
|
377 |
-
* If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
|
378 |
-
*
|
379 |
-
* Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, it
|
380 |
-
* will detect whether the array has values or is empty.
|
381 |
-
*
|
382 |
-
* @link https://github.com/wimg/PHPCompatibility/issues/120
|
383 |
-
* @link https://github.com/wimg/PHPCompatibility/issues/152
|
384 |
-
*
|
385 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
386 |
-
* @param int $stackPtr The position of the function call token.
|
387 |
-
*
|
388 |
-
* @return bool
|
389 |
-
*/
|
390 |
-
public function doesFunctionCallHaveParameters(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
391 |
-
{
|
392 |
-
$tokens = $phpcsFile->getTokens();
|
393 |
-
|
394 |
-
// Check for the existence of the token.
|
395 |
-
if (isset($tokens[$stackPtr]) === false) {
|
396 |
-
return false;
|
397 |
-
}
|
398 |
-
|
399 |
-
// Is this one of the tokens this function handles ?
|
400 |
-
if (in_array($tokens[$stackPtr]['code'], array(T_STRING, T_ARRAY, T_OPEN_SHORT_ARRAY), true) === false) {
|
401 |
-
return false;
|
402 |
-
}
|
403 |
-
|
404 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
405 |
-
|
406 |
-
// Deal with short array syntax.
|
407 |
-
if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
|
408 |
-
if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
|
409 |
-
return false;
|
410 |
-
}
|
411 |
-
|
412 |
-
if ($nextNonEmpty === $tokens[$stackPtr]['bracket_closer']) {
|
413 |
-
// No parameters.
|
414 |
-
return false;
|
415 |
-
} else {
|
416 |
-
return true;
|
417 |
-
}
|
418 |
-
}
|
419 |
-
|
420 |
-
// Deal with function calls & long arrays.
|
421 |
-
// Next non-empty token should be the open parenthesis.
|
422 |
-
if ($nextNonEmpty === false && $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) {
|
423 |
-
return false;
|
424 |
-
}
|
425 |
-
|
426 |
-
if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
|
427 |
-
return false;
|
428 |
-
}
|
429 |
-
|
430 |
-
$closeParenthesis = $tokens[$nextNonEmpty]['parenthesis_closer'];
|
431 |
-
$nextNextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $nextNonEmpty + 1, $closeParenthesis + 1, true);
|
432 |
-
|
433 |
-
if ($nextNextNonEmpty === $closeParenthesis) {
|
434 |
-
// No parameters.
|
435 |
-
return false;
|
436 |
-
}
|
437 |
-
|
438 |
-
return true;
|
439 |
-
}
|
440 |
-
|
441 |
-
|
442 |
-
/**
|
443 |
-
* Count the number of parameters a function call has been passed.
|
444 |
-
*
|
445 |
-
* Expects to be passed the T_STRING stack pointer for the function call.
|
446 |
-
* If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
|
447 |
-
*
|
448 |
-
* Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
|
449 |
-
* it will return the number of values in the array.
|
450 |
-
*
|
451 |
-
* @link https://github.com/wimg/PHPCompatibility/issues/111
|
452 |
-
* @link https://github.com/wimg/PHPCompatibility/issues/114
|
453 |
-
* @link https://github.com/wimg/PHPCompatibility/issues/151
|
454 |
-
*
|
455 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
456 |
-
* @param int $stackPtr The position of the function call token.
|
457 |
-
*
|
458 |
-
* @return int
|
459 |
-
*/
|
460 |
-
public function getFunctionCallParameterCount(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
461 |
-
{
|
462 |
-
if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) {
|
463 |
-
return 0;
|
464 |
-
}
|
465 |
-
|
466 |
-
return count($this->getFunctionCallParameters($phpcsFile, $stackPtr));
|
467 |
-
}
|
468 |
-
|
469 |
-
|
470 |
-
/**
|
471 |
-
* Get information on all parameters passed to a function call.
|
472 |
-
*
|
473 |
-
* Expects to be passed the T_STRING stack pointer for the function call.
|
474 |
-
* If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
|
475 |
-
*
|
476 |
-
* Will return an multi-dimentional array with the start token pointer, end token
|
477 |
-
* pointer and raw parameter value for all parameters. Index will be 1-based.
|
478 |
-
* If no parameters are found, will return an empty array.
|
479 |
-
*
|
480 |
-
* Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
|
481 |
-
* it will tokenize the values / key/value pairs contained in the array call.
|
482 |
-
*
|
483 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
484 |
-
* @param int $stackPtr The position of the function call token.
|
485 |
-
*
|
486 |
-
* @return array
|
487 |
-
*/
|
488 |
-
public function getFunctionCallParameters(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
489 |
-
{
|
490 |
-
if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) {
|
491 |
-
return array();
|
492 |
-
}
|
493 |
-
|
494 |
-
// Ok, we know we have a T_STRING, T_ARRAY or T_OPEN_SHORT_ARRAY with parameters
|
495 |
-
// and valid open & close brackets/parenthesis.
|
496 |
-
$tokens = $phpcsFile->getTokens();
|
497 |
-
|
498 |
-
// Mark the beginning and end tokens.
|
499 |
-
if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
|
500 |
-
$opener = $stackPtr;
|
501 |
-
$closer = $tokens[$stackPtr]['bracket_closer'];
|
502 |
-
|
503 |
-
$nestedParenthesisCount = 0;
|
504 |
-
|
505 |
-
} else {
|
506 |
-
$opener = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
507 |
-
$closer = $tokens[$opener]['parenthesis_closer'];
|
508 |
-
|
509 |
-
$nestedParenthesisCount = 1;
|
510 |
-
}
|
511 |
-
|
512 |
-
// Which nesting level is the one we are interested in ?
|
513 |
-
if (isset($tokens[$opener]['nested_parenthesis'])) {
|
514 |
-
$nestedParenthesisCount += count($tokens[$opener]['nested_parenthesis']);
|
515 |
-
}
|
516 |
-
|
517 |
-
$parameters = array();
|
518 |
-
$nextComma = $opener;
|
519 |
-
$paramStart = $opener + 1;
|
520 |
-
$cnt = 1;
|
521 |
-
while (($nextComma = $phpcsFile->findNext(array(T_COMMA, $tokens[$closer]['code'], T_OPEN_SHORT_ARRAY), $nextComma + 1, $closer + 1)) !== false) {
|
522 |
-
// Ignore anything within short array definition brackets.
|
523 |
-
if ($tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY'
|
524 |
-
&& (isset($tokens[$nextComma]['bracket_opener'])
|
525 |
-
&& $tokens[$nextComma]['bracket_opener'] === $nextComma)
|
526 |
-
&& isset($tokens[$nextComma]['bracket_closer'])
|
527 |
-
) {
|
528 |
-
// Skip forward to the end of the short array definition.
|
529 |
-
$nextComma = $tokens[$nextComma]['bracket_closer'];
|
530 |
-
continue;
|
531 |
-
}
|
532 |
-
|
533 |
-
// Ignore comma's at a lower nesting level.
|
534 |
-
if ($tokens[$nextComma]['type'] === 'T_COMMA'
|
535 |
-
&& isset($tokens[$nextComma]['nested_parenthesis'])
|
536 |
-
&& count($tokens[$nextComma]['nested_parenthesis']) !== $nestedParenthesisCount
|
537 |
-
) {
|
538 |
-
continue;
|
539 |
-
}
|
540 |
-
|
541 |
-
// Ignore closing parenthesis/bracket if not 'ours'.
|
542 |
-
if ($tokens[$nextComma]['type'] === $tokens[$closer]['type'] && $nextComma !== $closer) {
|
543 |
-
continue;
|
544 |
-
}
|
545 |
-
|
546 |
-
// Ok, we've reached the end of the parameter.
|
547 |
-
$parameters[$cnt]['start'] = $paramStart;
|
548 |
-
$parameters[$cnt]['end'] = $nextComma - 1;
|
549 |
-
$parameters[$cnt]['raw'] = trim($phpcsFile->getTokensAsString($paramStart, ($nextComma - $paramStart)));
|
550 |
-
|
551 |
-
// Check if there are more tokens before the closing parenthesis.
|
552 |
-
// Prevents code like the following from setting a third parameter:
|
553 |
-
// functionCall( $param1, $param2, );
|
554 |
-
$hasNextParam = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $nextComma + 1, $closer, true, null, true);
|
555 |
-
if ($hasNextParam === false) {
|
556 |
-
break;
|
557 |
-
}
|
558 |
-
|
559 |
-
// Prepare for the next parameter.
|
560 |
-
$paramStart = $nextComma + 1;
|
561 |
-
$cnt++;
|
562 |
-
}
|
563 |
-
|
564 |
-
return $parameters;
|
565 |
-
}
|
566 |
-
|
567 |
-
|
568 |
-
/**
|
569 |
-
* Get information on a specific parameter passed to a function call.
|
570 |
-
*
|
571 |
-
* Expects to be passed the T_STRING stack pointer for the function call.
|
572 |
-
* If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
|
573 |
-
*
|
574 |
-
* Will return a array with the start token pointer, end token pointer and the raw value
|
575 |
-
* of the parameter at a specific offset.
|
576 |
-
* If the specified parameter is not found, will return false.
|
577 |
-
*
|
578 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
579 |
-
* @param int $stackPtr The position of the function call token.
|
580 |
-
* @param int $paramOffset The 1-based index position of the parameter to retrieve.
|
581 |
-
*
|
582 |
-
* @return array|false
|
583 |
-
*/
|
584 |
-
public function getFunctionCallParameter(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $paramOffset)
|
585 |
-
{
|
586 |
-
$parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
|
587 |
-
|
588 |
-
if (isset($parameters[$paramOffset]) === false) {
|
589 |
-
return false;
|
590 |
-
} else {
|
591 |
-
return $parameters[$paramOffset];
|
592 |
-
}
|
593 |
-
}
|
594 |
-
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Verify whether a token is within a scoped condition.
|
598 |
-
*
|
599 |
-
* If the optional $validScopes parameter has been passed, the function
|
600 |
-
* will check that the token has at least one condition which is of a
|
601 |
-
* type defined in $validScopes.
|
602 |
-
*
|
603 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
604 |
-
* @param int $stackPtr The position of the token.
|
605 |
-
* @param array|int $validScopes Optional. Array of valid scopes
|
606 |
-
* or int value of a valid scope.
|
607 |
-
* Pass the T_.. constant(s) for the
|
608 |
-
* desired scope to this parameter.
|
609 |
-
*
|
610 |
-
* @return bool Without the optional $scopeTypes: True if within a scope, false otherwise.
|
611 |
-
* If the $scopeTypes are set: True if *one* of the conditions is a
|
612 |
-
* valid scope, false otherwise.
|
613 |
-
*/
|
614 |
-
public function tokenHasScope(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $validScopes = null)
|
615 |
-
{
|
616 |
-
$tokens = $phpcsFile->getTokens();
|
617 |
-
|
618 |
-
// Check for the existence of the token.
|
619 |
-
if (isset($tokens[$stackPtr]) === false) {
|
620 |
-
return false;
|
621 |
-
}
|
622 |
-
|
623 |
-
// No conditions = no scope.
|
624 |
-
if (empty($tokens[$stackPtr]['conditions'])) {
|
625 |
-
return false;
|
626 |
-
}
|
627 |
-
|
628 |
-
// Ok, there are conditions, do we have to check for specific ones ?
|
629 |
-
if (isset($validScopes) === false) {
|
630 |
-
return true;
|
631 |
-
}
|
632 |
-
|
633 |
-
return $phpcsFile->hasCondition($stackPtr, $validScopes);
|
634 |
-
}
|
635 |
-
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Verify whether a token is within a class scope.
|
639 |
-
*
|
640 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
641 |
-
* @param int $stackPtr The position of the token.
|
642 |
-
* @param bool $strict Whether to strictly check for the T_CLASS
|
643 |
-
* scope or also accept interfaces and traits
|
644 |
-
* as scope.
|
645 |
-
*
|
646 |
-
* @return bool True if within class scope, false otherwise.
|
647 |
-
*/
|
648 |
-
public function inClassScope(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
|
649 |
-
{
|
650 |
-
$validScopes = array(T_CLASS);
|
651 |
-
if (defined('T_ANON_CLASS') === true) {
|
652 |
-
$validScopes[] = T_ANON_CLASS;
|
653 |
-
}
|
654 |
-
|
655 |
-
if ($strict === false) {
|
656 |
-
$validScopes[] = T_INTERFACE;
|
657 |
-
|
658 |
-
if (defined('T_TRAIT')) {
|
659 |
-
$validScopes[] = constant('T_TRAIT');
|
660 |
-
}
|
661 |
-
}
|
662 |
-
|
663 |
-
return $phpcsFile->hasCondition($stackPtr, $validScopes);
|
664 |
-
}
|
665 |
-
|
666 |
-
|
667 |
-
/**
|
668 |
-
* Verify whether a token is within a scoped use statement.
|
669 |
-
*
|
670 |
-
* PHPCS cross-version compatibility method.
|
671 |
-
*
|
672 |
-
* In PHPCS 1.x no conditions are set for a scoped use statement.
|
673 |
-
* This method works around that limitation.
|
674 |
-
*
|
675 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
676 |
-
* @param int $stackPtr The position of the token.
|
677 |
-
*
|
678 |
-
* @return bool True if within use scope, false otherwise.
|
679 |
-
*/
|
680 |
-
public function inUseScope(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
681 |
-
{
|
682 |
-
static $isLowPHPCS, $ignoreTokens;
|
683 |
-
|
684 |
-
if (isset($isLowPHPCS) === false) {
|
685 |
-
$isLowPHPCS = version_compare(PHPCSHelper::getVersion(), '2.3.0', '<');
|
686 |
-
}
|
687 |
-
if (isset($ignoreTokens) === false) {
|
688 |
-
$ignoreTokens = \PHP_CodeSniffer_Tokens::$emptyTokens;
|
689 |
-
$ignoreTokens[T_STRING] = T_STRING;
|
690 |
-
$ignoreTokens[T_AS] = T_AS;
|
691 |
-
$ignoreTokens[T_PUBLIC] = T_PUBLIC;
|
692 |
-
$ignoreTokens[T_PROTECTED] = T_PROTECTED;
|
693 |
-
$ignoreTokens[T_PRIVATE] = T_PRIVATE;
|
694 |
-
}
|
695 |
-
|
696 |
-
// PHPCS 2.0.
|
697 |
-
if ($isLowPHPCS === false) {
|
698 |
-
return $phpcsFile->hasCondition($stackPtr, T_USE);
|
699 |
-
} else {
|
700 |
-
// PHPCS 1.x.
|
701 |
-
$tokens = $phpcsFile->getTokens();
|
702 |
-
$maybeCurlyOpen = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true);
|
703 |
-
if ($tokens[$maybeCurlyOpen]['code'] === T_OPEN_CURLY_BRACKET) {
|
704 |
-
$maybeUseStatement = $phpcsFile->findPrevious($ignoreTokens, ($maybeCurlyOpen - 1), null, true);
|
705 |
-
if ($tokens[$maybeUseStatement]['code'] === T_USE) {
|
706 |
-
return true;
|
707 |
-
}
|
708 |
-
}
|
709 |
-
return false;
|
710 |
-
}
|
711 |
-
}
|
712 |
-
|
713 |
-
|
714 |
-
/**
|
715 |
-
* Returns the fully qualified class name for a new class instantiation.
|
716 |
-
*
|
717 |
-
* Returns an empty string if the class name could not be reliably inferred.
|
718 |
-
*
|
719 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
720 |
-
* @param int $stackPtr The position of a T_NEW token.
|
721 |
-
*
|
722 |
-
* @return string
|
723 |
-
*/
|
724 |
-
public function getFQClassNameFromNewToken(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
725 |
-
{
|
726 |
-
$tokens = $phpcsFile->getTokens();
|
727 |
-
|
728 |
-
// Check for the existence of the token.
|
729 |
-
if (isset($tokens[$stackPtr]) === false) {
|
730 |
-
return '';
|
731 |
-
}
|
732 |
-
|
733 |
-
if ($tokens[$stackPtr]['code'] !== T_NEW) {
|
734 |
-
return '';
|
735 |
-
}
|
736 |
-
|
737 |
-
$start = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
|
738 |
-
if ($start === false) {
|
739 |
-
return '';
|
740 |
-
}
|
741 |
-
|
742 |
-
// Bow out if the next token is a variable as we don't know where it was defined.
|
743 |
-
if ($tokens[$start]['code'] === T_VARIABLE) {
|
744 |
-
return '';
|
745 |
-
}
|
746 |
-
|
747 |
-
// Bow out if the next token is the class keyword.
|
748 |
-
if ($tokens[$start]['type'] === 'T_ANON_CLASS' || $tokens[$start]['code'] === T_CLASS) {
|
749 |
-
return '';
|
750 |
-
}
|
751 |
-
|
752 |
-
$find = array(
|
753 |
-
T_NS_SEPARATOR,
|
754 |
-
T_STRING,
|
755 |
-
T_NAMESPACE,
|
756 |
-
T_WHITESPACE,
|
757 |
-
);
|
758 |
-
|
759 |
-
$end = $phpcsFile->findNext($find, ($start + 1), null, true, null, true);
|
760 |
-
$className = $phpcsFile->getTokensAsString($start, ($end - $start));
|
761 |
-
$className = trim($className);
|
762 |
-
|
763 |
-
return $this->getFQName($phpcsFile, $stackPtr, $className);
|
764 |
-
}
|
765 |
-
|
766 |
-
|
767 |
-
/**
|
768 |
-
* Returns the fully qualified name of the class that the specified class extends.
|
769 |
-
*
|
770 |
-
* Returns an empty string if the class does not extend another class or if
|
771 |
-
* the class name could not be reliably inferred.
|
772 |
-
*
|
773 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
774 |
-
* @param int $stackPtr The position of a T_CLASS token.
|
775 |
-
*
|
776 |
-
* @return string
|
777 |
-
*/
|
778 |
-
public function getFQExtendedClassName(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
779 |
-
{
|
780 |
-
$tokens = $phpcsFile->getTokens();
|
781 |
-
|
782 |
-
// Check for the existence of the token.
|
783 |
-
if (isset($tokens[$stackPtr]) === false) {
|
784 |
-
return '';
|
785 |
-
}
|
786 |
-
|
787 |
-
if ($tokens[$stackPtr]['code'] !== T_CLASS
|
788 |
-
&& $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS'
|
789 |
-
&& $tokens[$stackPtr]['type'] !== 'T_INTERFACE'
|
790 |
-
) {
|
791 |
-
return '';
|
792 |
-
}
|
793 |
-
|
794 |
-
$extends = $this->findExtendedClassName($phpcsFile, $stackPtr);
|
795 |
-
if (empty($extends) || is_string($extends) === false) {
|
796 |
-
return '';
|
797 |
-
}
|
798 |
-
|
799 |
-
return $this->getFQName($phpcsFile, $stackPtr, $extends);
|
800 |
-
}
|
801 |
-
|
802 |
-
|
803 |
-
/**
|
804 |
-
* Returns the class name for the static usage of a class.
|
805 |
-
* This can be a call to a method, the use of a property or constant.
|
806 |
-
*
|
807 |
-
* Returns an empty string if the class name could not be reliably inferred.
|
808 |
-
*
|
809 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
810 |
-
* @param int $stackPtr The position of a T_NEW token.
|
811 |
-
*
|
812 |
-
* @return string
|
813 |
-
*/
|
814 |
-
public function getFQClassNameFromDoubleColonToken(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
815 |
-
{
|
816 |
-
$tokens = $phpcsFile->getTokens();
|
817 |
-
|
818 |
-
// Check for the existence of the token.
|
819 |
-
if (isset($tokens[$stackPtr]) === false) {
|
820 |
-
return '';
|
821 |
-
}
|
822 |
-
|
823 |
-
if ($tokens[$stackPtr]['code'] !== T_DOUBLE_COLON) {
|
824 |
-
return '';
|
825 |
-
}
|
826 |
-
|
827 |
-
// Nothing to do if previous token is a variable as we don't know where it was defined.
|
828 |
-
if ($tokens[$stackPtr - 1]['code'] === T_VARIABLE) {
|
829 |
-
return '';
|
830 |
-
}
|
831 |
-
|
832 |
-
// Nothing to do if 'parent' or 'static' as we don't know how far the class tree extends.
|
833 |
-
if (in_array($tokens[$stackPtr - 1]['code'], array(T_PARENT, T_STATIC), true)) {
|
834 |
-
return '';
|
835 |
-
}
|
836 |
-
|
837 |
-
// Get the classname from the class declaration if self is used.
|
838 |
-
if ($tokens[$stackPtr - 1]['code'] === T_SELF) {
|
839 |
-
$classDeclarationPtr = $phpcsFile->findPrevious(T_CLASS, $stackPtr - 1);
|
840 |
-
if ($classDeclarationPtr === false) {
|
841 |
-
return '';
|
842 |
-
}
|
843 |
-
$className = $phpcsFile->getDeclarationName($classDeclarationPtr);
|
844 |
-
return $this->getFQName($phpcsFile, $classDeclarationPtr, $className);
|
845 |
-
}
|
846 |
-
|
847 |
-
$find = array(
|
848 |
-
T_NS_SEPARATOR,
|
849 |
-
T_STRING,
|
850 |
-
T_NAMESPACE,
|
851 |
-
T_WHITESPACE,
|
852 |
-
);
|
853 |
-
|
854 |
-
$start = $phpcsFile->findPrevious($find, $stackPtr - 1, null, true, null, true);
|
855 |
-
if ($start === false || isset($tokens[($start + 1)]) === false) {
|
856 |
-
return '';
|
857 |
-
}
|
858 |
-
|
859 |
-
$start = ($start + 1);
|
860 |
-
$className = $phpcsFile->getTokensAsString($start, ($stackPtr - $start));
|
861 |
-
$className = trim($className);
|
862 |
-
|
863 |
-
return $this->getFQName($phpcsFile, $stackPtr, $className);
|
864 |
-
}
|
865 |
-
|
866 |
-
|
867 |
-
/**
|
868 |
-
* Get the Fully Qualified name for a class/function/constant etc.
|
869 |
-
*
|
870 |
-
* Checks if a class/function/constant name is already fully qualified and
|
871 |
-
* if not, enrich it with the relevant namespace information.
|
872 |
-
*
|
873 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
874 |
-
* @param int $stackPtr The position of the token.
|
875 |
-
* @param string $name The class / function / constant name.
|
876 |
-
*
|
877 |
-
* @return string
|
878 |
-
*/
|
879 |
-
public function getFQName(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $name)
|
880 |
-
{
|
881 |
-
if (strpos($name, '\\') === 0) {
|
882 |
-
// Already fully qualified.
|
883 |
-
return $name;
|
884 |
-
}
|
885 |
-
|
886 |
-
// Remove the namespace keyword if used.
|
887 |
-
if (strpos($name, 'namespace\\') === 0) {
|
888 |
-
$name = substr($name, 10);
|
889 |
-
}
|
890 |
-
|
891 |
-
$namespace = $this->determineNamespace($phpcsFile, $stackPtr);
|
892 |
-
|
893 |
-
if ($namespace === '') {
|
894 |
-
return '\\' . $name;
|
895 |
-
} else {
|
896 |
-
return '\\' . $namespace . '\\' . $name;
|
897 |
-
}
|
898 |
-
}
|
899 |
-
|
900 |
-
|
901 |
-
/**
|
902 |
-
* Is the class/function/constant name namespaced or global ?
|
903 |
-
*
|
904 |
-
* @param string $FQName Fully Qualified name of a class, function etc.
|
905 |
-
* I.e. should always start with a `\`.
|
906 |
-
*
|
907 |
-
* @return bool True if namespaced, false if global.
|
908 |
-
*/
|
909 |
-
public function isNamespaced($FQName)
|
910 |
-
{
|
911 |
-
if (strpos($FQName, '\\') !== 0) {
|
912 |
-
throw new \PHP_CodeSniffer_Exception('$FQName must be a fully qualified name');
|
913 |
-
}
|
914 |
-
|
915 |
-
return (strpos(substr($FQName, 1), '\\') !== false);
|
916 |
-
}
|
917 |
-
|
918 |
-
|
919 |
-
/**
|
920 |
-
* Determine the namespace name an arbitrary token lives in.
|
921 |
-
*
|
922 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
923 |
-
* @param int $stackPtr The token position for which to determine the namespace.
|
924 |
-
*
|
925 |
-
* @return string Namespace name or empty string if it couldn't be determined or no namespace applies.
|
926 |
-
*/
|
927 |
-
public function determineNamespace(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
928 |
-
{
|
929 |
-
$tokens = $phpcsFile->getTokens();
|
930 |
-
|
931 |
-
// Check for the existence of the token.
|
932 |
-
if (isset($tokens[$stackPtr]) === false) {
|
933 |
-
return '';
|
934 |
-
}
|
935 |
-
|
936 |
-
// Check for scoped namespace {}.
|
937 |
-
if (empty($tokens[$stackPtr]['conditions']) === false) {
|
938 |
-
$namespacePtr = $phpcsFile->getCondition($stackPtr, T_NAMESPACE);
|
939 |
-
if ($namespacePtr !== false) {
|
940 |
-
$namespace = $this->getDeclaredNamespaceName($phpcsFile, $namespacePtr);
|
941 |
-
if ($namespace !== false) {
|
942 |
-
return $namespace;
|
943 |
-
}
|
944 |
-
|
945 |
-
// We are in a scoped namespace, but couldn't determine the name. Searching for a global namespace is futile.
|
946 |
-
return '';
|
947 |
-
}
|
948 |
-
}
|
949 |
-
|
950 |
-
/*
|
951 |
-
* Not in a scoped namespace, so let's see if we can find a non-scoped namespace instead.
|
952 |
-
* Keeping in mind that:
|
953 |
-
* - there can be multiple non-scoped namespaces in a file (bad practice, but it happens).
|
954 |
-
* - the namespace keyword can also be used as part of a function/method call and such.
|
955 |
-
* - that a non-named namespace resolves to the global namespace.
|
956 |
-
*/
|
957 |
-
$previousNSToken = $stackPtr;
|
958 |
-
$namespace = false;
|
959 |
-
do {
|
960 |
-
$previousNSToken = $phpcsFile->findPrevious(T_NAMESPACE, ($previousNSToken - 1));
|
961 |
-
|
962 |
-
// Stop if we encounter a scoped namespace declaration as we already know we're not in one.
|
963 |
-
if (empty($tokens[$previousNSToken]['scope_condition']) === false && $tokens[$previousNSToken]['scope_condition'] === $previousNSToken) {
|
964 |
-
break;
|
965 |
-
}
|
966 |
-
|
967 |
-
$namespace = $this->getDeclaredNamespaceName($phpcsFile, $previousNSToken);
|
968 |
-
|
969 |
-
} while ($namespace === false && $previousNSToken !== false);
|
970 |
-
|
971 |
-
// If we still haven't got a namespace, return an empty string.
|
972 |
-
if ($namespace === false) {
|
973 |
-
return '';
|
974 |
-
} else {
|
975 |
-
return $namespace;
|
976 |
-
}
|
977 |
-
}
|
978 |
-
|
979 |
-
/**
|
980 |
-
* Get the complete namespace name for a namespace declaration.
|
981 |
-
*
|
982 |
-
* For hierarchical namespaces, the name will be composed of several tokens,
|
983 |
-
* i.e. MyProject\Sub\Level which will be returned together as one string.
|
984 |
-
*
|
985 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
986 |
-
* @param int|bool $stackPtr The position of a T_NAMESPACE token.
|
987 |
-
*
|
988 |
-
* @return string|false Namespace name or false if not a namespace declaration.
|
989 |
-
* Namespace name can be an empty string for global namespace declaration.
|
990 |
-
*/
|
991 |
-
public function getDeclaredNamespaceName(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
992 |
-
{
|
993 |
-
$tokens = $phpcsFile->getTokens();
|
994 |
-
|
995 |
-
// Check for the existence of the token.
|
996 |
-
if ($stackPtr === false || isset($tokens[$stackPtr]) === false) {
|
997 |
-
return false;
|
998 |
-
}
|
999 |
-
|
1000 |
-
if ($tokens[$stackPtr]['code'] !== T_NAMESPACE) {
|
1001 |
-
return false;
|
1002 |
-
}
|
1003 |
-
|
1004 |
-
if ($tokens[($stackPtr + 1)]['code'] === T_NS_SEPARATOR) {
|
1005 |
-
// Not a namespace declaration, but use of, i.e. namespace\someFunction();
|
1006 |
-
return false;
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
$nextToken = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
1010 |
-
if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) {
|
1011 |
-
// Declaration for global namespace when using multiple namespaces in a file.
|
1012 |
-
// I.e.: namespace {}
|
1013 |
-
return '';
|
1014 |
-
}
|
1015 |
-
|
1016 |
-
// Ok, this should be a namespace declaration, so get all the parts together.
|
1017 |
-
$validTokens = array(
|
1018 |
-
T_STRING => true,
|
1019 |
-
T_NS_SEPARATOR => true,
|
1020 |
-
T_WHITESPACE => true,
|
1021 |
-
);
|
1022 |
-
|
1023 |
-
$namespaceName = '';
|
1024 |
-
while (isset($validTokens[$tokens[$nextToken]['code']]) === true) {
|
1025 |
-
$namespaceName .= trim($tokens[$nextToken]['content']);
|
1026 |
-
$nextToken++;
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
return $namespaceName;
|
1030 |
-
}
|
1031 |
-
|
1032 |
-
|
1033 |
-
/**
|
1034 |
-
* Get the stack pointer for a return type token for a given function.
|
1035 |
-
*
|
1036 |
-
* Compatible layer for older PHPCS versions which don't recognize
|
1037 |
-
* return type hints correctly.
|
1038 |
-
*
|
1039 |
-
* Expects to be passed T_RETURN_TYPE, T_FUNCTION or T_CLOSURE token.
|
1040 |
-
*
|
1041 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
1042 |
-
* @param int $stackPtr The position of the token.
|
1043 |
-
*
|
1044 |
-
* @return int|false Stack pointer to the return type token or false if
|
1045 |
-
* no return type was found or the passed token was
|
1046 |
-
* not of the correct type.
|
1047 |
-
*/
|
1048 |
-
public function getReturnTypeHintToken(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1049 |
-
{
|
1050 |
-
$tokens = $phpcsFile->getTokens();
|
1051 |
-
|
1052 |
-
if (defined('T_RETURN_TYPE') && $tokens[$stackPtr]['code'] === T_RETURN_TYPE) {
|
1053 |
-
return $tokens[$stackPtr]['code'];
|
1054 |
-
}
|
1055 |
-
|
1056 |
-
if ($tokens[$stackPtr]['code'] !== T_FUNCTION && $tokens[$stackPtr]['code'] !== T_CLOSURE) {
|
1057 |
-
return false;
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
if (isset($tokens[$stackPtr]['parenthesis_closer'], $tokens[$stackPtr]['scope_opener']) === false
|
1061 |
-
|| ($tokens[$stackPtr]['parenthesis_closer'] + 1) === $tokens[$stackPtr]['scope_opener']
|
1062 |
-
) {
|
1063 |
-
return false;
|
1064 |
-
}
|
1065 |
-
|
1066 |
-
$hasColon = $phpcsFile->findNext(array(T_COLON, T_INLINE_ELSE), ($tokens[$stackPtr]['parenthesis_closer'] + 1), $tokens[$stackPtr]['scope_opener']);
|
1067 |
-
if ($hasColon === false) {
|
1068 |
-
return false;
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
// `self`, `parent` and `callable` are not being recognized as return types in PHPCS < 2.6.0.
|
1072 |
-
$unrecognizedTypes = array(
|
1073 |
-
T_CALLABLE,
|
1074 |
-
T_SELF,
|
1075 |
-
T_PARENT,
|
1076 |
-
);
|
1077 |
-
|
1078 |
-
// Return types are not recognized at all in PHPCS < 2.4.0.
|
1079 |
-
if (defined('T_RETURN_TYPE') === false) {
|
1080 |
-
$unrecognizedTypes[] = T_ARRAY;
|
1081 |
-
$unrecognizedTypes[] = T_STRING;
|
1082 |
-
}
|
1083 |
-
|
1084 |
-
return $phpcsFile->findNext($unrecognizedTypes, ($hasColon + 1), $tokens[$stackPtr]['scope_opener']);
|
1085 |
-
}
|
1086 |
-
|
1087 |
-
|
1088 |
-
/**
|
1089 |
-
* Check whether a T_VARIABLE token is a class property declaration.
|
1090 |
-
*
|
1091 |
-
* Compatibility layer for PHPCS cross-version compatibility
|
1092 |
-
* as PHPCS 2.4.0 - 2.7.1 does not have good enough support for
|
1093 |
-
* anonymous classes. Along the same lines, the`getMemberProperties()`
|
1094 |
-
* method does not support the `var` prefix.
|
1095 |
-
*
|
1096 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
1097 |
-
* @param int $stackPtr The position in the stack of the
|
1098 |
-
* T_VARIABLE token to verify.
|
1099 |
-
*
|
1100 |
-
* @return bool
|
1101 |
-
*/
|
1102 |
-
public function isClassProperty(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1103 |
-
{
|
1104 |
-
$tokens = $phpcsFile->getTokens();
|
1105 |
-
|
1106 |
-
if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== T_VARIABLE) {
|
1107 |
-
return false;
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
// Note: interfaces can not declare properties.
|
1111 |
-
$validScopes = array(
|
1112 |
-
'T_CLASS' => true,
|
1113 |
-
'T_ANON_CLASS' => true,
|
1114 |
-
'T_TRAIT' => true,
|
1115 |
-
);
|
1116 |
-
if ($this->validDirectScope($phpcsFile, $stackPtr, $validScopes) === true) {
|
1117 |
-
// Make sure it's not a method parameter.
|
1118 |
-
if (empty($tokens[$stackPtr]['nested_parenthesis']) === true) {
|
1119 |
-
return true;
|
1120 |
-
}
|
1121 |
-
}
|
1122 |
-
|
1123 |
-
return false;
|
1124 |
-
}
|
1125 |
-
|
1126 |
-
|
1127 |
-
/**
|
1128 |
-
* Check whether a T_CONST token is a class constant declaration.
|
1129 |
-
*
|
1130 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
1131 |
-
* @param int $stackPtr The position in the stack of the
|
1132 |
-
* T_CONST token to verify.
|
1133 |
-
*
|
1134 |
-
* @return bool
|
1135 |
-
*/
|
1136 |
-
public function isClassConstant(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1137 |
-
{
|
1138 |
-
$tokens = $phpcsFile->getTokens();
|
1139 |
-
|
1140 |
-
if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== T_CONST) {
|
1141 |
-
return false;
|
1142 |
-
}
|
1143 |
-
|
1144 |
-
// Note: traits can not declare constants.
|
1145 |
-
$validScopes = array(
|
1146 |
-
'T_CLASS' => true,
|
1147 |
-
'T_ANON_CLASS' => true,
|
1148 |
-
'T_INTERFACE' => true,
|
1149 |
-
);
|
1150 |
-
if ($this->validDirectScope($phpcsFile, $stackPtr, $validScopes) === true) {
|
1151 |
-
return true;
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
return false;
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
|
1158 |
-
/**
|
1159 |
-
* Check whether the direct wrapping scope of a token is within a limited set of
|
1160 |
-
* acceptable tokens.
|
1161 |
-
*
|
1162 |
-
* Used to check, for instance, if a T_CONST is a class constant.
|
1163 |
-
*
|
1164 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
1165 |
-
* @param int $stackPtr The position in the stack of the
|
1166 |
-
* T_CONST token to verify.
|
1167 |
-
* @param array $validScopes Array of token types.
|
1168 |
-
* Keys should be the token types in string
|
1169 |
-
* format to allow for newer token types.
|
1170 |
-
* Value is irrelevant.
|
1171 |
-
*
|
1172 |
-
* @return bool
|
1173 |
-
*/
|
1174 |
-
protected function validDirectScope(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $validScopes)
|
1175 |
-
{
|
1176 |
-
$tokens = $phpcsFile->getTokens();
|
1177 |
-
|
1178 |
-
if (empty($tokens[$stackPtr]['conditions']) === true) {
|
1179 |
-
return false;
|
1180 |
-
}
|
1181 |
-
|
1182 |
-
/*
|
1183 |
-
* Check only the direct wrapping scope of the token.
|
1184 |
-
*/
|
1185 |
-
$conditions = array_keys($tokens[$stackPtr]['conditions']);
|
1186 |
-
$ptr = array_pop($conditions);
|
1187 |
-
|
1188 |
-
if (isset($tokens[$ptr]) === false) {
|
1189 |
-
return false;
|
1190 |
-
}
|
1191 |
-
|
1192 |
-
if (isset($validScopes[$tokens[$ptr]['type']]) === true) {
|
1193 |
-
return true;
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
return false;
|
1197 |
-
}
|
1198 |
-
|
1199 |
-
|
1200 |
-
/**
|
1201 |
-
* Get an array of just the type hints from a function declaration.
|
1202 |
-
*
|
1203 |
-
* Expects to be passed T_FUNCTION or T_CLOSURE token.
|
1204 |
-
*
|
1205 |
-
* Strips potential nullable indicator and potential global namespace
|
1206 |
-
* indicator from the type hints before returning them.
|
1207 |
-
*
|
1208 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
1209 |
-
* @param int $stackPtr The position of the token.
|
1210 |
-
*
|
1211 |
-
* @return array Array with type hints or an empty array if
|
1212 |
-
* - the function does not have any parameters
|
1213 |
-
* - no type hints were found
|
1214 |
-
* - or the passed token was not of the correct type.
|
1215 |
-
*/
|
1216 |
-
public function getTypeHintsFromFunctionDeclaration(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1217 |
-
{
|
1218 |
-
$tokens = $phpcsFile->getTokens();
|
1219 |
-
|
1220 |
-
if ($tokens[$stackPtr]['code'] !== T_FUNCTION && $tokens[$stackPtr]['code'] !== T_CLOSURE) {
|
1221 |
-
return array();
|
1222 |
-
}
|
1223 |
-
|
1224 |
-
$parameters = $this->getMethodParameters($phpcsFile, $stackPtr);
|
1225 |
-
if (empty($parameters) || is_array($parameters) === false) {
|
1226 |
-
return array();
|
1227 |
-
}
|
1228 |
-
|
1229 |
-
$typeHints = array();
|
1230 |
-
|
1231 |
-
foreach ($parameters as $param) {
|
1232 |
-
if ($param['type_hint'] === '') {
|
1233 |
-
continue;
|
1234 |
-
}
|
1235 |
-
|
1236 |
-
// Strip off potential nullable indication.
|
1237 |
-
$typeHint = ltrim($param['type_hint'], '?');
|
1238 |
-
|
1239 |
-
// Strip off potential (global) namespace indication.
|
1240 |
-
$typeHint = ltrim($typeHint, '\\');
|
1241 |
-
|
1242 |
-
if ($typeHint !== '') {
|
1243 |
-
$typeHints[] = $typeHint;
|
1244 |
-
}
|
1245 |
-
}
|
1246 |
-
|
1247 |
-
return $typeHints;
|
1248 |
-
}
|
1249 |
-
|
1250 |
-
|
1251 |
-
/**
|
1252 |
-
* Returns the method parameters for the specified function token.
|
1253 |
-
*
|
1254 |
-
* Each parameter is in the following format:
|
1255 |
-
*
|
1256 |
-
* <code>
|
1257 |
-
* 0 => array(
|
1258 |
-
* 'token' => int, // The position of the var in the token stack.
|
1259 |
-
* 'name' => '$var', // The variable name.
|
1260 |
-
* 'content' => string, // The full content of the variable definition.
|
1261 |
-
* 'pass_by_reference' => boolean, // Is the variable passed by reference?
|
1262 |
-
* 'variable_length' => boolean, // Is the param of variable length through use of `...` ?
|
1263 |
-
* 'type_hint' => string, // The type hint for the variable.
|
1264 |
-
* 'nullable_type' => boolean, // Is the variable using a nullable type?
|
1265 |
-
* )
|
1266 |
-
* </code>
|
1267 |
-
*
|
1268 |
-
* Parameters with default values have an additional array index of
|
1269 |
-
* 'default' with the value of the default as a string.
|
1270 |
-
*
|
1271 |
-
* {@internal Duplicate of same method as contained in the `\PHP_CodeSniffer_File`
|
1272 |
-
* class, but with some improvements which have been introduced in
|
1273 |
-
* PHPCS 2.8.0.
|
1274 |
-
* {@link https://github.com/squizlabs/PHP_CodeSniffer/pull/1117},
|
1275 |
-
* {@link https://github.com/squizlabs/PHP_CodeSniffer/pull/1193} and
|
1276 |
-
* {@link https://github.com/squizlabs/PHP_CodeSniffer/pull/1293}.
|
1277 |
-
*
|
1278 |
-
* Once the minimum supported PHPCS version for this standard goes beyond
|
1279 |
-
* that, this method can be removed and calls to it replaced with
|
1280 |
-
* `$phpcsFile->getMethodParameters($stackPtr)` calls.
|
1281 |
-
*
|
1282 |
-
* NOTE: This version does not deal with the new T_NULLABLE token type.
|
1283 |
-
* This token is included upstream only in 2.8.0+ and as we defer to upstream
|
1284 |
-
* in that case, no need to deal with it here.
|
1285 |
-
*
|
1286 |
-
* Last synced with PHPCS version: PHPCS 2.9.0-alpha at commit f1511adad043edfd6d2e595e77385c32577eb2bc}}
|
1287 |
-
*
|
1288 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
1289 |
-
* @param int $stackPtr The position in the stack of the
|
1290 |
-
* function token to acquire the
|
1291 |
-
* parameters for.
|
1292 |
-
*
|
1293 |
-
* @return array|false
|
1294 |
-
* @throws \PHP_CodeSniffer_Exception If the specified $stackPtr is not of
|
1295 |
-
* type T_FUNCTION or T_CLOSURE.
|
1296 |
-
*/
|
1297 |
-
public function getMethodParameters(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1298 |
-
{
|
1299 |
-
if (version_compare(PHPCSHelper::getVersion(), '2.7.1', '>') === true) {
|
1300 |
-
return $phpcsFile->getMethodParameters($stackPtr);
|
1301 |
-
}
|
1302 |
-
|
1303 |
-
$tokens = $phpcsFile->getTokens();
|
1304 |
-
|
1305 |
-
// Check for the existence of the token.
|
1306 |
-
if (isset($tokens[$stackPtr]) === false) {
|
1307 |
-
return false;
|
1308 |
-
}
|
1309 |
-
|
1310 |
-
if ($tokens[$stackPtr]['code'] !== T_FUNCTION && $tokens[$stackPtr]['code'] !== T_CLOSURE) {
|
1311 |
-
throw new \PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION or T_CLOSURE');
|
1312 |
-
}
|
1313 |
-
|
1314 |
-
$opener = $tokens[$stackPtr]['parenthesis_opener'];
|
1315 |
-
$closer = $tokens[$stackPtr]['parenthesis_closer'];
|
1316 |
-
|
1317 |
-
$vars = array();
|
1318 |
-
$currVar = null;
|
1319 |
-
$paramStart = ($opener + 1);
|
1320 |
-
$defaultStart = null;
|
1321 |
-
$paramCount = 0;
|
1322 |
-
$passByReference = false;
|
1323 |
-
$variableLength = false;
|
1324 |
-
$typeHint = '';
|
1325 |
-
$nullableType = false;
|
1326 |
-
|
1327 |
-
for ($i = $paramStart; $i <= $closer; $i++) {
|
1328 |
-
// Check to see if this token has a parenthesis or bracket opener. If it does
|
1329 |
-
// it's likely to be an array which might have arguments in it. This
|
1330 |
-
// could cause problems in our parsing below, so lets just skip to the
|
1331 |
-
// end of it.
|
1332 |
-
if (isset($tokens[$i]['parenthesis_opener']) === true) {
|
1333 |
-
// Don't do this if it's the close parenthesis for the method.
|
1334 |
-
if ($i !== $tokens[$i]['parenthesis_closer']) {
|
1335 |
-
$i = ($tokens[$i]['parenthesis_closer'] + 1);
|
1336 |
-
}
|
1337 |
-
}
|
1338 |
-
|
1339 |
-
if (isset($tokens[$i]['bracket_opener']) === true) {
|
1340 |
-
// Don't do this if it's the close parenthesis for the method.
|
1341 |
-
if ($i !== $tokens[$i]['bracket_closer']) {
|
1342 |
-
$i = ($tokens[$i]['bracket_closer'] + 1);
|
1343 |
-
}
|
1344 |
-
}
|
1345 |
-
|
1346 |
-
switch ($tokens[$i]['type']) {
|
1347 |
-
case 'T_BITWISE_AND':
|
1348 |
-
$passByReference = true;
|
1349 |
-
break;
|
1350 |
-
case 'T_VARIABLE':
|
1351 |
-
$currVar = $i;
|
1352 |
-
break;
|
1353 |
-
case 'T_ELLIPSIS':
|
1354 |
-
$variableLength = true;
|
1355 |
-
break;
|
1356 |
-
case 'T_ARRAY_HINT':
|
1357 |
-
case 'T_CALLABLE':
|
1358 |
-
$typeHint .= $tokens[$i]['content'];
|
1359 |
-
break;
|
1360 |
-
case 'T_SELF':
|
1361 |
-
case 'T_PARENT':
|
1362 |
-
case 'T_STATIC':
|
1363 |
-
// Self is valid, the others invalid, but were probably intended as type hints.
|
1364 |
-
if (isset($defaultStart) === false) {
|
1365 |
-
$typeHint .= $tokens[$i]['content'];
|
1366 |
-
}
|
1367 |
-
break;
|
1368 |
-
case 'T_STRING':
|
1369 |
-
// This is a string, so it may be a type hint, but it could
|
1370 |
-
// also be a constant used as a default value.
|
1371 |
-
$prevComma = false;
|
1372 |
-
for ($t = $i; $t >= $opener; $t--) {
|
1373 |
-
if ($tokens[$t]['code'] === T_COMMA) {
|
1374 |
-
$prevComma = $t;
|
1375 |
-
break;
|
1376 |
-
}
|
1377 |
-
}
|
1378 |
-
|
1379 |
-
if ($prevComma !== false) {
|
1380 |
-
$nextEquals = false;
|
1381 |
-
for ($t = $prevComma; $t < $i; $t++) {
|
1382 |
-
if ($tokens[$t]['code'] === T_EQUAL) {
|
1383 |
-
$nextEquals = $t;
|
1384 |
-
break;
|
1385 |
-
}
|
1386 |
-
}
|
1387 |
-
|
1388 |
-
if ($nextEquals !== false) {
|
1389 |
-
break;
|
1390 |
-
}
|
1391 |
-
}
|
1392 |
-
|
1393 |
-
if ($defaultStart === null) {
|
1394 |
-
$typeHint .= $tokens[$i]['content'];
|
1395 |
-
}
|
1396 |
-
break;
|
1397 |
-
case 'T_NS_SEPARATOR':
|
1398 |
-
// Part of a type hint or default value.
|
1399 |
-
if ($defaultStart === null) {
|
1400 |
-
$typeHint .= $tokens[$i]['content'];
|
1401 |
-
}
|
1402 |
-
break;
|
1403 |
-
case 'T_INLINE_THEN':
|
1404 |
-
if ($defaultStart === null) {
|
1405 |
-
$nullableType = true;
|
1406 |
-
$typeHint .= $tokens[$i]['content'];
|
1407 |
-
}
|
1408 |
-
break;
|
1409 |
-
case 'T_CLOSE_PARENTHESIS':
|
1410 |
-
case 'T_COMMA':
|
1411 |
-
// If it's null, then there must be no parameters for this
|
1412 |
-
// method.
|
1413 |
-
if ($currVar === null) {
|
1414 |
-
continue;
|
1415 |
-
}
|
1416 |
-
|
1417 |
-
$vars[$paramCount] = array();
|
1418 |
-
$vars[$paramCount]['token'] = $currVar;
|
1419 |
-
$vars[$paramCount]['name'] = $tokens[$currVar]['content'];
|
1420 |
-
$vars[$paramCount]['content'] = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart)));
|
1421 |
-
|
1422 |
-
if ($defaultStart !== null) {
|
1423 |
-
$vars[$paramCount]['default']
|
1424 |
-
= trim($phpcsFile->getTokensAsString(
|
1425 |
-
$defaultStart,
|
1426 |
-
($i - $defaultStart)
|
1427 |
-
));
|
1428 |
-
}
|
1429 |
-
|
1430 |
-
$vars[$paramCount]['pass_by_reference'] = $passByReference;
|
1431 |
-
$vars[$paramCount]['variable_length'] = $variableLength;
|
1432 |
-
$vars[$paramCount]['type_hint'] = $typeHint;
|
1433 |
-
$vars[$paramCount]['nullable_type'] = $nullableType;
|
1434 |
-
|
1435 |
-
// Reset the vars, as we are about to process the next parameter.
|
1436 |
-
$defaultStart = null;
|
1437 |
-
$paramStart = ($i + 1);
|
1438 |
-
$passByReference = false;
|
1439 |
-
$variableLength = false;
|
1440 |
-
$typeHint = '';
|
1441 |
-
$nullableType = false;
|
1442 |
-
|
1443 |
-
$paramCount++;
|
1444 |
-
break;
|
1445 |
-
case 'T_EQUAL':
|
1446 |
-
$defaultStart = ($i + 1);
|
1447 |
-
break;
|
1448 |
-
}//end switch
|
1449 |
-
}//end for
|
1450 |
-
|
1451 |
-
return $vars;
|
1452 |
-
|
1453 |
-
}//end getMethodParameters()
|
1454 |
-
|
1455 |
-
|
1456 |
-
/**
|
1457 |
-
* Returns the name of the class that the specified class extends
|
1458 |
-
* (works for classes, anonymous classes and interfaces).
|
1459 |
-
*
|
1460 |
-
* Returns FALSE on error or if there is no extended class name.
|
1461 |
-
*
|
1462 |
-
* {@internal Duplicate of same method as contained in the `\PHP_CodeSniffer_File`
|
1463 |
-
* class, but with some improvements which have been introduced in
|
1464 |
-
* PHPCS 2.8.0.
|
1465 |
-
* {@link https://github.com/squizlabs/PHP_CodeSniffer/commit/0011d448119d4c568e3ac1f825ae78815bf2cc34}.
|
1466 |
-
*
|
1467 |
-
* Once the minimum supported PHPCS version for this standard goes beyond
|
1468 |
-
* that, this method can be removed and calls to it replaced with
|
1469 |
-
* `$phpcsFile->findExtendedClassName($stackPtr)` calls.
|
1470 |
-
*
|
1471 |
-
* Last synced with PHPCS version: PHPCS 3.1.0-alpha at commit a9efcc9b0703f3f9f4a900623d4e97128a6aafc6}}
|
1472 |
-
*
|
1473 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
1474 |
-
* @param int $stackPtr The position of the class token in the stack.
|
1475 |
-
*
|
1476 |
-
* @return string|false
|
1477 |
-
*/
|
1478 |
-
public function findExtendedClassName(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1479 |
-
{
|
1480 |
-
if (version_compare(PHPCSHelper::getVersion(), '3.1.0', '>=') === true) {
|
1481 |
-
return $phpcsFile->findExtendedClassName($stackPtr);
|
1482 |
-
}
|
1483 |
-
|
1484 |
-
$tokens = $phpcsFile->getTokens();
|
1485 |
-
|
1486 |
-
// Check for the existence of the token.
|
1487 |
-
if (isset($tokens[$stackPtr]) === false) {
|
1488 |
-
return false;
|
1489 |
-
}
|
1490 |
-
|
1491 |
-
if ($tokens[$stackPtr]['code'] !== T_CLASS
|
1492 |
-
&& $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS'
|
1493 |
-
&& $tokens[$stackPtr]['type'] !== 'T_INTERFACE'
|
1494 |
-
) {
|
1495 |
-
return false;
|
1496 |
-
}
|
1497 |
-
|
1498 |
-
if (isset($tokens[$stackPtr]['scope_closer']) === false) {
|
1499 |
-
return false;
|
1500 |
-
}
|
1501 |
-
|
1502 |
-
$classCloserIndex = $tokens[$stackPtr]['scope_closer'];
|
1503 |
-
$extendsIndex = $phpcsFile->findNext(T_EXTENDS, $stackPtr, $classCloserIndex);
|
1504 |
-
if (false === $extendsIndex) {
|
1505 |
-
return false;
|
1506 |
-
}
|
1507 |
-
|
1508 |
-
$find = array(
|
1509 |
-
T_NS_SEPARATOR,
|
1510 |
-
T_STRING,
|
1511 |
-
T_WHITESPACE,
|
1512 |
-
);
|
1513 |
-
|
1514 |
-
$end = $phpcsFile->findNext($find, ($extendsIndex + 1), $classCloserIndex, true);
|
1515 |
-
$name = $phpcsFile->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1));
|
1516 |
-
$name = trim($name);
|
1517 |
-
|
1518 |
-
if ($name === '') {
|
1519 |
-
return false;
|
1520 |
-
}
|
1521 |
-
|
1522 |
-
return $name;
|
1523 |
-
|
1524 |
-
}//end findExtendedClassName()
|
1525 |
-
|
1526 |
-
|
1527 |
-
/**
|
1528 |
-
* Get the hash algorithm name from the parameter in a hash function call.
|
1529 |
-
*
|
1530 |
-
* @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
|
1531 |
-
* @param int $stackPtr The position of the T_STRING function token.
|
1532 |
-
*
|
1533 |
-
* @return string|false The algorithm name without quotes if this was a relevant hash
|
1534 |
-
* function call or false if it was not.
|
1535 |
-
*/
|
1536 |
-
public function getHashAlgorithmParameter(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1537 |
-
{
|
1538 |
-
$tokens = $phpcsFile->getTokens();
|
1539 |
-
|
1540 |
-
// Check for the existence of the token.
|
1541 |
-
if (isset($tokens[$stackPtr]) === false) {
|
1542 |
-
return false;
|
1543 |
-
}
|
1544 |
-
|
1545 |
-
if ($tokens[$stackPtr]['code'] !== T_STRING) {
|
1546 |
-
return false;
|
1547 |
-
}
|
1548 |
-
|
1549 |
-
$functionName = $tokens[$stackPtr]['content'];
|
1550 |
-
$functionNameLc = strtolower($functionName);
|
1551 |
-
|
1552 |
-
// Bow out if not one of the functions we're targetting.
|
1553 |
-
if (isset($this->hashAlgoFunctions[$functionNameLc]) === false) {
|
1554 |
-
return false;
|
1555 |
-
}
|
1556 |
-
|
1557 |
-
// Get the parameter from the function call which should contain the algorithm name.
|
1558 |
-
$algoParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->hashAlgoFunctions[$functionNameLc]);
|
1559 |
-
if ($algoParam === false) {
|
1560 |
-
return false;
|
1561 |
-
}
|
1562 |
-
|
1563 |
-
// Algorithm is a text string, so we need to remove the quotes.
|
1564 |
-
$algo = strtolower(trim($algoParam['raw']));
|
1565 |
-
$algo = $this->stripQuotes($algo);
|
1566 |
-
|
1567 |
-
return $algo;
|
1568 |
-
}
|
1569 |
-
|
1570 |
-
|
1571 |
-
/**
|
1572 |
-
* Determine whether an arbitrary T_STRING token is the use of a global constant.
|
1573 |
-
*
|
1574 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
1575 |
-
* @param int $stackPtr The position of the function call token.
|
1576 |
-
*
|
1577 |
-
* @return bool
|
1578 |
-
*/
|
1579 |
-
public function isUseOfGlobalConstant(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
1580 |
-
{
|
1581 |
-
static $isLowPHPCS, $isLowPHP;
|
1582 |
-
|
1583 |
-
$tokens = $phpcsFile->getTokens();
|
1584 |
-
|
1585 |
-
// Check for the existence of the token.
|
1586 |
-
if (isset($tokens[$stackPtr]) === false) {
|
1587 |
-
return false;
|
1588 |
-
}
|
1589 |
-
|
1590 |
-
// Is this one of the tokens this function handles ?
|
1591 |
-
if ($tokens[$stackPtr]['code'] !== T_STRING) {
|
1592 |
-
return false;
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
// Check for older PHP, PHPCS version so we can compensate for misidentified tokens.
|
1596 |
-
if (isset($isLowPHPCS, $isLowPHP) === false) {
|
1597 |
-
$isLowPHP = false;
|
1598 |
-
$isLowPHPCS = false;
|
1599 |
-
if (version_compare(PHP_VERSION_ID, '50400', '<')) {
|
1600 |
-
$isLowPHP = true;
|
1601 |
-
$isLowPHPCS = version_compare(PHPCSHelper::getVersion(), '2.4.0', '<');
|
1602 |
-
}
|
1603 |
-
}
|
1604 |
-
|
1605 |
-
$next = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
1606 |
-
if ($next !== false
|
1607 |
-
&& ($tokens[$next]['code'] === T_OPEN_PARENTHESIS
|
1608 |
-
|| $tokens[$next]['code'] === T_DOUBLE_COLON)
|
1609 |
-
) {
|
1610 |
-
// Function call or declaration.
|
1611 |
-
return false;
|
1612 |
-
}
|
1613 |
-
|
1614 |
-
// Array of tokens which if found preceding the $stackPtr indicate that a T_STRING is not a global constant.
|
1615 |
-
$tokensToIgnore = array(
|
1616 |
-
'T_NAMESPACE' => true,
|
1617 |
-
'T_USE' => true,
|
1618 |
-
'T_CLASS' => true,
|
1619 |
-
'T_TRAIT' => true,
|
1620 |
-
'T_INTERFACE' => true,
|
1621 |
-
'T_EXTENDS' => true,
|
1622 |
-
'T_IMPLEMENTS' => true,
|
1623 |
-
'T_NEW' => true,
|
1624 |
-
'T_FUNCTION' => true,
|
1625 |
-
'T_DOUBLE_COLON' => true,
|
1626 |
-
'T_OBJECT_OPERATOR' => true,
|
1627 |
-
'T_INSTANCEOF' => true,
|
1628 |
-
'T_INSTEADOF' => true,
|
1629 |
-
'T_GOTO' => true,
|
1630 |
-
'T_AS' => true,
|
1631 |
-
'T_PUBLIC' => true,
|
1632 |
-
'T_PROTECTED' => true,
|
1633 |
-
'T_PRIVATE' => true,
|
1634 |
-
);
|
1635 |
-
|
1636 |
-
$prev = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
1637 |
-
if ($prev !== false
|
1638 |
-
&& (isset($tokensToIgnore[$tokens[$prev]['type']]) === true)
|
1639 |
-
|| ($tokens[$prev]['code'] === T_STRING
|
1640 |
-
&& (($isLowPHPCS === true
|
1641 |
-
&& $tokens[$prev]['content'] === 'trait')
|
1642 |
-
|| ($isLowPHP === true
|
1643 |
-
&& $tokens[$prev]['content'] === 'insteadof')))
|
1644 |
-
) {
|
1645 |
-
// Not the use of a constant.
|
1646 |
-
return false;
|
1647 |
-
}
|
1648 |
-
|
1649 |
-
if ($prev !== false
|
1650 |
-
&& $tokens[$prev]['code'] === T_NS_SEPARATOR
|
1651 |
-
&& $tokens[($prev - 1)]['code'] === T_STRING
|
1652 |
-
) {
|
1653 |
-
// Namespaced constant of the same name.
|
1654 |
-
return false;
|
1655 |
-
}
|
1656 |
-
|
1657 |
-
if ($prev !== false
|
1658 |
-
&& $tokens[$prev]['code'] === T_CONST
|
1659 |
-
&& $this->isClassConstant($phpcsFile, $prev) === true
|
1660 |
-
) {
|
1661 |
-
// Class constant declaration of the same name.
|
1662 |
-
return false;
|
1663 |
-
}
|
1664 |
-
|
1665 |
-
/*
|
1666 |
-
* Deal with a number of variations of use statements.
|
1667 |
-
*/
|
1668 |
-
for ($i = $stackPtr; $i > 0; $i--) {
|
1669 |
-
if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) {
|
1670 |
-
break;
|
1671 |
-
}
|
1672 |
-
}
|
1673 |
-
|
1674 |
-
$firstOnLine = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true);
|
1675 |
-
if ($firstOnLine !== false && $tokens[$firstOnLine]['code'] === T_USE) {
|
1676 |
-
$nextOnLine = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($firstOnLine + 1), null, true);
|
1677 |
-
if ($nextOnLine !== false) {
|
1678 |
-
if (($tokens[$nextOnLine]['code'] === T_STRING && $tokens[$nextOnLine]['content'] === 'const')
|
1679 |
-
|| $tokens[$nextOnLine]['code'] === T_CONST // Happens in some PHPCS versions.
|
1680 |
-
) {
|
1681 |
-
$hasNsSep = $phpcsFile->findNext(T_NS_SEPARATOR, ($nextOnLine + 1), $stackPtr);
|
1682 |
-
if ($hasNsSep !== false) {
|
1683 |
-
// Namespaced const (group) use statement.
|
1684 |
-
return false;
|
1685 |
-
}
|
1686 |
-
} else {
|
1687 |
-
// Not a const use statement.
|
1688 |
-
return false;
|
1689 |
-
}
|
1690 |
-
}
|
1691 |
-
}
|
1692 |
-
|
1693 |
-
return true;
|
1694 |
-
}
|
1695 |
-
|
1696 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingConstSniff.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ConstantArraysUsingConstSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.6
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ConstantArraysUsingConstSniff.
|
18 |
-
*
|
19 |
-
* Constant arrays using the constant keyword in PHP 5.6
|
20 |
-
*
|
21 |
-
* PHP version 5.6
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
-
*/
|
27 |
-
class ConstantArraysUsingConstSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Returns an array of tokens this test wants to listen for.
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function register()
|
36 |
-
{
|
37 |
-
return array(T_CONST);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes this test, when one of its tokens is encountered.
|
42 |
-
*
|
43 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
44 |
-
* @param int $stackPtr The position of the current token in the
|
45 |
-
* stack passed in $tokens.
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
50 |
-
{
|
51 |
-
if ($this->supportsBelow('5.5') !== true) {
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
$find = array(
|
56 |
-
T_ARRAY => T_ARRAY,
|
57 |
-
T_OPEN_SHORT_ARRAY => T_OPEN_SHORT_ARRAY,
|
58 |
-
T_CLOSE_SHORT_ARRAY => T_CLOSE_SHORT_ARRAY,
|
59 |
-
);
|
60 |
-
|
61 |
-
$hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true);
|
62 |
-
if ($hasArray !== false) {
|
63 |
-
$phpcsFile->addError(
|
64 |
-
'Constant arrays using the "const" keyword are not allowed in PHP 5.5 or earlier',
|
65 |
-
$hasArray,
|
66 |
-
'Found'
|
67 |
-
);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ConstantArraysUsingDefineSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ConstantArraysUsingDefineSniff.
|
18 |
-
*
|
19 |
-
* Constant arrays using define in PHP 7.0
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim@cu.be>
|
26 |
-
*/
|
27 |
-
class ConstantArraysUsingDefineSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Returns an array of tokens this test wants to listen for.
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function register()
|
36 |
-
{
|
37 |
-
return array(T_STRING);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes this test, when one of its tokens is encountered.
|
42 |
-
*
|
43 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
44 |
-
* @param int $stackPtr The position of the current token in the
|
45 |
-
* stack passed in $tokens.
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
50 |
-
{
|
51 |
-
if ($this->supportsBelow('5.6') !== true) {
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
$tokens = $phpcsFile->getTokens();
|
56 |
-
|
57 |
-
$ignore = array(
|
58 |
-
T_DOUBLE_COLON,
|
59 |
-
T_OBJECT_OPERATOR,
|
60 |
-
T_FUNCTION,
|
61 |
-
T_CONST,
|
62 |
-
);
|
63 |
-
|
64 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
65 |
-
if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
|
66 |
-
// Not a call to a PHP function.
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
|
70 |
-
$functionLc = strtolower($tokens[$stackPtr]['content']);
|
71 |
-
if ($functionLc !== 'define') {
|
72 |
-
return;
|
73 |
-
}
|
74 |
-
|
75 |
-
$secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2);
|
76 |
-
if (isset($secondParam['start'], $secondParam['end']) === false) {
|
77 |
-
return;
|
78 |
-
}
|
79 |
-
|
80 |
-
$targetNestingLevel = 0;
|
81 |
-
if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
|
82 |
-
$targetNestingLevel = count($tokens[$secondParam['start']]['nested_parenthesis']);
|
83 |
-
}
|
84 |
-
|
85 |
-
$array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
|
86 |
-
if ($array !== false) {
|
87 |
-
if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
|
88 |
-
$phpcsFile->addError(
|
89 |
-
'Constant arrays using define are not allowed in PHP 5.6 or earlier',
|
90 |
-
$array,
|
91 |
-
'Found'
|
92 |
-
);
|
93 |
-
}
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php
DELETED
@@ -1,904 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedFunctionsSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Wim Godden <wim.godden@cu.be>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
11 |
-
|
12 |
-
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedFunctionsSniff.
|
16 |
-
*
|
17 |
-
* @category PHP
|
18 |
-
* @package PHPCompatibility
|
19 |
-
* @author Wim Godden <wim.godden@cu.be>
|
20 |
-
*/
|
21 |
-
class DeprecatedFunctionsSniff extends AbstractRemovedFeatureSniff
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* A list of deprecated and removed functions with their alternatives.
|
25 |
-
*
|
26 |
-
* The array lists : version number with false (deprecated) or true (removed) and an alternative function.
|
27 |
-
* If no alternative exists, it is NULL, i.e, the function should just not be used.
|
28 |
-
*
|
29 |
-
* @var array(string => array(string => bool|string|null))
|
30 |
-
*/
|
31 |
-
protected $removedFunctions = array(
|
32 |
-
'php_check_syntax' => array(
|
33 |
-
'5.0.5' => true,
|
34 |
-
'alternative' => null,
|
35 |
-
),
|
36 |
-
'call_user_method' => array(
|
37 |
-
'5.3' => false,
|
38 |
-
'5.4' => false,
|
39 |
-
'5.5' => false,
|
40 |
-
'5.6' => false,
|
41 |
-
'7.0' => true,
|
42 |
-
'alternative' => 'call_user_func()',
|
43 |
-
),
|
44 |
-
'call_user_method_array' => array(
|
45 |
-
'5.3' => false,
|
46 |
-
'5.4' => false,
|
47 |
-
'5.5' => false,
|
48 |
-
'5.6' => false,
|
49 |
-
'7.0' => true,
|
50 |
-
'alternative' => 'call_user_func_array()',
|
51 |
-
),
|
52 |
-
'define_syslog_variables' => array(
|
53 |
-
'5.3' => false,
|
54 |
-
'5.4' => true,
|
55 |
-
'5.5' => true,
|
56 |
-
'5.6' => true,
|
57 |
-
'alternative' => null,
|
58 |
-
),
|
59 |
-
'dl' => array(
|
60 |
-
'5.3' => false,
|
61 |
-
'5.4' => false,
|
62 |
-
'5.5' => false,
|
63 |
-
'5.6' => false,
|
64 |
-
'alternative' => null,
|
65 |
-
),
|
66 |
-
'ereg' => array(
|
67 |
-
'5.3' => false,
|
68 |
-
'5.4' => false,
|
69 |
-
'5.5' => false,
|
70 |
-
'5.6' => false,
|
71 |
-
'7.0' => true,
|
72 |
-
'alternative' => 'preg_match()',
|
73 |
-
),
|
74 |
-
'ereg_replace' => array(
|
75 |
-
'5.3' => false,
|
76 |
-
'5.4' => false,
|
77 |
-
'5.5' => false,
|
78 |
-
'5.6' => false,
|
79 |
-
'7.0' => true,
|
80 |
-
'alternative' => 'preg_replace()',
|
81 |
-
),
|
82 |
-
'eregi' => array(
|
83 |
-
'5.3' => false,
|
84 |
-
'5.4' => false,
|
85 |
-
'5.5' => false,
|
86 |
-
'5.6' => false,
|
87 |
-
'7.0' => true,
|
88 |
-
'alternative' => 'preg_match()',
|
89 |
-
),
|
90 |
-
'eregi_replace' => array(
|
91 |
-
'5.3' => false,
|
92 |
-
'5.4' => false,
|
93 |
-
'5.5' => false,
|
94 |
-
'5.6' => false,
|
95 |
-
'7.0' => true,
|
96 |
-
'alternative' => 'preg_replace()',
|
97 |
-
),
|
98 |
-
'imagepsbbox' => array(
|
99 |
-
'7.0' => true,
|
100 |
-
'alternative' => null,
|
101 |
-
),
|
102 |
-
'imagepsencodefont' => array(
|
103 |
-
'7.0' => true,
|
104 |
-
'alternative' => null,
|
105 |
-
),
|
106 |
-
'imagepsextendfont' => array(
|
107 |
-
'7.0' => true,
|
108 |
-
'alternative' => null,
|
109 |
-
),
|
110 |
-
'imagepsfreefont' => array(
|
111 |
-
'7.0' => true,
|
112 |
-
'alternative' => null,
|
113 |
-
),
|
114 |
-
'imagepsloadfont' => array(
|
115 |
-
'7.0' => true,
|
116 |
-
'alternative' => null,
|
117 |
-
),
|
118 |
-
'imagepsslantfont' => array(
|
119 |
-
'7.0' => true,
|
120 |
-
'alternative' => null,
|
121 |
-
),
|
122 |
-
'imagepstext' => array(
|
123 |
-
'7.0' => true,
|
124 |
-
'alternative' => null,
|
125 |
-
),
|
126 |
-
'import_request_variables' => array(
|
127 |
-
'5.3' => false,
|
128 |
-
'5.4' => true,
|
129 |
-
'alternative' => null,
|
130 |
-
),
|
131 |
-
'ldap_sort' => array(
|
132 |
-
'7.0' => false,
|
133 |
-
'alternative' => null,
|
134 |
-
),
|
135 |
-
'mcrypt_generic_end' => array(
|
136 |
-
'5.3' => false,
|
137 |
-
'5.4' => false,
|
138 |
-
'5.5' => false,
|
139 |
-
'5.6' => false,
|
140 |
-
'7.0' => true,
|
141 |
-
'alternative' => 'mcrypt_generic_deinit()',
|
142 |
-
),
|
143 |
-
'mysql_db_query' => array(
|
144 |
-
'5.3' => false,
|
145 |
-
'5.4' => false,
|
146 |
-
'5.5' => false,
|
147 |
-
'5.6' => false,
|
148 |
-
'7.0' => true,
|
149 |
-
'alternative' => 'mysqli::select_db() and mysqli::query()',
|
150 |
-
),
|
151 |
-
'mysql_escape_string' => array(
|
152 |
-
'5.3' => false,
|
153 |
-
'5.4' => false,
|
154 |
-
'5.5' => false,
|
155 |
-
'5.6' => false,
|
156 |
-
'7.0' => true,
|
157 |
-
'alternative' => 'mysqli::real_escape_string()',
|
158 |
-
),
|
159 |
-
'mysql_list_dbs' => array(
|
160 |
-
'5.4' => false,
|
161 |
-
'5.5' => false,
|
162 |
-
'5.6' => false,
|
163 |
-
'7.0' => true,
|
164 |
-
'alternative' => null,
|
165 |
-
),
|
166 |
-
'mysqli_bind_param' => array(
|
167 |
-
'5.3' => false,
|
168 |
-
'5.4' => true,
|
169 |
-
'5.5' => true,
|
170 |
-
'5.6' => true,
|
171 |
-
'alternative' => 'mysqli_stmt::bind_param()',
|
172 |
-
),
|
173 |
-
'mysqli_bind_result' => array(
|
174 |
-
'5.3' => false,
|
175 |
-
'5.4' => true,
|
176 |
-
'5.5' => true,
|
177 |
-
'5.6' => true,
|
178 |
-
'alternative' => 'mysqli_stmt::bind_result()',
|
179 |
-
),
|
180 |
-
'mysqli_client_encoding' => array(
|
181 |
-
'5.3' => false,
|
182 |
-
'5.4' => true,
|
183 |
-
'5.5' => true,
|
184 |
-
'5.6' => true,
|
185 |
-
'alternative' => 'mysqli::character_set_name()',
|
186 |
-
),
|
187 |
-
'mysqli_fetch' => array(
|
188 |
-
'5.3' => false,
|
189 |
-
'5.4' => true,
|
190 |
-
'5.5' => true,
|
191 |
-
'5.6' => true,
|
192 |
-
'alternative' => 'mysqli_stmt::fetch()',
|
193 |
-
),
|
194 |
-
'mysqli_param_count' => array(
|
195 |
-
'5.3' => false,
|
196 |
-
'5.4' => true,
|
197 |
-
'5.5' => true,
|
198 |
-
'5.6' => true,
|
199 |
-
'alternative' => 'mysqli_stmt_param_count()',
|
200 |
-
),
|
201 |
-
'mysqli_get_metadata' => array(
|
202 |
-
'5.3' => false,
|
203 |
-
'5.4' => true,
|
204 |
-
'5.5' => true,
|
205 |
-
'5.6' => true,
|
206 |
-
'alternative' => 'mysqli_stmt::result_metadata()',
|
207 |
-
),
|
208 |
-
'mysqli_send_long_data' => array(
|
209 |
-
'5.3' => false,
|
210 |
-
'5.4' => true,
|
211 |
-
'5.5' => true,
|
212 |
-
'5.6' => true,
|
213 |
-
'alternative' => 'mysqli_stmt::send_long_data()',
|
214 |
-
),
|
215 |
-
'magic_quotes_runtime' => array(
|
216 |
-
'5.3' => false,
|
217 |
-
'5.4' => false,
|
218 |
-
'5.5' => false,
|
219 |
-
'5.6' => false,
|
220 |
-
'7.0' => true,
|
221 |
-
'alternative' => null,
|
222 |
-
),
|
223 |
-
'session_register' => array(
|
224 |
-
'5.3' => false,
|
225 |
-
'5.4' => true,
|
226 |
-
'5.5' => true,
|
227 |
-
'5.6' => true,
|
228 |
-
'alternative' => '$_SESSION',
|
229 |
-
),
|
230 |
-
'session_unregister' => array(
|
231 |
-
'5.3' => false,
|
232 |
-
'5.4' => true,
|
233 |
-
'5.5' => true,
|
234 |
-
'5.6' => true,
|
235 |
-
'alternative' => '$_SESSION',
|
236 |
-
),
|
237 |
-
'session_is_registered' => array(
|
238 |
-
'5.3' => false,
|
239 |
-
'5.4' => true,
|
240 |
-
'5.5' => true,
|
241 |
-
'5.6' => true,
|
242 |
-
'alternative' => '$_SESSION',
|
243 |
-
),
|
244 |
-
'set_magic_quotes_runtime' => array(
|
245 |
-
'5.3' => false,
|
246 |
-
'5.4' => false,
|
247 |
-
'5.5' => false,
|
248 |
-
'5.6' => false,
|
249 |
-
'7.0' => true,
|
250 |
-
'alternative' => null,
|
251 |
-
),
|
252 |
-
'set_socket_blocking' => array(
|
253 |
-
'5.3' => false,
|
254 |
-
'5.4' => false,
|
255 |
-
'5.5' => false,
|
256 |
-
'5.6' => false,
|
257 |
-
'7.0' => true,
|
258 |
-
'alternative' => 'stream_set_blocking()',
|
259 |
-
),
|
260 |
-
'split' => array(
|
261 |
-
'5.3' => false,
|
262 |
-
'5.4' => false,
|
263 |
-
'5.5' => false,
|
264 |
-
'5.6' => false,
|
265 |
-
'7.0' => true,
|
266 |
-
'alternative' => 'preg_split()',
|
267 |
-
),
|
268 |
-
'spliti' => array(
|
269 |
-
'5.3' => false,
|
270 |
-
'5.4' => false,
|
271 |
-
'5.5' => false,
|
272 |
-
'5.6' => false,
|
273 |
-
'7.0' => true,
|
274 |
-
'alternative' => 'preg_split()',
|
275 |
-
),
|
276 |
-
'sql_regcase' => array(
|
277 |
-
'5.3' => false,
|
278 |
-
'5.4' => false,
|
279 |
-
'5.5' => false,
|
280 |
-
'5.6' => false,
|
281 |
-
'7.0' => true,
|
282 |
-
'alternative' => null,
|
283 |
-
),
|
284 |
-
'php_logo_guid' => array(
|
285 |
-
'5.5' => true,
|
286 |
-
'5.6' => true,
|
287 |
-
'alternative' => null,
|
288 |
-
),
|
289 |
-
'php_egg_logo_guid' => array(
|
290 |
-
'5.5' => true,
|
291 |
-
'5.6' => true,
|
292 |
-
'alternative' => null,
|
293 |
-
),
|
294 |
-
'php_real_logo_guid' => array(
|
295 |
-
'5.5' => true,
|
296 |
-
'5.6' => true,
|
297 |
-
'alternative' => null,
|
298 |
-
),
|
299 |
-
'zend_logo_guid' => array(
|
300 |
-
'5.5' => true,
|
301 |
-
'5.6' => true,
|
302 |
-
'alternative' => null,
|
303 |
-
),
|
304 |
-
'datefmt_set_timezone_id' => array(
|
305 |
-
'5.5' => false,
|
306 |
-
'5.6' => false,
|
307 |
-
'7.0' => true,
|
308 |
-
'alternative' => 'IntlDateFormatter::setTimeZone()',
|
309 |
-
),
|
310 |
-
'mcrypt_ecb' => array(
|
311 |
-
'5.5' => false,
|
312 |
-
'5.6' => false,
|
313 |
-
'7.0' => true,
|
314 |
-
'alternative' => null,
|
315 |
-
),
|
316 |
-
'mcrypt_cbc' => array(
|
317 |
-
'5.5' => false,
|
318 |
-
'5.6' => false,
|
319 |
-
'7.0' => true,
|
320 |
-
'alternative' => null,
|
321 |
-
),
|
322 |
-
'mcrypt_cfb' => array(
|
323 |
-
'5.5' => false,
|
324 |
-
'5.6' => false,
|
325 |
-
'7.0' => true,
|
326 |
-
'alternative' => null,
|
327 |
-
),
|
328 |
-
'mcrypt_ofb' => array(
|
329 |
-
'5.5' => false,
|
330 |
-
'5.6' => false,
|
331 |
-
'7.0' => true,
|
332 |
-
'alternative' => null,
|
333 |
-
),
|
334 |
-
'ocibindbyname' => array(
|
335 |
-
'5.4' => false,
|
336 |
-
'5.5' => false,
|
337 |
-
'5.6' => false,
|
338 |
-
'alternative' => 'oci_bind_by_name()',
|
339 |
-
),
|
340 |
-
'ocicancel' => array(
|
341 |
-
'5.4' => false,
|
342 |
-
'5.5' => false,
|
343 |
-
'5.6' => false,
|
344 |
-
'alternative' => 'oci_cancel()',
|
345 |
-
),
|
346 |
-
'ocicloselob' => array(
|
347 |
-
'5.4' => false,
|
348 |
-
'5.5' => false,
|
349 |
-
'5.6' => false,
|
350 |
-
'alternative' => 'OCI-Lob::close()',
|
351 |
-
),
|
352 |
-
'ocicollappend' => array(
|
353 |
-
'5.4' => false,
|
354 |
-
'5.5' => false,
|
355 |
-
'5.6' => false,
|
356 |
-
'alternative' => 'OCI-Collection::append()',
|
357 |
-
),
|
358 |
-
'ocicollassign' => array(
|
359 |
-
'5.4' => false,
|
360 |
-
'5.5' => false,
|
361 |
-
'5.6' => false,
|
362 |
-
'alternative' => 'OCI-Collection::assign()',
|
363 |
-
),
|
364 |
-
'ocicollassignelem' => array(
|
365 |
-
'5.4' => false,
|
366 |
-
'5.5' => false,
|
367 |
-
'5.6' => false,
|
368 |
-
'alternative' => 'OCI-Collection::assignElem()',
|
369 |
-
),
|
370 |
-
'ocicollgetelem' => array(
|
371 |
-
'5.4' => false,
|
372 |
-
'5.5' => false,
|
373 |
-
'5.6' => false,
|
374 |
-
'alternative' => 'OCI-Collection::getElem()',
|
375 |
-
),
|
376 |
-
'ocicollmax' => array(
|
377 |
-
'5.4' => false,
|
378 |
-
'5.5' => false,
|
379 |
-
'5.6' => false,
|
380 |
-
'alternative' => 'OCI-Collection::max()',
|
381 |
-
),
|
382 |
-
'ocicollsize' => array(
|
383 |
-
'5.4' => false,
|
384 |
-
'5.5' => false,
|
385 |
-
'5.6' => false,
|
386 |
-
'alternative' => 'OCI-Collection::size()',
|
387 |
-
),
|
388 |
-
'ocicolltrim' => array(
|
389 |
-
'5.4' => false,
|
390 |
-
'5.5' => false,
|
391 |
-
'5.6' => false,
|
392 |
-
'alternative' => 'OCI-Collection::trim()',
|
393 |
-
),
|
394 |
-
'ocicolumnisnull' => array(
|
395 |
-
'5.4' => false,
|
396 |
-
'5.5' => false,
|
397 |
-
'5.6' => false,
|
398 |
-
'alternative' => 'oci_field_is_null()',
|
399 |
-
),
|
400 |
-
'ocicolumnname' => array(
|
401 |
-
'5.4' => false,
|
402 |
-
'5.5' => false,
|
403 |
-
'5.6' => false,
|
404 |
-
'alternative' => 'oci_field_name()',
|
405 |
-
),
|
406 |
-
'ocicolumnprecision' => array(
|
407 |
-
'5.4' => false,
|
408 |
-
'5.5' => false,
|
409 |
-
'5.6' => false,
|
410 |
-
'alternative' => 'oci_field_precision()',
|
411 |
-
),
|
412 |
-
'ocicolumnscale' => array(
|
413 |
-
'5.4' => false,
|
414 |
-
'5.5' => false,
|
415 |
-
'5.6' => false,
|
416 |
-
'alternative' => 'oci_field_scale()',
|
417 |
-
),
|
418 |
-
'ocicolumnsize' => array(
|
419 |
-
'5.4' => false,
|
420 |
-
'5.5' => false,
|
421 |
-
'5.6' => false,
|
422 |
-
'alternative' => 'oci_field_size()',
|
423 |
-
),
|
424 |
-
'ocicolumntype' => array(
|
425 |
-
'5.4' => false,
|
426 |
-
'5.5' => false,
|
427 |
-
'5.6' => false,
|
428 |
-
'alternative' => 'oci_field_type()',
|
429 |
-
),
|
430 |
-
'ocicolumntyperaw' => array(
|
431 |
-
'5.4' => false,
|
432 |
-
'5.5' => false,
|
433 |
-
'5.6' => false,
|
434 |
-
'alternative' => 'oci_field_type_raw()',
|
435 |
-
),
|
436 |
-
'ocicommit' => array(
|
437 |
-
'5.4' => false,
|
438 |
-
'5.5' => false,
|
439 |
-
'5.6' => false,
|
440 |
-
'alternative' => 'oci_commit()',
|
441 |
-
),
|
442 |
-
'ocidefinebyname' => array(
|
443 |
-
'5.4' => false,
|
444 |
-
'5.5' => false,
|
445 |
-
'5.6' => false,
|
446 |
-
'alternative' => 'oci_define_by_name()',
|
447 |
-
),
|
448 |
-
'ocierror' => array(
|
449 |
-
'5.4' => false,
|
450 |
-
'5.5' => false,
|
451 |
-
'5.6' => false,
|
452 |
-
'alternative' => 'oci_error()',
|
453 |
-
),
|
454 |
-
'ociexecute' => array(
|
455 |
-
'5.4' => false,
|
456 |
-
'5.5' => false,
|
457 |
-
'5.6' => false,
|
458 |
-
'alternative' => 'oci_execute()',
|
459 |
-
),
|
460 |
-
'ocifetch' => array(
|
461 |
-
'5.4' => false,
|
462 |
-
'5.5' => false,
|
463 |
-
'5.6' => false,
|
464 |
-
'alternative' => 'oci_fetch()',
|
465 |
-
),
|
466 |
-
'ocifetchinto' => array(
|
467 |
-
'5.4' => false,
|
468 |
-
'5.5' => false,
|
469 |
-
'5.6' => false,
|
470 |
-
'alternative' => null,
|
471 |
-
),
|
472 |
-
'ocifetchstatement' => array(
|
473 |
-
'5.4' => false,
|
474 |
-
'5.5' => false,
|
475 |
-
'5.6' => false,
|
476 |
-
'alternative' => 'oci_fetch_all()',
|
477 |
-
),
|
478 |
-
'ocifreecollection' => array(
|
479 |
-
'5.4' => false,
|
480 |
-
'5.5' => false,
|
481 |
-
'5.6' => false,
|
482 |
-
'alternative' => 'OCI-Collection::free()',
|
483 |
-
),
|
484 |
-
'ocifreecursor' => array(
|
485 |
-
'5.4' => false,
|
486 |
-
'5.5' => false,
|
487 |
-
'5.6' => false,
|
488 |
-
'alternative' => 'oci_free_statement()',
|
489 |
-
),
|
490 |
-
'ocifreedesc' => array(
|
491 |
-
'5.4' => false,
|
492 |
-
'5.5' => false,
|
493 |
-
'5.6' => false,
|
494 |
-
'alternative' => 'OCI-Lob::free()',
|
495 |
-
),
|
496 |
-
'ocifreestatement' => array(
|
497 |
-
'5.4' => false,
|
498 |
-
'5.5' => false,
|
499 |
-
'5.6' => false,
|
500 |
-
'alternative' => 'oci_free_statement()',
|
501 |
-
),
|
502 |
-
'ociinternaldebug' => array(
|
503 |
-
'5.4' => false,
|
504 |
-
'5.5' => false,
|
505 |
-
'5.6' => false,
|
506 |
-
'alternative' => 'oci_internal_debug()',
|
507 |
-
),
|
508 |
-
'ociloadlob' => array(
|
509 |
-
'5.4' => false,
|
510 |
-
'5.5' => false,
|
511 |
-
'5.6' => false,
|
512 |
-
'alternative' => 'OCI-Lob::load()',
|
513 |
-
),
|
514 |
-
'ocilogoff' => array(
|
515 |
-
'5.4' => false,
|
516 |
-
'5.5' => false,
|
517 |
-
'5.6' => false,
|
518 |
-
'alternative' => 'oci_close()',
|
519 |
-
),
|
520 |
-
'ocilogon' => array(
|
521 |
-
'5.4' => false,
|
522 |
-
'5.5' => false,
|
523 |
-
'5.6' => false,
|
524 |
-
'alternative' => 'oci_connect()',
|
525 |
-
),
|
526 |
-
'ocinewcollection' => array(
|
527 |
-
'5.4' => false,
|
528 |
-
'5.5' => false,
|
529 |
-
'5.6' => false,
|
530 |
-
'alternative' => 'oci_new_collection()',
|
531 |
-
),
|
532 |
-
'ocinewcursor' => array(
|
533 |
-
'5.4' => false,
|
534 |
-
'5.5' => false,
|
535 |
-
'5.6' => false,
|
536 |
-
'alternative' => 'oci_new_cursor()',
|
537 |
-
),
|
538 |
-
'ocinewdescriptor' => array(
|
539 |
-
'5.4' => false,
|
540 |
-
'5.5' => false,
|
541 |
-
'5.6' => false,
|
542 |
-
'alternative' => 'oci_new_descriptor()',
|
543 |
-
),
|
544 |
-
'ocinlogon' => array(
|
545 |
-
'5.4' => false,
|
546 |
-
'5.5' => false,
|
547 |
-
'5.6' => false,
|
548 |
-
'alternative' => 'oci_new_connect()',
|
549 |
-
),
|
550 |
-
'ocinumcols' => array(
|
551 |
-
'5.4' => false,
|
552 |
-
'5.5' => false,
|
553 |
-
'5.6' => false,
|
554 |
-
'alternative' => 'oci_num_fields()',
|
555 |
-
),
|
556 |
-
'ociparse' => array(
|
557 |
-
'5.4' => false,
|
558 |
-
'5.5' => false,
|
559 |
-
'5.6' => false,
|
560 |
-
'alternative' => 'oci_parse()',
|
561 |
-
),
|
562 |
-
'ociplogon' => array(
|
563 |
-
'5.4' => false,
|
564 |
-
'5.5' => false,
|
565 |
-
'5.6' => false,
|
566 |
-
'alternative' => 'oci_pconnect()',
|
567 |
-
),
|
568 |
-
'ociresult' => array(
|
569 |
-
'5.4' => false,
|
570 |
-
'5.5' => false,
|
571 |
-
'5.6' => false,
|
572 |
-
'alternative' => 'oci_result()',
|
573 |
-
),
|
574 |
-
'ocirollback' => array(
|
575 |
-
'5.4' => false,
|
576 |
-
'5.5' => false,
|
577 |
-
'5.6' => false,
|
578 |
-
'alternative' => 'oci_rollback()',
|
579 |
-
),
|
580 |
-
'ocirowcount' => array(
|
581 |
-
'5.4' => false,
|
582 |
-
'5.5' => false,
|
583 |
-
'5.6' => false,
|
584 |
-
'alternative' => 'oci_num_rows()',
|
585 |
-
),
|
586 |
-
'ocisavelob' => array(
|
587 |
-
'5.4' => false,
|
588 |
-
'5.5' => false,
|
589 |
-
'5.6' => false,
|
590 |
-
'alternative' => 'OCI-Lob::save()',
|
591 |
-
),
|
592 |
-
'ocisavelobfile' => array(
|
593 |
-
'5.4' => false,
|
594 |
-
'5.5' => false,
|
595 |
-
'5.6' => false,
|
596 |
-
'alternative' => 'OCI-Lob::import()',
|
597 |
-
),
|
598 |
-
'ociserverversion' => array(
|
599 |
-
'5.4' => false,
|
600 |
-
'5.5' => false,
|
601 |
-
'5.6' => false,
|
602 |
-
'alternative' => 'oci_server_version()',
|
603 |
-
),
|
604 |
-
'ocisetprefetch' => array(
|
605 |
-
'5.4' => false,
|
606 |
-
'5.5' => false,
|
607 |
-
'5.6' => false,
|
608 |
-
'alternative' => 'oci_set_prefetch()',
|
609 |
-
),
|
610 |
-
'ocistatementtype' => array(
|
611 |
-
'5.4' => false,
|
612 |
-
'5.5' => false,
|
613 |
-
'5.6' => false,
|
614 |
-
'alternative' => 'oci_statement_type()',
|
615 |
-
),
|
616 |
-
'ociwritelobtofile' => array(
|
617 |
-
'5.4' => false,
|
618 |
-
'5.5' => false,
|
619 |
-
'5.6' => false,
|
620 |
-
'alternative' => 'OCI-Lob::export()',
|
621 |
-
),
|
622 |
-
'ociwritetemporarylob' => array(
|
623 |
-
'5.4' => false,
|
624 |
-
'5.5' => false,
|
625 |
-
'5.6' => false,
|
626 |
-
'alternative' => 'OCI-Lob::writeTemporary()',
|
627 |
-
),
|
628 |
-
'mysqli_get_cache_stats' => array(
|
629 |
-
'5.4' => true,
|
630 |
-
'alternative' => null,
|
631 |
-
),
|
632 |
-
|
633 |
-
'mcrypt_create_iv' => array(
|
634 |
-
'7.1' => false,
|
635 |
-
'7.2' => true,
|
636 |
-
'alternative' => 'random_bytes() or OpenSSL',
|
637 |
-
),
|
638 |
-
'mcrypt_decrypt' => array(
|
639 |
-
'7.1' => false,
|
640 |
-
'7.2' => true,
|
641 |
-
'alternative' => 'OpenSSL',
|
642 |
-
),
|
643 |
-
'mcrypt_enc_get_algorithms_name' => array(
|
644 |
-
'7.1' => false,
|
645 |
-
'7.2' => true,
|
646 |
-
'alternative' => 'OpenSSL',
|
647 |
-
),
|
648 |
-
'mcrypt_enc_get_block_size' => array(
|
649 |
-
'7.1' => false,
|
650 |
-
'7.2' => true,
|
651 |
-
'alternative' => 'OpenSSL',
|
652 |
-
),
|
653 |
-
'mcrypt_enc_get_iv_size' => array(
|
654 |
-
'7.1' => false,
|
655 |
-
'7.2' => true,
|
656 |
-
'alternative' => 'OpenSSL',
|
657 |
-
),
|
658 |
-
'mcrypt_enc_get_key_size' => array(
|
659 |
-
'7.1' => false,
|
660 |
-
'7.2' => true,
|
661 |
-
'alternative' => 'OpenSSL',
|
662 |
-
),
|
663 |
-
'mcrypt_enc_get_modes_name' => array(
|
664 |
-
'7.1' => false,
|
665 |
-
'7.2' => true,
|
666 |
-
'alternative' => 'OpenSSL',
|
667 |
-
),
|
668 |
-
'mcrypt_enc_get_supported_key_sizes' => array(
|
669 |
-
'7.1' => false,
|
670 |
-
'7.2' => true,
|
671 |
-
'alternative' => 'OpenSSL',
|
672 |
-
),
|
673 |
-
'mcrypt_enc_is_block_algorithm_mode' => array(
|
674 |
-
'7.1' => false,
|
675 |
-
'7.2' => true,
|
676 |
-
'alternative' => 'OpenSSL',
|
677 |
-
),
|
678 |
-
'mcrypt_enc_is_block_algorithm' => array(
|
679 |
-
'7.1' => false,
|
680 |
-
'7.2' => true,
|
681 |
-
'alternative' => 'OpenSSL',
|
682 |
-
),
|
683 |
-
'mcrypt_enc_is_block_mode' => array(
|
684 |
-
'7.1' => false,
|
685 |
-
'7.2' => true,
|
686 |
-
'alternative' => 'OpenSSL',
|
687 |
-
),
|
688 |
-
'mcrypt_enc_self_test' => array(
|
689 |
-
'7.1' => false,
|
690 |
-
'7.2' => true,
|
691 |
-
'alternative' => 'OpenSSL',
|
692 |
-
),
|
693 |
-
'mcrypt_encrypt' => array(
|
694 |
-
'7.1' => false,
|
695 |
-
'7.2' => true,
|
696 |
-
'alternative' => 'OpenSSL',
|
697 |
-
),
|
698 |
-
'mcrypt_generic_deinit' => array(
|
699 |
-
'7.1' => false,
|
700 |
-
'7.2' => true,
|
701 |
-
'alternative' => 'OpenSSL',
|
702 |
-
),
|
703 |
-
'mcrypt_generic_init' => array(
|
704 |
-
'7.1' => false,
|
705 |
-
'7.2' => true,
|
706 |
-
'alternative' => 'OpenSSL',
|
707 |
-
),
|
708 |
-
'mcrypt_generic' => array(
|
709 |
-
'7.1' => false,
|
710 |
-
'7.2' => true,
|
711 |
-
'alternative' => 'OpenSSL',
|
712 |
-
),
|
713 |
-
'mcrypt_get_block_size' => array(
|
714 |
-
'7.1' => false,
|
715 |
-
'7.2' => true,
|
716 |
-
'alternative' => 'OpenSSL',
|
717 |
-
),
|
718 |
-
'mcrypt_get_cipher_name' => array(
|
719 |
-
'7.1' => false,
|
720 |
-
'7.2' => true,
|
721 |
-
'alternative' => 'OpenSSL',
|
722 |
-
),
|
723 |
-
'mcrypt_get_iv_size' => array(
|
724 |
-
'7.1' => false,
|
725 |
-
'7.2' => true,
|
726 |
-
'alternative' => 'OpenSSL',
|
727 |
-
),
|
728 |
-
'mcrypt_get_key_size' => array(
|
729 |
-
'7.1' => false,
|
730 |
-
'7.2' => true,
|
731 |
-
'alternative' => 'OpenSSL',
|
732 |
-
),
|
733 |
-
'mcrypt_list_algorithms' => array(
|
734 |
-
'7.1' => false,
|
735 |
-
'7.2' => true,
|
736 |
-
'alternative' => 'OpenSSL',
|
737 |
-
),
|
738 |
-
'mcrypt_list_modes' => array(
|
739 |
-
'7.1' => false,
|
740 |
-
'7.2' => true,
|
741 |
-
'alternative' => 'OpenSSL',
|
742 |
-
),
|
743 |
-
'mcrypt_module_close' => array(
|
744 |
-
'7.1' => false,
|
745 |
-
'7.2' => true,
|
746 |
-
'alternative' => 'OpenSSL',
|
747 |
-
),
|
748 |
-
'mcrypt_module_get_algo_block_size' => array(
|
749 |
-
'7.1' => false,
|
750 |
-
'7.2' => true,
|
751 |
-
'alternative' => 'OpenSSL',
|
752 |
-
),
|
753 |
-
'mcrypt_module_get_algo_key_size' => array(
|
754 |
-
'7.1' => false,
|
755 |
-
'7.2' => true,
|
756 |
-
'alternative' => 'OpenSSL',
|
757 |
-
),
|
758 |
-
'mcrypt_module_get_supported_key_sizes' => array(
|
759 |
-
'7.1' => false,
|
760 |
-
'7.2' => true,
|
761 |
-
'alternative' => 'OpenSSL',
|
762 |
-
),
|
763 |
-
'mcrypt_module_is_block_algorithm_mode' => array(
|
764 |
-
'7.1' => false,
|
765 |
-
'7.2' => true,
|
766 |
-
'alternative' => 'OpenSSL',
|
767 |
-
),
|
768 |
-
'mcrypt_module_is_block_algorithm' => array(
|
769 |
-
'7.1' => false,
|
770 |
-
'7.2' => true,
|
771 |
-
'alternative' => 'OpenSSL',
|
772 |
-
),
|
773 |
-
'mcrypt_module_is_block_mode' => array(
|
774 |
-
'7.1' => false,
|
775 |
-
'7.2' => true,
|
776 |
-
'alternative' => 'OpenSSL',
|
777 |
-
),
|
778 |
-
'mcrypt_module_open' => array(
|
779 |
-
'7.1' => false,
|
780 |
-
'7.2' => true,
|
781 |
-
'alternative' => 'OpenSSL',
|
782 |
-
),
|
783 |
-
'mcrypt_module_self_test' => array(
|
784 |
-
'7.1' => false,
|
785 |
-
'7.2' => true,
|
786 |
-
'alternative' => 'OpenSSL',
|
787 |
-
),
|
788 |
-
'mdecrypt_generic' => array(
|
789 |
-
'7.1' => false,
|
790 |
-
'7.2' => true,
|
791 |
-
'alternative' => 'OpenSSL',
|
792 |
-
),
|
793 |
-
'jpeg2wbmp' => array(
|
794 |
-
'7.2' => false,
|
795 |
-
'alternative' => 'imagecreatefromjpeg() and imagewbmp()',
|
796 |
-
),
|
797 |
-
'png2wbmp' => array(
|
798 |
-
'7.2' => false,
|
799 |
-
'alternative' => 'imagecreatefrompng() or imagewbmp()',
|
800 |
-
),
|
801 |
-
'create_function' => array(
|
802 |
-
'7.2' => false,
|
803 |
-
'alternative' => 'an anonymous function',
|
804 |
-
),
|
805 |
-
'each' => array(
|
806 |
-
'7.2' => false,
|
807 |
-
'alternative' => 'a foreach loop',
|
808 |
-
),
|
809 |
-
'gmp_random' => array(
|
810 |
-
'7.2' => false,
|
811 |
-
'alternative' => 'gmp_random_bits() or gmp_random_range()',
|
812 |
-
),
|
813 |
-
'read_exif_data' => array(
|
814 |
-
'7.2' => false,
|
815 |
-
'alternative' => 'exif_read_data()',
|
816 |
-
),
|
817 |
-
);
|
818 |
-
|
819 |
-
|
820 |
-
/**
|
821 |
-
* Returns an array of tokens this test wants to listen for.
|
822 |
-
*
|
823 |
-
* @return array
|
824 |
-
*/
|
825 |
-
public function register()
|
826 |
-
{
|
827 |
-
// Handle case-insensitivity of function names.
|
828 |
-
$this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions);
|
829 |
-
|
830 |
-
return array(T_STRING);
|
831 |
-
|
832 |
-
}//end register()
|
833 |
-
|
834 |
-
|
835 |
-
/**
|
836 |
-
* Processes this test, when one of its tokens is encountered.
|
837 |
-
*
|
838 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
839 |
-
* @param int $stackPtr The position of the current token in
|
840 |
-
* the stack passed in $tokens.
|
841 |
-
*
|
842 |
-
* @return void
|
843 |
-
*/
|
844 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
845 |
-
{
|
846 |
-
$tokens = $phpcsFile->getTokens();
|
847 |
-
|
848 |
-
$ignore = array(
|
849 |
-
T_DOUBLE_COLON,
|
850 |
-
T_OBJECT_OPERATOR,
|
851 |
-
T_FUNCTION,
|
852 |
-
T_CLASS,
|
853 |
-
T_CONST,
|
854 |
-
T_USE,
|
855 |
-
T_NS_SEPARATOR,
|
856 |
-
);
|
857 |
-
|
858 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
859 |
-
if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
|
860 |
-
// Not a call to a PHP function.
|
861 |
-
return;
|
862 |
-
}
|
863 |
-
|
864 |
-
$function = $tokens[$stackPtr]['content'];
|
865 |
-
$functionLc = strtolower($function);
|
866 |
-
|
867 |
-
if (isset($this->removedFunctions[$functionLc]) === false) {
|
868 |
-
return;
|
869 |
-
}
|
870 |
-
|
871 |
-
$itemInfo = array(
|
872 |
-
'name' => $function,
|
873 |
-
'nameLc' => $functionLc,
|
874 |
-
);
|
875 |
-
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
876 |
-
|
877 |
-
}//end process()
|
878 |
-
|
879 |
-
|
880 |
-
/**
|
881 |
-
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
882 |
-
*
|
883 |
-
* @param array $itemInfo Base information about the item.
|
884 |
-
*
|
885 |
-
* @return array Version and other information about the item.
|
886 |
-
*/
|
887 |
-
public function getItemArray(array $itemInfo)
|
888 |
-
{
|
889 |
-
return $this->removedFunctions[$itemInfo['nameLc']];
|
890 |
-
}
|
891 |
-
|
892 |
-
|
893 |
-
/**
|
894 |
-
* Get the error message template for this sniff.
|
895 |
-
*
|
896 |
-
* @return string
|
897 |
-
*/
|
898 |
-
protected function getErrorMsgTemplate()
|
899 |
-
{
|
900 |
-
return 'Function %s() is ';
|
901 |
-
}
|
902 |
-
|
903 |
-
|
904 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php
DELETED
@@ -1,338 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedIniDirectivesSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Wim Godden <wim.godden@cu.be>
|
8 |
-
* @copyright 2012 Cu.be Solutions bvba
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
12 |
-
|
13 |
-
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedIniDirectivesSniff.
|
17 |
-
*
|
18 |
-
* Discourages the use of deprecated INI directives through ini_set() or ini_get().
|
19 |
-
*
|
20 |
-
* @category PHP
|
21 |
-
* @package PHPCompatibility
|
22 |
-
* @author Wim Godden <wim.godden@cu.be>
|
23 |
-
* @copyright 2012 Cu.be Solutions bvba
|
24 |
-
*/
|
25 |
-
class DeprecatedIniDirectivesSniff extends AbstractRemovedFeatureSniff
|
26 |
-
{
|
27 |
-
/**
|
28 |
-
* A list of deprecated INI directives.
|
29 |
-
*
|
30 |
-
* The array lists : version number with false (deprecated) and true (removed).
|
31 |
-
* If's sufficient to list the first version where the ini directive was deprecated/removed.
|
32 |
-
*
|
33 |
-
* @var array(string)
|
34 |
-
*/
|
35 |
-
protected $deprecatedIniDirectives = array(
|
36 |
-
'fbsql.batchSize' => array(
|
37 |
-
'5.1' => true,
|
38 |
-
'alternative' => 'fbsql.batchsize',
|
39 |
-
),
|
40 |
-
|
41 |
-
'ifx.allow_persistent' => array(
|
42 |
-
'5.2.1' => true,
|
43 |
-
),
|
44 |
-
'ifx.blobinfile' => array(
|
45 |
-
'5.2.1' => true,
|
46 |
-
),
|
47 |
-
'ifx.byteasvarchar' => array(
|
48 |
-
'5.2.1' => true,
|
49 |
-
),
|
50 |
-
'ifx.charasvarchar' => array(
|
51 |
-
'5.2.1' => true,
|
52 |
-
),
|
53 |
-
'ifx.default_host' => array(
|
54 |
-
'5.2.1' => true,
|
55 |
-
),
|
56 |
-
'ifx.default_password' => array(
|
57 |
-
'5.2.1' => true,
|
58 |
-
),
|
59 |
-
'ifx.default_user' => array(
|
60 |
-
'5.2.1' => true,
|
61 |
-
),
|
62 |
-
'ifx.max_links' => array(
|
63 |
-
'5.2.1' => true,
|
64 |
-
),
|
65 |
-
'ifx.max_persistent' => array(
|
66 |
-
'5.2.1' => true,
|
67 |
-
),
|
68 |
-
'ifx.nullformat' => array(
|
69 |
-
'5.2.1' => true,
|
70 |
-
),
|
71 |
-
'ifx.textasvarchar' => array(
|
72 |
-
'5.2.1' => true,
|
73 |
-
),
|
74 |
-
|
75 |
-
'zend.ze1_compatibility_mode' => array(
|
76 |
-
'5.3' => true,
|
77 |
-
),
|
78 |
-
|
79 |
-
'allow_call_time_pass_reference' => array(
|
80 |
-
'5.3' => false,
|
81 |
-
'5.4' => true,
|
82 |
-
),
|
83 |
-
'define_syslog_variables' => array(
|
84 |
-
'5.3' => false,
|
85 |
-
'5.4' => true,
|
86 |
-
),
|
87 |
-
'detect_unicode' => array(
|
88 |
-
'5.4' => true,
|
89 |
-
'alternative' => 'zend.detect_unicode',
|
90 |
-
),
|
91 |
-
'highlight.bg' => array(
|
92 |
-
'5.3' => false,
|
93 |
-
'5.4' => true,
|
94 |
-
),
|
95 |
-
'magic_quotes_gpc' => array(
|
96 |
-
'5.3' => false,
|
97 |
-
'5.4' => true,
|
98 |
-
),
|
99 |
-
'magic_quotes_runtime' => array(
|
100 |
-
'5.3' => false,
|
101 |
-
'5.4' => true,
|
102 |
-
),
|
103 |
-
'magic_quotes_sybase' => array(
|
104 |
-
'5.3' => false,
|
105 |
-
'5.4' => true,
|
106 |
-
),
|
107 |
-
'mbstring.script_encoding' => array(
|
108 |
-
'5.4' => true,
|
109 |
-
'alternative' => 'zend.script_encoding',
|
110 |
-
),
|
111 |
-
'register_globals' => array(
|
112 |
-
'5.3' => false,
|
113 |
-
'5.4' => true,
|
114 |
-
),
|
115 |
-
'register_long_arrays' => array(
|
116 |
-
'5.3' => false,
|
117 |
-
'5.4' => true,
|
118 |
-
),
|
119 |
-
'safe_mode' => array(
|
120 |
-
'5.3' => false,
|
121 |
-
'5.4' => true,
|
122 |
-
),
|
123 |
-
'safe_mode_allowed_env_vars' => array(
|
124 |
-
'5.3' => false,
|
125 |
-
'5.4' => true,
|
126 |
-
),
|
127 |
-
'safe_mode_exec_dir' => array(
|
128 |
-
'5.3' => false,
|
129 |
-
'5.4' => true,
|
130 |
-
),
|
131 |
-
'safe_mode_gid' => array(
|
132 |
-
'5.3' => false,
|
133 |
-
'5.4' => true,
|
134 |
-
),
|
135 |
-
'safe_mode_include_dir' => array(
|
136 |
-
'5.3' => false,
|
137 |
-
'5.4' => true,
|
138 |
-
),
|
139 |
-
'safe_mode_protected_env_vars' => array(
|
140 |
-
'5.3' => false,
|
141 |
-
'5.4' => true,
|
142 |
-
),
|
143 |
-
'session.bug_compat_42' => array(
|
144 |
-
'5.3' => false,
|
145 |
-
'5.4' => true,
|
146 |
-
),
|
147 |
-
'session.bug_compat_warn' => array(
|
148 |
-
'5.3' => false,
|
149 |
-
'5.4' => true,
|
150 |
-
),
|
151 |
-
'y2k_compliance' => array(
|
152 |
-
'5.3' => false,
|
153 |
-
'5.4' => true,
|
154 |
-
),
|
155 |
-
|
156 |
-
'always_populate_raw_post_data' => array(
|
157 |
-
'5.6' => false,
|
158 |
-
'7.0' => true,
|
159 |
-
),
|
160 |
-
'iconv.input_encoding' => array(
|
161 |
-
'5.6' => false,
|
162 |
-
),
|
163 |
-
'iconv.output_encoding' => array(
|
164 |
-
'5.6' => false,
|
165 |
-
),
|
166 |
-
'iconv.internal_encoding' => array(
|
167 |
-
'5.6' => false,
|
168 |
-
),
|
169 |
-
'mbstring.http_input' => array(
|
170 |
-
'5.6' => false,
|
171 |
-
),
|
172 |
-
'mbstring.http_output' => array(
|
173 |
-
'5.6' => false,
|
174 |
-
),
|
175 |
-
'mbstring.internal_encoding' => array(
|
176 |
-
'5.6' => false,
|
177 |
-
),
|
178 |
-
|
179 |
-
'asp_tags' => array(
|
180 |
-
'7.0' => true,
|
181 |
-
),
|
182 |
-
'xsl.security_prefs' => array(
|
183 |
-
'7.0' => true,
|
184 |
-
),
|
185 |
-
|
186 |
-
'mcrypt.algorithms_dir' => array(
|
187 |
-
'7.1' => false,
|
188 |
-
'7.2' => true,
|
189 |
-
),
|
190 |
-
'mcrypt.modes_dir' => array(
|
191 |
-
'7.1' => false,
|
192 |
-
'7.2' => true,
|
193 |
-
),
|
194 |
-
'session.entropy_file' => array(
|
195 |
-
'7.1' => true,
|
196 |
-
),
|
197 |
-
'session.entropy_length' => array(
|
198 |
-
'7.1' => true,
|
199 |
-
),
|
200 |
-
'session.hash_function' => array(
|
201 |
-
'7.1' => true,
|
202 |
-
),
|
203 |
-
'session.hash_bits_per_character' => array(
|
204 |
-
'7.1' => true,
|
205 |
-
),
|
206 |
-
|
207 |
-
'mbstring.func_overload' => array(
|
208 |
-
'7.2' => false,
|
209 |
-
),
|
210 |
-
'sql.safe_mode' => array(
|
211 |
-
'7.2' => true,
|
212 |
-
),
|
213 |
-
'track_errors' => array(
|
214 |
-
'7.2' => false,
|
215 |
-
),
|
216 |
-
'opcache.fast_shutdown' => array(
|
217 |
-
'7.2' => true,
|
218 |
-
),
|
219 |
-
);
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Returns an array of tokens this test wants to listen for.
|
223 |
-
*
|
224 |
-
* @return array
|
225 |
-
*/
|
226 |
-
public function register()
|
227 |
-
{
|
228 |
-
return array(T_STRING);
|
229 |
-
|
230 |
-
}//end register()
|
231 |
-
|
232 |
-
/**
|
233 |
-
* Processes this test, when one of its tokens is encountered.
|
234 |
-
*
|
235 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
236 |
-
* @param int $stackPtr The position of the current token in the
|
237 |
-
* stack passed in $tokens.
|
238 |
-
*
|
239 |
-
* @return void
|
240 |
-
*/
|
241 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
242 |
-
{
|
243 |
-
$tokens = $phpcsFile->getTokens();
|
244 |
-
|
245 |
-
$ignore = array(
|
246 |
-
T_DOUBLE_COLON,
|
247 |
-
T_OBJECT_OPERATOR,
|
248 |
-
T_FUNCTION,
|
249 |
-
T_CONST,
|
250 |
-
);
|
251 |
-
|
252 |
-
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
|
253 |
-
if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
|
254 |
-
// Not a call to a PHP function.
|
255 |
-
return;
|
256 |
-
}
|
257 |
-
|
258 |
-
$functionLc = strtolower($tokens[$stackPtr]['content']);
|
259 |
-
if (isset($this->iniFunctions[$functionLc]) === false) {
|
260 |
-
return;
|
261 |
-
}
|
262 |
-
|
263 |
-
$iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
|
264 |
-
if ($iniToken === false) {
|
265 |
-
return;
|
266 |
-
}
|
267 |
-
|
268 |
-
$filteredToken = $this->stripQuotes($iniToken['raw']);
|
269 |
-
if (isset($this->deprecatedIniDirectives[$filteredToken]) === false) {
|
270 |
-
return;
|
271 |
-
}
|
272 |
-
|
273 |
-
$itemInfo = array(
|
274 |
-
'name' => $filteredToken,
|
275 |
-
'functionLc' => $functionLc,
|
276 |
-
);
|
277 |
-
$this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
|
278 |
-
|
279 |
-
}//end process()
|
280 |
-
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
284 |
-
*
|
285 |
-
* @param array $itemInfo Base information about the item.
|
286 |
-
*
|
287 |
-
* @return array Version and other information about the item.
|
288 |
-
*/
|
289 |
-
public function getItemArray(array $itemInfo)
|
290 |
-
{
|
291 |
-
return $this->deprecatedIniDirectives[$itemInfo['name']];
|
292 |
-
}
|
293 |
-
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Retrieve the relevant detail (version) information for use in an error message.
|
297 |
-
*
|
298 |
-
* @param array $itemArray Version and other information about the item.
|
299 |
-
* @param array $itemInfo Base information about the item.
|
300 |
-
*
|
301 |
-
* @return array
|
302 |
-
*/
|
303 |
-
public function getErrorInfo(array $itemArray, array $itemInfo)
|
304 |
-
{
|
305 |
-
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
|
306 |
-
|
307 |
-
// Lower error level to warning if the function used was ini_get.
|
308 |
-
if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
|
309 |
-
$errorInfo['error'] = false;
|
310 |
-
}
|
311 |
-
|
312 |
-
return $errorInfo;
|
313 |
-
}
|
314 |
-
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Get the error message template for this sniff.
|
318 |
-
*
|
319 |
-
* @return string
|
320 |
-
*/
|
321 |
-
protected function getErrorMsgTemplate()
|
322 |
-
{
|
323 |
-
return "INI directive '%s' is ";
|
324 |
-
}
|
325 |
-
|
326 |
-
|
327 |
-
/**
|
328 |
-
* Get the error message template for suggesting an alternative for a specific sniff.
|
329 |
-
*
|
330 |
-
* @return string
|
331 |
-
*/
|
332 |
-
protected function getAlternativeOptionTemplate()
|
333 |
-
{
|
334 |
-
return str_replace("%s", "'%s'", parent::getAlternativeOptionTemplate());
|
335 |
-
}
|
336 |
-
|
337 |
-
|
338 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedMagicAutoloadSniff.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedMagicAutoloadSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.2
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim.godden@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedMagicAutoloadSniff.
|
18 |
-
*
|
19 |
-
* @category PHP
|
20 |
-
* @package PHPCompatibility
|
21 |
-
* @author Wim Godden <wim.godden@cu.be>
|
22 |
-
*/
|
23 |
-
class DeprecatedMagicAutoloadSniff extends Sniff
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Scopes to look for when testing using validDirectScope
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
private $checkForScopes = array(
|
31 |
-
'T_CLASS' => true,
|
32 |
-
'T_ANON_CLASS' => true,
|
33 |
-
'T_INTERFACE' => true,
|
34 |
-
'T_TRAIT' => true,
|
35 |
-
'T_NAMESPACE' => true,
|
36 |
-
);
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Returns an array of tokens this test wants to listen for.
|
40 |
-
*
|
41 |
-
* @return array
|
42 |
-
*/
|
43 |
-
public function register()
|
44 |
-
{
|
45 |
-
return array(T_FUNCTION);
|
46 |
-
}//end register()
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Processes this test, when one of its tokens is encountered.
|
50 |
-
*
|
51 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
52 |
-
* @param int $stackPtr The position of the current token in the
|
53 |
-
* stack passed in $tokens.
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
58 |
-
{
|
59 |
-
if ($this->supportsAbove('7.2') === false) {
|
60 |
-
return;
|
61 |
-
}
|
62 |
-
|
63 |
-
$funcName = $phpcsFile->getDeclarationName($stackPtr);
|
64 |
-
|
65 |
-
if (strtolower($funcName) !== '__autoload') {
|
66 |
-
return;
|
67 |
-
}
|
68 |
-
|
69 |
-
if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) === true) {
|
70 |
-
return;
|
71 |
-
}
|
72 |
-
|
73 |
-
if ($this->determineNamespace($phpcsFile, $stackPtr) != '') {
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
|
77 |
-
$phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
|
78 |
-
}//end process()
|
79 |
-
|
80 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedNewReferenceSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.4
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim.godden@cu.be>
|
10 |
-
* @copyright 2012 Cu.be Solutions bvba
|
11 |
-
*/
|
12 |
-
|
13 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
14 |
-
|
15 |
-
use PHPCompatibility\Sniff;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedNewReferenceSniff.
|
19 |
-
*
|
20 |
-
* Discourages the use of assigning the return value of new by reference
|
21 |
-
*
|
22 |
-
* PHP version 5.4
|
23 |
-
*
|
24 |
-
* @category PHP
|
25 |
-
* @package PHPCompatibility
|
26 |
-
* @author Wim Godden <wim.godden@cu.be>
|
27 |
-
* @copyright 2012 Cu.be Solutions bvba
|
28 |
-
*/
|
29 |
-
class DeprecatedNewReferenceSniff extends Sniff
|
30 |
-
{
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Returns an array of tokens this test wants to listen for.
|
34 |
-
*
|
35 |
-
* @return array
|
36 |
-
*/
|
37 |
-
public function register()
|
38 |
-
{
|
39 |
-
return array(T_NEW);
|
40 |
-
|
41 |
-
}//end register()
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Processes this test, when one of its tokens is encountered.
|
45 |
-
*
|
46 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
47 |
-
* @param int $stackPtr The position of the current token in the
|
48 |
-
* stack passed in $tokens.
|
49 |
-
*
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
53 |
-
{
|
54 |
-
if ($this->supportsAbove('5.3') === false) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
|
58 |
-
$tokens = $phpcsFile->getTokens();
|
59 |
-
$prevNonEmpty = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
60 |
-
if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['type'] !== 'T_BITWISE_AND') {
|
61 |
-
return;
|
62 |
-
}
|
63 |
-
|
64 |
-
$error = 'Assigning the return value of new by reference is deprecated in PHP 5.3';
|
65 |
-
$isError = false;
|
66 |
-
$errorCode = 'Deprecated';
|
67 |
-
|
68 |
-
if ($this->supportsAbove('7.0') === true) {
|
69 |
-
$error .= ' and forbidden in PHP 7.0';
|
70 |
-
$isError = true;
|
71 |
-
$errorCode = 'Forbidden';
|
72 |
-
}
|
73 |
-
|
74 |
-
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode);
|
75 |
-
|
76 |
-
}//end process()
|
77 |
-
|
78 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DeprecatedTypeCastsSniff.php
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedTypeCastsSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
11 |
-
|
12 |
-
use PHPCompatibility\AbstractRemovedFeatureSniff;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* \PHPCompatibility\Sniffs\PHP\DeprecatedTypeCastsSniff.
|
16 |
-
*
|
17 |
-
* @category PHP
|
18 |
-
* @package PHPCompatibility
|
19 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
-
*/
|
21 |
-
class DeprecatedTypeCastsSniff extends AbstractRemovedFeatureSniff
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* A list of deprecated and removed type casts with their alternatives.
|
25 |
-
*
|
26 |
-
* The array lists : version number with false (deprecated) or true (removed) and an alternative function.
|
27 |
-
* If no alternative exists, it is NULL, i.e, the function should just not be used.
|
28 |
-
*
|
29 |
-
* @var array(string => array(string => bool|string|null))
|
30 |
-
*/
|
31 |
-
protected $deprecatedTypeCasts = array(
|
32 |
-
'T_UNSET_CAST' => array(
|
33 |
-
'7.2' => false,
|
34 |
-
'alternative' => 'unset()',
|
35 |
-
'description' => 'unset',
|
36 |
-
),
|
37 |
-
);
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Returns an array of tokens this test wants to listen for.
|
42 |
-
*
|
43 |
-
* @return array
|
44 |
-
*/
|
45 |
-
public function register()
|
46 |
-
{
|
47 |
-
$tokens = array();
|
48 |
-
foreach ($this->deprecatedTypeCasts as $token => $versions) {
|
49 |
-
$tokens[] = constant($token);
|
50 |
-
}
|
51 |
-
|
52 |
-
return $tokens;
|
53 |
-
|
54 |
-
}//end register()
|
55 |
-
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Processes this test, when one of its tokens is encountered.
|
59 |
-
*
|
60 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
61 |
-
* @param int $stackPtr The position of the current token in
|
62 |
-
* the stack passed in $tokens.
|
63 |
-
*
|
64 |
-
* @return void
|
65 |
-
*/
|
66 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
67 |
-
{
|
68 |
-
$tokens = $phpcsFile->getTokens();
|
69 |
-
$tokenType = $tokens[$stackPtr]['type'];
|
70 |
-
|
71 |
-
if (isset($this->deprecatedTypeCasts[$tokenType]) === false) {
|
72 |
-
return;
|
73 |
-
}
|
74 |
-
|
75 |
-
$itemInfo = array(
|
76 |
-
'name' => $tokenType,
|
77 |
-
'description' => $this->deprecatedTypeCasts[$tokenType]['description'],
|
78 |
-
);
|
79 |
-
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
80 |
-
|
81 |
-
}//end process()
|
82 |
-
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Get an array of the non-PHP-version array keys used in a sub-array.
|
86 |
-
*
|
87 |
-
* @return array
|
88 |
-
*/
|
89 |
-
protected function getNonVersionArrayKeys()
|
90 |
-
{
|
91 |
-
return array('description', 'alternative');
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
96 |
-
*
|
97 |
-
* @param array $itemInfo Base information about the item.
|
98 |
-
*
|
99 |
-
* @return array Version and other information about the item.
|
100 |
-
*/
|
101 |
-
public function getItemArray(array $itemInfo)
|
102 |
-
{
|
103 |
-
return $this->deprecatedTypeCasts[$itemInfo['name']];
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Get the error message template for this sniff.
|
109 |
-
*
|
110 |
-
* @return string
|
111 |
-
*/
|
112 |
-
protected function getErrorMsgTemplate()
|
113 |
-
{
|
114 |
-
return 'The %s cast is ';
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Filter the error data before it's passed to PHPCS.
|
120 |
-
*
|
121 |
-
* @param array $data The error data array which was created.
|
122 |
-
* @param array $itemInfo Base information about the item this error message applied to.
|
123 |
-
* @param array $errorInfo Detail information about an item this error message applied to.
|
124 |
-
*
|
125 |
-
* @return array
|
126 |
-
*/
|
127 |
-
protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
|
128 |
-
{
|
129 |
-
$data[0] = $itemInfo['description'];
|
130 |
-
return $data;
|
131 |
-
}
|
132 |
-
|
133 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/DynamicAccessToStaticSniff.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\DynamicAccessToStaticSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.3
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
use PHP_CodeSniffer_Tokens as Tokens;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* \PHPCompatibility\Sniffs\PHP\DynamicAccessToStaticSniff.
|
19 |
-
*
|
20 |
-
* As of PHP 5.3, static properties and methods as well as class constants
|
21 |
-
* can be accessed using a dynamic (variable) class name.
|
22 |
-
*
|
23 |
-
* PHP version 5.3
|
24 |
-
*
|
25 |
-
* @category PHP
|
26 |
-
* @package PHPCompatibility
|
27 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
28 |
-
*/
|
29 |
-
class DynamicAccessToStaticSniff extends Sniff
|
30 |
-
{
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Returns an array of tokens this test wants to listen for.
|
34 |
-
*
|
35 |
-
* @return array
|
36 |
-
*/
|
37 |
-
public function register()
|
38 |
-
{
|
39 |
-
return array(
|
40 |
-
T_DOUBLE_COLON,
|
41 |
-
);
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Processes this test, when one of its tokens is encountered.
|
46 |
-
*
|
47 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
48 |
-
* @param int $stackPtr The position of the current token in the
|
49 |
-
* stack passed in $tokens.
|
50 |
-
*
|
51 |
-
* @return void
|
52 |
-
*/
|
53 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
54 |
-
{
|
55 |
-
if ($this->supportsBelow('5.2') === false) {
|
56 |
-
return;
|
57 |
-
}
|
58 |
-
|
59 |
-
$tokens = $phpcsFile->getTokens();
|
60 |
-
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
61 |
-
|
62 |
-
// Disregard `static::` as well. Late static binding is reported by another sniff.
|
63 |
-
if ($tokens[$prevNonEmpty]['code'] === T_SELF
|
64 |
-
|| $tokens[$prevNonEmpty]['code'] === T_PARENT
|
65 |
-
|| $tokens[$prevNonEmpty]['code'] === T_STATIC
|
66 |
-
) {
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
|
70 |
-
if ($tokens[$prevNonEmpty]['code'] === T_STRING) {
|
71 |
-
$prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
|
72 |
-
|
73 |
-
if ($tokens[$prevPrevNonEmpty]['code'] !== T_OBJECT_OPERATOR) {
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
$phpcsFile->addError(
|
79 |
-
'Static class properties and methods, as well as class constants, could not be accessed using a dynamic (variable) classname in PHP 5.2 or earlier.',
|
80 |
-
$stackPtr,
|
81 |
-
'Found'
|
82 |
-
);
|
83 |
-
}
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\EmptyNonVariableSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.5
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\EmptyNonVariableSniff.
|
18 |
-
*
|
19 |
-
* Verify that nothing but variables are passed to empty().
|
20 |
-
*
|
21 |
-
* PHP version 5.5
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
-
*/
|
27 |
-
class EmptyNonVariableSniff extends Sniff
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* List of tokens to check against.
|
31 |
-
*
|
32 |
-
* @var array
|
33 |
-
*/
|
34 |
-
protected $tokenBlackList = array();
|
35 |
-
|
36 |
-
/**
|
37 |
-
* List of brackets which can be part of a variable variable.
|
38 |
-
*
|
39 |
-
* Key is the open bracket token, value the close bracket token.
|
40 |
-
*
|
41 |
-
* @var array
|
42 |
-
*/
|
43 |
-
protected $bracketTokens = array(
|
44 |
-
T_OPEN_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
|
45 |
-
T_OPEN_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET,
|
46 |
-
);
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Returns an array of tokens this test wants to listen for.
|
51 |
-
*
|
52 |
-
* @return array
|
53 |
-
*/
|
54 |
-
public function register()
|
55 |
-
{
|
56 |
-
// Set the token blacklist only once.
|
57 |
-
$tokenBlackList = array_unique(array_merge(
|
58 |
-
\PHP_CodeSniffer_Tokens::$assignmentTokens,
|
59 |
-
\PHP_CodeSniffer_Tokens::$equalityTokens,
|
60 |
-
\PHP_CodeSniffer_Tokens::$comparisonTokens,
|
61 |
-
\PHP_CodeSniffer_Tokens::$operators,
|
62 |
-
\PHP_CodeSniffer_Tokens::$booleanOperators,
|
63 |
-
\PHP_CodeSniffer_Tokens::$castTokens,
|
64 |
-
array(T_OPEN_PARENTHESIS, T_STRING_CONCAT)
|
65 |
-
));
|
66 |
-
$this->tokenBlackList = array_combine($tokenBlackList, $tokenBlackList);
|
67 |
-
|
68 |
-
return array(T_EMPTY);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Processes this test, when one of its tokens is encountered.
|
73 |
-
*
|
74 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
75 |
-
* @param int $stackPtr The position of the current token in the
|
76 |
-
* stack passed in $tokens.
|
77 |
-
*
|
78 |
-
* @return void
|
79 |
-
*/
|
80 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
81 |
-
{
|
82 |
-
if ($this->supportsBelow('5.4') === false) {
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
|
86 |
-
$tokens = $phpcsFile->getTokens();
|
87 |
-
|
88 |
-
$open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
|
89 |
-
if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
|
90 |
-
return;
|
91 |
-
}
|
92 |
-
|
93 |
-
$close = $tokens[$open]['parenthesis_closer'];
|
94 |
-
|
95 |
-
// If no variable at all was found, then it's definitely a no-no.
|
96 |
-
$hasVariable = $phpcsFile->findNext(T_VARIABLE, $open + 1, $close);
|
97 |
-
if ($hasVariable === false) {
|
98 |
-
$this->addError($phpcsFile, $stackPtr);
|
99 |
-
return;
|
100 |
-
}
|
101 |
-
|
102 |
-
// Check if the variable found is at the right level. Deeper levels are always an error.
|
103 |
-
if (isset($tokens[$open + 1]['nested_parenthesis'], $tokens[$hasVariable]['nested_parenthesis'])) {
|
104 |
-
$nestingLevel = count($tokens[$open + 1]['nested_parenthesis']);
|
105 |
-
if (count($tokens[$hasVariable]['nested_parenthesis']) !== $nestingLevel) {
|
106 |
-
$this->addError($phpcsFile, $stackPtr);
|
107 |
-
return;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
// Ok, so the first variable is at the right level, now are there any
|
112 |
-
// blacklisted tokens within the empty() ?
|
113 |
-
$hasBadToken = $phpcsFile->findNext($this->tokenBlackList, $open + 1, $close);
|
114 |
-
if ($hasBadToken === false) {
|
115 |
-
return;
|
116 |
-
}
|
117 |
-
|
118 |
-
// If there are also bracket tokens, the blacklisted token might be part of a variable
|
119 |
-
// variable, but if there are no bracket tokens, we know we have an error.
|
120 |
-
$hasBrackets = $phpcsFile->findNext($this->bracketTokens, $open + 1, $close);
|
121 |
-
if ($hasBrackets === false) {
|
122 |
-
$this->addError($phpcsFile, $stackPtr);
|
123 |
-
return;
|
124 |
-
}
|
125 |
-
|
126 |
-
// Ok, we have both a blacklisted token as well as brackets, so we need to walk
|
127 |
-
// the tokens of the variable variable.
|
128 |
-
for ($i = ($open + 1); $i < $close; $i++) {
|
129 |
-
// If this is a bracket token, skip to the end of the bracketed expression.
|
130 |
-
if (isset($this->bracketTokens[$tokens[$i]['code']], $tokens[$i]['bracket_closer'])) {
|
131 |
-
$i = $tokens[$i]['bracket_closer'];
|
132 |
-
continue;
|
133 |
-
}
|
134 |
-
|
135 |
-
// If it's a blacklisted token, not within brackets, we have an error.
|
136 |
-
if (isset($this->tokenBlackList[$tokens[$i]['code']])) {
|
137 |
-
$this->addError($phpcsFile, $stackPtr);
|
138 |
-
return;
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Add the error message.
|
146 |
-
*
|
147 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
148 |
-
* @param int $stackPtr The position of the current token in the
|
149 |
-
* stack passed in $tokens.
|
150 |
-
*
|
151 |
-
* @return void
|
152 |
-
*/
|
153 |
-
protected function addError(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
154 |
-
{
|
155 |
-
$phpcsFile->addError(
|
156 |
-
'Only variables can be passed to empty() prior to PHP 5.5.',
|
157 |
-
$stackPtr,
|
158 |
-
'Found'
|
159 |
-
);
|
160 |
-
}
|
161 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php
DELETED
@@ -1,102 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenBreakContinueVariableArguments.
|
4 |
-
*
|
5 |
-
* PHP version 5.4
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim.godden@cu.be>
|
10 |
-
* @copyright 2012 Cu.be Solutions bvba
|
11 |
-
*/
|
12 |
-
|
13 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
14 |
-
|
15 |
-
use PHPCompatibility\Sniff;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenBreakContinueVariableArguments.
|
19 |
-
*
|
20 |
-
* Forbids variable arguments on break or continue statements.
|
21 |
-
*
|
22 |
-
* PHP version 5.4
|
23 |
-
*
|
24 |
-
* @category PHP
|
25 |
-
* @package PHPCompatibility
|
26 |
-
* @author Wim Godden <wim.godden@cu.be>
|
27 |
-
* @copyright 2012 Cu.be Solutions bvba
|
28 |
-
*/
|
29 |
-
class ForbiddenBreakContinueVariableArgumentsSniff extends Sniff
|
30 |
-
{
|
31 |
-
/**
|
32 |
-
* Error types this sniff handles for forbidden break/continue arguments.
|
33 |
-
*
|
34 |
-
* Array key is the error code. Array value will be used as part of the error message.
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
private $errorTypes = array(
|
39 |
-
'variableArgument' => 'a variable argument',
|
40 |
-
'zeroArgument' => '0 as an argument',
|
41 |
-
);
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Returns an array of tokens this test wants to listen for.
|
45 |
-
*
|
46 |
-
* @return array
|
47 |
-
*/
|
48 |
-
public function register()
|
49 |
-
{
|
50 |
-
return array(T_BREAK, T_CONTINUE);
|
51 |
-
|
52 |
-
}//end register()
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Processes this test, when one of its tokens is encountered.
|
56 |
-
*
|
57 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
58 |
-
* @param int $stackPtr The position of the current token in the
|
59 |
-
* stack passed in $tokens.
|
60 |
-
*
|
61 |
-
* @return void
|
62 |
-
*/
|
63 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
64 |
-
{
|
65 |
-
if ($this->supportsAbove('5.4') === false) {
|
66 |
-
return;
|
67 |
-
}
|
68 |
-
|
69 |
-
$tokens = $phpcsFile->getTokens();
|
70 |
-
$nextSemicolonToken = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr), null, false);
|
71 |
-
$errorType = '';
|
72 |
-
for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
|
73 |
-
if ($tokens[$curToken]['type'] === 'T_STRING') {
|
74 |
-
// If the next non-whitespace token after the string
|
75 |
-
// is an opening parenthesis then it's a function call.
|
76 |
-
$openBracket = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
|
77 |
-
if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS) {
|
78 |
-
$errorType = 'variableArgument';
|
79 |
-
break;
|
80 |
-
}
|
81 |
-
|
82 |
-
} elseif (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
|
83 |
-
$errorType = 'variableArgument';
|
84 |
-
break;
|
85 |
-
|
86 |
-
} elseif ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
|
87 |
-
$errorType = 'zeroArgument';
|
88 |
-
break;
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
if ($errorType !== '') {
|
93 |
-
$error = 'Using %s on break or continue is forbidden since PHP 5.4';
|
94 |
-
$errorCode = $errorType.'Found';
|
95 |
-
$data = array($this->errorTypes[$errorType]);
|
96 |
-
|
97 |
-
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
98 |
-
}
|
99 |
-
|
100 |
-
}//end process()
|
101 |
-
|
102 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php
DELETED
@@ -1,233 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenCallTimePassByReference.
|
4 |
-
*
|
5 |
-
* PHP version 5.4
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Gary Rogers <gmrwebde@gmail.com>
|
10 |
-
* @author Florian Grandel <jerico.dev@gmail.com>
|
11 |
-
* @copyright 2009 Florian Grandel
|
12 |
-
*/
|
13 |
-
|
14 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
15 |
-
|
16 |
-
use PHPCompatibility\Sniff;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenCallTimePassByReference.
|
20 |
-
*
|
21 |
-
* Discourages the use of call time pass by references
|
22 |
-
*
|
23 |
-
* PHP version 5.4
|
24 |
-
*
|
25 |
-
* @category PHP
|
26 |
-
* @package PHPCompatibility
|
27 |
-
* @author Gary Rogers <gmrwebde@gmail.com>
|
28 |
-
* @author Florian Grandel <jerico.dev@gmail.com>
|
29 |
-
* @copyright 2009 Florian Grandel
|
30 |
-
*/
|
31 |
-
class ForbiddenCallTimePassByReferenceSniff extends Sniff
|
32 |
-
{
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Tokens that represent assignments or equality comparisons.
|
36 |
-
*
|
37 |
-
* Near duplicate of Tokens::$assignmentTokens + Tokens::$equalityTokens.
|
38 |
-
* Copied in for PHPCS cross-version compatibility.
|
39 |
-
*
|
40 |
-
* @var array
|
41 |
-
*/
|
42 |
-
private $assignOrCompare = array(
|
43 |
-
// Comparison tokens.
|
44 |
-
'T_IS_EQUAL' => true,
|
45 |
-
'T_IS_NOT_EQUAL' => true,
|
46 |
-
'T_IS_IDENTICAL' => true,
|
47 |
-
'T_IS_NOT_IDENTICAL' => true,
|
48 |
-
'T_IS_SMALLER_OR_EQUAL' => true,
|
49 |
-
'T_IS_GREATER_OR_EQUAL' => true,
|
50 |
-
|
51 |
-
// Assignment tokens.
|
52 |
-
'T_EQUAL' => true,
|
53 |
-
'T_AND_EQUAL' => true,
|
54 |
-
'T_OR_EQUAL' => true,
|
55 |
-
'T_CONCAT_EQUAL' => true,
|
56 |
-
'T_DIV_EQUAL' => true,
|
57 |
-
'T_MINUS_EQUAL' => true,
|
58 |
-
'T_POW_EQUAL' => true,
|
59 |
-
'T_MOD_EQUAL' => true,
|
60 |
-
'T_MUL_EQUAL' => true,
|
61 |
-
'T_PLUS_EQUAL' => true,
|
62 |
-
'T_XOR_EQUAL' => true,
|
63 |
-
'T_DOUBLE_ARROW' => true,
|
64 |
-
'T_SL_EQUAL' => true,
|
65 |
-
'T_SR_EQUAL' => true,
|
66 |
-
'T_COALESCE_EQUAL' => true,
|
67 |
-
'T_ZSR_EQUAL' => true,
|
68 |
-
);
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Returns an array of tokens this test wants to listen for.
|
72 |
-
*
|
73 |
-
* @return array
|
74 |
-
*/
|
75 |
-
public function register()
|
76 |
-
{
|
77 |
-
return array(T_STRING);
|
78 |
-
|
79 |
-
}//end register()
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Processes this test, when one of its tokens is encountered.
|
83 |
-
*
|
84 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
85 |
-
* @param int $stackPtr The position of the current token
|
86 |
-
* in the stack passed in $tokens.
|
87 |
-
*
|
88 |
-
* @return void
|
89 |
-
*/
|
90 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
91 |
-
{
|
92 |
-
if ($this->supportsAbove('5.3') === false) {
|
93 |
-
return;
|
94 |
-
}
|
95 |
-
|
96 |
-
$tokens = $phpcsFile->getTokens();
|
97 |
-
|
98 |
-
// Skip tokens that are the names of functions or classes
|
99 |
-
// within their definitions. For example: function myFunction...
|
100 |
-
// "myFunction" is T_STRING but we should skip because it is not a
|
101 |
-
// function or method *call*.
|
102 |
-
$findTokens = \PHP_CodeSniffer_Tokens::$emptyTokens;
|
103 |
-
$findTokens[] = T_BITWISE_AND;
|
104 |
-
|
105 |
-
$prevNonEmpty = $phpcsFile->findPrevious(
|
106 |
-
$findTokens,
|
107 |
-
($stackPtr - 1),
|
108 |
-
null,
|
109 |
-
true
|
110 |
-
);
|
111 |
-
|
112 |
-
if ($prevNonEmpty !== false && in_array($tokens[$prevNonEmpty]['type'], array('T_FUNCTION', 'T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
|
113 |
-
return;
|
114 |
-
}
|
115 |
-
|
116 |
-
// If the next non-whitespace token after the function or method call
|
117 |
-
// is not an opening parenthesis then it can't really be a *call*.
|
118 |
-
$openBracket = $phpcsFile->findNext(
|
119 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
120 |
-
($stackPtr + 1),
|
121 |
-
null,
|
122 |
-
true
|
123 |
-
);
|
124 |
-
|
125 |
-
if ($openBracket === false || $tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS
|
126 |
-
|| isset($tokens[$openBracket]['parenthesis_closer']) === false
|
127 |
-
) {
|
128 |
-
return;
|
129 |
-
}
|
130 |
-
|
131 |
-
// Get the function call parameters.
|
132 |
-
$parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
|
133 |
-
if (count($parameters) === 0) {
|
134 |
-
return;
|
135 |
-
}
|
136 |
-
|
137 |
-
// Which nesting level is the one we are interested in ?
|
138 |
-
$nestedParenthesisCount = 1;
|
139 |
-
if (isset($tokens[$openBracket]['nested_parenthesis'])) {
|
140 |
-
$nestedParenthesisCount = count($tokens[$openBracket]['nested_parenthesis']) + 1;
|
141 |
-
}
|
142 |
-
|
143 |
-
foreach ($parameters as $parameter) {
|
144 |
-
if ($this->isCallTimePassByReferenceParam($phpcsFile, $parameter, $nestedParenthesisCount) === true) {
|
145 |
-
// T_BITWISE_AND represents a pass-by-reference.
|
146 |
-
$error = 'Using a call-time pass-by-reference is deprecated since PHP 5.3';
|
147 |
-
$isError = false;
|
148 |
-
$errorCode = 'Deprecated';
|
149 |
-
|
150 |
-
if ($this->supportsAbove('5.4')) {
|
151 |
-
$error .= ' and prohibited since PHP 5.4';
|
152 |
-
$isError = true;
|
153 |
-
$errorCode = 'NotAllowed';
|
154 |
-
}
|
155 |
-
|
156 |
-
$this->addMessage($phpcsFile, $error, $parameter['start'], $isError, $errorCode);
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}//end process()
|
160 |
-
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Determine whether a parameter is passed by reference.
|
164 |
-
*
|
165 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
166 |
-
* @param array $parameter Information on the current parameter
|
167 |
-
* to be examined.
|
168 |
-
* @param int $nestingLevel Target nesting level.
|
169 |
-
*
|
170 |
-
* @return bool
|
171 |
-
*/
|
172 |
-
protected function isCallTimePassByReferenceParam(\PHP_CodeSniffer_File $phpcsFile, $parameter, $nestingLevel)
|
173 |
-
{
|
174 |
-
$tokens = $phpcsFile->getTokens();
|
175 |
-
|
176 |
-
$searchStartToken = $parameter['start'] - 1;
|
177 |
-
$searchEndToken = $parameter['end'] + 1;
|
178 |
-
$nextVariable = $searchStartToken;
|
179 |
-
do {
|
180 |
-
$nextVariable = $phpcsFile->findNext(T_VARIABLE, ($nextVariable + 1), $searchEndToken);
|
181 |
-
if ($nextVariable === false) {
|
182 |
-
return false;
|
183 |
-
}
|
184 |
-
|
185 |
-
// Make sure the variable belongs directly to this function call
|
186 |
-
// and is not inside a nested function call or array.
|
187 |
-
if (isset($tokens[$nextVariable]['nested_parenthesis']) === false
|
188 |
-
|| (count($tokens[$nextVariable]['nested_parenthesis']) !== $nestingLevel)
|
189 |
-
) {
|
190 |
-
continue;
|
191 |
-
}
|
192 |
-
|
193 |
-
// Checking this: $value = my_function(...[*]$arg...).
|
194 |
-
$tokenBefore = $phpcsFile->findPrevious(
|
195 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
196 |
-
($nextVariable - 1),
|
197 |
-
$searchStartToken,
|
198 |
-
true
|
199 |
-
);
|
200 |
-
|
201 |
-
if ($tokenBefore === false || $tokens[$tokenBefore]['code'] !== T_BITWISE_AND) {
|
202 |
-
// Nothing before the token or no &.
|
203 |
-
continue;
|
204 |
-
}
|
205 |
-
|
206 |
-
if ($phpcsFile->isReference($tokenBefore) === false) {
|
207 |
-
continue;
|
208 |
-
}
|
209 |
-
|
210 |
-
// Checking this: $value = my_function(...[*]&$arg...).
|
211 |
-
$tokenBefore = $phpcsFile->findPrevious(
|
212 |
-
\PHP_CodeSniffer_Tokens::$emptyTokens,
|
213 |
-
($tokenBefore - 1),
|
214 |
-
$searchStartToken,
|
215 |
-
true
|
216 |
-
);
|
217 |
-
|
218 |
-
// Prevent false positive on assign by reference and compare with reference
|
219 |
-
// within function call parameters.
|
220 |
-
if (isset($this->assignOrCompare[$tokens[$tokenBefore]['type']])) {
|
221 |
-
continue;
|
222 |
-
}
|
223 |
-
|
224 |
-
// The found T_BITWISE_AND represents a pass-by-reference.
|
225 |
-
return true;
|
226 |
-
|
227 |
-
} while ($nextVariable < $searchEndToken);
|
228 |
-
|
229 |
-
// This code should never be reached, but here in case of weird bugs ;-)
|
230 |
-
return false;
|
231 |
-
}
|
232 |
-
|
233 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenClosureUseVariableNamesSniff.php
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHP 7.1 Forbidden variable names in closure use statements.
|
4 |
-
*
|
5 |
-
* PHP version 7.1
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* PHP 7.1 Forbidden variable names in closure use statements.
|
18 |
-
*
|
19 |
-
* Variables bound to a closure via the use construct cannot use the same name
|
20 |
-
* as any superglobals, $this, or any parameter since PHP 7.1.
|
21 |
-
*
|
22 |
-
* PHP version 7.1
|
23 |
-
*
|
24 |
-
* @category PHP
|
25 |
-
* @package PHPCompatibility
|
26 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
27 |
-
*/
|
28 |
-
class ForbiddenClosureUseVariableNamesSniff extends Sniff
|
29 |
-
{
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Returns an array of tokens this test wants to listen for.
|
33 |
-
*
|
34 |
-
* @return array
|
35 |
-
*/
|
36 |
-
public function register()
|
37 |
-
{
|
38 |
-
return array(T_USE);
|
39 |
-
|
40 |
-
}//end register()
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Processes this test, when one of its tokens is encountered.
|
44 |
-
*
|
45 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
46 |
-
* @param int $stackPtr The position of the current token
|
47 |
-
* in the stack passed in $tokens.
|
48 |
-
*
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
52 |
-
{
|
53 |
-
if ($this->supportsAbove('7.1') === false) {
|
54 |
-
return;
|
55 |
-
}
|
56 |
-
|
57 |
-
$tokens = $phpcsFile->getTokens();
|
58 |
-
|
59 |
-
// Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
|
60 |
-
$previousNonEmpty = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
61 |
-
if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== T_CLOSE_PARENTHESIS
|
62 |
-
|| isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
|
63 |
-
) {
|
64 |
-
return;
|
65 |
-
}
|
66 |
-
|
67 |
-
// ... and (a variable within) parenthesis after it.
|
68 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
|
69 |
-
if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) {
|
70 |
-
return;
|
71 |
-
}
|
72 |
-
|
73 |
-
if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
|
74 |
-
// Live coding.
|
75 |
-
return;
|
76 |
-
}
|
77 |
-
|
78 |
-
$closurePtr = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true);
|
79 |
-
if ($closurePtr === false || $tokens[$closurePtr]['code'] !== T_CLOSURE) {
|
80 |
-
return;
|
81 |
-
}
|
82 |
-
|
83 |
-
// Get the parameters declared by the closure.
|
84 |
-
$closureParams = $this->getMethodParameters($phpcsFile, $closurePtr);
|
85 |
-
|
86 |
-
$errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s';
|
87 |
-
|
88 |
-
for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
|
89 |
-
if ($tokens[$i]['code'] !== T_VARIABLE) {
|
90 |
-
continue;
|
91 |
-
}
|
92 |
-
|
93 |
-
$variableName = $tokens[$i]['content'];
|
94 |
-
|
95 |
-
if ($variableName === '$this') {
|
96 |
-
$phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName));
|
97 |
-
continue;
|
98 |
-
}
|
99 |
-
|
100 |
-
if (in_array($variableName, $this->superglobals, true) === true) {
|
101 |
-
$phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
|
102 |
-
continue;
|
103 |
-
}
|
104 |
-
|
105 |
-
// Check whether it is one of the parameters declared by the closure.
|
106 |
-
if (empty($closureParams) === false) {
|
107 |
-
foreach ($closureParams as $param) {
|
108 |
-
if ($param['name'] === $variableName) {
|
109 |
-
$phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName));
|
110 |
-
continue 2;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
}//end process()
|
117 |
-
|
118 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenEmptyListAssignmentSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
use PHPCompatibility\PHPCSHelper;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenEmptyListAssignmentSniff.
|
19 |
-
*
|
20 |
-
* Empty list() assignments have been removed in PHP 7.0
|
21 |
-
*
|
22 |
-
* PHP version 7.0
|
23 |
-
*
|
24 |
-
* @category PHP
|
25 |
-
* @package PHPCompatibility
|
26 |
-
* @author Wim Godden <wim@cu.be>
|
27 |
-
*/
|
28 |
-
class ForbiddenEmptyListAssignmentSniff extends Sniff
|
29 |
-
{
|
30 |
-
|
31 |
-
/**
|
32 |
-
* List of tokens to disregard when determining whether the list() is empty.
|
33 |
-
*
|
34 |
-
* @var array
|
35 |
-
*/
|
36 |
-
protected $ignoreTokens = array();
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Returns an array of tokens this test wants to listen for.
|
40 |
-
*
|
41 |
-
* @return array
|
42 |
-
*/
|
43 |
-
public function register()
|
44 |
-
{
|
45 |
-
// Set up a list of tokens to disregard when determining whether the list() is empty.
|
46 |
-
// Only needs to be set up once.
|
47 |
-
$this->ignoreTokens = \PHP_CodeSniffer_Tokens::$emptyTokens;
|
48 |
-
if (version_compare(PHPCSHelper::getVersion(), '2.0', '<')) {
|
49 |
-
$this->ignoreTokens = array_combine($this->ignoreTokens, $this->ignoreTokens);
|
50 |
-
}
|
51 |
-
$this->ignoreTokens[T_COMMA] = T_COMMA;
|
52 |
-
$this->ignoreTokens[T_OPEN_PARENTHESIS] = T_OPEN_PARENTHESIS;
|
53 |
-
$this->ignoreTokens[T_CLOSE_PARENTHESIS] = T_CLOSE_PARENTHESIS;
|
54 |
-
|
55 |
-
return array(T_LIST);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Processes this test, when one of its tokens is encountered.
|
60 |
-
*
|
61 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
62 |
-
* @param int $stackPtr The position of the current token in the
|
63 |
-
* stack passed in $tokens.
|
64 |
-
*
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
68 |
-
{
|
69 |
-
if ($this->supportsAbove('7.0')) {
|
70 |
-
$tokens = $phpcsFile->getTokens();
|
71 |
-
|
72 |
-
$open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
|
73 |
-
if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
|
77 |
-
$close = $tokens[$open]['parenthesis_closer'];
|
78 |
-
$error = true;
|
79 |
-
if (($close - $open) > 1) {
|
80 |
-
for ($cnt = $open + 1; $cnt < $close; $cnt++) {
|
81 |
-
if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
|
82 |
-
$error = false;
|
83 |
-
break;
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
if ($error === true) {
|
89 |
-
$phpcsFile->addError(
|
90 |
-
'Empty list() assignments are not allowed since PHP 7.0',
|
91 |
-
$stackPtr,
|
92 |
-
'Found'
|
93 |
-
);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenFunctionParametersWithSameName.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenFunctionParametersWithSameName.
|
18 |
-
*
|
19 |
-
* Functions can not have multiple parameters with the same name since PHP 7.0
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim@cu.be>
|
26 |
-
*/
|
27 |
-
class ForbiddenFunctionParametersWithSameNameSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Returns an array of tokens this test wants to listen for.
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function register()
|
36 |
-
{
|
37 |
-
return array(
|
38 |
-
T_FUNCTION,
|
39 |
-
T_CLOSURE,
|
40 |
-
);
|
41 |
-
|
42 |
-
}//end register()
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Processes this test, when one of its tokens is encountered.
|
46 |
-
*
|
47 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
48 |
-
* @param int $stackPtr The position of the current token
|
49 |
-
* in the stack passed in $tokens.
|
50 |
-
*
|
51 |
-
* @return void
|
52 |
-
*/
|
53 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
54 |
-
{
|
55 |
-
if ($this->supportsAbove('7.0') === false) {
|
56 |
-
return;
|
57 |
-
}
|
58 |
-
|
59 |
-
$tokens = $phpcsFile->getTokens();
|
60 |
-
$token = $tokens[$stackPtr];
|
61 |
-
// Skip function without body.
|
62 |
-
if (isset($token['scope_opener']) === false) {
|
63 |
-
return;
|
64 |
-
}
|
65 |
-
|
66 |
-
// Get all parameters from method signature.
|
67 |
-
$parameters = $this->getMethodParameters($phpcsFile, $stackPtr);
|
68 |
-
if (empty($parameters) || is_array($parameters) === false) {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
$paramNames = array();
|
73 |
-
foreach ($parameters as $param) {
|
74 |
-
$paramNames[] = strtolower($param['name']);
|
75 |
-
}
|
76 |
-
|
77 |
-
if (count($paramNames) !== count(array_unique($paramNames))) {
|
78 |
-
$phpcsFile->addError(
|
79 |
-
'Functions can not have multiple parameters with the same name since PHP 7.0',
|
80 |
-
$stackPtr,
|
81 |
-
'Found'
|
82 |
-
);
|
83 |
-
}
|
84 |
-
|
85 |
-
}//end process()
|
86 |
-
|
87 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php
DELETED
@@ -1,252 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNamesAsDeclaredClassSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.0+
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNamesAsDeclaredClassSniff.
|
18 |
-
*
|
19 |
-
* Prohibits the use of some reserved keywords to name a class, interface, trait or namespace.
|
20 |
-
* Emits errors for reserved words and warnings for soft-reserved words.
|
21 |
-
*
|
22 |
-
* @see http://php.net/manual/en/reserved.other-reserved-words.php
|
23 |
-
*
|
24 |
-
* PHP version 7.0+
|
25 |
-
*
|
26 |
-
* @category PHP
|
27 |
-
* @package PHPCompatibility
|
28 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
29 |
-
*/
|
30 |
-
class ForbiddenNamesAsDeclaredSniff extends Sniff
|
31 |
-
{
|
32 |
-
|
33 |
-
/**
|
34 |
-
* List of tokens which can not be used as class, interface, trait names or as part of a namespace.
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
protected $forbiddenTokens = array(
|
39 |
-
T_NULL => '7.0',
|
40 |
-
T_TRUE => '7.0',
|
41 |
-
T_FALSE => '7.0',
|
42 |
-
);
|
43 |
-
|
44 |
-
/**
|
45 |
-
* T_STRING keywords to recognize as forbidden names.
|
46 |
-
*
|
47 |
-
* @var array
|
48 |
-
*/
|
49 |
-
protected $forbiddenNames = array(
|
50 |
-
'null' => '7.0',
|
51 |
-
'true' => '7.0',
|
52 |
-
'false' => '7.0',
|
53 |
-
'bool' => '7.0',
|
54 |
-
'int' => '7.0',
|
55 |
-
'float' => '7.0',
|
56 |
-
'string' => '7.0',
|
57 |
-
'iterable' => '7.1',
|
58 |
-
'void' => '7.1',
|
59 |
-
'object' => '7.2',
|
60 |
-
);
|
61 |
-
|
62 |
-
/**
|
63 |
-
* T_STRING keywords to recognize as soft reserved names.
|
64 |
-
*
|
65 |
-
* Using any of these keywords to name a class, interface, trait or namespace
|
66 |
-
* is highly discouraged since they may be used in future versions of PHP.
|
67 |
-
*
|
68 |
-
* @var array
|
69 |
-
*/
|
70 |
-
protected $softReservedNames = array(
|
71 |
-
'resource' => '7.0',
|
72 |
-
'object' => '7.0',
|
73 |
-
'mixed' => '7.0',
|
74 |
-
'numeric' => '7.0',
|
75 |
-
);
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Combined list of the two lists above.
|
79 |
-
*
|
80 |
-
* Used for quick check whether or not something is a reserved
|
81 |
-
* word.
|
82 |
-
* Set from the `register()` method.
|
83 |
-
*
|
84 |
-
* @var array
|
85 |
-
*/
|
86 |
-
private $allForbiddenNames = array();
|
87 |
-
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Returns an array of tokens this test wants to listen for.
|
91 |
-
*
|
92 |
-
* @return array
|
93 |
-
*/
|
94 |
-
public function register()
|
95 |
-
{
|
96 |
-
// Do the list merge only once.
|
97 |
-
$this->allForbiddenNames = array_merge($this->forbiddenNames, $this->softReservedNames);
|
98 |
-
|
99 |
-
$targets = array(
|
100 |
-
T_CLASS,
|
101 |
-
T_INTERFACE,
|
102 |
-
T_NAMESPACE,
|
103 |
-
T_STRING, // Compat for PHPCS 1.x and PHP < 5.3.
|
104 |
-
);
|
105 |
-
|
106 |
-
if (defined('T_TRAIT')) {
|
107 |
-
$targets[] = constant('T_TRAIT');
|
108 |
-
}
|
109 |
-
|
110 |
-
return $targets;
|
111 |
-
|
112 |
-
}//end register()
|
113 |
-
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Processes this test, when one of its tokens is encountered.
|
117 |
-
*
|
118 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
119 |
-
* @param int $stackPtr The position of the current token in the
|
120 |
-
* stack passed in $tokens.
|
121 |
-
*
|
122 |
-
* @return void
|
123 |
-
*/
|
124 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
125 |
-
{
|
126 |
-
if ($this->supportsAbove('7.0') === false) {
|
127 |
-
return;
|
128 |
-
}
|
129 |
-
|
130 |
-
$tokens = $phpcsFile->getTokens();
|
131 |
-
$tokenCode = $tokens[$stackPtr]['code'];
|
132 |
-
$tokenType = $tokens[$stackPtr]['type'];
|
133 |
-
$tokenContentLc = strtolower($tokens[$stackPtr]['content']);
|
134 |
-
|
135 |
-
// For string tokens we only care about 'trait' as that is the only one
|
136 |
-
// which may not be correctly recognized as it's own token.
|
137 |
-
// This only happens in older versions of PHP where the token doesn't exist yet as a keyword.
|
138 |
-
if ($tokenCode === T_STRING && $tokenContentLc !== 'trait') {
|
139 |
-
return;
|
140 |
-
}
|
141 |
-
|
142 |
-
if (in_array($tokenType, array('T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
|
143 |
-
// Check for the declared name being a name which is not tokenized as T_STRING.
|
144 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
145 |
-
if ($nextNonEmpty !== false && isset($this->forbiddenTokens[$tokens[$nextNonEmpty]['code']]) === true) {
|
146 |
-
$name = $tokens[$nextNonEmpty]['content'];
|
147 |
-
} else {
|
148 |
-
// Get the declared name if it's a T_STRING.
|
149 |
-
$name = $phpcsFile->getDeclarationName($stackPtr);
|
150 |
-
}
|
151 |
-
unset($nextNonEmpty);
|
152 |
-
|
153 |
-
if (isset($name) === false || is_string($name) === false || $name === '') {
|
154 |
-
return;
|
155 |
-
}
|
156 |
-
|
157 |
-
$nameLc = strtolower($name);
|
158 |
-
if (isset($this->allForbiddenNames[$nameLc]) === false) {
|
159 |
-
return;
|
160 |
-
}
|
161 |
-
|
162 |
-
} elseif ($tokenCode === T_NAMESPACE) {
|
163 |
-
$namespaceName = $this->getDeclaredNamespaceName($phpcsFile, $stackPtr);
|
164 |
-
|
165 |
-
if ($namespaceName === false || $namespaceName === '') {
|
166 |
-
return;
|
167 |
-
}
|
168 |
-
|
169 |
-
$namespaceParts = explode('\\', $namespaceName);
|
170 |
-
foreach ($namespaceParts as $namespacePart) {
|
171 |
-
$partLc = strtolower($namespacePart);
|
172 |
-
if (isset($this->allForbiddenNames[$partLc]) === true) {
|
173 |
-
$name = $namespacePart;
|
174 |
-
$nameLc = $partLc;
|
175 |
-
break;
|
176 |
-
}
|
177 |
-
}
|
178 |
-
} elseif ($tokenCode === T_STRING) {
|
179 |
-
// Traits which are not yet tokenized as T_TRAIT.
|
180 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
181 |
-
if ($nextNonEmpty === false) {
|
182 |
-
return;
|
183 |
-
}
|
184 |
-
|
185 |
-
$nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
|
186 |
-
|
187 |
-
if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
|
188 |
-
$name = $tokens[$nextNonEmpty]['content'];
|
189 |
-
$nameLc = strtolower($tokens[$nextNonEmpty]['content']);
|
190 |
-
} elseif ($nextNonEmptyCode === T_STRING) {
|
191 |
-
$endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
|
192 |
-
if ($endOfStatement === false) {
|
193 |
-
return;
|
194 |
-
}
|
195 |
-
|
196 |
-
do {
|
197 |
-
$nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
|
198 |
-
|
199 |
-
if (isset($this->allForbiddenNames[$nextNonEmptyLc]) === true) {
|
200 |
-
$name = $tokens[$nextNonEmpty]['content'];
|
201 |
-
$nameLc = $nextNonEmptyLc;
|
202 |
-
break;
|
203 |
-
}
|
204 |
-
|
205 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
|
206 |
-
} while ($nextNonEmpty !== false);
|
207 |
-
}
|
208 |
-
unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
|
209 |
-
}
|
210 |
-
|
211 |
-
if (isset($name, $nameLc) === false) {
|
212 |
-
return;
|
213 |
-
}
|
214 |
-
|
215 |
-
// Still here, so this is one of the reserved words.
|
216 |
-
// Build up the error message.
|
217 |
-
$error = "'%s' is a";
|
218 |
-
$isError = null;
|
219 |
-
$errorCode = $this->stringToErrorCode($nameLc).'Found';
|
220 |
-
$data = array(
|
221 |
-
$nameLc,
|
222 |
-
);
|
223 |
-
|
224 |
-
if (isset($this->softReservedNames[$nameLc]) === true
|
225 |
-
&& $this->supportsAbove($this->softReservedNames[$nameLc]) === true
|
226 |
-
) {
|
227 |
-
$error .= ' soft reserved keyword as of PHP version %s';
|
228 |
-
$isError = false;
|
229 |
-
$data[] = $this->softReservedNames[$nameLc];
|
230 |
-
}
|
231 |
-
|
232 |
-
if (isset($this->forbiddenNames[$nameLc]) === true
|
233 |
-
&& $this->supportsAbove($this->forbiddenNames[$nameLc]) === true
|
234 |
-
) {
|
235 |
-
if (isset($isError) === true) {
|
236 |
-
$error .= ' and a';
|
237 |
-
}
|
238 |
-
$error .= ' reserved keyword as of PHP version %s';
|
239 |
-
$isError = true;
|
240 |
-
$data[] = $this->forbiddenNames[$nameLc];
|
241 |
-
}
|
242 |
-
|
243 |
-
if (isset($isError) === true) {
|
244 |
-
$error .= ' and should not be used to name a class, interface or trait or as part of a namespace (%s)';
|
245 |
-
$data[] = $tokens[$stackPtr]['type'];
|
246 |
-
|
247 |
-
$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
|
248 |
-
}
|
249 |
-
|
250 |
-
}//end process()
|
251 |
-
|
252 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php
DELETED
@@ -1,411 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNamesSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Wim Godden <wim.godden@cu.be>
|
8 |
-
* @copyright 2012 Cu.be Solutions bvba
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
12 |
-
|
13 |
-
use PHPCompatibility\Sniff;
|
14 |
-
use PHPCompatibility\PHPCSHelper;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNamesSniff.
|
18 |
-
*
|
19 |
-
* Prohibits the use of reserved keywords as class, function, namespace or constant names.
|
20 |
-
*
|
21 |
-
* @category PHP
|
22 |
-
* @package PHPCompatibility
|
23 |
-
* @author Wim Godden <wim.godden@cu.be>
|
24 |
-
* @copyright 2012 Cu.be Solutions bvba
|
25 |
-
*/
|
26 |
-
class ForbiddenNamesSniff extends Sniff
|
27 |
-
{
|
28 |
-
|
29 |
-
/**
|
30 |
-
* A list of keywords that can not be used as function, class and namespace name or constant name.
|
31 |
-
* Mentions since which version it's not allowed.
|
32 |
-
*
|
33 |
-
* @var array(string => string)
|
34 |
-
*/
|
35 |
-
protected $invalidNames = array(
|
36 |
-
'abstract' => '5.0',
|
37 |
-
'and' => 'all',
|
38 |
-
'array' => 'all',
|
39 |
-
'as' => 'all',
|
40 |
-
'break' => 'all',
|
41 |
-
'callable' => '5.4',
|
42 |
-
'case' => 'all',
|
43 |
-
'catch' => '5.0',
|
44 |
-
'class' => 'all',
|
45 |
-
'clone' => '5.0',
|
46 |
-
'const' => 'all',
|
47 |
-
'continue' => 'all',
|
48 |
-
'declare' => 'all',
|
49 |
-
'default' => 'all',
|
50 |
-
'do' => 'all',
|
51 |
-
'else' => 'all',
|
52 |
-
'elseif' => 'all',
|
53 |
-
'enddeclare' => 'all',
|
54 |
-
'endfor' => 'all',
|
55 |
-
'endforeach' => 'all',
|
56 |
-
'endif' => 'all',
|
57 |
-
'endswitch' => 'all',
|
58 |
-
'endwhile' => 'all',
|
59 |
-
'extends' => 'all',
|
60 |
-
'final' => '5.0',
|
61 |
-
'finally' => '5.5',
|
62 |
-
'for' => 'all',
|
63 |
-
'foreach' => 'all',
|
64 |
-
'function' => 'all',
|
65 |
-
'global' => 'all',
|
66 |
-
'goto' => '5.3',
|
67 |
-
'if' => 'all',
|
68 |
-
'implements' => '5.0',
|
69 |
-
'interface' => '5.0',
|
70 |
-
'instanceof' => '5.0',
|
71 |
-
'insteadof' => '5.4',
|
72 |
-
'namespace' => '5.3',
|
73 |
-
'new' => 'all',
|
74 |
-
'or' => 'all',
|
75 |
-
'private' => '5.0',
|
76 |
-
'protected' => '5.0',
|
77 |
-
'public' => '5.0',
|
78 |
-
'static' => 'all',
|
79 |
-
'switch' => 'all',
|
80 |
-
'throw' => '5.0',
|
81 |
-
'trait' => '5.4',
|
82 |
-
'try' => '5.0',
|
83 |
-
'use' => 'all',
|
84 |
-
'var' => 'all',
|
85 |
-
'while' => 'all',
|
86 |
-
'xor' => 'all',
|
87 |
-
'__class__' => 'all',
|
88 |
-
'__dir__' => '5.3',
|
89 |
-
'__file__' => 'all',
|
90 |
-
'__function__' => 'all',
|
91 |
-
'__method__' => 'all',
|
92 |
-
'__namespace__' => '5.3',
|
93 |
-
);
|
94 |
-
|
95 |
-
/**
|
96 |
-
* A list of keywords that can follow use statements.
|
97 |
-
*
|
98 |
-
* @var array(string => string)
|
99 |
-
*/
|
100 |
-
protected $validUseNames = array(
|
101 |
-
'const' => true,
|
102 |
-
'function' => true,
|
103 |
-
);
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Whether PHPCS 1.x is used or not.
|
107 |
-
*
|
108 |
-
* @var bool
|
109 |
-
*/
|
110 |
-
protected $isLowPHPCS = false;
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Scope modifiers and other keywords allowed in trait use statements.
|
114 |
-
*
|
115 |
-
* @var array
|
116 |
-
*/
|
117 |
-
private $allowed_modifiers = array();
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Targeted tokens.
|
121 |
-
*
|
122 |
-
* @var array
|
123 |
-
*/
|
124 |
-
protected $targetedTokens = array(
|
125 |
-
T_CLASS,
|
126 |
-
T_FUNCTION,
|
127 |
-
T_NAMESPACE,
|
128 |
-
T_STRING,
|
129 |
-
T_CONST,
|
130 |
-
T_USE,
|
131 |
-
T_AS,
|
132 |
-
T_EXTENDS,
|
133 |
-
T_INTERFACE,
|
134 |
-
);
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Returns an array of tokens this test wants to listen for.
|
138 |
-
*
|
139 |
-
* @return array
|
140 |
-
*/
|
141 |
-
public function register()
|
142 |
-
{
|
143 |
-
$this->isLowPHPCS = version_compare(PHPCSHelper::getVersion(), '2.0', '<');
|
144 |
-
|
145 |
-
$this->allowed_modifiers = array_combine(
|
146 |
-
\PHP_CodeSniffer_Tokens::$scopeModifiers,
|
147 |
-
\PHP_CodeSniffer_Tokens::$scopeModifiers
|
148 |
-
);
|
149 |
-
$this->allowed_modifiers[T_FINAL] = T_FINAL;
|
150 |
-
|
151 |
-
$tokens = $this->targetedTokens;
|
152 |
-
|
153 |
-
if (defined('T_TRAIT')) {
|
154 |
-
$tokens[] = constant('T_TRAIT');
|
155 |
-
}
|
156 |
-
|
157 |
-
if (defined('T_ANON_CLASS')) {
|
158 |
-
$tokens[] = constant('T_ANON_CLASS');
|
159 |
-
}
|
160 |
-
|
161 |
-
return $tokens;
|
162 |
-
}//end register()
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Processes this test, when one of its tokens is encountered.
|
166 |
-
*
|
167 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
168 |
-
* @param int $stackPtr The position of the current token in the
|
169 |
-
* stack passed in $tokens.
|
170 |
-
*
|
171 |
-
* @return void
|
172 |
-
*/
|
173 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
174 |
-
{
|
175 |
-
$tokens = $phpcsFile->getTokens();
|
176 |
-
|
177 |
-
/*
|
178 |
-
* We distinguish between the class, function and namespace names vs the define statements.
|
179 |
-
*/
|
180 |
-
if ($tokens[$stackPtr]['type'] === 'T_STRING') {
|
181 |
-
$this->processString($phpcsFile, $stackPtr, $tokens);
|
182 |
-
} else {
|
183 |
-
$this->processNonString($phpcsFile, $stackPtr, $tokens);
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Processes this test, when one of its tokens is encountered.
|
189 |
-
*
|
190 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
191 |
-
* @param int $stackPtr The position of the current token in the
|
192 |
-
* stack passed in $tokens.
|
193 |
-
* @param array $tokens The stack of tokens that make up
|
194 |
-
* the file.
|
195 |
-
*
|
196 |
-
* @return void
|
197 |
-
*/
|
198 |
-
public function processNonString(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens)
|
199 |
-
{
|
200 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
201 |
-
if ($nextNonEmpty === false) {
|
202 |
-
return;
|
203 |
-
}
|
204 |
-
|
205 |
-
/*
|
206 |
-
* Deal with anonymous classes - `class` before a reserved keyword is sometimes
|
207 |
-
* misidentified as `T_ANON_CLASS`.
|
208 |
-
* In PHPCS < 2.3.4 these were tokenized as T_CLASS no matter what.
|
209 |
-
*/
|
210 |
-
if ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS') {
|
211 |
-
$prevNonEmpty = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
|
212 |
-
if ($prevNonEmpty !== false && $tokens[$prevNonEmpty]['type'] === 'T_NEW') {
|
213 |
-
return;
|
214 |
-
}
|
215 |
-
}
|
216 |
-
|
217 |
-
/*
|
218 |
-
* PHP 5.6 allows for use const and use function, but only if followed by the function/constant name.
|
219 |
-
* - `use function HelloWorld` => move to the next token (HelloWorld) to verify.
|
220 |
-
* - `use const HelloWorld` => move to the next token (HelloWorld) to verify.
|
221 |
-
*/
|
222 |
-
elseif ($tokens[$stackPtr]['type'] === 'T_USE'
|
223 |
-
&& isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === true
|
224 |
-
) {
|
225 |
-
$maybeUseNext = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
|
226 |
-
if ($maybeUseNext !== false && $this->isEndOfUseStatement($tokens[$maybeUseNext]) === false) {
|
227 |
-
// Prevent duplicate messages: `const` is T_CONST in PHPCS 1.x and T_STRING in PHPCS 2.x.
|
228 |
-
if ($this->isLowPHPCS === true) {
|
229 |
-
return;
|
230 |
-
}
|
231 |
-
$nextNonEmpty = $maybeUseNext;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
|
235 |
-
/*
|
236 |
-
* Deal with visibility modifiers.
|
237 |
-
* - `use HelloWorld { sayHello as protected; }` => valid, bow out.
|
238 |
-
* - `use HelloWorld { sayHello as private myPrivateHello; }` => move to the next token to verify.
|
239 |
-
*/
|
240 |
-
elseif ($tokens[$stackPtr]['type'] === 'T_AS'
|
241 |
-
&& isset($this->allowed_modifiers[$tokens[$nextNonEmpty]['code']]) === true
|
242 |
-
&& $this->inUseScope($phpcsFile, $stackPtr) === true
|
243 |
-
) {
|
244 |
-
$maybeUseNext = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
|
245 |
-
if ($maybeUseNext === false || $this->isEndOfUseStatement($tokens[$maybeUseNext]) === true) {
|
246 |
-
return;
|
247 |
-
}
|
248 |
-
|
249 |
-
$nextNonEmpty = $maybeUseNext;
|
250 |
-
}
|
251 |
-
|
252 |
-
/*
|
253 |
-
* Deal with functions declared to return by reference.
|
254 |
-
*/
|
255 |
-
elseif ($tokens[$stackPtr]['type'] === 'T_FUNCTION'
|
256 |
-
&& $tokens[$nextNonEmpty]['type'] === 'T_BITWISE_AND'
|
257 |
-
) {
|
258 |
-
$maybeUseNext = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
|
259 |
-
if ($maybeUseNext === false) {
|
260 |
-
// Live coding.
|
261 |
-
return;
|
262 |
-
}
|
263 |
-
|
264 |
-
$nextNonEmpty = $maybeUseNext;
|
265 |
-
}
|
266 |
-
|
267 |
-
/*
|
268 |
-
* Deal with nested namespaces.
|
269 |
-
*/
|
270 |
-
elseif ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') {
|
271 |
-
if ($tokens[$stackPtr + 1]['code'] === T_NS_SEPARATOR) {
|
272 |
-
// Not a namespace declaration, but use of, i.e. namespace\someFunction();
|
273 |
-
return;
|
274 |
-
}
|
275 |
-
|
276 |
-
$endToken = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1), null, false, null, true);
|
277 |
-
$namespaceName = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($endToken - $stackPtr - 1)));
|
278 |
-
if (empty($namespaceName) === true) {
|
279 |
-
return;
|
280 |
-
}
|
281 |
-
|
282 |
-
$namespaceParts = explode('\\', $namespaceName);
|
283 |
-
foreach ($namespaceParts as $namespacePart) {
|
284 |
-
$partLc = strtolower($namespacePart);
|
285 |
-
if (isset($this->invalidNames[$partLc]) === false) {
|
286 |
-
continue;
|
287 |
-
}
|
288 |
-
|
289 |
-
// Find the token position of the part which matched.
|
290 |
-
for ($i = ($stackPtr + 1); $i < $endToken; $i++) {
|
291 |
-
if ($tokens[$i]['content'] === $namespacePart) {
|
292 |
-
$nextNonEmpty = $i;
|
293 |
-
break;
|
294 |
-
}
|
295 |
-
}
|
296 |
-
}
|
297 |
-
unset($i, $namespacePart, $partLc);
|
298 |
-
}
|
299 |
-
|
300 |
-
$nextContentLc = strtolower($tokens[$nextNonEmpty]['content']);
|
301 |
-
if (isset($this->invalidNames[$nextContentLc]) === false) {
|
302 |
-
return;
|
303 |
-
}
|
304 |
-
|
305 |
-
/*
|
306 |
-
* Deal with PHP 7 relaxing the rules.
|
307 |
-
* "As of PHP 7.0.0 these keywords are allowed as property, constant, and method names
|
308 |
-
* of classes, interfaces and traits, except that class may not be used as constant name."
|
309 |
-
*/
|
310 |
-
if ((($tokens[$stackPtr]['type'] === 'T_FUNCTION'
|
311 |
-
&& $this->inClassScope($phpcsFile, $stackPtr, false) === true)
|
312 |
-
|| ($tokens[$stackPtr]['type'] === 'T_CONST'
|
313 |
-
&& $this->isClassConstant($phpcsFile, $stackPtr) === true
|
314 |
-
&& $nextContentLc !== 'class')
|
315 |
-
) && $this->supportsBelow('5.6') === false
|
316 |
-
) {
|
317 |
-
return;
|
318 |
-
}
|
319 |
-
|
320 |
-
if ($this->supportsAbove($this->invalidNames[$nextContentLc])) {
|
321 |
-
$data = array(
|
322 |
-
$tokens[$nextNonEmpty]['content'],
|
323 |
-
$this->invalidNames[$nextContentLc],
|
324 |
-
);
|
325 |
-
$this->addError($phpcsFile, $stackPtr, $tokens[$nextNonEmpty]['content'], $data);
|
326 |
-
}
|
327 |
-
|
328 |
-
}//end processNonString()
|
329 |
-
|
330 |
-
/**
|
331 |
-
* Processes this test, when one of its tokens is encountered.
|
332 |
-
*
|
333 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
334 |
-
* @param int $stackPtr The position of the current token in the
|
335 |
-
* stack passed in $tokens.
|
336 |
-
* @param array $tokens The stack of tokens that make up
|
337 |
-
* the file.
|
338 |
-
*
|
339 |
-
* @return void
|
340 |
-
*/
|
341 |
-
public function processString(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens)
|
342 |
-
{
|
343 |
-
$tokenContentLc = strtolower($tokens[$stackPtr]['content']);
|
344 |
-
|
345 |
-
/*
|
346 |
-
* Special case for PHP versions where the target is not yet identified as
|
347 |
-
* its own token, but presents as T_STRING.
|
348 |
-
* - namespace keyword in PHP < 5.3
|
349 |
-
* - trait keyword in PHP < 5.4
|
350 |
-
*/
|
351 |
-
if (version_compare(PHP_VERSION_ID, '50400', '<') && $tokenContentLc === 'trait') {
|
352 |
-
$this->processNonString($phpcsFile, $stackPtr, $tokens);
|
353 |
-
return;
|
354 |
-
}
|
355 |
-
|
356 |
-
// Look for any define/defined tokens (both T_STRING ones, blame Tokenizer).
|
357 |
-
if ($tokenContentLc !== 'define' && $tokenContentLc !== 'defined') {
|
358 |
-
return;
|
359 |
-
}
|
360 |
-
|
361 |
-
// Retrieve the define(d) constant name.
|
362 |
-
$firstParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
|
363 |
-
if ($firstParam === false) {
|
364 |
-
return;
|
365 |
-
}
|
366 |
-
|
367 |
-
$defineName = $this->stripQuotes($firstParam['raw']);
|
368 |
-
$defineNameLc = strtolower($defineName);
|
369 |
-
|
370 |
-
if (isset($this->invalidNames[$defineNameLc]) && $this->supportsAbove($this->invalidNames[$defineNameLc])) {
|
371 |
-
$data = array(
|
372 |
-
$defineName,
|
373 |
-
$this->invalidNames[$defineNameLc],
|
374 |
-
);
|
375 |
-
$this->addError($phpcsFile, $stackPtr, $defineNameLc, $data);
|
376 |
-
}
|
377 |
-
}//end processString()
|
378 |
-
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Add the error message.
|
382 |
-
*
|
383 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
384 |
-
* @param int $stackPtr The position of the current token in the
|
385 |
-
* stack passed in $tokens.
|
386 |
-
* @param string $content The token content found.
|
387 |
-
* @param array $data The data to pass into the error message.
|
388 |
-
*
|
389 |
-
* @return void
|
390 |
-
*/
|
391 |
-
protected function addError($phpcsFile, $stackPtr, $content, $data)
|
392 |
-
{
|
393 |
-
$error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
|
394 |
-
$errorCode = $this->stringToErrorCode($content).'Found';
|
395 |
-
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
396 |
-
}
|
397 |
-
|
398 |
-
|
399 |
-
/**
|
400 |
-
* Check if the current token code is for a token which can be considered
|
401 |
-
* the end of a (partial) use statement.
|
402 |
-
*
|
403 |
-
* @param int $token The current token information.
|
404 |
-
*
|
405 |
-
* @return bool
|
406 |
-
*/
|
407 |
-
protected function isEndOfUseStatement($token)
|
408 |
-
{
|
409 |
-
return in_array($token['code'], array(T_CLOSE_CURLY_BRACKET, T_SEMICOLON, T_COMMA), true);
|
410 |
-
}
|
411 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNegativeBitshift.
|
4 |
-
*
|
5 |
-
* PHP version 7.0
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\ForbiddenNegativeBitshift.
|
18 |
-
*
|
19 |
-
* Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0.
|
20 |
-
*
|
21 |
-
* PHP version 7.0
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim@cu.be>
|
26 |
-
*/
|
27 |
-
class ForbiddenNegativeBitshiftSniff extends Sniff
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Returns an array of tokens this test wants to listen for.
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function register()
|
36 |
-
{
|
37 |
-
return array(T_SR);
|
38 |
-
|
39 |
-
}//end register()
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Processes this test, when one of its tokens is encountered.
|
43 |
-
*
|
44 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
45 |
-
* @param int $stackPtr The position of the current token
|
46 |
-
* in the stack passed in $tokens.
|
47 |
-
*
|
48 |
-
* @return void
|
49 |
-
*/
|
50 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
51 |
-
{
|
52 |
-
if ($this->supportsAbove('7.0') === false) {
|
53 |
-
return;
|
54 |
-
}
|
55 |
-
|
56 |
-
$nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr + 1, null, false, null, true);
|
57 |
-
if ($nextNumber === false || ($stackPtr + 1) === $nextNumber) {
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
|
61 |
-
$hasMinusSign = $phpcsFile->findNext(T_MINUS, $stackPtr + 1, $nextNumber, false, null, true);
|
62 |
-
if ($hasMinusSign === false) {
|
63 |
-
return;
|
64 |
-
}
|
65 |
-
|
66 |
-
$phpcsFile->addError(
|
67 |
-
'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0',
|
68 |
-
$hasMinusSign,
|
69 |
-
'Found'
|
70 |
-
);
|
71 |
-
|
72 |
-
}//end process()
|
73 |
-
|
74 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\InternalInterfacesSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
11 |
-
|
12 |
-
use PHPCompatibility\Sniff;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* \PHPCompatibility\Sniffs\PHP\InternalInterfacesSniff.
|
16 |
-
*
|
17 |
-
* @category PHP
|
18 |
-
* @package PHPCompatibility
|
19 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
-
*/
|
21 |
-
class InternalInterfacesSniff extends Sniff
|
22 |
-
{
|
23 |
-
|
24 |
-
/**
|
25 |
-
* A list of PHP internal interfaces, not intended to be implemented by userland classes.
|
26 |
-
*
|
27 |
-
* The array lists : the error message to use.
|
28 |
-
*
|
29 |
-
* @var array(string => string)
|
30 |
-
*/
|
31 |
-
protected $internalInterfaces = array(
|
32 |
-
'Traversable' => 'shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.',
|
33 |
-
'DateTimeInterface' => 'is intended for type hints only and is not implementable.',
|
34 |
-
'Throwable' => 'cannot be implemented directly, extend the Exception class instead.',
|
35 |
-
);
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Returns an array of tokens this test wants to listen for.
|
40 |
-
*
|
41 |
-
* @return array
|
42 |
-
*/
|
43 |
-
public function register()
|
44 |
-
{
|
45 |
-
// Handle case-insensitivity of interface names.
|
46 |
-
$this->internalInterfaces = $this->arrayKeysToLowercase($this->internalInterfaces);
|
47 |
-
|
48 |
-
$targets = array(T_CLASS);
|
49 |
-
|
50 |
-
if (defined('T_ANON_CLASS')) {
|
51 |
-
$targets[] = constant('T_ANON_CLASS');
|
52 |
-
}
|
53 |
-
|
54 |
-
return $targets;
|
55 |
-
|
56 |
-
}//end register()
|
57 |
-
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Processes this test, when one of its tokens is encountered.
|
61 |
-
*
|
62 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
63 |
-
* @param int $stackPtr The position of the current token in
|
64 |
-
* the stack passed in $tokens.
|
65 |
-
*
|
66 |
-
* @return void
|
67 |
-
*/
|
68 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
69 |
-
{
|
70 |
-
$interfaces = $this->findImplementedInterfaceNames($phpcsFile, $stackPtr);
|
71 |
-
|
72 |
-
if (is_array($interfaces) === false || $interfaces === array()) {
|
73 |
-
return;
|
74 |
-
}
|
75 |
-
|
76 |
-
foreach ($interfaces as $interface) {
|
77 |
-
$interfaceLc = strtolower($interface);
|
78 |
-
if (isset($this->internalInterfaces[$interfaceLc]) === true) {
|
79 |
-
$error = 'The interface %s %s';
|
80 |
-
$errorCode = $this->stringToErrorCode($interfaceLc).'Found';
|
81 |
-
$data = array(
|
82 |
-
$interface,
|
83 |
-
$this->internalInterfaces[$interfaceLc],
|
84 |
-
);
|
85 |
-
|
86 |
-
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
}//end process()
|
91 |
-
|
92 |
-
|
93 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php
DELETED
@@ -1,122 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\MbstringReplaceEModifierSniff.
|
4 |
-
*
|
5 |
-
* PHP version 7.1
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\MbstringReplaceEModifierSniff.
|
18 |
-
*
|
19 |
-
* PHP version 7.1
|
20 |
-
*
|
21 |
-
* @category PHP
|
22 |
-
* @package PHPCompatibility
|
23 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
24 |
-
*/
|
25 |
-
class MbstringReplaceEModifierSniff extends Sniff
|
26 |
-
{
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Functions to check for.
|
30 |
-
*
|
31 |
-
* Key is the function name, value the parameter position of the options parameter.
|
32 |
-
*
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
protected $functions = array(
|
36 |
-
'mb_ereg_replace' => 4,
|
37 |
-
'mb_eregi_replace' => 4,
|
38 |
-
'mb_regex_set_options' => 1,
|
39 |
-
);
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Returns an array of tokens this test wants to listen for.
|
44 |
-
*
|
45 |
-
* @return array
|
46 |
-
*/
|
47 |
-
public function register()
|
48 |
-
{
|
49 |
-
return array(T_STRING);
|
50 |
-
}//end register()
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Processes this test, when one of its tokens is encountered.
|
55 |
-
*
|
56 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
57 |
-
* @param int $stackPtr The position of the current token in the
|
58 |
-
* stack passed in $tokens.
|
59 |
-
*
|
60 |
-
* @return void
|
61 |
-
*/
|
62 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
63 |
-
{
|
64 |
-
if ($this->supportsAbove('7.1') === false) {
|
65 |
-
return;
|
66 |
-
}
|
67 |
-
|
68 |
-
$tokens = $phpcsFile->getTokens();
|
69 |
-
$functionNameLc = strtolower($tokens[$stackPtr]['content']);
|
70 |
-
|
71 |
-
// Bow out if not one of the functions we're targetting.
|
72 |
-
if (isset($this->functions[$functionNameLc]) === false) {
|
73 |
-
return;
|
74 |
-
}
|
75 |
-
|
76 |
-
// Get the options parameter in the function call.
|
77 |
-
$optionsParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->functions[$functionNameLc]);
|
78 |
-
if ($optionsParam === false) {
|
79 |
-
return;
|
80 |
-
}
|
81 |
-
|
82 |
-
$stringToken = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
|
83 |
-
if ($stringToken === false) {
|
84 |
-
// No string token found in the options parameter, so skip it (e.g. variable passed in).
|
85 |
-
return;
|
86 |
-
}
|
87 |
-
|
88 |
-
$options = '';
|
89 |
-
|
90 |
-
/*
|
91 |
-
* Get the content of any string tokens in the options parameter and remove the quotes and variables.
|
92 |
-
*/
|
93 |
-
for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
|
94 |
-
if (in_array($tokens[$i]['code'], \PHP_CodeSniffer_Tokens::$stringTokens, true) === false) {
|
95 |
-
continue;
|
96 |
-
}
|
97 |
-
|
98 |
-
$content = $this->stripQuotes($tokens[$i]['content']);
|
99 |
-
if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
|
100 |
-
$content = $this->stripVariables($content);
|
101 |
-
}
|
102 |
-
$content = trim($content);
|
103 |
-
|
104 |
-
if (empty($content) === false) {
|
105 |
-
$options .= $content;
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
if (strpos($options, 'e') !== false) {
|
110 |
-
$error = 'The Mbstring regex "e" modifier is deprecated since PHP 7.1.';
|
111 |
-
|
112 |
-
// The alternative mb_ereg_replace_callback() function is only available since 5.4.1.
|
113 |
-
if ($this->supportsBelow('5.4.1') === false) {
|
114 |
-
$error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
|
115 |
-
}
|
116 |
-
|
117 |
-
$phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
|
118 |
-
}
|
119 |
-
|
120 |
-
}//end process()
|
121 |
-
|
122 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewArrayStringDereferencingSniff.php
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewArrayStringDereferencingSniff.
|
4 |
-
*
|
5 |
-
* PHP version 5.5
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\NewArrayStringDereferencingSniff.
|
18 |
-
*
|
19 |
-
* Array and string literals can now be dereferenced directly to access individual elements and characters.
|
20 |
-
*
|
21 |
-
* PHP version 5.5
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
-
*/
|
27 |
-
class NewArrayStringDereferencingSniff extends Sniff
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Returns an array of tokens this test wants to listen for.
|
31 |
-
*
|
32 |
-
* @return array
|
33 |
-
*/
|
34 |
-
public function register()
|
35 |
-
{
|
36 |
-
return array(
|
37 |
-
T_ARRAY,
|
38 |
-
T_OPEN_SHORT_ARRAY,
|
39 |
-
T_CONSTANT_ENCAPSED_STRING,
|
40 |
-
);
|
41 |
-
}//end register()
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Processes this test, when one of its tokens is encountered.
|
45 |
-
*
|
46 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
47 |
-
* @param int $stackPtr The position of the current token in
|
48 |
-
* the stack passed in $tokens.
|
49 |
-
*
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
53 |
-
{
|
54 |
-
if ($this->supportsBelow('5.4') === false) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
|
58 |
-
$tokens = $phpcsFile->getTokens();
|
59 |
-
|
60 |
-
switch ($tokens[$stackPtr]['code']) {
|
61 |
-
case T_CONSTANT_ENCAPSED_STRING:
|
62 |
-
$type = 'string literals';
|
63 |
-
$end = $stackPtr;
|
64 |
-
break;
|
65 |
-
|
66 |
-
case T_ARRAY:
|
67 |
-
if (isset($tokens[$stackPtr]['parenthesis_closer']) === false) {
|
68 |
-
// Live coding.
|
69 |
-
return;
|
70 |
-
} else {
|
71 |
-
$type = 'arrays';
|
72 |
-
$end = $tokens[$stackPtr]['parenthesis_closer'];
|
73 |
-
}
|
74 |
-
break;
|
75 |
-
|
76 |
-
case T_OPEN_SHORT_ARRAY:
|
77 |
-
if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
|
78 |
-
// Live coding.
|
79 |
-
return;
|
80 |
-
} else {
|
81 |
-
$type = 'arrays';
|
82 |
-
$end = $tokens[$stackPtr]['bracket_closer'];
|
83 |
-
}
|
84 |
-
break;
|
85 |
-
}
|
86 |
-
|
87 |
-
if (isset($type, $end) === false) {
|
88 |
-
// Shouldn't happen, but for some reason did.
|
89 |
-
return;
|
90 |
-
}
|
91 |
-
|
92 |
-
$nextNonEmpty = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true, null, true);
|
93 |
-
|
94 |
-
if ($nextNonEmpty !== false &&
|
95 |
-
($tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET' ||
|
96 |
-
$tokens[$nextNonEmpty]['type'] === 'T_OPEN_SHORT_ARRAY') // Work around bug #1381 in PHPCS 2.8.1 and lower.
|
97 |
-
) {
|
98 |
-
$phpcsFile->addError(
|
99 |
-
'Direct array dereferencing of %s is not present in PHP version 5.4 or earlier',
|
100 |
-
$nextNonEmpty,
|
101 |
-
'Found',
|
102 |
-
array($type)
|
103 |
-
);
|
104 |
-
}
|
105 |
-
|
106 |
-
}//end process()
|
107 |
-
|
108 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php
DELETED
@@ -1,569 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewClassesSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Wim Godden <wim.godden@cu.be>
|
8 |
-
* @copyright 2013 Cu.be Solutions bvba
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
12 |
-
|
13 |
-
use PHPCompatibility\AbstractNewFeatureSniff;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* \PHPCompatibility\Sniffs\PHP\NewClassesSniff.
|
17 |
-
*
|
18 |
-
* @category PHP
|
19 |
-
* @package PHPCompatibility
|
20 |
-
* @author Wim Godden <wim.godden@cu.be>
|
21 |
-
* @copyright 2013 Cu.be Solutions bvba
|
22 |
-
*/
|
23 |
-
class NewClassesSniff extends AbstractNewFeatureSniff
|
24 |
-
{
|
25 |
-
|
26 |
-
/**
|
27 |
-
* A list of new classes, not present in older versions.
|
28 |
-
*
|
29 |
-
* The array lists : version number with false (not present) or true (present).
|
30 |
-
* If's sufficient to list the first version where the class appears.
|
31 |
-
*
|
32 |
-
* @var array(string => array(string => bool))
|
33 |
-
*/
|
34 |
-
protected $newClasses = array(
|
35 |
-
'libXMLError' => array(
|
36 |
-
'5.0' => false,
|
37 |
-
'5.1' => true,
|
38 |
-
),
|
39 |
-
|
40 |
-
'DateTime' => array(
|
41 |
-
'5.1' => false,
|
42 |
-
'5.2' => true,
|
43 |
-
),
|
44 |
-
'DateTimeZone' => array(
|
45 |
-
'5.1' => false,
|
46 |
-
'5.2' => true,
|
47 |
-
),
|
48 |
-
'RegexIterator' => array(
|
49 |
-
'5.1' => false,
|
50 |
-
'5.2' => true,
|
51 |
-
),
|
52 |
-
'RecursiveRegexIterator' => array(
|
53 |
-
'5.1' => false,
|
54 |
-
'5.2' => true,
|
55 |
-
),
|
56 |
-
|
57 |
-
'DateInterval' => array(
|
58 |
-
'5.2' => false,
|
59 |
-
'5.3' => true,
|
60 |
-
),
|
61 |
-
'DatePeriod' => array(
|
62 |
-
'5.2' => false,
|
63 |
-
'5.3' => true,
|
64 |
-
),
|
65 |
-
'Phar' => array(
|
66 |
-
'5.2' => false,
|
67 |
-
'5.3' => true,
|
68 |
-
),
|
69 |
-
'PharData' => array(
|
70 |
-
'5.2' => false,
|
71 |
-
'5.3' => true,
|
72 |
-
),
|
73 |
-
'PharFileInfo' => array(
|
74 |
-
'5.2' => false,
|
75 |
-
'5.3' => true,
|
76 |
-
),
|
77 |
-
'FilesystemIterator' => array(
|
78 |
-
'5.2' => false,
|
79 |
-
'5.3' => true,
|
80 |
-
),
|
81 |
-
'GlobIterator' => array(
|
82 |
-
'5.2' => false,
|
83 |
-
'5.3' => true,
|
84 |
-
),
|
85 |
-
'MultipleIterator' => array(
|
86 |
-
'5.2' => false,
|
87 |
-
'5.3' => true,
|
88 |
-
),
|
89 |
-
'RecursiveTreeIterator' => array(
|
90 |
-
'5.2' => false,
|
91 |
-
'5.3' => true,
|
92 |
-
),
|
93 |
-
'SplDoublyLinkedList' => array(
|
94 |
-
'5.2' => false,
|
95 |
-
'5.3' => true,
|
96 |
-
),
|
97 |
-
'SplFixedArray' => array(
|
98 |
-
'5.2' => false,
|
99 |
-
'5.3' => true,
|
100 |
-
),
|
101 |
-
'SplHeap' => array(
|
102 |
-
'5.2' => false,
|
103 |
-
'5.3' => true,
|
104 |
-
),
|
105 |
-
'SplMaxHeap' => array(
|
106 |
-
'5.2' => false,
|
107 |
-
'5.3' => true,
|
108 |
-
),
|
109 |
-
'SplMinHeap' => array(
|
110 |
-
'5.2' => false,
|
111 |
-
'5.3' => true,
|
112 |
-
),
|
113 |
-
'SplPriorityQueue' => array(
|
114 |
-
'5.2' => false,
|
115 |
-
'5.3' => true,
|
116 |
-
),
|
117 |
-
'SplQueue' => array(
|
118 |
-
'5.2' => false,
|
119 |
-
'5.3' => true,
|
120 |
-
),
|
121 |
-
'SplStack' => array(
|
122 |
-
'5.2' => false,
|
123 |
-
'5.3' => true,
|
124 |
-
),
|
125 |
-
|
126 |
-
'CallbackFilterIterator' => array(
|
127 |
-
'5.3' => false,
|
128 |
-
'5.4' => true,
|
129 |
-
),
|
130 |
-
'RecursiveCallbackFilterIterator' => array(
|
131 |
-
'5.3' => false,
|
132 |
-
'5.4' => true,
|
133 |
-
),
|
134 |
-
'ReflectionZendExtension' => array(
|
135 |
-
'5.3' => false,
|
136 |
-
'5.4' => true,
|
137 |
-
),
|
138 |
-
'SessionHandler' => array(
|
139 |
-
'5.3' => false,
|
140 |
-
'5.4' => true,
|
141 |
-
),
|
142 |
-
'SNMP' => array(
|
143 |
-
'5.3' => false,
|
144 |
-
'5.4' => true,
|
145 |
-
),
|
146 |
-
'Transliterator' => array(
|
147 |
-
'5.3' => false,
|
148 |
-
'5.4' => true,
|
149 |
-
),
|
150 |
-
'Spoofchecker' => array(
|
151 |
-
'5.3' => false,
|
152 |
-
'5.4' => true,
|
153 |
-
),
|
154 |
-
|
155 |
-
'CURLFile' => array(
|
156 |
-
'5.4' => false,
|
157 |
-
'5.5' => true,
|
158 |
-
),
|
159 |
-
'DateTimeImmutable' => array(
|
160 |
-
'5.4' => false,
|
161 |
-
'5.5' => true,
|
162 |
-
),
|
163 |
-
'IntlCalendar' => array(
|
164 |
-
'5.4' => false,
|
165 |
-
'5.5' => true,
|
166 |
-
),
|
167 |
-
'IntlGregorianCalendar' => array(
|
168 |
-
'5.4' => false,
|
169 |
-
'5.5' => true,
|
170 |
-
),
|
171 |
-
'IntlTimeZone' => array(
|
172 |
-
'5.4' => false,
|
173 |
-
'5.5' => true,
|
174 |
-
),
|
175 |
-
'IntlBreakIterator' => array(
|
176 |
-
'5.4' => false,
|
177 |
-
'5.5' => true,
|
178 |
-
),
|
179 |
-
'IntlRuleBasedBreakIterator' => array(
|
180 |
-
'5.4' => false,
|
181 |
-
'5.5' => true,
|
182 |
-
),
|
183 |
-
'IntlCodePointBreakIterator' => array(
|
184 |
-
'5.4' => false,
|
185 |
-
'5.5' => true,
|
186 |
-
),
|
187 |
-
|
188 |
-
);
|
189 |
-
|
190 |
-
/**
|
191 |
-
* A list of new Exception classes, not present in older versions.
|
192 |
-
*
|
193 |
-
* The array lists : version number with false (not present) or true (present).
|
194 |
-
* If's sufficient to list the first version where the class appears.
|
195 |
-
*
|
196 |
-
* {@internal Classes listed here do not need to be added to the $newClasses
|
197 |
-
* property as well.
|
198 |
-
* This list is automatically added to the $newClasses property
|
199 |
-
* in the `register()` method.}}
|
200 |
-
*
|
201 |
-
* @var array(string => array(string => bool))
|
202 |
-
*/
|
203 |
-
protected $newExceptions = array(
|
204 |
-
'Exception' => array(
|
205 |
-
// According to the docs introduced in PHP 5.1, but this appears to be.
|
206 |
-
// an error. Class was introduced with try/catch keywords in PHP 5.0.
|
207 |
-
'4.4' => false,
|
208 |
-
'5.0' => true,
|
209 |
-
),
|
210 |
-
'ErrorException' => array(
|
211 |
-
'5.0' => false,
|
212 |
-
'5.1' => true,
|
213 |
-
),
|
214 |
-
'BadFunctionCallException' => array(
|
215 |
-
'5.0' => false,
|
216 |
-
'5.1' => true,
|
217 |
-
),
|
218 |
-
'BadMethodCallException' => array(
|
219 |
-
'5.0' => false,
|
220 |
-
'5.1' => true,
|
221 |
-
),
|
222 |
-
'DomainException' => array(
|
223 |
-
'5.0' => false,
|
224 |
-
'5.1' => true,
|
225 |
-
),
|
226 |
-
'InvalidArgumentException' => array(
|
227 |
-
'5.0' => false,
|
228 |
-
'5.1' => true,
|
229 |
-
),
|
230 |
-
'LengthException' => array(
|
231 |
-
'5.0' => false,
|
232 |
-
'5.1' => true,
|
233 |
-
),
|
234 |
-
'LogicException' => array(
|
235 |
-
'5.0' => false,
|
236 |
-
'5.1' => true,
|
237 |
-
),
|
238 |
-
'OutOfBoundsException' => array(
|
239 |
-
'5.0' => false,
|
240 |
-
'5.1' => true,
|
241 |
-
),
|
242 |
-
'OutOfRangeException' => array(
|
243 |
-
'5.0' => false,
|
244 |
-
'5.1' => true,
|
245 |
-
),
|
246 |
-
'OverflowException' => array(
|
247 |
-
'5.0' => false,
|
248 |
-
'5.1' => true,
|
249 |
-
),
|
250 |
-
'RangeException' => array(
|
251 |
-
'5.0' => false,
|
252 |
-
'5.1' => true,
|
253 |
-
),
|
254 |
-
'RuntimeException' => array(
|
255 |
-
'5.0' => false,
|
256 |
-
'5.1' => true,
|
257 |
-
),
|
258 |
-
'UnderflowException' => array(
|
259 |
-
'5.0' => false,
|
260 |
-
'5.1' => true,
|
261 |
-
),
|
262 |
-
'UnexpectedValueException' => array(
|
263 |
-
'5.0' => false,
|
264 |
-
'5.1' => true,
|
265 |
-
),
|
266 |
-
'DOMException' => array(
|
267 |
-
'4.4' => false,
|
268 |
-
'5.0' => true,
|
269 |
-
),
|
270 |
-
'mysqli_sql_exception' => array(
|
271 |
-
'4.4' => false,
|
272 |
-
'5.0' => true,
|
273 |
-
),
|
274 |
-
'PDOException' => array(
|
275 |
-
'5.0' => false,
|
276 |
-
'5.1' => true,
|
277 |
-
),
|
278 |
-
'ReflectionException' => array(
|
279 |
-
'4.4' => false,
|
280 |
-
'5.0' => true,
|
281 |
-
),
|
282 |
-
'SoapFault' => array(
|
283 |
-
'4.4' => false,
|
284 |
-
'5.0' => true,
|
285 |
-
),
|
286 |
-
|
287 |
-
'PharException' => array(
|
288 |
-
'5.2' => false,
|
289 |
-
'5.3' => true,
|
290 |
-
),
|
291 |
-
|
292 |
-
'SNMPException' => array(
|
293 |
-
'5.3' => false,
|
294 |
-
'5.4' => true,
|
295 |
-
),
|
296 |
-
|
297 |
-
'IntlException' => array(
|
298 |
-
'5.5.0' => false,
|
299 |
-
'5.5.1' => true,
|
300 |
-
),
|
301 |
-
|
302 |
-
'Error' => array(
|
303 |
-
'5.6' => false,
|
304 |
-
'7.0' => true,
|
305 |
-
),
|
306 |
-
'ArithmeticError' => array(
|
307 |
-
'5.6' => false,
|
308 |
-
'7.0' => true,
|
309 |
-
),
|
310 |
-
'AssertionError' => array(
|
311 |
-
'5.6' => false,
|
312 |
-
'7.0' => true,
|
313 |
-
),
|
314 |
-
'DivisionByZeroError' => array(
|
315 |
-
'5.6' => false,
|
316 |
-
'7.0' => true,
|
317 |
-
),
|
318 |
-
'ParseError' => array(
|
319 |
-
'5.6' => false,
|
320 |
-
'7.0' => true,
|
321 |
-
),
|
322 |
-
'TypeError' => array(
|
323 |
-
'5.6' => false,
|
324 |
-
'7.0' => true,
|
325 |
-
),
|
326 |
-
'UI\Exception\InvalidArgumentException' => array(
|
327 |
-
'5.6' => false,
|
328 |
-
'7.0' => true,
|
329 |
-
),
|
330 |
-
'UI\Exception\RuntimeException' => array(
|
331 |
-
'5.6' => false,
|
332 |
-
'7.0' => true,
|
333 |
-
),
|
334 |
-
|
335 |
-
);
|
336 |
-
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Returns an array of tokens this test wants to listen for.
|
340 |
-
*
|
341 |
-
* @return array
|
342 |
-
*/
|
343 |
-
public function register()
|
344 |
-
{
|
345 |
-
// Handle case-insensitivity of class names.
|
346 |
-
$this->newClasses = $this->arrayKeysToLowercase($this->newClasses);
|
347 |
-
$this->newExceptions = $this->arrayKeysToLowercase($this->newExceptions);
|
348 |
-
|
349 |
-
// Add the Exception classes to the Classes list.
|
350 |
-
$this->newClasses = array_merge($this->newClasses, $this->newExceptions);
|
351 |
-
|
352 |
-
$targets = array(
|
353 |
-
T_NEW,
|
354 |
-
T_CLASS,
|
355 |
-
T_DOUBLE_COLON,
|
356 |
-
T_FUNCTION,
|
357 |
-
T_CLOSURE,
|
358 |
-
T_CATCH,
|
359 |
-
);
|
360 |
-
|
361 |
-
if (defined('T_ANON_CLASS')) {
|
362 |
-
$targets[] = constant('T_ANON_CLASS');
|
363 |
-
}
|
364 |
-
|
365 |
-
return $targets;
|
366 |
-
|
367 |
-
}//end register()
|
368 |
-
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Processes this test, when one of its tokens is encountered.
|
372 |
-
*
|
373 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
374 |
-
* @param int $stackPtr The position of the current token in
|
375 |
-
* the stack passed in $tokens.
|
376 |
-
*
|
377 |
-
* @return void
|
378 |
-
*/
|
379 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
380 |
-
{
|
381 |
-
$tokens = $phpcsFile->getTokens();
|
382 |
-
|
383 |
-
switch ($tokens[$stackPtr]['type']) {
|
384 |
-
case 'T_FUNCTION':
|
385 |
-
case 'T_CLOSURE':
|
386 |
-
$this->processFunctionToken($phpcsFile, $stackPtr);
|
387 |
-
break;
|
388 |
-
|
389 |
-
case 'T_CATCH':
|
390 |
-
$this->processCatchToken($phpcsFile, $stackPtr);
|
391 |
-
break;
|
392 |
-
|
393 |
-
default:
|
394 |
-
$this->processSingularToken($phpcsFile, $stackPtr);
|
395 |
-
break;
|
396 |
-
}
|
397 |
-
|
398 |
-
}//end process()
|
399 |
-
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Processes this test for when a token resulting in a singular class name is encountered.
|
403 |
-
*
|
404 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
405 |
-
* @param int $stackPtr The position of the current token in
|
406 |
-
* the stack passed in $tokens.
|
407 |
-
*
|
408 |
-
* @return void
|
409 |
-
*/
|
410 |
-
private function processSingularToken(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
411 |
-
{
|
412 |
-
$tokens = $phpcsFile->getTokens();
|
413 |
-
$FQClassName = '';
|
414 |
-
|
415 |
-
if ($tokens[$stackPtr]['type'] === 'T_NEW') {
|
416 |
-
$FQClassName = $this->getFQClassNameFromNewToken($phpcsFile, $stackPtr);
|
417 |
-
|
418 |
-
} elseif ($tokens[$stackPtr]['type'] === 'T_CLASS' || $tokens[$stackPtr]['type'] === 'T_ANON_CLASS') {
|
419 |
-
$FQClassName = $this->getFQExtendedClassName($phpcsFile, $stackPtr);
|
420 |
-
|
421 |
-
} elseif ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') {
|
422 |
-
$FQClassName = $this->getFQClassNameFromDoubleColonToken($phpcsFile, $stackPtr);
|
423 |
-
}
|
424 |
-
|
425 |
-
if ($FQClassName === '') {
|
426 |
-
return;
|
427 |
-
}
|
428 |
-
|
429 |
-
$className = substr($FQClassName, 1); // Remove global namespace indicator.
|
430 |
-
$classNameLc = strtolower($className);
|
431 |
-
|
432 |
-
if (isset($this->newClasses[$classNameLc]) === false) {
|
433 |
-
return;
|
434 |
-
}
|
435 |
-
|
436 |
-
$itemInfo = array(
|
437 |
-
'name' => $className,
|
438 |
-
'nameLc' => $classNameLc,
|
439 |
-
);
|
440 |
-
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
441 |
-
|
442 |
-
}//end processSingularToken()
|
443 |
-
|
444 |
-
|
445 |
-
/**
|
446 |
-
* Processes this test for when a function token is encountered.
|
447 |
-
*
|
448 |
-
* - Detect new classes when used as a type hint.
|
449 |
-
*
|
450 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
451 |
-
* @param int $stackPtr The position of the current token in
|
452 |
-
* the stack passed in $tokens.
|
453 |
-
*
|
454 |
-
* @return void
|
455 |
-
*/
|
456 |
-
private function processFunctionToken(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
457 |
-
{
|
458 |
-
// Retrieve typehints stripped of global NS indicator and/or nullable indicator.
|
459 |
-
$typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
|
460 |
-
if (empty($typeHints) || is_array($typeHints) === false) {
|
461 |
-
return;
|
462 |
-
}
|
463 |
-
|
464 |
-
foreach ($typeHints as $hint) {
|
465 |
-
|
466 |
-
$typeHintLc = strtolower($hint);
|
467 |
-
|
468 |
-
if (isset($this->newClasses[$typeHintLc]) === true) {
|
469 |
-
$itemInfo = array(
|
470 |
-
'name' => $hint,
|
471 |
-
'nameLc' => $typeHintLc,
|
472 |
-
);
|
473 |
-
$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
|
474 |
-
}
|
475 |
-
}
|
476 |
-
}
|
477 |
-
|
478 |
-
|
479 |
-
/**
|
480 |
-
* Processes this test for when a catch token is encountered.
|
481 |
-
*
|
482 |
-
* - Detect exceptions when used in a catch statement.
|
483 |
-
*
|
484 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
485 |
-
* @param int $stackPtr The position of the current token in
|
486 |
-
* the stack passed in $tokens.
|
487 |
-
*
|
488 |
-
* @return void
|
489 |
-
*/
|
490 |
-
private function processCatchToken(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
491 |
-
{
|
492 |
-
$tokens = $phpcsFile->getTokens();
|
493 |
-
|
494 |
-
// Bow out during live coding.
|
495 |
-
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
|
496 |
-
return;
|
497 |
-
}
|
498 |
-
|
499 |
-
$opener = $tokens[$stackPtr]['parenthesis_opener'];
|
500 |
-
$closer = ($tokens[$stackPtr]['parenthesis_closer'] + 1);
|
501 |
-
$name = '';
|
502 |
-
$listen = array(
|
503 |
-
// Parts of a (namespaced) class name.
|
504 |
-
T_STRING => true,
|
505 |
-
T_NS_SEPARATOR => true,
|
506 |
-
// End/split tokens.
|
507 |
-
T_VARIABLE => false,
|
508 |
-
T_BITWISE_OR => false,
|
509 |
-
T_CLOSE_CURLY_BRACKET => false, // Shouldn't be needed as we expect a var before this.
|
510 |
-
);
|
511 |
-
|
512 |
-
for ($i = ($opener + 1); $i < $closer; $i++) {
|
513 |
-
if (isset($listen[$tokens[$i]['code']]) === false) {
|
514 |
-
continue;
|
515 |
-
}
|
516 |
-
|
517 |
-
if ($listen[$tokens[$i]['code']] === true) {
|
518 |
-
$name .= $tokens[$i]['content'];
|
519 |
-
continue;
|
520 |
-
} else {
|
521 |
-
if (empty($name) === true) {
|
522 |
-
// Weird, we should have a name by the time we encounter a variable or |.
|
523 |
-
// So this may be the closer.
|
524 |
-
continue;
|
525 |
-
}
|
526 |
-
|
527 |
-
$name = ltrim($name, '\\');
|
528 |
-
$nameLC = strtolower($name);
|
529 |
-
|
530 |
-
if (isset($this->newExceptions[$nameLC]) === true) {
|
531 |
-
$itemInfo = array(
|
532 |
-
'name' => $name,
|
533 |
-
'nameLc' => $nameLC,
|
534 |
-
);
|
535 |
-
$this->handleFeature($phpcsFile, $i, $itemInfo);
|
536 |
-
}
|
537 |
-
|
538 |
-
// Reset for a potential multi-catch.
|
539 |
-
$name = '';
|
540 |
-
}
|
541 |
-
}
|
542 |
-
}
|
543 |
-
|
544 |
-
|
545 |
-
/**
|
546 |
-
* Get the relevant sub-array for a specific item from a multi-dimensional array.
|
547 |
-
*
|
548 |
-
* @param array $itemInfo Base information about the item.
|
549 |
-
*
|
550 |
-
* @return array Version and other information about the item.
|
551 |
-
*/
|
552 |
-
public function getItemArray(array $itemInfo)
|
553 |
-
{
|
554 |
-
return $this->newClasses[$itemInfo['nameLc']];
|
555 |
-
}
|
556 |
-
|
557 |
-
|
558 |
-
/**
|
559 |
-
* Get the error message template for this sniff.
|
560 |
-
*
|
561 |
-
* @return string
|
562 |
-
*/
|
563 |
-
protected function getErrorMsgTemplate()
|
564 |
-
{
|
565 |
-
return 'The built-in class '.parent::getErrorMsgTemplate();
|
566 |
-
}
|
567 |
-
|
568 |
-
|
569 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php
DELETED
@@ -1,187 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewClosure.
|
4 |
-
*
|
5 |
-
* PHP version 5.3
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Wim Godden <wim@cu.be>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\NewClosure.
|
18 |
-
*
|
19 |
-
* Closures are available since PHP 5.3
|
20 |
-
*
|
21 |
-
* PHP version 5.3
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Wim Godden <wim@cu.be>
|
26 |
-
*/
|
27 |
-
class NewClosureSniff extends Sniff
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Returns an array of tokens this test wants to listen for.
|
31 |
-
*
|
32 |
-
* @return array
|
33 |
-
*/
|
34 |
-
public function register()
|
35 |
-
{
|
36 |
-
return array(T_CLOSURE);
|
37 |
-
|
38 |
-
}//end register()
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes this test, when one of its tokens is encountered.
|
42 |
-
*
|
43 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
44 |
-
* @param int $stackPtr The position of the current token
|
45 |
-
* in the stack passed in $tokens.
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
50 |
-
{
|
51 |
-
if ($this->supportsBelow('5.2')) {
|
52 |
-
$phpcsFile->addError(
|
53 |
-
'Closures / anonymous functions are not available in PHP 5.2 or earlier',
|
54 |
-
$stackPtr,
|
55 |
-
'Found'
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
$isStatic = $this->isClosureStatic($phpcsFile, $stackPtr);
|
60 |
-
$usesThis = $this->findThisUsageInClosure($phpcsFile, $stackPtr);
|
61 |
-
|
62 |
-
if ($this->supportsBelow('5.3')) {
|
63 |
-
|
64 |
-
/*
|
65 |
-
* Closures can only be declared as static since PHP 5.4.
|
66 |
-
*/
|
67 |
-
if ($isStatic === true) {
|
68 |
-
$phpcsFile->addError(
|
69 |
-
'Closures / anonymous functions could not be declared as static in PHP 5.3 or earlier',
|
70 |
-
$stackPtr,
|
71 |
-
'StaticFound'
|
72 |
-
);
|
73 |
-
}
|
74 |
-
|
75 |
-
/*
|
76 |
-
* Closures declared within classes only have access to $this since PHP 5.4.
|
77 |
-
*/
|
78 |
-
if ($usesThis !== false) {
|
79 |
-
$thisFound = $usesThis;
|
80 |
-
do {
|
81 |
-
$phpcsFile->addError(
|
82 |
-
'Closures / anonymous functions did not have access to $this in PHP 5.3 or earlier',
|
83 |
-
$thisFound,
|
84 |
-
'ThisFound'
|
85 |
-
);
|
86 |
-
|
87 |
-
$thisFound = $this->findThisUsageInClosure($phpcsFile, $stackPtr, ($thisFound + 1));
|
88 |
-
|
89 |
-
} while ($thisFound !== false);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
/*
|
94 |
-
* Check for correct usage.
|
95 |
-
*/
|
96 |
-
if ($this->supportsAbove('5.4') && $usesThis !== false) {
|
97 |
-
|
98 |
-
$thisFound = $usesThis;
|
99 |
-
|
100 |
-
do {
|
101 |
-
/*
|
102 |
-
* Closures only have access to $this if not declared as static.
|
103 |
-
*/
|
104 |
-
if ($isStatic === true) {
|
105 |
-
$phpcsFile->addError(
|
106 |
-
'Closures / anonymous functions declared as static do not have access to $this',
|
107 |
-
$thisFound,
|
108 |
-
'ThisFoundInStatic'
|
109 |
-
);
|
110 |
-
}
|
111 |
-
|
112 |
-
/*
|
113 |
-
* Closures only have access to $this if used within a class context.
|
114 |
-
*/
|
115 |
-
elseif ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
|
116 |
-
$phpcsFile->addWarning(
|
117 |
-
'Closures / anonymous functions only have access to $this if used within a class or when bound to an object using bindTo(). Please verify.',
|
118 |
-
$thisFound,
|
119 |
-
'ThisFoundOutsideClass'
|
120 |
-
);
|
121 |
-
}
|
122 |
-
|
123 |
-
$thisFound = $this->findThisUsageInClosure($phpcsFile, $stackPtr, ($thisFound + 1));
|
124 |
-
|
125 |
-
} while ($thisFound !== false);
|
126 |
-
}
|
127 |
-
|
128 |
-
}//end process()
|
129 |
-
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Check whether the closure is declared as static.
|
133 |
-
*
|
134 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
135 |
-
* @param int $stackPtr The position of the current token
|
136 |
-
* in the stack passed in $tokens.
|
137 |
-
*
|
138 |
-
* @return bool
|
139 |
-
*/
|
140 |
-
protected function isClosureStatic(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
141 |
-
{
|
142 |
-
$tokens = $phpcsFile->getTokens();
|
143 |
-
$prevToken = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
144 |
-
|
145 |
-
return ($prevToken !== false && $tokens[$prevToken]['code'] === T_STATIC);
|
146 |
-
}
|
147 |
-
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Check if the code within a closure uses the $this variable.
|
151 |
-
*
|
152 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
153 |
-
* @param int $stackPtr The position of the closure token.
|
154 |
-
* @param int $startToken Optional. The position within the closure to continue searching from.
|
155 |
-
*
|
156 |
-
* @return int|false The stackPtr to the first $this usage if found or false if
|
157 |
-
* $this is not used or usage of $this could not reliably be determined.
|
158 |
-
*/
|
159 |
-
protected function findThisUsageInClosure(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $startToken = null)
|
160 |
-
{
|
161 |
-
$tokens = $phpcsFile->getTokens();
|
162 |
-
|
163 |
-
if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
|
164 |
-
// Live coding or parse error.
|
165 |
-
return false;
|
166 |
-
}
|
167 |
-
|
168 |
-
// Make sure the optional $startToken is valid.
|
169 |
-
if (isset($startToken) === true && (isset($tokens[$startToken]) === false || $startToken >= $tokens[$stackPtr]['scope_closer'])) {
|
170 |
-
return false;
|
171 |
-
}
|
172 |
-
|
173 |
-
$start = ($tokens[$stackPtr]['scope_opener'] + 1);
|
174 |
-
if (isset($startToken) === true) {
|
175 |
-
$start = $startToken;
|
176 |
-
}
|
177 |
-
|
178 |
-
return $phpcsFile->findNext(
|
179 |
-
T_VARIABLE,
|
180 |
-
$start,
|
181 |
-
$tokens[$stackPtr]['scope_closer'],
|
182 |
-
false,
|
183 |
-
'$this'
|
184 |
-
);
|
185 |
-
}
|
186 |
-
|
187 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewConstVisibility.
|
4 |
-
*
|
5 |
-
* PHP version 7.1
|
6 |
-
*
|
7 |
-
* @category PHP
|
8 |
-
* @package PHPCompatibility
|
9 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
13 |
-
|
14 |
-
use PHPCompatibility\Sniff;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* \PHPCompatibility\Sniffs\PHP\NewConstVisibility.
|
18 |
-
*
|
19 |
-
* Visibility for class constants is available since PHP 7.1.
|
20 |
-
*
|
21 |
-
* PHP version 7.1
|
22 |
-
*
|
23 |
-
* @category PHP
|
24 |
-
* @package PHPCompatibility
|
25 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
26 |
-
*/
|
27 |
-
class NewConstVisibilitySniff extends Sniff
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Returns an array of tokens this test wants to listen for.
|
31 |
-
*
|
32 |
-
* @return array
|
33 |
-
*/
|
34 |
-
public function register()
|
35 |
-
{
|
36 |
-
return array(T_CONST);
|
37 |
-
|
38 |
-
}//end register()
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes this test, when one of its tokens is encountered.
|
42 |
-
*
|
43 |
-
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
44 |
-
* @param int $stackPtr The position of the current token
|
45 |
-
* in the stack passed in $tokens.
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
50 |
-
{
|
51 |
-
if ($this->supportsBelow('7.0') === false) {
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
$tokens = $phpcsFile->getTokens();
|
56 |
-
$prevToken = $phpcsFile->findPrevious(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
|
57 |
-
|
58 |
-
// Is the previous token a visibility indicator ?
|
59 |
-
if ($prevToken === false || in_array($tokens[$prevToken]['code'], \PHP_CodeSniffer_Tokens::$scopeModifiers, true) === false) {
|
60 |
-
return;
|
61 |
-
}
|
62 |
-
|
63 |
-
// Is this a class constant ?
|
64 |
-
if ($this->isClassConstant($phpcsFile, $stackPtr) === false) {
|
65 |
-
// This may be a constant declaration in the global namespace with visibility,
|
66 |
-
// but that would throw a parse error, i.e. not our concern.
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
|
70 |
-
$phpcsFile->addError(
|
71 |
-
'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"',
|
72 |
-
$stackPtr,
|
73 |
-
'Found',
|
74 |
-
array($tokens[$prevToken]['content'])
|
75 |
-
);
|
76 |
-
|
77 |
-
}//end process()
|
78 |
-
|
79 |
-
}//end class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wimg/php-compatibility/PHPCompatibility/Sniffs/PHP/NewConstantsSniff.php
DELETED
@@ -1,2998 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* \PHPCompatibility\Sniffs\PHP\NewConstantsSniff.
|
4 |
-
*
|
5 |
-
* @category PHP
|
6 |
-
* @package PHPCompatibility
|
7 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
8 |
-
*/
|
9 |
-
|
10 |
-
namespace PHPCompatibility\Sniffs\PHP;
|
11 |
-
|
12 |
-
use PHPCompatibility\AbstractNewFeatureSniff;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* \PHPCompatibility\Sniffs\PHP\NewConstantsSniff.
|
16 |
-
*
|
17 |
-
* @category PHP
|
18 |
-
* @package PHPCompatibility
|
19 |
-
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
|
20 |
-
*/
|
21 |
-
class NewConstantsSniff extends AbstractNewFeatureSniff
|
22 |
-
{
|
23 |
-
|
24 |
-
/**
|
25 |
-
* A list of new PHP Constants, not present in older versions.
|
26 |
-
*
|
27 |
-
* The array lists : version number with false (not present) or true (present).
|
28 |
-
* If's sufficient to list the first version where the constant appears.
|
29 |
-
*
|
30 |
-
* Note: PHP Constants are case-sensitive!
|
31 |
-
*
|
32 |
-
* @var array(string => array(string => bool|string|null))
|
33 |
-
*/
|
34 |
-
protected $newConstants = array(
|
35 |
-
'E_STRICT' => array(
|
36 |
-
'4.4' => false,
|
37 |
-
'5.0' => true
|
38 |
-
),
|
39 |
-
// Curl:
|
40 |
-
'CURLOPT_FTP_USE_EPRT' => array(
|
41 |
-
'4.4' => false,
|
42 |
-
'5.0' => true
|
43 |
-
),
|
44 |
-
'CURLOPT_NOSIGNAL' => array(
|
45 |
-
'4.4' => false,
|
46 |
-
'5.0' => true
|
47 |
-
),
|
48 |
-
'CURLOPT_UNRESTRICTED_AUTH' => array(
|
49 |
-
'4.4' => false,
|
50 |
-
'5.0' => true
|
51 |
-
),
|
52 |
-
'CURLOPT_BUFFERSIZE' => array(
|
53 |
-
'4.4' => false,
|
54 |
-
'5.0' => true
|
55 |
-
),
|
56 |
-
'CURLOPT_HTTPAUTH' => array(
|
57 |
-
'4.4' => false,
|
58 |
-
'5.0' => true
|
59 |
-
),
|
60 |
-
'CURLOPT_PROXYPORT' => array(
|
61 |
-
'4.4' => false,
|
62 |
-
'5.0' => true
|
63 |
-
),
|
64 |
-
'CURLOPT_PROXYTYPE' => array(
|
65 |
-
'4.4' => false,
|
66 |
-
'5.0' => true
|
67 |
-
),
|
68 |
-
'CURLOPT_SSLCERTTYPE' => array(
|
69 |
-
'4.4' => false,
|
70 |
-
'5.0' => true
|
71 |
-
),
|
72 |
-
'CURLOPT_HTTP200ALIASES' => array(
|
73 |
-
'4.4' => false,
|
74 |
-
'5.0' => true
|
75 |
-
),
|
76 |
-
// OpenSSL:
|
77 |
-
'OPENSSL_ALGO_MD2' => array(
|
78 |
-
'4.4' => false,
|
79 |
-
'5.0' => true
|
80 |
-
),
|
81 |
-
'OPENSSL_ALGO_MD4' => array(
|
82 |
-
'4.4' => false,
|
83 |
-
'5.0' => true
|
84 |
-
),
|
85 |
-
'OPENSSL_ALGO_MD5' => array(
|
86 |
-
'4.4' => false,
|
87 |
-
'5.0' => true
|
88 |
-
),
|
89 |
-
'OPENSSL_ALGO_SHA1' => array(
|
90 |
-
'4.4' => false,
|
91 |
-
'5.0' => true
|
92 |
-
),
|
93 |
-
'OPENSSL_ALGO_DSS1' => array(
|
94 |
-
'4.4' => false,
|
95 |
-
'5.0' => true
|
96 |
-
),
|
97 |
-
// Tokenizer:
|
98 |
-
'T_ABSTRACT' => array(
|
99 |
-
'4.4' => false,
|
100 |
-
'5.0' => true
|
101 |
-
),
|
102 |
-
'T_CATCH' => array(
|
103 |
-
'4.4' => false,
|
104 |
-
'5.0' => true
|
105 |
-
),
|
106 |
-
|
107 |
-
'SORT_LOCALE_STRING' => array(
|
108 |
-
'5.0.1' => false,
|
109 |
-
'5.0.2' => true
|
110 |
-
),
|
111 |
-
'PHP_EOL' => array(
|
112 |
-
'5.0.1' => false,
|
113 |
-
'5.0.2' => true
|
114 |
-
),
|
115 |
-
|
116 |
-
'PHP_INT_MAX' => array(
|
117 |
-
'5.0.4' => false,
|
118 |
-
'5.0.5' => true
|
119 |
-
),
|
120 |
-
'PHP_INT_SIZE' => array(
|
121 |
-
'5.0.4' => false,
|
122 |
-
'5.0.5' => true
|
123 |
-
),
|
124 |
-
|
125 |
-
'__COMPILER_HALT_OFFSET__' => array(
|
126 |
-
'5.0' => false,
|
127 |
-
'5.1' => true
|
128 |
-
),
|
129 |
-
'GLOB_ERR' => array(
|
130 |
-
'5.0' => false,
|
131 |
-
'5.1' => true
|
132 |
-
),
|
133 |
-
// Curl:
|
134 |
-
'CURLOPT_AUTOREFERER' => array(
|
135 |
-
'5.0' => false,
|
136 |
-
'5.1' => true
|
137 |
-
),
|
138 |
-
'CURLOPT_BINARYTRANSFER' => array(
|
139 |
-
'5.0' => false,
|
140 |
-
'5.1' => true
|
141 |
-
),
|
142 |
-
'CURLOPT_COOKIESESSION' => array(
|
143 |
-
'5.0' => false,
|
144 |
-
'5.1' => true
|
145 |
-
),
|
146 |
-
'CURLOPT_FTPSSLAUTH' => array(
|
147 |
-
'5.0' => false,
|
148 |
-
'5.1' => true
|
149 |
-
),
|
150 |
-
'CURLOPT_PROXYAUTH' => array(
|
151 |
-
'5.0' => false,
|
152 |
-
'5.1' => true
|
153 |
-
),
|
154 |
-
'CURLOPT_TIMECONDITION' => array(
|
155 |
-
'5.0' => false,
|
156 |
-
'5.1' => true
|
157 |
-
),
|
158 |
-
// POSIX:
|
159 |
-
'POSIX_F_OK' => array(
|
160 |
-
'5.0' => false,
|
161 |
-
'5.1' => true
|
162 |
-
),
|
163 |
-
'POSIX_R_OK' => array(
|
164 |
-
'5.0' => false,
|
165 |
-
'5.1' => true
|
166 |
-
),
|
167 |
-
'POSIX_W_OK' => array(
|
168 |
-
'5.0' => false,
|
169 |
-
'5.1' => true
|
170 |
-
),
|
171 |
-
'POSIX_X_OK' => array(
|
172 |
-
'5.0' => false,
|
173 |
-
'5.1' => true
|
174 |
-
),
|
175 |
-
'POSIX_S_IFBLK' => array(
|
176 |
-
'5.0' => false,
|
177 |
-
'5.1' => true
|
178 |
-
),
|
179 |
-
'POSIX_S_IFCHR' => array(
|
180 |
-
'5.0' => false,
|
181 |
-
'5.1' => true
|
182 |
-
),
|
183 |
-
'POSIX_S_IFIFO' => array(
|
184 |
-
'5.0' => false,
|
185 |
-
'5.1' => true
|
186 |
-
),
|
187 |
-
'POSIX_S_IFREG' => array(
|
188 |
-
'5.0' => false,
|
189 |
-
'5.1' => true
|
190 |
-
),
|
191 |
-
'POSIX_S_IFSOCK' => array(
|
192 |
-
'5.0' => false,
|
193 |
-
'5.1' => true
|
194 |
-
),
|
195 |
-
// Streams:
|
196 |
-
'STREAM_IPPROTO_ICMP' => array(
|
197 |
-
'5.0' => false,
|
198 |
-
'5.1' => true
|
199 |
-
),
|
200 |
-
'STREAM_IPPROTO_IP' => array(
|
201 |
-
'5.0' => false,
|
202 |
-
'5.1' => true
|
203 |
-
),
|
204 |
-
'STREAM_IPPROTO_RAW' => array(
|
205 |
-
'5.0' => false,
|
206 |
-
'5.1' => true
|
207 |
-
),
|
208 |
-
'STREAM_IPPROTO_TCP' => array(
|
209 |
-
'5.0' => false,
|
210 |
-
'5.1' => true
|
211 |
-
),
|
212 |
-
'STREAM_IPPROTO_UDP' => array(
|
213 |
-
'5.0' => false,
|
214 |
-
'5.1' => true
|
215 |
-
),
|
216 |
-
'STREAM_PF_INET' => array(
|
217 |
-
'5.0' => false,
|
218 |
-
'5.1' => true
|
219 |
-
),
|
220 |
-
'STREAM_PF_INET6' => array(
|
221 |
-
'5.0' => false,
|
222 |
-
'5.1' => true
|
223 |
-
),
|
224 |
-
'STREAM_PF_UNIX' => array(
|
225 |
-
'5.0' => false,
|
226 |
-
'5.1' => true
|
227 |
-
),
|
228 |
-
'STREAM_SOCK_DGRAM' => array(
|
229 |
-
'5.0' => false,
|
230 |
-
'5.1' => true
|
231 |
-
),
|
232 |
-
'STREAM_SOCK_RAW' => array(
|
233 |
-
'5.0' => false,
|
234 |
-
'5.1' => true
|
235 |
-
),
|
236 |
-
'STREAM_SOCK_RDM' => array(
|
237 |
-
'5.0' => false,
|
238 |
-
'5.1' => true
|
239 |
-
),
|
240 |
-
'STREAM_SOCK_SEQPACKET' => array(
|
241 |
-
'5.0' => false,
|
242 |
-
'5.1' => true
|
243 |
-
),
|
244 |
-
'STREAM_SOCK_STREAM' => array(
|
245 |
-
'5.0' => false,
|
246 |
-
'5.1' => true
|
247 |
-
),
|
248 |
-
// Tokenizer:
|
249 |
-
'T_HALT_COMPILER' => array(
|
250 |
-
'5.0' => false,
|
251 |
-
'5.1' => true
|
252 |
-
),
|
253 |
-
|
254 |
-
// Date/Time:
|
255 |
-
'DATE_ATOM' => array(
|
256 |
-
'5.1.0' => false,
|
257 |
-
'5.1.1' => true
|
258 |
-
),
|
259 |
-
'DATE_COOKIE' => array(
|
260 |
-
'5.1.0' => false,
|
261 |
-
'5.1.1' => true
|
262 |
-
),
|
263 |
-
'DATE_ISO8601' => array(
|
264 |
-
'5.1.0' => false,
|
265 |
-
'5.1.1' => true
|
266 |
-
),
|
267 |
-
'DATE_RFC822' => array(
|
268 |
-
'5.1.0' => false,
|
269 |
-
'5.1.1' => true
|
270 |
-
),
|
271 |
-
'DATE_RFC850' => array(
|
272 |
-
'5.1.0' => false,
|
273 |
-
'5.1.1' => true
|
274 |
-
),
|
275 |
-
'DATE_RFC1036' => array(
|
276 |
-
'5.1.0' => false,
|
277 |
-
'5.1.1' => true
|
278 |
-
),
|
279 |
-
'DATE_RFC1123' => array(
|
280 |
-
'5.1.0' => false,
|
281 |
-
'5.1.1' => true
|
282 |
-
),
|
283 |
-
'DATE_RFC2822' => array(
|
284 |
-
'5.1.0' => false,
|
285 |
-
'5.1.1' => true
|
286 |
-
),
|
287 |
-
'DATE_RFC3339' => array(
|
288 |
-
'5.1.0' => false,
|
289 |
-
'5.1.1' => true
|
290 |
-
),
|
291 |
-
'DATE_RSS' => array(
|
292 |
-
'5.1.0' => false,
|
293 |
-
'5.1.1' => true
|
294 |
-
),
|
295 |
-
'DATE_W3C' => array(
|
296 |
-
'5.1.0' => false,
|
297 |
-
'5.1.1' => true
|
298 |
-
),
|
299 |
-
|
300 |
-
// Date/Time:
|
301 |
-
'SUNFUNCS_RET_TIMESTAMP' => array(
|
302 |
-
'5.1.1' => false,
|
303 |
-
'5.1.2' => true
|
304 |
-
),
|
305 |
-
'SUNFUNCS_RET_STRING' => array(
|
306 |
-
'5.1.1' => false,
|
307 |
-
'5.1.2' => true
|
308 |
-
),
|
309 |
-
'SUNFUNCS_RET_DOUBLE' => array(
|
310 |
-
'5.1.1' => false,
|
311 |
-
'5.1.2' => true
|
312 |
-
),
|
313 |
-
// XSL:
|
314 |
-
'LIBXSLT_VERSION' => array(
|
315 |
-
'5.1.1' => false,
|
316 |
-
'5.1.2' => true
|
317 |
-
),
|
318 |
-
'LIBXSLT_DOTTED_VERSION' => array(
|
319 |
-
'5.1.1' => false,
|
320 |
-
'5.1.2' => true
|
321 |
-
),
|
322 |
-
'LIBEXSLT_VERSION' => array(
|
323 |
-
'5.1.1' => false,
|
324 |
-
'5.1.2' => true
|
325 |
-
),
|
326 |
-
'LIBEXSLT_DOTTED_VERSION' => array(
|
327 |
-
'5.1.1' => false,
|
328 |
-
'5.1.2' => true
|
329 |
-
),
|
330 |
-
// URL:
|
331 |
-
'PHP_URL_SCHEME' => array(
|
332 |
-
'5.1.1' => false,
|
333 |
-
'5.1.2' => true
|
334 |
-
),
|
335 |
-
'PHP_URL_HOST' => array(
|
336 |
-
'5.1.1' => false,
|
337 |
-
'5.1.2' => true
|
338 |
-
),
|
339 |
-
'PHP_URL_PORT' => array(
|
340 |
-
'5.1.1' => false,
|
341 |
-
'5.1.2' => true
|
342 |
-
),
|
343 |
-
'PHP_URL_USER' => array(
|
344 |
-
'5.1.1' => false,
|
345 |
-
'5.1.2' => true
|
346 |
-
),
|
347 |
-
'PHP_URL_PASS' => array(
|
348 |
-
'5.1.1' => false,
|
349 |
-
'5.1.2' => true
|
350 |
-
),
|
351 |
-
'PHP_URL_PATH' => array(
|
352 |
-
'5.1.1' => false,
|
353 |
-
'5.1.2' => true
|
354 |
-
),
|
355 |
-
'PHP_URL_QUERY' => array(
|
356 |
-
'5.1.1' => false,
|
357 |
-
'5.1.2' => true
|
358 |
-
),
|
359 |
-
'PHP_URL_FRAGMENT' => array(
|
360 |
-
'5.1.1' => false,
|
361 |
-
'5.1.2' => true
|
362 |
-
),
|
363 |
-
'PHP_QUERY_RFC1738' => array(
|
364 |
-
'5.1.1' => false,
|
365 |
-
'5.1.2' => true
|
366 |
-
),
|
367 |
-
'PHP_QUERY_RFC3986' => array(
|
368 |
-
'5.1.1' => false,
|
369 |
-
'5.1.2' => true
|
370 |
-
),
|
371 |
-
|
372 |
-
// Curl:
|
373 |
-
'CURLINFO_HEADER_OUT' => array(
|
374 |
-
'5.1.2' => false,
|
375 |
-
'5.1.3' => true
|
376 |
-
),
|
377 |
-
|
378 |
-
// Core:
|
379 |
-
'E_RECOVERABLE_ERROR' => array(
|
380 |
-
'5.1' => false,
|
381 |
-
'5.2' => true
|
382 |
-
),
|
383 |
-
// Math:
|
384 |
-
'M_EULER' => array(
|
385 |
-
'5.1' => false,
|
386 |
-
'5.2' => true
|
387 |
-
),
|
388 |
-
'M_LNPI' => array(
|
389 |
-
'5.1' => false,
|
390 |
-
'5.2' => true
|
391 |
-
),
|
392 |
-
'M_SQRT3' => array(
|
393 |
-
'5.1' => false,
|
394 |
-
'5.2' => true
|
395 |
-
),
|
396 |
-
'M_SQRTPI' => array(
|
397 |
-
'5.1' => false,
|
398 |
-
'5.2' => true
|
399 |
-
),
|
400 |
-
'PATHINFO_FILENAME' => array(
|
401 |
-
'5.1' => false,
|
402 |
-
'5.2' => true
|
403 |
-
),
|
404 |
-
'UPLOAD_ERR_EXTENSION' => array(
|
405 |
-
'5.1' => false,
|
406 |
-
'5.2' => true
|
407 |
-
),
|
408 |
-
// Curl:
|
409 |
-
'CURLE_FILESIZE_EXCEEDED' => array(
|
410 |
-
'5.1' => false,
|
411 |
-
'5.2' => true
|
412 |
-
),
|
413 |
-
'CURLE_FTP_SSL_FAILED' => array(
|
414 |
-
'5.1' => false,
|
415 |
-
'5.2' => true
|
416 |
-
),
|
417 |
-
'CURLE_LDAP_INVALID_URL' => array(
|
418 |
-
'5.1' => false,
|
419 |
-
'5.2' => true
|
420 |
-
),
|
421 |
-
'CURLFTPAUTH_DEFAULT' => array(
|
422 |
-
'5.1' => false,
|
423 |
-
'5.2' => true
|
424 |
-
),
|
425 |
-
'CURLFTPAUTH_SSL' => array(
|
426 |
-
'5.1' => false,
|
427 |
-
'5.2' => true
|
428 |
-
),
|
429 |
-
'CURLFTPAUTH_TLS' => array(
|
430 |
-
'5.1' => false,
|
431 |
-
'5.2' => true
|
432 |
-
),
|
433 |
-
'CURLFTPSSL_ALL' => array(
|
434 |
-
'5.1' => false,
|
435 |
-
'5.2' => true
|
436 |
-
),
|
437 |
-
'CURLFTPSSL_CONTROL' => array(
|
438 |
-
'5.1' => false,
|
439 |
-
'5.2' => true
|
440 |
-
),
|
441 |
-
'CURLFTPSSL_NONE' => array(
|
442 |
-
'5.1' => false,
|
443 |
-
'5.2' => true
|
444 |
-
),
|
445 |
-
'CURLFTPSSL_TRY' => array(
|
446 |
-
'5.1' => false,
|
447 |
-
'5.2' => true
|
448 |
-
),
|
449 |
-
'CURLOPT_FTP_SSL' => array(
|
450 |
-
'5.1' => false,
|
451 |
-
'5.2' => true
|
452 |
-
),
|
453 |
-
// Ming:
|
454 |
-
'SWFTEXTFIELD_USEFONT' => array(
|
455 |
-
'5.1' => false,
|
456 |
-
'5.2' => true
|
457 |
-
),
|
458 |
-
'SWFTEXTFIELD_AUTOSIZE' => array(
|
459 |
-
'5.1' => false,
|
460 |
-
'5.2' => true
|
461 |
-
),
|
462 |
-
'SWF_SOUND_NOT_COMPRESSED' => array(
|
463 |
-
'5.1' => false,
|
464 |
-
'5.2' => true
|
465 |
-
),
|
466 |
-
'SWF_SOUND_ADPCM_COMPRESSED' => array(
|
467 |
-
'5.1' => false,
|
468 |
-
'5.2' => true
|
469 |
-
),
|
470 |
-
'SWF_SOUND_MP3_COMPRESSED' => array(
|
471 |
-
'5.1' => false,
|
472 |
-
'5.2' => true
|
473 |
-
),
|
474 |
-
'SWF_SOUND_NOT_COMPRESSED_LE' => array(
|
475 |
-
'5.1' => false,
|
476 |
-
'5.2' => true
|
477 |
-
),
|
478 |
-
'SWF_SOUND_NELLY_COMPRESSED' => array(
|
479 |
-
'5.1' => false,
|
480 |
-
'5.2' => true
|
481 |
-
),
|
482 |
-
'SWF_SOUND_5KHZ' => array(
|
483 |
-
'5.1' => false,
|
484 |
-
'5.2' => true
|
485 |
-
),
|
486 |
-
'SWF_SOUND_11KHZ' => array(
|
487 |
-
'5.1' => false,
|
488 |
-
'5.2' => true
|
489 |
-
),
|
490 |
-
'SWF_SOUND_22KHZ' => array(
|
491 |
-
'5.1' => false,
|
492 |
-
'5.2' => true
|
493 |
-
),
|
494 |
-
'SWF_SOUND_44KHZ' => array(
|
495 |
-
'5.1' => false,
|
496 |
-
'5.2' => true
|
497 |
-
),
|
498 |
-
'SWF_SOUND_8BITS' => array(
|
499 |
-
'5.1' => false,
|
500 |
-
'5.2' => true
|
501 |
-
),
|
502 |
-
'SWF_SOUND_16BITS' => array(
|
503 |
-
'5.1' => false,
|
504 |
-
'5.2' => true
|
505 |
-
),
|
506 |
-
'SWF_SOUND_MONO' => array(
|
507 |
-
'5.1' => false,
|
508 |
-
'5.2' => true
|
509 |
-
),
|
510 |
-
'SWF_SOUND_STEREO' => array(
|
511 |
-
'5.1' => false,
|
512 |
-
'5.2' => true
|
513 |
-
),
|
514 |
-
// OpenSSL:
|
515 |
-
'OPENSSL_KEYTYPE_EC' => array(
|
516 |
-
'5.1' => false,
|
517 |
-
'5.2' => true
|
518 |
-
),
|
519 |
-
'OPENSSL_VERSION_NUMBER' => array(
|
520 |
-
'5.1' => false,
|
521 |
-
'5.2' => true
|
522 |
-
),
|
523 |
-
'OPENSSL_VERSION_TEXT' => array(
|
524 |
-
'5.1' => false,
|
525 |
-
'5.2' => true
|
526 |
-
),
|
527 |
-
// PCRE:
|
528 |
-
'PREG_BACKTRACK_LIMIT_ERROR' => array(
|
529 |
-
'5.1' => false,
|
530 |
-
'5.2' => true
|
531 |
-
),
|
532 |
-
'PREG_BAD_UTF8_ERROR' => array(
|
533 |
-
'5.1' => false,
|
534 |
-
'5.2' => true
|
535 |
-
),
|
536 |
-
'PREG_INTERNAL_ERROR' => array(
|
537 |
-
'5.1' => false,
|
538 |
-
'5.2' => true
|
539 |
-
),
|
540 |
-
'PREG_NO_ERROR' => array(
|
541 |
-
'5.1' => false,
|
542 |
-
'5.2' => true
|
543 |
-
),
|
544 |
-
'PREG_RECURSION_LIMIT_ERROR' => array(
|
545 |
-
'5.1' => false,
|
546 |
-
'5.2' => true
|
547 |
-
),
|
548 |
-
// Snmp:
|
549 |
-
'SNMP_OID_OUTPUT_FULL' => array(
|
550 |
-
'5.1' => false,
|
551 |
-
'5.2' => true
|
552 |
-
),
|
553 |
-
'SNMP_OID_OUTPUT_NUMERIC' => array(
|
554 |
-
'5.1' => false,
|
555 |
-
'5.2' => true
|
556 |
-
),
|
557 |
-
// Semaphore:
|
558 |
-
'MSG_EAGAIN' => array(
|
559 |
-
'5.1' => false,
|
560 |
-
'5.2' => true
|
561 |
-
),
|
562 |
-
'MSG_ENOMSG' => array(
|
563 |
-
'5.1' => false,
|
564 |
-
'5.2' => true
|
565 |
-
),
|
566 |
-
|
567 |
-
// Curl:
|
568 |
-
'CURLOPT_TCP_NODELAY' => array(
|
569 |
-
'5.2.0' => false,
|
570 |
-
'5.2.1' => true
|
571 |
-
),
|
572 |
-
|
573 |
-
// Stream:
|
574 |
-
'STREAM_SHUT_RD' => array(
|
575 |
-
'5.2.0' => false,
|
576 |
-
'5.2.1' => true
|
577 |
-
),
|
578 |
-
'STREAM_SHUT_WR' => array(
|
579 |
-
'5.2.0' => false,
|
580 |
-
'5.2.1' => true
|
581 |
-
),
|
582 |
-
'STREAM_SHUT_RDWR' => array(
|
583 |
-
'5.2.0' => false,
|
584 |
-
'5.2.1' => true
|
585 |
-
),
|
586 |
-
|
587 |
-
'GMP_VERSION' => array(
|
588 |
-
'5.2.1' => false,
|
589 |
-
'5.2.2' => true
|
590 |
-
),
|
591 |
-
|
592 |
-
// Curl:
|
593 |
-
'CURLOPT_TIMEOUT_MS' => array(
|
594 |
-
'5.2.2' => false,
|
595 |
-
'5.2.3' => true
|
596 |
-
),
|
597 |
-
'CURLOPT_CONNECTTIMEOUT_MS' => array(
|
598 |
-
'5.2.2' => false,
|
599 |
-
'5.2.3' => true
|
600 |
-
),
|
601 |
-
|
602 |
-
// Curl:
|
603 |
-
'CURLOPT_PRIVATE' => array(
|
604 |
-
'5.2.3' => false,
|
605 |
-
'5.2.4' => true
|
606 |
-
),
|
607 |
-
'CURLINFO_PRIVATE' => array(
|
608 |
-
'5.2.3' => false,
|
609 |
-
'5.2.4' => true
|
610 |
-
),
|
611 |
-
// GD:
|
612 |
-
'GD_VERSION' => array(
|
613 |
-
'5.2.3' => false,
|
614 |
-
'5.2.4' => true
|
615 |
-
),
|
616 |
-
'GD_MAJOR_VERSION' => array(
|
617 |
-
'5.2.3' => false,
|
618 |
-
'5.2.4' => true
|
619 |
-
),
|
620 |
-
'GD_MINOR_VERSION' => array(
|
621 |
-
'5.2.3' => false,
|
622 |
-
'5.2.4' => true
|
623 |
-
),
|
624 |
-
'GD_RELEASE_VERSION' => array(
|
625 |
-
'5.2.3' => false,
|
626 |
-
'5.2.4' => true
|
627 |
-
),
|
628 |
-
'GD_EXTRA_VERSION' => array(
|
629 |
-
'5.2.3' => false,
|
630 |
-
'5.2.4' => true
|
631 |
-
),
|
632 |
-
// PCRE:
|
633 |
-
'PCRE_VERSION' => array(
|
634 |
-
'5.2.3' => false,
|
635 |
-
'5.2.4' => true
|
636 |
-
),
|
637 |
-
|
638 |
-
'PHP_MAJOR_VERSION' => array(
|
639 |
-
'5.2.6' => false,
|
640 |
-
'5.2.7' => true
|
641 |
-
),
|
642 |
-
'PHP_MINOR_VERSION' => array(
|
643 |
-
'5.2.6' => false,
|
644 |
-
'5.2.7' => true
|
645 |
-
),
|
646 |
-
'PHP_RELEASE_VERSION' => array(
|
647 |
-
'5.2.6' => false,
|
648 |
-
'5.2.7' => true
|
649 |
-
),
|
650 |
-
'PHP_VERSION_ID' => array(
|
651 |
-
'5.2.6' => false,
|
652 |
-
'5.2.7' => true
|
653 |
-
),
|
654 |
-
'PHP_EXTRA_VERSION' => array(
|
655 |
-
'5.2.6' => false,
|
656 |
-
'5.2.7' => true
|
657 |
-
),
|
658 |
-
'PHP_ZTS' => array(
|
659 |
-
'5.2.6' => false,
|
660 |
-
'5.2.7' => true
|
661 |
-
),
|
662 |
-
'PHP_DEBUG' => array(
|
663 |
-
'5.2.6' => false,
|
664 |
-
'5.2.7' => true
|
665 |
-
),
|
666 |
-
'FILE_BINARY' => array(
|
667 |
-
'5.2.6' => false,
|
668 |
-
'5.2.7' => true
|
669 |
-
),
|
670 |
-
'FILE_TEXT' => array(
|
671 |
-
'5.2.6' => false,
|
672 |
-
'5.2.7' => true
|
673 |
-
),
|
674 |
-
// Sockets:
|
675 |
-
'TCP_NODELAY' => array(
|
676 |
-
'5.2.6' => false,
|
677 |
-
'5.2.7' => true
|
678 |
-
),
|
679 |
-
|
680 |
-
// Curl:
|
681 |
-
'CURLOPT_PROTOCOLS' => array(
|
682 |
-
'5.2.9' => false,
|
683 |
-
'5.2.10' => true
|
684 |
-
),
|
685 |
-
'CURLOPT_REDIR_PROTOCOLS' => array(
|
686 |
-
'5.2.9' => false,
|
687 |
-
'5.2.10' => true
|
688 |
-
),
|
689 |
-
'CURLPROXY_SOCKS4' => array(
|
690 |
-
'5.2.9' => false,
|
691 |
-
'5.2.10' => true
|
692 |
-
),
|
693 |
-
|
694 |
-
// Libxml:
|
695 |
-
'LIBXML_PARSEHUGE' => array(
|
696 |
-
'5.2.11' => false,
|
697 |
-
'5.2.12' => true
|
698 |
-
),
|
699 |
-
|
700 |
-
// Core:
|
701 |
-
'ENT_IGNORE' => array(
|
702 |
-
'5.2' => false,
|
703 |
-
'5.3' => true
|
704 |
-
),
|
705 |
-
'E_DEPRECATED' => array(
|
706 |
-
'5.2' => false,
|
707 |
-
'5.3' => true
|
708 |
-
),
|
709 |
-
'E_USER_DEPRECATED' => array(
|
710 |
-
'5.2' => false,
|
711 |
-
'5.3' => true
|
712 |
-
),
|
713 |
-
'INI_SCANNER_NORMAL' => array(
|
714 |
-
'5.2' => false,
|
715 |
-
'5.3' => true
|
716 |
-
),
|
717 |
-
'INI_SCANNER_RAW' => array(
|
718 |
-
'5.2' => false,
|
719 |
-
'5.3' => true
|
720 |
-
),
|
721 |
-
'PHP_MAXPATHLEN' => array(
|
722 |
-
'5.2' => false,
|
723 |
-
'5.3' => true
|
724 |
-
),
|
725 |
-
'PHP_WINDOWS_NT_DOMAIN_CONTROLLER' => array(
|
726 |
-
'5.2' => false,
|
727 |
-
'5.3' => true
|
728 |
-
),
|
729 |
-
'PHP_WINDOWS_NT_SERVER' => array(
|
730 |
-
'5.2' => false,
|
731 |
-
'5.3' => true
|
732 |
-
),
|
733 |
-
'PHP_WINDOWS_NT_WORKSTATION' => array(
|
734 |
-
'5.2' => false,
|
735 |
-
'5.3' => true
|
736 |
-
),
|
737 |
-
'PHP_WINDOWS_VERSION_BUILD' => array(
|
738 |
-
'5.2' => false,
|
739 |
-
'5.3' => true
|
740 |
-
),
|
741 |
-
'PHP_WINDOWS_VERSION_MAJOR' => array(
|
742 |
-
'5.2' => false,
|
743 |
-
'5.3' => true
|
744 |
-
),
|
745 |
-
'PHP_WINDOWS_VERSION_MINOR' => array(
|
746 |
-
'5.2' => false,
|
747 |
-
'5.3' => true
|
748 |
-
),
|
749 |
-
'PHP_WINDOWS_VERSION_PLATFORM' => array(
|
750 |
-
'5.2' => false,
|
751 |
-
'5.3' => true
|
752 |
-
),
|
753 |
-
'PHP_WINDOWS_VERSION_PRODUCTTYPE' => array(
|
754 |
-
'5.2' => false,
|
755 |
-
'5.3' => true
|
756 |
-
),
|
757 |
-
'PHP_WINDOWS_VERSION_SP_MAJOR' => array(
|
758 |
-
'5.2' => false,
|
759 |
-
'5.3' => true
|
760 |
-
),
|
761 |
-
'PHP_WINDOWS_VERSION_SP_MINOR' => array(
|
762 |
-
'5.2' => false,
|
763 |
-
'5.3' => true
|
764 |
-
),
|
765 |
-
'PHP_WINDOWS_VERSION_SUITEMASK' => array(
|
766 |
-
'5.2' => false,
|
767 |
-
'5.3' => true
|
768 |
-
),
|
769 |
-
// Curl:
|
770 |
-
'CURLINFO_CERTINFO' => array(
|
771 |
-
'5.2' => false,
|
772 |
-
'5.3' => true
|
773 |
-
),
|
774 |
-
'CURLOPT_PROGRESSFUNCTION' => array(
|
775 |
-
'5.2' => false,
|
776 |
-
'5.3' => true
|
777 |
-
),
|
778 |
-
'CURLE_SSH' => array(
|
779 |
-
'5.2' => false,
|
780 |
-
'5.3' => true
|
781 |
-
),
|
782 |
-
// GD:
|
783 |
-
'IMG_FILTER_PIXELATE' => array(
|
784 |
-
'5.2' => false,
|
785 |
-
'5.3' => true
|
786 |
-
),
|
787 |
-
'IMAGETYPE_ICO' => array(
|
788 |
-
'5.2' => false,
|
789 |
-
'5.3' => true
|
790 |
-
),
|
791 |
-
// Fileinfo:
|
792 |
-
'FILEINFO_MIME_TYPE' => array(
|
793 |
-
'5.2' => false,
|
794 |
-
'5.3' => true
|
795 |
-
),
|
796 |
-
'FILEINFO_MIME_ENCODING' => array(
|
797 |
-
'5.2' => false,
|
798 |
-
'5.3' => true
|
799 |
-
),
|
800 |
-
// JSON:
|
801 |
-
'JSON_ERROR_CTRL_CHAR' => array(
|
802 |
-
'5.2' => false,
|
803 |
-
'5.3' => true
|
804 |
-
),
|
805 |
-
'JSON_ERROR_DEPTH' => array(
|
806 |
-
'5.2' => false,
|
807 |
-
'5.3' => true
|
808 |
-
),
|
809 |
-
'JSON_ERROR_NONE' => array(
|
810 |
-
'5.2' => false,
|
811 |
-
'5.3' => true
|
812 |
-
),
|
813 |
-
'JSON_ERROR_STATE_MISMATCH' => array(
|
814 |
-
'5.2' => false,
|
815 |
-
'5.3' => true
|
816 |
-
),
|
817 |
-
'JSON_ERROR_SYNTAX' => array(
|
818 |
-
'5.2' => false,
|
819 |
-
'5.3' => true
|
820 |
-
),
|
821 |
-
'JSON_FORCE_OBJECT' => array(
|
822 |
-
'5.2' => false,
|
823 |
-
'5.3' => true
|
824 |
-
),
|
825 |
-
'JSON_HEX_TAG' => array(
|
826 |
-
'5.2' => false,
|
827 |
-
'5.3' => true
|
828 |
-
),
|
829 |
-
'JSON_HEX_AMP' => array(
|
830 |
-
'5.2' => false,
|
831 |
-
'5.3' => true
|
832 |
-
),
|
833 |
-
'JSON_HEX_APOS' => array(
|
834 |
-
'5.2' => false,
|
835 |
-
'5.3' => true
|
836 |
-
),
|
837 |
-
'JSON_HEX_QUOT' => array(
|
838 |
-
'5.2' => false,
|
839 |
-
'5.3' => true
|
840 |
-
),
|
841 |
-
// LDAP:
|
842 |
-
'LDAP_OPT_NETWORK_TIMEOUT' => array(
|
843 |
-
'5.2' => false,
|
844 |
-
'5.3' => true
|
845 |
-
),
|
846 |
-
// libxml:
|
847 |
-
'LIBXML_LOADED_VERSION' => array(
|
848 |
-
'5.2' => false,
|
849 |
-
'5.3' => true
|
850 |
-
),
|
851 |
-
// Math:
|
852 |
-
'PHP_ROUND_HALF_UP' => array(
|
853 |
-
'5.2' => false,
|
854 |
-
'5.3' => true
|
855 |
-
),
|
856 |
-
'PHP_ROUND_HALF_DOWN' => array(
|
857 |
-
'5.2' => false,
|
858 |
-
'5.3' => true
|
859 |
-
),
|
860 |
-
'PHP_ROUND_HALF_EVEN' => array(
|
861 |
-
'5.2' => false,
|
862 |
-
'5.3' => true
|
863 |
-
),
|
864 |
-
'PHP_ROUND_HALF_ODD' => array(
|
865 |
-
'5.2' => false,
|
866 |
-
'5.3' => true
|
867 |
-
),
|
868 |
-
// Mysqli
|
869 |
-
'MYSQLI_OPT_INT_AND_FLOAT_NATIVE' => array(
|
870 |
-
'5.2' => false,
|
871 |
-
'5.3' => true
|
872 |
-
),
|
873 |
-
'MYSQLI_OPT_NET_CMD_BUFFER_SIZE' => array(
|
874 |
-
'5.2' => false,
|
875 |
-
'5.3' => true
|
876 |
-
),
|
877 |
-
'MYSQLI_OPT_NET_READ_BUFFER_SIZE' => array(
|
878 |
-
'5.2' => false,
|
879 |
-
'5.3' => true
|
880 |
-
),
|
881 |
-
'MYSQLI_OPT_SSL_VERIFY_SERVER_CERT' => array(
|
882 |
-
'5.2' => false,
|
883 |
-
'5.3' => true
|
884 |
-
),
|
885 |
-
// OCI8:
|
886 |
-
'OCI_CRED_EXT' => array(
|
887 |
-
'5.2' => false,
|
888 |
-
'5.3' => true
|
889 |
-
),
|
890 |
-
// PCRE:
|
891 |
-
'PREG_BAD_UTF8_OFFSET_ERROR' => array(
|
892 |
-
'5.2' => false,
|
893 |
-
'5.3' => true
|
894 |
-
),
|
895 |
-
// PCNTL:
|
896 |
-
'BUS_ADRALN' => array(
|
897 |
-
'5.2' => false,
|
898 |
-
'5.3' => true
|
899 |
-
),
|
900 |
-
'BUS_ADRERR' => array(
|
901 |
-
'5.2' => false,
|
902 |
-
'5.3' => true
|
903 |
-
),
|
904 |
-
'BUS_OBJERR' => array(
|
905 |
-
'5.2' => false,
|
906 |
-
'5.3' => true
|
907 |
-
),
|
908 |
-
'CLD_CONTIUNED' => array(
|
909 |
-
'5.2' => false,
|
910 |
-
'5.3' => true
|
911 |
-
),
|
912 |
-
'CLD_DUMPED' => array(
|
913 |
-
'5.2' => false,
|
914 |
-
'5.3' => true
|
915 |
-
),
|
916 |
-
'CLD_EXITED' => array(
|
917 |
-
'5.2' => false,
|
918 |
-
'5.3' => true
|
919 |
-
),
|
920 |
-
'CLD_KILLED' => array(
|
921 |
-
'5.2' => false,
|
922 |
-
'5.3' => true
|
923 |
-
),
|
924 |
-
'CLD_STOPPED' => array(
|
925 |
-
'5.2' => false,
|
926 |
-
'5.3' => true
|
927 |
-
),
|
928 |
-
'CLD_TRAPPED' => array(
|
929 |
-
'5.2' => false,
|
930 |
-
'5.3' => true
|
931 |
-
),
|
932 |
-
'FPE_FLTDIV' => array(
|
933 |
-
'5.2' => false,
|
934 |
-
'5.3' => true
|
935 |
-
),
|
936 |
-
'FPE_FLTINV' => array(
|
937 |
-
'5.2' => false,
|
938 |
-
'5.3' => true
|
939 |
-
),
|
940 |
-
'FPE_FLTOVF' => array(
|
941 |
-
'5.2' => false,
|
942 |
-
'5.3' => true
|
943 |
-
),
|
944 |
-
'FPE_FLTRES' => array(
|
945 |
-
'5.2' => false,
|
946 |
-
'5.3' => true
|
947 |
-
),
|
948 |
-
'FPE_FLTSUB' => array(
|
949 |
-
'5.2' => false,
|
950 |
-
'5.3' => true
|
951 |
-
),
|
952 |
-
'FPE_FLTUND' => array(
|
953 |
-
'5.2' => false,
|
954 |
-
'5.3' => true
|
955 |
-
),
|
956 |
-
'FPE_INTDIV' => array(
|
957 |
-
'5.2' => false,
|
958 |
-
'5.3' => true
|
959 |
-
),
|
960 |
-
'FPE_INTOVF' => array(
|
961 |
-
'5.2' => false,
|
962 |
-
'5.3' => true
|
963 |
-
),
|
964 |
-
'ILL_BADSTK' => array(
|
965 |
-
'5.2' => false,
|
966 |
-
'5.3' => true
|
967 |
-
),
|
968 |
-
'ILL_COPROC' => array(
|
969 |
-
'5.2' => false,
|
970 |
-
'5.3' => true
|
971 |
-
),
|
972 |
-
'ILL_ILLADR' => array(
|
973 |
-
'5.2' => false,
|
974 |
-
'5.3' => true
|
975 |
-
),
|
976 |
-
'ILL_ILLOPC' => array(
|
977 |
-
'5.2' => false,
|
978 |
-
'5.3' => true
|
979 |
-
),
|
980 |
-
'ILL_ILLOPN' => array(
|
981 |
-
'5.2' => false,
|
982 |
-
'5.3' => true
|
983 |
-
),
|
984 |
-
'ILL_ILLTRP' => array(
|
985 |
-
'5.2' => false,
|
986 |
-
'5.3' => true
|
987 |
-
),
|
988 |
-
'ILL_PRVOPC' => array(
|
989 |
-
'5.2' => false,
|
990 |
-
'5.3' => true
|
991 |
-
),
|
992 |
-
'ILL_PRVREG' => array(
|
993 |
-
'5.2' => false,
|
994 |
-
'5.3' => true
|
995 |
-
),
|
996 |
-
'POLL_ERR' => array(
|
997 |
-
'5.2' => false,
|
998 |
-
'5.3' => true
|
999 |
-
),
|
1000 |
-
'POLL_HUP' => array(
|
1001 |
-
'5.2' => false,
|
1002 |
-
'5.3' => true
|
1003 |
-
),
|
1004 |
-
'POLL_IN' => array(
|
1005 |
-
'5.2' => false,
|
1006 |
-
'5.3' => true
|
1007 |
-
),
|
1008 |
-
'POLL_MSG' => array(
|
1009 |
-
'5.2' => false,
|
1010 |
-
'5.3' => true
|
1011 |
-
),
|
1012 |
-
'POLL_OUT' => array(
|
1013 |
-
'5.2' => false,
|
1014 |
-
'5.3' => true
|
1015 |
-
),
|
1016 |
-
'POLL_PRI' => array(
|
1017 |
-
'5.2' => false,
|
1018 |
-
'5.3' => true
|
1019 |
-
),
|
1020 |
-
'SEGV_ACCERR' => array(
|
1021 |
-
'5.2' => false,
|
1022 |
-
'5.3' => true
|
1023 |
-
),
|
1024 |
-
'SEGV_MAPERR' => array(
|
1025 |
-
'5.2' => false,
|
1026 |
-
'5.3' => true
|
1027 |
-
),
|
1028 |
-
'SI_ASYNCIO' => array(
|
1029 |
-
'5.2' => false,
|
1030 |
-
'5.3' => true
|
1031 |
-
),
|
1032 |
-
'SI_KERNEL' => array(
|
1033 |
-
'5.2' => false,
|
1034 |
-
'5.3' => true
|
1035 |
-
),
|
1036 |
-
'SI_MSGGQ' => array(
|
1037 |
-
'5.2' => false,
|
1038 |
-
'5.3' => true
|
1039 |
-
),
|
1040 |
-
'SI_NOINFO' => array(
|
1041 |
-
'5.2' => false,
|
1042 |
-
'5.3' => true
|
1043 |
-
),
|
1044 |
-
'SI_QUEUE' => array(
|
1045 |
-
'5.2' => false,
|
1046 |
-
'5.3' => true
|
1047 |
-
),
|
1048 |
-
'SI_SIGIO' => array(
|
1049 |
-
'5.2' => false,
|
1050 |
-
'5.3' => true
|
1051 |
-
),
|
1052 |
-
'SI_TIMER' => array(
|
1053 |
-
'5.2' => false,
|
1054 |
-
'5.3' => true
|
1055 |
-
),
|
1056 |
-
'SI_TKILL' => array(
|
1057 |
-
'5.2' => false,
|
1058 |
-
'5.3' => true
|
1059 |
-
),
|
1060 |
-
'SI_USER' => array(
|
1061 |
-
'5.2' => false,
|
1062 |
-
'5.3' => true
|
1063 |
-
),
|
1064 |
-
'SIG_BLOCK' => array(
|
1065 |
-
'5.2' => false,
|
1066 |
-
'5.3' => true
|
1067 |
-
),
|
1068 |
-
'SIG_SETMASK' => array(
|
1069 |
-
'5.2' => false,
|
1070 |
-
'5.3' => true
|
1071 |
-
),
|
1072 |
-
'SIG_UNBLOCK' => array(
|
1073 |
-
'5.2' => false,
|
1074 |
-
'5.3' => true
|
1075 |
-
),
|
1076 |
-
'TRAP_BRKPT' => array(
|
1077 |
-
'5.2' => false,
|
1078 |
-
'5.3' => true
|
1079 |
-
),
|
1080 |
-
'TRAP_TRACE' => array(
|
1081 |
-
'5.2' => false,
|
1082 |
-
'5.3' => true
|
1083 |
-
),
|
1084 |
-
// Tokenizer:
|
1085 |
-
'T_DIR' => array(
|
1086 |
-
'5.2' => false,
|
1087 |
-
'5.3' => true
|
1088 |
-
),
|
1089 |
-
'T_GOTO' => array(
|
1090 |
-
'5.2' => false,
|
1091 |
-
'5.3' => true
|
1092 |
-
),
|
1093 |
-
'T_NAMESPACE' => array(
|
1094 |
-
'5.2' => false,
|
1095 |
-
'5.3' => true
|
1096 |
-
),
|
1097 |
-
'T_NS_C' => array(
|
1098 |
-
'5.2' => false,
|
1099 |
-
'5.3' => true
|
1100 |
-
),
|
1101 |
-
'T_NS_SEPARATOR' => array(
|
1102 |
-
'5.2' => false,
|
1103 |
-
'5.3' => true
|
1104 |
-
),
|
1105 |
-
'T_USE' => array(
|
1106 |
-
'5.2' => false,
|
1107 |
-
'5.3' => true
|
1108 |
-
),
|
1109 |
-
|
1110 |
-
// OCI8:
|
1111 |
-
'OCI_NO_AUTO_COMMIT' => array(
|
1112 |
-
'5.3.1' => false,
|
1113 |
-
'5.3.2' => true
|
1114 |
-
),
|
1115 |
-
// OpenSSL:
|
1116 |
-
'OPENSSL_TLSEXT_SERVER_NAME' => array(
|
1117 |
-
'5.3.1' => false,
|
1118 |
-
'5.3.2' => true
|
1119 |
-
),
|
1120 |
-
|
1121 |
-
// JSON:
|
1122 |
-
'JSON_ERROR_UTF8' => array(
|
1123 |
-
'5.3.2' => false,
|
1124 |
-
'5.3.3' => true
|
1125 |
-
),
|
1126 |
-
'JSON_NUMERIC_CHECK' => array(
|
1127 |
-
'5.3.2' => false,
|
1128 |
-
'5.3.3' => true
|
1129 |
-
),
|
1130 |
-
|
1131 |
-
'DEBUG_BACKTRACE_IGNORE_ARGS' => array(
|
1132 |
-
'5.3.5' => false,
|
1133 |
-
'5.3.6' => true
|
1134 |
-
),
|
1135 |
-
|
1136 |
-
'CURLINFO_REDIRECT_URL' => array(
|
1137 |
-
'5.3.6' => false,
|
1138 |
-
'5.3.7' => true
|
1139 |
-
),
|
1140 |
-
'PHP_MANDIR' => array(
|
1141 |
-
'5.3.6' => false,
|
1142 |
-
'5.3.7' => true
|
1143 |
-
),
|
1144 |
-
|
1145 |
-
'PHP_BINARY' => array(
|
1146 |
-
'5.3' => false,
|
1147 |
-
'5.4' => true
|
1148 |
-
),
|
1149 |
-
'SORT_NATURAL' => array(
|
1150 |
-
'5.3' => false,
|
1151 |
-
'5.4' => true
|
1152 |
-
),
|
1153 |
-
'SORT_FLAG_CASE' => array(
|
1154 |
-
'5.3' => false,
|
1155 |
-
'5.4' => true
|
1156 |
-
),
|
1157 |
-
'ENT_HTML401' => array(
|
1158 |
-
'5.3' => false,
|
1159 |
-
'5.4' => true
|
1160 |
-
),
|
1161 |
-
'ENT_XML1' => array(
|
1162 |
-
'5.3' => false,
|
1163 |
-
'5.4' => true
|
1164 |
-
),
|
1165 |
-
'ENT_XHTML' => array(
|
1166 |
-
'5.3' => false,
|
1167 |
-
'5.4' => true
|
1168 |
-
),
|
1169 |
-
'ENT_HTML5' => array(
|
1170 |
-
'5.3' => false,
|
1171 |
-
'5.4' => true
|
1172 |
-
),
|
1173 |
-
'ENT_SUBSTITUTE' => array(
|
1174 |
-
'5.3' => false,
|
1175 |
-
'5.4' => true
|
1176 |
-
),
|
1177 |
-
'ENT_DISALLOWED' => array(
|
1178 |
-
'5.3' => false,
|
1179 |
-
'5.4' => true
|
1180 |
-
),
|
1181 |
-
'IPPROTO_IP' => array(
|
1182 |
-
'5.3' => false,
|
1183 |
-
'5.4' => true
|
1184 |
-
),
|
1185 |
-
'IPPROTO_IPV6' => array(
|
1186 |
-
'5.3' => false,
|
1187 |
-
'5.4' => true
|
1188 |
-
),
|
1189 |
-
'IPV6_MULTICAST_HOPS' => array(
|
1190 |
-
'5.3' => false,
|
1191 |
-
'5.4' => true
|
1192 |
-
),
|
1193 |
-
'IPV6_MULTICAST_IF' => array(
|
1194 |
-
'5.3' => false,
|
1195 |
-
'5.4' => true
|
1196 |
-
),
|
1197 |
-
'IPV6_MULTICAST_LOOP' => array(
|
1198 |
-
'5.3' => false,
|
1199 |
-
'5.4' => true
|
1200 |
-
),
|
1201 |
-
'IP_MULTICAST_IF' => array(
|
1202 |
-
'5.3' => false,
|
1203 |
-
'5.4' => true
|
1204 |
-
),
|
1205 |
-
'IP_MULTICAST_LOOP' => array(
|
1206 |
-
'5.3' => false,
|
1207 |
-
'5.4' => true
|
1208 |
-
),
|
1209 |
-
'IP_MULTICAST_TTL' => array(
|
1210 |
-
'5.3' => false,
|
1211 |
-
'5.4' => true
|
1212 |
-
),
|
1213 |
-
'MCAST_JOIN_GROUP' => array(
|
1214 |
-
'5.3' => false,
|
1215 |
-
'5.4' => true
|
1216 |
-
),
|
1217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|