Cloudflare - Version 3.8.1

Version Description

  • 2020-10-02 =

  • Fixed typo in config.js(on) that resulted in warning #292

  • Check for array indicies are set before using #278

Download this release

Release Info

Developer epatryk
Plugin Icon 128x128 Cloudflare
Version 3.8.1
Comparing to
See all releases

Code changes from version 3.8.0 to 3.8.1

Files changed (190) hide show
  1. .github/workflows/php.yml +0 -48
  2. .github/workflows/stale.yml +0 -25
  3. CONTRIBUTING.md +2 -2
  4. Dockerfile.wordpress +0 -4
  5. assets/analytics-welcome.svg +0 -0
  6. assets/details-arrows.png +0 -0
  7. assets/icon-bolt.svg +0 -0
  8. assets/icon-lock.svg +0 -0
  9. assets/icon-pin.svg +0 -0
  10. assets/icon-shield.svg +0 -0
  11. assets/icons-seee324dde5.png +0 -0
  12. assets/icons_2x-s6333fe7591.png +0 -0
  13. assets/layers-2x.png +0 -0
  14. assets/layers.png +0 -0
  15. assets/logo-reverse.svg +0 -0
  16. assets/logo-symbol.svg +0 -0
  17. assets/logo.svg +0 -0
  18. assets/modal-two-factor-auth.png +0 -0
  19. assets/modal-two-factor-auth_2x.png +0 -0
  20. assets/overview-welcome-yjs.svg +0 -0
  21. assets/overview-welcome.svg +0 -0
  22. assets/plan-changed-success.svg +0 -0
  23. assets/request-submitted-success.svg +0 -0
  24. assets/select2-cf.png +0 -0
  25. assets/select2x2-cf.png +0 -0
  26. assets/spinner.gif +0 -0
  27. assets/vertical-range.png +0 -0
  28. assets/yjs-logo.svg +0 -0
  29. cloudflare.php +1 -1
  30. composer.json +1 -1
  31. config.json +27 -27
  32. docker-compose.yaml +0 -42
  33. fonts/cloudflare-font.eot +0 -0
  34. fonts/cloudflare-font.svg +0 -0
  35. fonts/cloudflare-font.ttf +0 -0
  36. fonts/cloudflare-font.woff +0 -0
  37. fonts/opensans-300.eot +0 -0
  38. fonts/opensans-300.ttf +0 -0
  39. fonts/opensans-300.woff +0 -0
  40. fonts/opensans-300.woff2 +0 -0
  41. fonts/opensans-300i.eot +0 -0
  42. fonts/opensans-300i.ttf +0 -0
  43. fonts/opensans-300i.woff +0 -0
  44. fonts/opensans-300i.woff2 +0 -0
  45. fonts/opensans-400.eot +0 -0
  46. fonts/opensans-400.ttf +0 -0
  47. fonts/opensans-400.woff +0 -0
  48. fonts/opensans-400.woff2 +0 -0
  49. fonts/opensans-400i.eot +0 -0
  50. fonts/opensans-400i.ttf +0 -0
  51. fonts/opensans-400i.woff +0 -0
  52. fonts/opensans-400i.woff2 +0 -0
  53. fonts/opensans-600.eot +0 -0
  54. fonts/opensans-600.ttf +0 -0
  55. fonts/opensans-600.woff +0 -0
  56. fonts/opensans-600.woff2 +0 -0
  57. fonts/opensans-700.eot +0 -0
  58. fonts/opensans-700.ttf +0 -0
  59. fonts/opensans-700.woff +0 -0
  60. fonts/opensans-700.woff2 +0 -0
  61. index.php +1 -1
  62. lang/de.js +0 -0
  63. lang/es.js +0 -0
  64. lang/fr.js +0 -0
  65. lang/it.js +0 -0
  66. lang/nl.js +0 -0
  67. lang/pt.js +0 -0
  68. readme.txt +6 -1
  69. src/WordPress/ClientActions.php +2 -2
  70. src/WordPress/Proxy.php +1 -1
  71. src/WordPress/composer.json +1 -1
  72. src/WordPress/config.json +27 -27
  73. stylesheets/cf.core.css +0 -0
  74. stylesheets/hacks.css +0 -0
  75. vendor/dealerdirect/phpcodesniffer-composer-installer/.yamllint +0 -6
  76. vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md +0 -21
  77. vendor/dealerdirect/phpcodesniffer-composer-installer/README.md +0 -250
  78. vendor/dealerdirect/phpcodesniffer-composer-installer/composer.json +0 -48
  79. vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php +0 -605
  80. vendor/myclabs/deep-copy/.gitattributes +0 -7
  81. vendor/myclabs/deep-copy/.gitignore +0 -3
  82. vendor/myclabs/deep-copy/.travis.yml +0 -40
  83. vendor/myclabs/deep-copy/LICENSE +0 -20
  84. vendor/myclabs/deep-copy/README.md +0 -372
  85. vendor/myclabs/deep-copy/composer.json +0 -35
  86. vendor/myclabs/deep-copy/doc/clone.png +0 -0
  87. vendor/myclabs/deep-copy/doc/deep-clone.png +0 -0
  88. vendor/myclabs/deep-copy/doc/deep-copy.png +0 -0
  89. vendor/myclabs/deep-copy/doc/graph.png +0 -0
  90. vendor/myclabs/deep-copy/fixtures/f001/A.php +0 -20
  91. vendor/myclabs/deep-copy/fixtures/f001/B.php +0 -20
  92. vendor/myclabs/deep-copy/fixtures/f002/A.php +0 -33
  93. vendor/myclabs/deep-copy/fixtures/f003/Foo.php +0 -26
  94. vendor/myclabs/deep-copy/fixtures/f004/UnclonableItem.php +0 -13
  95. vendor/myclabs/deep-copy/fixtures/f005/Foo.php +0 -13
  96. vendor/myclabs/deep-copy/fixtures/f006/A.php +0 -26
  97. vendor/myclabs/deep-copy/fixtures/f006/B.php +0 -26
  98. vendor/myclabs/deep-copy/fixtures/f007/FooDateInterval.php +0 -15
  99. vendor/myclabs/deep-copy/fixtures/f007/FooDateTimeZone.php +0 -15
  100. vendor/myclabs/deep-copy/fixtures/f008/A.php +0 -18
  101. vendor/myclabs/deep-copy/fixtures/f008/B.php +0 -7
  102. vendor/myclabs/deep-copy/src/DeepCopy/DeepCopy.php +0 -281
  103. vendor/myclabs/deep-copy/src/DeepCopy/Exception/CloneException.php +0 -9
  104. vendor/myclabs/deep-copy/src/DeepCopy/Exception/PropertyException.php +0 -9
  105. vendor/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php +0 -33
  106. vendor/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineEmptyCollectionFilter.php +0 -28
  107. vendor/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineProxyFilter.php +0 -22
  108. vendor/myclabs/deep-copy/src/DeepCopy/Filter/Filter.php +0 -18
  109. vendor/myclabs/deep-copy/src/DeepCopy/Filter/KeepFilter.php +0 -16
  110. vendor/myclabs/deep-copy/src/DeepCopy/Filter/ReplaceFilter.php +0 -39
  111. vendor/myclabs/deep-copy/src/DeepCopy/Filter/SetNullFilter.php +0 -24
  112. vendor/myclabs/deep-copy/src/DeepCopy/Matcher/Doctrine/DoctrineProxyMatcher.php +0 -22
  113. vendor/myclabs/deep-copy/src/DeepCopy/Matcher/Matcher.php +0 -14
  114. vendor/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyMatcher.php +0 -39
  115. vendor/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyNameMatcher.php +0 -32
  116. vendor/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyTypeMatcher.php +0 -46
  117. vendor/myclabs/deep-copy/src/DeepCopy/Reflection/ReflectionHelper.php +0 -78
  118. vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/Date/DateIntervalFilter.php +0 -33
  119. vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/ReplaceFilter.php +0 -30
  120. vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/ShallowCopyFilter.php +0 -17
  121. vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedList.php +0 -10
  122. vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedListFilter.php +0 -51
  123. vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/TypeFilter.php +0 -13
  124. vendor/myclabs/deep-copy/src/DeepCopy/TypeMatcher/TypeMatcher.php +0 -29
  125. vendor/myclabs/deep-copy/src/DeepCopy/deep_copy.php +0 -16
  126. vendor/phpcompatibility/php-compatibility/CHANGELOG.md +0 -1488
  127. vendor/phpcompatibility/php-compatibility/LICENSE +0 -165
  128. vendor/phpcompatibility/php-compatibility/PHPCSAliases.php +0 -73
  129. vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractComplexVersionSniff.php +0 -147
  130. vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractFunctionCallParameterSniff.php +0 -193
  131. vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractNewFeatureSniff.php +0 -115
  132. vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractRemovedFeatureSniff.php +0 -156
  133. vendor/phpcompatibility/php-compatibility/PHPCompatibility/ComplexVersionInterface.php +0 -84
  134. vendor/phpcompatibility/php-compatibility/PHPCompatibility/PHPCSHelper.php +0 -678
  135. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniff.php +0 -2267
  136. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/ForbiddenAbstractPrivateMethodsSniff.php +0 -90
  137. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewAnonymousClassesSniff.php +0 -91
  138. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php +0 -913
  139. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewConstVisibilitySniff.php +0 -80
  140. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewLateStaticBindingSniff.php +0 -88
  141. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php +0 -132
  142. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedOrphanedParentSniff.php +0 -115
  143. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewConstantsSniff.php +0 -3756
  144. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php +0 -80
  145. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/RemovedConstantsSniff.php +0 -574
  146. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php +0 -238
  147. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/ForbiddenBreakContinueOutsideLoopSniff.php +0 -116
  148. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/ForbiddenBreakContinueVariableArgumentsSniff.php +0 -110
  149. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +0 -81
  150. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php +0 -378
  151. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewForeachExpressionReferencingSniff.php +0 -99
  152. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewListInForeachSniff.php +0 -84
  153. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewMultiCatchSniff.php +0 -78
  154. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php +0 -346
  155. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenParameterShadowSuperGlobalsSniff.php +0 -79
  156. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenParametersWithSameNameSniff.php +0 -88
  157. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenToStringParametersSniff.php +0 -99
  158. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenVariableNamesInClosureUseSniff.php +0 -122
  159. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewClosureSniff.php +0 -264
  160. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewExceptionsFromToStringSniff.php +0 -171
  161. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewNullableTypesSniff.php +0 -169
  162. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewParamTypeDeclarationsSniff.php +0 -237
  163. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewReturnTypeDeclarationsSniff.php +0 -194
  164. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NonStaticMagicMethodsSniff.php +0 -216
  165. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/NewMagicMethodsSniff.php +0 -231
  166. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedMagicAutoloadSniff.php +0 -92
  167. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedNamespacedAssertSniff.php +0 -101
  168. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedPHP4StyleConstructorsSniff.php +0 -158
  169. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/ReservedFunctionNamesSniff.php +0 -205
  170. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php +0 -455
  171. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsUsageSniff.php +0 -169
  172. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionParametersSniff.php +0 -1109
  173. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionsSniff.php +0 -2008
  174. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/OptionalToRequiredFunctionParametersSniff.php +0 -173
  175. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionParametersSniff.php +0 -292
  176. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionsSniff.php +0 -1104
  177. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RequiredToOptionalFunctionParametersSniff.php +0 -350
  178. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php +0 -158
  179. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/IniDirectives/NewIniDirectivesSniff.php +0 -855
  180. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/IniDirectives/RemovedIniDirectivesSniff.php +0 -424
  181. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewConstantArraysUsingConstSniff.php +0 -82
  182. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewConstantArraysUsingDefineSniff.php +0 -101
  183. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewConstantScalarExpressionsSniff.php +0 -556
  184. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewHeredocSniff.php +0 -100
  185. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/InternalInterfacesSniff.php +0 -103
  186. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php +0 -362
  187. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/CaseSensitiveKeywordsSniff.php +0 -76
  188. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesAsDeclaredSniff.php +0 -259
  189. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesAsInvokedFunctionsSniff.php +0 -188
  190. vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesSniff.php +0 -345
.github/workflows/php.yml DELETED
@@ -1,48 +0,0 @@
1
- name: PHP Composer
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- build:
11
-
12
- runs-on: ubuntu-latest
13
-
14
- strategy:
15
- matrix:
16
- php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
17
-
18
- steps:
19
- - uses: actions/checkout@v2
20
-
21
- - name: Setup PHP
22
- uses: shivammathur/setup-php@v2
23
- with:
24
- php-version: ${{ matrix.php-versions }}
25
- env:
26
- update: true
27
-
28
- - name: Validate composer.json and composer.lock
29
- run: composer validate
30
-
31
- - name: Install dependencies
32
- if: steps.composer-cache.outputs.cache-hit != 'true'
33
- run: composer install --prefer-dist --no-progress --no-suggest --verbose
34
-
35
- - name: Format
36
- run: |
37
- composer run-script format || exit_code=$?
38
- if (( exit_code > 1 )) ; then
39
- exit $exit_code
40
- fi
41
-
42
- # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
43
- # Docs: https://getcomposer.org/doc/articles/scripts.md
44
-
45
- - name: Run test suite
46
- # Skip testing on PHP 7.4, because php-mock required by PHP 5.6 breaks on 7.4+
47
- if: matrix.php-versions < '7.4'
48
- run: composer run-script test
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/stale.yml DELETED
@@ -1,25 +0,0 @@
1
- name: Mark stale issues and pull requests
2
-
3
- on:
4
- schedule:
5
- - cron: "30 1 * * *"
6
-
7
- jobs:
8
- stale:
9
-
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - uses: actions/stale@v3
14
- with:
15
- repo-token: ${{ secrets.GITHUB_TOKEN }}
16
- stale-issue-message: >
17
- This issue has been automatically marked as stale because it has not had
18
- recent activity. It will be closed if no further activity occurs. Thank you
19
- for your contributions.
20
- stale-pr-message: >
21
- This pull request has been automatically marked as stale because it has not had
22
- recent activity. It will be closed if no further activity occurs. Thank you
23
- for your contributions.
24
- days-before-stale: 180
25
- days-before-close: 30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CONTRIBUTING.md CHANGED
@@ -19,11 +19,11 @@ We welcome community contribution to this repository. To help add functionality
19
 
20
  Cloudflare has multiple plugins using shared codebases.
21
 
22
- [WordPress](https://github.com/cloudflare/Cloudflare-WordPress), [CPanel](https://github.com/cloudflare/CloudFlare-CPanel), [Magento](https://github.com/cloudflare/CloudFlare-Magento) are the main repositories of the plugins. Every plugin has a config.js file which allows them to control the frontend of the plugin.
23
 
24
  Below are Cloudflare maintained repositories the plugins depend on.
25
 
26
- * [cloudflare-frontend](https://github.com/cloudflare/CloudFlare-FrontEnd) is a generic frontend used in plugins. You can add/remove cards simply by editing [config](https://github.com/cloudflare/CloudFlare-FrontEnd/blob/master/config.js) file.
27
  * [cf-ui](https://github.com/cloudflare/cf-ui) is a Cloudflare UI Framework where cloudflare-frontend is using.
28
  * [cloudflare-plugin-backend](https://github.com/cloudflare/cloudflare-plugin-backend) is a generic backend plugins use.
29
  * [cf-ip-rewrite](https://github.com/cloudflare/cf-ip-rewrite) allows to rewrite Cloudflare IP's in Application level.
19
 
20
  Cloudflare has multiple plugins using shared codebases.
21
 
22
+ [WordPress](https://github.com/cloudflare/Cloudflare-WordPress), [CPanel](https://github.com/cloudflare/CloudFlare-CPanel), [Magento](https://github.com/cloudflare/CloudFlare-Magento) are the main repositories of the plugins. Every plugin has a config.json file which allows them to control the frontend of the plugin.
23
 
24
  Below are Cloudflare maintained repositories the plugins depend on.
25
 
26
+ * [cloudflare-frontend](https://github.com/cloudflare/CloudFlare-FrontEnd) is a generic frontend used in plugins. You can add/remove cards simply by editing [config](https://github.com/cloudflare/cloudflare-plugin-frontend/blob/master/config.json.sample) file.
27
  * [cf-ui](https://github.com/cloudflare/cf-ui) is a Cloudflare UI Framework where cloudflare-frontend is using.
28
  * [cloudflare-plugin-backend](https://github.com/cloudflare/cloudflare-plugin-backend) is a generic backend plugins use.
29
  * [cf-ip-rewrite](https://github.com/cloudflare/cf-ip-rewrite) allows to rewrite Cloudflare IP's in Application level.
Dockerfile.wordpress DELETED
@@ -1,4 +0,0 @@
1
- FROM wordpress:latest
2
- RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
3
- && chmod +x wp-cli.phar \
4
- && mv wp-cli.phar /usr/local/bin/wp
 
 
 
 
assets/analytics-welcome.svg CHANGED
File without changes
assets/details-arrows.png CHANGED
File without changes
assets/icon-bolt.svg CHANGED
File without changes
assets/icon-lock.svg CHANGED
File without changes
assets/icon-pin.svg CHANGED
File without changes
assets/icon-shield.svg CHANGED
File without changes
assets/icons-seee324dde5.png CHANGED
File without changes
assets/icons_2x-s6333fe7591.png CHANGED
File without changes
assets/layers-2x.png CHANGED
File without changes
assets/layers.png CHANGED
File without changes
assets/logo-reverse.svg CHANGED
File without changes
assets/logo-symbol.svg CHANGED
File without changes
assets/logo.svg CHANGED
File without changes
assets/modal-two-factor-auth.png CHANGED
File without changes
assets/modal-two-factor-auth_2x.png CHANGED
File without changes
assets/overview-welcome-yjs.svg CHANGED
File without changes
assets/overview-welcome.svg CHANGED
File without changes
assets/plan-changed-success.svg CHANGED
File without changes
assets/request-submitted-success.svg CHANGED
File without changes
assets/select2-cf.png CHANGED
File without changes
assets/select2x2-cf.png CHANGED
File without changes
assets/spinner.gif CHANGED
File without changes
assets/vertical-range.png CHANGED
File without changes
assets/yjs-logo.svg CHANGED
File without changes
cloudflare.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cloudflare
4
  Plugin URI: https://blog.cloudflare.com/new-wordpress-plugin/
5
  Description: Cloudflare speeds up and protects your WordPress site.
6
- Version: 3.8.0
7
  Author: Cloudflare, Inc.
8
  License: BSD-3-Clause
9
  */
3
  Plugin Name: Cloudflare
4
  Plugin URI: https://blog.cloudflare.com/new-wordpress-plugin/
5
  Description: Cloudflare speeds up and protects your WordPress site.
6
+ Version: 3.8.1
7
  Author: Cloudflare, Inc.
8
  License: BSD-3-Clause
9
  */
composer.json CHANGED
@@ -29,7 +29,7 @@
29
  "_comment": [
30
  "php-compatibility-install comes from https://github.com/wimg/PHPCompatibility/issues/102#issuecomment-255778195"
31
  ],
32
- "version": "3.8.0",
33
  "config": {
34
  "platform": {
35
  "php": "5.6.40"
29
  "_comment": [
30
  "php-compatibility-install comes from https://github.com/wimg/PHPCompatibility/issues/102#issuecomment-255778195"
31
  ],
32
+ "version": "3.8.1",
33
  "config": {
34
  "platform": {
35
  "php": "5.6.40"
config.json CHANGED
@@ -1,29 +1,29 @@
1
  {
2
- "debug": false,
3
- "featureManagerIsFullZoneProvisioningEnabled": false,
4
- "isDNSPageEnabled": false,
5
- "isSubdomainCheckEnabled": true,
6
- "useHostAPILogin": false,
7
- "homePageCards": [
8
- "ApplyDefaultSettingsCard",
9
- "AutomaticPlatformOptimizationCard",
10
- "PurgeCacheCard"
11
- ],
12
- "moreSettingsCards": {
13
- "container.moresettings.speed": [
14
- "AlwaysOnlineCard",
15
- "ImageOptimizationCard",
16
- "PluginSpecificCacheCard",
17
- "DevelopmentModeCard"
18
  ],
19
- "container.moresettings.security": [
20
- "SecurityLevelCard",
21
- "WAFCard",
22
- "AdvanceDDoSCard",
23
- "AutomaticHTTPSRewritesCard"
24
- ]
25
- },
26
- "locale": "en",
27
- "integrationName": "wordpress",
28
- "version": "3.8.0"
29
- }
 
 
 
 
 
 
 
1
  {
2
+ "debug": false,
3
+ "featureManagerIsFullZoneProvisioningEnabled": false,
4
+ "isDNSPageEnabled": false,
5
+ "isSubdomainCheckEnabled": true,
6
+ "useHostAPILogin": false,
7
+ "homePageCards": [
8
+ "ApplyDefaultSettingsCard",
9
+ "AutomaticPlatformOptimizationCard",
10
+ "PurgeCacheCard"
 
 
 
 
 
 
 
11
  ],
12
+ "moreSettingsCards": {
13
+ "container.moresettings.speed": [
14
+ "AlwaysOnlineCard",
15
+ "ImageOptimizationCard",
16
+ "PluginSpecificCacheCard",
17
+ "DevelopmentModeCard"
18
+ ],
19
+ "container.moresettings.security": [
20
+ "SecurityLevelCard",
21
+ "WAFCard",
22
+ "AdvanceDDoSCard",
23
+ "AutomaticHTTPSRewritesCard"
24
+ ]
25
+ },
26
+ "locale": "en",
27
+ "integrationName": "wordpress",
28
+ "version": "3.8.1"
29
+ }
docker-compose.yaml DELETED
@@ -1,42 +0,0 @@
1
- version: '3'
2
-
3
- services:
4
- db:
5
- image: mysql:5.7
6
- volumes:
7
- - db_data:/var/lib/mysql
8
- restart: always
9
- environment:
10
- MYSQL_ROOT_PASSWORD: somewordpress
11
- MYSQL_DATABASE: wordpress
12
- MYSQL_USER: wordpress
13
- MYSQL_PASSWORD: wordpress
14
-
15
- wordpress:
16
- depends_on:
17
- - db
18
- build:
19
- dockerfile: Dockerfile.wordpress
20
- context: .
21
- volumes:
22
- - ./:/var/www/html/wp-content/plugins/cloudflare
23
- ports:
24
- - "8000:80"
25
- restart: always
26
- environment:
27
- WORDPRESS_DB_HOST: db:3306
28
- WORDPRESS_DB_USER: wordpress
29
- WORDPRESS_DB_PASSWORD: wordpress
30
- WORDPRESS_DB_NAME: wordpress
31
-
32
- adminer:
33
- image: adminer
34
- restart: always
35
- ports:
36
- - 8080:8080
37
- depends_on:
38
- - db
39
-
40
- volumes:
41
- db_data: {}
42
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fonts/cloudflare-font.eot CHANGED
File without changes
fonts/cloudflare-font.svg CHANGED
File without changes
fonts/cloudflare-font.ttf CHANGED
File without changes
fonts/cloudflare-font.woff CHANGED
File without changes
fonts/opensans-300.eot CHANGED
File without changes
fonts/opensans-300.ttf CHANGED
File without changes
fonts/opensans-300.woff CHANGED
File without changes
fonts/opensans-300.woff2 CHANGED
File without changes
fonts/opensans-300i.eot CHANGED
File without changes
fonts/opensans-300i.ttf CHANGED
File without changes
fonts/opensans-300i.woff CHANGED
File without changes
fonts/opensans-300i.woff2 CHANGED
File without changes
fonts/opensans-400.eot CHANGED
File without changes
fonts/opensans-400.ttf CHANGED
File without changes
fonts/opensans-400.woff CHANGED
File without changes
fonts/opensans-400.woff2 CHANGED
File without changes
fonts/opensans-400i.eot CHANGED
File without changes
fonts/opensans-400i.ttf CHANGED
File without changes
fonts/opensans-400i.woff CHANGED
File without changes
fonts/opensans-400i.woff2 CHANGED
File without changes
fonts/opensans-600.eot CHANGED
File without changes
fonts/opensans-600.ttf CHANGED
File without changes
fonts/opensans-600.woff CHANGED
File without changes
fonts/opensans-600.woff2 CHANGED
File without changes
fonts/opensans-700.eot CHANGED
File without changes
fonts/opensans-700.ttf CHANGED
File without changes
fonts/opensans-700.woff CHANGED
File without changes
fonts/opensans-700.woff2 CHANGED
File without changes
index.php CHANGED
@@ -3,7 +3,7 @@ if (!defined('ABSPATH')) { // Exit if accessed directly
3
  exit;
4
  }
5
 
6
- $config = new CF\Integration\DefaultConfig(file_get_contents('config.js', true));
7
  $logger = new CF\Integration\DefaultLogger($config->getValue('debug'));
8
  $dataStore = new CF\WordPress\DataStore($logger);
9
  $wordpressAPI = new CF\WordPress\WordPressAPI($dataStore);
3
  exit;
4
  }
5
 
6
+ $config = new CF\Integration\DefaultConfig(file_get_contents('config.json', true));
7
  $logger = new CF\Integration\DefaultLogger($config->getValue('debug'));
8
  $dataStore = new CF\WordPress\DataStore($logger);
9
  $wordpressAPI = new CF\WordPress\WordPressAPI($dataStore);
lang/de.js CHANGED
File without changes
lang/es.js CHANGED
File without changes
lang/fr.js CHANGED
File without changes
lang/it.js CHANGED
File without changes
lang/nl.js CHANGED
File without changes
lang/pt.js CHANGED
File without changes
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: icyapril, manatarms, thillcf, deuill, epatryk
3
  Tags: cloudflare, seo, ssl, ddos, speed, security, cdn, performance, free
4
  Requires at least: 3.4
5
  Tested up to: 5.5.1
6
- Stable tag: 3.8.0
7
  License: BSD-3-Clause
8
 
9
  All of Cloudflare’s performance and security benefits in a simple one-click install.
@@ -91,6 +91,11 @@ Yes, Cloudflare works with, and helps speed up your site even more, if you have
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
94
  = 3.8.0 - 2020-10-01 =
95
 
96
  * Added APO support
3
  Tags: cloudflare, seo, ssl, ddos, speed, security, cdn, performance, free
4
  Requires at least: 3.4
5
  Tested up to: 5.5.1
6
+ Stable tag: 3.8.1
7
  License: BSD-3-Clause
8
 
9
  All of Cloudflare’s performance and security benefits in a simple one-click install.
91
 
92
  == Changelog ==
93
 
94
+ = 3.8.1 - 2020-10-02 =
95
+
96
+ * Fixed typo in config.js(on) that resulted in warning [#292](https://github.com/cloudflare/Cloudflare-WordPress/pull/292)
97
+ * Check for array indicies are set before using [#278](https://github.com/cloudflare/Cloudflare-WordPress/pull/278)
98
+
99
  = 3.8.0 - 2020-10-01 =
100
 
101
  * Added APO support
src/WordPress/ClientActions.php CHANGED
@@ -90,10 +90,10 @@ class ClientActions
90
 
91
  public function cacheDomainName($response)
92
  {
93
- // Check if domain name needs to cached
94
  $wpDomain = $this->wordpressAPI->getOriginalDomain();
95
  $cachedDomainList = $this->wordpressAPI->getDomainList();
96
- $cachedDomain = $cachedDomainList[0];
97
 
98
  if (Utils::getRegistrableDomain($wpDomain) !== $cachedDomain) {
99
  // If it's not a subdomain cache the current domain
90
 
91
  public function cacheDomainName($response)
92
  {
93
+ // Check if domain name needs to be cached
94
  $wpDomain = $this->wordpressAPI->getOriginalDomain();
95
  $cachedDomainList = $this->wordpressAPI->getDomainList();
96
+ $cachedDomain = isset($cachedDomainList[0]) ? $cachedDomainList[0] : '';
97
 
98
  if (Utils::getRegistrableDomain($wpDomain) !== $cachedDomain) {
99
  // If it's not a subdomain cache the current domain
src/WordPress/Proxy.php CHANGED
@@ -59,7 +59,7 @@ class Proxy
59
 
60
  $response = null;
61
  $body = $request->getBody();
62
- $csrfToken = $body['cfCSRFToken'];
63
  if ($this->isCloudFlareCSRFTokenValid($request->getMethod(), $csrfToken)) {
64
  $response = $this->requestRouter->route($request);
65
  } else {
59
 
60
  $response = null;
61
  $body = $request->getBody();
62
+ $csrfToken = isset($body['cfCSRFToken']) ? $body['cfCSRFToken'] : null;
63
  if ($this->isCloudFlareCSRFTokenValid($request->getMethod(), $csrfToken)) {
64
  $response = $this->requestRouter->route($request);
65
  } else {
src/WordPress/composer.json CHANGED
@@ -29,7 +29,7 @@
29
  "_comment": [
30
  "php-compatibility-install comes from https://github.com/wimg/PHPCompatibility/issues/102#issuecomment-255778195"
31
  ],
32
- "version": "3.8.0",
33
  "config": {
34
  "platform": {
35
  "php": "5.6.40"
29
  "_comment": [
30
  "php-compatibility-install comes from https://github.com/wimg/PHPCompatibility/issues/102#issuecomment-255778195"
31
  ],
32
+ "version": "3.8.1",
33
  "config": {
34
  "platform": {
35
  "php": "5.6.40"
src/WordPress/config.json CHANGED
@@ -1,29 +1,29 @@
1
  {
2
- "debug": false,
3
- "featureManagerIsFullZoneProvisioningEnabled": false,
4
- "isDNSPageEnabled": false,
5
- "isSubdomainCheckEnabled": true,
6
- "useHostAPILogin": false,
7
- "homePageCards": [
8
- "ApplyDefaultSettingsCard",
9
- "AutomaticPlatformOptimizationCard",
10
- "PurgeCacheCard"
11
- ],
12
- "moreSettingsCards": {
13
- "container.moresettings.speed": [
14
- "AlwaysOnlineCard",
15
- "ImageOptimizationCard",
16
- "PluginSpecificCacheCard",
17
- "DevelopmentModeCard"
18
  ],
19
- "container.moresettings.security": [
20
- "SecurityLevelCard",
21
- "WAFCard",
22
- "AdvanceDDoSCard",
23
- "AutomaticHTTPSRewritesCard"
24
- ]
25
- },
26
- "locale": "en",
27
- "integrationName": "wordpress",
28
- "version": "3.8.0"
29
- }
 
 
 
 
 
 
 
1
  {
2
+ "debug": false,
3
+ "featureManagerIsFullZoneProvisioningEnabled": false,
4
+ "isDNSPageEnabled": false,
5
+ "isSubdomainCheckEnabled": true,
6
+ "useHostAPILogin": false,
7
+ "homePageCards": [
8
+ "ApplyDefaultSettingsCard",
9
+ "AutomaticPlatformOptimizationCard",
10
+ "PurgeCacheCard"
 
 
 
 
 
 
 
11
  ],
12
+ "moreSettingsCards": {
13
+ "container.moresettings.speed": [
14
+ "AlwaysOnlineCard",
15
+ "ImageOptimizationCard",
16
+ "PluginSpecificCacheCard",
17
+ "DevelopmentModeCard"
18
+ ],
19
+ "container.moresettings.security": [
20
+ "SecurityLevelCard",
21
+ "WAFCard",
22
+ "AdvanceDDoSCard",
23
+ "AutomaticHTTPSRewritesCard"
24
+ ]
25
+ },
26
+ "locale": "en",
27
+ "integrationName": "wordpress",
28
+ "version": "3.8.1"
29
+ }
stylesheets/cf.core.css CHANGED
File without changes
stylesheets/hacks.css CHANGED
File without changes
vendor/dealerdirect/phpcodesniffer-composer-installer/.yamllint DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- extends: default
3
- rules:
4
- line-length:
5
- level: warning
6
- max: 120
 
 
 
 
 
 
vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2016-2020 Dealerdirect B.V.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/dealerdirect/phpcodesniffer-composer-installer/README.md DELETED
@@ -1,250 +0,0 @@
1
- # PHP_CodeSniffer Standards Composer Installer Plugin
2
-
3
- ![Project Stage][project-stage-shield]
4
- ![Last Commit][last-updated-shield]
5
- ![Awesome][awesome-shield]
6
- [![License][license-shield]](LICENSE.md)
7
-
8
- [![Travis][travis-shield]][travis]
9
- [![Scrutinizer][scrutinizer-shield]][scrutinizer]
10
- [![Latest Version on Packagist][packagist-version-shield]][packagist-version]
11
- [![Packagist][packagist-shield]][packagist]
12
-
13
- This composer installer plugin allows for easy installation of [PHP_CodeSniffer][codesniffer] coding standards (rulesets).
14
-
15
- No more symbolic linking of directories, checking out repositories on specific locations or changing
16
- the `phpcs` configuration.
17
-
18
- _Note: This plugin is compatible with both version 2.x and 3.x of_ [PHP_CodeSniffer][codesniffer]
19
-
20
- ## Usage
21
-
22
- Installation can be done with [composer], by requiring this package as a development dependency:
23
-
24
- ```bash
25
- composer require --dev dealerdirect/phpcodesniffer-composer-installer
26
- ```
27
-
28
- That's it.
29
-
30
- ### How it works
31
-
32
- Basically, this plugin executes the following steps:
33
-
34
- - This plugin searches for `phpcodesniffer-standard` packages in all of your currently installed Composer packages.
35
- - Matching packages and the project itself are scanned for PHP_CodeSniffer rulesets.
36
- - The plugin will call PHP_CodeSniffer and configure the `installed_paths` option.
37
-
38
- ### Example project
39
-
40
- The following is an example Composer project and has included
41
- multiple `phpcodesniffer-standard` packages.
42
-
43
- ```json
44
- {
45
- "name": "dealerdirect/example-project",
46
- "description": "Just an example project",
47
- "type": "project",
48
- "require": {},
49
- "require-dev": {
50
- "dealerdirect/phpcodesniffer-composer-installer": "*",
51
- "object-calisthenics/phpcs-calisthenics-rules": "*",
52
- "phpcompatibility/php-compatibility": "*",
53
- "wp-coding-standards/wpcs": "*"
54
- }
55
- }
56
- ```
57
-
58
- After running `composer install` PHP_CodeSniffer just works:
59
-
60
- ```bash
61
- $ ./vendor/bin/phpcs -i
62
- The installed coding standards are MySource, PEAR, PSR1, PSR2, Squiz, Zend, PHPCompatibility, WordPress,
63
- WordPress-Core, WordPress-Docs, WordPress-Extra and WordPress-VIP
64
- ```
65
-
66
- ### Calling the plugin directly
67
-
68
- In some circumstances, it is desirable to call this plugin's functionality
69
- directly. For instance, during development or in [CI][definition-ci] environments.
70
-
71
- As the plugin requires Composer to work, direct calls need to be wired through a
72
- project's `composer.json`.
73
-
74
- This is done by adding a call to the `Plugin::run` function in the `script`
75
- section of the `composer.json`:
76
-
77
- ```json
78
- {
79
- "scripts": {
80
- "install-codestandards": [
81
- "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
82
- ]
83
- }
84
- }
85
-
86
- ```
87
-
88
- The command can then be called using `composer run-script install-codestandards` or
89
- referenced from other script configurations, as follows:
90
-
91
- ```json
92
- {
93
- "scripts": {
94
- "install-codestandards": [
95
- "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
96
- ],
97
- "post-install-cmd": [
98
- "@install-codestandards"
99
- ]
100
- }
101
- }
102
-
103
- ```
104
-
105
- For more details about Composer scripts, please refer to [the section on scripts
106
- in the Composer manual][composer-manual-scripts].
107
-
108
- ### Changing the Coding Standards search depth
109
-
110
- By default, this plugin searches up for Coding Standards up to three directories
111
- deep. In most cases, this should be sufficient. However, this plugin allows
112
- you to customize the search depth setting if needed.
113
-
114
- ```json
115
- {
116
- "extra": {
117
- "phpcodesniffer-search-depth": 5
118
- }
119
- }
120
- ```
121
-
122
- ### Caveats
123
-
124
- When this plugin is installed globally, composer will load the _global_ plugin rather
125
- than the one from the local repository. Despite [this behavior being documented
126
- in the composer manual][using-composer-plugins], it could potentially confuse
127
- as another version of the plugin could be run and not the one specified by the project.
128
-
129
- ## Developing Coding Standards
130
-
131
- Coding standard can be developed normally, as documented by [PHP_CodeSniffer][codesniffer], in the [Coding Standard Tutorial][tutorial].
132
-
133
- Create a composer package of your coding standard by adding a `composer.json` file.
134
-
135
- ```json
136
- {
137
- "name" : "acme/phpcodesniffer-our-standards",
138
- "description" : "Package contains all coding standards of the Acme company",
139
- "require" : {
140
- "php" : ">=5.4.0,<8.0.0-dev",
141
- "squizlabs/php_codesniffer" : "^3.0"
142
- },
143
- "type" : "phpcodesniffer-standard"
144
- }
145
- ```
146
-
147
- Requirements:
148
- * The repository may contain one or more standards.
149
- * Each standard can have a separate directory no deeper than 3 levels from the repository root.
150
- * The package `type` must be `phpcodesniffer-standard`. Without this, the plugin will not trigger.
151
-
152
- ### Requiring the plugin from within your coding standard
153
-
154
- If your coding standard itself depends on additional external PHPCS standards, this plugin can
155
- make life easier on your end-users by taking care of the installation of all standards - yours
156
- and your dependencies - for them.
157
-
158
- This can help reduce the number of support questions about setting the `installed_paths`, as well
159
- as simplify your standard's installation instructions.
160
-
161
- For this to work, make sure your external standard adds this plugin to the `composer.json` config
162
- via `require`, **not** `require-dev`.
163
-
164
- > :warning: Your end-user may already `require-dev` this plugin and/or other external standards used
165
- > by your end-users may require this plugin as well.
166
- >
167
- > To prevent your end-users getting into "_dependency hell_", make sure to make the version requirement
168
- > for this plugin flexible.
169
- >
170
- > As, for now, this plugin is still regarded as "unstable" (version < 1.0), remember that Composer
171
- > treats unstable minors as majors and will not be able to resolve one config requiring this plugin
172
- > at version `^0.5`, while another requires it at version `^0.6`.
173
- > Either allow multiple minors or use `*` as the version requirement.
174
- >
175
- > Some examples of flexible requirements which can be used:
176
- > ```bash
177
- > composer require dealerdirect/phpcodesniffer-composer-installer:"*"
178
- > composer require dealerdirect/phpcodesniffer-composer-installer:"0.*"
179
- > composer require dealerdirect/phpcodesniffer-composer-installer:"^0.4 || ^0.5 || ^0.6"
180
- > ```
181
-
182
- ## Changelog
183
-
184
- This repository does not contain a `CHANGELOG.md` file, however, we do publish a changelog on each release
185
- using the [GitHub releases][changelog] functionality.
186
-
187
- ## Contributing
188
-
189
- This is an active open-source project. We are always open to people who want to
190
- use the code or contribute to it.
191
-
192
- We've set up a separate document for our [contribution guidelines][contributing-guidelines].
193
-
194
- Thank you for being involved! :heart_eyes:
195
-
196
- ## Authors & contributors
197
-
198
- The original idea and setup of this repository is by [Franck Nijhof][frenck], employee @ Dealerdirect.
199
-
200
- For a full list of all author and/or contributors, check [the contributors page][contributors].
201
-
202
- ## License
203
-
204
- The MIT License (MIT)
205
-
206
- Copyright (c) 2016-2020 Dealerdirect B.V.
207
-
208
- Permission is hereby granted, free of charge, to any person obtaining a copy
209
- of this software and associated documentation files (the "Software"), to deal
210
- in the Software without restriction, including without limitation the rights
211
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
212
- copies of the Software, and to permit persons to whom the Software is
213
- furnished to do so, subject to the following conditions:
214
-
215
- The above copyright notice and this permission notice shall be included in
216
- all copies or substantial portions of the Software.
217
-
218
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
219
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
220
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
221
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
222
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
223
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
224
- THE SOFTWARE.
225
-
226
- [awesome-shield]: https://img.shields.io/badge/awesome%3F-yes-brightgreen.svg
227
- [changelog]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases
228
- [codesniffer]: https://github.com/squizlabs/PHP_CodeSniffer
229
- [composer-manual-scripts]: https://getcomposer.org/doc/articles/scripts.md
230
- [composer]: https://getcomposer.org/
231
- [contributing-guidelines]: CONTRIBUTING.md
232
- [contributors]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors
233
- [dealerdirectcom]: http://www.dealerdirect.com/en
234
- [definition-ci]: https://en.wikipedia.org/wiki/Continuous_integration
235
- [frenck]: https://github.com/frenck
236
- [get-in-touch]: https://www.dealerdirect.com/en/contact
237
- [license-shield]: https://img.shields.io/github/license/dealerdirect/phpcodesniffer-composer-installer.svg
238
- [last-updated-shield]: https://img.shields.io/github/last-commit/Dealerdirect/phpcodesniffer-composer-installer.svg
239
- [packagist-shield]: https://img.shields.io/packagist/dt/dealerdirect/phpcodesniffer-composer-installer.svg
240
- [packagist-version-shield]: https://img.shields.io/packagist/v/dealerdirect/phpcodesniffer-composer-installer.svg
241
- [packagist-version]: https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
242
- [packagist]: https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
243
- [project-stage-shield]: https://img.shields.io/badge/Project%20Stage-Development-yellowgreen.svg
244
- [scrutinizer-shield]: https://img.shields.io/scrutinizer/g/dealerdirect/phpcodesniffer-composer-installer.svg
245
- [scrutinizer]: https://scrutinizer-ci.com/g/dealerdirect/phpcodesniffer-composer-installer/
246
- [travis-shield]: https://img.shields.io/travis/Dealerdirect/phpcodesniffer-composer-installer.svg
247
- [travis]: https://travis-ci.org/Dealerdirect/phpcodesniffer-composer-installer
248
- [tutorial]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial
249
- [using-composer-plugins]: https://getcomposer.org/doc/articles/plugins.md#using-plugins
250
- [vacancies]: https://www.dealerdirect.com/en/vacancies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/dealerdirect/phpcodesniffer-composer-installer/composer.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "name": "dealerdirect/phpcodesniffer-composer-installer",
3
- "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
4
- "type": "composer-plugin",
5
- "keywords": [
6
- "composer", "installer", "plugin",
7
- "phpcs", "codesniffer", "phpcodesniffer", "php_codesniffer",
8
- "standard", "standards", "style guide", "stylecheck",
9
- "qa", "quality", "code quality", "tests"
10
- ],
11
- "homepage": "http://www.dealerdirect.com",
12
- "license": "MIT",
13
- "authors": [
14
- {
15
- "name": "Franck Nijhof",
16
- "email": "franck.nijhof@dealerdirect.com",
17
- "homepage": "http://www.frenck.nl",
18
- "role": "Developer / IT Manager"
19
- }
20
- ],
21
- "support": {
22
- "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
23
- "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
24
- },
25
- "require": {
26
- "php": "^5.3|^7",
27
- "composer-plugin-api": "^1.0",
28
- "squizlabs/php_codesniffer": "^2|^3"
29
- },
30
- "require-dev": {
31
- "composer/composer": "*",
32
- "sensiolabs/security-checker": "^4.1.0",
33
- "phpcompatibility/php-compatibility": "^9.0"
34
- },
35
- "autoload": {
36
- "psr-4": {
37
- "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
38
- }
39
- },
40
- "extra": {
41
- "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
42
- },
43
- "scripts": {
44
- "install-codestandards": [
45
- "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
46
- ]
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php DELETED
@@ -1,605 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * This file is part of the Dealerdirect PHP_CodeSniffer Standards
5
- * Composer Installer Plugin package.
6
- *
7
- * @copyright 2016-2020 Dealerdirect B.V.
8
- * @license MIT
9
- */
10
-
11
- namespace Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer;
12
-
13
- use Composer\Composer;
14
- use Composer\EventDispatcher\EventSubscriberInterface;
15
- use Composer\IO\IOInterface;
16
- use Composer\Package\AliasPackage;
17
- use Composer\Package\PackageInterface;
18
- use Composer\Package\RootpackageInterface;
19
- use Composer\Plugin\PluginInterface;
20
- use Composer\Script\Event;
21
- use Composer\Script\ScriptEvents;
22
- use Composer\Util\Filesystem;
23
- use Composer\Util\ProcessExecutor;
24
- use Symfony\Component\Finder\Finder;
25
- use Symfony\Component\Process\Exception\LogicException;
26
- use Symfony\Component\Process\Exception\ProcessFailedException;
27
- use Symfony\Component\Process\Exception\RuntimeException;
28
- use Symfony\Component\Process\PhpExecutableFinder;
29
-
30
- /**
31
- * PHP_CodeSniffer standard installation manager.
32
- *
33
- * @author Franck Nijhof <franck.nijhof@dealerdirect.com>
34
- */
35
- class Plugin implements PluginInterface, EventSubscriberInterface
36
- {
37
-
38
- const KEY_MAX_DEPTH = 'phpcodesniffer-search-depth';
39
-
40
- const MESSAGE_ERROR_WRONG_MAX_DEPTH =
41
- 'The value of "%s" (in the composer.json "extra".section) must be an integer larger then %d, %s given.';
42
- const MESSAGE_NOT_INSTALLED = 'PHPCodeSniffer is not installed';
43
- const MESSAGE_NOTHING_TO_INSTALL = 'Nothing to install or update';
44
- const MESSAGE_PLUGIN_UNINSTALLED = 'PHPCodeSniffer Composer Installer is uninstalled';
45
- const MESSAGE_RUNNING_INSTALLER = 'Running PHPCodeSniffer Composer Installer';
46
-
47
- const PACKAGE_NAME = 'squizlabs/php_codesniffer';
48
- const PACKAGE_TYPE = 'phpcodesniffer-standard';
49
-
50
- const PHPCS_CONFIG_REGEX = '`%s:[^\r\n]+`';
51
- const PHPCS_CONFIG_KEY = 'installed_paths';
52
-
53
- const PLUGIN_NAME = 'dealerdirect/phpcodesniffer-composer-installer';
54
-
55
- /**
56
- * @var Composer
57
- */
58
- private $composer;
59
-
60
- /**
61
- * @var string
62
- */
63
- private $cwd;
64
-
65
- /**
66
- * @var Filesystem
67
- */
68
- private $filesystem;
69
-
70
- /**
71
- * @var array
72
- */
73
- private $installedPaths;
74
-
75
- /**
76
- * @var IOInterface
77
- */
78
- private $io;
79
-
80
- /**
81
- * @var ProcessExecutor
82
- */
83
- private $processExecutor;
84
-
85
- /**
86
- * Triggers the plugin's main functionality.
87
- *
88
- * Makes it possible to run the plugin as a custom command.
89
- *
90
- * @param Event $event
91
- *
92
- * @throws \InvalidArgumentException
93
- * @throws \RuntimeException
94
- * @throws LogicException
95
- * @throws ProcessFailedException
96
- * @throws RuntimeException
97
- */
98
- public static function run(Event $event)
99
- {
100
- $io = $event->getIO();
101
- $composer = $event->getComposer();
102
-
103
- $instance = new static();
104
-
105
- $instance->io = $io;
106
- $instance->composer = $composer;
107
- $instance->init();
108
- $instance->onDependenciesChangedEvent();
109
- }
110
-
111
- /**
112
- * {@inheritDoc}
113
- *
114
- * @throws \RuntimeException
115
- * @throws LogicException
116
- * @throws ProcessFailedException
117
- * @throws RuntimeException
118
- */
119
- public function activate(Composer $composer, IOInterface $io)
120
- {
121
- $this->composer = $composer;
122
- $this->io = $io;
123
-
124
- $this->init();
125
- }
126
-
127
- /**
128
- * Prepares the plugin so it's main functionality can be run.
129
- *
130
- * @throws \RuntimeException
131
- * @throws LogicException
132
- * @throws ProcessFailedException
133
- * @throws RuntimeException
134
- */
135
- private function init()
136
- {
137
- $this->cwd = getcwd();
138
- $this->installedPaths = array();
139
-
140
- $this->processExecutor = new ProcessExecutor($this->io);
141
- $this->filesystem = new Filesystem($this->processExecutor);
142
- }
143
-
144
- /**
145
- * {@inheritDoc}
146
- */
147
- public static function getSubscribedEvents()
148
- {
149
- return array(
150
- ScriptEvents::POST_INSTALL_CMD => array(
151
- array('onDependenciesChangedEvent', 0),
152
- ),
153
- ScriptEvents::POST_UPDATE_CMD => array(
154
- array('onDependenciesChangedEvent', 0),
155
- ),
156
- );
157
- }
158
-
159
- /**
160
- * Entry point for post install and post update events.
161
- *
162
- * @throws \InvalidArgumentException
163
- * @throws LogicException
164
- * @throws ProcessFailedException
165
- * @throws RuntimeException
166
- */
167
- public function onDependenciesChangedEvent()
168
- {
169
- $io = $this->io;
170
- $isVerbose = $io->isVerbose();
171
- $exitCode = 0;
172
-
173
- if ($isVerbose) {
174
- $io->write(sprintf('<info>%s</info>', self::MESSAGE_RUNNING_INSTALLER));
175
- }
176
-
177
- if ($this->isPHPCodeSnifferInstalled() === true) {
178
- $this->loadInstalledPaths();
179
- $installPathCleaned = $this->cleanInstalledPaths();
180
- $installPathUpdated = $this->updateInstalledPaths();
181
-
182
- if ($installPathCleaned === true || $installPathUpdated === true) {
183
- $exitCode = $this->saveInstalledPaths();
184
- } elseif ($isVerbose) {
185
- $io->write(sprintf('<info>%s</info>', self::MESSAGE_NOTHING_TO_INSTALL));
186
- }
187
- } else {
188
- $pluginPackage = $this
189
- ->composer
190
- ->getRepositoryManager()
191
- ->getLocalRepository()
192
- ->findPackages(self::PLUGIN_NAME)
193
- ;
194
-
195
- $isPluginUninstalled = count($pluginPackage) === 0;
196
-
197
- if ($isPluginUninstalled) {
198
- if ($isVerbose) {
199
- $io->write(sprintf('<info>%s</info>', self::MESSAGE_PLUGIN_UNINSTALLED));
200
- }
201
- } else {
202
- $exitCode = 1;
203
- if ($isVerbose) {
204
- $io->write(sprintf('<error>%s</error>', self::MESSAGE_NOT_INSTALLED));
205
- }
206
- }
207
- }
208
-
209
- return $exitCode;
210
- }
211
-
212
- /**
213
- * Load all paths from PHP_CodeSniffer into an array.
214
- *
215
- * @throws LogicException
216
- * @throws ProcessFailedException
217
- * @throws RuntimeException
218
- */
219
- private function loadInstalledPaths()
220
- {
221
- if ($this->isPHPCodeSnifferInstalled() === true) {
222
- $this->processExecutor->execute(
223
- sprintf(
224
- 'phpcs --config-show %s',
225
- self::PHPCS_CONFIG_KEY
226
- ),
227
- $output,
228
- $this->composer->getConfig()->get('bin-dir')
229
- );
230
-
231
- $regex = sprintf(self::PHPCS_CONFIG_REGEX, self::PHPCS_CONFIG_KEY);
232
- if (preg_match($regex, $output, $match) === 1) {
233
- $phpcsInstalledPaths = str_replace(self::PHPCS_CONFIG_KEY . ': ', '', $match[0]);
234
- $phpcsInstalledPaths = trim($phpcsInstalledPaths);
235
-
236
- if ($phpcsInstalledPaths !== '') {
237
- $this->installedPaths = explode(',', $phpcsInstalledPaths);
238
- }
239
- }
240
- }
241
- }
242
-
243
- /**
244
- * Save all coding standard paths back into PHP_CodeSniffer
245
- *
246
- * @throws LogicException
247
- * @throws ProcessFailedException
248
- * @throws RuntimeException
249
- *
250
- * @return int Exit code. 0 for success, 1 or higher for failure.
251
- */
252
- private function saveInstalledPaths()
253
- {
254
- // Check if we found installed paths to set.
255
- if (count($this->installedPaths) !== 0) {
256
- $paths = implode(',', $this->installedPaths);
257
- $arguments = array('--config-set', self::PHPCS_CONFIG_KEY, $paths);
258
- $configMessage = sprintf(
259
- 'PHP CodeSniffer Config <info>%s</info> <comment>set to</comment> <info>%s</info>',
260
- self::PHPCS_CONFIG_KEY,
261
- $paths
262
- );
263
- } else {
264
- // Delete the installed paths if none were found.
265
- $arguments = array('--config-delete', self::PHPCS_CONFIG_KEY);
266
- $configMessage = sprintf(
267
- 'PHP CodeSniffer Config <info>%s</info> <comment>delete</comment>',
268
- self::PHPCS_CONFIG_KEY
269
- );
270
- }
271
-
272
- // Prepare message in case of failure
273
- $failMessage = sprintf(
274
- 'Failed to set PHP CodeSniffer <info>%s</info> Config',
275
- self::PHPCS_CONFIG_KEY
276
- );
277
-
278
- // Determine the path to the main PHPCS file.
279
- $phpcsPath = $this->getPHPCodeSnifferInstallPath();
280
- if (file_exists($phpcsPath . '/bin/phpcs') === true) {
281
- // PHPCS 3.x.
282
- $phpcsExecutable = './bin/phpcs';
283
- } else {
284
- // PHPCS 2.x.
285
- $phpcsExecutable = './scripts/phpcs';
286
- }
287
-
288
- // Okay, lets rock!
289
- $command = vsprintf(
290
- '%s %s %s',
291
- array(
292
- 'php executable' => $this->getPhpExecCommand(),
293
- 'phpcs executable' => $phpcsExecutable,
294
- 'arguments' => implode(' ', $arguments)
295
- )
296
- );
297
-
298
- $exitCode = $this->processExecutor->execute($command, $configResult, $phpcsPath);
299
- if ($exitCode === 0) {
300
- $exitCode = $this->verifySaveSuccess();
301
- }
302
-
303
- if ($exitCode === 0) {
304
- $this->io->write($configMessage);
305
- } else {
306
- $this->io->write($failMessage);
307
- }
308
-
309
- if ($this->io->isVerbose() && !empty($configResult)) {
310
- $this->io->write(sprintf('<info>%s</info>', $configResult));
311
- }
312
-
313
- return $exitCode;
314
- }
315
-
316
- /**
317
- * Verify that the paths which were expected to be saved, have been.
318
- *
319
- * @return int Exit code. 0 for success, 1 for failure.
320
- */
321
- private function verifySaveSuccess()
322
- {
323
- $exitCode = 1;
324
- $expectedPaths = $this->installedPaths;
325
-
326
- // Request the currently set installed paths after the save.
327
- $this->loadInstalledPaths();
328
-
329
- $registeredPaths = array_intersect($this->installedPaths, $expectedPaths);
330
- $registeredCount = count($registeredPaths);
331
- $expectedCount = count($expectedPaths);
332
-
333
- if ($expectedCount === $registeredCount) {
334
- $exitCode = 0;
335
- }
336
-
337
- if ($exitCode === 1 && $this->io->isVerbose()) {
338
- $verificationMessage = sprintf(
339
- "Paths to external standards found by the plugin: <info>%s</info>\n"
340
- . 'Actual paths registered with PHPCS: <info>%s</info>',
341
- implode(', ', $expectedPaths),
342
- implode(', ', $this->installedPaths)
343
- );
344
- $this->io->write($verificationMessage);
345
- }
346
-
347
- return $exitCode;
348
- }
349
-
350
- /**
351
- * Get the path to the current PHP version being used.
352
- *
353
- * Duplicate of the same in the EventDispatcher class in Composer itself.
354
- */
355
- protected function getPhpExecCommand()
356
- {
357
- $finder = new PhpExecutableFinder();
358
-
359
- $phpPath = $finder->find(false);
360
-
361
- if ($phpPath === false) {
362
- throw new \RuntimeException('Failed to locate PHP binary to execute ' . $phpPath);
363
- }
364
-
365
- $phpArgs = $finder->findArguments();
366
- $phpArgs = $phpArgs
367
- ? ' ' . implode(' ', $phpArgs)
368
- : ''
369
- ;
370
-
371
- $command = ProcessExecutor::escape($phpPath) .
372
- $phpArgs .
373
- ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen')) .
374
- ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions')) .
375
- ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'))
376
- ;
377
-
378
- return $command;
379
- }
380
-
381
- /**
382
- * Iterate trough all known paths and check if they are still valid.
383
- *
384
- * If path does not exists, is not an directory or isn't readable, the path
385
- * is removed from the list.
386
- *
387
- * @return bool True if changes where made, false otherwise
388
- */
389
- private function cleanInstalledPaths()
390
- {
391
- $changes = false;
392
- foreach ($this->installedPaths as $key => $path) {
393
- // This might be a relative path as well
394
- $alternativePath = realpath($this->getPHPCodeSnifferInstallPath() . DIRECTORY_SEPARATOR . $path);
395
-
396
- if (
397
- (is_dir($path) === false || is_readable($path) === false) &&
398
- (is_dir($alternativePath) === false || is_readable($alternativePath) === false)
399
- ) {
400
- unset($this->installedPaths[$key]);
401
- $changes = true;
402
- }
403
- }
404
- return $changes;
405
- }
406
-
407
- /**
408
- * Check all installed packages (including the root package) against
409
- * the installed paths from PHP_CodeSniffer and add the missing ones.
410
- *
411
- * @return bool True if changes where made, false otherwise
412
- *
413
- * @throws \InvalidArgumentException
414
- * @throws \RuntimeException
415
- */
416
- private function updateInstalledPaths()
417
- {
418
- $changes = false;
419
-
420
- $searchPaths = array($this->cwd);
421
- $codingStandardPackages = $this->getPHPCodingStandardPackages();
422
- foreach ($codingStandardPackages as $package) {
423
- $installPath = $this->composer->getInstallationManager()->getInstallPath($package);
424
- if ($this->filesystem->isAbsolutePath($installPath) === false) {
425
- $installPath = $this->filesystem->normalizePath(
426
- $this->cwd . DIRECTORY_SEPARATOR . $installPath
427
- );
428
- }
429
- $searchPaths[] = $installPath;
430
- }
431
-
432
- $finder = new Finder();
433
- $finder->files()
434
- ->depth('<= ' . $this->getMaxDepth())
435
- ->depth('>= ' . $this->getMinDepth())
436
- ->ignoreUnreadableDirs()
437
- ->ignoreVCS(true)
438
- ->in($searchPaths)
439
- ->name('ruleset.xml');
440
-
441
- // Process each found possible ruleset.
442
- foreach ($finder as $ruleset) {
443
- $standardsPath = $ruleset->getPath();
444
-
445
- // Pick the directory above the directory containing the standard, unless this is the project root.
446
- if ($standardsPath !== $this->cwd) {
447
- $standardsPath = dirname($standardsPath);
448
- }
449
-
450
- // Use relative paths for local project repositories.
451
- if ($this->isRunningGlobally() === false) {
452
- $standardsPath = $this->filesystem->findShortestPath(
453
- $this->getPHPCodeSnifferInstallPath(),
454
- $standardsPath,
455
- true
456
- );
457
- }
458
-
459
- // De-duplicate and add when directory is not configured.
460
- if (in_array($standardsPath, $this->installedPaths, true) === false) {
461
- $this->installedPaths[] = $standardsPath;
462
- $changes = true;
463
- }
464
- }
465
-
466
- return $changes;
467
- }
468
-
469
- /**
470
- * Iterates through Composers' local repository looking for valid Coding
471
- * Standard packages.
472
- *
473
- * If the package is the RootPackage (the one the plugin is installed into),
474
- * the package is ignored for now since it needs a different install path logic.
475
- *
476
- * @return array Composer packages containing coding standard(s)
477
- */
478
- private function getPHPCodingStandardPackages()
479
- {
480
- $codingStandardPackages = array_filter(
481
- $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(),
482
- function (PackageInterface $package) {
483
- if ($package instanceof AliasPackage) {
484
- return false;
485
- }
486
- return $package->getType() === Plugin::PACKAGE_TYPE;
487
- }
488
- );
489
-
490
- if (
491
- ! $this->composer->getPackage() instanceof RootpackageInterface
492
- && $this->composer->getPackage()->getType() === self::PACKAGE_TYPE
493
- ) {
494
- $codingStandardPackages[] = $this->composer->getPackage();
495
- }
496
-
497
- return $codingStandardPackages;
498
- }
499
-
500
- /**
501
- * Searches for the installed PHP_CodeSniffer Composer package
502
- *
503
- * @param null|string|\Composer\Semver\Constraint\ConstraintInterface $versionConstraint to match against
504
- *
505
- * @return PackageInterface|null
506
- */
507
- private function getPHPCodeSnifferPackage($versionConstraint = null)
508
- {
509
- $packages = $this
510
- ->composer
511
- ->getRepositoryManager()
512
- ->getLocalRepository()
513
- ->findPackages(self::PACKAGE_NAME, $versionConstraint);
514
-
515
- return array_shift($packages);
516
- }
517
-
518
- /**
519
- * Returns the path to the PHP_CodeSniffer package installation location
520
- *
521
- * @return string
522
- */
523
- private function getPHPCodeSnifferInstallPath()
524
- {
525
- return $this->composer->getInstallationManager()->getInstallPath($this->getPHPCodeSnifferPackage());
526
- }
527
-
528
- /**
529
- * Simple check if PHP_CodeSniffer is installed.
530
- *
531
- * @param null|string|\Composer\Semver\Constraint\ConstraintInterface $versionConstraint to match against
532
- *
533
- * @return bool Whether PHP_CodeSniffer is installed
534
- */
535
- private function isPHPCodeSnifferInstalled($versionConstraint = null)
536
- {
537
- return ($this->getPHPCodeSnifferPackage($versionConstraint) !== null);
538
- }
539
-
540
- /**
541
- * Test if composer is running "global"
542
- * This check kinda dirty, but it is the "Composer Way"
543
- *
544
- * @return bool Whether Composer is running "globally"
545
- *
546
- * @throws \RuntimeException
547
- */
548
- private function isRunningGlobally()
549
- {
550
- return ($this->composer->getConfig()->get('home') === $this->cwd);
551
- }
552
-
553
- /**
554
- * Determines the maximum search depth when searching for Coding Standards.
555
- *
556
- * @return int
557
- *
558
- * @throws \InvalidArgumentException
559
- */
560
- private function getMaxDepth()
561
- {
562
- $maxDepth = 3;
563
-
564
- $extra = $this->composer->getPackage()->getExtra();
565
-
566
- if (array_key_exists(self::KEY_MAX_DEPTH, $extra)) {
567
- $maxDepth = $extra[self::KEY_MAX_DEPTH];
568
- $minDepth = $this->getMinDepth();
569
-
570
- if (
571
- (string) (int) $maxDepth !== (string) $maxDepth /* Must be an integer or cleanly castable to one */
572
- || $maxDepth <= $minDepth /* Larger than the minimum */
573
- || is_float($maxDepth) === true /* Within the boundaries of integer */
574
- ) {
575
- $message = vsprintf(
576
- self::MESSAGE_ERROR_WRONG_MAX_DEPTH,
577
- array(
578
- 'key' => self::KEY_MAX_DEPTH,
579
- 'min' => $minDepth,
580
- 'given' => var_export($maxDepth, true),
581
- )
582
- );
583
-
584
- throw new \InvalidArgumentException($message);
585
- }
586
- }
587
-
588
- return (int) $maxDepth;
589
- }
590
-
591
- /**
592
- * Returns the minimal search depth for Coding Standard packages.
593
- *
594
- * Usually this is 0, unless PHP_CodeSniffer >= 3 is used.
595
- *
596
- * @return int
597
- */
598
- private function getMinDepth()
599
- {
600
- if ($this->isPHPCodeSnifferInstalled('>= 3.0.0') !== true) {
601
- return 1;
602
- }
603
- return 0;
604
- }
605
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/.gitattributes DELETED
@@ -1,7 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
3
-
4
- *.png binary
5
-
6
- tests/ export-ignore
7
- phpunit.xml.dist export-ignore
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- /composer.phar
2
- /composer.lock
3
- /vendor/*
 
 
 
vendor/myclabs/deep-copy/.travis.yml DELETED
@@ -1,40 +0,0 @@
1
- language: php
2
-
3
- sudo: false
4
-
5
- php:
6
- - '5.6'
7
- - '7.0'
8
- - '7.1'
9
- - nightly
10
-
11
- matrix:
12
- fast_finish: true
13
- include:
14
- - php: '5.6'
15
- env: COMPOSER_FLAGS="--prefer-lowest"
16
- allow_failures:
17
- - php: nightly
18
-
19
- cache:
20
- directories:
21
- - $HOME/.composer/cache/files
22
-
23
- before_install:
24
- - |
25
- if [ "$TRAVIS_PHP_VERSION" = "nightly" ]; then
26
- COMPOSER_FLAGS="$COMPOSER_FLAGS --ignore-platform-reqs"
27
- fi;
28
-
29
- install:
30
- - composer update --no-interaction --no-progress --no-suggest --prefer-dist $COMPOSER_FLAGS
31
- - wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.0/coveralls.phar
32
-
33
- before_script:
34
- - mkdir -p build/logs
35
-
36
- script:
37
- - vendor/bin/phpunit --coverage-clover build/logs/clover.xml
38
-
39
- after_script:
40
- - php coveralls.phar -v
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 My C-Sense
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/README.md DELETED
@@ -1,372 +0,0 @@
1
- # DeepCopy
2
-
3
- DeepCopy helps you create deep copies (clones) of your objects. It is designed to handle cycles in the association graph.
4
-
5
- [![Build Status](https://travis-ci.org/myclabs/DeepCopy.png?branch=master)](https://travis-ci.org/myclabs/DeepCopy)
6
- [![Coverage Status](https://coveralls.io/repos/myclabs/DeepCopy/badge.png?branch=master)](https://coveralls.io/r/myclabs/DeepCopy?branch=master)
7
- [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/myclabs/DeepCopy/badges/quality-score.png?s=2747100c19b275f93a777e3297c6c12d1b68b934)](https://scrutinizer-ci.com/g/myclabs/DeepCopy/)
8
- [![Total Downloads](https://poser.pugx.org/myclabs/deep-copy/downloads.svg)](https://packagist.org/packages/myclabs/deep-copy)
9
-
10
-
11
- ## Table of Contents
12
-
13
- 1. [How](#how)
14
- 1. [Why](#why)
15
- 1. [Using simply `clone`](#using-simply-clone)
16
- 1. [Overridding `__clone()`](#overridding-__clone)
17
- 1. [With `DeepCopy`](#with-deepcopy)
18
- 1. [How it works](#how-it-works)
19
- 1. [Going further](#going-further)
20
- 1. [Matchers](#matchers)
21
- 1. [Property name](#property-name)
22
- 1. [Specific property](#specific-property)
23
- 1. [Type](#type)
24
- 1. [Filters](#filters)
25
- 1. [`SetNullFilter`](#setnullfilter-filter)
26
- 1. [`KeepFilter`](#keepfilter-filter)
27
- 1. [`DoctrineCollectionFilter`](#doctrinecollectionfilter-filter)
28
- 1. [`DoctrineEmptyCollectionFilter`](#doctrineemptycollectionfilter-filter)
29
- 1. [`DoctrineProxyFilter`](#doctrineproxyfilter-filter)
30
- 1. [`ReplaceFilter`](#replacefilter-type-filter)
31
- 1. [`ShallowCopyFilter`](#doctrinecollectionfilter-type-filter)
32
- 1. [Edge cases](#edge-cases)
33
- 1. [Contributing](#contributing)
34
- 1. [Tests](#tests)
35
-
36
-
37
- ## How?
38
-
39
- Install with Composer:
40
-
41
- ```json
42
- composer require myclabs/deep-copy
43
- ```
44
-
45
- Use simply:
46
-
47
- ```php
48
- use DeepCopy\DeepCopy;
49
-
50
- $copier = new DeepCopy();
51
- $myCopy = $copier->copy($myObject);
52
- ```
53
-
54
-
55
- ## Why?
56
-
57
- - How do you create copies of your objects?
58
-
59
- ```php
60
- $myCopy = clone $myObject;
61
- ```
62
-
63
- - How do you create **deep** copies of your objects (i.e. copying also all the objects referenced in the properties)?
64
-
65
- You use [`__clone()`](http://www.php.net/manual/en/language.oop5.cloning.php#object.clone) and implement the behavior
66
- yourself.
67
-
68
- - But how do you handle **cycles** in the association graph?
69
-
70
- Now you're in for a big mess :(
71
-
72
- ![association graph](doc/graph.png)
73
-
74
-
75
- ### Using simply `clone`
76
-
77
- ![Using clone](doc/clone.png)
78
-
79
-
80
- ### Overridding `__clone()`
81
-
82
- ![Overridding __clone](doc/deep-clone.png)
83
-
84
-
85
- ### With `DeepCopy`
86
-
87
- ![With DeepCopy](doc/deep-copy.png)
88
-
89
-
90
- ## How it works
91
-
92
- DeepCopy recursively traverses all the object's properties and clones them. To avoid cloning the same object twice it
93
- keeps a hash map of all instances and thus preserves the object graph.
94
-
95
- To use it:
96
-
97
- ```php
98
- use function DeepCopy\deep_copy;
99
-
100
- $copy = deep_copy($var);
101
- ```
102
-
103
- Alternatively, you can create your own `DeepCopy` instance to configure it differently for example:
104
-
105
- ```php
106
- use DeepCopy\DeepCopy;
107
-
108
- $copier = new DeepCopy(true);
109
-
110
- $copy = $copier->copy($var);
111
- ```
112
-
113
- You may want to roll your own deep copy function:
114
-
115
- ```php
116
- namespace Acme;
117
-
118
- use DeepCopy\DeepCopy;
119
-
120
- function deep_copy($var)
121
- {
122
- static $copier = null;
123
-
124
- if (null === $copier) {
125
- $copier = new DeepCopy(true);
126
- }
127
-
128
- return $copier->copy($var);
129
- }
130
- ```
131
-
132
-
133
- ## Going further
134
-
135
- You can add filters to customize the copy process.
136
-
137
- The method to add a filter is `DeepCopy\DeepCopy::addFilter($filter, $matcher)`,
138
- with `$filter` implementing `DeepCopy\Filter\Filter`
139
- and `$matcher` implementing `DeepCopy\Matcher\Matcher`.
140
-
141
- We provide some generic filters and matchers.
142
-
143
-
144
- ### Matchers
145
-
146
- - `DeepCopy\Matcher` applies on a object attribute.
147
- - `DeepCopy\TypeMatcher` applies on any element found in graph, including array elements.
148
-
149
-
150
- #### Property name
151
-
152
- The `PropertyNameMatcher` will match a property by its name:
153
-
154
- ```php
155
- use DeepCopy\Matcher\PropertyNameMatcher;
156
-
157
- // Will apply a filter to any property of any objects named "id"
158
- $matcher = new PropertyNameMatcher('id');
159
- ```
160
-
161
-
162
- #### Specific property
163
-
164
- The `PropertyMatcher` will match a specific property of a specific class:
165
-
166
- ```php
167
- use DeepCopy\Matcher\PropertyMatcher;
168
-
169
- // Will apply a filter to the property "id" of any objects of the class "MyClass"
170
- $matcher = new PropertyMatcher('MyClass', 'id');
171
- ```
172
-
173
-
174
- #### Type
175
-
176
- The `TypeMatcher` will match any element by its type (instance of a class or any value that could be parameter of
177
- [gettype()](http://php.net/manual/en/function.gettype.php) function):
178
-
179
- ```php
180
- use DeepCopy\TypeMatcher\TypeMatcher;
181
-
182
- // Will apply a filter to any object that is an instance of Doctrine\Common\Collections\Collection
183
- $matcher = new TypeMatcher('Doctrine\Common\Collections\Collection');
184
- ```
185
-
186
-
187
- ### Filters
188
-
189
- - `DeepCopy\Filter` applies a transformation to the object attribute matched by `DeepCopy\Matcher`
190
- - `DeepCopy\TypeFilter` applies a transformation to any element matched by `DeepCopy\TypeMatcher`
191
-
192
-
193
- #### `SetNullFilter` (filter)
194
-
195
- Let's say for example that you are copying a database record (or a Doctrine entity), so you want the copy not to have
196
- any ID:
197
-
198
- ```php
199
- use DeepCopy\DeepCopy;
200
- use DeepCopy\Filter\SetNullFilter;
201
- use DeepCopy\Matcher\PropertyNameMatcher;
202
-
203
- $object = MyClass::load(123);
204
- echo $object->id; // 123
205
-
206
- $copier = new DeepCopy();
207
- $copier->addFilter(new SetNullFilter(), new PropertyNameMatcher('id'));
208
-
209
- $copy = $copier->copy($object);
210
-
211
- echo $copy->id; // null
212
- ```
213
-
214
-
215
- #### `KeepFilter` (filter)
216
-
217
- If you want a property to remain untouched (for example, an association to an object):
218
-
219
- ```php
220
- use DeepCopy\DeepCopy;
221
- use DeepCopy\Filter\KeepFilter;
222
- use DeepCopy\Matcher\PropertyMatcher;
223
-
224
- $copier = new DeepCopy();
225
- $copier->addFilter(new KeepFilter(), new PropertyMatcher('MyClass', 'category'));
226
-
227
- $copy = $copier->copy($object);
228
- // $copy->category has not been touched
229
- ```
230
-
231
-
232
- #### `DoctrineCollectionFilter` (filter)
233
-
234
- If you use Doctrine and want to copy an entity, you will need to use the `DoctrineCollectionFilter`:
235
-
236
- ```php
237
- use DeepCopy\DeepCopy;
238
- use DeepCopy\Filter\Doctrine\DoctrineCollectionFilter;
239
- use DeepCopy\Matcher\PropertyTypeMatcher;
240
-
241
- $copier = new DeepCopy();
242
- $copier->addFilter(new DoctrineCollectionFilter(), new PropertyTypeMatcher('Doctrine\Common\Collections\Collection'));
243
-
244
- $copy = $copier->copy($object);
245
- ```
246
-
247
-
248
- #### `DoctrineEmptyCollectionFilter` (filter)
249
-
250
- If you use Doctrine and want to copy an entity who contains a `Collection` that you want to be reset, you can use the
251
- `DoctrineEmptyCollectionFilter`
252
-
253
- ```php
254
- use DeepCopy\DeepCopy;
255
- use DeepCopy\Filter\Doctrine\DoctrineEmptyCollectionFilter;
256
- use DeepCopy\Matcher\PropertyMatcher;
257
-
258
- $copier = new DeepCopy();
259
- $copier->addFilter(new DoctrineEmptyCollectionFilter(), new PropertyMatcher('MyClass', 'myProperty'));
260
-
261
- $copy = $copier->copy($object);
262
-
263
- // $copy->myProperty will return an empty collection
264
- ```
265
-
266
-
267
- #### `DoctrineProxyFilter` (filter)
268
-
269
- If you use Doctrine and use cloning on lazy loaded entities, you might encounter errors mentioning missing fields on a
270
- Doctrine proxy class (...\\\_\_CG\_\_\Proxy).
271
- You can use the `DoctrineProxyFilter` to load the actual entity behind the Doctrine proxy class.
272
- **Make sure, though, to put this as one of your very first filters in the filter chain so that the entity is loaded
273
- before other filters are applied!**
274
-
275
- ```php
276
- use DeepCopy\DeepCopy;
277
- use DeepCopy\Filter\Doctrine\DoctrineProxyFilter;
278
- use DeepCopy\Matcher\Doctrine\DoctrineProxyMatcher;
279
-
280
- $copier = new DeepCopy();
281
- $copier->addFilter(new DoctrineProxyFilter(), new DoctrineProxyMatcher());
282
-
283
- $copy = $copier->copy($object);
284
-
285
- // $copy should now contain a clone of all entities, including those that were not yet fully loaded.
286
- ```
287
-
288
-
289
- #### `ReplaceFilter` (type filter)
290
-
291
- 1. If you want to replace the value of a property:
292
-
293
- ```php
294
- use DeepCopy\DeepCopy;
295
- use DeepCopy\Filter\ReplaceFilter;
296
- use DeepCopy\Matcher\PropertyMatcher;
297
-
298
- $copier = new DeepCopy();
299
- $callback = function ($currentValue) {
300
- return $currentValue . ' (copy)'
301
- };
302
- $copier->addFilter(new ReplaceFilter($callback), new PropertyMatcher('MyClass', 'title'));
303
-
304
- $copy = $copier->copy($object);
305
-
306
- // $copy->title will contain the data returned by the callback, e.g. 'The title (copy)'
307
- ```
308
-
309
- 2. If you want to replace whole element:
310
-
311
- ```php
312
- use DeepCopy\DeepCopy;
313
- use DeepCopy\TypeFilter\ReplaceFilter;
314
- use DeepCopy\TypeMatcher\TypeMatcher;
315
-
316
- $copier = new DeepCopy();
317
- $callback = function (MyClass $myClass) {
318
- return get_class($myClass);
319
- };
320
- $copier->addTypeFilter(new ReplaceFilter($callback), new TypeMatcher('MyClass'));
321
-
322
- $copy = $copier->copy([new MyClass, 'some string', new MyClass]);
323
-
324
- // $copy will contain ['MyClass', 'some string', 'MyClass']
325
- ```
326
-
327
-
328
- The `$callback` parameter of the `ReplaceFilter` constructor accepts any PHP callable.
329
-
330
-
331
- #### `ShallowCopyFilter` (type filter)
332
-
333
- Stop *DeepCopy* from recursively copying element, using standard `clone` instead:
334
-
335
- ```php
336
- use DeepCopy\DeepCopy;
337
- use DeepCopy\TypeFilter\ShallowCopyFilter;
338
- use DeepCopy\TypeMatcher\TypeMatcher;
339
- use Mockery as m;
340
-
341
- $this->deepCopy = new DeepCopy();
342
- $this->deepCopy->addTypeFilter(
343
- new ShallowCopyFilter,
344
- new TypeMatcher(m\MockInterface::class)
345
- );
346
-
347
- $myServiceWithMocks = new MyService(m::mock(MyDependency1::class), m::mock(MyDependency2::class));
348
- // All mocks will be just cloned, not deep copied
349
- ```
350
-
351
-
352
- ## Edge cases
353
-
354
- The following structures cannot be deep-copied with PHP Reflection. As a result they are shallow cloned and filters are
355
- not applied. There is two ways for you to handle them:
356
-
357
- - Implement your own `__clone()` method
358
- - Use a filter with a type matcher
359
-
360
-
361
- ## Contributing
362
-
363
- DeepCopy is distributed under the MIT license.
364
-
365
-
366
- ### Tests
367
-
368
- Running the tests is simple:
369
-
370
- ```php
371
- vendor/bin/phpunit
372
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/composer.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "name": "myclabs/deep-copy",
3
- "type": "library",
4
- "description": "Create deep copies (clones) of your objects",
5
- "keywords": ["clone", "copy", "duplicate", "object", "object graph"],
6
- "license": "MIT",
7
-
8
- "autoload": {
9
- "psr-4": {
10
- "DeepCopy\\": "src/DeepCopy/"
11
- },
12
- "files": [
13
- "src/DeepCopy/deep_copy.php"
14
- ]
15
- },
16
- "autoload-dev": {
17
- "psr-4": {
18
- "DeepCopy\\": "fixtures/",
19
- "DeepCopyTest\\": "tests/DeepCopyTest/"
20
- }
21
- },
22
-
23
- "require": {
24
- "php": "^5.6 || ^7.0"
25
- },
26
- "require-dev": {
27
- "doctrine/collections": "^1.0",
28
- "doctrine/common": "^2.6",
29
- "phpunit/phpunit": "^4.1"
30
- },
31
-
32
- "config": {
33
- "sort-packages": true
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/doc/clone.png DELETED
Binary file
vendor/myclabs/deep-copy/doc/deep-clone.png DELETED
Binary file
vendor/myclabs/deep-copy/doc/deep-copy.png DELETED
Binary file
vendor/myclabs/deep-copy/doc/graph.png DELETED
Binary file
vendor/myclabs/deep-copy/fixtures/f001/A.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f001;
4
-
5
- class A
6
- {
7
- private $aProp;
8
-
9
- public function getAProp()
10
- {
11
- return $this->aProp;
12
- }
13
-
14
- public function setAProp($prop)
15
- {
16
- $this->aProp = $prop;
17
-
18
- return $this;
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f001/B.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f001;
4
-
5
- class B extends A
6
- {
7
- private $bProp;
8
-
9
- public function getBProp()
10
- {
11
- return $this->bProp;
12
- }
13
-
14
- public function setBProp($prop)
15
- {
16
- $this->bProp = $prop;
17
-
18
- return $this;
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f002/A.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f002;
4
-
5
- class A
6
- {
7
- private $prop1;
8
- private $prop2;
9
-
10
- public function getProp1()
11
- {
12
- return $this->prop1;
13
- }
14
-
15
- public function setProp1($prop)
16
- {
17
- $this->prop1 = $prop;
18
-
19
- return $this;
20
- }
21
-
22
- public function getProp2()
23
- {
24
- return $this->prop2;
25
- }
26
-
27
- public function setProp2($prop)
28
- {
29
- $this->prop2 = $prop;
30
-
31
- return $this;
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f003/Foo.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f003;
4
-
5
- class Foo
6
- {
7
- private $name;
8
- private $prop;
9
-
10
- public function __construct($name)
11
- {
12
- $this->name = $name;
13
- }
14
-
15
- public function getProp()
16
- {
17
- return $this->prop;
18
- }
19
-
20
- public function setProp($prop)
21
- {
22
- $this->prop = $prop;
23
-
24
- return $this;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f004/UnclonableItem.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f004;
4
-
5
- use BadMethodCallException;
6
-
7
- class UnclonableItem
8
- {
9
- private function __clone()
10
- {
11
- throw new BadMethodCallException('Unsupported call.');
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f005/Foo.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f005;
4
-
5
- class Foo
6
- {
7
- public $cloned = false;
8
-
9
- public function __clone()
10
- {
11
- $this->cloned = true;
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f006/A.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f006;
4
-
5
- class A
6
- {
7
- public $cloned = false;
8
- private $aProp;
9
-
10
- public function getAProp()
11
- {
12
- return $this->aProp;
13
- }
14
-
15
- public function setAProp($prop)
16
- {
17
- $this->aProp = $prop;
18
-
19
- return $this;
20
- }
21
-
22
- public function __clone()
23
- {
24
- $this->cloned = true;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f006/B.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f006;
4
-
5
- class B
6
- {
7
- public $cloned = false;
8
- private $bProp;
9
-
10
- public function getBProp()
11
- {
12
- return $this->bProp;
13
- }
14
-
15
- public function setBProp($prop)
16
- {
17
- $this->bProp = $prop;
18
-
19
- return $this;
20
- }
21
-
22
- public function __clone()
23
- {
24
- $this->cloned = true;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f007/FooDateInterval.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f007;
4
-
5
- use DateInterval;
6
-
7
- class FooDateInterval extends DateInterval
8
- {
9
- public $cloned = false;
10
-
11
- public function __clone()
12
- {
13
- $this->cloned = true;
14
- }
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f007/FooDateTimeZone.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f007;
4
-
5
- use DateTimeZone;
6
-
7
- class FooDateTimeZone extends DateTimeZone
8
- {
9
- public $cloned = false;
10
-
11
- public function __clone()
12
- {
13
- $this->cloned = true;
14
- }
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f008/A.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f008;
4
-
5
- class A
6
- {
7
- private $foo;
8
-
9
- public function __construct($foo)
10
- {
11
- $this->foo = $foo;
12
- }
13
-
14
- public function getFoo()
15
- {
16
- return $this->foo;
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/fixtures/f008/B.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\f008;
4
-
5
- class B extends A
6
- {
7
- }
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/DeepCopy.php DELETED
@@ -1,281 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy;
4
-
5
- use DateInterval;
6
- use DateTimeInterface;
7
- use DateTimeZone;
8
- use DeepCopy\Exception\CloneException;
9
- use DeepCopy\Filter\Filter;
10
- use DeepCopy\Matcher\Matcher;
11
- use DeepCopy\TypeFilter\Date\DateIntervalFilter;
12
- use DeepCopy\TypeFilter\Spl\SplDoublyLinkedListFilter;
13
- use DeepCopy\TypeFilter\TypeFilter;
14
- use DeepCopy\TypeMatcher\TypeMatcher;
15
- use ReflectionObject;
16
- use ReflectionProperty;
17
- use DeepCopy\Reflection\ReflectionHelper;
18
- use SplDoublyLinkedList;
19
-
20
- /**
21
- * @final
22
- */
23
- class DeepCopy
24
- {
25
- /**
26
- * @var object[] List of objects copied.
27
- */
28
- private $hashMap = [];
29
-
30
- /**
31
- * Filters to apply.
32
- *
33
- * @var array Array of ['filter' => Filter, 'matcher' => Matcher] pairs.
34
- */
35
- private $filters = [];
36
-
37
- /**
38
- * Type Filters to apply.
39
- *
40
- * @var array Array of ['filter' => Filter, 'matcher' => Matcher] pairs.
41
- */
42
- private $typeFilters = [];
43
-
44
- /**
45
- * @var bool
46
- */
47
- private $skipUncloneable = false;
48
-
49
- /**
50
- * @var bool
51
- */
52
- private $useCloneMethod;
53
-
54
- /**
55
- * @param bool $useCloneMethod If set to true, when an object implements the __clone() function, it will be used
56
- * instead of the regular deep cloning.
57
- */
58
- public function __construct($useCloneMethod = false)
59
- {
60
- $this->useCloneMethod = $useCloneMethod;
61
-
62
- $this->addTypeFilter(new DateIntervalFilter(), new TypeMatcher(DateInterval::class));
63
- $this->addTypeFilter(new SplDoublyLinkedListFilter($this), new TypeMatcher(SplDoublyLinkedList::class));
64
- }
65
-
66
- /**
67
- * If enabled, will not throw an exception when coming across an uncloneable property.
68
- *
69
- * @param $skipUncloneable
70
- *
71
- * @return $this
72
- */
73
- public function skipUncloneable($skipUncloneable = true)
74
- {
75
- $this->skipUncloneable = $skipUncloneable;
76
-
77
- return $this;
78
- }
79
-
80
- /**
81
- * Deep copies the given object.
82
- *
83
- * @param mixed $object
84
- *
85
- * @return mixed
86
- */
87
- public function copy($object)
88
- {
89
- $this->hashMap = [];
90
-
91
- return $this->recursiveCopy($object);
92
- }
93
-
94
- public function addFilter(Filter $filter, Matcher $matcher)
95
- {
96
- $this->filters[] = [
97
- 'matcher' => $matcher,
98
- 'filter' => $filter,
99
- ];
100
- }
101
-
102
- public function addTypeFilter(TypeFilter $filter, TypeMatcher $matcher)
103
- {
104
- $this->typeFilters[] = [
105
- 'matcher' => $matcher,
106
- 'filter' => $filter,
107
- ];
108
- }
109
-
110
- private function recursiveCopy($var)
111
- {
112
- // Matches Type Filter
113
- if ($filter = $this->getFirstMatchedTypeFilter($this->typeFilters, $var)) {
114
- return $filter->apply($var);
115
- }
116
-
117
- // Resource
118
- if (is_resource($var)) {
119
- return $var;
120
- }
121
-
122
- // Array
123
- if (is_array($var)) {
124
- return $this->copyArray($var);
125
- }
126
-
127
- // Scalar
128
- if (! is_object($var)) {
129
- return $var;
130
- }
131
-
132
- // Object
133
- return $this->copyObject($var);
134
- }
135
-
136
- /**
137
- * Copy an array
138
- * @param array $array
139
- * @return array
140
- */
141
- private function copyArray(array $array)
142
- {
143
- foreach ($array as $key => $value) {
144
- $array[$key] = $this->recursiveCopy($value);
145
- }
146
-
147
- return $array;
148
- }
149
-
150
- /**
151
- * Copies an object.
152
- *
153
- * @param object $object
154
- *
155
- * @throws CloneException
156
- *
157
- * @return object
158
- */
159
- private function copyObject($object)
160
- {
161
- $objectHash = spl_object_hash($object);
162
-
163
- if (isset($this->hashMap[$objectHash])) {
164
- return $this->hashMap[$objectHash];
165
- }
166
-
167
- $reflectedObject = new ReflectionObject($object);
168
- $isCloneable = $reflectedObject->isCloneable();
169
-
170
- if (false === $isCloneable) {
171
- if ($this->skipUncloneable) {
172
- $this->hashMap[$objectHash] = $object;
173
-
174
- return $object;
175
- }
176
-
177
- throw new CloneException(
178
- sprintf(
179
- 'The class "%s" is not cloneable.',
180
- $reflectedObject->getName()
181
- )
182
- );
183
- }
184
-
185
- $newObject = clone $object;
186
- $this->hashMap[$objectHash] = $newObject;
187
-
188
- if ($this->useCloneMethod && $reflectedObject->hasMethod('__clone')) {
189
- return $newObject;
190
- }
191
-
192
- if ($newObject instanceof DateTimeInterface || $newObject instanceof DateTimeZone) {
193
- return $newObject;
194
- }
195
-
196
- foreach (ReflectionHelper::getProperties($reflectedObject) as $property) {
197
- $this->copyObjectProperty($newObject, $property);
198
- }
199
-
200
- return $newObject;
201
- }
202
-
203
- private function copyObjectProperty($object, ReflectionProperty $property)
204
- {
205
- // Ignore static properties
206
- if ($property->isStatic()) {
207
- return;
208
- }
209
-
210
- // Apply the filters
211
- foreach ($this->filters as $item) {
212
- /** @var Matcher $matcher */
213
- $matcher = $item['matcher'];
214
- /** @var Filter $filter */
215
- $filter = $item['filter'];
216
-
217
- if ($matcher->matches($object, $property->getName())) {
218
- $filter->apply(
219
- $object,
220
- $property->getName(),
221
- function ($object) {
222
- return $this->recursiveCopy($object);
223
- }
224
- );
225
-
226
- // If a filter matches, we stop processing this property
227
- return;
228
- }
229
- }
230
-
231
- $property->setAccessible(true);
232
- $propertyValue = $property->getValue($object);
233
-
234
- // Copy the property
235
- $property->setValue($object, $this->recursiveCopy($propertyValue));
236
- }
237
-
238
- /**
239
- * Returns first filter that matches variable, `null` if no such filter found.
240
- *
241
- * @param array $filterRecords Associative array with 2 members: 'filter' with value of type {@see TypeFilter} and
242
- * 'matcher' with value of type {@see TypeMatcher}
243
- * @param mixed $var
244
- *
245
- * @return TypeFilter|null
246
- */
247
- private function getFirstMatchedTypeFilter(array $filterRecords, $var)
248
- {
249
- $matched = $this->first(
250
- $filterRecords,
251
- function (array $record) use ($var) {
252
- /* @var TypeMatcher $matcher */
253
- $matcher = $record['matcher'];
254
-
255
- return $matcher->matches($var);
256
- }
257
- );
258
-
259
- return isset($matched) ? $matched['filter'] : null;
260
- }
261
-
262
- /**
263
- * Returns first element that matches predicate, `null` if no such element found.
264
- *
265
- * @param array $elements Array of ['filter' => Filter, 'matcher' => Matcher] pairs.
266
- * @param callable $predicate Predicate arguments are: element.
267
- *
268
- * @return array|null Associative array with 2 members: 'filter' with value of type {@see TypeFilter} and 'matcher'
269
- * with value of type {@see TypeMatcher} or `null`.
270
- */
271
- private function first(array $elements, callable $predicate)
272
- {
273
- foreach ($elements as $element) {
274
- if (call_user_func($predicate, $element)) {
275
- return $element;
276
- }
277
- }
278
-
279
- return null;
280
- }
281
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Exception/CloneException.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Exception;
4
-
5
- use UnexpectedValueException;
6
-
7
- class CloneException extends UnexpectedValueException
8
- {
9
- }
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Exception/PropertyException.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Exception;
4
-
5
- use ReflectionException;
6
-
7
- class PropertyException extends ReflectionException
8
- {
9
- }
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter\Doctrine;
4
-
5
- use DeepCopy\Filter\Filter;
6
- use DeepCopy\Reflection\ReflectionHelper;
7
-
8
- /**
9
- * @final
10
- */
11
- class DoctrineCollectionFilter implements Filter
12
- {
13
- /**
14
- * Copies the object property doctrine collection.
15
- *
16
- * {@inheritdoc}
17
- */
18
- public function apply($object, $property, $objectCopier)
19
- {
20
- $reflectionProperty = ReflectionHelper::getProperty($object, $property);
21
-
22
- $reflectionProperty->setAccessible(true);
23
- $oldCollection = $reflectionProperty->getValue($object);
24
-
25
- $newCollection = $oldCollection->map(
26
- function ($item) use ($objectCopier) {
27
- return $objectCopier($item);
28
- }
29
- );
30
-
31
- $reflectionProperty->setValue($object, $newCollection);
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineEmptyCollectionFilter.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter\Doctrine;
4
-
5
- use DeepCopy\Filter\Filter;
6
- use DeepCopy\Reflection\ReflectionHelper;
7
- use Doctrine\Common\Collections\ArrayCollection;
8
-
9
- /**
10
- * @final
11
- */
12
- class DoctrineEmptyCollectionFilter implements Filter
13
- {
14
- /**
15
- * Sets the object property to an empty doctrine collection.
16
- *
17
- * @param object $object
18
- * @param string $property
19
- * @param callable $objectCopier
20
- */
21
- public function apply($object, $property, $objectCopier)
22
- {
23
- $reflectionProperty = ReflectionHelper::getProperty($object, $property);
24
- $reflectionProperty->setAccessible(true);
25
-
26
- $reflectionProperty->setValue($object, new ArrayCollection());
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/Doctrine/DoctrineProxyFilter.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter\Doctrine;
4
-
5
- use DeepCopy\Filter\Filter;
6
-
7
- /**
8
- * @final
9
- */
10
- class DoctrineProxyFilter implements Filter
11
- {
12
- /**
13
- * Triggers the magic method __load() on a Doctrine Proxy class to load the
14
- * actual entity from the database.
15
- *
16
- * {@inheritdoc}
17
- */
18
- public function apply($object, $property, $objectCopier)
19
- {
20
- $object->__load();
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/Filter.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter;
4
-
5
- /**
6
- * Filter to apply to a property while copying an object
7
- */
8
- interface Filter
9
- {
10
- /**
11
- * Applies the filter to the object.
12
- *
13
- * @param object $object
14
- * @param string $property
15
- * @param callable $objectCopier
16
- */
17
- public function apply($object, $property, $objectCopier);
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/KeepFilter.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter;
4
-
5
- class KeepFilter implements Filter
6
- {
7
- /**
8
- * Keeps the value of the object property.
9
- *
10
- * {@inheritdoc}
11
- */
12
- public function apply($object, $property, $objectCopier)
13
- {
14
- // Nothing to do
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/ReplaceFilter.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter;
4
-
5
- use DeepCopy\Reflection\ReflectionHelper;
6
-
7
- /**
8
- * @final
9
- */
10
- class ReplaceFilter implements Filter
11
- {
12
- /**
13
- * @var callable
14
- */
15
- protected $callback;
16
-
17
- /**
18
- * @param callable $callable Will be called to get the new value for each property to replace
19
- */
20
- public function __construct(callable $callable)
21
- {
22
- $this->callback = $callable;
23
- }
24
-
25
- /**
26
- * Replaces the object property by the result of the callback called with the object property.
27
- *
28
- * {@inheritdoc}
29
- */
30
- public function apply($object, $property, $objectCopier)
31
- {
32
- $reflectionProperty = ReflectionHelper::getProperty($object, $property);
33
- $reflectionProperty->setAccessible(true);
34
-
35
- $value = call_user_func($this->callback, $reflectionProperty->getValue($object));
36
-
37
- $reflectionProperty->setValue($object, $value);
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Filter/SetNullFilter.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Filter;
4
-
5
- use DeepCopy\Reflection\ReflectionHelper;
6
-
7
- /**
8
- * @final
9
- */
10
- class SetNullFilter implements Filter
11
- {
12
- /**
13
- * Sets the object property to null.
14
- *
15
- * {@inheritdoc}
16
- */
17
- public function apply($object, $property, $objectCopier)
18
- {
19
- $reflectionProperty = ReflectionHelper::getProperty($object, $property);
20
-
21
- $reflectionProperty->setAccessible(true);
22
- $reflectionProperty->setValue($object, null);
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Matcher/Doctrine/DoctrineProxyMatcher.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Matcher\Doctrine;
4
-
5
- use DeepCopy\Matcher\Matcher;
6
- use Doctrine\Common\Persistence\Proxy;
7
-
8
- /**
9
- * @final
10
- */
11
- class DoctrineProxyMatcher implements Matcher
12
- {
13
- /**
14
- * Matches a Doctrine Proxy class.
15
- *
16
- * {@inheritdoc}
17
- */
18
- public function matches($object, $property)
19
- {
20
- return $object instanceof Proxy;
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Matcher/Matcher.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Matcher;
4
-
5
- interface Matcher
6
- {
7
- /**
8
- * @param object $object
9
- * @param string $property
10
- *
11
- * @return boolean
12
- */
13
- public function matches($object, $property);
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyMatcher.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Matcher;
4
-
5
- /**
6
- * @final
7
- */
8
- class PropertyMatcher implements Matcher
9
- {
10
- /**
11
- * @var string
12
- */
13
- private $class;
14
-
15
- /**
16
- * @var string
17
- */
18
- private $property;
19
-
20
- /**
21
- * @param string $class Class name
22
- * @param string $property Property name
23
- */
24
- public function __construct($class, $property)
25
- {
26
- $this->class = $class;
27
- $this->property = $property;
28
- }
29
-
30
- /**
31
- * Matches a specific property of a specific class.
32
- *
33
- * {@inheritdoc}
34
- */
35
- public function matches($object, $property)
36
- {
37
- return ($object instanceof $this->class) && $property == $this->property;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyNameMatcher.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Matcher;
4
-
5
- /**
6
- * @final
7
- */
8
- class PropertyNameMatcher implements Matcher
9
- {
10
- /**
11
- * @var string
12
- */
13
- private $property;
14
-
15
- /**
16
- * @param string $property Property name
17
- */
18
- public function __construct($property)
19
- {
20
- $this->property = $property;
21
- }
22
-
23
- /**
24
- * Matches a property by its name.
25
- *
26
- * {@inheritdoc}
27
- */
28
- public function matches($object, $property)
29
- {
30
- return $property == $this->property;
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Matcher/PropertyTypeMatcher.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Matcher;
4
-
5
- use DeepCopy\Reflection\ReflectionHelper;
6
- use ReflectionException;
7
-
8
- /**
9
- * Matches a property by its type.
10
- *
11
- * It is recommended to use {@see DeepCopy\TypeFilter\TypeFilter} instead, as it applies on all occurrences
12
- * of given type in copied context (eg. array elements), not just on object properties.
13
- *
14
- * @final
15
- */
16
- class PropertyTypeMatcher implements Matcher
17
- {
18
- /**
19
- * @var string
20
- */
21
- private $propertyType;
22
-
23
- /**
24
- * @param string $propertyType Property type
25
- */
26
- public function __construct($propertyType)
27
- {
28
- $this->propertyType = $propertyType;
29
- }
30
-
31
- /**
32
- * {@inheritdoc}
33
- */
34
- public function matches($object, $property)
35
- {
36
- try {
37
- $reflectionProperty = ReflectionHelper::getProperty($object, $property);
38
- } catch (ReflectionException $exception) {
39
- return false;
40
- }
41
-
42
- $reflectionProperty->setAccessible(true);
43
-
44
- return $reflectionProperty->getValue($object) instanceof $this->propertyType;
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/Reflection/ReflectionHelper.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\Reflection;
4
-
5
- use DeepCopy\Exception\PropertyException;
6
- use ReflectionClass;
7
- use ReflectionException;
8
- use ReflectionObject;
9
- use ReflectionProperty;
10
-
11
- class ReflectionHelper
12
- {
13
- /**
14
- * Retrieves all properties (including private ones), from object and all its ancestors.
15
- *
16
- * Standard \ReflectionClass->getProperties() does not return private properties from ancestor classes.
17
- *
18
- * @author muratyaman@gmail.com
19
- * @see http://php.net/manual/en/reflectionclass.getproperties.php
20
- *
21
- * @param ReflectionClass $ref
22
- *
23
- * @return ReflectionProperty[]
24
- */
25
- public static function getProperties(ReflectionClass $ref)
26
- {
27
- $props = $ref->getProperties();
28
- $propsArr = array();
29
-
30
- foreach ($props as $prop) {
31
- $propertyName = $prop->getName();
32
- $propsArr[$propertyName] = $prop;
33
- }
34
-
35
- if ($parentClass = $ref->getParentClass()) {
36
- $parentPropsArr = self::getProperties($parentClass);
37
- foreach ($propsArr as $key => $property) {
38
- $parentPropsArr[$key] = $property;
39
- }
40
-
41
- return $parentPropsArr;
42
- }
43
-
44
- return $propsArr;
45
- }
46
-
47
- /**
48
- * Retrieves property by name from object and all its ancestors.
49
- *
50
- * @param object|string $object
51
- * @param string $name
52
- *
53
- * @throws PropertyException
54
- * @throws ReflectionException
55
- *
56
- * @return ReflectionProperty
57
- */
58
- public static function getProperty($object, $name)
59
- {
60
- $reflection = is_object($object) ? new ReflectionObject($object) : new ReflectionClass($object);
61
-
62
- if ($reflection->hasProperty($name)) {
63
- return $reflection->getProperty($name);
64
- }
65
-
66
- if ($parentClass = $reflection->getParentClass()) {
67
- return self::getProperty($parentClass->getName(), $name);
68
- }
69
-
70
- throw new PropertyException(
71
- sprintf(
72
- 'The class "%s" doesn\'t have a property with the given name: "%s".',
73
- is_object($object) ? get_class($object) : $object,
74
- $name
75
- )
76
- );
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/Date/DateIntervalFilter.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeFilter\Date;
4
-
5
- use DateInterval;
6
- use DeepCopy\TypeFilter\TypeFilter;
7
-
8
- /**
9
- * @final
10
- *
11
- * @deprecated Will be removed in 2.0. This filter will no longer be necessary in PHP 7.1+.
12
- */
13
- class DateIntervalFilter implements TypeFilter
14
- {
15
-
16
- /**
17
- * {@inheritdoc}
18
- *
19
- * @param DateInterval $element
20
- *
21
- * @see http://news.php.net/php.bugs/205076
22
- */
23
- public function apply($element)
24
- {
25
- $copy = new DateInterval('P0D');
26
-
27
- foreach ($element as $propertyName => $propertyValue) {
28
- $copy->{$propertyName} = $propertyValue;
29
- }
30
-
31
- return $copy;
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/ReplaceFilter.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeFilter;
4
-
5
- /**
6
- * @final
7
- */
8
- class ReplaceFilter implements TypeFilter
9
- {
10
- /**
11
- * @var callable
12
- */
13
- protected $callback;
14
-
15
- /**
16
- * @param callable $callable Will be called to get the new value for each element to replace
17
- */
18
- public function __construct(callable $callable)
19
- {
20
- $this->callback = $callable;
21
- }
22
-
23
- /**
24
- * {@inheritdoc}
25
- */
26
- public function apply($element)
27
- {
28
- return call_user_func($this->callback, $element);
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/ShallowCopyFilter.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeFilter;
4
-
5
- /**
6
- * @final
7
- */
8
- class ShallowCopyFilter implements TypeFilter
9
- {
10
- /**
11
- * {@inheritdoc}
12
- */
13
- public function apply($element)
14
- {
15
- return clone $element;
16
- }
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedList.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeFilter\Spl;
4
-
5
- /**
6
- * @deprecated Use {@see SplDoublyLinkedListFilter} instead.
7
- */
8
- class SplDoublyLinkedList extends SplDoublyLinkedListFilter
9
- {
10
- }
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedListFilter.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeFilter\Spl;
4
-
5
- use Closure;
6
- use DeepCopy\DeepCopy;
7
- use DeepCopy\TypeFilter\TypeFilter;
8
- use SplDoublyLinkedList;
9
-
10
- /**
11
- * @final
12
- */
13
- class SplDoublyLinkedListFilter implements TypeFilter
14
- {
15
- private $copier;
16
-
17
- public function __construct(DeepCopy $copier)
18
- {
19
- $this->copier = $copier;
20
- }
21
-
22
- /**
23
- * {@inheritdoc}
24
- */
25
- public function apply($element)
26
- {
27
- $newElement = clone $element;
28
-
29
- $copy = $this->createCopyClosure();
30
-
31
- return $copy($newElement);
32
- }
33
-
34
- private function createCopyClosure()
35
- {
36
- $copier = $this->copier;
37
-
38
- $copy = function (SplDoublyLinkedList $list) use ($copier) {
39
- // Replace each element in the list with a deep copy of itself
40
- for ($i = 1; $i <= $list->count(); $i++) {
41
- $copy = $copier->recursiveCopy($list->shift());
42
-
43
- $list->push($copy);
44
- }
45
-
46
- return $list;
47
- };
48
-
49
- return Closure::bind($copy, null, DeepCopy::class);
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeFilter/TypeFilter.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeFilter;
4
-
5
- interface TypeFilter
6
- {
7
- /**
8
- * Applies the filter to the object.
9
- *
10
- * @param mixed $element
11
- */
12
- public function apply($element);
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/TypeMatcher/TypeMatcher.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy\TypeMatcher;
4
-
5
- class TypeMatcher
6
- {
7
- /**
8
- * @var string
9
- */
10
- private $type;
11
-
12
- /**
13
- * @param string $type
14
- */
15
- public function __construct($type)
16
- {
17
- $this->type = $type;
18
- }
19
-
20
- /**
21
- * @param mixed $element
22
- *
23
- * @return boolean
24
- */
25
- public function matches($element)
26
- {
27
- return is_object($element) ? is_a($element, $this->type) : gettype($element) === $this->type;
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/myclabs/deep-copy/src/DeepCopy/deep_copy.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- namespace DeepCopy;
4
-
5
- /**
6
- * Deep copies the given value.
7
- *
8
- * @param mixed $value
9
- * @param bool $useCloneMethod
10
- *
11
- * @return mixed
12
- */
13
- function deep_copy($value, $useCloneMethod = false)
14
- {
15
- return (new DeepCopy($useCloneMethod))->copy($value);
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/CHANGELOG.md DELETED
@@ -1,1488 +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
- <!-- Legend to the icons used: https://github.com/PHPCompatibility/PHPCompatibility/pull/506#discussion_r131650488 -->
11
-
12
-
13
- ## [Unreleased]
14
-
15
- _Nothing yet._
16
-
17
- ## [9.3.5] - 2019-12-27
18
-
19
- See all related issues and PRs in the [9.3.5 milestone].
20
-
21
- ### Added
22
- - :star: `PHPCompatibility.Classes.NewClasses` sniff: recognize the new `FFI` extension related classes as introduced in PHP 7.4. [#949](https://github.com/PHPCompatibility/PHPCompatibility/pull/949)
23
- - :star: `PHPCompatibility.IniDirectives.NewIniDirectives` sniff: detect use of the new `FFI` extension related ini directives as introduced in PHP 7.4. [#949](https://github.com/PHPCompatibility/PHPCompatibility/pull/949)
24
-
25
- ### Changed
26
- - :pencil: `PHPCompatibility.Syntax.NewShortArray`: improved clarity of the error message and made it consistent with other error messages in this standard. [#934](https://github.com/PHPCompatibility/PHPCompatibility/pull/934)
27
- - :pencil: `PHPCompatibility.Interfaces.NewInterfaces`: updated the URL which is mentioned in select error messages. [#942](https://github.com/PHPCompatibility/PHPCompatibility/pull/942)
28
- - :recycle: Another slew of code documentation fixes. [#937](https://github.com/PHPCompatibility/PHPCompatibility/pull/937), [#939](https://github.com/PHPCompatibility/PHPCompatibility/pull/939), [#940](https://github.com/PHPCompatibility/PHPCompatibility/pull/940), [#941](https://github.com/PHPCompatibility/PHPCompatibility/pull/941), [#943](https://github.com/PHPCompatibility/PHPCompatibility/pull/943), [#944](https://github.com/PHPCompatibility/PHPCompatibility/pull/944), [#951](https://github.com/PHPCompatibility/PHPCompatibility/pull/951), [#950](https://github.com/PHPCompatibility/PHPCompatibility/pull/950). Fixes [#734](https://github.com/PHPCompatibility/PHPCompatibility/issues/734).
29
- - :green_heart: Travis: various tweaks. The builds against PHP 7.4 are no longer allowed to fail. [#935](https://github.com/PHPCompatibility/PHPCompatibility/pull/935), [#938](https://github.com/PHPCompatibility/PHPCompatibility/pull/938)
30
- For running the sniffs on PHP 7.4, it is recommended to use PHP_CodeSniffer 3.5.0+ as PHP_CodeSniffer itself is
31
- not compatible with PHP 7.4 until version 3.5.0.
32
-
33
- ### Fixed
34
- - :bug: `PHPCompatibility.Classes.NewClasses`: two new PHP 7.4 classes were being checked as if they were Exceptions. [#945](https://github.com/PHPCompatibility/PHPCompatibility/pull/945)
35
-
36
- ### Credits
37
- Thanks go out to [William Entriken] for their contribution to this version. :clap:
38
-
39
-
40
- ## [9.3.4] - 2019-11-15
41
-
42
- See all related issues and PRs in the [9.3.4 milestone].
43
-
44
- ### Fixed
45
- - :bug: `PHPCompatibility.Keywords.ForbiddenNames`: false positive for list when used in a `foreach()` condition. [#930](https://github.com/PHPCompatibility/PHPCompatibility/pull/930). Fixes [#928](https://github.com/PHPCompatibility/PHPCompatibility/issues/928), [#929](https://github.com/PHPCompatibility/PHPCompatibility/pull/929)
46
-
47
- ### Credits
48
- Thanks go out to [Sergii Bondarenko] for their contribution to this version. :clap:
49
-
50
-
51
- ## [9.3.3] - 2019-11-11
52
-
53
- See all related issues and PRs in the [9.3.3 milestone].
54
-
55
- ### Added
56
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: detection of yet more (undocumented) PHP 7.2 Sodium constants. [#924](https://github.com/PHPCompatibility/PHPCompatibility/pull/924)
57
- - :star: `PHPCompatibility.Keywords.ForbiddenNames` sniff: detect the use of more reserved keywords which are not allowed to be used to name certain constructs. [#923](https://github.com/PHPCompatibility/PHPCompatibility/pull/923). Fixes [#922](https://github.com/PHPCompatibility/PHPCompatibility/issues/922)
58
-
59
- ### Fixed
60
- - :bug: `PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors`: false positive detecting PHP4-style constructors when declared in interfaces. The class implementing the interface will not have the same name as the interface, so the actual method would not be regarded as a PHP4 style constructor. [#921](https://github.com/PHPCompatibility/PHPCompatibility/pull/921)
61
-
62
- ### Credits
63
- Thanks go out to [Nikhil] for their contribution to this version. :clap:
64
-
65
-
66
- ## [9.3.2] - 2019-10-16
67
-
68
- See all related issues and PRs in the [9.3.2 milestone].
69
-
70
- ### Added
71
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: detection of the PHP 7.2 `SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13` constant. [#915](https://github.com/PHPCompatibility/PHPCompatibility/pull/915)
72
- - :books: Readme: a list of projects which are build upon or extend PHPCompatibility. [#904](https://github.com/PHPCompatibility/PHPCompatibility/pull/904)
73
-
74
- ### Changed
75
- - :pushpin: `PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors`: minor efficiency fix to make the sniff faster. [#912](https://github.com/PHPCompatibility/PHPCompatibility/pull/912)
76
- - :pushpin: `PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames`: functions marked as `@deprecated` in the function docblock will now be ignored by this sniff. [#917](https://github.com/PHPCompatibility/PHPCompatibility/pull/917). Fixes [#911](https://github.com/PHPCompatibility/PHPCompatibility/issues/911)
77
- - :pencil: `PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameters`: the `$ooScopeTokens` property is now `protected`, it should never have been `public` in the first place. [#907](https://github.com/PHPCompatibility/PHPCompatibility/pull/907)
78
- - :recycle: More code documentation fixes. [#903](https://github.com/PHPCompatibility/PHPCompatibility/pull/903), [#916](https://github.com/PHPCompatibility/PHPCompatibility/pull/916)
79
- - :books: Readme/Contributing: various tweaks. [#904](https://github.com/PHPCompatibility/PHPCompatibility/pull/904), [#905](https://github.com/PHPCompatibility/PHPCompatibility/pull/905)
80
-
81
- ### Fixed
82
- - :bug: `PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters`: false positive when a class is instantiated which has the same name as one of the affected functions. [#914](https://github.com/PHPCompatibility/PHPCompatibility/pull/914). Fixes [#913](https://github.com/PHPCompatibility/PHPCompatibility/issues/913)
83
- - :bug: `PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters`: false positive when a class is instantiated which has the same name as one of the affected functions. [#914](https://github.com/PHPCompatibility/PHPCompatibility/pull/914)
84
- - :bug: `PHPCompatibility.MethodUse.NewDirectCallsToClone`: false positive on calling `__clone()` from within the class being cloned [#910](https://github.com/PHPCompatibility/PHPCompatibility/pull/910). Fixes [#629 (comment)](https://github.com/PHPCompatibility/PHPCompatibility/issues/629#issuecomment-532607809)
85
- - :bug: `PHPCompatibility.Miscellaneous.ValidIntegers`: binary numbers using an uppercase `B` were not always recognized correctly. [#909](https://github.com/PHPCompatibility/PHPCompatibility/pull/909)
86
-
87
-
88
- ## [9.3.1] - 2019-09-06
89
-
90
- See all related issues and PRs in the [9.3.1 milestone].
91
-
92
- ### Changed
93
- - :recycle: A whole slew of code documentation fixes. [#892](https://github.com/PHPCompatibility/PHPCompatibility/pull/892), [#895](https://github.com/PHPCompatibility/PHPCompatibility/pull/895), [#896](https://github.com/PHPCompatibility/PHPCompatibility/pull/896), [#897](https://github.com/PHPCompatibility/PHPCompatibility/pull/897), [#898](https://github.com/PHPCompatibility/PHPCompatibility/pull/898), [#899](https://github.com/PHPCompatibility/PHPCompatibility/pull/899), [#900](https://github.com/PHPCompatibility/PHPCompatibility/pull/900)
94
- - :wrench: Travis: minor tweaks to the build script. [#893](https://github.com/PHPCompatibility/PHPCompatibility/pull/893)
95
-
96
- ### Fixed
97
- - :bug: `PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder`: false positive when an array item in the second parameter contained a ternary. [#891](https://github.com/PHPCompatibility/PHPCompatibility/pull/891). Fixes [#890](https://github.com/PHPCompatibility/PHPCompatibility/issues/890)
98
- - :bug: `PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder`: will now take array casts into account when determining which parameter is `$pieces`. [#891](https://github.com/PHPCompatibility/PHPCompatibility/pull/891).
99
- - :bug: `PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder`: hardening of the logic to not examine the second parameter when the first is just and only a text string (`$glue`). [#891](https://github.com/PHPCompatibility/PHPCompatibility/pull/891).
100
-
101
-
102
- ## [9.3.0] - 2019-08-29
103
-
104
- See all related issues and PRs in the [9.3.0 milestone].
105
-
106
- To keep informed of the progress of covering "_everything PHP 7.4_" in PHPCompatibility, please subscribe to issue [#808](https://github.com/PHPCompatibility/PHPCompatibility/issues/808).
107
-
108
- ### Changes expected in PHPCompatibility 10.0.0
109
- The next version of PHPCompatibility is expected to include a new external dependency.
110
-
111
- In this same release, support for PHP < 5.4 and PHP_CodeSniffer < 2.6.0 will be dropped.
112
-
113
- The `10.0.0` release is expected around the same time as the release of PHP 7.4 - end of November/beginning of December 2019.
114
-
115
- ### Added
116
- - :star2: New `PHPCompatibility.Miscellaneous.NewPHPOpenTagEOF` sniff to detect a stand-alone PHP open tag at the end of a file, without trailing newline, as will be supported as of PHP 7.4. [#843](https://github.com/PHPCompatibility/PHPCompatibility/pull/846)
117
- - :star2: New `PHPCompatibility.ParameterValues.ForbiddenStripTagsSelfClosingXHTML` sniff to detect calls to `strip_tags()` passing self-closing XHTML tags in the `$allowable_tags` parameter. This has not been supported since PHP 5.3.4. [#866](https://github.com/PHPCompatibility/PHPCompatibility/pull/866)
118
- - :star2: New `PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault` sniff to detect calls to `html_entity_decode()`, `htmlentities()` and `htmlspecialchars()` which are impacted by the change to the default value of the `$encoding` parameter in PHP 5.4. [#862](https://github.com/PHPCompatibility/PHPCompatibility/pull/862)
119
- - :star2: New `PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault` sniff to detect code impacted by the change in the `default_charset` value in PHP 5.6. [#864](https://github.com/PHPCompatibility/PHPCompatibility/pull/864) Fixes [#839](https://github.com/PHPCompatibility/PHPCompatibility/issues/839)
120
- - :star2: New `PHPCompatibility.ParameterValues.NewIDNVariantDefault` sniff to detect calls to `idn_to_ascii()` and `idn_to_utf8()` impacted by the PHP 7.4 change in the default value for the `$variant` parameter. [#861](https://github.com/PHPCompatibility/PHPCompatibility/pull/861)
121
- - :star2: New `PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues` sniff to detect calls to `password_hash()` and `password_needs_rehash()` impacted by the changed value of the `PASSWORD_DEFAULT`, `PASSWORD_BCRYPT`, `PASSWORD_ARGON2I` and `PASSWORD_ARGON2ID` constants in PHP 7.4. [#865](https://github.com/PHPCompatibility/PHPCompatibility/pull/865)
122
- - :star2: New `PHPCompatibility.ParameterValues.NewProcOpenCmdArray` sniff to detect calls to `proc_open()` passing an array for the `$cmd` parameter as supported as of PHP 7.4. [#869](https://github.com/PHPCompatibility/PHPCompatibility/pull/869)
123
- - :star2: New `PHPCompatibility.ParameterValues.NewStripTagsAllowableTagsArray` sniff to detect calls to `strip_tags()` passing an array for the `$allowable_tags` parameter as will be supported as of PHP 7.4. [#867](https://github.com/PHPCompatibility/PHPCompatibility/pull/867)
124
- - :star2: New `PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder` sniff to detect `implode()` being called with `$glue` and `$pieces` in reverse order from the documented argument order. This was previously allowed for historical reasons, but will be deprecated in PHP 7.4. [#846](https://github.com/PHPCompatibility/PHPCompatibility/pull/846)
125
- - :star2: New `PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParam` sniff to detect the `$encoding` being passed as the third, instead of the fourth parameter, to `mb_strrpos()` as has been soft deprecated since PHP 5.2 and will be hard deprecated as of PHP 7.4. [#860](https://github.com/PHPCompatibility/PHPCompatibility/pull/860)
126
- - :star2: New `PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess` sniff to detect array and string offset access using curly braces as will be deprecated as of PHP 7.4. [#855](https://github.com/PHPCompatibility/PHPCompatibility/pull/855)
127
- - In contrast to any other sniff in the PHPCompatibility standard, this sniff contains an auto-fixer.
128
- - :star2: New `PHPCompatibility.TextStrings.NewUnicodeEscapeSequence` sniff to detect use of the PHP 7.0+ unicode codepoint escape sequences and issues with invalid sequences. [#856](https://github.com/PHPCompatibility/PHPCompatibility/pull/856)
129
- - :star2: New `PHPCompatibility.Upgrade.LowPHP` sniff to give users of old PHP versions advance warning when support will be dropped in the near future. [#838](https://github.com/PHPCompatibility/PHPCompatibility/pull/838)
130
- At this moment, the intention is to drop support for PHP 5.3 by the end of this year.
131
- - :star: `PHPCompatibility.Classes.NewClasses` sniff: recognize the new `WeakReference` class as introduced in PHP 7.4. [#857](https://github.com/PHPCompatibility/PHPCompatibility/pull/857)
132
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: detection of new Curl constants as introduced in PHP 7.3.5. [#878](https://github.com/PHPCompatibility/PHPCompatibility/pull/878)
133
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: detection of the revived `T_BAD_CHARACTER` constant as re-introduced in PHP 7.4. [#882](https://github.com/PHPCompatibility/PHPCompatibility/pull/882)
134
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: detection of the new `IMG_FILTER_SCATTER` and `PASSWORD_ARGON2_PROVIDER` constants as introduced in PHP 7.4. [#887](https://github.com/PHPCompatibility/PHPCompatibility/pull/887)
135
- - :star: `PHPCompatibility.Constants.RemovedConstants` sniff: detection of use of the `CURLPIPE_HTTP1` constant which will be deprecated in PHP 7.4. [#879](https://github.com/PHPCompatibility/PHPCompatibility/pull/879)
136
- - :star: `PHPCompatibility.Constants.RemovedConstants` sniff: detection of use of the `FILTER_SANITIZE_MAGIC_QUOTES` constant which will be deprecated in PHP 7.4. [#845](https://github.com/PHPCompatibility/PHPCompatibility/pull/845)
137
- - :star: `PHPCompatibility.Constants.RemovedConstants` sniff: detection of use of the `T_CHARACTER` and `T_BAD_CHARACTER` constants which were removed in PHP 7.0. [#882](https://github.com/PHPCompatibility/PHPCompatibility/pull/882)
138
- - :star: `PHPCompatibility.FunctionDeclarations.NewMagicMethods` sniff: recognize the new `__serialize()` and `__unserialize()` magic methods as introduced in PHP 7.4. [#868](https://github.com/PHPCompatibility/PHPCompatibility/pull/868)
139
- - :star: `PHPCompatibility.FunctionDeclarations.NewMagicMethods` sniff: recognize the PHP 5.0 `__construct()` and `__destruct()` magic methods. [#884](https://github.com/PHPCompatibility/PHPCompatibility/pull/884)
140
- - :star: `PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods` sniff: recognize the new `__serialize()` and `__unserialize()` magic methods as introduced in PHP 7.4. [#868](https://github.com/PHPCompatibility/PHPCompatibility/pull/868)
141
- - :star: `PHPCompatibility.FunctionUse.NewFunctions` sniff: recognize the new PHP 7.4 function `imagecreatefromtga()`. [#873](https://github.com/PHPCompatibility/PHPCompatibility/pull/873)
142
- - :star: `PHPCompatibility.FunctionUse.RemovedFunctionParameters` sniff: recognize the deprecation of the `$age` parameter of the `curl_version()` function. [#874](https://github.com/PHPCompatibility/PHPCompatibility/pull/874)
143
- - :star: `PHPCompatibility.FunctionUse.RemovedFunctions` sniff: recognize the PHP 7.4 deprecated `convert_cyr_string()()`, `ezmlm_hash()`, `get_magic_quotes_gpc()`, `get_magic_quotes_runtime()`, `hebrevc()`, `is_real()`, `money_format()` and `restore_include_path()` functions. [#847](https://github.com/PHPCompatibility/PHPCompatibility/pull/847)
144
- - :star: `PHPCompatibility.IniDirectives.NewIniDirectives` sniff: detect use of the new PHP 7.4 `zend.exception_ignore_args` ini directive. [#871](https://github.com/PHPCompatibility/PHPCompatibility/pull/871)
145
- - :star: `PHPCompatibility.IniDirectives.RemovedIniDirectives` sniff: detect use of the `allow_url_include` ini directive which is deprecated as of PHP 7.4. [#870](https://github.com/PHPCompatibility/PHPCompatibility/pull/870)
146
- - :star: `PHPCompatibility.IniDirectives.RemovedIniDirectives` sniff: detection of use of the `opcache.load_comments` directive which was removed in PHP 7.0. [#883](https://github.com/PHPCompatibility/PHPCompatibility/pull/883)
147
- - :star: `PHPCompatibility.ParameterValues.NewHashAlgorithms`: recognize use of the new PHP 7.4 `crc32c` hash algorithm. [#872](https://github.com/PHPCompatibility/PHPCompatibility/pull/872)
148
- - :star: `PHPCompatibility.TypeCasts.RemovedTypeCasts` sniff: detect usage of the `(real)` type cast which will be deprecated in PHP 7.4. [#844](https://github.com/PHPCompatibility/PHPCompatibility/pull/844)
149
- - :star: Recognize the `recode` extension functionality which will be removed in PHP 7.4 (moved to PECL) in the `RemovedExtensions` and `RemovedFunctions` sniffs. [#841](https://github.com/PHPCompatibility/PHPCompatibility/pull/841)
150
- - :star: Recognize the `OPcache` extension functionality which was be introduced in PHP 5.5, but not yet fully accounted for in the `NewFunctions` and `NewIniDirectives` sniffs. [#883](https://github.com/PHPCompatibility/PHPCompatibility/pull/883)
151
- - :star: New `getCompleteTextString()` utility method to the `PHPCompatibility\Sniff` class. [#856](https://github.com/PHPCompatibility/PHPCompatibility/pull/856)
152
- - :umbrella: Unit test for the `PHPCompatibility.Upgrade.LowPHPCS` sniff.
153
- - :umbrella: Some extra unit tests for the `PHPCompatibility.ParameterValues.NewNegativeStringOffset`, `PHPCompatibility.ParameterValues.RemovedMbStringModifiers` and sniffs. [#876](https://github.com/PHPCompatibility/PHPCompatibility/pull/876), [#877](https://github.com/PHPCompatibility/PHPCompatibility/pull/877)
154
- - :books: `CONTRIBUTING.md`: Added a list of typical sources for information about changes to PHP. [#875](https://github.com/PHPCompatibility/PHPCompatibility/pull/875)
155
-
156
- ### Changed
157
- - :pushpin: `PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString` sniff: the sniff will now also examine the function docblock, if available, and will throw an error when a `@throws` tag is found in the docblock. [#880](https://github.com/PHPCompatibility/PHPCompatibility/pull/880). Fixes [#863](https://github.com/PHPCompatibility/PHPCompatibility/issues/863)
158
- - :pushpin: `PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods` sniff: will now also check the visibility and `static` (or not) requirements of the magic `__construct()`, `__destruct()`, `__clone()`, `__debugInfo()`, `__invoke()` and `__set_state()` methods. [#885](https://github.com/PHPCompatibility/PHPCompatibility/pull/885)
159
- - :pushpin: `PHPCompatibility.Syntax.NewArrayStringDereferencing` sniff: the sniff will now also recognize array string dereferencing using curly braces as was (silently) supported since PHP 7.0. [#851](https://github.com/PHPCompatibility/PHPCompatibility/pull/851)
160
- - The sniff will now also throw errors for each dereference found on the array/string, not just the first one.
161
- - :pushpin: `PHPCompatibility.Syntax.NewClassMemberAccess` sniff: the sniff will now also recognize class member access on instantiation and cloning using curly braces as was (silently) supported since PHP 7.0. [#852](https://github.com/PHPCompatibility/PHPCompatibility/pull/852)
162
- - The sniff will now also throw errors for each access detected, not just the first one.
163
- - The line number on which the error is thrown in now set more precisely.
164
- - :pushpin: `PHPCompatibility.Syntax.NewFunctionArrayDereferencing` sniff: the sniff will now also recognize function array dereferencing using curly braces as was (silently) supported since PHP 7.0. [#853](https://github.com/PHPCompatibility/PHPCompatibility/pull/853)
165
- - The sniff will now also throw errors for each access detected, not just the first one.
166
- - The line number on which the error is thrown in now set more precisely.
167
- - :recycle: Various code clean-up and improvements. [#849](https://github.com/PHPCompatibility/PHPCompatibility/pull/849), [#850](https://github.com/PHPCompatibility/PHPCompatibility/pull/850)
168
- - :recycle: Various minor inline documentation fixes. [#854](https://github.com/PHPCompatibility/PHPCompatibility/pull/854), [#886](https://github.com/PHPCompatibility/PHPCompatibility/pull/886)
169
- - :wrench: Travis: various tweaks to the build script. [#834](https://github.com/PHPCompatibility/PHPCompatibility/pull/834), [#842](https://github.com/PHPCompatibility/PHPCompatibility/pull/842)
170
-
171
- ### Fixed
172
- - :bug: `PHPCompatibility.FunctionDeclarations.ForbiddenParametersWithSameName` sniff: variable names are case-sensitive, so recognition of same named parameters should be done in a case-sensitive manner. [#848](https://github.com/PHPCompatibility/PHPCompatibility/pull/848)
173
- - :bug: `PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString` sniff: Exceptions thrown within a `try` should not trigger the sniff. [#880](https://github.com/PHPCompatibility/PHPCompatibility/pull/880). Fixes [#863](https://github.com/PHPCompatibility/PHPCompatibility/issues/863)
174
- - :bug: `PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString` sniff: the `$ooScopeTokens` property should never have been a public property. [#880](https://github.com/PHPCompatibility/PHPCompatibility/pull/880).
175
- - :umbrella: Some of the unit tests for the `PHPCompatibility.Operators.RemovedTernaryAssociativity` sniff were not being run. [#836](https://github.com/PHPCompatibility/PHPCompatibility/pull/836)
176
-
177
-
178
- ## [9.2.0] - 2019-06-28
179
-
180
- See all related issues and PRs in the [9.2.0 milestone].
181
-
182
- To keep informed of the progress of covering "_everything PHP 7.4_" in PHPCompatibility, please subscribe to issue [#808](https://github.com/PHPCompatibility/PHPCompatibility/issues/808).
183
-
184
- ### Added
185
- - :star2: New `PHPCompatibility.Classes.ForbiddenAbstractPrivateMethods` sniff to detect methods declared as both `private` as well as `abstract`. This was allowed between PHP 5.0.0 and 5.0.4, but disallowed in PHP 5.1 as the behaviour of `private` and `abstract` are mutually exclusive. [#822](https://github.com/PHPCompatibility/PHPCompatibility/pull/822)
186
- - :star2: New `PHPCompatibility.Classes.NewTypedProperties` sniff to detect PHP 7.4 typed property declarations. [#801](https://github.com/PHPCompatibility/PHPCompatibility/pull/801), [#829](https://github.com/PHPCompatibility/PHPCompatibility/pull/829)
187
- - :star2: New `PHPCompatibility.Classes.RemovedOrphanedParent` sniff to detect the use of the `parent` keyword in classes without a parent (non-extended classes). This code pattern is deprecated in PHP 7.4 and will become a compile-error in PHP 8.0. [#818](https://github.com/PHPCompatibility/PHPCompatibility/pull/818)
188
- - :star2: New `PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString` sniff to detect throwing exceptions from `__toString()` methods. This would previously result in a fatal error, but will be allowed as of PHP 7.4. [#814](https://github.com/PHPCompatibility/PHPCompatibility/pull/814)
189
- - :star2: New `PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameters` sniff to detect `__toString()` function declarations expecting parameters. This was disallowed in PHP 5.3. [#815](https://github.com/PHPCompatibility/PHPCompatibility/pull/815)
190
- - :star2: New `PHPCompatibility.MethodUse.ForbiddenToStringParameters` sniff to detect direct calls to `__toString()` magic methods passing parameters. This was disallowed in PHP 5.3. [#830](https://github.com/PHPCompatibility/PHPCompatibility/pull/830)
191
- - :star2: New `PHPCompatibility.Operators.ChangedConcatOperatorPrecedence` sniff to detect code affected by the upcoming change in operator precedence for the concatenation operator. The concatenation operator precedence will be lowered in PHP 8.0, with deprecation notices for code affected being thrown in PHP 7.4. [#805](https://github.com/PHPCompatibility/PHPCompatibility/pull/805)
192
- - :star2: New `PHPCompatibility.Operators.RemovedTernaryAssociativity` sniff to detect code relying on left-associativity of the ternary operator. This behaviour will be deprecated in PHP 7.4 and removed in PHP 8.0. [#810](https://github.com/PHPCompatibility/PHPCompatibility/pull/810)
193
- - :star2: New `PHPCompatibility.Syntax.NewArrayUnpacking` sniff to detect the use of the spread operator to unpack arrays when declaring a new array, as introduced in PHP 7.4. [#804](https://github.com/PHPCompatibility/PHPCompatibility/pull/804)
194
- - :star: `PHPCompatibility.Classes.NewClasses` sniff: recognize the new `ReflectionReference` class as introduced in PHP 7.4. [#820](https://github.com/PHPCompatibility/PHPCompatibility/pull/820)
195
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: detection of the new PHP 7.4 Core (Standard), MBString, Socket and Tidy constants. [#821](https://github.com/PHPCompatibility/PHPCompatibility/pull/821)
196
- - :star: `PHPCompatibility.FunctionUse.NewFunctions` sniff: detect usage of the new PHP 7.4 `get_mangled_object_vars()`, `mb_str_split()`, `openssl_x509_verify()`, `password_algos()`, `pcntl_unshare()`, `sapi_windows_set_ctrl_handler()` and `sapi_windows_generate_ctrl_event()` functions. [#811](https://github.com/PHPCompatibility/PHPCompatibility/pull/811), [#819](https://github.com/PHPCompatibility/PHPCompatibility/pull/819), [#827](https://github.com/PHPCompatibility/PHPCompatibility/pull/827)
197
- - :star: `PHPCompatibility.FunctionUse.NewFunctions` sniff: recognize the new OCI functions as introduced in PHP 7.2.14 and PHP 7.3.1. [#786](https://github.com/PHPCompatibility/PHPCompatibility/pull/786)
198
- - :star: `PHPCompatibility.FunctionUse.RemovedFunctions` sniff: recognize the PHP 7.4 deprecated `ldap_control_paged_result_response()` and `ldap_control_paged_result()` functions. [#831](https://github.com/PHPCompatibility/PHPCompatibility/pull/831)
199
- - :star: `PHPCompatibility.FunctionUse.RemovedFunctions` sniff: recognize the `Payflow Pro/pfpro` functions as removed in PHP 5.1. [#823](https://github.com/PHPCompatibility/PHPCompatibility/pull/823)
200
- - :star: `PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters` sniff: account for the parameters for `array_merge()` and `array_merge_recursive()` becoming optional in PHP 7.4. [#817](https://github.com/PHPCompatibility/PHPCompatibility/pull/817)
201
- - :star: `PHPCompatibility.IniDirectives.RemovedIniDirectives` sniff: recognize the `Payflow Pro/pfpro` ini directives as removed in PHP 5.1. [#823](https://github.com/PHPCompatibility/PHPCompatibility/pull/823)
202
- - :star: Recognize the `interbase/Firebird` extension functionality which will be removed in PHP 7.4 (moved to PECL) in the `RemovedConstants`, `RemovedExtensions`, `RemovedFunctions` and `RemovedIniDirectives` sniffs. [#807](https://github.com/PHPCompatibility/PHPCompatibility/pull/807)
203
- - :star: Recognize the `wddx` extension functionality which will be removed in PHP 7.4 (moved to PECL) in the `RemovedExtensions` and `RemovedFunctions` sniffs. [#826](https://github.com/PHPCompatibility/PHPCompatibility/pull/826)
204
- - :star: New `isShortTernary()` and `isUnaryPlusMinus()` utility methods to the `PHPCompatibility\Sniff` class. [#810](https://github.com/PHPCompatibility/PHPCompatibility/pull/810), [#805](https://github.com/PHPCompatibility/PHPCompatibility/pull/805)
205
-
206
- ### Changed
207
- - :pencil2: The `PHPCompatibility.Extensions.RemovedExtensions` sniff will now only report on the removed `Payflow Pro` extension when a function uses `pfpro_` as a prefix. Previously, it used the `pfpro` prefix (without underscore) for detection. [#812](https://github.com/PHPCompatibility/PHPCompatibility/pull/812)
208
- - :pencil2: The error message thrown when the `T_ELLIPSIS` token, i.e. the spread operator, is detected. [#803](https://github.com/PHPCompatibility/PHPCompatibility/pull/803)
209
- PHP 7.4 adds a third use-case for the spread operator. The adjusted error message accounts for this.
210
- - :umbrella: `PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations` is now also tested with parameters using the splat operator. [#802](https://github.com/PHPCompatibility/PHPCompatibility/pull/802)
211
- - :books: The documentation now uses the GitHub repo of `PHP_CodeSniffer` as the canonical entry point for `PHP_CodeSniffer`. Previously, it would point to the PEAR package. [#788](https://github.com/PHPCompatibility/PHPCompatibility/pull/788)
212
- - :books: The links in the changelog now all point to the `PHPCompatibility/PHPCompatibility` repo and no longer to the (deprecated) `wimg/PHPCompatibility` repo. [#828](https://github.com/PHPCompatibility/PHPCompatibility/pull/828)
213
- - :recycle: Various minor inline documentation improvements. [#825](https://github.com/PHPCompatibility/PHPCompatibility/pull/825)
214
- - :wrench: Various performance optimizations and code simplifications. [#783](https://github.com/PHPCompatibility/PHPCompatibility/pull/783), [#784](https://github.com/PHPCompatibility/PHPCompatibility/pull/784), [#795](https://github.com/PHPCompatibility/PHPCompatibility/pull/795), [#813](https://github.com/PHPCompatibility/PHPCompatibility/pull/813)
215
- - :green_heart: Travis: build tests are now being run against PHP 7.4 (unstable) as well. [#790](https://github.com/PHPCompatibility/PHPCompatibility/pull/790)
216
- Note: the builds are currently not (yet) tested against PHP 8.0 (unstable) as there is no compatible PHPUnit version available (yet).
217
- - :wrench: Travis: The build script has been refactored to use [stages](https://docs.travis-ci.com/user/build-stages/) to get the most relevant results faster. Additionally some more tweaks have been made to improve and/or simplify the build script. [#798](https://github.com/PHPCompatibility/PHPCompatibility/pull/798)
218
- - :wrench: Build/PHPCS: warnings are no longer allowed for the PHPCompatibility native code. [#800](https://github.com/PHPCompatibility/PHPCompatibility/pull/800)
219
- - :wrench: Build/PHPCS: added variable assignment alignment check and file include check to the PHPCompatibility native CS configuration. [#824](https://github.com/PHPCompatibility/PHPCompatibility/pull/824)
220
- - :wrench: The minimum version for the recommended `DealerDirect/phpcodesniffer-composer-installer` Composer plugin has been upped to `0.5.0`. [#791](https://github.com/PHPCompatibility/PHPCompatibility/pull/791)
221
-
222
- ### Fixed
223
- - :bug: The `PHPCompatibility.Extensions.RemovedExtensions` sniff contained a typo in the alternative recommended for the removed `mcve` extension. [#806](https://github.com/PHPCompatibility/PHPCompatibility/pull/806)
224
- - :bug: The `PHPCompatibility.Extensions.RemovedExtensions` sniff listed the wrong removal version number for the `Payflow Pro/pfpro` extension (PHP 5.3 instead of the correct 5.1). [#823](https://github.com/PHPCompatibility/PHPCompatibility/pull/823)
225
-
226
- ### Credits
227
- Thanks go out to [Yılmaz] and [Tim Millwood] for their contribution to this version. :clap:
228
-
229
-
230
- ## [9.1.1] - 2018-12-31
231
-
232
- See all related issues and PRs in the [9.1.1 milestone].
233
-
234
- ### Fixed
235
- - :bug: `ForbiddenThisUseContexts`: false positive for unsetting `$this['key']` on objects implementing `ArrayAccess`. [#781](https://github.com/PHPCompatibility/PHPCompatibility/pull/781). Fixes [#780](https://github.com/PHPCompatibility/PHPCompatibility/issues/780)
236
-
237
- ## [9.1.0] - 2018-12-16
238
-
239
- See all related issues and PRs in the [9.1.0 milestone].
240
-
241
- ### Added
242
- - :star2: New `PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue` sniff to detect code which could be affected by the PHP 7.0 change in the values reported by `func_get_arg()`, `func_get_args()`, `debug_backtrace()` and exception backtraces. [#750](https://github.com/PHPCompatibility/PHPCompatibility/pull/750). Fixes [#585](https://github.com/PHPCompatibility/PHPCompatibility/pull/585).
243
- - :star2: New `PHPCompatibility.MethodUse.NewDirectCallsToClone` sniff to detect direct call to a `__clone()` magic method which wasn't allowed prior to PHP 7.0. [#743](https://github.com/PHPCompatibility/PHPCompatibility/pull/743). Fixes [#629](https://github.com/PHPCompatibility/PHPCompatibility/issues/629).
244
- - :star2: New `PHPCompatibility.Variables.ForbiddenThisUseContext` sniff to detect most of the inconsistencies surrounding the use of the `$this` variable, which were removed in PHP 7.1. [#762](https://github.com/PHPCompatibility/PHPCompatibility/pull/762), [#771](https://github.com/PHPCompatibility/PHPCompatibility/pull/771). Fixes [#262](https://github.com/PHPCompatibility/PHPCompatibility/issues/262) and [#740](https://github.com/PHPCompatibility/PHPCompatibility/issues/740).
245
- - :star: `NewClasses`: detection of more native PHP Exceptions. [#743](https://github.com/PHPCompatibility/PHPCompatibility/pull/743), [#753](https://github.com/PHPCompatibility/PHPCompatibility/pull/753)
246
- - :star: `NewConstants` : detection of the new PHP 7.3 Curl, Stream Crypto and LDAP constants and some more PHP 7.0 Tokenizer constants. [#752](https://github.com/PHPCompatibility/PHPCompatibility/pull/752), [#767](https://github.com/PHPCompatibility/PHPCompatibility/pull/767), [#778](https://github.com/PHPCompatibility/PHPCompatibility/pull/778)
247
- - :star: `NewFunctions` sniff: recognize (more) new LDAP functions as introduced in PHP 7.3. [#768](https://github.com/PHPCompatibility/PHPCompatibility/pull/768)
248
- - :star: `NewFunctionParameters` sniff: recognize the new `$serverctrls` parameter which was added to a number of LDAP functions in PHP 7.3. [#769](https://github.com/PHPCompatibility/PHPCompatibility/pull/769)
249
- - :star: `NewIniDirectives` sniff: recognize the new `imap.enable_insecure_rsh` ini directive as introduced in PHP 7.1.25, 7.2.13 and 7.3.0. [#770](https://github.com/PHPCompatibility/PHPCompatibility/pull/770)
250
- - :star: `NewInterfaces` sniff: recognize two more Session related interfaces which were introduced in PHP 5.5.1 and 7.0 respectively. [#748](https://github.com/PHPCompatibility/PHPCompatibility/pull/748)
251
- - :star: Duplicate of upstream `findStartOfStatement()` method to the `PHPCompatibility\PHPCSHelper` class to allow for PHPCS cross-version usage of that method. [#750](https://github.com/PHPCompatibility/PHPCompatibility/pull/750)
252
-
253
- ### Changed
254
- - :pushpin: `RemovedPHP4StyleConstructors`: will now also detect PHP4-style constructors when declared in interfaces. [#751](https://github.com/PHPCompatibility/PHPCompatibility/pull/751)
255
- - :pushpin: `Sniff::validDirectScope()`: the return value of this method has changed. Previously it would always be a boolean. It will stil return `false` when no valid direct scope has been found, but it will now return the `stackPtr` to the scope token if a _valid_ direct scope was encountered. [#758](https://github.com/PHPCompatibility/PHPCompatibility/pull/758)
256
- - :rewind: `NewOperators` : updated the version number for `T_COALESCE_EQUAL`. [#746](https://github.com/PHPCompatibility/PHPCompatibility/pull/746)
257
- - :pencil: Minor improvement to an error message in the unit test suite. [#742](https://github.com/PHPCompatibility/PHPCompatibility/pull/742)
258
- - :recycle: Various code clean-up and improvements. [#745](https://github.com/PHPCompatibility/PHPCompatibility/pull/745), [#756](https://github.com/PHPCompatibility/PHPCompatibility/pull/756), [#774](https://github.com/PHPCompatibility/PHPCompatibility/pull/774)
259
- - :recycle: Various minor inline documentation fixes. [#749](https://github.com/PHPCompatibility/PHPCompatibility/pull/749), [#757](https://github.com/PHPCompatibility/PHPCompatibility/pull/757)
260
- - :umbrella: Improved code coverage recording. [#744](https://github.com/PHPCompatibility/PHPCompatibility/pull/744), [#776](https://github.com/PHPCompatibility/PHPCompatibility/pull/776)
261
- - :green_heart: Travis: build tests are now being run against PHP 7.3 as well. [#511](https://github.com/PHPCompatibility/PHPCompatibility/pull/511)
262
- 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.
263
-
264
- ### Fixed
265
- - :white_check_mark: Compatibility with the upcoming release of PHPCS 3.4.0. Deal with changed behaviour of the PHPCS `Tokenizer` regarding binary type casts. [#760](https://github.com/PHPCompatibility/PHPCompatibility/pull/760)
266
- - :bug: `InternalInterfaces`: false negative for implemented/extended interfaces prefixed with a namespace separator. [#775](https://github.com/PHPCompatibility/PHPCompatibility/pull/775)
267
- - :bug: `NewClasses`: the introduction version of various native PHP Exceptions has been corrected. [#743](https://github.com/PHPCompatibility/PHPCompatibility/pull/743), [#753](https://github.com/PHPCompatibility/PHPCompatibility/pull/753)
268
- - :bug: `NewInterfaces`: false negative for implemented/extended interfaces prefixed with a namespace separator. [#775](https://github.com/PHPCompatibility/PHPCompatibility/pull/775)
269
- - :bug: `RemovedPHP4StyleConstructors`: the sniff would examine methods in nested anonymous classes as if they were methods of the higher level class. [#751](https://github.com/PHPCompatibility/PHPCompatibility/pull/751)
270
- - :rewind: `RemovedPHP4StyleConstructors`: the sniff will no longer throw false positives for the first method in an anonymous class when used in combination with PHPCS 2.3.x. [#751](https://github.com/PHPCompatibility/PHPCompatibility/pull/751)
271
- - :rewind: `ReservedFunctionNames`: fixed incorrect error message text for methods in anonymous classes when used in combination with PHPCS 2.3.x. [#755](https://github.com/PHPCompatibility/PHPCompatibility/pull/755)
272
- - :bug: `ReservedFunctionNames`: prevent duplicate errors being thrown for methods in nested anonymous classes. [#755](https://github.com/PHPCompatibility/PHPCompatibility/pull/755)
273
- - :bug: `PHPCSHelper::findEndOfStatement()`: minor bug fix. [#749](https://github.com/PHPCompatibility/PHPCompatibility/pull/749)
274
- - :bug: `Sniff::isClassProperty()`: class properties for classes nested in conditions or function calls were not always recognized as class properties. [#758](https://github.com/PHPCompatibility/PHPCompatibility/pull/758)
275
-
276
- ### Credits
277
- Thanks go out to [Jonathan Champ] for his contribution to this version. :clap:
278
-
279
-
280
- ## [9.0.0] - 2018-10-07
281
-
282
- **IMPORTANT**: This release contains **breaking changes**. Please read the below information carefully before upgrading!
283
-
284
- All sniffs have been placed in meaningful categories and a number of sniffs have been renamed to have more consistent, meaningful and future-proof names.
285
-
286
- Both the `PHPCompatibilityJoomla` [[GH](https://github.com/PHPCompatibility/PHPCompatibilityJoomla) | [Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-joomla)] as well as the `PHPCompatibilityWP` [[GH](https://github.com/PHPCompatibility/PHPCompatibilityWP)|[Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-wp)] rulesets have already been adjusted for this change and have released a new version which is compatible with this version of PHPCompatibility.
287
-
288
- Aside from those CMS-based rulesets, this project now also offers a number of polyfill-library specific rulesets, such as `PHPCompatibilityPasswordCompat` [[GH](https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat) | [Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-passwordcompat)] for @ircmaxell's [`password_compat`](https://github.com/ircmaxell/password_compat) libary, `PHPCompatibilityParagonieRandomCompat` and `PHPCompatibilityParagonieSodiumCompat` [[GH](https://github.com/PHPCompatibility/PHPCompatibilityParagonie)|[Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-paragonie)] for the [Paragonie polyfills](https://github.com/paragonie?utf8=?&q=polyfill) and a number of rulesets related to various [polyfills offered by the Symfony project](https://github.com/symfony?utf8=?&q=polyfill) [[GH](https://github.com/PHPCompatibility/PHPCompatibilitySymfony)|[Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-symfony)].
289
-
290
- If your project uses one of these polyfills, please consider using these special polyfill rulesets to prevent false positives.
291
-
292
- Also as of this version, [Juliette Reinders Folmer] is now officially a co-maintainer of this package.
293
-
294
- ### Upgrade instructions
295
-
296
- * If you have `<exclude name="..."/>` directives in your own project's custom ruleset which relate to sniffs from the PHPCompatibility library, you will need to update your ruleset to use the new sniff names.
297
- * If you use the new [PHPCS 3.2+ inline annotations](https://github.com/squizlabs/PHP_CodeSniffer/releases/3.2.0), i.e. `// phpcs:ignore Standard.Category.SniffName`, in combination with PHPCompatibility sniff names, you will need to update these annotations.
298
- * If you use neither of the above, you should be fine and upgrading should be painless.
299
-
300
- ### Overview of all the sniff renames:
301
-
302
- Old Category.SniffName | New Category.SniffName
303
- --- | ---
304
- **PHP**.ArgumentFunctionsUsage | **FunctionUse**.ArgumentFunctionsUsage
305
- **PHP**.CaseSensitiveKeywords | **Keywords**.CaseSensitiveKeywords
306
- **PHP**.ConstantArraysUsingConst | **InitialValue**.**New**ConstantArraysUsingConst
307
- **PHP**.ConstantArraysUsingDefine | **InitialValue**.**New**ConstantArraysUsingDefine
308
- **PHP**.**Deprecated**Functions | **FunctionUse**.**Removed**Functions
309
- **PHP**.**Deprecated**IniDirectives | **IniDirectives**.**Removed**IniDirectives
310
- **PHP**.**Deprecated**MagicAutoload | **FunctionNameRestrictions**.**Removed**MagicAutoload
311
- **PHP**.**Deprecated**NewReference | **Syntax**.**Removed**NewReference
312
- **PHP**.**Deprecated**PHP4StyleConstructors | **FunctionNameRestrictions**.**Removed**PHP4StyleConstructors
313
- **PHP**.**Deprecated**TypeCasts | **TypeCasts**.**Removed**TypeCasts
314
- **PHP**.DiscouragedSwitchContinue | **ControlStructures**.DiscouragedSwitchContinue
315
- **PHP**.DynamicAccessToStatic | **Syntax**.**New**DynamicAccessToStatic
316
- **PHP**.EmptyNonVariable | **LanguageConstructs**.**New**EmptyNonVariable
317
- **PHP**.ForbiddenBreakContinueOutsideLoop | **ControlStructures**.ForbiddenBreakContinueOutsideLoop
318
- **PHP**.ForbiddenBreakContinueVariableArguments | **ControlStructures**.ForbiddenBreakContinueVariableArguments
319
- **PHP**.ForbiddenCallTimePassByReference | **Syntax**.ForbiddenCallTimePassByReference
320
- **PHP**.Forbidden**ClosureUseVariableNames** | **FunctionDeclarations**.Forbidden**VariableNamesInClosureUse**
321
- **PHP**.ForbiddenEmptyListAssignment | **Lists**.ForbiddenEmptyListAssignment
322
- **PHP**.Forbidden**Function**ParametersWithSameName | **FunctionDeclarations**.ForbiddenParametersWithSameName
323
- **PHP**.ForbiddenGlobalVariableVariable | **Variables**.ForbiddenGlobalVariableVariable
324
- **PHP**.ForbiddenNames | **Keywords**.ForbiddenNames
325
- **PHP**.ForbiddenNamesAsDeclared | **Keywords**.ForbiddenNamesAsDeclared
326
- **PHP**.ForbiddenNamesAsInvokedFunctions | **Keywords**.ForbiddenNamesAsInvokedFunctions
327
- **PHP**.ForbiddenNegativeBitshift | **Operators**.ForbiddenNegativeBitshift
328
- **PHP**.ForbiddenSwitchWithMultipleDefaultBlocks | **ControlStructures**.ForbiddenSwitchWithMultipleDefaultBlocks
329
- **PHP**.InternalInterfaces | **Interfaces**.InternalInterfaces
330
- **PHP**.LateStaticBinding | **Classes**.**New**LateStaticBinding
331
- **PHP**.**MbstringReplaceE**Modifier | **ParameterValues**.**RemovedMbstring**Modifier**s**
332
- **PHP**.NewAnonymousClasses | **Classes**.NewAnonymousClasses
333
- **PHP**.NewArrayStringDereferencing | **Syntax**.NewArrayStringDereferencing
334
- **PHP**.NewClasses | **Classes**.NewClasses
335
- **PHP**.NewClassMemberAccess | **Syntax**.NewClassMemberAccess
336
- **PHP**.NewClosure | **FunctionDeclarations**.NewClosure
337
- **PHP**.NewConstants | **Constants**.NewConstants
338
- **PHP**.NewConstantScalarExpressions | **InitialValue**.NewConstantScalarExpressions
339
- **PHP**.NewConstVisibility | **Classes**.NewConstVisibility
340
- **PHP**.NewExecutionDirectives | **ControlStructures**.NewExecutionDirectives
341
- **PHP**.NewFunctionArrayDereferencing | **Syntax**.NewFunctionArrayDereferencing
342
- **PHP**.NewFunctionParameters | **FunctionUse**.NewFunctionParameters
343
- **PHP**.NewFunctions | **FunctionUse**.NewFunctions
344
- **PHP**.NewGeneratorReturn | **Generators**.NewGeneratorReturn
345
- **PHP**.NewGroupUseDeclarations | **UseDeclarations**.NewGroupUseDeclarations
346
- **PHP**.NewHashAlgorithms | **ParameterValues**.NewHashAlgorithms
347
- **PHP**.NewHeredoc**Initialize** | **InitialValue**.NewHeredoc
348
- **PHP**.NewIniDirectives | **IniDirectives**.NewIniDirectives
349
- **PHP**.NewInterfaces | **Interfaces**.NewInterfaces
350
- **PHP**.NewKeywords | **Keywords**.NewKeywords
351
- **PHP**.NewLanguageConstructs | **LanguageConstructs**.NewLanguageConstructs
352
- **PHP**.NewMagicClassConstant | **Constants**.NewMagicClassConstant
353
- **PHP**.NewMagicMethods | **FunctionNameRestrictions**.NewMagicMethods
354
- **PHP**.NewMultiCatch | **ControlStructures**.NewMultiCatch
355
- **PHP**.NewNullableTypes | **FunctionDeclarations**.NewNullableTypes
356
- **PHP**.NewReturnTypeDeclarations | **FunctionDeclarations**.NewReturnTypeDeclarations
357
- **PHP**.New**Scalar**TypeDeclarations | **FunctionDeclarations**.New**Param**TypeDeclarations
358
- **PHP**.NewTrailingComma | **Syntax**.New**FunctionCall**TrailingComma
359
- **PHP**.NewTypeCasts | **TypeCasts**.NewTypeCasts
360
- **PHP**.NewUseConstFunction | **UseDeclarations**.NewUseConstFunction
361
- **PHP**.NonStaticMagicMethods | **FunctionDeclarations**.NonStaticMagicMethods
362
- **PHP**.OptionalRequiredFunctionParameters | **FunctionUse**.Optional**To**RequiredFunctionParameters
363
- **PHP**.ParameterShadowSuperGlobals | **FunctionDeclarations**.**Forbidden**ParameterShadowSuperGlobals
364
- **PHP**.**PCRENew**Modifiers | **ParameterValues**.**NewPCRE**Modifiers
365
- **PHP**.**PregReplaceE**Modifier | **ParameterValues**.**RemovedPCRE**Modifier**s**
366
- **PHP**.RemovedAlternativePHPTags | **Miscellaneous**.RemovedAlternativePHPTags
367
- **PHP**.RemovedConstants | **Constants**.RemovedConstants
368
- **PHP**.RemovedExtensions | **Extensions**.RemovedExtensions
369
- **PHP**.RemovedFunctionParameters | **FunctionUse**.RemovedFunctionParameters
370
- **PHP**.RemovedGlobalVariables | **Variables**.Removed**Predefined**GlobalVariables
371
- **PHP**.RemovedHashAlgorithms | **ParameterValues**.RemovedHashAlgorithms
372
- **PHP**.ReservedFunctionNames | **FunctionNameRestrictions**.ReservedFunctionNames
373
- **PHP**.RequiredOptionalFunctionParameters | **FunctionUse**.Required**To**OptionalFunctionParameters
374
- **PHP**.ShortArray | **Syntax**.**New**ShortArray
375
- **PHP**.Ternary**Operators** | **Operators**.**NewShort**Ternary
376
- **PHP**.ValidIntegers | **Miscellaneous**.ValidIntegers
377
- **PHP**.**VariableVariables** | **Variables**.**NewUniformVariableSyntax**
378
-
379
- ### Changelog for version 9.0.0
380
-
381
- See all related issues and PRs in the [9.0.0 milestone].
382
-
383
- ### Added
384
- - :star2: New `PHPCompatibility.ControlStructures.NewForeachExpressionReferencing` sniff to detect referencing of `$value` within a `foreach()` when the iterated array is not a variable. This was not supported prior to PHP 5.5. [#664](https://github.com/PHPCompatibility/PHPCompatibility/pull/664)
385
- - :star2: New `PHPCompatibility.ControlStructures.NewListInForeach` sniff to detect unpacking nested arrays into separate variables via the `list()` construct in a `foreach()` statement. This was not supported prior to PHP 5.5. [#657](https://github.com/PHPCompatibility/PHPCompatibility/pull/657)
386
- - :star2: New `PHPCompatibility.FunctionNameRestrictions.RemovedNamespacedAssert` sniff to detect declaring a function called `assert()` within a namespace. This has been deprecated as of PHP 7.3. [#735](https://github.com/PHPCompatibility/PHPCompatibility/pull/735). Partially fixes [#718](https://github.com/PHPCompatibility/PHPCompatibility/issues/718).
387
- - :star2: New `PHPCompatibility.Lists.AssignmentOrder` sniff to detect `list()` constructs affected by the change in assignment order in PHP 7.0. [#656](https://github.com/PHPCompatibility/PHPCompatibility/pull/656)
388
- - :star2: New `PHPCompatibility.Lists.NewKeyedList` sniff to detect usage of keys in `list()`, support for which was added in PHP 7.1. [#655](https://github.com/PHPCompatibility/PHPCompatibility/pull/655). Fixes [#252](https://github.com/PHPCompatibility/PHPCompatibility/issues/252).
389
- - :star2: New `PHPCompatibility.Lists.NewListReferenceAssignment` sniff to detect reference assignments being used in `list()` constructs, support for which has been added in PHP 7.3. [#731](https://github.com/PHPCompatibility/PHPCompatibility/pull/731)
390
- - :star2: New `PHPCompatibility.Lists.NewShortList` sniff to detect the shorthand array syntax `[]` being used for symmetric array destructuring as introduced in PHP 7.1. [#654](https://github.com/PHPCompatibility/PHPCompatibility/pull/654). Fixes [#248](https://github.com/PHPCompatibility/PHPCompatibility/issues/248).
391
- - :star2: New `PHPCompatibility.Operators.NewOperators` sniff which checks for usage of the pow, pow equals, spaceship and coalesce (equals) operators. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738)
392
- These checks were previously contained within the `PHPCompatibility.LanguageConstructs.NewLanguageConstructs` sniff.
393
- - :star2: New `PHPCompatibility.ParameterValues.ForbiddenGetClassNull` sniff to detect `null` being passed to `get_class()`, support for which has been removed in PHP 7.2 [#659](https://github.com/PHPCompatibility/PHPCompatibility/pull/659). Fixes [#557](https://github.com/PHPCompatibility/PHPCompatibility/issues/557).
394
- - :star2: New `PHPCompatibility.ParameterValues.NewArrayReduceInitialType` sniff to detect non-integers being passed as the `$initial` parameter to the `array_reduce()` function, which was not supported before PHP 5.3. [#666](https://github.com/PHPCompatibility/PHPCompatibility/pull/666). Fixes [#649](https://github.com/PHPCompatibility/PHPCompatibility/issues/649)
395
- - :star2: New `PHPCompatibility.ParameterValues.NewFopenModes` sniff to examine the `$mode` parameter passed to `fopen()` for modes not available in older PHP versions. [#658](https://github.com/PHPCompatibility/PHPCompatibility/pull/658)
396
- - :star2: New `PHPCompatibility.ParameterValues.NewNegativeStringOffset` sniff to detect negative string offsets being passed to string manipulation functions which was not supported before PHP 7.1. [#662](https://github.com/PHPCompatibility/PHPCompatibility/pull/662). Partially fixes [#253](https://github.com/PHPCompatibility/PHPCompatibility/issues/253).
397
- - :star2: New `PHPCompatibility.ParameterValues.NewPackFormats` sniff to examine the `$format` parameter passed to `pack()` for formats not available in older PHP versions. [#665](https://github.com/PHPCompatibility/PHPCompatibility/pull/665)
398
- - :star2: New `PHPCompatibility.ParameterValues.RemovedIconvEncoding` sniff to detect the PHP 5.6 deprecated encoding `$type`s being passed to `iconv_set_encoding()`. [#660](https://github.com/PHPCompatibility/PHPCompatibility/pull/660). Fixes [#475](https://github.com/PHPCompatibility/PHPCompatibility/issues/475).
399
- - :star2: New `PHPCompatibility.ParameterValues.RemovedNonCryptoHashes` sniff to detect non-cryptographic hash algorithms being passed to various `hash_*()` functions. This is no longer accepted as of PHP 7.2. [#663](https://github.com/PHPCompatibility/PHPCompatibility/pull/663). Fixes [#559](https://github.com/PHPCompatibility/PHPCompatibility/issues/559)
400
- - :star2: New `PHPCompatibility.ParameterValues.RemovedSetlocaleString` sniff to detect string literals being passed to the `$category` parameter of the `setlocale()` function. This behaviour was deprecated in PHP 4.2 and support has been removed in PHP 7.0. [#661](https://github.com/PHPCompatibility/PHPCompatibility/pull/661)
401
- - :star2: New `PHPCompatibility.Syntax.NewFlexibleHeredocNowdoc` sniff to detect the new heredoc/nowdoc format as allowed as of PHP 7.3. [#736](https://github.com/PHPCompatibility/PHPCompatibility/pull/736). Fixes [#705](https://github.com/PHPCompatibility/PHPCompatibility/issues/705).
402
- Note: This sniff is only supported in combination with PHP_CodeSniffer 2.6.0 and higher.
403
- - :star: `PHPCompatibility.Classes.NewClasses` sniff: recognize the new `CompileError` and `JsonException` classes as introduced in PHP 7.3. [#676](https://github.com/PHPCompatibility/PHPCompatibility/pull/676)
404
- - :star: `PHPCompatibility.Constants.NewConstants` sniff: recognize new constants which are being introduced in PHP 7.3. [#678](https://github.com/PHPCompatibility/PHPCompatibility/pull/678)
405
- - :star: `PHPCompatibility.Constants.RemovedConstants` sniff: recognize constants which have been deprecated or removed in PHP 7.3. [#710](https://github.com/PHPCompatibility/PHPCompatibility/pull/710). Partially fixes [#718](https://github.com/PHPCompatibility/PHPCompatibility/issues/718).
406
- - :star: `PHPCompatibility.FunctionUse.NewFunctions` sniff: recognize various new functions being introduced in PHP 7.3. [#679](https://github.com/PHPCompatibility/PHPCompatibility/pull/679)
407
- - :star: `PHPCompatibility.FunctionUse.NewFunctions` sniff: recognize the `sapi_windows_*()`, `hash_hkdf()` and `pcntl_signal_get_handler()` functions as introduced in PHP 7.1. [#728](https://github.com/PHPCompatibility/PHPCompatibility/pull/728)
408
- - :star: `PHPCompatibility.FunctionUse.RemovedFunctionParameters` sniff: recognize the deprecation of the `$case_insensitive` parameter for the `define()` function in PHP 7.3. [#706](https://github.com/PHPCompatibility/PHPCompatibility/pull/706)
409
- - :star: `PHPCompatibility.FunctionUse.RemovedFunctions` sniff: recognize the PHP 7.3 deprecation of the `image2wbmp()`, `fgetss()` and `gzgetss()` functions, as well as the deprecation of undocumented Mbstring function aliases. [#681](https://github.com/PHPCompatibility/PHPCompatibility/pull/681), [#714](https://github.com/PHPCompatibility/PHPCompatibility/pull/714), [#720](https://github.com/PHPCompatibility/PHPCompatibility/pull/720). Partially fixes [#718](https://github.com/PHPCompatibility/PHPCompatibility/issues/718).
410
- - :star: `PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters` sniff: account for the second parameter for `array_push()` and `array_unshift()` becoming optional in PHP 7.3, as well as for the `$mode` parameter for a range of `ftp_*()` functions becoming optional. [#680](https://github.com/PHPCompatibility/PHPCompatibility/pull/680)
411
- - :star: `PHPCompatibility.IniDirectives.NewIniDirectives` sniff: recognize new `syslog` and `session` ini directives as introduced in PHP 7.3. [#702](https://github.com/PHPCompatibility/PHPCompatibility/pull/702), [#719](https://github.com/PHPCompatibility/PHPCompatibility/pull/719), [#730](https://github.com/PHPCompatibility/PHPCompatibility/pull/730)
412
- - :star: `PHPCompatibility.IniDirectives.NewIniDirectives` sniff: recognize some more ini directives which were introduced in PHP 7.1. [#727](https://github.com/PHPCompatibility/PHPCompatibility/pull/727)
413
- - :star: `PHPCompatibility.IniDirectives.RemovedIniDirectived` sniff: recognize ini directives removed in PHP 7.3. [#677](https://github.com/PHPCompatibility/PHPCompatibility/pull/677), [#717](https://github.com/PHPCompatibility/PHPCompatibility/pull/717). Partially fixes [#718](https://github.com/PHPCompatibility/PHPCompatibility/issues/718).
414
- - :star: New `isNumericCalculation()` and `isVariable()` utility methods to the `PHPCompatibility\Sniff` class. [#664](https://github.com/PHPCompatibility/PHPCompatibility/pull/664), [#666](https://github.com/PHPCompatibility/PHPCompatibility/pull/666)
415
- - :books: A section about the new sniff naming conventions to the `Contributing` file. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738)
416
-
417
- ### Changed
418
- - :fire: All sniffs have been placed in meaningful categories and a number of sniffs have been renamed to have more consistent, meaningful and future-proof names. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738). Fixes [#601](https://github.com/PHPCompatibility/PHPCompatibility/issues/601), [#692](https://github.com/PHPCompatibility/PHPCompatibility/issues/692)
419
- See the table at the top of this changelog for details of all the file renames.
420
- - :umbrella: The unit test files have been moved about as well. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738)
421
- * The directory structure for these now mirrors the default directory structure used by PHPCS itself.
422
- * The file names of the unit test files have been adjusted for the changes made in the sniffs.
423
- * The unit test case files have been renamed and moved to the same directory as the actual test file they apply to.
424
- * The `BaseSniffTest::sniffFile()` method has been adjusted to match. The signature of this method has changed. Where it previously expected a relative path to the unit test case file, it now expects an absolute path.
425
- * The unit tests for the utility methods in the `PHPCompatibility\Sniff` class have been moved to a new `PHPCompatibility\Util\Tests\Core` subdirectory.
426
- * The bootstrap file used for PHPUnit has been moved to the project root directory and renamed `phpunit-bootstrap.php`.
427
- - :twisted_rightwards_arrows: The `PHPCompatibility.LanguageConstructs.NewLanguageConstructs` sniff has been split into two sniffs. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738)
428
- The `PHPCompatibility.LanguageConstructs.NewLanguageConstructs` sniff now contains just the checks for the namespace separator and the ellipsis.
429
- The new `PHPCompatibility.Operators.NewOperators` sniff now contains the checks regarding the pow, pow equals, spaceship and coalesce (equals) operators.
430
- - :pushpin: The `PHPCompatibility.ParameterValues.RemovedMbstringModifiers` sniff will now also recognize removed regex modifiers when used within a function call to one of the undocumented Mbstring function aliases for the Mbstring regex functions. [#715](https://github.com/PHPCompatibility/PHPCompatibility/pull/715)
431
- - :pushpin: The `PHPCompatibility\Sniff::getFunctionCallParameter()` utility method now allows for closures called via a variable. [#723](https://github.com/PHPCompatibility/PHPCompatibility/pull/723)
432
- - :pencil2: `PHPCompatibility.Upgrade.LowPHPCS`: the minimum supported PHPCS version is now 2.3.0. [#699](https://github.com/PHPCompatibility/PHPCompatibility/pull/699)
433
- - :pencil2: Minor inline documentation improvements. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738)
434
- - :umbrella: Minor improvements to the unit tests for the `PHPCompatibility.FunctionNameRestrctions.RemovedMagicAutoload` sniff. [#716](https://github.com/PHPCompatibility/PHPCompatibility/pull/716)
435
- - :recycle: Minor other optimizations. [#698](https://github.com/PHPCompatibility/PHPCompatibility/pull/698), [#697](https://github.com/PHPCompatibility/PHPCompatibility/pull/697)
436
- - :wrench: Minor improvements to the build tools. [#701](https://github.com/PHPCompatibility/PHPCompatibility/pull/701)
437
- - :wrench: Removed some unnecessary inline annotations. [#700](https://github.com/PHPCompatibility/PHPCompatibility/pull/700)
438
- - :books: Replaced some of the badges in the Readme file. [#721](https://github.com/PHPCompatibility/PHPCompatibility/pull/721), [#722](https://github.com/PHPCompatibility/PHPCompatibility/pull/722)
439
- - :books: Composer: updated the list of package authors. [#739](https://github.com/PHPCompatibility/PHPCompatibility/pull/739)
440
-
441
- ### Removed
442
- - :no_entry_sign: Support for PHP_CodeSniffer 1.x and low 2.x versions. The new minimum version of PHP_CodeSniffer to be able to use this library is 2.3.0. [#699](https://github.com/PHPCompatibility/PHPCompatibility/pull/699). Fixes [#691](https://github.com/PHPCompatibility/PHPCompatibility/issues/691).
443
- The minimum _recommended_ version of PHP_CodeSniffer remains the same, i.e. 2.6.0.
444
- - :no_entry_sign: The `\PHPCompatibility\Sniff::inUseScope()` method has been removed as it is no longer needed now support for PHPCS 1.x has been dropped. [#699](https://github.com/PHPCompatibility/PHPCompatibility/pull/699)
445
- - :no_entry_sign: Composer: The `autoload` section has been removed from the `composer.json` file. [#738](https://github.com/PHPCompatibility/PHPCompatibility/pull/738). Fixes [#568](https://github.com/PHPCompatibility/PHPCompatibility/issues/568).
446
- Autoloading for this library is done via the PHP_CodeSniffer default mechanism, enhanced with our own autoloader, so the Composer autoloader shouldn't be needed and was causing issues in a particular use-case.
447
-
448
- ### Fixed
449
- - :bug: `PHPCompatibility.FunctionUse.NewFunctionParameters` sniff: The new `$mode` parameter of the `php_uname()` function was added in PHP 4.3, not in PHP 7.0 as was previously being reported.
450
- The previous implementation of this check was based on an error in the PHP documentation. The error in the PHP documentation has been rectified and the sniff has followed suit. [#711](https://github.com/PHPCompatibility/PHPCompatibility/pull/711)
451
- - :bug: `PHPCompatibility.Generators.NewGeneratorReturn` sniff: The sniff would throw false positives for `return` statements in nested constructs and did not correctly detect the scope which should be examined. [#725](https://github.com/PHPCompatibility/PHPCompatibility/pull/725). Fixes [#724](https://github.com/PHPCompatibility/PHPCompatibility/pull/724).
452
- - :bug: `PHPCompatibility.Keywords.NewKeywords` sniff: PHP magic constants are case _in_sensitive. This sniff now accounts for this. [#707](https://github.com/PHPCompatibility/PHPCompatibility/pull/707)
453
- - :bug: Various bugs in the `PHPCompatibility.Syntax.ForbiddenCallTimePassByReference` sniff [#723](https://github.com/PHPCompatibility/PHPCompatibility/pull/723):
454
- - Closures called via a variable will now also be examined. (false negative)
455
- - References within arrays/closures passed as function call parameters would incorrectly trigger an error. (false positive)
456
- - :green_heart: Compatibility with PHPUnit 7.2. [#712](https://github.com/PHPCompatibility/PHPCompatibility/pull/712)
457
-
458
- ### Credits
459
- Thanks go out to [Jonathan Champ] for his contribution to this version. :clap:
460
-
461
-
462
- ## [8.2.0] - 2018-07-17
463
-
464
- See all related issues and PRs in the [8.2.0 milestone].
465
-
466
- ### Important changes
467
-
468
- #### The repository has moved
469
- As of July 13 2018, the PHPCompatibility repository has moved from the personal account of Wim Godden `wimg` to its own organization `PHPCompatibility`.
470
- Composer users are advised to update their `composer.json`. The dependency is now called `phpcompatibility/php-compatibility`.
471
-
472
- #### Framework/CMS specific PHPCompatibility rulesets
473
- Within this new organization, hosting will be offered for framework/CMS specific PHPCompatibility rulesets.
474
-
475
- The first two such repositories have been created and are now available for use:
476
- * PHPCompatibilityJoomla [GitHub](https://github.com/PHPCompatibility/PHPCompatibilityJoomla)|[Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-joomla)
477
- * PHPCompatibilityWP [GitHub](https://github.com/PHPCompatibility/PHPCompatibilityWP)|[Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-wp)
478
-
479
- If you want to make sure you have all PHPCompatibility rulesets available at any time, you can use the PHPCompatibilityAll package [GitHub](https://github.com/PHPCompatibility/PHPCompatibilityAll)|[Packagist](https://packagist.org/packages/phpcompatibility/phpcompatibility-all).
480
-
481
- For more information, see the [Readme](https://github.com/PHPCompatibility/PHPCompatibility#using-a-frameworkcms-specific-ruleset) and [Contributing guidelines](https://github.com/PHPCompatibility/PHPCompatibility/blob/master/.github/CONTRIBUTING.md#frameworkcms-specific-rulesets).
482
-
483
- #### Changes expected in PHPCompatibility 9.0.0
484
- The next version of PHPCompatibility will include a major directory layout restructuring which means that the sniff codes of all sniffs will change.
485
-
486
- In this same release, support for PHP_CodeSniffer 1.5.x will be dropped. The new minimum supported PHPCS version will be 2.3.0.
487
-
488
- For more information about these upcoming changes, please read the [announcement](https://github.com/PHPCompatibility/PHPCompatibility/issues/688).
489
-
490
- The `9.0.0` release is expected to be ready later this summer.
491
-
492
-
493
- ### Added
494
- - :star2: New `ArgumentFunctionsUsage` sniff to detect usage of the `func_get_args()`, `func_get_arg()` and `func_num_args()` functions and the changes regarding these functions introduced in PHP 5.3. [#596](https://github.com/PHPCompatibility/PHPCompatibility/pull/596). Fixes [#372](https://github.com/PHPCompatibility/PHPCompatibility/issues/372).
495
- - :star2: New `DiscouragedSwitchContinue` sniff to detect `continue` targetting a `switch` control structure for which `E_WARNINGS` will be thrown as of PHP 7.3. [#687](https://github.com/PHPCompatibility/PHPCompatibility/pull/687)
496
- - :star2: New `NewClassMemberAccess` sniff to detect class member access on instantiation as added in PHP 5.4 and class member access on cloning as added in PHP 7.0. [#619](https://github.com/PHPCompatibility/PHPCompatibility/pull/619). Fixes [#53](https://github.com/PHPCompatibility/PHPCompatibility/issues/53).
497
- - :star2: New `NewConstantScalarExpressions` sniff to detect PHP 5.6 scalar expression in contexts where PHP previously only allowed static values. [#617](https://github.com/PHPCompatibility/PHPCompatibility/pull/617). Fixes [#399](https://github.com/PHPCompatibility/PHPCompatibility/issues/399).
498
- - :star2: New `NewGeneratorReturn` sniff to detect `return` statements within generators as introduced in PHP 7.0. [#618](https://github.com/PHPCompatibility/PHPCompatibility/pull/618)
499
- - :star2: New `PCRENewModifiers` sniff to initially detect the new `J` regex modifier as introduced in PHP 7.2. [#600](https://github.com/PHPCompatibility/PHPCompatibility/pull/600). Fixes [#556](https://github.com/PHPCompatibility/PHPCompatibility/issues/556).
500
- - :star2: New `ReservedFunctionNames` sniff to report on double underscore prefixed functions and methods. This was previously reported via an upstream sniff. [#581](https://github.com/PHPCompatibility/PHPCompatibility/pull/581)
501
- - :star2: New `NewTrailingComma` sniff to detect trailing comma's in function calls, method calls, `isset()` and `unset()` as will be introduced in PHP 7.3. [#632](https://github.com/PHPCompatibility/PHPCompatibility/pull/632)
502
- - :star2: New `Upgrade/LowPHPCS` sniff to give users of old PHP_CodeSniffer versions advance warning when support will be dropped in the near future. [#693](https://github.com/PHPCompatibility/PHPCompatibility/pull/693)
503
- - :star: `NewClasses` sniff: check for some 40+ additional PHP native classes added in various PHP versions. [#573](https://github.com/PHPCompatibility/PHPCompatibility/pull/573)
504
- - :star: `NewClosure` sniff: check for usage of `self`/`parent`/`static::` being used within closures, support for which was only added in PHP 5.4. [#669](https://github.com/PHPCompatibility/PHPCompatibility/pull/669). Fixes [#668](https://github.com/PHPCompatibility/PHPCompatibility/pull/668).
505
- - :star: `NewConstants` sniff: recognize constants added by the PHP 5.5+ password extension. [#626](https://github.com/PHPCompatibility/PHPCompatibility/pull/626)
506
- - :star: `NewFunctionParameters` sniff: recognize a number of additional function parameters added in PHP 7.0, 7.1 and 7.2. [#602](https://github.com/PHPCompatibility/PHPCompatibility/pull/602)
507
- - :star: `NewFunctions` sniff: recognize the PHP 5.1 SPL extension functions, the PHP 5.1.1 `hash_hmac()` function, the PHP 5.6 `pg_lo_truncate()` function, more PHP 7.2 Sodium functions and the new PHP 7.3 `is_countable()` function. [#606](https://github.com/PHPCompatibility/PHPCompatibility/pull/606), [#625](https://github.com/PHPCompatibility/PHPCompatibility/pull/625), [#640](https://github.com/PHPCompatibility/PHPCompatibility/pull/640), [#651](https://github.com/PHPCompatibility/PHPCompatibility/pull/651)
508
- - :star: `NewHashAlgorithms` sniff: recognize the new hash algorithms which were added in PHP 7.1. [#599](https://github.com/PHPCompatibility/PHPCompatibility/pull/599)
509
- - :star: `NewInterfaces` sniff: check for the PHP 5.0 `Reflector` interface. [#572](https://github.com/PHPCompatibility/PHPCompatibility/pull/572)
510
- - :star: `OptionalRequiredFunctionParameters` sniff: detect missing `$salt` parameter in calls to the `crypt()` function (PHP 5.6+). [#605](https://github.com/PHPCompatibility/PHPCompatibility/pull/605)
511
- - :star: `RequiredOptionalFunctionParameters` sniff: recognize that the `$varname` parameter of `getenv()` and the `$scale` parameter of `bcscale()` have become optional as of PHP 7.1 and 7.3 respectively. [#598](https://github.com/PHPCompatibility/PHPCompatibility/pull/598), [#612](https://github.com/PHPCompatibility/PHPCompatibility/pull/612)
512
- - :star: New `AbstractFunctionCallParameterSniff` to be used as a basis for sniffs examining function call parameters. [#636](https://github.com/PHPCompatibility/PHPCompatibility/pull/636)
513
- - :star: New `getReturnTypeHintName()` utility method to the `PHPCompatibility\Sniff` class. [#578](https://github.com/PHPCompatibility/PHPCompatibility/pull/578), [#642](https://github.com/PHPCompatibility/PHPCompatibility/pull/642)
514
- - :star: New `isNumber()`, `isPositiveNumber()` and `isNegativeNumber()` utility methods to the `PHPCompatibility\Sniff` class. [#610](https://github.com/PHPCompatibility/PHPCompatibility/pull/610), [#650](https://github.com/PHPCompatibility/PHPCompatibility/pull/650)
515
- - :star: New `isShortList()` utility method to the `PHPCompatibility\Sniff` class. [#635](https://github.com/PHPCompatibility/PHPCompatibility/pull/635)
516
- - :star: New `getCommandLineData()` method to the `PHPCompatibility\PHPCSHelper` class to provide PHPCS cross-version compatible access to command line info at run time. [#693](https://github.com/PHPCompatibility/PHPCompatibility/pull/693)
517
- - :star: Duplicate of upstream `findEndOfStatement()` method to the `PHPCompatibility\PHPCSHelper` class to allow for PHPCS cross-version usage of that method. [#614](https://github.com/PHPCompatibility/PHPCompatibility/pull/614)
518
- - :umbrella: additional unit test to confirm that the `PHPCompatibility\Sniff::isUseOfGlobalConstant()` method handles multi-constant declarations correctly. [#587](https://github.com/PHPCompatibility/PHPCompatibility/pull/587)
519
- - :umbrella: additional unit tests to confirm that the `PHPCompatibility\Sniff::isClassProperty()` method handles multi-property declarations correctly. [#583](https://github.com/PHPCompatibility/PHPCompatibility/pull/583)
520
- - :books: [Readme](https://github.com/PHPCompatibility/PHPCompatibility#using-a-frameworkcms-specific-ruleset) & [Contributing](https://github.com/PHPCompatibility/PHPCompatibility/blob/master/.github/CONTRIBUTING.md#frameworkcms-specific-rulesets): add information about the framework/CMS specific rulesets. Related PRs: [#615](https://github.com/PHPCompatibility/PHPCompatibility/pull/615), [#624](https://github.com/PHPCompatibility/PHPCompatibility/pull/624), [#648](https://github.com/PHPCompatibility/PHPCompatibility/pull/648), [#674](https://github.com/PHPCompatibility/PHPCompatibility/pull/674), [#685](https://github.com/PHPCompatibility/PHPCompatibility/pull/685), [#694](https://github.com/PHPCompatibility/PHPCompatibility/pull/694). Related to issue [#530](https://github.com/PHPCompatibility/PHPCompatibility/issues/530).
521
- - :books: Readme: information about the PHPCS 3.3.0 change which allows for a `testVersion` in a custom ruleset to be overruled by the command-line. [#607](https://github.com/PHPCompatibility/PHPCompatibility/pull/607)
522
-
523
- ### Changed
524
- - :books: Adjusted references to the old repository location throughout the codebase to reflect the move to a GitHub organization. [#689](https://github.com/PHPCompatibility/PHPCompatibility/pull/689)
525
- This repository will now live in [https://github.com/PHPCompatibility/PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) and the Packagist reference will now be `phpcompatibility/php-compatibility`.
526
- - :white_check_mark: The `getReturnTypeHintToken()` utility method has been made compatible with the changes in the PHPCS tokenizer which were introduced in PHP_CodeSniffer 3.3.0. [#642](https://github.com/PHPCompatibility/PHPCompatibility/pull/642). Fixes [#639](https://github.com/PHPCompatibility/PHPCompatibility/issues/639).
527
- - :pushpin: `ConstantArrayUsingConst`: improved handling of multi-constant declarations. [#593](https://github.com/PHPCompatibility/PHPCompatibility/pull/593)
528
- - :pushpin: `NewHeredocInitialize`: improved handling of constant declarations using the `const` keyword.
529
- The sniff will now also report on multi-declarations for variables, constants and class properties and on using heredoc as a function parameter default. [#641](https://github.com/PHPCompatibility/PHPCompatibility/pull/641)
530
- - :pushpin: `ForbiddenEmptyListAssignment`: this sniff will now also report on empty list assignments when the PHP 7.1 short list syntax is used. [#653](https://github.com/PHPCompatibility/PHPCompatibility/pull/653)
531
- - :pushpin: The `ForbiddenNegativeBitshift` sniff would previously only report on "bitshift right". As of this version, "bitshift left" and bitshift assignments will also be recognized. [#614](https://github.com/PHPCompatibility/PHPCompatibility/pull/614)
532
- - :pushpin: The `NewClasses` and `NewInterfaces` sniffs will now also report on new classes/interfaces when used as _return type_ declarations. [#578](https://github.com/PHPCompatibility/PHPCompatibility/pull/578)
533
- - :pushpin: The `NewScalarTypeDeclarations` sniff will now recognize `parent` as a valid type declaration.
534
- The sniff will now also throw an error about using `self` and `parent` when PHP < 5.2 needs to be supported as PHP 5.1 and lower would presume these to be class names instead of keywords. [#595](https://github.com/PHPCompatibility/PHPCompatibility/pull/595)
535
- - :pushpin: The `PregReplaceEModifier` sniff - and the `PCRENewModifiers` sniff by extension - will now correctly examine and report on modifiers in regexes passed via calls to `preg_replace_callback_array()`. [#600](https://github.com/PHPCompatibility/PHPCompatibility/pull/600), [#636](https://github.com/PHPCompatibility/PHPCompatibility/pull/636)
536
- - :pushpin: `getReturnTypeHintToken()` utility method: improved support for interface methods and abstract function declarations. [#652](https://github.com/PHPCompatibility/PHPCompatibility/pull/652)
537
- - :pushpin: The `findExtendedClassName()`, `findImplementedInterfaceNames()`, `getMethodParameters()` utility methods which are duplicates of upstream PHPCS methods, have been moved from the `PHPCompatibility\Sniff` class to the `PHPCompatibility\PHPCSHelper` class and have become static methods. [#613](https://github.com/PHPCompatibility/PHPCompatibility/pull/613)
538
- - :white_check_mark: `getReturnTypeHintToken()` utility method: align returned `$stackPtr` with native PHPCS behaviour by returning the last token of the type declaration. [#575](https://github.com/PHPCompatibility/PHPCompatibility/pull/575)
539
- - :white_check_mark: PHPCS cross-version compatibility: sync `getMethodParameters()` method with improved upstream version. [#643](https://github.com/PHPCompatibility/PHPCompatibility/pull/643)
540
- - :pencil2: The `MbstringReplaceEModifier`, `PregReplaceEModifier` and the `PregReplaceEModifier` sniffs now `extend` the new `AbstractFunctionCallParameterSniff` class. This should yield more accurate results when checking whether one of the target PHP functions was called. [#636](https://github.com/PHPCompatibility/PHPCompatibility/pull/636)
541
- - :pencil2: `DeprecatedNewReference` sniff: minor change to the error text and code - was `Forbidden`, now `Removed` -. Custom rulesets which explicitly excluded this error code will need to be updated. [#594](https://github.com/PHPCompatibility/PHPCompatibility/pull/594)
542
- - :pencil2: `NewScalarTypeDeclarations` sniff: minor change to the error message text.[#644](https://github.com/PHPCompatibility/PHPCompatibility/pull/644)
543
- - :umbrella: The unit test framework now allows for sniffs in categories other than `PHP`. [#634](https://github.com/PHPCompatibility/PHPCompatibility/pull/634)
544
- - :umbrella: Boyscouting: fixed up some (non-relevant) parse errors in a unit test case file. [#576](https://github.com/PHPCompatibility/PHPCompatibility/pull/576)
545
- - :green_heart: Travis: build tests are now also being run against the lowest supported PHPCS 3.x version. Previously only the highest supported PHPCS 3.x version was tested against. [#633](https://github.com/PHPCompatibility/PHPCompatibility/pull/633)
546
- - :books: Readme: Improved Composer install instructions. [#690](https://github.com/PHPCompatibility/PHPCompatibility/pull/690)
547
- - :books: Minor documentation fixes. [#672](https://github.com/PHPCompatibility/PHPCompatibility/pull/672)
548
- - :wrench: Minor performance optimizations and code simplifications. [#592](https://github.com/PHPCompatibility/PHPCompatibility/pull/592), [#630](https://github.com/PHPCompatibility/PHPCompatibility/pull/630), [#671](https://github.com/PHPCompatibility/PHPCompatibility/pull/671)
549
- - :wrench: Composer: Various improvements, including improved information about the suggested packages, suggesting `roave/security-advisories`, allowing for PHPUnit 7.x. [#604](https://github.com/PHPCompatibility/PHPCompatibility/pull/604/files), [#616](https://github.com/PHPCompatibility/PHPCompatibility/pull/616), [#622](https://github.com/PHPCompatibility/PHPCompatibility/pull/622), [#646](https://github.com/PHPCompatibility/PHPCompatibility/pull/646)
550
- - :wrench: Various Travis build script improvements, including tweaks for faster build time, validation of the `composer.json` file, validation of the framework specific rulesets. [#570](https://github.com/PHPCompatibility/PHPCompatibility/pull/570), [#571](https://github.com/PHPCompatibility/PHPCompatibility/pull/571), [#579](https://github.com/PHPCompatibility/PHPCompatibility/pull/579), [#621](https://github.com/PHPCompatibility/PHPCompatibility/pull/621), [#631](https://github.com/PHPCompatibility/PHPCompatibility/pull/631)
551
- - :wrench: Build/PHPCS: made some more CS conventions explicit and start using PHPCS 3.x options for the PHPCompatibility native ruleset. [#586](https://github.com/PHPCompatibility/PHPCompatibility/pull/586), [#667](https://github.com/PHPCompatibility/PHPCompatibility/pull/667), [#673](https://github.com/PHPCompatibility/PHPCompatibility/pull/673)
552
- - :wrench: Some code style clean up and start using the new inline PHPCS 3.2+ annotations where applicable. [#586](https://github.com/PHPCompatibility/PHPCompatibility/pull/586), [#591](https://github.com/PHPCompatibility/PHPCompatibility/pull/591), [#620](https://github.com/PHPCompatibility/PHPCompatibility/pull/620), [#673](https://github.com/PHPCompatibility/PHPCompatibility/pull/673)
553
-
554
- ### Removed
555
- - :no_entry_sign: PHPCompatibility no longer explicitly supports PHP_CodeSniffer 2.2.0. [#687](https://github.com/PHPCompatibility/PHPCompatibility/pull/687), [#690](https://github.com/PHPCompatibility/PHPCompatibility/pull/690)
556
- - :no_entry_sign: The PHPCompatibility ruleset no longer includes the PHPCS native `Generic.NamingConventions.CamelCapsFunctionName`. Double underscore prefixed function names are now being reported on by a new dedicated sniff. [#581](https://github.com/PHPCompatibility/PHPCompatibility/pull/581)
557
- - :no_entry_sign: PHPCompatibility no longer explicitly supports HHVM and builds are no longer tested against HHVM.
558
- For now, running PHPCompatibility on HHVM to test PHP code may still work for a little while, but HHVM has announced they are [dropping PHP support](https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html). [#623](https://github.com/PHPCompatibility/PHPCompatibility/pull/623). Fixes [#603](https://github.com/PHPCompatibility/PHPCompatibility/issues/603).
559
- - :books: Readme: badges from services which are no longer supported or inaccurate. [#609](https://github.com/PHPCompatibility/PHPCompatibility/pull/609), [#628](https://github.com/PHPCompatibility/PHPCompatibility/pull/628)
560
-
561
- ### Fixed
562
- - :bug: Previously, the PHPCS native `Generic.NamingConventions.CamelCapsFunctionName` sniff was included in PHPCompatibility. Some error codes of this sniff were excluded, as well as some error messages changed (via the ruleset).
563
- If/when PHPCompatibility would be used in combination with a code style-type ruleset, this could inadvertently lead to underreporting of issues which the CS-type ruleset intends to have reported - i.e. the error codes excluded by PHPCompatibility -. This has now been fixed. [#581](https://github.com/PHPCompatibility/PHPCompatibility/pull/581)
564
- - :bug: The `ForbiddenNegativeBitshift` sniff would incorrectly throw an error when a bitshift was based on a calculation which included a negative number, but would not necessarily result in a negative number. [#614](https://github.com/PHPCompatibility/PHPCompatibility/pull/614). Fixes [#294](https://github.com/PHPCompatibility/PHPCompatibility/issues/294), [#466](https://github.com/PHPCompatibility/PHPCompatibility/issues/466).
565
- - :bug: The `NewClosure` sniff would report the same issue twice when the issue was encountered in a nested closure. [#669](https://github.com/PHPCompatibility/PHPCompatibility/pull/669)
566
- - :bug: The `NewKeywords` sniff would underreport on non-lowercase keywords. [#627](https://github.com/PHPCompatibility/PHPCompatibility/pull/627)
567
- - :bug: The `NewKeywords` sniff would incorrectly report on the use of class constants and class properties using the same name as a keyword. [#627](https://github.com/PHPCompatibility/PHPCompatibility/pull/627)
568
- - :bug: The `NewNullableTypes` sniff would potentially underreport when comments where interspersed in the (return) type declarations. [#577](https://github.com/PHPCompatibility/PHPCompatibility/pull/577)
569
- - :bug: The `Sniff::getFunctionCallParameters()` utility method would in rare cases return incorrect results when it encountered a closure as a parameter. [#682](https://github.com/PHPCompatibility/PHPCompatibility/pull/682)
570
- - :bug: The `Sniff::getReturnTypeHintToken()` utility method would not always return a `$stackPtr`. [#645](https://github.com/PHPCompatibility/PHPCompatibility/pull/645)
571
- - :bug: Minor miscellanous other bugfixes. [#670](https://github.com/PHPCompatibility/PHPCompatibility/pull/670)
572
- - :umbrella: `PHPCompatibility\Tests\BaseClass\MethodTestFrame::getTargetToken()` could potentially not find the correct token to run a test against. [#588](https://github.com/PHPCompatibility/PHPCompatibility/pull/588)
573
-
574
- ### Credits
575
- Thanks go out to [Michael Babker] and [Juliette Reinders Folmer] for their contributions to this version. :clap:
576
-
577
-
578
- ## [8.1.0] - 2017-12-27
579
-
580
- See all related issues and PRs in the [8.1.0 milestone].
581
-
582
- ### Added
583
- - :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/PHPCompatibility/PHPCompatibility/pull/525), [#551](https://github.com/PHPCompatibility/PHPCompatibility/pull/551), [#566](https://github.com/PHPCompatibility/PHPCompatibility/pull/566). Fixes [#263](https://github.com/PHPCompatibility/PHPCompatibility/issues/263).
584
- - :star2: New `MagicAutoloadDeprecation` sniff to detect deprecated `__autoload()` functions as deprecated in PHP 7.2. [#540](https://github.com/PHPCompatibility/PHPCompatibility/pull/540)
585
- - :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/PHPCompatibility/PHPCompatibility/pull/524)
586
- - :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/PHPCompatibility/PHPCompatibility/pull/535). Fixes [#534](https://github.com/PHPCompatibility/PHPCompatibility/issues/534).
587
- - :star: `DeprecatedFunctions` sniff: recognize yet more PHP 7.2 deprecated functions. [#561](https://github.com/PHPCompatibility/PHPCompatibility/pull/561), [#566](https://github.com/PHPCompatibility/PHPCompatibility/pull/566)
588
- - :star: `DeprecatedIniDirectives` sniff: recognize the last of the PHP 7.2 deprecated ini directives. [#566](https://github.com/PHPCompatibility/PHPCompatibility/pull/566), [#567](https://github.com/PHPCompatibility/PHPCompatibility/pull/567)
589
- - :star: `NewFunctions` : detection of all new PHP 7.2 functions added. [#522](https://github.com/PHPCompatibility/PHPCompatibility/pull/522), [#545](https://github.com/PHPCompatibility/PHPCompatibility/pull/545), [#551](https://github.com/PHPCompatibility/PHPCompatibility/pull/551), [#565](https://github.com/PHPCompatibility/PHPCompatibility/pull/565)
590
- - :star: `RemovedExtensions` : report on usage of the `mcrypt` extension which has been removed in PHP 7.2. [#566](https://github.com/PHPCompatibility/PHPCompatibility/pull/566)
591
- - :star: `RemovedGlobalVariables` : detection of the use of `$php_errormsg` with `track_errors` which has been deprecated in PHP 7.2. [#528](https://github.com/PHPCompatibility/PHPCompatibility/pull/528)
592
- - :books: Documentation : added reporting usage instructions. [#533](https://github.com/PHPCompatibility/PHPCompatibility/pull/533), [#552](https://github.com/PHPCompatibility/PHPCompatibility/pull/552)
593
-
594
- ### Changed
595
- - :pushpin: `NewClosures` : downgraded "$this found in closure outside class" to warning. [#536](https://github.com/PHPCompatibility/PHPCompatibility/pull/535). Fixes [#527](https://github.com/PHPCompatibility/PHPCompatibility/issues/527).
596
- - :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/PHPCompatibility/PHPCompatibility/pull/564)
597
- - :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/PHPCompatibility/PHPCompatibility/pull/564)
598
- - :rewind: `NewLanguageConstructs` : updated the version number for `T_COALESCE_EQUAL`. [#523](https://github.com/PHPCompatibility/PHPCompatibility/pull/523)
599
- - :pencil2: `Sniff::getTestVersion()` : simplified regex logic. [#520](https://github.com/PHPCompatibility/PHPCompatibility/pull/520)
600
- - :green_heart: Travis : build tests are now being run against PHP 7.2 as well. [#511](https://github.com/PHPCompatibility/PHPCompatibility/pull/511)
601
- - :wrench: Improved check for superfluous whitespaces in files. [#542](https://github.com/PHPCompatibility/PHPCompatibility/pull/542)
602
- - :wrench: Build/PHPCS : stabilized the exclude patterns. [#529](https://github.com/PHPCompatibility/PHPCompatibility/pull/529)
603
- - :wrench: Build/PHPCS : added array indentation check. [#538](https://github.com/PHPCompatibility/PHPCompatibility/pull/538)
604
- - :white_check_mark: PHPCS cross-version compatibility : sync `FindExtendedClassname()` method with upstream. [#507](https://github.com/PHPCompatibility/PHPCompatibility/pull/507)
605
- - :wrench: The minimum version for the recommended `DealerDirect/phpcodesniffer-composer-installer` Composer plugin has been upped to `0.4.3`. [#548](https://github.com/PHPCompatibility/PHPCompatibility/pull/548)
606
-
607
- ### Fixed
608
- - :bug: `ForbiddenCallTimePassByReference` : a false positive was being thrown when a global constant was followed by a _bitwise and_. [#562](https://github.com/PHPCompatibility/PHPCompatibility/pull/562). Fixes [#39](https://github.com/PHPCompatibility/PHPCompatibility/issues/39).
609
- - :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/PHPCompatibility/PHPCompatibility/pull/564). Fixes [#537](https://github.com/PHPCompatibility/PHPCompatibility/issues/537).
610
- - :bug: `ForbiddenGlobalVariableVariable` : variables interspersed with whitespace and/or comments were not being reported. [#564](https://github.com/PHPCompatibility/PHPCompatibility/pull/564)
611
- - :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/PHPCompatibility/PHPCompatibility/pull/516). Fixes [#515](https://github.com/PHPCompatibility/PHPCompatibility/issues/515)
612
- - :bug: `VariableVariables` : variables interspersed with whitespace and/or comments were not being reported. [#563](https://github.com/PHPCompatibility/PHPCompatibility/pull/563)
613
- - :umbrella: Fixed some unintentional syntax errors in test files. [#539](https://github.com/PHPCompatibility/PHPCompatibility/pull/539)
614
- - :umbrella: Tests : fixed case numbering error. [#525](https://github.com/PHPCompatibility/PHPCompatibility/pull/525)
615
- - :books: Tests : added missing test skip explanation. [#521](https://github.com/PHPCompatibility/PHPCompatibility/pull/521)
616
- - :wrench: Fixed PHPCS whitespaces. [#543](https://github.com/PHPCompatibility/PHPCompatibility/pull/543)
617
- - :wrench: Fixed code test coverage verification. [#550](https://github.com/PHPCompatibility/PHPCompatibility/pull/550). Fixes [#549](https://github.com/PHPCompatibility/PHPCompatibility/issues/549).
618
-
619
- ### Credits
620
- Thanks go out to [Juliette Reinders Folmer] and [Jonathan Van Belle] for their contributions to this version. :clap:
621
-
622
-
623
- ## [8.0.1] - 2017-08-07
624
-
625
- See all related issues and PRs in the [8.0.1 milestone].
626
-
627
- ### Added
628
- - :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/PHPCompatibility/PHPCompatibility/pull/498)
629
- - :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/PHPCompatibility/PHPCompatibility/pull/497)
630
- - :star: `NewGroupUseDeclaration`: Detection of PHP 7.2 trailing comma's in group use statements. [#504](https://github.com/PHPCompatibility/PHPCompatibility/pull/504)
631
- - :star: `DeprecatedFunctions` sniff: recognize some more PHP 7.2 deprecated functions. [#501](https://github.com/PHPCompatibility/PHPCompatibility/pull/501)
632
- - :star: `DeprecatedIniDirectives` sniff: recognize more PHP 7.2 deprecated ini directives. [#500](https://github.com/PHPCompatibility/PHPCompatibility/pull/500)
633
- - :star: `ForbiddenNames` sniff: recognize `object` as a forbidden keyword since PHP 7.2. [#499](https://github.com/PHPCompatibility/PHPCompatibility/pull/499)
634
- - :star: `NewReturnTypeDeclarations` sniff: recognize generic `parent`, PHP 7.1 `iterable` and PHP 7.2 `object` return type declarations. [#505](https://github.com/PHPCompatibility/PHPCompatibility/pull/505), [#499](https://github.com/PHPCompatibility/PHPCompatibility/pull/499)
635
- - :star: `NewScalarTypeDeclarations` sniff: recognize PHP 7.2 `object` type declarion. [#499](https://github.com/PHPCompatibility/PHPCompatibility/pull/499)
636
-
637
- ### Changed
638
- - :pencil2: Improved clarity of the deprecated functions alternative in the error message. [#502](https://github.com/PHPCompatibility/PHPCompatibility/pull/502)
639
-
640
- ### Fixed
641
- - :fire_engine: Temporary hotfix for installed_paths (pending [upstream fix](https://github.com/squizlabs/PHP_CodeSniffer/issues/1591).) [#503](https://github.com/PHPCompatibility/PHPCompatibility/pull/503)
642
-
643
- ### Credits
644
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
645
-
646
-
647
-
648
- ## [8.0.0] - 2017-08-03
649
-
650
- **IMPORTANT**: This release contains a **breaking change**. Please read the below information carefully before upgrading!
651
-
652
- The directory layout of the PHPCompatibility standard has been changed for improved compatibility with Composer.
653
- This means that the PHPCompatibility standard no longer extends from the root directory of the repository, but now lives in its own subdirectory `/PHPCompatibility`.
654
-
655
- This release also bring compatibility with PHPCS 3.x to the PHPCompatibility standard.
656
-
657
- There are two things you will need to be aware of:
658
- * The path to the PHPCompatibility standard has changed.
659
- * If you intend to upgrade to PHPCS 3.x, the path to the `phpcs` script has changed (upstream change).
660
-
661
- Please follow the below upgrade instructions carefully. This should be a one-time only action.
662
-
663
- ### Upgrade instructions
664
-
665
- ### Before upgrading
666
-
667
- If you had previously made accommodations for the old directory layout, you should remove any such _"hacks"_ (meant in the kindest of ways) now.
668
-
669
- 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.
670
-
671
- So, please remove those first.
672
-
673
- > **Side-note**:
674
- >
675
- > 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.
676
-
677
- ### Upgrading: re-registering PHPCompatibility with PHP CodeSniffer
678
-
679
- 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.
680
-
681
- 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.
682
-
683
- #### Using a Composer plugin
684
-
685
- 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.
686
- ```bash
687
- composer remove --dev simplyadmire/composer-plugins
688
- composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.4.3
689
- composer install
690
- composer update phpcompatibility/php-compatibility squizlabs/php_codesniffer
691
- vendor/bin/phpcs -i
692
- ```
693
- If all went well, you should now see PHPCompatibility listed again in the list of installed standards.
694
-
695
- #### Manually re-registering PHPCompatibility
696
-
697
- 1. First run `phpcs --config-show` to check which path(s) are currently registered with PHP CodeSniffer for external standards.
698
- 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):
699
-
700
- Install type | Old path | New path
701
- ------------ | -------- | ---------
702
- Composer | `vendor/wimg` | `vendor/phpcompatibility/php-compatibility`
703
- Unzipped release to arbitrary directory | `path/to/dir/abovePHPCompatibility` | `path/to/dir/abovePHPCompatibility/PHPCompatibility`
704
- Git checkout | `path/to/dir/abovePHPCompatibility` | `path/to/dir/abovePHPCompatibility/PHPCompatibility`
705
- PEAR | If the old install instruction has been followed, not registered. | `path/to/PHPCompatibility`
706
-
707
- > **Side-note**:
708
- >
709
- > 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.
710
-
711
- 3. There are two ways in which you can register the new `installed_paths` value with PHP CodeSniffer. Choose your preferred method:
712
- * Run `phpcs --config-set installed_paths ...` and include all previously installed paths including the _adjusted_ path for the PHPCompatibility standard.
713
-
714
- For example, if the previous value of `installed_paths` was
715
-
716
- `/path/to/MyStandard,/path/to/dir/abovePHPCompatibility`
717
-
718
- you should now set it using
719
-
720
- `phpcs --config-set installed_paths /path/to/MyStandard,/path/to/PHPCompatibility`
721
-
722
- * 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:
723
- ```xml
724
- <config name="installed_paths" value="vendor/phpcompatibility/php-compatibility" />
725
- ```
726
- 4. Run `phpcs -i` to verify that the PHPCompatibility standard is now listed again in the list of installed standards.
727
-
728
-
729
- ### Upgrading to PHPCS 3.x
730
-
731
- The path to the `phpcs` script has changed in PHPCS 3.x which will impact how you call PHPCS.
732
-
733
- Version | PHPCS 2.x | PHPCS 3.x
734
- ------- | --------- | ---------
735
- Generic `phpcs` Command | `path/to/PHP_CodeSniffer/scripts/phpcs ....` | `path/to/PHP_CodeSniffer/bin/phpcs ....`
736
- Composer command | `vendor/bin/phpcs ...` | `vendor/bin/phpcs ...`
737
-
738
- 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.
739
-
740
-
741
- ### Upgrading a Travis build script
742
-
743
- If you run PHPCompatibility against your code as part of your Travis build:
744
- * 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.
745
- * 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:
746
- 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.
747
- 2. Check to which path PHPCompatibility is being cloned and adjust the path if necessary.
748
- 3. Adjust the `phpcs --config-set installed_paths` command as described above to point to the root of the cloned PHPCompatibility repo.
749
- 4. If you switched to using PHPCS 3.x, adjust the call to PHPCS.
750
-
751
-
752
-
753
- ### Changelog for version 8.0.0
754
-
755
- See all related issues and PRs in the [8.0.0 milestone].
756
-
757
- ### Added
758
- - :two_hearts: Support for PHP CodeSniffer 3.x. [#482](https://github.com/PHPCompatibility/PHPCompatibility/pull/482), [#481](https://github.com/PHPCompatibility/PHPCompatibility/pull/481), [#480](https://github.com/PHPCompatibility/PHPCompatibility/pull/480), [#488](https://github.com/PHPCompatibility/PHPCompatibility/pull/488), [#489](https://github.com/PHPCompatibility/PHPCompatibility/pull/489), [#495](https://github.com/PHPCompatibility/PHPCompatibility/pull/495)
759
-
760
- ### Changed
761
- - :gift: As of this version PHPCompatibility will use semantic versioning.
762
- - :fire: The directory structure of the repository has changed for better compatibility with installation via Composer. [#446](https://github.com/PHPCompatibility/PHPCompatibility/pull/446). Fixes [#102](https://github.com/PHPCompatibility/PHPCompatibility/issues/102), [#107](https://github.com/PHPCompatibility/PHPCompatibility/issues/107)
763
- - :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/PHPCompatibility/PHPCompatibility/pull/482)
764
- - :wrench: Improved the information provided to Composer from the `composer.json` file. [#446](https://github.com/PHPCompatibility/PHPCompatibility/pull/446), [#482](https://github.com/PHPCompatibility/PHPCompatibility/pull/482), [#486](https://github.com/PHPCompatibility/PHPCompatibility/pull/486)
765
- - :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/PHPCompatibility/PHPCompatibility/pull/494)
766
- - :wrench: A variety of minor improvements to the build process. [#485](https://github.com/PHPCompatibility/PHPCompatibility/pull/485), [#486](https://github.com/PHPCompatibility/PHPCompatibility/pull/486), [#487](https://github.com/PHPCompatibility/PHPCompatibility/pull/487)
767
- - :wrench: Some files for use by contributors have been renamed to use `.dist` extensions or moved for easier access. [#478](https://github.com/PHPCompatibility/PHPCompatibility/pull/478), [#479](https://github.com/PHPCompatibility/PHPCompatibility/pull/479), [#483](https://github.com/PHPCompatibility/PHPCompatibility/pull/483), [#493](https://github.com/PHPCompatibility/PHPCompatibility/pull/493)
768
- - :books: The installation instructions in the Readme. [#496](https://github.com/PHPCompatibility/PHPCompatibility/pull/496)
769
- - :books: The unit test instructions in the Contributing file. [#496](https://github.com/PHPCompatibility/PHPCompatibility/pull/496)
770
- - :books: Improved the example code in the Readme. [#490](https://github.com/PHPCompatibility/PHPCompatibility/pull/490)
771
-
772
- ### Removed
773
- - :no_entry_sign: Support for PHP 5.1 and 5.2.
774
-
775
- 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/PHPCompatibility/PHPCompatibility/pull/484), [#482](https://github.com/PHPCompatibility/PHPCompatibility/pull/482)
776
-
777
- ### Credits
778
- Thanks go out to [Gary Jones] and [Juliette Reinders Folmer] for their contributions to this version. :clap:
779
-
780
-
781
- ## [7.1.5] - 2017-07-17
782
-
783
- See all related issues and PRs in the [7.1.5 milestone].
784
-
785
- ### Added
786
- - :star: The `NewKeywords` sniff will now also sniff for `yield from` which was introduced in PHP 7.0. [#477](https://github.com/PHPCompatibility/PHPCompatibility/pull/477). Fixes [#476](https://github.com/PHPCompatibility/PHPCompatibility/issues/476)
787
- - :books: The LGPL-3.0 license. [#447](https://github.com/PHPCompatibility/PHPCompatibility/pull/447)
788
-
789
- ### Changed
790
- - :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/PHPCompatibility/PHPCompatibility/pull/451)
791
- - :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/PHPCompatibility/PHPCompatibility/pull/452)
792
- - :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/PHPCompatibility/PHPCompatibility/pull/454)
793
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#443](https://github.com/PHPCompatibility/PHPCompatibility/pull/443), [#474](https://github.com/PHPCompatibility/PHPCompatibility/pull/474)
794
- - :pencil2: Renamed a test file for consistency. [#453](https://github.com/PHPCompatibility/PHPCompatibility/pull/453)
795
- - :wrench: Code style clean up. [#429](https://github.com/PHPCompatibility/PHPCompatibility/pull/429)
796
- - :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/PHPCompatibility/PHPCompatibility/pull/444)
797
- - :green_heart: The code base will now be checked for consistent code style during build testing. [#429](https://github.com/PHPCompatibility/PHPCompatibility/pull/429)
798
- - :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/PHPCompatibility/PHPCompatibility/pull/450)
799
- - :books: Made it explicit that - at this moment - PHPCS 3.x is not (yet) supported. [#444](https://github.com/PHPCompatibility/PHPCompatibility/pull/444)
800
- - :books: Minor improvements to the Readme. [#448](https://github.com/PHPCompatibility/PHPCompatibility/pull/448), [#449](https://github.com/PHPCompatibility/PHPCompatibility/pull/449), [#468](https://github.com/PHPCompatibility/PHPCompatibility/pull/468)
801
- - :books: Minor improvements to the Contributing guidelines. [#467](https://github.com/PHPCompatibility/PHPCompatibility/pull/467)
802
-
803
- ### Removed
804
- - :no_entry_sign: The `DefaultTimeZoneRequired` sniff. This sniff was checking server settings rather than code. [#458](https://github.com/PHPCompatibility/PHPCompatibility/pull/458). Fixes [#457](https://github.com/PHPCompatibility/PHPCompatibility/issues/457)
805
- - :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/PHPCompatibility/PHPCompatibility/pull/442). Fixes [#436](https://github.com/PHPCompatibility/PHPCompatibility/issues/436)
806
-
807
- ### Fixed
808
- - :bug: `NewClass` sniff: was reporting an incorrect introduction version number for a few of the Exception classes. [#441](https://github.com/PHPCompatibility/PHPCompatibility/pull/441). Fixes [#440](https://github.com/PHPCompatibility/PHPCompatibility/issues/440).
809
- - :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/PHPCompatibility/PHPCompatibility/pull/462). Fixes [#460](https://github.com/PHPCompatibility/PHPCompatibility/issues/460)
810
- - :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/PHPCompatibility/PHPCompatibility/pull/463).
811
- - :bug: `DeprecatedFunctions` sniff: was reporting false positives for classes using the same name as a deprecated function. [#465](https://github.com/PHPCompatibility/PHPCompatibility/pull/465). Fixes [#464](https://github.com/PHPCompatibility/PHPCompatibility/issues/464)
812
-
813
- ### Credits
814
- Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
815
-
816
-
817
- ## [7.1.4] - 2017-05-06
818
-
819
- See all related issues and PRs in the [7.1.4 milestone].
820
-
821
- ### Added
822
- - :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/PHPCompatibility/PHPCompatibility/pull/382)
823
- - :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/PHPCompatibility/PHPCompatibility/pull/397)
824
- - :star2: New `ForbiddenClosureUseVariableNames` sniff to detect PHP 7.1 forbidden variable names in closure use statements. [#386](https://github.com/PHPCompatibility/PHPCompatibility/pull/386). Fixes [#374](https://github.com/PHPCompatibility/PHPCompatibility/issues/374)
825
- - :star2: New `NewArrayStringDereferencing` sniff to detect array and string literal dereferencing as introduced in PHP 5.5. [#388](https://github.com/PHPCompatibility/PHPCompatibility/pull/388)
826
- - :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/PHPCompatibility/PHPCompatibility/pull/391). Fixes [#51](https://github.com/PHPCompatibility/PHPCompatibility/issues/51)
827
- - :star2: New `NewMagicClassConstant` sniff to detect use of the magic `::class` constant as introduced in PHP 5.5. [#403](https://github.com/PHPCompatibility/PHPCompatibility/pull/403). Fixes [#364](https://github.com/PHPCompatibility/PHPCompatibility/issues/364).
828
- - :star2: New `NewUseConstFunction` sniff to detect use statements importing constants and functions as introduced in PHP 5.6. [#401](https://github.com/PHPCompatibility/PHPCompatibility/pull/401)
829
- - :star: `DeprecatedFunctions` sniff: recognize PHP 7.2 deprecated GD functions. [#392](https://github.com/PHPCompatibility/PHPCompatibility/pull/392)
830
- - :star: `DeprecatedIniDirectives` sniff: recognize PHP 7.2 deprecated `mbstring.func_overload` directive. [#377](https://github.com/PHPCompatibility/PHPCompatibility/pull/377)
831
- - :star: `NewClasses` sniff: check for the PHP 5.1 `libXMLError` class. [#412](https://github.com/PHPCompatibility/PHPCompatibility/pull/412)
832
- - :star: `NewClasses` sniff: recognize all native PHP Exception classes. [#418](https://github.com/PHPCompatibility/PHPCompatibility/pull/418)
833
- - :star: `NewClosure` 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/PHPCompatibility/PHPCompatibility/pull/389). Fixes [#24](https://github.com/PHPCompatibility/PHPCompatibility/issues/24).
834
- - :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/PHPCompatibility/PHPCompatibility/pull/375)
835
- - :star: `NewFunctions` sniff: recognize new PHP 7.2 socket related functions. [#376](https://github.com/PHPCompatibility/PHPCompatibility/pull/376)
836
- - :star: `NewInterfaces` sniff: check for some more PHP native interfaces. [#411](https://github.com/PHPCompatibility/PHPCompatibility/pull/411)
837
- - :star: New `isClassProperty()`, `isClassConstant()` and `validDirectScope()` utility methods to the `PHPCompatibility_Sniff` class. [#393](https://github.com/PHPCompatibility/PHPCompatibility/pull/393), [#391](https://github.com/PHPCompatibility/PHPCompatibility/pull/391).
838
- - :star: New `getTypeHintsFromFunctionDeclaration()` utility method to the `PHPCompatibility_Sniff` class. [#414](https://github.com/PHPCompatibility/PHPCompatibility/pull/414).
839
- - :umbrella: Unit tests against false positives for the `NewMagicMethods` sniff. [#381](https://github.com/PHPCompatibility/PHPCompatibility/pull/381)
840
- - :umbrella: More unit tests for the `getTestVersion()` utility method. [#405](https://github.com/PHPCompatibility/PHPCompatibility/pull/405), [#430](https://github.com/PHPCompatibility/PHPCompatibility/pull/430)
841
- - :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/PHPCompatibility/PHPCompatibility/pull/433)
842
- - :books: Readme: information about setting `installed_paths` via a custom ruleset. [#407](https://github.com/PHPCompatibility/PHPCompatibility/pull/407)
843
- - :books: `Changelog.md` file containing a record of notable changes since the first tagged release. [#421](https://github.com/PHPCompatibility/PHPCompatibility/pull/421)
844
-
845
- ### Changed
846
- - :pushpin: The `ForbiddenNamesAsDeclared` sniff will now emit `warning`s for soft reserved keywords. [#406](https://github.com/PHPCompatibility/PHPCompatibility/pull/406), [#370](https://github.com/PHPCompatibility/PHPCompatibility/pull/370).
847
- - :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/PHPCompatibility/PHPCompatibility/pull/417)
848
- - :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/PHPCompatibility/PHPCompatibility/pull/378), [#383](https://github.com/PHPCompatibility/PHPCompatibility/pull/383), [#393](https://github.com/PHPCompatibility/PHPCompatibility/pull/393), [#394](https://github.com/PHPCompatibility/PHPCompatibility/pull/394), [#395](https://github.com/PHPCompatibility/PHPCompatibility/pull/395), [#396](https://github.com/PHPCompatibility/PHPCompatibility/pull/396). Fixes [#351](https://github.com/PHPCompatibility/PHPCompatibility/issues/351) and [#333](https://github.com/PHPCompatibility/PHPCompatibility/issues/333).
849
- - :pushpin: The `NewClasses` and `NewInterfaces` sniffs will now also report on new classes/interfaces when used as type hints. [#414](https://github.com/PHPCompatibility/PHPCompatibility/pull/414), [#416](https://github.com/PHPCompatibility/PHPCompatibility/pull/416). Fixes [#352](https://github.com/PHPCompatibility/PHPCompatibility/issues/352)
850
- - :pushpin: The `NewClasses` sniff will now also report on Exception classes when used in (multi-)`catch` statements. [#418](https://github.com/PHPCompatibility/PHPCompatibility/pull/418). Fixes [#373](https://github.com/PHPCompatibility/PHPCompatibility/issues/373).
851
- - :pushpin: The `NewScalarTypeDeclarations` sniff will now report on new type hints even when the type hint is nullable. [#379](https://github.com/PHPCompatibility/PHPCompatibility/pull/379)
852
- - :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/PHPCompatibility/PHPCompatibility/pull/390)
853
- - :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/PHPCompatibility/PHPCompatibility/pull/432). Fixes [#334](https://github.com/PHPCompatibility/PHPCompatibility/issues/334).
854
- - :pencil2: `NewFunctionParameter` sniff: version number precision for two parameters. [#384](https://github.com/PHPCompatibility/PHPCompatibility/pull/384), [#428](https://github.com/PHPCompatibility/PHPCompatibility/pull/428)
855
- - :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/PHPCompatibility/PHPCompatibility/pull/408)
856
- - :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/PHPCompatibility/PHPCompatibility/pull/431)
857
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#385](https://github.com/PHPCompatibility/PHPCompatibility/pull/385), [#387](https://github.com/PHPCompatibility/PHPCompatibility/pull/387), [#415](https://github.com/PHPCompatibility/PHPCompatibility/pull/415), [#423](https://github.com/PHPCompatibility/PHPCompatibility/pull/423), [#424](https://github.com/PHPCompatibility/PHPCompatibility/pull/424)
858
- - :recycle: Minor simplification of the PHPUnit 6 compatibility layer and other test code. [#426](https://github.com/PHPCompatibility/PHPCompatibility/pull/426), [#425](https://github.com/PHPCompatibility/PHPCompatibility/pull/425)
859
- - General housekeeping. [#398](https://github.com/PHPCompatibility/PHPCompatibility/pull/398), [#400](https://github.com/PHPCompatibility/PHPCompatibility/pull/400)
860
- - :wrench: Minor tweaks to the Travis build script. [#409](https://github.com/PHPCompatibility/PHPCompatibility/pull/409)
861
- - :green_heart: The sniffs are now also tested against PHP nightly for consistent results. [#380](https://github.com/PHPCompatibility/PHPCompatibility/pull/380)
862
-
863
- ### Fixed
864
- - :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/PHPCompatibility/PHPCompatibility/pull/430)
865
- - :bug: The `ForbiddenNames` sniff would throw false positives for `use` statements with the `final` modifier in traits. [#402](https://github.com/PHPCompatibility/PHPCompatibility/pull/402).
866
- - :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/PHPCompatibility/PHPCompatibility/pull/413)
867
- - :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/PHPCompatibility/PHPCompatibility/pull/419)
868
- - :bug: The `ForbiddenNames` sniff would not always correctly report on use statements importing constants or functions using reserved keywords. [#420](https://github.com/PHPCompatibility/PHPCompatibility/pull/420)
869
- - :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/PHPCompatibility/PHPCompatibility/pull/424)
870
- - :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/PHPCompatibility/PHPCompatibility/pull/422)
871
-
872
- ### Credits
873
- Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
874
-
875
-
876
- ## [7.1.3] - 2017-04-02
877
-
878
- See all related issues and PRs in the [7.1.3 milestone].
879
-
880
- ### Added
881
- - :zap: The `testVersion` config parameter now allows for specifying unbounded ranges.
882
- For example: specifying `-5.6` means: check for compatibility with all PHP versions up to and including PHP 5.6;
883
- Specifying `7.0-` means: check for compatibility with all PHP versions from PHP 7.0 upwards.
884
- For more information about setting the `testVersion`, see [Using the compatibility sniffs](https://github.com/PHPCompatibility/PHPCompatibility#using-the-compatibility-sniffs) in the readme.
885
- - :umbrella: Unit test for multi-line short arrays for the `ShortArray` sniff. [#347](https://github.com/PHPCompatibility/PHPCompatibility/pull/347)
886
- - :umbrella: Various additional unit tests against false positives. [#345](https://github.com/PHPCompatibility/PHPCompatibility/pull/345), [#369](https://github.com/PHPCompatibility/PHPCompatibility/pull/369)
887
- - :umbrella: Unit tests for the `supportsBelow()`, `supportsAbove()` and `getTestVersion()` utility methods. [#363](https://github.com/PHPCompatibility/PHPCompatibility/pull/363)
888
- - :books: Readme: information about installation of the standard using git check-out. [#349](https://github.com/PHPCompatibility/PHPCompatibility/pull/349)
889
- - :books: `Contributing.md` file with information about reporting bugs, requesting features, making pull requests and running the unit tests. [#350](https://github.com/PHPCompatibility/PHPCompatibility/pull/350)
890
-
891
- ### Changed
892
- - :pushpin: The `ForbiddenFunctionParametersWithSameName`, `NewScalarTypeDeclarations`, `ParameterShadowSuperGlobals` sniff will now also sniff for and report violations in closures. [#331](https://github.com/PHPCompatibility/PHPCompatibility/pull/331)
893
- - :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/PHPCompatibility/PHPCompatibility/pull/335)
894
- - :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/PHPCompatibility/PHPCompatibility/pull/362)
895
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#360](https://github.com/PHPCompatibility/PHPCompatibility/pull/360)
896
- - :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.
897
- Relevant additional unit tests have been added and others adjusted. [#369](https://github.com/PHPCompatibility/PHPCompatibility/pull/369)
898
- - :recycle: Refactoring/tidying up of some unit test code. [#343](https://github.com/PHPCompatibility/PHPCompatibility/pull/343), [#345](https://github.com/PHPCompatibility/PHPCompatibility/pull/345), [#356](https://github.com/PHPCompatibility/PHPCompatibility/pull/356), [#355](https://github.com/PHPCompatibility/PHPCompatibility/pull/355), [#359](https://github.com/PHPCompatibility/PHPCompatibility/pull/359)
899
- - General housekeeping. [#346](https://github.com/PHPCompatibility/PHPCompatibility/pull/346)
900
- - :books: Readme: Clarify minimum requirements and influence on the results. [#348](https://github.com/PHPCompatibility/PHPCompatibility/pull/348)
901
-
902
- ### Removed
903
- - :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/PHPCompatibility/PHPCompatibility/pull/354)
904
-
905
- ### Fixed
906
- - :bug: The `PregReplaceEModifier` sniff would throw a false positive if a quote character was used as the regex delimiter. [#357](https://github.com/PHPCompatibility/PHPCompatibility/pull/357)
907
- - :bug: `RemovedGlobalVariables` sniff would report false positives for class properties shadowing the removed `$HTTP_RAW_POST_DATA` variables. [#354](https://github.com/PHPCompatibility/PHPCompatibility/pull/354).
908
- - :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/PHPCompatibility/PHPCompatibility/pull/338), [#342](https://github.com/PHPCompatibility/PHPCompatibility/pull/342)
909
- - :bug: The `determineNamespace()` utility method would in certain cases not break out a loop. [#358](https://github.com/PHPCompatibility/PHPCompatibility/pull/358)
910
- - :wrench: Travis script: Minor tweak for PHP 5.2 compatibility. [#341](https://github.com/PHPCompatibility/PHPCompatibility/pull/341)
911
- - :wrench: The unit test suite is now also compatible with PHPUnit 6. [#365](https://github.com/PHPCompatibility/PHPCompatibility/pull/365)
912
- - :books: Readme: Typo in the composer instructions. [#344](https://github.com/PHPCompatibility/PHPCompatibility/pull/344)
913
-
914
- ### Credits
915
- Thanks go out to [Arthur Edamov], [Juliette Reinders Folmer], [Mark Clements] and [Tadas Juozapaitis] for their contributions to this version. :clap:
916
-
917
-
918
- ## [7.1.2] - 2017-02-17
919
-
920
- See all related issues and PRs in the [7.1.2 milestone].
921
-
922
- ### Added
923
- - :star2: New `VariableVariables` sniff to detect variables variables for which the behaviour has changed in PHP 7.0. [#310](https://github.com/PHPCompatibility/PHPCompatibility/pull/310) Fixes [#309](https://github.com/PHPCompatibility/PHPCompatibility/issues/309).
924
- - :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/PHPCompatibility/PHPCompatibility/pull/323)
925
- - :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/PHPCompatibility/PHPCompatibility/pull/340)
926
- - :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/PHPCompatibility/PHPCompatibility/pull/323).
927
- - :star: New `stripVariables()` utility method to the `PHPCompatibility_Sniff` class to strip variables from interpolated text strings. [#341](https://github.com/PHPCompatibility/PHPCompatibility/pull/314).
928
- - :umbrella: Additional unit tests covering previously uncovered code. [#308](https://github.com/PHPCompatibility/PHPCompatibility/pull/308)
929
-
930
- ### Changed
931
- - :pushpin: The `MbstringReplaceEModifier`, `PregReplaceEModifier` and `NewExecutionDirectives` sniffs will now also correctly interpret double quoted text strings with interpolated variables. [#341](https://github.com/PHPCompatibility/PHPCompatibility/pull/314), [#324](https://github.com/PHPCompatibility/PHPCompatibility/pull/324).
932
- - :pushpin: The `NewNullableTypes` sniff will now also report on nullable (return) type hints when used with closures. [#323](https://github.com/PHPCompatibility/PHPCompatibility/pull/323)
933
- - :pushpin: The `NewReturnTypeDeclarations` sniff will now also report on return type hints when used with closures. [#323](https://github.com/PHPCompatibility/PHPCompatibility/pull/323)
934
- - :pushpin: Allow for anonymous classes in the `inClassScope()` utility method. [#315](https://github.com/PHPCompatibility/PHPCompatibility/pull/315)
935
- - :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/PHPCompatibility/PHPCompatibility/pull/300)
936
- - :twisted_rightwards_arrows: The `NewScalarReturnTypeDeclarations` sniff has been renamed to `NewReturnTypeDeclarations`. [#323](https://github.com/PHPCompatibility/PHPCompatibility/pull/323)
937
- - :rewind: The `ForbiddenNames` sniff will now also correctly ignore anonymous classes when used in combination with PHPCS < 2.3.4. [#319](https://github.com/PHPCompatibility/PHPCompatibility/pull/319)
938
- - :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/PHPCompatibility/PHPCompatibility/pull/325)
939
- - :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/PHPCompatibility/PHPCompatibility/pull/320)
940
- - :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/PHPCompatibility/PHPCompatibility/pull/323)
941
- - :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/PHPCompatibility/PHPCompatibility/pull/323)
942
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#317](https://github.com/PHPCompatibility/PHPCompatibility/pull/317)
943
- - :recycle: Defer to upstream `hasCondition()` utility method where appropriate. [#315](https://github.com/PHPCompatibility/PHPCompatibility/pull/315)
944
- - :recycle: Minor refactoring of some unit test code. [#304](https://github.com/PHPCompatibility/PHPCompatibility/pull/304), [#303](https://github.com/PHPCompatibility/PHPCompatibility/pull/303), [#318](https://github.com/PHPCompatibility/PHPCompatibility/pull/318)
945
- - :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/PHPCompatibility/PHPCompatibility/pull/305)
946
- - :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/PHPCompatibility/PHPCompatibility/pull/307)
947
- - :wrench: Minor tweaks to the travis script. [#322](https://github.com/PHPCompatibility/PHPCompatibility/pull/322)
948
- - :green_heart: The PHPCompatibility code base itself will now be checked for cross-version compatibility during build testing. [#322](https://github.com/PHPCompatibility/PHPCompatibility/pull/322)
949
-
950
- ### Fixed
951
- - :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/PHPCompatibility/PHPCompatibility/pull/327)
952
- - :bug: The `ForbiddenCallTimePassByReference` sniff would throw false positives on assign by reference within function calls or conditions. [#302](https://github.com/PHPCompatibility/PHPCompatibility/pull/302) Fixes the last two cases reported in [#68](https://github.com/PHPCompatibility/PHPCompatibility/issues/68#issuecomment-231366445)
953
- - :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/PHPCompatibility/PHPCompatibility/pull/316)
954
- - :bug: The `NewKeywords` sniff would throw a false positive for the `const` keyword when encountered in an interface. [#312](https://github.com/PHPCompatibility/PHPCompatibility/pull/312)
955
- - :bug: The `NewNullableTypes` sniff would not report on nullable return types for namespaced classnames used as a type hint. [#323](https://github.com/PHPCompatibility/PHPCompatibility/pull/323)
956
- - :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/PHPCompatibility/PHPCompatibility/pull/300)
957
- - :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/PHPCompatibility/PHPCompatibility/pull/300)
958
- - :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/PHPCompatibility/PHPCompatibility/pull/313), [#323](https://github.com/PHPCompatibility/PHPCompatibility/pull/323), [#326](https://github.com/PHPCompatibility/PHPCompatibility/pull/326), [#340](https://github.com/PHPCompatibility/PHPCompatibility/pull/340)
959
-
960
- ### Credits
961
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
962
-
963
-
964
- ## [7.1.1] - 2016-12-14
965
-
966
- See all related issues and PRs in the [7.1.1 milestone].
967
-
968
- ### Added
969
- - :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/PHPCompatibility/PHPCompatibility/pull/298)
970
-
971
- ### Fixed
972
- - :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would incorrectly throw an error if the `clone` keyword was used with parenthesis. [#299](https://github.com/PHPCompatibility/PHPCompatibility/pull/299). Fixes [#284](https://github.com/PHPCompatibility/PHPCompatibility/issues/284)
973
-
974
- ### Credits
975
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
976
-
977
-
978
- ## [7.1.0] - 2016-12-14
979
-
980
- See all related issues and PRs in the [7.1.0 milestone].
981
-
982
- ### Added
983
- - :star: New `stringToErrorCode()`, `arrayKeysToLowercase()` and `addMessage()` utility methods to the `PHPCompatibility_Sniff` class. [#291](https://github.com/PHPCompatibility/PHPCompatibility/pull/291).
984
-
985
- ### Changed
986
- - :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/PHPCompatibility/PHPCompatibility/pull/291)
987
- - :pencil2: Minor changes to some of the error message texts for consistency across sniffs. [#291](https://github.com/PHPCompatibility/PHPCompatibility/pull/291)
988
- - :recycle: Refactored the complex version sniffs to reduce code duplication. [#291](https://github.com/PHPCompatibility/PHPCompatibility/pull/291)
989
- - :recycle: Miscellaneous other refactoring for improved performance and sniff accuracy. [#291](https://github.com/PHPCompatibility/PHPCompatibility/pull/291)
990
- - :umbrella: The unit tests for the `RemovedExtensions` sniff now verify that the correct alternative extension is being suggested. [#291](https://github.com/PHPCompatibility/PHPCompatibility/pull/291)
991
-
992
- ### Credits
993
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
994
-
995
-
996
- ## [7.0.8] - 2016-10-31 - :ghost: Spooky! :jack_o_lantern:
997
-
998
- See all related issues and PRs in the [7.0.8 milestone].
999
-
1000
- ### Added
1001
- - :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/PHPCompatibility/PHPCompatibility/pull/287). Fixes [#115](https://github.com/PHPCompatibility/PHPCompatibility/issues/115).
1002
- 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).
1003
- - :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/PHPCompatibility/PHPCompatibility/pull/271).
1004
- - :umbrella: More unit tests for the `ForbiddenNames` sniff. [#271](https://github.com/PHPCompatibility/PHPCompatibility/pull/271).
1005
-
1006
- ### Changed
1007
- - :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/PHPCompatibility/PHPCompatibility/pull/286)
1008
- This change affects the following sniffs:
1009
- * `DeprecatedPHP4StyleConstructors` will now throw a `warning` instead of an `error` for deprecated PHP4 style class constructors.
1010
- * `ForbiddenCallTimePassByReference` will now throw a `warning` if the `testVersion` is `5.3` and an `error` if the `testVersion` if `5.4` or higher.
1011
- * `MbstringReplaceEModifier` will now throw a `warning` instead of an `error` for usage of the deprecated `e` modifier.
1012
- * `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/PHPCompatibility/PHPCompatibility/issues/290).
1013
- * `TernaryOperators` will now throw an `error` when the `testVersion` < `5.3` and the middle part has been omitted.
1014
- * `ValidIntegers` will now throw a `warning` when an invalid binary integer is detected.
1015
- - :pencil2: `DeprecatedFunctions` and `DeprecatedIniDirectives` sniffs: minor change in the sniff error message text. Use _"removed"_ rather than the ominous _"forbidden"_. [#285](https://github.com/PHPCompatibility/PHPCompatibility/pull/285)
1016
- Also updated relevant internal variable names and documentation to match.
1017
-
1018
- ### Fixed
1019
- - :bug: `ForbiddenNames` sniff would throw false positives for `use` statements which changed the visibility of methods in traits. [#271](https://github.com/PHPCompatibility/PHPCompatibility/pull/271).
1020
- - :bug: `ForbiddenNames` sniff would not report reserved keywords when used in combination with `use function` or `use const`. [#271](https://github.com/PHPCompatibility/PHPCompatibility/pull/271).
1021
- - :bug: `ForbiddenNames` sniff would potentially - unintentionally - skip over tokens, thereby - potentially - not reporting all errors. [#271](https://github.com/PHPCompatibility/PHPCompatibility/pull/271).
1022
- - :wrench: Composer config: `prefer-stable` should be a root element of the json file. Fixes [#277](https://github.com/PHPCompatibility/PHPCompatibility/issues/277).
1023
-
1024
- ### Credits
1025
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
1026
-
1027
-
1028
- ## [7.0.7] - 2016-10-20
1029
-
1030
- See all related issues and PRs in the [7.0.7 milestone].
1031
-
1032
- ### Added
1033
- - :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/PHPCompatibility/PHPCompatibility/pull/278). Fixes [#275](https://github.com/PHPCompatibility/PHPCompatibility/issues/275)
1034
- - :star2: New `NewConstVisibility` sniff: detect visibility indicators for `class` and `interface` constants as introduced in PHP 7.1. [#280](https://github.com/PHPCompatibility/PHPCompatibility/pull/280). Fixes [#249](https://github.com/PHPCompatibility/PHPCompatibility/issues/249)
1035
- - :star2: New `NewHashAlgorithms` sniff to check used hash algorithms against the PHP version in which they were introduced. [#242](https://github.com/PHPCompatibility/PHPCompatibility/pull/242)
1036
- - :star2: New `NewMultiCatch` sniff: detect catch statements catching multiple Exceptions as introduced in PHP 7.1. [#281](https://github.com/PHPCompatibility/PHPCompatibility/pull/281). Fixes [#251](https://github.com/PHPCompatibility/PHPCompatibility/issues/251)
1037
- - :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/PHPCompatibility/PHPCompatibility/pull/282). Fixes [#247](https://github.com/PHPCompatibility/PHPCompatibility/issues/247)
1038
- - :star: `DeprecatedIniDirectives` sniff: recognize PHP 7.1 removed `session` ini directives. [#256](https://github.com/PHPCompatibility/PHPCompatibility/pull/256)
1039
- - :star: `NewFunctions` sniff: recognize new `socket_export_stream()` function as introduced in PHP 7.0.7. [#264](https://github.com/PHPCompatibility/PHPCompatibility/pull/264)
1040
- - :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/PHPCompatibility/PHPCompatibility/pull/273)
1041
- - :star: `NewFunctionParameters` sniff: recognize new OpenSSL function parameters as introduced in PHP 7.1. [#258](https://github.com/PHPCompatibility/PHPCompatibility/pull/258)
1042
- - :star: `NewIniDirectives` sniff: recognize new `session` ini directives as introduced in PHP 7.1. [#259](https://github.com/PHPCompatibility/PHPCompatibility/pull/259)
1043
- - :star: `NewScalarReturnTypeDeclarations` sniff: recognize PHP 7.1 `void` return type hint. [#250](https://github.com/PHPCompatibility/PHPCompatibility/pull/250)
1044
- - :star: `NewScalarTypeDeclarations` sniff: recognize PHP 7.1 `iterable` type hint. [#255](https://github.com/PHPCompatibility/PHPCompatibility/pull/255)
1045
- - :star: Recognize the PHP 7.1 deprecated `mcrypt` functionality in the `RemovedExtensions`, `DeprecatedFunctions` and `DeprecatedIniDirectives` sniffs. [#257](https://github.com/PHPCompatibility/PHPCompatibility/pull/257)
1046
-
1047
- ### Changed
1048
- - :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/PHPCompatibility/PHPCompatibility/pull/270)
1049
- - :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/PHPCompatibility/PHPCompatibility/pull/246).
1050
- - :pushpin: `RemovedHashAlgorithms` sniff: also recognize removed algorithms when used with the PHP 5.5+ `hash_pbkdf2()` function. [#240](https://github.com/PHPCompatibility/PHPCompatibility/pull/240)
1051
- - :pushpin: Properly recognize nullable type hints in the `getMethodParameters()` utility method. [#282](https://github.com/PHPCompatibility/PHPCompatibility/pull/282)
1052
- - :pencil2: `DeprecatedPHP4StyleConstructors` sniff: minor error message text fix. [#236](https://github.com/PHPCompatibility/PHPCompatibility/pull/236)
1053
- - :pencil2: `NewIniDirectives` sniff: improved precision for the introduction version numbers being reported. [#246](https://github.com/PHPCompatibility/PHPCompatibility/pull/246)
1054
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#238](https://github.com/PHPCompatibility/PHPCompatibility/pull/238), [#244](https://github.com/PHPCompatibility/PHPCompatibility/pull/244), [#240](https://github.com/PHPCompatibility/PHPCompatibility/pull/240), [#276](https://github.com/PHPCompatibility/PHPCompatibility/pull/276)
1055
- - :umbrella: Re-activate the unit tests for the `NewScalarReturnTypeDeclarations` sniff. [#250](https://github.com/PHPCompatibility/PHPCompatibility/pull/250)
1056
-
1057
- ### Fixed
1058
- - :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/PHPCompatibility/PHPCompatibility/pull/236)
1059
- - :bug: `LongArrays` sniff would report false positives for class properties shadowing removed PHP superglobals. [#270](https://github.com/PHPCompatibility/PHPCompatibility/pull/270). Fixes [#268](https://github.com/PHPCompatibility/PHPCompatibility/issues/268).
1060
- - :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/PHPCompatibility/PHPCompatibility/pull/237)
1061
- - :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/PHPCompatibility/PHPCompatibility/pull/246)
1062
- - :bug: `PregReplaceEModifier` sniff would report false positives for compound regex parameters with different quote types. [#266](https://github.com/PHPCompatibility/PHPCompatibility/pull/266). Fixes [#265](https://github.com/PHPCompatibility/PHPCompatibility/issues/265).
1063
- - :bug: `RemovedGlobalVariables` sniff would report false positives for lowercase/mixed cased variables shadowing superglobals. [#245](https://github.com/PHPCompatibility/PHPCompatibility/pull/245).
1064
- - :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/PHPCompatibility/PHPCompatibility/pull/240)
1065
- - :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/PHPCompatibility/PHPCompatibility/pull/238)
1066
-
1067
- ### Credits
1068
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
1069
-
1070
-
1071
- ## [7.0.6] - 2016-09-23
1072
-
1073
- See all related issues and PRs in the [7.0.6 milestone].
1074
-
1075
- ### Added
1076
- - :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/PHPCompatibility/PHPCompatibility/pull/224)
1077
- - :books: Readme: Add _PHP Version Support_ section. [#225](https://github.com/PHPCompatibility/PHPCompatibility/pull/225)
1078
-
1079
- ### Changed
1080
- - :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/PHPCompatibility/PHPCompatibility/pull/203)
1081
- - :pushpin: The `NewFunctionArrayDereferencing` sniff will now also check _method_ calls for array dereferencing, not just function calls. [#229](https://github.com/PHPCompatibility/PHPCompatibility/pull/229). Fixes [#227](https://github.com/PHPCompatibility/PHPCompatibility/issues/227).
1082
- - :pencil2: The `NewExecutionDirectives` sniff will now throw `warning`s instead of `error`s for invalid values encountered in execution directives. [#223](https://github.com/PHPCompatibility/PHPCompatibility/pull/223)
1083
- - :pencil2: Minor miscellaneous fixes. [#231](https://github.com/PHPCompatibility/PHPCompatibility/pull/231)
1084
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#219](https://github.com/PHPCompatibility/PHPCompatibility/pull/219), [#203](https://github.com/PHPCompatibility/PHPCompatibility/pull/203)
1085
- - :recycle: Defer to upstream `findImplementedInterfaceNames()` utility method when it exists. [#222](https://github.com/PHPCompatibility/PHPCompatibility/pull/222)
1086
- - :wrench: Exclude the test files from analysis by Scrutinizer CI. [#230](https://github.com/PHPCompatibility/PHPCompatibility/pull/230)
1087
-
1088
- ### Removed
1089
- - :no_entry_sign: Some redundant code. [#232](https://github.com/PHPCompatibility/PHPCompatibility/pull/232)
1090
-
1091
- ### Fixed
1092
- - :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/PHPCompatibility/PHPCompatibility/pull/212). Fixes [#210](https://github.com/PHPCompatibility/PHPCompatibility/issues/210).
1093
- - :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/PHPCompatibility/PHPCompatibility/pull/228). Fixes [#226](https://github.com/PHPCompatibility/PHPCompatibility/issues/226).
1094
- - :bug: `ParameterShadowSuperGlobals` sniff would report false positives for lowercase/mixed cased variables shadowing superglobals. [#218](https://github.com/PHPCompatibility/PHPCompatibility/pull/218). Fixes [#214](https://github.com/PHPCompatibility/PHPCompatibility/issues/214).
1095
- - :bug: The `determineNamespace()` utility method now accounts properly for namespaces within scoped `declare()` statements. [#221](https://github.com/PHPCompatibility/PHPCompatibility/pull/221)
1096
- - :books: Readme: Logo alignment in the Credits section. [#233](https://github.com/PHPCompatibility/PHPCompatibility/pull/233)
1097
-
1098
- ### Credits
1099
- Thanks go out to [Jason Stallings], [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
1100
-
1101
-
1102
- ## [7.0.5] - 2016-09-08
1103
-
1104
- See all related issues and PRs in the [7.0.5 milestone].
1105
-
1106
- ### Added
1107
- - :star2: New `MbstringReplaceEModifier` sniff to detect the use of the PHP 7.1 deprecated `e` modifier in Mbstring regex functions. [#202](https://github.com/PHPCompatibility/PHPCompatibility/pull/202)
1108
- - :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/PHPCompatibility/PHPCompatibility/pull/209)
1109
- - :star: New `getFunctionCallParameters()`, `getFunctionCallParameter()` utility methods in the `PHPCompatibility_Sniff` base class. [#170](https://github.com/PHPCompatibility/PHPCompatibility/pull/170)
1110
- - :star: New `tokenHasScope()` utility method in the `PHPCompatibility_Sniff` base class. [#189](https://github.com/PHPCompatibility/PHPCompatibility/pull/189)
1111
- - :umbrella: Unit test for `goto` and `callable` detection and some other miscellanous extra unit tests for the `NewKeywords` sniff. [#189](https://github.com/PHPCompatibility/PHPCompatibility/pull/189)
1112
- - :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/PHPCompatibility/PHPCompatibility/pull/217)
1113
-
1114
- ### Changed
1115
- - :pushpin: The `ForbiddenNames` sniff will now also check interface declarations for usage of reserved keywords. [#200](https://github.com/PHPCompatibility/PHPCompatibility/pull/200)
1116
- - :pushpin: `PregReplaceEModifier` sniff: improved handling of regexes build up of a combination of variables, function calls and/or text strings. [#201](https://github.com/PHPCompatibility/PHPCompatibility/pull/201)
1117
- - :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/PHPCompatibility/PHPCompatibility/pull/189)
1118
- - :pencil2: `PregReplaceEModifier` sniff: minor improvement to the error message text. [#201](https://github.com/PHPCompatibility/PHPCompatibility/pull/201)
1119
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#170](https://github.com/PHPCompatibility/PHPCompatibility/pull/170), [#188](https://github.com/PHPCompatibility/PHPCompatibility/pull/188), [#189](https://github.com/PHPCompatibility/PHPCompatibility/pull/189), [#199](https://github.com/PHPCompatibility/PHPCompatibility/pull/199), [#200](https://github.com/PHPCompatibility/PHPCompatibility/pull/200), [#201](https://github.com/PHPCompatibility/PHPCompatibility/pull/201), [#208](https://github.com/PHPCompatibility/PHPCompatibility/pull/208)
1120
- - :wrench: The unit tests for the utility methods have been moved to their own subdirectory within `Tests`. [#215](https://github.com/PHPCompatibility/PHPCompatibility/pull/215)
1121
- - :green_heart: The sniffs are now also tested against PHP 7.1 for consistent results. [#216](https://github.com/PHPCompatibility/PHPCompatibility/pull/216)
1122
-
1123
- ### Removed
1124
- - :no_entry_sign: Some redundant code. [26d0b6](https://github.com/PHPCompatibility/PHPCompatibility/commit/26d0b6cf0921f75d93a4faaf09c390f386dde9ff) and [841616](https://github.com/PHPCompatibility/PHPCompatibility/commit/8416162ea81f4067226324f5948f4a50f7958a9b)
1125
-
1126
- ### Fixed
1127
- - :bug: `ConstantArraysUsingDefine` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#199](https://github.com/PHPCompatibility/PHPCompatibility/pull/199)
1128
- - :bug: The `DeprecatedIniDirectives` and `NewIniDirectives` sniffs could potentially trigger on the ini value instead of the ini directive name. [#170](https://github.com/PHPCompatibility/PHPCompatibility/pull/170)
1129
- - :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/PHPCompatibility/PHPCompatibility/pull/200)
1130
- - :bug: `PregReplaceEModifier` sniff would not report errors when the function name used was not in lowercase. [#201](https://github.com/PHPCompatibility/PHPCompatibility/pull/201)
1131
- - :bug: `TernaryOperators` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#188](https://github.com/PHPCompatibility/PHPCompatibility/pull/188)
1132
- - :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/PHPCompatibility/PHPCompatibility/pull/206). Fixes [#205](https://github.com/PHPCompatibility/PHPCompatibility/issues/205).
1133
- - :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/PHPCompatibility/PHPCompatibility/pull/213). Fixes [#211](https://github.com/PHPCompatibility/PHPCompatibility/issues/211).
1134
- - :umbrella: Unit tests for the `NewFunctionArrayDereferencing` sniff were not being run due to a naming error. [#208](https://github.com/PHPCompatibility/PHPCompatibility/pull/208)
1135
- - :books: Readme: Information about setting the `testVersion` from a custom ruleset was incorrect. [#204](https://github.com/PHPCompatibility/PHPCompatibility/pull/204)
1136
- - :wrench: Path to PHPCS in the unit tests breaking for non-Composer installs. [#198](https://github.com/PHPCompatibility/PHPCompatibility/pull/198)
1137
-
1138
- ### Credits
1139
- Thanks go out to [Juliette Reinders Folmer] and [Yoshiaki Yoshida] for their contributions to this version. :clap:
1140
-
1141
-
1142
- ## [7.0.4] - 2016-08-20
1143
-
1144
- See all related issues and PRs in the [7.0.4 milestone].
1145
-
1146
- ### Added
1147
- - :star2: New `EmptyNonVariable` sniff: detection of empty being used on non-variables for PHP < 5.5. [#187](https://github.com/PHPCompatibility/PHPCompatibility/pull/187)
1148
- - :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/PHPCompatibility/PHPCompatibility/pull/176). Fixes [#64](https://github.com/PHPCompatibility/PHPCompatibility/issues/64).
1149
- - :star2: New `RemovedAlternativePHPTags` sniff: detection of ASP and script open tags for which support was removed in PHP 7.0. [#184](https://github.com/PHPCompatibility/PHPCompatibility/pull/184), [#193](https://github.com/PHPCompatibility/PHPCompatibility/pull/193). Fixes [#127](https://github.com/PHPCompatibility/PHPCompatibility/issues/127).
1150
- - :star: `NonStaticMagicMethods` sniff: detection of the `__callStatic()`, `__sleep()`, `__toString()` and `__set_state()` magic methods.
1151
- - :green_heart: Lint all non-test case files for syntax errors during the build testing by Travis. [#192](https://github.com/PHPCompatibility/PHPCompatibility/pull/192)
1152
-
1153
- ### Changed
1154
- - :pushpin: `NonStaticMagicMethods` sniff: will now also sniff `trait`s for magic methods. [#174](https://github.com/PHPCompatibility/PHPCompatibility/pull/174)
1155
- - :pushpin: `NonStaticMagicMethods` sniff: will now also check for magic methods which should be declared as `static`. [#174](https://github.com/PHPCompatibility/PHPCompatibility/pull/174)
1156
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#178](https://github.com/PHPCompatibility/PHPCompatibility/pull/178), [#179](https://github.com/PHPCompatibility/PHPCompatibility/pull/179), [#174](https://github.com/PHPCompatibility/PHPCompatibility/pull/174), [#171](https://github.com/PHPCompatibility/PHPCompatibility/pull/171)
1157
- - :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/PHPCompatibility/PHPCompatibility/pull/148)
1158
- - :books: Readme: Minor clarification of the minimum requirements.
1159
- - :books: Readme: Advise to use the latest stable version of this repository.
1160
- - :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/PHPCompatibility/PHPCompatibility/pull/191).
1161
- - :wrench: Improved coveralls configuration and compatibility. [#194](https://github.com/PHPCompatibility/PHPCompatibility/pull/194)
1162
- - :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/PHPCompatibility/PHPCompatibility/pull/196)
1163
-
1164
- ### Fixed
1165
- - :bug: The `ForbiddenBreakContinueVariableArguments` sniff would not report on `break`/`continue` with a closure as an argument. [#171](https://github.com/PHPCompatibility/PHPCompatibility/pull/171)
1166
- - :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would not report on reserved keywords which were not lowercase. [#186](https://github.com/PHPCompatibility/PHPCompatibility/pull/186)
1167
- - :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would not report on the `goto` and `namespace` keywords when run on PHP 5.2. [#193](https://github.com/PHPCompatibility/PHPCompatibility/pull/193)
1168
- - :bug: `NewAnonymousClasses` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#195](https://github.com/PHPCompatibility/PHPCompatibility/pull/195).
1169
- - :bug: `NewGroupUseDeclarations` sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. [#190](https://github.com/PHPCompatibility/PHPCompatibility/pull/190).
1170
- - :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/PHPCompatibility/PHPCompatibility/pull/174)
1171
- - :wrench: The unit tests would exit with `0` if PHPCS could not be found. [#191](https://github.com/PHPCompatibility/PHPCompatibility/pull/191)
1172
- - :green_heart: The PHPCompatibility library itself was not fully compatible with PHP 5.2. [#193](https://github.com/PHPCompatibility/PHPCompatibility/pull/193)
1173
-
1174
- ### Credits
1175
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
1176
-
1177
-
1178
- ## [7.0.3] - 2016-08-18
1179
-
1180
- See all related issues and PRs in the [7.0.3 milestone].
1181
-
1182
- ### Added
1183
- - :star2: New `InternalInterfaces` sniff: detection of internal PHP interfaces being which should not be implemented by user land classes. [#144](https://github.com/PHPCompatibility/PHPCompatibility/pull/144)
1184
- - :star2: New `LateStaticBinding` sniff: detection of PHP 5.3 late static binding. [#177](https://github.com/PHPCompatibility/PHPCompatibility/pull/177)
1185
- - :star2: New `NewExecutionDirectives` sniff: verify execution directives set with `declare()`. [#169](https://github.com/PHPCompatibility/PHPCompatibility/pull/169)
1186
- - :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/PHPCompatibility/PHPCompatibility/pull/144)
1187
- - :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/PHPCompatibility/PHPCompatibility/pull/165)
1188
- - :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/PHPCompatibility/PHPCompatibility/pull/160). Fixes [#55](https://github.com/PHPCompatibility/PHPCompatibility/issues/55).
1189
- - :star: `DeprecatedExtensions` sniff: detect removal of the `ereg` extension in PHP 7. [#149](https://github.com/PHPCompatibility/PHPCompatibility/pull/149)
1190
- - :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/PHPCompatibility/PHPCompatibility/pull/155).
1191
- - :star: `DeprecatedFunctions` sniff: detect deprecation of a number of the `mysqli` functions in PHP 5.3. [#149](https://github.com/PHPCompatibility/PHPCompatibility/pull/149)
1192
- - :star: `DeprecatedFunctions` sniff: detect removal of the `call_user_method()`, `ldap_sort()`, `ereg_*()` and `mysql_*()` functions in PHP 7.0. [#149](https://github.com/PHPCompatibility/PHPCompatibility/pull/149)
1193
- - :star: `DeprecatedIniDirectives` sniff: detection of a _lot_ more deprecated/removed ini directives. [#146](https://github.com/PHPCompatibility/PHPCompatibility/pull/146)
1194
- - :star: `NewFunctionParameters` sniff: detection of a _lot_ more new function parameters. [#164](https://github.com/PHPCompatibility/PHPCompatibility/pull/164)
1195
- - :star: `NewFunctions` sniff: detection of numerous extra new functions. [#161](https://github.com/PHPCompatibility/PHPCompatibility/pull/161)
1196
- - :star: `NewIniDirectives` sniff: detection of a _lot_ more new ini directives. [#146](https://github.com/PHPCompatibility/PHPCompatibility/pull/146)
1197
- - :star: `NewLanguageConstructs` sniff: detection of the PHP 5.6 ellipsis `...` construct. [#175](https://github.com/PHPCompatibility/PHPCompatibility/pull/175)
1198
- - :star: `NewScalarTypeDeclarations` sniff: detection of PHP 5.1 `array` and PHP 5.4 `callable` type hints. [#168](https://github.com/PHPCompatibility/PHPCompatibility/pull/168)
1199
- - :star: `RemovedFunctionParameters` sniff: detection of a few extra removed function parameters. [#163](https://github.com/PHPCompatibility/PHPCompatibility/pull/163)
1200
- - :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/PHPCompatibility/PHPCompatibility/pull/173)
1201
- - :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/PHPCompatibility/PHPCompatibility/pull/162)
1202
- - :recycle: New `inClassScope()` utility method in the `PHPCompatibility_Sniff` base class. [#168](https://github.com/PHPCompatibility/PHPCompatibility/pull/168)
1203
- - :recycle: New `doesFunctionCallHaveParameters()` and `getFunctionCallParameterCount()` utility methods in the `PHPCompatibility_Sniff` base class. [#153](https://github.com/PHPCompatibility/PHPCompatibility/pull/153)
1204
- - :umbrella: Unit test for `__halt_compiler()` detection by the `NewKeywords` sniff.
1205
- - :umbrella: Unit tests for the `NewFunctions` sniff. [#161](https://github.com/PHPCompatibility/PHPCompatibility/pull/161)
1206
- - :umbrella: Unit tests for the `ParameterShadowSuperGlobals` sniff. [#180](https://github.com/PHPCompatibility/PHPCompatibility/pull/180)
1207
- - :wrench: Minimal config for Scrutinizer CI. [#145](https://github.com/PHPCompatibility/PHPCompatibility/pull/145).
1208
-
1209
- ### Changed
1210
- - :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/PHPCompatibility/PHPCompatibility/pull/146)
1211
- - :pushpin: The `NewClasses` sniff will now also report on new classes being extended by child classes. [#140](https://github.com/PHPCompatibility/PHPCompatibility/pull/140).
1212
- - :pushpin: The `NewClasses` sniff will now also report on static use of new classes. [#162](https://github.com/PHPCompatibility/PHPCompatibility/pull/162).
1213
- - :pushpin: The `NewScalarTypeDeclarations` sniff will now throw an error on use of type hints pre-PHP 5.0. [#168](https://github.com/PHPCompatibility/PHPCompatibility/pull/168)
1214
- - :pushpin: The `NewScalarTypeDeclarations` sniff will now verify type hints used against typical mistakes. [#168](https://github.com/PHPCompatibility/PHPCompatibility/pull/168)
1215
- - :pushpin: The `ParameterShadowSuperGlobals` sniff will now do a case-insensitive variable name compare. [#180](https://github.com/PHPCompatibility/PHPCompatibility/pull/180)
1216
- - :pushpin: The `RemovedFunctionParameters` sniff will now also report `warning`s on deprecation of function parameters. [#163](https://github.com/PHPCompatibility/PHPCompatibility/pull/163)
1217
- - :twisted_rightwards_arrows: The check for `JsonSerializable` has been moved from the `NewClasses` sniff to the `NewInterfaces` sniff. [#162](https://github.com/PHPCompatibility/PHPCompatibility/pull/162)
1218
- - :rewind: The `NewLanguageConstructs` sniff will now also recognize new language constructs when used in combination with PHPCS 1.5.x. [#175](https://github.com/PHPCompatibility/PHPCompatibility/pull/175)
1219
- - :pencil2: `NewFunctionParameters` sniff: use correct name for the new parameter for the `dirname()` function. [#164](https://github.com/PHPCompatibility/PHPCompatibility/pull/164)
1220
- - :pencil2: `NewScalarTypeDeclarations` sniff: minor change in the sniff error message text. [#168](https://github.com/PHPCompatibility/PHPCompatibility/pull/168)
1221
- - :pencil2: `RemovedFunctionParameters` sniff: minor change in the sniff error message text. [#163](https://github.com/PHPCompatibility/PHPCompatibility/pull/163)
1222
- - :pencil2: The `ParameterShadowSuperGlobals` sniff now extends the `PHPCompatibility_Sniff` class. [#180](https://github.com/PHPCompatibility/PHPCompatibility/pull/180)
1223
- - :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#181](https://github.com/PHPCompatibility/PHPCompatibility/pull/181), [#182](https://github.com/PHPCompatibility/PHPCompatibility/pull/182), [#166](https://github.com/PHPCompatibility/PHPCompatibility/pull/166), [#167](https://github.com/PHPCompatibility/PHPCompatibility/pull/167), [#172](https://github.com/PHPCompatibility/PHPCompatibility/pull/172), [#180](https://github.com/PHPCompatibility/PHPCompatibility/pull/180), [#146](https://github.com/PHPCompatibility/PHPCompatibility/pull/146), [#138](https://github.com/PHPCompatibility/PHPCompatibility/pull/138)
1224
- - :recycle: Various refactoring to remove code duplication in the unit tests and add proper test skip notifications where relevant. [#139](https://github.com/PHPCompatibility/PHPCompatibility/pull/139), [#149](https://github.com/PHPCompatibility/PHPCompatibility/pull/149)
1225
-
1226
- ### Fixed
1227
- - :bug: The `DeprecatedFunctions` sniff was reporting an incorrect deprecation/removal version number for a few functions. [#149](https://github.com/PHPCompatibility/PHPCompatibility/pull/149)
1228
- - :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/PHPCompatibility/PHPCompatibility/pull/146)
1229
- - :bug: The `DeprecatedPHP4StyleConstructors` sniff would cause false positives for methods with the same name as the class in namespaced classes. [#167](https://github.com/PHPCompatibility/PHPCompatibility/pull/167)
1230
- - :bug: The `ForbiddenEmptyListAssignment` sniff did not report errors when there were only comments or parentheses between the list parentheses. [#166](https://github.com/PHPCompatibility/PHPCompatibility/pull/166)
1231
- - :bug: The `ForbiddenEmptyListAssignment` sniff will no longer cause false positives during live coding. [#166](https://github.com/PHPCompatibility/PHPCompatibility/pull/166)
1232
- - :bug: The `NewClasses` sniff would potentially misidentify namespaced classes as PHP native classes. [#161](https://github.com/PHPCompatibility/PHPCompatibility/pull/162)
1233
- - :bug: The `NewFunctions` sniff would fail to identify called functions when the function call was not lowercase. [#161](https://github.com/PHPCompatibility/PHPCompatibility/pull/161)
1234
- - :bug: The `NewFunctions` sniff would potentially misidentify namespaced userland functions as new functions. [#161](https://github.com/PHPCompatibility/PHPCompatibility/pull/161)
1235
- - :bug: The `NewIniDirectives` sniff was reporting an incorrect introduction version number for a few ini directives. [#146](https://github.com/PHPCompatibility/PHPCompatibility/pull/146)
1236
- - :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/PHPCompatibility/PHPCompatibility/pull/147). Fixes [#129](https://github.com/PHPCompatibility/PHPCompatibility/issues/129).
1237
- - :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/PHPCompatibility/PHPCompatibility/pull/156)
1238
- - :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/PHPCompatibility/PHPCompatibility/pull/153) Fixes [#120](https://github.com/PHPCompatibility/PHPCompatibility/issues/120), [#151](https://github.com/PHPCompatibility/PHPCompatibility/issues/151), [#152](https://github.com/PHPCompatibility/PHPCompatibility/issues/152).
1239
- - :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/PHPCompatibility/PHPCompatibility/pull/138)
1240
- - :wrench: The unit tests would fail to run when used in combination with a PEAR install of PHPCS. [#157](https://github.com/PHPCompatibility/PHPCompatibility/pull/157).
1241
- - :green_heart: Unit tests failing against PHPCS 2.6.1. [#158](https://github.com/PHPCompatibility/PHPCompatibility/pull/158)
1242
- 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.
1243
-
1244
- ### Credits
1245
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
1246
-
1247
-
1248
- ## [7.0.2] - 2016-08-03
1249
-
1250
- See all related issues and PRs in the [7.0.2 milestone].
1251
-
1252
- ### Added
1253
- - :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/PHPCompatibility/PHPCompatibility/pull/130). Fixes [#123](https://github.com/PHPCompatibility/PHPCompatibility/issues/123).
1254
- To use this feature, add the `functionWhitelist` property in your custom ruleset. For more information, see the [README](https://github.com/PHPCompatibility/PHPCompatibility#phpcompatibility-specific-options).
1255
-
1256
- ### Changed
1257
- - :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/PHPCompatibility/PHPCompatibility/pull/135)
1258
- - :wrench: Composer config: Stable packages are preferred over unstable/dev.
1259
- - :pencil2: Ruleset name. [#134](https://github.com/PHPCompatibility/PHPCompatibility/pull/134)
1260
-
1261
- ### Credits
1262
- Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
1263
-
1264
-
1265
- ## [7.0.1] - 2016-08-02
1266
-
1267
- See all related issues and PRs in the [7.0.1 milestone].
1268
-
1269
- ### Changed
1270
- - :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/PHPCompatibility/PHPCompatibility/pull/122) Fixes [#119](https://github.com/PHPCompatibility/PHPCompatibility/issues/119).
1271
- Usage of deprecated ini directives in combination with `ini_set()` will still throw an `error`.
1272
- - :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/PHPCompatibility/PHPCompatibility/pull/128)
1273
- - :pencil2: The `RemovedExtensions` sniff contained superfluous deprecation information in the error message. [#131](https://github.com/PHPCompatibility/PHPCompatibility/pull/131)
1274
-
1275
- ### Removed
1276
- - :wrench: Duplicate builds from the Travis CI build matrix. [#132](https://github.com/PHPCompatibility/PHPCompatibility/pull/132)
1277
-
1278
- ### Fixed
1279
- - :bug: The `ForbiddenNames` sniff did not allow for the PHP 5.6 `use function ...` and `use const ...` syntax. [#126](https://github.com/PHPCompatibility/PHPCompatibility/pull/126) Fixes [#124](https://github.com/PHPCompatibility/PHPCompatibility/issues/124).
1280
- - :bug: The `NewClasses` sniff failed to detect new classes when the class was instantiated without parenthesis, i.e. `new NewClass;`. [#121](https://github.com/PHPCompatibility/PHPCompatibility/pull/121)
1281
- - :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/PHPCompatibility/PHPCompatibility/pull/128)
1282
- - :green_heart: Unit tests failing against PHPCS 2.6.1.
1283
-
1284
- ### Credits
1285
- Thanks go out to [Jason Stallings], [Juliette Reinders Folmer] and [Ryan Neufeld] for their contributions to this version. :clap:
1286
-
1287
-
1288
- ## [7.0] - 2016-07-02
1289
-
1290
- See all related issues and PRs in the [7.0 milestone].
1291
-
1292
- ### Added
1293
- - :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/PHPCompatibility/PHPCompatibility/pull/99)
1294
- - :star2: New `NewFunctionArrayDereferencing` sniff to detect function array dereferencing as introduced in PHP 5.4. Fixes [#52](https://github.com/PHPCompatibility/PHPCompatibility/issues/52).
1295
- - :star2: New `ShortArray` sniff to detect short array syntax as introduced in PHP 5.4. [#97](https://github.com/PHPCompatibility/PHPCompatibility/pull/97). Fixes [#47](https://github.com/PHPCompatibility/PHPCompatibility/issues/47).
1296
- - :star2: New `TernaryOperators` sniff to detect ternaries without the middle part (`elvis` operator) as introduced in PHP 5.3. [#101](https://github.com/PHPCompatibility/PHPCompatibility/pull/101), [#103](https://github.com/PHPCompatibility/PHPCompatibility/pull/103). Fixes [#49](https://github.com/PHPCompatibility/PHPCompatibility/issues/49).
1297
- - :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/PHPCompatibility/PHPCompatibility/pull/110)
1298
- - :star2: New `DeprecatedPHP4StyleConstructors` sniff to detect PHP 4 style class constructor methods which are deprecated as of PHP 7. [#109](https://github.com/PHPCompatibility/PHPCompatibility/pull/109).
1299
- - :star2: New `ForbiddenEmptyListAssignment` sniff to detect empty list() assignments which have been removed in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1300
- - :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/PHPCompatibility/PHPCompatibility/pull/110)
1301
- - :star2: New `ForbiddenGlobalVariableVariable` sniff to detect variable variables being made `global` which is not allowed since PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1302
- - :star2: New `ForbiddenNegativeBitshift` sniff to detect bitwise shifts by negative number which will throw an ArithmeticError in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1303
- - :star2: New `ForbiddenSwitchWithMultipleDefaultBlocks` sniff to detect switch statements with multiple default blocks which is not allowed since PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1304
- - :star2: New `NewAnonymousClasses` sniff to detect anonymous classes as introduced in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1305
- - :star2: New `NewClosure` sniff to detect anonymous functions as introduced in PHP 5.3. Fixes [#35](https://github.com/PHPCompatibility/PHPCompatibility/issues/35)
1306
- - :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/PHPCompatibility/PHPCompatibility/pull/110), [#112](https://github.com/PHPCompatibility/PHPCompatibility/pull/112). Fixes [#27](https://github.com/PHPCompatibility/PHPCompatibility/issues/27).
1307
- - :star2: New `NewGroupUseDeclarations` sniff to detect group use declarations as introduced in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1308
- - :star2: New `NewScalarReturnTypeDeclarations` sniff to detect scalar return type hints as introduced in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1309
- - :star2: New `NewScalarTypeDeclarations` sniff to detect scalar function parameter type hints as introduced in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1310
- - :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/PHPCompatibility/PHPCompatibility/pull/110)
1311
- - :star2: New `RemovedGlobalVariables` sniff to detect the PHP 7.0 removed `$HTTP_RAW_POST_DATA` superglobal. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1312
- - :star: `DeprecatedFunctions` sniff: detection of the PHP 5.4 deprecated OCI8 functions. [#93](https://github.com/PHPCompatibility/PHPCompatibility/pull/93)
1313
- - :star: `ForbiddenNamesAsInvokedFunctions` sniff: recognize PHP 5.5 `finally` as a reserved keywords when invoked as a function. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1314
- - :star: `NewKeywords` sniff: detection of the use of the PHP 5.1+ `__halt_compiler` keyword. Fixes [#50](https://github.com/PHPCompatibility/PHPCompatibility/issues/50).
1315
- - :star: `NewKeywords` sniff: detection of the PHP 5.3+ `nowdoc` syntax. Fixes [#48](https://github.com/PHPCompatibility/PHPCompatibility/issues/48).
1316
- - :star: `NewKeywords` sniff: detection of the use of the `const` keyword outside of a class for PHP < 5.3. Fixes [#50](https://github.com/PHPCompatibility/PHPCompatibility/issues/50).
1317
- - :star: `DeprecatedFunctions` sniff: recognize PHP 7.0 deprecated and removed functions. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1318
- - :star: `DeprecatedIniDirectives` sniff: recognize PHP 7.0 removed ini directives. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1319
- - :star: `ForbiddenNamesAsInvokedFunctions` sniff: recognize new PHP 7.0 reserved keywords when invoked as functions. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1320
- - :star: `ForbiddenNames` sniff: recognize new PHP 7.0 reserved keywords. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1321
- - :star: `NewFunctions` sniff: recognize new functions as introduced in PHP 7.0. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1322
- - :star: `NewLanguageConstructs` sniff: recognize new PHP 7.0 `<=>` "spaceship" and `??` null coalescing operators. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1323
- - :star: `RemovedExtensions` sniff: recognize PHP 7.0 removed `ereg`, `mssql`, `mysql` and `sybase_ct` extensions. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1324
- - :umbrella: Additional unit tests for the `NewLanguageConstructs` sniff. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1325
- - :books: Readme: New section containing information about the use of the `testVersion` config variable.
1326
- - :books: Readme: Sponsor credits.
1327
-
1328
- ### Changed
1329
- - :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/PHPCompatibility/PHPCompatibility/pull/110).
1330
- - :pushpin: The `DeprecatedNewReference` sniff will now throw an error when the `testVersion` includes PHP 7.0 or higher. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1331
- - :pushpin: The `ForbiddenNames` sniff now supports detection of reserved keywords when used in combination with PHP 7 anonymous classes. [#108](https://github.com/PHPCompatibility/PHPCompatibility/pull/108), [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110).
1332
- - :pushpin: The `PregReplaceEModifier` sniff will now throw an error when the `testVersion` includes PHP 7.0 or higher. [#110](https://github.com/PHPCompatibility/PHPCompatibility/pull/110)
1333
- - :pencil2: `NewKeywords` sniff: clarified the error message text for the `use` keyword. Fixes [#46](https://github.com/PHPCompatibility/PHPCompatibility/issues/46).
1334
- - :recycle: Minor refactor of the `testVersion` related utility functions. [#98](https://github.com/PHPCompatibility/PHPCompatibility/pull/98)
1335
- - :wrench: Add autoload to the `composer.json` file. [#96](https://github.com/PHPCompatibility/PHPCompatibility/pull/96) Fixes [#67](https://github.com/PHPCompatibility/PHPCompatibility/issues/67).
1336
- - :wrench: Minor other updates to the `composer.json` file. [#75](https://github.com/PHPCompatibility/PHPCompatibility/pull/75)
1337
- - :wrench: Improved creation of the code coverage reports needed by coveralls via Travis.
1338
- - :green_heart: The sniffs are now also tested against PHP 7.0 for consistent results.
1339
-
1340
- ### Fixed
1341
- - :bug: The `ForbiddenCallTimePassByReference` sniff was throwing `Undefined index` notices when used in combination with PHPCS 2.2.0. [#100](https://github.com/PHPCompatibility/PHPCompatibility/pull/100). Fixes [#42](https://github.com/PHPCompatibility/PHPCompatibility/issues/42).
1342
- - :bug: The `ForbiddenNamesAsInvokedFunctions` sniff would incorrectly throw an error if the `throw` keyword was used with parenthesis. Fixes [#118](https://github.com/PHPCompatibility/PHPCompatibility/issues/118).
1343
- - :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/PHPCompatibility/PHPCompatibility/pull/94)
1344
- - :bug: The `RemovedExtensions` sniff was throwing an `error` instead of a `warning` for deprecated, but not (yet) removed extensions. Fixes [#62](https://github.com/PHPCompatibility/PHPCompatibility/issues/62).
1345
-
1346
- ### Credits
1347
- 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:
1348
-
1349
-
1350
- ## [5.6] - 2015-09-14
1351
-
1352
- See all related issues and PRs in the [5.6 milestone].
1353
-
1354
- ### Added
1355
- - :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/PHPCompatibility/PHPCompatibility/pull/87). Fixes [#60](https://github.com/PHPCompatibility/PHPCompatibility/issues/60).
1356
- - :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/PHPCompatibility/PHPCompatibility/pull/74)
1357
- - :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/PHPCompatibility/PHPCompatibility/pull/81), [#84](https://github.com/PHPCompatibility/PHPCompatibility/pull/84). Fixes [#71](https://github.com/PHPCompatibility/PHPCompatibility/issues/71), [#83](https://github.com/PHPCompatibility/PHPCompatibility/issues/83).
1358
- - :star: `DeprecatedIniDirectives` sniff: PHP 5.6 deprecated ini directives.
1359
- - :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/PHPCompatibility/PHPCompatibility/pull/57)
1360
- - :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/PHPCompatibility/PHPCompatibility/pull/77)
1361
- - :books: Readme: Composer installation instructions. [#32](https://github.com/PHPCompatibility/PHPCompatibility/pull/32), [#61](https://github.com/PHPCompatibility/PHPCompatibility/pull/61)
1362
- - :wrench: `.gitignore` to ignore vendor and IDE related directories. [#78](https://github.com/PHPCompatibility/PHPCompatibility/pull/78)
1363
- - :green_heart: Code coverage checking via coveralls.
1364
-
1365
- ### Changed
1366
- - :twisted_rightwards_arrows: The check for the `\` namespace separator has been moved from the `NewKeywords` sniff to the `NewLanguageConstructs` sniff. [#88](https://github.com/PHPCompatibility/PHPCompatibility/pull/88)
1367
- - :pencil2: `DeprecatedIniDirectives` sniff: minor change in the sniff error message text.
1368
- - :pencil2: `DeprecatedFunctions` sniff: minor change in the sniff error message text.
1369
- - :wrench: Minor updates to the `composer.json` file. [#31](https://github.com/PHPCompatibility/PHPCompatibility/pull/31), [34](https://github.com/PHPCompatibility/PHPCompatibility/pull/34), [#70](https://github.com/PHPCompatibility/PHPCompatibility/pull/70)
1370
- - :wrench: Tests: The unit tests can now be run without configuration.
1371
- - :wrench: Tests: Skipped unit tests will now be annotated as such. [#85](https://github.com/PHPCompatibility/PHPCompatibility/pull/85)
1372
- - :green_heart: The sniffs are now also tested against PHP 5.6 for consistent results.
1373
- - :green_heart: The sniffs are now also tested against PHPCS 2.0+.
1374
- - :green_heart: The sniffs are now tested using the new container-based infrastructure in Travis CI. [#37](https://github.com/PHPCompatibility/PHPCompatibility/pull/37)
1375
-
1376
- ### Fixed
1377
- - :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/PHPCompatibility/PHPCompatibility/pull/44). Fixes [#39](https://github.com/PHPCompatibility/PHPCompatibility/issues/39).
1378
- - :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/PHPCompatibility/PHPCompatibility/pull/29)
1379
- - :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/PHPCompatibility/PHPCompatibility/pull/80)
1380
- - :white_check_mark: Compatibility with PHPCS 2.0 - 2.3. [#63](https://github.com/PHPCompatibility/PHPCompatibility/pull/63), [#65](https://github.com/PHPCompatibility/PHPCompatibility/pull/65)
1381
-
1382
- ### Credits
1383
- 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:
1384
-
1385
-
1386
- ## 5.5 - 2014-04-04
1387
-
1388
- First tagged release.
1389
-
1390
- See all related issues and PRs in the [5.5 milestone].
1391
-
1392
-
1393
-
1394
- [Unreleased]: https://github.com/PHPCompatibility/PHPCompatibility/compare/master...HEAD
1395
- [9.3.5]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.3.4...9.3.5
1396
- [9.3.4]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.3.3...9.3.4
1397
- [9.3.3]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.3.2...9.3.3
1398
- [9.3.2]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.3.1...9.3.2
1399
- [9.3.1]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.3.0...9.3.1
1400
- [9.3.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.2.0...9.3.0
1401
- [9.2.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.1.1...9.2.0
1402
- [9.1.1]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.1.0...9.1.1
1403
- [9.1.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/9.0.0...9.1.0
1404
- [9.0.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/8.2.0...9.0.0
1405
- [8.2.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/8.1.0...8.2.0
1406
- [8.1.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/8.0.1...8.1.0
1407
- [8.0.1]: https://github.com/PHPCompatibility/PHPCompatibility/compare/8.0.0...8.0.1
1408
- [8.0.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.1.5...8.0.0
1409
- [7.1.5]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.1.4...7.1.5
1410
- [7.1.4]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.1.3...7.1.4
1411
- [7.1.3]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.1.2...7.1.3
1412
- [7.1.2]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.1.1...7.1.2
1413
- [7.1.1]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.1.0...7.1.1
1414
- [7.1.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.8...7.1.0
1415
- [7.0.8]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.7...7.0.8
1416
- [7.0.7]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.6...7.0.7
1417
- [7.0.6]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.5...7.0.6
1418
- [7.0.5]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.4...7.0.5
1419
- [7.0.4]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.3...7.0.4
1420
- [7.0.3]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.2...7.0.3
1421
- [7.0.2]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0.1...7.0.2
1422
- [7.0.1]: https://github.com/PHPCompatibility/PHPCompatibility/compare/7.0...7.0.1
1423
- [7.0]: https://github.com/PHPCompatibility/PHPCompatibility/compare/5.6...7.0
1424
- [5.6]: https://github.com/PHPCompatibility/PHPCompatibility/compare/5.5...5.6
1425
-
1426
- [9.3.5 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/34
1427
- [9.3.4 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/33
1428
- [9.3.3 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/32
1429
- [9.3.2 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/31
1430
- [9.3.1 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/30
1431
- [9.3.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/29
1432
- [9.2.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/28
1433
- [9.1.1 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/27
1434
- [9.1.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/25
1435
- [9.0.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/24
1436
- [8.2.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/22
1437
- [8.1.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/21
1438
- [8.0.1 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/20
1439
- [8.0.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/19
1440
- [7.1.5 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/17
1441
- [7.1.4 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/15
1442
- [7.1.3 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/14
1443
- [7.1.2 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/13
1444
- [7.1.1 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/12
1445
- [7.1.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/11
1446
- [7.0.8 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/10
1447
- [7.0.7 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/9
1448
- [7.0.6 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/8
1449
- [7.0.5 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/7
1450
- [7.0.4 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/6
1451
- [7.0.3 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/5
1452
- [7.0.2 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/4
1453
- [7.0.1 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/3
1454
- [7.0 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/2
1455
- [5.6 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/1
1456
- [5.5 milestone]: https://github.com/PHPCompatibility/PHPCompatibility/milestone/16
1457
-
1458
- [Arthur Edamov]: https://github.com/edamov
1459
- [Chris Abernethy]: https://github.com/cabernet-zerve
1460
- [Declan Kelly]: https://github.com/declank
1461
- [dgudgeon]: https://github.com/dgudgeon
1462
- [djaenecke]: https://github.com/djaenecke
1463
- [Dominic]: https://github.com/dol
1464
- [Eugene Maslovich]: https://github.com/ehpc
1465
- [Gary Jones]: https://github.com/GaryJones
1466
- [Jaap van Otterdijk]: https://github.com/jaapio
1467
- [Jason Stallings]: https://github.com/octalmage
1468
- [Jonathan Champ]: https://github.com/jrchamp
1469
- [Jonathan Van Belle]: https://github.com/Grummfy
1470
- [Juliette Reinders Folmer]: https://github.com/jrfnl
1471
- [Ken Guest]: https://github.com/kenguest
1472
- [Komarov Alexey]: https://github.com/erdraug
1473
- [Marin Crnkovic]: https://github.com/anorgan
1474
- [Mark Clements]: https://github.com/MarkMaldaba
1475
- [Michael Babker]: https://github.com/mbabker
1476
- [Nick Pack]: https://github.com/nickpack
1477
- [Nikhil]: https://github.com/Nikschavan
1478
- [Oliver Klee]: https://github.com/oliverklee
1479
- [Remko van Bezooijen]: https://github.com/emkookmer
1480
- [Rowan Collins]: https://github.com/IMSoP
1481
- [Ryan Neufeld]: https://github.com/ryanneufeld
1482
- [Sam Van der Borght]: https://github.com/samvdb
1483
- [Sergii Bondarenko]: https://github.com/BR0kEN-
1484
- [Tadas Juozapaitis]: https://github.com/kasp3r
1485
- [Tim Millwood]: https://github.com/timmillwood
1486
- [William Entriken]: https://github.com/fulldecent
1487
- [Yılmaz]: https://github.com/edigu
1488
- [Yoshiaki Yoshida]: https://github.com/kakakakakku
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/LICENSE DELETED
@@ -1,165 +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
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCSAliases.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
- /**
3
- * PHPCompatibility, an external standard for PHP_CodeSniffer.
4
- *
5
- * PHPCS cross-version compatibility helper.
6
- *
7
- * @package PHPCompatibility
8
- * @copyright 2012-2019 PHPCompatibility Contributors
9
- * @license https://opensource.org/licenses/LGPL-3.0 LGPL3
10
- * @link https://github.com/PHPCompatibility/PHPCompatibility
11
- *
12
- * @since 8.0.0
13
- */
14
-
15
- /*
16
- * Alias a number of PHPCS 3.x classes to their PHPCS 2.x equivalents.
17
- *
18
- * This file is auto-loaded by PHPCS 3.x before any sniffs are loaded
19
- * through the PHPCS 3.x `<autoload>` ruleset directive.
20
- *
21
- * {@internal The PHPCS file have been reorganized in PHPCS 3.x, quite
22
- * a few "old" classes have been split and spread out over several "new"
23
- * classes. In other words, this will only work for a limited number
24
- * of classes.}
25
- *
26
- * {@internal The `class_exists` wrappers are needed to play nice with other
27
- * external PHPCS standards creating cross-version compatibility in the same
28
- * manner.}
29
- */
30
- if (defined('PHPCOMPATIBILITY_PHPCS_ALIASES_SET') === false) {
31
- if (interface_exists('\PHP_CodeSniffer_Sniff') === false) {
32
- class_alias('PHP_CodeSniffer\Sniffs\Sniff', '\PHP_CodeSniffer_Sniff');
33
- }
34
- if (class_exists('\PHP_CodeSniffer_File') === false) {
35
- class_alias('PHP_CodeSniffer\Files\File', '\PHP_CodeSniffer_File');
36
- }
37
- if (class_exists('\PHP_CodeSniffer_Tokens') === false) {
38
- class_alias('PHP_CodeSniffer\Util\Tokens', '\PHP_CodeSniffer_Tokens');
39
- }
40
- if (class_exists('\PHP_CodeSniffer_Exception') === false) {
41
- class_alias('PHP_CodeSniffer\Exceptions\RuntimeException', '\PHP_CodeSniffer_Exception');
42
- }
43
- if (class_exists('\PHP_CodeSniffer_Standards_AbstractScopeSniff') === false) {
44
- class_alias('PHP_CodeSniffer\Sniffs\AbstractScopeSniff', '\PHP_CodeSniffer_Standards_AbstractScopeSniff');
45
- }
46
- if (class_exists('\Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff') === false) {
47
- class_alias('PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff', '\Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff');
48
- }
49
-
50
- define('PHPCOMPATIBILITY_PHPCS_ALIASES_SET', true);
51
-
52
- /*
53
- * Register an autoloader.
54
- *
55
- * {@internal When `installed_paths` is set via the ruleset, this autoloader
56
- * is needed to run the sniffs.
57
- * Upstream issue: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1591} }
58
- *
59
- * @since 8.0.0
60
- */
61
- spl_autoload_register(function ($class) {
62
- // Only try & load our own classes.
63
- if (stripos($class, 'PHPCompatibility') !== 0) {
64
- return;
65
- }
66
-
67
- $file = realpath(__DIR__) . DIRECTORY_SEPARATOR . strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
68
-
69
- if (file_exists($file)) {
70
- include_once $file;
71
- }
72
- });
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractComplexVersionSniff.php DELETED
@@ -1,147 +0,0 @@
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;
12
-
13
- use PHP_CodeSniffer_File as File;
14
-
15
- /**
16
- * Abstract base class for sniffs based on complex arrays with PHP version information.
17
- *
18
- * @since 7.1.0
19
- */
20
- abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface
21
- {
22
-
23
-
24
- /**
25
- * Handle the retrieval of relevant information and - if necessary - throwing of an
26
- * error/warning for an item.
27
- *
28
- * @since 7.1.0
29
- *
30
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
31
- * @param int $stackPtr The position of the relevant token in
32
- * the stack.
33
- * @param array $itemInfo Base information about the item.
34
- *
35
- * @return void
36
- */
37
- public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
38
- {
39
- $itemArray = $this->getItemArray($itemInfo);
40
- $errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
41
-
42
- if ($this->shouldThrowError($errorInfo) === true) {
43
- $this->addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
44
- }
45
- }
46
-
47
-
48
- /**
49
- * Determine whether an error/warning should be thrown for an item based on collected information.
50
- *
51
- * @since 7.1.0
52
- *
53
- * @param array $errorInfo Detail information about an item.
54
- *
55
- * @return bool
56
- */
57
- abstract protected function shouldThrowError(array $errorInfo);
58
-
59
-
60
- /**
61
- * Get an array of the non-PHP-version array keys used in a sub-array.
62
- *
63
- * @since 7.1.0
64
- *
65
- * @return array
66
- */
67
- protected function getNonVersionArrayKeys()
68
- {
69
- return array();
70
- }
71
-
72
-
73
- /**
74
- * Retrieve a subset of an item array containing only the array keys which
75
- * contain PHP version information.
76
- *
77
- * @since 7.1.0
78
- *
79
- * @param array $itemArray Version and other information about an item.
80
- *
81
- * @return array Array with only the version information.
82
- */
83
- protected function getVersionArray(array $itemArray)
84
- {
85
- return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys()));
86
- }
87
-
88
-
89
- /**
90
- * Get the item name to be used for the creation of the error code and in the error message.
91
- *
92
- * @since 7.1.0
93
- *
94
- * @param array $itemInfo Base information about the item.
95
- * @param array $errorInfo Detail information about an item.
96
- *
97
- * @return string
98
- */
99
- protected function getItemName(array $itemInfo, array $errorInfo)
100
- {
101
- return $itemInfo['name'];
102
- }
103
-
104
-
105
- /**
106
- * Get the error message template for a specific sniff.
107
- *
108
- * @since 7.1.0
109
- *
110
- * @return string
111
- */
112
- abstract protected function getErrorMsgTemplate();
113
-
114
-
115
- /**
116
- * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
117
- *
118
- * @since 7.1.0
119
- *
120
- * @param string $error The error message which was created.
121
- * @param array $itemInfo Base information about the item this error message applies to.
122
- * @param array $errorInfo Detail information about an item this error message applies to.
123
- *
124
- * @return string
125
- */
126
- protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
127
- {
128
- return $error;
129
- }
130
-
131
-
132
- /**
133
- * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
134
- *
135
- * @since 7.1.0
136
- *
137
- * @param array $data The error data array which was created.
138
- * @param array $itemInfo Base information about the item this error message applies to.
139
- * @param array $errorInfo Detail information about an item this error message applies to.
140
- *
141
- * @return array
142
- */
143
- protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
144
- {
145
- return $data;
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractFunctionCallParameterSniff.php DELETED
@@ -1,193 +0,0 @@
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;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Abstract class to use as a base for examining the parameter values passed to function calls.
19
- *
20
- * @since 8.2.0
21
- */
22
- abstract class AbstractFunctionCallParameterSniff extends Sniff
23
- {
24
- /**
25
- * Is the sniff looking for a function call or a method call ?
26
- *
27
- * Note: the child class may need to do additional checks to make sure that
28
- * the method called is of the right class/object.
29
- * Checking that is outside of the scope of this abstract sniff.
30
- *
31
- * @since 8.2.0
32
- *
33
- * @var bool False (default) if the sniff is looking for function calls.
34
- * True if the sniff is looking for method calls.
35
- */
36
- protected $isMethod = false;
37
-
38
- /**
39
- * Functions the sniff is looking for. Should be defined in the child class.
40
- *
41
- * @since 8.2.0
42
- *
43
- * @var array The only requirement for this array is that the top level
44
- * array keys are the names of the functions you're looking for.
45
- * Other than that, the array can have arbitrary content
46
- * depending on your needs.
47
- */
48
- protected $targetFunctions = array();
49
-
50
- /**
51
- * List of tokens which when they preceed the $stackPtr indicate that this
52
- * is not a function call.
53
- *
54
- * @since 8.2.0
55
- *
56
- * @var array
57
- */
58
- private $ignoreTokens = array(
59
- \T_DOUBLE_COLON => true,
60
- \T_OBJECT_OPERATOR => true,
61
- \T_FUNCTION => true,
62
- \T_NEW => true,
63
- \T_CONST => true,
64
- \T_USE => true,
65
- );
66
-
67
-
68
- /**
69
- * Returns an array of tokens this test wants to listen for.
70
- *
71
- * @since 8.2.0
72
- *
73
- * @return array
74
- */
75
- public function register()
76
- {
77
- // Handle case-insensitivity of function names.
78
- $this->targetFunctions = $this->arrayKeysToLowercase($this->targetFunctions);
79
-
80
- return array(\T_STRING);
81
- }
82
-
83
-
84
- /**
85
- * Processes this test, when one of its tokens is encountered.
86
- *
87
- * @since 8.2.0
88
- *
89
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
90
- * @param int $stackPtr The position of the current token in
91
- * the stack passed in $tokens.
92
- *
93
- * @return int|void Integer stack pointer to skip forward or void to continue
94
- * normal file processing.
95
- */
96
- public function process(File $phpcsFile, $stackPtr)
97
- {
98
- if ($this->bowOutEarly() === true) {
99
- return;
100
- }
101
-
102
- $tokens = $phpcsFile->getTokens();
103
- $function = $tokens[$stackPtr]['content'];
104
- $functionLc = strtolower($function);
105
-
106
- if (isset($this->targetFunctions[$functionLc]) === false) {
107
- return;
108
- }
109
-
110
- $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
111
-
112
- if ($this->isMethod === true) {
113
- if ($tokens[$prevNonEmpty]['code'] !== \T_DOUBLE_COLON
114
- && $tokens[$prevNonEmpty]['code'] !== \T_OBJECT_OPERATOR
115
- ) {
116
- // Not a call to a PHP method.
117
- return;
118
- }
119
- } else {
120
- if (isset($this->ignoreTokens[$tokens[$prevNonEmpty]['code']]) === true) {
121
- // Not a call to a PHP function.
122
- return;
123
- }
124
-
125
- if ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR
126
- && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING
127
- ) {
128
- // Namespaced function.
129
- return;
130
- }
131
- }
132
-
133
- $parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
134
-
135
- if (empty($parameters)) {
136
- return $this->processNoParameters($phpcsFile, $stackPtr, $function);
137
- } else {
138
- return $this->processParameters($phpcsFile, $stackPtr, $function, $parameters);
139
- }
140
- }
141
-
142
-
143
- /**
144
- * Do a version check to determine if this sniff needs to run at all.
145
- *
146
- * @since 8.2.0
147
- *
148
- * If the check done in a child class is not specific to one PHP version,
149
- * this function should return `false`.
150
- *
151
- * @return bool
152
- */
153
- abstract protected function bowOutEarly();
154
-
155
-
156
- /**
157
- * Process the parameters of a matched function.
158
- *
159
- * This method has to be made concrete in child classes.
160
- *
161
- * @since 8.2.0
162
- *
163
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
164
- * @param int $stackPtr The position of the current token in the stack.
165
- * @param string $functionName The token content (function name) which was matched.
166
- * @param array $parameters Array with information about the parameters.
167
- *
168
- * @return int|void Integer stack pointer to skip forward or void to continue
169
- * normal file processing.
170
- */
171
- abstract public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters);
172
-
173
-
174
- /**
175
- * Process the function if no parameters were found.
176
- *
177
- * Defaults to doing nothing. Can be overloaded in child classes to handle functions
178
- * were parameters are expected, but none found.
179
- *
180
- * @since 8.2.0
181
- *
182
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
183
- * @param int $stackPtr The position of the current token in the stack.
184
- * @param string $functionName The token content (function name) which was matched.
185
- *
186
- * @return int|void Integer stack pointer to skip forward or void to continue
187
- * normal file processing.
188
- */
189
- public function processNoParameters(File $phpcsFile, $stackPtr, $functionName)
190
- {
191
- return;
192
- }
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractNewFeatureSniff.php DELETED
@@ -1,115 +0,0 @@
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;
12
-
13
- use PHP_CodeSniffer_File as File;
14
-
15
- /**
16
- * Base class for new feature sniffs.
17
- *
18
- * @since 7.1.0
19
- */
20
- abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff
21
- {
22
-
23
-
24
- /**
25
- * Determine whether an error/warning should be thrown for an item based on collected information.
26
- *
27
- * @since 7.1.0
28
- *
29
- * @param array $errorInfo Detail information about an item.
30
- *
31
- * @return bool
32
- */
33
- protected function shouldThrowError(array $errorInfo)
34
- {
35
- return ($errorInfo['not_in_version'] !== '');
36
- }
37
-
38
-
39
- /**
40
- * Retrieve the relevant detail (version) information for use in an error message.
41
- *
42
- * @since 7.1.0
43
- *
44
- * @param array $itemArray Version and other information about the item.
45
- * @param array $itemInfo Base information about the item.
46
- *
47
- * @return array
48
- */
49
- public function getErrorInfo(array $itemArray, array $itemInfo)
50
- {
51
- $errorInfo = array(
52
- 'not_in_version' => '',
53
- 'error' => true,
54
- );
55
-
56
- $versionArray = $this->getVersionArray($itemArray);
57
-
58
- if (empty($versionArray) === false) {
59
- foreach ($versionArray as $version => $present) {
60
- if ($errorInfo['not_in_version'] === '' && $present === false
61
- && $this->supportsBelow($version) === true
62
- ) {
63
- $errorInfo['not_in_version'] = $version;
64
- }
65
- }
66
- }
67
-
68
- return $errorInfo;
69
- }
70
-
71
-
72
- /**
73
- * Get the error message template for this sniff.
74
- *
75
- * @since 7.1.0
76
- *
77
- * @return string
78
- */
79
- protected function getErrorMsgTemplate()
80
- {
81
- return '%s is not present in PHP version %s or earlier';
82
- }
83
-
84
-
85
- /**
86
- * Generates the error or warning for this item.
87
- *
88
- * @since 7.1.0
89
- *
90
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
91
- * @param int $stackPtr The position of the relevant token in
92
- * the stack.
93
- * @param array $itemInfo Base information about the item.
94
- * @param array $errorInfo Array with detail (version) information
95
- * relevant to the item.
96
- *
97
- * @return void
98
- */
99
- public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
100
- {
101
- $itemName = $this->getItemName($itemInfo, $errorInfo);
102
- $error = $this->getErrorMsgTemplate();
103
-
104
- $errorCode = $this->stringToErrorCode($itemName) . 'Found';
105
- $data = array(
106
- $itemName,
107
- $errorInfo['not_in_version'],
108
- );
109
-
110
- $error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
111
- $data = $this->filterErrorData($data, $itemInfo, $errorInfo);
112
-
113
- $this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractRemovedFeatureSniff.php DELETED
@@ -1,156 +0,0 @@
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;
12
-
13
- use PHP_CodeSniffer_File as File;
14
-
15
- /**
16
- * Base class for removed feature sniffs.
17
- *
18
- * @since 7.1.0
19
- */
20
- abstract class AbstractRemovedFeatureSniff extends AbstractComplexVersionSniff
21
- {
22
-
23
-
24
- /**
25
- * Determine whether an error/warning should be thrown for an item based on collected information.
26
- *
27
- * @since 7.1.0
28
- *
29
- * @param array $errorInfo Detail information about an item.
30
- *
31
- * @return bool
32
- */
33
- protected function shouldThrowError(array $errorInfo)
34
- {
35
- return ($errorInfo['deprecated'] !== '' || $errorInfo['removed'] !== '');
36
- }
37
-
38
-
39
- /**
40
- * Get an array of the non-PHP-version array keys used in a sub-array.
41
- *
42
- * By default, removed feature version arrays, contain an additional 'alternative' array key.
43
- *
44
- * @since 7.1.0
45
- *
46
- * @return array
47
- */
48
- protected function getNonVersionArrayKeys()
49
- {
50
- return array('alternative');
51
- }
52
-
53
-
54
- /**
55
- * Retrieve the relevant detail (version) information for use in an error message.
56
- *
57
- * @since 7.1.0
58
- *
59
- * @param array $itemArray Version and other information about the item.
60
- * @param array $itemInfo Base information about the item.
61
- *
62
- * @return array
63
- */
64
- public function getErrorInfo(array $itemArray, array $itemInfo)
65
- {
66
- $errorInfo = array(
67
- 'deprecated' => '',
68
- 'removed' => '',
69
- 'alternative' => '',
70
- 'error' => false,
71
- );
72
-
73
- $versionArray = $this->getVersionArray($itemArray);
74
-
75
- if (empty($versionArray) === false) {
76
- foreach ($versionArray as $version => $removed) {
77
- if ($this->supportsAbove($version) === true) {
78
- if ($removed === true && $errorInfo['removed'] === '') {
79
- $errorInfo['removed'] = $version;
80
- $errorInfo['error'] = true;
81
- } elseif ($errorInfo['deprecated'] === '') {
82
- $errorInfo['deprecated'] = $version;
83
- }
84
- }
85
- }
86
- }
87
-
88
- if (isset($itemArray['alternative']) === true) {
89
- $errorInfo['alternative'] = $itemArray['alternative'];
90
- }
91
-
92
- return $errorInfo;
93
- }
94
-
95
-
96
- /**
97
- * Get the error message template for suggesting an alternative for a specific sniff.
98
- *
99
- * @since 7.1.0
100
- *
101
- * @return string
102
- */
103
- protected function getAlternativeOptionTemplate()
104
- {
105
- return '; Use %s instead';
106
- }
107
-
108
-
109
- /**
110
- * Generates the error or warning for this item.
111
- *
112
- * @since 7.1.0
113
- *
114
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
115
- * @param int $stackPtr The position of the relevant token in
116
- * the stack.
117
- * @param array $itemInfo Base information about the item.
118
- * @param array $errorInfo Array with detail (version) information
119
- * relevant to the item.
120
- *
121
- * @return void
122
- */
123
- public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
124
- {
125
- $itemName = $this->getItemName($itemInfo, $errorInfo);
126
- $error = $this->getErrorMsgTemplate();
127
-
128
- $errorCode = $this->stringToErrorCode($itemName);
129
- $data = array($itemName);
130
-
131
- if ($errorInfo['deprecated'] !== '') {
132
- $error .= 'deprecated since PHP %s and ';
133
- $errorCode .= 'Deprecated';
134
- $data[] = $errorInfo['deprecated'];
135
- }
136
-
137
- if ($errorInfo['removed'] !== '') {
138
- $error .= 'removed since PHP %s and ';
139
- $errorCode .= 'Removed';
140
- $data[] = $errorInfo['removed'];
141
- }
142
-
143
- // Remove the last 'and' from the message.
144
- $error = substr($error, 0, (\strlen($error) - 5));
145
-
146
- if ($errorInfo['alternative'] !== '') {
147
- $error .= $this->getAlternativeOptionTemplate();
148
- $data[] = $errorInfo['alternative'];
149
- }
150
-
151
- $error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
152
- $data = $this->filterErrorData($data, $itemInfo, $errorInfo);
153
-
154
- $this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
155
- }
156
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/ComplexVersionInterface.php DELETED
@@ -1,84 +0,0 @@
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;
12
-
13
- use PHP_CodeSniffer_File as File;
14
-
15
- /**
16
- * Complex Version Interface.
17
- *
18
- * Interface to be implemented by sniffs using a multi-dimensional array of
19
- * PHP features (functions, classes etc) being sniffed for with version
20
- * information in sub-arrays.
21
- *
22
- * @since 7.1.0
23
- */
24
- interface ComplexVersionInterface
25
- {
26
-
27
-
28
- /**
29
- * Handle the retrieval of relevant information and - if necessary - throwing of an
30
- * error/warning for an item.
31
- *
32
- * @since 7.1.0
33
- *
34
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
35
- * @param int $stackPtr The position of the relevant token in
36
- * the stack.
37
- * @param array $itemInfo Base information about the item.
38
- *
39
- * @return void
40
- */
41
- public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo);
42
-
43
-
44
- /**
45
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
46
- *
47
- * @since 7.1.0
48
- *
49
- * @param array $itemInfo Base information about the item.
50
- *
51
- * @return array Version and other information about the item.
52
- */
53
- public function getItemArray(array $itemInfo);
54
-
55
-
56
- /**
57
- * Retrieve the relevant detail (version) information for use in an error message.
58
- *
59
- * @since 7.1.0
60
- *
61
- * @param array $itemArray Version and other information about the item.
62
- * @param array $itemInfo Base information about the item.
63
- *
64
- * @return array
65
- */
66
- public function getErrorInfo(array $itemArray, array $itemInfo);
67
-
68
-
69
- /**
70
- * Generates the error or warning for this item.
71
- *
72
- * @since 7.1.0
73
- *
74
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
75
- * @param int $stackPtr The position of the relevant token in
76
- * the stack.
77
- * @param array $itemInfo Base information about the item.
78
- * @param array $errorInfo Array with detail (version) information
79
- * relevant to the item.
80
- *
81
- * @return void
82
- */
83
- public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo);
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/PHPCSHelper.php DELETED
@@ -1,678 +0,0 @@
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;
12
-
13
- use PHP_CodeSniffer_Exception as PHPCS_Exception;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * PHPCS cross-version compatibility helper class.
19
- *
20
- * A number of PHPCS classes were split up into several classes in PHPCS 3.x
21
- * Those classes cannot be aliased as they don't represent the same object.
22
- * This class provides helper methods for functions which were contained in
23
- * one of these classes and which are used within the PHPCompatibility library.
24
- *
25
- * Additionally, this class contains some duplicates of PHPCS native methods.
26
- * These methods have received bug fixes or improved functionality between the
27
- * lowest supported PHPCS version and the latest PHPCS stable version and
28
- * to provide the same results cross-version, PHPCompatibility needs to use
29
- * the up-to-date versions of these methods.
30
- *
31
- * @since 8.0.0
32
- * @since 8.2.0 The duplicate PHPCS methods have been moved from the `Sniff`
33
- * base class to this class.
34
- */
35
- class PHPCSHelper
36
- {
37
-
38
- /**
39
- * Get the PHPCS version number.
40
- *
41
- * @since 8.0.0
42
- *
43
- * @return string
44
- */
45
- public static function getVersion()
46
- {
47
- if (\defined('\PHP_CodeSniffer\Config::VERSION')) {
48
- // PHPCS 3.x.
49
- return \PHP_CodeSniffer\Config::VERSION;
50
- } else {
51
- // PHPCS 2.x.
52
- return \PHP_CodeSniffer::VERSION;
53
- }
54
- }
55
-
56
-
57
- /**
58
- * Pass config data to PHPCS.
59
- *
60
- * PHPCS cross-version compatibility helper.
61
- *
62
- * @since 8.0.0
63
- *
64
- * @param string $key The name of the config value.
65
- * @param string|null $value The value to set. If null, the config entry
66
- * is deleted, reverting it to the default value.
67
- * @param boolean $temp Set this config data temporarily for this script run.
68
- * This will not write the config data to the config file.
69
- *
70
- * @return void
71
- */
72
- public static function setConfigData($key, $value, $temp = false)
73
- {
74
- if (method_exists('\PHP_CodeSniffer\Config', 'setConfigData')) {
75
- // PHPCS 3.x.
76
- \PHP_CodeSniffer\Config::setConfigData($key, $value, $temp);
77
- } else {
78
- // PHPCS 2.x.
79
- \PHP_CodeSniffer::setConfigData($key, $value, $temp);
80
- }
81
- }
82
-
83
-
84
- /**
85
- * Get the value of a single PHPCS config key.
86
- *
87
- * @since 8.0.0
88
- *
89
- * @param string $key The name of the config value.
90
- *
91
- * @return string|null
92
- */
93
- public static function getConfigData($key)
94
- {
95
- if (method_exists('\PHP_CodeSniffer\Config', 'getConfigData')) {
96
- // PHPCS 3.x.
97
- return \PHP_CodeSniffer\Config::getConfigData($key);
98
- } else {
99
- // PHPCS 2.x.
100
- return \PHP_CodeSniffer::getConfigData($key);
101
- }
102
- }
103
-
104
-
105
- /**
106
- * Get the value of a single PHPCS config key.
107
- *
108
- * This config key can be set in the `CodeSniffer.conf` file, on the
109
- * command-line or in a ruleset.
110
- *
111
- * @since 8.2.0
112
- *
113
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
114
- * @param string $key The name of the config value.
115
- *
116
- * @return string|null
117
- */
118
- public static function getCommandLineData(File $phpcsFile, $key)
119
- {
120
- if (class_exists('\PHP_CodeSniffer\Config')) {
121
- // PHPCS 3.x.
122
- $config = $phpcsFile->config;
123
- if (isset($config->{$key})) {
124
- return $config->{$key};
125
- }
126
- } else {
127
- // PHPCS 2.x.
128
- $config = $phpcsFile->phpcs->cli->getCommandLineValues();
129
- if (isset($config[$key])) {
130
- return $config[$key];
131
- }
132
- }
133
-
134
- return null;
135
- }
136
-
137
-
138
- /**
139
- * Returns the position of the first non-whitespace token in a statement.
140
- *
141
- * {@internal Duplicate of same method as contained in the `\PHP_CodeSniffer_File`
142
- * class and introduced in PHPCS 2.1.0 and improved in PHPCS 2.7.1.
143
- *
144
- * Once the minimum supported PHPCS version for this standard goes beyond
145
- * that, this method can be removed and calls to it replaced with
146
- * `$phpcsFile->findStartOfStatement($start, $ignore)` calls.
147
- *
148
- * Last synced with PHPCS version: PHPCS 3.3.2 at commit 6ad28354c04b364c3c71a34e4a18b629cc3b231e}
149
- *
150
- * @since 9.1.0
151
- *
152
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
153
- * @param int $start The position to start searching from in the token stack.
154
- * @param int|array $ignore Token types that should not be considered stop points.
155
- *
156
- * @return int
157
- */
158
- public static function findStartOfStatement(File $phpcsFile, $start, $ignore = null)
159
- {
160
- if (version_compare(self::getVersion(), '2.7.1', '>=') === true) {
161
- return $phpcsFile->findStartOfStatement($start, $ignore);
162
- }
163
-
164
- $tokens = $phpcsFile->getTokens();
165
- $endTokens = Tokens::$blockOpeners;
166
-
167
- $endTokens[\T_COLON] = true;
168
- $endTokens[\T_COMMA] = true;
169
- $endTokens[\T_DOUBLE_ARROW] = true;
170
- $endTokens[\T_SEMICOLON] = true;
171
- $endTokens[\T_OPEN_TAG] = true;
172
- $endTokens[\T_CLOSE_TAG] = true;
173
- $endTokens[\T_OPEN_SHORT_ARRAY] = true;
174
-
175
- if ($ignore !== null) {
176
- $ignore = (array) $ignore;
177
- foreach ($ignore as $code) {
178
- if (isset($endTokens[$code]) === true) {
179
- unset($endTokens[$code]);
180
- }
181
- }
182
- }
183
-
184
- $lastNotEmpty = $start;
185
-
186
- for ($i = $start; $i >= 0; $i--) {
187
- if (isset($endTokens[$tokens[$i]['code']]) === true) {
188
- // Found the end of the previous statement.
189
- return $lastNotEmpty;
190
- }
191
-
192
- if (isset($tokens[$i]['scope_opener']) === true
193
- && $i === $tokens[$i]['scope_closer']
194
- ) {
195
- // Found the end of the previous scope block.
196
- return $lastNotEmpty;
197
- }
198
-
199
- // Skip nested statements.
200
- if (isset($tokens[$i]['bracket_opener']) === true
201
- && $i === $tokens[$i]['bracket_closer']
202
- ) {
203
- $i = $tokens[$i]['bracket_opener'];
204
- } elseif (isset($tokens[$i]['parenthesis_opener']) === true
205
- && $i === $tokens[$i]['parenthesis_closer']
206
- ) {
207
- $i = $tokens[$i]['parenthesis_opener'];
208
- }
209
-
210
- if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
211
- $lastNotEmpty = $i;
212
- }
213
- }//end for
214
-
215
- return 0;
216
- }
217
-
218
-
219
- /**
220
- * Returns the position of the last non-whitespace token in a statement.
221
- *
222
- * {@internal Duplicate of same method as contained in the `\PHP_CodeSniffer_File`
223
- * class and introduced in PHPCS 2.1.0 and improved in PHPCS 2.7.1 and 3.3.0.
224
- *
225
- * Once the minimum supported PHPCS version for this standard goes beyond
226
- * that, this method can be removed and calls to it replaced with
227
- * `$phpcsFile->findEndOfStatement($start, $ignore)` calls.
228
- *
229
- * Last synced with PHPCS version: PHPCS 3.3.0-alpha at commit f5d899dcb5c534a1c3cca34668624517856ba823}
230
- *
231
- * @since 8.2.0
232
- *
233
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
234
- * @param int $start The position to start searching from in the token stack.
235
- * @param int|array $ignore Token types that should not be considered stop points.
236
- *
237
- * @return int
238
- */
239
- public static function findEndOfStatement(File $phpcsFile, $start, $ignore = null)
240
- {
241
- if (version_compare(self::getVersion(), '3.3.0', '>=') === true) {
242
- return $phpcsFile->findEndOfStatement($start, $ignore);
243
- }
244
-
245
- $tokens = $phpcsFile->getTokens();
246
- $endTokens = array(
247
- \T_COLON => true,
248
- \T_COMMA => true,
249
- \T_DOUBLE_ARROW => true,
250
- \T_SEMICOLON => true,
251
- \T_CLOSE_PARENTHESIS => true,
252
- \T_CLOSE_SQUARE_BRACKET => true,
253
- \T_CLOSE_CURLY_BRACKET => true,
254
- \T_CLOSE_SHORT_ARRAY => true,
255
- \T_OPEN_TAG => true,
256
- \T_CLOSE_TAG => true,
257
- );
258
-
259
- if ($ignore !== null) {
260
- $ignore = (array) $ignore;
261
- foreach ($ignore as $code) {
262
- if (isset($endTokens[$code]) === true) {
263
- unset($endTokens[$code]);
264
- }
265
- }
266
- }
267
-
268
- $lastNotEmpty = $start;
269
-
270
- for ($i = $start; $i < $phpcsFile->numTokens; $i++) {
271
- if ($i !== $start && isset($endTokens[$tokens[$i]['code']]) === true) {
272
- // Found the end of the statement.
273
- if ($tokens[$i]['code'] === \T_CLOSE_PARENTHESIS
274
- || $tokens[$i]['code'] === \T_CLOSE_SQUARE_BRACKET
275
- || $tokens[$i]['code'] === \T_CLOSE_CURLY_BRACKET
276
- || $tokens[$i]['code'] === \T_CLOSE_SHORT_ARRAY
277
- || $tokens[$i]['code'] === \T_OPEN_TAG
278
- || $tokens[$i]['code'] === \T_CLOSE_TAG
279
- ) {
280
- return $lastNotEmpty;
281
- }
282
-
283
- return $i;
284
- }
285
-
286
- // Skip nested statements.
287
- if (isset($tokens[$i]['scope_closer']) === true
288
- && ($i === $tokens[$i]['scope_opener']
289
- || $i === $tokens[$i]['scope_condition'])
290
- ) {
291
- if ($i === $start && isset(Tokens::$scopeOpeners[$tokens[$i]['code']]) === true) {
292
- return $tokens[$i]['scope_closer'];
293
- }
294
-
295
- $i = $tokens[$i]['scope_closer'];
296
- } elseif (isset($tokens[$i]['bracket_closer']) === true
297
- && $i === $tokens[$i]['bracket_opener']
298
- ) {
299
- $i = $tokens[$i]['bracket_closer'];
300
- } elseif (isset($tokens[$i]['parenthesis_closer']) === true
301
- && $i === $tokens[$i]['parenthesis_opener']
302
- ) {
303
- $i = $tokens[$i]['parenthesis_closer'];
304
- }
305
-
306
- if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
307
- $lastNotEmpty = $i;
308
- }
309
- }//end for
310
-
311
- return ($phpcsFile->numTokens - 1);
312
- }
313
-
314
-
315
- /**
316
- * Returns the name of the class that the specified class extends
317
- * (works for classes, anonymous classes and interfaces).
318
- *
319
- * Returns FALSE on error or if there is no extended class name.
320
- *
321
- * {@internal Duplicate of same method as contained in the `\PHP_CodeSniffer_File`
322
- * class, but with some improvements which have been introduced in
323
- * PHPCS 2.8.0.
324
- * {@link https://github.com/squizlabs/PHP_CodeSniffer/commit/0011d448119d4c568e3ac1f825ae78815bf2cc34}.
325
- *
326
- * Once the minimum supported PHPCS version for this standard goes beyond
327
- * that, this method can be removed and calls to it replaced with
328
- * `$phpcsFile->findExtendedClassName($stackPtr)` calls.
329
- *
330
- * Last synced with PHPCS version: PHPCS 3.1.0-alpha at commit a9efcc9b0703f3f9f4a900623d4e97128a6aafc6}
331
- *
332
- * @since 7.1.4
333
- * @since 8.2.0 Moved from the `Sniff` class to this class.
334
- *
335
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
336
- * @param int $stackPtr The position of the class token in the stack.
337
- *
338
- * @return string|false
339
- */
340
- public static function findExtendedClassName(File $phpcsFile, $stackPtr)
341
- {
342
- if (version_compare(self::getVersion(), '3.1.0', '>=') === true) {
343
- return $phpcsFile->findExtendedClassName($stackPtr);
344
- }
345
-
346
- $tokens = $phpcsFile->getTokens();
347
-
348
- // Check for the existence of the token.
349
- if (isset($tokens[$stackPtr]) === false) {
350
- return false;
351
- }
352
-
353
- if ($tokens[$stackPtr]['code'] !== \T_CLASS
354
- && $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS'
355
- && $tokens[$stackPtr]['type'] !== 'T_INTERFACE'
356
- ) {
357
- return false;
358
- }
359
-
360
- if (isset($tokens[$stackPtr]['scope_closer']) === false) {
361
- return false;
362
- }
363
-
364
- $classCloserIndex = $tokens[$stackPtr]['scope_closer'];
365
- $extendsIndex = $phpcsFile->findNext(\T_EXTENDS, $stackPtr, $classCloserIndex);
366
- if ($extendsIndex === false) {
367
- return false;
368
- }
369
-
370
- $find = array(
371
- \T_NS_SEPARATOR,
372
- \T_STRING,
373
- \T_WHITESPACE,
374
- );
375
-
376
- $end = $phpcsFile->findNext($find, ($extendsIndex + 1), $classCloserIndex, true);
377
- $name = $phpcsFile->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1));
378
- $name = trim($name);
379
-
380
- if ($name === '') {
381
- return false;
382
- }
383
-
384
- return $name;
385
- }
386
-
387
-
388
- /**
389
- * Returns the name(s) of the interface(s) that the specified class implements.
390
- *
391
- * Returns FALSE on error or if there are no implemented interface names.
392
- *
393
- * {@internal Duplicate of same method as introduced in PHPCS 2.7.
394
- * This method also includes an improvement we use which was only introduced
395
- * in PHPCS 2.8.0, so only defer to upstream for higher versions.
396
- * Once the minimum supported PHPCS version for this sniff library goes beyond
397
- * that, this method can be removed and calls to it replaced with
398
- * `$phpcsFile->findImplementedInterfaceNames($stackPtr)` calls.}
399
- *
400
- * @since 7.0.3
401
- * @since 8.2.0 Moved from the `Sniff` class to this class.
402
- *
403
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
404
- * @param int $stackPtr The position of the class token.
405
- *
406
- * @return array|false
407
- */
408
- public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr)
409
- {
410
- if (version_compare(self::getVersion(), '2.7.1', '>') === true) {
411
- return $phpcsFile->findImplementedInterfaceNames($stackPtr);
412
- }
413
-
414
- $tokens = $phpcsFile->getTokens();
415
-
416
- // Check for the existence of the token.
417
- if (isset($tokens[$stackPtr]) === false) {
418
- return false;
419
- }
420
-
421
- if ($tokens[$stackPtr]['code'] !== \T_CLASS
422
- && $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS'
423
- ) {
424
- return false;
425
- }
426
-
427
- if (isset($tokens[$stackPtr]['scope_closer']) === false) {
428
- return false;
429
- }
430
-
431
- $classOpenerIndex = $tokens[$stackPtr]['scope_opener'];
432
- $implementsIndex = $phpcsFile->findNext(\T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
433
- if ($implementsIndex === false) {
434
- return false;
435
- }
436
-
437
- $find = array(
438
- \T_NS_SEPARATOR,
439
- \T_STRING,
440
- \T_WHITESPACE,
441
- \T_COMMA,
442
- );
443
-
444
- $end = $phpcsFile->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true);
445
- $name = $phpcsFile->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1));
446
- $name = trim($name);
447
-
448
- if ($name === '') {
449
- return false;
450
- } else {
451
- $names = explode(',', $name);
452
- $names = array_map('trim', $names);
453
- return $names;
454
- }
455
- }
456
-
457
-
458
- /**
459
- * Returns the method parameters for the specified function token.
460
- *
461
- * Each parameter is in the following format:
462
- *
463
- * <code>
464
- * 0 => array(
465
- * 'name' => '$var', // The variable name.
466
- * 'token' => integer, // The stack pointer to the variable name.
467
- * 'content' => string, // The full content of the variable definition.
468
- * 'pass_by_reference' => boolean, // Is the variable passed by reference?
469
- * 'variable_length' => boolean, // Is the param of variable length through use of `...` ?
470
- * 'type_hint' => string, // The type hint for the variable.
471
- * 'type_hint_token' => integer, // The stack pointer to the type hint
472
- * // or false if there is no type hint.
473
- * 'nullable_type' => boolean, // Is the variable using a nullable type?
474
- * )
475
- * </code>
476
- *
477
- * Parameters with default values have an additional array index of
478
- * 'default' with the value of the default as a string.
479
- *
480
- * {@internal Duplicate of same method as contained in the `\PHP_CodeSniffer_File`
481
- * class.
482
- *
483
- * Last synced with PHPCS version: PHPCS 3.3.0-alpha at commit 53a28408d345044c0360c2c1b4a2aaebf4a3b8c9}
484
- *
485
- * @since 7.0.3
486
- * @since 8.2.0 Moved from the `Sniff` class to this class.
487
- *
488
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
489
- * @param int $stackPtr The position in the stack of the
490
- * function token to acquire the
491
- * parameters for.
492
- *
493
- * @return array|false
494
- * @throws \PHP_CodeSniffer_Exception If the specified $stackPtr is not of
495
- * type T_FUNCTION or T_CLOSURE.
496
- */
497
- public static function getMethodParameters(File $phpcsFile, $stackPtr)
498
- {
499
- if (version_compare(self::getVersion(), '3.3.0', '>=') === true) {
500
- return $phpcsFile->getMethodParameters($stackPtr);
501
- }
502
-
503
- $tokens = $phpcsFile->getTokens();
504
-
505
- // Check for the existence of the token.
506
- if (isset($tokens[$stackPtr]) === false) {
507
- return false;
508
- }
509
-
510
- if ($tokens[$stackPtr]['code'] !== \T_FUNCTION
511
- && $tokens[$stackPtr]['code'] !== \T_CLOSURE
512
- ) {
513
- throw new PHPCS_Exception('$stackPtr must be of type T_FUNCTION or T_CLOSURE');
514
- }
515
-
516
- $opener = $tokens[$stackPtr]['parenthesis_opener'];
517
- $closer = $tokens[$stackPtr]['parenthesis_closer'];
518
-
519
- $vars = array();
520
- $currVar = null;
521
- $paramStart = ($opener + 1);
522
- $defaultStart = null;
523
- $paramCount = 0;
524
- $passByReference = false;
525
- $variableLength = false;
526
- $typeHint = '';
527
- $typeHintToken = false;
528
- $nullableType = false;
529
-
530
- for ($i = $paramStart; $i <= $closer; $i++) {
531
- // Check to see if this token has a parenthesis or bracket opener. If it does
532
- // it's likely to be an array which might have arguments in it. This
533
- // could cause problems in our parsing below, so lets just skip to the
534
- // end of it.
535
- if (isset($tokens[$i]['parenthesis_opener']) === true) {
536
- // Don't do this if it's the close parenthesis for the method.
537
- if ($i !== $tokens[$i]['parenthesis_closer']) {
538
- $i = ($tokens[$i]['parenthesis_closer'] + 1);
539
- }
540
- }
541
-
542
- if (isset($tokens[$i]['bracket_opener']) === true) {
543
- // Don't do this if it's the close parenthesis for the method.
544
- if ($i !== $tokens[$i]['bracket_closer']) {
545
- $i = ($tokens[$i]['bracket_closer'] + 1);
546
- }
547
- }
548
-
549
- switch ($tokens[$i]['type']) {
550
- case 'T_BITWISE_AND':
551
- if ($defaultStart === null) {
552
- $passByReference = true;
553
- }
554
- break;
555
- case 'T_VARIABLE':
556
- $currVar = $i;
557
- break;
558
- case 'T_ELLIPSIS':
559
- $variableLength = true;
560
- break;
561
- case 'T_ARRAY_HINT': // Pre-PHPCS 3.3.0.
562
- case 'T_CALLABLE':
563
- if ($typeHintToken === false) {
564
- $typeHintToken = $i;
565
- }
566
-
567
- $typeHint .= $tokens[$i]['content'];
568
- break;
569
- case 'T_SELF':
570
- case 'T_PARENT':
571
- case 'T_STATIC':
572
- // Self and parent are valid, static invalid, but was probably intended as type hint.
573
- if (isset($defaultStart) === false) {
574
- if ($typeHintToken === false) {
575
- $typeHintToken = $i;
576
- }
577
-
578
- $typeHint .= $tokens[$i]['content'];
579
- }
580
- break;
581
- case 'T_STRING':
582
- // This is a string, so it may be a type hint, but it could
583
- // also be a constant used as a default value.
584
- $prevComma = false;
585
- for ($t = $i; $t >= $opener; $t--) {
586
- if ($tokens[$t]['code'] === \T_COMMA) {
587
- $prevComma = $t;
588
- break;
589
- }
590
- }
591
-
592
- if ($prevComma !== false) {
593
- $nextEquals = false;
594
- for ($t = $prevComma; $t < $i; $t++) {
595
- if ($tokens[$t]['code'] === \T_EQUAL) {
596
- $nextEquals = $t;
597
- break;
598
- }
599
- }
600
-
601
- if ($nextEquals !== false) {
602
- break;
603
- }
604
- }
605
-
606
- if ($defaultStart === null) {
607
- if ($typeHintToken === false) {
608
- $typeHintToken = $i;
609
- }
610
-
611
- $typeHint .= $tokens[$i]['content'];
612
- }
613
- break;
614
- case 'T_NS_SEPARATOR':
615
- // Part of a type hint or default value.
616
- if ($defaultStart === null) {
617
- if ($typeHintToken === false) {
618
- $typeHintToken = $i;
619
- }
620
-
621
- $typeHint .= $tokens[$i]['content'];
622
- }
623
- break;
624
- case 'T_NULLABLE':
625
- case 'T_INLINE_THEN': // Pre-PHPCS 2.8.0.
626
- if ($defaultStart === null) {
627
- $nullableType = true;
628
- $typeHint .= $tokens[$i]['content'];
629
- }
630
- break;
631
- case 'T_CLOSE_PARENTHESIS':
632
- case 'T_COMMA':
633
- // If it's null, then there must be no parameters for this
634
- // method.
635
- if ($currVar === null) {
636
- break;
637
- }
638
-
639
- $vars[$paramCount] = array();
640
- $vars[$paramCount]['token'] = $currVar;
641
- $vars[$paramCount]['name'] = $tokens[$currVar]['content'];
642
- $vars[$paramCount]['content'] = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart)));
643
-
644
- if ($defaultStart !== null) {
645
- $vars[$paramCount]['default'] = trim(
646
- $phpcsFile->getTokensAsString(
647
- $defaultStart,
648
- ($i - $defaultStart)
649
- )
650
- );
651
- }
652
-
653
- $vars[$paramCount]['pass_by_reference'] = $passByReference;
654
- $vars[$paramCount]['variable_length'] = $variableLength;
655
- $vars[$paramCount]['type_hint'] = $typeHint;
656
- $vars[$paramCount]['type_hint_token'] = $typeHintToken;
657
- $vars[$paramCount]['nullable_type'] = $nullableType;
658
-
659
- // Reset the vars, as we are about to process the next parameter.
660
- $defaultStart = null;
661
- $paramStart = ($i + 1);
662
- $passByReference = false;
663
- $variableLength = false;
664
- $typeHint = '';
665
- $typeHintToken = false;
666
- $nullableType = false;
667
-
668
- $paramCount++;
669
- break;
670
- case 'T_EQUAL':
671
- $defaultStart = ($i + 1);
672
- break;
673
- }//end switch
674
- }//end for
675
-
676
- return $vars;
677
- }
678
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniff.php DELETED
@@ -1,2267 +0,0 @@
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;
12
-
13
- use PHPCompatibility\PHPCSHelper;
14
- use PHP_CodeSniffer_Exception as PHPCS_Exception;
15
- use PHP_CodeSniffer_File as File;
16
- use PHP_CodeSniffer_Sniff as PHPCS_Sniff;
17
- use PHP_CodeSniffer_Tokens as Tokens;
18
-
19
- /**
20
- * Base class from which all PHPCompatibility sniffs extend.
21
- *
22
- * @since 5.6
23
- */
24
- abstract class Sniff implements PHPCS_Sniff
25
- {
26
-
27
- /**
28
- * Regex to match variables in a double quoted string.
29
- *
30
- * This matches plain variables, but also more complex variables, such
31
- * as $obj->prop, self::prop and $var[].
32
- *
33
- * @since 7.1.2
34
- *
35
- * @var string
36
- */
37
- const REGEX_COMPLEX_VARS = '`(?:(\{)?(?<!\\\\)\$)?(\{)?(?<!\\\\)\$(\{)?(?P<varname>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?:->\$?(?P>varname)|\[[^\]]+\]|::\$?(?P>varname)|\([^\)]*\))*(?(3)\}|)(?(2)\}|)(?(1)\}|)`';
38
-
39
- /**
40
- * List of superglobals as an array of strings.
41
- *
42
- * Used by the ForbiddenParameterShadowSuperGlobals and ForbiddenClosureUseVariableNames sniffs.
43
- *
44
- * @since 7.0.0
45
- * @since 7.1.4 Moved from the `ForbiddenParameterShadowSuperGlobals` sniff to the base `Sniff` class.
46
- *
47
- * @var array
48
- */
49
- protected $superglobals = array(
50
- '$GLOBALS' => true,
51
- '$_SERVER' => true,
52
- '$_GET' => true,
53
- '$_POST' => true,
54
- '$_FILES' => true,
55
- '$_COOKIE' => true,
56
- '$_SESSION' => true,
57
- '$_REQUEST' => true,
58
- '$_ENV' => true,
59
- );
60
-
61
- /**
62
- * List of functions using hash algorithm as parameter (always the first parameter).
63
- *
64
- * Used by the new/removed hash algorithm sniffs.
65
- * Key is the function name, value is the 1-based parameter position in the function call.
66
- *
67
- * @since 5.5
68
- * @since 7.0.7 Moved from the `RemovedHashAlgorithms` sniff to the base `Sniff` class.
69
- *
70
- * @var array
71
- */
72
- protected $hashAlgoFunctions = array(
73
- 'hash_file' => 1,
74
- 'hash_hmac_file' => 1,
75
- 'hash_hmac' => 1,
76
- 'hash_init' => 1,
77
- 'hash_pbkdf2' => 1,
78
- 'hash' => 1,
79
- );
80
-
81
-
82
- /**
83
- * List of functions which take an ini directive as parameter (always the first parameter).
84
- *
85
- * Used by the new/removed ini directives sniffs.
86
- * Key is the function name, value is the 1-based parameter position in the function call.
87
- *
88
- * @since 7.1.0
89
- *
90
- * @var array
91
- */
92
- protected $iniFunctions = array(
93
- 'ini_get' => 1,
94
- 'ini_set' => 1,
95
- );
96
-
97
-
98
- /**
99
- * Get the testVersion configuration variable.
100
- *
101
- * The testVersion configuration variable may be in any of the following formats:
102
- * 1) Omitted/empty, in which case no version is specified. This effectively
103
- * disables all the checks for new PHP features provided by this standard.
104
- * 2) A single PHP version number, e.g. "5.4" in which case the standard checks that
105
- * the code will run on that version of PHP (no deprecated features or newer
106
- * features being used).
107
- * 3) A range, e.g. "5.0-5.5", in which case the standard checks the code will run
108
- * on all PHP versions in that range, and that it doesn't use any features that
109
- * were deprecated by the final version in the list, or which were not available
110
- * for the first version in the list.
111
- * We accept ranges where one of the components is missing, e.g. "-5.6" means
112
- * all versions up to PHP 5.6, and "7.0-" means all versions above PHP 7.0.
113
- * PHP version numbers should always be in Major.Minor format. Both "5", "5.3.2"
114
- * would be treated as invalid, and ignored.
115
- *
116
- * @since 7.0.0
117
- * @since 7.1.3 Now allows for partial ranges such as `5.2-`.
118
- *
119
- * @return array $arrTestVersions will hold an array containing min/max version
120
- * of PHP that we are checking against (see above). If only a
121
- * single version number is specified, then this is used as
122
- * both the min and max.
123
- *
124
- * @throws \PHP_CodeSniffer_Exception If testVersion is invalid.
125
- */
126
- private function getTestVersion()
127
- {
128
- static $arrTestVersions = array();
129
-
130
- $default = array(null, null);
131
- $testVersion = trim(PHPCSHelper::getConfigData('testVersion'));
132
-
133
- if (empty($testVersion) === false && isset($arrTestVersions[$testVersion]) === false) {
134
-
135
- $arrTestVersions[$testVersion] = $default;
136
-
137
- if (preg_match('`^\d+\.\d+$`', $testVersion)) {
138
- $arrTestVersions[$testVersion] = array($testVersion, $testVersion);
139
- return $arrTestVersions[$testVersion];
140
- }
141
-
142
- if (preg_match('`^(\d+\.\d+)?\s*-\s*(\d+\.\d+)?$`', $testVersion, $matches)) {
143
- if (empty($matches[1]) === false || empty($matches[2]) === false) {
144
- // If no lower-limit is set, we set the min version to 4.0.
145
- // Whilst development focuses on PHP 5 and above, we also accept
146
- // sniffs for PHP 4, so we include that as the minimum.
147
- // (It makes no sense to support PHP 3 as this was effectively a
148
- // different language).
149
- $min = empty($matches[1]) ? '4.0' : $matches[1];
150
-
151
- // If no upper-limit is set, we set the max version to 99.9.
152
- $max = empty($matches[2]) ? '99.9' : $matches[2];
153
-
154
- if (version_compare($min, $max, '>')) {
155
- trigger_error(
156
- "Invalid range in testVersion setting: '" . $testVersion . "'",
157
- \E_USER_WARNING
158
- );
159
- return $default;
160
- } else {
161
- $arrTestVersions[$testVersion] = array($min, $max);
162
- return $arrTestVersions[$testVersion];
163
- }
164
- }
165
- }
166
-
167
- trigger_error(
168
- "Invalid testVersion setting: '" . $testVersion . "'",
169
- \E_USER_WARNING
170
- );
171
- return $default;
172
- }
173
-
174
- if (isset($arrTestVersions[$testVersion])) {
175
- return $arrTestVersions[$testVersion];
176
- }
177
-
178
- return $default;
179
- }
180
-
181
-
182
- /**
183
- * Check whether a specific PHP version is equal to or higher than the maximum
184
- * supported PHP version as provided by the user in `testVersion`.
185
- *
186
- * Should be used when sniffing for *old* PHP features (deprecated/removed).
187
- *
188
- * @since 5.6
189
- *
190
- * @param string $phpVersion A PHP version number in 'major.minor' format.
191
- *
192
- * @return bool True if testVersion has not been provided or if the PHP version
193
- * is equal to or higher than the highest supported PHP version
194
- * in testVersion. False otherwise.
195
- */
196
- public function supportsAbove($phpVersion)
197
- {
198
- $testVersion = $this->getTestVersion();
199
- $testVersion = $testVersion[1];
200
-
201
- if (\is_null($testVersion)
202
- || version_compare($testVersion, $phpVersion) >= 0
203
- ) {
204
- return true;
205
- } else {
206
- return false;
207
- }
208
- }
209
-
210
-
211
- /**
212
- * Check whether a specific PHP version is equal to or lower than the minimum
213
- * supported PHP version as provided by the user in `testVersion`.
214
- *
215
- * Should be used when sniffing for *new* PHP features.
216
- *
217
- * @since 5.6
218
- *
219
- * @param string $phpVersion A PHP version number in 'major.minor' format.
220
- *
221
- * @return bool True if the PHP version is equal to or lower than the lowest
222
- * supported PHP version in testVersion.
223
- * False otherwise or if no testVersion is provided.
224
- */
225
- public function supportsBelow($phpVersion)
226
- {
227
- $testVersion = $this->getTestVersion();
228
- $testVersion = $testVersion[0];
229
-
230
- if (\is_null($testVersion) === false
231
- && version_compare($testVersion, $phpVersion) <= 0
232
- ) {
233
- return true;
234
- } else {
235
- return false;
236
- }
237
- }
238
-
239
-
240
- /**
241
- * Add a PHPCS message to the output stack as either a warning or an error.
242
- *
243
- * @since 7.1.0
244
- *
245
- * @param \PHP_CodeSniffer_File $phpcsFile The file the message applies to.
246
- * @param string $message The message.
247
- * @param int $stackPtr The position of the token
248
- * the message relates to.
249
- * @param bool $isError Whether to report the message as an
250
- * 'error' or 'warning'.
251
- * Defaults to true (error).
252
- * @param string $code The error code for the message.
253
- * Defaults to 'Found'.
254
- * @param array $data Optional input for the data replacements.
255
- *
256
- * @return void
257
- */
258
- public function addMessage(File $phpcsFile, $message, $stackPtr, $isError, $code = 'Found', $data = array())
259
- {
260
- if ($isError === true) {
261
- $phpcsFile->addError($message, $stackPtr, $code, $data);
262
- } else {
263
- $phpcsFile->addWarning($message, $stackPtr, $code, $data);
264
- }
265
- }
266
-
267
-
268
- /**
269
- * Convert an arbitrary string to an alphanumeric string with underscores.
270
- *
271
- * Pre-empt issues with arbitrary strings being used as error codes in XML and PHP.
272
- *
273
- * @since 7.1.0
274
- *
275
- * @param string $baseString Arbitrary string.
276
- *
277
- * @return string
278
- */
279
- public function stringToErrorCode($baseString)
280
- {
281
- return preg_replace('`[^a-z0-9_]`i', '_', strtolower($baseString));
282
- }
283
-
284
-
285
- /**
286
- * Strip quotes surrounding an arbitrary string.
287
- *
288
- * Intended for use with the contents of a T_CONSTANT_ENCAPSED_STRING / T_DOUBLE_QUOTED_STRING.
289
- *
290
- * @since 7.0.6
291
- *
292
- * @param string $string The raw string.
293
- *
294
- * @return string String without quotes around it.
295
- */
296
- public function stripQuotes($string)
297
- {
298
- return preg_replace('`^([\'"])(.*)\1$`Ds', '$2', $string);
299
- }
300
-
301
-
302
- /**
303
- * Strip variables from an arbitrary double quoted string.
304
- *
305
- * Intended for use with the contents of a T_DOUBLE_QUOTED_STRING.
306
- *
307
- * @since 7.1.2
308
- *
309
- * @param string $string The raw string.
310
- *
311
- * @return string String without variables in it.
312
- */
313
- public function stripVariables($string)
314
- {
315
- if (strpos($string, '$') === false) {
316
- return $string;
317
- }
318
-
319
- return preg_replace(self::REGEX_COMPLEX_VARS, '', $string);
320
- }
321
-
322
-
323
- /**
324
- * Make all top level array keys in an array lowercase.
325
- *
326
- * @since 7.1.0
327
- *
328
- * @param array $array Initial array.
329
- *
330
- * @return array Same array, but with all lowercase top level keys.
331
- */
332
- public function arrayKeysToLowercase($array)
333
- {
334
- return array_change_key_case($array, \CASE_LOWER);
335
- }
336
-
337
-
338
- /**
339
- * Checks if a function call has parameters.
340
- *
341
- * Expects to be passed the T_STRING or T_VARIABLE stack pointer for the function call.
342
- * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
343
- *
344
- * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, it
345
- * will detect whether the array has values or is empty.
346
- *
347
- * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/120
348
- * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/152
349
- *
350
- * @since 7.0.3
351
- *
352
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
353
- * @param int $stackPtr The position of the function call token.
354
- *
355
- * @return bool
356
- */
357
- public function doesFunctionCallHaveParameters(File $phpcsFile, $stackPtr)
358
- {
359
- $tokens = $phpcsFile->getTokens();
360
-
361
- // Check for the existence of the token.
362
- if (isset($tokens[$stackPtr]) === false) {
363
- return false;
364
- }
365
-
366
- // Is this one of the tokens this function handles ?
367
- if (\in_array($tokens[$stackPtr]['code'], array(\T_STRING, \T_ARRAY, \T_OPEN_SHORT_ARRAY, \T_VARIABLE), true) === false) {
368
- return false;
369
- }
370
-
371
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
372
-
373
- // Deal with short array syntax.
374
- if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
375
- if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
376
- return false;
377
- }
378
-
379
- if ($nextNonEmpty === $tokens[$stackPtr]['bracket_closer']) {
380
- // No parameters.
381
- return false;
382
- } else {
383
- return true;
384
- }
385
- }
386
-
387
- // Deal with function calls & long arrays.
388
- // Next non-empty token should be the open parenthesis.
389
- if ($nextNonEmpty === false && $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
390
- return false;
391
- }
392
-
393
- if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
394
- return false;
395
- }
396
-
397
- $closeParenthesis = $tokens[$nextNonEmpty]['parenthesis_closer'];
398
- $nextNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $nextNonEmpty + 1, $closeParenthesis + 1, true);
399
-
400
- if ($nextNextNonEmpty === $closeParenthesis) {
401
- // No parameters.
402
- return false;
403
- }
404
-
405
- return true;
406
- }
407
-
408
-
409
- /**
410
- * Count the number of parameters a function call has been passed.
411
- *
412
- * Expects to be passed the T_STRING or T_VARIABLE stack pointer for the function call.
413
- * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
414
- *
415
- * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
416
- * it will return the number of values in the array.
417
- *
418
- * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/111
419
- * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/114
420
- * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/151
421
- *
422
- * @since 7.0.3
423
- *
424
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
425
- * @param int $stackPtr The position of the function call token.
426
- *
427
- * @return int
428
- */
429
- public function getFunctionCallParameterCount(File $phpcsFile, $stackPtr)
430
- {
431
- if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) {
432
- return 0;
433
- }
434
-
435
- return \count($this->getFunctionCallParameters($phpcsFile, $stackPtr));
436
- }
437
-
438
-
439
- /**
440
- * Get information on all parameters passed to a function call.
441
- *
442
- * Expects to be passed the T_STRING or T_VARIABLE stack pointer for the function call.
443
- * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
444
- *
445
- * Will return an multi-dimentional array with the start token pointer, end token
446
- * pointer and raw parameter value for all parameters. Index will be 1-based.
447
- * If no parameters are found, will return an empty array.
448
- *
449
- * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
450
- * it will tokenize the values / key/value pairs contained in the array call.
451
- *
452
- * @since 7.0.5 Split off from the `getFunctionCallParameterCount()` method.
453
- *
454
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
455
- * @param int $stackPtr The position of the function call token.
456
- *
457
- * @return array
458
- */
459
- public function getFunctionCallParameters(File $phpcsFile, $stackPtr)
460
- {
461
- if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) {
462
- return array();
463
- }
464
-
465
- // Ok, we know we have a T_STRING, T_VARIABLE, T_ARRAY or T_OPEN_SHORT_ARRAY with parameters
466
- // and valid open & close brackets/parenthesis.
467
- $tokens = $phpcsFile->getTokens();
468
-
469
- // Mark the beginning and end tokens.
470
- if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
471
- $opener = $stackPtr;
472
- $closer = $tokens[$stackPtr]['bracket_closer'];
473
-
474
- $nestedParenthesisCount = 0;
475
-
476
- } else {
477
- $opener = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
478
- $closer = $tokens[$opener]['parenthesis_closer'];
479
-
480
- $nestedParenthesisCount = 1;
481
- }
482
-
483
- // Which nesting level is the one we are interested in ?
484
- if (isset($tokens[$opener]['nested_parenthesis'])) {
485
- $nestedParenthesisCount += \count($tokens[$opener]['nested_parenthesis']);
486
- }
487
-
488
- $parameters = array();
489
- $nextComma = $opener;
490
- $paramStart = $opener + 1;
491
- $cnt = 1;
492
- while (($nextComma = $phpcsFile->findNext(array(\T_COMMA, $tokens[$closer]['code'], \T_OPEN_SHORT_ARRAY, \T_CLOSURE), $nextComma + 1, $closer + 1)) !== false) {
493
- // Ignore anything within short array definition brackets.
494
- if ($tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY'
495
- && (isset($tokens[$nextComma]['bracket_opener'])
496
- && $tokens[$nextComma]['bracket_opener'] === $nextComma)
497
- && isset($tokens[$nextComma]['bracket_closer'])
498
- ) {
499
- // Skip forward to the end of the short array definition.
500
- $nextComma = $tokens[$nextComma]['bracket_closer'];
501
- continue;
502
- }
503
-
504
- // Skip past closures passed as function parameters.
505
- if ($tokens[$nextComma]['type'] === 'T_CLOSURE'
506
- && (isset($tokens[$nextComma]['scope_condition'])
507
- && $tokens[$nextComma]['scope_condition'] === $nextComma)
508
- && isset($tokens[$nextComma]['scope_closer'])
509
- ) {
510
- // Skip forward to the end of the closure declaration.
511
- $nextComma = $tokens[$nextComma]['scope_closer'];
512
- continue;
513
- }
514
-
515
- // Ignore comma's at a lower nesting level.
516
- if ($tokens[$nextComma]['type'] === 'T_COMMA'
517
- && isset($tokens[$nextComma]['nested_parenthesis'])
518
- && \count($tokens[$nextComma]['nested_parenthesis']) !== $nestedParenthesisCount
519
- ) {
520
- continue;
521
- }
522
-
523
- // Ignore closing parenthesis/bracket if not 'ours'.
524
- if ($tokens[$nextComma]['type'] === $tokens[$closer]['type'] && $nextComma !== $closer) {
525
- continue;
526
- }
527
-
528
- // Ok, we've reached the end of the parameter.
529
- $parameters[$cnt]['start'] = $paramStart;
530
- $parameters[$cnt]['end'] = $nextComma - 1;
531
- $parameters[$cnt]['raw'] = trim($phpcsFile->getTokensAsString($paramStart, ($nextComma - $paramStart)));
532
-
533
- /*
534
- * Check if there are more tokens before the closing parenthesis.
535
- * Prevents code like the following from setting a third parameter:
536
- * `functionCall( $param1, $param2, );`.
537
- */
538
- $hasNextParam = $phpcsFile->findNext(Tokens::$emptyTokens, $nextComma + 1, $closer, true, null, true);
539
- if ($hasNextParam === false) {
540
- break;
541
- }
542
-
543
- // Prepare for the next parameter.
544
- $paramStart = $nextComma + 1;
545
- $cnt++;
546
- }
547
-
548
- return $parameters;
549
- }
550
-
551
-
552
- /**
553
- * Get information on a specific parameter passed to a function call.
554
- *
555
- * Expects to be passed the T_STRING or T_VARIABLE stack pointer for the function call.
556
- * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
557
- *
558
- * Will return a array with the start token pointer, end token pointer and the raw value
559
- * of the parameter at a specific offset.
560
- * If the specified parameter is not found, will return false.
561
- *
562
- * @since 7.0.5
563
- *
564
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
565
- * @param int $stackPtr The position of the function call token.
566
- * @param int $paramOffset The 1-based index position of the parameter to retrieve.
567
- *
568
- * @return array|false
569
- */
570
- public function getFunctionCallParameter(File $phpcsFile, $stackPtr, $paramOffset)
571
- {
572
- $parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
573
-
574
- if (isset($parameters[$paramOffset]) === false) {
575
- return false;
576
- } else {
577
- return $parameters[$paramOffset];
578
- }
579
- }
580
-
581
-
582
- /**
583
- * Verify whether a token is within a scoped condition.
584
- *
585
- * If the optional $validScopes parameter has been passed, the function
586
- * will check that the token has at least one condition which is of a
587
- * type defined in $validScopes.
588
- *
589
- * @since 7.0.5 Largely split off from the `inClassScope()` method.
590
- *
591
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
592
- * @param int $stackPtr The position of the token.
593
- * @param array|int $validScopes Optional. Array of valid scopes
594
- * or int value of a valid scope.
595
- * Pass the T_.. constant(s) for the
596
- * desired scope to this parameter.
597
- *
598
- * @return bool Without the optional $scopeTypes: True if within a scope, false otherwise.
599
- * If the $scopeTypes are set: True if *one* of the conditions is a
600
- * valid scope, false otherwise.
601
- */
602
- public function tokenHasScope(File $phpcsFile, $stackPtr, $validScopes = null)
603
- {
604
- $tokens = $phpcsFile->getTokens();
605
-
606
- // Check for the existence of the token.
607
- if (isset($tokens[$stackPtr]) === false) {
608
- return false;
609
- }
610
-
611
- // No conditions = no scope.
612
- if (empty($tokens[$stackPtr]['conditions'])) {
613
- return false;
614
- }
615
-
616
- // Ok, there are conditions, do we have to check for specific ones ?
617
- if (isset($validScopes) === false) {
618
- return true;
619
- }
620
-
621
- return $phpcsFile->hasCondition($stackPtr, $validScopes);
622
- }
623
-
624
-
625
- /**
626
- * Verify whether a token is within a class scope.
627
- *
628
- * @since 7.0.3
629
- *
630
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
631
- * @param int $stackPtr The position of the token.
632
- * @param bool $strict Whether to strictly check for the T_CLASS
633
- * scope or also accept interfaces and traits
634
- * as scope.
635
- *
636
- * @return bool True if within class scope, false otherwise.
637
- */
638
- public function inClassScope(File $phpcsFile, $stackPtr, $strict = true)
639
- {
640
- $validScopes = array(\T_CLASS);
641
- if (\defined('T_ANON_CLASS') === true) {
642
- $validScopes[] = \T_ANON_CLASS;
643
- }
644
-
645
- if ($strict === false) {
646
- $validScopes[] = \T_INTERFACE;
647
- $validScopes[] = \T_TRAIT;
648
- }
649
-
650
- return $phpcsFile->hasCondition($stackPtr, $validScopes);
651
- }
652
-
653
-
654
- /**
655
- * Returns the fully qualified class name for a new class instantiation.
656
- *
657
- * Returns an empty string if the class name could not be reliably inferred.
658
- *
659
- * @since 7.0.3
660
- *
661
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
662
- * @param int $stackPtr The position of a T_NEW token.
663
- *
664
- * @return string
665
- */
666
- public function getFQClassNameFromNewToken(File $phpcsFile, $stackPtr)
667
- {
668
- $tokens = $phpcsFile->getTokens();
669
-
670
- // Check for the existence of the token.
671
- if (isset($tokens[$stackPtr]) === false) {
672
- return '';
673
- }
674
-
675
- if ($tokens[$stackPtr]['code'] !== \T_NEW) {
676
- return '';
677
- }
678
-
679
- $start = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
680
- if ($start === false) {
681
- return '';
682
- }
683
-
684
- // Bow out if the next token is a variable as we don't know where it was defined.
685
- if ($tokens[$start]['code'] === \T_VARIABLE) {
686
- return '';
687
- }
688
-
689
- // Bow out if the next token is the class keyword.
690
- if ($tokens[$start]['type'] === 'T_ANON_CLASS' || $tokens[$start]['code'] === \T_CLASS) {
691
- return '';
692
- }
693
-
694
- $find = array(
695
- \T_NS_SEPARATOR,
696
- \T_STRING,
697
- \T_NAMESPACE,
698
- \T_WHITESPACE,
699
- );
700
-
701
- $end = $phpcsFile->findNext($find, ($start + 1), null, true, null, true);
702
- $className = $phpcsFile->getTokensAsString($start, ($end - $start));
703
- $className = trim($className);
704
-
705
- return $this->getFQName($phpcsFile, $stackPtr, $className);
706
- }
707
-
708
-
709
- /**
710
- * Returns the fully qualified name of the class that the specified class extends.
711
- *
712
- * Returns an empty string if the class does not extend another class or if
713
- * the class name could not be reliably inferred.
714
- *
715
- * @since 7.0.3
716
- *
717
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
718
- * @param int $stackPtr The position of a T_CLASS token.
719
- *
720
- * @return string
721
- */
722
- public function getFQExtendedClassName(File $phpcsFile, $stackPtr)
723
- {
724
- $tokens = $phpcsFile->getTokens();
725
-
726
- // Check for the existence of the token.
727
- if (isset($tokens[$stackPtr]) === false) {
728
- return '';
729
- }
730
-
731
- if ($tokens[$stackPtr]['code'] !== \T_CLASS
732
- && $tokens[$stackPtr]['type'] !== 'T_ANON_CLASS'
733
- && $tokens[$stackPtr]['type'] !== 'T_INTERFACE'
734
- ) {
735
- return '';
736
- }
737
-
738
- $extends = PHPCSHelper::findExtendedClassName($phpcsFile, $stackPtr);
739
- if (empty($extends) || \is_string($extends) === false) {
740
- return '';
741
- }
742
-
743
- return $this->getFQName($phpcsFile, $stackPtr, $extends);
744
- }
745
-
746
-
747
- /**
748
- * Returns the class name for the static usage of a class.
749
- * This can be a call to a method, the use of a property or constant.
750
- *
751
- * Returns an empty string if the class name could not be reliably inferred.
752
- *
753
- * @since 7.0.3
754
- *
755
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
756
- * @param int $stackPtr The position of a T_NEW token.
757
- *
758
- * @return string
759
- */
760
- public function getFQClassNameFromDoubleColonToken(File $phpcsFile, $stackPtr)
761
- {
762
- $tokens = $phpcsFile->getTokens();
763
-
764
- // Check for the existence of the token.
765
- if (isset($tokens[$stackPtr]) === false) {
766
- return '';
767
- }
768
-
769
- if ($tokens[$stackPtr]['code'] !== \T_DOUBLE_COLON) {
770
- return '';
771
- }
772
-
773
- // Nothing to do if previous token is a variable as we don't know where it was defined.
774
- if ($tokens[$stackPtr - 1]['code'] === \T_VARIABLE) {
775
- return '';
776
- }
777
-
778
- // Nothing to do if 'parent' or 'static' as we don't know how far the class tree extends.
779
- if (\in_array($tokens[$stackPtr - 1]['code'], array(\T_PARENT, \T_STATIC), true)) {
780
- return '';
781
- }
782
-
783
- // Get the classname from the class declaration if self is used.
784
- if ($tokens[$stackPtr - 1]['code'] === \T_SELF) {
785
- $classDeclarationPtr = $phpcsFile->findPrevious(\T_CLASS, $stackPtr - 1);
786
- if ($classDeclarationPtr === false) {
787
- return '';
788
- }
789
- $className = $phpcsFile->getDeclarationName($classDeclarationPtr);
790
- return $this->getFQName($phpcsFile, $classDeclarationPtr, $className);
791
- }
792
-
793
- $find = array(
794
- \T_NS_SEPARATOR,
795
- \T_STRING,
796
- \T_NAMESPACE,
797
- \T_WHITESPACE,
798
- );
799
-
800
- $start = $phpcsFile->findPrevious($find, $stackPtr - 1, null, true, null, true);
801
- if ($start === false || isset($tokens[($start + 1)]) === false) {
802
- return '';
803
- }
804
-
805
- $start = ($start + 1);
806
- $className = $phpcsFile->getTokensAsString($start, ($stackPtr - $start));
807
- $className = trim($className);
808
-
809
- return $this->getFQName($phpcsFile, $stackPtr, $className);
810
- }
811
-
812
-
813
- /**
814
- * Get the Fully Qualified name for a class/function/constant etc.
815
- *
816
- * Checks if a class/function/constant name is already fully qualified and
817
- * if not, enrich it with the relevant namespace information.
818
- *
819
- * @since 7.0.3
820
- *
821
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
822
- * @param int $stackPtr The position of the token.
823
- * @param string $name The class / function / constant name.
824
- *
825
- * @return string
826
- */
827
- public function getFQName(File $phpcsFile, $stackPtr, $name)
828
- {
829
- if (strpos($name, '\\') === 0) {
830
- // Already fully qualified.
831
- return $name;
832
- }
833
-
834
- // Remove the namespace keyword if used.
835
- if (strpos($name, 'namespace\\') === 0) {
836
- $name = substr($name, 10);
837
- }
838
-
839
- $namespace = $this->determineNamespace($phpcsFile, $stackPtr);
840
-
841
- if ($namespace === '') {
842
- return '\\' . $name;
843
- } else {
844
- return '\\' . $namespace . '\\' . $name;
845
- }
846
- }
847
-
848
-
849
- /**
850
- * Is the class/function/constant name namespaced or global ?
851
- *
852
- * @since 7.0.3
853
- *
854
- * @param string $FQName Fully Qualified name of a class, function etc.
855
- * I.e. should always start with a `\`.
856
- *
857
- * @return bool True if namespaced, false if global.
858
- *
859
- * @throws \PHP_CodeSniffer_Exception If the name in the passed parameter
860
- * is not fully qualified.
861
- */
862
- public function isNamespaced($FQName)
863
- {
864
- if (strpos($FQName, '\\') !== 0) {
865
- throw new PHPCS_Exception('$FQName must be a fully qualified name');
866
- }
867
-
868
- return (strpos(substr($FQName, 1), '\\') !== false);
869
- }
870
-
871
-
872
- /**
873
- * Determine the namespace name an arbitrary token lives in.
874
- *
875
- * @since 7.0.3
876
- *
877
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
878
- * @param int $stackPtr The token position for which to determine the namespace.
879
- *
880
- * @return string Namespace name or empty string if it couldn't be determined or no namespace applies.
881
- */
882
- public function determineNamespace(File $phpcsFile, $stackPtr)
883
- {
884
- $tokens = $phpcsFile->getTokens();
885
-
886
- // Check for the existence of the token.
887
- if (isset($tokens[$stackPtr]) === false) {
888
- return '';
889
- }
890
-
891
- // Check for scoped namespace {}.
892
- if (empty($tokens[$stackPtr]['conditions']) === false) {
893
- $namespacePtr = $phpcsFile->getCondition($stackPtr, \T_NAMESPACE);
894
- if ($namespacePtr !== false) {
895
- $namespace = $this->getDeclaredNamespaceName($phpcsFile, $namespacePtr);
896
- if ($namespace !== false) {
897
- return $namespace;
898
- }
899
-
900
- // We are in a scoped namespace, but couldn't determine the name. Searching for a global namespace is futile.
901
- return '';
902
- }
903
- }
904
-
905
- /*
906
- * Not in a scoped namespace, so let's see if we can find a non-scoped namespace instead.
907
- * Keeping in mind that:
908
- * - there can be multiple non-scoped namespaces in a file (bad practice, but it happens).
909
- * - the namespace keyword can also be used as part of a function/method call and such.
910
- * - that a non-named namespace resolves to the global namespace.
911
- */
912
- $previousNSToken = $stackPtr;
913
- $namespace = false;
914
- do {
915
- $previousNSToken = $phpcsFile->findPrevious(\T_NAMESPACE, ($previousNSToken - 1));
916
-
917
- // Stop if we encounter a scoped namespace declaration as we already know we're not in one.
918
- if (empty($tokens[$previousNSToken]['scope_condition']) === false && $tokens[$previousNSToken]['scope_condition'] === $previousNSToken) {
919
- break;
920
- }
921
-
922
- $namespace = $this->getDeclaredNamespaceName($phpcsFile, $previousNSToken);
923
-
924
- } while ($namespace === false && $previousNSToken !== false);
925
-
926
- // If we still haven't got a namespace, return an empty string.
927
- if ($namespace === false) {
928
- return '';
929
- } else {
930
- return $namespace;
931
- }
932
- }
933
-
934
- /**
935
- * Get the complete namespace name for a namespace declaration.
936
- *
937
- * For hierarchical namespaces, the name will be composed of several tokens,
938
- * i.e. MyProject\Sub\Level which will be returned together as one string.
939
- *
940
- * @since 7.0.3
941
- *
942
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
943
- * @param int|bool $stackPtr The position of a T_NAMESPACE token.
944
- *
945
- * @return string|false Namespace name or false if not a namespace declaration.
946
- * Namespace name can be an empty string for global namespace declaration.
947
- */
948
- public function getDeclaredNamespaceName(File $phpcsFile, $stackPtr)
949
- {
950
- $tokens = $phpcsFile->getTokens();
951
-
952
- // Check for the existence of the token.
953
- if ($stackPtr === false || isset($tokens[$stackPtr]) === false) {
954
- return false;
955
- }
956
-
957
- if ($tokens[$stackPtr]['code'] !== \T_NAMESPACE) {
958
- return false;
959
- }
960
-
961
- if ($tokens[($stackPtr + 1)]['code'] === \T_NS_SEPARATOR) {
962
- // Not a namespace declaration, but use of, i.e. `namespace\someFunction();`.
963
- return false;
964
- }
965
-
966
- $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
967
- if ($tokens[$nextToken]['code'] === \T_OPEN_CURLY_BRACKET) {
968
- /*
969
- * Declaration for global namespace when using multiple namespaces in a file.
970
- * I.e.: `namespace {}`.
971
- */
972
- return '';
973
- }
974
-
975
- // Ok, this should be a namespace declaration, so get all the parts together.
976
- $validTokens = array(
977
- \T_STRING => true,
978
- \T_NS_SEPARATOR => true,
979
- \T_WHITESPACE => true,
980
- );
981
-
982
- $namespaceName = '';
983
- while (isset($validTokens[$tokens[$nextToken]['code']]) === true) {
984
- $namespaceName .= trim($tokens[$nextToken]['content']);
985
- $nextToken++;
986
- }
987
-
988
- return $namespaceName;
989
- }
990
-
991
-
992
- /**
993
- * Get the stack pointer for a return type token for a given function.
994
- *
995
- * Compatible layer for older PHPCS versions which don't recognize
996
- * return type hints correctly.
997
- *
998
- * Expects to be passed T_RETURN_TYPE, T_FUNCTION or T_CLOSURE token.
999
- *
1000
- * @since 7.1.2
1001
- *
1002
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1003
- * @param int $stackPtr The position of the token.
1004
- *
1005
- * @return int|false Stack pointer to the return type token or false if
1006
- * no return type was found or the passed token was
1007
- * not of the correct type.
1008
- */
1009
- public function getReturnTypeHintToken(File $phpcsFile, $stackPtr)
1010
- {
1011
- $tokens = $phpcsFile->getTokens();
1012
-
1013
- if (\defined('T_RETURN_TYPE') && $tokens[$stackPtr]['code'] === \T_RETURN_TYPE) {
1014
- return $stackPtr;
1015
- }
1016
-
1017
- if ($tokens[$stackPtr]['code'] !== \T_FUNCTION && $tokens[$stackPtr]['code'] !== \T_CLOSURE) {
1018
- return false;
1019
- }
1020
-
1021
- if (isset($tokens[$stackPtr]['parenthesis_closer']) === false) {
1022
- return false;
1023
- }
1024
-
1025
- // Allow for interface and abstract method declarations.
1026
- $endOfFunctionDeclaration = null;
1027
- if (isset($tokens[$stackPtr]['scope_opener'])) {
1028
- $endOfFunctionDeclaration = $tokens[$stackPtr]['scope_opener'];
1029
- } else {
1030
- $nextSemiColon = $phpcsFile->findNext(\T_SEMICOLON, ($tokens[$stackPtr]['parenthesis_closer'] + 1), null, false, null, true);
1031
- if ($nextSemiColon !== false) {
1032
- $endOfFunctionDeclaration = $nextSemiColon;
1033
- }
1034
- }
1035
-
1036
- if (isset($endOfFunctionDeclaration) === false) {
1037
- return false;
1038
- }
1039
-
1040
- $hasColon = $phpcsFile->findNext(
1041
- array(\T_COLON, \T_INLINE_ELSE),
1042
- ($tokens[$stackPtr]['parenthesis_closer'] + 1),
1043
- $endOfFunctionDeclaration
1044
- );
1045
- if ($hasColon === false) {
1046
- return false;
1047
- }
1048
-
1049
- /*
1050
- * - `self`, `parent` and `callable` are not being recognized as return types in PHPCS < 2.6.0.
1051
- * - Return types are not recognized at all in PHPCS < 2.4.0.
1052
- * - The T_RETURN_TYPE token is defined, but no longer in use since PHPCS 3.3.0+.
1053
- * The token will now be tokenized as T_STRING.
1054
- * - An `array` (return) type declaration was tokenized as `T_ARRAY_HINT` in PHPCS 2.3.3 - 3.2.3
1055
- * to prevent confusing sniffs looking for array declarations.
1056
- * As of PHPCS 3.3.0 `array` as a type declaration will be tokenized as `T_STRING`.
1057
- */
1058
- $unrecognizedTypes = array(
1059
- \T_CALLABLE,
1060
- \T_SELF,
1061
- \T_PARENT,
1062
- \T_ARRAY, // PHPCS < 2.4.0.
1063
- \T_STRING,
1064
- );
1065
-
1066
- return $phpcsFile->findPrevious($unrecognizedTypes, ($endOfFunctionDeclaration - 1), $hasColon);
1067
- }
1068
-
1069
-
1070
- /**
1071
- * Get the complete return type declaration for a given function.
1072
- *
1073
- * Cross-version compatible way to retrieve the complete return type declaration.
1074
- *
1075
- * For a classname-based return type, PHPCS, as well as the Sniff::getReturnTypeHintToken()
1076
- * method will mark the classname as the return type token.
1077
- * This method will find preceeding namespaces and namespace separators and will return a
1078
- * string containing the qualified return type declaration.
1079
- *
1080
- * Expects to be passed a T_RETURN_TYPE token or the return value from a call to
1081
- * the Sniff::getReturnTypeHintToken() method.
1082
- *
1083
- * @since 8.2.0
1084
- *
1085
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1086
- * @param int $stackPtr The position of the return type token.
1087
- *
1088
- * @return string The name of the return type token.
1089
- */
1090
- public function getReturnTypeHintName(File $phpcsFile, $stackPtr)
1091
- {
1092
- $tokens = $phpcsFile->getTokens();
1093
-
1094
- // In older PHPCS versions, the nullable indicator will turn a return type colon into a T_INLINE_ELSE.
1095
- $colon = $phpcsFile->findPrevious(array(\T_COLON, \T_INLINE_ELSE, \T_FUNCTION, \T_CLOSE_PARENTHESIS), ($stackPtr - 1));
1096
- if ($colon === false
1097
- || ($tokens[$colon]['code'] !== \T_COLON && $tokens[$colon]['code'] !== \T_INLINE_ELSE)
1098
- ) {
1099
- // Shouldn't happen, just in case.
1100
- return '';
1101
- }
1102
-
1103
- $returnTypeHint = '';
1104
- for ($i = ($colon + 1); $i <= $stackPtr; $i++) {
1105
- // As of PHPCS 3.3.0+, all tokens are tokenized as "normal", so T_CALLABLE, T_SELF etc are
1106
- // all possible, just exclude anything that's regarded as empty and the nullable indicator.
1107
- if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
1108
- continue;
1109
- }
1110
-
1111
- if ($tokens[$i]['type'] === 'T_NULLABLE') {
1112
- continue;
1113
- }
1114
-
1115
- if (\defined('T_NULLABLE') === false && $tokens[$i]['code'] === \T_INLINE_THEN) {
1116
- // Old PHPCS.
1117
- continue;
1118
- }
1119
-
1120
- $returnTypeHint .= $tokens[$i]['content'];
1121
- }
1122
-
1123
- return $returnTypeHint;
1124
- }
1125
-
1126
-
1127
- /**
1128
- * Check whether a T_VARIABLE token is a class property declaration.
1129
- *
1130
- * Compatibility layer for PHPCS cross-version compatibility
1131
- * as PHPCS 2.4.0 - 2.7.1 does not have good enough support for
1132
- * anonymous classes. Along the same lines, the`getMemberProperties()`
1133
- * method does not support the `var` prefix.
1134
- *
1135
- * @since 7.1.4
1136
- *
1137
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
1138
- * @param int $stackPtr The position in the stack of the
1139
- * T_VARIABLE token to verify.
1140
- *
1141
- * @return bool
1142
- */
1143
- public function isClassProperty(File $phpcsFile, $stackPtr)
1144
- {
1145
- $tokens = $phpcsFile->getTokens();
1146
-
1147
- if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_VARIABLE) {
1148
- return false;
1149
- }
1150
-
1151
- // Note: interfaces can not declare properties.
1152
- $validScopes = array(
1153
- 'T_CLASS' => true,
1154
- 'T_ANON_CLASS' => true,
1155
- 'T_TRAIT' => true,
1156
- );
1157
-
1158
- $scopePtr = $this->validDirectScope($phpcsFile, $stackPtr, $validScopes);
1159
- if ($scopePtr !== false) {
1160
- // Make sure it's not a method parameter.
1161
- if (empty($tokens[$stackPtr]['nested_parenthesis']) === true) {
1162
- return true;
1163
- } else {
1164
- $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']);
1165
- $deepestOpen = array_pop($parenthesis);
1166
- if ($deepestOpen < $scopePtr
1167
- || isset($tokens[$deepestOpen]['parenthesis_owner']) === false
1168
- || $tokens[$tokens[$deepestOpen]['parenthesis_owner']]['code'] !== \T_FUNCTION
1169
- ) {
1170
- return true;
1171
- }
1172
- }
1173
- }
1174
-
1175
- return false;
1176
- }
1177
-
1178
-
1179
- /**
1180
- * Check whether a T_CONST token is a class constant declaration.
1181
- *
1182
- * @since 7.1.4
1183
- *
1184
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
1185
- * @param int $stackPtr The position in the stack of the
1186
- * T_CONST token to verify.
1187
- *
1188
- * @return bool
1189
- */
1190
- public function isClassConstant(File $phpcsFile, $stackPtr)
1191
- {
1192
- $tokens = $phpcsFile->getTokens();
1193
-
1194
- if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_CONST) {
1195
- return false;
1196
- }
1197
-
1198
- // Note: traits can not declare constants.
1199
- $validScopes = array(
1200
- 'T_CLASS' => true,
1201
- 'T_ANON_CLASS' => true,
1202
- 'T_INTERFACE' => true,
1203
- );
1204
- if ($this->validDirectScope($phpcsFile, $stackPtr, $validScopes) !== false) {
1205
- return true;
1206
- }
1207
-
1208
- return false;
1209
- }
1210
-
1211
-
1212
- /**
1213
- * Check whether the direct wrapping scope of a token is within a limited set of
1214
- * acceptable tokens.
1215
- *
1216
- * Used to check, for instance, if a T_CONST is a class constant.
1217
- *
1218
- * @since 7.1.4
1219
- *
1220
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
1221
- * @param int $stackPtr The position in the stack of the
1222
- * token to verify.
1223
- * @param array $validScopes Array of token types.
1224
- * Keys should be the token types in string
1225
- * format to allow for newer token types.
1226
- * Value is irrelevant.
1227
- *
1228
- * @return int|bool StackPtr to the scope if valid, false otherwise.
1229
- */
1230
- protected function validDirectScope(File $phpcsFile, $stackPtr, $validScopes)
1231
- {
1232
- $tokens = $phpcsFile->getTokens();
1233
-
1234
- if (empty($tokens[$stackPtr]['conditions']) === true) {
1235
- return false;
1236
- }
1237
-
1238
- /*
1239
- * Check only the direct wrapping scope of the token.
1240
- */
1241
- $conditions = array_keys($tokens[$stackPtr]['conditions']);
1242
- $ptr = array_pop($conditions);
1243
-
1244
- if (isset($tokens[$ptr]) === false) {
1245
- return false;
1246
- }
1247
-
1248
- if (isset($validScopes[$tokens[$ptr]['type']]) === true) {
1249
- return $ptr;
1250
- }
1251
-
1252
- return false;
1253
- }
1254
-
1255
-
1256
- /**
1257
- * Get an array of just the type hints from a function declaration.
1258
- *
1259
- * Expects to be passed T_FUNCTION or T_CLOSURE token.
1260
- *
1261
- * Strips potential nullable indicator and potential global namespace
1262
- * indicator from the type hints before returning them.
1263
- *
1264
- * @since 7.1.4
1265
- *
1266
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1267
- * @param int $stackPtr The position of the token.
1268
- *
1269
- * @return array Array with type hints or an empty array if
1270
- * - the function does not have any parameters
1271
- * - no type hints were found
1272
- * - or the passed token was not of the correct type.
1273
- */
1274
- public function getTypeHintsFromFunctionDeclaration(File $phpcsFile, $stackPtr)
1275
- {
1276
- $tokens = $phpcsFile->getTokens();
1277
-
1278
- if ($tokens[$stackPtr]['code'] !== \T_FUNCTION && $tokens[$stackPtr]['code'] !== \T_CLOSURE) {
1279
- return array();
1280
- }
1281
-
1282
- $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
1283
- if (empty($parameters) || \is_array($parameters) === false) {
1284
- return array();
1285
- }
1286
-
1287
- $typeHints = array();
1288
-
1289
- foreach ($parameters as $param) {
1290
- if ($param['type_hint'] === '') {
1291
- continue;
1292
- }
1293
-
1294
- // Strip off potential nullable indication.
1295
- $typeHint = ltrim($param['type_hint'], '?');
1296
-
1297
- // Strip off potential (global) namespace indication.
1298
- $typeHint = ltrim($typeHint, '\\');
1299
-
1300
- if ($typeHint !== '') {
1301
- $typeHints[] = $typeHint;
1302
- }
1303
- }
1304
-
1305
- return $typeHints;
1306
- }
1307
-
1308
-
1309
- /**
1310
- * Get the hash algorithm name from the parameter in a hash function call.
1311
- *
1312
- * @since 7.0.7 Logic was originally contained in the `RemovedHashAlgorithms` sniff.
1313
- *
1314
- * @param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
1315
- * @param int $stackPtr The position of the T_STRING function token.
1316
- *
1317
- * @return string|false The algorithm name without quotes if this was a relevant hash
1318
- * function call or false if it was not.
1319
- */
1320
- public function getHashAlgorithmParameter(File $phpcsFile, $stackPtr)
1321
- {
1322
- $tokens = $phpcsFile->getTokens();
1323
-
1324
- // Check for the existence of the token.
1325
- if (isset($tokens[$stackPtr]) === false) {
1326
- return false;
1327
- }
1328
-
1329
- if ($tokens[$stackPtr]['code'] !== \T_STRING) {
1330
- return false;
1331
- }
1332
-
1333
- $functionName = $tokens[$stackPtr]['content'];
1334
- $functionNameLc = strtolower($functionName);
1335
-
1336
- // Bow out if not one of the functions we're targetting.
1337
- if (isset($this->hashAlgoFunctions[$functionNameLc]) === false) {
1338
- return false;
1339
- }
1340
-
1341
- // Get the parameter from the function call which should contain the algorithm name.
1342
- $algoParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->hashAlgoFunctions[$functionNameLc]);
1343
- if ($algoParam === false) {
1344
- return false;
1345
- }
1346
-
1347
- // Algorithm is a text string, so we need to remove the quotes.
1348
- $algo = strtolower(trim($algoParam['raw']));
1349
- $algo = $this->stripQuotes($algo);
1350
-
1351
- return $algo;
1352
- }
1353
-
1354
-
1355
- /**
1356
- * Determine whether an arbitrary T_STRING token is the use of a global constant.
1357
- *
1358
- * @since 8.1.0
1359
- *
1360
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1361
- * @param int $stackPtr The position of the T_STRING token.
1362
- *
1363
- * @return bool
1364
- */
1365
- public function isUseOfGlobalConstant(File $phpcsFile, $stackPtr)
1366
- {
1367
- static $isLowPHPCS, $isLowPHP;
1368
-
1369
- $tokens = $phpcsFile->getTokens();
1370
-
1371
- // Check for the existence of the token.
1372
- if (isset($tokens[$stackPtr]) === false) {
1373
- return false;
1374
- }
1375
-
1376
- // Is this one of the tokens this function handles ?
1377
- if ($tokens[$stackPtr]['code'] !== \T_STRING) {
1378
- return false;
1379
- }
1380
-
1381
- // Check for older PHP, PHPCS version so we can compensate for misidentified tokens.
1382
- if (isset($isLowPHPCS, $isLowPHP) === false) {
1383
- $isLowPHP = false;
1384
- $isLowPHPCS = false;
1385
- if (version_compare(\PHP_VERSION_ID, '50400', '<')) {
1386
- $isLowPHP = true;
1387
- $isLowPHPCS = version_compare(PHPCSHelper::getVersion(), '2.4.0', '<');
1388
- }
1389
- }
1390
-
1391
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
1392
- if ($next !== false
1393
- && ($tokens[$next]['code'] === \T_OPEN_PARENTHESIS
1394
- || $tokens[$next]['code'] === \T_DOUBLE_COLON)
1395
- ) {
1396
- // Function call or declaration.
1397
- return false;
1398
- }
1399
-
1400
- // Array of tokens which if found preceding the $stackPtr indicate that a T_STRING is not a global constant.
1401
- $tokensToIgnore = array(
1402
- 'T_NAMESPACE' => true,
1403
- 'T_USE' => true,
1404
- 'T_CLASS' => true,
1405
- 'T_TRAIT' => true,
1406
- 'T_INTERFACE' => true,
1407
- 'T_EXTENDS' => true,
1408
- 'T_IMPLEMENTS' => true,
1409
- 'T_NEW' => true,
1410
- 'T_FUNCTION' => true,
1411
- 'T_DOUBLE_COLON' => true,
1412
- 'T_OBJECT_OPERATOR' => true,
1413
- 'T_INSTANCEOF' => true,
1414
- 'T_INSTEADOF' => true,
1415
- 'T_GOTO' => true,
1416
- 'T_AS' => true,
1417
- 'T_PUBLIC' => true,
1418
- 'T_PROTECTED' => true,
1419
- 'T_PRIVATE' => true,
1420
- );
1421
-
1422
- $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
1423
- if ($prev !== false
1424
- && (isset($tokensToIgnore[$tokens[$prev]['type']]) === true
1425
- || ($tokens[$prev]['code'] === \T_STRING
1426
- && (($isLowPHPCS === true
1427
- && $tokens[$prev]['content'] === 'trait')
1428
- || ($isLowPHP === true
1429
- && $tokens[$prev]['content'] === 'insteadof'))))
1430
- ) {
1431
- // Not the use of a constant.
1432
- return false;
1433
- }
1434
-
1435
- if ($prev !== false
1436
- && $tokens[$prev]['code'] === \T_NS_SEPARATOR
1437
- && $tokens[($prev - 1)]['code'] === \T_STRING
1438
- ) {
1439
- // Namespaced constant of the same name.
1440
- return false;
1441
- }
1442
-
1443
- if ($prev !== false
1444
- && $tokens[$prev]['code'] === \T_CONST
1445
- && $this->isClassConstant($phpcsFile, $prev) === true
1446
- ) {
1447
- // Class constant declaration of the same name.
1448
- return false;
1449
- }
1450
-
1451
- /*
1452
- * Deal with a number of variations of use statements.
1453
- */
1454
- for ($i = $stackPtr; $i > 0; $i--) {
1455
- if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) {
1456
- break;
1457
- }
1458
- }
1459
-
1460
- $firstOnLine = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
1461
- if ($firstOnLine !== false && $tokens[$firstOnLine]['code'] === \T_USE) {
1462
- $nextOnLine = $phpcsFile->findNext(Tokens::$emptyTokens, ($firstOnLine + 1), null, true);
1463
- if ($nextOnLine !== false) {
1464
- if (($tokens[$nextOnLine]['code'] === \T_STRING && $tokens[$nextOnLine]['content'] === 'const')
1465
- || $tokens[$nextOnLine]['code'] === \T_CONST // Happens in some PHPCS versions.
1466
- ) {
1467
- $hasNsSep = $phpcsFile->findNext(\T_NS_SEPARATOR, ($nextOnLine + 1), $stackPtr);
1468
- if ($hasNsSep !== false) {
1469
- // Namespaced const (group) use statement.
1470
- return false;
1471
- }
1472
- } else {
1473
- // Not a const use statement.
1474
- return false;
1475
- }
1476
- }
1477
- }
1478
-
1479
- return true;
1480
- }
1481
-
1482
-
1483
- /**
1484
- * Determine whether the tokens between $start and $end together form a positive number
1485
- * as recognized by PHP.
1486
- *
1487
- * The outcome of this function is reliable for `true`, `false` should be regarded as
1488
- * "undetermined".
1489
- *
1490
- * Note: Zero is *not* regarded as a positive number.
1491
- *
1492
- * @since 8.2.0
1493
- *
1494
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1495
- * @param int $start Start of the snippet (inclusive), i.e. this
1496
- * token will be examined as part of the snippet.
1497
- * @param int $end End of the snippet (inclusive), i.e. this
1498
- * token will be examined as part of the snippet.
1499
- * @param bool $allowFloats Whether to only consider integers, or also floats.
1500
- *
1501
- * @return bool True if PHP would evaluate the snippet as a positive number.
1502
- * False if not or if it could not be reliably determined
1503
- * (variable or calculations and such).
1504
- */
1505
- public function isPositiveNumber(File $phpcsFile, $start, $end, $allowFloats = false)
1506
- {
1507
- $number = $this->isNumber($phpcsFile, $start, $end, $allowFloats);
1508
-
1509
- if ($number === false) {
1510
- return false;
1511
- }
1512
-
1513
- return ($number > 0);
1514
- }
1515
-
1516
-
1517
- /**
1518
- * Determine whether the tokens between $start and $end together form a negative number
1519
- * as recognized by PHP.
1520
- *
1521
- * The outcome of this function is reliable for `true`, `false` should be regarded as
1522
- * "undetermined".
1523
- *
1524
- * Note: Zero is *not* regarded as a negative number.
1525
- *
1526
- * @since 8.2.0
1527
- *
1528
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1529
- * @param int $start Start of the snippet (inclusive), i.e. this
1530
- * token will be examined as part of the snippet.
1531
- * @param int $end End of the snippet (inclusive), i.e. this
1532
- * token will be examined as part of the snippet.
1533
- * @param bool $allowFloats Whether to only consider integers, or also floats.
1534
- *
1535
- * @return bool True if PHP would evaluate the snippet as a negative number.
1536
- * False if not or if it could not be reliably determined
1537
- * (variable or calculations and such).
1538
- */
1539
- public function isNegativeNumber(File $phpcsFile, $start, $end, $allowFloats = false)
1540
- {
1541
- $number = $this->isNumber($phpcsFile, $start, $end, $allowFloats);
1542
-
1543
- if ($number === false) {
1544
- return false;
1545
- }
1546
-
1547
- return ($number < 0);
1548
- }
1549
-
1550
- /**
1551
- * Determine whether the tokens between $start and $end together form a number
1552
- * as recognized by PHP.
1553
- *
1554
- * The outcome of this function is reliable for "true-ish" values, `false` should
1555
- * be regarded as "undetermined".
1556
- *
1557
- * @link https://3v4l.org/npTeM
1558
- *
1559
- * Mainly intended for examining variable assignments, function call parameters, array values
1560
- * where the start and end of the snippet to examine is very clear.
1561
- *
1562
- * @since 8.2.0
1563
- *
1564
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1565
- * @param int $start Start of the snippet (inclusive), i.e. this
1566
- * token will be examined as part of the snippet.
1567
- * @param int $end End of the snippet (inclusive), i.e. this
1568
- * token will be examined as part of the snippet.
1569
- * @param bool $allowFloats Whether to only consider integers, or also floats.
1570
- *
1571
- * @return int|float|bool The number found if PHP would evaluate the snippet as a number.
1572
- * The return type will be int if $allowFloats is false, if
1573
- * $allowFloats is true, the return type will be float.
1574
- * False will be returned when the snippet does not evaluate to a
1575
- * number or if it could not be reliably determined
1576
- * (variable or calculations and such).
1577
- */
1578
- protected function isNumber(File $phpcsFile, $start, $end, $allowFloats = false)
1579
- {
1580
- $stringTokens = Tokens::$heredocTokens + Tokens::$stringTokens;
1581
-
1582
- $validTokens = array();
1583
- $validTokens[\T_LNUMBER] = true;
1584
- $validTokens[\T_TRUE] = true; // Evaluates to int 1.
1585
- $validTokens[\T_FALSE] = true; // Evaluates to int 0.
1586
- $validTokens[\T_NULL] = true; // Evaluates to int 0.
1587
-
1588
- if ($allowFloats === true) {
1589
- $validTokens[\T_DNUMBER] = true;
1590
- }
1591
-
1592
- $maybeValidTokens = $stringTokens + $validTokens;
1593
-
1594
- $tokens = $phpcsFile->getTokens();
1595
- $searchEnd = ($end + 1);
1596
- $negativeNumber = false;
1597
-
1598
- if (isset($tokens[$start], $tokens[$searchEnd]) === false) {
1599
- return false;
1600
- }
1601
-
1602
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $start, $searchEnd, true);
1603
- while ($nextNonEmpty !== false
1604
- && ($tokens[$nextNonEmpty]['code'] === \T_PLUS
1605
- || $tokens[$nextNonEmpty]['code'] === \T_MINUS)
1606
- ) {
1607
-
1608
- if ($tokens[$nextNonEmpty]['code'] === \T_MINUS) {
1609
- $negativeNumber = ($negativeNumber === false) ? true : false;
1610
- }
1611
-
1612
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), $searchEnd, true);
1613
- }
1614
-
1615
- if ($nextNonEmpty === false || isset($maybeValidTokens[$tokens[$nextNonEmpty]['code']]) === false) {
1616
- return false;
1617
- }
1618
-
1619
- $content = false;
1620
- if ($tokens[$nextNonEmpty]['code'] === \T_LNUMBER
1621
- || $tokens[$nextNonEmpty]['code'] === \T_DNUMBER
1622
- ) {
1623
- $content = (float) $tokens[$nextNonEmpty]['content'];
1624
- } elseif ($tokens[$nextNonEmpty]['code'] === \T_TRUE) {
1625
- $content = 1.0;
1626
- } elseif ($tokens[$nextNonEmpty]['code'] === \T_FALSE
1627
- || $tokens[$nextNonEmpty]['code'] === \T_NULL
1628
- ) {
1629
- $content = 0.0;
1630
- } elseif (isset($stringTokens[$tokens[$nextNonEmpty]['code']]) === true) {
1631
-
1632
- if ($tokens[$nextNonEmpty]['code'] === \T_START_HEREDOC
1633
- || $tokens[$nextNonEmpty]['code'] === \T_START_NOWDOC
1634
- ) {
1635
- // Skip past heredoc/nowdoc opener to the first content.
1636
- $firstDocToken = $phpcsFile->findNext(array(\T_HEREDOC, \T_NOWDOC), ($nextNonEmpty + 1), $searchEnd);
1637
- if ($firstDocToken === false) {
1638
- // Live coding or parse error.
1639
- return false;
1640
- }
1641
-
1642
- $stringContent = $content = $tokens[$firstDocToken]['content'];
1643
-
1644
- // Skip forward to the end in preparation for the next part of the examination.
1645
- $nextNonEmpty = $phpcsFile->findNext(array(\T_END_HEREDOC, \T_END_NOWDOC), ($nextNonEmpty + 1), $searchEnd);
1646
- if ($nextNonEmpty === false) {
1647
- // Live coding or parse error.
1648
- return false;
1649
- }
1650
- } else {
1651
- // Gather subsequent lines for a multi-line string.
1652
- for ($i = $nextNonEmpty; $i < $searchEnd; $i++) {
1653
- if ($tokens[$i]['code'] !== $tokens[$nextNonEmpty]['code']) {
1654
- break;
1655
- }
1656
- $content .= $tokens[$i]['content'];
1657
- }
1658
-
1659
- $nextNonEmpty = --$i;
1660
- $content = $this->stripQuotes($content);
1661
- $stringContent = $content;
1662
- }
1663
-
1664
- /*
1665
- * Regexes based on the formats outlined in the manual, created by JRF.
1666
- * @link https://www.php.net/manual/en/language.types.float.php
1667
- */
1668
- $regexInt = '`^\s*[0-9]+`';
1669
- $regexFloat = '`^\s*(?:[+-]?(?:(?:(?P<LNUM>[0-9]+)|(?P<DNUM>([0-9]*\.(?P>LNUM)|(?P>LNUM)\.[0-9]*)))[eE][+-]?(?P>LNUM))|(?P>DNUM))`';
1670
-
1671
- $intString = preg_match($regexInt, $content, $intMatch);
1672
- $floatString = preg_match($regexFloat, $content, $floatMatch);
1673
-
1674
- // Does the text string start with a number ? If so, PHP would juggle it and use it as a number.
1675
- if ($allowFloats === false) {
1676
- if ($intString !== 1 || $floatString === 1) {
1677
- if ($floatString === 1) {
1678
- // Found float. Only integers targetted.
1679
- return false;
1680
- }
1681
-
1682
- $content = 0.0;
1683
- } else {
1684
- $content = (float) trim($intMatch[0]);
1685
- }
1686
- } else {
1687
- if ($intString !== 1 && $floatString !== 1) {
1688
- $content = 0.0;
1689
- } else {
1690
- $content = ($floatString === 1) ? (float) trim($floatMatch[0]) : (float) trim($intMatch[0]);
1691
- }
1692
- }
1693
-
1694
- // Allow for different behaviour for hex numeric strings between PHP 5 vs PHP 7.
1695
- if ($intString === 1 && trim($intMatch[0]) === '0'
1696
- && preg_match('`^\s*(0x[A-Fa-f0-9]+)`', $stringContent, $hexNumberString) === 1
1697
- && $this->supportsBelow('5.6') === true
1698
- ) {
1699
- // The filter extension still allows for hex numeric strings in PHP 7, so
1700
- // use that to get the numeric value if possible.
1701
- // If the filter extension is not available, the value will be zero, but so be it.
1702
- if (function_exists('filter_var')) {
1703
- $filtered = filter_var($hexNumberString[1], \FILTER_VALIDATE_INT, \FILTER_FLAG_ALLOW_HEX);
1704
- if ($filtered !== false) {
1705
- $content = $filtered;
1706
- }
1707
- }
1708
- }
1709
- }
1710
-
1711
- // OK, so we have a number, now is there still more code after it ?
1712
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), $searchEnd, true);
1713
- if ($nextNonEmpty !== false) {
1714
- return false;
1715
- }
1716
-
1717
- if ($negativeNumber === true) {
1718
- $content = -$content;
1719
- }
1720
-
1721
- if ($allowFloats === false) {
1722
- return (int) $content;
1723
- }
1724
-
1725
- return $content;
1726
- }
1727
-
1728
-
1729
- /**
1730
- * Determine whether the tokens between $start and $end together form a numberic calculation
1731
- * as recognized by PHP.
1732
- *
1733
- * The outcome of this function is reliable for `true`, `false` should be regarded as "undetermined".
1734
- *
1735
- * Mainly intended for examining variable assignments, function call parameters, array values
1736
- * where the start and end of the snippet to examine is very clear.
1737
- *
1738
- * @since 9.0.0
1739
- *
1740
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1741
- * @param int $start Start of the snippet (inclusive), i.e. this
1742
- * token will be examined as part of the snippet.
1743
- * @param int $end End of the snippet (inclusive), i.e. this
1744
- * token will be examined as part of the snippet.
1745
- *
1746
- * @return bool
1747
- */
1748
- protected function isNumericCalculation(File $phpcsFile, $start, $end)
1749
- {
1750
- $arithmeticTokens = Tokens::$arithmeticTokens;
1751
-
1752
- // phpcs:disable PHPCompatibility.Constants.NewConstants.t_powFound
1753
- if (\defined('T_POW') && isset($arithmeticTokens[\T_POW]) === false) {
1754
- // T_POW was not added to the arithmetic array until PHPCS 2.9.0.
1755
- $arithmeticTokens[\T_POW] = \T_POW;
1756
- }
1757
- // phpcs:enable
1758
-
1759
- $skipTokens = Tokens::$emptyTokens;
1760
- $skipTokens[] = \T_MINUS;
1761
- $skipTokens[] = \T_PLUS;
1762
-
1763
- // Find the first arithmetic operator, but skip past +/- signs before numbers.
1764
- $nextNonEmpty = ($start - 1);
1765
- do {
1766
- $nextNonEmpty = $phpcsFile->findNext($skipTokens, ($nextNonEmpty + 1), ($end + 1), true);
1767
- $arithmeticOperator = $phpcsFile->findNext($arithmeticTokens, ($nextNonEmpty + 1), ($end + 1));
1768
- } while ($nextNonEmpty !== false && $arithmeticOperator !== false && $nextNonEmpty === $arithmeticOperator);
1769
-
1770
- if ($arithmeticOperator === false) {
1771
- return false;
1772
- }
1773
-
1774
- $tokens = $phpcsFile->getTokens();
1775
- $subsetStart = $start;
1776
- $subsetEnd = ($arithmeticOperator - 1);
1777
-
1778
- while ($this->isNumber($phpcsFile, $subsetStart, $subsetEnd, true) !== false
1779
- && isset($tokens[($arithmeticOperator + 1)]) === true
1780
- ) {
1781
- // Recognize T_POW for PHPCS < 2.4.0 on low PHP versions.
1782
- if (\defined('T_POW') === false
1783
- && $tokens[$arithmeticOperator]['code'] === \T_MULTIPLY
1784
- && $tokens[($arithmeticOperator + 1)]['code'] === \T_MULTIPLY
1785
- && isset($tokens[$arithmeticOperator + 2]) === true
1786
- ) {
1787
- // Move operator one forward to the second * in T_POW.
1788
- ++$arithmeticOperator;
1789
- }
1790
-
1791
- $subsetStart = ($arithmeticOperator + 1);
1792
- $nextNonEmpty = $arithmeticOperator;
1793
- do {
1794
- $nextNonEmpty = $phpcsFile->findNext($skipTokens, ($nextNonEmpty + 1), ($end + 1), true);
1795
- $arithmeticOperator = $phpcsFile->findNext($arithmeticTokens, ($nextNonEmpty + 1), ($end + 1));
1796
- } while ($nextNonEmpty !== false && $arithmeticOperator !== false && $nextNonEmpty === $arithmeticOperator);
1797
-
1798
- if ($arithmeticOperator === false) {
1799
- // Last calculation operator already reached.
1800
- if ($this->isNumber($phpcsFile, $subsetStart, $end, true) !== false) {
1801
- return true;
1802
- }
1803
-
1804
- return false;
1805
- }
1806
-
1807
- $subsetEnd = ($arithmeticOperator - 1);
1808
- }
1809
-
1810
- return false;
1811
- }
1812
-
1813
-
1814
-
1815
- /**
1816
- * Determine whether a ternary is a short ternary, i.e. without "middle".
1817
- *
1818
- * N.B.: This is a back-fill for a new method which is expected to go into
1819
- * PHP_CodeSniffer 3.5.0.
1820
- * Once that method has been merged into PHPCS, this one should be moved
1821
- * to the PHPCSHelper.php file.
1822
- *
1823
- * @since 9.2.0
1824
- *
1825
- * @codeCoverageIgnore Method as pulled upstream is accompanied by unit tests.
1826
- *
1827
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1828
- * @param int $stackPtr The position of the ternary operator
1829
- * in the stack.
1830
- *
1831
- * @return bool True if short ternary, or false otherwise.
1832
- */
1833
- public function isShortTernary(File $phpcsFile, $stackPtr)
1834
- {
1835
- $tokens = $phpcsFile->getTokens();
1836
- if (isset($tokens[$stackPtr]) === false
1837
- || $tokens[$stackPtr]['code'] !== \T_INLINE_THEN
1838
- ) {
1839
- return false;
1840
- }
1841
-
1842
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
1843
- if ($nextNonEmpty === false) {
1844
- // Live coding or parse error.
1845
- return false;
1846
- }
1847
-
1848
- if ($tokens[$nextNonEmpty]['code'] === \T_INLINE_ELSE) {
1849
- return true;
1850
- }
1851
-
1852
- return false;
1853
- }
1854
-
1855
-
1856
- /**
1857
- * Determine whether a T_OPEN/CLOSE_SHORT_ARRAY token is a list() construct.
1858
- *
1859
- * Note: A variety of PHPCS versions have bugs in the tokenizing of short arrays.
1860
- * In that case, the tokens are identified as T_OPEN/CLOSE_SQUARE_BRACKET.
1861
- *
1862
- * @since 8.2.0
1863
- *
1864
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1865
- * @param int $stackPtr The position of the function call token.
1866
- *
1867
- * @return bool
1868
- */
1869
- public function isShortList(File $phpcsFile, $stackPtr)
1870
- {
1871
- $tokens = $phpcsFile->getTokens();
1872
-
1873
- // Check for the existence of the token.
1874
- if (isset($tokens[$stackPtr]) === false) {
1875
- return false;
1876
- }
1877
-
1878
- // Is this one of the tokens this function handles ?
1879
- if ($tokens[$stackPtr]['code'] !== \T_OPEN_SHORT_ARRAY
1880
- && $tokens[$stackPtr]['code'] !== \T_CLOSE_SHORT_ARRAY
1881
- ) {
1882
- return false;
1883
- }
1884
-
1885
- switch ($tokens[$stackPtr]['code']) {
1886
- case \T_OPEN_SHORT_ARRAY:
1887
- if (isset($tokens[$stackPtr]['bracket_closer']) === true) {
1888
- $opener = $stackPtr;
1889
- $closer = $tokens[$stackPtr]['bracket_closer'];
1890
- }
1891
- break;
1892
-
1893
- case \T_CLOSE_SHORT_ARRAY:
1894
- if (isset($tokens[$stackPtr]['bracket_opener']) === true) {
1895
- $opener = $tokens[$stackPtr]['bracket_opener'];
1896
- $closer = $stackPtr;
1897
- }
1898
- break;
1899
- }
1900
-
1901
- if (isset($opener, $closer) === false) {
1902
- // Parse error, live coding or real square bracket.
1903
- return false;
1904
- }
1905
-
1906
- /*
1907
- * PHPCS cross-version compatibility: work around for square brackets misidentified
1908
- * as short array when preceded by a variable variable in older PHPCS versions.
1909
- */
1910
- $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true, null, true);
1911
-
1912
- if ($prevNonEmpty !== false
1913
- && $tokens[$prevNonEmpty]['code'] === \T_CLOSE_CURLY_BRACKET
1914
- && isset($tokens[$prevNonEmpty]['bracket_opener']) === true
1915
- ) {
1916
- $maybeVariableVariable = $phpcsFile->findPrevious(
1917
- Tokens::$emptyTokens,
1918
- ($tokens[$prevNonEmpty]['bracket_opener'] - 1),
1919
- null,
1920
- true,
1921
- null,
1922
- true
1923
- );
1924
-
1925
- if ($tokens[$maybeVariableVariable]['code'] === \T_VARIABLE
1926
- || $tokens[$maybeVariableVariable]['code'] === \T_DOLLAR
1927
- ) {
1928
- return false;
1929
- }
1930
- }
1931
-
1932
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($closer + 1), null, true, null, true);
1933
-
1934
- if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === \T_EQUAL) {
1935
- return true;
1936
- }
1937
-
1938
- if ($prevNonEmpty !== false
1939
- && $tokens[$prevNonEmpty]['code'] === \T_AS
1940
- && isset($tokens[$prevNonEmpty]['nested_parenthesis']) === true
1941
- ) {
1942
- $parentheses = array_reverse($tokens[$prevNonEmpty]['nested_parenthesis'], true);
1943
- foreach ($parentheses as $open => $close) {
1944
- if (isset($tokens[$open]['parenthesis_owner'])
1945
- && $tokens[$tokens[$open]['parenthesis_owner']]['code'] === \T_FOREACH
1946
- ) {
1947
- return true;
1948
- }
1949
- }
1950
- }
1951
-
1952
- // Maybe this is a short list syntax nested inside another short list syntax ?
1953
- $parentOpener = $opener;
1954
- do {
1955
- $parentOpener = $phpcsFile->findPrevious(
1956
- array(\T_OPEN_SHORT_ARRAY, \T_OPEN_SQUARE_BRACKET),
1957
- ($parentOpener - 1),
1958
- null,
1959
- false,
1960
- null,
1961
- true
1962
- );
1963
-
1964
- if ($parentOpener === false) {
1965
- return false;
1966
- }
1967
-
1968
- } while (isset($tokens[$parentOpener]['bracket_closer']) === true
1969
- && $tokens[$parentOpener]['bracket_closer'] < $opener
1970
- );
1971
-
1972
- if (isset($tokens[$parentOpener]['bracket_closer']) === true
1973
- && $tokens[$parentOpener]['bracket_closer'] > $closer
1974
- ) {
1975
- // Work around tokenizer issue in PHPCS 2.0 - 2.7.
1976
- $phpcsVersion = PHPCSHelper::getVersion();
1977
- if ((version_compare($phpcsVersion, '2.0', '>') === true
1978
- && version_compare($phpcsVersion, '2.8', '<') === true)
1979
- && $tokens[$parentOpener]['code'] === \T_OPEN_SQUARE_BRACKET
1980
- ) {
1981
- $nextNonEmpty = $phpcsFile->findNext(
1982
- Tokens::$emptyTokens,
1983
- ($tokens[$parentOpener]['bracket_closer'] + 1),
1984
- null,
1985
- true,
1986
- null,
1987
- true
1988
- );
1989
-
1990
- if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === \T_EQUAL) {
1991
- return true;
1992
- }
1993
-
1994
- return false;
1995
- }
1996
-
1997
- return $this->isShortList($phpcsFile, $parentOpener);
1998
- }
1999
-
2000
- return false;
2001
- }
2002
-
2003
-
2004
- /**
2005
- * Determine whether the tokens between $start and $end could together represent a variable.
2006
- *
2007
- * @since 9.0.0
2008
- *
2009
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
2010
- * @param int $start Starting point stack pointer. Inclusive.
2011
- * I.e. this token should be taken into account.
2012
- * @param int $end End point stack pointer. Exclusive.
2013
- * I.e. this token should not be taken into account.
2014
- * @param int $targetNestingLevel The nesting level the variable should be at.
2015
- *
2016
- * @return bool
2017
- */
2018
- public function isVariable(File $phpcsFile, $start, $end, $targetNestingLevel)
2019
- {
2020
- static $tokenBlackList, $bracketTokens;
2021
-
2022
- // Create the token arrays only once.
2023
- if (isset($tokenBlackList, $bracketTokens) === false) {
2024
-
2025
- $tokenBlackList = array(
2026
- \T_OPEN_PARENTHESIS => \T_OPEN_PARENTHESIS,
2027
- \T_STRING_CONCAT => \T_STRING_CONCAT,
2028
- );
2029
- $tokenBlackList += Tokens::$assignmentTokens;
2030
- $tokenBlackList += Tokens::$equalityTokens;
2031
- $tokenBlackList += Tokens::$comparisonTokens;
2032
- $tokenBlackList += Tokens::$operators;
2033
- $tokenBlackList += Tokens::$booleanOperators;
2034
- $tokenBlackList += Tokens::$castTokens;
2035
-
2036
- /*
2037
- * List of brackets which can be part of a variable variable.
2038
- *
2039
- * Key is the open bracket token, value the close bracket token.
2040
- */
2041
- $bracketTokens = array(
2042
- \T_OPEN_CURLY_BRACKET => \T_CLOSE_CURLY_BRACKET,
2043
- \T_OPEN_SQUARE_BRACKET => \T_CLOSE_SQUARE_BRACKET,
2044
- );
2045
- }
2046
-
2047
- $tokens = $phpcsFile->getTokens();
2048
-
2049
- // If no variable at all was found, then it's definitely a no-no.
2050
- $hasVariable = $phpcsFile->findNext(\T_VARIABLE, $start, $end);
2051
- if ($hasVariable === false) {
2052
- return false;
2053
- }
2054
-
2055
- // Check if the variable found is at the right level. Deeper levels are always an error.
2056
- if (isset($tokens[$hasVariable]['nested_parenthesis'])
2057
- && \count($tokens[$hasVariable]['nested_parenthesis']) !== $targetNestingLevel
2058
- ) {
2059
- return false;
2060
- }
2061
-
2062
- // Ok, so the first variable is at the right level, now are there any
2063
- // blacklisted tokens within the empty() ?
2064
- $hasBadToken = $phpcsFile->findNext($tokenBlackList, $start, $end);
2065
- if ($hasBadToken === false) {
2066
- return true;
2067
- }
2068
-
2069
- // If there are also bracket tokens, the blacklisted token might be part of a variable
2070
- // variable, but if there are no bracket tokens, we know we have an error.
2071
- $hasBrackets = $phpcsFile->findNext($bracketTokens, $start, $end);
2072
- if ($hasBrackets === false) {
2073
- return false;
2074
- }
2075
-
2076
- // Ok, we have both a blacklisted token as well as brackets, so we need to walk
2077
- // the tokens of the variable variable.
2078
- for ($i = $start; $i < $end; $i++) {
2079
- // If this is a bracket token, skip to the end of the bracketed expression.
2080
- if (isset($bracketTokens[$tokens[$i]['code']], $tokens[$i]['bracket_closer'])) {
2081
- $i = $tokens[$i]['bracket_closer'];
2082
- continue;
2083
- }
2084
-
2085
- // If it's a blacklisted token, not within brackets, we have an error.
2086
- if (isset($tokenBlackList[$tokens[$i]['code']])) {
2087
- return false;
2088
- }
2089
- }
2090
-
2091
- return true;
2092
- }
2093
-
2094
- /**
2095
- * Determine whether a T_MINUS/T_PLUS token is a unary operator.
2096
- *
2097
- * N.B.: This is a back-fill for a new method which is expected to go into
2098
- * PHP_CodeSniffer 3.5.0.
2099
- * Once that method has been merged into PHPCS, this one should be moved
2100
- * to the PHPCSHelper.php file.
2101
- *
2102
- * @since 9.2.0
2103
- *
2104
- * @codeCoverageIgnore Method as pulled upstream is accompanied by unit tests.
2105
- *
2106
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
2107
- * @param int $stackPtr The position of the plus/minus token.
2108
- *
2109
- * @return bool True if the token passed is a unary operator.
2110
- * False otherwise or if the token is not a T_PLUS/T_MINUS token.
2111
- */
2112
- public static function isUnaryPlusMinus(File $phpcsFile, $stackPtr)
2113
- {
2114
- $tokens = $phpcsFile->getTokens();
2115
-
2116
- if (isset($tokens[$stackPtr]) === false
2117
- || ($tokens[$stackPtr]['code'] !== \T_PLUS
2118
- && $tokens[$stackPtr]['code'] !== \T_MINUS)
2119
- ) {
2120
- return false;
2121
- }
2122
-
2123
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
2124
- if ($next === false) {
2125
- // Live coding or parse error.
2126
- return false;
2127
- }
2128
-
2129
- if (isset(Tokens::$operators[$tokens[$next]['code']]) === true) {
2130
- // Next token is an operator, so this is not a unary.
2131
- return false;
2132
- }
2133
-
2134
- $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
2135
-
2136
- if ($tokens[$prev]['code'] === \T_RETURN) {
2137
- // Just returning a positive/negative value; eg. (return -1).
2138
- return true;
2139
- }
2140
-
2141
- if (isset(Tokens::$operators[$tokens[$prev]['code']]) === true) {
2142
- // Just trying to operate on a positive/negative value; eg. ($var * -1).
2143
- return true;
2144
- }
2145
-
2146
- if (isset(Tokens::$comparisonTokens[$tokens[$prev]['code']]) === true) {
2147
- // Just trying to compare a positive/negative value; eg. ($var === -1).
2148
- return true;
2149
- }
2150
-
2151
- if (isset(Tokens::$booleanOperators[$tokens[$prev]['code']]) === true) {
2152
- // Just trying to compare a positive/negative value; eg. ($var || -1 === $b).
2153
- return true;
2154
- }
2155
-
2156
- if (isset(Tokens::$assignmentTokens[$tokens[$prev]['code']]) === true) {
2157
- // Just trying to assign a positive/negative value; eg. ($var = -1).
2158
- return true;
2159
- }
2160
-
2161
- if (isset(Tokens::$castTokens[$tokens[$prev]['code']]) === true) {
2162
- // Just casting a positive/negative value; eg. (string) -$var.
2163
- return true;
2164
- }
2165
-
2166
- // Other indicators that a plus/minus sign is a unary operator.
2167
- $invalidTokens = array(
2168
- \T_COMMA => true,
2169
- \T_OPEN_PARENTHESIS => true,
2170
- \T_OPEN_SQUARE_BRACKET => true,
2171
- \T_OPEN_SHORT_ARRAY => true,
2172
- \T_COLON => true,
2173
- \T_INLINE_THEN => true,
2174
- \T_INLINE_ELSE => true,
2175
- \T_CASE => true,
2176
- \T_OPEN_CURLY_BRACKET => true,
2177
- \T_STRING_CONCAT => true,
2178
- );
2179
-
2180
- if (isset($invalidTokens[$tokens[$prev]['code']]) === true) {
2181
- // Just trying to use a positive/negative value; eg. myFunction($var, -2).
2182
- return true;
2183
- }
2184
-
2185
- return false;
2186
- }
2187
-
2188
- /**
2189
- * Get the complete contents of a multi-line text string.
2190
- *
2191
- * N.B.: This is a back-fill for a new method which is expected to go into
2192
- * PHP_CodeSniffer 3.5.0.
2193
- * Once that method has been merged into PHPCS, this one should be moved
2194
- * to the PHPCSHelper.php file.
2195
- *
2196
- * @since 9.3.0
2197
- *
2198
- * @codeCoverageIgnore Method as pulled upstream is accompanied by unit tests.
2199
- *
2200
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
2201
- * @param int $stackPtr Pointer to the first text string token
2202
- * of a multi-line text string or to a
2203
- * Nowdoc/Heredoc opener.
2204
- * @param bool $stripQuotes Optional. Whether to strip text delimiter
2205
- * quotes off the resulting text string.
2206
- * Defaults to true.
2207
- *
2208
- * @return string
2209
- *
2210
- * @throws \PHP_CodeSniffer_Exception If the specified position is not a
2211
- * valid text string token or if the
2212
- * token is not the first text string token.
2213
- */
2214
- public function getCompleteTextString(File $phpcsFile, $stackPtr, $stripQuotes = true)
2215
- {
2216
- $tokens = $phpcsFile->getTokens();
2217
-
2218
- // Must be the start of a text string token.
2219
- if ($tokens[$stackPtr]['code'] !== \T_START_HEREDOC
2220
- && $tokens[$stackPtr]['code'] !== \T_START_NOWDOC
2221
- && $tokens[$stackPtr]['code'] !== \T_CONSTANT_ENCAPSED_STRING
2222
- && $tokens[$stackPtr]['code'] !== \T_DOUBLE_QUOTED_STRING
2223
- ) {
2224
- throw new PHPCS_Exception('$stackPtr must be of type T_START_HEREDOC, T_START_NOWDOC, T_CONSTANT_ENCAPSED_STRING or T_DOUBLE_QUOTED_STRING');
2225
- }
2226
-
2227
- if ($tokens[$stackPtr]['code'] === \T_CONSTANT_ENCAPSED_STRING
2228
- || $tokens[$stackPtr]['code'] === \T_DOUBLE_QUOTED_STRING
2229
- ) {
2230
- $prev = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
2231
- if ($tokens[$stackPtr]['code'] === $tokens[$prev]['code']) {
2232
- throw new PHPCS_Exception('$stackPtr must be the start of the text string');
2233
- }
2234
- }
2235
-
2236
- switch ($tokens[$stackPtr]['code']) {
2237
- case \T_START_HEREDOC:
2238
- $stripQuotes = false;
2239
- $targetType = \T_HEREDOC;
2240
- $current = ($stackPtr + 1);
2241
- break;
2242
-
2243
- case \T_START_NOWDOC:
2244
- $stripQuotes = false;
2245
- $targetType = \T_NOWDOC;
2246
- $current = ($stackPtr + 1);
2247
- break;
2248
-
2249
- default:
2250
- $targetType = $tokens[$stackPtr]['code'];
2251
- $current = $stackPtr;
2252
- break;
2253
- }
2254
-
2255
- $string = '';
2256
- do {
2257
- $string .= $tokens[$current]['content'];
2258
- ++$current;
2259
- } while ($tokens[$current]['code'] === $targetType);
2260
-
2261
- if ($stripQuotes === true) {
2262
- return $this->stripQuotes($string);
2263
- }
2264
-
2265
- return $string;
2266
- }
2267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/ForbiddenAbstractPrivateMethodsSniff.php DELETED
@@ -1,90 +0,0 @@
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
- * PHP version 5.1
24
- *
25
- * @link https://www.php.net/manual/en/migration51.oop.php#migration51.oop-methods
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/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewAnonymousClassesSniff.php DELETED
@@ -1,91 +0,0 @@
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
- * Anonymous classes are supported since PHP 7.0.
19
- *
20
- * PHP version 7.0
21
- *
22
- * @link https://www.php.net/manual/en/language.oop5.anonymous.php
23
- * @link https://wiki.php.net/rfc/anonymous_classes
24
- *
25
- * @since 7.0.0
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
- * @since 7.1.2
37
- *
38
- * @var array
39
- */
40
- private $indicators = array(
41
- \T_CLASS => \T_CLASS,
42
- );
43
-
44
- /**
45
- * Returns an array of tokens this test wants to listen for.
46
- *
47
- * @since 7.0.0
48
- *
49
- * @return array
50
- */
51
- public function register()
52
- {
53
- if (\defined('T_ANON_CLASS')) {
54
- $this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
55
- }
56
-
57
- return array(\T_NEW);
58
- }
59
-
60
-
61
- /**
62
- * Processes this test, when one of its tokens is encountered.
63
- *
64
- * @since 7.0.0
65
- *
66
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
67
- * @param int $stackPtr The position of the current token in the
68
- * stack passed in $tokens.
69
- *
70
- * @return void
71
- */
72
- public function process(File $phpcsFile, $stackPtr)
73
- {
74
- if ($this->supportsBelow('5.6') === false) {
75
- return;
76
- }
77
-
78
- $tokens = $phpcsFile->getTokens();
79
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
80
- if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
81
- return;
82
- }
83
-
84
- // Still here ? In that case, it is an anonymous class.
85
- $phpcsFile->addError(
86
- 'Anonymous classes are not supported in PHP 5.6 or earlier',
87
- $stackPtr,
88
- 'Found'
89
- );
90
- }
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php DELETED
@@ -1,913 +0,0 @@
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\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect use of new PHP native classes.
18
- *
19
- * The sniff analyses the following constructs to find usage of new classes:
20
- * - Class instantiation using the `new` keyword.
21
- * - (Anonymous) Class declarations to detect new classes being extended by userland classes.
22
- * - Static use of class properties, constants or functions using the double colon.
23
- * - Function/closure declarations to detect new classes used as parameter type declarations.
24
- * - Function/closure declarations to detect new classes used as return type declarations.
25
- * - Try/catch statements to detect new exception classes being caught.
26
- *
27
- * PHP version All
28
- *
29
- * @since 5.5
30
- * @since 5.6 Now extends the base `Sniff` class.
31
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` class.
32
- */
33
- class NewClassesSniff extends AbstractNewFeatureSniff
34
- {
35
-
36
- /**
37
- * A list of new classes, not present in older versions.
38
- *
39
- * The array lists : version number with false (not present) or true (present).
40
- * If's sufficient to list the first version where the class appears.
41
- *
42
- * @since 5.5
43
- *
44
- * @var array(string => array(string => bool))
45
- */
46
- protected $newClasses = array(
47
- 'ArrayObject' => array(
48
- '4.4' => false,
49
- '5.0' => true,
50
- ),
51
- 'ArrayIterator' => array(
52
- '4.4' => false,
53
- '5.0' => true,
54
- ),
55
- 'CachingIterator' => array(
56
- '4.4' => false,
57
- '5.0' => true,
58
- ),
59
- 'DirectoryIterator' => array(
60
- '4.4' => false,
61
- '5.0' => true,
62
- ),
63
- 'RecursiveDirectoryIterator' => array(
64
- '4.4' => false,
65
- '5.0' => true,
66
- ),
67
- 'RecursiveIteratorIterator' => array(
68
- '4.4' => false,
69
- '5.0' => true,
70
- ),
71
- 'php_user_filter' => array(
72
- '4.4' => false,
73
- '5.0' => true,
74
- ),
75
- 'tidy' => array(
76
- '4.4' => false,
77
- '5.0' => true,
78
- ),
79
-
80
- 'SimpleXMLElement' => array(
81
- '5.0.0' => false,
82
- '5.0.1' => true,
83
- ),
84
- 'tidyNode' => array(
85
- '5.0.0' => false,
86
- '5.0.1' => true,
87
- ),
88
-
89
- 'libXMLError' => array(
90
- '5.0' => false,
91
- '5.1' => true,
92
- ),
93
- 'PDO' => array(
94
- '5.0' => false,
95
- '5.1' => true,
96
- ),
97
- 'PDOStatement' => array(
98
- '5.0' => false,
99
- '5.1' => true,
100
- ),
101
- 'AppendIterator' => array(
102
- '5.0' => false,
103
- '5.1' => true,
104
- ),
105
- 'EmptyIterator' => array(
106
- '5.0' => false,
107
- '5.1' => true,
108
- ),
109
- 'FilterIterator' => array(
110
- '5.0' => false,
111
- '5.1' => true,
112
- ),
113
- 'InfiniteIterator' => array(
114
- '5.0' => false,
115
- '5.1' => true,
116
- ),
117
- 'IteratorIterator' => array(
118
- '5.0' => false,
119
- '5.1' => true,
120
- ),
121
- 'LimitIterator' => array(
122
- '5.0' => false,
123
- '5.1' => true,
124
- ),
125
- 'NoRewindIterator' => array(
126
- '5.0' => false,
127
- '5.1' => true,
128
- ),
129
- 'ParentIterator' => array(
130
- '5.0' => false,
131
- '5.1' => true,
132
- ),
133
- 'RecursiveArrayIterator' => array(
134
- '5.0' => false,
135
- '5.1' => true,
136
- ),
137
- 'RecursiveCachingIterator' => array(
138
- '5.0' => false,
139
- '5.1' => true,
140
- ),
141
- 'RecursiveFilterIterator' => array(
142
- '5.0' => false,
143
- '5.1' => true,
144
- ),
145
- 'SimpleXMLIterator' => array(
146
- '5.0' => false,
147
- '5.1' => true,
148
- ),
149
- 'SplFileObject' => array(
150
- '5.0' => false,
151
- '5.1' => true,
152
- ),
153
- 'XMLReader' => array(
154
- '5.0' => false,
155
- '5.1' => true,
156
- ),
157
-
158
- 'SplFileInfo' => array(
159
- '5.1.1' => false,
160
- '5.1.2' => true,
161
- ),
162
- 'SplTempFileObject' => array(
163
- '5.1.1' => false,
164
- '5.1.2' => true,
165
- ),
166
- 'XMLWriter' => array(
167
- '5.1.1' => false,
168
- '5.1.2' => true,
169
- ),
170
-
171
- 'DateTime' => array(
172
- '5.1' => false,
173
- '5.2' => true,
174
- ),
175
- 'DateTimeZone' => array(
176
- '5.1' => false,
177
- '5.2' => true,
178
- ),
179
- 'RegexIterator' => array(
180
- '5.1' => false,
181
- '5.2' => true,
182
- ),
183
- 'RecursiveRegexIterator' => array(
184
- '5.1' => false,
185
- '5.2' => true,
186
- ),
187
- 'ReflectionFunctionAbstract' => array(
188
- '5.1' => false,
189
- '5.2' => true,
190
- ),
191
- 'ZipArchive' => array(
192
- '5.1' => false,
193
- '5.2' => true,
194
- ),
195
-
196
- 'Closure' => array(
197
- '5.2' => false,
198
- '5.3' => true,
199
- ),
200
- 'DateInterval' => array(
201
- '5.2' => false,
202
- '5.3' => true,
203
- ),
204
- 'DatePeriod' => array(
205
- '5.2' => false,
206
- '5.3' => true,
207
- ),
208
- 'finfo' => array(
209
- '5.2' => false,
210
- '5.3' => true,
211
- ),
212
- 'Collator' => array(
213
- '5.2' => false,
214
- '5.3' => true,
215
- ),
216
- 'NumberFormatter' => array(
217
- '5.2' => false,
218
- '5.3' => true,
219
- ),
220
- 'Locale' => array(
221
- '5.2' => false,
222
- '5.3' => true,
223
- ),
224
- 'Normalizer' => array(
225
- '5.2' => false,
226
- '5.3' => true,
227
- ),
228
- 'MessageFormatter' => array(
229
- '5.2' => false,
230
- '5.3' => true,
231
- ),
232
- 'IntlDateFormatter' => array(
233
- '5.2' => false,
234
- '5.3' => true,
235
- ),
236
- 'Phar' => array(
237
- '5.2' => false,
238
- '5.3' => true,
239
- ),
240
- 'PharData' => array(
241
- '5.2' => false,
242
- '5.3' => true,
243
- ),
244
- 'PharFileInfo' => array(
245
- '5.2' => false,
246
- '5.3' => true,
247
- ),
248
- 'FilesystemIterator' => array(
249
- '5.2' => false,
250
- '5.3' => true,
251
- ),
252
- 'GlobIterator' => array(
253
- '5.2' => false,
254
- '5.3' => true,
255
- ),
256
- 'MultipleIterator' => array(
257
- '5.2' => false,
258
- '5.3' => true,
259
- ),
260
- 'RecursiveTreeIterator' => array(
261
- '5.2' => false,
262
- '5.3' => true,
263
- ),
264
- 'SplDoublyLinkedList' => array(
265
- '5.2' => false,
266
- '5.3' => true,
267
- ),
268
- 'SplFixedArray' => array(
269
- '5.2' => false,
270
- '5.3' => true,
271
- ),
272
- 'SplHeap' => array(
273
- '5.2' => false,
274
- '5.3' => true,
275
- ),
276
- 'SplMaxHeap' => array(
277
- '5.2' => false,
278
- '5.3' => true,
279
- ),
280
- 'SplMinHeap' => array(
281
- '5.2' => false,
282
- '5.3' => true,
283
- ),
284
- 'SplObjectStorage' => array(
285
- '5.2' => false,
286
- '5.3' => true,
287
- ),
288
- 'SplPriorityQueue' => array(
289
- '5.2' => false,
290
- '5.3' => true,
291
- ),
292
- 'SplQueue' => array(
293
- '5.2' => false,
294
- '5.3' => true,
295
- ),
296
- 'SplStack' => array(
297
- '5.2' => false,
298
- '5.3' => true,
299
- ),
300
-
301
- 'ResourceBundle' => array(
302
- '5.3.1' => false,
303
- '5.3.2' => true,
304
- ),
305
-
306
- 'CallbackFilterIterator' => array(
307
- '5.3' => false,
308
- '5.4' => true,
309
- ),
310
- 'RecursiveCallbackFilterIterator' => array(
311
- '5.3' => false,
312
- '5.4' => true,
313
- ),
314
- 'ReflectionZendExtension' => array(
315
- '5.3' => false,
316
- '5.4' => true,
317
- ),
318
- 'SessionHandler' => array(
319
- '5.3' => false,
320
- '5.4' => true,
321
- ),
322
- 'SNMP' => array(
323
- '5.3' => false,
324
- '5.4' => true,
325
- ),
326
- 'Transliterator' => array(
327
- '5.3' => false,
328
- '5.4' => true,
329
- ),
330
- 'Spoofchecker' => array(
331
- '5.3' => false,
332
- '5.4' => true,
333
- ),
334
-
335
- 'Generator' => array(
336
- '5.4' => false,
337
- '5.5' => true,
338
- ),
339
- 'CURLFile' => array(
340
- '5.4' => false,
341
- '5.5' => true,
342
- ),
343
- 'DateTimeImmutable' => array(
344
- '5.4' => false,
345
- '5.5' => true,
346
- ),
347
- 'IntlCalendar' => array(
348
- '5.4' => false,
349
- '5.5' => true,
350
- ),
351
- 'IntlGregorianCalendar' => array(
352
- '5.4' => false,
353
- '5.5' => true,
354
- ),
355
- 'IntlTimeZone' => array(
356
- '5.4' => false,
357
- '5.5' => true,
358
- ),
359
- 'IntlBreakIterator' => array(
360
- '5.4' => false,
361
- '5.5' => true,
362
- ),
363
- 'IntlRuleBasedBreakIterator' => array(
364
- '5.4' => false,
365
- '5.5' => true,
366
- ),
367
- 'IntlCodePointBreakIterator' => array(
368
- '5.4' => false,
369
- '5.5' => true,
370
- ),
371
- 'UConverter' => array(
372
- '5.4' => false,
373
- '5.5' => true,
374
- ),
375
-
376
- 'GMP' => array(
377
- '5.5' => false,
378
- '5.6' => true,
379
- ),
380
-
381
- 'IntlChar' => array(
382
- '5.6' => false,
383
- '7.0' => true,
384
- ),
385
- 'ReflectionType' => array(
386
- '5.6' => false,
387
- '7.0' => true,
388
- ),
389
- 'ReflectionGenerator' => array(
390
- '5.6' => false,
391
- '7.0' => true,
392
- ),
393
-
394
- 'ReflectionClassConstant' => array(
395
- '7.0' => false,
396
- '7.1' => true,
397
- ),
398
-
399
- 'FFI' => array(
400
- '7.3' => false,
401
- '7.4' => true,
402
- ),
403
- 'FFI\CData' => array(
404
- '7.3' => false,
405
- '7.4' => true,
406
- ),
407
- 'FFI\CType' => array(
408
- '7.3' => false,
409
- '7.4' => true,
410
- ),
411
- 'ReflectionReference' => array(
412
- '7.3' => false,
413
- '7.4' => true,
414
- ),
415
- 'WeakReference' => array(
416
- '7.3' => false,
417
- '7.4' => true,
418
- ),
419
- );
420
-
421
- /**
422
- * A list of new Exception classes, not present in older versions.
423
- *
424
- * The array lists : version number with false (not present) or true (present).
425
- * If's sufficient to list the first version where the class appears.
426
- *
427
- * {@internal Classes listed here do not need to be added to the $newClasses
428
- * property as well.
429
- * This list is automatically added to the $newClasses property
430
- * in the `register()` method.}
431
- *
432
- * {@internal Helper to update this list: https://3v4l.org/MhlUp}
433
- *
434
- * @since 7.1.4
435
- *
436
- * @var array(string => array(string => bool))
437
- */
438
- protected $newExceptions = array(
439
- 'com_exception' => array(
440
- '4.4' => false,
441
- '5.0' => true,
442
- ),
443
- 'DOMException' => array(
444
- '4.4' => false,
445
- '5.0' => true,
446
- ),
447
- 'Exception' => array(
448
- // According to the docs introduced in PHP 5.1, but this appears to be.
449
- // an error. Class was introduced with try/catch keywords in PHP 5.0.
450
- '4.4' => false,
451
- '5.0' => true,
452
- ),
453
- 'ReflectionException' => array(
454
- '4.4' => false,
455
- '5.0' => true,
456
- ),
457
- 'SoapFault' => array(
458
- '4.4' => false,
459
- '5.0' => true,
460
- ),
461
- 'SQLiteException' => array(
462
- '4.4' => false,
463
- '5.0' => true,
464
- ),
465
-
466
- 'ErrorException' => array(
467
- '5.0' => false,
468
- '5.1' => true,
469
- ),
470
- 'BadFunctionCallException' => array(
471
- '5.0' => false,
472
- '5.1' => true,
473
- ),
474
- 'BadMethodCallException' => array(
475
- '5.0' => false,
476
- '5.1' => true,
477
- ),
478
- 'DomainException' => array(
479
- '5.0' => false,
480
- '5.1' => true,
481
- ),
482
- 'InvalidArgumentException' => array(
483
- '5.0' => false,
484
- '5.1' => true,
485
- ),
486
- 'LengthException' => array(
487
- '5.0' => false,
488
- '5.1' => true,
489
- ),
490
- 'LogicException' => array(
491
- '5.0' => false,
492
- '5.1' => true,
493
- ),
494
- 'mysqli_sql_exception' => array(
495
- '5.0' => false,
496
- '5.1' => true,
497
- ),
498
- 'OutOfBoundsException' => array(
499
- '5.0' => false,
500
- '5.1' => true,
501
- ),
502
- 'OutOfRangeException' => array(
503
- '5.0' => false,
504
- '5.1' => true,
505
- ),
506
- 'OverflowException' => array(
507
- '5.0' => false,
508
- '5.1' => true,
509
- ),
510
- 'PDOException' => array(
511
- '5.0' => false,
512
- '5.1' => true,
513
- ),
514
- 'RangeException' => array(
515
- '5.0' => false,
516
- '5.1' => true,
517
- ),
518
- 'RuntimeException' => array(
519
- '5.0' => false,
520
- '5.1' => true,
521
- ),
522
- 'UnderflowException' => array(
523
- '5.0' => false,
524
- '5.1' => true,
525
- ),
526
- 'UnexpectedValueException' => array(
527
- '5.0' => false,
528
- '5.1' => true,
529
- ),
530
-
531
- 'PharException' => array(
532
- '5.2' => false,
533
- '5.3' => true,
534
- ),
535
-
536
- 'SNMPException' => array(
537
- '5.3' => false,
538
- '5.4' => true,
539
- ),
540
-
541
- 'IntlException' => array(
542
- '5.4' => false,
543
- '5.5' => true,
544
- ),
545
-
546
- 'Error' => array(
547
- '5.6' => false,
548
- '7.0' => true,
549
- ),
550
- 'ArithmeticError' => array(
551
- '5.6' => false,
552
- '7.0' => true,
553
- ),
554
- 'AssertionError' => array(
555
- '5.6' => false,
556
- '7.0' => true,
557
- ),
558
- 'DivisionByZeroError' => array(
559
- '5.6' => false,
560
- '7.0' => true,
561
- ),
562
- 'ParseError' => array(
563
- '5.6' => false,
564
- '7.0' => true,
565
- ),
566
- 'TypeError' => array(
567
- '5.6' => false,
568
- '7.0' => true,
569
- ),
570
- 'ClosedGeneratorException' => array(
571
- '5.6' => false,
572
- '7.0' => true,
573
- ),
574
- 'UI\Exception\InvalidArgumentException' => array(
575
- '5.6' => false,
576
- '7.0' => true,
577
- ),
578
- 'UI\Exception\RuntimeException' => array(
579
- '5.6' => false,
580
- '7.0' => true,
581
- ),
582
-
583
- 'ArgumentCountError' => array(
584
- '7.0' => false,
585
- '7.1' => true,
586
- ),
587
-
588
- 'SodiumException' => array(
589
- '7.1' => false,
590
- '7.2' => true,
591
- ),
592
-
593
- 'CompileError' => array(
594
- '7.2' => false,
595
- '7.3' => true,
596
- ),
597
- 'JsonException' => array(
598
- '7.2' => false,
599
- '7.3' => true,
600
- ),
601
-
602
- 'FFI\Exception' => array(
603
- '7.3' => false,
604
- '7.4' => true,
605
- ),
606
- 'FFI\ParserException' => array(
607
- '7.3' => false,
608
- '7.4' => true,
609
- ),
610
- );
611
-
612
-
613
- /**
614
- * Returns an array of tokens this test wants to listen for.
615
- *
616
- * @since 5.5
617
- * @since 7.0.3 - Now also targets the `class` keyword to detect extended classes.
618
- * - Now also targets double colons to detect static class use.
619
- * @since 7.1.4 - Now also targets anonymous classes to detect extended classes.
620
- * - Now also targets functions/closures to detect new classes used
621
- * as parameter type declarations.
622
- * - Now also targets the `catch` control structure to detect new
623
- * exception classes being caught.
624
- * @since 8.2.0 Now also targets the `T_RETURN_TYPE` token to detect new classes used
625
- * as return type declarations.
626
- *
627
- * @return array
628
- */
629
- public function register()
630
- {
631
- // Handle case-insensitivity of class names.
632
- $this->newClasses = $this->arrayKeysToLowercase($this->newClasses);
633
- $this->newExceptions = $this->arrayKeysToLowercase($this->newExceptions);
634
-
635
- // Add the Exception classes to the Classes list.
636
- $this->newClasses = array_merge($this->newClasses, $this->newExceptions);
637
-
638
- $targets = array(
639
- \T_NEW,
640
- \T_CLASS,
641
- \T_DOUBLE_COLON,
642
- \T_FUNCTION,
643
- \T_CLOSURE,
644
- \T_CATCH,
645
- );
646
-
647
- if (\defined('T_ANON_CLASS')) {
648
- $targets[] = \T_ANON_CLASS;
649
- }
650
-
651
- if (\defined('T_RETURN_TYPE')) {
652
- $targets[] = \T_RETURN_TYPE;
653
- }
654
-
655
- return $targets;
656
- }
657
-
658
-
659
- /**
660
- * Processes this test, when one of its tokens is encountered.
661
- *
662
- * @since 5.5
663
- *
664
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
665
- * @param int $stackPtr The position of the current token in
666
- * the stack passed in $tokens.
667
- *
668
- * @return void
669
- */
670
- public function process(File $phpcsFile, $stackPtr)
671
- {
672
- $tokens = $phpcsFile->getTokens();
673
-
674
- switch ($tokens[$stackPtr]['type']) {
675
- case 'T_FUNCTION':
676
- case 'T_CLOSURE':
677
- $this->processFunctionToken($phpcsFile, $stackPtr);
678
-
679
- // Deal with older PHPCS version which don't recognize return type hints
680
- // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
681
- $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
682
- if ($returnTypeHint !== false) {
683
- $this->processReturnTypeToken($phpcsFile, $returnTypeHint);
684
- }
685
- break;
686
-
687
- case 'T_CATCH':
688
- $this->processCatchToken($phpcsFile, $stackPtr);
689
- break;
690
-
691
- case 'T_RETURN_TYPE':
692
- $this->processReturnTypeToken($phpcsFile, $stackPtr);
693
- break;
694
-
695
- default:
696
- $this->processSingularToken($phpcsFile, $stackPtr);
697
- break;
698
- }
699
- }
700
-
701
-
702
- /**
703
- * Processes this test for when a token resulting in a singular class name is encountered.
704
- *
705
- * @since 7.1.4
706
- *
707
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
708
- * @param int $stackPtr The position of the current token in
709
- * the stack passed in $tokens.
710
- *
711
- * @return void
712
- */
713
- private function processSingularToken(File $phpcsFile, $stackPtr)
714
- {
715
- $tokens = $phpcsFile->getTokens();
716
- $FQClassName = '';
717
-
718
- if ($tokens[$stackPtr]['type'] === 'T_NEW') {
719
- $FQClassName = $this->getFQClassNameFromNewToken($phpcsFile, $stackPtr);
720
-
721
- } elseif ($tokens[$stackPtr]['type'] === 'T_CLASS' || $tokens[$stackPtr]['type'] === 'T_ANON_CLASS') {
722
- $FQClassName = $this->getFQExtendedClassName($phpcsFile, $stackPtr);
723
-
724
- } elseif ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') {
725
- $FQClassName = $this->getFQClassNameFromDoubleColonToken($phpcsFile, $stackPtr);
726
- }
727
-
728
- if ($FQClassName === '') {
729
- return;
730
- }
731
-
732
- $className = substr($FQClassName, 1); // Remove global namespace indicator.
733
- $classNameLc = strtolower($className);
734
-
735
- if (isset($this->newClasses[$classNameLc]) === false) {
736
- return;
737
- }
738
-
739
- $itemInfo = array(
740
- 'name' => $className,
741
- 'nameLc' => $classNameLc,
742
- );
743
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
744
- }
745
-
746
-
747
- /**
748
- * Processes this test for when a function token is encountered.
749
- *
750
- * - Detect new classes when used as a parameter type declaration.
751
- *
752
- * @since 7.1.4
753
- *
754
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
755
- * @param int $stackPtr The position of the current token in
756
- * the stack passed in $tokens.
757
- *
758
- * @return void
759
- */
760
- private function processFunctionToken(File $phpcsFile, $stackPtr)
761
- {
762
- // Retrieve typehints stripped of global NS indicator and/or nullable indicator.
763
- $typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
764
- if (empty($typeHints) || \is_array($typeHints) === false) {
765
- return;
766
- }
767
-
768
- foreach ($typeHints as $hint) {
769
-
770
- $typeHintLc = strtolower($hint);
771
-
772
- if (isset($this->newClasses[$typeHintLc]) === true) {
773
- $itemInfo = array(
774
- 'name' => $hint,
775
- 'nameLc' => $typeHintLc,
776
- );
777
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
778
- }
779
- }
780
- }
781
-
782
-
783
- /**
784
- * Processes this test for when a catch token is encountered.
785
- *
786
- * - Detect exceptions when used in a catch statement.
787
- *
788
- * @since 7.1.4
789
- *
790
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
791
- * @param int $stackPtr The position of the current token in
792
- * the stack passed in $tokens.
793
- *
794
- * @return void
795
- */
796
- private function processCatchToken(File $phpcsFile, $stackPtr)
797
- {
798
- $tokens = $phpcsFile->getTokens();
799
-
800
- // Bow out during live coding.
801
- if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
802
- return;
803
- }
804
-
805
- $opener = $tokens[$stackPtr]['parenthesis_opener'];
806
- $closer = ($tokens[$stackPtr]['parenthesis_closer'] + 1);
807
- $name = '';
808
- $listen = array(
809
- // Parts of a (namespaced) class name.
810
- \T_STRING => true,
811
- \T_NS_SEPARATOR => true,
812
- // End/split tokens.
813
- \T_VARIABLE => false,
814
- \T_BITWISE_OR => false,
815
- \T_CLOSE_CURLY_BRACKET => false, // Shouldn't be needed as we expect a var before this.
816
- );
817
-
818
- for ($i = ($opener + 1); $i < $closer; $i++) {
819
- if (isset($listen[$tokens[$i]['code']]) === false) {
820
- continue;
821
- }
822
-
823
- if ($listen[$tokens[$i]['code']] === true) {
824
- $name .= $tokens[$i]['content'];
825
- continue;
826
- } else {
827
- if (empty($name) === true) {
828
- // Weird, we should have a name by the time we encounter a variable or |.
829
- // So this may be the closer.
830
- continue;
831
- }
832
-
833
- $name = ltrim($name, '\\');
834
- $nameLC = strtolower($name);
835
-
836
- if (isset($this->newExceptions[$nameLC]) === true) {
837
- $itemInfo = array(
838
- 'name' => $name,
839
- 'nameLc' => $nameLC,
840
- );
841
- $this->handleFeature($phpcsFile, $i, $itemInfo);
842
- }
843
-
844
- // Reset for a potential multi-catch.
845
- $name = '';
846
- }
847
- }
848
- }
849
-
850
-
851
- /**
852
- * Processes this test for when a return type token is encountered.
853
- *
854
- * - Detect new classes when used as a return type declaration.
855
- *
856
- * @since 8.2.0
857
- *
858
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
859
- * @param int $stackPtr The position of the current token in
860
- * the stack passed in $tokens.
861
- *
862
- * @return void
863
- */
864
- private function processReturnTypeToken(File $phpcsFile, $stackPtr)
865
- {
866
- $returnTypeHint = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
867
- if (empty($returnTypeHint)) {
868
- return;
869
- }
870
-
871
- $returnTypeHint = ltrim($returnTypeHint, '\\');
872
- $returnTypeHintLc = strtolower($returnTypeHint);
873
-
874
- if (isset($this->newClasses[$returnTypeHintLc]) === false) {
875
- return;
876
- }
877
-
878
- // Still here ? Then this is a return type declaration using a new class.
879
- $itemInfo = array(
880
- 'name' => $returnTypeHint,
881
- 'nameLc' => $returnTypeHintLc,
882
- );
883
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
884
- }
885
-
886
-
887
- /**
888
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
889
- *
890
- * @since 7.1.0
891
- *
892
- * @param array $itemInfo Base information about the item.
893
- *
894
- * @return array Version and other information about the item.
895
- */
896
- public function getItemArray(array $itemInfo)
897
- {
898
- return $this->newClasses[$itemInfo['nameLc']];
899
- }
900
-
901
-
902
- /**
903
- * Get the error message template for this sniff.
904
- *
905
- * @since 7.1.0
906
- *
907
- * @return string
908
- */
909
- protected function getErrorMsgTemplate()
910
- {
911
- return 'The built-in class ' . parent::getErrorMsgTemplate();
912
- }
913
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewConstVisibilitySniff.php DELETED
@@ -1,80 +0,0 @@
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
- * Visibility for class constants is available since PHP 7.1.
19
- *
20
- * PHP version 7.1
21
- *
22
- * @link https://wiki.php.net/rfc/class_const_visibility
23
- * @link https://www.php.net/manual/en/language.oop5.constants.php#language.oop5.basic.class.this
24
- *
25
- * @since 7.0.7
26
- */
27
- class NewConstVisibilitySniff extends Sniff
28
- {
29
- /**
30
- * Returns an array of tokens this test wants to listen for.
31
- *
32
- * @since 7.0.7
33
- *
34
- * @return array
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.
43
- *
44
- * @since 7.0.7
45
- *
46
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
47
- * @param int $stackPtr The position of the current token
48
- * in the stack passed in $tokens.
49
- *
50
- * @return void
51
- */
52
- public function process(File $phpcsFile, $stackPtr)
53
- {
54
- if ($this->supportsBelow('7.0') === false) {
55
- return;
56
- }
57
-
58
- $tokens = $phpcsFile->getTokens();
59
- $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
60
-
61
- // Is the previous token a visibility indicator ?
62
- if ($prevToken === false || isset(Tokens::$scopeModifiers[$tokens[$prevToken]['code']]) === false) {
63
- return;
64
- }
65
-
66
- // Is this a class constant ?
67
- if ($this->isClassConstant($phpcsFile, $stackPtr) === false) {
68
- // This may be a constant declaration in the global namespace with visibility,
69
- // but that would throw a parse error, i.e. not our concern.
70
- return;
71
- }
72
-
73
- $phpcsFile->addError(
74
- 'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"',
75
- $stackPtr,
76
- 'Found',
77
- array($tokens[$prevToken]['content'])
78
- );
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewLateStaticBindingSniff.php DELETED
@@ -1,88 +0,0 @@
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
- * Detect use of late static binding as introduced in PHP 5.3.
19
- *
20
- * Checks for:
21
- * - Late static binding as introduced in PHP 5.3.
22
- * - Late static binding being used outside of class scope (unsupported).
23
- *
24
- * PHP version 5.3
25
- *
26
- * @link https://www.php.net/manual/en/language.oop5.late-static-bindings.php
27
- * @link https://wiki.php.net/rfc/lsb_parentself_forwarding
28
- *
29
- * @since 7.0.3
30
- * @since 9.0.0 Renamed from `LateStaticBindingSniff` to `NewLateStaticBindingSniff`.
31
- */
32
- class NewLateStaticBindingSniff extends Sniff
33
- {
34
- /**
35
- * Returns an array of tokens this test wants to listen for.
36
- *
37
- * @since 7.0.3
38
- *
39
- * @return array
40
- */
41
- public function register()
42
- {
43
- return array(\T_STATIC);
44
- }
45
-
46
-
47
- /**
48
- * Processes this test, when one of its tokens is encountered.
49
- *
50
- * @since 7.0.3
51
- *
52
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
- * @param int $stackPtr The position of the current token in the
54
- * stack passed in $tokens.
55
- *
56
- * @return void
57
- */
58
- public function process(File $phpcsFile, $stackPtr)
59
- {
60
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
61
- if ($nextNonEmpty === false) {
62
- return;
63
- }
64
-
65
- $tokens = $phpcsFile->getTokens();
66
- if ($tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
67
- return;
68
- }
69
-
70
- $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
71
-
72
- if ($inClass === true && $this->supportsBelow('5.2') === true) {
73
- $phpcsFile->addError(
74
- 'Late static binding is not supported in PHP 5.2 or earlier.',
75
- $stackPtr,
76
- 'Found'
77
- );
78
- }
79
-
80
- if ($inClass === false) {
81
- $phpcsFile->addError(
82
- 'Late static binding is not supported outside of class scope.',
83
- $stackPtr,
84
- 'OutsideClassScope'
85
- );
86
- }
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php DELETED
@@ -1,132 +0,0 @@
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 class property declarations are available since PHP 7.4.
19
- *
20
- * PHP version 7.4
21
- *
22
- * @link https://www.php.net/manual/en/migration74.new-features.php#migration74.new-features.core.typed-properties
23
- * @link https://wiki.php.net/rfc/typed_properties_v2
24
- *
25
- * @since 9.2.0
26
- */
27
- class NewTypedPropertiesSniff extends Sniff
28
- {
29
-
30
- /**
31
- * Valid property modifier keywords.
32
- *
33
- * @since 9.2.0
34
- *
35
- * @var array
36
- */
37
- private $modifierKeywords = array(
38
- \T_PRIVATE => \T_PRIVATE,
39
- \T_PROTECTED => \T_PROTECTED,
40
- \T_PUBLIC => \T_PUBLIC,
41
- \T_STATIC => \T_STATIC,
42
- \T_VAR => \T_VAR,
43
- );
44
-
45
-
46
- /**
47
- * Returns an array of tokens this test wants to listen for.
48
- *
49
- * @since 9.2.0
50
- *
51
- * @return array
52
- */
53
- public function register()
54
- {
55
- return array(\T_VARIABLE);
56
- }
57
-
58
- /**
59
- * Processes this test, when one of its tokens is encountered.
60
- *
61
- * @since 9.2.0
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 int|void Integer stack pointer to skip forward or void to continue
68
- * normal file processing.
69
- */
70
- public function process(File $phpcsFile, $stackPtr)
71
- {
72
- if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
73
- return;
74
- }
75
-
76
- $find = $this->modifierKeywords;
77
- $find += array(
78
- \T_SEMICOLON => \T_SEMICOLON,
79
- \T_OPEN_CURLY_BRACKET => \T_OPEN_CURLY_BRACKET,
80
- );
81
-
82
- $tokens = $phpcsFile->getTokens();
83
- $modifier = $phpcsFile->findPrevious($find, ($stackPtr - 1));
84
- if ($modifier === false
85
- || $tokens[$modifier]['code'] === \T_SEMICOLON
86
- || $tokens[$modifier]['code'] === \T_OPEN_CURLY_BRACKET
87
- ) {
88
- // Parse error. Ignore.
89
- return;
90
- }
91
-
92
- $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($modifier + 1), null, true);
93
- if ($tokens[$type]['code'] === \T_VARIABLE) {
94
- return;
95
- }
96
-
97
- // Still here ? In that case, this will be a typed property.
98
- if ($this->supportsBelow('7.3') === true) {
99
- $phpcsFile->addError(
100
- 'Typed properties are not supported in PHP 7.3 or earlier',
101
- $type,
102
- 'Found'
103
- );
104
- }
105
-
106
- if ($this->supportsAbove('7.4') === true) {
107
- // Examine the type to verify it's valid.
108
- if ($tokens[$type]['type'] === 'T_NULLABLE'
109
- // Needed to support PHPCS < 3.5.0 which doesn't correct to the nullable token type yet.
110
- || $tokens[$type]['code'] === \T_INLINE_THEN
111
- ) {
112
- $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($type + 1), null, true);
113
- }
114
-
115
- $content = $tokens[$type]['content'];
116
- if ($content === 'void' || $content === 'callable') {
117
- $phpcsFile->addError(
118
- '%s is not supported as a type declaration for properties',
119
- $type,
120
- 'InvalidType',
121
- array($content)
122
- );
123
- }
124
- }
125
-
126
- $endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1));
127
- if ($endOfStatement !== false) {
128
- // Don't throw the same error multiple times for multi-property declarations.
129
- return ($endOfStatement + 1);
130
- }
131
- }
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedOrphanedParentSniff.php DELETED
@@ -1,115 +0,0 @@
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
- * PHP version 7.4
23
- *
24
- * @link https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.parent
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/Constants/NewConstantsSniff.php DELETED
@@ -1,3756 +0,0 @@
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\Constants;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect use of new PHP native global constants.
18
- *
19
- * PHP version All
20
- *
21
- * @since 8.1.0
22
- */
23
- class NewConstantsSniff extends AbstractNewFeatureSniff
24
- {
25
-
26
- /**
27
- * A list of new PHP Constants, 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 constant appears.
31
- *
32
- * Note: PHP constants are case-sensitive!
33
- *
34
- * @since 8.1.0
35
- *
36
- * @var array(string => array(string => bool))
37
- */
38
- protected $newConstants = array(
39
- 'E_STRICT' => array(
40
- '4.4' => false,
41
- '5.0' => true,
42
- ),
43
- // Curl:
44
- 'CURLOPT_FTP_USE_EPRT' => array(
45
- '4.4' => false,
46
- '5.0' => true,
47
- ),
48
- 'CURLOPT_NOSIGNAL' => array(
49
- '4.4' => false,
50
- '5.0' => true,
51
- ),
52
- 'CURLOPT_UNRESTRICTED_AUTH' => array(
53
- '4.4' => false,
54
- '5.0' => true,
55
- ),
56
- 'CURLOPT_BUFFERSIZE' => array(
57
- '4.4' => false,
58
- '5.0' => true,
59
- ),
60
- 'CURLOPT_HTTPAUTH' => array(
61
- '4.4' => false,
62
- '5.0' => true,
63
- ),
64
- 'CURLOPT_PROXYPORT' => array(
65
- '4.4' => false,
66
- '5.0' => true,
67
- ),
68
- 'CURLOPT_PROXYTYPE' => array(
69
- '4.4' => false,
70
- '5.0' => true,
71
- ),
72
- 'CURLOPT_SSLCERTTYPE' => array(
73
- '4.4' => false,
74
- '5.0' => true,
75
- ),
76
- 'CURLOPT_HTTP200ALIASES' => array(
77
- '4.4' => false,
78
- '5.0' => true,
79
- ),
80
- // OpenSSL:
81
- 'OPENSSL_ALGO_MD2' => array(
82
- '4.4' => false,
83
- '5.0' => true,
84
- ),
85
- 'OPENSSL_ALGO_MD4' => array(
86
- '4.4' => false,
87
- '5.0' => true,
88
- ),
89
- 'OPENSSL_ALGO_MD5' => array(
90
- '4.4' => false,
91
- '5.0' => true,
92
- ),
93
- 'OPENSSL_ALGO_SHA1' => array(
94
- '4.4' => false,
95
- '5.0' => true,
96
- ),
97
- 'OPENSSL_ALGO_DSS1' => array(
98
- '4.4' => false,
99
- '5.0' => true,
100
- ),
101
- // Tokenizer:
102
- 'T_ABSTRACT' => array(
103
- '4.4' => false,
104
- '5.0' => true,
105
- ),
106
- 'T_CATCH' => array(
107
- '4.4' => false,
108
- '5.0' => true,
109
- ),
110
-
111
- 'SORT_LOCALE_STRING' => array(
112
- '5.0.1' => false,
113
- '5.0.2' => true,
114
- ),
115
- 'PHP_EOL' => array(
116
- '5.0.1' => false,
117
- '5.0.2' => true,
118
- ),
119
-
120
- 'PHP_INT_MAX' => array(
121
- '5.0.4' => false,
122
- '5.0.5' => true,
123
- ),
124
- 'PHP_INT_SIZE' => array(
125
- '5.0.4' => false,
126
- '5.0.5' => true,
127
- ),
128
-
129
- '__COMPILER_HALT_OFFSET__' => array(
130
- '5.0' => false,
131
- '5.1' => true,
132
- ),
133
- 'GLOB_ERR' => array(
134
- '5.0' => false,
135
- '5.1' => true,
136
- ),
137
- // Curl:
138
- 'CURLOPT_AUTOREFERER' => array(
139
- '5.0' => false,
140
- '5.1' => true,
141
- ),
142
- 'CURLOPT_BINARYTRANSFER' => array(
143
- '5.0' => false,
144
- '5.1' => true,
145
- ),
146
- 'CURLOPT_COOKIESESSION' => array(
147
- '5.0' => false,
148
- '5.1' => true,
149
- ),
150
- 'CURLOPT_FTPSSLAUTH' => array(
151
- '5.0' => false,
152
- '5.1' => true,
153
- ),
154
- 'CURLOPT_PROXYAUTH' => array(
155
- '5.0' => false,
156
- '5.1' => true,
157
- ),
158
- 'CURLOPT_TIMECONDITION' => array(
159
- '5.0' => false,
160
- '5.1' => true,
161
- ),
162
- // POSIX:
163
- 'POSIX_F_OK' => array(
164
- '5.0' => false,
165
- '5.1' => true,
166
- ),
167
- 'POSIX_R_OK' => array(
168
- '5.0' => false,
169
- '5.1' => true,
170
- ),
171
- 'POSIX_W_OK' => array(
172
- '5.0' => false,
173
- '5.1' => true,
174
- ),
175
- 'POSIX_X_OK' => array(
176
- '5.0' => false,
177
- '5.1' => true,
178
- ),
179
- 'POSIX_S_IFBLK' => array(
180
- '5.0' => false,
181
- '5.1' => true,
182
- ),
183
- 'POSIX_S_IFCHR' => array(
184
- '5.0' => false,
185
- '5.1' => true,
186
- ),
187
- 'POSIX_S_IFIFO' => array(
188
- '5.0' => false,
189
- '5.1' => true,
190
- ),
191
- 'POSIX_S_IFREG' => array(
192
- '5.0' => false,
193
- '5.1' => true,
194
- ),
195
- 'POSIX_S_IFSOCK' => array(
196
- '5.0' => false,
197
- '5.1' => true,
198
- ),
199
- // Streams:
200
- 'STREAM_IPPROTO_ICMP' => array(
201
- '5.0' => false,
202
- '5.1' => true,
203
- ),
204
- 'STREAM_IPPROTO_IP' => array(
205
- '5.0' => false,
206
- '5.1' => true,
207
- ),
208
- 'STREAM_IPPROTO_RAW' => array(
209
- '5.0' => false,
210
- '5.1' => true,
211
- ),
212
- 'STREAM_IPPROTO_TCP' => array(
213
- '5.0' => false,
214
- '5.1' => true,
215
- ),
216
- 'STREAM_IPPROTO_UDP' => array(
217
- '5.0' => false,
218
- '5.1' => true,
219
- ),
220
- 'STREAM_PF_INET' => array(
221
- '5.0' => false,
222
- '5.1' => true,
223
- ),
224
- 'STREAM_PF_INET6' => array(
225
- '5.0' => false,
226
- '5.1' => true,
227
- ),
228
- 'STREAM_PF_UNIX' => array(
229
- '5.0' => false,
230
- '5.1' => true,
231
- ),
232
- 'STREAM_SOCK_DGRAM' => array(
233
- '5.0' => false,
234
- '5.1' => true,
235
- ),
236
- 'STREAM_SOCK_RAW' => array(
237
- '5.0' => false,
238
- '5.1' => true,
239
- ),
240
- 'STREAM_SOCK_RDM' => array(
241
- '5.0' => false,
242
- '5.1' => true,
243
- ),
244
- 'STREAM_SOCK_SEQPACKET' => array(
245
- '5.0' => false,
246
- '5.1' => true,
247
- ),
248
- 'STREAM_SOCK_STREAM' => array(
249
- '5.0' => false,
250
- '5.1' => true,
251
- ),
252
- // Tokenizer:
253
- 'T_HALT_COMPILER' => array(
254
- '5.0' => false,
255
- '5.1' => true,
256
- ),
257
-
258
- // Date/Time:
259
- 'DATE_ATOM' => array(
260
- '5.1.0' => false,
261
- '5.1.1' => true,
262
- ),
263
- 'DATE_COOKIE' => array(
264
- '5.1.0' => false,
265
- '5.1.1' => true,
266
- ),
267
- 'DATE_ISO8601' => array(
268
- '5.1.0' => false,
269
- '5.1.1' => true,
270
- ),
271
- 'DATE_RFC822' => array(
272
- '5.1.0' => false,
273
- '5.1.1' => true,
274
- ),
275
- 'DATE_RFC850' => array(
276
- '5.1.0' => false,
277
- '5.1.1' => true,
278
- ),
279
- 'DATE_RFC1036' => array(
280
- '5.1.0' => false,
281
- '5.1.1' => true,
282
- ),
283
- 'DATE_RFC1123' => array(
284
- '5.1.0' => false,
285
- '5.1.1' => true,
286
- ),
287
- 'DATE_RFC2822' => array(
288
- '5.1.0' => false,
289
- '5.1.1' => true,
290
- ),
291
- 'DATE_RFC3339' => array(
292
- '5.1.0' => false,
293
- '5.1.1' => true,
294
- ),
295
- 'DATE_RSS' => array(
296
- '5.1.0' => false,
297
- '5.1.1' => true,
298
- ),
299
- 'DATE_W3C' => array(
300
- '5.1.0' => false,
301
- '5.1.1' => true,
302
- ),
303
-
304
- // Date/Time:
305
- 'SUNFUNCS_RET_TIMESTAMP' => array(
306
- '5.1.1' => false,
307
- '5.1.2' => true,
308
- ),
309
- 'SUNFUNCS_RET_STRING' => array(
310
- '5.1.1' => false,
311
- '5.1.2' => true,
312
- ),
313
- 'SUNFUNCS_RET_DOUBLE' => array(
314
- '5.1.1' => false,
315
- '5.1.2' => true,
316
- ),
317
- // XSL:
318
- 'LIBXSLT_VERSION' => array(
319
- '5.1.1' => false,
320
- '5.1.2' => true,
321
- ),
322
- 'LIBXSLT_DOTTED_VERSION' => array(
323
- '5.1.1' => false,
324
- '5.1.2' => true,
325
- ),
326
- 'LIBEXSLT_VERSION' => array(
327
- '5.1.1' => false,
328
- '5.1.2' => true,
329
- ),
330
- 'LIBEXSLT_DOTTED_VERSION' => array(
331
- '5.1.1' => false,
332
- '5.1.2' => true,
333
- ),
334
- // URL:
335
- 'PHP_URL_SCHEME' => array(
336
- '5.1.1' => false,
337
- '5.1.2' => true,
338
- ),
339
- 'PHP_URL_HOST' => array(
340
- '5.1.1' => false,
341
- '5.1.2' => true,
342
- ),
343
- 'PHP_URL_PORT' => array(
344
- '5.1.1' => false,
345
- '5.1.2' => true,
346
- ),
347
- 'PHP_URL_USER' => array(
348
- '5.1.1' => false,
349
- '5.1.2' => true,
350
- ),
351
- 'PHP_URL_PASS' => array(
352
- '5.1.1' => false,
353
- '5.1.2' => true,
354
- ),
355
- 'PHP_URL_PATH' => array(
356
- '5.1.1' => false,
357
- '5.1.2' => true,
358
- ),
359
- 'PHP_URL_QUERY' => array(
360
- '5.1.1' => false,
361
- '5.1.2' => true,
362
- ),
363
- 'PHP_URL_FRAGMENT' => array(
364
- '5.1.1' => false,
365
- '5.1.2' => true,
366
- ),
367
- 'PHP_QUERY_RFC1738' => array(
368
- '5.1.1' => false,
369
- '5.1.2' => true,
370
- ),
371
- 'PHP_QUERY_RFC3986' => array(
372
- '5.1.1' => false,
373
- '5.1.2' => true,
374
- ),
375
-
376
- // Curl:
377
- 'CURLINFO_HEADER_OUT' => array(
378
- '5.1.2' => false,
379
- '5.1.3' => true,
380
- ),
381
-
382
- // Core:
383
- 'E_RECOVERABLE_ERROR' => array(
384
- '5.1' => false,
385
- '5.2' => true,
386
- ),
387
- // Math:
388
- 'M_EULER' => array(
389
- '5.1' => false,
390
- '5.2' => true,
391
- ),
392
- 'M_LNPI' => array(
393
- '5.1' => false,
394
- '5.2' => true,
395
- ),
396
- 'M_SQRT3' => array(
397
- '5.1' => false,
398
- '5.2' => true,
399
- ),
400
- 'M_SQRTPI' => array(
401
- '5.1' => false,
402
- '5.2' => true,
403
- ),
404
- 'PATHINFO_FILENAME' => array(
405
- '5.1' => false,
406
- '5.2' => true,
407
- ),
408
- 'UPLOAD_ERR_EXTENSION' => array(
409
- '5.1' => false,
410
- '5.2' => true,
411
- ),
412
- // Curl:
413
- 'CURLE_FILESIZE_EXCEEDED' => array(
414
- '5.1' => false,
415
- '5.2' => true,
416
- ),
417
- 'CURLE_FTP_SSL_FAILED' => array(
418
- '5.1' => false,
419
- '5.2' => true,
420
- ),
421
- 'CURLE_LDAP_INVALID_URL' => array(
422
- '5.1' => false,
423
- '5.2' => true,
424
- ),
425
- 'CURLFTPAUTH_DEFAULT' => array(
426
- '5.1' => false,
427
- '5.2' => true,
428
- ),
429
- 'CURLFTPAUTH_SSL' => array(
430
- '5.1' => false,
431
- '5.2' => true,
432
- ),
433
- 'CURLFTPAUTH_TLS' => array(
434
- '5.1' => false,
435
- '5.2' => true,
436
- ),
437
- 'CURLFTPSSL_ALL' => array(
438
- '5.1' => false,
439
- '5.2' => true,
440
- ),
441
- 'CURLFTPSSL_CONTROL' => array(
442
- '5.1' => false,
443
- '5.2' => true,
444
- ),
445
- 'CURLFTPSSL_NONE' => array(
446
- '5.1' => false,
447
- '5.2' => true,
448
- ),
449
- 'CURLFTPSSL_TRY' => array(
450
- '5.1' => false,
451
- '5.2' => true,
452
- ),
453
- 'CURLOPT_FTP_SSL' => array(
454
- '5.1' => false,
455
- '5.2' => true,
456
- ),
457
- // Ming:
458
- 'SWFTEXTFIELD_USEFONT' => array(
459
- '5.1' => false,
460
- '5.2' => true,
461
- ),
462
- 'SWFTEXTFIELD_AUTOSIZE' => array(
463
- '5.1' => false,
464
- '5.2' => true,
465
- ),
466
- 'SWF_SOUND_NOT_COMPRESSED' => array(
467
- '5.1' => false,
468
- '5.2' => true,
469
- ),
470
- 'SWF_SOUND_ADPCM_COMPRESSED' => array(
471
- '5.1' => false,
472
- '5.2' => true,
473
- ),
474
- 'SWF_SOUND_MP3_COMPRESSED' => array(
475
- '5.1' => false,
476
- '5.2' => true,
477
- ),
478
- 'SWF_SOUND_NOT_COMPRESSED_LE' => array(
479
- '5.1' => false,
480
- '5.2' => true,
481
- ),
482
- 'SWF_SOUND_NELLY_COMPRESSED' => array(
483
- '5.1' => false,
484
- '5.2' => true,
485
- ),
486
- 'SWF_SOUND_5KHZ' => array(
487
- '5.1' => false,
488
- '5.2' => true,
489
- ),
490
- 'SWF_SOUND_11KHZ' => array(
491
- '5.1' => false,
492
- '5.2' => true,
493
- ),
494
- 'SWF_SOUND_22KHZ' => array(
495
- '5.1' => false,
496
- '5.2' => true,
497
- ),
498
- 'SWF_SOUND_44KHZ' => array(
499
- '5.1' => false,
500
- '5.2' => true,
501
- ),
502
- 'SWF_SOUND_8BITS' => array(
503
- '5.1' => false,
504
- '5.2' => true,
505
- ),
506
- 'SWF_SOUND_16BITS' => array(
507
- '5.1' => false,
508
- '5.2' => true,
509
- ),
510
- 'SWF_SOUND_MONO' => array(
511
- '5.1' => false,
512
- '5.2' => true,
513
- ),
514
- 'SWF_SOUND_STEREO' => array(
515
- '5.1' => false,
516
- '5.2' => true,
517
- ),
518
- // OpenSSL:
519
- 'OPENSSL_KEYTYPE_EC' => array(
520
- '5.1' => false,
521
- '5.2' => true,
522
- ),
523
- 'OPENSSL_VERSION_NUMBER' => array(
524
- '5.1' => false,
525
- '5.2' => true,
526
- ),
527
- 'OPENSSL_VERSION_TEXT' => array(
528
- '5.1' => false,
529
- '5.2' => true,
530
- ),
531
- // PCRE:
532
- 'PREG_BACKTRACK_LIMIT_ERROR' => array(
533
- '5.1' => false,
534
- '5.2' => true,
535
- ),
536
- 'PREG_BAD_UTF8_ERROR' => array(
537
- '5.1' => false,
538
- '5.2' => true,
539
- ),
540
- 'PREG_INTERNAL_ERROR' => array(
541
- '5.1' => false,
542
- '5.2' => true,
543
- ),
544
- 'PREG_NO_ERROR' => array(
545
- '5.1' => false,
546
- '5.2' => true,
547
- ),
548
- 'PREG_RECURSION_LIMIT_ERROR' => array(
549
- '5.1' => false,
550
- '5.2' => true,
551
- ),
552
- // Snmp:
553
- 'SNMP_OID_OUTPUT_FULL' => array(
554
- '5.1' => false,
555
- '5.2' => true,
556
- ),
557
- 'SNMP_OID_OUTPUT_NUMERIC' => array(
558
- '5.1' => false,
559
- '5.2' => true,
560
- ),
561
- // Semaphore:
562
- 'MSG_EAGAIN' => array(
563
- '5.1' => false,
564
- '5.2' => true,
565
- ),
566
- 'MSG_ENOMSG' => array(
567
- '5.1' => false,
568
- '5.2' => true,
569
- ),
570
-
571
- // Curl:
572
- 'CURLOPT_TCP_NODELAY' => array(
573
- '5.2.0' => false,
574
- '5.2.1' => true,
575
- ),
576
-
577
- // Stream:
578
- 'STREAM_SHUT_RD' => array(
579
- '5.2.0' => false,
580
- '5.2.1' => true,
581
- ),
582
- 'STREAM_SHUT_WR' => array(
583
- '5.2.0' => false,
584
- '5.2.1' => true,
585
- ),
586
- 'STREAM_SHUT_RDWR' => array(
587
- '5.2.0' => false,
588
- '5.2.1' => true,
589
- ),
590
-
591
- 'GMP_VERSION' => array(
592
- '5.2.1' => false,
593
- '5.2.2' => true,
594
- ),
595
-
596
- // Curl:
597
- 'CURLOPT_TIMEOUT_MS' => array(
598
- '5.2.2' => false,
599
- '5.2.3' => true,
600
- ),
601
- 'CURLOPT_CONNECTTIMEOUT_MS' => array(
602
- '5.2.2' => false,
603
- '5.2.3' => true,
604
- ),
605
-
606
- // Curl:
607
- 'CURLOPT_PRIVATE' => array(
608
- '5.2.3' => false,
609
- '5.2.4' => true,
610
- ),
611
- 'CURLINFO_PRIVATE' => array(
612
- '5.2.3' => false,
613
- '5.2.4' => true,
614
- ),
615
- // GD:
616
- 'GD_VERSION' => array(
617
- '5.2.3' => false,
618
- '5.2.4' => true,
619
- ),
620
- 'GD_MAJOR_VERSION' => array(
621
- '5.2.3' => false,
622
- '5.2.4' => true,
623
- ),
624
- 'GD_MINOR_VERSION' => array(
625
- '5.2.3' => false,
626
- '5.2.4' => true,
627
- ),
628
- 'GD_RELEASE_VERSION' => array(
629
- '5.2.3' => false,
630
- '5.2.4' => true,
631
- ),
632
- 'GD_EXTRA_VERSION' => array(
633
- '5.2.3' => false,
634
- '5.2.4' => true,
635
- ),
636
- // PCRE:
637
- 'PCRE_VERSION' => array(
638
- '5.2.3' => false,
639
- '5.2.4' => true,
640
- ),
641
-
642
- 'PHP_MAJOR_VERSION' => array(
643
- '5.2.6' => false,
644
- '5.2.7' => true,
645
- ),
646
- 'PHP_MINOR_VERSION' => array(
647
- '5.2.6' => false,
648
- '5.2.7' => true,
649
- ),
650
- 'PHP_RELEASE_VERSION' => array(
651
- '5.2.6' => false,
652
- '5.2.7' => true,
653
- ),
654
- 'PHP_VERSION_ID' => array(
655
- '5.2.6' => false,
656
- '5.2.7' => true,
657
- ),
658
- 'PHP_EXTRA_VERSION' => array(
659
- '5.2.6' => false,
660
- '5.2.7' => true,
661
- ),
662
- 'PHP_ZTS' => array(
663
- '5.2.6' => false,
664
- '5.2.7' => true,
665
- ),
666
- 'PHP_DEBUG' => array(
667
- '5.2.6' => false,
668
- '5.2.7' => true,
669
- ),
670
- 'FILE_BINARY' => array(
671
- '5.2.6' => false,
672
- '5.2.7' => true,
673
- ),
674
- 'FILE_TEXT' => array(
675
- '5.2.6' => false,
676
- '5.2.7' => true,
677
- ),
678
- // Sockets:
679
- 'TCP_NODELAY' => array(
680
- '5.2.6' => false,
681
- '5.2.7' => true,
682
- ),
683
-
684
- // Curl:
685
- 'CURLOPT_PROTOCOLS' => array(
686
- '5.2.9' => false,
687
- '5.2.10' => true,
688
- ),
689
- 'CURLOPT_REDIR_PROTOCOLS' => array(
690
- '5.2.9' => false,
691
- '5.2.10' => true,
692
- ),
693
- 'CURLPROXY_SOCKS4' => array(
694
- '5.2.9' => false,
695
- '5.2.10' => true,
696
- ),
697
-
698
- // Libxml:
699
- 'LIBXML_PARSEHUGE' => array(
700
- '5.2.11' => false,
701
- '5.2.12' => true,
702
- ),
703
-
704
- // Core:
705
- 'ENT_IGNORE' => array(
706
- '5.2' => false,
707
- '5.3' => true,
708
- ),
709
- 'E_DEPRECATED' => array(
710
- '5.2' => false,
711
- '5.3' => true,
712
- ),
713
- 'E_USER_DEPRECATED' => array(
714
- '5.2' => false,
715
- '5.3' => true,
716
- ),
717
- 'INI_SCANNER_NORMAL' => array(
718
- '5.2' => false,
719
- '5.3' => true,
720
- ),
721
- 'INI_SCANNER_RAW' => array(
722
- '5.2' => false,
723
- '5.3' => true,
724
- ),
725
- 'PHP_MAXPATHLEN' => array(
726
- '5.2' => false,
727
- '5.3' => true,
728
- ),
729
- 'PHP_WINDOWS_NT_DOMAIN_CONTROLLER' => array(
730
- '5.2' => false,
731
- '5.3' => true,
732
- ),
733
- 'PHP_WINDOWS_NT_SERVER' => array(
734
- '5.2' => false,
735
- '5.3' => true,
736
- ),
737
- 'PHP_WINDOWS_NT_WORKSTATION' => array(
738
- '5.2' => false,
739
- '5.3' => true,
740
- ),
741
- 'PHP_WINDOWS_VERSION_BUILD' => array(
742
- '5.2' => false,
743
- '5.3' => true,
744
- ),
745
- 'PHP_WINDOWS_VERSION_MAJOR' => array(
746
- '5.2' => false,
747
- '5.3' => true,
748
- ),
749
- 'PHP_WINDOWS_VERSION_MINOR' => array(
750
- '5.2' => false,
751
- '5.3' => true,
752
- ),
753
- 'PHP_WINDOWS_VERSION_PLATFORM' => array(
754
- '5.2' => false,
755
- '5.3' => true,
756
- ),
757
- 'PHP_WINDOWS_VERSION_PRODUCTTYPE' => array(
758
- '5.2' => false,
759
- '5.3' => true,
760
- ),
761
- 'PHP_WINDOWS_VERSION_SP_MAJOR' => array(
762
- '5.2' => false,
763
- '5.3' => true,
764
- ),
765
- 'PHP_WINDOWS_VERSION_SP_MINOR' => array(
766
- '5.2' => false,
767
- '5.3' => true,
768
- ),
769
- 'PHP_WINDOWS_VERSION_SUITEMASK' => array(
770
- '5.2' => false,
771
- '5.3' => true,
772
- ),
773
- // Curl:
774
- 'CURLINFO_CERTINFO' => array(
775
- '5.2' => false,
776
- '5.3' => true,
777
- ),
778
- 'CURLOPT_PROGRESSFUNCTION' => array(
779
- '5.2' => false,
780
- '5.3' => true,
781
- ),
782
- 'CURLE_SSH' => array(
783
- '5.2' => false,
784
- '5.3' => true,
785
- ),
786
- // GD:
787
- 'IMG_FILTER_PIXELATE' => array(
788
- '5.2' => false,
789
- '5.3' => true,
790
- ),
791
- 'IMAGETYPE_ICO' => array(
792
- '5.2' => false,
793
- '5.3' => true,
794
- ),
795
- // Fileinfo:
796
- 'FILEINFO_MIME_TYPE' => array(
797
- '5.2' => false,
798
- '5.3' => true,
799
- ),
800
- 'FILEINFO_MIME_ENCODING' => array(
801
- '5.2' => false,
802
- '5.3' => true,
803
- ),
804
- // JSON:
805
- 'JSON_ERROR_CTRL_CHAR' => array(
806
- '5.2' => false,
807
- '5.3' => true,
808
- ),
809
- 'JSON_ERROR_DEPTH' => array(
810
- '5.2' => false,
811
- '5.3' => true,
812
- ),
813
- 'JSON_ERROR_NONE' => array(
814
- '5.2' => false,
815
- '5.3' => true,
816
- ),
817
- 'JSON_ERROR_STATE_MISMATCH' => array(
818
- '5.2' => false,
819
- '5.3' => true,
820
- ),
821
- 'JSON_ERROR_SYNTAX' => array(
822
- '5.2' => false,
823
- '5.3' => true,
824
- ),
825
- 'JSON_FORCE_OBJECT' => array(
826
- '5.2' => false,
827
- '5.3' => true,
828
- ),
829
- 'JSON_HEX_TAG' => array(
830
- '5.2' => false,
831
- '5.3' => true,
832
- ),
833
- 'JSON_HEX_AMP' => array(
834
- '5.2' => false,
835
- '5.3' => true,
836
- ),
837
- 'JSON_HEX_APOS' => array(
838
- '5.2' => false,
839
- '5.3' => true,
840
- ),
841
- 'JSON_HEX_QUOT' => array(
842
- '5.2' => false,
843
- '5.3' => true,
844
- ),
845
- // LDAP:
846
- 'LDAP_OPT_NETWORK_TIMEOUT' => array(
847
- '5.2' => false,
848
- '5.3' => true,
849
- ),
850
- // Libxml:
851
- 'LIBXML_LOADED_VERSION' => array(
852
- '5.2' => false,
853
- '5.3' => true,
854
- ),
855
- // Math:
856
- 'PHP_ROUND_HALF_UP' => array(
857
- '5.2' => false,
858
- '5.3' => true,
859
- ),
860
- 'PHP_ROUND_HALF_DOWN' => array(
861
- '5.2' => false,
862
- '5.3' => true,
863
- ),
864
- 'PHP_ROUND_HALF_EVEN' => array(
865
- '5.2' => false,
866
- '5.3' => true,
867
- ),
868
- 'PHP_ROUND_HALF_ODD' => array(
869
- '5.2' => false,
870
- '5.3' => true,
871
- ),
872
- // Mysqli
873
- 'MYSQLI_OPT_INT_AND_FLOAT_NATIVE' => array(
874
- '5.2' => false,
875
- '5.3' => true,
876
- ),
877
- 'MYSQLI_OPT_NET_CMD_BUFFER_SIZE' => array(
878
- '5.2' => false,
879
- '5.3' => true,
880
- ),
881
- 'MYSQLI_OPT_NET_READ_BUFFER_SIZE' => array(
882
- '5.2' => false,
883
- '5.3' => true,
884
- ),
885
- 'MYSQLI_OPT_SSL_VERIFY_SERVER_CERT' => array(
886
- '5.2' => false,
887
- '5.3' => true,
888
- ),
889
- // OCI8:
890
- 'OCI_CRED_EXT' => array(
891
- '5.2' => false,
892
- '5.3' => true,
893
- ),
894
- // PCRE:
895
- 'PREG_BAD_UTF8_OFFSET_ERROR' => array(
896
- '5.2' => false,
897
- '5.3' => true,
898
- ),
899
- // PCNTL:
900
- 'BUS_ADRALN' => array(
901
- '5.2' => false,
902
- '5.3' => true,
903
- ),
904
- 'BUS_ADRERR' => array(
905
- '5.2' => false,
906
- '5.3' => true,
907
- ),
908
- 'BUS_OBJERR' => array(
909
- '5.2' => false,
910
- '5.3' => true,
911
- ),
912
- 'CLD_CONTIUNED' => array(
913
- '5.2' => false,
914
- '5.3' => true,
915
- ),
916
- 'CLD_DUMPED' => array(
917
- '5.2' => false,
918
- '5.3' => true,
919
- ),
920
- 'CLD_EXITED' => array(
921
- '5.2' => false,
922
- '5.3' => true,
923
- ),
924
- 'CLD_KILLED' => array(
925
- '5.2' => false,
926
- '5.3' => true,
927
- ),
928
- 'CLD_STOPPED' => array(
929
- '5.2' => false,
930
- '5.3' => true,
931
- ),
932
- 'CLD_TRAPPED' => array(
933
- '5.2' => false,
934
- '5.3' => true,
935
- ),
936
- 'FPE_FLTDIV' => array(
937
- '5.2' => false,
938
- '5.3' => true,
939
- ),
940
- 'FPE_FLTINV' => array(
941
- '5.2' => false,
942
- '5.3' => true,
943
- ),
944
- 'FPE_FLTOVF' => array(
945
- '5.2' => false,
946
- '5.3' => true,
947
- ),
948
- 'FPE_FLTRES' => array(
949
- '5.2' => false,
950
- '5.3' => true,
951
- ),
952
- 'FPE_FLTSUB' => array(
953
- '5.2' => false,
954
- '5.3' => true,
955
- ),
956
- 'FPE_FLTUND' => array(
957
- '5.2' => false,
958
- '5.3' => true,
959
- ),
960
- 'FPE_INTDIV' => array(
961
- '5.2' => false,
962
- '5.3' => true,
963
- ),
964
- 'FPE_INTOVF' => array(
965
- '5.2' => false,
966
- '5.3' => true,
967
- ),
968
- 'ILL_BADSTK' => array(
969
- '5.2' => false,
970
- '5.3' => true,
971
- ),
972
- 'ILL_COPROC' => array(
973
- '5.2' => false,
974
- '5.3' => true,
975
- ),
976
- 'ILL_ILLADR' => array(
977
- '5.2' => false,
978
- '5.3' => true,
979
- ),
980
- 'ILL_ILLOPC' => array(
981
- '5.2' => false,
982
- '5.3' => true,
983
- ),
984
- 'ILL_ILLOPN' => array(
985
- '5.2' => false,
986
- '5.3' => true,
987
- ),
988
- 'ILL_ILLTRP' => array(
989
- '5.2' => false,
990
- '5.3' => true,
991
- ),
992
- 'ILL_PRVOPC' => array(
993
- '5.2' => false,
994
- '5.3' => true,
995
- ),
996
- 'ILL_PRVREG' => array(
997
- '5.2' => false,
998
- '5.3' => true,
999
- ),
1000
- 'POLL_ERR' => array(
1001
- '5.2' => false,
1002
- '5.3' => true,
1003
- ),
1004
- 'POLL_HUP' => array(
1005
- '5.2' => false,
1006
- '5.3' => true,
1007
- ),
1008
- 'POLL_IN' => array(
1009
- '5.2' => false,
1010
- '5.3' => true,
1011
- ),
1012
- 'POLL_MSG' => array(
1013
- '5.2' => false,
1014
- '5.3' => true,
1015
- ),
1016
- 'POLL_OUT' => array(
1017
- '5.2' => false,
1018
- '5.3' => true,
1019
- ),
1020
- 'POLL_PRI' => array(
1021
- '5.2' => false,
1022
- '5.3' => true,
1023
- ),
1024
- 'SEGV_ACCERR' => array(
1025
- '5.2' => false,
1026
- '5.3' => true,
1027
- ),
1028
- 'SEGV_MAPERR' => array(
1029
- '5.2' => false,
1030
- '5.3' => true,
1031
- ),
1032
- 'SI_ASYNCIO' => array(
1033
- '5.2' => false,
1034
- '5.3' => true,
1035
- ),
1036
- 'SI_KERNEL' => array(
1037
- '5.2' => false,
1038
- '5.3' => true,
1039
- ),
1040
- 'SI_MSGGQ' => array(
1041
- '5.2' => false,
1042
- '5.3' => true,
1043
- ),
1044
- 'SI_NOINFO' => array(
1045
- '5.2' => false,
1046
- '5.3' => true,
1047
- ),
1048
- 'SI_QUEUE' => array(
1049
- '5.2' => false,
1050
- '5.3' => true,
1051
- ),
1052
- 'SI_SIGIO' => array(
1053
- '5.2' => false,
1054
- '5.3' => true,
1055
- ),
1056
- 'SI_TIMER' => array(
1057
- '5.2' => false,
1058
- '5.3' => true,
1059
- ),
1060
- 'SI_TKILL' => array(
1061
- '5.2' => false,
1062
- '5.3' => true,
1063
- ),
1064
- 'SI_USER' => array(
1065
- '5.2' => false,
1066
- '5.3' => true,
1067
- ),
1068
- 'SIG_BLOCK' => array(
1069
- '5.2' => false,
1070
- '5.3' => true,
1071
- ),
1072
- 'SIG_SETMASK' => array(
1073
- '5.2' => false,
1074
- '5.3' => true,
1075
- ),
1076
- 'SIG_UNBLOCK' => array(
1077
- '5.2' => false,
1078
- '5.3' => true,
1079
- ),
1080
- 'TRAP_BRKPT' => array(
1081
- '5.2' => false,
1082
- '5.3' => true,
1083
- ),
1084
- 'TRAP_TRACE' => array(
1085
- '5.2' => false,
1086
- '5.3' => true,
1087
- ),
1088
- // Tokenizer:
1089
- 'T_DIR' => array(
1090
- '5.2' => false,
1091
- '5.3' => true,
1092
- ),
1093
- 'T_GOTO' => array(
1094
- '5.2' => false,
1095
- '5.3' => true,
1096
- ),
1097
- 'T_NAMESPACE' => array(
1098
- '5.2' => false,
1099
- '5.3' => true,
1100
- ),
1101
- 'T_NS_C' => array(
1102
- '5.2' => false,
1103
- '5.3' => true,
1104
- ),
1105
- 'T_NS_SEPARATOR' => array(
1106
- '5.2' => false,
1107
- '5.3' => true,
1108
- ),
1109
- 'T_USE' => array(
1110
- '5.2' => false,
1111
- '5.3' => true,
1112
- ),
1113
-
1114
- // OCI8:
1115
- 'OCI_NO_AUTO_COMMIT' => array(
1116
- '5.3.1' => false,
1117
- '5.3.2' => true,
1118
- ),
1119
- // OpenSSL:
1120
- 'OPENSSL_TLSEXT_SERVER_NAME' => array(
1121
- '5.3.1' => false,
1122
- '5.3.2' => true,
1123
- ),
1124
-
1125
- // JSON:
1126
- 'JSON_ERROR_UTF8' => array(
1127
- '5.3.2' => false,
1128
- '5.3.3' => true,
1129
- ),
1130
- 'JSON_NUMERIC_CHECK' => array(
1131
- '5.3.2' => false,
1132
- '5.3.3' => true,
1133
- ),
1134
-
1135
- 'DEBUG_BACKTRACE_IGNORE_ARGS' => array(
1136
- '5.3.5' => false,
1137
- '5.3.6' => true,
1138
- ),
1139
-
1140
- 'CURLINFO_REDIRECT_URL' => array(
1141
- '5.3.6' => false,
1142
- '5.3.7' => true,
1143
- ),
1144
- 'PHP_MANDIR' => array(
1145
- '5.3.6' => false,
1146
- '5.3.7' => true,
1147
- ),
1148
-
1149
- 'PHP_BINARY' => array(
1150
- '5.3' => false,
1151
- '5.4' => true,
1152
- ),
1153
- 'SORT_NATURAL' => array(
1154
- '5.3' => false,
1155
- '5.4' => true,
1156
- ),
1157
- 'SORT_FLAG_CASE' => array(
1158
- '5.3' => false,
1159
- '5.4' => true,
1160
- ),
1161
- 'ENT_HTML401' => array(
1162
- '5.3' => false,
1163
- '5.4' => true,
1164
- ),
1165
- 'ENT_XML1' => array(
1166
- '5.3' => false,
1167
- '5.4' => true,
1168
- ),
1169
- 'ENT_XHTML' => array(
1170
- '5.3' => false,
1171
- '5.4' => true,
1172
- ),
1173
- 'ENT_HTML5' => array(
1174
- '5.3' => false,
1175
- '5.4' => true,
1176
- ),
1177
- 'ENT_SUBSTITUTE' => array(
1178
- '5.3' => false,
1179
- '5.4' => true,
1180
- ),
1181
- 'ENT_DISALLOWED' => array(
1182
- '5.3' => false,
1183
- '5.4' => true,
1184
- ),
1185
- 'IPPROTO_IP' => array(
1186
- '5.3' => false,
1187
- '5.4' => true,
1188
- ),
1189
- 'IPPROTO_IPV6' => array(
1190
- '5.3' => false,
1191
- '5.4' => true,
1192
- ),
1193
- 'IPV6_MULTICAST_HOPS' => array(
1194
- '5.3' => false,
1195
- '5.4' => true,
1196
- ),
1197
- 'IPV6_MULTICAST_IF' => array(
1198
- '5.3' => false,
1199
- '5.4' => true,
1200
- ),
1201
- 'IPV6_MULTICAST_LOOP' => array(
1202
- '5.3' => false,
1203
- '5.4' => true,
1204
- ),
1205
- 'IP_MULTICAST_IF' => array(
1206
- '5.3' => false,
1207
- '5.4' => true,
1208
- ),
1209
- 'IP_MULTICAST_LOOP' => array(
1210
- '5.3' => false,
1211
- '5.4' => true,
1212
- ),
1213
- 'IP_MULTICAST_TTL' => array(
1214
- '5.3' => false,
1215
- '5.4' => true,
1216
- ),
1217
- 'MCAST_JOIN_GROUP' => array(
1218
- '5.3' => false,
1219
- '5.4' => true,
1220
- ),
1221
- 'MCAST_LEAVE_GROUP' => array(
1222
- '5.3' => false,
1223
- '5.4' => true,
1224
- ),
1225
- 'MCAST_BLOCK_SOURCE' => array(
1226
- '5.3' => false,
1227
- '5.4' => true,
1228
- ),
1229
- 'MCAST_UNBLOCK_SOURCE' => array(
1230
- '5.3' => false,
1231
- '5.4' => true,
1232
- ),
1233
- 'MCAST_JOIN_SOURCE_GROUP' => array(
1234
- '5.3' => false,
1235
- '5.4' => true,
1236
- ),
1237
- 'MCAST_LEAVE_SOURCE_GROUP' => array(
1238
- '5.3' => false,
1239
- '5.4' => true,
1240
- ),
1241
- // Curl:
1242
- 'CURLOPT_MAX_RECV_SPEED_LARGE' => array(
1243
- '5.3' => false,
1244
- '5.4' => true,
1245
- ),
1246
- 'CURLOPT_MAX_SEND_SPEED_LARGE' => array(
1247
- '5.3' => false,
1248
- '5.4' => true,
1249
- ),
1250
- // Directories:
1251
- 'SCANDIR_SORT_ASCENDING' => array(
1252
- '5.3' => false,
1253
- '5.4' => true,
1254
- ),
1255
- 'SCANDIR_SORT_DESCENDING' => array(
1256
- '5.3' => false,
1257
- '5.4' => true,
1258
- ),
1259
- 'SCANDIR_SORT_NONE' => array(
1260
- '5.3' => false,
1261
- '5.4' => true,
1262
- ),
1263
- // LibXML:
1264
- 'LIBXML_HTML_NODEFDTD' => array(
1265
- '5.3' => false,
1266
- '5.4' => true,
1267
- ),
1268
- 'LIBXML_HTML_NOIMPLIED' => array(
1269
- '5.3' => false,
1270
- '5.4' => true,
1271
- ),
1272
- 'LIBXML_PEDANTIC' => array(
1273
- '5.3' => false,
1274
- '5.4' => true,
1275
- ),
1276
- // OpenSSL:
1277
- 'OPENSSL_CIPHER_AES_128_CBC' => array(
1278
- '5.3' => false,
1279
- '5.4' => true,
1280
- ),
1281
- 'OPENSSL_CIPHER_AES_192_CBC' => array(
1282
- '5.3' => false,
1283
- '5.4' => true,
1284
- ),
1285
- 'OPENSSL_CIPHER_AES_256_CBC' => array(
1286
- '5.3' => false,
1287
- '5.4' => true,
1288
- ),
1289
- 'OPENSSL_RAW_DATA' => array(
1290
- '5.3' => false,
1291
- '5.4' => true,
1292
- ),
1293
- 'OPENSSL_ZERO_PADDING' => array(
1294
- '5.3' => false,
1295
- '5.4' => true,
1296
- ),
1297
- // Output buffering:
1298
- 'PHP_OUTPUT_HANDLER_CLEAN' => array(
1299
- '5.3' => false,
1300
- '5.4' => true,
1301
- ),
1302
- 'PHP_OUTPUT_HANDLER_CLEANABLE' => array(
1303
- '5.3' => false,
1304
- '5.4' => true,
1305
- ),
1306
- 'PHP_OUTPUT_HANDLER_DISABLED' => array(
1307
- '5.3' => false,
1308
- '5.4' => true,
1309
- ),
1310
- 'PHP_OUTPUT_HANDLER_FINAL' => array(
1311
- '5.3' => false,
1312
- '5.4' => true,
1313
- ),
1314
- 'PHP_OUTPUT_HANDLER_FLUSH' => array(
1315
- '5.3' => false,
1316
- '5.4' => true,
1317
- ),
1318
- 'PHP_OUTPUT_HANDLER_FLUSHABLE' => array(
1319
- '5.3' => false,
1320
- '5.4' => true,
1321
- ),
1322
- 'PHP_OUTPUT_HANDLER_REMOVABLE' => array(
1323
- '5.3' => false,
1324
- '5.4' => true,
1325
- ),
1326
- 'PHP_OUTPUT_HANDLER_STARTED' => array(
1327
- '5.3' => false,
1328
- '5.4' => true,
1329
- ),
1330
- 'PHP_OUTPUT_HANDLER_STDFLAGS' => array(
1331
- '5.3' => false,
1332
- '5.4' => true,
1333
- ),
1334
- 'PHP_OUTPUT_HANDLER_WRITE' => array(
1335
- '5.3' => false,
1336
- '5.4' => true,
1337
- ),
1338
- // Sessions:
1339
- 'PHP_SESSION_ACTIVE' => array(
1340
- '5.3' => false,
1341
- '5.4' => true,
1342
- ),
1343
- 'PHP_SESSION_DISABLED' => array(
1344
- '5.3' => false,
1345
- '5.4' => true,
1346
- ),
1347
- 'PHP_SESSION_NONE' => array(
1348
- '5.3' => false,
1349
- '5.4' => true,
1350
- ),
1351
- // Streams:
1352
- 'STREAM_META_ACCESS' => array(
1353
- '5.3' => false,
1354
- '5.4' => true,
1355
- ),
1356
- 'STREAM_META_GROUP' => array(
1357
- '5.3' => false,
1358
- '5.4' => true,
1359
- ),
1360
- 'STREAM_META_GROUP_NAME' => array(
1361
- '5.3' => false,
1362
- '5.4' => true,
1363
- ),
1364
- 'STREAM_META_OWNER' => array(
1365
- '5.3' => false,
1366
- '5.4' => true,
1367
- ),
1368
- 'STREAM_META_OWNER_NAME' => array(
1369
- '5.3' => false,
1370
- '5.4' => true,
1371
- ),
1372
- 'STREAM_META_TOUCH' => array(
1373
- '5.3' => false,
1374
- '5.4' => true,
1375
- ),
1376
- // Intl:
1377
- 'U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR' => array(
1378
- '5.3' => false,
1379
- '5.4' => true,
1380
- ),
1381
- 'IDNA_CHECK_BIDI' => array(
1382
- '5.3' => false,
1383
- '5.4' => true,
1384
- ),
1385
- 'IDNA_CHECK_CONTEXTJ' => array(
1386
- '5.3' => false,
1387
- '5.4' => true,
1388
- ),
1389
- 'IDNA_NONTRANSITIONAL_TO_ASCII' => array(
1390
- '5.3' => false,
1391
- '5.4' => true,
1392
- ),
1393
- 'IDNA_NONTRANSITIONAL_TO_UNICODE' => array(
1394
- '5.3' => false,
1395
- '5.4' => true,
1396
- ),
1397
- 'INTL_IDNA_VARIANT_2003' => array(
1398
- '5.3' => false,
1399
- '5.4' => true,
1400
- ),
1401
- 'INTL_IDNA_VARIANT_UTS46' => array(
1402
- '5.3' => false,
1403
- '5.4' => true,
1404
- ),
1405
- 'IDNA_ERROR_EMPTY_LABEL' => array(
1406
- '5.3' => false,
1407
- '5.4' => true,
1408
- ),
1409
- 'IDNA_ERROR_LABEL_TOO_LONG' => array(
1410
- '5.3' => false,
1411
- '5.4' => true,
1412
- ),
1413
- 'IDNA_ERROR_DOMAIN_NAME_TOO_LONG' => array(
1414
- '5.3' => false,
1415
- '5.4' => true,
1416
- ),
1417
- 'IDNA_ERROR_LEADING_HYPHEN' => array(
1418
- '5.3' => false,
1419
- '5.4' => true,
1420
- ),
1421
- 'IDNA_ERROR_TRAILING_HYPHEN' => array(
1422
- '5.3' => false,
1423
- '5.4' => true,
1424
- ),
1425
- 'IDNA_ERROR_HYPHEN_3_4' => array(
1426
- '5.3' => false,
1427
- '5.4' => true,
1428
- ),
1429
- 'IDNA_ERROR_LEADING_COMBINING_MARK' => array(
1430
- '5.3' => false,
1431
- '5.4' => true,
1432
- ),
1433
- 'IDNA_ERROR_DISALLOWED' => array(
1434
- '5.3' => false,
1435
- '5.4' => true,
1436
- ),
1437
- 'IDNA_ERROR_PUNYCODE' => array(
1438
- '5.3' => false,
1439
- '5.4' => true,
1440
- ),
1441
- 'IDNA_ERROR_LABEL_HAS_DOT' => array(
1442
- '5.3' => false,
1443
- '5.4' => true,
1444
- ),
1445
- 'IDNA_ERROR_INVALID_ACE_LABEL' => array(
1446
- '5.3' => false,
1447
- '5.4' => true,
1448
- ),
1449
- 'IDNA_ERROR_BIDI' => array(
1450
- '5.3' => false,
1451
- '5.4' => true,
1452
- ),
1453
- 'IDNA_ERROR_CONTEXTJ' => array(
1454
- '5.3' => false,
1455
- '5.4' => true,
1456
- ),
1457
- // Json:
1458
- 'JSON_PRETTY_PRINT' => array(
1459
- '5.3' => false,
1460
- '5.4' => true,
1461
- ),
1462
- 'JSON_UNESCAPED_SLASHES' => array(
1463
- '5.3' => false,
1464
- '5.4' => true,
1465
- ),
1466
- 'JSON_UNESCAPED_UNICODE' => array(
1467
- '5.3' => false,
1468
- '5.4' => true,
1469
- ),
1470
- 'JSON_BIGINT_AS_STRING' => array(
1471
- '5.3' => false,
1472
- '5.4' => true,
1473
- ),
1474
- 'JSON_OBJECT_AS_ARRAY' => array(
1475
- '5.3' => false,
1476
- '5.4' => true,
1477
- ),
1478
- // Snmp:
1479
- 'SNMP_OID_OUTPUT_SUFFIX' => array(
1480
- '5.3' => false,
1481
- '5.4' => true,
1482
- ),
1483
- 'SNMP_OID_OUTPUT_MODULE' => array(
1484
- '5.3' => false,
1485
- '5.4' => true,
1486
- ),
1487
- 'SNMP_OID_OUTPUT_UCD' => array(
1488
- '5.3' => false,
1489
- '5.4' => true,
1490
- ),
1491
- 'SNMP_OID_OUTPUT_NONE' => array(
1492
- '5.3' => false,
1493
- '5.4' => true,
1494
- ),
1495
- // Tokenizer:
1496
- 'T_INSTEADOF' => array(
1497
- '5.3' => false,
1498
- '5.4' => true,
1499
- ),
1500
- 'T_TRAIT' => array(
1501
- '5.3' => false,
1502
- '5.4' => true,
1503
- ),
1504
- 'T_TRAIT_C' => array(
1505
- '5.3' => false,
1506
- '5.4' => true,
1507
- ),
1508
-
1509
- // Curl:
1510
- 'CURLINFO_PRIMARY_IP' => array(
1511
- '5.4.6' => false,
1512
- '5.4.7' => true,
1513
- ),
1514
- 'CURLINFO_PRIMARY_PORT' => array(
1515
- '5.4.6' => false,
1516
- '5.4.7' => true,
1517
- ),
1518
- 'CURLINFO_LOCAL_IP' => array(
1519
- '5.4.6' => false,
1520
- '5.4.7' => true,
1521
- ),
1522
- 'CURLINFO_LOCAL_PORT' => array(
1523
- '5.4.6' => false,
1524
- '5.4.7' => true,
1525
- ),
1526
-
1527
- // OpenSSL:
1528
- 'OPENSSL_ALGO_RMD160' => array(
1529
- '5.4.7' => false,
1530
- '5.4.8' => true,
1531
- ),
1532
- 'OPENSSL_ALGO_SHA224' => array(
1533
- '5.4.7' => false,
1534
- '5.4.8' => true,
1535
- ),
1536
- 'OPENSSL_ALGO_SHA256' => array(
1537
- '5.4.7' => false,
1538
- '5.4.8' => true,
1539
- ),
1540
- 'OPENSSL_ALGO_SHA384' => array(
1541
- '5.4.7' => false,
1542
- '5.4.8' => true,
1543
- ),
1544
- 'OPENSSL_ALGO_SHA512' => array(
1545
- '5.4.7' => false,
1546
- '5.4.8' => true,
1547
- ),
1548
-
1549
- // Filter:
1550
- 'FILTER_VALIDATE_MAC' => array(
1551
- '5.4' => false,
1552
- '5.5' => true,
1553
- ),
1554
- // GD
1555
- 'IMG_AFFINE_TRANSLATE' => array(
1556
- '5.4' => false,
1557
- '5.5' => true,
1558
- ),
1559
- 'IMG_AFFINE_SCALE' => array(
1560
- '5.4' => false,
1561
- '5.5' => true,
1562
- ),
1563
- 'IMG_AFFINE_ROTATE' => array(
1564
- '5.4' => false,
1565
- '5.5' => true,
1566
- ),
1567
- 'IMG_AFFINE_SHEAR_HORIZONTAL' => array(
1568
- '5.4' => false,
1569
- '5.5' => true,
1570
- ),
1571
- 'IMG_AFFINE_SHEAR_VERTICAL' => array(
1572
- '5.4' => false,
1573
- '5.5' => true,
1574
- ),
1575
- 'IMG_CROP_DEFAULT' => array(
1576
- '5.4' => false,
1577
- '5.5' => true,
1578
- ),
1579
- 'IMG_CROP_TRANSPARENT' => array(
1580
- '5.4' => false,
1581
- '5.5' => true,
1582
- ),
1583
- 'IMG_CROP_BLACK' => array(
1584
- '5.4' => false,
1585
- '5.5' => true,
1586
- ),
1587
- 'IMG_CROP_WHITE' => array(
1588
- '5.4' => false,
1589
- '5.5' => true,
1590
- ),
1591
- 'IMG_CROP_SIDES' => array(
1592
- '5.4' => false,
1593
- '5.5' => true,
1594
- ),
1595
- 'IMG_FLIP_BOTH' => array(
1596
- '5.4' => false,
1597
- '5.5' => true,
1598
- ),
1599
- 'IMG_FLIP_HORIZONTAL' => array(
1600
- '5.4' => false,
1601
- '5.5' => true,
1602
- ),
1603
- 'IMG_FLIP_VERTICAL' => array(
1604
- '5.4' => false,
1605
- '5.5' => true,
1606
- ),
1607
- 'IMG_BELL' => array(
1608
- '5.4' => false,
1609
- '5.5' => true,
1610
- ),
1611
- 'IMG_BESSEL' => array(
1612
- '5.4' => false,
1613
- '5.5' => true,
1614
- ),
1615
- 'IMG_BILINEAR_FIXED' => array(
1616
- '5.4' => false,
1617
- '5.5' => true,
1618
- ),
1619
- 'IMG_BICUBIC' => array(
1620
- '5.4' => false,
1621
- '5.5' => true,
1622
- ),
1623
- 'IMG_BICUBIC_FIXED' => array(
1624
- '5.4' => false,
1625
- '5.5' => true,
1626
- ),
1627
- 'IMG_BLACKMAN' => array(
1628
- '5.4' => false,
1629
- '5.5' => true,
1630
- ),
1631
- 'IMG_BOX' => array(
1632
- '5.4' => false,
1633
- '5.5' => true,
1634
- ),
1635
- 'IMG_BSPLINE' => array(
1636
- '5.4' => false,
1637
- '5.5' => true,
1638
- ),
1639
- 'IMG_CATMULLROM' => array(
1640
- '5.4' => false,
1641
- '5.5' => true,
1642
- ),
1643
- 'IMG_GAUSSIAN' => array(
1644
- '5.4' => false,
1645
- '5.5' => true,
1646
- ),
1647
- 'IMG_GENERALIZED_CUBIC' => array(
1648
- '5.4' => false,
1649
- '5.5' => true,
1650
- ),
1651
- 'IMG_HERMITE' => array(
1652
- '5.4' => false,
1653
- '5.5' => true,
1654
- ),
1655
- 'IMG_HAMMING' => array(
1656
- '5.4' => false,
1657
- '5.5' => true,
1658
- ),
1659
- 'IMG_HANNING' => array(
1660
- '5.4' => false,
1661
- '5.5' => true,
1662
- ),
1663
- 'IMG_MITCHELL' => array(
1664
- '5.4' => false,
1665
- '5.5' => true,
1666
- ),
1667
- 'IMG_POWER' => array(
1668
- '5.4' => false,
1669
- '5.5' => true,
1670
- ),
1671
- 'IMG_QUADRATIC' => array(
1672
- '5.4' => false,
1673
- '5.5' => true,
1674
- ),
1675
- 'IMG_SINC' => array(
1676
- '5.4' => false,
1677
- '5.5' => true,
1678
- ),
1679
- 'IMG_NEAREST_NEIGHBOUR' => array(
1680
- '5.4' => false,
1681
- '5.5' => true,
1682
- ),
1683
- 'IMG_WEIGHTED4' => array(
1684
- '5.4' => false,
1685
- '5.5' => true,
1686
- ),
1687
- 'IMG_TRIANGLE' => array(
1688
- '5.4' => false,
1689
- '5.5' => true,
1690
- ),
1691
- // JSON:
1692
- 'JSON_ERROR_RECURSION' => array(
1693
- '5.4' => false,
1694
- '5.5' => true,
1695
- ),
1696
- 'JSON_ERROR_INF_OR_NAN' => array(
1697
- '5.4' => false,
1698
- '5.5' => true,
1699
- ),
1700
- 'JSON_ERROR_UNSUPPORTED_TYPE' => array(
1701
- '5.4' => false,
1702
- '5.5' => true,
1703
- ),
1704
- 'JSON_PARTIAL_OUTPUT_ON_ERROR' => array(
1705
- '5.4' => false,
1706
- '5.5' => true,
1707
- ),
1708
- // MySQLi
1709
- 'MYSQLI_SERVER_PUBLIC_KEY' => array(
1710
- '5.4' => false,
1711
- '5.5' => true,
1712
- ),
1713
- // Curl:
1714
- 'CURLOPT_SHARE' => array(
1715
- '5.4' => false,
1716
- '5.5' => true,
1717
- ),
1718
- 'CURLOPT_SSL_OPTIONS' => array(
1719
- '5.4' => false,
1720
- '5.5' => true,
1721
- ),
1722
- 'CURLSSLOPT_ALLOW_BEAST' => array(
1723
- '5.4' => false,
1724
- '5.5' => true,
1725
- ),
1726
- 'CURLOPT_USERNAME' => array(
1727
- '5.4' => false,
1728
- '5.5' => true,
1729
- ),
1730
- 'CURLINFO_RESPONSE_CODE' => array(
1731
- '5.4' => false,
1732
- '5.5' => true,
1733
- ),
1734
- 'CURLINFO_HTTP_CONNECTCODE' => array(
1735
- '5.4' => false,
1736
- '5.5' => true,
1737
- ),
1738
- 'CURLINFO_HTTPAUTH_AVAIL' => array(
1739
- '5.4' => false,
1740
- '5.5' => true,
1741
- ),
1742
- 'CURLINFO_PROXYAUTH_AVAIL' => array(
1743
- '5.4' => false,
1744
- '5.5' => true,
1745
- ),
1746
- 'CURLINFO_OS_ERRNO' => array(
1747
- '5.4' => false,
1748
- '5.5' => true,
1749
- ),
1750
- 'CURLINFO_NUM_CONNECTS' => array(
1751
- '5.4' => false,
1752
- '5.5' => true,
1753
- ),
1754
- 'CURLINFO_SSL_ENGINES' => array(
1755
- '5.4' => false,
1756
- '5.5' => true,
1757
- ),
1758
- 'CURLINFO_COOKIELIST' => array(
1759
- '5.4' => false,
1760
- '5.5' => true,
1761
- ),
1762
- 'CURLINFO_FTP_ENTRY_PATH' => array(
1763
- '5.4' => false,
1764
- '5.5' => true,
1765
- ),
1766
- 'CURLINFO_APPCONNECT_TIME' => array(
1767
- '5.4' => false,
1768
- '5.5' => true,
1769
- ),
1770
- 'CURLINFO_CONDITION_UNMET' => array(
1771
- '5.4' => false,
1772
- '5.5' => true,
1773
- ),
1774
- 'CURLINFO_RTSP_CLIENT_CSEQ' => array(
1775
- '5.4' => false,
1776
- '5.5' => true,
1777
- ),
1778
- 'CURLINFO_RTSP_CSEQ_RECV' => array(
1779
- '5.4' => false,
1780
- '5.5' => true,
1781
- ),
1782
- 'CURLINFO_RTSP_SERVER_CSEQ' => array(
1783
- '5.4' => false,
1784
- '5.5' => true,
1785
- ),
1786
- 'CURLINFO_RTSP_SESSION_ID' => array(
1787
- '5.4' => false,
1788
- '5.5' => true,
1789
- ),
1790
- 'CURLMOPT_PIPELINING' => array(
1791
- '5.4' => false,
1792
- '5.5' => true,
1793
- ),
1794
- 'CURLMOPT_MAXCONNECTS' => array(
1795
- '5.4' => false,
1796
- '5.5' => true,
1797
- ),
1798
- 'CURLPAUSE_ALL' => array(
1799
- '5.4' => false,
1800
- '5.5' => true,
1801
- ),
1802
- 'CURLPAUSE_CONT' => array(
1803
- '5.4' => false,
1804
- '5.5' => true,
1805
- ),
1806
- 'CURLPAUSE_RECV' => array(
1807
- '5.4' => false,
1808
- '5.5' => true,
1809
- ),
1810
- 'CURLPAUSE_RECV_CONT' => array(
1811
- '5.4' => false,
1812
- '5.5' => true,
1813
- ),
1814
- 'CURLPAUSE_SEND' => array(
1815
- '5.4' => false,
1816
- '5.5' => true,
1817
- ),
1818
- 'CURLPAUSE_SEND_CONT' => array(
1819
- '5.4' => false,
1820
- '5.5' => true,
1821
- ),
1822
- // Soap:
1823
- 'SOAP_SSL_METHOD_TLS' => array(
1824
- '5.4' => false,
1825
- '5.5' => true,
1826
- ),
1827
- 'SOAP_SSL_METHOD_SSLv2' => array(
1828
- '5.4' => false,
1829
- '5.5' => true,
1830
- ),
1831
- 'SOAP_SSL_METHOD_SSLv3' => array(
1832
- '5.4' => false,
1833
- '5.5' => true,
1834
- ),
1835
- 'SOAP_SSL_METHOD_SSLv23' => array(
1836
- '5.4' => false,
1837
- '5.5' => true,
1838
- ),
1839
- // Tokenizer:
1840
- 'T_FINALLY' => array(
1841
- '5.4' => false,
1842
- '5.5' => true,
1843
- ),
1844
- 'T_YIELD' => array(
1845
- '5.4' => false,
1846
- '5.5' => true,
1847
- ),
1848
- // Core/Password Hashing:
1849
- 'PASSWORD_BCRYPT' => array(
1850
- '5.4' => false,
1851
- '5.5' => true,
1852
- ),
1853
- 'PASSWORD_DEFAULT' => array(
1854
- '5.4' => false,
1855
- '5.5' => true,
1856
- ),
1857
- 'PASSWORD_BCRYPT_DEFAULT_COST' => array(
1858
- '5.4' => false,
1859
- '5.5' => true,
1860
- ),
1861
-
1862
-
1863
- // Libxml:
1864
- 'LIBXML_SCHEMA_CREATE' => array(
1865
- '5.5.1' => false,
1866
- '5.5.2' => true,
1867
- ),
1868
-
1869
- // Curl:
1870
- 'CURL_SSLVERSION_TLSv1_0' => array(
1871
- '5.5.18' => false,
1872
- '5.5.19' => true,
1873
- ),
1874
- 'CURL_SSLVERSION_TLSv1_1' => array(
1875
- '5.5.18' => false,
1876
- '5.5.19' => true,
1877
- ),
1878
- 'CURL_SSLVERSION_TLSv1_2' => array(
1879
- '5.5.18' => false,
1880
- '5.5.19' => true,
1881
- ),
1882
-
1883
- 'CURLPROXY_SOCKS4A' => array(
1884
- '5.5.22' => false,
1885
- '5.5.23' => true,
1886
- ),
1887
- 'CURLPROXY_SOCKS5_HOSTNAME' => array(
1888
- '5.5.22' => false,
1889
- '5.5.23' => true,
1890
- ),
1891
-
1892
- 'CURL_VERSION_HTTP2' => array(
1893
- '5.5.23' => false,
1894
- '5.5.24' => true,
1895
- ),
1896
-
1897
- 'ARRAY_FILTER_USE_KEY' => array(
1898
- '5.5' => false,
1899
- '5.6' => true,
1900
- ),
1901
- 'ARRAY_FILTER_USE_BOTH' => array(
1902
- '5.5' => false,
1903
- '5.6' => true,
1904
- ),
1905
- // LDAP:
1906
- 'LDAP_ESCAPE_DN' => array(
1907
- '5.5' => false,
1908
- '5.6' => true,
1909
- ),
1910
- 'LDAP_ESCAPE_FILTER' => array(
1911
- '5.5' => false,
1912
- '5.6' => true,
1913
- ),
1914
- // OpenSSL:
1915
- 'OPENSSL_DEFAULT_STREAM_CIPHERS' => array(
1916
- '5.5' => false,
1917
- '5.6' => true,
1918
- ),
1919
- 'STREAM_CRYPTO_METHOD_ANY_CLIENT' => array(
1920
- '5.5' => false,
1921
- '5.6' => true,
1922
- ),
1923
- 'STREAM_CRYPTO_METHOD_ANY_SERVER' => array(
1924
- '5.5' => false,
1925
- '5.6' => true,
1926
- ),
1927
- 'STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT' => array(
1928
- '5.5' => false,
1929
- '5.6' => true,
1930
- ),
1931
- 'STREAM_CRYPTO_METHOD_TLSv1_0_SERVER' => array(
1932
- '5.5' => false,
1933
- '5.6' => true,
1934
- ),
1935
- 'STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT' => array(
1936
- '5.5' => false,
1937
- '5.6' => true,
1938
- ),
1939
- 'STREAM_CRYPTO_METHOD_TLSv1_1_SERVER' => array(
1940
- '5.5' => false,
1941
- '5.6' => true,
1942
- ),
1943
- 'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT' => array(
1944
- '5.5' => false,
1945
- '5.6' => true,
1946
- ),
1947
- 'STREAM_CRYPTO_METHOD_TLSv1_2_SERVER' => array(
1948
- '5.5' => false,
1949
- '5.6' => true,
1950
- ),
1951
- // PostgreSQL:
1952
- 'PGSQL_CONNECT_ASYNC' => array(
1953
- '5.5' => false,
1954
- '5.6' => true,
1955
- ),
1956
- 'PGSQL_CONNECTION_AUTH_OK' => array(
1957
- '5.5' => false,
1958
- '5.6' => true,
1959
- ),
1960
- 'PGSQL_CONNECTION_AWAITING_RESPONSE' => array(
1961
- '5.5' => false,
1962
- '5.6' => true,
1963
- ),
1964
- 'PGSQL_CONNECTION_MADE' => array(
1965
- '5.5' => false,
1966
- '5.6' => true,
1967
- ),
1968
- 'PGSQL_CONNECTION_SETENV' => array(
1969
- '5.5' => false,
1970
- '5.6' => true,
1971
- ),
1972
- 'PGSQL_CONNECTION_SSL_STARTUP' => array(
1973
- '5.5' => false,
1974
- '5.6' => true,
1975
- ),
1976
- 'PGSQL_CONNECTION_STARTED' => array(
1977
- '5.5' => false,
1978
- '5.6' => true,
1979
- ),
1980
- 'PGSQL_DML_ESCAPE' => array(
1981
- '5.5' => false,
1982
- '5.6' => true,
1983
- ),
1984
- 'PGSQL_POLLING_ACTIVE' => array(
1985
- '5.5' => false,
1986
- '5.6' => true,
1987
- ),
1988
- 'PGSQL_POLLING_FAILED' => array(
1989
- '5.5' => false,
1990
- '5.6' => true,
1991
- ),
1992
- 'PGSQL_POLLING_OK' => array(
1993
- '5.5' => false,
1994
- '5.6' => true,
1995
- ),
1996
- 'PGSQL_POLLING_READING' => array(
1997
- '5.5' => false,
1998
- '5.6' => true,
1999
- ),
2000
- 'PGSQL_POLLING_WRITING' => array(
2001
- '5.5' => false,
2002
- '5.6' => true,
2003
- ),
2004
- // Tokenizer:
2005
- 'T_ELLIPSIS' => array(
2006
- '5.5' => false,
2007
- '5.6' => true,
2008
- ),
2009
- 'T_POW' => array(
2010
- '5.5' => false,
2011
- '5.6' => true,
2012
- ),
2013
- 'T_POW_EQUAL' => array(
2014
- '5.5' => false,
2015
- '5.6' => true,
2016
- ),
2017
-
2018
- 'INI_SCANNER_TYPED' => array(
2019
- '5.6.0' => false,
2020
- '5.6.1' => true,
2021
- ),
2022
-
2023
- 'JSON_PRESERVE_ZERO_FRACTION' => array(
2024
- '5.6.5' => false,
2025
- '5.6.6' => true,
2026
- ),
2027
-
2028
- 'MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT' => array(
2029
- '5.6.15' => false,
2030
- '5.6.16' => true,
2031
- ),
2032
-
2033
- // GD:
2034
- // Also introduced in 7.0.10.
2035
- 'IMG_WEBP' => array(
2036
- '5.6.24' => false,
2037
- '5.6.25' => true,
2038
- ),
2039
-
2040
-
2041
- 'TOKEN_PARSE' => array(
2042
- '5.6' => false,
2043
- '7.0' => true,
2044
- ),
2045
- 'FILTER_VALIDATE_DOMAIN' => array(
2046
- '5.6' => false,
2047
- '7.0' => true,
2048
- ),
2049
- 'PHP_INT_MIN' => array(
2050
- '5.6' => false,
2051
- '7.0' => true,
2052
- ),
2053
- // Curl:
2054
- 'CURLPIPE_NOTHING' => array(
2055
- '5.6' => false,
2056
- '7.0' => true,
2057
- ),
2058
- 'CURLPIPE_HTTP1' => array(
2059
- '5.6' => false,
2060
- '7.0' => true,
2061
- ),
2062
- 'CURLPIPE_MULTIPLEX' => array(
2063
- '5.6' => false,
2064
- '7.0' => true,
2065
- ),
2066
- // JSON:
2067
- 'JSON_ERROR_INVALID_PROPERTY_NAME' => array(
2068
- '5.6' => false,
2069
- '7.0' => true,
2070
- ),
2071
- 'JSON_ERROR_UTF16' => array(
2072
- '5.6' => false,
2073
- '7.0' => true,
2074
- ),
2075
- // LibXML:
2076
- 'LIBXML_BIGLINES' => array(
2077
- '5.6' => false,
2078
- '7.0' => true,
2079
- ),
2080
- // PCRE:
2081
- 'PREG_JIT_STACKLIMIT_ERROR' => array(
2082
- '5.6' => false,
2083
- '7.0' => true,
2084
- ),
2085
- // POSIX:
2086
- 'POSIX_RLIMIT_AS' => array(
2087
- '5.6' => false,
2088
- '7.0' => true,
2089
- ),
2090
- 'POSIX_RLIMIT_CORE' => array(
2091
- '5.6' => false,
2092
- '7.0' => true,
2093
- ),
2094
- 'POSIX_RLIMIT_CPU' => array(
2095
- '5.6' => false,
2096
- '7.0' => true,
2097
- ),
2098
- 'POSIX_RLIMIT_DATA' => array(
2099
- '5.6' => false,
2100
- '7.0' => true,
2101
- ),
2102
- 'POSIX_RLIMIT_FSIZE' => array(
2103
- '5.6' => false,
2104
- '7.0' => true,
2105
- ),
2106
- 'POSIX_RLIMIT_LOCKS' => array(
2107
- '5.6' => false,
2108
- '7.0' => true,
2109
- ),
2110
- 'POSIX_RLIMIT_MEMLOCK' => array(
2111
- '5.6' => false,
2112
- '7.0' => true,
2113
- ),
2114
- 'POSIX_RLIMIT_MSGQUEUE' => array(
2115
- '5.6' => false,
2116
- '7.0' => true,
2117
- ),
2118
- 'POSIX_RLIMIT_NICE' => array(
2119
- '5.6' => false,
2120
- '7.0' => true,
2121
- ),
2122
- 'POSIX_RLIMIT_NOFILE' => array(
2123
- '5.6' => false,
2124
- '7.0' => true,
2125
- ),
2126
- 'POSIX_RLIMIT_NPROC' => array(
2127
- '5.6' => false,
2128
- '7.0' => true,
2129
- ),
2130
- 'POSIX_RLIMIT_RSS' => array(
2131
- '5.6' => false,
2132
- '7.0' => true,
2133
- ),
2134
- 'POSIX_RLIMIT_RTPRIO' => array(
2135
- '5.6' => false,
2136
- '7.0' => true,
2137
- ),
2138
- 'POSIX_RLIMIT_RTTIME' => array(
2139
- '5.6' => false,
2140
- '7.0' => true,
2141
- ),
2142
- 'POSIX_RLIMIT_SIGPENDING' => array(
2143
- '5.6' => false,
2144
- '7.0' => true,
2145
- ),
2146
- 'POSIX_RLIMIT_STACK' => array(
2147
- '5.6' => false,
2148
- '7.0' => true,
2149
- ),
2150
- 'POSIX_RLIMIT_INFINITY' => array(
2151
- '5.6' => false,
2152
- '7.0' => true,
2153
- ),
2154
- // Tokenizer:
2155
- 'T_COALESCE' => array(
2156
- '5.6' => false,
2157
- '7.0' => true,
2158
- ),
2159
- 'T_SPACESHIP' => array(
2160
- '5.6' => false,
2161
- '7.0' => true,
2162
- ),
2163
- 'T_YIELD_FROM' => array(
2164
- '5.6' => false,
2165
- '7.0' => true,
2166
- ),
2167
-
2168
- // Zlib:
2169
- // The first three are in the PHP 5.4 changelog, but the Extension constant page says 7.0.
2170
- 'ZLIB_ENCODING_RAW' => array(
2171
- '5.6' => false,
2172
- '7.0' => true,
2173
- ),
2174
- 'ZLIB_ENCODING_DEFLATE' => array(
2175
- '5.6' => false,
2176
- '7.0' => true,
2177
- ),
2178
- 'ZLIB_ENCODING_GZIP' => array(
2179
- '5.6' => false,
2180
- '7.0' => true,
2181
- ),
2182
- 'ZLIB_FILTERED' => array(
2183
- '5.6' => false,
2184
- '7.0' => true,
2185
- ),
2186
- 'ZLIB_HUFFMAN_ONLY' => array(
2187
- '5.6' => false,
2188
- '7.0' => true,
2189
- ),
2190
- 'ZLIB_FIXED' => array(
2191
- '5.6' => false,
2192
- '7.0' => true,
2193
- ),
2194
- 'ZLIB_RLE' => array(
2195
- '5.6' => false,
2196
- '7.0' => true,
2197
- ),
2198
- 'ZLIB_DEFAULT_STRATEGY' => array(
2199
- '5.6' => false,
2200
- '7.0' => true,
2201
- ),
2202
- 'ZLIB_BLOCK' => array(
2203
- '5.6' => false,
2204
- '7.0' => true,
2205
- ),
2206
- 'ZLIB_FINISH' => array(
2207
- '5.6' => false,
2208
- '7.0' => true,
2209
- ),
2210
- 'ZLIB_FULL_FLUSH' => array(
2211
- '5.6' => false,
2212
- '7.0' => true,
2213
- ),
2214
- 'ZLIB_NO_FLUSH' => array(
2215
- '5.6' => false,
2216
- '7.0' => true,
2217
- ),
2218
- 'ZLIB_PARTIAL_FLUSH' => array(
2219
- '5.6' => false,
2220
- '7.0' => true,
2221
- ),
2222
- 'ZLIB_SYNC_FLUSH' => array(
2223
- '5.6' => false,
2224
- '7.0' => true,
2225
- ),
2226
-
2227
- 'CURL_HTTP_VERSION_2' => array(
2228
- '7.0.6' => false,
2229
- '7.0.7' => true,
2230
- ),
2231
- 'CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE' => array(
2232
- '7.0.6' => false,
2233
- '7.0.7' => true,
2234
- ),
2235
- 'CURL_HTTP_VERSION_2TLS' => array(
2236
- '7.0.6' => false,
2237
- '7.0.7' => true,
2238
- ),
2239
- 'CURL_REDIR_POST_301' => array(
2240
- '7.0.6' => false,
2241
- '7.0.7' => true,
2242
- ),
2243
- 'CURL_REDIR_POST_302' => array(
2244
- '7.0.6' => false,
2245
- '7.0.7' => true,
2246
- ),
2247
- 'CURL_REDIR_POST_303' => array(
2248
- '7.0.6' => false,
2249
- '7.0.7' => true,
2250
- ),
2251
- 'CURL_REDIR_POST_ALL' => array(
2252
- '7.0.6' => false,
2253
- '7.0.7' => true,
2254
- ),
2255
- 'CURL_VERSION_KERBEROS5' => array(
2256
- '7.0.6' => false,
2257
- '7.0.7' => true,
2258
- ),
2259
- 'CURL_VERSION_PSL' => array(
2260
- '7.0.6' => false,
2261
- '7.0.7' => true,
2262
- ),
2263
- 'CURL_VERSION_UNIX_SOCKETS' => array(
2264
- '7.0.6' => false,
2265
- '7.0.7' => true,
2266
- ),
2267
- 'CURLAUTH_NEGOTIATE' => array(
2268
- '7.0.6' => false,
2269
- '7.0.7' => true,
2270
- ),
2271
- 'CURLAUTH_NTLM_WB' => array(
2272
- '7.0.6' => false,
2273
- '7.0.7' => true,
2274
- ),
2275
- 'CURLFTP_CREATE_DIR' => array(
2276
- '7.0.6' => false,
2277
- '7.0.7' => true,
2278
- ),
2279
- 'CURLFTP_CREATE_DIR_NONE' => array(
2280
- '7.0.6' => false,
2281
- '7.0.7' => true,
2282
- ),
2283
- 'CURLFTP_CREATE_DIR_RETRY' => array(
2284
- '7.0.6' => false,
2285
- '7.0.7' => true,
2286
- ),
2287
- 'CURLHEADER_SEPARATE' => array(
2288
- '7.0.6' => false,
2289
- '7.0.7' => true,
2290
- ),
2291
- 'CURLHEADER_UNIFIED' => array(
2292
- '7.0.6' => false,
2293
- '7.0.7' => true,
2294
- ),
2295
- 'CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE' => array(
2296
- '7.0.6' => false,
2297
- '7.0.7' => true,
2298
- ),
2299
- 'CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE' => array(
2300
- '7.0.6' => false,
2301
- '7.0.7' => true,
2302
- ),
2303
- 'CURLMOPT_MAX_HOST_CONNECTIONS' => array(
2304
- '7.0.6' => false,
2305
- '7.0.7' => true,
2306
- ),
2307
- 'CURLMOPT_MAX_PIPELINE_LENGTH' => array(
2308
- '7.0.6' => false,
2309
- '7.0.7' => true,
2310
- ),
2311
- 'CURLMOPT_MAX_TOTAL_CONNECTIONS' => array(
2312
- '7.0.6' => false,
2313
- '7.0.7' => true,
2314
- ),
2315
- 'CURLOPT_CONNECT_TO' => array(
2316
- '7.0.6' => false,
2317
- '7.0.7' => true,
2318
- ),
2319
- 'CURLOPT_DEFAULT_PROTOCOL' => array(
2320
- '7.0.6' => false,
2321
- '7.0.7' => true,
2322
- ),
2323
- 'CURLOPT_DNS_INTERFACE' => array(
2324
- '7.0.6' => false,
2325
- '7.0.7' => true,
2326
- ),
2327
- 'CURLOPT_DNS_LOCAL_IP4' => array(
2328
- '7.0.6' => false,
2329
- '7.0.7' => true,
2330
- ),
2331
- 'CURLOPT_DNS_LOCAL_IP6' => array(
2332
- '7.0.6' => false,
2333
- '7.0.7' => true,
2334
- ),
2335
- 'CURLOPT_EXPECT_100_TIMEOUT_MS' => array(
2336
- '7.0.6' => false,
2337
- '7.0.7' => true,
2338
- ),
2339
- 'CURLOPT_HEADEROPT' => array(
2340
- '7.0.6' => false,
2341
- '7.0.7' => true,
2342
- ),
2343
- 'CURLOPT_LOGIN_OPTIONS' => array(
2344
- '7.0.6' => false,
2345
- '7.0.7' => true,
2346
- ),
2347
- 'CURLOPT_PATH_AS_IS' => array(
2348
- '7.0.6' => false,
2349
- '7.0.7' => true,
2350
- ),
2351
- 'CURLOPT_PINNEDPUBLICKEY' => array(
2352
- '7.0.6' => false,
2353
- '7.0.7' => true,
2354
- ),
2355
- 'CURLOPT_PIPEWAIT' => array(
2356
- '7.0.6' => false,
2357
- '7.0.7' => true,
2358
- ),
2359
- 'CURLOPT_PROXY_SERVICE_NAME' => array(
2360
- '7.0.6' => false,
2361
- '7.0.7' => true,
2362
- ),
2363
- 'CURLOPT_PROXYHEADER' => array(
2364
- '7.0.6' => false,
2365
- '7.0.7' => true,
2366
- ),
2367
- 'CURLOPT_SASL_IR' => array(
2368
- '7.0.6' => false,
2369
- '7.0.7' => true,
2370
- ),
2371
- 'CURLOPT_SERVICE_NAME' => array(
2372
- '7.0.6' => false,
2373
- '7.0.7' => true,
2374
- ),
2375
- 'CURLOPT_SSL_ENABLE_ALPN' => array(
2376
- '7.0.6' => false,
2377
- '7.0.7' => true,
2378
- ),
2379
- 'CURLOPT_SSL_ENABLE_NPN' => array(
2380
- '7.0.6' => false,
2381
- '7.0.7' => true,
2382
- ),
2383
- 'CURLOPT_SSL_FALSESTART' => array(
2384
- '7.0.6' => false,
2385
- '7.0.7' => true,
2386
- ),
2387
- 'CURLOPT_SSL_VERIFYSTATUS' => array(
2388
- '7.0.6' => false,
2389
- '7.0.7' => true,
2390
- ),
2391
- 'CURLOPT_STREAM_WEIGHT' => array(
2392
- '7.0.6' => false,
2393
- '7.0.7' => true,
2394
- ),
2395
- 'CURLOPT_TCP_FASTOPEN' => array(
2396
- '7.0.6' => false,
2397
- '7.0.7' => true,
2398
- ),
2399
- 'CURLOPT_TFTP_NO_OPTIONS' => array(
2400
- '7.0.6' => false,
2401
- '7.0.7' => true,
2402
- ),
2403
- 'CURLOPT_UNIX_SOCKET_PATH' => array(
2404
- '7.0.6' => false,
2405
- '7.0.7' => true,
2406
- ),
2407
- 'CURLOPT_XOAUTH2_BEARER' => array(
2408
- '7.0.6' => false,
2409
- '7.0.7' => true,
2410
- ),
2411
- 'CURLPROTO_SMB' => array(
2412
- '7.0.6' => false,
2413
- '7.0.7' => true,
2414
- ),
2415
- 'CURLPROTO_SMBS' => array(
2416
- '7.0.6' => false,
2417
- '7.0.7' => true,
2418
- ),
2419
- 'CURLPROXY_HTTP_1_0' => array(
2420
- '7.0.6' => false,
2421
- '7.0.7' => true,
2422
- ),
2423
- 'CURLSSH_AUTH_AGENT' => array(
2424
- '7.0.6' => false,
2425
- '7.0.7' => true,
2426
- ),
2427
- 'CURLSSLOPT_NO_REVOKE' => array(
2428
- '7.0.6' => false,
2429
- '7.0.7' => true,
2430
- ),
2431
-
2432
- 'PHP_FD_SETSIZE' => array(
2433
- '7.0' => false,
2434
- '7.1' => true,
2435
- ),
2436
- // Curl:
2437
- 'CURLMOPT_PUSHFUNCTION' => array(
2438
- '7.0' => false,
2439
- '7.1' => true,
2440
- ),
2441
- 'CURL_PUSH_OK' => array(
2442
- '7.0' => false,
2443
- '7.1' => true,
2444
- ),
2445
- 'CURL_PUSH_DENY' => array(
2446
- '7.0' => false,
2447
- '7.1' => true,
2448
- ),
2449
- // Filter:
2450
- 'FILTER_FLAG_EMAIL_UNICODE' => array(
2451
- '7.0' => false,
2452
- '7.1' => true,
2453
- ),
2454
- // GD:
2455
- 'IMAGETYPE_WEBP' => array(
2456
- '7.0' => false,
2457
- '7.1' => true,
2458
- ),
2459
- // Json:
2460
- 'JSON_UNESCAPED_LINE_TERMINATORS' => array(
2461
- '7.0' => false,
2462
- '7.1' => true,
2463
- ),
2464
- // LDAP:
2465
- 'LDAP_OPT_X_SASL_NOCANON' => array(
2466
- '7.0' => false,
2467
- '7.1' => true,
2468
- ),
2469
- 'LDAP_OPT_X_SASL_USERNAME' => array(
2470
- '7.0' => false,
2471
- '7.1' => true,
2472
- ),
2473
- 'LDAP_OPT_X_TLS_CACERTDIR' => array(
2474
- '7.0' => false,
2475
- '7.1' => true,
2476
- ),
2477
- 'LDAP_OPT_X_TLS_CACERTFILE' => array(
2478
- '7.0' => false,
2479
- '7.1' => true,
2480
- ),
2481
- 'LDAP_OPT_X_TLS_CERTFILE' => array(
2482
- '7.0' => false,
2483
- '7.1' => true,
2484
- ),
2485
- 'LDAP_OPT_X_TLS_CIPHER_SUITE' => array(
2486
- '7.0' => false,
2487
- '7.1' => true,
2488
- ),
2489
- 'LDAP_OPT_X_TLS_KEYFILE' => array(
2490
- '7.0' => false,
2491
- '7.1' => true,
2492
- ),
2493
- 'LDAP_OPT_X_TLS_RANDOM_FILE' => array(
2494
- '7.0' => false,
2495
- '7.1' => true,
2496
- ),
2497
- 'LDAP_OPT_X_TLS_CRLCHECK' => array(
2498
- '7.0' => false,
2499
- '7.1' => true,
2500
- ),
2501
- 'LDAP_OPT_X_TLS_CRL_NONE' => array(
2502
- '7.0' => false,
2503
- '7.1' => true,
2504
- ),
2505
- 'LDAP_OPT_X_TLS_CRL_PEER' => array(
2506
- '7.0' => false,
2507
- '7.1' => true,
2508
- ),
2509
- 'LDAP_OPT_X_TLS_CRL_ALL' => array(
2510
- '7.0' => false,
2511
- '7.1' => true,
2512
- ),
2513
- 'LDAP_OPT_X_TLS_DHFILE' => array(
2514
- '7.0' => false,
2515
- '7.1' => true,
2516
- ),
2517
- 'LDAP_OPT_X_TLS_CRLFILE' => array(
2518
- '7.0' => false,
2519
- '7.1' => true,
2520
- ),
2521
- 'LDAP_OPT_X_TLS_PROTOCOL_MIN' => array(
2522
- '7.0' => false,
2523
- '7.1' => true,
2524
- ),
2525
- 'LDAP_OPT_X_TLS_PROTOCOL_SSL2' => array(
2526
- '7.0' => false,
2527
- '7.1' => true,
2528
- ),
2529
- 'LDAP_OPT_X_TLS_PROTOCOL_SSL3' => array(
2530
- '7.0' => false,
2531
- '7.1' => true,
2532
- ),
2533
- 'LDAP_OPT_X_TLS_PROTOCOL_TLS1_0' => array(
2534
- '7.0' => false,
2535
- '7.1' => true,
2536
- ),
2537
- 'LDAP_OPT_X_TLS_PROTOCOL_TLS1_1' => array(
2538
- '7.0' => false,
2539
- '7.1' => true,
2540
- ),
2541
- 'LDAP_OPT_X_TLS_PROTOCOL_TLS1_2' => array(
2542
- '7.0' => false,
2543
- '7.1' => true,
2544
- ),
2545
- 'LDAP_OPT_X_TLS_PACKAGE' => array(
2546
- '7.0' => false,
2547
- '7.1' => true,
2548
- ),
2549
- 'LDAP_OPT_X_KEEPALIVE_IDLE' => array(
2550
- '7.0' => false,
2551
- '7.1' => true,
2552
- ),
2553
- 'LDAP_OPT_X_KEEPALIVE_PROBES' => array(
2554
- '7.0' => false,
2555
- '7.1' => true,
2556
- ),
2557
- 'LDAP_OPT_X_KEEPALIVE_INTERVAL' => array(
2558
- '7.0' => false,
2559
- '7.1' => true,
2560
- ),
2561
- // PostgreSQL:
2562
- 'PGSQL_NOTICE_LAST' => array(
2563
- '7.0' => false,
2564
- '7.1' => true,
2565
- ),
2566
- 'PGSQL_NOTICE_ALL' => array(
2567
- '7.0' => false,
2568
- '7.1' => true,
2569
- ),
2570
- 'PGSQL_NOTICE_CLEAR' => array(
2571
- '7.0' => false,
2572
- '7.1' => true,
2573
- ),
2574
- // SPL:
2575
- 'MT_RAND_PHP' => array(
2576
- '7.0' => false,
2577
- '7.1' => true,
2578
- ),
2579
-
2580
- // SQLite3:
2581
- 'SQLITE3_DETERMINISTIC' => array(
2582
- '7.1.3' => false,
2583
- '7.1.4' => true,
2584
- ),
2585
-
2586
- // Core:
2587
- 'PHP_OS_FAMILY' => array(
2588
- '7.1' => false,
2589
- '7.2' => true,
2590
- ),
2591
- 'PHP_FLOAT_DIG' => array(
2592
- '7.1' => false,
2593
- '7.2' => true,
2594
- ),
2595
- 'PHP_FLOAT_EPSILON' => array(
2596
- '7.1' => false,
2597
- '7.2' => true,
2598
- ),
2599
- 'PHP_FLOAT_MIN' => array(
2600
- '7.1' => false,
2601
- '7.2' => true,
2602
- ),
2603
- 'PHP_FLOAT_MAX' => array(
2604
- '7.1' => false,
2605
- '7.2' => true,
2606
- ),
2607
-
2608
- // Core/Password Hashing:
2609
- 'PASSWORD_ARGON2I' => array(
2610
- '7.1' => false,
2611
- '7.2' => true,
2612
- ),
2613
- 'PASSWORD_ARGON2_DEFAULT_MEMORY_COST' => array(
2614
- '7.1' => false,
2615
- '7.2' => true,
2616
- ),
2617
- 'PASSWORD_ARGON2_DEFAULT_TIME_COST' => array(
2618
- '7.1' => false,
2619
- '7.2' => true,
2620
- ),
2621
- 'PASSWORD_ARGON2_DEFAULT_THREADS' => array(
2622
- '7.1' => false,
2623
- '7.2' => true,
2624
- ),
2625
-
2626
- // Fileinfo:
2627
- 'FILEINFO_EXTENSION' => array(
2628
- '7.1' => false,
2629
- '7.2' => true,
2630
- ),
2631
-
2632
- // GD:
2633
- 'IMG_EFFECT_MULTIPLY' => array(
2634
- '7.1' => false,
2635
- '7.2' => true,
2636
- ),
2637
- 'IMG_BMP' => array(
2638
- '7.1' => false,
2639
- '7.2' => true,
2640
- ),
2641
-
2642
- // JSON:
2643
- 'JSON_INVALID_UTF8_IGNORE' => array(
2644
- '7.1' => false,
2645
- '7.2' => true,
2646
- ),
2647
- 'JSON_INVALID_UTF8_SUBSTITUTE' => array(
2648
- '7.1' => false,
2649
- '7.2' => true,
2650
- ),
2651
-
2652
- // LDAP:
2653
- 'LDAP_EXOP_START_TLS' => array(
2654
- '7.1' => false,
2655
- '7.2' => true,
2656
- ),
2657
- 'LDAP_EXOP_MODIFY_PASSWD' => array(
2658
- '7.1' => false,
2659
- '7.2' => true,
2660
- ),
2661
- 'LDAP_EXOP_REFRESH' => array(
2662
- '7.1' => false,
2663
- '7.2' => true,
2664
- ),
2665
- 'LDAP_EXOP_WHO_AM_I' => array(
2666
- '7.1' => false,
2667
- '7.2' => true,
2668
- ),
2669
- 'LDAP_EXOP_TURN' => array(
2670
- '7.1' => false,
2671
- '7.2' => true,
2672
- ),
2673
-
2674
- // PCRE:
2675
- 'PREG_UNMATCHED_AS_NULL' => array(
2676
- '7.1' => false,
2677
- '7.2' => true,
2678
- ),
2679
-
2680
- // Sodium:
2681
- 'SODIUM_LIBRARY_VERSION' => array(
2682
- '7.1' => false,
2683
- '7.2' => true,
2684
- ),
2685
- 'SODIUM_LIBRARY_MAJOR_VERSION' => array(
2686
- '7.1' => false,
2687
- '7.2' => true,
2688
- ),
2689
- 'SODIUM_LIBRARY_MINOR_VERSION' => array(
2690
- '7.1' => false,
2691
- '7.2' => true,
2692
- ),
2693
- 'SODIUM_BASE64_VARIANT_ORIGINAL' => array(
2694
- '7.1' => false,
2695
- '7.2' => true,
2696
- ),
2697
- 'SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING' => array(
2698
- '7.1' => false,
2699
- '7.2' => true,
2700
- ),
2701
- 'SODIUM_BASE64_VARIANT_URLSAFE' => array(
2702
- '7.1' => false,
2703
- '7.2' => true,
2704
- ),
2705
- 'SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING' => array(
2706
- '7.1' => false,
2707
- '7.2' => true,
2708
- ),
2709
- 'SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES' => array(
2710
- '7.1' => false,
2711
- '7.2' => true,
2712
- ),
2713
- 'SODIUM_CRYPTO_AEAD_AES256GCM_NSECBYTES' => array(
2714
- '7.1' => false,
2715
- '7.2' => true,
2716
- ),
2717
- 'SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES' => array(
2718
- '7.1' => false,
2719
- '7.2' => true,
2720
- ),
2721
- 'SODIUM_CRYPTO_AEAD_AES256GCM_ABYTES' => array(
2722
- '7.1' => false,
2723
- '7.2' => true,
2724
- ),
2725
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES' => array(
2726
- '7.1' => false,
2727
- '7.2' => true,
2728
- ),
2729
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES' => array(
2730
- '7.1' => false,
2731
- '7.2' => true,
2732
- ),
2733
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES' => array(
2734
- '7.1' => false,
2735
- '7.2' => true,
2736
- ),
2737
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_ABYTES' => array(
2738
- '7.1' => false,
2739
- '7.2' => true,
2740
- ),
2741
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES' => array(
2742
- '7.1' => false,
2743
- '7.2' => true,
2744
- ),
2745
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES' => array(
2746
- '7.1' => false,
2747
- '7.2' => true,
2748
- ),
2749
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES' => array(
2750
- '7.1' => false,
2751
- '7.2' => true,
2752
- ),
2753
- 'SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES' => array(
2754
- '7.1' => false,
2755
- '7.2' => true,
2756
- ),
2757
- 'SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES' => array(
2758
- '7.1' => false,
2759
- '7.2' => true,
2760
- ),
2761
- 'SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES' => array(
2762
- '7.1' => false,
2763
- '7.2' => true,
2764
- ),
2765
- 'SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES' => array(
2766
- '7.1' => false,
2767
- '7.2' => true,
2768
- ),
2769
- 'SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES' => array(
2770
- '7.1' => false,
2771
- '7.2' => true,
2772
- ),
2773
- 'SODIUM_CRYPTO_AUTH_BYTES' => array(
2774
- '7.1' => false,
2775
- '7.2' => true,
2776
- ),
2777
- 'SODIUM_CRYPTO_AUTH_KEYBYTES' => array(
2778
- '7.1' => false,
2779
- '7.2' => true,
2780
- ),
2781
- 'SODIUM_CRYPTO_BOX_SEALBYTES' => array(
2782
- '7.1' => false,
2783
- '7.2' => true,
2784
- ),
2785
- 'SODIUM_CRYPTO_BOX_SECRETKEYBYTES' => array(
2786
- '7.1' => false,
2787
- '7.2' => true,
2788
- ),
2789
- 'SODIUM_CRYPTO_BOX_PUBLICKEYBYTES' => array(
2790
- '7.1' => false,
2791
- '7.2' => true,
2792
- ),
2793
- 'SODIUM_CRYPTO_BOX_KEYPAIRBYTES' => array(
2794
- '7.1' => false,
2795
- '7.2' => true,
2796
- ),
2797
- 'SODIUM_CRYPTO_BOX_MACBYTES' => array(
2798
- '7.1' => false,
2799
- '7.2' => true,
2800
- ),
2801
- 'SODIUM_CRYPTO_BOX_NONCEBYTES' => array(
2802
- '7.1' => false,
2803
- '7.2' => true,
2804
- ),
2805
- 'SODIUM_CRYPTO_BOX_SEEDBYTES' => array(
2806
- '7.1' => false,
2807
- '7.2' => true,
2808
- ),
2809
- 'SODIUM_CRYPTO_KDF_BYTES_MIN' => array(
2810
- '7.1' => false,
2811
- '7.2' => true,
2812
- ),
2813
- 'SODIUM_CRYPTO_KDF_BYTES_MAX' => array(
2814
- '7.1' => false,
2815
- '7.2' => true,
2816
- ),
2817
- 'SODIUM_CRYPTO_KDF_CONTEXTBYTES' => array(
2818
- '7.1' => false,
2819
- '7.2' => true,
2820
- ),
2821
- 'SODIUM_CRYPTO_KDF_KEYBYTES' => array(
2822
- '7.1' => false,
2823
- '7.2' => true,
2824
- ),
2825
- 'SODIUM_CRYPTO_KX_SEEDBYTES' => array(
2826
- '7.1' => false,
2827
- '7.2' => true,
2828
- ),
2829
- 'SODIUM_CRYPTO_KX_SESSIONKEYBYTES' => array(
2830
- '7.1' => false,
2831
- '7.2' => true,
2832
- ),
2833
- 'SODIUM_CRYPTO_KX_PUBLICKEYBYTES' => array(
2834
- '7.1' => false,
2835
- '7.2' => true,
2836
- ),
2837
- 'SODIUM_CRYPTO_KX_SECRETKEYBYTES' => array(
2838
- '7.1' => false,
2839
- '7.2' => true,
2840
- ),
2841
- 'SODIUM_CRYPTO_KX_KEYPAIRBYTES' => array(
2842
- '7.1' => false,
2843
- '7.2' => true,
2844
- ),
2845
- 'SODIUM_CRYPTO_GENERICHASH_BYTES' => array(
2846
- '7.1' => false,
2847
- '7.2' => true,
2848
- ),
2849
- 'SODIUM_CRYPTO_GENERICHASH_BYTES_MIN' => array(
2850
- '7.1' => false,
2851
- '7.2' => true,
2852
- ),
2853
- 'SODIUM_CRYPTO_GENERICHASH_BYTES_MAX' => array(
2854
- '7.1' => false,
2855
- '7.2' => true,
2856
- ),
2857
- 'SODIUM_CRYPTO_GENERICHASH_KEYBYTES' => array(
2858
- '7.1' => false,
2859
- '7.2' => true,
2860
- ),
2861
- 'SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MIN' => array(
2862
- '7.1' => false,
2863
- '7.2' => true,
2864
- ),
2865
- 'SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MAX' => array(
2866
- '7.1' => false,
2867
- '7.2' => true,
2868
- ),
2869
- 'SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13' => array(
2870
- '7.1' => false,
2871
- '7.2' => true,
2872
- ),
2873
- 'SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13' => array(
2874
- '7.1' => false,
2875
- '7.2' => true,
2876
- ),
2877
- 'SODIUM_CRYPTO_PWHASH_ALG_DEFAULT' => array(
2878
- '7.1' => false,
2879
- '7.2' => true,
2880
- ),
2881
- 'SODIUM_CRYPTO_PWHASH_SALTBYTES' => array(
2882
- '7.1' => false,
2883
- '7.2' => true,
2884
- ),
2885
- 'SODIUM_CRYPTO_PWHASH_STRPREFIX' => array(
2886
- '7.1' => false,
2887
- '7.2' => true,
2888
- ),
2889
- 'SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE' => array(
2890
- '7.1' => false,
2891
- '7.2' => true,
2892
- ),
2893
- 'SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE' => array(
2894
- '7.1' => false,
2895
- '7.2' => true,
2896
- ),
2897
- 'SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE' => array(
2898
- '7.1' => false,
2899
- '7.2' => true,
2900
- ),
2901
- 'SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE' => array(
2902
- '7.1' => false,
2903
- '7.2' => true,
2904
- ),
2905
- 'SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE' => array(
2906
- '7.1' => false,
2907
- '7.2' => true,
2908
- ),
2909
- 'SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE' => array(
2910
- '7.1' => false,
2911
- '7.2' => true,
2912
- ),
2913
- 'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES' => array(
2914
- '7.1' => false,
2915
- '7.2' => true,
2916
- ),
2917
- 'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX' => array(
2918
- '7.1' => false,
2919
- '7.2' => true,
2920
- ),
2921
- 'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE' => array(
2922
- '7.1' => false,
2923
- '7.2' => true,
2924
- ),
2925
- 'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE' => array(
2926
- '7.1' => false,
2927
- '7.2' => true,
2928
- ),
2929
- 'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE' => array(
2930
- '7.1' => false,
2931
- '7.2' => true,
2932
- ),
2933
- 'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE' => array(
2934
- '7.1' => false,
2935
- '7.2' => true,
2936
- ),
2937
- 'SODIUM_CRYPTO_SCALARMULT_BYTES' => array(
2938
- '7.1' => false,
2939
- '7.2' => true,
2940
- ),
2941
- 'SODIUM_CRYPTO_SCALARMULT_SCALARBYTES' => array(
2942
- '7.1' => false,
2943
- '7.2' => true,
2944
- ),
2945
- 'SODIUM_CRYPTO_SHORTHASH_BYTES' => array(
2946
- '7.1' => false,
2947
- '7.2' => true,
2948
- ),
2949
- 'SODIUM_CRYPTO_SHORTHASH_KEYBYTES' => array(
2950
- '7.1' => false,
2951
- '7.2' => true,
2952
- ),
2953
- 'SODIUM_CRYPTO_SECRETBOX_KEYBYTES' => array(
2954
- '7.1' => false,
2955
- '7.2' => true,
2956
- ),
2957
- 'SODIUM_CRYPTO_SECRETBOX_MACBYTES' => array(
2958
- '7.1' => false,
2959
- '7.2' => true,
2960
- ),
2961
- 'SODIUM_CRYPTO_SECRETBOX_NONCEBYTES' => array(
2962
- '7.1' => false,
2963
- '7.2' => true,
2964
- ),
2965
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES' => array(
2966
- '7.1' => false,
2967
- '7.2' => true,
2968
- ),
2969
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES' => array(
2970
- '7.1' => false,
2971
- '7.2' => true,
2972
- ),
2973
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES' => array(
2974
- '7.1' => false,
2975
- '7.2' => true,
2976
- ),
2977
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX' => array(
2978
- '7.1' => false,
2979
- '7.2' => true,
2980
- ),
2981
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE' => array(
2982
- '7.1' => false,
2983
- '7.2' => true,
2984
- ),
2985
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH' => array(
2986
- '7.1' => false,
2987
- '7.2' => true,
2988
- ),
2989
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY' => array(
2990
- '7.1' => false,
2991
- '7.2' => true,
2992
- ),
2993
- 'SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL' => array(
2994
- '7.1' => false,
2995
- '7.2' => true,
2996
- ),
2997
- 'SODIUM_CRYPTO_SIGN_BYTES' => array(
2998
- '7.1' => false,
2999
- '7.2' => true,
3000
- ),
3001
- 'SODIUM_CRYPTO_SIGN_SEEDBYTES' => array(
3002
- '7.1' => false,
3003
- '7.2' => true,
3004
- ),
3005
- 'SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES' => array(
3006
- '7.1' => false,
3007
- '7.2' => true,
3008
- ),
3009
- 'SODIUM_CRYPTO_SIGN_SECRETKEYBYTES' => array(
3010
- '7.1' => false,
3011
- '7.2' => true,
3012
- ),
3013
- 'SODIUM_CRYPTO_SIGN_KEYPAIRBYTES' => array(
3014
- '7.1' => false,
3015
- '7.2' => true,
3016
- ),
3017
- 'SODIUM_CRYPTO_STREAM_NONCEBYTES' => array(
3018
- '7.1' => false,
3019
- '7.2' => true,
3020
- ),
3021
- 'SODIUM_CRYPTO_STREAM_KEYBYTES' => array(
3022
- '7.1' => false,
3023
- '7.2' => true,
3024
- ),
3025
-
3026
- 'CURLAUTH_BEARER' => array(
3027
- '7.2' => false,
3028
- '7.3' => true,
3029
- ),
3030
- 'CURLAUTH_GSSAPI' => array(
3031
- '7.2' => false,
3032
- '7.3' => true,
3033
- ),
3034
- 'CURLE_WEIRD_SERVER_REPLY' => array(
3035
- '7.2' => false,
3036
- '7.3' => true,
3037
- ),
3038
- 'CURLINFO_APPCONNECT_TIME_T' => array(
3039
- '7.2' => false,
3040
- '7.3' => true,
3041
- ),
3042
- 'CURLINFO_CONNECT_TIME_T' => array(
3043
- '7.2' => false,
3044
- '7.3' => true,
3045
- ),
3046
- 'CURLINFO_CONTENT_LENGTH_DOWNLOAD_T' => array(
3047
- '7.2' => false,
3048
- '7.3' => true,
3049
- ),
3050
- 'CURLINFO_CONTENT_LENGTH_UPLOAD_T' => array(
3051
- '7.2' => false,
3052
- '7.3' => true,
3053
- ),
3054
- 'CURLINFO_FILETIME_T' => array(
3055
- '7.2' => false,
3056
- '7.3' => true,
3057
- ),
3058
- 'CURLINFO_HTTP_VERSION' => array(
3059
- '7.2' => false,
3060
- '7.3' => true,
3061
- ),
3062
- 'CURLINFO_NAMELOOKUP_TIME_T' => array(
3063
- '7.2' => false,
3064
- '7.3' => true,
3065
- ),
3066
- 'CURLINFO_PRETRANSFER_TIME_T' => array(
3067
- '7.2' => false,
3068
- '7.3' => true,
3069
- ),
3070
- 'CURLINFO_PROTOCOL' => array(
3071
- '7.2' => false,
3072
- '7.3' => true,
3073
- ),
3074
- 'CURLINFO_PROXY_SSL_VERIFYRESULT' => array(
3075
- '7.2' => false,
3076
- '7.3' => true,
3077
- ),
3078
- 'CURLINFO_REDIRECT_TIME_T' => array(
3079
- '7.2' => false,
3080
- '7.3' => true,
3081
- ),
3082
- 'CURLINFO_SCHEME' => array(
3083
- '7.2' => false,
3084
- '7.3' => true,
3085
- ),
3086
- 'CURLINFO_SIZE_DOWNLOAD_T' => array(
3087
- '7.2' => false,
3088
- '7.3' => true,
3089
- ),
3090
- 'CURLINFO_SIZE_UPLOAD_T' => array(
3091
- '7.2' => false,
3092
- '7.3' => true,
3093
- ),
3094
- 'CURLINFO_SPEED_DOWNLOAD_T' => array(
3095
- '7.2' => false,
3096
- '7.3' => true,
3097
- ),
3098
- 'CURLINFO_SPEED_UPLOAD_T' => array(
3099
- '7.2' => false,
3100
- '7.3' => true,
3101
- ),
3102
- 'CURLINFO_STARTTRANSFER_TIME_T' => array(
3103
- '7.2' => false,
3104
- '7.3' => true,
3105
- ),
3106
- 'CURLINFO_TOTAL_TIME_T' => array(
3107
- '7.2' => false,
3108
- '7.3' => true,
3109
- ),
3110
- 'CURL_LOCK_DATA_CONNECT' => array(
3111
- '7.2' => false,
3112
- '7.3' => true,
3113
- ),
3114
- 'CURL_LOCK_DATA_PSL' => array(
3115
- '7.2' => false,
3116
- '7.3' => true,
3117
- ),
3118
- 'CURL_MAX_READ_SIZE' => array(
3119
- '7.2' => false,
3120
- '7.3' => true,
3121
- ),
3122
- 'CURLOPT_ABSTRACT_UNIX_SOCKET' => array(
3123
- '7.2' => false,
3124
- '7.3' => true,
3125
- ),
3126
- 'CURLOPT_DISALLOW_USERNAME_IN_URL' => array(
3127
- '7.2' => false,
3128
- '7.3' => true,
3129
- ),
3130
- 'CURLOPT_DNS_SHUFFLE_ADDRESSES' => array(
3131
- '7.2' => false,
3132
- '7.3' => true,
3133
- ),
3134
- 'CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS' => array(
3135
- '7.2' => false,
3136
- '7.3' => true,
3137
- ),
3138
- 'CURLOPT_HAPROXYPROTOCOL' => array(
3139
- '7.2' => false,
3140
- '7.3' => true,
3141
- ),
3142
- 'CURLOPT_KEEP_SENDING_ON_ERROR' => array(
3143
- '7.2' => false,
3144
- '7.3' => true,
3145
- ),
3146
- 'CURLOPT_PRE_PROXY' => array(
3147
- '7.2' => false,
3148
- '7.3' => true,
3149
- ),
3150
- 'CURLOPT_PROXY_CAINFO' => array(
3151
- '7.2' => false,
3152
- '7.3' => true,
3153
- ),
3154
- 'CURLOPT_PROXY_CAPATH' => array(
3155
- '7.2' => false,
3156
- '7.3' => true,
3157
- ),
3158
- 'CURLOPT_PROXY_CRLFILE' => array(
3159
- '7.2' => false,
3160
- '7.3' => true,
3161
- ),
3162
- 'CURLOPT_PROXY_KEYPASSWD' => array(
3163
- '7.2' => false,
3164
- '7.3' => true,
3165
- ),
3166
- 'CURLOPT_PROXY_PINNEDPUBLICKEY' => array(
3167
- '7.2' => false,
3168
- '7.3' => true,
3169
- ),
3170
- 'CURLOPT_PROXY_SSLCERT' => array(
3171
- '7.2' => false,
3172
- '7.3' => true,
3173
- ),
3174
- 'CURLOPT_PROXY_SSLCERTTYPE' => array(
3175
- '7.2' => false,
3176
- '7.3' => true,
3177
- ),
3178
- 'CURLOPT_PROXY_SSL_CIPHER_LIST' => array(
3179
- '7.2' => false,
3180
- '7.3' => true,
3181
- ),
3182
- 'CURLOPT_PROXY_SSLKEY' => array(
3183
- '7.2' => false,
3184
- '7.3' => true,
3185
- ),
3186
- 'CURLOPT_PROXY_SSLKEYTYPE' => array(
3187
- '7.2' => false,
3188
- '7.3' => true,
3189
- ),
3190
- 'CURLOPT_PROXY_SSL_OPTIONS' => array(
3191
- '7.2' => false,
3192
- '7.3' => true,
3193
- ),
3194
- 'CURLOPT_PROXY_SSL_VERIFYHOST' => array(
3195
- '7.2' => false,
3196
- '7.3' => true,
3197
- ),
3198
- 'CURLOPT_PROXY_SSL_VERIFYPEER' => array(
3199
- '7.2' => false,
3200
- '7.3' => true,
3201
- ),
3202
- 'CURLOPT_PROXY_SSLVERSION' => array(
3203
- '7.2' => false,
3204
- '7.3' => true,
3205
- ),
3206
- 'CURLOPT_PROXY_TLS13_CIPHERS' => array(
3207
- '7.2' => false,
3208
- '7.3' => true,
3209
- ),
3210
- 'CURLOPT_PROXY_TLSAUTH_PASSWORD' => array(
3211
- '7.2' => false,
3212
- '7.3' => true,
3213
- ),
3214
- 'CURLOPT_PROXY_TLSAUTH_TYPE' => array(
3215
- '7.2' => false,
3216
- '7.3' => true,
3217
- ),
3218
- 'CURLOPT_PROXY_TLSAUTH_USERNAME' => array(
3219
- '7.2' => false,
3220
- '7.3' => true,
3221
- ),
3222
- 'CURLOPT_REQUEST_TARGET' => array(
3223
- '7.2' => false,
3224
- '7.3' => true,
3225
- ),
3226
- 'CURLOPT_SOCKS5_AUTH' => array(
3227
- '7.2' => false,
3228
- '7.3' => true,
3229
- ),
3230
- 'CURLOPT_SSH_COMPRESSION' => array(
3231
- '7.2' => false,
3232
- '7.3' => true,
3233
- ),
3234
- 'CURLOPT_SUPPRESS_CONNECT_HEADERS' => array(
3235
- '7.2' => false,
3236
- '7.3' => true,
3237
- ),
3238
- 'CURLOPT_TIMEVALUE_LARGE' => array(
3239
- '7.2' => false,
3240
- '7.3' => true,
3241
- ),
3242
- 'CURLOPT_TLS13_CIPHERS' => array(
3243
- '7.2' => false,
3244
- '7.3' => true,
3245
- ),
3246
- 'CURLPROXY_HTTPS' => array(
3247
- '7.2' => false,
3248
- '7.3' => true,
3249
- ),
3250
- 'CURLSSH_AUTH_GSSAPI' => array(
3251
- '7.2' => false,
3252
- '7.3' => true,
3253
- ),
3254
- 'CURL_SSLVERSION_MAX_DEFAULT' => array(
3255
- '7.2' => false,
3256
- '7.3' => true,
3257
- ),
3258
- 'CURL_SSLVERSION_MAX_NONE' => array(
3259
- '7.2' => false,
3260
- '7.3' => true,
3261
- ),
3262
- 'CURL_SSLVERSION_MAX_TLSv1_0' => array(
3263
- '7.2' => false,
3264
- '7.3' => true,
3265
- ),
3266
- 'CURL_SSLVERSION_MAX_TLSv1_1' => array(
3267
- '7.2' => false,
3268
- '7.3' => true,
3269
- ),
3270
- 'CURL_SSLVERSION_MAX_TLSv1_2' => array(
3271
- '7.2' => false,
3272
- '7.3' => true,
3273
- ),
3274
- 'CURL_SSLVERSION_MAX_TLSv1_3' => array(
3275
- '7.2' => false,
3276
- '7.3' => true,
3277
- ),
3278
- 'CURL_SSLVERSION_TLSv1_3' => array(
3279
- '7.2' => false,
3280
- '7.3' => true,
3281
- ),
3282
- 'CURL_VERSION_ASYNCHDNS' => array(
3283
- '7.2' => false,
3284
- '7.3' => true,
3285
- ),
3286
- 'CURL_VERSION_BROTLI' => array(
3287
- '7.2' => false,
3288
- '7.3' => true,
3289
- ),
3290
- 'CURL_VERSION_CONV' => array(
3291
- '7.2' => false,
3292
- '7.3' => true,
3293
- ),
3294
- 'CURL_VERSION_DEBUG' => array(
3295
- '7.2' => false,
3296
- '7.3' => true,
3297
- ),
3298
- 'CURL_VERSION_GSSAPI' => array(
3299
- '7.2' => false,
3300
- '7.3' => true,
3301
- ),
3302
- 'CURL_VERSION_GSSNEGOTIATE' => array(
3303
- '7.2' => false,
3304
- '7.3' => true,
3305
- ),
3306
- 'CURL_VERSION_HTTPS_PROXY' => array(
3307
- '7.2' => false,
3308
- '7.3' => true,
3309
- ),
3310
- 'CURL_VERSION_IDN' => array(
3311
- '7.2' => false,
3312
- '7.3' => true,
3313
- ),
3314
- 'CURL_VERSION_LARGEFILE' => array(
3315
- '7.2' => false,
3316
- '7.3' => true,
3317
- ),
3318
- 'CURL_VERSION_MULTI_SSL' => array(
3319
- '7.2' => false,
3320
- '7.3' => true,
3321
- ),
3322
- 'CURL_VERSION_NTLM' => array(
3323
- '7.2' => false,
3324
- '7.3' => true,
3325
- ),
3326
- 'CURL_VERSION_NTLM_WB' => array(
3327
- '7.2' => false,
3328
- '7.3' => true,
3329
- ),
3330
- 'CURL_VERSION_SPNEGO' => array(
3331
- '7.2' => false,
3332
- '7.3' => true,
3333
- ),
3334
- 'CURL_VERSION_SSPI' => array(
3335
- '7.2' => false,
3336
- '7.3' => true,
3337
- ),
3338
- 'CURL_VERSION_TLSAUTH_SRP' => array(
3339
- '7.2' => false,
3340
- '7.3' => true,
3341
- ),
3342
- 'FILTER_SANITIZE_ADD_SLASHES' => array(
3343
- '7.2' => false,
3344
- '7.3' => true,
3345
- ),
3346
- 'JSON_THROW_ON_ERROR' => array(
3347
- '7.2' => false,
3348
- '7.3' => true,
3349
- ),
3350
- 'LDAP_CONTROL_MANAGEDSAIT' => array(
3351
- '7.2' => false,
3352
- '7.3' => true,
3353
- ),
3354
- 'LDAP_CONTROL_PROXY_AUTHZ' => array(
3355
- '7.2' => false,
3356
- '7.3' => true,
3357
- ),
3358
- 'LDAP_CONTROL_SUBENTRIES' => array(
3359
- '7.2' => false,
3360
- '7.3' => true,
3361
- ),
3362
- 'LDAP_CONTROL_VALUESRETURNFILTER' => array(
3363
- '7.2' => false,
3364
- '7.3' => true,
3365
- ),
3366
- 'LDAP_CONTROL_ASSERT' => array(
3367
- '7.2' => false,
3368
- '7.3' => true,
3369
- ),
3370
- 'LDAP_CONTROL_PRE_READ' => array(
3371
- '7.2' => false,
3372
- '7.3' => true,
3373
- ),
3374
- 'LDAP_CONTROL_POST_READ' => array(
3375
- '7.2' => false,
3376
- '7.3' => true,
3377
- ),
3378
- 'LDAP_CONTROL_SORTREQUEST' => array(
3379
- '7.2' => false,
3380
- '7.3' => true,
3381
- ),
3382
- 'LDAP_CONTROL_SORTRESPONSE' => array(
3383
- '7.2' => false,
3384
- '7.3' => true,
3385
- ),
3386
- 'LDAP_CONTROL_PAGEDRESULTS' => array(
3387
- '7.2' => false,
3388
- '7.3' => true,
3389
- ),
3390
- 'LDAP_CONTROL_AUTHZID_REQUEST' => array(
3391
- '7.2' => false,
3392
- '7.3' => true,
3393
- ),
3394
- 'LDAP_CONTROL_AUTHZID_RESPONSE' => array(
3395
- '7.2' => false,
3396
- '7.3' => true,
3397
- ),
3398
- 'LDAP_CONTROL_SYNC' => array(
3399
- '7.2' => false,
3400
- '7.3' => true,
3401
- ),
3402
- 'LDAP_CONTROL_SYNC_STATE' => array(
3403
- '7.2' => false,
3404
- '7.3' => true,
3405
- ),
3406
- 'LDAP_CONTROL_SYNC_DONE' => array(
3407
- '7.2' => false,
3408
- '7.3' => true,
3409
- ),
3410
- 'LDAP_CONTROL_DONTUSECOPY' => array(
3411
- '7.2' => false,
3412
- '7.3' => true,
3413
- ),
3414
- 'LDAP_CONTROL_PASSWORDPOLICYREQUEST' => array(
3415
- '7.2' => false,
3416
- '7.3' => true,
3417
- ),
3418
- 'LDAP_CONTROL_PASSWORDPOLICYRESPONSE' => array(
3419
- '7.2' => false,
3420
- '7.3' => true,
3421
- ),
3422
- 'LDAP_CONTROL_X_INCREMENTAL_VALUES' => array(
3423
- '7.2' => false,
3424
- '7.3' => true,
3425
- ),
3426
- 'LDAP_CONTROL_X_DOMAIN_SCOPE' => array(
3427
- '7.2' => false,
3428
- '7.3' => true,
3429
- ),
3430
- 'LDAP_CONTROL_X_PERMISSIVE_MODIFY' => array(
3431
- '7.2' => false,
3432
- '7.3' => true,
3433
- ),
3434
- 'LDAP_CONTROL_X_SEARCH_OPTIONS' => array(
3435
- '7.2' => false,
3436
- '7.3' => true,
3437
- ),
3438
- 'LDAP_CONTROL_X_TREE_DELETE' => array(
3439
- '7.2' => false,
3440
- '7.3' => true,
3441
- ),
3442
- 'LDAP_CONTROL_X_EXTENDED_DN' => array(
3443
- '7.2' => false,
3444
- '7.3' => true,
3445
- ),
3446
- 'LDAP_CONTROL_VLVREQUEST' => array(
3447
- '7.2' => false,
3448
- '7.3' => true,
3449
- ),
3450
- 'LDAP_CONTROL_VLVRESPONSE' => array(
3451
- '7.2' => false,
3452
- '7.3' => true,
3453
- ),
3454
- 'MB_CASE_FOLD' => array(
3455
- '7.2' => false,
3456
- '7.3' => true,
3457
- ),
3458
- 'MB_CASE_UPPER_SIMPLE' => array(
3459
- '7.2' => false,
3460
- '7.3' => true,
3461
- ),
3462
- 'MB_CASE_LOWER_SIMPLE' => array(
3463
- '7.2' => false,
3464
- '7.3' => true,
3465
- ),
3466
- 'MB_CASE_TITLE_SIMPLE' => array(
3467
- '7.2' => false,
3468
- '7.3' => true,
3469
- ),
3470
- 'MB_CASE_FOLD_SIMPLE' => array(
3471
- '7.2' => false,
3472
- '7.3' => true,
3473
- ),
3474
- 'PGSQL_DIAG_SCHEMA_NAME' => array(
3475
- '7.2' => false,
3476
- '7.3' => true,
3477
- ),
3478
- 'PGSQL_DIAG_TABLE_NAME' => array(
3479
- '7.2' => false,
3480
- '7.3' => true,
3481
- ),
3482
- 'PGSQL_DIAG_COLUMN_NAME' => array(
3483
- '7.2' => false,
3484
- '7.3' => true,
3485
- ),
3486
- 'PGSQL_DIAG_DATATYPE_NAME' => array(
3487
- '7.2' => false,
3488
- '7.3' => true,
3489
- ),
3490
- 'PGSQL_DIAG_CONSTRAINT_NAME' => array(
3491
- '7.2' => false,
3492
- '7.3' => true,
3493
- ),
3494
- 'PGSQL_DIAG_SEVERITY_NONLOCALIZED' => array(
3495
- '7.2' => false,
3496
- '7.3' => true,
3497
- ),
3498
- 'PASSWORD_ARGON2ID' => array(
3499
- '7.2' => false,
3500
- '7.3' => true,
3501
- ),
3502
- 'STREAM_CRYPTO_PROTO_SSLv3' => array(
3503
- '7.2' => false,
3504
- '7.3' => true,
3505
- ),
3506
- 'STREAM_CRYPTO_PROTO_TLSv1_0' => array(
3507
- '7.2' => false,
3508
- '7.3' => true,
3509
- ),
3510
- 'STREAM_CRYPTO_PROTO_TLSv1_1' => array(
3511
- '7.2' => false,
3512
- '7.3' => true,
3513
- ),
3514
- 'STREAM_CRYPTO_PROTO_TLSv1_2' => array(
3515
- '7.2' => false,
3516
- '7.3' => true,
3517
- ),
3518
-
3519
- 'CURL_VERSION_ALTSVC' => array(
3520
- '7.3.5' => false,
3521
- '7.3.6' => true,
3522
- ),
3523
- 'CURL_VERSION_CURLDEBUG' => array(
3524
- '7.3.5' => false,
3525
- '7.3.6' => true,
3526
- ),
3527
-
3528
- 'IMG_FILTER_SCATTER' => array(
3529
- '7.3' => false,
3530
- '7.4' => true,
3531
- ),
3532
- 'MB_ONIGURUMA_VERSION' => array(
3533
- '7.3' => false,
3534
- '7.4' => true,
3535
- ),
3536
- 'SO_LABEL' => array(
3537
- '7.3' => false,
3538
- '7.4' => true,
3539
- ),
3540
- 'SO_PEERLABEL' => array(
3541
- '7.3' => false,
3542
- '7.4' => true,
3543
- ),
3544
- 'SO_LISTENQLIMIT' => array(
3545
- '7.3' => false,
3546
- '7.4' => true,
3547
- ),
3548
- 'SO_LISTENQLEN' => array(
3549
- '7.3' => false,
3550
- '7.4' => true,
3551
- ),
3552
- 'SO_USER_COOKIE' => array(
3553
- '7.3' => false,
3554
- '7.4' => true,
3555
- ),
3556
- 'PASSWORD_ARGON2_PROVIDER' => array(
3557
- '7.3' => false,
3558
- '7.4' => true,
3559
- ),
3560
- 'PHP_WINDOWS_EVENT_CTRL_C' => array(
3561
- '7.3' => false,
3562
- '7.4' => true,
3563
- ),
3564
- 'PHP_WINDOWS_EVENT_CTRL_BREAK' => array(
3565
- '7.3' => false,
3566
- '7.4' => true,
3567
- ),
3568
- 'T_BAD_CHARACTER' => array(
3569
- '7.3' => false,
3570
- '7.4' => true,
3571
- ),
3572
- 'TIDY_TAG_ARTICLE' => array(
3573
- '7.3' => false,
3574
- '7.4' => true,
3575
- ),
3576
- 'TIDY_TAG_ASIDE' => array(
3577
- '7.3' => false,
3578
- '7.4' => true,
3579
- ),
3580
- 'TIDY_TAG_AUDIO' => array(
3581
- '7.3' => false,
3582
- '7.4' => true,
3583
- ),
3584
- 'TIDY_TAG_BDI' => array(
3585
- '7.3' => false,
3586
- '7.4' => true,
3587
- ),
3588
- 'TIDY_TAG_CANVAS' => array(
3589
- '7.3' => false,
3590
- '7.4' => true,
3591
- ),
3592
- 'TIDY_TAG_COMMAND' => array(
3593
- '7.3' => false,
3594
- '7.4' => true,
3595
- ),
3596
- 'TIDY_TAG_DATALIST' => array(
3597
- '7.3' => false,
3598
- '7.4' => true,
3599
- ),
3600
- 'TIDY_TAG_DETAILS' => array(
3601
- '7.3' => false,
3602
- '7.4' => true,
3603
- ),
3604
- 'TIDY_TAG_DIALOG' => array(
3605
- '7.3' => false,
3606
- '7.4' => true,
3607
- ),
3608
- 'TIDY_TAG_FIGCAPTION' => array(
3609
- '7.3' => false,
3610
- '7.4' => true,
3611
- ),
3612
- 'TIDY_TAG_FIGURE' => array(
3613
- '7.3' => false,
3614
- '7.4' => true,
3615
- ),
3616
- 'TIDY_TAG_FOOTER' => array(
3617
- '7.3' => false,
3618
- '7.4' => true,
3619
- ),
3620
- 'TIDY_TAG_HEADER' => array(
3621
- '7.3' => false,
3622
- '7.4' => true,
3623
- ),
3624
- 'TIDY_TAG_HGROUP' => array(
3625
- '7.3' => false,
3626
- '7.4' => true,
3627
- ),
3628
- 'TIDY_TAG_MAIN' => array(
3629
- '7.3' => false,
3630
- '7.4' => true,
3631
- ),
3632
- 'TIDY_TAG_MARK' => array(
3633
- '7.3' => false,
3634
- '7.4' => true,
3635
- ),
3636
- 'TIDY_TAG_MENUITEM' => array(
3637
- '7.3' => false,
3638
- '7.4' => true,
3639
- ),
3640
- 'TIDY_TAG_METER' => array(
3641
- '7.3' => false,
3642
- '7.4' => true,
3643
- ),
3644
- 'TIDY_TAG_NAV' => array(
3645
- '7.3' => false,
3646
- '7.4' => true,
3647
- ),
3648
- 'TIDY_TAG_OUTPUT' => array(
3649
- '7.3' => false,
3650
- '7.4' => true,
3651
- ),
3652
- 'TIDY_TAG_PROGRESS' => array(
3653
- '7.3' => false,
3654
- '7.4' => true,
3655
- ),
3656
- 'TIDY_TAG_SECTION' => array(
3657
- '7.3' => false,
3658
- '7.4' => true,
3659
- ),
3660
- 'TIDY_TAG_SOURCE' => array(
3661
- '7.3' => false,
3662
- '7.4' => true,
3663
- ),
3664
- 'TIDY_TAG_SUMMARY' => array(
3665
- '7.3' => false,
3666
- '7.4' => true,
3667
- ),
3668
- 'TIDY_TAG_TEMPLATE' => array(
3669
- '7.3' => false,
3670
- '7.4' => true,
3671
- ),
3672
- 'TIDY_TAG_TIME' => array(
3673
- '7.3' => false,
3674
- '7.4' => true,
3675
- ),
3676
- 'TIDY_TAG_TRACK' => array(
3677
- '7.3' => false,
3678
- '7.4' => true,
3679
- ),
3680
- 'TIDY_TAG_VIDEO' => array(
3681
- '7.3' => false,
3682
- '7.4' => true,
3683
- ),
3684
- );
3685
-
3686
-
3687
- /**
3688
- * Returns an array of tokens this test wants to listen for.
3689
- *
3690
- * @since 8.1.0
3691
- *
3692
- * @return array
3693
- */
3694
- public function register()
3695
- {
3696
- return array(\T_STRING);
3697
- }
3698
-
3699
- /**
3700
- * Processes this test, when one of its tokens is encountered.
3701
- *
3702
- * @since 8.1.0
3703
- *
3704
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
3705
- * @param int $stackPtr The position of the current token in the
3706
- * stack passed in $tokens.
3707
- *
3708
- * @return void
3709
- */
3710
- public function process(File $phpcsFile, $stackPtr)
3711
- {
3712
- $tokens = $phpcsFile->getTokens();
3713
- $constantName = $tokens[$stackPtr]['content'];
3714
-
3715
- if (isset($this->newConstants[$constantName]) === false) {
3716
- return;
3717
- }
3718
-
3719
- if ($this->isUseOfGlobalConstant($phpcsFile, $stackPtr) === false) {
3720
- return;
3721
- }
3722
-
3723
- $itemInfo = array(
3724
- 'name' => $constantName,
3725
- );
3726
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
3727
- }
3728
-
3729
-
3730
- /**
3731
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
3732
- *
3733
- * @since 8.1.0
3734
- *
3735
- * @param array $itemInfo Base information about the item.
3736
- *
3737
- * @return array Version and other information about the item.
3738
- */
3739
- public function getItemArray(array $itemInfo)
3740
- {
3741
- return $this->newConstants[$itemInfo['name']];
3742
- }
3743
-
3744
-
3745
- /**
3746
- * Get the error message template for this sniff.
3747
- *
3748
- * @since 8.1.0
3749
- *
3750
- * @return string
3751
- */
3752
- protected function getErrorMsgTemplate()
3753
- {
3754
- return 'The constant "%s" is not present in PHP version %s or earlier';
3755
- }
3756
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php DELETED
@@ -1,80 +0,0 @@
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\Constants;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect usage of the magic `::class` constant introduced in PHP 5.5.
19
- *
20
- * The special `ClassName::class` constant is available as of PHP 5.5.0, and allows
21
- * for fully qualified class name resolution at compile time.
22
- *
23
- * PHP version 5.5
24
- *
25
- * @link https://wiki.php.net/rfc/class_name_scalars
26
- * @link https://www.php.net/manual/en/language.oop5.constants.php#example-186
27
- *
28
- * @since 7.1.4
29
- * @since 7.1.5 Removed the incorrect checks against invalid usage of the constant.
30
- */
31
- class NewMagicClassConstantSniff extends Sniff
32
- {
33
-
34
- /**
35
- * Returns an array of tokens this test wants to listen for.
36
- *
37
- * @since 7.1.4
38
- *
39
- * @return array
40
- */
41
- public function register()
42
- {
43
- return array(\T_STRING);
44
- }
45
-
46
- /**
47
- * Processes this test, when one of its tokens is encountered.
48
- *
49
- * @since 7.1.4
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(File $phpcsFile, $stackPtr)
58
- {
59
- if ($this->supportsBelow('5.4') === false) {
60
- return;
61
- }
62
-
63
- $tokens = $phpcsFile->getTokens();
64
-
65
- if (strtolower($tokens[$stackPtr]['content']) !== 'class') {
66
- return;
67
- }
68
-
69
- $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
70
- if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_DOUBLE_COLON) {
71
- return;
72
- }
73
-
74
- $phpcsFile->addError(
75
- 'The magic class constant ClassName::class was not available in PHP 5.4 or earlier',
76
- $stackPtr,
77
- 'Found'
78
- );
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/RemovedConstantsSniff.php DELETED
@@ -1,574 +0,0 @@
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\Constants;
12
-
13
- use PHPCompatibility\AbstractRemovedFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect use of deprecated and/or removed PHP native global constants.
18
- *
19
- * PHP version All
20
- *
21
- * @since 8.1.0
22
- */
23
- class RemovedConstantsSniff extends AbstractRemovedFeatureSniff
24
- {
25
-
26
- /**
27
- * A list of removed PHP Constants.
28
- *
29
- * The array lists : version number with false (deprecated) or true (removed).
30
- * If's sufficient to list the first version where the constant was deprecated/removed.
31
- *
32
- * Optional, the array can contain an `alternative` key listing an alternative constant
33
- * to be used instead.
34
- *
35
- * Note: PHP Constants are case-sensitive!
36
- *
37
- * @since 8.1.0
38
- *
39
- * @var array(string => array(string => bool|string))
40
- */
41
- protected $removedConstants = array(
42
- // Disabled since PHP 5.3.0 due to thread safety issues.
43
- 'FILEINFO_COMPRESS' => array(
44
- '5.3' => true,
45
- ),
46
-
47
- 'CURLOPT_CLOSEPOLICY' => array(
48
- '5.6' => true,
49
- ),
50
- 'CURLCLOSEPOLICY_LEAST_RECENTLY_USED' => array(
51
- '5.6' => true,
52
- ),
53
- 'CURLCLOSEPOLICY_LEAST_TRAFFIC' => array(
54
- '5.6' => true,
55
- ),
56
- 'CURLCLOSEPOLICY_SLOWEST' => array(
57
- '5.6' => true,
58
- ),
59
- 'CURLCLOSEPOLICY_CALLBACK' => array(
60
- '5.6' => true,
61
- ),
62
- 'CURLCLOSEPOLICY_OLDEST' => array(
63
- '5.6' => true,
64
- ),
65
-
66
- 'PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT' => array(
67
- '7.0' => true,
68
- ),
69
- 'T_CHARACTER' => array(
70
- '7.0' => true,
71
- ),
72
- 'T_BAD_CHARACTER' => array(
73
- '7.0' => true,
74
- ),
75
-
76
- 'INTL_IDNA_VARIANT_2003' => array(
77
- '7.2' => false,
78
- ),
79
-
80
- 'MCRYPT_MODE_ECB' => array(
81
- '7.1' => false,
82
- '7.2' => true,
83
- ),
84
- 'MCRYPT_MODE_CBC' => array(
85
- '7.1' => false,
86
- '7.2' => true,
87
- ),
88
- 'MCRYPT_MODE_CFB' => array(
89
- '7.1' => false,
90
- '7.2' => true,
91
- ),
92
- 'MCRYPT_MODE_OFB' => array(
93
- '7.1' => false,
94
- '7.2' => true,
95
- ),
96
- 'MCRYPT_MODE_NOFB' => array(
97
- '7.1' => false,
98
- '7.2' => true,
99
- ),
100
- 'MCRYPT_MODE_STREAM' => array(
101
- '7.1' => false,
102
- '7.2' => true,
103
- ),
104
- 'MCRYPT_ENCRYPT' => array(
105
- '7.1' => false,
106
- '7.2' => true,
107
- ),
108
- 'MCRYPT_DECRYPT' => array(
109
- '7.1' => false,
110
- '7.2' => true,
111
- ),
112
- 'MCRYPT_DEV_RANDOM' => array(
113
- '7.1' => false,
114
- '7.2' => true,
115
- ),
116
- 'MCRYPT_DEV_URANDOM' => array(
117
- '7.1' => false,
118
- '7.2' => true,
119
- ),
120
- 'MCRYPT_RAND' => array(
121
- '7.1' => false,
122
- '7.2' => true,
123
- ),
124
- 'MCRYPT_3DES' => array(
125
- '7.1' => false,
126
- '7.2' => true,
127
- ),
128
- 'MCRYPT_ARCFOUR_IV' => array(
129
- '7.1' => false,
130
- '7.2' => true,
131
- ),
132
- 'MCRYPT_ARCFOUR' => array(
133
- '7.1' => false,
134
- '7.2' => true,
135
- ),
136
- 'MCRYPT_BLOWFISH' => array(
137
- '7.1' => false,
138
- '7.2' => true,
139
- ),
140
- 'MCRYPT_CAST_128' => array(
141
- '7.1' => false,
142
- '7.2' => true,
143
- ),
144
- 'MCRYPT_CAST_256' => array(
145
- '7.1' => false,
146
- '7.2' => true,
147
- ),
148
- 'MCRYPT_CRYPT' => array(
149
- '7.1' => false,
150
- '7.2' => true,
151
- ),
152
- 'MCRYPT_DES' => array(
153
- '7.1' => false,
154
- '7.2' => true,
155
- ),
156
- 'MCRYPT_DES_COMPAT' => array(
157
- '7.1' => false,
158
- '7.2' => true,
159
- ),
160
- 'MCRYPT_ENIGMA' => array(
161
- '7.1' => false,
162
- '7.2' => true,
163
- ),
164
- 'MCRYPT_GOST' => array(
165
- '7.1' => false,
166
- '7.2' => true,
167
- ),
168
- 'MCRYPT_IDEA' => array(
169
- '7.1' => false,
170
- '7.2' => true,
171
- ),
172
- 'MCRYPT_LOKI97' => array(
173
- '7.1' => false,
174
- '7.2' => true,
175
- ),
176
- 'MCRYPT_MARS' => array(
177
- '7.1' => false,
178
- '7.2' => true,
179
- ),
180
- 'MCRYPT_PANAMA' => array(
181
- '7.1' => false,
182
- '7.2' => true,
183
- ),
184
- 'MCRYPT_RIJNDAEL_128' => array(
185
- '7.1' => false,
186
- '7.2' => true,
187
- ),
188
- 'MCRYPT_RIJNDAEL_192' => array(
189
- '7.1' => false,
190
- '7.2' => true,
191
- ),
192
- 'MCRYPT_RIJNDAEL_256' => array(
193
- '7.1' => false,
194
- '7.2' => true,
195
- ),
196
- 'MCRYPT_RC2' => array(
197
- '7.1' => false,
198
- '7.2' => true,
199
- ),
200
- 'MCRYPT_RC4' => array(
201
- '7.1' => false,
202
- '7.2' => true,
203
- ),
204
- 'MCRYPT_RC6' => array(
205
- '7.1' => false,
206
- '7.2' => true,
207
- ),
208
- 'MCRYPT_RC6_128' => array(
209
- '7.1' => false,
210
- '7.2' => true,
211
- ),
212
- 'MCRYPT_RC6_192' => array(
213
- '7.1' => false,
214
- '7.2' => true,
215
- ),
216
- 'MCRYPT_RC6_256' => array(
217
- '7.1' => false,
218
- '7.2' => true,
219
- ),
220
- 'MCRYPT_SAFER64' => array(
221
- '7.1' => false,
222
- '7.2' => true,
223
- ),
224
- 'MCRYPT_SAFER128' => array(
225
- '7.1' => false,
226
- '7.2' => true,
227
- ),
228
- 'MCRYPT_SAFERPLUS' => array(
229
- '7.1' => false,
230
- '7.2' => true,
231
- ),
232
- 'MCRYPT_SERPENT' => array(
233
- '7.1' => false,
234
- '7.2' => true,
235
- ),
236
- 'MCRYPT_SERPENT_128' => array(
237
- '7.1' => false,
238
- '7.2' => true,
239
- ),
240
- 'MCRYPT_SERPENT_192' => array(
241
- '7.1' => false,
242
- '7.2' => true,
243
- ),
244
- 'MCRYPT_SERPENT_256' => array(
245
- '7.1' => false,
246
- '7.2' => true,
247
- ),
248
- 'MCRYPT_SKIPJACK' => array(
249
- '7.1' => false,
250
- '7.2' => true,
251
- ),
252
- 'MCRYPT_TEAN' => array(
253
- '7.1' => false,
254
- '7.2' => true,
255
- ),
256
- 'MCRYPT_THREEWAY' => array(
257
- '7.1' => false,
258
- '7.2' => true,
259
- ),
260
- 'MCRYPT_TRIPLEDES' => array(
261
- '7.1' => false,
262
- '7.2' => true,
263
- ),
264
- 'MCRYPT_TWOFISH' => array(
265
- '7.1' => false,
266
- '7.2' => true,
267
- ),
268
- 'MCRYPT_TWOFISH128' => array(
269
- '7.1' => false,
270
- '7.2' => true,
271
- ),
272
- 'MCRYPT_TWOFISH192' => array(
273
- '7.1' => false,
274
- '7.2' => true,
275
- ),
276
- 'MCRYPT_TWOFISH256' => array(
277
- '7.1' => false,
278
- '7.2' => true,
279
- ),
280
- 'MCRYPT_WAKE' => array(
281
- '7.1' => false,
282
- '7.2' => true,
283
- ),
284
- 'MCRYPT_XTEA' => array(
285
- '7.1' => false,
286
- '7.2' => true,
287
- ),
288
-
289
- 'PHPDBG_FILE' => array(
290
- '7.3' => true,
291
- ),
292
- 'PHPDBG_METHOD' => array(
293
- '7.3' => true,
294
- ),
295
- 'PHPDBG_LINENO' => array(
296
- '7.3' => true,
297
- ),
298
- 'PHPDBG_FUNC' => array(
299
- '7.3' => true,
300
- ),
301
- 'FILTER_FLAG_SCHEME_REQUIRED' => array(
302
- '7.3' => false,
303
- ),
304
- 'FILTER_FLAG_HOST_REQUIRED' => array(
305
- '7.3' => false,
306
- ),
307
-
308
- 'CURLPIPE_HTTP1' => array(
309
- '7.4' => false,
310
- ),
311
- 'FILTER_SANITIZE_MAGIC_QUOTES' => array(
312
- '7.4' => false,
313
- 'alternative' => 'FILTER_SANITIZE_ADD_SLASHES',
314
- ),
315
- 'IBASE_BKP_CONVERT' => array(
316
- '7.4' => true,
317
- ),
318
- 'IBASE_BKP_IGNORE_CHECKSUMS' => array(
319
- '7.4' => true,
320
- ),
321
- 'IBASE_BKP_IGNORE_LIMBO' => array(
322
- '7.4' => true,
323
- ),
324
- 'IBASE_BKP_METADATA_ONLY' => array(
325
- '7.4' => true,
326
- ),
327
- 'IBASE_BKP_NO_GARBAGE_COLLECT' => array(
328
- '7.4' => true,
329
- ),
330
- 'IBASE_BKP_NON_TRANSPORTABLE' => array(
331
- '7.4' => true,
332
- ),
333
- 'IBASE_BKP_OLD_DESCRIPTIONS' => array(
334
- '7.4' => true,
335
- ),
336
- 'IBASE_COMMITTED' => array(
337
- '7.4' => true,
338
- ),
339
- 'IBASE_CONCURRENCY' => array(
340
- '7.4' => true,
341
- ),
342
- 'IBASE_CONSISTENCY' => array(
343
- '7.4' => true,
344
- ),
345
- 'IBASE_DEFAULT' => array(
346
- '7.4' => true,
347
- ),
348
- 'IBASE_FETCH_ARRAYS' => array(
349
- '7.4' => true,
350
- ),
351
- 'IBASE_FETCH_BLOBS' => array(
352
- '7.4' => true,
353
- ),
354
- 'IBASE_NOWAIT' => array(
355
- '7.4' => true,
356
- ),
357
- 'IBASE_PRP_ACCESS_MODE' => array(
358
- '7.4' => true,
359
- ),
360
- 'IBASE_PRP_ACTIVATE' => array(
361
- '7.4' => true,
362
- ),
363
- 'IBASE_PRP_AM_READONLY' => array(
364
- '7.4' => true,
365
- ),
366
- 'IBASE_PRP_AM_READWRITE' => array(
367
- '7.4' => true,
368
- ),
369
- 'IBASE_PRP_DENY_NEW_ATTACHMENTS' => array(
370
- '7.4' => true,
371
- ),
372
- 'IBASE_PRP_DENY_NEW_TRANSACTIONS' => array(
373
- '7.4' => true,
374
- ),
375
- 'IBASE_PRP_DB_ONLINE' => array(
376
- '7.4' => true,
377
- ),
378
- 'IBASE_PRP_PAGE_BUFFERS' => array(
379
- '7.4' => true,
380
- ),
381
- 'IBASE_PRP_RES' => array(
382
- '7.4' => true,
383
- ),
384
- 'IBASE_PRP_RES_USE_FULL' => array(
385
- '7.4' => true,
386
- ),
387
- 'IBASE_PRP_RESERVE_SPACE' => array(
388
- '7.4' => true,
389
- ),
390
- 'IBASE_PRP_SET_SQL_DIALECT' => array(
391
- '7.4' => true,
392
- ),
393
- 'IBASE_PRP_SHUTDOWN_DB' => array(
394
- '7.4' => true,
395
- ),
396
- 'IBASE_PRP_SWEEP_INTERVAL' => array(
397
- '7.4' => true,
398
- ),
399
- 'IBASE_PRP_WM_ASYNC' => array(
400
- '7.4' => true,
401
- ),
402
- 'IBASE_PRP_WM_SYNC' => array(
403
- '7.4' => true,
404
- ),
405
- 'IBASE_PRP_WRITE_MODE' => array(
406
- '7.4' => true,
407
- ),
408
- 'IBASE_READ' => array(
409
- '7.4' => true,
410
- ),
411
- 'IBASE_RES_CREATE' => array(
412
- '7.4' => true,
413
- ),
414
- 'IBASE_RES_DEACTIVATE_IDX' => array(
415
- '7.4' => true,
416
- ),
417
- 'IBASE_RES_NO_SHADOW' => array(
418
- '7.4' => true,
419
- ),
420
- 'IBASE_RES_NO_VALIDITY' => array(
421
- '7.4' => true,
422
- ),
423
- 'IBASE_RES_ONE_AT_A_TIME' => array(
424
- '7.4' => true,
425
- ),
426
- 'IBASE_RES_REPLACE' => array(
427
- '7.4' => true,
428
- ),
429
- 'IBASE_RES_USE_ALL_SPACE' => array(
430
- '7.4' => true,
431
- ),
432
- 'IBASE_RPR_CHECK_DB' => array(
433
- '7.4' => true,
434
- ),
435
- 'IBASE_RPR_FULL' => array(
436
- '7.4' => true,
437
- ),
438
- 'IBASE_RPR_IGNORE_CHECKSUM' => array(
439
- '7.4' => true,
440
- ),
441
- 'IBASE_RPR_KILL_SHADOWS' => array(
442
- '7.4' => true,
443
- ),
444
- 'IBASE_RPR_MEND_DB' => array(
445
- '7.4' => true,
446
- ),
447
- 'IBASE_RPR_SWEEP_DB' => array(
448
- '7.4' => true,
449
- ),
450
- 'IBASE_RPR_VALIDATE_DB' => array(
451
- '7.4' => true,
452
- ),
453
- 'IBASE_STS_DATA_PAGES' => array(
454
- '7.4' => true,
455
- ),
456
- 'IBASE_STS_DB_LOG' => array(
457
- '7.4' => true,
458
- ),
459
- 'IBASE_STS_HDR_PAGES' => array(
460
- '7.4' => true,
461
- ),
462
- 'IBASE_STS_IDX_PAGES' => array(
463
- '7.4' => true,
464
- ),
465
- 'IBASE_STS_SYS_RELATIONS' => array(
466
- '7.4' => true,
467
- ),
468
- 'IBASE_SVC_GET_ENV' => array(
469
- '7.4' => true,
470
- ),
471
- 'IBASE_SVC_GET_ENV_LOCK' => array(
472
- '7.4' => true,
473
- ),
474
- 'IBASE_SVC_GET_ENV_MSG' => array(
475
- '7.4' => true,
476
- ),
477
- 'IBASE_SVC_GET_USERS' => array(
478
- '7.4' => true,
479
- ),
480
- 'IBASE_SVC_IMPLEMENTATION' => array(
481
- '7.4' => true,
482
- ),
483
- 'IBASE_SVC_SERVER_VERSION' => array(
484
- '7.4' => true,
485
- ),
486
- 'IBASE_SVC_SVR_DB_INFO' => array(
487
- '7.4' => true,
488
- ),
489
- 'IBASE_SVC_USER_DBPATH' => array(
490
- '7.4' => true,
491
- ),
492
- 'IBASE_UNIXTIME' => array(
493
- '7.4' => true,
494
- ),
495
- 'IBASE_WAIT' => array(
496
- '7.4' => true,
497
- ),
498
- 'IBASE_WRITE' => array(
499
- '7.4' => true,
500
- ),
501
- );
502
-
503
-
504
- /**
505
- * Returns an array of tokens this test wants to listen for.
506
- *
507
- * @since 8.1.0
508
- *
509
- * @return array
510
- */
511
- public function register()
512
- {
513
- return array(\T_STRING);
514
- }
515
-
516
-
517
- /**
518
- * Processes this test, when one of its tokens is encountered.
519
- *
520
- * @since 8.1.0
521
- *
522
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
523
- * @param int $stackPtr The position of the current token in
524
- * the stack passed in $tokens.
525
- *
526
- * @return void
527
- */
528
- public function process(File $phpcsFile, $stackPtr)
529
- {
530
- $tokens = $phpcsFile->getTokens();
531
- $constantName = $tokens[$stackPtr]['content'];
532
-
533
- if (isset($this->removedConstants[$constantName]) === false) {
534
- return;
535
- }
536
-
537
- if ($this->isUseOfGlobalConstant($phpcsFile, $stackPtr) === false) {
538
- return;
539
- }
540
-
541
- $itemInfo = array(
542
- 'name' => $constantName,
543
- );
544
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
545
- }
546
-
547
-
548
- /**
549
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
550
- *
551
- * @since 8.1.0
552
- *
553
- * @param array $itemInfo Base information about the item.
554
- *
555
- * @return array Version and other information about the item.
556
- */
557
- public function getItemArray(array $itemInfo)
558
- {
559
- return $this->removedConstants[$itemInfo['name']];
560
- }
561
-
562
-
563
- /**
564
- * Get the error message template for this sniff.
565
- *
566
- * @since 8.1.0
567
- *
568
- * @return string
569
- */
570
- protected function getErrorMsgTemplate()
571
- {
572
- return 'The constant "%s" is ';
573
- }
574
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php DELETED
@@ -1,238 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect use of `continue` in `switch` control structures.
19
- *
20
- * As of PHP 7.3, PHP will throw a warning when `continue` is used to target a `switch`
21
- * control structure.
22
- * The sniff takes numeric arguments used with `continue` into account.
23
- *
24
- * PHP version 7.3
25
- *
26
- * @link https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.continue-targeting-switch
27
- * @link https://wiki.php.net/rfc/continue_on_switch_deprecation
28
- * @link https://github.com/php/php-src/commit/04e3523b7d095341f65ed5e71a3cac82fca690e4
29
- * (actual implementation which is different from the RFC).
30
- * @link https://www.php.net/manual/en/control-structures.switch.php
31
- *
32
- * @since 8.2.0
33
- */
34
- class DiscouragedSwitchContinueSniff extends Sniff
35
- {
36
-
37
- /**
38
- * Token codes of control structures which can be targeted using continue.
39
- *
40
- * @since 8.2.0
41
- *
42
- * @var array
43
- */
44
- protected $loopStructures = array(
45
- \T_FOR => \T_FOR,
46
- \T_FOREACH => \T_FOREACH,
47
- \T_WHILE => \T_WHILE,
48
- \T_DO => \T_DO,
49
- \T_SWITCH => \T_SWITCH,
50
- );
51
-
52
- /**
53
- * Tokens which start a new case within a switch.
54
- *
55
- * @since 8.2.0
56
- *
57
- * @var array
58
- */
59
- protected $caseTokens = array(
60
- \T_CASE => \T_CASE,
61
- \T_DEFAULT => \T_DEFAULT,
62
- );
63
-
64
- /**
65
- * Token codes which are accepted to determine the level for the continue.
66
- *
67
- * This array is enriched with the arithmetic operators in the register() method.
68
- *
69
- * @since 8.2.0
70
- *
71
- * @var array
72
- */
73
- protected $acceptedLevelTokens = array(
74
- \T_LNUMBER => \T_LNUMBER,
75
- \T_OPEN_PARENTHESIS => \T_OPEN_PARENTHESIS,
76
- \T_CLOSE_PARENTHESIS => \T_CLOSE_PARENTHESIS,
77
- );
78
-
79
-
80
- /**
81
- * Returns an array of tokens this test wants to listen for.
82
- *
83
- * @since 8.2.0
84
- *
85
- * @return array
86
- */
87
- public function register()
88
- {
89
- $this->acceptedLevelTokens += Tokens::$arithmeticTokens;
90
- $this->acceptedLevelTokens += Tokens::$emptyTokens;
91
-
92
- return array(\T_SWITCH);
93
- }
94
-
95
- /**
96
- * Processes this test, when one of its tokens is encountered.
97
- *
98
- * @since 8.2.0
99
- *
100
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
101
- * @param int $stackPtr The position of the current token in the
102
- * stack passed in $tokens.
103
- *
104
- * @return void
105
- */
106
- public function process(File $phpcsFile, $stackPtr)
107
- {
108
- if ($this->supportsAbove('7.3') === false) {
109
- return;
110
- }
111
-
112
- $tokens = $phpcsFile->getTokens();
113
-
114
- if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
115
- return;
116
- }
117
-
118
- $switchOpener = $tokens[$stackPtr]['scope_opener'];
119
- $switchCloser = $tokens[$stackPtr]['scope_closer'];
120
-
121
- // Quick check whether we need to bother with the more complex logic.
122
- $hasContinue = $phpcsFile->findNext(\T_CONTINUE, ($switchOpener + 1), $switchCloser);
123
- if ($hasContinue === false) {
124
- return;
125
- }
126
-
127
- $caseDefault = $switchOpener;
128
-
129
- do {
130
- $caseDefault = $phpcsFile->findNext($this->caseTokens, ($caseDefault + 1), $switchCloser);
131
- if ($caseDefault === false) {
132
- break;
133
- }
134
-
135
- if (isset($tokens[$caseDefault]['scope_opener']) === false) {
136
- // Unknown start of the case, skip.
137
- continue;
138
- }
139
-
140
- $caseOpener = $tokens[$caseDefault]['scope_opener'];
141
- $nextCaseDefault = $phpcsFile->findNext($this->caseTokens, ($caseDefault + 1), $switchCloser);
142
- if ($nextCaseDefault === false) {
143
- $caseCloser = $switchCloser;
144
- } else {
145
- $caseCloser = $nextCaseDefault;
146
- }
147
-
148
- // Check for unscoped control structures within the case.
149
- $controlStructure = $caseOpener;
150
- $doCount = 0;
151
- while (($controlStructure = $phpcsFile->findNext($this->loopStructures, ($controlStructure + 1), $caseCloser)) !== false) {
152
- if ($tokens[$controlStructure]['code'] === \T_DO) {
153
- $doCount++;
154
- }
155
-
156
- if (isset($tokens[$controlStructure]['scope_opener'], $tokens[$controlStructure]['scope_closer']) === false) {
157
- if ($tokens[$controlStructure]['code'] === \T_WHILE && $doCount > 0) {
158
- // While in a do-while construct.
159
- $doCount--;
160
- continue;
161
- }
162
-
163
- // Control structure without braces found within the case, ignore this case.
164
- continue 2;
165
- }
166
- }
167
-
168
- // Examine the contents of the case.
169
- $continue = $caseOpener;
170
-
171
- do {
172
- $continue = $phpcsFile->findNext(\T_CONTINUE, ($continue + 1), $caseCloser);
173
- if ($continue === false) {
174
- break;
175
- }
176
-
177
- $nextSemicolon = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($continue + 1), $caseCloser);
178
- $codeString = '';
179
- for ($i = ($continue + 1); $i < $nextSemicolon; $i++) {
180
- if (isset($this->acceptedLevelTokens[$tokens[$i]['code']]) === false) {
181
- // Function call/variable or other token which make numeric level impossible to determine.
182
- continue 2;
183
- }
184
-
185
- if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
186
- continue;
187
- }
188
-
189
- $codeString .= $tokens[$i]['content'];
190
- }
191
-
192
- $level = null;
193
- if ($codeString !== '') {
194
- if (is_numeric($codeString)) {
195
- $level = (int) $codeString;
196
- } else {
197
- // With the above logic, the string can only contain digits and operators, eval!
198
- $level = eval("return ( $codeString );");
199
- }
200
- }
201
-
202
- if (isset($level) === false || $level === 0) {
203
- $level = 1;
204
- }
205
-
206
- // Examine which control structure is being targeted by the continue statement.
207
- if (isset($tokens[$continue]['conditions']) === false) {
208
- continue;
209
- }
210
-
211
- $conditions = array_reverse($tokens[$continue]['conditions'], true);
212
- // PHPCS adds more structures to the conditions array than we want to take into
213
- // consideration, so clean up the array.
214
- foreach ($conditions as $tokenPtr => $tokenCode) {
215
- if (isset($this->loopStructures[$tokenCode]) === false) {
216
- unset($conditions[$tokenPtr]);
217
- }
218
- }
219
-
220
- $targetCondition = \array_slice($conditions, ($level - 1), 1, true);
221
- if (empty($targetCondition)) {
222
- continue;
223
- }
224
-
225
- $conditionToken = key($targetCondition);
226
- if ($conditionToken === $stackPtr) {
227
- $phpcsFile->addWarning(
228
- "Targeting a 'switch' control structure with a 'continue' statement is strongly discouraged and will throw a warning as of PHP 7.3.",
229
- $continue,
230
- 'Found'
231
- );
232
- }
233
-
234
- } while ($continue < $caseCloser);
235
-
236
- } while ($caseDefault < $switchCloser);
237
- }
238
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/ForbiddenBreakContinueOutsideLoopSniff.php DELETED
@@ -1,116 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect using `break` and/or `continue` statements outside of a looping structure.
18
- *
19
- * PHP version 7.0
20
- *
21
- * @link https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.break-continue
22
- * @link https://www.php.net/manual/en/control-structures.break.php
23
- * @link https://www.php.net/manual/en/control-structures.continue.php
24
- *
25
- * @since 7.0.7
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
- * @since 7.0.7
34
- *
35
- * @var array
36
- */
37
- protected $validLoopStructures = array(
38
- \T_FOR => true,
39
- \T_FOREACH => true,
40
- \T_WHILE => true,
41
- \T_DO => true,
42
- \T_SWITCH => true,
43
- );
44
-
45
- /**
46
- * Token codes which did not correctly get a condition assigned in older PHPCS versions.
47
- *
48
- * @since 7.0.7
49
- *
50
- * @var array
51
- */
52
- protected $backCompat = array(
53
- \T_CASE => true,
54
- \T_DEFAULT => true,
55
- );
56
-
57
- /**
58
- * Returns an array of tokens this test wants to listen for.
59
- *
60
- * @since 7.0.7
61
- *
62
- * @return array
63
- */
64
- public function register()
65
- {
66
- return array(
67
- \T_BREAK,
68
- \T_CONTINUE,
69
- );
70
- }
71
-
72
- /**
73
- * Processes this test, when one of its tokens is encountered.
74
- *
75
- * @since 7.0.7
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
- $tokens = $phpcsFile->getTokens();
86
- $token = $tokens[$stackPtr];
87
-
88
- // Check if the break/continue is within a valid loop structure.
89
- if (empty($token['conditions']) === false) {
90
- foreach ($token['conditions'] as $tokenCode) {
91
- if (isset($this->validLoopStructures[$tokenCode]) === true) {
92
- return;
93
- }
94
- }
95
- } else {
96
- // Deal with older PHPCS versions.
97
- if (isset($token['scope_condition']) === true && isset($this->backCompat[$tokens[$token['scope_condition']]['code']]) === true) {
98
- return;
99
- }
100
- }
101
-
102
- // If we're still here, no valid loop structure container has been found, so throw an error.
103
- $error = "Using '%s' outside of a loop or switch structure is invalid";
104
- $isError = false;
105
- $errorCode = 'Found';
106
- $data = array($token['content']);
107
-
108
- if ($this->supportsAbove('7.0')) {
109
- $error .= ' and will throw a fatal error since PHP 7.0';
110
- $isError = true;
111
- $errorCode = 'FatalError';
112
- }
113
-
114
- $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
115
- }
116
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/ForbiddenBreakContinueVariableArgumentsSniff.php DELETED
@@ -1,110 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detects using 0 and variable numeric arguments on `break` and `continue` statements.
19
- *
20
- * This sniff checks for:
21
- * - Using `break` and/or `continue` with a variable as the numeric argument.
22
- * - Using `break` and/or `continue` with a zero - 0 - as the numeric argument.
23
- *
24
- * PHP version 5.4
25
- *
26
- * @link https://www.php.net/manual/en/migration54.incompatible.php
27
- * @link https://www.php.net/manual/en/control-structures.break.php
28
- * @link https://www.php.net/manual/en/control-structures.continue.php
29
- *
30
- * @since 5.5
31
- * @since 5.6 Now extends the base `Sniff` class.
32
- */
33
- class ForbiddenBreakContinueVariableArgumentsSniff extends Sniff
34
- {
35
- /**
36
- * Error types this sniff handles for forbidden break/continue arguments.
37
- *
38
- * Array key is the error code. Array value will be used as part of the error message.
39
- *
40
- * @since 7.0.5
41
- * @since 7.1.0 Changed from class constants to property.
42
- *
43
- * @var array
44
- */
45
- private $errorTypes = array(
46
- 'variableArgument' => 'a variable argument',
47
- 'zeroArgument' => '0 as an argument',
48
- );
49
-
50
- /**
51
- * Returns an array of tokens this test wants to listen for.
52
- *
53
- * @since 5.5
54
- *
55
- * @return array
56
- */
57
- public function register()
58
- {
59
- return array(\T_BREAK, \T_CONTINUE);
60
- }
61
-
62
- /**
63
- * Processes this test, when one of its tokens is encountered.
64
- *
65
- * @since 5.5
66
- *
67
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
- * @param int $stackPtr The position of the current token in the
69
- * stack passed in $tokens.
70
- *
71
- * @return void
72
- */
73
- public function process(File $phpcsFile, $stackPtr)
74
- {
75
- if ($this->supportsAbove('5.4') === false) {
76
- return;
77
- }
78
-
79
- $tokens = $phpcsFile->getTokens();
80
- $nextSemicolonToken = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr), null, false);
81
- $errorType = '';
82
- for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
83
- if ($tokens[$curToken]['type'] === 'T_STRING') {
84
- // If the next non-whitespace token after the string
85
- // is an opening parenthesis then it's a function call.
86
- $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, $curToken + 1, null, true);
87
- if ($tokens[$openBracket]['code'] === \T_OPEN_PARENTHESIS) {
88
- $errorType = 'variableArgument';
89
- break;
90
- }
91
-
92
- } elseif (\in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
93
- $errorType = 'variableArgument';
94
- break;
95
-
96
- } elseif ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
97
- $errorType = 'zeroArgument';
98
- break;
99
- }
100
- }
101
-
102
- if ($errorType !== '') {
103
- $error = 'Using %s on break or continue is forbidden since PHP 5.4';
104
- $errorCode = $errorType . 'Found';
105
- $data = array($this->errorTypes[$errorType]);
106
-
107
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
108
- }
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php DELETED
@@ -1,81 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Switch statements can not have multiple default blocks since PHP 7.0.
18
- *
19
- * PHP version 7.0
20
- *
21
- * @link https://wiki.php.net/rfc/switch.default.multiple
22
- * @link https://www.php.net/manual/en/control-structures.switch.php
23
- *
24
- * @since 7.0.0
25
- */
26
- class ForbiddenSwitchWithMultipleDefaultBlocksSniff extends Sniff
27
- {
28
-
29
- /**
30
- * Returns an array of tokens this test wants to listen for.
31
- *
32
- * @since 7.0.0
33
- *
34
- * @return array
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.
43
- *
44
- * @since 7.0.0
45
- *
46
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
47
- * @param int $stackPtr The position of the current token
48
- * in the stack passed in $tokens.
49
- *
50
- * @return void
51
- */
52
- public function process(File $phpcsFile, $stackPtr)
53
- {
54
- if ($this->supportsAbove('7.0') === false) {
55
- return;
56
- }
57
-
58
- $tokens = $phpcsFile->getTokens();
59
- if (isset($tokens[$stackPtr]['scope_closer']) === false) {
60
- return;
61
- }
62
-
63
- $defaultToken = $stackPtr;
64
- $defaultCount = 0;
65
- $targetLevel = $tokens[$stackPtr]['level'] + 1;
66
- while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(\T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) {
67
- // Same level or one below (= two default cases after each other).
68
- if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
69
- $defaultCount++;
70
- }
71
- }
72
-
73
- if ($defaultCount > 1) {
74
- $phpcsFile->addError(
75
- 'Switch statements can not have multiple default blocks since PHP 7.0',
76
- $stackPtr,
77
- 'Found'
78
- );
79
- }
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php DELETED
@@ -1,378 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHPCompatibility\PHPCSHelper;
15
- use PHP_CodeSniffer_File as File;
16
- use PHP_CodeSniffer_Tokens as Tokens;
17
-
18
- /**
19
- * Check for valid execution directives set with `declare()`.
20
- *
21
- * The sniff contains three distinct checks:
22
- * - Check if the execution directive used is valid. PHP currently only supports
23
- * three execution directives.
24
- * - Check if the execution directive used is available in the PHP versions
25
- * for which support is being checked.
26
- * In the case of the `encoding` directive on PHP 5.3, support is conditional
27
- * on the `--enable-zend-multibyte` compilation option. This will be indicated as such.
28
- * - Check whether the value for the directive is valid.
29
- *
30
- * PHP version All
31
- *
32
- * @link https://www.php.net/manual/en/control-structures.declare.php
33
- * @link https://wiki.php.net/rfc/scalar_type_hints_v5#strict_types_declare_directive
34
- *
35
- * @since 7.0.3
36
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class.
37
- */
38
- class NewExecutionDirectivesSniff extends AbstractNewFeatureSniff
39
- {
40
-
41
- /**
42
- * A list of new execution directives
43
- *
44
- * The array lists : version number with false (not present) or true (present).
45
- * If the execution order is conditional, add the condition as a string to the version nr.
46
- * If's sufficient to list the first version where the execution directive appears.
47
- *
48
- * @since 7.0.3
49
- *
50
- * @var array(string => array(string => bool|string|array))
51
- */
52
- protected $newDirectives = array(
53
- 'ticks' => array(
54
- '3.1' => false,
55
- '4.0' => true,
56
- 'valid_value_callback' => 'isNumeric',
57
- ),
58
- 'encoding' => array(
59
- '5.2' => false,
60
- '5.3' => '--enable-zend-multibyte', // Directive ignored unless.
61
- '5.4' => true,
62
- 'valid_value_callback' => 'validEncoding',
63
- ),
64
- 'strict_types' => array(
65
- '5.6' => false,
66
- '7.0' => true,
67
- 'valid_values' => array(1),
68
- ),
69
- );
70
-
71
-
72
- /**
73
- * Tokens to ignore when trying to find the value for the directive.
74
- *
75
- * @since 7.0.3
76
- *
77
- * @var array
78
- */
79
- protected $ignoreTokens = array();
80
-
81
-
82
- /**
83
- * Returns an array of tokens this test wants to listen for.
84
- *
85
- * @since 7.0.3
86
- *
87
- * @return array
88
- */
89
- public function register()
90
- {
91
- $this->ignoreTokens = Tokens::$emptyTokens;
92
- $this->ignoreTokens[\T_EQUAL] = \T_EQUAL;
93
-
94
- return array(\T_DECLARE);
95
- }
96
-
97
-
98
- /**
99
- * Processes this test, when one of its tokens is encountered.
100
- *
101
- * @since 7.0.3
102
- *
103
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
104
- * @param int $stackPtr The position of the current token in
105
- * the stack passed in $tokens.
106
- *
107
- * @return void
108
- */
109
- public function process(File $phpcsFile, $stackPtr)
110
- {
111
- $tokens = $phpcsFile->getTokens();
112
-
113
- if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === true) {
114
- $openParenthesis = $tokens[$stackPtr]['parenthesis_opener'];
115
- $closeParenthesis = $tokens[$stackPtr]['parenthesis_closer'];
116
- } else {
117
- if (version_compare(PHPCSHelper::getVersion(), '2.3.4', '>=')) {
118
- return;
119
- }
120
-
121
- // Deal with PHPCS 2.3.0-2.3.3 which do not yet set the parenthesis properly for declare statements.
122
- $openParenthesis = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true);
123
- if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
124
- return;
125
- }
126
- $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
127
- }
128
-
129
- $directivePtr = $phpcsFile->findNext(\T_STRING, ($openParenthesis + 1), $closeParenthesis, false);
130
- if ($directivePtr === false) {
131
- return;
132
- }
133
-
134
- $directiveContent = $tokens[$directivePtr]['content'];
135
-
136
- if (isset($this->newDirectives[$directiveContent]) === false) {
137
- $error = 'Declare can only be used with the directives %s. Found: %s';
138
- $data = array(
139
- implode(', ', array_keys($this->newDirectives)),
140
- $directiveContent,
141
- );
142
-
143
- $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
144
-
145
- } else {
146
- // Check for valid directive for version.
147
- $itemInfo = array(
148
- 'name' => $directiveContent,
149
- );
150
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
151
-
152
- // Check for valid directive value.
153
- $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
154
- if ($valuePtr === false) {
155
- return;
156
- }
157
-
158
- $this->addWarningOnInvalidValue($phpcsFile, $valuePtr, $directiveContent);
159
- }
160
- }
161
-
162
-
163
- /**
164
- * Determine whether an error/warning should be thrown for an item based on collected information.
165
- *
166
- * @since 7.1.0
167
- *
168
- * @param array $errorInfo Detail information about an item.
169
- *
170
- * @return bool
171
- */
172
- protected function shouldThrowError(array $errorInfo)
173
- {
174
- return ($errorInfo['not_in_version'] !== '' || $errorInfo['conditional_version'] !== '');
175
- }
176
-
177
-
178
- /**
179
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
180
- *
181
- * @since 7.1.0
182
- *
183
- * @param array $itemInfo Base information about the item.
184
- *
185
- * @return array Version and other information about the item.
186
- */
187
- public function getItemArray(array $itemInfo)
188
- {
189
- return $this->newDirectives[$itemInfo['name']];
190
- }
191
-
192
-
193
- /**
194
- * Get an array of the non-PHP-version array keys used in a sub-array.
195
- *
196
- * @since 7.1.0
197
- *
198
- * @return array
199
- */
200
- protected function getNonVersionArrayKeys()
201
- {
202
- return array(
203
- 'valid_value_callback',
204
- 'valid_values',
205
- );
206
- }
207
-
208
-
209
- /**
210
- * Retrieve the relevant detail (version) information for use in an error message.
211
- *
212
- * @since 7.1.0
213
- *
214
- * @param array $itemArray Version and other information about the item.
215
- * @param array $itemInfo Base information about the item.
216
- *
217
- * @return array
218
- */
219
- public function getErrorInfo(array $itemArray, array $itemInfo)
220
- {
221
- $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
222
- $errorInfo['conditional_version'] = '';
223
- $errorInfo['condition'] = '';
224
-
225
- $versionArray = $this->getVersionArray($itemArray);
226
-
227
- if (empty($versionArray) === false) {
228
- foreach ($versionArray as $version => $present) {
229
- if (\is_string($present) === true && $this->supportsBelow($version) === true) {
230
- // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
231
- $errorInfo['conditional_version'] = $version;
232
- $errorInfo['condition'] = $present;
233
- }
234
- }
235
- }
236
-
237
- return $errorInfo;
238
- }
239
-
240
-
241
- /**
242
- * Get the error message template for this sniff.
243
- *
244
- * @since 7.1.0
245
- *
246
- * @return string
247
- */
248
- protected function getErrorMsgTemplate()
249
- {
250
- return 'Directive ' . parent::getErrorMsgTemplate();
251
- }
252
-
253
-
254
- /**
255
- * Generates the error or warning for this item.
256
- *
257
- * @since 7.0.3
258
- * @since 7.1.0 This method now overloads the method from the `AbstractNewFeatureSniff` class.
259
- * - Renamed from `maybeAddError()` to `addError()`.
260
- * - Changed visibility from `protected` to `public`.
261
- *
262
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
263
- * @param int $stackPtr The position of the relevant token in
264
- * the stack.
265
- * @param array $itemInfo Base information about the item.
266
- * @param array $errorInfo Array with detail (version) information
267
- * relevant to the item.
268
- *
269
- * @return void
270
- */
271
- public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
272
- {
273
- if ($errorInfo['not_in_version'] !== '') {
274
- parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
275
- } elseif ($errorInfo['conditional_version'] !== '') {
276
- $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
277
- $errorCode = $this->stringToErrorCode($itemInfo['name']) . 'WithConditionFound';
278
- $data = array(
279
- $itemInfo['name'],
280
- $errorInfo['conditional_version'],
281
- $errorInfo['condition'],
282
- );
283
-
284
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
285
- }
286
- }
287
-
288
-
289
- /**
290
- * Generates a error or warning for this sniff.
291
- *
292
- * @since 7.0.3
293
- * @since 7.0.6 Renamed from `addErrorOnInvalidValue()` to `addWarningOnInvalidValue()`.
294
- *
295
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
296
- * @param int $stackPtr The position of the execution directive value
297
- * in the token array.
298
- * @param string $directive The directive.
299
- *
300
- * @return void
301
- */
302
- protected function addWarningOnInvalidValue(File $phpcsFile, $stackPtr, $directive)
303
- {
304
- $tokens = $phpcsFile->getTokens();
305
-
306
- $value = $tokens[$stackPtr]['content'];
307
- if (isset(Tokens::$stringTokens[$tokens[$stackPtr]['code']]) === true) {
308
- $value = $this->stripQuotes($value);
309
- }
310
-
311
- $isError = false;
312
- if (isset($this->newDirectives[$directive]['valid_values'])) {
313
- if (\in_array($value, $this->newDirectives[$directive]['valid_values']) === false) {
314
- $isError = true;
315
- }
316
- } elseif (isset($this->newDirectives[$directive]['valid_value_callback'])) {
317
- $valid = \call_user_func(array($this, $this->newDirectives[$directive]['valid_value_callback']), $value);
318
- if ($valid === false) {
319
- $isError = true;
320
- }
321
- }
322
-
323
- if ($isError === true) {
324
- $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
325
- $errorCode = $this->stringToErrorCode($directive) . 'InvalidValueFound';
326
- $data = array(
327
- $directive,
328
- $value,
329
- );
330
-
331
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
332
- }
333
- }
334
-
335
-
336
- /**
337
- * Check whether a value is numeric.
338
- *
339
- * Callback function to test whether the value for an execution directive is valid.
340
- *
341
- * @since 7.0.3
342
- *
343
- * @param mixed $value The value to test.
344
- *
345
- * @return bool
346
- */
347
- protected function isNumeric($value)
348
- {
349
- return is_numeric($value);
350
- }
351
-
352
-
353
- /**
354
- * Check whether a value is a valid encoding.
355
- *
356
- * Callback function to test whether the value for an execution directive is valid.
357
- *
358
- * @since 7.0.3
359
- *
360
- * @param mixed $value The value to test.
361
- *
362
- * @return bool
363
- */
364
- protected function validEncoding($value)
365
- {
366
- static $encodings;
367
- if (isset($encodings) === false && function_exists('mb_list_encodings')) {
368
- $encodings = mb_list_encodings();
369
- }
370
-
371
- if (empty($encodings) || \is_array($encodings) === false) {
372
- // If we can't test the encoding, let it pass through.
373
- return true;
374
- }
375
-
376
- return \in_array($value, $encodings, true);
377
- }
378
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewForeachExpressionReferencingSniff.php DELETED
@@ -1,99 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect `foreach` expression referencing.
18
- *
19
- * Before PHP 5.5.0, referencing `$value` in a `foreach` was only possible
20
- * if the iterated array could be referenced (i.e. if it is a variable).
21
- *
22
- * PHP version 5.5
23
- *
24
- * @link https://www.php.net/manual/en/control-structures.foreach.php
25
- *
26
- * @since 9.0.0
27
- */
28
- class NewForeachExpressionReferencingSniff extends Sniff
29
- {
30
-
31
- /**
32
- * Returns an array of tokens this test wants to listen for.
33
- *
34
- * @since 9.0.0
35
- *
36
- * @return array
37
- */
38
- public function register()
39
- {
40
- return array(\T_FOREACH);
41
- }
42
-
43
- /**
44
- * Processes this test, when one of its tokens is encountered.
45
- *
46
- * @since 9.0.0
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(File $phpcsFile, $stackPtr)
55
- {
56
- if ($this->supportsBelow('5.4') === false) {
57
- return;
58
- }
59
-
60
- $tokens = $phpcsFile->getTokens();
61
-
62
- if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
63
- return;
64
- }
65
-
66
- $opener = $tokens[$stackPtr]['parenthesis_opener'];
67
- $closer = $tokens[$stackPtr]['parenthesis_closer'];
68
-
69
- $asToken = $phpcsFile->findNext(\T_AS, ($opener + 1), $closer);
70
- if ($asToken === false) {
71
- return;
72
- }
73
-
74
- /*
75
- * Note: referencing $key is not allowed in any version, so this should only find referenced $values.
76
- * If it does find a referenced key, it would be a parse error anyway.
77
- */
78
- $hasReference = $phpcsFile->findNext(\T_BITWISE_AND, ($asToken + 1), $closer);
79
- if ($hasReference === false) {
80
- return;
81
- }
82
-
83
- $nestingLevel = 0;
84
- if ($asToken !== ($opener + 1) && isset($tokens[$opener + 1]['nested_parenthesis'])) {
85
- $nestingLevel = \count($tokens[$opener + 1]['nested_parenthesis']);
86
- }
87
-
88
- if ($this->isVariable($phpcsFile, ($opener + 1), $asToken, $nestingLevel) === true) {
89
- return;
90
- }
91
-
92
- // Non-variable detected before the `as` keyword.
93
- $phpcsFile->addError(
94
- 'Referencing $value is only possible if the iterated array is a variable in PHP 5.4 or earlier.',
95
- $hasReference,
96
- 'Found'
97
- );
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewListInForeachSniff.php DELETED
@@ -1,84 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect unpacking nested arrays with `list()` in a `foreach()` as available since PHP 5.5.
18
- *
19
- * PHP version 5.5
20
- *
21
- * @link https://www.php.net/manual/en/migration55.new-features.php#migration55.new-features.foreach-list
22
- * @link https://wiki.php.net/rfc/foreachlist
23
- * @link https://www.php.net/manual/en/control-structures.foreach.php#control-structures.foreach.list
24
- *
25
- * @since 9.0.0
26
- */
27
- class NewListInForeachSniff extends Sniff
28
- {
29
-
30
- /**
31
- * Returns an array of tokens this test wants to listen for.
32
- *
33
- * @since 9.0.0
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
- * @since 9.0.0
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(File $phpcsFile, $stackPtr)
54
- {
55
- if ($this->supportsBelow('5.4') === false) {
56
- return;
57
- }
58
-
59
- $tokens = $phpcsFile->getTokens();
60
-
61
- if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
62
- return;
63
- }
64
-
65
- $opener = $tokens[$stackPtr]['parenthesis_opener'];
66
- $closer = $tokens[$stackPtr]['parenthesis_closer'];
67
-
68
- $asToken = $phpcsFile->findNext(\T_AS, ($opener + 1), $closer);
69
- if ($asToken === false) {
70
- return;
71
- }
72
-
73
- $hasList = $phpcsFile->findNext(array(\T_LIST, \T_OPEN_SHORT_ARRAY), ($asToken + 1), $closer);
74
- if ($hasList === false) {
75
- return;
76
- }
77
-
78
- $phpcsFile->addError(
79
- 'Unpacking nested arrays with list() in a foreach is not supported in PHP 5.4 or earlier.',
80
- $hasList,
81
- 'Found'
82
- );
83
- }
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewMultiCatchSniff.php DELETED
@@ -1,78 +0,0 @@
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\ControlStructures;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Catching multiple exception types in one statement is available since PHP 7.1.
18
- *
19
- * PHP version 7.1
20
- *
21
- * @link https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.mulit-catch-exception-handling
22
- * @link https://wiki.php.net/rfc/multiple-catch
23
- * @link https://www.php.net/manual/en/language.exceptions.php#language.exceptions.catch
24
- *
25
- * @since 7.0.7
26
- */
27
- class NewMultiCatchSniff extends Sniff
28
- {
29
- /**
30
- * Returns an array of tokens this test wants to listen for.
31
- *
32
- * @since 7.0.7
33
- *
34
- * @return array
35
- */
36
- public function register()
37
- {
38
- return array(\T_CATCH);
39
- }
40
-
41
- /**
42
- * Processes this test, when one of its tokens is encountered.
43
- *
44
- * @since 7.0.7
45
- *
46
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
47
- * @param int $stackPtr The position of the current token
48
- * in the stack passed in $tokens.
49
- *
50
- * @return void
51
- */
52
- public function process(File $phpcsFile, $stackPtr)
53
- {
54
- if ($this->supportsBelow('7.0') === false) {
55
- return;
56
- }
57
-
58
- $tokens = $phpcsFile->getTokens();
59
- $token = $tokens[$stackPtr];
60
-
61
- // Bow out during live coding.
62
- if (isset($token['parenthesis_opener'], $token['parenthesis_closer']) === false) {
63
- return;
64
- }
65
-
66
- $hasBitwiseOr = $phpcsFile->findNext(\T_BITWISE_OR, $token['parenthesis_opener'], $token['parenthesis_closer']);
67
-
68
- if ($hasBitwiseOr === false) {
69
- return;
70
- }
71
-
72
- $phpcsFile->addError(
73
- 'Catching multiple exceptions within one statement is not supported in PHP 7.0 or earlier.',
74
- $hasBitwiseOr,
75
- 'Found'
76
- );
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php DELETED
@@ -1,346 +0,0 @@
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\Extensions;
12
-
13
- use PHPCompatibility\AbstractRemovedFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect the use of deprecated and/or removed PHP extensions.
19
- *
20
- * This sniff examines function calls made and flags function calls to functions
21
- * prefixed with the dedicated prefix from a deprecated/removed native PHP extension.
22
- *
23
- * Suggests alternative extensions if available.
24
- *
25
- * As userland functions may be prefixed with a prefix also used by a native
26
- * PHP extension, the sniff offers the ability to whitelist specific functions
27
- * from being flagged by this sniff via a property in a custom ruleset
28
- * (since PHPCompatibility 7.0.2).
29
- *
30
- * {@internal This sniff is a candidate for removal once all functions from all
31
- * deprecated/removed extensions have been added to the RemovedFunctions sniff.}
32
- *
33
- * PHP version All
34
- *
35
- * @since 5.5
36
- * @since 7.1.0 Now extends the `AbstractRemovedFeatureSniff` instead of the base `Sniff` class.
37
- */
38
- class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
39
- {
40
- /**
41
- * A list of functions to whitelist, if any.
42
- *
43
- * This is intended for projects using functions which start with the same
44
- * prefix as one of the removed extensions.
45
- *
46
- * This property can be set from the ruleset, like so:
47
- * <rule ref="PHPCompatibility.Extensions.RemovedExtensions">
48
- * <properties>
49
- * <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
50
- * </properties>
51
- * </rule>
52
- *
53
- * @since 7.0.2
54
- *
55
- * @var array
56
- */
57
- public $functionWhitelist;
58
-
59
- /**
60
- * A list of removed extensions with their alternative, if any.
61
- *
62
- * The array lists : version number with false (deprecated) and true (removed).
63
- * If's sufficient to list the first version where the extension was deprecated/removed.
64
- *
65
- * @since 5.5
66
- *
67
- * @var array(string => array(string => bool|string|null))
68
- */
69
- protected $removedExtensions = array(
70
- 'activescript' => array(
71
- '5.1' => true,
72
- 'alternative' => 'pecl/activescript',
73
- ),
74
- 'cpdf' => array(
75
- '5.1' => true,
76
- 'alternative' => 'pecl/pdflib',
77
- ),
78
- 'dbase' => array(
79
- '5.3' => true,
80
- 'alternative' => null,
81
- ),
82
- 'dbx' => array(
83
- '5.1' => true,
84
- 'alternative' => 'pecl/dbx',
85
- ),
86
- 'dio' => array(
87
- '5.1' => true,
88
- 'alternative' => 'pecl/dio',
89
- ),
90
- 'ereg' => array(
91
- '5.3' => false,
92
- '7.0' => true,
93
- 'alternative' => 'pcre',
94
- ),
95
- 'fam' => array(
96
- '5.1' => true,
97
- 'alternative' => null,
98
- ),
99
- 'fbsql' => array(
100
- '5.3' => true,
101
- 'alternative' => null,
102
- ),
103
- 'fdf' => array(
104
- '5.3' => true,
105
- 'alternative' => 'pecl/fdf',
106
- ),
107
- 'filepro' => array(
108
- '5.2' => true,
109
- 'alternative' => null,
110
- ),
111
- 'hw_api' => array(
112
- '5.2' => true,
113
- 'alternative' => null,
114
- ),
115
- 'ibase' => array(
116
- '7.4' => true,
117
- 'alternative' => 'pecl/ibase',
118
- ),
119
- 'ingres' => array(
120
- '5.1' => true,
121
- 'alternative' => 'pecl/ingres',
122
- ),
123
- 'ircg' => array(
124
- '5.1' => true,
125
- 'alternative' => null,
126
- ),
127
- 'mcrypt' => array(
128
- '7.1' => false,
129
- '7.2' => true,
130
- 'alternative' => 'openssl (preferred) or pecl/mcrypt once available',
131
- ),
132
- 'mcve' => array(
133
- '5.1' => true,
134
- 'alternative' => 'pecl/mcve',
135
- ),
136
- 'ming' => array(
137
- '5.3' => true,
138
- 'alternative' => 'pecl/ming',
139
- ),
140
- 'mnogosearch' => array(
141
- '5.1' => true,
142
- 'alternative' => null,
143
- ),
144
- 'msql' => array(
145
- '5.3' => true,
146
- 'alternative' => null,
147
- ),
148
- 'mssql' => array(
149
- '7.0' => true,
150
- 'alternative' => null,
151
- ),
152
- 'mysql_' => array(
153
- '5.5' => false,
154
- '7.0' => true,
155
- 'alternative' => 'mysqli',
156
- ),
157
- 'ncurses' => array(
158
- '5.3' => true,
159
- 'alternative' => 'pecl/ncurses',
160
- ),
161
- 'oracle' => array(
162
- '5.1' => true,
163
- 'alternative' => 'oci8 or pdo_oci',
164
- ),
165
- 'ovrimos' => array(
166
- '5.1' => true,
167
- 'alternative' => null,
168
- ),
169
- 'pfpro_' => array(
170
- '5.1' => true,
171
- 'alternative' => null,
172
- ),
173
- 'recode' => array(
174
- '7.4' => true,
175
- 'alternative' => 'iconv or mbstring',
176
- ),
177
- 'sqlite' => array(
178
- '5.4' => true,
179
- 'alternative' => null,
180
- ),
181
- // Has to be before `sybase` as otherwise it will never match.
182
- 'sybase_ct' => array(
183
- '7.0' => true,
184
- 'alternative' => null,
185
- ),
186
- 'sybase' => array(
187
- '5.3' => true,
188
- 'alternative' => 'sybase_ct',
189
- ),
190
- 'w32api' => array(
191
- '5.1' => true,
192
- 'alternative' => 'pecl/ffi',
193
- ),
194
- 'wddx' => array(
195
- '7.4' => true,
196
- 'alternative' => 'pecl/wddx',
197
- ),
198
- 'yp' => array(
199
- '5.1' => true,
200
- 'alternative' => null,
201
- ),
202
- );
203
-
204
- /**
205
- * Returns an array of tokens this test wants to listen for.
206
- *
207
- * @since 5.5
208
- *
209
- * @return array
210
- */
211
- public function register()
212
- {
213
- // Handle case-insensitivity of function names.
214
- $this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
215
-
216
- return array(\T_STRING);
217
- }
218
-
219
- /**
220
- * Processes this test, when one of its tokens is encountered.
221
- *
222
- * @since 5.5
223
- *
224
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
225
- * @param int $stackPtr The position of the current token in the
226
- * stack passed in $tokens.
227
- *
228
- * @return void
229
- */
230
- public function process(File $phpcsFile, $stackPtr)
231
- {
232
- $tokens = $phpcsFile->getTokens();
233
-
234
- // Find the next non-empty token.
235
- $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
236
-
237
- if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
238
- // Not a function call.
239
- return;
240
- }
241
-
242
- if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
243
- // Not a function call.
244
- return;
245
- }
246
-
247
- // Find the previous non-empty token.
248
- $search = Tokens::$emptyTokens;
249
- $search[] = \T_BITWISE_AND;
250
- $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
251
- if ($tokens[$previous]['code'] === \T_FUNCTION) {
252
- // It's a function definition, not a function call.
253
- return;
254
- }
255
-
256
- if ($tokens[$previous]['code'] === \T_NEW) {
257
- // We are creating an object, not calling a function.
258
- return;
259
- }
260
-
261
- if ($tokens[$previous]['code'] === \T_OBJECT_OPERATOR) {
262
- // We are calling a method of an object.
263
- return;
264
- }
265
-
266
- $function = $tokens[$stackPtr]['content'];
267
- $functionLc = strtolower($function);
268
-
269
- if ($this->isWhiteListed($functionLc) === true) {
270
- // Function is whitelisted.
271
- return;
272
- }
273
-
274
- foreach ($this->removedExtensions as $extension => $versionList) {
275
- if (strpos($functionLc, $extension) === 0) {
276
- $itemInfo = array(
277
- 'name' => $extension,
278
- );
279
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
280
- break;
281
- }
282
- }
283
- }
284
-
285
-
286
- /**
287
- * Is the current function being checked whitelisted ?
288
- *
289
- * Parsing the list late as it may be provided as a property, but also inline.
290
- *
291
- * @since 7.0.2
292
- *
293
- * @param string $content Content of the current token.
294
- *
295
- * @return bool
296
- */
297
- protected function isWhiteListed($content)
298
- {
299
- if (isset($this->functionWhitelist) === false) {
300
- return false;
301
- }
302
-
303
- if (\is_string($this->functionWhitelist) === true) {
304
- if (strpos($this->functionWhitelist, ',') !== false) {
305
- $this->functionWhitelist = explode(',', $this->functionWhitelist);
306
- } else {
307
- $this->functionWhitelist = (array) $this->functionWhitelist;
308
- }
309
- }
310
-
311
- if (\is_array($this->functionWhitelist) === true) {
312
- $this->functionWhitelist = array_map('strtolower', $this->functionWhitelist);
313
- return \in_array($content, $this->functionWhitelist, true);
314
- }
315
-
316
- return false;
317
- }
318
-
319
-
320
- /**
321
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
322
- *
323
- * @since 7.1.0
324
- *
325
- * @param array $itemInfo Base information about the item.
326
- *
327
- * @return array Version and other information about the item.
328
- */
329
- public function getItemArray(array $itemInfo)
330
- {
331
- return $this->removedExtensions[$itemInfo['name']];
332
- }
333
-
334
-
335
- /**
336
- * Get the error message template for this sniff.
337
- *
338
- * @since 7.1.0
339
- *
340
- * @return string
341
- */
342
- protected function getErrorMsgTemplate()
343
- {
344
- return "Extension '%s' is ";
345
- }
346
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenParameterShadowSuperGlobalsSniff.php DELETED
@@ -1,79 +0,0 @@
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
- * Detect the use of superglobals as parameters for functions, support for which was removed in PHP 5.4.
19
- *
20
- * {@internal List of superglobals is maintained in the parent class.}
21
- *
22
- * PHP version 5.4
23
- *
24
- * @link https://www.php.net/manual/en/migration54.incompatible.php
25
- *
26
- * @since 7.0.0
27
- */
28
- class ForbiddenParameterShadowSuperGlobalsSniff extends Sniff
29
- {
30
-
31
- /**
32
- * Register the tokens to listen for.
33
- *
34
- * @since 7.0.0
35
- * @since 7.1.3 Allows for closures.
36
- *
37
- * @return array
38
- */
39
- public function register()
40
- {
41
- return array(
42
- \T_FUNCTION,
43
- \T_CLOSURE,
44
- );
45
- }
46
-
47
- /**
48
- * Processes the test.
49
- *
50
- * @since 7.0.0
51
- *
52
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
- * @param int $stackPtr The position of the current token.
54
- *
55
- * @return void
56
- */
57
- public function process(File $phpcsFile, $stackPtr)
58
- {
59
- if ($this->supportsAbove('5.4') === false) {
60
- return;
61
- }
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']);
74
-
75
- $phpcsFile->addError($error, $param['token'], $errorCode, $data);
76
- }
77
- }
78
- }
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenParametersWithSameNameSniff.php DELETED
@@ -1,88 +0,0 @@
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
- * Functions can not have multiple parameters with the same name since PHP 7.0.
19
- *
20
- * PHP version 7.0
21
- *
22
- * @link https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameters
23
- *
24
- * @since 7.0.0
25
- */
26
- class ForbiddenParametersWithSameNameSniff extends Sniff
27
- {
28
-
29
- /**
30
- * Returns an array of tokens this test wants to listen for.
31
- *
32
- * @since 7.0.0
33
- * @since 7.1.3 Allows for closures.
34
- *
35
- * @return array
36
- */
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.
47
- *
48
- * @since 7.0.0
49
- *
50
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
- * @param int $stackPtr The position of the current token
52
- * in the stack passed in $tokens.
53
- *
54
- * @return void
55
- */
56
- public function process(File $phpcsFile, $stackPtr)
57
- {
58
- if ($this->supportsAbove('7.0') === false) {
59
- return;
60
- }
61
-
62
- $tokens = $phpcsFile->getTokens();
63
- $token = $tokens[$stackPtr];
64
- // Skip function without body.
65
- if (isset($token['scope_opener']) === false) {
66
- return;
67
- }
68
-
69
- // Get all parameters from method signature.
70
- $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
71
- if (empty($parameters) || \is_array($parameters) === false) {
72
- return;
73
- }
74
-
75
- $paramNames = array();
76
- foreach ($parameters as $param) {
77
- $paramNames[] = $param['name'];
78
- }
79
-
80
- if (\count($paramNames) !== \count(array_unique($paramNames))) {
81
- $phpcsFile->addError(
82
- 'Functions can not have multiple parameters with the same name since PHP 7.0',
83
- $stackPtr,
84
- 'Found'
85
- );
86
- }
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenToStringParametersSniff.php DELETED
@@ -1,99 +0,0 @@
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
- * PHP version 5.3
23
- *
24
- * @link https://www.php.net/manual/en/migration53.incompatible.php
25
- * @link https://www.php.net/manual/en/language.oop5.magic.php#object.tostring
26
- *
27
- * @since 9.2.0
28
- */
29
- class ForbiddenToStringParametersSniff extends Sniff
30
- {
31
-
32
- /**
33
- * Valid scopes for the __toString() method to live in.
34
- *
35
- * @since 9.2.0
36
- * @since 9.3.2 Visibility changed from `public` to `protected`.
37
- *
38
- * @var array
39
- */
40
- protected $ooScopeTokens = array(
41
- 'T_CLASS' => true,
42
- 'T_INTERFACE' => true,
43
- 'T_TRAIT' => true,
44
- 'T_ANON_CLASS' => true,
45
- );
46
-
47
- /**
48
- * Returns an array of tokens this test wants to listen for.
49
- *
50
- * @since 9.2.0
51
- *
52
- * @return array
53
- */
54
- public function register()
55
- {
56
- return array(\T_FUNCTION);
57
- }
58
-
59
- /**
60
- * Processes this test, when one of its tokens is encountered.
61
- *
62
- * @since 9.2.0
63
- *
64
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
- * @param int $stackPtr The position of the current token
66
- * in the stack passed in $tokens.
67
- *
68
- * @return void
69
- */
70
- public function process(File $phpcsFile, $stackPtr)
71
- {
72
- if ($this->supportsAbove('5.3') === false) {
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
- $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
88
- if (empty($params)) {
89
- // Function declared without parameters.
90
- return;
91
- }
92
-
93
- $phpcsFile->addError(
94
- 'The __toString() magic method can no longer accept arguments since PHP 5.3',
95
- $stackPtr,
96
- 'Declared'
97
- );
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/ForbiddenVariableNamesInClosureUseSniff.php DELETED
@@ -1,122 +0,0 @@
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
- use PHP_CodeSniffer_Tokens as Tokens;
17
-
18
- /**
19
- * Detect variable names forbidden to be used in closure `use` statements.
20
- *
21
- * Variables bound to a closure via the `use` construct cannot use the same name
22
- * as any superglobals, `$this`, or any parameter since PHP 7.1.
23
- *
24
- * PHP version 7.1
25
- *
26
- * @link https://www.php.net/manual/en/migration71.incompatible.php#migration71.incompatible.lexical-names
27
- * @link https://www.php.net/manual/en/functions.anonymous.php
28
- *
29
- * @since 7.1.4
30
- */
31
- class ForbiddenVariableNamesInClosureUseSniff extends Sniff
32
- {
33
-
34
- /**
35
- * Returns an array of tokens this test wants to listen for.
36
- *
37
- * @since 7.1.4
38
- *
39
- * @return array
40
- */
41
- public function register()
42
- {
43
- return array(\T_USE);
44
- }
45
-
46
- /**
47
- * Processes this test, when one of its tokens is encountered.
48
- *
49
- * @since 7.1.4
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('7.1') === false) {
60
- return;
61
- }
62
-
63
- $tokens = $phpcsFile->getTokens();
64
-
65
- // Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
66
- $previousNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
67
- if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== \T_CLOSE_PARENTHESIS
68
- || isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
69
- ) {
70
- return;
71
- }
72
-
73
- // ... and (a variable within) parenthesis after it.
74
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
75
- if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
76
- return;
77
- }
78
-
79
- if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
80
- // Live coding.
81
- return;
82
- }
83
-
84
- $closurePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true);
85
- if ($closurePtr === false || $tokens[$closurePtr]['code'] !== \T_CLOSURE) {
86
- return;
87
- }
88
-
89
- // Get the parameters declared by the closure.
90
- $closureParams = PHPCSHelper::getMethodParameters($phpcsFile, $closurePtr);
91
-
92
- $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';
93
-
94
- for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
95
- if ($tokens[$i]['code'] !== \T_VARIABLE) {
96
- continue;
97
- }
98
-
99
- $variableName = $tokens[$i]['content'];
100
-
101
- if ($variableName === '$this') {
102
- $phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName));
103
- continue;
104
- }
105
-
106
- if (isset($this->superglobals[$variableName]) === true) {
107
- $phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
108
- continue;
109
- }
110
-
111
- // Check whether it is one of the parameters declared by the closure.
112
- if (empty($closureParams) === false) {
113
- foreach ($closureParams as $param) {
114
- if ($param['name'] === $variableName) {
115
- $phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName));
116
- continue 2;
117
- }
118
- }
119
- }
120
- }
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewClosureSniff.php DELETED
@@ -1,264 +0,0 @@
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
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect closures and verify that the features used are supported.
19
- *
20
- * Version based checks:
21
- * - Closures are available since PHP 5.3.
22
- * - Closures can be declared as `static` since PHP 5.4.
23
- * - Closures can use the `$this` variable within a class context since PHP 5.4.
24
- * - Closures can use `self`/`parent`/`static` since PHP 5.4.
25
- *
26
- * Version independent checks:
27
- * - Static closures don't have access to the `$this` variable.
28
- * - Closures declared outside of a class context don't have access to the `$this`
29
- * variable unless bound to an object.
30
- *
31
- * PHP version 5.3
32
- * PHP version 5.4
33
- *
34
- * @link https://www.php.net/manual/en/functions.anonymous.php
35
- * @link https://wiki.php.net/rfc/closures
36
- * @link https://wiki.php.net/rfc/closures/object-extension
37
- *
38
- * @since 7.0.0
39
- */
40
- class NewClosureSniff extends Sniff
41
- {
42
- /**
43
- * Returns an array of tokens this test wants to listen for.
44
- *
45
- * @since 7.0.0
46
- *
47
- * @return array
48
- */
49
- public function register()
50
- {
51
- return array(\T_CLOSURE);
52
- }
53
-
54
- /**
55
- * Processes this test, when one of its tokens is encountered.
56
- *
57
- * @since 7.0.0
58
- * @since 7.1.4 - Added check for closure being declared as static < 5.4.
59
- * - Added check for use of `$this` variable in class context < 5.4.
60
- * - Added check for use of `$this` variable in static closures (unsupported).
61
- * - Added check for use of `$this` variable outside class context (unsupported).
62
- * @since 8.2.0 Added check for use of `self`/`static`/`parent` < 5.4.
63
- *
64
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
- * @param int $stackPtr The position of the current token
66
- * in the stack passed in $tokens.
67
- *
68
- * @return int|void Integer stack pointer to skip forward or void to continue
69
- * normal file processing.
70
- */
71
- public function process(File $phpcsFile, $stackPtr)
72
- {
73
- if ($this->supportsBelow('5.2')) {
74
- $phpcsFile->addError(
75
- 'Closures / anonymous functions are not available in PHP 5.2 or earlier',
76
- $stackPtr,
77
- 'Found'
78
- );
79
- }
80
-
81
- /*
82
- * Closures can only be declared as static since PHP 5.4.
83
- */
84
- $isStatic = $this->isClosureStatic($phpcsFile, $stackPtr);
85
- if ($this->supportsBelow('5.3') && $isStatic === true) {
86
- $phpcsFile->addError(
87
- 'Closures / anonymous functions could not be declared as static in PHP 5.3 or earlier',
88
- $stackPtr,
89
- 'StaticFound'
90
- );
91
- }
92
-
93
- $tokens = $phpcsFile->getTokens();
94
-
95
- if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
96
- // Live coding or parse error.
97
- return;
98
- }
99
-
100
- $scopeStart = ($tokens[$stackPtr]['scope_opener'] + 1);
101
- $scopeEnd = $tokens[$stackPtr]['scope_closer'];
102
- $usesThis = $this->findThisUsageInClosure($phpcsFile, $scopeStart, $scopeEnd);
103
-
104
- if ($this->supportsBelow('5.3')) {
105
- /*
106
- * Closures declared within classes only have access to $this since PHP 5.4.
107
- */
108
- if ($usesThis !== false) {
109
- $thisFound = $usesThis;
110
- do {
111
- $phpcsFile->addError(
112
- 'Closures / anonymous functions did not have access to $this in PHP 5.3 or earlier',
113
- $thisFound,
114
- 'ThisFound'
115
- );
116
-
117
- $thisFound = $this->findThisUsageInClosure($phpcsFile, ($thisFound + 1), $scopeEnd);
118
-
119
- } while ($thisFound !== false);
120
- }
121
-
122
- /*
123
- * Closures declared within classes only have access to self/parent/static since PHP 5.4.
124
- */
125
- $usesClassRef = $this->findClassRefUsageInClosure($phpcsFile, $scopeStart, $scopeEnd);
126
-
127
- if ($usesClassRef !== false) {
128
- do {
129
- $phpcsFile->addError(
130
- 'Closures / anonymous functions could not use "%s::" in PHP 5.3 or earlier',
131
- $usesClassRef,
132
- 'ClassRefFound',
133
- array(strtolower($tokens[$usesClassRef]['content']))
134
- );
135
-
136
- $usesClassRef = $this->findClassRefUsageInClosure($phpcsFile, ($usesClassRef + 1), $scopeEnd);
137
-
138
- } while ($usesClassRef !== false);
139
- }
140
- }
141
-
142
- /*
143
- * Check for correct usage.
144
- */
145
- if ($this->supportsAbove('5.4') && $usesThis !== false) {
146
-
147
- $thisFound = $usesThis;
148
-
149
- do {
150
- /*
151
- * Closures only have access to $this if not declared as static.
152
- */
153
- if ($isStatic === true) {
154
- $phpcsFile->addError(
155
- 'Closures / anonymous functions declared as static do not have access to $this',
156
- $thisFound,
157
- 'ThisFoundInStatic'
158
- );
159
- }
160
-
161
- /*
162
- * Closures only have access to $this if used within a class context.
163
- */
164
- elseif ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
165
- $phpcsFile->addWarning(
166
- 'Closures / anonymous functions only have access to $this if used within a class or when bound to an object using bindTo(). Please verify.',
167
- $thisFound,
168
- 'ThisFoundOutsideClass'
169
- );
170
- }
171
-
172
- $thisFound = $this->findThisUsageInClosure($phpcsFile, ($thisFound + 1), $scopeEnd);
173
-
174
- } while ($thisFound !== false);
175
- }
176
-
177
- // Prevent double reporting for nested closures.
178
- return $scopeEnd;
179
- }
180
-
181
-
182
- /**
183
- * Check whether the closure is declared as static.
184
- *
185
- * @since 7.1.4
186
- *
187
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
188
- * @param int $stackPtr The position of the current token
189
- * in the stack passed in $tokens.
190
- *
191
- * @return bool
192
- */
193
- protected function isClosureStatic(File $phpcsFile, $stackPtr)
194
- {
195
- $tokens = $phpcsFile->getTokens();
196
- $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
197
-
198
- return ($prevToken !== false && $tokens[$prevToken]['code'] === \T_STATIC);
199
- }
200
-
201
-
202
- /**
203
- * Check if the code within a closure uses the $this variable.
204
- *
205
- * @since 7.1.4
206
- *
207
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
208
- * @param int $startToken The position within the closure to continue searching from.
209
- * @param int $endToken The closure scope closer to stop searching at.
210
- *
211
- * @return int|false The stackPtr to the first $this usage if found or false if
212
- * $this is not used.
213
- */
214
- protected function findThisUsageInClosure(File $phpcsFile, $startToken, $endToken)
215
- {
216
- // Make sure the $startToken is valid.
217
- if ($startToken >= $endToken) {
218
- return false;
219
- }
220
-
221
- return $phpcsFile->findNext(
222
- \T_VARIABLE,
223
- $startToken,
224
- $endToken,
225
- false,
226
- '$this'
227
- );
228
- }
229
-
230
- /**
231
- * Check if the code within a closure uses "self/parent/static".
232
- *
233
- * @since 8.2.0
234
- *
235
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
236
- * @param int $startToken The position within the closure to continue searching from.
237
- * @param int $endToken The closure scope closer to stop searching at.
238
- *
239
- * @return int|false The stackPtr to the first classRef usage if found or false if
240
- * they are not used.
241
- */
242
- protected function findClassRefUsageInClosure(File $phpcsFile, $startToken, $endToken)
243
- {
244
- // Make sure the $startToken is valid.
245
- if ($startToken >= $endToken) {
246
- return false;
247
- }
248
-
249
- $tokens = $phpcsFile->getTokens();
250
- $classRef = $phpcsFile->findNext(array(\T_SELF, \T_PARENT, \T_STATIC), $startToken, $endToken);
251
-
252
- if ($classRef === false || $tokens[$classRef]['code'] !== \T_STATIC) {
253
- return $classRef;
254
- }
255
-
256
- // T_STATIC, make sure it is used as a class reference.
257
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($classRef + 1), $endToken, true);
258
- if ($next === false || $tokens[$next]['code'] !== \T_DOUBLE_COLON) {
259
- return false;
260
- }
261
-
262
- return $classRef;
263
- }
264
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewExceptionsFromToStringSniff.php DELETED
@@ -1,171 +0,0 @@
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
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * As of PHP 7.4, throwing exceptions from a `__toString()` method is allowed.
19
- *
20
- * PHP version 7.4
21
- *
22
- * @link https://wiki.php.net/rfc/tostring_exceptions
23
- * @link https://www.php.net/manual/en/language.oop5.magic.php#object.tostring
24
- *
25
- * @since 9.2.0
26
- */
27
- class NewExceptionsFromToStringSniff extends Sniff
28
- {
29
-
30
- /**
31
- * Valid scopes for the __toString() method to live in.
32
- *
33
- * @since 9.2.0
34
- * @since 9.3.0 Visibility changed from `public` to `protected`.
35
- *
36
- * @var array
37
- */
38
- protected $ooScopeTokens = array(
39
- 'T_CLASS' => true,
40
- 'T_TRAIT' => true,
41
- 'T_ANON_CLASS' => true,
42
- );
43
-
44
- /**
45
- * Tokens which should be ignored when they preface a function declaration
46
- * when trying to find the docblock (if any).
47
- *
48
- * Array will be added to in the register() method.
49
- *
50
- * @since 9.3.0
51
- *
52
- * @var array
53
- */
54
- private $docblockIgnoreTokens = array(
55
- \T_WHITESPACE => \T_WHITESPACE,
56
- );
57
-
58
- /**
59
- * Returns an array of tokens this test wants to listen for.
60
- *
61
- * @since 9.2.0
62
- *
63
- * @return array
64
- */
65
- public function register()
66
- {
67
- // Enhance the array of tokens to ignore for finding the docblock.
68
- $this->docblockIgnoreTokens += Tokens::$methodPrefixes;
69
- if (isset(Tokens::$phpcsCommentTokens)) {
70
- $this->docblockIgnoreTokens += Tokens::$phpcsCommentTokens;
71
- }
72
-
73
- return array(\T_FUNCTION);
74
- }
75
-
76
- /**
77
- * Processes this test, when one of its tokens is encountered.
78
- *
79
- * @since 9.2.0
80
- *
81
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
82
- * @param int $stackPtr The position of the current token
83
- * in the stack passed in $tokens.
84
- *
85
- * @return void
86
- */
87
- public function process(File $phpcsFile, $stackPtr)
88
- {
89
- if ($this->supportsBelow('7.3') === false) {
90
- return;
91
- }
92
-
93
- $tokens = $phpcsFile->getTokens();
94
- if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
95
- // Abstract function, interface function, live coding or parse error.
96
- return;
97
- }
98
-
99
- $functionName = $phpcsFile->getDeclarationName($stackPtr);
100
- if (strtolower($functionName) !== '__tostring') {
101
- // Not the right function.
102
- return;
103
- }
104
-
105
- if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
106
- // Function, not method.
107
- return;
108
- }
109
-
110
- /*
111
- * Examine the content of the function.
112
- */
113
- $error = 'Throwing exceptions from __toString() was not allowed prior to PHP 7.4';
114
- $throwPtr = $tokens[$stackPtr]['scope_opener'];
115
- $errorThrown = false;
116
-
117
- do {
118
- $throwPtr = $phpcsFile->findNext(\T_THROW, ($throwPtr + 1), $tokens[$stackPtr]['scope_closer']);
119
- if ($throwPtr === false) {
120
- break;
121
- }
122
-
123
- $conditions = $tokens[$throwPtr]['conditions'];
124
- $conditions = array_reverse($conditions, true);
125
- $inTryCatch = false;
126
- foreach ($conditions as $ptr => $type) {
127
- if ($type === \T_TRY) {
128
- $inTryCatch = true;
129
- break;
130
- }
131
-
132
- if ($ptr === $stackPtr) {
133
- // Don't check the conditions outside the function scope.
134
- break;
135
- }
136
- }
137
-
138
- if ($inTryCatch === false) {
139
- $phpcsFile->addError($error, $throwPtr, 'Found');
140
- $errorThrown = true;
141
- }
142
- } while (true);
143
-
144
- if ($errorThrown === true) {
145
- // We've already thrown an error for this method, no need to examine the docblock.
146
- return;
147
- }
148
-
149
- /*
150
- * Check whether the function has a docblock and if so, whether it contains a @throws tag.
151
- *
152
- * {@internal This can be partially replaced by the findCommentAboveFunction()
153
- * utility function in due time.}
154
- */
155
- $commentEnd = $phpcsFile->findPrevious($this->docblockIgnoreTokens, ($stackPtr - 1), null, true);
156
- if ($commentEnd === false || $tokens[$commentEnd]['code'] !== \T_DOC_COMMENT_CLOSE_TAG) {
157
- return;
158
- }
159
-
160
- $commentStart = $tokens[$commentEnd]['comment_opener'];
161
- foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
162
- if ($tokens[$tag]['content'] !== '@throws') {
163
- continue;
164
- }
165
-
166
- // Found a throws tag.
167
- $phpcsFile->addError($error, $stackPtr, 'ThrowsTagFoundInDocblock');
168
- break;
169
- }
170
- }
171
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewNullableTypesSniff.php DELETED
@@ -1,169 +0,0 @@
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
- use PHP_CodeSniffer_Tokens as Tokens;
17
-
18
- /**
19
- * Nullable parameter type declarations and return types are available since PHP 7.1.
20
- *
21
- * PHP version 7.1
22
- *
23
- * @link https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.nullable-types
24
- * @link https://wiki.php.net/rfc/nullable_types
25
- * @link https://www.php.net/manual/en/functions.arguments.php#example-146
26
- *
27
- * @since 7.0.7
28
- */
29
- class NewNullableTypesSniff extends Sniff
30
- {
31
- /**
32
- * Returns an array of tokens this test wants to listen for.
33
- *
34
- * {@internal Not sniffing for T_NULLABLE which was introduced in PHPCS 2.7.2
35
- * as in that case we can't distinguish between parameter type hints and
36
- * return type hints for the error message.}
37
- *
38
- * @since 7.0.7
39
- *
40
- * @return array
41
- */
42
- public function register()
43
- {
44
- $tokens = array(
45
- \T_FUNCTION,
46
- \T_CLOSURE,
47
- );
48
-
49
- if (\defined('T_RETURN_TYPE')) {
50
- $tokens[] = \T_RETURN_TYPE;
51
- }
52
-
53
- return $tokens;
54
- }
55
-
56
-
57
- /**
58
- * Processes this test, when one of its tokens is encountered.
59
- *
60
- * @since 7.0.7
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->supportsBelow('7.0') === false) {
71
- return;
72
- }
73
-
74
- $tokens = $phpcsFile->getTokens();
75
- $tokenCode = $tokens[$stackPtr]['code'];
76
-
77
- if ($tokenCode === \T_FUNCTION || $tokenCode === \T_CLOSURE) {
78
- $this->processFunctionDeclaration($phpcsFile, $stackPtr);
79
-
80
- // Deal with older PHPCS version which don't recognize return type hints
81
- // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
82
- $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
83
- if ($returnTypeHint !== false) {
84
- $this->processReturnType($phpcsFile, $returnTypeHint);
85
- }
86
- } else {
87
- $this->processReturnType($phpcsFile, $stackPtr);
88
- }
89
- }
90
-
91
-
92
- /**
93
- * Process this test for function tokens.
94
- *
95
- * @since 7.0.7
96
- *
97
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
98
- * @param int $stackPtr The position of the current token
99
- * in the stack passed in $tokens.
100
- *
101
- * @return void
102
- */
103
- protected function processFunctionDeclaration(File $phpcsFile, $stackPtr)
104
- {
105
- $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
106
-
107
- if (empty($params) === false && \is_array($params)) {
108
- foreach ($params as $param) {
109
- if ($param['nullable_type'] === true) {
110
- $phpcsFile->addError(
111
- 'Nullable type declarations are not supported in PHP 7.0 or earlier. Found: %s',
112
- $param['token'],
113
- 'typeDeclarationFound',
114
- array($param['type_hint'])
115
- );
116
- }
117
- }
118
- }
119
- }
120
-
121
-
122
- /**
123
- * Process this test for return type tokens.
124
- *
125
- * @since 7.0.7
126
- *
127
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
128
- * @param int $stackPtr The position of the current token
129
- * in the stack passed in $tokens.
130
- *
131
- * @return void
132
- */
133
- protected function processReturnType(File $phpcsFile, $stackPtr)
134
- {
135
- $tokens = $phpcsFile->getTokens();
136
-
137
- if (isset($tokens[($stackPtr - 1)]['code']) === false) {
138
- return;
139
- }
140
-
141
- $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
142
-
143
- // Deal with namespaced class names.
144
- if ($tokens[$previous]['code'] === \T_NS_SEPARATOR) {
145
- $validTokens = Tokens::$emptyTokens;
146
- $validTokens[\T_STRING] = true;
147
- $validTokens[\T_NS_SEPARATOR] = true;
148
-
149
- $stackPtr--;
150
-
151
- while (isset($validTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
152
- $stackPtr--;
153
- }
154
-
155
- $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
156
- }
157
-
158
- // T_NULLABLE token was introduced in PHPCS 2.7.2. Before that it identified as T_INLINE_THEN.
159
- if ((\defined('T_NULLABLE') === true && $tokens[$previous]['type'] === 'T_NULLABLE')
160
- || (\defined('T_NULLABLE') === false && $tokens[$previous]['code'] === \T_INLINE_THEN)
161
- ) {
162
- $phpcsFile->addError(
163
- 'Nullable return types are not supported in PHP 7.0 or earlier.',
164
- $stackPtr,
165
- 'returnTypeFound'
166
- );
167
- }
168
- }
169
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewParamTypeDeclarationsSniff.php DELETED
@@ -1,237 +0,0 @@
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\AbstractNewFeatureSniff;
14
- use PHPCompatibility\PHPCSHelper;
15
- use PHP_CodeSniffer_File as File;
16
-
17
- /**
18
- * Detect and verify the use of parameter type declarations in function declarations.
19
- *
20
- * Parameter type declarations - class/interface names only - is available since PHP 5.0.
21
- * - Since PHP 5.1, the `array` keyword can be used.
22
- * - Since PHP 5.2, `self` and `parent` can be used. Previously, those were interpreted as
23
- * class names.
24
- * - Since PHP 5.4, the `callable` keyword.
25
- * - Since PHP 7.0, scalar type declarations are available.
26
- * - Since PHP 7.1, the `iterable` pseudo-type is available.
27
- * - Since PHP 7.2, the generic `object` type is available.
28
- *
29
- * Additionally, this sniff does a cursory check for typical invalid type declarations,
30
- * such as:
31
- * - `boolean` (should be `bool`), `integer` (should be `int`) and `static`.
32
- * - `self`/`parent` as type declaration used outside class context throws a fatal error since PHP 7.0.
33
- *
34
- * PHP version 5.0+
35
- *
36
- * @link https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
37
- * @link https://wiki.php.net/rfc/callable
38
- * @link https://wiki.php.net/rfc/scalar_type_hints_v5
39
- * @link https://wiki.php.net/rfc/iterable
40
- * @link https://wiki.php.net/rfc/object-typehint
41
- *
42
- * @since 7.0.0
43
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class.
44
- * @since 9.0.0 Renamed from `NewScalarTypeDeclarationsSniff` to `NewParamTypeDeclarationsSniff`.
45
- */
46
- class NewParamTypeDeclarationsSniff extends AbstractNewFeatureSniff
47
- {
48
-
49
- /**
50
- * A list of new types.
51
- *
52
- * The array lists : version number with false (not present) or true (present).
53
- * If's sufficient to list the first version where the keyword appears.
54
- *
55
- * @since 7.0.0
56
- * @since 7.0.3 Now lists all param type declarations, not just the PHP 7+ scalar ones.
57
- *
58
- * @var array(string => array(string => bool))
59
- */
60
- protected $newTypes = array(
61
- 'array' => array(
62
- '5.0' => false,
63
- '5.1' => true,
64
- ),
65
- 'self' => array(
66
- '5.1' => false,
67
- '5.2' => true,
68
- ),
69
- 'parent' => array(
70
- '5.1' => false,
71
- '5.2' => true,
72
- ),
73
- 'callable' => array(
74
- '5.3' => false,
75
- '5.4' => true,
76
- ),
77
- 'int' => array(
78
- '5.6' => false,
79
- '7.0' => true,
80
- ),
81
- 'float' => array(
82
- '5.6' => false,
83
- '7.0' => true,
84
- ),
85
- 'bool' => array(
86
- '5.6' => false,
87
- '7.0' => true,
88
- ),
89
- 'string' => array(
90
- '5.6' => false,
91
- '7.0' => true,
92
- ),
93
- 'iterable' => array(
94
- '7.0' => false,
95
- '7.1' => true,
96
- ),
97
- 'object' => array(
98
- '7.1' => false,
99
- '7.2' => true,
100
- ),
101
- );
102
-
103
-
104
- /**
105
- * Invalid types
106
- *
107
- * The array lists : the invalid type hint => what was probably intended/alternative.
108
- *
109
- * @since 7.0.3
110
- *
111
- * @var array(string => string)
112
- */
113
- protected $invalidTypes = array(
114
- 'static' => 'self',
115
- 'boolean' => 'bool',
116
- 'integer' => 'int',
117
- );
118
-
119
-
120
- /**
121
- * Returns an array of tokens this test wants to listen for.
122
- *
123
- * @since 7.0.0
124
- * @since 7.1.3 Now also checks closures.
125
- *
126
- * @return array
127
- */
128
- public function register()
129
- {
130
- return array(
131
- \T_FUNCTION,
132
- \T_CLOSURE,
133
- );
134
- }
135
-
136
-
137
- /**
138
- * Processes this test, when one of its tokens is encountered.
139
- *
140
- * @since 7.0.0
141
- * @since 7.0.3 - Added check for non-scalar type declarations.
142
- * - Added check for invalid type declarations.
143
- * - Added check for usage of `self` type declaration outside
144
- * class scope.
145
- * @since 8.2.0 Added check for `parent` type declaration outside class scope.
146
- *
147
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
148
- * @param int $stackPtr The position of the current token in
149
- * the stack passed in $tokens.
150
- *
151
- * @return void
152
- */
153
- public function process(File $phpcsFile, $stackPtr)
154
- {
155
- // Get all parameters from method signature.
156
- $paramNames = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
157
- if (empty($paramNames)) {
158
- return;
159
- }
160
-
161
- $supportsPHP4 = $this->supportsBelow('4.4');
162
-
163
- foreach ($paramNames as $param) {
164
- if ($param['type_hint'] === '') {
165
- continue;
166
- }
167
-
168
- // Strip off potential nullable indication.
169
- $typeHint = ltrim($param['type_hint'], '?');
170
-
171
- if ($supportsPHP4 === true) {
172
- $phpcsFile->addError(
173
- 'Type declarations were not present in PHP 4.4 or earlier.',
174
- $param['token'],
175
- 'TypeHintFound'
176
- );
177
-
178
- } elseif (isset($this->newTypes[$typeHint])) {
179
- $itemInfo = array(
180
- 'name' => $typeHint,
181
- );
182
- $this->handleFeature($phpcsFile, $param['token'], $itemInfo);
183
-
184
- // As of PHP 7.0, using `self` or `parent` outside class scope throws a fatal error.
185
- // Only throw this error for PHP 5.2+ as before that the "type hint not supported" error
186
- // will be thrown.
187
- if (($typeHint === 'self' || $typeHint === 'parent')
188
- && $this->inClassScope($phpcsFile, $stackPtr, false) === false
189
- && $this->supportsAbove('5.2') !== false
190
- ) {
191
- $phpcsFile->addError(
192
- "'%s' type cannot be used outside of class scope",
193
- $param['token'],
194
- ucfirst($typeHint) . 'OutsideClassScopeFound',
195
- array($typeHint)
196
- );
197
- }
198
- } elseif (isset($this->invalidTypes[$typeHint])) {
199
- $error = "'%s' is not a valid type declaration. Did you mean %s ?";
200
- $data = array(
201
- $typeHint,
202
- $this->invalidTypes[$typeHint],
203
- );
204
-
205
- $phpcsFile->addError($error, $param['token'], 'InvalidTypeHintFound', $data);
206
- }
207
- }
208
- }
209
-
210
-
211
- /**
212
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
213
- *
214
- * @since 7.1.0
215
- *
216
- * @param array $itemInfo Base information about the item.
217
- *
218
- * @return array Version and other information about the item.
219
- */
220
- public function getItemArray(array $itemInfo)
221
- {
222
- return $this->newTypes[$itemInfo['name']];
223
- }
224
-
225
-
226
- /**
227
- * Get the error message template for this sniff.
228
- *
229
- * @since 7.1.0
230
- *
231
- * @return string
232
- */
233
- protected function getErrorMsgTemplate()
234
- {
235
- return "'%s' type declaration is not present in PHP version %s or earlier";
236
- }
237
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NewReturnTypeDeclarationsSniff.php DELETED
@@ -1,194 +0,0 @@
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\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect and verify the use of return type declarations in function declarations.
18
- *
19
- * Return type declarations are available since PHP 7.0.
20
- * - Since PHP 7.1, the `iterable` and `void` pseudo-types are available.
21
- * - Since PHP 7.2, the generic `object` type is available.
22
- *
23
- * PHP version 7.0+
24
- *
25
- * @link https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.return-type-declarations
26
- * @link https://www.php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration
27
- * @link https://wiki.php.net/rfc/return_types
28
- * @link https://wiki.php.net/rfc/iterable
29
- * @link https://wiki.php.net/rfc/void_return_type
30
- * @link https://wiki.php.net/rfc/object-typehint
31
- *
32
- * @since 7.0.0
33
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class.
34
- * @since 7.1.2 Renamed from `NewScalarReturnTypeDeclarationsSniff` to `NewReturnTypeDeclarationsSniff`.
35
- */
36
- class NewReturnTypeDeclarationsSniff extends AbstractNewFeatureSniff
37
- {
38
-
39
- /**
40
- * A list of new types
41
- *
42
- * The array lists : version number with false (not present) or true (present).
43
- * If's sufficient to list the first version where the keyword appears.
44
- *
45
- * @since 7.0.0
46
- *
47
- * @var array(string => array(string => bool))
48
- */
49
- protected $newTypes = array(
50
- 'int' => array(
51
- '5.6' => false,
52
- '7.0' => true,
53
- ),
54
- 'float' => array(
55
- '5.6' => false,
56
- '7.0' => true,
57
- ),
58
- 'bool' => array(
59
- '5.6' => false,
60
- '7.0' => true,
61
- ),
62
- 'string' => array(
63
- '5.6' => false,
64
- '7.0' => true,
65
- ),
66
- 'array' => array(
67
- '5.6' => false,
68
- '7.0' => true,
69
- ),
70
- 'callable' => array(
71
- '5.6' => false,
72
- '7.0' => true,
73
- ),
74
- 'parent' => array(
75
- '5.6' => false,
76
- '7.0' => true,
77
- ),
78
- 'self' => array(
79
- '5.6' => false,
80
- '7.0' => true,
81
- ),
82
- 'Class name' => array(
83
- '5.6' => false,
84
- '7.0' => true,
85
- ),
86
-
87
- 'iterable' => array(
88
- '7.0' => false,
89
- '7.1' => true,
90
- ),
91
- 'void' => array(
92
- '7.0' => false,
93
- '7.1' => true,
94
- ),
95
-
96
- 'object' => array(
97
- '7.1' => false,
98
- '7.2' => true,
99
- ),
100
- );
101
-
102
-
103
- /**
104
- * Returns an array of tokens this test wants to listen for.
105
- *
106
- * @since 7.0.0
107
- * @since 7.1.2 Now also checks based on the function and closure keywords.
108
- *
109
- * @return array
110
- */
111
- public function register()
112
- {
113
- $tokens = array(
114
- \T_FUNCTION,
115
- \T_CLOSURE,
116
- );
117
-
118
- if (\defined('T_RETURN_TYPE')) {
119
- $tokens[] = \T_RETURN_TYPE;
120
- }
121
-
122
- return $tokens;
123
- }
124
-
125
-
126
- /**
127
- * Processes this test, when one of its tokens is encountered.
128
- *
129
- * @since 7.0.0
130
- *
131
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
132
- * @param int $stackPtr The position of the current token in
133
- * the stack passed in $tokens.
134
- *
135
- * @return void
136
- */
137
- public function process(File $phpcsFile, $stackPtr)
138
- {
139
- $tokens = $phpcsFile->getTokens();
140
-
141
- // Deal with older PHPCS version which don't recognize return type hints
142
- // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
143
- if ($tokens[$stackPtr]['code'] === \T_FUNCTION || $tokens[$stackPtr]['code'] === \T_CLOSURE) {
144
- $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
145
- if ($returnTypeHint !== false) {
146
- $stackPtr = $returnTypeHint;
147
- }
148
- }
149
-
150
- if (isset($this->newTypes[$tokens[$stackPtr]['content']]) === true) {
151
- $itemInfo = array(
152
- 'name' => $tokens[$stackPtr]['content'],
153
- );
154
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
155
- }
156
- // Handle class name based return types.
157
- elseif ($tokens[$stackPtr]['code'] === \T_STRING
158
- || (\defined('T_RETURN_TYPE') && $tokens[$stackPtr]['code'] === \T_RETURN_TYPE)
159
- ) {
160
- $itemInfo = array(
161
- 'name' => 'Class name',
162
- );
163
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
164
- }
165
- }
166
-
167
-
168
- /**
169
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
170
- *
171
- * @since 7.1.0
172
- *
173
- * @param array $itemInfo Base information about the item.
174
- *
175
- * @return array Version and other information about the item.
176
- */
177
- public function getItemArray(array $itemInfo)
178
- {
179
- return $this->newTypes[$itemInfo['name']];
180
- }
181
-
182
-
183
- /**
184
- * Get the error message template for this sniff.
185
- *
186
- * @since 7.1.0
187
- *
188
- * @return string
189
- */
190
- protected function getErrorMsgTemplate()
191
- {
192
- return '%s return type is not present in PHP version %s or earlier';
193
- }
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/NonStaticMagicMethodsSniff.php DELETED
@@ -1,216 +0,0 @@
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
- * Verifies the use of the correct visibility and static properties of magic methods.
18
- *
19
- * The requirements have always existed, but as of PHP 5.3, a warning will be thrown
20
- * when magic methods have the wrong modifiers.
21
- *
22
- * PHP version 5.3
23
- *
24
- * @link https://www.php.net/manual/en/language.oop5.magic.php
25
- *
26
- * @since 5.5
27
- * @since 5.6 Now extends the base `Sniff` class.
28
- */
29
- class NonStaticMagicMethodsSniff extends Sniff
30
- {
31
-
32
- /**
33
- * A list of PHP magic methods and their visibility and static requirements.
34
- *
35
- * Method names in the array should be all *lowercase*.
36
- * Visibility can be either 'public', 'protected' or 'private'.
37
- * Static can be either 'true' - *must* be static, or 'false' - *must* be non-static.
38
- * When a method does not have a specific requirement for either visibility or static,
39
- * do *not* add the key.
40
- *
41
- * @since 5.5
42
- * @since 5.6 The array format has changed to allow the sniff to also verify the
43
- * use of the correct visibility for a magic method.
44
- *
45
- * @var array(string)
46
- */
47
- protected $magicMethods = array(
48
- '__construct' => array(
49
- 'static' => false,
50
- ),
51
- '__destruct' => array(
52
- 'visibility' => 'public',
53
- 'static' => false,
54
- ),
55
- '__clone' => array(
56
- 'static' => false,
57
- ),
58
- '__get' => array(
59
- 'visibility' => 'public',
60
- 'static' => false,
61
- ),
62
- '__set' => array(
63
- 'visibility' => 'public',
64
- 'static' => false,
65
- ),
66
- '__isset' => array(
67
- 'visibility' => 'public',
68
- 'static' => false,
69
- ),
70
- '__unset' => array(
71
- 'visibility' => 'public',
72
- 'static' => false,
73
- ),
74
- '__call' => array(
75
- 'visibility' => 'public',
76
- 'static' => false,
77
- ),
78
- '__callstatic' => array(
79
- 'visibility' => 'public',
80
- 'static' => true,
81
- ),
82
- '__sleep' => array(
83
- 'visibility' => 'public',
84
- ),
85
- '__tostring' => array(
86
- 'visibility' => 'public',
87
- ),
88
- '__set_state' => array(
89
- 'visibility' => 'public',
90
- 'static' => true,
91
- ),
92
- '__debuginfo' => array(
93
- 'visibility' => 'public',
94
- 'static' => false,
95
- ),
96
- '__invoke' => array(
97
- 'visibility' => 'public',
98
- 'static' => false,
99
- ),
100
- '__serialize' => array(
101
- 'visibility' => 'public',
102
- 'static' => false,
103
- ),
104
- '__unserialize' => array(
105
- 'visibility' => 'public',
106
- 'static' => false,
107
- ),
108
- );
109
-
110
-
111
- /**
112
- * Returns an array of tokens this test wants to listen for.
113
- *
114
- * @since 5.5
115
- * @since 5.6 Now also checks traits.
116
- * @since 7.1.4 Now also checks anonymous classes.
117
- *
118
- * @return array
119
- */
120
- public function register()
121
- {
122
- $targets = array(
123
- \T_CLASS,
124
- \T_INTERFACE,
125
- \T_TRAIT,
126
- );
127
-
128
- if (\defined('T_ANON_CLASS')) {
129
- $targets[] = \T_ANON_CLASS;
130
- }
131
-
132
- return $targets;
133
- }
134
-
135
-
136
- /**
137
- * Processes this test, when one of its tokens is encountered.
138
- *
139
- * @since 5.5
140
- *
141
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
142
- * @param int $stackPtr The position of the current token in the
143
- * stack passed in $tokens.
144
- *
145
- * @return void
146
- */
147
- public function process(File $phpcsFile, $stackPtr)
148
- {
149
- // Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
150
- if ($this->supportsAbove('5.3') === false) {
151
- return;
152
- }
153
-
154
- $tokens = $phpcsFile->getTokens();
155
-
156
- if (isset($tokens[$stackPtr]['scope_closer']) === false) {
157
- return;
158
- }
159
-
160
- $classScopeCloser = $tokens[$stackPtr]['scope_closer'];
161
- $functionPtr = $stackPtr;
162
-
163
- // Find all the functions in this class or interface.
164
- while (($functionToken = $phpcsFile->findNext(\T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) {
165
- /*
166
- * Get the scope closer for this function in order to know how
167
- * to advance to the next function.
168
- * If no body of function (e.g. for interfaces), there is
169
- * no closing curly brace; advance the pointer differently.
170
- */
171
- if (isset($tokens[$functionToken]['scope_closer'])) {
172
- $scopeCloser = $tokens[$functionToken]['scope_closer'];
173
- } else {
174
- $scopeCloser = ($functionToken + 1);
175
- }
176
-
177
- $methodName = $phpcsFile->getDeclarationName($functionToken);
178
- $methodNameLc = strtolower($methodName);
179
- if (isset($this->magicMethods[$methodNameLc]) === false) {
180
- $functionPtr = $scopeCloser;
181
- continue;
182
- }
183
-
184
- $methodProperties = $phpcsFile->getMethodProperties($functionToken);
185
- $errorCodeBase = $this->stringToErrorCode($methodNameLc);
186
-
187
- if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
188
- $error = 'Visibility for magic method %s must be %s. Found: %s';
189
- $errorCode = $errorCodeBase . 'MethodVisibility';
190
- $data = array(
191
- $methodName,
192
- $this->magicMethods[$methodNameLc]['visibility'],
193
- $methodProperties['scope'],
194
- );
195
-
196
- $phpcsFile->addError($error, $functionToken, $errorCode, $data);
197
- }
198
-
199
- if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
200
- $error = 'Magic method %s cannot be defined as static.';
201
- $errorCode = $errorCodeBase . 'MethodStatic';
202
- $data = array($methodName);
203
-
204
- if ($this->magicMethods[$methodNameLc]['static'] === true) {
205
- $error = 'Magic method %s must be defined as static.';
206
- $errorCode = $errorCodeBase . 'MethodNonStatic';
207
- }
208
-
209
- $phpcsFile->addError($error, $functionToken, $errorCode, $data);
210
- }
211
-
212
- // Advance to next function.
213
- $functionPtr = $scopeCloser;
214
- }
215
- }
216
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/NewMagicMethodsSniff.php DELETED
@@ -1,231 +0,0 @@
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\FunctionNameRestrictions;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Warns for non-magic behaviour of magic methods prior to becoming magic.
18
- *
19
- * PHP version 5.0+
20
- *
21
- * @link https://www.php.net/manual/en/language.oop5.magic.php
22
- * @link https://wiki.php.net/rfc/closures#additional_goodyinvoke
23
- * @link https://wiki.php.net/rfc/debug-info
24
- *
25
- * @since 7.0.4
26
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class.
27
- */
28
- class NewMagicMethodsSniff extends AbstractNewFeatureSniff
29
- {
30
-
31
- /**
32
- * A list of new magic methods, not considered magic in older versions.
33
- *
34
- * Method names in the array should be all *lowercase*.
35
- * The array lists : version number with false (not magic) or true (magic).
36
- * If's sufficient to list the first version where the method became magic.
37
- *
38
- * @since 7.0.4
39
- *
40
- * @var array(string => array(string => bool|string))
41
- */
42
- protected $newMagicMethods = array(
43
- '__construct' => array(
44
- '4.4' => false,
45
- '5.0' => true,
46
- ),
47
- '__destruct' => array(
48
- '4.4' => false,
49
- '5.0' => true,
50
- ),
51
- '__get' => array(
52
- '4.4' => false,
53
- '5.0' => true,
54
- ),
55
-
56
- '__isset' => array(
57
- '5.0' => false,
58
- '5.1' => true,
59
- ),
60
- '__unset' => array(
61
- '5.0' => false,
62
- '5.1' => true,
63
- ),
64
- '__set_state' => array(
65
- '5.0' => false,
66
- '5.1' => true,
67
- ),
68
-
69
- '__callstatic' => array(
70
- '5.2' => false,
71
- '5.3' => true,
72
- ),
73
- '__invoke' => array(
74
- '5.2' => false,
75
- '5.3' => true,
76
- ),
77
-
78
- '__debuginfo' => array(
79
- '5.5' => false,
80
- '5.6' => true,
81
- ),
82
-
83
- // Special case - only became properly magical in 5.2.0,
84
- // before that it was only called for echo and print.
85
- '__tostring' => array(
86
- '5.1' => false,
87
- '5.2' => true,
88
- 'message' => 'The method %s() was not truly magical in PHP version %s and earlier. The associated magic functionality will only be called when directly combined with echo or print.',
89
- ),
90
-
91
- '__serialize' => array(
92
- '7.3' => false,
93
- '7.4' => true,
94
- ),
95
- '__unserialize' => array(
96
- '7.3' => false,
97
- '7.4' => true,
98
- ),
99
- );
100
-
101
-
102
- /**
103
- * Returns an array of tokens this test wants to listen for.
104
- *
105
- * @since 7.0.4
106
- *
107
- * @return array
108
- */
109
- public function register()
110
- {
111
- return array(\T_FUNCTION);
112
- }
113
-
114
-
115
- /**
116
- * Processes this test, when one of its tokens is encountered.
117
- *
118
- * @since 7.0.4
119
- *
120
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
121
- * @param int $stackPtr The position of the current token in the
122
- * stack passed in $tokens.
123
- *
124
- * @return void
125
- */
126
- public function process(File $phpcsFile, $stackPtr)
127
- {
128
- $functionName = $phpcsFile->getDeclarationName($stackPtr);
129
- $functionNameLc = strtolower($functionName);
130
-
131
- if (isset($this->newMagicMethods[$functionNameLc]) === false) {
132
- return;
133
- }
134
-
135
- if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
136
- return;
137
- }
138
-
139
- $itemInfo = array(
140
- 'name' => $functionName,
141
- 'nameLc' => $functionNameLc,
142
- );
143
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
144
- }
145
-
146
-
147
- /**
148
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
149
- *
150
- * @since 7.1.0
151
- *
152
- * @param array $itemInfo Base information about the item.
153
- *
154
- * @return array Version and other information about the item.
155
- */
156
- public function getItemArray(array $itemInfo)
157
- {
158
- return $this->newMagicMethods[$itemInfo['nameLc']];
159
- }
160
-
161
-
162
- /**
163
- * Get an array of the non-PHP-version array keys used in a sub-array.
164
- *
165
- * @since 7.1.0
166
- *
167
- * @return array
168
- */
169
- protected function getNonVersionArrayKeys()
170
- {
171
- return array('message');
172
- }
173
-
174
-
175
- /**
176
- * Retrieve the relevant detail (version) information for use in an error message.
177
- *
178
- * @since 7.1.0
179
- *
180
- * @param array $itemArray Version and other information about the item.
181
- * @param array $itemInfo Base information about the item.
182
- *
183
- * @return array
184
- */
185
- public function getErrorInfo(array $itemArray, array $itemInfo)
186
- {
187
- $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
188
- $errorInfo['error'] = false; // Warning, not error.
189
- $errorInfo['message'] = '';
190
-
191
- if (empty($itemArray['message']) === false) {
192
- $errorInfo['message'] = $itemArray['message'];
193
- }
194
-
195
- return $errorInfo;
196
- }
197
-
198
-
199
- /**
200
- * Get the error message template for this sniff.
201
- *
202
- * @since 7.1.0
203
- *
204
- * @return string
205
- */
206
- protected function getErrorMsgTemplate()
207
- {
208
- return 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
209
- }
210
-
211
-
212
- /**
213
- * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
214
- *
215
- * @since 7.1.0
216
- *
217
- * @param string $error The error message which was created.
218
- * @param array $itemInfo Base information about the item this error message applies to.
219
- * @param array $errorInfo Detail information about an item this error message applies to.
220
- *
221
- * @return string
222
- */
223
- protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
224
- {
225
- if ($errorInfo['message'] !== '') {
226
- $error = $errorInfo['message'];
227
- }
228
-
229
- return $error;
230
- }
231
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedMagicAutoloadSniff.php DELETED
@@ -1,92 +0,0 @@
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\FunctionNameRestrictions;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect declaration of the magic `__autoload()` method.
18
- *
19
- * This method has been deprecated in PHP 7.2 in favour of `spl_autoload_register()`.
20
- *
21
- * PHP version 7.2
22
- *
23
- * @link https://www.php.net/manual/en/migration72.deprecated.php#migration72.deprecated.__autoload-method
24
- * @link https://wiki.php.net/rfc/deprecations_php_7_2#autoload
25
- * @link https://www.php.net/manual/en/function.autoload.php
26
- *
27
- * @since 8.1.0
28
- * @since 9.0.0 Renamed from `DeprecatedMagicAutoloadSniff` to `RemovedMagicAutoloadSniff`.
29
- */
30
- class RemovedMagicAutoloadSniff extends Sniff
31
- {
32
- /**
33
- * Scopes to look for when testing using validDirectScope.
34
- *
35
- * @since 8.1.0
36
- *
37
- * @var array
38
- */
39
- private $checkForScopes = array(
40
- 'T_CLASS' => true,
41
- 'T_ANON_CLASS' => true,
42
- 'T_INTERFACE' => true,
43
- 'T_TRAIT' => true,
44
- 'T_NAMESPACE' => true,
45
- );
46
-
47
- /**
48
- * Returns an array of tokens this test wants to listen for.
49
- *
50
- * @since 8.1.0
51
- *
52
- * @return array
53
- */
54
- public function register()
55
- {
56
- return array(\T_FUNCTION);
57
- }
58
-
59
- /**
60
- * Processes this test, when one of its tokens is encountered.
61
- *
62
- * @since 8.1.0
63
- *
64
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
- * @param int $stackPtr The position of the current token in the
66
- * stack passed in $tokens.
67
- *
68
- * @return void
69
- */
70
- public function process(File $phpcsFile, $stackPtr)
71
- {
72
- if ($this->supportsAbove('7.2') === false) {
73
- return;
74
- }
75
-
76
- $funcName = $phpcsFile->getDeclarationName($stackPtr);
77
-
78
- if (strtolower($funcName) !== '__autoload') {
79
- return;
80
- }
81
-
82
- if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) !== false) {
83
- return;
84
- }
85
-
86
- if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
87
- return;
88
- }
89
-
90
- $phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
91
- }
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedNamespacedAssertSniff.php DELETED
@@ -1,101 +0,0 @@
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\FunctionNameRestrictions;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect declaration of a namespaced function called `assert()`.
18
- *
19
- * As of PHP 7.3, a compile-time deprecation warning will be thrown when a function
20
- * called `assert()` is declared. In PHP 8 this will become a compile-error.
21
- *
22
- * Methods are unaffected.
23
- * Global, non-namespaced, `assert()` function declarations were always a fatal
24
- * "function already declared" error, so not the concern of this sniff.
25
- *
26
- * PHP version 7.3
27
- *
28
- * @link https://www.php.net/manual/en/migration73.deprecated.php#migration73.deprecated.core.assert
29
- * @link https://wiki.php.net/rfc/deprecations_php_7_3#defining_a_free-standing_assert_function
30
- * @link https://www.php.net/manual/en/function.assert.php
31
- *
32
- * @since 9.0.0
33
- */
34
- class RemovedNamespacedAssertSniff extends Sniff
35
- {
36
- /**
37
- * Scopes in which an `assert` function can be declared without issue.
38
- *
39
- * @since 9.0.0
40
- *
41
- * @var array
42
- */
43
- private $scopes = array(
44
- \T_CLASS,
45
- \T_INTERFACE,
46
- \T_TRAIT,
47
- \T_CLOSURE,
48
- );
49
-
50
- /**
51
- * Returns an array of tokens this test wants to listen for.
52
- *
53
- * @since 9.0.0
54
- *
55
- * @return array
56
- */
57
- public function register()
58
- {
59
- // Enrich the scopes list.
60
- if (\defined('T_ANON_CLASS')) {
61
- $this->scopes[] = \T_ANON_CLASS;
62
- }
63
-
64
- return array(\T_FUNCTION);
65
- }
66
-
67
- /**
68
- * Processes this test, when one of its tokens is encountered.
69
- *
70
- * @since 9.0.0
71
- *
72
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
73
- * @param int $stackPtr The position of the current token in the
74
- * stack passed in $tokens.
75
- *
76
- * @return void
77
- */
78
- public function process(File $phpcsFile, $stackPtr)
79
- {
80
- if ($this->supportsAbove('7.3') === false) {
81
- return;
82
- }
83
-
84
- $funcName = $phpcsFile->getDeclarationName($stackPtr);
85
-
86
- if (strtolower($funcName) !== 'assert') {
87
- return;
88
- }
89
-
90
- if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) {
91
- return;
92
- }
93
-
94
- if ($this->determineNamespace($phpcsFile, $stackPtr) === '') {
95
- // Not a namespaced function declaration. This may be a parse error, but not our concern.
96
- return;
97
- }
98
-
99
- $phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found');
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/RemovedPHP4StyleConstructorsSniff.php DELETED
@@ -1,158 +0,0 @@
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\FunctionNameRestrictions;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect declarations of PHP 4 style constructors which are deprecated as of PHP 7.0.0.
19
- *
20
- * PHP 4 style constructors - methods that have the same name as the class they are defined in -
21
- * are deprecated as of PHP 7.0.0, and will be removed in the future.
22
- * PHP 7 will emit `E_DEPRECATED` if a PHP 4 constructor is the only constructor defined
23
- * within a class. Classes that implement a `__construct()` method are unaffected.
24
- *
25
- * Note: Methods with the same name as the class they are defined in _within a namespace_
26
- * are not recognized as constructors anyway and therefore outside the scope of this sniff.
27
- *
28
- * PHP version 7.0
29
- *
30
- * @link https://www.php.net/manual/en/migration70.deprecated.php#migration70.deprecated.php4-constructors
31
- * @link https://wiki.php.net/rfc/remove_php4_constructors
32
- * @link https://www.php.net/manual/en/language.oop5.decon.php
33
- *
34
- * @since 7.0.0
35
- * @since 7.0.8 This sniff now throws a warning instead of an error as the functionality is
36
- * only deprecated (for now).
37
- * @since 9.0.0 Renamed from `DeprecatedPHP4StyleConstructorsSniff` to `RemovedPHP4StyleConstructorsSniff`.
38
- */
39
- class RemovedPHP4StyleConstructorsSniff extends Sniff
40
- {
41
-
42
- /**
43
- * Returns an array of tokens this test wants to listen for.
44
- *
45
- * @since 7.0.0
46
- *
47
- * @return array
48
- */
49
- public function register()
50
- {
51
- return array(
52
- \T_CLASS,
53
- );
54
- }
55
-
56
- /**
57
- * Processes this test, when one of its tokens is encountered.
58
- *
59
- * @since 7.0.0
60
- * @since 7.0.8 The message is downgraded from error to warning as - for now - support
61
- * for PHP4-style constructors is just deprecated, not yet removed.
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.0') === false) {
72
- return;
73
- }
74
-
75
- if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
76
- /*
77
- * Namespaced methods with the same name as the class are treated as
78
- * regular methods, so we can bow out if we're in a namespace.
79
- *
80
- * Note: the exception to this is PHP 5.3.0-5.3.2. This is currently
81
- * not dealt with.
82
- */
83
- return;
84
- }
85
-
86
- $tokens = $phpcsFile->getTokens();
87
-
88
- $class = $tokens[$stackPtr];
89
-
90
- if (isset($class['scope_closer']) === false) {
91
- return;
92
- }
93
-
94
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
95
- if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
96
- // Anonymous class in combination with PHPCS 2.3.x.
97
- return;
98
- }
99
-
100
- $scopeCloser = $class['scope_closer'];
101
- $className = $tokens[$nextNonEmpty]['content'];
102
-
103
- if (empty($className) || \is_string($className) === false) {
104
- return;
105
- }
106
-
107
- $nextFunc = $stackPtr;
108
- $classNameLc = strtolower($className);
109
- $newConstructorFound = false;
110
- $oldConstructorFound = false;
111
- $oldConstructorPos = -1;
112
- while (($nextFunc = $phpcsFile->findNext(array(\T_FUNCTION, \T_DOC_COMMENT_OPEN_TAG), ($nextFunc + 1), $scopeCloser)) !== false) {
113
- // Skip over docblocks.
114
- if ($tokens[$nextFunc]['code'] === \T_DOC_COMMENT_OPEN_TAG) {
115
- $nextFunc = $tokens[$nextFunc]['comment_closer'];
116
- continue;
117
- }
118
-
119
- $functionScopeCloser = $nextFunc;
120
- if (isset($tokens[$nextFunc]['scope_closer'])) {
121
- // Normal (non-interface, non-abstract) method.
122
- $functionScopeCloser = $tokens[$nextFunc]['scope_closer'];
123
- }
124
-
125
- $funcName = $phpcsFile->getDeclarationName($nextFunc);
126
- if (empty($funcName) || \is_string($funcName) === false) {
127
- $nextFunc = $functionScopeCloser;
128
- continue;
129
- }
130
-
131
- $funcNameLc = strtolower($funcName);
132
-
133
- if ($funcNameLc === '__construct') {
134
- $newConstructorFound = true;
135
- }
136
-
137
- if ($funcNameLc === $classNameLc) {
138
- $oldConstructorFound = true;
139
- $oldConstructorPos = $nextFunc;
140
- }
141
-
142
- // If both have been found, no need to continue looping through the functions.
143
- if ($newConstructorFound === true && $oldConstructorFound === true) {
144
- break;
145
- }
146
-
147
- $nextFunc = $functionScopeCloser;
148
- }
149
-
150
- if ($newConstructorFound === false && $oldConstructorFound === true) {
151
- $phpcsFile->addWarning(
152
- 'Use of deprecated PHP4 style class constructor is not supported since PHP 7.',
153
- $oldConstructorPos,
154
- 'Found'
155
- );
156
- }
157
- }
158
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionNameRestrictions/ReservedFunctionNamesSniff.php DELETED
@@ -1,205 +0,0 @@
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\FunctionNameRestrictions;
12
-
13
- use Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff as PHPCS_CamelCapsFunctionNameSniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Standards_AbstractScopeSniff as PHPCS_AbstractScopeSniff;
16
- use PHP_CodeSniffer_Tokens as Tokens;
17
-
18
- /**
19
- * All function and method names starting with double underscore are reserved by PHP.
20
- *
21
- * PHP version All
22
- *
23
- * {@internal Extends an upstream sniff to benefit from the properties contained therein.
24
- * The properties are lists of valid PHP magic function and method names, which
25
- * should be ignored for the purposes of this sniff.
26
- * As this sniff is not PHP version specific, we don't need access to the utility
27
- * methods in the PHPCompatibility\Sniff, so extending the upstream sniff is fine.
28
- * As the upstream sniff checks the same (and more, but we don't need the rest),
29
- * the logic in this sniff is largely the same as used upstream.
30
- * Extending the upstream sniff instead of including it via the ruleset, however,
31
- * prevents hard to debug issues of errors not being reported from the upstream sniff
32
- * if this library is used in combination with other rulesets.}
33
- *
34
- * @link https://www.php.net/manual/en/language.oop5.magic.php
35
- *
36
- * @since 8.2.0 This was previously, since 7.0.3, checked by the upstream sniff.
37
- * @since 9.3.2 The sniff will now ignore functions marked as `@deprecated` by design.
38
- */
39
- class ReservedFunctionNamesSniff extends PHPCS_CamelCapsFunctionNameSniff
40
- {
41
-
42
- /**
43
- * Overload the constructor to work round various PHPCS cross-version compatibility issues.
44
- *
45
- * @since 8.2.0
46
- */
47
- public function __construct()
48
- {
49
- $scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT);
50
- if (\defined('T_ANON_CLASS')) {
51
- $scopeTokens[] = \T_ANON_CLASS;
52
- }
53
-
54
- // Call the grand-parent constructor directly.
55
- PHPCS_AbstractScopeSniff::__construct($scopeTokens, array(\T_FUNCTION), true);
56
-
57
- // Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1.
58
- $this->magicMethods['debuginfo'] = true;
59
- }
60
-
61
-
62
- /**
63
- * Processes the tokens within the scope.
64
- *
65
- * @since 8.2.0
66
- *
67
- * @param \PHP_CodeSniffer_File $phpcsFile The file being processed.
68
- * @param int $stackPtr The position where this token was
69
- * found.
70
- * @param int $currScope The position of the current scope.
71
- *
72
- * @return void
73
- */
74
- protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
75
- {
76
- $tokens = $phpcsFile->getTokens();
77
-
78
- /*
79
- * Determine if this is a function which needs to be examined.
80
- * The `processTokenWithinScope()` is called for each valid scope a method is in,
81
- * so for nested classes, we need to make sure we only examine the token for
82
- * the lowest level valid scope.
83
- */
84
- $conditions = $tokens[$stackPtr]['conditions'];
85
- end($conditions);
86
- $deepestScope = key($conditions);
87
- if ($deepestScope !== $currScope) {
88
- return;
89
- }
90
-
91
- if ($this->isFunctionDeprecated($phpcsFile, $stackPtr) === true) {
92
- /*
93
- * Deprecated functions don't have to comply with the naming conventions,
94
- * otherwise functions deprecated in favour of a function with a compliant
95
- * name would still trigger an error.
96
- */
97
- return;
98
- }
99
-
100
- $methodName = $phpcsFile->getDeclarationName($stackPtr);
101
- if ($methodName === null) {
102
- // Ignore closures.
103
- return;
104
- }
105
-
106
- // Is this a magic method. i.e., is prefixed with "__" ?
107
- if (preg_match('|^__[^_]|', $methodName) > 0) {
108
- $magicPart = strtolower(substr($methodName, 2));
109
- if (isset($this->magicMethods[$magicPart]) === false
110
- && isset($this->methodsDoubleUnderscore[$magicPart]) === false
111
- ) {
112
- $className = '[anonymous class]';
113
- $scopeNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($currScope + 1), null, true);
114
- if ($scopeNextNonEmpty !== false && $tokens[$scopeNextNonEmpty]['code'] === \T_STRING) {
115
- $className = $tokens[$scopeNextNonEmpty]['content'];
116
- }
117
-
118
- $phpcsFile->addWarning(
119
- 'Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
120
- $stackPtr,
121
- 'MethodDoubleUnderscore',
122
- array($className . '::' . $methodName)
123
- );
124
- }
125
- }
126
- }
127
-
128
-
129
- /**
130
- * Processes the tokens outside the scope.
131
- *
132
- * @since 8.2.0
133
- *
134
- * @param \PHP_CodeSniffer_File $phpcsFile The file being processed.
135
- * @param int $stackPtr The position where this token was
136
- * found.
137
- *
138
- * @return void
139
- */
140
- protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
141
- {
142
- if ($this->isFunctionDeprecated($phpcsFile, $stackPtr) === true) {
143
- /*
144
- * Deprecated functions don't have to comply with the naming conventions,
145
- * otherwise functions deprecated in favour of a function with a compliant
146
- * name would still trigger an error.
147
- */
148
- return;
149
- }
150
-
151
- $functionName = $phpcsFile->getDeclarationName($stackPtr);
152
- if ($functionName === null) {
153
- // Ignore closures.
154
- return;
155
- }
156
-
157
- // Is this a magic function. i.e., it is prefixed with "__".
158
- if (preg_match('|^__[^_]|', $functionName) > 0) {
159
- $magicPart = strtolower(substr($functionName, 2));
160
- if (isset($this->magicFunctions[$magicPart]) === false) {
161
- $phpcsFile->addWarning(
162
- 'Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
163
- $stackPtr,
164
- 'FunctionDoubleUnderscore',
165
- array($functionName)
166
- );
167
- }
168
- }
169
- }
170
-
171
-
172
- /**
173
- * Check whether a function has been marked as deprecated via a @deprecated tag
174
- * in the function docblock.
175
- *
176
- * @since 9.3.2
177
- *
178
- * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
179
- * @param int $stackPtr The position of a T_FUNCTION
180
- * token in the stack.
181
- *
182
- * @return bool
183
- */
184
- private function isFunctionDeprecated(File $phpcsFile, $stackPtr)
185
- {
186
- $tokens = $phpcsFile->getTokens();
187
- $find = Tokens::$methodPrefixes;
188
- $find[] = \T_WHITESPACE;
189
-
190
- $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
191
- if ($tokens[$commentEnd]['code'] !== \T_DOC_COMMENT_CLOSE_TAG) {
192
- // Function doesn't have a doc comment or is using the wrong type of comment.
193
- return false;
194
- }
195
-
196
- $commentStart = $tokens[$commentEnd]['comment_opener'];
197
- foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
198
- if ($tokens[$tag]['content'] === '@deprecated') {
199
- return true;
200
- }
201
- }
202
-
203
- return false;
204
- }
205
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php DELETED
@@ -1,455 +0,0 @@
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\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 parameter value as was passed to the function,
24
- * but will instead provide the current value (which might have been modified).
25
- *
26
- * PHP version 7.0
27
- *
28
- * @link https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameter-modified
29
- *
30
- * @since 9.1.0
31
- */
32
- class ArgumentFunctionsReportCurrentValueSniff extends Sniff
33
- {
34
-
35
- /**
36
- * A list of functions that, when called, can behave differently in PHP 7
37
- * when dealing with parameters of the function they're called in.
38
- *
39
- * @since 9.1.0
40
- *
41
- * @var array
42
- */
43
- protected $changedFunctions = array(
44
- 'func_get_arg' => true,
45
- 'func_get_args' => true,
46
- 'debug_backtrace' => true,
47
- 'debug_print_backtrace' => true,
48
- );
49
-
50
- /**
51
- * Tokens to look out for to allow us to skip past nested scoped structures.
52
- *
53
- * @since 9.1.0
54
- *
55
- * @var array
56
- */
57
- private $skipPastNested = array(
58
- 'T_CLASS' => true,
59
- 'T_ANON_CLASS' => true,
60
- 'T_INTERFACE' => true,
61
- 'T_TRAIT' => true,
62
- 'T_FUNCTION' => true,
63
- 'T_CLOSURE' => true,
64
- );
65
-
66
- /**
67
- * List of tokens which when they preceed a T_STRING *within a function* indicate
68
- * this is not a call to a PHP native function.
69
- *
70
- * This list already takes into account that nested scoped structures are being
71
- * skipped over, so doesn't check for those again.
72
- * Similarly, as constants won't have parentheses, those don't need to be checked
73
- * for either.
74
- *
75
- * @since 9.1.0
76
- *
77
- * @var array
78
- */
79
- private $noneFunctionCallIndicators = array(
80
- \T_DOUBLE_COLON => true,
81
- \T_OBJECT_OPERATOR => true,
82
- );
83
-
84
- /**
85
- * The tokens for variable incrementing/decrementing.
86
- *
87
- * @since 9.1.0
88
- *
89
- * @var array
90
- */
91
- private $plusPlusMinusMinus = array(
92
- \T_DEC => true,
93
- \T_INC => true,
94
- );
95
-
96
- /**
97
- * Tokens to ignore when determining the start of a statement.
98
- *
99
- * @since 9.1.0
100
- *
101
- * @var array
102
- */
103
- private $ignoreForStartOfStatement = array(
104
- \T_COMMA,
105
- \T_DOUBLE_ARROW,
106
- \T_OPEN_SQUARE_BRACKET,
107
- \T_OPEN_PARENTHESIS,
108
- );
109
-
110
- /**
111
- * Returns an array of tokens this test wants to listen for.
112
- *
113
- * @since 9.1.0
114
- *
115
- * @return array
116
- */
117
- public function register()
118
- {
119
- return array(
120
- \T_FUNCTION,
121
- \T_CLOSURE,
122
- );
123
- }
124
-
125
- /**
126
- * Processes this test, when one of its tokens is encountered.
127
- *
128
- * @since 9.1.0
129
- *
130
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
131
- * @param int $stackPtr The position of the current token
132
- * in the stack passed in $tokens.
133
- *
134
- * @return void
135
- */
136
- public function process(File $phpcsFile, $stackPtr)
137
- {
138
- if ($this->supportsAbove('7.0') === false) {
139
- return;
140
- }
141
-
142
- $tokens = $phpcsFile->getTokens();
143
-
144
- if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
145
- // Abstract function, interface function, live coding or parse error.
146
- return;
147
- }
148
-
149
- $scopeOpener = $tokens[$stackPtr]['scope_opener'];
150
- $scopeCloser = $tokens[$stackPtr]['scope_closer'];
151
-
152
- // Does the function declaration have parameters ?
153
- $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
154
- if (empty($params)) {
155
- // No named arguments found, so no risk of them being changed.
156
- return;
157
- }
158
-
159
- $paramNames = array();
160
- foreach ($params as $param) {
161
- $paramNames[] = $param['name'];
162
- }
163
-
164
- for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) {
165
- if (isset($this->skipPastNested[$tokens[$i]['type']]) && isset($tokens[$i]['scope_closer'])) {
166
- // Skip past nested structures.
167
- $i = $tokens[$i]['scope_closer'];
168
- continue;
169
- }
170
-
171
- if ($tokens[$i]['code'] !== \T_STRING) {
172
- continue;
173
- }
174
-
175
- $foundFunctionName = strtolower($tokens[$i]['content']);
176
-
177
- if (isset($this->changedFunctions[$foundFunctionName]) === false) {
178
- // Not one of the target functions.
179
- continue;
180
- }
181
-
182
- /*
183
- * Ok, so is this really a function call to one of the PHP native functions ?
184
- */
185
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
186
- if ($next === false || $tokens[$next]['code'] !== \T_OPEN_PARENTHESIS) {
187
- // Live coding, parse error or not a function call.
188
- continue;
189
- }
190
-
191
- $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
192
- if ($prev !== false) {
193
- if (isset($this->noneFunctionCallIndicators[$tokens[$prev]['code']])) {
194
- continue;
195
- }
196
-
197
- // Check for namespaced functions, ie: \foo\bar() not \bar().
198
- if ($tokens[ $prev ]['code'] === \T_NS_SEPARATOR) {
199
- $pprev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
200
- if ($pprev !== false && $tokens[ $pprev ]['code'] === \T_STRING) {
201
- continue;
202
- }
203
- }
204
- }
205
-
206
- /*
207
- * Address some special cases.
208
- */
209
- if ($foundFunctionName !== 'func_get_args') {
210
- $paramOne = $this->getFunctionCallParameter($phpcsFile, $i, 1);
211
- if ($paramOne !== false) {
212
- switch ($foundFunctionName) {
213
- /*
214
- * Check if `debug_(print_)backtrace()` is called with the
215
- * `DEBUG_BACKTRACE_IGNORE_ARGS` option.
216
- */
217
- case 'debug_backtrace':
218
- case 'debug_print_backtrace':
219
- $hasIgnoreArgs = $phpcsFile->findNext(
220
- \T_STRING,
221
- $paramOne['start'],
222
- ($paramOne['end'] + 1),
223
- false,
224
- 'DEBUG_BACKTRACE_IGNORE_ARGS'
225
- );
226
-
227
- if ($hasIgnoreArgs !== false) {
228
- // Debug_backtrace() called with ignore args option.
229
- continue 2;
230
- }
231
- break;
232
-
233
- /*
234
- * Collect the necessary information to only throw a notice if the argument
235
- * touched/changed is in line with the passed $arg_num.
236
- *
237
- * Also, we can ignore `func_get_arg()` if the argument offset passed is
238
- * higher than the number of named parameters.
239
- *
240
- * {@internal Note: This does not take calculations into account!
241
- * Should be exceptionally rare and can - if needs be - be addressed at a later stage.}
242
- */
243
- case 'func_get_arg':
244
- $number = $phpcsFile->findNext(\T_LNUMBER, $paramOne['start'], ($paramOne['end'] + 1));
245
- if ($number !== false) {
246
- $argNumber = $tokens[$number]['content'];
247
-
248
- if (isset($paramNames[$argNumber]) === false) {
249
- // Requesting a non-named additional parameter. Ignore.
250
- continue 2;
251
- }
252
- }
253
- break;
254
- }
255
- }
256
- } else {
257
- /*
258
- * Check if the call to func_get_args() happens to be in an array_slice() or
259
- * array_splice() with an $offset higher than the number of named parameters.
260
- * In that case, we can ignore it.
261
- *
262
- * {@internal Note: This does not take offset calculations into account!
263
- * Should be exceptionally rare and can - if needs be - be addressed at a later stage.}
264
- */
265
- if ($prev !== false && $tokens[$prev]['code'] === \T_OPEN_PARENTHESIS) {
266
-
267
- $maybeFunctionCall = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
268
- if ($maybeFunctionCall !== false
269
- && $tokens[$maybeFunctionCall]['code'] === \T_STRING
270
- && ($tokens[$maybeFunctionCall]['content'] === 'array_slice'
271
- || $tokens[$maybeFunctionCall]['content'] === 'array_splice')
272
- ) {
273
- $parentFuncParamTwo = $this->getFunctionCallParameter($phpcsFile, $maybeFunctionCall, 2);
274
- $number = $phpcsFile->findNext(
275
- \T_LNUMBER,
276
- $parentFuncParamTwo['start'],
277
- ($parentFuncParamTwo['end'] + 1)
278
- );
279
-
280
- if ($number !== false && isset($paramNames[$tokens[$number]['content']]) === false) {
281
- // Requesting non-named additional parameters. Ignore.
282
- continue ;
283
- }
284
-
285
- // Slice starts at a named argument, but we know which params are being accessed.
286
- $paramNamesSubset = \array_slice($paramNames, $tokens[$number]['content']);
287
- }
288
- }
289
- }
290
-
291
- /*
292
- * For debug_backtrace(), check if the result is being dereferenced and if so,
293
- * whether the `args` index is used.
294
- * I.e. whether `$index` in `debug_backtrace()[$stackFrame][$index]` is a string
295
- * with the content `args`.
296
- *
297
- * Note: We already know that $next is the open parenthesis of the function call.
298
- */
299
- if ($foundFunctionName === 'debug_backtrace' && isset($tokens[$next]['parenthesis_closer'])) {
300
- $afterParenthesis = $phpcsFile->findNext(
301
- Tokens::$emptyTokens,
302
- ($tokens[$next]['parenthesis_closer'] + 1),
303
- null,
304
- true
305
- );
306
-
307
- if ($tokens[$afterParenthesis]['code'] === \T_OPEN_SQUARE_BRACKET
308
- && isset($tokens[$afterParenthesis]['bracket_closer'])
309
- ) {
310
- $afterStackFrame = $phpcsFile->findNext(
311
- Tokens::$emptyTokens,
312
- ($tokens[$afterParenthesis]['bracket_closer'] + 1),
313
- null,
314
- true
315
- );
316
-
317
- if ($tokens[$afterStackFrame]['code'] === \T_OPEN_SQUARE_BRACKET
318
- && isset($tokens[$afterStackFrame]['bracket_closer'])
319
- ) {
320
- $arrayIndex = $phpcsFile->findNext(
321
- \T_CONSTANT_ENCAPSED_STRING,
322
- ($afterStackFrame + 1),
323
- $tokens[$afterStackFrame]['bracket_closer']
324
- );
325
-
326
- if ($arrayIndex !== false && $this->stripQuotes($tokens[$arrayIndex]['content']) !== 'args') {
327
- continue;
328
- }
329
- }
330
- }
331
- }
332
-
333
- /*
334
- * Only check for variables before the start of the statement to
335
- * prevent false positives on the return value of the function call
336
- * being assigned to one of the parameters, i.e.:
337
- * `$param = func_get_args();`.
338
- */
339
- $startOfStatement = PHPCSHelper::findStartOfStatement($phpcsFile, $i, $this->ignoreForStartOfStatement);
340
-
341
- /*
342
- * Ok, so we've found one of the target functions in the right scope.
343
- * Now, let's check if any of the passed parameters were touched.
344
- */
345
- $scanResult = 'clean';
346
- for ($j = ($scopeOpener + 1); $j < $startOfStatement; $j++) {
347
- if (isset($this->skipPastNested[$tokens[$j]['type']])
348
- && isset($tokens[$j]['scope_closer'])
349
- ) {
350
- // Skip past nested structures.
351
- $j = $tokens[$j]['scope_closer'];
352
- continue;
353
- }
354
-
355
- if ($tokens[$j]['code'] !== \T_VARIABLE) {
356
- continue;
357
- }
358
-
359
- if ($foundFunctionName === 'func_get_arg' && isset($argNumber)) {
360
- if (isset($paramNames[$argNumber])
361
- && $tokens[$j]['content'] !== $paramNames[$argNumber]
362
- ) {
363
- // Different param than the one requested by func_get_arg().
364
- continue;
365
- }
366
- } elseif ($foundFunctionName === 'func_get_args' && isset($paramNamesSubset)) {
367
- if (\in_array($tokens[$j]['content'], $paramNamesSubset, true) === false) {
368
- // Different param than the ones requested by func_get_args().
369
- continue;
370
- }
371
- } elseif (\in_array($tokens[$j]['content'], $paramNames, true) === false) {
372
- // Variable is not one of the function parameters.
373
- continue;
374
- }
375
-
376
- /*
377
- * Ok, so we've found a variable which was passed as one of the parameters.
378
- * Now, is this variable being changed, i.e. incremented, decremented or
379
- * assigned something ?
380
- */
381
- $scanResult = 'warning';
382
- if (isset($variableToken) === false) {
383
- $variableToken = $j;
384
- }
385
-
386
- $beforeVar = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($j - 1), null, true);
387
- if ($beforeVar !== false && isset($this->plusPlusMinusMinus[$tokens[$beforeVar]['code']])) {
388
- // Variable is being (pre-)incremented/decremented.
389
- $scanResult = 'error';
390
- $variableToken = $j;
391
- break;
392
- }
393
-
394
- $afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($j + 1), null, true);
395
- if ($afterVar === false) {
396
- // Shouldn't be possible, but just in case.
397
- continue;
398
- }
399
-
400
- if (isset($this->plusPlusMinusMinus[$tokens[$afterVar]['code']])) {
401
- // Variable is being (post-)incremented/decremented.
402
- $scanResult = 'error';
403
- $variableToken = $j;
404
- break;
405
- }
406
-
407
- if ($tokens[$afterVar]['code'] === \T_OPEN_SQUARE_BRACKET
408
- && isset($tokens[$afterVar]['bracket_closer'])
409
- ) {
410
- // Skip past array access on the variable.
411
- while (($afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($tokens[$afterVar]['bracket_closer'] + 1), null, true)) !== false) {
412
- if ($tokens[$afterVar]['code'] !== \T_OPEN_SQUARE_BRACKET
413
- || isset($tokens[$afterVar]['bracket_closer']) === false
414
- ) {
415
- break;
416
- }
417
- }
418
- }
419
-
420
- if ($afterVar !== false
421
- && isset(Tokens::$assignmentTokens[$tokens[$afterVar]['code']])
422
- ) {
423
- // Variable is being assigned something.
424
- $scanResult = 'error';
425
- $variableToken = $j;
426
- break;
427
- }
428
- }
429
-
430
- unset($argNumber, $paramNamesSubset);
431
-
432
- if ($scanResult === 'clean') {
433
- continue;
434
- }
435
-
436
- $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.';
437
- $data = array(
438
- $foundFunctionName,
439
- $tokens[$variableToken]['content'],
440
- $tokens[$variableToken]['line'],
441
- );
442
-
443
- if ($scanResult === 'error') {
444
- $data[] = 'changed';
445
- $phpcsFile->addError($error, $i, 'Changed', $data);
446
-
447
- } elseif ($scanResult === 'warning') {
448
- $data[] = 'used, and possibly changed (by reference),';
449
- $phpcsFile->addWarning($error, $i, 'NeedsInspection', $data);
450
- }
451
-
452
- unset($variableToken);
453
- }
454
- }
455
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsUsageSniff.php DELETED
@@ -1,169 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect usage of `func_get_args()`, `func_get_arg()` and `func_num_args()` in invalid context.
19
- *
20
- * Checks for:
21
- * - Prior to PHP 5.3, these functions could not be used as a function call parameter.
22
- * - Calling these functions from the outermost scope of a file which has been included by
23
- * calling `include` or `require` from within a function in the calling file, worked
24
- * prior to PHP 5.3. As of PHP 5.3, this will generate a warning and will always return false/-1.
25
- * If the file was called directly or included in the global scope, calls to these
26
- * functions would already generate a warning prior to PHP 5.3.
27
- *
28
- * PHP version 5.3
29
- *
30
- * @link https://www.php.net/manual/en/migration53.incompatible.php
31
- *
32
- * @since 8.2.0
33
- */
34
- class ArgumentFunctionsUsageSniff extends Sniff
35
- {
36
-
37
- /**
38
- * The target functions for this sniff.
39
- *
40
- * @since 8.2.0
41
- *
42
- * @var array
43
- */
44
- protected $targetFunctions = array(
45
- 'func_get_args' => true,
46
- 'func_get_arg' => true,
47
- 'func_num_args' => true,
48
- );
49
-
50
-
51
- /**
52
- * Returns an array of tokens this test wants to listen for.
53
- *
54
- * @since 8.2.0
55
- *
56
- * @return array
57
- */
58
- public function register()
59
- {
60
- return array(\T_STRING);
61
- }
62
-
63
-
64
- /**
65
- * Processes this test, when one of its tokens is encountered.
66
- *
67
- * @since 8.2.0
68
- *
69
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
70
- * @param int $stackPtr The position of the current token in the
71
- * stack passed in $tokens.
72
- *
73
- * @return void
74
- */
75
- public function process(File $phpcsFile, $stackPtr)
76
- {
77
- $tokens = $phpcsFile->getTokens();
78
- $functionLc = strtolower($tokens[$stackPtr]['content']);
79
- if (isset($this->targetFunctions[$functionLc]) === false) {
80
- return;
81
- }
82
-
83
- // Next non-empty token should be the open parenthesis.
84
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
85
- if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
86
- return;
87
- }
88
-
89
- $ignore = array(
90
- \T_DOUBLE_COLON => true,
91
- \T_OBJECT_OPERATOR => true,
92
- \T_FUNCTION => true,
93
- \T_NEW => true,
94
- );
95
-
96
- $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
97
- if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) {
98
- // Not a call to a PHP function.
99
- return;
100
- } elseif ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING) {
101
- // Namespaced function.
102
- return;
103
- }
104
-
105
- $data = $tokens[$stackPtr]['content'];
106
-
107
- /*
108
- * Check for use of the functions in the global scope.
109
- *
110
- * As PHPCS can not determine whether a file is included from within a function in
111
- * another file, so always throw a warning/error.
112
- */
113
- if ($phpcsFile->hasCondition($stackPtr, array(\T_FUNCTION, \T_CLOSURE)) === false) {
114
- $isError = false;
115
- $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.';
116
-
117
- if ($this->supportsAbove('5.3') === true) {
118
- $isError = true;
119
- $message .= ' As of PHP 5.3, it is no longer supported at all.';
120
- }
121
-
122
- $this->addMessage($phpcsFile, $message, $stackPtr, $isError, 'OutsideFunctionScope', $data);
123
- }
124
-
125
- /*
126
- * Check for use of the functions as a parameter in a function call.
127
- */
128
- if ($this->supportsBelow('5.2') === false) {
129
- return;
130
- }
131
-
132
- if (isset($tokens[$stackPtr]['nested_parenthesis']) === false) {
133
- return;
134
- }
135
-
136
- $throwError = false;
137
-
138
- $closer = end($tokens[$stackPtr]['nested_parenthesis']);
139
- if (isset($tokens[$closer]['parenthesis_owner'])
140
- && $tokens[$tokens[$closer]['parenthesis_owner']]['type'] === 'T_CLOSURE'
141
- ) {
142
- $throwError = true;
143
- } else {
144
- $opener = key($tokens[$stackPtr]['nested_parenthesis']);
145
- $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
146
- if ($tokens[$prevNonEmpty]['code'] !== \T_STRING) {
147
- return;
148
- }
149
-
150
- $prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
151
- if ($tokens[$prevPrevNonEmpty]['code'] === \T_FUNCTION) {
152
- return;
153
- }
154
-
155
- $throwError = true;
156
- }
157
-
158
- if ($throwError === false) {
159
- return;
160
- }
161
-
162
- $phpcsFile->addError(
163
- '%s() could not be used in parameter lists prior to PHP 5.3.',
164
- $stackPtr,
165
- 'InParameterList',
166
- $data
167
- );
168
- }
169
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionParametersSniff.php DELETED
@@ -1,1109 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect use of new function parameters in calls to native PHP functions.
19
- *
20
- * PHP version All
21
- *
22
- * @link https://www.php.net/manual/en/doc.changelog.php
23
- *
24
- * @since 7.0.0
25
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class..
26
- */
27
- class NewFunctionParametersSniff extends AbstractNewFeatureSniff
28
- {
29
- /**
30
- * A list of functions which have new parameters, not present in older versions.
31
- *
32
- * The array lists : version number with false (not present) or true (present).
33
- * The index is the location of the parameter in the parameter list, starting at 0 !
34
- * If's sufficient to list the first version where the function appears.
35
- *
36
- * @since 7.0.0
37
- * @since 7.0.2 Visibility changed from `public` to `protected`.
38
- *
39
- * @var array
40
- */
41
- protected $newFunctionParameters = array(
42
- 'array_filter' => array(
43
- 2 => array(
44
- 'name' => 'flag',
45
- '5.5' => false,
46
- '5.6' => true,
47
- ),
48
- ),
49
- 'array_slice' => array(
50
- 1 => array(
51
- 'name' => 'preserve_keys',
52
- '5.0.1' => false,
53
- '5.0.2' => true,
54
- ),
55
- ),
56
- 'array_unique' => array(
57
- 1 => array(
58
- 'name' => 'sort_flags',
59
- '5.2.8' => false,
60
- '5.2.9' => true,
61
- ),
62
- ),
63
- 'assert' => array(
64
- 1 => array(
65
- 'name' => 'description',
66
- '5.4.7' => false,
67
- '5.4.8' => true,
68
- ),
69
- ),
70
- 'base64_decode' => array(
71
- 1 => array(
72
- 'name' => 'strict',
73
- '5.1' => false,
74
- '5.2' => true,
75
- ),
76
- ),
77
- 'bcmod' => array(
78
- 2 => array(
79
- 'name' => 'scale',
80
- '7.1' => false,
81
- '7.2' => true,
82
- ),
83
- ),
84
- 'class_implements' => array(
85
- 1 => array(
86
- 'name' => 'autoload',
87
- '5.0' => false,
88
- '5.1' => true,
89
- ),
90
- ),
91
- 'class_parents' => array(
92
- 1 => array(
93
- 'name' => 'autoload',
94
- '5.0' => false,
95
- '5.1' => true,
96
- ),
97
- ),
98
- 'clearstatcache' => array(
99
- 0 => array(
100
- 'name' => 'clear_realpath_cache',
101
- '5.2' => false,
102
- '5.3' => true,
103
- ),
104
- 1 => array(
105
- 'name' => 'filename',
106
- '5.2' => false,
107
- '5.3' => true,
108
- ),
109
- ),
110
- 'copy' => array(
111
- 2 => array(
112
- 'name' => 'context',
113
- '5.2' => false,
114
- '5.3' => true,
115
- ),
116
- ),
117
- 'curl_multi_info_read' => array(
118
- 1 => array(
119
- 'name' => 'msgs_in_queue',
120
- '5.1' => false,
121
- '5.2' => true,
122
- ),
123
- ),
124
- 'debug_backtrace' => array(
125
- 0 => array(
126
- 'name' => 'options',
127
- '5.2.4' => false,
128
- '5.2.5' => true,
129
- ),
130
- 1 => array(
131
- 'name' => 'limit',
132
- '5.3' => false,
133
- '5.4' => true,
134
- ),
135
- ),
136
- 'debug_print_backtrace' => array(
137
- 0 => array(
138
- 'name' => 'options',
139
- '5.3.5' => false,
140
- '5.3.6' => true,
141
- ),
142
- 1 => array(
143
- 'name' => 'limit',
144
- '5.3' => false,
145
- '5.4' => true,
146
- ),
147
- ),
148
- 'dirname' => array(
149
- 1 => array(
150
- 'name' => 'levels',
151
- '5.6' => false,
152
- '7.0' => true,
153
- ),
154
- ),
155
- 'dns_get_record' => array(
156
- 4 => array(
157
- 'name' => 'raw',
158
- '5.3' => false,
159
- '5.4' => true,
160
- ),
161
- ),
162
- 'fgetcsv' => array(
163
- 4 => array(
164
- 'name' => 'escape',
165
- '5.2' => false,
166
- '5.3' => true,
167
- ),
168
- ),
169
- 'fputcsv' => array(
170
- 4 => array(
171
- 'name' => 'escape_char',
172
- '5.5.3' => false,
173
- '5.5.4' => true,
174
- ),
175
- ),
176
- 'file_get_contents' => array(
177
- 3 => array(
178
- 'name' => 'offset',
179
- '5.0' => false,
180
- '5.1' => true,
181
- ),
182
- 4 => array(
183
- 'name' => 'maxlen',
184
- '5.0' => false,
185
- '5.1' => true,
186
- ),
187
- ),
188
- 'filter_input_array' => array(
189
- 2 => array(
190
- 'name' => 'add_empty',
191
- '5.3' => false,
192
- '5.4' => true,
193
- ),
194
- ),
195
- 'filter_var_array' => array(
196
- 2 => array(
197
- 'name' => 'add_empty',
198
- '5.3' => false,
199
- '5.4' => true,
200
- ),
201
- ),
202
- 'getenv' => array(
203
- 1 => array(
204
- 'name' => 'local_only',
205
- '5.5.37' => false,
206
- '5.5.38' => true, // Also introduced in PHP 5.6.24 and 7.0.9.
207
- ),
208
- ),
209
- 'getopt' => array(
210
- 2 => array(
211
- 'name' => 'optind',
212
- '7.0' => false,
213
- '7.1' => true,
214
- ),
215
- ),
216
- 'gettimeofday' => array(
217
- 0 => array(
218
- 'name' => 'return_float',
219
- '5.0' => false,
220
- '5.1' => true,
221
- ),
222
- ),
223
- 'get_defined_functions' => array(
224
- 0 => array(
225
- 'name' => 'exclude_disabled',
226
- '7.0.14' => false,
227
- '7.0.15' => true,
228
- ),
229
- ),
230
- 'get_headers' => array(
231
- 2 => array(
232
- 'name' => 'context',
233
- '7.0' => false,
234
- '7.1' => true,
235
- ),
236
- ),
237
- 'get_html_translation_table' => array(
238
- 2 => array(
239
- 'name' => 'encoding',
240
- '5.3.3' => false,
241
- '5.3.4' => true,
242
- ),
243
- ),
244
- 'get_loaded_extensions' => array(
245
- 0 => array(
246
- 'name' => 'zend_extensions',
247
- '5.2.3' => false,
248
- '5.2.4' => true,
249
- ),
250
- ),
251
- 'gzcompress' => array(
252
- 2 => array(
253
- 'name' => 'encoding',
254
- '5.3' => false,
255
- '5.4' => true,
256
- ),
257
- ),
258
- 'gzdeflate' => array(
259
- 2 => array(
260
- 'name' => 'encoding',
261
- '5.3' => false,
262
- '5.4' => true,
263
- ),
264
- ),
265
- 'htmlentities' => array(
266
- 3 => array(
267
- 'name' => 'double_encode',
268
- '5.2.2' => false,
269
- '5.2.3' => true,
270
- ),
271
- ),
272
- 'htmlspecialchars' => array(
273
- 3 => array(
274
- 'name' => 'double_encode',
275
- '5.2.2' => false,
276
- '5.2.3' => true,
277
- ),
278
- ),
279
- 'http_build_query' => array(
280
- 2 => array(
281
- 'name' => 'arg_separator',
282
- '5.1.1' => false,
283
- '5.1.2' => true,
284
- ),
285
- 3 => array(
286
- 'name' => 'enc_type',
287
- '5.3' => false,
288
- '5.4' => true,
289
- ),
290
- ),
291
- 'idn_to_ascii' => array(
292
- 2 => array(
293
- 'name' => 'variant',
294
- '5.3' => false,
295
- '5.4' => true,
296
- ),
297
- 3 => array(
298
- 'name' => 'idna_info',
299
- '5.3' => false,
300
- '5.4' => true,
301
- ),
302
- ),
303
- 'idn_to_utf8' => array(
304
- 2 => array(
305
- 'name' => 'variant',
306
- '5.3' => false,
307
- '5.4' => true,
308
- ),
309
- 3 => array(
310
- 'name' => 'idna_info',
311
- '5.3' => false,
312
- '5.4' => true,
313
- ),
314
- ),
315
- 'imagecolorset' => array(
316
- 5 => array(
317
- 'name' => 'alpha',
318
- '5.3' => false,
319
- '5.4' => true,
320
- ),
321
- ),
322
- 'imagepng' => array(
323
- 2 => array(
324
- 'name' => 'quality',
325
- '5.1.1' => false,
326
- '5.1.2' => true,
327
- ),
328
- 3 => array(
329
- 'name' => 'filters',
330
- '5.1.2' => false,
331
- '5.1.3' => true,
332
- ),
333
- ),
334
- 'imagerotate' => array(
335
- 3 => array(
336
- 'name' => 'ignore_transparent',
337
- '5.0' => false,
338
- '5.1' => true,
339
- ),
340
- ),
341
- 'imap_open' => array(
342
- 4 => array(
343
- 'name' => 'n_retries',
344
- '5.1' => false,
345
- '5.2' => true,
346
- ),
347
- 5 => array(
348
- 'name' => 'params',
349
- '5.3.1' => false,
350
- '5.3.2' => true,
351
- ),
352
- ),
353
- 'imap_reopen' => array(
354
- 3 => array(
355
- 'name' => 'n_retries',
356
- '5.1' => false,
357
- '5.2' => true,
358
- ),
359
- ),
360
- 'ini_get_all' => array(
361
- 1 => array(
362
- 'name' => 'details',
363
- '5.2' => false,
364
- '5.3' => true,
365
- ),
366
- ),
367
- 'is_a' => array(
368
- 2 => array(
369
- 'name' => 'allow_string',
370
- '5.3.8' => false,
371
- '5.3.9' => true,
372
- ),
373
- ),
374
- 'is_subclass_of' => array(
375
- 2 => array(
376
- 'name' => 'allow_string',
377
- '5.3.8' => false,
378
- '5.3.9' => true,
379
- ),
380
- ),
381
- 'iterator_to_array' => array(
382
- 1 => array(
383
- 'name' => 'use_keys',
384
- '5.2.0' => false,
385
- '5.2.1' => true,
386
- ),
387
- ),
388
- 'json_decode' => array(
389
- 2 => array(
390
- 'name' => 'depth',
391
- '5.2' => false,
392
- '5.3' => true,
393
- ),
394
- 3 => array(
395
- 'name' => 'options',
396
- '5.3' => false,
397
- '5.4' => true,
398
- ),
399
- ),
400
- 'json_encode' => array(
401
- 1 => array(
402
- 'name' => 'options',
403
- '5.2' => false,
404
- '5.3' => true,
405
- ),
406
- 2 => array(
407
- 'name' => 'depth',
408
- '5.4' => false,
409
- '5.5' => true,
410
- ),
411
- ),
412
- 'ldap_add' => array(
413
- 3 => array(
414
- 'name' => 'serverctrls',
415
- '7.2' => false,
416
- '7.3' => true,
417
- ),
418
- ),
419
- 'ldap_compare' => array(
420
- 4 => array(
421
- 'name' => 'serverctrls',
422
- '7.2' => false,
423
- '7.3' => true,
424
- ),
425
- ),
426
- 'ldap_delete' => array(
427
- 2 => array(
428
- 'name' => 'serverctrls',
429
- '7.2' => false,
430
- '7.3' => true,
431
- ),
432
- ),
433
- 'ldap_list' => array(
434
- 8 => array(
435
- 'name' => 'serverctrls',
436
- '7.2' => false,
437
- '7.3' => true,
438
- ),
439
- ),
440
- 'ldap_mod_add' => array(
441
- 3 => array(
442
- 'name' => 'serverctrls',
443
- '7.2' => false,
444
- '7.3' => true,
445
- ),
446
- ),
447
- 'ldap_mod_del' => array(
448
- 3 => array(
449
- 'name' => 'serverctrls',
450
- '7.2' => false,
451
- '7.3' => true,
452
- ),
453
- ),
454
- 'ldap_mod_replace' => array(
455
- 3 => array(
456
- 'name' => 'serverctrls',
457
- '7.2' => false,
458
- '7.3' => true,
459
- ),
460
- ),
461
- 'ldap_modify_batch' => array(
462
- 3 => array(
463
- 'name' => 'serverctrls',
464
- '7.2' => false,
465
- '7.3' => true,
466
- ),
467
- ),
468
- 'ldap_parse_result' => array(
469
- 6 => array(
470
- 'name' => 'serverctrls',
471
- '7.2' => false,
472
- '7.3' => true,
473
- ),
474
- ),
475
- 'ldap_read' => array(
476
- 8 => array(
477
- 'name' => 'serverctrls',
478
- '7.2' => false,
479
- '7.3' => true,
480
- ),
481
- ),
482
- 'ldap_rename' => array(
483
- 5 => array(
484
- 'name' => 'serverctrls',
485
- '7.2' => false,
486
- '7.3' => true,
487
- ),
488
- ),
489
- 'ldap_search' => array(
490
- 8 => array(
491
- 'name' => 'serverctrls',
492
- '7.2' => false,
493
- '7.3' => true,
494
- ),
495
- ),
496
- 'memory_get_peak_usage' => array(
497
- 0 => array(
498
- 'name' => 'real_usage',
499
- '5.1' => false,
500
- '5.2' => true,
501
- ),
502
- ),
503
- 'memory_get_usage' => array(
504
- 0 => array(
505
- 'name' => 'real_usage',
506
- '5.1' => false,
507
- '5.2' => true,
508
- ),
509
- ),
510
- 'mb_encode_numericentity' => array(
511
- 3 => array(
512
- 'name' => 'is_hex',
513
- '5.3' => false,
514
- '5.4' => true,
515
- ),
516
- ),
517
- 'mb_strrpos' => array(
518
- /*
519
- * Note: the actual position is 2, but the original 3rd
520
- * parameter 'encoding' was moved to the 4th position.
521
- * So the only way to detect if offset is used is when
522
- * both offset and encoding are set.
523
- */
524
- 3 => array(
525
- 'name' => 'offset',
526
- '5.1' => false,
527
- '5.2' => true,
528
- ),
529
- ),
530
- 'mssql_connect' => array(
531
- 3 => array(
532
- 'name' => 'new_link',
533
- '5.0' => false,
534
- '5.1' => true,
535
- ),
536
- ),
537
- 'mysqli_commit' => array(
538
- 1 => array(
539
- 'name' => 'flags',
540
- '5.4' => false,
541
- '5.5' => true,
542
- ),
543
- 2 => array(
544
- 'name' => 'name',
545
- '5.4' => false,
546
- '5.5' => true,
547
- ),
548
- ),
549
- 'mysqli_rollback' => array(
550
- 1 => array(
551
- 'name' => 'flags',
552
- '5.4' => false,
553
- '5.5' => true,
554
- ),
555
- 2 => array(
556
- 'name' => 'name',
557
- '5.4' => false,
558
- '5.5' => true,
559
- ),
560
- ),
561
- 'nl2br' => array(
562
- 1 => array(
563
- 'name' => 'is_xhtml',
564
- '5.2' => false,
565
- '5.3' => true,
566
- ),
567
- ),
568
- 'openssl_decrypt' => array(
569
- 4 => array(
570
- 'name' => 'iv',
571
- '5.3.2' => false,
572
- '5.3.3' => true,
573
- ),
574
- 5 => array(
575
- 'name' => 'tag',
576
- '7.0' => false,
577
- '7.1' => true,
578
- ),
579
- 6 => array(
580
- 'name' => 'aad',
581
- '7.0' => false,
582
- '7.1' => true,
583
- ),
584
- ),
585
- 'openssl_encrypt' => array(
586
- 4 => array(
587
- 'name' => 'iv',
588
- '5.3.2' => false,
589
- '5.3.3' => true,
590
- ),
591
- 5 => array(
592
- 'name' => 'tag',
593
- '7.0' => false,
594
- '7.1' => true,
595
- ),
596
- 6 => array(
597
- 'name' => 'aad',
598
- '7.0' => false,
599
- '7.1' => true,
600
- ),
601
- 7 => array(
602
- 'name' => 'tag_length',
603
- '7.0' => false,
604
- '7.1' => true,
605
- ),
606
- ),
607
- 'openssl_open' => array(
608
- 4 => array(
609
- 'name' => 'method',
610
- '5.2' => false,
611
- '5.3' => true,
612
- ),
613
- 5 => array(
614
- 'name' => 'iv',
615
- '5.6' => false,
616
- '7.0' => true,
617
- ),
618
- ),
619
- 'openssl_pkcs7_verify' => array(
620
- 5 => array(
621
- 'name' => 'content',
622
- '5.0' => false,
623
- '5.1' => true,
624
- ),
625
- 6 => array(
626
- 'name' => 'p7bfilename',
627
- '7.1' => false,
628
- '7.2' => true,
629
- ),
630
- ),
631
- 'openssl_seal' => array(
632
- 4 => array(
633
- 'name' => 'method',
634
- '5.2' => false,
635
- '5.3' => true,
636
- ),
637
- 5 => array(
638
- 'name' => 'iv',
639
- '5.6' => false,
640
- '7.0' => true,
641
- ),
642
- ),
643
- 'openssl_verify' => array(
644
- 3 => array(
645
- 'name' => 'signature_alg',
646
- '5.1' => false,
647
- '5.2' => true,
648
- ),
649
- ),
650
- 'parse_ini_file' => array(
651
- 2 => array(
652
- 'name' => 'scanner_mode',
653
- '5.2' => false,
654
- '5.3' => true,
655
- ),
656
- ),
657
- 'parse_url' => array(
658
- 1 => array(
659
- 'name' => 'component',
660
- '5.1.1' => false,
661
- '5.1.2' => true,
662
- ),
663
- ),
664
- 'pg_fetch_all' => array(
665
- 1 => array(
666
- 'name' => 'result_type',
667
- '7.0' => false,
668
- '7.1' => true,
669
- ),
670
- ),
671
- 'pg_last_notice' => array(
672
- 1 => array(
673
- 'name' => 'option',
674
- '7.0' => false,
675
- '7.1' => true,
676
- ),
677
- ),
678
- 'pg_lo_create' => array(
679
- 1 => array(
680
- 'name' => 'object_id',
681
- '5.2' => false,
682
- '5.3' => true,
683
- ),
684
- ),
685
- 'pg_lo_import' => array(
686
- 2 => array(
687
- 'name' => 'object_id',
688
- '5.2' => false,
689
- '5.3' => true,
690
- ),
691
- ),
692
- 'pg_select' => array(
693
- 4 => array(
694
- 'name' => 'result_type',
695
- '7.0' => false,
696
- '7.1' => true,
697
- ),
698
- ),
699
- 'php_uname' => array(
700
- 0 => array(
701
- 'name' => 'mode',
702
- '4.2' => false,
703
- '4.3' => true,
704
- ),
705
- ),
706
- 'preg_replace' => array(
707
- 4 => array(
708
- 'name' => 'count',
709
- '5.0' => false,
710
- '5.1' => true,
711
- ),
712
- ),
713
- 'preg_replace_callback' => array(
714
- 4 => array(
715
- 'name' => 'count',
716
- '5.0' => false,
717
- '5.1' => true,
718
- ),
719
- 5 => array(
720
- 'name' => 'flags',
721
- '7.3' => false,
722
- '7.4' => true,
723
- ),
724
- ),
725
- 'preg_replace_callback_array' => array(
726
- 4 => array(
727
- 'name' => 'flags',
728
- '7.3' => false,
729
- '7.4' => true,
730
- ),
731
- ),
732
- 'round' => array(
733
- 2 => array(
734
- 'name' => 'mode',
735
- '5.2' => false,
736
- '5.3' => true,
737
- ),
738
- ),
739
- 'sem_acquire' => array(
740
- 1 => array(
741
- 'name' => 'nowait',
742
- '5.6' => false,
743
- '5.6.1' => true,
744
- ),
745
- ),
746
- 'session_regenerate_id' => array(
747
- 0 => array(
748
- 'name' => 'delete_old_session',
749
- '5.0' => false,
750
- '5.1' => true,
751
- ),
752
- ),
753
- 'session_set_cookie_params' => array(
754
- 4 => array(
755
- 'name' => 'httponly',
756
- '5.1' => false,
757
- '5.2' => true,
758
- ),
759
- ),
760
- 'session_set_save_handler' => array(
761
- 6 => array(
762
- 'name' => 'create_sid',
763
- '5.5.0' => false,
764
- '5.5.1' => true,
765
- ),
766
- 7 => array(
767
- 'name' => 'validate_sid',
768
- '5.6' => false,
769
- '7.0' => true,
770
- ),
771
- 8 => array(
772
- 'name' => 'update_timestamp',
773
- '5.6' => false,
774
- '7.0' => true,
775
- ),
776
- ),
777
- 'session_start' => array(
778
- 0 => array(
779
- 'name' => 'options',
780
- '5.6' => false,
781
- '7.0' => true,
782
- ),
783
- ),
784
- 'setcookie' => array(
785
- 6 => array(
786
- 'name' => 'httponly',
787
- '5.1' => false,
788
- '5.2' => true,
789
- ),
790
- ),
791
- 'setrawcookie' => array(
792
- 6 => array(
793
- 'name' => 'httponly',
794
- '5.1' => false,
795
- '5.2' => true,
796
- ),
797
- ),
798
- 'simplexml_load_file' => array(
799
- 4 => array(
800
- 'name' => 'is_prefix',
801
- '5.1' => false,
802
- '5.2' => true,
803
- ),
804
- ),
805
- 'simplexml_load_string' => array(
806
- 4 => array(
807
- 'name' => 'is_prefix',
808
- '5.1' => false,
809
- '5.2' => true,
810
- ),
811
- ),
812
- 'spl_autoload_register' => array(
813
- 2 => array(
814
- 'name' => 'prepend',
815
- '5.2' => false,
816
- '5.3' => true,
817
- ),
818
- ),
819
- 'stream_context_create' => array(
820
- 1 => array(
821
- 'name' => 'params',
822
- '5.2' => false,
823
- '5.3' => true,
824
- ),
825
- ),
826
- 'stream_copy_to_stream' => array(
827
- 3 => array(
828
- 'name' => 'offset',
829
- '5.0' => false,
830
- '5.1' => true,
831
- ),
832
- ),
833
- 'stream_get_contents' => array(
834
- 2 => array(
835
- 'name' => 'offset',
836
- '5.0' => false,
837
- '5.1' => true,
838
- ),
839
- ),
840
- 'stream_wrapper_register' => array(
841
- 2 => array(
842
- 'name' => 'flags',
843
- '5.2.3' => false,
844
- '5.2.4' => true,
845
- ),
846
- ),
847
- 'stristr' => array(
848
- 2 => array(
849
- 'name' => 'before_needle',
850
- '5.2' => false,
851
- '5.3' => true,
852
- ),
853
- ),
854
- 'strstr' => array(
855
- 2 => array(
856
- 'name' => 'before_needle',
857
- '5.2' => false,
858
- '5.3' => true,
859
- ),
860
- ),
861
- 'str_word_count' => array(
862
- 2 => array(
863
- 'name' => 'charlist',
864
- '5.0' => false,
865
- '5.1' => true,
866
- ),
867
- ),
868
- 'substr_count' => array(
869
- 2 => array(
870
- 'name' => 'offset',
871
- '5.0' => false,
872
- '5.1' => true,
873
- ),
874
- 3 => array(
875
- 'name' => 'length',
876
- '5.0' => false,
877
- '5.1' => true,
878
- ),
879
- ),
880
- 'sybase_connect' => array(
881
- 5 => array(
882
- 'name' => 'new',
883
- '5.2' => false,
884
- '5.3' => true,
885
- ),
886
- ),
887
- 'timezone_transitions_get' => array(
888
- 1 => array(
889
- 'name' => 'timestamp_begin',
890
- '5.2' => false,
891
- '5.3' => true,
892
- ),
893
- 2 => array(
894
- 'name' => 'timestamp_end',
895
- '5.2' => false,
896
- '5.3' => true,
897
- ),
898
- ),
899
- 'timezone_identifiers_list' => array(
900
- 0 => array(
901
- 'name' => 'what',
902
- '5.2' => false,
903
- '5.3' => true,
904
- ),
905
- 1 => array(
906
- 'name' => 'country',
907
- '5.2' => false,
908
- '5.3' => true,
909
- ),
910
- ),
911
- 'token_get_all' => array(
912
- 1 => array(
913
- 'name' => 'flags',
914
- '5.6' => false,
915
- '7.0' => true,
916
- ),
917
- ),
918
- 'ucwords' => array(
919
- 1 => array(
920
- 'name' => 'delimiters',
921
- '5.4.31' => false,
922
- '5.5.15' => false,
923
- '5.4.32' => true,
924
- '5.5.16' => true,
925
- ),
926
- ),
927
- 'unpack' => array(
928
- 2 => array(
929
- 'name' => 'offset',
930
- '7.0' => false,
931
- '7.1' => true,
932
- ),
933
- ),
934
- 'unserialize' => array(
935
- 1 => array(
936
- 'name' => 'options',
937
- '5.6' => false,
938
- '7.0' => true,
939
- ),
940
- ),
941
- );
942
-
943
-
944
- /**
945
- * Returns an array of tokens this test wants to listen for.
946
- *
947
- * @since 7.0.0
948
- *
949
- * @return array
950
- */
951
- public function register()
952
- {
953
- // Handle case-insensitivity of function names.
954
- $this->newFunctionParameters = $this->arrayKeysToLowercase($this->newFunctionParameters);
955
-
956
- return array(\T_STRING);
957
- }
958
-
959
- /**
960
- * Processes this test, when one of its tokens is encountered.
961
- *
962
- * @since 7.0.0
963
- *
964
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
965
- * @param int $stackPtr The position of the current token in
966
- * the stack passed in $tokens.
967
- *
968
- * @return void
969
- */
970
- public function process(File $phpcsFile, $stackPtr)
971
- {
972
- $tokens = $phpcsFile->getTokens();
973
-
974
- $ignore = array(
975
- \T_DOUBLE_COLON => true,
976
- \T_OBJECT_OPERATOR => true,
977
- \T_FUNCTION => true,
978
- \T_CONST => true,
979
- );
980
-
981
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
982
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
983
- // Not a call to a PHP function.
984
- return;
985
- }
986
-
987
- $function = $tokens[$stackPtr]['content'];
988
- $functionLc = strtolower($function);
989
-
990
- if (isset($this->newFunctionParameters[$functionLc]) === false) {
991
- return;
992
- }
993
-
994
- $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
995
- if ($parameterCount === 0) {
996
- return;
997
- }
998
-
999
- // If the parameter count returned > 0, we know there will be valid open parenthesis.
1000
- $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
1001
- $parameterOffsetFound = $parameterCount - 1;
1002
-
1003
- foreach ($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
1004
- if ($offset <= $parameterOffsetFound) {
1005
- $itemInfo = array(
1006
- 'name' => $function,
1007
- 'nameLc' => $functionLc,
1008
- 'offset' => $offset,
1009
- );
1010
- $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
1011
- }
1012
- }
1013
- }
1014
-
1015
-
1016
- /**
1017
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
1018
- *
1019
- * @since 7.1.0
1020
- *
1021
- * @param array $itemInfo Base information about the item.
1022
- *
1023
- * @return array Version and other information about the item.
1024
- */
1025
- public function getItemArray(array $itemInfo)
1026
- {
1027
- return $this->newFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
1028
- }
1029
-
1030
-
1031
- /**
1032
- * Get an array of the non-PHP-version array keys used in a sub-array.
1033
- *
1034
- * @since 7.1.0
1035
- *
1036
- * @return array
1037
- */
1038
- protected function getNonVersionArrayKeys()
1039
- {
1040
- return array('name');
1041
- }
1042
-
1043
-
1044
- /**
1045
- * Retrieve the relevant detail (version) information for use in an error message.
1046
- *
1047
- * @since 7.1.0
1048
- *
1049
- * @param array $itemArray Version and other information about the item.
1050
- * @param array $itemInfo Base information about the item.
1051
- *
1052
- * @return array
1053
- */
1054
- public function getErrorInfo(array $itemArray, array $itemInfo)
1055
- {
1056
- $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
1057
- $errorInfo['paramName'] = $itemArray['name'];
1058
-
1059
- return $errorInfo;
1060
- }
1061
-
1062
-
1063
- /**
1064
- * Get the item name to be used for the creation of the error code.
1065
- *
1066
- * @since 7.1.0
1067
- *
1068
- * @param array $itemInfo Base information about the item.
1069
- * @param array $errorInfo Detail information about an item.
1070
- *
1071
- * @return string
1072
- */
1073
- protected function getItemName(array $itemInfo, array $errorInfo)
1074
- {
1075
- return $itemInfo['name'] . '_' . $errorInfo['paramName'];
1076
- }
1077
-
1078
-
1079
- /**
1080
- * Get the error message template for this sniff.
1081
- *
1082
- * @since 7.1.0
1083
- *
1084
- * @return string
1085
- */
1086
- protected function getErrorMsgTemplate()
1087
- {
1088
- return 'The function %s() does not have a parameter "%s" in PHP version %s or earlier';
1089
- }
1090
-
1091
-
1092
- /**
1093
- * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
1094
- *
1095
- * @since 7.1.0
1096
- *
1097
- * @param array $data The error data array which was created.
1098
- * @param array $itemInfo Base information about the item this error message applies to.
1099
- * @param array $errorInfo Detail information about an item this error message applies to.
1100
- *
1101
- * @return array
1102
- */
1103
- protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
1104
- {
1105
- array_shift($data);
1106
- array_unshift($data, $itemInfo['name'], $errorInfo['paramName']);
1107
- return $data;
1108
- }
1109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionsSniff.php DELETED
@@ -1,2008 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect calls to new native PHP functions.
18
- *
19
- * PHP version All
20
- *
21
- * @since 5.5
22
- * @since 5.6 Now extends the base `Sniff` class instead of the upstream
23
- * `Generic.PHP.ForbiddenFunctions` sniff.
24
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class..
25
- */
26
- class NewFunctionsSniff extends AbstractNewFeatureSniff
27
- {
28
- /**
29
- * A list of new functions, not present in older versions.
30
- *
31
- * The array lists : version number with false (not present) or true (present).
32
- * If's sufficient to list the first version where the function appears.
33
- *
34
- * @since 5.5
35
- * @since 5.6 Visibility changed from `protected` to `public`.
36
- * @since 7.0.2 Visibility changed back from `public` to `protected`.
37
- * The earlier change was made to be in line with the upstream sniff,
38
- * but that sniff is no longer being extended.
39
- * @since 7.0.8 Renamed from `$forbiddenFunctions` to the more descriptive `$newFunctions`.
40
- *
41
- * @var array(string => array(string => bool))
42
- */
43
- protected $newFunctions = array(
44
- 'iterator_count' => array(
45
- '5.0' => false,
46
- '5.1' => true,
47
- ),
48
- 'iterator_to_array' => array(
49
- '5.0' => false,
50
- '5.1' => true,
51
- ),
52
- 'spl_autoload_call' => array(
53
- '5.0' => false,
54
- '5.1' => true,
55
- ),
56
- 'spl_autoload_extensions' => array(
57
- '5.0' => false,
58
- '5.1' => true,
59
- ),
60
- 'spl_autoload_functions' => array(
61
- '5.0' => false,
62
- '5.1' => true,
63
- ),
64
- 'spl_autoload_register' => array(
65
- '5.0' => false,
66
- '5.1' => true,
67
- ),
68
- 'spl_autoload_unregister' => array(
69
- '5.0' => false,
70
- '5.1' => true,
71
- ),
72
- 'spl_autoload' => array(
73
- '5.0' => false,
74
- '5.1' => true,
75
- ),
76
- 'hash_hmac' => array(
77
- '5.1.1' => false,
78
- '5.1.2' => true,
79
- ),
80
- 'array_fill_keys' => array(
81
- '5.1' => false,
82
- '5.2' => true,
83
- ),
84
- 'error_get_last' => array(
85
- '5.1' => false,
86
- '5.2' => true,
87
- ),
88
- 'image_type_to_extension' => array(
89
- '5.1' => false,
90
- '5.2' => true,
91
- ),
92
- 'memory_get_peak_usage' => array(
93
- '5.1' => false,
94
- '5.2' => true,
95
- ),
96
- 'sys_get_temp_dir' => array(
97
- '5.1' => false,
98
- '5.2' => true,
99
- ),
100
- 'timezone_abbreviations_list' => array(
101
- '5.1' => false,
102
- '5.2' => true,
103
- ),
104
- 'timezone_identifiers_list' => array(
105
- '5.1' => false,
106
- '5.2' => true,
107
- ),
108
- 'timezone_name_from_abbr' => array(
109
- '5.1' => false,
110
- '5.2' => true,
111
- ),
112
- 'stream_socket_shutdown' => array(
113
- '5.1' => false,
114
- '5.2' => true,
115
- ),
116
- 'imagegrabscreen' => array(
117
- '5.1' => false,
118
- '5.2' => true,
119
- ),
120
- 'imagegrabwindow' => array(
121
- '5.1' => false,
122
- '5.2' => true,
123
- ),
124
- 'libxml_disable_entity_loader' => array(
125
- '5.1' => false,
126
- '5.2' => true,
127
- ),
128
- 'mb_stripos' => array(
129
- '5.1' => false,
130
- '5.2' => true,
131
- ),
132
- 'mb_stristr' => array(
133
- '5.1' => false,
134
- '5.2' => true,
135
- ),
136
- 'mb_strrchr' => array(
137
- '5.1' => false,
138
- '5.2' => true,
139
- ),
140
- 'mb_strrichr' => array(
141
- '5.1' => false,
142
- '5.2' => true,
143
- ),
144
- 'mb_strripos' => array(
145
- '5.1' => false,
146
- '5.2' => true,
147
- ),
148
- 'ming_setSWFCompression' => array(
149
- '5.1' => false,
150
- '5.2' => true,
151
- ),
152
- 'openssl_csr_get_public_key' => array(
153
- '5.1' => false,
154
- '5.2' => true,
155
- ),
156
- 'openssl_csr_get_subject' => array(
157
- '5.1' => false,
158
- '5.2' => true,
159
- ),
160
- 'openssl_pkey_get_details' => array(
161
- '5.1' => false,
162
- '5.2' => true,
163
- ),
164
- 'spl_object_hash' => array(
165
- '5.1' => false,
166
- '5.2' => true,
167
- ),
168
- 'iterator_apply' => array(
169
- '5.1' => false,
170
- '5.2' => true,
171
- ),
172
- 'preg_last_error' => array(
173
- '5.1' => false,
174
- '5.2' => true,
175
- ),
176
- 'pg_field_table' => array(
177
- '5.1' => false,
178
- '5.2' => true,
179
- ),
180
- 'posix_initgroups' => array(
181
- '5.1' => false,
182
- '5.2' => true,
183
- ),
184
- 'gmp_nextprime' => array(
185
- '5.1' => false,
186
- '5.2' => true,
187
- ),
188
- 'xmlwriter_full_end_element' => array(
189
- '5.1' => false,
190
- '5.2' => true,
191
- ),
192
- 'xmlwriter_write_raw' => array(
193
- '5.1' => false,
194
- '5.2' => true,
195
- ),
196
- 'xmlwriter_start_dtd_entity' => array(
197
- '5.1' => false,
198
- '5.2' => true,
199
- ),
200
- 'xmlwriter_end_dtd_entity' => array(
201
- '5.1' => false,
202
- '5.2' => true,
203
- ),
204
- 'xmlwriter_write_dtd_entity' => array(
205
- '5.1' => false,
206
- '5.2' => true,
207
- ),
208
- 'filter_has_var' => array(
209
- '5.1' => false,
210
- '5.2' => true,
211
- ),
212
- 'filter_id' => array(
213
- '5.1' => false,
214
- '5.2' => true,
215
- ),
216
- 'filter_input_array' => array(
217
- '5.1' => false,
218
- '5.2' => true,
219
- ),
220
- 'filter_input' => array(
221
- '5.1' => false,
222
- '5.2' => true,
223
- ),
224
- 'filter_list' => array(
225
- '5.1' => false,
226
- '5.2' => true,
227
- ),
228
- 'filter_var_array' => array(
229
- '5.1' => false,
230
- '5.2' => true,
231
- ),
232
- 'filter_var' => array(
233
- '5.1' => false,
234
- '5.2' => true,
235
- ),
236
- 'json_decode' => array(
237
- '5.1' => false,
238
- '5.2' => true,
239
- ),
240
- 'json_encode' => array(
241
- '5.1' => false,
242
- '5.2' => true,
243
- ),
244
- 'zip_close' => array(
245
- '5.1' => false,
246
- '5.2' => true,
247
- ),
248
- 'zip_entry_close' => array(
249
- '5.1' => false,
250
- '5.2' => true,
251
- ),
252
- 'zip_entry_compressedsize' => array(
253
- '5.1' => false,
254
- '5.2' => true,
255
- ),
256
- 'zip_entry_compressionmethod' => array(
257
- '5.1' => false,
258
- '5.2' => true,
259
- ),
260
- 'zip_entry_filesize' => array(
261
- '5.1' => false,
262
- '5.2' => true,
263
- ),
264
- 'zip_entry_name' => array(
265
- '5.1' => false,
266
- '5.2' => true,
267
- ),
268
- 'zip_entry_open' => array(
269
- '5.1' => false,
270
- '5.2' => true,
271
- ),
272
- 'zip_entry_read' => array(
273
- '5.1' => false,
274
- '5.2' => true,
275
- ),
276
- 'zip_open' => array(
277
- '5.1' => false,
278
- '5.2' => true,
279
- ),
280
- 'zip_read' => array(
281
- '5.1' => false,
282
- '5.2' => true,
283
- ),
284
-
285
- 'array_replace' => array(
286
- '5.2' => false,
287
- '5.3' => true,
288
- ),
289
- 'array_replace_recursive' => array(
290
- '5.2' => false,
291
- '5.3' => true,
292
- ),
293
- 'class_alias' => array(
294
- '5.2' => false,
295
- '5.3' => true,
296
- ),
297
- 'forward_static_call' => array(
298
- '5.2' => false,
299
- '5.3' => true,
300
- ),
301
- 'forward_static_call_array' => array(
302
- '5.2' => false,
303
- '5.3' => true,
304
- ),
305
- 'gc_collect_cycles' => array(
306
- '5.2' => false,
307
- '5.3' => true,
308
- ),
309
- 'gc_disable' => array(
310
- '5.2' => false,
311
- '5.3' => true,
312
- ),
313
- 'gc_enable' => array(
314
- '5.2' => false,
315
- '5.3' => true,
316
- ),
317
- 'gc_enabled' => array(
318
- '5.2' => false,
319
- '5.3' => true,
320
- ),
321
- 'get_called_class' => array(
322
- '5.2' => false,
323
- '5.3' => true,
324
- ),
325
- 'gethostname' => array(
326
- '5.2' => false,
327
- '5.3' => true,
328
- ),
329
- 'header_remove' => array(
330
- '5.2' => false,
331
- '5.3' => true,
332
- ),
333
- 'lcfirst' => array(
334
- '5.2' => false,
335
- '5.3' => true,
336
- ),
337
- 'parse_ini_string' => array(
338
- '5.2' => false,
339
- '5.3' => true,
340
- ),
341
- 'quoted_printable_encode' => array(
342
- '5.2' => false,
343
- '5.3' => true,
344
- ),
345
- 'str_getcsv' => array(
346
- '5.2' => false,
347
- '5.3' => true,
348
- ),
349
- 'stream_context_set_default' => array(
350
- '5.2' => false,
351
- '5.3' => true,
352
- ),
353
- 'stream_supports_lock' => array(
354
- '5.2' => false,
355
- '5.3' => true,
356
- ),
357
- 'stream_context_get_params' => array(
358
- '5.2' => false,
359
- '5.3' => true,
360
- ),
361
- 'date_add' => array(
362
- '5.2' => false,
363
- '5.3' => true,
364
- ),
365
- 'date_create_from_format' => array(
366
- '5.2' => false,
367
- '5.3' => true,
368
- ),
369
- 'date_diff' => array(
370
- '5.2' => false,
371
- '5.3' => true,
372
- ),
373
- 'date_get_last_errors' => array(
374
- '5.2' => false,
375
- '5.3' => true,
376
- ),
377
- 'date_parse_from_format' => array(
378
- '5.2' => false,
379
- '5.3' => true,
380
- ),
381
- 'date_sub' => array(
382
- '5.2' => false,
383
- '5.3' => true,
384
- ),
385
- 'timezone_version_get' => array(
386
- '5.2' => false,
387
- '5.3' => true,
388
- ),
389
- 'gmp_testbit' => array(
390
- '5.2' => false,
391
- '5.3' => true,
392
- ),
393
- 'hash_copy' => array(
394
- '5.2' => false,
395
- '5.3' => true,
396
- ),
397
- 'imap_gc' => array(
398
- '5.2' => false,
399
- '5.3' => true,
400
- ),
401
- 'imap_utf8_to_mutf7' => array(
402
- '5.2' => false,
403
- '5.3' => true,
404
- ),
405
- 'imap_mutf7_to_utf8' => array(
406
- '5.2' => false,
407
- '5.3' => true,
408
- ),
409
- 'json_last_error' => array(
410
- '5.2' => false,
411
- '5.3' => true,
412
- ),
413
- 'mysqli_get_cache_stats' => array(
414
- '5.2' => false,
415
- '5.3' => true,
416
- ),
417
- 'mysqli_fetch_all' => array(
418
- '5.2' => false,
419
- '5.3' => true,
420
- ),
421
- 'mysqli_get_connection_status' => array(
422
- '5.2' => false,
423
- '5.3' => true,
424
- ),
425
- 'mysqli_poll' => array(
426
- '5.2' => false,
427
- '5.3' => true,
428
- ),
429
- 'mysqli_read_async_query' => array(
430
- '5.2' => false,
431
- '5.3' => true,
432
- ),
433
- 'openssl_random_pseudo_bytes' => array(
434
- '5.2' => false,
435
- '5.3' => true,
436
- ),
437
- 'pcntl_signal_dispatch' => array(
438
- '5.2' => false,
439
- '5.3' => true,
440
- ),
441
- 'pcntl_sigprocmask' => array(
442
- '5.2' => false,
443
- '5.3' => true,
444
- ),
445
- 'pcntl_sigtimedwait' => array(
446
- '5.2' => false,
447
- '5.3' => true,
448
- ),
449
- 'pcntl_sigwaitinfo' => array(
450
- '5.2' => false,
451
- '5.3' => true,
452
- ),
453
- 'preg_filter' => array(
454
- '5.2' => false,
455
- '5.3' => true,
456
- ),
457
- 'msg_queue_exists' => array(
458
- '5.2' => false,
459
- '5.3' => true,
460
- ),
461
- 'shm_has_vars' => array(
462
- '5.2' => false,
463
- '5.3' => true,
464
- ),
465
- 'acosh' => array(
466
- '5.2' => false,
467
- '5.3' => true,
468
- ),
469
- 'asinh' => array(
470
- '5.2' => false,
471
- '5.3' => true,
472
- ),
473
- 'atanh' => array(
474
- '5.2' => false,
475
- '5.3' => true,
476
- ),
477
- 'expm1' => array(
478
- '5.2' => false,
479
- '5.3' => true,
480
- ),
481
- 'log1p' => array(
482
- '5.2' => false,
483
- '5.3' => true,
484
- ),
485
- 'enchant_broker_describe' => array(
486
- '5.2' => false,
487
- '5.3' => true,
488
- ),
489
- 'enchant_broker_dict_exists' => array(
490
- '5.2' => false,
491
- '5.3' => true,
492
- ),
493
- 'enchant_broker_free_dict' => array(
494
- '5.2' => false,
495
- '5.3' => true,
496
- ),
497
- 'enchant_broker_free' => array(
498
- '5.2' => false,
499
- '5.3' => true,
500
- ),
501
- 'enchant_broker_get_error' => array(
502
- '5.2' => false,
503
- '5.3' => true,
504
- ),
505
- 'enchant_broker_init' => array(
506
- '5.2' => false,
507
- '5.3' => true,
508
- ),
509
- 'enchant_broker_list_dicts' => array(
510
- '5.2' => false,
511
- '5.3' => true,
512
- ),
513
- 'enchant_broker_request_dict' => array(
514
- '5.2' => false,
515
- '5.3' => true,
516
- ),
517
- 'enchant_broker_request_pwl_dict' => array(
518
- '5.2' => false,
519
- '5.3' => true,
520
- ),
521
- 'enchant_broker_set_ordering' => array(
522
- '5.2' => false,
523
- '5.3' => true,
524
- ),
525
- 'enchant_dict_add_to_personal' => array(
526
- '5.2' => false,
527
- '5.3' => true,
528
- ),
529
- 'enchant_dict_add_to_session' => array(
530
- '5.2' => false,
531
- '5.3' => true,
532
- ),
533
- 'enchant_dict_check' => array(
534
- '5.2' => false,
535
- '5.3' => true,
536
- ),
537
- 'enchant_dict_describe' => array(
538
- '5.2' => false,
539
- '5.3' => true,
540
- ),
541
- 'enchant_dict_get_error' => array(
542
- '5.2' => false,
543
- '5.3' => true,
544
- ),
545
- 'enchant_dict_is_in_session' => array(
546
- '5.2' => false,
547
- '5.3' => true,
548
- ),
549
- 'enchant_dict_quick_check' => array(
550
- '5.2' => false,
551
- '5.3' => true,
552
- ),
553
- 'enchant_dict_store_replacement' => array(
554
- '5.2' => false,
555
- '5.3' => true,
556
- ),
557
- 'enchant_dict_suggest' => array(
558
- '5.2' => false,
559
- '5.3' => true,
560
- ),
561
- 'finfo_buffer' => array(
562
- '5.2' => false,
563
- '5.3' => true,
564
- ),
565
- 'finfo_close' => array(
566
- '5.2' => false,
567
- '5.3' => true,
568
- ),
569
- 'finfo_file' => array(
570
- '5.2' => false,
571
- '5.3' => true,
572
- ),
573
- 'finfo_open' => array(
574
- '5.2' => false,
575
- '5.3' => true,
576
- ),
577
- 'finfo_set_flags' => array(
578
- '5.2' => false,
579
- '5.3' => true,
580
- ),
581
- 'intl_error_name' => array(
582
- '5.2' => false,
583
- '5.3' => true,
584
- ),
585
- 'intl_get_error_code' => array(
586
- '5.2' => false,
587
- '5.3' => true,
588
- ),
589
- 'intl_get_error_message' => array(
590
- '5.2' => false,
591
- '5.3' => true,
592
- ),
593
- 'intl_is_failure' => array(
594
- '5.2' => false,
595
- '5.3' => true,
596
- ),
597
-
598
- 'hex2bin' => array(
599
- '5.3' => false,
600
- '5.4' => true,
601
- ),
602
- 'http_response_code' => array(
603
- '5.3' => false,
604
- '5.4' => true,
605
- ),
606
- 'get_declared_traits' => array(
607
- '5.3' => false,
608
- '5.4' => true,
609
- ),
610
- 'getimagesizefromstring' => array(
611
- '5.3' => false,
612
- '5.4' => true,
613
- ),
614
- 'stream_set_chunk_size' => array(
615
- '5.3' => false,
616
- '5.4' => true,
617
- ),
618
- 'socket_import_stream' => array(
619
- '5.3' => false,
620
- '5.4' => true,
621
- ),
622
- 'trait_exists' => array(
623
- '5.3' => false,
624
- '5.4' => true,
625
- ),
626
- 'header_register_callback' => array(
627
- '5.3' => false,
628
- '5.4' => true,
629
- ),
630
- 'class_uses' => array(
631
- '5.3' => false,
632
- '5.4' => true,
633
- ),
634
- 'session_status' => array(
635
- '5.3' => false,
636
- '5.4' => true,
637
- ),
638
- 'session_register_shutdown' => array(
639
- '5.3' => false,
640
- '5.4' => true,
641
- ),
642
- 'mysqli_error_list' => array(
643
- '5.3' => false,
644
- '5.4' => true,
645
- ),
646
- 'mysqli_stmt_error_list' => array(
647
- '5.3' => false,
648
- '5.4' => true,
649
- ),
650
- 'libxml_set_external_entity_loader' => array(
651
- '5.3' => false,
652
- '5.4' => true,
653
- ),
654
- 'ldap_control_paged_result' => array(
655
- '5.3' => false,
656
- '5.4' => true,
657
- ),
658
- 'ldap_control_paged_result_response' => array(
659
- '5.3' => false,
660
- '5.4' => true,
661
- ),
662
- 'transliteral_create' => array(
663
- '5.3' => false,
664
- '5.4' => true,
665
- ),
666
- 'transliteral_create_from_rules' => array(
667
- '5.3' => false,
668
- '5.4' => true,
669
- ),
670
- 'transliteral_create_inverse' => array(
671
- '5.3' => false,
672
- '5.4' => true,
673
- ),
674
- 'transliteral_get_error_code' => array(
675
- '5.3' => false,
676
- '5.4' => true,
677
- ),
678
- 'transliteral_get_error_message' => array(
679
- '5.3' => false,
680
- '5.4' => true,
681
- ),
682
- 'transliteral_list_ids' => array(
683
- '5.3' => false,
684
- '5.4' => true,
685
- ),
686
- 'transliteral_transliterate' => array(
687
- '5.3' => false,
688
- '5.4' => true,
689
- ),
690
- 'zlib_decode' => array(
691
- '5.3' => false,
692
- '5.4' => true,
693
- ),
694
- 'zlib_encode' => array(
695
- '5.3' => false,
696
- '5.4' => true,
697
- ),
698
-
699
- 'array_column' => array(
700
- '5.4' => false,
701
- '5.5' => true,
702
- ),
703
- 'boolval' => array(
704
- '5.4' => false,
705
- '5.5' => true,
706
- ),
707
- 'json_last_error_msg' => array(
708
- '5.4' => false,
709
- '5.5' => true,
710
- ),
711
- 'password_get_info' => array(
712
- '5.4' => false,
713
- '5.5' => true,
714
- ),
715
- 'password_hash' => array(
716
- '5.4' => false,
717
- '5.5' => true,
718
- ),
719
- 'password_needs_rehash' => array(
720
- '5.4' => false,
721
- '5.5' => true,
722
- ),
723
- 'password_verify' => array(
724
- '5.4' => false,
725
- '5.5' => true,
726
- ),
727
- 'hash_pbkdf2' => array(
728
- '5.4' => false,
729
- '5.5' => true,
730
- ),
731
- 'openssl_pbkdf2' => array(
732
- '5.4' => false,
733
- '5.5' => true,
734
- ),
735
- 'curl_escape' => array(
736
- '5.4' => false,
737
- '5.5' => true,
738
- ),
739
- 'curl_file_create' => array(
740
- '5.4' => false,
741
- '5.5' => true,
742
- ),
743
- 'curl_multi_setopt' => array(
744
- '5.4' => false,
745
- '5.5' => true,
746
- ),
747
- 'curl_multi_strerror' => array(
748
- '5.4' => false,
749
- '5.5' => true,
750
- ),
751
- 'curl_pause' => array(
752
- '5.4' => false,
753
- '5.5' => true,
754
- ),
755
- 'curl_reset' => array(
756
- '5.4' => false,
757
- '5.5' => true,
758
- ),
759
- 'curl_share_close' => array(
760
- '5.4' => false,
761
- '5.5' => true,
762
- ),
763
- 'curl_share_init' => array(
764
- '5.4' => false,
765
- '5.5' => true,
766
- ),
767
- 'curl_share_setopt' => array(
768
- '5.4' => false,
769
- '5.5' => true,
770
- ),
771
- 'curl_strerror' => array(
772
- '5.4' => false,
773
- '5.5' => true,
774
- ),
775
- 'curl_unescape' => array(
776
- '5.4' => false,
777
- '5.5' => true,
778
- ),
779
- 'imageaffinematrixconcat' => array(
780
- '5.4' => false,
781
- '5.5' => true,
782
- ),
783
- 'imageaffinematrixget' => array(
784
- '5.4' => false,
785
- '5.5' => true,
786
- ),
787
- 'imagecrop' => array(
788
- '5.4' => false,
789
- '5.5' => true,
790
- ),
791
- 'imagecropauto' => array(
792
- '5.4' => false,
793
- '5.5' => true,
794
- ),
795
- 'imageflip' => array(
796
- '5.4' => false,
797
- '5.5' => true,
798
- ),
799
- 'imagepalettetotruecolor' => array(
800
- '5.4' => false,
801
- '5.5' => true,
802
- ),
803
- 'imagescale' => array(
804
- '5.4' => false,
805
- '5.5' => true,
806
- ),
807
- 'mysqli_begin_transaction' => array(
808
- '5.4' => false,
809
- '5.5' => true,
810
- ),
811
- 'mysqli_release_savepoint' => array(
812
- '5.4' => false,
813
- '5.5' => true,
814
- ),
815
- 'mysqli_savepoint' => array(
816
- '5.4' => false,
817
- '5.5' => true,
818
- ),
819
- 'pg_escape_literal' => array(
820
- '5.4' => false,
821
- '5.5' => true,
822
- ),
823
- 'pg_escape_identifier' => array(
824
- '5.4' => false,
825
- '5.5' => true,
826
- ),
827
- 'socket_sendmsg' => array(
828
- '5.4' => false,
829
- '5.5' => true,
830
- ),
831
- 'socket_recvmsg' => array(
832
- '5.4' => false,
833
- '5.5' => true,
834
- ),
835
- 'socket_cmsg_space' => array(
836
- '5.4' => false,
837
- '5.5' => true,
838
- ),
839
- 'cli_get_process_title' => array(
840
- '5.4' => false,
841
- '5.5' => true,
842
- ),
843
- 'cli_set_process_title' => array(
844
- '5.4' => false,
845
- '5.5' => true,
846
- ),
847
- 'datefmt_format_object' => array(
848
- '5.4' => false,
849
- '5.5' => true,
850
- ),
851
- 'datefmt_get_calendar_object' => array(
852
- '5.4' => false,
853
- '5.5' => true,
854
- ),
855
- 'datefmt_get_timezone' => array(
856
- '5.4' => false,
857
- '5.5' => true,
858
- ),
859
- 'datefmt_set_timezone' => array(
860
- '5.4' => false,
861
- '5.5' => true,
862
- ),
863
- 'intlcal_create_instance' => array(
864
- '5.4' => false,
865
- '5.5' => true,
866
- ),
867
- 'intlcal_get_keyword_values_for_locale' => array(
868
- '5.4' => false,
869
- '5.5' => true,
870
- ),
871
- 'intlcal_get_now' => array(
872
- '5.4' => false,
873
- '5.5' => true,
874
- ),
875
- 'intlcal_get_available_locales' => array(
876
- '5.4' => false,
877
- '5.5' => true,
878
- ),
879
- 'intlcal_get' => array(
880
- '5.4' => false,
881
- '5.5' => true,
882
- ),
883
- 'intlcal_get_time' => array(
884
- '5.4' => false,
885
- '5.5' => true,
886
- ),
887
- 'intlcal_set_time' => array(
888
- '5.4' => false,
889
- '5.5' => true,
890
- ),
891
- 'intlcal_add' => array(
892
- '5.4' => false,
893
- '5.5' => true,
894
- ),
895
- 'intlcal_set_time_zone' => array(
896
- '5.4' => false,
897
- '5.5' => true,
898
- ),
899
- 'intlcal_after' => array(
900
- '5.4' => false,
901
- '5.5' => true,
902
- ),
903
- 'intlcal_before' => array(
904
- '5.4' => false,
905
- '5.5' => true,
906
- ),
907
- 'intlcal_set' => array(
908
- '5.4' => false,
909
- '5.5' => true,
910
- ),
911
- 'intlcal_roll' => array(
912
- '5.4' => false,
913
- '5.5' => true,
914
- ),
915
- 'intlcal_clear' => array(
916
- '5.4' => false,
917
- '5.5' => true,
918
- ),
919
- 'intlcal_field_difference' => array(
920
- '5.4' => false,
921
- '5.5' => true,
922
- ),
923
- 'intlcal_get_actual_maximum' => array(
924
- '5.4' => false,
925
- '5.5' => true,
926
- ),
927
- 'intlcal_get_actual_minumum' => array(
928
- '5.4' => false,
929
- '5.5' => true,
930
- ),
931
- 'intlcal_get_day_of_week_type' => array(
932
- '5.4' => false,
933
- '5.5' => true,
934
- ),
935
- 'intlcal_get_first_day_of_week' => array(
936
- '5.4' => false,
937
- '5.5' => true,
938
- ),
939
- 'intlcal_get_greatest_minimum' => array(
940
- '5.4' => false,
941
- '5.5' => true,
942
- ),
943
- 'intlcal_get_least_maximum' => array(
944
- '5.4' => false,
945
- '5.5' => true,
946
- ),
947
- 'intlcal_get_locale' => array(
948
- '5.4' => false,
949
- '5.5' => true,
950
- ),
951
- 'intlcal_get_maximum' => array(
952
- '5.4' => false,
953
- '5.5' => true,
954
- ),
955
- 'intlcal_get_minimal_days_in_first_week' => array(
956
- '5.4' => false,
957
- '5.5' => true,
958
- ),
959
- 'intlcal_get_minimum' => array(
960
- '5.4' => false,
961
- '5.5' => true,
962
- ),
963
- 'intlcal_get_time_zone' => array(
964
- '5.4' => false,
965
- '5.5' => true,
966
- ),
967
- 'intlcal_get_type' => array(
968
- '5.4' => false,
969
- '5.5' => true,
970
- ),
971
- 'intlcal_get_weekend_transition' => array(
972
- '5.4' => false,
973
- '5.5' => true,
974
- ),
975
- 'intlcal_in_daylight_time' => array(
976
- '5.4' => false,
977
- '5.5' => true,
978
- ),
979
- 'intlcal_is_equivalent_to' => array(
980
- '5.4' => false,
981
- '5.5' => true,
982
- ),
983
- 'intlcal_is_lenient' => array(
984
- '5.4' => false,
985
- '5.5' => true,
986
- ),
987
- 'intlcal_equals' => array(
988
- '5.4' => false,
989
- '5.5' => true,
990
- ),
991
- 'intlcal_get_repeated_wall_time_option' => array(
992
- '5.4' => false,
993
- '5.5' => true,
994
- ),
995
- 'intlcal_get_skipped_wall_time_option' => array(
996
- '5.4' => false,
997
- '5.5' => true,
998
- ),
999
- 'intlcal_set_repeated_wall_time_option' => array(
1000
- '5.4' => false,
1001
- '5.5' => true,
1002
- ),
1003
- 'intlcal_set_skipped_wall_time_option' => array(
1004
- '5.4' => false,
1005
- '5.5' => true,
1006
- ),
1007
- 'intlcal_from_date_time' => array(
1008
- '5.4' => false,
1009
- '5.5' => true,
1010
- ),
1011
- 'intlcal_to_date_time' => array(
1012
- '5.4' => false,
1013
- '5.5' => true,
1014
- ),
1015
- 'intlcal_get_error_code' => array(
1016
- '5.4' => false,
1017
- '5.5' => true,
1018
- ),
1019
- 'intlcal_get_error_message' => array(
1020
- '5.4' => false,
1021
- '5.5' => true,
1022
- ),
1023
- 'intlgregcal_create_instance' => array(
1024
- '5.4' => false,
1025
- '5.5' => true,
1026
- ),
1027
- 'intlgregcal_set_gregorian_change' => array(
1028
- '5.4' => false,
1029
- '5.5' => true,
1030
- ),
1031
- 'intlgregcal_get_gregorian_change' => array(
1032
- '5.4' => false,
1033
- '5.5' => true,
1034
- ),
1035
- 'intlgregcal_is_leap_year' => array(
1036
- '5.4' => false,
1037
- '5.5' => true,
1038
- ),
1039
- 'intlz_create_time_zone' => array(
1040
- '5.4' => false,
1041
- '5.5' => true,
1042
- ),
1043
- 'intlz_create_default' => array(
1044
- '5.4' => false,
1045
- '5.5' => true,
1046
- ),
1047
- 'intlz_get_id' => array(
1048
- '5.4' => false,
1049
- '5.5' => true,
1050
- ),
1051
- 'intlz_get_gmt' => array(
1052
- '5.4' => false,
1053
- '5.5' => true,
1054
- ),
1055
- 'intlz_get_unknown' => array(
1056
- '5.4' => false,
1057
- '5.5' => true,
1058
- ),
1059
- 'intlz_create_enumeration' => array(
1060
- '5.4' => false,
1061
- '5.5' => true,
1062
- ),
1063
- 'intlz_count_equivalent_ids' => array(
1064
- '5.4' => false,
1065
- '5.5' => true,
1066
- ),
1067
- 'intlz_create_time_zone_id_enumeration' => array(
1068
- '5.4' => false,
1069
- '5.5' => true,
1070
- ),
1071
- 'intlz_get_canonical_id' => array(
1072
- '5.4' => false,
1073
- '5.5' => true,
1074
- ),
1075
- 'intlz_get_region' => array(
1076
- '5.4' => false,
1077
- '5.5' => true,
1078
- ),
1079
- 'intlz_get_tz_data_version' => array(
1080
- '5.4' => false,
1081
- '5.5' => true,
1082
- ),
1083
- 'intlz_get_equivalent_id' => array(
1084
- '5.4' => false,
1085
- '5.5' => true,
1086
- ),
1087
- 'intlz_use_daylight_time' => array(
1088
- '5.4' => false,
1089
- '5.5' => true,
1090
- ),
1091
- 'intlz_get_offset' => array(
1092
- '5.4' => false,
1093
- '5.5' => true,
1094
- ),
1095
- 'intlz_get_raw_offset' => array(
1096
- '5.4' => false,
1097
- '5.5' => true,
1098
- ),
1099
- 'intlz_has_same_rules' => array(
1100
- '5.4' => false,
1101
- '5.5' => true,
1102
- ),
1103
- 'intlz_get_display_name' => array(
1104
- '5.4' => false,
1105
- '5.5' => true,
1106
- ),
1107
- 'intlz_get_dst_savings' => array(
1108
- '5.4' => false,
1109
- '5.5' => true,
1110
- ),
1111
- 'intlz_from_date_time_zone' => array(
1112
- '5.4' => false,
1113
- '5.5' => true,
1114
- ),
1115
- 'intlz_to_date_time_zone' => array(
1116
- '5.4' => false,
1117
- '5.5' => true,
1118
- ),
1119
- 'intlz_get_error_code' => array(
1120
- '5.4' => false,
1121
- '5.5' => true,
1122
- ),
1123
- 'intlz_get_error_message' => array(
1124
- '5.4' => false,
1125
- '5.5' => true,
1126
- ),
1127
- 'opcache_compile_file' => array(
1128
- '5.4' => false,
1129
- '5.5' => true,
1130
- ),
1131
- 'opcache_get_configuration' => array(
1132
- '5.4' => false,
1133
- '5.5' => true,
1134
- ),
1135
- 'opcache_get_status' => array(
1136
- '5.4' => false,
1137
- '5.5' => true,
1138
- ),
1139
- 'opcache_invalidate' => array(
1140
- '5.4' => false,
1141
- '5.5' => true,
1142
- ),
1143
- 'opcache_reset' => array(
1144
- '5.4' => false,
1145
- '5.5' => true,
1146
- ),
1147
-
1148
- 'opcache_is_script_cached' => array(
1149
- '5.5.10' => false,
1150
- '5.5.11' => true,
1151
- ),
1152
-
1153
- 'gmp_root' => array(
1154
- '5.5' => false,
1155
- '5.6' => true,
1156
- ),
1157
- 'gmp_rootrem' => array(
1158
- '5.5' => false,
1159
- '5.6' => true,
1160
- ),
1161
- 'hash_equals' => array(
1162
- '5.5' => false,
1163
- '5.6' => true,
1164
- ),
1165
- 'ldap_escape' => array(
1166
- '5.5' => false,
1167
- '5.6' => true,
1168
- ),
1169
- 'ldap_modify_batch' => array(
1170
- '5.4.25' => false,
1171
- '5.5.9' => false,
1172
- '5.4.26' => true,
1173
- '5.5.10' => true,
1174
- '5.6.0' => true,
1175
- ),
1176
- 'mysqli_get_links_stats' => array(
1177
- '5.5' => false,
1178
- '5.6' => true,
1179
- ),
1180
- 'openssl_get_cert_locations' => array(
1181
- '5.5' => false,
1182
- '5.6' => true,
1183
- ),
1184
- 'openssl_x509_fingerprint' => array(
1185
- '5.5' => false,
1186
- '5.6' => true,
1187
- ),
1188
- 'openssl_spki_new' => array(
1189
- '5.5' => false,
1190
- '5.6' => true,
1191
- ),
1192
- 'openssl_spki_verify' => array(
1193
- '5.5' => false,
1194
- '5.6' => true,
1195
- ),
1196
- 'openssl_spki_export_challenge' => array(
1197
- '5.5' => false,
1198
- '5.6' => true,
1199
- ),
1200
- 'openssl_spki_export' => array(
1201
- '5.5' => false,
1202
- '5.6' => true,
1203
- ),
1204
- 'pg_connect_poll' => array(
1205
- '5.5' => false,
1206
- '5.6' => true,
1207
- ),
1208
- 'pg_consume_input' => array(
1209
- '5.5' => false,
1210
- '5.6' => true,
1211
- ),
1212
- 'pg_flush' => array(
1213
- '5.5' => false,
1214
- '5.6' => true,
1215
- ),
1216
- 'pg_lo_truncate' => array(
1217
- '5.5' => false,
1218
- '5.6' => true,
1219
- ),
1220
- 'pg_socket' => array(
1221
- '5.5' => false,
1222
- '5.6' => true,
1223
- ),
1224
- 'session_abort' => array(
1225
- '5.5' => false,
1226
- '5.6' => true,
1227
- ),
1228
- 'session_reset' => array(
1229
- '5.5' => false,
1230
- '5.6' => true,
1231
- ),
1232
-
1233
- 'random_bytes' => array(
1234
- '5.6' => false,
1235
- '7.0' => true,
1236
- ),
1237
- 'random_int' => array(
1238
- '5.6' => false,
1239
- '7.0' => true,
1240
- ),
1241
- 'error_clear_last' => array(
1242
- '5.6' => false,
1243
- '7.0' => true,
1244
- ),
1245
- 'gmp_random_seed' => array(
1246
- '5.6' => false,
1247
- '7.0' => true,
1248
- ),
1249
- 'intdiv' => array(
1250
- '5.6' => false,
1251
- '7.0' => true,
1252
- ),
1253
- 'preg_replace_callback_array' => array(
1254
- '5.6' => false,
1255
- '7.0' => true,
1256
- ),
1257
- 'gc_mem_caches' => array(
1258
- '5.6' => false,
1259
- '7.0' => true,
1260
- ),
1261
- 'get_resources' => array(
1262
- '5.6' => false,
1263
- '7.0' => true,
1264
- ),
1265
- 'posix_setrlimit' => array(
1266
- '5.6' => false,
1267
- '7.0' => true,
1268
- ),
1269
- 'inflate_add' => array(
1270
- '5.6' => false,
1271
- '7.0' => true,
1272
- ),
1273
- 'deflate_add' => array(
1274
- '5.6' => false,
1275
- '7.0' => true,
1276
- ),
1277
- 'inflate_init' => array(
1278
- '5.6' => false,
1279
- '7.0' => true,
1280
- ),
1281
- 'deflate_init' => array(
1282
- '5.6' => false,
1283
- '7.0' => true,
1284
- ),
1285
-
1286
- 'socket_export_stream' => array(
1287
- '7.0.6' => false,
1288
- '7.0.7' => true,
1289
- ),
1290
-
1291
- 'curl_multi_errno' => array(
1292
- '7.0' => false,
1293
- '7.1' => true,
1294
- ),
1295
- 'curl_share_errno' => array(
1296
- '7.0' => false,
1297
- '7.1' => true,
1298
- ),
1299
- 'curl_share_strerror' => array(
1300
- '7.0' => false,
1301
- '7.1' => true,
1302
- ),
1303
- 'is_iterable' => array(
1304
- '7.0' => false,
1305
- '7.1' => true,
1306
- ),
1307
- 'pcntl_async_signals' => array(
1308
- '7.0' => false,
1309
- '7.1' => true,
1310
- ),
1311
- 'pcntl_signal_get_handler' => array(
1312
- '7.0' => false,
1313
- '7.1' => true,
1314
- ),
1315
- 'session_create_id' => array(
1316
- '7.0' => false,
1317
- '7.1' => true,
1318
- ),
1319
- 'session_gc' => array(
1320
- '7.0' => false,
1321
- '7.1' => true,
1322
- ),
1323
- 'sapi_windows_cp_set' => array(
1324
- '7.0' => false,
1325
- '7.1' => true,
1326
- ),
1327
- 'sapi_windows_cp_get' => array(
1328
- '7.0' => false,
1329
- '7.1' => true,
1330
- ),
1331
- 'sapi_windows_cp_is_utf8' => array(
1332
- '7.0' => false,
1333
- '7.1' => true,
1334
- ),
1335
- 'sapi_windows_cp_conv' => array(
1336
- '7.0' => false,
1337
- '7.1' => true,
1338
- ),
1339
-
1340
- 'hash_hkdf' => array(
1341
- '7.1.1' => false,
1342
- '7.1.2' => true,
1343
- ),
1344
- 'oci_register_taf_callback' => array(
1345
- '7.1.6' => false,
1346
- '7.1.7' => true,
1347
- ),
1348
- 'oci_unregister_taf_callback' => array(
1349
- '7.1.8' => false,
1350
- '7.1.9' => true,
1351
- ),
1352
-
1353
- 'stream_isatty' => array(
1354
- '7.1' => false,
1355
- '7.2' => true,
1356
- ),
1357
- 'sapi_windows_vt100_support' => array(
1358
- '7.1' => false,
1359
- '7.2' => true,
1360
- ),
1361
- 'ftp_append' => array(
1362
- '7.1' => false,
1363
- '7.2' => true,
1364
- ),
1365
- 'hash_hmac_algos' => array(
1366
- '7.1' => false,
1367
- '7.2' => true,
1368
- ),
1369
- 'imagebmp' => array(
1370
- '7.1' => false,
1371
- '7.2' => true,
1372
- ),
1373
- 'imagecreatefrombmp' => array(
1374
- '7.1' => false,
1375
- '7.2' => true,
1376
- ),
1377
- 'imagegetclip' => array(
1378
- '7.1' => false,
1379
- '7.2' => true,
1380
- ),
1381
- 'imageopenpolygon' => array(
1382
- '7.1' => false,
1383
- '7.2' => true,
1384
- ),
1385
- 'imageresolution' => array(
1386
- '7.1' => false,
1387
- '7.2' => true,
1388
- ),
1389
- 'imagesetclip' => array(
1390
- '7.1' => false,
1391
- '7.2' => true,
1392
- ),
1393
- 'ldap_exop' => array(
1394
- '7.1' => false,
1395
- '7.2' => true,
1396
- ),
1397
- 'ldap_exop_passwd' => array(
1398
- '7.1' => false,
1399
- '7.2' => true,
1400
- ),
1401
- 'ldap_exop_whoami' => array(
1402
- '7.1' => false,
1403
- '7.2' => true,
1404
- ),
1405
- 'ldap_parse_exop' => array(
1406
- '7.1' => false,
1407
- '7.2' => true,
1408
- ),
1409
- 'mb_chr' => array(
1410
- '7.1' => false,
1411
- '7.2' => true,
1412
- ),
1413
- 'mb_ord' => array(
1414
- '7.1' => false,
1415
- '7.2' => true,
1416
- ),
1417
- 'mb_scrub' => array(
1418
- '7.1' => false,
1419
- '7.2' => true,
1420
- ),
1421
- 'socket_addrinfo_lookup' => array(
1422
- '7.1' => false,
1423
- '7.2' => true,
1424
- ),
1425
- 'socket_addrinfo_connect' => array(
1426
- '7.1' => false,
1427
- '7.2' => true,
1428
- ),
1429
- 'socket_addrinfo_bind' => array(
1430
- '7.1' => false,
1431
- '7.2' => true,
1432
- ),
1433
- 'socket_addrinfo_explain' => array(
1434
- '7.1' => false,
1435
- '7.2' => true,
1436
- ),
1437
- 'spl_object_id' => array(
1438
- '7.1' => false,
1439
- '7.2' => true,
1440
- ),
1441
- 'sodium_add' => array(
1442
- '7.1' => false,
1443
- '7.2' => true,
1444
- ),
1445
- 'sodium_base642bin' => array(
1446
- '7.1' => false,
1447
- '7.2' => true,
1448
- ),
1449
- 'sodium_bin2base64' => array(
1450
- '7.1' => false,
1451
- '7.2' => true,
1452
- ),
1453
- 'sodium_bin2hex' => array(
1454
- '7.1' => false,
1455
- '7.2' => true,
1456
- ),
1457
- 'sodium_compare' => array(
1458
- '7.1' => false,
1459
- '7.2' => true,
1460
- ),
1461
- 'sodium_crypto_aead_aes256gcm_decrypt' => array(
1462
- '7.1' => false,
1463
- '7.2' => true,
1464
- ),
1465
- 'sodium_crypto_aead_aes256gcm_encrypt' => array(
1466
- '7.1' => false,
1467
- '7.2' => true,
1468
- ),
1469
- 'sodium_crypto_aead_aes256gcm_is_available' => array(
1470
- '7.1' => false,
1471
- '7.2' => true,
1472
- ),
1473
- 'sodium_crypto_aead_aes256gcm_keygen' => array(
1474
- '7.1' => false,
1475
- '7.2' => true,
1476
- ),
1477
- 'sodium_crypto_aead_chacha20poly1305_decrypt' => array(
1478
- '7.1' => false,
1479
- '7.2' => true,
1480
- ),
1481
- 'sodium_crypto_aead_chacha20poly1305_encrypt' => array(
1482
- '7.1' => false,
1483
- '7.2' => true,
1484
- ),
1485
- 'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => array(
1486
- '7.1' => false,
1487
- '7.2' => true,
1488
- ),
1489
- 'sodium_crypto_aead_chacha20poly1305_ietf_encrypt' => array(
1490
- '7.1' => false,
1491
- '7.2' => true,
1492
- ),
1493
- 'sodium_crypto_aead_chacha20poly1305_ietf_keygen' => array(
1494
- '7.1' => false,
1495
- '7.2' => true,
1496
- ),
1497
- 'sodium_crypto_aead_chacha20poly1305_keygen' => array(
1498
- '7.1' => false,
1499
- '7.2' => true,
1500
- ),
1501
- 'sodium_crypto_aead_xchacha20poly1305_ietf_decrypt' => array(
1502
- '7.1' => false,
1503
- '7.2' => true,
1504
- ),
1505
- 'sodium_crypto_aead_xchacha20poly1305_ietf_encrypt' => array(
1506
- '7.1' => false,
1507
- '7.2' => true,
1508
- ),
1509
- 'sodium_crypto_aead_xchacha20poly1305_ietf_keygen' => array(
1510
- '7.1' => false,
1511
- '7.2' => true,
1512
- ),
1513
- 'sodium_crypto_auth_keygen' => array(
1514
- '7.1' => false,
1515
- '7.2' => true,
1516
- ),
1517
- 'sodium_crypto_auth_verify' => array(
1518
- '7.1' => false,
1519
- '7.2' => true,
1520
- ),
1521
- 'sodium_crypto_auth' => array(
1522
- '7.1' => false,
1523
- '7.2' => true,
1524
- ),
1525
- 'sodium_crypto_box_keypair_from_secretkey_and_publickey' => array(
1526
- '7.1' => false,
1527
- '7.2' => true,
1528
- ),
1529
- 'sodium_crypto_box_keypair' => array(
1530
- '7.1' => false,
1531
- '7.2' => true,
1532
- ),
1533
- 'sodium_crypto_box_open' => array(
1534
- '7.1' => false,
1535
- '7.2' => true,
1536
- ),
1537
- 'sodium_crypto_box_publickey_from_secretkey' => array(
1538
- '7.1' => false,
1539
- '7.2' => true,
1540
- ),
1541
- 'sodium_crypto_box_publickey' => array(
1542
- '7.1' => false,
1543
- '7.2' => true,
1544
- ),
1545
- 'sodium_crypto_box_seal_open' => array(
1546
- '7.1' => false,
1547
- '7.2' => true,
1548
- ),
1549
- 'sodium_crypto_box_seal' => array(
1550
- '7.1' => false,
1551
- '7.2' => true,
1552
- ),
1553
- 'sodium_crypto_box_secretkey' => array(
1554
- '7.1' => false,
1555
- '7.2' => true,
1556
- ),
1557
- 'sodium_crypto_box_seed_keypair' => array(
1558
- '7.1' => false,
1559
- '7.2' => true,
1560
- ),
1561
- 'sodium_crypto_box' => array(
1562
- '7.1' => false,
1563
- '7.2' => true,
1564
- ),
1565
- 'sodium_crypto_generichash_final' => array(
1566
- '7.1' => false,
1567
- '7.2' => true,
1568
- ),
1569
- 'sodium_crypto_generichash_init' => array(
1570
- '7.1' => false,
1571
- '7.2' => true,
1572
- ),
1573
- 'sodium_crypto_generichash_keygen' => array(
1574
- '7.1' => false,
1575
- '7.2' => true,
1576
- ),
1577
- 'sodium_crypto_generichash_update' => array(
1578
- '7.1' => false,
1579
- '7.2' => true,
1580
- ),
1581
- 'sodium_crypto_generichash' => array(
1582
- '7.1' => false,
1583
- '7.2' => true,
1584
- ),
1585
- 'sodium_crypto_kdf_derive_from_key' => array(
1586
- '7.1' => false,
1587
- '7.2' => true,
1588
- ),
1589
- 'sodium_crypto_kdf_keygen' => array(
1590
- '7.1' => false,
1591
- '7.2' => true,
1592
- ),
1593
- 'sodium_crypto_kx_client_session_keys' => array(
1594
- '7.1' => false,
1595
- '7.2' => true,
1596
- ),
1597
- 'sodium_crypto_kx_keypair' => array(
1598
- '7.1' => false,
1599
- '7.2' => true,
1600
- ),
1601
- 'sodium_crypto_kx_publickey' => array(
1602
- '7.1' => false,
1603
- '7.2' => true,
1604
- ),
1605
- 'sodium_crypto_kx_secretkey' => array(
1606
- '7.1' => false,
1607
- '7.2' => true,
1608
- ),
1609
- 'sodium_crypto_kx_seed_keypair' => array(
1610
- '7.1' => false,
1611
- '7.2' => true,
1612
- ),
1613
- 'sodium_crypto_kx_server_session_keys' => array(
1614
- '7.1' => false,
1615
- '7.2' => true,
1616
- ),
1617
- 'sodium_crypto_pwhash_scryptsalsa208sha256_str_verify' => array(
1618
- '7.1' => false,
1619
- '7.2' => true,
1620
- ),
1621
- 'sodium_crypto_pwhash_scryptsalsa208sha256_str' => array(
1622
- '7.1' => false,
1623
- '7.2' => true,
1624
- ),
1625
- 'sodium_crypto_pwhash_scryptsalsa208sha256' => array(
1626
- '7.1' => false,
1627
- '7.2' => true,
1628
- ),
1629
- 'sodium_crypto_pwhash_str_needs_rehash' => array(
1630
- '7.1' => false,
1631
- '7.2' => true,
1632
- ),
1633
- 'sodium_crypto_pwhash_str_verify' => array(
1634
- '7.1' => false,
1635
- '7.2' => true,
1636
- ),
1637
- 'sodium_crypto_pwhash_str' => array(
1638
- '7.1' => false,
1639
- '7.2' => true,
1640
- ),
1641
- 'sodium_crypto_pwhash' => array(
1642
- '7.1' => false,
1643
- '7.2' => true,
1644
- ),
1645
- 'sodium_crypto_scalarmult_base' => array(
1646
- '7.1' => false,
1647
- '7.2' => true,
1648
- ),
1649
- 'sodium_crypto_scalarmult' => array(
1650
- '7.1' => false,
1651
- '7.2' => true,
1652
- ),
1653
- 'sodium_crypto_secretbox_keygen' => array(
1654
- '7.1' => false,
1655
- '7.2' => true,
1656
- ),
1657
- 'sodium_crypto_secretbox_open' => array(
1658
- '7.1' => false,
1659
- '7.2' => true,
1660
- ),
1661
- 'sodium_crypto_secretbox' => array(
1662
- '7.1' => false,
1663
- '7.2' => true,
1664
- ),
1665
- 'sodium_crypto_secretstream_xchacha20poly1305_init_pull' => array(
1666
- '7.1' => false,
1667
- '7.2' => true,
1668
- ),
1669
- 'sodium_crypto_secretstream_xchacha20poly1305_init_push' => array(
1670
- '7.1' => false,
1671
- '7.2' => true,
1672
- ),
1673
- 'sodium_crypto_secretstream_xchacha20poly1305_keygen' => array(
1674
- '7.1' => false,
1675
- '7.2' => true,
1676
- ),
1677
- 'sodium_crypto_secretstream_xchacha20poly1305_pull' => array(
1678
- '7.1' => false,
1679
- '7.2' => true,
1680
- ),
1681
- 'sodium_crypto_secretstream_xchacha20poly1305_push' => array(
1682
- '7.1' => false,
1683
- '7.2' => true,
1684
- ),
1685
- 'sodium_crypto_secretstream_xchacha20poly1305_rekey' => array(
1686
- '7.1' => false,
1687
- '7.2' => true,
1688
- ),
1689
- 'sodium_crypto_shorthash_keygen' => array(
1690
- '7.1' => false,
1691
- '7.2' => true,
1692
- ),
1693
- 'sodium_crypto_shorthash' => array(
1694
- '7.1' => false,
1695
- '7.2' => true,
1696
- ),
1697
- 'sodium_crypto_sign_detached' => array(
1698
- '7.1' => false,
1699
- '7.2' => true,
1700
- ),
1701
- 'sodium_crypto_sign_ed25519_pk_to_curve25519' => array(
1702
- '7.1' => false,
1703
- '7.2' => true,
1704
- ),
1705
- 'sodium_crypto_sign_ed25519_sk_to_curve25519' => array(
1706
- '7.1' => false,
1707
- '7.2' => true,
1708
- ),
1709
- 'sodium_crypto_sign_keypair_from_secretkey_and_publickey' => array(
1710
- '7.1' => false,
1711
- '7.2' => true,
1712
- ),
1713
- 'sodium_crypto_sign_keypair' => array(
1714
- '7.1' => false,
1715
- '7.2' => true,
1716
- ),
1717
- 'sodium_crypto_sign_open' => array(
1718
- '7.1' => false,
1719
- '7.2' => true,
1720
- ),
1721
- 'sodium_crypto_sign_publickey_from_secretkey' => array(
1722
- '7.1' => false,
1723
- '7.2' => true,
1724
- ),
1725
- 'sodium_crypto_sign_publickey' => array(
1726
- '7.1' => false,
1727
- '7.2' => true,
1728
- ),
1729
- 'sodium_crypto_sign_secretkey' => array(
1730
- '7.1' => false,
1731
- '7.2' => true,
1732
- ),
1733
- 'sodium_crypto_sign_seed_keypair' => array(
1734
- '7.1' => false,
1735
- '7.2' => true,
1736
- ),
1737
- 'sodium_crypto_sign_verify_detached' => array(
1738
- '7.1' => false,
1739
- '7.2' => true,
1740
- ),
1741
- 'sodium_crypto_sign' => array(
1742
- '7.1' => false,
1743
- '7.2' => true,
1744
- ),
1745
- 'sodium_crypto_stream_keygen' => array(
1746
- '7.1' => false,
1747
- '7.2' => true,
1748
- ),
1749
- 'sodium_crypto_stream_xor' => array(
1750
- '7.1' => false,
1751
- '7.2' => true,
1752
- ),
1753
- 'sodium_crypto_stream' => array(
1754
- '7.1' => false,
1755
- '7.2' => true,
1756
- ),
1757
- 'sodium_hex2bin' => array(
1758
- '7.1' => false,
1759
- '7.2' => true,
1760
- ),
1761
- 'sodium_increment' => array(
1762
- '7.1' => false,
1763
- '7.2' => true,
1764
- ),
1765
- 'sodium_memcmp' => array(
1766
- '7.1' => false,
1767
- '7.2' => true,
1768
- ),
1769
- 'sodium_memzero' => array(
1770
- '7.1' => false,
1771
- '7.2' => true,
1772
- ),
1773
- 'sodium_pad' => array(
1774
- '7.1' => false,
1775
- '7.2' => true,
1776
- ),
1777
- 'sodium_unpad' => array(
1778
- '7.1' => false,
1779
- '7.2' => true,
1780
- ),
1781
- // Introduced in 7.2.14 and 7.3.1 simultanously.
1782
- 'oci_set_call_timeout' => array(
1783
- '7.2.13' => false,
1784
- '7.2.14' => true,
1785
- ),
1786
- // Introduced in 7.2.14 and 7.3.1 simultanously.
1787
- 'oci_set_db_operation' => array(
1788
- '7.2.13' => false,
1789
- '7.2.14' => true,
1790
- ),
1791
-
1792
- 'hrtime' => array(
1793
- '7.2' => false,
1794
- '7.3' => true,
1795
- ),
1796
- 'is_countable' => array(
1797
- '7.2' => false,
1798
- '7.3' => true,
1799
- ),
1800
- 'array_key_first' => array(
1801
- '7.2' => false,
1802
- '7.3' => true,
1803
- ),
1804
- 'array_key_last' => array(
1805
- '7.2' => false,
1806
- '7.3' => true,
1807
- ),
1808
- 'fpm_get_status' => array(
1809
- '7.2' => false,
1810
- '7.3' => true,
1811
- ),
1812
- 'net_get_interfaces' => array(
1813
- '7.2' => false,
1814
- '7.3' => true,
1815
- ),
1816
- 'gmp_binomial' => array(
1817
- '7.2' => false,
1818
- '7.3' => true,
1819
- ),
1820
- 'gmp_lcm' => array(
1821
- '7.2' => false,
1822
- '7.3' => true,
1823
- ),
1824
- 'gmp_perfect_power' => array(
1825
- '7.2' => false,
1826
- '7.3' => true,
1827
- ),
1828
- 'gmp_kronecker' => array(
1829
- '7.2' => false,
1830
- '7.3' => true,
1831
- ),
1832
- 'ldap_add_ext' => array(
1833
- '7.2' => false,
1834
- '7.3' => true,
1835
- ),
1836
- 'ldap_bind_ext' => array(
1837
- '7.2' => false,
1838
- '7.3' => true,
1839
- ),
1840
- 'ldap_delete_ext' => array(
1841
- '7.2' => false,
1842
- '7.3' => true,
1843
- ),
1844
- 'ldap_exop_refresh' => array(
1845
- '7.2' => false,
1846
- '7.3' => true,
1847
- ),
1848
- 'ldap_mod_add_ext' => array(
1849
- '7.2' => false,
1850
- '7.3' => true,
1851
- ),
1852
- 'ldap_mod_replace_ext' => array(
1853
- '7.2' => false,
1854
- '7.3' => true,
1855
- ),
1856
- 'ldap_mod_del_ext' => array(
1857
- '7.2' => false,
1858
- '7.3' => true,
1859
- ),
1860
- 'ldap_rename_ext' => array(
1861
- '7.2' => false,
1862
- '7.3' => true,
1863
- ),
1864
- 'normalizer_get_raw_decomposition' => array(
1865
- '7.2' => false,
1866
- '7.3' => true,
1867
- ),
1868
- 'openssl_pkey_derive' => array(
1869
- '7.2' => false,
1870
- '7.3' => true,
1871
- ),
1872
- 'socket_wsaprotocol_info_export' => array(
1873
- '7.2' => false,
1874
- '7.3' => true,
1875
- ),
1876
- 'socket_wsaprotocol_info_import' => array(
1877
- '7.2' => false,
1878
- '7.3' => true,
1879
- ),
1880
- 'socket_wsaprotocol_info_release' => array(
1881
- '7.2' => false,
1882
- '7.3' => true,
1883
- ),
1884
-
1885
- 'get_mangled_object_vars' => array(
1886
- '7.3' => false,
1887
- '7.4' => true,
1888
- ),
1889
- 'imagecreatefromtga' => array(
1890
- '7.3' => false,
1891
- '7.4' => true,
1892
- ),
1893
- 'mb_str_split' => array(
1894
- '7.3' => false,
1895
- '7.4' => true,
1896
- ),
1897
- 'openssl_x509_verify' => array(
1898
- '7.3' => false,
1899
- '7.4' => true,
1900
- ),
1901
- 'password_algos' => array(
1902
- '7.3' => false,
1903
- '7.4' => true,
1904
- ),
1905
- 'pcntl_unshare' => array(
1906
- '7.3' => false,
1907
- '7.4' => true,
1908
- ),
1909
- 'sapi_windows_set_ctrl_handler' => array(
1910
- '7.3' => false,
1911
- '7.4' => true,
1912
- ),
1913
- 'sapi_windows_generate_ctrl_event' => array(
1914
- '7.3' => false,
1915
- '7.4' => true,
1916
- ),
1917
- );
1918
-
1919
-
1920
- /**
1921
- * Returns an array of tokens this test wants to listen for.
1922
- *
1923
- * @since 5.6
1924
- *
1925
- * @return array
1926
- */
1927
- public function register()
1928
- {
1929
- // Handle case-insensitivity of function names.
1930
- $this->newFunctions = $this->arrayKeysToLowercase($this->newFunctions);
1931
-
1932
- return array(\T_STRING);
1933
- }
1934
-
1935
- /**
1936
- * Processes this test, when one of its tokens is encountered.
1937
- *
1938
- * @since 5.5
1939
- *
1940
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1941
- * @param int $stackPtr The position of the current token in
1942
- * the stack passed in $tokens.
1943
- *
1944
- * @return void
1945
- */
1946
- public function process(File $phpcsFile, $stackPtr)
1947
- {
1948
- $tokens = $phpcsFile->getTokens();
1949
-
1950
- $ignore = array(
1951
- \T_DOUBLE_COLON => true,
1952
- \T_OBJECT_OPERATOR => true,
1953
- \T_FUNCTION => true,
1954
- \T_CONST => true,
1955
- );
1956
-
1957
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
1958
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
1959
- // Not a call to a PHP function.
1960
- return;
1961
-
1962
- } elseif ($tokens[$prevToken]['code'] === \T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === \T_STRING) {
1963
- // Namespaced function.
1964
- return;
1965
- }
1966
-
1967
- $function = $tokens[$stackPtr]['content'];
1968
- $functionLc = strtolower($function);
1969
-
1970
- if (isset($this->newFunctions[$functionLc]) === false) {
1971
- return;
1972
- }
1973
-
1974
- $itemInfo = array(
1975
- 'name' => $function,
1976
- 'nameLc' => $functionLc,
1977
- );
1978
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
1979
- }
1980
-
1981
-
1982
- /**
1983
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
1984
- *
1985
- * @since 7.1.0
1986
- *
1987
- * @param array $itemInfo Base information about the item.
1988
- *
1989
- * @return array Version and other information about the item.
1990
- */
1991
- public function getItemArray(array $itemInfo)
1992
- {
1993
- return $this->newFunctions[$itemInfo['nameLc']];
1994
- }
1995
-
1996
-
1997
- /**
1998
- * Get the error message template for this sniff.
1999
- *
2000
- * @since 7.1.0
2001
- *
2002
- * @return string
2003
- */
2004
- protected function getErrorMsgTemplate()
2005
- {
2006
- return 'The function %s() is not present in PHP version %s or earlier';
2007
- }
2008
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/OptionalToRequiredFunctionParametersSniff.php DELETED
@@ -1,173 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect missing required function parameters in calls to native PHP functions.
18
- *
19
- * Specifically when those function parameters used to be optional in older PHP versions.
20
- *
21
- * PHP version All
22
- *
23
- * @link https://www.php.net/manual/en/doc.changelog.php
24
- *
25
- * @since 8.1.0
26
- * @since 9.0.0 Renamed from `OptionalRequiredFunctionParametersSniff` to `OptionalToRequiredFunctionParametersSniff`.
27
- */
28
- class OptionalToRequiredFunctionParametersSniff extends RequiredToOptionalFunctionParametersSniff
29
- {
30
-
31
- /**
32
- * A list of function parameters, which were optional in older versions and became required later on.
33
- *
34
- * The array lists : version number with true (required) and false (optional use deprecated).
35
- *
36
- * The index is the location of the parameter in the parameter list, starting at 0 !
37
- * If's sufficient to list the last version in which the parameter was not yet required.
38
- *
39
- * @since 8.1.0
40
- *
41
- * @var array
42
- */
43
- protected $functionParameters = array(
44
- // Special case, the optional nature is not deprecated, but usage is recommended
45
- // and leaving the parameter out will throw an E_NOTICE.
46
- 'crypt' => array(
47
- 1 => array(
48
- 'name' => 'salt',
49
- '5.6' => 'recommended',
50
- ),
51
- ),
52
- 'parse_str' => array(
53
- 1 => array(
54
- 'name' => 'result',
55
- '7.2' => false,
56
- ),
57
- ),
58
- );
59
-
60
-
61
- /**
62
- * Determine whether an error/warning should be thrown for an item based on collected information.
63
- *
64
- * @since 8.1.0
65
- *
66
- * @param array $errorInfo Detail information about an item.
67
- *
68
- * @return bool
69
- */
70
- protected function shouldThrowError(array $errorInfo)
71
- {
72
- return ($errorInfo['optionalDeprecated'] !== ''
73
- || $errorInfo['optionalRemoved'] !== ''
74
- || $errorInfo['optionalRecommended'] !== '');
75
- }
76
-
77
-
78
- /**
79
- * Retrieve the relevant detail (version) information for use in an error message.
80
- *
81
- * @since 8.1.0
82
- *
83
- * @param array $itemArray Version and other information about the item.
84
- * @param array $itemInfo Base information about the item.
85
- *
86
- * @return array
87
- */
88
- public function getErrorInfo(array $itemArray, array $itemInfo)
89
- {
90
- $errorInfo = array(
91
- 'paramName' => '',
92
- 'optionalRecommended' => '',
93
- 'optionalDeprecated' => '',
94
- 'optionalRemoved' => '',
95
- 'error' => false,
96
- );
97
-
98
- $versionArray = $this->getVersionArray($itemArray);
99
-
100
- if (empty($versionArray) === false) {
101
- foreach ($versionArray as $version => $required) {
102
- if ($this->supportsAbove($version) === true) {
103
- if ($required === true && $errorInfo['optionalRemoved'] === '') {
104
- $errorInfo['optionalRemoved'] = $version;
105
- $errorInfo['error'] = true;
106
- } elseif ($required === 'recommended' && $errorInfo['optionalRecommended'] === '') {
107
- $errorInfo['optionalRecommended'] = $version;
108
- } elseif ($errorInfo['optionalDeprecated'] === '') {
109
- $errorInfo['optionalDeprecated'] = $version;
110
- }
111
- }
112
- }
113
- }
114
-
115
- $errorInfo['paramName'] = $itemArray['name'];
116
-
117
- return $errorInfo;
118
- }
119
-
120
-
121
- /**
122
- * Generates the error or warning for this item.
123
- *
124
- * @since 8.1.0
125
- *
126
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
127
- * @param int $stackPtr The position of the relevant token in
128
- * the stack.
129
- * @param array $itemInfo Base information about the item.
130
- * @param array $errorInfo Array with detail (version) information
131
- * relevant to the item.
132
- *
133
- * @return void
134
- */
135
- public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
136
- {
137
- $error = 'The "%s" parameter for function %s() is missing. Passing this parameter is ';
138
- if ($errorInfo['optionalRecommended'] === '') {
139
- $error .= 'no longer optional. The optional nature of the parameter is ';
140
- } else {
141
- $error .= 'strongly recommended ';
142
- }
143
-
144
- $errorCode = $this->stringToErrorCode($itemInfo['name'] . '_' . $errorInfo['paramName']);
145
- $data = array(
146
- $errorInfo['paramName'],
147
- $itemInfo['name'],
148
- );
149
-
150
- if ($errorInfo['optionalRecommended'] !== '') {
151
- $error .= 'since PHP %s ';
152
- $errorCode .= 'SoftRecommended';
153
- $data[] = $errorInfo['optionalRecommended'];
154
- } else {
155
- if ($errorInfo['optionalDeprecated'] !== '') {
156
- $error .= 'deprecated since PHP %s and ';
157
- $errorCode .= 'SoftRequired';
158
- $data[] = $errorInfo['optionalDeprecated'];
159
- }
160
-
161
- if ($errorInfo['optionalRemoved'] !== '') {
162
- $error .= 'removed since PHP %s and ';
163
- $errorCode .= 'HardRequired';
164
- $data[] = $errorInfo['optionalRemoved'];
165
- }
166
-
167
- // Remove the last 'and' from the message.
168
- $error = substr($error, 0, (\strlen($error) - 5));
169
- }
170
-
171
- $this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
172
- }
173
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionParametersSniff.php DELETED
@@ -1,292 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\AbstractRemovedFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect use of deprecated/removed function parameters in calls to native PHP functions.
19
- *
20
- * PHP version All
21
- *
22
- * @link https://www.php.net/manual/en/doc.changelog.php
23
- *
24
- * @since 7.0.0
25
- * @since 7.1.0 Now extends the `AbstractRemovedFeatureSniff` instead of the base `Sniff` class.
26
- */
27
- class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff
28
- {
29
- /**
30
- * A list of removed function parameters, which were present in older versions.
31
- *
32
- * The array lists : version number with false (deprecated) and true (removed).
33
- * The index is the location of the parameter in the parameter list, starting at 0 !
34
- * If's sufficient to list the first version where the function parameter was deprecated/removed.
35
- *
36
- * The optional `callback` key can be used to pass a method name which should be called for an
37
- * additional check. The method will be passed the parameter info and should return true
38
- * if the notice should be thrown or false otherwise.
39
- *
40
- * @since 7.0.0
41
- * @since 7.0.2 Visibility changed from `public` to `protected`.
42
- * @since 9.3.0 Optional `callback` key.
43
- *
44
- * @var array
45
- */
46
- protected $removedFunctionParameters = array(
47
- 'curl_version' => array(
48
- 0 => array(
49
- 'name' => 'age',
50
- '7.4' => false,
51
- 'callback' => 'curlVersionInvalidValue',
52
- ),
53
- ),
54
- 'define' => array(
55
- 2 => array(
56
- 'name' => 'case_insensitive',
57
- '7.3' => false, // Slated for removal in PHP 8.0.0.
58
- ),
59
- ),
60
- 'gmmktime' => array(
61
- 6 => array(
62
- 'name' => 'is_dst',
63
- '5.1' => false,
64
- '7.0' => true,
65
- ),
66
- ),
67
- 'ldap_first_attribute' => array(
68
- 2 => array(
69
- 'name' => 'ber_identifier',
70
- '5.2.4' => true,
71
- ),
72
- ),
73
- 'ldap_next_attribute' => array(
74
- 2 => array(
75
- 'name' => 'ber_identifier',
76
- '5.2.4' => true,
77
- ),
78
- ),
79
- 'mktime' => array(
80
- 6 => array(
81
- 'name' => 'is_dst',
82
- '5.1' => false,
83
- '7.0' => true,
84
- ),
85
- ),
86
- );
87
-
88
-
89
- /**
90
- * Returns an array of tokens this test wants to listen for.
91
- *
92
- * @since 7.0.0
93
- *
94
- * @return array
95
- */
96
- public function register()
97
- {
98
- // Handle case-insensitivity of function names.
99
- $this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters);
100
-
101
- return array(\T_STRING);
102
- }
103
-
104
- /**
105
- * Processes this test, when one of its tokens is encountered.
106
- *
107
- * @since 7.0.0
108
- *
109
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
110
- * @param int $stackPtr The position of the current token in
111
- * the stack passed in $tokens.
112
- *
113
- * @return void
114
- */
115
- public function process(File $phpcsFile, $stackPtr)
116
- {
117
- $tokens = $phpcsFile->getTokens();
118
-
119
- $ignore = array(
120
- \T_DOUBLE_COLON => true,
121
- \T_OBJECT_OPERATOR => true,
122
- \T_FUNCTION => true,
123
- \T_CONST => true,
124
- );
125
-
126
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
127
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
128
- // Not a call to a PHP function.
129
- return;
130
- }
131
-
132
- $function = $tokens[$stackPtr]['content'];
133
- $functionLc = strtolower($function);
134
-
135
- if (isset($this->removedFunctionParameters[$functionLc]) === false) {
136
- return;
137
- }
138
-
139
- $parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
140
- $parameterCount = \count($parameters);
141
- if ($parameterCount === 0) {
142
- return;
143
- }
144
-
145
- // If the parameter count returned > 0, we know there will be valid open parenthesis.
146
- $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
147
- $parameterOffsetFound = $parameterCount - 1;
148
-
149
- foreach ($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) {
150
- if ($offset <= $parameterOffsetFound) {
151
- if (isset($parameterDetails['callback']) && method_exists($this, $parameterDetails['callback'])) {
152
- if ($this->{$parameterDetails['callback']}($phpcsFile, $parameters[($offset + 1)]) === false) {
153
- continue;
154
- }
155
- }
156
-
157
- $itemInfo = array(
158
- 'name' => $function,
159
- 'nameLc' => $functionLc,
160
- 'offset' => $offset,
161
- );
162
- $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
163
- }
164
- }
165
- }
166
-
167
-
168
- /**
169
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
170
- *
171
- * @since 7.1.0
172
- *
173
- * @param array $itemInfo Base information about the item.
174
- *
175
- * @return array Version and other information about the item.
176
- */
177
- public function getItemArray(array $itemInfo)
178
- {
179
- return $this->removedFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
180
- }
181
-
182
-
183
- /**
184
- * Get an array of the non-PHP-version array keys used in a sub-array.
185
- *
186
- * @since 7.1.0
187
- *
188
- * @return array
189
- */
190
- protected function getNonVersionArrayKeys()
191
- {
192
- return array('name', 'callback');
193
- }
194
-
195
-
196
- /**
197
- * Retrieve the relevant detail (version) information for use in an error message.
198
- *
199
- * @since 7.1.0
200
- *
201
- * @param array $itemArray Version and other information about the item.
202
- * @param array $itemInfo Base information about the item.
203
- *
204
- * @return array
205
- */
206
- public function getErrorInfo(array $itemArray, array $itemInfo)
207
- {
208
- $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
209
- $errorInfo['paramName'] = $itemArray['name'];
210
-
211
- return $errorInfo;
212
- }
213
-
214
-
215
- /**
216
- * Get the item name to be used for the creation of the error code.
217
- *
218
- * @since 7.1.0
219
- *
220
- * @param array $itemInfo Base information about the item.
221
- * @param array $errorInfo Detail information about an item.
222
- *
223
- * @return string
224
- */
225
- protected function getItemName(array $itemInfo, array $errorInfo)
226
- {
227
- return $itemInfo['name'] . '_' . $errorInfo['paramName'];
228
- }
229
-
230
-
231
- /**
232
- * Get the error message template for this sniff.
233
- *
234
- * @since 7.1.0
235
- *
236
- * @return string
237
- */
238
- protected function getErrorMsgTemplate()
239
- {
240
- return 'The "%s" parameter for function %s() is ';
241
- }
242
-
243
-
244
- /**
245
- * Filter the error data before it's passed to PHPCS.
246
- *
247
- * @since 7.1.0
248
- *
249
- * @param array $data The error data array which was created.
250
- * @param array $itemInfo Base information about the item this error message applies to.
251
- * @param array $errorInfo Detail information about an item this error message applies to.
252
- *
253
- * @return array
254
- */
255
- protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
256
- {
257
- array_shift($data);
258
- array_unshift($data, $errorInfo['paramName'], $itemInfo['name']);
259
- return $data;
260
- }
261
-
262
- /**
263
- * Check whether curl_version() was passed the default CURLVERSION_NOW.
264
- *
265
- * @since 9.3.0
266
- *
267
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
268
- * @param array $parameter Parameter info array.
269
- *
270
- * @return bool True if the value was not CURLVERSION_NOW, false otherwise.
271
- */
272
- protected function curlVersionInvalidValue(File $phpcsFile, array $parameter)
273
- {
274
- $tokens = $phpcsFile->getTokens();
275
- $raw = '';
276
- for ($i = $parameter['start']; $i <= $parameter['end']; $i++) {
277
- if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
278
- continue;
279
- }
280
-
281
- $raw .= $tokens[$i]['content'];
282
- }
283
-
284
- if ($raw !== 'CURLVERSION_NOW'
285
- && $raw !== (string) \CURLVERSION_NOW
286
- ) {
287
- return true;
288
- }
289
-
290
- return false;
291
- }
292
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionsSniff.php DELETED
@@ -1,1104 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\AbstractRemovedFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect calls to deprecated/removed native PHP functions.
18
- *
19
- * Suggests alternative if available.
20
- *
21
- * PHP version All
22
- *
23
- * @since 5.5
24
- * @since 5.6 Now extends the base `Sniff` class instead of the upstream
25
- * `Generic.PHP.ForbiddenFunctions` sniff.
26
- * @since 7.1.0 Now extends the `AbstractRemovedFeatureSniff` instead of the base `Sniff` class.
27
- * @since 9.0.0 Renamed from `DeprecatedFunctionsSniff` to `RemovedFunctionsSniff`.
28
- */
29
- class RemovedFunctionsSniff extends AbstractRemovedFeatureSniff
30
- {
31
- /**
32
- * A list of deprecated and removed functions with their alternatives.
33
- *
34
- * The array lists : version number with false (deprecated) or true (removed) and an alternative function.
35
- * If no alternative exists, it is NULL, i.e, the function should just not be used.
36
- *
37
- * @since 5.5
38
- * @since 5.6 Visibility changed from `protected` to `public`.
39
- * @since 7.0.2 Visibility changed back from `public` to `protected`.
40
- * The earlier change was made to be in line with the upstream sniff,
41
- * but that sniff is no longer being extended.
42
- * @since 7.0.8 Property renamed from `$forbiddenFunctions` to `$removedFunctions`.
43
- *
44
- * @var array(string => array(string => bool|string|null))
45
- */
46
- protected $removedFunctions = array(
47
- 'php_check_syntax' => array(
48
- '5.0.5' => true,
49
- 'alternative' => null,
50
- ),
51
-
52
- 'pfpro_cleanup' => array(
53
- '5.1' => true,
54
- 'alternative' => null,
55
- ),
56
- 'pfpro_init' => array(
57
- '5.1' => true,
58
- 'alternative' => null,
59
- ),
60
- 'pfpro_process_raw' => array(
61
- '5.1' => true,
62
- 'alternative' => null,
63
- ),
64
- 'pfpro_process' => array(
65
- '5.1' => true,
66
- 'alternative' => null,
67
- ),
68
- 'pfpro_version' => array(
69
- '5.1' => true,
70
- 'alternative' => null,
71
- ),
72
-
73
- 'call_user_method' => array(
74
- '5.3' => false,
75
- '7.0' => true,
76
- 'alternative' => 'call_user_func()',
77
- ),
78
- 'call_user_method_array' => array(
79
- '5.3' => false,
80
- '7.0' => true,
81
- 'alternative' => 'call_user_func_array()',
82
- ),
83
- 'define_syslog_variables' => array(
84
- '5.3' => false,
85
- '5.4' => true,
86
- 'alternative' => null,
87
- ),
88
- 'dl' => array(
89
- '5.3' => false,
90
- 'alternative' => null,
91
- ),
92
- 'ereg' => array(
93
- '5.3' => false,
94
- '7.0' => true,
95
- 'alternative' => 'preg_match()',
96
- ),
97
- 'ereg_replace' => array(
98
- '5.3' => false,
99
- '7.0' => true,
100
- 'alternative' => 'preg_replace()',
101
- ),
102
- 'eregi' => array(
103
- '5.3' => false,
104
- '7.0' => true,
105
- 'alternative' => 'preg_match()',
106
- ),
107
- 'eregi_replace' => array(
108
- '5.3' => false,
109
- '7.0' => true,
110
- 'alternative' => 'preg_replace()',
111
- ),
112
- 'imagepsbbox' => array(
113
- '7.0' => true,
114
- 'alternative' => null,
115
- ),
116
- 'imagepsencodefont' => array(
117
- '7.0' => true,
118
- 'alternative' => null,
119
- ),
120
- 'imagepsextendfont' => array(
121
- '7.0' => true,
122
- 'alternative' => null,
123
- ),
124
- 'imagepsfreefont' => array(
125
- '7.0' => true,
126
- 'alternative' => null,
127
- ),
128
- 'imagepsloadfont' => array(
129
- '7.0' => true,
130
- 'alternative' => null,
131
- ),
132
- 'imagepsslantfont' => array(
133
- '7.0' => true,
134
- 'alternative' => null,
135
- ),
136
- 'imagepstext' => array(
137
- '7.0' => true,
138
- 'alternative' => null,
139
- ),
140
- 'import_request_variables' => array(
141
- '5.3' => false,
142
- '5.4' => true,
143
- 'alternative' => null,
144
- ),
145
- 'ldap_sort' => array(
146
- '7.0' => false,
147
- 'alternative' => null,
148
- ),
149
- 'mcrypt_generic_end' => array(
150
- '5.3' => false,
151
- '7.0' => true,
152
- 'alternative' => 'mcrypt_generic_deinit()',
153
- ),
154
- 'mysql_db_query' => array(
155
- '5.3' => false,
156
- '7.0' => true,
157
- 'alternative' => 'mysqli::select_db() and mysqli::query()',
158
- ),
159
- 'mysql_escape_string' => array(
160
- '5.3' => false,
161
- '7.0' => true,
162
- 'alternative' => 'mysqli::real_escape_string()',
163
- ),
164
- 'mysql_list_dbs' => array(
165
- '5.4' => false,
166
- '7.0' => true,
167
- 'alternative' => null,
168
- ),
169
- 'mysqli_bind_param' => array(
170
- '5.3' => false,
171
- '5.4' => true,
172
- 'alternative' => 'mysqli_stmt::bind_param()',
173
- ),
174
- 'mysqli_bind_result' => array(
175
- '5.3' => false,
176
- '5.4' => true,
177
- 'alternative' => 'mysqli_stmt::bind_result()',
178
- ),
179
- 'mysqli_client_encoding' => array(
180
- '5.3' => false,
181
- '5.4' => true,
182
- 'alternative' => 'mysqli::character_set_name()',
183
- ),
184
- 'mysqli_fetch' => array(
185
- '5.3' => false,
186
- '5.4' => true,
187
- 'alternative' => 'mysqli_stmt::fetch()',
188
- ),
189
- 'mysqli_param_count' => array(
190
- '5.3' => false,
191
- '5.4' => true,
192
- 'alternative' => 'mysqli_stmt_param_count()',
193
- ),
194
- 'mysqli_get_metadata' => array(
195
- '5.3' => false,
196
- '5.4' => true,
197
- 'alternative' => 'mysqli_stmt::result_metadata()',
198
- ),
199
- 'mysqli_send_long_data' => array(
200
- '5.3' => false,
201
- '5.4' => true,
202
- 'alternative' => 'mysqli_stmt::send_long_data()',
203
- ),
204
- 'magic_quotes_runtime' => array(
205
- '5.3' => false,
206
- '7.0' => true,
207
- 'alternative' => null,
208
- ),
209
- 'session_register' => array(
210
- '5.3' => false,
211
- '5.4' => true,
212
- 'alternative' => '$_SESSION',
213
- ),
214
- 'session_unregister' => array(
215
- '5.3' => false,
216
- '5.4' => true,
217
- 'alternative' => '$_SESSION',
218
- ),
219
- 'session_is_registered' => array(
220
- '5.3' => false,
221
- '5.4' => true,
222
- 'alternative' => '$_SESSION',
223
- ),
224
- 'set_magic_quotes_runtime' => array(
225
- '5.3' => false,
226
- '7.0' => true,
227
- 'alternative' => null,
228
- ),
229
- 'set_socket_blocking' => array(
230
- '5.3' => false,
231
- '7.0' => true,
232
- 'alternative' => 'stream_set_blocking()',
233
- ),
234
- 'split' => array(
235
- '5.3' => false,
236
- '7.0' => true,
237
- 'alternative' => 'preg_split()',
238
- ),
239
- 'spliti' => array(
240
- '5.3' => false,
241
- '7.0' => true,
242
- 'alternative' => 'preg_split()',
243
- ),
244
- 'sql_regcase' => array(
245
- '5.3' => false,
246
- '7.0' => true,
247
- 'alternative' => null,
248
- ),
249
- 'php_logo_guid' => array(
250
- '5.5' => true,
251
- 'alternative' => null,
252
- ),
253
- 'php_egg_logo_guid' => array(
254
- '5.5' => true,
255
- 'alternative' => null,
256
- ),
257
- 'php_real_logo_guid' => array(
258
- '5.5' => true,
259
- 'alternative' => null,
260
- ),
261
- 'zend_logo_guid' => array(
262
- '5.5' => true,
263
- 'alternative' => null,
264
- ),
265
- 'datefmt_set_timezone_id' => array(
266
- '5.5' => false,
267
- '7.0' => true,
268
- 'alternative' => 'IntlDateFormatter::setTimeZone()',
269
- ),
270
- 'mcrypt_ecb' => array(
271
- '5.5' => false,
272
- '7.0' => true,
273
- 'alternative' => null,
274
- ),
275
- 'mcrypt_cbc' => array(
276
- '5.5' => false,
277
- '7.0' => true,
278
- 'alternative' => null,
279
- ),
280
- 'mcrypt_cfb' => array(
281
- '5.5' => false,
282
- '7.0' => true,
283
- 'alternative' => null,
284
- ),
285
- 'mcrypt_ofb' => array(
286
- '5.5' => false,
287
- '7.0' => true,
288
- 'alternative' => null,
289
- ),
290
- 'ocibindbyname' => array(
291
- '5.4' => false,
292
- 'alternative' => 'oci_bind_by_name()',
293
- ),
294
- 'ocicancel' => array(
295
- '5.4' => false,
296
- 'alternative' => 'oci_cancel()',
297
- ),
298
- 'ocicloselob' => array(
299
- '5.4' => false,
300
- 'alternative' => 'OCI-Lob::close()',
301
- ),
302
- 'ocicollappend' => array(
303
- '5.4' => false,
304
- 'alternative' => 'OCI-Collection::append()',
305
- ),
306
- 'ocicollassign' => array(
307
- '5.4' => false,
308
- 'alternative' => 'OCI-Collection::assign()',
309
- ),
310
- 'ocicollassignelem' => array(
311
- '5.4' => false,
312
- 'alternative' => 'OCI-Collection::assignElem()',
313
- ),
314
- 'ocicollgetelem' => array(
315
- '5.4' => false,
316
- 'alternative' => 'OCI-Collection::getElem()',
317
- ),
318
- 'ocicollmax' => array(
319
- '5.4' => false,
320
- 'alternative' => 'OCI-Collection::max()',
321
- ),
322
- 'ocicollsize' => array(
323
- '5.4' => false,
324
- 'alternative' => 'OCI-Collection::size()',
325
- ),
326
- 'ocicolltrim' => array(
327
- '5.4' => false,
328
- 'alternative' => 'OCI-Collection::trim()',
329
- ),
330
- 'ocicolumnisnull' => array(
331
- '5.4' => false,
332
- 'alternative' => 'oci_field_is_null()',
333
- ),
334
- 'ocicolumnname' => array(
335
- '5.4' => false,
336
- 'alternative' => 'oci_field_name()',
337
- ),
338
- 'ocicolumnprecision' => array(
339
- '5.4' => false,
340
- 'alternative' => 'oci_field_precision()',
341
- ),
342
- 'ocicolumnscale' => array(
343
- '5.4' => false,
344
- 'alternative' => 'oci_field_scale()',
345
- ),
346
- 'ocicolumnsize' => array(
347
- '5.4' => false,
348
- 'alternative' => 'oci_field_size()',
349
- ),
350
- 'ocicolumntype' => array(
351
- '5.4' => false,
352
- 'alternative' => 'oci_field_type()',
353
- ),
354
- 'ocicolumntyperaw' => array(
355
- '5.4' => false,
356
- 'alternative' => 'oci_field_type_raw()',
357
- ),
358
- 'ocicommit' => array(
359
- '5.4' => false,
360
- 'alternative' => 'oci_commit()',
361
- ),
362
- 'ocidefinebyname' => array(
363
- '5.4' => false,
364
- 'alternative' => 'oci_define_by_name()',
365
- ),
366
- 'ocierror' => array(
367
- '5.4' => false,
368
- 'alternative' => 'oci_error()',
369
- ),
370
- 'ociexecute' => array(
371
- '5.4' => false,
372
- 'alternative' => 'oci_execute()',
373
- ),
374
- 'ocifetch' => array(
375
- '5.4' => false,
376
- 'alternative' => 'oci_fetch()',
377
- ),
378
- 'ocifetchinto' => array(
379
- '5.4' => false,
380
- 'alternative' => null,
381
- ),
382
- 'ocifetchstatement' => array(
383
- '5.4' => false,
384
- 'alternative' => 'oci_fetch_all()',
385
- ),
386
- 'ocifreecollection' => array(
387
- '5.4' => false,
388
- 'alternative' => 'OCI-Collection::free()',
389
- ),
390
- 'ocifreecursor' => array(
391
- '5.4' => false,
392
- 'alternative' => 'oci_free_statement()',
393
- ),
394
- 'ocifreedesc' => array(
395
- '5.4' => false,
396
- 'alternative' => 'OCI-Lob::free()',
397
- ),
398
- 'ocifreestatement' => array(
399
- '5.4' => false,
400
- 'alternative' => 'oci_free_statement()',
401
- ),
402
- 'ociinternaldebug' => array(
403
- '5.4' => false,
404
- 'alternative' => 'oci_internal_debug()',
405
- ),
406
- 'ociloadlob' => array(
407
- '5.4' => false,
408
- 'alternative' => 'OCI-Lob::load()',
409
- ),
410
- 'ocilogoff' => array(
411
- '5.4' => false,
412
- 'alternative' => 'oci_close()',
413
- ),
414
- 'ocilogon' => array(
415
- '5.4' => false,
416
- 'alternative' => 'oci_connect()',
417
- ),
418
- 'ocinewcollection' => array(
419
- '5.4' => false,
420
- 'alternative' => 'oci_new_collection()',
421
- ),
422
- 'ocinewcursor' => array(
423
- '5.4' => false,
424
- 'alternative' => 'oci_new_cursor()',
425
- ),
426
- 'ocinewdescriptor' => array(
427
- '5.4' => false,
428
- 'alternative' => 'oci_new_descriptor()',
429
- ),
430
- 'ocinlogon' => array(
431
- '5.4' => false,
432
- 'alternative' => 'oci_new_connect()',
433
- ),
434
- 'ocinumcols' => array(
435
- '5.4' => false,
436
- 'alternative' => 'oci_num_fields()',
437
- ),
438
- 'ociparse' => array(
439
- '5.4' => false,
440
- 'alternative' => 'oci_parse()',
441
- ),
442
- 'ociplogon' => array(
443
- '5.4' => false,
444
- 'alternative' => 'oci_pconnect()',
445
- ),
446
- 'ociresult' => array(
447
- '5.4' => false,
448
- 'alternative' => 'oci_result()',
449
- ),
450
- 'ocirollback' => array(
451
- '5.4' => false,
452
- 'alternative' => 'oci_rollback()',
453
- ),
454
- 'ocirowcount' => array(
455
- '5.4' => false,
456
- 'alternative' => 'oci_num_rows()',
457
- ),
458
- 'ocisavelob' => array(
459
- '5.4' => false,
460
- 'alternative' => 'OCI-Lob::save()',
461
- ),
462
- 'ocisavelobfile' => array(
463
- '5.4' => false,
464
- 'alternative' => 'OCI-Lob::import()',
465
- ),
466
- 'ociserverversion' => array(
467
- '5.4' => false,
468
- 'alternative' => 'oci_server_version()',
469
- ),
470
- 'ocisetprefetch' => array(
471
- '5.4' => false,
472
- 'alternative' => 'oci_set_prefetch()',
473
- ),
474
- 'ocistatementtype' => array(
475
- '5.4' => false,
476
- 'alternative' => 'oci_statement_type()',
477
- ),
478
- 'ociwritelobtofile' => array(
479
- '5.4' => false,
480
- 'alternative' => 'OCI-Lob::export()',
481
- ),
482
- 'ociwritetemporarylob' => array(
483
- '5.4' => false,
484
- 'alternative' => 'OCI-Lob::writeTemporary()',
485
- ),
486
- 'mysqli_get_cache_stats' => array(
487
- '5.4' => true,
488
- 'alternative' => null,
489
- ),
490
-
491
- 'mcrypt_create_iv' => array(
492
- '7.1' => false,
493
- '7.2' => true,
494
- 'alternative' => 'random_bytes() or OpenSSL',
495
- ),
496
- 'mcrypt_decrypt' => array(
497
- '7.1' => false,
498
- '7.2' => true,
499
- 'alternative' => 'OpenSSL',
500
- ),
501
- 'mcrypt_enc_get_algorithms_name' => array(
502
- '7.1' => false,
503
- '7.2' => true,
504
- 'alternative' => 'OpenSSL',
505
- ),
506
- 'mcrypt_enc_get_block_size' => array(
507
- '7.1' => false,
508
- '7.2' => true,
509
- 'alternative' => 'OpenSSL',
510
- ),
511
- 'mcrypt_enc_get_iv_size' => array(
512
- '7.1' => false,
513
- '7.2' => true,
514
- 'alternative' => 'OpenSSL',
515
- ),
516
- 'mcrypt_enc_get_key_size' => array(
517
- '7.1' => false,
518
- '7.2' => true,
519
- 'alternative' => 'OpenSSL',
520
- ),
521
- 'mcrypt_enc_get_modes_name' => array(
522
- '7.1' => false,
523
- '7.2' => true,
524
- 'alternative' => 'OpenSSL',
525
- ),
526
- 'mcrypt_enc_get_supported_key_sizes' => array(
527
- '7.1' => false,
528
- '7.2' => true,
529
- 'alternative' => 'OpenSSL',
530
- ),
531
- 'mcrypt_enc_is_block_algorithm_mode' => array(
532
- '7.1' => false,
533
- '7.2' => true,
534
- 'alternative' => 'OpenSSL',
535
- ),
536
- 'mcrypt_enc_is_block_algorithm' => array(
537
- '7.1' => false,
538
- '7.2' => true,
539
- 'alternative' => 'OpenSSL',
540
- ),
541
- 'mcrypt_enc_is_block_mode' => array(
542
- '7.1' => false,
543
- '7.2' => true,
544
- 'alternative' => 'OpenSSL',
545
- ),
546
- 'mcrypt_enc_self_test' => array(
547
- '7.1' => false,
548
- '7.2' => true,
549
- 'alternative' => 'OpenSSL',
550
- ),
551
- 'mcrypt_encrypt' => array(
552
- '7.1' => false,
553
- '7.2' => true,
554
- 'alternative' => 'OpenSSL',
555
- ),
556
- 'mcrypt_generic_deinit' => array(
557
- '7.1' => false,
558
- '7.2' => true,
559
- 'alternative' => 'OpenSSL',
560
- ),
561
- 'mcrypt_generic_init' => array(
562
- '7.1' => false,
563
- '7.2' => true,
564
- 'alternative' => 'OpenSSL',
565
- ),
566
- 'mcrypt_generic' => array(
567
- '7.1' => false,
568
- '7.2' => true,
569
- 'alternative' => 'OpenSSL',
570
- ),
571
- 'mcrypt_get_block_size' => array(
572
- '7.1' => false,
573
- '7.2' => true,
574
- 'alternative' => 'OpenSSL',
575
- ),
576
- 'mcrypt_get_cipher_name' => array(
577
- '7.1' => false,
578
- '7.2' => true,
579
- 'alternative' => 'OpenSSL',
580
- ),
581
- 'mcrypt_get_iv_size' => array(
582
- '7.1' => false,
583
- '7.2' => true,
584
- 'alternative' => 'OpenSSL',
585
- ),
586
- 'mcrypt_get_key_size' => array(
587
- '7.1' => false,
588
- '7.2' => true,
589
- 'alternative' => 'OpenSSL',
590
- ),
591
- 'mcrypt_list_algorithms' => array(
592
- '7.1' => false,
593
- '7.2' => true,
594
- 'alternative' => 'OpenSSL',
595
- ),
596
- 'mcrypt_list_modes' => array(
597
- '7.1' => false,
598
- '7.2' => true,
599
- 'alternative' => 'OpenSSL',
600
- ),
601
- 'mcrypt_module_close' => array(
602
- '7.1' => false,
603
- '7.2' => true,
604
- 'alternative' => 'OpenSSL',
605
- ),
606
- 'mcrypt_module_get_algo_block_size' => array(
607
- '7.1' => false,
608
- '7.2' => true,
609
- 'alternative' => 'OpenSSL',
610
- ),
611
- 'mcrypt_module_get_algo_key_size' => array(
612
- '7.1' => false,
613
- '7.2' => true,
614
- 'alternative' => 'OpenSSL',
615
- ),
616
- 'mcrypt_module_get_supported_key_sizes' => array(
617
- '7.1' => false,
618
- '7.2' => true,
619
- 'alternative' => 'OpenSSL',
620
- ),
621
- 'mcrypt_module_is_block_algorithm_mode' => array(
622
- '7.1' => false,
623
- '7.2' => true,
624
- 'alternative' => 'OpenSSL',
625
- ),
626
- 'mcrypt_module_is_block_algorithm' => array(
627
- '7.1' => false,
628
- '7.2' => true,
629
- 'alternative' => 'OpenSSL',
630
- ),
631
- 'mcrypt_module_is_block_mode' => array(
632
- '7.1' => false,
633
- '7.2' => true,
634
- 'alternative' => 'OpenSSL',
635
- ),
636
- 'mcrypt_module_open' => array(
637
- '7.1' => false,
638
- '7.2' => true,
639
- 'alternative' => 'OpenSSL',
640
- ),
641
- 'mcrypt_module_self_test' => array(
642
- '7.1' => false,
643
- '7.2' => true,
644
- 'alternative' => 'OpenSSL',
645
- ),
646
- 'mdecrypt_generic' => array(
647
- '7.1' => false,
648
- '7.2' => true,
649
- 'alternative' => 'OpenSSL',
650
- ),
651
- 'jpeg2wbmp' => array(
652
- '7.2' => false,
653
- 'alternative' => 'imagecreatefromjpeg() and imagewbmp()',
654
- ),
655
- 'png2wbmp' => array(
656
- '7.2' => false,
657
- 'alternative' => 'imagecreatefrompng() or imagewbmp()',
658
- ),
659
- 'create_function' => array(
660
- '7.2' => false,
661
- 'alternative' => 'an anonymous function',
662
- ),
663
- 'each' => array(
664
- '7.2' => false,
665
- 'alternative' => 'a foreach loop',
666
- ),
667
- 'gmp_random' => array(
668
- '7.2' => false,
669
- 'alternative' => 'gmp_random_bits() or gmp_random_range()',
670
- ),
671
- 'read_exif_data' => array(
672
- '7.2' => false,
673
- 'alternative' => 'exif_read_data()',
674
- ),
675
-
676
- 'image2wbmp' => array(
677
- '7.3' => false,
678
- 'alternative' => 'imagewbmp()',
679
- ),
680
- 'mbregex_encoding' => array(
681
- '7.3' => false,
682
- 'alternative' => 'mb_regex_encoding()',
683
- ),
684
- 'mbereg' => array(
685
- '7.3' => false,
686
- 'alternative' => 'mb_ereg()',
687
- ),
688
- 'mberegi' => array(
689
- '7.3' => false,
690
- 'alternative' => 'mb_eregi()',
691
- ),
692
- 'mbereg_replace' => array(
693
- '7.3' => false,
694
- 'alternative' => 'mb_ereg_replace()',
695
- ),
696
- 'mberegi_replace' => array(
697
- '7.3' => false,
698
- 'alternative' => 'mb_eregi_replace()',
699
- ),
700
- 'mbsplit' => array(
701
- '7.3' => false,
702
- 'alternative' => 'mb_split()',
703
- ),
704
- 'mbereg_match' => array(
705
- '7.3' => false,
706
- 'alternative' => 'mb_ereg_match()',
707
- ),
708
- 'mbereg_search' => array(
709
- '7.3' => false,
710
- 'alternative' => 'mb_ereg_search()',
711
- ),
712
- 'mbereg_search_pos' => array(
713
- '7.3' => false,
714
- 'alternative' => 'mb_ereg_search_pos()',
715
- ),
716
- 'mbereg_search_regs' => array(
717
- '7.3' => false,
718
- 'alternative' => 'mb_ereg_search_regs()',
719
- ),
720
- 'mbereg_search_init' => array(
721
- '7.3' => false,
722
- 'alternative' => 'mb_ereg_search_init()',
723
- ),
724
- 'mbereg_search_getregs' => array(
725
- '7.3' => false,
726
- 'alternative' => 'mb_ereg_search_getregs()',
727
- ),
728
- 'mbereg_search_getpos' => array(
729
- '7.3' => false,
730
- 'alternative' => 'mb_ereg_search_getpos()',
731
- ),
732
- 'mbereg_search_setpos' => array(
733
- '7.3' => false,
734
- 'alternative' => 'mb_ereg_search_setpos()',
735
- ),
736
- 'fgetss' => array(
737
- '7.3' => false,
738
- 'alternative' => null,
739
- ),
740
- 'gzgetss' => array(
741
- '7.3' => false,
742
- 'alternative' => null,
743
- ),
744
-
745
- 'convert_cyr_string' => array(
746
- '7.4' => false,
747
- 'alternative' => 'mb_convert_encoding(), iconv() or UConverter',
748
- ),
749
- 'ezmlm_hash' => array(
750
- '7.4' => false,
751
- 'alternative' => null,
752
- ),
753
- 'get_magic_quotes_gpc' => array(
754
- '7.4' => false,
755
- 'alternative' => null,
756
- ),
757
- 'get_magic_quotes_runtime' => array(
758
- '7.4' => false,
759
- 'alternative' => null,
760
- ),
761
- 'hebrevc' => array(
762
- '7.4' => false,
763
- 'alternative' => null,
764
- ),
765
- 'is_real' => array(
766
- '7.4' => false,
767
- 'alternative' => 'is_float()',
768
- ),
769
- 'money_format' => array(
770
- '7.4' => false,
771
- 'alternative' => 'NumberFormatter::formatCurrency()',
772
- ),
773
- 'restore_include_path' => array(
774
- '7.4' => false,
775
- 'alternative' => "ini_restore('include_path')",
776
- ),
777
- 'ibase_add_user' => array(
778
- '7.4' => true,
779
- 'alternative' => null,
780
- ),
781
- 'ibase_affected_rows' => array(
782
- '7.4' => true,
783
- 'alternative' => null,
784
- ),
785
- 'ibase_backup' => array(
786
- '7.4' => true,
787
- 'alternative' => null,
788
- ),
789
- 'ibase_blob_add' => array(
790
- '7.4' => true,
791
- 'alternative' => null,
792
- ),
793
- 'ibase_blob_cancel' => array(
794
- '7.4' => true,
795
- 'alternative' => null,
796
- ),
797
- 'ibase_blob_close' => array(
798
- '7.4' => true,
799
- 'alternative' => null,
800
- ),
801
- 'ibase_blob_create' => array(
802
- '7.4' => true,
803
- 'alternative' => null,
804
- ),
805
- 'ibase_blob_echo' => array(
806
- '7.4' => true,
807
- 'alternative' => null,
808
- ),
809
- 'ibase_blob_get' => array(
810
- '7.4' => true,
811
- 'alternative' => null,
812
- ),
813
- 'ibase_blob_import' => array(
814
- '7.4' => true,
815
- 'alternative' => null,
816
- ),
817
- 'ibase_blob_info' => array(
818
- '7.4' => true,
819
- 'alternative' => null,
820
- ),
821
- 'ibase_blob_open' => array(
822
- '7.4' => true,
823
- 'alternative' => null,
824
- ),
825
- 'ibase_close' => array(
826
- '7.4' => true,
827
- 'alternative' => null,
828
- ),
829
- 'ibase_commit_ret' => array(
830
- '7.4' => true,
831
- 'alternative' => null,
832
- ),
833
- 'ibase_commit' => array(
834
- '7.4' => true,
835
- 'alternative' => null,
836
- ),
837
- 'ibase_connect' => array(
838
- '7.4' => true,
839
- 'alternative' => null,
840
- ),
841
- 'ibase_db_info' => array(
842
- '7.4' => true,
843
- 'alternative' => null,
844
- ),
845
- 'ibase_delete_user' => array(
846
- '7.4' => true,
847
- 'alternative' => null,
848
- ),
849
- 'ibase_drop_db' => array(
850
- '7.4' => true,
851
- 'alternative' => null,
852
- ),
853
- 'ibase_errcode' => array(
854
- '7.4' => true,
855
- 'alternative' => null,
856
- ),
857
- 'ibase_errmsg' => array(
858
- '7.4' => true,
859
- 'alternative' => null,
860
- ),
861
- 'ibase_execute' => array(
862
- '7.4' => true,
863
- 'alternative' => null,
864
- ),
865
- 'ibase_fetch_assoc' => array(
866
- '7.4' => true,
867
- 'alternative' => null,
868
- ),
869
- 'ibase_fetch_object' => array(
870
- '7.4' => true,
871
- 'alternative' => null,
872
- ),
873
- 'ibase_fetch_row' => array(
874
- '7.4' => true,
875
- 'alternative' => null,
876
- ),
877
- 'ibase_field_info' => array(
878
- '7.4' => true,
879
- 'alternative' => null,
880
- ),
881
- 'ibase_free_event_handler' => array(
882
- '7.4' => true,
883
- 'alternative' => null,
884
- ),
885
- 'ibase_free_query' => array(
886
- '7.4' => true,
887
- 'alternative' => null,
888
- ),
889
- 'ibase_free_result' => array(
890
- '7.4' => true,
891
- 'alternative' => null,
892
- ),
893
- 'ibase_gen_id' => array(
894
- '7.4' => true,
895
- 'alternative' => null,
896
- ),
897
- 'ibase_maintain_db' => array(
898
- '7.4' => true,
899
- 'alternative' => null,
900
- ),
901
- 'ibase_modify_user' => array(
902
- '7.4' => true,
903
- 'alternative' => null,
904
- ),
905
- 'ibase_name_result' => array(
906
- '7.4' => true,
907
- 'alternative' => null,
908
- ),
909
- 'ibase_num_fields' => array(
910
- '7.4' => true,
911
- 'alternative' => null,
912
- ),
913
- 'ibase_num_params' => array(
914
- '7.4' => true,
915
- 'alternative' => null,
916
- ),
917
- 'ibase_param_info' => array(
918
- '7.4' => true,
919
- 'alternative' => null,
920
- ),
921
- 'ibase_pconnect' => array(
922
- '7.4' => true,
923
- 'alternative' => null,
924
- ),
925
- 'ibase_prepare' => array(
926
- '7.4' => true,
927
- 'alternative' => null,
928
- ),
929
- 'ibase_query' => array(
930
- '7.4' => true,
931
- 'alternative' => null,
932
- ),
933
- 'ibase_restore' => array(
934
- '7.4' => true,
935
- 'alternative' => null,
936
- ),
937
- 'ibase_rollback_ret' => array(
938
- '7.4' => true,
939
- 'alternative' => null,
940
- ),
941
- 'ibase_rollback' => array(
942
- '7.4' => true,
943
- 'alternative' => null,
944
- ),
945
- 'ibase_server_info' => array(
946
- '7.4' => true,
947
- 'alternative' => null,
948
- ),
949
- 'ibase_service_attach' => array(
950
- '7.4' => true,
951
- 'alternative' => null,
952
- ),
953
- 'ibase_service_detach' => array(
954
- '7.4' => true,
955
- 'alternative' => null,
956
- ),
957
- 'ibase_set_event_handler' => array(
958
- '7.4' => true,
959
- 'alternative' => null,
960
- ),
961
- 'ibase_trans' => array(
962
- '7.4' => true,
963
- 'alternative' => null,
964
- ),
965
- 'ibase_wait_event' => array(
966
- '7.4' => true,
967
- 'alternative' => null,
968
- ),
969
- 'ldap_control_paged_result_response' => array(
970
- '7.4' => false,
971
- 'alternative' => 'ldap_search()',
972
- ),
973
- 'ldap_control_paged_result' => array(
974
- '7.4' => false,
975
- 'alternative' => 'ldap_search()',
976
- ),
977
- 'recode_file' => array(
978
- '7.4' => true,
979
- 'alternative' => 'the iconv or mbstring extension',
980
- ),
981
- 'recode_string' => array(
982
- '7.4' => true,
983
- 'alternative' => 'the iconv or mbstring extension',
984
- ),
985
- 'recode' => array(
986
- '7.4' => true,
987
- 'alternative' => 'the iconv or mbstring extension',
988
- ),
989
- 'wddx_add_vars' => array(
990
- '7.4' => true,
991
- 'alternative' => null,
992
- ),
993
- 'wddx_deserialize' => array(
994
- '7.4' => true,
995
- 'alternative' => null,
996
- ),
997
- 'wddx_packet_end' => array(
998
- '7.4' => true,
999
- 'alternative' => null,
1000
- ),
1001
- 'wddx_packet_start' => array(
1002
- '7.4' => true,
1003
- 'alternative' => null,
1004
- ),
1005
- 'wddx_serialize_value' => array(
1006
- '7.4' => true,
1007
- 'alternative' => null,
1008
- ),
1009
- 'wddx_serialize_vars' => array(
1010
- '7.4' => true,
1011
- 'alternative' => null,
1012
- ),
1013
- );
1014
-
1015
-
1016
- /**
1017
- * Returns an array of tokens this test wants to listen for.
1018
- *
1019
- * @since 5.6
1020
- *
1021
- * @return array
1022
- */
1023
- public function register()
1024
- {
1025
- // Handle case-insensitivity of function names.
1026
- $this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions);
1027
-
1028
- return array(\T_STRING);
1029
- }
1030
-
1031
-
1032
- /**
1033
- * Processes this test, when one of its tokens is encountered.
1034
- *
1035
- * @since 5.5
1036
- *
1037
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
1038
- * @param int $stackPtr The position of the current token in
1039
- * the stack passed in $tokens.
1040
- *
1041
- * @return void
1042
- */
1043
- public function process(File $phpcsFile, $stackPtr)
1044
- {
1045
- $tokens = $phpcsFile->getTokens();
1046
-
1047
- $ignore = array(
1048
- \T_DOUBLE_COLON => true,
1049
- \T_OBJECT_OPERATOR => true,
1050
- \T_FUNCTION => true,
1051
- \T_CLASS => true,
1052
- \T_CONST => true,
1053
- \T_USE => true,
1054
- \T_NS_SEPARATOR => true,
1055
- );
1056
-
1057
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
1058
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
1059
- // Not a call to a PHP function.
1060
- return;
1061
- }
1062
-
1063
- $function = $tokens[$stackPtr]['content'];
1064
- $functionLc = strtolower($function);
1065
-
1066
- if (isset($this->removedFunctions[$functionLc]) === false) {
1067
- return;
1068
- }
1069
-
1070
- $itemInfo = array(
1071
- 'name' => $function,
1072
- 'nameLc' => $functionLc,
1073
- );
1074
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
1075
- }
1076
-
1077
-
1078
- /**
1079
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
1080
- *
1081
- * @since 7.1.0
1082
- *
1083
- * @param array $itemInfo Base information about the item.
1084
- *
1085
- * @return array Version and other information about the item.
1086
- */
1087
- public function getItemArray(array $itemInfo)
1088
- {
1089
- return $this->removedFunctions[$itemInfo['nameLc']];
1090
- }
1091
-
1092
-
1093
- /**
1094
- * Get the error message template for this sniff.
1095
- *
1096
- * @since 7.1.0
1097
- *
1098
- * @return string
1099
- */
1100
- protected function getErrorMsgTemplate()
1101
- {
1102
- return 'Function %s() is ';
1103
- }
1104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RequiredToOptionalFunctionParametersSniff.php DELETED
@@ -1,350 +0,0 @@
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\FunctionUse;
12
-
13
- use PHPCompatibility\AbstractComplexVersionSniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect missing required function parameters in calls to native PHP functions.
19
- *
20
- * Specifically when those function parameters are no longer required in more recent PHP versions.
21
- *
22
- * PHP version All
23
- *
24
- * @link https://www.php.net/manual/en/doc.changelog.php
25
- *
26
- * @since 7.0.3
27
- * @since 7.1.0 Now extends the `AbstractComplexVersionSniff` instead of the base `Sniff` class.
28
- * @since 9.0.0 Renamed from `RequiredOptionalFunctionParametersSniff` to `RequiredToOptionalFunctionParametersSniff`.
29
- */
30
- class RequiredToOptionalFunctionParametersSniff extends AbstractComplexVersionSniff
31
- {
32
-
33
- /**
34
- * A list of function parameters, which were required in older versions and became optional later on.
35
- *
36
- * The array lists : version number with true (required) and false (optional).
37
- *
38
- * The index is the location of the parameter in the parameter list, starting at 0 !
39
- * If's sufficient to list the last version in which the parameter was still required.
40
- *
41
- * @since 7.0.3
42
- *
43
- * @var array
44
- */
45
- protected $functionParameters = array(
46
- 'array_merge' => array(
47
- 0 => array(
48
- 'name' => 'array(s) to merge',
49
- '7.3' => true,
50
- '7.4' => false,
51
- ),
52
- ),
53
- 'array_merge_recursive' => array(
54
- 0 => array(
55
- 'name' => 'array(s) to merge',
56
- '7.3' => true,
57
- '7.4' => false,
58
- ),
59
- ),
60
- 'array_push' => array(
61
- 1 => array(
62
- 'name' => 'element to push',
63
- '7.2' => true,
64
- '7.3' => false,
65
- ),
66
- ),
67
- 'array_unshift' => array(
68
- 1 => array(
69
- 'name' => 'element to prepend',
70
- '7.2' => true,
71
- '7.3' => false,
72
- ),
73
- ),
74
- 'bcscale' => array(
75
- 0 => array(
76
- 'name' => 'scale',
77
- '7.2' => true,
78
- '7.3' => false,
79
- ),
80
- ),
81
- 'ftp_fget' => array(
82
- 3 => array(
83
- 'name' => 'mode',
84
- '7.2' => true,
85
- '7.3' => false,
86
- ),
87
- ),
88
- 'ftp_fput' => array(
89
- 3 => array(
90
- 'name' => 'mode',
91
- '7.2' => true,
92
- '7.3' => false,
93
- ),
94
- ),
95
- 'ftp_get' => array(
96
- 3 => array(
97
- 'name' => 'mode',
98
- '7.2' => true,
99
- '7.3' => false,
100
- ),
101
- ),
102
- 'ftp_nb_fget' => array(
103
- 3 => array(
104
- 'name' => 'mode',
105
- '7.2' => true,
106
- '7.3' => false,
107
- ),
108
- ),
109
- 'ftp_nb_fput' => array(
110
- 3 => array(
111
- 'name' => 'mode',
112
- '7.2' => true,
113
- '7.3' => false,
114
- ),
115
- ),
116
- 'ftp_nb_get' => array(
117
- 3 => array(
118
- 'name' => 'mode',
119
- '7.2' => true,
120
- '7.3' => false,
121
- ),
122
- ),
123
- 'ftp_nb_put' => array(
124
- 3 => array(
125
- 'name' => 'mode',
126
- '7.2' => true,
127
- '7.3' => false,
128
- ),
129
- ),
130
- 'ftp_put' => array(
131
- 3 => array(
132
- 'name' => 'mode',
133
- '7.2' => true,
134
- '7.3' => false,
135
- ),
136
- ),
137
- 'getenv' => array(
138
- 0 => array(
139
- 'name' => 'varname',
140
- '7.0' => true,
141
- '7.1' => false,
142
- ),
143
- ),
144
- 'preg_match_all' => array(
145
- 2 => array(
146
- 'name' => 'matches',
147
- '5.3' => true,
148
- '5.4' => false,
149
- ),
150
- ),
151
- 'stream_socket_enable_crypto' => array(
152
- 2 => array(
153
- 'name' => 'crypto_type',
154
- '5.5' => true,
155
- '5.6' => false,
156
- ),
157
- ),
158
- );
159
-
160
-
161
- /**
162
- * Returns an array of tokens this test wants to listen for.
163
- *
164
- * @since 7.0.3
165
- *
166
- * @return array
167
- */
168
- public function register()
169
- {
170
- // Handle case-insensitivity of function names.
171
- $this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters);
172
-
173
- return array(\T_STRING);
174
- }
175
-
176
- /**
177
- * Processes this test, when one of its tokens is encountered.
178
- *
179
- * @since 7.0.3
180
- *
181
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
182
- * @param int $stackPtr The position of the current token in
183
- * the stack passed in $tokens.
184
- *
185
- * @return void
186
- */
187
- public function process(File $phpcsFile, $stackPtr)
188
- {
189
- $tokens = $phpcsFile->getTokens();
190
-
191
- $ignore = array(
192
- \T_DOUBLE_COLON => true,
193
- \T_OBJECT_OPERATOR => true,
194
- \T_FUNCTION => true,
195
- \T_CONST => true,
196
- \T_NEW => true,
197
- );
198
-
199
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
200
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
201
- // Not a call to a PHP function.
202
- return;
203
- }
204
-
205
- $function = $tokens[$stackPtr]['content'];
206
- $functionLc = strtolower($function);
207
-
208
- if (isset($this->functionParameters[$functionLc]) === false) {
209
- return;
210
- }
211
-
212
- $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
213
- $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
214
-
215
- // If the parameter count returned > 0, we know there will be valid open parenthesis.
216
- if ($parameterCount === 0 && $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS) {
217
- return;
218
- }
219
-
220
- $parameterOffsetFound = $parameterCount - 1;
221
-
222
- foreach ($this->functionParameters[$functionLc] as $offset => $parameterDetails) {
223
- if ($offset > $parameterOffsetFound) {
224
- $itemInfo = array(
225
- 'name' => $function,
226
- 'nameLc' => $functionLc,
227
- 'offset' => $offset,
228
- );
229
- $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
230
- }
231
- }
232
- }
233
-
234
-
235
- /**
236
- * Determine whether an error/warning should be thrown for an item based on collected information.
237
- *
238
- * @since 7.1.0
239
- *
240
- * @param array $errorInfo Detail information about an item.
241
- *
242
- * @return bool
243
- */
244
- protected function shouldThrowError(array $errorInfo)
245
- {
246
- return ($errorInfo['requiredVersion'] !== '');
247
- }
248
-
249
-
250
- /**
251
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
252
- *
253
- * @since 7.1.0
254
- *
255
- * @param array $itemInfo Base information about the item.
256
- *
257
- * @return array Version and other information about the item.
258
- */
259
- public function getItemArray(array $itemInfo)
260
- {
261
- return $this->functionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
262
- }
263
-
264
-
265
- /**
266
- * Get an array of the non-PHP-version array keys used in a sub-array.
267
- *
268
- * @since 7.1.0
269
- *
270
- * @return array
271
- */
272
- protected function getNonVersionArrayKeys()
273
- {
274
- return array('name');
275
- }
276
-
277
-
278
- /**
279
- * Retrieve the relevant detail (version) information for use in an error message.
280
- *
281
- * @since 7.1.0
282
- *
283
- * @param array $itemArray Version and other information about the item.
284
- * @param array $itemInfo Base information about the item.
285
- *
286
- * @return array
287
- */
288
- public function getErrorInfo(array $itemArray, array $itemInfo)
289
- {
290
- $errorInfo = array(
291
- 'paramName' => '',
292
- 'requiredVersion' => '',
293
- );
294
-
295
- $versionArray = $this->getVersionArray($itemArray);
296
-
297
- if (empty($versionArray) === false) {
298
- foreach ($versionArray as $version => $required) {
299
- if ($required === true && $this->supportsBelow($version) === true) {
300
- $errorInfo['requiredVersion'] = $version;
301
- }
302
- }
303
- }
304
-
305
- $errorInfo['paramName'] = $itemArray['name'];
306
-
307
- return $errorInfo;
308
- }
309
-
310
-
311
- /**
312
- * Get the error message template for this sniff.
313
- *
314
- * @since 7.1.0
315
- *
316
- * @return string
317
- */
318
- protected function getErrorMsgTemplate()
319
- {
320
- return 'The "%s" parameter for function %s() is missing, but was required for PHP version %s and lower';
321
- }
322
-
323
-
324
- /**
325
- * Generates the error or warning for this item.
326
- *
327
- * @since 7.1.0
328
- *
329
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
330
- * @param int $stackPtr The position of the relevant token in
331
- * the stack.
332
- * @param array $itemInfo Base information about the item.
333
- * @param array $errorInfo Array with detail (version) information
334
- * relevant to the item.
335
- *
336
- * @return void
337
- */
338
- public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
339
- {
340
- $error = $this->getErrorMsgTemplate();
341
- $errorCode = $this->stringToErrorCode($itemInfo['name'] . '_' . $errorInfo['paramName']) . 'Missing';
342
- $data = array(
343
- $errorInfo['paramName'],
344
- $itemInfo['name'],
345
- $errorInfo['requiredVersion'],
346
- );
347
-
348
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
349
- }
350
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php DELETED
@@ -1,158 +0,0 @@
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\Generators;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHPCompatibility\PHPCSHelper;
15
- use PHP_CodeSniffer_File as File;
16
-
17
- /**
18
- * As of PHP 7.0, a `return` statement can be used within a generator for a final expression to be returned.
19
- *
20
- * PHP version 7.0
21
- *
22
- * @link https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.generator-return-expressions
23
- * @link https://wiki.php.net/rfc/generator-return-expressions
24
- * @link https://www.php.net/manual/en/language.generators.syntax.php
25
- *
26
- * @since 8.2.0
27
- */
28
- class NewGeneratorReturnSniff extends Sniff
29
- {
30
- /**
31
- * Scope conditions within which a yield can exist.
32
- *
33
- * @since 9.0.0
34
- *
35
- * @var array
36
- */
37
- private $validConditions = array(
38
- \T_FUNCTION => \T_FUNCTION,
39
- \T_CLOSURE => \T_CLOSURE,
40
- );
41
-
42
-
43
- /**
44
- * Returns an array of tokens this test wants to listen for.
45
- *
46
- * @since 8.2.0
47
- *
48
- * @return array
49
- */
50
- public function register()
51
- {
52
- $targets = array(
53
- \T_YIELD,
54
- );
55
-
56
- /*
57
- * The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.
58
- * The `yield from` keyword was introduced in PHP 7.0 and tokenizes as
59
- * "T_YIELD T_WHITESPACE T_STRING".
60
- *
61
- * Pre-PHPCS 3.1.0, the T_YIELD token was not correctly back-filled for PHP < 5.5.
62
- * Also, as of PHPCS 3.1.0, the PHPCS tokenizer adds a new T_YIELD_FROM
63
- * token.
64
- *
65
- * So for PHP 5.3-5.4 icw PHPCS < 3.1.0, we need to look for T_STRING with content "yield".
66
- * For PHP 5.5+ we need to look for T_YIELD.
67
- * For PHPCS 3.1.0+, we also need to look for T_YIELD_FROM.
68
- */
69
- if (version_compare(\PHP_VERSION_ID, '50500', '<') === true
70
- && version_compare(PHPCSHelper::getVersion(), '3.1.0', '<') === true
71
- ) {
72
- $targets[] = \T_STRING;
73
- }
74
-
75
- if (\defined('T_YIELD_FROM')) {
76
- $targets[] = \T_YIELD_FROM;
77
- }
78
-
79
- return $targets;
80
- }
81
-
82
- /**
83
- * Processes this test, when one of its tokens is encountered.
84
- *
85
- * @since 8.2.0
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|int Void or a stack pointer to skip forward.
92
- */
93
- public function process(File $phpcsFile, $stackPtr)
94
- {
95
- if ($this->supportsBelow('5.6') !== true) {
96
- return;
97
- }
98
-
99
- $tokens = $phpcsFile->getTokens();
100
-
101
- if ($tokens[$stackPtr]['code'] === \T_STRING
102
- && $tokens[$stackPtr]['content'] !== 'yield'
103
- ) {
104
- return;
105
- }
106
-
107
- if (empty($tokens[$stackPtr]['conditions']) === true) {
108
- return;
109
- }
110
-
111
- // Walk the condition from inner to outer to see if we can find a valid function/closure scope.
112
- $conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
113
- foreach ($conditions as $ptr => $type) {
114
- if (isset($this->validConditions[$type]) === true) {
115
- $function = $ptr;
116
- break;
117
- }
118
- }
119
-
120
- if (isset($function) === false) {
121
- // Yield outside function scope, fatal error, but not our concern.
122
- return;
123
- }
124
-
125
- if (isset($tokens[$function]['scope_opener'], $tokens[$function]['scope_closer']) === false) {
126
- // Can't reliably determine start/end of function scope.
127
- return;
128
- }
129
-
130
- $targets = array(\T_RETURN, \T_CLOSURE, \T_FUNCTION, \T_CLASS);
131
- if (\defined('T_ANON_CLASS')) {
132
- $targets[] = \T_ANON_CLASS;
133
- }
134
-
135
- $current = $tokens[$function]['scope_opener'];
136
-
137
- while (($current = $phpcsFile->findNext($targets, ($current + 1), $tokens[$function]['scope_closer'])) !== false) {
138
- if ($tokens[$current]['code'] === \T_RETURN) {
139
- $phpcsFile->addError(
140
- 'Returning a final expression from a generator was not supported in PHP 5.6 or earlier',
141
- $current,
142
- 'ReturnFound'
143
- );
144
-
145
- return $tokens[$function]['scope_closer'];
146
- }
147
-
148
- // Found a nested scope in which return can exist without problems.
149
- if (isset($tokens[$current]['scope_closer'])) {
150
- // Skip past the nested scope.
151
- $current = $tokens[$current]['scope_closer'];
152
- }
153
- }
154
-
155
- // Don't examine this function again.
156
- return $tokens[$function]['scope_closer'];
157
- }
158
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/IniDirectives/NewIniDirectivesSniff.php DELETED
@@ -1,855 +0,0 @@
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\IniDirectives;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect the use of new INI directives through `ini_set()` or `ini_get()`.
18
- *
19
- * PHP version All
20
- *
21
- * @link https://www.php.net/manual/en/ini.list.php
22
- * @link https://www.php.net/manual/en/ini.core.php
23
- *
24
- * @since 5.5
25
- * @since 7.0.7 When a new directive is used with `ini_set()`, the sniff will now throw an error
26
- * instead of a warning.
27
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class..
28
- */
29
- class NewIniDirectivesSniff extends AbstractNewFeatureSniff
30
- {
31
- /**
32
- * A list of new INI directives
33
- *
34
- * The array lists : version number with false (not present) or true (present).
35
- * If's sufficient to list the first version where the ini directive appears.
36
- *
37
- * @since 5.5
38
- * @since 7.0.3 Support for 'alternative' has been added.
39
- *
40
- * @var array(string)
41
- */
42
- protected $newIniDirectives = array(
43
- 'auto_globals_jit' => array(
44
- '4.4' => false,
45
- '5.0' => true,
46
- ),
47
- 'com.code_page' => array(
48
- '4.4' => false,
49
- '5.0' => true,
50
- ),
51
- 'date.default_latitude' => array(
52
- '4.4' => false,
53
- '5.0' => true,
54
- ),
55
- 'date.default_longitude' => array(
56
- '4.4' => false,
57
- '5.0' => true,
58
- ),
59
- 'date.sunrise_zenith' => array(
60
- '4.4' => false,
61
- '5.0' => true,
62
- ),
63
- 'date.sunset_zenith' => array(
64
- '4.4' => false,
65
- '5.0' => true,
66
- ),
67
- 'ibase.default_charset' => array(
68
- '4.4' => false,
69
- '5.0' => true,
70
- ),
71
- 'ibase.default_db' => array(
72
- '4.4' => false,
73
- '5.0' => true,
74
- ),
75
- 'mail.force_extra_parameters' => array(
76
- '4.4' => false,
77
- '5.0' => true,
78
- ),
79
- 'mime_magic.debug' => array(
80
- '4.4' => false,
81
- '5.0' => true,
82
- ),
83
- 'mysqli.max_links' => array(
84
- '4.4' => false,
85
- '5.0' => true,
86
- ),
87
- 'mysqli.default_port' => array(
88
- '4.4' => false,
89
- '5.0' => true,
90
- ),
91
- 'mysqli.default_socket' => array(
92
- '4.4' => false,
93
- '5.0' => true,
94
- ),
95
- 'mysqli.default_host' => array(
96
- '4.4' => false,
97
- '5.0' => true,
98
- ),
99
- 'mysqli.default_user' => array(
100
- '4.4' => false,
101
- '5.0' => true,
102
- ),
103
- 'mysqli.default_pw' => array(
104
- '4.4' => false,
105
- '5.0' => true,
106
- ),
107
- 'report_zend_debug' => array(
108
- '4.4' => false,
109
- '5.0' => true,
110
- ),
111
- 'session.hash_bits_per_character' => array(
112
- '4.4' => false,
113
- '5.0' => true,
114
- ),
115
- 'session.hash_function' => array(
116
- '4.4' => false,
117
- '5.0' => true,
118
- ),
119
- 'soap.wsdl_cache_dir' => array(
120
- '4.4' => false,
121
- '5.0' => true,
122
- ),
123
- 'soap.wsdl_cache_enabled' => array(
124
- '4.4' => false,
125
- '5.0' => true,
126
- ),
127
- 'soap.wsdl_cache_ttl' => array(
128
- '4.4' => false,
129
- '5.0' => true,
130
- ),
131
- 'sqlite.assoc_case' => array(
132
- '4.4' => false,
133
- '5.0' => true,
134
- ),
135
- 'tidy.clean_output' => array(
136
- '4.4' => false,
137
- '5.0' => true,
138
- ),
139
- 'tidy.default_config' => array(
140
- '4.4' => false,
141
- '5.0' => true,
142
- ),
143
- 'zend.ze1_compatibility_mode' => array(
144
- '4.4' => false,
145
- '5.0' => true,
146
- ),
147
-
148
- 'date.timezone' => array(
149
- '5.0' => false,
150
- '5.1' => true,
151
- ),
152
- 'detect_unicode' => array(
153
- '5.0' => false,
154
- '5.1' => true,
155
- ),
156
- 'fbsql.batchsize' => array(
157
- '5.0' => false,
158
- '5.1' => true,
159
- 'alternative' => 'fbsql.batchSize',
160
- ),
161
- 'realpath_cache_size' => array(
162
- '5.0' => false,
163
- '5.1' => true,
164
- ),
165
- 'realpath_cache_ttl' => array(
166
- '5.0' => false,
167
- '5.1' => true,
168
- ),
169
-
170
- 'mbstring.strict_detection' => array(
171
- '5.1.1' => false,
172
- '5.1.2' => true,
173
- ),
174
- 'mssql.charset' => array(
175
- '5.1.1' => false,
176
- '5.1.2' => true,
177
- ),
178
-
179
- 'gd.jpeg_ignore_warning' => array(
180
- '5.1.2' => false,
181
- '5.1.3' => true,
182
- ),
183
-
184
- 'fbsql.show_timestamp_decimals' => array(
185
- '5.1.4' => false,
186
- '5.1.5' => true,
187
- ),
188
- 'soap.wsdl_cache' => array(
189
- '5.1.4' => false,
190
- '5.1.5' => true,
191
- ),
192
- 'soap.wsdl_cache_limit' => array(
193
- '5.1.4' => false,
194
- '5.1.5' => true,
195
- ),
196
-
197
- 'allow_url_include' => array(
198
- '5.1' => false,
199
- '5.2' => true,
200
- ),
201
- 'filter.default' => array(
202
- '5.1' => false,
203
- '5.2' => true,
204
- ),
205
- 'filter.default_flags' => array(
206
- '5.1' => false,
207
- '5.2' => true,
208
- ),
209
- 'pcre.backtrack_limit' => array(
210
- '5.1' => false,
211
- '5.2' => true,
212
- ),
213
- 'pcre.recursion_limit' => array(
214
- '5.1' => false,
215
- '5.2' => true,
216
- ),
217
- 'session.cookie_httponly' => array(
218
- '5.1' => false,
219
- '5.2' => true,
220
- ),
221
-
222
- 'cgi.check_shebang_line' => array(
223
- '5.2.0' => false,
224
- '5.2.1' => true,
225
- ),
226
-
227
- 'max_input_nesting_level' => array(
228
- '5.2.2' => false,
229
- '5.2.3' => true,
230
- ),
231
-
232
- 'mysqli.allow_local_infile' => array(
233
- '5.2.3' => false,
234
- '5.2.4' => true,
235
- ),
236
-
237
- 'max_file_uploads' => array(
238
- '5.2.11' => false,
239
- '5.2.12' => true,
240
- ),
241
-
242
- 'cgi.discard_path' => array(
243
- '5.2' => false,
244
- '5.3' => true,
245
- ),
246
- 'exit_on_timeout' => array(
247
- '5.2' => false,
248
- '5.3' => true,
249
- ),
250
- 'intl.default_locale' => array(
251
- '5.2' => false,
252
- '5.3' => true,
253
- ),
254
- 'intl.error_level' => array(
255
- '5.2' => false,
256
- '5.3' => true,
257
- ),
258
- 'mail.add_x_header' => array(
259
- '5.2' => false,
260
- '5.3' => true,
261
- ),
262
- 'mail.log' => array(
263
- '5.2' => false,
264
- '5.3' => true,
265
- ),
266
- 'mbstring.http_output_conv_mimetype' => array(
267
- '5.2' => false,
268
- '5.3' => true,
269
- ),
270
- 'mysqli.allow_persistent' => array(
271
- '5.2' => false,
272
- '5.3' => true,
273
- ),
274
- 'mysqli.cache_size' => array(
275
- '5.2' => false,
276
- '5.3' => true,
277
- ),
278
- 'mysqli.max_persistent' => array(
279
- '5.2' => false,
280
- '5.3' => true,
281
- ),
282
- 'mysqlnd.collect_memory_statistics' => array(
283
- '5.2' => false,
284
- '5.3' => true,
285
- ),
286
- 'mysqlnd.collect_statistics' => array(
287
- '5.2' => false,
288
- '5.3' => true,
289
- ),
290
- 'mysqlnd.debug' => array(
291
- '5.2' => false,
292
- '5.3' => true,
293
- ),
294
- 'mysqlnd.net_read_buffer_size' => array(
295
- '5.2' => false,
296
- '5.3' => true,
297
- ),
298
- 'odbc.default_cursortype' => array(
299
- '5.2' => false,
300
- '5.3' => true,
301
- ),
302
- 'request_order' => array(
303
- '5.2' => false,
304
- '5.3' => true,
305
- ),
306
- 'user_ini.cache_ttl' => array(
307
- '5.2' => false,
308
- '5.3' => true,
309
- ),
310
- 'user_ini.filename' => array(
311
- '5.2' => false,
312
- '5.3' => true,
313
- ),
314
- 'zend.enable_gc' => array(
315
- '5.2' => false,
316
- '5.3' => true,
317
- ),
318
-
319
- 'curl.cainfo' => array(
320
- '5.3.6' => false,
321
- '5.3.7' => true,
322
- ),
323
-
324
- 'max_input_vars' => array(
325
- '5.3.8' => false,
326
- '5.3.9' => true,
327
- ),
328
-
329
- 'sqlite3.extension_dir' => array(
330
- '5.3.10' => false,
331
- '5.3.11' => true,
332
- ),
333
-
334
- 'cli.pager' => array(
335
- '5.3' => false,
336
- '5.4' => true,
337
- ),
338
- 'cli.prompt' => array(
339
- '5.3' => false,
340
- '5.4' => true,
341
- ),
342
- 'cli_server.color' => array(
343
- '5.3' => false,
344
- '5.4' => true,
345
- ),
346
- 'enable_post_data_reading' => array(
347
- '5.3' => false,
348
- '5.4' => true,
349
- ),
350
- 'mysqlnd.mempool_default_size' => array(
351
- '5.3' => false,
352
- '5.4' => true,
353
- ),
354
- 'mysqlnd.net_cmd_buffer_size' => array(
355
- '5.3' => false,
356
- '5.4' => true,
357
- ),
358
- 'mysqlnd.net_read_timeout' => array(
359
- '5.3' => false,
360
- '5.4' => true,
361
- ),
362
- 'phar.cache_list' => array(
363
- '5.3' => false,
364
- '5.4' => true,
365
- ),
366
- 'session.upload_progress.enabled' => array(
367
- '5.3' => false,
368
- '5.4' => true,
369
- ),
370
- 'session.upload_progress.cleanup' => array(
371
- '5.3' => false,
372
- '5.4' => true,
373
- ),
374
- 'session.upload_progress.name' => array(
375
- '5.3' => false,
376
- '5.4' => true,
377
- ),
378
- 'session.upload_progress.freq' => array(
379
- '5.3' => false,
380
- '5.4' => true,
381
- ),
382
- 'session.upload_progress.min_freq' => array(
383
- '5.3' => false,
384
- '5.4' => true,
385
- ),
386
- 'session.upload_progress.prefix' => array(
387
- '5.3' => false,
388
- '5.4' => true,
389
- ),
390
- 'windows_show_crt_warning' => array(
391
- '5.3' => false,
392
- '5.4' => true,
393
- ),
394
- 'zend.detect_unicode' => array(
395
- '5.3' => false,
396
- '5.4' => true,
397
- 'alternative' => 'detect_unicode',
398
- ),
399
- 'zend.multibyte' => array(
400
- '5.3' => false,
401
- '5.4' => true,
402
- ),
403
- 'zend.script_encoding' => array(
404
- '5.3' => false,
405
- '5.4' => true,
406
- ),
407
- 'zend.signal_check' => array(
408
- '5.3' => false,
409
- '5.4' => true,
410
- ),
411
- 'mysqlnd.log_mask' => array(
412
- '5.3' => false,
413
- '5.4' => true,
414
- ),
415
-
416
- 'intl.use_exceptions' => array(
417
- '5.4' => false,
418
- '5.5' => true,
419
- ),
420
- 'mysqlnd.sha256_server_public_key' => array(
421
- '5.4' => false,
422
- '5.5' => true,
423
- ),
424
- 'mysqlnd.trace_alloc' => array(
425
- '5.4' => false,
426
- '5.5' => true,
427
- ),
428
- 'sys_temp_dir' => array(
429
- '5.4' => false,
430
- '5.5' => true,
431
- ),
432
- 'xsl.security_prefs' => array(
433
- '5.4' => false,
434
- '5.5' => true,
435
- ),
436
- 'opcache.enable' => array(
437
- '5.4' => false,
438
- '5.5' => true,
439
- ),
440
- 'opcache.enable_cli' => array(
441
- '5.4' => false,
442
- '5.5' => true,
443
- ),
444
- 'opcache.memory_consumption' => array(
445
- '5.4' => false,
446
- '5.5' => true,
447
- ),
448
- 'opcache.interned_strings_buffer' => array(
449
- '5.4' => false,
450
- '5.5' => true,
451
- ),
452
- 'opcache.max_accelerated_files' => array(
453
- '5.4' => false,
454
- '5.5' => true,
455
- ),
456
- 'opcache.max_wasted_percentage' => array(
457
- '5.4' => false,
458
- '5.5' => true,
459
- ),
460
- 'opcache.use_cwd' => array(
461
- '5.4' => false,
462
- '5.5' => true,
463
- ),
464
- 'opcache.validate_timestamps' => array(
465
- '5.4' => false,
466
- '5.5' => true,
467
- ),
468
- 'opcache.revalidate_freq' => array(
469
- '5.4' => false,
470
- '5.5' => true,
471
- ),
472
- 'opcache.revalidate_path' => array(
473
- '5.4' => false,
474
- '5.5' => true,
475
- ),
476
- 'opcache.save_comments' => array(
477
- '5.4' => false,
478
- '5.5' => true,
479
- ),
480
- 'opcache.load_comments' => array(
481
- '5.4' => false,
482
- '5.5' => true,
483
- ),
484
- 'opcache.fast_shutdown' => array(
485
- '5.4' => false,
486
- '5.5' => true,
487
- ),
488
- 'opcache.enable_file_override' => array(
489
- '5.4' => false,
490
- '5.5' => true,
491
- ),
492
- 'opcache.optimization_level' => array(
493
- '5.4' => false,
494
- '5.5' => true,
495
- ),
496
- 'opcache.inherited_hack' => array(
497
- '5.4' => false,
498
- '5.5' => true,
499
- ),
500
- 'opcache.dups_fix' => array(
501
- '5.4' => false,
502
- '5.5' => true,
503
- ),
504
- 'opcache.blacklist_filename' => array(
505
- '5.4' => false,
506
- '5.5' => true,
507
- ),
508
- 'opcache.max_file_size' => array(
509
- '5.4' => false,
510
- '5.5' => true,
511
- ),
512
- 'opcache.consistency_checks' => array(
513
- '5.4' => false,
514
- '5.5' => true,
515
- ),
516
- 'opcache.force_restart_timeout' => array(
517
- '5.4' => false,
518
- '5.5' => true,
519
- ),
520
- 'opcache.error_log' => array(
521
- '5.4' => false,
522
- '5.5' => true,
523
- ),
524
- 'opcache.log_verbosity_level' => array(
525
- '5.4' => false,
526
- '5.5' => true,
527
- ),
528
- 'opcache.preferred_memory_model' => array(
529
- '5.4' => false,
530
- '5.5' => true,
531
- ),
532
- 'opcache.protect_memory' => array(
533
- '5.4' => false,
534
- '5.5' => true,
535
- ),
536
- 'opcache.mmap_base' => array(
537
- '5.4' => false,
538
- '5.5' => true,
539
- ),
540
- 'opcache.restrict_api' => array(
541
- '5.4' => false,
542
- '5.5' => true,
543
- ),
544
- 'opcache.file_update_protection' => array(
545
- '5.4' => false,
546
- '5.5' => true,
547
- ),
548
- 'opcache.huge_code_pages' => array(
549
- '5.4' => false,
550
- '5.5' => true,
551
- ),
552
- 'opcache.lockfile_path' => array(
553
- '5.4' => false,
554
- '5.5' => true,
555
- ),
556
- 'opcache.opt_debug_level' => array(
557
- '5.4' => false,
558
- '5.5' => true,
559
- ),
560
-
561
- 'session.use_strict_mode' => array(
562
- '5.5.1' => false,
563
- '5.5.2' => true,
564
- ),
565
-
566
- 'mysqli.rollback_on_cached_plink' => array(
567
- '5.5' => false,
568
- '5.6' => true,
569
- ),
570
-
571
- 'assert.exception' => array(
572
- '5.6' => false,
573
- '7.0' => true,
574
- ),
575
- 'pcre.jit' => array(
576
- '5.6' => false,
577
- '7.0' => true,
578
- ),
579
- 'session.lazy_write' => array(
580
- '5.6' => false,
581
- '7.0' => true,
582
- ),
583
- 'zend.assertions' => array(
584
- '5.6' => false,
585
- '7.0' => true,
586
- ),
587
- 'opcache.file_cache' => array(
588
- '5.6' => false,
589
- '7.0' => true,
590
- ),
591
- 'opcache.file_cache_only' => array(
592
- '5.6' => false,
593
- '7.0' => true,
594
- ),
595
- 'opcache.file_cache_consistency_checks' => array(
596
- '5.6' => false,
597
- '7.0' => true,
598
- ),
599
- 'opcache.file_cache_fallback' => array(
600
- '5.6' => false,
601
- '7.0' => true,
602
- ), // Windows only.
603
-
604
- 'opcache.validate_permission' => array(
605
- '7.0.13' => false,
606
- '7.0.14' => true,
607
- ),
608
- 'opcache.validate_root' => array(
609
- '7.0.13' => false,
610
- '7.0.14' => true,
611
- ),
612
-
613
- 'hard_timeout' => array(
614
- '7.0' => false,
615
- '7.1' => true,
616
- ),
617
- 'session.sid_length' => array(
618
- '7.0' => false,
619
- '7.1' => true,
620
- ),
621
- 'session.sid_bits_per_character' => array(
622
- '7.0' => false,
623
- '7.1' => true,
624
- ),
625
- 'session.trans_sid_hosts' => array(
626
- '7.0' => false,
627
- '7.1' => true,
628
- ),
629
- 'session.trans_sid_tags' => array(
630
- '7.0' => false,
631
- '7.1' => true,
632
- ),
633
- 'url_rewriter.hosts' => array(
634
- '7.0' => false,
635
- '7.1' => true,
636
- ),
637
-
638
- // Introduced in PHP 7.1.25, 7.2.13, 7.3.0.
639
- 'imap.enable_insecure_rsh' => array(
640
- '7.1.24' => false,
641
- '7.1.25' => true,
642
- ),
643
-
644
- 'syslog.facility' => array(
645
- '7.2' => false,
646
- '7.3' => true,
647
- ),
648
- 'syslog.filter' => array(
649
- '7.2' => false,
650
- '7.3' => true,
651
- ),
652
- 'syslog.ident' => array(
653
- '7.2' => false,
654
- '7.3' => true,
655
- ),
656
- 'session.cookie_samesite' => array(
657
- '7.2' => false,
658
- '7.3' => true,
659
- ),
660
-
661
- 'ffi.enable' => array(
662
- '7.3' => false,
663
- '7.4' => true,
664
- ),
665
- 'ffi.preload' => array(
666
- '7.3' => false,
667
- '7.4' => true,
668
- ),
669
- 'opcache.cache_id' => array(
670
- '7.3' => false,
671
- '7.4' => true,
672
- ),
673
- 'opcache.preload' => array(
674
- '7.3' => false,
675
- '7.4' => true,
676
- ),
677
- 'zend.exception_ignore_args' => array(
678
- '7.3' => false,
679
- '7.4' => true,
680
- ),
681
- );
682
-
683
- /**
684
- * Returns an array of tokens this test wants to listen for.
685
- *
686
- * @since 5.5
687
- *
688
- * @return array
689
- */
690
- public function register()
691
- {
692
- return array(\T_STRING);
693
- }
694
-
695
- /**
696
- * Processes this test, when one of its tokens is encountered.
697
- *
698
- * @since 5.5
699
- *
700
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
701
- * @param int $stackPtr The position of the current token in the
702
- * stack passed in $tokens.
703
- *
704
- * @return void
705
- */
706
- public function process(File $phpcsFile, $stackPtr)
707
- {
708
- $tokens = $phpcsFile->getTokens();
709
-
710
- $ignore = array(
711
- \T_DOUBLE_COLON => true,
712
- \T_OBJECT_OPERATOR => true,
713
- \T_FUNCTION => true,
714
- \T_CONST => true,
715
- );
716
-
717
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
718
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
719
- // Not a call to a PHP function.
720
- return;
721
- }
722
-
723
- $functionLc = strtolower($tokens[$stackPtr]['content']);
724
- if (isset($this->iniFunctions[$functionLc]) === false) {
725
- return;
726
- }
727
-
728
- $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
729
- if ($iniToken === false) {
730
- return;
731
- }
732
-
733
- $filteredToken = $this->stripQuotes($iniToken['raw']);
734
- if (isset($this->newIniDirectives[$filteredToken]) === false) {
735
- return;
736
- }
737
-
738
- $itemInfo = array(
739
- 'name' => $filteredToken,
740
- 'functionLc' => $functionLc,
741
- );
742
- $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
743
- }
744
-
745
-
746
- /**
747
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
748
- *
749
- * @since 7.1.0
750
- *
751
- * @param array $itemInfo Base information about the item.
752
- *
753
- * @return array Version and other information about the item.
754
- */
755
- public function getItemArray(array $itemInfo)
756
- {
757
- return $this->newIniDirectives[$itemInfo['name']];
758
- }
759
-
760
-
761
- /**
762
- * Get an array of the non-PHP-version array keys used in a sub-array.
763
- *
764
- * @since 7.1.0
765
- *
766
- * @return array
767
- */
768
- protected function getNonVersionArrayKeys()
769
- {
770
- return array('alternative');
771
- }
772
-
773
-
774
- /**
775
- * Retrieve the relevant detail (version) information for use in an error message.
776
- *
777
- * @since 7.1.0
778
- *
779
- * @param array $itemArray Version and other information about the item.
780
- * @param array $itemInfo Base information about the item.
781
- *
782
- * @return array
783
- */
784
- public function getErrorInfo(array $itemArray, array $itemInfo)
785
- {
786
- $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
787
- $errorInfo['alternative'] = '';
788
-
789
- if (isset($itemArray['alternative']) === true) {
790
- $errorInfo['alternative'] = $itemArray['alternative'];
791
- }
792
-
793
- // Lower error level to warning if the function used was ini_get.
794
- if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
795
- $errorInfo['error'] = false;
796
- }
797
-
798
- return $errorInfo;
799
- }
800
-
801
-
802
- /**
803
- * Get the error message template for this sniff.
804
- *
805
- * @since 7.1.0
806
- *
807
- * @return string
808
- */
809
- protected function getErrorMsgTemplate()
810
- {
811
- return "INI directive '%s' is not present in PHP version %s or earlier";
812
- }
813
-
814
-
815
- /**
816
- * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
817
- *
818
- * @since 7.1.0
819
- *
820
- * @param string $error The error message which was created.
821
- * @param array $itemInfo Base information about the item this error message applies to.
822
- * @param array $errorInfo Detail information about an item this error message applies to.
823
- *
824
- * @return string
825
- */
826
- protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
827
- {
828
- if ($errorInfo['alternative'] !== '') {
829
- $error .= ". This directive was previously called '%s'.";
830
- }
831
-
832
- return $error;
833
- }
834
-
835
-
836
- /**
837
- * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
838
- *
839
- * @since 7.1.0
840
- *
841
- * @param array $data The error data array which was created.
842
- * @param array $itemInfo Base information about the item this error message applies to.
843
- * @param array $errorInfo Detail information about an item this error message applies to.
844
- *
845
- * @return array
846
- */
847
- protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
848
- {
849
- if ($errorInfo['alternative'] !== '') {
850
- $data[] = $errorInfo['alternative'];
851
- }
852
-
853
- return $data;
854
- }
855
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/IniDirectives/RemovedIniDirectivesSniff.php DELETED
@@ -1,424 +0,0 @@
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\IniDirectives;
12
-
13
- use PHPCompatibility\AbstractRemovedFeatureSniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect the use of deprecated and removed INI directives through `ini_set()` or `ini_get()`.
18
- *
19
- * PHP version All
20
- *
21
- * @link https://www.php.net/manual/en/ini.list.php
22
- * @link https://www.php.net/manual/en/ini.core.php
23
- *
24
- * @since 5.5
25
- * @since 7.0.0 This sniff now throws a warning (deprecated) or an error (removed) depending
26
- * on the `testVersion` set. Previously it would always throw a warning.
27
- * @since 7.0.1 The sniff will now only throw warnings for `ini_get()`.
28
- * @since 7.1.0 Now extends the `AbstractRemovedFeatureSniff` instead of the base `Sniff` class.
29
- * @since 9.0.0 Renamed from `DeprecatedIniDirectivesSniff` to `RemovedIniDirectivesSniff`.
30
- */
31
- class RemovedIniDirectivesSniff extends AbstractRemovedFeatureSniff
32
- {
33
- /**
34
- * A list of deprecated/removed INI directives.
35
- *
36
- * The array lists : version number with false (deprecated) and true (removed).
37
- * If's sufficient to list the first version where the ini directive was deprecated/removed.
38
- *
39
- * @since 5.5
40
- * @since 7.0.3 Support for 'alternative' has been added.
41
- *
42
- * @var array(string)
43
- */
44
- protected $deprecatedIniDirectives = array(
45
- 'fbsql.batchSize' => array(
46
- '5.1' => true,
47
- 'alternative' => 'fbsql.batchsize',
48
- ),
49
- 'pfpro.defaulthost' => array(
50
- '5.1' => true,
51
- ),
52
- 'pfpro.defaultport' => array(
53
- '5.1' => true,
54
- ),
55
- 'pfpro.defaulttimeout' => array(
56
- '5.1' => true,
57
- ),
58
- 'pfpro.proxyaddress' => array(
59
- '5.1' => true,
60
- ),
61
- 'pfpro.proxyport' => array(
62
- '5.1' => true,
63
- ),
64
- 'pfpro.proxylogon' => array(
65
- '5.1' => true,
66
- ),
67
- 'pfpro.proxypassword' => array(
68
- '5.1' => true,
69
- ),
70
-
71
- 'ifx.allow_persistent' => array(
72
- '5.2.1' => true,
73
- ),
74
- 'ifx.blobinfile' => array(
75
- '5.2.1' => true,
76
- ),
77
- 'ifx.byteasvarchar' => array(
78
- '5.2.1' => true,
79
- ),
80
- 'ifx.charasvarchar' => array(
81
- '5.2.1' => true,
82
- ),
83
- 'ifx.default_host' => array(
84
- '5.2.1' => true,
85
- ),
86
- 'ifx.default_password' => array(
87
- '5.2.1' => true,
88
- ),
89
- 'ifx.default_user' => array(
90
- '5.2.1' => true,
91
- ),
92
- 'ifx.max_links' => array(
93
- '5.2.1' => true,
94
- ),
95
- 'ifx.max_persistent' => array(
96
- '5.2.1' => true,
97
- ),
98
- 'ifx.nullformat' => array(
99
- '5.2.1' => true,
100
- ),
101
- 'ifx.textasvarchar' => array(
102
- '5.2.1' => true,
103
- ),
104
-
105
- 'zend.ze1_compatibility_mode' => array(
106
- '5.3' => true,
107
- ),
108
-
109
- 'allow_call_time_pass_reference' => array(
110
- '5.3' => false,
111
- '5.4' => true,
112
- ),
113
- 'define_syslog_variables' => array(
114
- '5.3' => false,
115
- '5.4' => true,
116
- ),
117
- 'detect_unicode' => array(
118
- '5.4' => true,
119
- 'alternative' => 'zend.detect_unicode',
120
- ),
121
- 'highlight.bg' => array(
122
- '5.3' => false,
123
- '5.4' => true,
124
- ),
125
- 'magic_quotes_gpc' => array(
126
- '5.3' => false,
127
- '5.4' => true,
128
- ),
129
- 'magic_quotes_runtime' => array(
130
- '5.3' => false,
131
- '5.4' => true,
132
- ),
133
- 'magic_quotes_sybase' => array(
134
- '5.3' => false,
135
- '5.4' => true,
136
- ),
137
- 'mbstring.script_encoding' => array(
138
- '5.4' => true,
139
- 'alternative' => 'zend.script_encoding',
140
- ),
141
- 'register_globals' => array(
142
- '5.3' => false,
143
- '5.4' => true,
144
- ),
145
- 'register_long_arrays' => array(
146
- '5.3' => false,
147
- '5.4' => true,
148
- ),
149
- 'safe_mode' => array(
150
- '5.3' => false,
151
- '5.4' => true,
152
- ),
153
- 'safe_mode_allowed_env_vars' => array(
154
- '5.3' => false,
155
- '5.4' => true,
156
- ),
157
- 'safe_mode_exec_dir' => array(
158
- '5.3' => false,
159
- '5.4' => true,
160
- ),
161
- 'safe_mode_gid' => array(
162
- '5.3' => false,
163
- '5.4' => true,
164
- ),
165
- 'safe_mode_include_dir' => array(
166
- '5.3' => false,
167
- '5.4' => true,
168
- ),
169
- 'safe_mode_protected_env_vars' => array(
170
- '5.3' => false,
171
- '5.4' => true,
172
- ),
173
- 'session.bug_compat_42' => array(
174
- '5.3' => false,
175
- '5.4' => true,
176
- ),
177
- 'session.bug_compat_warn' => array(
178
- '5.3' => false,
179
- '5.4' => true,
180
- ),
181
- 'y2k_compliance' => array(
182
- '5.3' => false,
183
- '5.4' => true,
184
- ),
185
-
186
- 'always_populate_raw_post_data' => array(
187
- '5.6' => false,
188
- '7.0' => true,
189
- ),
190
- 'iconv.input_encoding' => array(
191
- '5.6' => false,
192
- ),
193
- 'iconv.output_encoding' => array(
194
- '5.6' => false,
195
- ),
196
- 'iconv.internal_encoding' => array(
197
- '5.6' => false,
198
- ),
199
- 'mbstring.http_input' => array(
200
- '5.6' => false,
201
- ),
202
- 'mbstring.http_output' => array(
203
- '5.6' => false,
204
- ),
205
- 'mbstring.internal_encoding' => array(
206
- '5.6' => false,
207
- ),
208
-
209
- 'asp_tags' => array(
210
- '7.0' => true,
211
- ),
212
- 'xsl.security_prefs' => array(
213
- '7.0' => true,
214
- ),
215
- 'opcache.load_comments' => array(
216
- '7.0' => true,
217
- ),
218
-
219
- 'mcrypt.algorithms_dir' => array(
220
- '7.1' => false,
221
- '7.2' => true,
222
- ),
223
- 'mcrypt.modes_dir' => array(
224
- '7.1' => false,
225
- '7.2' => true,
226
- ),
227
- 'session.entropy_file' => array(
228
- '7.1' => true,
229
- ),
230
- 'session.entropy_length' => array(
231
- '7.1' => true,
232
- ),
233
- 'session.hash_function' => array(
234
- '7.1' => true,
235
- ),
236
- 'session.hash_bits_per_character' => array(
237
- '7.1' => true,
238
- ),
239
-
240
- 'mbstring.func_overload' => array(
241
- '7.2' => false,
242
- ),
243
- 'sql.safe_mode' => array(
244
- '7.2' => true,
245
- ),
246
- 'track_errors' => array(
247
- '7.2' => false,
248
- ),
249
- 'opcache.fast_shutdown' => array(
250
- '7.2' => true,
251
- ),
252
-
253
- 'birdstep.max_links' => array(
254
- '7.3' => true,
255
- ),
256
- 'opcache.inherited_hack' => array(
257
- '5.3' => false, // Soft deprecated, i.e. ignored.
258
- '7.3' => true,
259
- ),
260
- 'pdo_odbc.db2_instance_name' => array(
261
- '7.3' => false, // Has been marked as deprecated in the manual from before this time. Now hard-deprecated.
262
- ),
263
-
264
- 'allow_url_include' => array(
265
- '7.4' => false,
266
- ),
267
- 'ibase.allow_persistent' => array(
268
- '7.4' => true,
269
- ),
270
- 'ibase.max_persistent' => array(
271
- '7.4' => true,
272
- ),
273
- 'ibase.max_links' => array(
274
- '7.4' => true,
275
- ),
276
- 'ibase.default_db' => array(
277
- '7.4' => true,
278
- ),
279
- 'ibase.default_user' => array(
280
- '7.4' => true,
281
- ),
282
- 'ibase.default_password' => array(
283
- '7.4' => true,
284
- ),
285
- 'ibase.default_charset' => array(
286
- '7.4' => true,
287
- ),
288
- 'ibase.timestampformat' => array(
289
- '7.4' => true,
290
- ),
291
- 'ibase.dateformat' => array(
292
- '7.4' => true,
293
- ),
294
- 'ibase.timeformat' => array(
295
- '7.4' => true,
296
- ),
297
- );
298
-
299
- /**
300
- * Returns an array of tokens this test wants to listen for.
301
- *
302
- * @since 5.5
303
- *
304
- * @return array
305
- */
306
- public function register()
307
- {
308
- return array(\T_STRING);
309
- }
310
-
311
- /**
312
- * Processes this test, when one of its tokens is encountered.
313
- *
314
- * @since 5.5
315
- *
316
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
317
- * @param int $stackPtr The position of the current token in the
318
- * stack passed in $tokens.
319
- *
320
- * @return void
321
- */
322
- public function process(File $phpcsFile, $stackPtr)
323
- {
324
- $tokens = $phpcsFile->getTokens();
325
-
326
- $ignore = array(
327
- \T_DOUBLE_COLON => true,
328
- \T_OBJECT_OPERATOR => true,
329
- \T_FUNCTION => true,
330
- \T_CONST => true,
331
- );
332
-
333
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
334
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
335
- // Not a call to a PHP function.
336
- return;
337
- }
338
-
339
- $functionLc = strtolower($tokens[$stackPtr]['content']);
340
- if (isset($this->iniFunctions[$functionLc]) === false) {
341
- return;
342
- }
343
-
344
- $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
345
- if ($iniToken === false) {
346
- return;
347
- }
348
-
349
- $filteredToken = $this->stripQuotes($iniToken['raw']);
350
- if (isset($this->deprecatedIniDirectives[$filteredToken]) === false) {
351
- return;
352
- }
353
-
354
- $itemInfo = array(
355
- 'name' => $filteredToken,
356
- 'functionLc' => $functionLc,
357
- );
358
- $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
359
- }
360
-
361
-
362
- /**
363
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
364
- *
365
- * @since 7.1.0
366
- *
367
- * @param array $itemInfo Base information about the item.
368
- *
369
- * @return array Version and other information about the item.
370
- */
371
- public function getItemArray(array $itemInfo)
372
- {
373
- return $this->deprecatedIniDirectives[$itemInfo['name']];
374
- }
375
-
376
-
377
- /**
378
- * Retrieve the relevant detail (version) information for use in an error message.
379
- *
380
- * @since 7.1.0
381
- *
382
- * @param array $itemArray Version and other information about the item.
383
- * @param array $itemInfo Base information about the item.
384
- *
385
- * @return array
386
- */
387
- public function getErrorInfo(array $itemArray, array $itemInfo)
388
- {
389
- $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
390
-
391
- // Lower error level to warning if the function used was ini_get.
392
- if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
393
- $errorInfo['error'] = false;
394
- }
395
-
396
- return $errorInfo;
397
- }
398
-
399
-
400
- /**
401
- * Get the error message template for this sniff.
402
- *
403
- * @since 7.1.0
404
- *
405
- * @return string
406
- */
407
- protected function getErrorMsgTemplate()
408
- {
409
- return "INI directive '%s' is ";
410
- }
411
-
412
-
413
- /**
414
- * Get the error message template for suggesting an alternative for a specific sniff.
415
- *
416
- * @since 7.1.0
417
- *
418
- * @return string
419
- */
420
- protected function getAlternativeOptionTemplate()
421
- {
422
- return str_replace('%s', "'%s'", parent::getAlternativeOptionTemplate());
423
- }
424
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewConstantArraysUsingConstSniff.php DELETED
@@ -1,82 +0,0 @@
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\InitialValue;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect declaration of constants using the `const` keyword with a (constant) array value
18
- * as supported since PHP 5.6.
19
- *
20
- * PHP version 5.6
21
- *
22
- * @link https://wiki.php.net/rfc/const_scalar_exprs
23
- * @link https://www.php.net/manual/en/language.constants.syntax.php
24
- *
25
- * @since 7.1.4
26
- * @since 9.0.0 Renamed from `ConstantArraysUsingConstSniff` to `NewConstantArraysUsingConstSniff`.
27
- */
28
- class NewConstantArraysUsingConstSniff extends Sniff
29
- {
30
-
31
- /**
32
- * Returns an array of tokens this test wants to listen for.
33
- *
34
- * @since 7.1.4
35
- *
36
- * @return array
37
- */
38
- public function register()
39
- {
40
- return array(\T_CONST);
41
- }
42
-
43
- /**
44
- * Processes this test, when one of its tokens is encountered.
45
- *
46
- * @since 7.1.4
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(File $phpcsFile, $stackPtr)
55
- {
56
- if ($this->supportsBelow('5.5') !== true) {
57
- return;
58
- }
59
-
60
- $tokens = $phpcsFile->getTokens();
61
- $find = array(
62
- \T_ARRAY => \T_ARRAY,
63
- \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
64
- );
65
-
66
- while (($hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true)) !== false) {
67
- $phpcsFile->addError(
68
- 'Constant arrays using the "const" keyword are not allowed in PHP 5.5 or earlier',
69
- $hasArray,
70
- 'Found'
71
- );
72
-
73
- // Skip past the content of the array.
74
- $stackPtr = $hasArray;
75
- if ($tokens[$hasArray]['code'] === \T_OPEN_SHORT_ARRAY && isset($tokens[$hasArray]['bracket_closer'])) {
76
- $stackPtr = $tokens[$hasArray]['bracket_closer'];
77
- } elseif ($tokens[$hasArray]['code'] === \T_ARRAY && isset($tokens[$hasArray]['parenthesis_closer'])) {
78
- $stackPtr = $tokens[$hasArray]['parenthesis_closer'];
79
- }
80
- }
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewConstantArraysUsingDefineSniff.php DELETED
@@ -1,101 +0,0 @@
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\InitialValue;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect declaration of constants using `define()` with a (constant) array value
18
- * as supported since PHP 7.0.
19
- *
20
- * PHP version 7.0
21
- *
22
- * @link https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.define-array
23
- * @link https://www.php.net/manual/en/language.constants.syntax.php
24
- *
25
- * @since 7.0.0
26
- * @since 9.0.0 Renamed from `ConstantArraysUsingDefineSniff` to `NewConstantArraysUsingDefineSniff`.
27
- */
28
- class NewConstantArraysUsingDefineSniff extends Sniff
29
- {
30
-
31
- /**
32
- * Returns an array of tokens this test wants to listen for.
33
- *
34
- * @since 7.0.0
35
- *
36
- * @return array
37
- */
38
- public function register()
39
- {
40
- return array(\T_STRING);
41
- }
42
-
43
- /**
44
- * Processes this test, when one of its tokens is encountered.
45
- *
46
- * @since 7.0.0
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(File $phpcsFile, $stackPtr)
55
- {
56
- if ($this->supportsBelow('5.6') !== true) {
57
- return;
58
- }
59
-
60
- $tokens = $phpcsFile->getTokens();
61
-
62
- $ignore = array(
63
- \T_DOUBLE_COLON => true,
64
- \T_OBJECT_OPERATOR => true,
65
- \T_FUNCTION => true,
66
- \T_CONST => true,
67
- );
68
-
69
- $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
70
- if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
71
- // Not a call to a PHP function.
72
- return;
73
- }
74
-
75
- $functionLc = strtolower($tokens[$stackPtr]['content']);
76
- if ($functionLc !== 'define') {
77
- return;
78
- }
79
-
80
- $secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2);
81
- if (isset($secondParam['start'], $secondParam['end']) === false) {
82
- return;
83
- }
84
-
85
- $targetNestingLevel = 0;
86
- if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
87
- $targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);
88
- }
89
-
90
- $array = $phpcsFile->findNext(array(\T_ARRAY, \T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
91
- if ($array !== false) {
92
- if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
93
- $phpcsFile->addError(
94
- 'Constant arrays using define are not allowed in PHP 5.6 or earlier',
95
- $array,
96
- 'Found'
97
- );
98
- }
99
- }
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewConstantScalarExpressionsSniff.php DELETED
@@ -1,556 +0,0 @@
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\InitialValue;
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 constant scalar expressions being used to set an initial value.
20
- *
21
- * Since PHP 5.6, it is now possible to provide a scalar expression involving
22
- * numeric and string literals and/or constants in contexts where PHP previously
23
- * expected a static value, such as constant and property declarations and
24
- * default values for function parameters.
25
- *
26
- * PHP version 5.6
27
- *
28
- * @link https://www.php.net/manual/en/migration56.new-features.php#migration56.new-features.const-scalar-exprs
29
- * @link https://wiki.php.net/rfc/const_scalar_exprs
30
- *
31
- * @since 8.2.0
32
- */
33
- class NewConstantScalarExpressionsSniff extends Sniff
34
- {
35
-
36
- /**
37
- * Error message.
38
- *
39
- * @since 8.2.0
40
- *
41
- * @var string
42
- */
43
- const ERROR_PHRASE = 'Constant scalar expressions are not allowed %s in PHP 5.5 or earlier.';
44
-
45
- /**
46
- * Partial error phrases to be used in combination with the error message constant.
47
- *
48
- * @since 8.2.0
49
- *
50
- * @var array
51
- */
52
- protected $errorPhrases = array(
53
- 'const' => 'when defining constants using the const keyword',
54
- 'property' => 'in property declarations',
55
- 'staticvar' => 'in static variable declarations',
56
- 'default' => 'in default function arguments',
57
- );
58
-
59
- /**
60
- * Tokens which were allowed to be used in these declarations prior to PHP 5.6.
61
- *
62
- * This list will be enriched in the setProperties() method.
63
- *
64
- * @since 8.2.0
65
- *
66
- * @var array
67
- */
68
- protected $safeOperands = array(
69
- \T_LNUMBER => \T_LNUMBER,
70
- \T_DNUMBER => \T_DNUMBER,
71
- \T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING,
72
- \T_TRUE => \T_TRUE,
73
- \T_FALSE => \T_FALSE,
74
- \T_NULL => \T_NULL,
75
-
76
- \T_LINE => \T_LINE,
77
- \T_FILE => \T_FILE,
78
- \T_DIR => \T_DIR,
79
- \T_FUNC_C => \T_FUNC_C,
80
- \T_CLASS_C => \T_CLASS_C,
81
- \T_TRAIT_C => \T_TRAIT_C,
82
- \T_METHOD_C => \T_METHOD_C,
83
- \T_NS_C => \T_NS_C,
84
-
85
- // Special cases:
86
- \T_NS_SEPARATOR => \T_NS_SEPARATOR,
87
- /*
88
- * This can be neigh anything, but for any usage except constants,
89
- * the T_STRING will be combined with non-allowed tokens, so we should be good.
90
- */
91
- \T_STRING => \T_STRING,
92
- );
93
-
94
-
95
- /**
96
- * Returns an array of tokens this test wants to listen for.
97
- *
98
- * @since 8.2.0
99
- *
100
- * @return array
101
- */
102
- public function register()
103
- {
104
- // Set the properties up only once.
105
- $this->setProperties();
106
-
107
- return array(
108
- \T_CONST,
109
- \T_VARIABLE,
110
- \T_FUNCTION,
111
- \T_CLOSURE,
112
- \T_STATIC,
113
- );
114
- }
115
-
116
-
117
- /**
118
- * Make some adjustments to the $safeOperands property.
119
- *
120
- * @since 8.2.0
121
- *
122
- * @return void
123
- */
124
- public function setProperties()
125
- {
126
- $this->safeOperands += Tokens::$heredocTokens;
127
- $this->safeOperands += Tokens::$emptyTokens;
128
- }
129
-
130
-
131
- /**
132
- * Do a version check to determine if this sniff needs to run at all.
133
- *
134
- * @since 8.2.0
135
- *
136
- * @return bool
137
- */
138
- protected function bowOutEarly()
139
- {
140
- return ($this->supportsBelow('5.5') !== true);
141
- }
142
-
143
-
144
- /**
145
- * Processes this test, when one of its tokens is encountered.
146
- *
147
- * @since 8.2.0
148
- *
149
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
150
- * @param int $stackPtr The position of the current token in the
151
- * stack passed in $tokens.
152
- *
153
- * @return void|int Null or integer stack pointer to skip forward.
154
- */
155
- public function process(File $phpcsFile, $stackPtr)
156
- {
157
- if ($this->bowOutEarly() === true) {
158
- return;
159
- }
160
-
161
- $tokens = $phpcsFile->getTokens();
162
-
163
- switch ($tokens[$stackPtr]['type']) {
164
- case 'T_FUNCTION':
165
- case 'T_CLOSURE':
166
- $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
167
- if (empty($params)) {
168
- // No parameters.
169
- return;
170
- }
171
-
172
- $funcToken = $tokens[$stackPtr];
173
-
174
- if (isset($funcToken['parenthesis_owner'], $funcToken['parenthesis_opener'], $funcToken['parenthesis_closer']) === false
175
- || $funcToken['parenthesis_owner'] !== $stackPtr
176
- || isset($tokens[$funcToken['parenthesis_opener']], $tokens[$funcToken['parenthesis_closer']]) === false
177
- ) {
178
- // Hmm.. something is going wrong as these should all be available & valid.
179
- return;
180
- }
181
-
182
- $opener = $funcToken['parenthesis_opener'];
183
- $closer = $funcToken['parenthesis_closer'];
184
-
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) {
192
- if (isset($param['default']) === false) {
193
- continue;
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;
201
- continue;
202
- }
203
-
204
- // Ignore closing parenthesis/bracket if not 'ours'.
205
- if ($tokens[$end]['code'] === \T_CLOSE_PARENTHESIS && $end !== $closer) {
206
- continue;
207
- }
208
-
209
- // Ok, we've found the end of the param default value declaration.
210
- break;
211
- }
212
-
213
- if ($this->isValidAssignment($phpcsFile, $param['token'], $end) === false) {
214
- $this->throwError($phpcsFile, $param['token'], 'default', $param['content']);
215
- }
216
- }
217
-
218
- /*
219
- * No need for the sniff to be triggered by the T_VARIABLEs in the function
220
- * definition as we've already examined them above, so let's skip over them.
221
- */
222
- return $closer;
223
-
224
- case 'T_VARIABLE':
225
- case 'T_STATIC':
226
- case 'T_CONST':
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
- }
234
-
235
- $type = 'property';
236
-
237
- // Move back one token to have the same starting point as the others.
238
- $stackPtr = ($stackPtr - 1);
239
- }
240
-
241
- // Filter out late static binding and class properties.
242
- if ($tokens[$stackPtr]['code'] === \T_STATIC) {
243
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
244
- if ($next === false || $tokens[$next]['code'] !== \T_VARIABLE) {
245
- // Late static binding.
246
- return;
247
- }
248
-
249
- if ($this->isClassProperty($phpcsFile, $next) === true) {
250
- // Class properties are examined based on the T_VARIABLE token.
251
- return;
252
- }
253
- unset($next);
254
-
255
- $type = 'staticvar';
256
- }
257
-
258
- $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1));
259
- if ($endOfStatement === false) {
260
- // No semi-colon - live coding.
261
- return;
262
- }
263
-
264
- $targetNestingLevel = 0;
265
- if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
266
- $targetNestingLevel = \count($tokens[$stackPtr]['nested_parenthesis']);
267
- }
268
-
269
- // Examine each variable/constant in multi-declarations.
270
- $start = $stackPtr;
271
- $end = $stackPtr;
272
- while (($end = $phpcsFile->findNext(array(\T_COMMA, \T_SEMICOLON, \T_OPEN_SHORT_ARRAY, \T_CLOSE_TAG), ($end + 1), ($endOfStatement + 1))) !== false) {
273
-
274
- $maybeSkipTo = $this->isRealEndOfDeclaration($tokens, $end, $targetNestingLevel);
275
- if ($maybeSkipTo !== true) {
276
- $end = $maybeSkipTo;
277
- continue;
278
- }
279
-
280
- $start = $phpcsFile->findNext(Tokens::$emptyTokens, ($start + 1), $end, true);
281
- if ($start === false
282
- || ($tokens[$stackPtr]['code'] === \T_CONST && $tokens[$start]['code'] !== \T_STRING)
283
- || ($tokens[$stackPtr]['code'] !== \T_CONST && $tokens[$start]['code'] !== \T_VARIABLE)
284
- ) {
285
- // Shouldn't be possible.
286
- continue;
287
- }
288
-
289
- if ($this->isValidAssignment($phpcsFile, $start, $end) === false) {
290
- // Create the "found" snippet.
291
- $content = '';
292
- $tokenCount = ($end - $start);
293
- if ($tokenCount < 20) {
294
- // Prevent large arrays from being added to the error message.
295
- $content = $phpcsFile->getTokensAsString($start, ($tokenCount + 1));
296
- }
297
-
298
- $this->throwError($phpcsFile, $start, $type, $content);
299
- }
300
-
301
- $start = $end;
302
- }
303
-
304
- // Skip to the end of the statement to prevent duplicate messages for multi-declarations.
305
- return $endOfStatement;
306
- }
307
- }
308
-
309
-
310
- /**
311
- * Is a value declared and is the value declared valid pre-PHP 5.6 ?
312
- *
313
- * @since 8.2.0
314
- *
315
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
316
- * @param int $stackPtr The position of the current token in the
317
- * stack passed in $tokens.
318
- * @param int $end The end of the value definition.
319
- * This will normally be a comma or semi-colon.
320
- *
321
- * @return bool
322
- */
323
- protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
324
- {
325
- $tokens = $phpcsFile->getTokens();
326
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
327
- if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
328
- // No value assigned.
329
- return true;
330
- }
331
-
332
- return $this->isStaticValue($phpcsFile, $tokens, ($next + 1), ($end - 1));
333
- }
334
-
335
-
336
- /**
337
- * Is a value declared and is the value declared constant as accepted in PHP 5.5 and lower ?
338
- *
339
- * @since 8.2.0
340
- *
341
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
342
- * @param array $tokens The token stack of the current file.
343
- * @param int $start The stackPtr from which to start examining.
344
- * @param int $end The end of the value definition (inclusive),
345
- * i.e. this token will be examined as part of
346
- * the snippet.
347
- * @param int $nestedArrays Optional. Array nesting level when examining
348
- * the content of an array.
349
- *
350
- * @return bool
351
- */
352
- protected function isStaticValue(File $phpcsFile, $tokens, $start, $end, $nestedArrays = 0)
353
- {
354
- $nextNonSimple = $phpcsFile->findNext($this->safeOperands, $start, ($end + 1), true);
355
- if ($nextNonSimple === false) {
356
- return true;
357
- }
358
-
359
- /*
360
- * OK, so we have at least one token which needs extra examination.
361
- */
362
- switch ($tokens[$nextNonSimple]['code']) {
363
- case \T_MINUS:
364
- case \T_PLUS:
365
- if ($this->isNumber($phpcsFile, $start, $end, true) !== false) {
366
- // Int or float with sign.
367
- return true;
368
- }
369
-
370
- return false;
371
-
372
- case \T_NAMESPACE:
373
- case \T_PARENT:
374
- case \T_SELF:
375
- case \T_DOUBLE_COLON:
376
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonSimple + 1), ($end + 1), true);
377
-
378
- if ($tokens[$nextNonSimple]['code'] === \T_NAMESPACE) {
379
- // Allow only `namespace\...`.
380
- if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_NS_SEPARATOR) {
381
- return false;
382
- }
383
- } elseif ($tokens[$nextNonSimple]['code'] === \T_PARENT
384
- || $tokens[$nextNonSimple]['code'] === \T_SELF
385
- ) {
386
- // Allow only `parent::` and `self::`.
387
- if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
388
- return false;
389
- }
390
- } elseif ($tokens[$nextNonSimple]['code'] === \T_DOUBLE_COLON) {
391
- // Allow only `T_STRING::T_STRING`.
392
- if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
393
- return false;
394
- }
395
-
396
- $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextNonSimple - 1), null, true);
397
- // No need to worry about parent/self, that's handled above and
398
- // the double colon is skipped over in that case.
399
- if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['code'] !== \T_STRING) {
400
- return false;
401
- }
402
- }
403
-
404
- // Examine what comes after the namespace/parent/self/double colon, if anything.
405
- return $this->isStaticValue($phpcsFile, $tokens, ($nextNonEmpty + 1), $end, $nestedArrays);
406
-
407
- case \T_ARRAY:
408
- case \T_OPEN_SHORT_ARRAY:
409
- ++$nestedArrays;
410
-
411
- $arrayItems = $this->getFunctionCallParameters($phpcsFile, $nextNonSimple);
412
- if (empty($arrayItems) === false) {
413
- foreach ($arrayItems as $item) {
414
- // Check for a double arrow, but only if it's for this array item, not for a nested array.
415
- $doubleArrow = false;
416
-
417
- $maybeDoubleArrow = $phpcsFile->findNext(
418
- array(\T_DOUBLE_ARROW, \T_ARRAY, \T_OPEN_SHORT_ARRAY),
419
- $item['start'],
420
- ($item['end'] + 1)
421
- );
422
- if ($maybeDoubleArrow !== false && $tokens[$maybeDoubleArrow]['code'] === \T_DOUBLE_ARROW) {
423
- // Double arrow is for this nesting level.
424
- $doubleArrow = $maybeDoubleArrow;
425
- }
426
-
427
- if ($doubleArrow === false) {
428
- if ($this->isStaticValue($phpcsFile, $tokens, $item['start'], $item['end'], $nestedArrays) === false) {
429
- return false;
430
- }
431
-
432
- } else {
433
- // Examine array key.
434
- if ($this->isStaticValue($phpcsFile, $tokens, $item['start'], ($doubleArrow - 1), $nestedArrays) === false) {
435
- return false;
436
- }
437
-
438
- // Examine array value.
439
- if ($this->isStaticValue($phpcsFile, $tokens, ($doubleArrow + 1), $item['end'], $nestedArrays) === false) {
440
- return false;
441
- }
442
- }
443
- }
444
- }
445
-
446
- --$nestedArrays;
447
-
448
- /*
449
- * Find the end of the array.
450
- * We already know we will have a valid closer as otherwise we wouldn't have been
451
- * able to get the array items.
452
- */
453
- $closer = ($nextNonSimple + 1);
454
- if ($tokens[$nextNonSimple]['code'] === \T_OPEN_SHORT_ARRAY
455
- && isset($tokens[$nextNonSimple]['bracket_closer']) === true
456
- ) {
457
- $closer = $tokens[$nextNonSimple]['bracket_closer'];
458
- } else {
459
- $maybeOpener = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonSimple + 1), ($end + 1), true);
460
- if ($tokens[$maybeOpener]['code'] === \T_OPEN_PARENTHESIS) {
461
- $opener = $maybeOpener;
462
- if (isset($tokens[$opener]['parenthesis_closer']) === true) {
463
- $closer = $tokens[$opener]['parenthesis_closer'];
464
- }
465
- }
466
- }
467
-
468
- if ($closer === $end) {
469
- return true;
470
- }
471
-
472
- // Examine what comes after the array, if anything.
473
- return $this->isStaticValue($phpcsFile, $tokens, ($closer + 1), $end, $nestedArrays);
474
-
475
- }
476
-
477
- // Ok, so this unsafe token was not one of the exceptions, i.e. this is a PHP 5.6+ syntax.
478
- return false;
479
- }
480
-
481
-
482
- /**
483
- * Throw an error if a scalar expression is found.
484
- *
485
- * @since 8.2.0
486
- *
487
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
488
- * @param int $stackPtr The position of the token to link the error to.
489
- * @param string $type Type of usage found.
490
- * @param string $content Optional. The value for the declaration as found.
491
- *
492
- * @return void
493
- */
494
- protected function throwError(File $phpcsFile, $stackPtr, $type, $content = '')
495
- {
496
- $error = static::ERROR_PHRASE;
497
- $phrase = '';
498
- $errorCode = 'Found';
499
-
500
- if (isset($this->errorPhrases[$type]) === true) {
501
- $errorCode = $this->stringToErrorCode($type) . 'Found';
502
- $phrase = $this->errorPhrases[$type];
503
- }
504
-
505
- $data = array($phrase);
506
-
507
- if (empty($content) === false) {
508
- $error .= ' Found: %s';
509
- $data[] = $content;
510
- }
511
-
512
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
513
- }
514
-
515
-
516
- /**
517
- * Helper function to find the end of multi variable/constant declarations.
518
- *
519
- * Checks whether a certain part of a declaration needs to be skipped over or
520
- * if it is the real end of the declaration.
521
- *
522
- * @since 8.2.0
523
- *
524
- * @param array $tokens Token stack of the current file.
525
- * @param int $endPtr The token to examine as a candidate end pointer.
526
- * @param int $targetLevel Target nesting level.
527
- *
528
- * @return bool|int True if this is the real end. Int stackPtr to skip to if not.
529
- */
530
- private function isRealEndOfDeclaration($tokens, $endPtr, $targetLevel)
531
- {
532
- // Ignore anything within short array definition brackets for now.
533
- if ($tokens[$endPtr]['code'] === \T_OPEN_SHORT_ARRAY
534
- && (isset($tokens[$endPtr]['bracket_opener'])
535
- && $tokens[$endPtr]['bracket_opener'] === $endPtr)
536
- && isset($tokens[$endPtr]['bracket_closer'])
537
- ) {
538
- // Skip forward to the end of the short array definition.
539
- return $tokens[$endPtr]['bracket_closer'];
540
- }
541
-
542
- // Skip past comma's at a lower nesting level.
543
- if ($tokens[$endPtr]['code'] === \T_COMMA) {
544
- // Check if a comma is at the nesting level we're targetting.
545
- $nestingLevel = 0;
546
- if (isset($tokens[$endPtr]['nested_parenthesis']) === true) {
547
- $nestingLevel = \count($tokens[$endPtr]['nested_parenthesis']);
548
- }
549
- if ($nestingLevel > $targetLevel) {
550
- return $endPtr;
551
- }
552
- }
553
-
554
- return true;
555
- }
556
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewHeredocSniff.php DELETED
@@ -1,100 +0,0 @@
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\InitialValue;
12
-
13
- use PHPCompatibility\Sniffs\InitialValue\NewConstantScalarExpressionsSniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detect a heredoc being used to set an initial value.
19
- *
20
- * As of PHP 5.3.0, it's possible to initialize static variables, class properties
21
- * and constants declared using the `const` keyword, using the Heredoc syntax.
22
- * And while not documented, heredoc initialization can now also be used for function param defaults.
23
- * See: https://3v4l.org/JVH8W
24
- *
25
- * These heredocs (still) cannot contain variables. That's, however, outside the scope of the
26
- * PHPCompatibility library until such time as there is a PHP version in which this would be accepted.
27
- *
28
- * PHP version 5.3
29
- *
30
- * @link https://www.php.net/manual/en/migration53.new-features.php
31
- * @link https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
32
- *
33
- * @since 7.1.4
34
- * @since 8.2.0 Now extends the NewConstantScalarExpressionsSniff instead of the base Sniff class.
35
- * @since 9.0.0 Renamed from `NewHeredocInitializeSniff` to `NewHeredocSniff`.
36
- */
37
- class NewHeredocSniff extends NewConstantScalarExpressionsSniff
38
- {
39
-
40
- /**
41
- * Error message.
42
- *
43
- * @since 8.2.0
44
- *
45
- * @var string
46
- */
47
- const ERROR_PHRASE = 'Initializing %s using the Heredoc syntax was not supported in PHP 5.2 or earlier';
48
-
49
- /**
50
- * Partial error phrases to be used in combination with the error message constant.
51
- *
52
- * @since 8.2.0
53
- *
54
- * @var array
55
- */
56
- protected $errorPhrases = array(
57
- 'const' => 'constants',
58
- 'property' => 'class properties',
59
- 'staticvar' => 'static variables',
60
- 'default' => 'default parameter values',
61
- );
62
-
63
-
64
- /**
65
- * Do a version check to determine if this sniff needs to run at all.
66
- *
67
- * @since 8.2.0
68
- *
69
- * @return bool
70
- */
71
- protected function bowOutEarly()
72
- {
73
- return ($this->supportsBelow('5.2') !== true);
74
- }
75
-
76
-
77
- /**
78
- * Is a value declared and does the declared value not contain an heredoc ?
79
- *
80
- * @since 8.2.0
81
- *
82
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
83
- * @param int $stackPtr The position of the current token in the
84
- * stack passed in $tokens.
85
- * @param int $end The end of the value definition.
86
- *
87
- * @return bool True if no heredoc (or assignment) is found, false otherwise.
88
- */
89
- protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
90
- {
91
- $tokens = $phpcsFile->getTokens();
92
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
93
- if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
94
- // No value assigned.
95
- return true;
96
- }
97
-
98
- return ($phpcsFile->findNext(\T_START_HEREDOC, ($next + 1), $end, false, null, true) === false);
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/InternalInterfacesSniff.php DELETED
@@ -1,103 +0,0 @@
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\Interfaces;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHPCompatibility\PHPCSHelper;
15
- use PHP_CodeSniffer_File as File;
16
-
17
- /**
18
- * Detect classes which implement PHP native interfaces intended only for PHP internal use.
19
- *
20
- * PHP version 5.0+
21
- *
22
- * @link https://www.php.net/manual/en/class.traversable.php
23
- * @link https://www.php.net/manual/en/class.throwable.php
24
- * @link https://www.php.net/manual/en/class.datetimeinterface.php
25
- *
26
- * @since 7.0.3
27
- */
28
- class InternalInterfacesSniff extends Sniff
29
- {
30
-
31
- /**
32
- * A list of PHP internal interfaces, not intended to be implemented by userland classes.
33
- *
34
- * The array lists : the error message to use.
35
- *
36
- * @since 7.0.3
37
- *
38
- * @var array(string => string)
39
- */
40
- protected $internalInterfaces = array(
41
- 'Traversable' => 'shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.',
42
- 'DateTimeInterface' => 'is intended for type hints only and is not implementable.',
43
- 'Throwable' => 'cannot be implemented directly, extend the Exception class instead.',
44
- );
45
-
46
-
47
- /**
48
- * Returns an array of tokens this test wants to listen for.
49
- *
50
- * @since 7.0.3
51
- *
52
- * @return array
53
- */
54
- public function register()
55
- {
56
- // Handle case-insensitivity of interface names.
57
- $this->internalInterfaces = $this->arrayKeysToLowercase($this->internalInterfaces);
58
-
59
- $targets = array(\T_CLASS);
60
-
61
- if (\defined('T_ANON_CLASS')) {
62
- $targets[] = \T_ANON_CLASS;
63
- }
64
-
65
- return $targets;
66
- }
67
-
68
-
69
- /**
70
- * Processes this test, when one of its tokens is encountered.
71
- *
72
- * @since 7.0.3
73
- *
74
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
75
- * @param int $stackPtr The position of the current token in
76
- * the stack passed in $tokens.
77
- *
78
- * @return void
79
- */
80
- public function process(File $phpcsFile, $stackPtr)
81
- {
82
- $interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);
83
-
84
- if (\is_array($interfaces) === false || $interfaces === array()) {
85
- return;
86
- }
87
-
88
- foreach ($interfaces as $interface) {
89
- $interface = ltrim($interface, '\\');
90
- $interfaceLc = strtolower($interface);
91
- if (isset($this->internalInterfaces[$interfaceLc]) === true) {
92
- $error = 'The interface %s %s';
93
- $errorCode = $this->stringToErrorCode($interfaceLc) . 'Found';
94
- $data = array(
95
- $interface,
96
- $this->internalInterfaces[$interfaceLc],
97
- );
98
-
99
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
100
- }
101
- }
102
- }
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php DELETED
@@ -1,362 +0,0 @@
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\Interfaces;
12
-
13
- use PHPCompatibility\AbstractNewFeatureSniff;
14
- use PHPCompatibility\PHPCSHelper;
15
- use PHP_CodeSniffer_File as File;
16
-
17
- /**
18
- * Detect use of new PHP native interfaces and unsupported interface methods.
19
- *
20
- * PHP version 5.0+
21
- *
22
- * @since 7.0.3
23
- * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class..
24
- * @since 7.1.4 Now also detects new interfaces when used as parameter type declarations.
25
- * @since 8.2.0 Now also detects new interfaces when used as return type declarations.
26
- */
27
- class NewInterfacesSniff extends AbstractNewFeatureSniff
28
- {
29
-
30
- /**
31
- * A list of new interfaces, not present in older versions.
32
- *
33
- * The array lists : version number with false (not present) or true (present).
34
- * If's sufficient to list the first version where the interface appears.
35
- *
36
- * @since 7.0.3
37
- *
38
- * @var array(string => array(string => bool))
39
- */
40
- protected $newInterfaces = array(
41
- 'Traversable' => array(
42
- '4.4' => false,
43
- '5.0' => true,
44
- ),
45
- 'Reflector' => array(
46
- '4.4' => false,
47
- '5.0' => true,
48
- ),
49
-
50
- 'Countable' => array(
51
- '5.0' => false,
52
- '5.1' => true,
53
- ),
54
- 'OuterIterator' => array(
55
- '5.0' => false,
56
- '5.1' => true,
57
- ),
58
- 'RecursiveIterator' => array(
59
- '5.0' => false,
60
- '5.1' => true,
61
- ),
62
- 'SeekableIterator' => array(
63
- '5.0' => false,
64
- '5.1' => true,
65
- ),
66
- 'Serializable' => array(
67
- '5.0' => false,
68
- '5.1' => true,
69
- ),
70
- 'SplObserver' => array(
71
- '5.0' => false,
72
- '5.1' => true,
73
- ),
74
- 'SplSubject' => array(
75
- '5.0' => false,
76
- '5.1' => true,
77
- ),
78
-
79
- 'JsonSerializable' => array(
80
- '5.3' => false,
81
- '5.4' => true,
82
- ),
83
- 'SessionHandlerInterface' => array(
84
- '5.3' => false,
85
- '5.4' => true,
86
- ),
87
-
88
- 'DateTimeInterface' => array(
89
- '5.4' => false,
90
- '5.5' => true,
91
- ),
92
-
93
- 'SessionIdInterface' => array(
94
- '5.5.0' => false,
95
- '5.5.1' => true,
96
- ),
97
-
98
- 'Throwable' => array(
99
- '5.6' => false,
100
- '7.0' => true,
101
- ),
102
- 'SessionUpdateTimestampHandlerInterface' => array(
103
- '5.6' => false,
104
- '7.0' => true,
105
- ),
106
- );
107
-
108
- /**
109
- * A list of methods which cannot be used in combination with particular interfaces.
110
- *
111
- * @since 7.0.3
112
- *
113
- * @var array(string => array(string => string))
114
- */
115
- protected $unsupportedMethods = array(
116
- 'Serializable' => array(
117
- '__sleep' => 'https://www.php.net/serializable',
118
- '__wakeup' => 'https://www.php.net/serializable',
119
- ),
120
- );
121
-
122
- /**
123
- * Returns an array of tokens this test wants to listen for.
124
- *
125
- * @since 7.0.3
126
- *
127
- * @return array
128
- */
129
- public function register()
130
- {
131
- // Handle case-insensitivity of interface names.
132
- $this->newInterfaces = $this->arrayKeysToLowercase($this->newInterfaces);
133
- $this->unsupportedMethods = $this->arrayKeysToLowercase($this->unsupportedMethods);
134
-
135
- $targets = array(
136
- \T_CLASS,
137
- \T_FUNCTION,
138
- \T_CLOSURE,
139
- );
140
-
141
- if (\defined('T_ANON_CLASS')) {
142
- $targets[] = \T_ANON_CLASS;
143
- }
144
-
145
- if (\defined('T_RETURN_TYPE')) {
146
- $targets[] = \T_RETURN_TYPE;
147
- }
148
-
149
- return $targets;
150
- }
151
-
152
-
153
- /**
154
- * Processes this test, when one of its tokens is encountered.
155
- *
156
- * @since 7.0.3
157
- *
158
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
159
- * @param int $stackPtr The position of the current token in
160
- * the stack passed in $tokens.
161
- *
162
- * @return void
163
- */
164
- public function process(File $phpcsFile, $stackPtr)
165
- {
166
- $tokens = $phpcsFile->getTokens();
167
-
168
- switch ($tokens[$stackPtr]['type']) {
169
- case 'T_CLASS':
170
- case 'T_ANON_CLASS':
171
- $this->processClassToken($phpcsFile, $stackPtr);
172
- break;
173
-
174
- case 'T_FUNCTION':
175
- case 'T_CLOSURE':
176
- $this->processFunctionToken($phpcsFile, $stackPtr);
177
-
178
- // Deal with older PHPCS versions which don't recognize return type hints
179
- // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
180
- $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
181
- if ($returnTypeHint !== false) {
182
- $this->processReturnTypeToken($phpcsFile, $returnTypeHint);
183
- }
184
- break;
185
-
186
- case 'T_RETURN_TYPE':
187
- $this->processReturnTypeToken($phpcsFile, $stackPtr);
188
- break;
189
-
190
- default:
191
- // Deliberately left empty.
192
- break;
193
- }
194
- }
195
-
196
-
197
- /**
198
- * Processes this test for when a class token is encountered.
199
- *
200
- * - Detect classes implementing the new interfaces.
201
- * - Detect classes implementing the new interfaces with unsupported functions.
202
- *
203
- * @since 7.1.4 Split off from the `process()` method.
204
- *
205
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
206
- * @param int $stackPtr The position of the current token in
207
- * the stack passed in $tokens.
208
- *
209
- * @return void
210
- */
211
- private function processClassToken(File $phpcsFile, $stackPtr)
212
- {
213
- $interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);
214
-
215
- if (\is_array($interfaces) === false || $interfaces === array()) {
216
- return;
217
- }
218
-
219
- $tokens = $phpcsFile->getTokens();
220
- $checkMethods = false;
221
-
222
- if (isset($tokens[$stackPtr]['scope_closer'])) {
223
- $checkMethods = true;
224
- $scopeCloser = $tokens[$stackPtr]['scope_closer'];
225
- }
226
-
227
- foreach ($interfaces as $interface) {
228
- $interface = ltrim($interface, '\\');
229
- $interfaceLc = strtolower($interface);
230
-
231
- if (isset($this->newInterfaces[$interfaceLc]) === true) {
232
- $itemInfo = array(
233
- 'name' => $interface,
234
- 'nameLc' => $interfaceLc,
235
- );
236
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
237
- }
238
-
239
- if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
240
- $nextFunc = $stackPtr;
241
- while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
242
- $funcName = $phpcsFile->getDeclarationName($nextFunc);
243
- $funcNameLc = strtolower($funcName);
244
- if ($funcNameLc === '') {
245
- continue;
246
- }
247
-
248
- if (isset($this->unsupportedMethods[$interfaceLc][$funcNameLc]) === true) {
249
- $error = 'Classes that implement interface %s do not support the method %s(). See %s';
250
- $errorCode = $this->stringToErrorCode($interface) . 'UnsupportedMethod';
251
- $data = array(
252
- $interface,
253
- $funcName,
254
- $this->unsupportedMethods[$interfaceLc][$funcNameLc],
255
- );
256
-
257
- $phpcsFile->addError($error, $nextFunc, $errorCode, $data);
258
- }
259
- }
260
- }
261
- }
262
- }
263
-
264
-
265
- /**
266
- * Processes this test for when a function token is encountered.
267
- *
268
- * - Detect new interfaces when used as a type hint.
269
- *
270
- * @since 7.1.4
271
- *
272
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
273
- * @param int $stackPtr The position of the current token in
274
- * the stack passed in $tokens.
275
- *
276
- * @return void
277
- */
278
- private function processFunctionToken(File $phpcsFile, $stackPtr)
279
- {
280
- $typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
281
- if (empty($typeHints) || \is_array($typeHints) === false) {
282
- return;
283
- }
284
-
285
- foreach ($typeHints as $hint) {
286
-
287
- $typeHintLc = strtolower($hint);
288
-
289
- if (isset($this->newInterfaces[$typeHintLc]) === true) {
290
- $itemInfo = array(
291
- 'name' => $hint,
292
- 'nameLc' => $typeHintLc,
293
- );
294
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
295
- }
296
- }
297
- }
298
-
299
-
300
- /**
301
- * Processes this test for when a return type token is encountered.
302
- *
303
- * - Detect new interfaces when used as a return type declaration.
304
- *
305
- * @since 8.2.0
306
- *
307
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
308
- * @param int $stackPtr The position of the current token in
309
- * the stack passed in $tokens.
310
- *
311
- * @return void
312
- */
313
- private function processReturnTypeToken(File $phpcsFile, $stackPtr)
314
- {
315
- $returnTypeHint = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
316
- if (empty($returnTypeHint)) {
317
- return;
318
- }
319
-
320
- $returnTypeHint = ltrim($returnTypeHint, '\\');
321
- $returnTypeHintLc = strtolower($returnTypeHint);
322
-
323
- if (isset($this->newInterfaces[$returnTypeHintLc]) === false) {
324
- return;
325
- }
326
-
327
- // Still here ? Then this is a return type declaration using a new interface.
328
- $itemInfo = array(
329
- 'name' => $returnTypeHint,
330
- 'nameLc' => $returnTypeHintLc,
331
- );
332
- $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
333
- }
334
-
335
-
336
- /**
337
- * Get the relevant sub-array for a specific item from a multi-dimensional array.
338
- *
339
- * @since 7.1.0
340
- *
341
- * @param array $itemInfo Base information about the item.
342
- *
343
- * @return array Version and other information about the item.
344
- */
345
- public function getItemArray(array $itemInfo)
346
- {
347
- return $this->newInterfaces[$itemInfo['nameLc']];
348
- }
349
-
350
-
351
- /**
352
- * Get the error message template for this sniff.
353
- *
354
- * @since 7.1.0
355
- *
356
- * @return string
357
- */
358
- protected function getErrorMsgTemplate()
359
- {
360
- return 'The built-in interface ' . parent::getErrorMsgTemplate();
361
- }
362
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/CaseSensitiveKeywordsSniff.php DELETED
@@ -1,76 +0,0 @@
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\Keywords;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
-
16
- /**
17
- * Detect usage of `self`, `parent` and `static` and verify they are lowercase.
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
- * @link https://www.php.net/manual/en/migration55.incompatible.php#migration55.incompatible.self-parent-static
25
- *
26
- * @since 7.1.4
27
- */
28
- class CaseSensitiveKeywordsSniff extends Sniff
29
- {
30
-
31
- /**
32
- * Returns an array of tokens this test wants to listen for.
33
- *
34
- * @since 7.1.4
35
- *
36
- * @return array
37
- */
38
- public function register()
39
- {
40
- return array(
41
- \T_SELF,
42
- \T_STATIC,
43
- \T_PARENT,
44
- );
45
- }
46
-
47
- /**
48
- * Processes this test, when one of its tokens is encountered.
49
- *
50
- * @since 7.1.4
51
- *
52
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
- * @param int $stackPtr The position of the current token in the
54
- * stack passed in $tokens.
55
- *
56
- * @return void
57
- */
58
- public function process(File $phpcsFile, $stackPtr)
59
- {
60
- if ($this->supportsBelow('5.4') === false) {
61
- return;
62
- }
63
-
64
- $tokens = $phpcsFile->getTokens();
65
- $tokenContentLC = strtolower($tokens[$stackPtr]['content']);
66
-
67
- if ($tokenContentLC !== $tokens[$stackPtr]['content']) {
68
- $phpcsFile->addError(
69
- '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.',
70
- $stackPtr,
71
- 'NonLowercaseFound',
72
- array($tokenContentLC)
73
- );
74
- }
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesAsDeclaredSniff.php DELETED
@@ -1,259 +0,0 @@
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\Keywords;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detects the use of some reserved keywords to name a class, interface, trait or namespace.
19
- *
20
- * Emits errors for reserved words and warnings for soft-reserved words.
21
- *
22
- * PHP version 7.0+
23
- *
24
- * @link https://www.php.net/manual/en/reserved.other-reserved-words.php
25
- * @link https://wiki.php.net/rfc/reserve_more_types_in_php_7
26
- *
27
- * @since 7.0.8
28
- * @since 7.1.4 This sniff now throws a warning (soft reserved) or an error (reserved) depending
29
- * on the `testVersion` set. Previously it would always throw an error.
30
- */
31
- class ForbiddenNamesAsDeclaredSniff extends Sniff
32
- {
33
-
34
- /**
35
- * List of tokens which can not be used as class, interface, trait names or as part of a namespace.
36
- *
37
- * @since 7.0.8
38
- *
39
- * @var array
40
- */
41
- protected $forbiddenTokens = array(
42
- \T_NULL => '7.0',
43
- \T_TRUE => '7.0',
44
- \T_FALSE => '7.0',
45
- );
46
-
47
- /**
48
- * T_STRING keywords to recognize as forbidden names.
49
- *
50
- * @since 7.0.8
51
- *
52
- * @var array
53
- */
54
- protected $forbiddenNames = array(
55
- 'null' => '7.0',
56
- 'true' => '7.0',
57
- 'false' => '7.0',
58
- 'bool' => '7.0',
59
- 'int' => '7.0',
60
- 'float' => '7.0',
61
- 'string' => '7.0',
62
- 'iterable' => '7.1',
63
- 'void' => '7.1',
64
- 'object' => '7.2',
65
- );
66
-
67
- /**
68
- * T_STRING keywords to recognize as soft reserved names.
69
- *
70
- * Using any of these keywords to name a class, interface, trait or namespace
71
- * is highly discouraged since they may be used in future versions of PHP.
72
- *
73
- * @since 7.0.8
74
- *
75
- * @var array
76
- */
77
- protected $softReservedNames = array(
78
- 'resource' => '7.0',
79
- 'object' => '7.0',
80
- 'mixed' => '7.0',
81
- 'numeric' => '7.0',
82
- );
83
-
84
- /**
85
- * Combined list of the two lists above.
86
- *
87
- * Used for quick check whether or not something is a reserved
88
- * word.
89
- * Set from the `register()` method.
90
- *
91
- * @since 7.0.8
92
- *
93
- * @var array
94
- */
95
- private $allForbiddenNames = array();
96
-
97
-
98
- /**
99
- * Returns an array of tokens this test wants to listen for.
100
- *
101
- * @since 7.0.8
102
- *
103
- * @return array
104
- */
105
- public function register()
106
- {
107
- // Do the list merge only once.
108
- $this->allForbiddenNames = array_merge($this->forbiddenNames, $this->softReservedNames);
109
-
110
- $targets = array(
111
- \T_CLASS,
112
- \T_INTERFACE,
113
- \T_TRAIT,
114
- \T_NAMESPACE,
115
- \T_STRING, // Compat for PHPCS < 2.4.0 and PHP < 5.3.
116
- );
117
-
118
- return $targets;
119
- }
120
-
121
-
122
- /**
123
- * Processes this test, when one of its tokens is encountered.
124
- *
125
- * @since 7.0.8
126
- *
127
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
128
- * @param int $stackPtr The position of the current token in the
129
- * stack passed in $tokens.
130
- *
131
- * @return void
132
- */
133
- public function process(File $phpcsFile, $stackPtr)
134
- {
135
- if ($this->supportsAbove('7.0') === false) {
136
- return;
137
- }
138
-
139
- $tokens = $phpcsFile->getTokens();
140
- $tokenCode = $tokens[$stackPtr]['code'];
141
- $tokenType = $tokens[$stackPtr]['type'];
142
- $tokenContentLc = strtolower($tokens[$stackPtr]['content']);
143
-
144
- // For string tokens we only care about 'trait' as that is the only one
145
- // which may not be correctly recognized as it's own token.
146
- // This only happens in older versions of PHP where the token doesn't exist yet as a keyword.
147
- if ($tokenCode === \T_STRING && $tokenContentLc !== 'trait') {
148
- return;
149
- }
150
-
151
- if (\in_array($tokenType, array('T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
152
- // Check for the declared name being a name which is not tokenized as T_STRING.
153
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
154
- if ($nextNonEmpty !== false && isset($this->forbiddenTokens[$tokens[$nextNonEmpty]['code']]) === true) {
155
- $name = $tokens[$nextNonEmpty]['content'];
156
- } else {
157
- // Get the declared name if it's a T_STRING.
158
- $name = $phpcsFile->getDeclarationName($stackPtr);
159
- }
160
- unset($nextNonEmpty);
161
-
162
- if (isset($name) === false || \is_string($name) === false || $name === '') {
163
- return;
164
- }
165
-
166
- $nameLc = strtolower($name);
167
- if (isset($this->allForbiddenNames[$nameLc]) === false) {
168
- return;
169
- }
170
-
171
- } elseif ($tokenCode === \T_NAMESPACE) {
172
- $namespaceName = $this->getDeclaredNamespaceName($phpcsFile, $stackPtr);
173
-
174
- if ($namespaceName === false || $namespaceName === '') {
175
- return;
176
- }
177
-
178
- $namespaceParts = explode('\\', $namespaceName);
179
- foreach ($namespaceParts as $namespacePart) {
180
- $partLc = strtolower($namespacePart);
181
- if (isset($this->allForbiddenNames[$partLc]) === true) {
182
- $name = $namespacePart;
183
- $nameLc = $partLc;
184
- break;
185
- }
186
- }
187
- } elseif ($tokenCode === \T_STRING) {
188
- // Traits which are not yet tokenized as T_TRAIT.
189
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
190
- if ($nextNonEmpty === false) {
191
- return;
192
- }
193
-
194
- $nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
195
-
196
- if ($nextNonEmptyCode !== \T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
197
- $name = $tokens[$nextNonEmpty]['content'];
198
- $nameLc = strtolower($tokens[$nextNonEmpty]['content']);
199
- } elseif ($nextNonEmptyCode === \T_STRING) {
200
- $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
201
- if ($endOfStatement === false) {
202
- return;
203
- }
204
-
205
- do {
206
- $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
207
-
208
- if (isset($this->allForbiddenNames[$nextNonEmptyLc]) === true) {
209
- $name = $tokens[$nextNonEmpty]['content'];
210
- $nameLc = $nextNonEmptyLc;
211
- break;
212
- }
213
-
214
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
215
- } while ($nextNonEmpty !== false);
216
- }
217
- unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
218
- }
219
-
220
- if (isset($name, $nameLc) === false) {
221
- return;
222
- }
223
-
224
- // Still here, so this is one of the reserved words.
225
- // Build up the error message.
226
- $error = "'%s' is a";
227
- $isError = null;
228
- $errorCode = $this->stringToErrorCode($nameLc) . 'Found';
229
- $data = array(
230
- $nameLc,
231
- );
232
-
233
- if (isset($this->softReservedNames[$nameLc]) === true
234
- && $this->supportsAbove($this->softReservedNames[$nameLc]) === true
235
- ) {
236
- $error .= ' soft reserved keyword as of PHP version %s';
237
- $isError = false;
238
- $data[] = $this->softReservedNames[$nameLc];
239
- }
240
-
241
- if (isset($this->forbiddenNames[$nameLc]) === true
242
- && $this->supportsAbove($this->forbiddenNames[$nameLc]) === true
243
- ) {
244
- if (isset($isError) === true) {
245
- $error .= ' and a';
246
- }
247
- $error .= ' reserved keyword as of PHP version %s';
248
- $isError = true;
249
- $data[] = $this->forbiddenNames[$nameLc];
250
- }
251
-
252
- if (isset($isError) === true) {
253
- $error .= ' and should not be used to name a class, interface or trait or as part of a namespace (%s)';
254
- $data[] = $tokens[$stackPtr]['type'];
255
-
256
- $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
257
- }
258
- }
259
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesAsInvokedFunctionsSniff.php DELETED
@@ -1,188 +0,0 @@
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\Keywords;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Prohibits the use of reserved keywords invoked as functions.
19
- *
20
- * PHP version All
21
- *
22
- * @link https://www.php.net/manual/en/reserved.keywords.php
23
- *
24
- * @since 5.5
25
- */
26
- class ForbiddenNamesAsInvokedFunctionsSniff extends Sniff
27
- {
28
-
29
- /**
30
- * List of tokens to register.
31
- *
32
- * @since 5.5
33
- *
34
- * @var array
35
- */
36
- protected $targetedTokens = array(
37
- \T_ABSTRACT => '5.0',
38
- \T_CALLABLE => '5.4',
39
- \T_CATCH => '5.0',
40
- \T_FINAL => '5.0',
41
- \T_FINALLY => '5.5',
42
- \T_GOTO => '5.3',
43
- \T_IMPLEMENTS => '5.0',
44
- \T_INTERFACE => '5.0',
45
- \T_INSTANCEOF => '5.0',
46
- \T_INSTEADOF => '5.4',
47
- \T_NAMESPACE => '5.3',
48
- \T_PRIVATE => '5.0',
49
- \T_PROTECTED => '5.0',
50
- \T_PUBLIC => '5.0',
51
- \T_TRAIT => '5.4',
52
- \T_TRY => '5.0',
53
-
54
- );
55
-
56
- /**
57
- * T_STRING keywords to recognize as targetted tokens.
58
- *
59
- * Compatibility for PHP versions where the keyword is not yet recognized
60
- * as its own token and for PHPCS versions which change the token to
61
- * T_STRING when used in a method call.
62
- *
63
- * @since 5.5
64
- *
65
- * @var array
66
- */
67
- protected $targetedStringTokens = array(
68
- 'abstract' => '5.0',
69
- 'callable' => '5.4',
70
- 'catch' => '5.0',
71
- 'final' => '5.0',
72
- 'finally' => '5.5',
73
- 'goto' => '5.3',
74
- 'implements' => '5.0',
75
- 'interface' => '5.0',
76
- 'instanceof' => '5.0',
77
- 'insteadof' => '5.4',
78
- 'namespace' => '5.3',
79
- 'private' => '5.0',
80
- 'protected' => '5.0',
81
- 'public' => '5.0',
82
- 'trait' => '5.4',
83
- 'try' => '5.0',
84
- );
85
-
86
- /**
87
- * Returns an array of tokens this test wants to listen for.
88
- *
89
- * @since 5.5
90
- *
91
- * @return array
92
- */
93
- public function register()
94
- {
95
- $tokens = array_keys($this->targetedTokens);
96
- $tokens[] = \T_STRING;
97
-
98
- return $tokens;
99
- }
100
-
101
- /**
102
- * Processes this test, when one of its tokens is encountered.
103
- *
104
- * @since 5.5
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(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(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(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
- }
188
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesSniff.php DELETED
@@ -1,442 +0,0 @@
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\Keywords;
12
-
13
- use PHPCompatibility\Sniff;
14
- use PHP_CodeSniffer_File as File;
15
- use PHP_CodeSniffer_Tokens as Tokens;
16
-
17
- /**
18
- * Detects the use of reserved keywords as class, function, namespace or constant names.
19
- *
20
- * PHP version All
21
- *
22
- * @link https://www.php.net/manual/en/reserved.keywords.php
23
- *
24
- * @since 5.5
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
- * @since 5.5
34
- *
35
- * @var array(string => string)
36
- */
37
- protected $invalidNames = array(
38
- 'abstract' => '5.0',
39
- 'and' => 'all',
40
- 'array' => 'all',
41
- 'as' => 'all',
42
- 'break' => 'all',
43
- 'callable' => '5.4',
44
- 'case' => 'all',
45
- 'catch' => '5.0',
46
- 'class' => 'all',
47
- 'clone' => '5.0',
48
- 'const' => 'all',
49
- 'continue' => 'all',
50
- 'declare' => 'all',
51
- 'default' => 'all',
52
- 'die' => 'all',
53
- 'do' => 'all',
54
- 'echo' => 'all',
55
- 'else' => 'all',
56
- 'elseif' => 'all',
57
- 'empty' => 'all',
58
- 'enddeclare' => 'all',
59
- 'endfor' => 'all',
60
- 'endforeach' => 'all',
61
- 'endif' => 'all',
62
- 'endswitch' => 'all',
63
- 'endwhile' => 'all',
64
- 'eval' => 'all',
65
- 'exit' => 'all',
66
- 'extends' => 'all',
67
- 'final' => '5.0',
68
- 'finally' => '5.5',
69
- 'for' => 'all',
70
- 'foreach' => 'all',
71
- 'function' => 'all',
72
- 'global' => 'all',
73
- 'goto' => '5.3',
74
- 'if' => 'all',
75
- 'implements' => '5.0',
76
- 'include' => 'all',
77
- 'include_once' => 'all',
78
- 'instanceof' => '5.0',
79
- 'insteadof' => '5.4',
80
- 'interface' => '5.0',
81
- 'isset' => 'all',
82
- 'list' => 'all',
83
- 'namespace' => '5.3',
84
- 'new' => 'all',
85
- 'or' => 'all',
86
- 'print' => 'all',
87
- 'private' => '5.0',
88
- 'protected' => '5.0',
89
- 'public' => '5.0',
90
- 'require' => 'all',
91
- 'require_once' => 'all',
92
- 'return' => 'all',
93
- 'static' => 'all',
94
- 'switch' => 'all',
95
- 'throw' => '5.0',
96
- 'trait' => '5.4',
97
- 'try' => '5.0',
98
- 'unset' => 'all',
99
- 'use' => 'all',
100
- 'var' => 'all',
101
- 'while' => 'all',
102
- 'xor' => 'all',
103
- 'yield' => '5.5',
104
- '__class__' => 'all',
105
- '__dir__' => '5.3',
106
- '__file__' => 'all',
107
- '__function__' => 'all',
108
- '__method__' => 'all',
109
- '__namespace__' => '5.3',
110
- );
111
-
112
- /**
113
- * A list of keywords that can follow use statements.
114
- *
115
- * @since 7.0.1
116
- *
117
- * @var array(string => string)
118
- */
119
- protected $validUseNames = array(
120
- 'const' => true,
121
- 'function' => true,
122
- );
123
-
124
- /**
125
- * Scope modifiers and other keywords allowed in trait use statements.
126
- *
127
- * @since 7.1.4
128
- *
129
- * @var array
130
- */
131
- private $allowedModifiers = array();
132
-
133
- /**
134
- * Targeted tokens.
135
- *
136
- * @since 5.5
137
- *
138
- * @var array
139
- */
140
- protected $targetedTokens = array(
141
- \T_CLASS,
142
- \T_FUNCTION,
143
- \T_NAMESPACE,
144
- \T_STRING,
145
- \T_CONST,
146
- \T_USE,
147
- \T_AS,
148
- \T_EXTENDS,
149
- \T_INTERFACE,
150
- \T_TRAIT,
151
- );
152
-
153
- /**
154
- * Returns an array of tokens this test wants to listen for.
155
- *
156
- * @since 5.5
157
- *
158
- * @return array
159
- */
160
- public function register()
161
- {
162
- $this->allowedModifiers = Tokens::$scopeModifiers;
163
- $this->allowedModifiers[\T_FINAL] = \T_FINAL;
164
-
165
- $tokens = $this->targetedTokens;
166
-
167
- if (\defined('T_ANON_CLASS')) {
168
- $tokens[] = \T_ANON_CLASS;
169
- }
170
-
171
- return $tokens;
172
- }
173
-
174
- /**
175
- * Processes this test, when one of its tokens is encountered.
176
- *
177
- * @since 5.5
178
- *
179
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
180
- * @param int $stackPtr The position of the current token in the
181
- * stack passed in $tokens.
182
- *
183
- * @return void
184
- */
185
- public function process(File $phpcsFile, $stackPtr)
186
- {
187
- $tokens = $phpcsFile->getTokens();
188
-
189
- /*
190
- * We distinguish between the class, function and namespace names vs the define statements.
191
- */
192
- if ($tokens[$stackPtr]['type'] === 'T_STRING') {
193
- $this->processString($phpcsFile, $stackPtr, $tokens);
194
- } else {
195
- $this->processNonString($phpcsFile, $stackPtr, $tokens);
196
- }
197
- }
198
-
199
- /**
200
- * Processes this test, when one of its tokens is encountered.
201
- *
202
- * @since 5.5
203
- *
204
- * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
205
- * @param int $stackPtr The position of the current token in the
206
- * stack passed in $tokens.
207
- * @param array $tokens The stack of tokens that make up
208
- * the file.
209
- *
210
- * @return void
211
- */
212
- public function processNonString(File $phpcsFile, $stackPtr, $tokens)
213
- {
214
- $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
215
- if ($nextNonEmpty === false) {
216
- return;
217
- }
218
-
219
- /*
220
- * Deal with anonymous classes - `class` before a reserved keyword is sometimes
221
- * misidentified as `T_ANON_CLASS`.
222
- * In PHPCS < 2.3.4 these were tokenized as T_CLASS no matter what.
223
- */
224
- if ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS') {
225
- $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
226
- if ($prevNonEmpty !== false && $tokens[$prevNonEmpty]['type'] === 'T_NEW') {
227
- return;
228
- }
229
- }
230
-
231
- /*
232
- * PHP 5.6 allows for use const and use function, but only if followed by the function/constant name.
233
- * - `use function HelloWorld` => move to the next token (HelloWorld) to verify.
234
- * - `use const HelloWorld` => move to the next token (HelloWorld) to verify.
235
- */
236
- elseif ($tokens[$stackPtr]['type'] === 'T_USE'
237
- && isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === true
238
- ) {
239
- $maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
240
- if ($maybeUseNext !== false && $this->isEndOfUseStatement($tokens[$maybeUseNext]) === false) {
241
- $nextNonEmpty = $maybeUseNext;
242
- }
243
- }
244
-
245
- /*
246
- * Deal with visibility modifiers.
247
- * - `use HelloWorld { sayHello as protected; }` => valid, bow out.
248
- * - `use HelloWorld { sayHello as private myPrivateHello; }` => move to the next token to verify.
249
- */
250
- elseif ($tokens[$stackPtr]['type'] === 'T_AS'
251
- && isset($this->allowedModifiers[$tokens[$nextNonEmpty]['code']]) === true
252
- && $phpcsFile->hasCondition($stackPtr, \T_USE) === true
253
- ) {
254
- $maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
255
- if ($maybeUseNext === false || $this->isEndOfUseStatement($tokens[$maybeUseNext]) === true) {
256
- return;
257
- }
258
-
259
- $nextNonEmpty = $maybeUseNext;
260
- }
261
-
262
- /*
263
- * Deal with foreach ( ... as list() ).
264
- */
265
- elseif ($tokens[$stackPtr]['type'] === 'T_AS'
266
- && isset($tokens[$stackPtr]['nested_parenthesis']) === true
267
- && $tokens[$nextNonEmpty]['code'] === \T_LIST
268
- ) {
269
- $parentheses = array_reverse($tokens[$stackPtr]['nested_parenthesis'], true);
270
- foreach ($parentheses as $open => $close) {
271
- if (isset($tokens[$open]['parenthesis_owner'])
272
- && $tokens[$tokens[$open]['parenthesis_owner']]['code'] === \T_FOREACH
273
- ) {
274
- return;
275
- }
276
- }
277
- }
278
-
279
- /*
280
- * Deal with functions declared to return by reference.
281
- */
282
- elseif ($tokens[$stackPtr]['type'] === 'T_FUNCTION'
283
- && $tokens[$nextNonEmpty]['type'] === 'T_BITWISE_AND'
284
- ) {
285
- $maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
286
- if ($maybeUseNext === false) {
287
- // Live coding.
288
- return;
289
- }
290
-
291
- $nextNonEmpty = $maybeUseNext;
292
- }
293
-
294
- /*
295
- * Deal with nested namespaces.
296
- */
297
- elseif ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') {
298
- if ($tokens[$stackPtr + 1]['code'] === \T_NS_SEPARATOR) {
299
- // Not a namespace declaration, but use of, i.e. `namespace\someFunction();`.
300
- return;
301
- }
302
-
303
- $endToken = $phpcsFile->findNext(array(\T_SEMICOLON, \T_OPEN_CURLY_BRACKET), ($stackPtr + 1), null, false, null, true);
304
- $namespaceName = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($endToken - $stackPtr - 1)));
305
- if (empty($namespaceName) === true) {
306
- return;
307
- }
308
-
309
- $namespaceParts = explode('\\', $namespaceName);
310
- foreach ($namespaceParts as $namespacePart) {
311
- $partLc = strtolower($namespacePart);
312
- if (isset($this->invalidNames[$partLc]) === false) {
313
- continue;
314
- }
315
-
316
- // Find the token position of the part which matched.
317
- for ($i = ($stackPtr + 1); $i < $endToken; $i++) {
318
- if ($tokens[$i]['content'] === $namespacePart) {
319
- $nextNonEmpty = $i;
320
- break;
321
- }
322
- }
323
- }
324
- unset($i, $namespacePart, $partLc);
325
- }
326
-
327
- $nextContentLc = strtolower($tokens[$nextNonEmpty]['content']);
328
- if (isset($this->invalidNames[$nextContentLc]) === false) {
329
- return;
330
- }
331
-
332
- /*
333
- * Deal with PHP 7 relaxing the rules.
334
- * "As of PHP 7.0.0 these keywords are allowed as property, constant, and method names
335
- * of classes, interfaces and traits, except that class may not be used as constant name."
336
- */
337
- if ((($tokens[$stackPtr]['type'] === 'T_FUNCTION'
338
- && $this->inClassScope($phpcsFile, $stackPtr, false) === true)
339
- || ($tokens[$stackPtr]['type'] === 'T_CONST'
340
- && $this->isClassConstant($phpcsFile, $stackPtr) === true
341
- && $nextContentLc !== 'class'))
342
- && $this->supportsBelow('5.6') === false
343
- ) {
344
- return;
345
-