PHP Compatibility Checker - Version 1.2.0

Version Description

  • Updated the PHPCompatibility library to latest version
  • Added support for PHP 5.6
Download this release

Release Info

Developer wpengine
Plugin Icon 128x128 PHP Compatibility Checker
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.2 to 1.2.0

Files changed (118) hide show
  1. readme.txt +9 -5
  2. src/js/run.js +6 -6
  3. src/ruleset-wordpress.xml +16 -0
  4. src/wpcli.php +2 -3
  5. src/wpephpcompat.php +23 -25
  6. vendor/autoload.php +1 -1
  7. vendor/composer/autoload_classmap.php +2 -0
  8. vendor/composer/autoload_real.php +3 -3
  9. vendor/composer/installed.json +51 -51
  10. vendor/squizlabs/php_codesniffer/CodeSniffer.conf +4 -0
  11. vendor/squizlabs/php_codesniffer/CodeSniffer.php +24 -8
  12. vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php +46 -8
  13. vendor/squizlabs/php_codesniffer/CodeSniffer/File.php +28 -8
  14. vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/VersionControl.php +55 -9
  15. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php +24 -0
  16. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +9 -5
  17. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +90 -0
  18. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +119 -60
  19. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +7 -7
  20. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/.coveralls.yml +1 -1
  21. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/.scrutinizer.yml +12 -0
  22. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/README.md +49 -4
  23. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniff.php +693 -11
  24. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php +13 -9
  25. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php +42 -25
  26. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php +92 -36
  27. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php +0 -7
  28. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php +34 -13
  29. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php +0 -7
  30. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php +29 -36
  31. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php +33 -22
  32. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php +1 -11
  33. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php +0 -7
  34. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php +16 -4
  35. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php +2 -9
  36. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +20 -24
  37. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php +84 -0
  38. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php +67 -0
  39. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php +8 -11
  40. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php +5 -6
  41. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php +35 -37
  42. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php +273 -0
  43. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php +2 -2
  44. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php +687 -48
  45. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php +116 -76
  46. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php +346 -16
  47. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php +198 -0
  48. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php +33 -18
  49. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php +81 -22
  50. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php +131 -0
  51. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php +4 -12
  52. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php +67 -37
  53. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php +96 -88
  54. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php +27 -24
  55. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php +13 -4
  56. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedExtensionsSniff.php +123 -12
  57. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php +69 -69
  58. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php +38 -33
  59. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php +0 -7
  60. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php +126 -0
  61. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ShortArraySniff.php +1 -1
  62. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ValidIntegersSniff.php +208 -0
  63. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/ruleset.xml +20 -2
  64. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +3 -1
  65. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php +104 -0
  66. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/ruleset.xml +1 -0
  67. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +5 -5
  68. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +50 -8
  69. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php +13 -10
  70. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +1 -1
  71. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php +22 -4
  72. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +3 -3
  73. vendor/squizlabs/php_codesniffer/phpcs.xml.dist +0 -1
  74. vendor/wimg/php-compatibility/.coveralls.yml +1 -1
  75. vendor/wimg/php-compatibility/.scrutinizer.yml +12 -0
  76. vendor/wimg/php-compatibility/README.md +49 -4
  77. vendor/wimg/php-compatibility/Sniff.php +693 -11
  78. vendor/wimg/php-compatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php +13 -9
  79. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php +42 -25
  80. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php +92 -36
  81. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php +0 -7
  82. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php +34 -13
  83. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php +0 -7
  84. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php +29 -36
  85. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php +33 -22
  86. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php +1 -11
  87. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php +0 -7
  88. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesSniff.php +16 -4
  89. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php +2 -9
  90. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +20 -24
  91. vendor/wimg/php-compatibility/Sniffs/PHP/InternalInterfacesSniff.php +84 -0
  92. vendor/wimg/php-compatibility/Sniffs/PHP/LateStaticBindingSniff.php +67 -0
  93. vendor/wimg/php-compatibility/Sniffs/PHP/LongArraysSniff.php +8 -11
  94. vendor/wimg/php-compatibility/Sniffs/PHP/NewAnonymousClassesSniff.php +5 -6
  95. vendor/wimg/php-compatibility/Sniffs/PHP/NewClassesSniff.php +35 -37
  96. vendor/wimg/php-compatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php +273 -0
  97. vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php +2 -2
  98. vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionParametersSniff.php +687 -48
  99. vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionsSniff.php +116 -76
  100. vendor/wimg/php-compatibility/Sniffs/PHP/NewIniDirectivesSniff.php +346 -16
  101. vendor/wimg/php-compatibility/Sniffs/PHP/NewInterfacesSniff.php +198 -0
  102. vendor/wimg/php-compatibility/Sniffs/PHP/NewKeywordsSniff.php +33 -18
  103. vendor/wimg/php-compatibility/Sniffs/PHP/NewLanguageConstructsSniff.php +81 -22
  104. vendor/wimg/php-compatibility/Sniffs/PHP/NewMagicMethodsSniff.php +131 -0
  105. vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php +4 -12
  106. vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php +67 -37
  107. vendor/wimg/php-compatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php +96 -88
  108. vendor/wimg/php-compatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php +27 -24
  109. vendor/wimg/php-compatibility/Sniffs/PHP/PregReplaceEModifierSniff.php +13 -4
  110. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedExtensionsSniff.php +123 -12
  111. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php +69 -69
  112. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php +38 -33
  113. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php +0 -7
  114. vendor/wimg/php-compatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php +126 -0
  115. vendor/wimg/php-compatibility/Sniffs/PHP/ShortArraySniff.php +1 -1
  116. vendor/wimg/php-compatibility/Sniffs/PHP/ValidIntegersSniff.php +208 -0
  117. vendor/wimg/php-compatibility/ruleset.xml +20 -2
  118. wpengine-phpcompat.php +41 -23
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: wpengine, octalmage, stevenkword, Taylor4484, pross
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.5
5
- Tested up to: 4.5
6
- Stable tag: 1.1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -21,9 +21,9 @@ This plugin will lint theme and plugin code inside your WordPress file system an
21
 
22
  = Update to PHP 7 =
23
  * Use this plugin to check your site for compatibility for PHP 7!
24
- * As of July 2016, 59.3% of WordPress websites run a PHP version less PHP 5.5.
25
  * These versions of PHP have been deprecated and unsupported for over 9 months.
26
- * Only 1.8% of WordPress websites run PHP 7, the current main version of PHP.
27
 
28
 
29
  = Disclaimer =
@@ -62,7 +62,7 @@ PHP Compatibility Checker includes WP-CLI command support:
62
  - active
63
  - all
64
  `
65
- Example: `wp phpcompat 5.5 --scan=active`
66
 
67
 
68
  == Frequently Asked Questions ==
@@ -112,6 +112,10 @@ To disclose security issues for this plugin please email WordPress@wpengine.com
112
 
113
  == Changelog ==
114
 
 
 
 
 
115
  = 1.1.2 =
116
  - Fixed issue with WordPress notices breaking the plugin header.
117
  - Changed the way we send and parse JSON.
2
  Contributors: wpengine, octalmage, stevenkword, Taylor4484, pross
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.5
5
+ Tested up to: 4.6
6
+ Stable tag: 1.2.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
21
 
22
  = Update to PHP 7 =
23
  * Use this plugin to check your site for compatibility for PHP 7!
24
+ * As of [August 2016](https://wordpress.org/about/stats/), 57.1% of WordPress websites run a PHP version less PHP 5.5.
25
  * These versions of PHP have been deprecated and unsupported for over 9 months.
26
+ * Only 2.2% of WordPress websites run PHP 7, the current main version of PHP.
27
 
28
 
29
  = Disclaimer =
62
  - active
63
  - all
64
  `
65
+ Example: `wp phpcompat 7.0 --scan=active`
66
 
67
 
68
  == Frequently Asked Questions ==
112
 
113
  == Changelog ==
114
 
115
+ = 1.2.0 =
116
+ - Updated the PHPCompatibility library to latest version
117
+ - Added support for PHP 5.6
118
+
119
  = 1.1.2 =
120
  - Fixed issue with WordPress notices breaking the plugin header.
121
  - Changed the way we send and parse JSON.
src/js/run.js CHANGED
@@ -70,9 +70,9 @@ function checkStatus() {
70
  * Status 0: the test as completed but is not currently running
71
  */
72
  if ( false === obj.results ) {
73
- jQuery( '#runButton' ).val( 'Run' );
74
  } else {
75
- jQuery( '#runButton' ).val( 'Re-run' );
76
  }
77
 
78
  if ( '1' === obj.status ) {
@@ -171,7 +171,7 @@ function displayReport( response ) {
171
  $( '#footer' ).show();
172
 
173
  // Separate plugins/themes.
174
- var plugins = response.replace( /^\s+|\s+$/g, '' ).split( 'Name: ' );
175
 
176
  // Remove the first item, it's empty.
177
  plugins.shift();
@@ -222,11 +222,11 @@ function displayReport( response ) {
222
 
223
  // Display global compatibility status.
224
  if ( compatible ) {
225
- $( '#standardMode' ).prepend( '<h3>Your WordPress install is PHP ' + test_version + ' compatible.</h3>' );
226
  } else {
227
  // Display scan stats.
228
- $( '#standardMode' ).prepend( '<p>' + failedCount + ' out of ' + plugins.length + ' plugins/themes are not compatible.</p>' );
229
 
230
- $( '#standardMode' ).prepend( '<h3>Your WordPress install is not PHP ' + test_version + ' compatible.</h3>' );
231
  }
232
  }
70
  * Status 0: the test as completed but is not currently running
71
  */
72
  if ( false === obj.results ) {
73
+ jQuery( '#runButton' ).val( window.wpephpcompat.run );
74
  } else {
75
+ jQuery( '#runButton' ).val( window.wpephpcompat.rerun );
76
  }
77
 
78
  if ( '1' === obj.status ) {
171
  $( '#footer' ).show();
172
 
173
  // Separate plugins/themes.
174
+ var plugins = response.replace( /^\s+|\s+$/g, '' ).split( window.wpephpcompat.name + ':' );
175
 
176
  // Remove the first item, it's empty.
177
  plugins.shift();
222
 
223
  // Display global compatibility status.
224
  if ( compatible ) {
225
+ $( '#standardMode' ).prepend( '<h3>' + window.wpephpcompat.your_wp + ' PHP ' + test_version + ' ' + window.wpephpcompat.compatible + '.</h3>' );
226
  } else {
227
  // Display scan stats.
228
+ $( '#standardMode' ).prepend( '<p>' + failedCount + ' ' + window.wpephpcompat.out_of + ' ' + plugins.length + ' ' + window.wpephpcompat.are_not + '.</p>' );
229
 
230
+ $( '#standardMode' ).prepend( '<h3>' + window.wpephpcompat.is_not + ' ' + test_version + ' ' + window.wpephpcompat.compatible + '.</h3>' );
231
  }
232
  }
src/ruleset-wordpress.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="WordPress-Core Custom">
3
+
4
+ <description>WordPress-Core Custom</description>
5
+
6
+ <!-- Include WordPress-Core standards. -->
7
+ <rule ref="WordPress-Core"/>
8
+
9
+ <!-- Whitelist member variables from core. -->
10
+ <rule ref="WordPress.NamingConventions.ValidVariableName">
11
+ <properties>
12
+ <property name="whitelisted_mixed_case_member_var_names" value="Name,ID" type="array"/>
13
+ </properties>
14
+ </rule>
15
+
16
+ </ruleset>
src/wpcli.php CHANGED
@@ -47,8 +47,7 @@ class PHPCompat_Command extends WP_CLI_Command {
47
 
48
  if ( preg_match( '/(\d*) ERRORS?/i', $results ) ) {
49
  WP_CLI::error( 'Your WordPress install is not compatible.' );
50
- }
51
- else {
52
  WP_CLI::success( 'Your WordPress install is compatible.' );
53
  }
54
  }
@@ -74,5 +73,5 @@ WP_CLI::add_command( 'phpcompat', 'PHPCompat_Command', array(
74
  'default' => 'active',
75
  'options' => array( 'active', 'all' ),
76
  ),
77
- )
78
  ));
47
 
48
  if ( preg_match( '/(\d*) ERRORS?/i', $results ) ) {
49
  WP_CLI::error( 'Your WordPress install is not compatible.' );
50
+ } else {
 
51
  WP_CLI::success( 'Your WordPress install is compatible.' );
52
  }
53
  }
73
  'default' => 'active',
74
  'options' => array( 'active', 'all' ),
75
  ),
76
+ ),
77
  ));
src/wpephpcompat.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  // Exit if this file is directly accessed
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- require_once ( __DIR__ . '/../vendor/autoload.php' );
6
 
7
  /**
8
  * Summary.
@@ -120,7 +120,7 @@ class WPEPHPCompat {
120
 
121
  $timestamp = wp_next_scheduled( 'wpephpcompat_start_test_cron' );
122
 
123
- if ( $timestamp == false ) {
124
  wp_schedule_single_event( time() + $timeout, 'wpephpcompat_start_test_cron' );
125
  }
126
  return;
@@ -175,7 +175,7 @@ class WPEPHPCompat {
175
 
176
  if ( ! $this->is_command_line() ) {
177
  // Close the connection to the browser.
178
- $this->close_connection("started");
179
 
180
  /**
181
  * Kill cron after a configurable timeout.
@@ -190,14 +190,14 @@ class WPEPHPCompat {
190
  $this->debug_log( 'Processing: ' . $directory->post_title );
191
 
192
  // Add the plugin/theme name to the results.
193
- $scan_results .= 'Name: ' . $directory->post_title . "\n\n";
194
 
195
  // Keep track of the number of times we've attempted to scan the plugin.
196
  $count = get_post_meta( $directory->ID, 'count', true ) ?: 1;
197
  $this->debug_log( 'Attempted scan count: ' . $count );
198
 
199
  if ( $count > 2 ) { // If we've already tried twice, skip it.
200
- $scan_results .= "The plugin/theme was skipped as it was too large to scan before the server killed the process.\n\n";
201
  update_option( 'wpephpcompat.scan_results', $scan_results , false );
202
  wp_delete_post( $directory->ID );
203
  $count = 0;
@@ -213,7 +213,7 @@ class WPEPHPCompat {
213
  $report = $this->process_file( $directory->post_content );
214
 
215
  if ( ! $report ) {
216
- $report = 'PHP ' . $this->test_version . ' compatible.';
217
  }
218
 
219
  $scan_results .= $report . "\n";
@@ -311,12 +311,12 @@ class WPEPHPCompat {
311
 
312
  foreach ( $all_plugins as $k => $v ) {
313
  //Exclude our plugin.
314
- if ( $v['Name'] === 'PHP Compatibility Checker' ) {
315
  continue;
316
  }
317
 
318
  // Exclude active plugins if only_active = "yes".
319
- if ( $this->only_active === 'yes' ) {
320
  // Get array of active plugins.
321
  $active_plugins = get_option( 'active_plugins' );
322
 
@@ -330,8 +330,7 @@ class WPEPHPCompat {
330
  // Plugin in root directory (like Hello Dolly).
331
  if ( './' === $plugin_file ) {
332
  $plugin_path = $plugin_base . $k;
333
- }
334
- else {
335
  $plugin_path = $plugin_base . $plugin_file;
336
  }
337
 
@@ -356,15 +355,16 @@ class WPEPHPCompat {
356
  $all_themes = wp_get_themes();
357
 
358
  foreach ( $all_themes as $k => $v ) {
359
- if ( $this->only_active === 'yes' ) {
360
  $current_theme = wp_get_theme();
361
- if ($all_themes[$k]->Name != $current_theme->Name)
362
- continue;
 
363
  }
364
 
365
- $theme_path = $all_themes[$k]->theme_root . DIRECTORY_SEPARATOR . $k . DIRECTORY_SEPARATOR;
366
 
367
- $this->add_directory( $all_themes[$k]->Name, $theme_path );
368
  }
369
 
370
  // Add parent theme if the current theme is a child theme.
@@ -385,7 +385,7 @@ class WPEPHPCompat {
385
  */
386
  public function clean_report( $report ) {
387
  // Remove unnecessary overview.
388
- $report = preg_replace ( '/Time:.+\n/si', '', $report );
389
 
390
  // Remove whitespace.
391
  $report = trim( $report );
@@ -411,7 +411,7 @@ class WPEPHPCompat {
411
  //Make sure all directories are removed from the queue.
412
  $args = array(
413
  'posts_per_page' => -1,
414
- 'post_type' => 'wpephpcompat_jobs'
415
  );
416
  $directories = get_posts( $args );
417
 
@@ -433,7 +433,7 @@ class WPEPHPCompat {
433
  'post_content' => $path,
434
  'post_status' => 'publish',
435
  'post_author' => 1,
436
- 'post_type' => 'wpephpcompat_jobs'
437
  );
438
 
439
  return wp_insert_post( $dir );
@@ -446,12 +446,11 @@ class WPEPHPCompat {
446
  * @param string $message Message to log.
447
  * @return null
448
  */
449
- private function debug_log( $message ){
450
  if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true && ! $this->is_command_line() ) {
451
  if ( is_array( $message ) || is_object( $message ) ) {
452
  error_log( print_r( $message , true ) );
453
- }
454
- else {
455
  error_log( 'WPE PHP Compatibility: ' . $message );
456
  }
457
  }
@@ -463,8 +462,7 @@ class WPEPHPCompat {
463
  * @since 1.0.0
464
  * @return boolean Returns true if the request came from the command line.
465
  */
466
- private function is_command_line()
467
- {
468
  return defined( 'WP_CLI' ) || defined( 'PHPUNIT_TEST' );
469
  }
470
 
@@ -476,7 +474,7 @@ class WPEPHPCompat {
476
  */
477
  private function close_connection( $body ) {
478
  ignore_user_abort( true );
479
- if (ob_get_length()) ob_end_clean();
480
  // Start buffering.
481
  ob_start();
482
  // Echo our response.
1
  <?php
2
  // Exit if this file is directly accessed
3
+ if ( ! defined( 'ABSPATH' ) ) { exit; }
4
 
5
+ require_once( __DIR__ . '/../vendor/autoload.php' );
6
 
7
  /**
8
  * Summary.
120
 
121
  $timestamp = wp_next_scheduled( 'wpephpcompat_start_test_cron' );
122
 
123
+ if ( false == $timestamp ) {
124
  wp_schedule_single_event( time() + $timeout, 'wpephpcompat_start_test_cron' );
125
  }
126
  return;
175
 
176
  if ( ! $this->is_command_line() ) {
177
  // Close the connection to the browser.
178
+ $this->close_connection( 'started' );
179
 
180
  /**
181
  * Kill cron after a configurable timeout.
190
  $this->debug_log( 'Processing: ' . $directory->post_title );
191
 
192
  // Add the plugin/theme name to the results.
193
+ $scan_results .= __( 'Name', 'php-compatibility-checker' ) . ': ' . $directory->post_title . "\n\n";
194
 
195
  // Keep track of the number of times we've attempted to scan the plugin.
196
  $count = get_post_meta( $directory->ID, 'count', true ) ?: 1;
197
  $this->debug_log( 'Attempted scan count: ' . $count );
198
 
199
  if ( $count > 2 ) { // If we've already tried twice, skip it.
200
+ $scan_results .= __( 'The plugin/theme was skipped as it was too large to scan before the server killed the process.', 'php-compatibility-checker' ) . "\n\n";
201
  update_option( 'wpephpcompat.scan_results', $scan_results , false );
202
  wp_delete_post( $directory->ID );
203
  $count = 0;
213
  $report = $this->process_file( $directory->post_content );
214
 
215
  if ( ! $report ) {
216
+ $report = 'PHP ' . $this->test_version . __( ' compatible.', 'php-compatibility-checker' );
217
  }
218
 
219
  $scan_results .= $report . "\n";
311
 
312
  foreach ( $all_plugins as $k => $v ) {
313
  //Exclude our plugin.
314
+ if ( 'PHP Compatibility Checker' === $v['Name'] ) {
315
  continue;
316
  }
317
 
318
  // Exclude active plugins if only_active = "yes".
319
+ if ( 'yes' === $this->only_active ) {
320
  // Get array of active plugins.
321
  $active_plugins = get_option( 'active_plugins' );
322
 
330
  // Plugin in root directory (like Hello Dolly).
331
  if ( './' === $plugin_file ) {
332
  $plugin_path = $plugin_base . $k;
333
+ } else {
 
334
  $plugin_path = $plugin_base . $plugin_file;
335
  }
336
 
355
  $all_themes = wp_get_themes();
356
 
357
  foreach ( $all_themes as $k => $v ) {
358
+ if ( 'yes' === $this->only_active ) {
359
  $current_theme = wp_get_theme();
360
+ if ( $all_themes[ $k ]->Name != $current_theme->Name ) {
361
+ continue;
362
+ }
363
  }
364
 
365
+ $theme_path = $all_themes[ $k ]->theme_root . DIRECTORY_SEPARATOR . $k . DIRECTORY_SEPARATOR;
366
 
367
+ $this->add_directory( $all_themes[ $k ]->Name, $theme_path );
368
  }
369
 
370
  // Add parent theme if the current theme is a child theme.
385
  */
386
  public function clean_report( $report ) {
387
  // Remove unnecessary overview.
388
+ $report = preg_replace( '/Time:.+\n/si', '', $report );
389
 
390
  // Remove whitespace.
391
  $report = trim( $report );
411
  //Make sure all directories are removed from the queue.
412
  $args = array(
413
  'posts_per_page' => -1,
414
+ 'post_type' => 'wpephpcompat_jobs',
415
  );
416
  $directories = get_posts( $args );
417
 
433
  'post_content' => $path,
434
  'post_status' => 'publish',
435
  'post_author' => 1,
436
+ 'post_type' => 'wpephpcompat_jobs',
437
  );
438
 
439
  return wp_insert_post( $dir );
446
  * @param string $message Message to log.
447
  * @return null
448
  */
449
+ private function debug_log( $message ) {
450
  if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true && ! $this->is_command_line() ) {
451
  if ( is_array( $message ) || is_object( $message ) ) {
452
  error_log( print_r( $message , true ) );
453
+ } else {
 
454
  error_log( 'WPE PHP Compatibility: ' . $message );
455
  }
456
  }
462
  * @since 1.0.0
463
  * @return boolean Returns true if the request came from the command line.
464
  */
465
+ private function is_command_line() {
 
466
  return defined( 'WP_CLI' ) || defined( 'PHPUNIT_TEST' );
467
  }
468
 
474
  */
475
  private function close_connection( $body ) {
476
  ignore_user_abort( true );
477
+ if ( ob_get_length() ) { ob_end_clean(); }
478
  // Start buffering.
479
  ob_start();
480
  // Echo our response.
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit51e22ebbb2a130bf15e98292ff8edf15::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitd41fb065716ad185f2f20e573132cd97::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -38,6 +38,7 @@ return array(
38
  'Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php',
39
  'Generic_Sniffs_Formatting_NoSpaceAfterCastSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php',
40
  'Generic_Sniffs_Formatting_SpaceAfterCastSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php',
 
41
  'Generic_Sniffs_Functions_CallTimePassByReferenceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php',
42
  'Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php',
43
  'Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php',
@@ -146,6 +147,7 @@ return array(
146
  'PSR2_Sniffs_Files_ClosingTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php',
147
  'PSR2_Sniffs_Files_EndFileNewlineSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php',
148
  'PSR2_Sniffs_Methods_FunctionCallSignatureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php',
 
149
  'PSR2_Sniffs_Methods_MethodDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php',
150
  'PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php',
151
  'PSR2_Sniffs_Namespaces_UseDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php',
38
  'Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php',
39
  'Generic_Sniffs_Formatting_NoSpaceAfterCastSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php',
40
  'Generic_Sniffs_Formatting_SpaceAfterCastSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php',
41
+ 'Generic_Sniffs_Formatting_SpaceAfterNotSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php',
42
  'Generic_Sniffs_Functions_CallTimePassByReferenceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php',
43
  'Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php',
44
  'Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php',
147
  'PSR2_Sniffs_Files_ClosingTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php',
148
  'PSR2_Sniffs_Files_EndFileNewlineSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php',
149
  'PSR2_Sniffs_Methods_FunctionCallSignatureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php',
150
+ 'PSR2_Sniffs_Methods_FunctionClosingBraceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php',
151
  'PSR2_Sniffs_Methods_MethodDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php',
152
  'PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php',
153
  'PSR2_Sniffs_Namespaces_UseDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit51e22ebbb2a130bf15e98292ff8edf15
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit51e22ebbb2a130bf15e98292ff8edf15
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit51e22ebbb2a130bf15e98292ff8edf15', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit51e22ebbb2a130bf15e98292ff8edf15', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitd41fb065716ad185f2f20e573132cd97
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitd41fb065716ad185f2f20e573132cd97', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitd41fb065716ad185f2f20e573132cd97', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
vendor/composer/installed.json CHANGED
@@ -1,17 +1,17 @@
1
  [
2
  {
3
  "name": "squizlabs/php_codesniffer",
4
- "version": "2.6.1",
5
- "version_normalized": "2.6.1.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
9
- "reference": "fb72ed32f8418db5e7770be1653e62e0d6f5dd3d"
10
  },
11
  "dist": {
12
  "type": "zip",
13
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/fb72ed32f8418db5e7770be1653e62e0d6f5dd3d",
14
- "reference": "fb72ed32f8418db5e7770be1653e62e0d6f5dd3d",
15
  "shasum": ""
16
  },
17
  "require": {
@@ -23,7 +23,7 @@
23
  "require-dev": {
24
  "phpunit/phpunit": "~4.0"
25
  },
26
- "time": "2016-05-30 22:24:32",
27
  "bin": [
28
  "scripts/phpcs",
29
  "scripts/phpcbf"
@@ -80,106 +80,106 @@
80
  ]
81
  },
82
  {
83
- "name": "simplyadmire/composer-plugins",
84
  "version": "dev-master",
85
  "version_normalized": "9999999-dev",
86
  "source": {
87
  "type": "git",
88
- "url": "https://github.com/SimplyAdmire/ComposerPlugins.git",
89
- "reference": "d8380f670694c1c2330b22591ca74adc82cffe19"
90
  },
91
  "dist": {
92
  "type": "zip",
93
- "url": "https://api.github.com/repos/SimplyAdmire/ComposerPlugins/zipball/d8380f670694c1c2330b22591ca74adc82cffe19",
94
- "reference": "d8380f670694c1c2330b22591ca74adc82cffe19",
95
  "shasum": ""
96
  },
97
  "require": {
98
- "composer-plugin-api": "^1.0",
99
- "squizlabs/php_codesniffer": "*"
 
100
  },
101
- "time": "2016-05-12 11:58:38",
102
- "type": "composer-plugin",
103
- "extra": {
104
- "class": [
105
- "SimplyAdmire\\ComposerPlugins\\PhpCodesnifferStandardInstallerPlugin"
106
- ]
107
  },
 
 
108
  "installation-source": "source",
109
  "autoload": {
110
- "psr-0": {
111
- "SimplyAdmire\\ComposerPlugins": ""
112
  }
113
  },
114
  "notification-url": "https://packagist.org/downloads/",
115
  "license": [
116
- "LGPL-3.0+"
117
  ],
118
  "authors": [
119
  {
120
- "name": "Rens Admiraal",
121
- "email": "rens@simplyadmire.com",
122
  "role": "lead"
123
  }
124
  ],
125
- "description": "Composer plugin for installing PHP_CodeSniffer standards",
 
126
  "keywords": [
127
- "PHP_CodeSniffer",
128
- "TYPO3 CMS",
129
- "TYPO3 Flow",
130
- "TYPO3 Neos",
131
  "phpcs",
132
- "standards",
133
- "typo3"
134
  ]
135
  },
136
  {
137
- "name": "wimg/php-compatibility",
138
  "version": "dev-master",
139
  "version_normalized": "9999999-dev",
140
  "source": {
141
  "type": "git",
142
- "url": "https://github.com/wimg/PHPCompatibility.git",
143
- "reference": "cc622c3416153b296d6c1194e59e1d9532490db6"
144
  },
145
  "dist": {
146
  "type": "zip",
147
- "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/cc622c3416153b296d6c1194e59e1d9532490db6",
148
- "reference": "cc622c3416153b296d6c1194e59e1d9532490db6",
149
  "shasum": ""
150
  },
151
  "require": {
152
- "ext-tokenizer": "*",
153
- "php": ">=5.1.2",
154
- "squizlabs/php_codesniffer": "~2.0"
155
  },
156
- "require-dev": {
157
- "satooshi/php-coveralls": "dev-master"
 
 
 
 
158
  },
159
- "time": "2016-06-29 16:11:00",
160
- "type": "phpcodesniffer-standard",
161
  "installation-source": "source",
162
  "autoload": {
163
- "psr-4": {
164
- "PHPCompatibility\\": ""
165
  }
166
  },
167
  "notification-url": "https://packagist.org/downloads/",
168
  "license": [
169
- "LGPL"
170
  ],
171
  "authors": [
172
  {
173
- "name": "Wim Godden",
 
174
  "role": "lead"
175
  }
176
  ],
177
- "description": "This is a set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
178
- "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
179
  "keywords": [
180
- "compatibility",
 
 
 
181
  "phpcs",
182
- "standards"
 
183
  ]
184
  }
185
  ]
1
  [
2
  {
3
  "name": "squizlabs/php_codesniffer",
4
+ "version": "2.6.2",
5
+ "version_normalized": "2.6.2.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
9
+ "reference": "4edb770cb853def6e60c93abb088ad5ac2010c83"
10
  },
11
  "dist": {
12
  "type": "zip",
13
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4edb770cb853def6e60c93abb088ad5ac2010c83",
14
+ "reference": "4edb770cb853def6e60c93abb088ad5ac2010c83",
15
  "shasum": ""
16
  },
17
  "require": {
23
  "require-dev": {
24
  "phpunit/phpunit": "~4.0"
25
  },
26
+ "time": "2016-07-13 23:29:13",
27
  "bin": [
28
  "scripts/phpcs",
29
  "scripts/phpcbf"
80
  ]
81
  },
82
  {
83
+ "name": "wimg/php-compatibility",
84
  "version": "dev-master",
85
  "version_normalized": "9999999-dev",
86
  "source": {
87
  "type": "git",
88
+ "url": "https://github.com/wimg/PHPCompatibility.git",
89
+ "reference": "caf3dfa912f2a75f75b4c8b7158b513d1544c6fd"
90
  },
91
  "dist": {
92
  "type": "zip",
93
+ "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/caf3dfa912f2a75f75b4c8b7158b513d1544c6fd",
94
+ "reference": "caf3dfa912f2a75f75b4c8b7158b513d1544c6fd",
95
  "shasum": ""
96
  },
97
  "require": {
98
+ "ext-tokenizer": "*",
99
+ "php": ">=5.1.2",
100
+ "squizlabs/php_codesniffer": "~2.0"
101
  },
102
+ "require-dev": {
103
+ "satooshi/php-coveralls": "dev-master"
 
 
 
 
104
  },
105
+ "time": "2016-08-18 09:41:13",
106
+ "type": "phpcodesniffer-standard",
107
  "installation-source": "source",
108
  "autoload": {
109
+ "psr-4": {
110
+ "PHPCompatibility\\": ""
111
  }
112
  },
113
  "notification-url": "https://packagist.org/downloads/",
114
  "license": [
115
+ "LGPL-3.0"
116
  ],
117
  "authors": [
118
  {
119
+ "name": "Wim Godden",
 
120
  "role": "lead"
121
  }
122
  ],
123
+ "description": "This is a set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
124
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
125
  "keywords": [
126
+ "compatibility",
 
 
 
127
  "phpcs",
128
+ "standards"
 
129
  ]
130
  },
131
  {
132
+ "name": "simplyadmire/composer-plugins",
133
  "version": "dev-master",
134
  "version_normalized": "9999999-dev",
135
  "source": {
136
  "type": "git",
137
+ "url": "https://github.com/SimplyAdmire/ComposerPlugins.git",
138
+ "reference": "d8380f670694c1c2330b22591ca74adc82cffe19"
139
  },
140
  "dist": {
141
  "type": "zip",
142
+ "url": "https://api.github.com/repos/SimplyAdmire/ComposerPlugins/zipball/d8380f670694c1c2330b22591ca74adc82cffe19",
143
+ "reference": "d8380f670694c1c2330b22591ca74adc82cffe19",
144
  "shasum": ""
145
  },
146
  "require": {
147
+ "composer-plugin-api": "^1.0",
148
+ "squizlabs/php_codesniffer": "*"
 
149
  },
150
+ "time": "2016-05-12 11:58:38",
151
+ "type": "composer-plugin",
152
+ "extra": {
153
+ "class": [
154
+ "SimplyAdmire\\ComposerPlugins\\PhpCodesnifferStandardInstallerPlugin"
155
+ ]
156
  },
 
 
157
  "installation-source": "source",
158
  "autoload": {
159
+ "psr-0": {
160
+ "SimplyAdmire\\ComposerPlugins": ""
161
  }
162
  },
163
  "notification-url": "https://packagist.org/downloads/",
164
  "license": [
165
+ "LGPL-3.0+"
166
  ],
167
  "authors": [
168
  {
169
+ "name": "Rens Admiraal",
170
+ "email": "rens@simplyadmire.com",
171
  "role": "lead"
172
  }
173
  ],
174
+ "description": "Composer plugin for installing PHP_CodeSniffer standards",
 
175
  "keywords": [
176
+ "PHP_CodeSniffer",
177
+ "TYPO3 CMS",
178
+ "TYPO3 Flow",
179
+ "TYPO3 Neos",
180
  "phpcs",
181
+ "standards",
182
+ "typo3"
183
  ]
184
  }
185
  ]
vendor/squizlabs/php_codesniffer/CodeSniffer.conf ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ $phpCodeSnifferConfig = array (
3
+ )
4
+ ?>
vendor/squizlabs/php_codesniffer/CodeSniffer.php CHANGED
@@ -73,7 +73,7 @@ class PHP_CodeSniffer
73
  *
74
  * @var string
75
  */
76
- const VERSION = '2.6.1';
77
 
78
  /**
79
  * Package stability; either stable, beta or alpha.
@@ -513,11 +513,12 @@ class PHP_CodeSniffer
513
  *
514
  * @param string|array $standards The set of code sniffs we are testing
515
  * against.
516
- * @param array $restrictions The sniff codes to restrict the
 
517
  *
518
  * @return void
519
  */
520
- public function initStandard($standards, array $restrictions=array())
521
  {
522
  $standards = (array) $standards;
523
 
@@ -547,7 +548,7 @@ class PHP_CodeSniffer
547
  }
548
 
549
  if (PHP_CODESNIFFER_VERBOSITY === 1) {
550
- $ruleset = simplexml_load_string(file_get_contents($standard));
551
  if ($ruleset !== false) {
552
  $standardName = (string) $ruleset['name'];
553
  }
@@ -567,7 +568,13 @@ class PHP_CodeSniffer
567
  $sniffRestrictions[] = $parts[0].'_sniffs_'.$parts[1].'_'.$parts[2].'sniff';
568
  }
569
 
570
- $this->registerSniffs($sniffs, $sniffRestrictions);
 
 
 
 
 
 
571
  $this->populateTokenListeners();
572
 
573
  if (PHP_CODESNIFFER_VERBOSITY === 1) {
@@ -704,7 +711,7 @@ class PHP_CodeSniffer
704
  echo "Processing ruleset $rulesetPath".PHP_EOL;
705
  }
706
 
707
- $ruleset = simplexml_load_string(file_get_contents($rulesetPath));
708
  if ($ruleset === false) {
709
  throw new PHP_CodeSniffer_Exception("Ruleset $rulesetPath is not valid");
710
  }
@@ -715,7 +722,6 @@ class PHP_CodeSniffer
715
  $cliValues = $this->cli->getCommandLineValues();
716
 
717
  $rulesetDir = dirname($rulesetPath);
718
- $rulesetName = basename($rulesetPath);
719
  self::$rulesetDirs[] = $rulesetDir;
720
 
721
  if (is_dir($rulesetDir.DIRECTORY_SEPARATOR.'Sniffs') === true) {
@@ -1335,11 +1341,13 @@ class PHP_CodeSniffer
1335
  * @param array $files Paths to the sniff files to register.
1336
  * @param array $restrictions The sniff class names to restrict the allowed
1337
  * listeners to.
 
 
1338
  *
1339
  * @return void
1340
  * @throws PHP_CodeSniffer_Exception If a sniff file path is invalid.
1341
  */
1342
- public function registerSniffs($files, $restrictions)
1343
  {
1344
  $listeners = array();
1345
 
@@ -1373,6 +1381,14 @@ class PHP_CodeSniffer
1373
  continue;
1374
  }
1375
 
 
 
 
 
 
 
 
 
1376
  include_once $file;
1377
 
1378
  // Support the use of PHP namespaces. If the class name we included
73
  *
74
  * @var string
75
  */
76
+ const VERSION = '2.6.2';
77
 
78
  /**
79
  * Package stability; either stable, beta or alpha.
513
  *
514
  * @param string|array $standards The set of code sniffs we are testing
515
  * against.
516
+ * @param array $restrictions The sniff codes to restrict the testing to.
517
+ * @param array $exclusions The sniff codes to exclude from testing.
518
  *
519
  * @return void
520
  */
521
+ public function initStandard($standards, array $restrictions=array(), array $exclusions=array())
522
  {
523
  $standards = (array) $standards;
524
 
548
  }
549
 
550
  if (PHP_CODESNIFFER_VERBOSITY === 1) {
551
+ $ruleset = simplexml_load_file($standard);
552
  if ($ruleset !== false) {
553
  $standardName = (string) $ruleset['name'];
554
  }
568
  $sniffRestrictions[] = $parts[0].'_sniffs_'.$parts[1].'_'.$parts[2].'sniff';
569
  }
570
 
571
+ $sniffExclusions = array();
572
+ foreach ($exclusions as $sniffCode) {
573
+ $parts = explode('.', strtolower($sniffCode));
574
+ $sniffExclusions[] = $parts[0].'_sniffs_'.$parts[1].'_'.$parts[2].'sniff';
575
+ }
576
+
577
+ $this->registerSniffs($sniffs, $sniffRestrictions, $sniffExclusions);
578
  $this->populateTokenListeners();
579
 
580
  if (PHP_CODESNIFFER_VERBOSITY === 1) {
711
  echo "Processing ruleset $rulesetPath".PHP_EOL;
712
  }
713
 
714
+ $ruleset = simplexml_load_file($rulesetPath);
715
  if ($ruleset === false) {
716
  throw new PHP_CodeSniffer_Exception("Ruleset $rulesetPath is not valid");
717
  }
722
  $cliValues = $this->cli->getCommandLineValues();
723
 
724
  $rulesetDir = dirname($rulesetPath);
 
725
  self::$rulesetDirs[] = $rulesetDir;
726
 
727
  if (is_dir($rulesetDir.DIRECTORY_SEPARATOR.'Sniffs') === true) {
1341
  * @param array $files Paths to the sniff files to register.
1342
  * @param array $restrictions The sniff class names to restrict the allowed
1343
  * listeners to.
1344
+ * @param array $exclusions The sniff class names to exclude from the
1345
+ * listeners list.
1346
  *
1347
  * @return void
1348
  * @throws PHP_CodeSniffer_Exception If a sniff file path is invalid.
1349
  */
1350
+ public function registerSniffs($files, $restrictions, $exclusions)
1351
  {
1352
  $listeners = array();
1353
 
1381
  continue;
1382
  }
1383
 
1384
+ // If they have specified a list of sniffs to exclude, check
1385
+ // to see if this sniff is allowed.
1386
+ if (empty($exclusions) === false
1387
+ && in_array(strtolower($className), $exclusions) === true
1388
+ ) {
1389
+ continue;
1390
+ }
1391
+
1392
  include_once $file;
1393
 
1394
  // Support the use of PHP namespaces. If the class name we included
vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php CHANGED
@@ -280,6 +280,7 @@ class PHP_CodeSniffer_CLI
280
  $defaults['showSources'] = false;
281
  $defaults['extensions'] = array();
282
  $defaults['sniffs'] = array();
 
283
  $defaults['ignored'] = array();
284
  $defaults['reportFile'] = null;
285
  $defaults['generator'] = '';
@@ -348,6 +349,13 @@ class PHP_CodeSniffer_CLI
348
  $defaults['showProgress'] = (bool) $showProgress;
349
  }
350
 
 
 
 
 
 
 
 
351
  $colors = PHP_CodeSniffer::getConfigData('colors');
352
  if ($colors === null) {
353
  $defaults['colors'] = false;
@@ -473,12 +481,15 @@ class PHP_CodeSniffer_CLI
473
  case '?':
474
  $this->printUsage();
475
  exit(0);
476
- break;
477
  case 'i' :
478
  $this->printInstalledStandards();
479
  exit(0);
480
- break;
481
  case 'v' :
 
 
 
 
 
482
  if (isset($this->values['verbosity']) === false) {
483
  $this->values['verbosity'] = 1;
484
  } else {
@@ -498,8 +509,19 @@ class PHP_CodeSniffer_CLI
498
  $this->values['explain'] = true;
499
  break;
500
  case 'p' :
 
 
 
 
 
501
  $this->values['showProgress'] = true;
502
  break;
 
 
 
 
 
 
503
  case 'd' :
504
  $ini = explode('=', $this->_cliArgs[($pos + 1)]);
505
  $this->_cliArgs[($pos + 1)] = '';
@@ -629,6 +651,17 @@ class PHP_CodeSniffer_CLI
629
  }
630
 
631
  $this->values['sniffs'] = $sniffs;
 
 
 
 
 
 
 
 
 
 
 
632
  } else if (substr($arg, 0, 10) === 'bootstrap=') {
633
  $files = explode(',', substr($arg, 10));
634
  foreach ($files as $file) {
@@ -722,6 +755,10 @@ class PHP_CodeSniffer_CLI
722
  $this->values['standard'] = explode(',', $standards);
723
  }
724
  } else if (substr($arg, 0, 11) === 'extensions=') {
 
 
 
 
725
  $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11)));
726
  } else if (substr($arg, 0, 9) === 'severity=') {
727
  $this->values['errorSeverity'] = (int) substr($arg, 9);
@@ -867,7 +904,7 @@ class PHP_CodeSniffer_CLI
867
 
868
  $phpcs = new PHP_CodeSniffer($values['verbosity'], null, null, null);
869
  $phpcs->setCli($this);
870
- $phpcs->initStandard($values['standard'], $values['sniffs']);
871
  $values = $this->values;
872
 
873
  $phpcs->setTabWidth($values['tabWidth']);
@@ -1213,12 +1250,12 @@ class PHP_CodeSniffer_CLI
1213
  */
1214
  public function printPHPCSUsage()
1215
  {
1216
- echo 'Usage: phpcs [-nwlsaepvi] [-d key[=value]] [--colors] [--no-colors] [--stdin-path=<stdinPath>]'.PHP_EOL;
1217
  echo ' [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>] ...'.PHP_EOL;
1218
  echo ' [--report-width=<reportWidth>] [--generator=<generator>] [--tab-width=<tabWidth>]'.PHP_EOL;
1219
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1220
  echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
1221
- echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--encoding=<encoding>]'.PHP_EOL;
1222
  echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
1223
  echo ' Set runtime value (see --config-set) '.PHP_EOL;
1224
  echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL;
@@ -1228,6 +1265,7 @@ class PHP_CodeSniffer_CLI
1228
  echo ' -a Run interactively'.PHP_EOL;
1229
  echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL;
1230
  echo ' -p Show progress of the run'.PHP_EOL;
 
1231
  echo ' -v[v][v] Print verbose output'.PHP_EOL;
1232
  echo ' -i Show a list of installed coding standards'.PHP_EOL;
1233
  echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
@@ -1253,7 +1291,7 @@ class PHP_CodeSniffer_CLI
1253
  echo ' <reportFile> Write the report to the specified file path'.PHP_EOL;
1254
  echo ' <reportWidth> How many columns wide screen reports should be printed'.PHP_EOL;
1255
  echo ' or set to "auto" to use current screen width, where supported'.PHP_EOL;
1256
- echo ' <sniffs> A comma separated list of sniff codes to limit the check to'.PHP_EOL;
1257
  echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1258
  echo ' <severity> The minimum severity required to display an error or warning'.PHP_EOL;
1259
  echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
@@ -1270,7 +1308,7 @@ class PHP_CodeSniffer_CLI
1270
  public function printPHPCBFUsage()
1271
  {
1272
  echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--stdin-path=<stdinPath>]'.PHP_EOL;
1273
- echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
1274
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1275
  echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>]'.PHP_EOL;
1276
  echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
@@ -1291,7 +1329,7 @@ class PHP_CodeSniffer_CLI
1291
  echo ' The type of the file can be specified using: ext/type'.PHP_EOL;
1292
  echo ' e.g., module/php,es/js'.PHP_EOL;
1293
  echo ' <patterns> A comma separated list of patterns to ignore files and directories'.PHP_EOL;
1294
- echo ' <sniffs> A comma separated list of sniff codes to limit the fixes to'.PHP_EOL;
1295
  echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1296
  echo ' <severity> The minimum severity required to fix an error or warning'.PHP_EOL;
1297
  echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
280
  $defaults['showSources'] = false;
281
  $defaults['extensions'] = array();
282
  $defaults['sniffs'] = array();
283
+ $defaults['exclude'] = array();
284
  $defaults['ignored'] = array();
285
  $defaults['reportFile'] = null;
286
  $defaults['generator'] = '';
349
  $defaults['showProgress'] = (bool) $showProgress;
350
  }
351
 
352
+ $quiet = PHP_CodeSniffer::getConfigData('quiet');
353
+ if ($quiet === null) {
354
+ $defaults['quiet'] = false;
355
+ } else {
356
+ $defaults['quiet'] = (bool) $quiet;
357
+ }
358
+
359
  $colors = PHP_CodeSniffer::getConfigData('colors');
360
  if ($colors === null) {
361
  $defaults['colors'] = false;
481
  case '?':
482
  $this->printUsage();
483
  exit(0);
 
484
  case 'i' :
485
  $this->printInstalledStandards();
486
  exit(0);
 
487
  case 'v' :
488
+ if ($this->values['quiet'] === true) {
489
+ // Ignore when quiet mode is enabled.
490
+ break;
491
+ }
492
+
493
  if (isset($this->values['verbosity']) === false) {
494
  $this->values['verbosity'] = 1;
495
  } else {
509
  $this->values['explain'] = true;
510
  break;
511
  case 'p' :
512
+ if ($this->values['quiet'] === true) {
513
+ // Ignore when quiet mode is enabled.
514
+ break;
515
+ }
516
+
517
  $this->values['showProgress'] = true;
518
  break;
519
+ case 'q' :
520
+ // Quiet mode disables a few other settings as well.
521
+ $this->values['quiet'] = true;
522
+ $this->values['showProgress'] = false;
523
+ $this->values['verbosity'] = 0;
524
+ break;
525
  case 'd' :
526
  $ini = explode('=', $this->_cliArgs[($pos + 1)]);
527
  $this->_cliArgs[($pos + 1)] = '';
651
  }
652
 
653
  $this->values['sniffs'] = $sniffs;
654
+ } else if (substr($arg, 0, 8) === 'exclude=') {
655
+ $sniffs = explode(',', substr($arg, 8));
656
+ foreach ($sniffs as $sniff) {
657
+ if (substr_count($sniff, '.') !== 2) {
658
+ echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
659
+ $this->printUsage();
660
+ exit(2);
661
+ }
662
+ }
663
+
664
+ $this->values['exclude'] = $sniffs;
665
  } else if (substr($arg, 0, 10) === 'bootstrap=') {
666
  $files = explode(',', substr($arg, 10));
667
  foreach ($files as $file) {
755
  $this->values['standard'] = explode(',', $standards);
756
  }
757
  } else if (substr($arg, 0, 11) === 'extensions=') {
758
+ if (isset($this->values['extensions']) === false) {
759
+ $this->values['extensions'] = array();
760
+ }
761
+
762
  $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11)));
763
  } else if (substr($arg, 0, 9) === 'severity=') {
764
  $this->values['errorSeverity'] = (int) substr($arg, 9);
904
 
905
  $phpcs = new PHP_CodeSniffer($values['verbosity'], null, null, null);
906
  $phpcs->setCli($this);
907
+ $phpcs->initStandard($values['standard'], $values['sniffs'], $values['exclude']);
908
  $values = $this->values;
909
 
910
  $phpcs->setTabWidth($values['tabWidth']);
1250
  */
1251
  public function printPHPCSUsage()
1252
  {
1253
+ echo 'Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors] [--stdin-path=<stdinPath>]'.PHP_EOL;
1254
  echo ' [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>] ...'.PHP_EOL;
1255
  echo ' [--report-width=<reportWidth>] [--generator=<generator>] [--tab-width=<tabWidth>]'.PHP_EOL;
1256
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1257
  echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
1258
+ echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--encoding=<encoding>]'.PHP_EOL;
1259
  echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
1260
  echo ' Set runtime value (see --config-set) '.PHP_EOL;
1261
  echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1265
  echo ' -a Run interactively'.PHP_EOL;
1266
  echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL;
1267
  echo ' -p Show progress of the run'.PHP_EOL;
1268
+ echo ' -q Quiet mode; disables progress and verbose output'.PHP_EOL;
1269
  echo ' -v[v][v] Print verbose output'.PHP_EOL;
1270
  echo ' -i Show a list of installed coding standards'.PHP_EOL;
1271
  echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
1291
  echo ' <reportFile> Write the report to the specified file path'.PHP_EOL;
1292
  echo ' <reportWidth> How many columns wide screen reports should be printed'.PHP_EOL;
1293
  echo ' or set to "auto" to use current screen width, where supported'.PHP_EOL;
1294
+ echo ' <sniffs> A comma separated list of sniff codes to include or exclude during checking'.PHP_EOL;
1295
  echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1296
  echo ' <severity> The minimum severity required to display an error or warning'.PHP_EOL;
1297
  echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
1308
  public function printPHPCBFUsage()
1309
  {
1310
  echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--stdin-path=<stdinPath>]'.PHP_EOL;
1311
+ echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
1312
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1313
  echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>]'.PHP_EOL;
1314
  echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
1329
  echo ' The type of the file can be specified using: ext/type'.PHP_EOL;
1330
  echo ' e.g., module/php,es/js'.PHP_EOL;
1331
  echo ' <patterns> A comma separated list of patterns to ignore files and directories'.PHP_EOL;
1332
+ echo ' <sniffs> A comma separated list of sniff codes to include or exclude during fixing'.PHP_EOL;
1333
  echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1334
  echo ' <severity> The minimum severity required to fix an error or warning'.PHP_EOL;
1335
  echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
vendor/squizlabs/php_codesniffer/CodeSniffer/File.php CHANGED
@@ -867,8 +867,8 @@ class PHP_CodeSniffer_File
867
  * @param int $line The line on which the error occurred.
868
  * @param string $code A violation code unique to the sniff message.
869
  * @param array $data Replacements for the error message.
870
- * @param int $severity The severity level for this error. A value of 0 will be converted into the default severity level.
871
- * will be converted into the default severity level.
872
  *
873
  * @return boolean
874
  */
@@ -891,8 +891,8 @@ class PHP_CodeSniffer_File
891
  * @param int $line The line on which the warning occurred.
892
  * @param string $code A violation code unique to the sniff message.
893
  * @param array $data Replacements for the warning message.
894
- * @param int $severity The severity level for this warning. A value of 0 will be converted into the default severity level.
895
- * will be converted into the default severity level.
896
  *
897
  * @return boolean
898
  */
@@ -3398,11 +3398,12 @@ class PHP_CodeSniffer_File
3398
  /**
3399
  * Returns the position of the first non-whitespace token in a statement.
3400
  *
3401
- * @param int $start The position to start searching from in the token stack.
 
3402
  *
3403
  * @return int
3404
  */
3405
- public function findStartOfStatement($start)
3406
  {
3407
  $endTokens = PHP_CodeSniffer_Tokens::$blockOpeners;
3408
 
@@ -3414,6 +3415,15 @@ class PHP_CodeSniffer_File
3414
  $endTokens[T_CLOSE_TAG] = true;
3415
  $endTokens[T_OPEN_SHORT_ARRAY] = true;
3416
 
 
 
 
 
 
 
 
 
 
3417
  $lastNotEmpty = $start;
3418
 
3419
  for ($i = $start; $i >= 0; $i--) {
@@ -3453,11 +3463,12 @@ class PHP_CodeSniffer_File
3453
  /**
3454
  * Returns the position of the last non-whitespace token in a statement.
3455
  *
3456
- * @param int $start The position to start searching from in the token stack.
 
3457
  *
3458
  * @return int
3459
  */
3460
- public function findEndOfStatement($start)
3461
  {
3462
  $endTokens = array(
3463
  T_COLON => true,
@@ -3472,6 +3483,15 @@ class PHP_CodeSniffer_File
3472
  T_CLOSE_TAG => true,
3473
  );
3474
 
 
 
 
 
 
 
 
 
 
3475
  $lastNotEmpty = $start;
3476
 
3477
  for ($i = $start; $i < $this->numTokens; $i++) {
867
  * @param int $line The line on which the error occurred.
868
  * @param string $code A violation code unique to the sniff message.
869
  * @param array $data Replacements for the error message.
870
+ * @param int $severity The severity level for this error. A value of 0
871
+ * will be converted into the default severity level.
872
  *
873
  * @return boolean
874
  */
891
  * @param int $line The line on which the warning occurred.
892
  * @param string $code A violation code unique to the sniff message.
893
  * @param array $data Replacements for the warning message.
894
+ * @param int $severity The severity level for this warning. A value of 0
895
+ * will be converted into the default severity level.
896
  *
897
  * @return boolean
898
  */
3398
  /**
3399
  * Returns the position of the first non-whitespace token in a statement.
3400
  *
3401
+ * @param int $start The position to start searching from in the token stack.
3402
+ * @param int|array $ignore Token types that should not be considered stop points.
3403
  *
3404
  * @return int
3405
  */
3406
+ public function findStartOfStatement($start, $ignore=null)
3407
  {
3408
  $endTokens = PHP_CodeSniffer_Tokens::$blockOpeners;
3409
 
3415
  $endTokens[T_CLOSE_TAG] = true;
3416
  $endTokens[T_OPEN_SHORT_ARRAY] = true;
3417
 
3418
+ if ($ignore !== null) {
3419
+ $ignore = (array) $ignore;
3420
+ foreach ($ignore as $code) {
3421
+ if (isset($endTokens[$code]) === true) {
3422
+ unset($endTokens[$code]);
3423
+ }
3424
+ }
3425
+ }
3426
+
3427
  $lastNotEmpty = $start;
3428
 
3429
  for ($i = $start; $i >= 0; $i--) {
3463
  /**
3464
  * Returns the position of the last non-whitespace token in a statement.
3465
  *
3466
+ * @param int $start The position to start searching from in the token stack.
3467
+ * @param int|array $ignore Token types that should not be considered stop points.
3468
  *
3469
  * @return int
3470
  */
3471
+ public function findEndOfStatement($start, $ignore=null)
3472
  {
3473
  $endTokens = array(
3474
  T_COLON => true,
3483
  T_CLOSE_TAG => true,
3484
  );
3485
 
3486
+ if ($ignore !== null) {
3487
+ $ignore = (array) $ignore;
3488
+ foreach ($ignore as $code) {
3489
+ if (isset($endTokens[$code]) === true) {
3490
+ unset($endTokens[$code]);
3491
+ }
3492
+ }
3493
+ }
3494
+
3495
  $lastNotEmpty = $start;
3496
 
3497
  for ($i = $start; $i < $this->numTokens; $i++) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/VersionControl.php CHANGED
@@ -107,9 +107,12 @@ abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer
107
  if ($showSources === true) {
108
  $source = $error['source'];
109
  if (isset($this->_sourceCache[$author][$source]) === false) {
110
- $this->_sourceCache[$author][$source] = 1;
 
 
 
111
  } else {
112
- $this->_sourceCache[$author][$source]++;
113
  }
114
  }
115
  }
@@ -183,7 +186,7 @@ abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer
183
  foreach ($this->_authorCache as $author => $count) {
184
  $maxLength = max($maxLength, strlen($author));
185
  if ($showSources === true && isset($this->_sourceCache[$author]) === true) {
186
- foreach ($this->_sourceCache[$author] as $source => $count) {
187
  if ($source === 'count') {
188
  continue;
189
  }
@@ -209,6 +212,16 @@ abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer
209
 
210
  echo "\033[0m";
211
 
 
 
 
 
 
 
 
 
 
 
212
  foreach ($this->_authorCache as $author => $count) {
213
  if ($this->_praiseCache[$author]['good'] === 0) {
214
  $percent = 0;
@@ -235,15 +248,43 @@ abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer
235
  asort($errors);
236
  $errors = array_reverse($errors);
237
 
238
- foreach ($errors as $source => $count) {
239
  if ($source === 'count') {
240
  continue;
241
  }
242
 
 
 
 
 
 
 
 
243
  $line = str_repeat(' ', (5 - strlen($count))).$count;
244
- echo ' '.$source.str_repeat(' ', ($width - 14 - strlen($source))).$line.PHP_EOL;
245
- }
246
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  }//end foreach
248
 
249
  echo str_repeat('-', $width).PHP_EOL;
@@ -260,8 +301,13 @@ abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer
260
  echo "\033[0m";
261
 
262
  if ($totalFixable > 0) {
263
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
264
- echo "\033[1mPHPCBF CAN FIX $totalFixable OF THESE SNIFF VIOLATIONS AUTOMATICALLY\033[0m";
 
 
 
 
 
265
  }
266
 
267
  echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
107
  if ($showSources === true) {
108
  $source = $error['source'];
109
  if (isset($this->_sourceCache[$author][$source]) === false) {
110
+ $this->_sourceCache[$author][$source] = array(
111
+ 'count' => 1,
112
+ 'fixable' => $error['fixable'],
113
+ );
114
  } else {
115
+ $this->_sourceCache[$author][$source]['count']++;
116
  }
117
  }
118
  }
186
  foreach ($this->_authorCache as $author => $count) {
187
  $maxLength = max($maxLength, strlen($author));
188
  if ($showSources === true && isset($this->_sourceCache[$author]) === true) {
189
+ foreach ($this->_sourceCache[$author] as $source => $sourceData) {
190
  if ($source === 'count') {
191
  continue;
192
  }
212
 
213
  echo "\033[0m";
214
 
215
+ if ($showSources === true) {
216
+ $maxSniffWidth = ($width - 15);
217
+
218
+ if ($totalFixable > 0) {
219
+ $maxSniffWidth -= 4;
220
+ }
221
+ }
222
+
223
+ $fixableSources = 0;
224
+
225
  foreach ($this->_authorCache as $author => $count) {
226
  if ($this->_praiseCache[$author]['good'] === 0) {
227
  $percent = 0;
248
  asort($errors);
249
  $errors = array_reverse($errors);
250
 
251
+ foreach ($errors as $source => $sourceData) {
252
  if ($source === 'count') {
253
  continue;
254
  }
255
 
256
+ $count = $sourceData['count'];
257
+
258
+ $srcLength = strlen($source);
259
+ if ($srcLength > $maxSniffWidth) {
260
+ $source = substr($source, 0, $maxSniffWidth);
261
+ }
262
+
263
  $line = str_repeat(' ', (5 - strlen($count))).$count;
264
+
265
+ echo ' ';
266
+ if ($totalFixable > 0) {
267
+ echo '[';
268
+ if ($sourceData['fixable'] === true) {
269
+ echo 'x';
270
+ $fixableSources++;
271
+ } else {
272
+ echo ' ';
273
+ }
274
+
275
+ echo '] ';
276
+ }
277
+
278
+ echo $source;
279
+ if ($totalFixable > 0) {
280
+ echo str_repeat(' ', ($width - 18 - strlen($source)));
281
+ } else {
282
+ echo str_repeat(' ', ($width - 14 - strlen($source)));
283
+ }
284
+
285
+ echo $line.PHP_EOL;
286
+ }//end foreach
287
+ }//end if
288
  }//end foreach
289
 
290
  echo str_repeat('-', $width).PHP_EOL;
301
  echo "\033[0m";
302
 
303
  if ($totalFixable > 0) {
304
+ if ($showSources === true) {
305
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
306
+ echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
307
+ } else {
308
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
309
+ echo "\033[1mPHPCBF CAN FIX $totalFixable OF THESE SNIFF VIOLATIONS AUTOMATICALLY\033[0m";
310
+ }
311
  }
312
 
313
  echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php CHANGED
@@ -127,6 +127,30 @@ class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
127
  $phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  if ($this->absoluteLineLimit > 0
131
  && $lineLength > $this->absoluteLineLimit
132
  ) {
127
  $phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
128
  }
129
 
130
+ // If this is a long comment, check if it can be broken up onto multiple lines.
131
+ // Some comments contain unbreakable strings like URLs and so it makes sense
132
+ // to ignore the line length in these cases if the URL would be longer than the max
133
+ // line length once you indent it to the correct level.
134
+ if ($lineLength > $this->lineLimit
135
+ && ($tokens[$stackPtr]['code'] === T_COMMENT
136
+ || $tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING)
137
+ ) {
138
+ $oldLength = strlen($tokens[$stackPtr]['content']);
139
+ $newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
140
+ $indent = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
141
+
142
+ $nonBreakingLength = $tokens[$stackPtr]['length'];
143
+
144
+ $space = strrpos($tokens[$stackPtr]['content'], ' ');
145
+ if ($space !== false) {
146
+ $nonBreakingLength -= ($space + 1);
147
+ }
148
+
149
+ if (($nonBreakingLength + $indent) > $this->lineLimit) {
150
+ return;
151
+ }
152
+ }
153
+
154
  if ($this->absoluteLineLimit > 0
155
  && $lineLength > $this->absoluteLineLimit
156
  ) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php CHANGED
@@ -257,6 +257,8 @@ class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_C
257
  return $stackPtr;
258
  }
259
 
 
 
260
  $errorGenerated = false;
261
  foreach ($assignments as $assignment => $data) {
262
  if ($data['found'] === $data['expected']) {
@@ -277,7 +279,7 @@ class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_C
277
  }
278
  }
279
 
280
- if (count($assignments) === 1) {
281
  $type = 'Incorrect';
282
  $error = 'Equals sign not aligned correctly; expected %s but found %s';
283
  } else {
@@ -308,10 +310,12 @@ class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_C
308
  }
309
  }//end foreach
310
 
311
- if ($errorGenerated === true) {
312
- $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'no');
313
- } else {
314
- $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'yes');
 
 
315
  }
316
 
317
  if ($stopped !== null) {
257
  return $stackPtr;
258
  }
259
 
260
+ $numAssignments = count($assignments);
261
+
262
  $errorGenerated = false;
263
  foreach ($assignments as $assignment => $data) {
264
  if ($data['found'] === $data['expected']) {
279
  }
280
  }
281
 
282
+ if ($numAssignments === 1) {
283
  $type = 'Incorrect';
284
  $error = 'Equals sign not aligned correctly; expected %s but found %s';
285
  } else {
310
  }
311
  }//end foreach
312
 
313
+ if ($numAssignments > 1) {
314
+ if ($errorGenerated === true) {
315
+ $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'no');
316
+ } else {
317
+ $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'yes');
318
+ }
319
  }
320
 
321
  if ($stopped !== null) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Formatting_SpaceAfterNotSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Formatting_SpaceAfterNotSniff.
17
+ *
18
+ * Ensures there is a single space after a NOT operator.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Formatting_SpaceAfterNotSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array(
37
+ 'PHP',
38
+ 'JS',
39
+ );
40
+
41
+
42
+ /**
43
+ * Returns an array of tokens this test wants to listen for.
44
+ *
45
+ * @return array
46
+ */
47
+ public function register()
48
+ {
49
+ return array(T_BOOLEAN_NOT);
50
+
51
+ }//end register()
52
+
53
+
54
+ /**
55
+ * Processes this test, when one of its tokens is encountered.
56
+ *
57
+ * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
58
+ * @param int $stackPtr The position of the current token in
59
+ * the stack passed in $tokens.
60
+ *
61
+ * @return void
62
+ */
63
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
+ {
65
+ $tokens = $phpcsFile->getTokens();
66
+
67
+ $spacing = 0;
68
+ if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
69
+ $spacing = $tokens[($stackPtr + 1)]['length'];
70
+ }
71
+
72
+ if ($spacing === 1) {
73
+ return;
74
+ }
75
+
76
+ $message = 'There must be a single space after a NOT operator; %s found';
77
+ $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', array($spacing));
78
+
79
+ if ($fix === true) {
80
+ if ($spacing === 0) {
81
+ $phpcsFile->fixer->addContent($stackPtr, ' ');
82
+ } else {
83
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
84
+ }
85
+ }
86
+
87
+ }//end process()
88
+
89
+
90
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php CHANGED
@@ -253,87 +253,146 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
253
 
254
  $parenOpener = $tokens[$parenCloser]['parenthesis_opener'];
255
  if ($tokens[$parenCloser]['line'] !== $tokens[$parenOpener]['line']) {
256
- $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parenOpener, true);
257
- $checkIndent = ($tokens[$first]['column'] - 1);
258
- if (isset($adjustments[$first]) === true) {
259
- $checkIndent += $adjustments[$first];
 
 
 
 
 
 
260
  }
261
 
262
- $exact = false;
263
-
264
- if ($this->_debug === true) {
265
- $line = $tokens[$first]['line'];
266
- $type = $tokens[$first]['type'];
267
- echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
 
 
 
 
 
268
  }
269
 
270
- if ($first === $tokens[$parenCloser]['parenthesis_opener']) {
271
- // This is unlikely to be the start of the statement, so look
272
- // back further to find it.
273
- $first--;
 
 
 
 
 
 
 
 
 
 
274
  }
275
 
276
- $prev = $phpcsFile->findStartOfStatement($first);
277
- if ($prev !== $first) {
278
- // This is not the start of the statement.
 
 
 
 
 
 
 
 
 
 
279
  if ($this->_debug === true) {
280
- $line = $tokens[$prev]['line'];
281
- $type = $tokens[$prev]['type'];
282
- echo "\t* previous is $type on line $line *".PHP_EOL;
 
 
 
 
 
 
283
  }
284
 
285
- $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
286
- $prev = $phpcsFile->findStartOfStatement($first);
287
- $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
288
  if ($this->_debug === true) {
289
  $line = $tokens[$first]['line'];
290
  $type = $tokens[$first]['type'];
291
- echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
292
  }
293
- }
294
 
295
- if (isset($tokens[$first]['scope_closer']) === true
296
- && $tokens[$first]['scope_closer'] === $first
297
- ) {
298
- if ($this->_debug === true) {
299
- echo "\t* first token is a scope closer *".PHP_EOL;
300
  }
301
 
302
- if (isset($tokens[$first]['scope_condition']) === true) {
303
- $scopeCloser = $first;
304
- $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['scope_condition'], true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
 
 
 
 
 
 
 
 
306
  $currentIndent = ($tokens[$first]['column'] - 1);
307
  if (isset($adjustments[$first]) === true) {
308
  $currentIndent += $adjustments[$first];
309
  }
310
 
311
- // Make sure it is divisible by our expected indent.
312
- if ($tokens[$tokens[$scopeCloser]['scope_condition']]['code'] !== T_CLOSURE) {
313
- $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
314
- }
315
-
316
  $setIndents[$first] = $currentIndent;
317
 
318
  if ($this->_debug === true) {
319
  $type = $tokens[$first]['type'];
320
- echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
321
  }
322
  }//end if
323
- } else {
324
- // Don't force current indent to divisible because there could be custom
325
- // rules in place between parenthesis, such as with arrays.
326
- $currentIndent = ($tokens[$first]['column'] - 1);
327
- if (isset($adjustments[$first]) === true) {
328
- $currentIndent += $adjustments[$first];
329
- }
330
-
331
- $setIndents[$first] = $currentIndent;
332
-
333
- if ($this->_debug === true) {
334
- $type = $tokens[$first]['type'];
335
- echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
336
- }
337
  }//end if
338
  } else if ($this->_debug === true) {
339
  echo "\t * ignoring single-line definition *".PHP_EOL;
@@ -379,7 +438,7 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
379
  $first--;
380
  }
381
 
382
- $prev = $phpcsFile->findStartOfStatement($first);
383
  if ($prev !== $first) {
384
  // This is not the start of the statement.
385
  if ($this->_debug === true) {
@@ -389,7 +448,7 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
389
  }
390
 
391
  $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
392
- $prev = $phpcsFile->findStartOfStatement($first);
393
  $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
394
  if ($this->_debug === true) {
395
  $line = $tokens[$first]['line'];
@@ -929,13 +988,13 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
929
  }
930
 
931
  // Make sure it is divisible by our expected indent.
932
- $currentIndent = (int) (floor($currentIndent / $this->indent) * $this->indent);
933
- $setIndents[$first] = $currentIndent;
934
  $i = $tokens[$i]['scope_opener'];
 
935
 
936
  if ($this->_debug === true) {
937
- $type = $tokens[$first]['type'];
938
- echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
939
  }
940
 
941
  continue;
@@ -1152,7 +1211,7 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
1152
  }
1153
 
1154
  if ($condition === 0 || $tokens[$condition]['scope_opener'] < $first) {
1155
- $currentIndent -= $this->indent;
1156
  } else if ($this->_debug === true) {
1157
  echo "\t* ignoring scope closer *".PHP_EOL;
1158
  }
253
 
254
  $parenOpener = $tokens[$parenCloser]['parenthesis_opener'];
255
  if ($tokens[$parenCloser]['line'] !== $tokens[$parenOpener]['line']) {
256
+ $parens = 0;
257
+ if (isset($tokens[$parenCloser]['nested_parenthesis']) === true
258
+ && empty($tokens[$parenCloser]['nested_parenthesis']) === false
259
+ ) {
260
+ end($tokens[$parenCloser]['nested_parenthesis']);
261
+ $parens = key($tokens[$parenCloser]['nested_parenthesis']);
262
+ if ($this->_debug === true) {
263
+ $line = $tokens[$parens]['line'];
264
+ echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
265
+ }
266
  }
267
 
268
+ $condition = 0;
269
+ if (isset($tokens[$parenCloser]['conditions']) === true
270
+ && empty($tokens[$parenCloser]['conditions']) === false
271
+ ) {
272
+ end($tokens[$parenCloser]['conditions']);
273
+ $condition = key($tokens[$parenCloser]['conditions']);
274
+ if ($this->_debug === true) {
275
+ $line = $tokens[$condition]['line'];
276
+ $type = $tokens[$condition]['type'];
277
+ echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL;
278
+ }
279
  }
280
 
281
+ if ($parens > $condition) {
282
+ if ($this->_debug === true) {
283
+ echo "\t* using parenthesis *".PHP_EOL;
284
+ }
285
+
286
+ $parenOpener = $parens;
287
+ $condition = 0;
288
+ } else if ($condition > 0) {
289
+ if ($this->_debug === true) {
290
+ echo "\t* using condition *".PHP_EOL;
291
+ }
292
+
293
+ $parenOpener = $condition;
294
+ $parens = 0;
295
  }
296
 
297
+ $exact = false;
298
+
299
+ if ($condition > 0
300
+ && isset($tokens[$condition]['scope_opener']) === true
301
+ && isset($setIndents[$tokens[$condition]['scope_opener']]) === true
302
+ ) {
303
+ $checkIndent = $setIndents[$tokens[$condition]['scope_opener']];
304
+ if (isset($adjustments[$condition]) === true) {
305
+ $checkIndent += $adjustments[$condition];
306
+ }
307
+
308
+ $currentIndent = $checkIndent;
309
+
310
  if ($this->_debug === true) {
311
+ $type = $tokens[$condition]['type'];
312
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $condition ($type)".PHP_EOL;
313
+ }
314
+ } else {
315
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parenOpener, true);
316
+
317
+ $checkIndent = ($tokens[$first]['column'] - 1);
318
+ if (isset($adjustments[$first]) === true) {
319
+ $checkIndent += $adjustments[$first];
320
  }
321
 
 
 
 
322
  if ($this->_debug === true) {
323
  $line = $tokens[$first]['line'];
324
  $type = $tokens[$first]['type'];
325
+ echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
326
  }
 
327
 
328
+ if ($first === $tokens[$parenCloser]['parenthesis_opener']) {
329
+ // This is unlikely to be the start of the statement, so look
330
+ // back further to find it.
331
+ $first--;
 
332
  }
333
 
334
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
335
+ if ($prev !== $first) {
336
+ // This is not the start of the statement.
337
+ if ($this->_debug === true) {
338
+ $line = $tokens[$prev]['line'];
339
+ $type = $tokens[$prev]['type'];
340
+ echo "\t* previous is $type on line $line *".PHP_EOL;
341
+ }
342
+
343
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
344
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
345
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
346
+ if ($this->_debug === true) {
347
+ $line = $tokens[$first]['line'];
348
+ $type = $tokens[$first]['type'];
349
+ echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
350
+ }
351
+ }
352
+
353
+ if (isset($tokens[$first]['scope_closer']) === true
354
+ && $tokens[$first]['scope_closer'] === $first
355
+ ) {
356
+ if ($this->_debug === true) {
357
+ echo "\t* first token is a scope closer *".PHP_EOL;
358
+ }
359
+
360
+ if (isset($tokens[$first]['scope_condition']) === true) {
361
+ $scopeCloser = $first;
362
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['scope_condition'], true);
363
+
364
+ $currentIndent = ($tokens[$first]['column'] - 1);
365
+ if (isset($adjustments[$first]) === true) {
366
+ $currentIndent += $adjustments[$first];
367
+ }
368
+
369
+ // Make sure it is divisible by our expected indent.
370
+ if ($tokens[$tokens[$scopeCloser]['scope_condition']]['code'] !== T_CLOSURE) {
371
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
372
+ }
373
+
374
+ $setIndents[$first] = $currentIndent;
375
 
376
+ if ($this->_debug === true) {
377
+ $type = $tokens[$first]['type'];
378
+ echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
379
+ }
380
+ }//end if
381
+ } else {
382
+ // Don't force current indent to divisible because there could be custom
383
+ // rules in place between parenthesis, such as with arrays.
384
  $currentIndent = ($tokens[$first]['column'] - 1);
385
  if (isset($adjustments[$first]) === true) {
386
  $currentIndent += $adjustments[$first];
387
  }
388
 
 
 
 
 
 
389
  $setIndents[$first] = $currentIndent;
390
 
391
  if ($this->_debug === true) {
392
  $type = $tokens[$first]['type'];
393
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
394
  }
395
  }//end if
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  }//end if
397
  } else if ($this->_debug === true) {
398
  echo "\t * ignoring single-line definition *".PHP_EOL;
438
  $first--;
439
  }
440
 
441
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
442
  if ($prev !== $first) {
443
  // This is not the start of the statement.
444
  if ($this->_debug === true) {
448
  }
449
 
450
  $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
451
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
452
  $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
453
  if ($this->_debug === true) {
454
  $line = $tokens[$first]['line'];
988
  }
989
 
990
  // Make sure it is divisible by our expected indent.
991
+ $currentIndent = (int) (floor($currentIndent / $this->indent) * $this->indent);
 
992
  $i = $tokens[$i]['scope_opener'];
993
+ $setIndents[$i] = $currentIndent;
994
 
995
  if ($this->_debug === true) {
996
+ $type = $tokens[$i]['type'];
997
+ echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
998
  }
999
 
1000
  continue;
1211
  }
1212
 
1213
  if ($condition === 0 || $tokens[$condition]['scope_opener'] < $first) {
1214
+ $currentIndent = $setIndents[$first];
1215
  } else if ($this->_debug === true) {
1216
  echo "\t* ignoring scope closer *".PHP_EOL;
1217
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php CHANGED
@@ -118,9 +118,9 @@ class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeS
118
  // Each line between the parenthesis should be indented 4 spaces
119
  // and start with an operator, unless the line is inside a
120
  // function call, in which case it is ignored.
121
- $lastLine = $tokens[$openBracket]['line'];
122
  for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
123
- if ($tokens[$i]['line'] !== $lastLine) {
124
  if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) {
125
  $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
126
  if ($next !== $closeBracket) {
@@ -152,7 +152,7 @@ class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeS
152
  }//end if
153
 
154
  if ($tokens[$i]['code'] === T_COMMENT) {
155
- $lastLine = $tokens[$i]['line'];
156
  continue;
157
  }
158
 
@@ -181,8 +181,8 @@ class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeS
181
  }
182
  }
183
 
184
- if ($tokens[$i]['line'] !== $tokens[$closeBracket]['line']) {
185
- $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $i, null, true);
186
  if (isset(PHP_CodeSniffer_Tokens::$booleanOperators[$tokens[$next]['code']]) === false) {
187
  $error = 'Each line in a multi-line IF statement must begin with a boolean operator';
188
  $fix = $phpcsFile->addFixableError($error, $i, 'StartWithBoolean');
@@ -202,7 +202,7 @@ class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeS
202
  }
203
  }//end if
204
 
205
- $lastLine = $tokens[$i]['line'];
206
  }//end if
207
 
208
  if ($tokens[$i]['code'] === T_STRING) {
@@ -211,7 +211,7 @@ class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeS
211
  // This is a function call, so skip to the end as they
212
  // have their own indentation rules.
213
  $i = $tokens[$next]['parenthesis_closer'];
214
- $lastLine = $tokens[$i]['line'];
215
  continue;
216
  }
217
  }
118
  // Each line between the parenthesis should be indented 4 spaces
119
  // and start with an operator, unless the line is inside a
120
  // function call, in which case it is ignored.
121
+ $prevLine = $tokens[$openBracket]['line'];
122
  for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
123
+ if ($tokens[$i]['line'] !== $prevLine) {
124
  if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) {
125
  $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
126
  if ($next !== $closeBracket) {
152
  }//end if
153
 
154
  if ($tokens[$i]['code'] === T_COMMENT) {
155
+ $prevLine = $tokens[$i]['line'];
156
  continue;
157
  }
158
 
181
  }
182
  }
183
 
184
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $i, null, true);
185
+ if ($next !== $closeBracket) {
186
  if (isset(PHP_CodeSniffer_Tokens::$booleanOperators[$tokens[$next]['code']]) === false) {
187
  $error = 'Each line in a multi-line IF statement must begin with a boolean operator';
188
  $fix = $phpcsFile->addFixableError($error, $i, 'StartWithBoolean');
202
  }
203
  }//end if
204
 
205
+ $prevLine = $tokens[$i]['line'];
206
  }//end if
207
 
208
  if ($tokens[$i]['code'] === T_STRING) {
211
  // This is a function call, so skip to the end as they
212
  // have their own indentation rules.
213
  $i = $tokens[$next]['parenthesis_closer'];
214
+ $prevLine = $tokens[$i]['line'];
215
  continue;
216
  }
217
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/.coveralls.yml CHANGED
@@ -1,3 +1,3 @@
1
  src_dir: Sniffs
2
  coverage_clover: build/logs/clover.xml
3
- json_path: build/logs/coveralls-upload.json
1
  src_dir: Sniffs
2
  coverage_clover: build/logs/clover.xml
3
+ json_path: build/logs/coveralls-upload.json
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/.scrutinizer.yml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ filter:
2
+ excluded_paths:
3
+ - 'Tests/sniff-examples/*'
4
+
5
+ tools:
6
+ php_sim: true
7
+ php_pdepend: true
8
+ php_analyzer: true
9
+ sensiolabs_security_checker: true
10
+
11
+ checks:
12
+ php: true
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/README.md CHANGED
@@ -20,8 +20,8 @@ Thanks to [![WPEngine](https://cu.be/img/wpengine.png)](http://wpengine.com) for
20
  Installation (method 1)
21
  -----------------------
22
 
23
- * Install [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) with `pear install PHP_CodeSniffer` (PHP_CodeSniffer 1.5.1 or later is required for full support, notices may be thrown on older versions).
24
- * Checkout this repository as `PHPCompatibility` into the `PHP/CodeSniffer/Standards` directory.
25
 
26
 
27
  Installation in Composer project (method 2)
@@ -32,8 +32,9 @@ Installation in Composer project (method 2)
32
  ```json
33
  "require-dev": {
34
  "squizlabs/php_codesniffer": "*",
35
- "wimg/php-compatibility": "dev-master",
36
- "simplyadmire/composer-plugins" : "@dev"
 
37
  },
38
 
39
  ```
@@ -50,6 +51,50 @@ Using the compatibility sniffs
50
 
51
  More information can be found on Wim Godden's [blog](http://techblog.wimgodden.be/tag/codesniffer).
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  Running the Sniff Tests
54
  -----------------------
55
  All the sniffs are fully tested with PHPUnit tests. In order to run the tests
20
  Installation (method 1)
21
  -----------------------
22
 
23
+ * Install [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) with `pear install PHP_CodeSniffer` (PHP_CodeSniffer 1.5.1 is required for 90% of the sniffs, 2.6 or later is required for full support, notices may be thrown on older versions).
24
+ * Checkout the latest release from https://github.com/wimg/PHPCompatibility/releases into the `PHP/CodeSniffer/Standards/PHPCompatibility` directory.
25
 
26
 
27
  Installation in Composer project (method 2)
32
  ```json
33
  "require-dev": {
34
  "squizlabs/php_codesniffer": "*",
35
+ "wimg/php-compatibility": "*",
36
+ "simplyadmire/composer-plugins" : "@dev",
37
+ "prefer-stable" : true
38
  },
39
 
40
  ```
51
 
52
  More information can be found on Wim Godden's [blog](http://techblog.wimgodden.be/tag/codesniffer).
53
 
54
+ Using a custom ruleset
55
+ ------------------------------
56
+ Alternatively, you can add PHPCompatibility to a custom PHPCS ruleset.
57
+
58
+ ```xml
59
+ <?xml version="1.0"?>
60
+ <ruleset name="Custom ruleset">
61
+ <description>My rules for PHP_CodeSniffer</description>
62
+
63
+ <!-- Run against the PHPCompatibility ruleset -->
64
+ <rule ref="PHPCompatibility" />
65
+
66
+ <!-- Run against a second ruleset -->
67
+ <rule ref="PSR2" />
68
+
69
+ </ruleset>
70
+ ```
71
+
72
+ You can also set the `testVersion` from within the ruleset:
73
+ ```xml
74
+ <arg name="testVersion" value="5.3-5.5"/>
75
+ ```
76
+
77
+ Other advanced options, such as changing the message type or severity, as described in the [PHPCS Annotated ruleset](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) wiki page are, of course, also supported.
78
+
79
+
80
+ ##### PHPCompatibility specific options
81
+
82
+ At this moment, there is one sniff which has a property which can be set via the ruleset. More custom properties may become available in the future.
83
+
84
+ The `PHPCompatibility.PHP.RemovedExtensions` sniff checks for removed extensions based on the function prefix used for these extensions.
85
+ This might clash with userland function using the same function prefix.
86
+
87
+ To whitelist userland functions, you can pass a comma-delimited list of function names to the sniff.
88
+ ```xml
89
+ <!-- Whitelist the mysql_to_rfc3339() and mysql_another_function() functions. -->
90
+ <rule ref="PHPCompatibility.PHP.RemovedExtensions">
91
+ <properties>
92
+ <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
93
+ </properties>
94
+ </rule>
95
+ ```
96
+
97
+
98
  Running the Sniff Tests
99
  -----------------------
100
  All the sniffs are fully tested with PHPUnit tests. In order to run the tests
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniff.php CHANGED
@@ -41,38 +41,43 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
41
  private function getTestVersion()
42
  {
43
  /**
44
- * var $testVersion will hold an array containing min/max version of PHP
45
  * that we are checking against (see above). If only a single version
46
  * number is specified, then this is used as both the min and max.
47
  */
48
- static $arrTestVersions;
49
 
50
- if (!isset($testVersion)) {
51
- $testVersion = PHP_CodeSniffer::getConfigData('testVersion');
52
- $testVersion = trim($testVersion);
53
 
54
- $arrTestVersions = array(null, null);
 
 
55
  if (preg_match('/^\d+\.\d+$/', $testVersion)) {
56
- $arrTestVersions = array($testVersion, $testVersion);
57
  }
58
  elseif (preg_match('/^(\d+\.\d+)\s*-\s*(\d+\.\d+)$/', $testVersion,
59
  $matches))
60
  {
61
- if (version_compare($matches[1], $matches[2], ">")) {
62
  trigger_error("Invalid range in testVersion setting: '"
63
  . $testVersion . "'", E_USER_WARNING);
64
  }
65
  else {
66
- $arrTestVersions = array($matches[1], $matches[2]);
67
  }
68
  }
69
- elseif (!$testVersion == "") {
70
  trigger_error("Invalid testVersion setting: '" . $testVersion
71
  . "'", E_USER_WARNING);
72
  }
73
  }
74
 
75
- return $arrTestVersions;
 
 
 
 
 
76
  }
77
 
78
  public function supportsAbove($phpVersion)
@@ -103,4 +108,681 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
103
  }
104
  }//end supportsBelow()
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }//end class
41
  private function getTestVersion()
42
  {
43
  /**
44
+ * var $arrTestVersions will hold an array containing min/max version of PHP
45
  * that we are checking against (see above). If only a single version
46
  * number is specified, then this is used as both the min and max.
47
  */
48
+ static $arrTestVersions = array();
49
 
50
+ $testVersion = trim(PHP_CodeSniffer::getConfigData('testVersion'));
 
 
51
 
52
+ if (!isset($arrTestVersions[$testVersion]) && !empty($testVersion)) {
53
+
54
+ $arrTestVersions[$testVersion] = array(null, null);
55
  if (preg_match('/^\d+\.\d+$/', $testVersion)) {
56
+ $arrTestVersions[$testVersion] = array($testVersion, $testVersion);
57
  }
58
  elseif (preg_match('/^(\d+\.\d+)\s*-\s*(\d+\.\d+)$/', $testVersion,
59
  $matches))
60
  {
61
+ if (version_compare($matches[1], $matches[2], '>')) {
62
  trigger_error("Invalid range in testVersion setting: '"
63
  . $testVersion . "'", E_USER_WARNING);
64
  }
65
  else {
66
+ $arrTestVersions[$testVersion] = array($matches[1], $matches[2]);
67
  }
68
  }
69
+ elseif (!$testVersion == '') {
70
  trigger_error("Invalid testVersion setting: '" . $testVersion
71
  . "'", E_USER_WARNING);
72
  }
73
  }
74
 
75
+ if (isset($arrTestVersions[$testVersion])) {
76
+ return $arrTestVersions[$testVersion];
77
+ }
78
+ else {
79
+ return array(null, null);
80
+ }
81
  }
82
 
83
  public function supportsAbove($phpVersion)
108
  }
109
  }//end supportsBelow()
110
 
111
+ /**
112
+ * Returns the name(s) of the interface(s) that the specified class implements.
113
+ *
114
+ * Returns FALSE on error or if there are no implemented interface names.
115
+ *
116
+ * {@internal Duplicate of same method as introduced in PHPCS 2.7.
117
+ * Once the minimum supported PHPCS version for this sniff library goes beyond
118
+ * that, this method can be removed and call to it replaced with
119
+ * `$phpcsFile->findImplementedInterfaceNames($stackPtr)` calls.}}
120
+ *
121
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
122
+ * @param int $stackPtr The position of the class token.
123
+ *
124
+ * @return array|false
125
+ */
126
+ public function findImplementedInterfaceNames($phpcsFile, $stackPtr)
127
+ {
128
+ $tokens = $phpcsFile->getTokens();
129
+
130
+ // Check for the existence of the token.
131
+ if (isset($tokens[$stackPtr]) === false) {
132
+ return false;
133
+ }
134
+
135
+ if ($tokens[$stackPtr]['code'] !== T_CLASS) {
136
+ return false;
137
+ }
138
+
139
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
140
+ return false;
141
+ }
142
+
143
+ $classOpenerIndex = $tokens[$stackPtr]['scope_opener'];
144
+ $implementsIndex = $phpcsFile->findNext(T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
145
+ if ($implementsIndex === false) {
146
+ return false;
147
+ }
148
+
149
+ $find = array(
150
+ T_NS_SEPARATOR,
151
+ T_STRING,
152
+ T_WHITESPACE,
153
+ T_COMMA,
154
+ );
155
+
156
+ $end = $phpcsFile->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true);
157
+ $name = $phpcsFile->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1));
158
+ $name = trim($name);
159
+
160
+ if ($name === '') {
161
+ return false;
162
+ } else {
163
+ $names = explode(',', $name);
164
+ $names = array_map('trim', $names);
165
+ return $names;
166
+ }
167
+
168
+ }//end findImplementedInterfaceNames()
169
+
170
+
171
+ /**
172
+ * Checks if a function call has parameters.
173
+ *
174
+ * Expects to be passed the T_STRING stack pointer for the function call.
175
+ * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
176
+ *
177
+ * @link https://github.com/wimg/PHPCompatibility/issues/120
178
+ * @link https://github.com/wimg/PHPCompatibility/issues/152
179
+ *
180
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
181
+ * @param int $stackPtr The position of the function call token.
182
+ *
183
+ * @return bool
184
+ */
185
+ public function doesFunctionCallHaveParameters(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
186
+ {
187
+ $tokens = $phpcsFile->getTokens();
188
+
189
+ // Check for the existence of the token.
190
+ if (isset($tokens[$stackPtr]) === false) {
191
+ return false;
192
+ }
193
+
194
+ if ($tokens[$stackPtr]['code'] !== T_STRING) {
195
+ return false;
196
+ }
197
+
198
+ // Next non-empty token should be the open parenthesis.
199
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
200
+ if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) {
201
+ return false;
202
+ }
203
+
204
+ if (isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
205
+ return false;
206
+ }
207
+
208
+ $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
209
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $openParenthesis + 1, $closeParenthesis + 1, true);
210
+
211
+ if ($nextNonEmpty === $closeParenthesis) {
212
+ // No parameters.
213
+ return false;
214
+ }
215
+
216
+ return true;
217
+ }
218
+
219
+
220
+ /**
221
+ * Count the number of parameters a function call has been passed.
222
+ *
223
+ * Expects to be passed the T_STRING stack pointer for the function call.
224
+ * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
225
+ *
226
+ * @link https://github.com/wimg/PHPCompatibility/issues/111
227
+ * @link https://github.com/wimg/PHPCompatibility/issues/114
228
+ * @link https://github.com/wimg/PHPCompatibility/issues/151
229
+ *
230
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
231
+ * @param int $stackPtr The position of the function call token.
232
+ *
233
+ * @return int
234
+ */
235
+ public function getFunctionCallParameterCount(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
236
+ {
237
+ if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) {
238
+ return 0;
239
+ }
240
+
241
+ // Ok, we know we have a T_STRING with parameters and valid open & close parenthesis.
242
+ $tokens = $phpcsFile->getTokens();
243
+
244
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
245
+ $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
246
+
247
+ // Which nesting level is the one we are interested in ?
248
+ $nestedParenthesisCount = 1;
249
+ if (isset($tokens[$openParenthesis]['nested_parenthesis'])) {
250
+ $nestedParenthesisCount = count($tokens[$openParenthesis]['nested_parenthesis']) + 1;
251
+ }
252
+
253
+ $nextComma = $openParenthesis;
254
+ $cnt = 0;
255
+ while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
256
+ // Ignore comma's at a lower nesting level.
257
+ if (
258
+ $tokens[$nextComma]['type'] == 'T_COMMA'
259
+ &&
260
+ isset($tokens[$nextComma]['nested_parenthesis'])
261
+ &&
262
+ count($tokens[$nextComma]['nested_parenthesis']) != $nestedParenthesisCount
263
+ ) {
264
+ continue;
265
+ }
266
+
267
+ // Ignore closing parenthesis if not 'ours'.
268
+ if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
269
+ continue;
270
+ }
271
+
272
+ $cnt++;
273
+ }
274
+
275
+ return $cnt;
276
+ }
277
+
278
+
279
+ /**
280
+ * Verify whether a token is within a class scope.
281
+ *
282
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
283
+ * @param int $stackPtr The position of the token.
284
+ * @param bool $strict Whether to strictly check for the T_CLASS
285
+ * scope or also accept interfaces and traits
286
+ * as scope.
287
+ *
288
+ * @return bool True if within class scope, false otherwise.
289
+ */
290
+ public function inClassScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
291
+ {
292
+ $tokens = $phpcsFile->getTokens();
293
+
294
+ // Check for the existence of the token.
295
+ if (isset($tokens[$stackPtr]) === false) {
296
+ return false;
297
+ }
298
+
299
+ // No conditions = no scope.
300
+ if (empty($tokens[$stackPtr]['conditions'])) {
301
+ return false;
302
+ }
303
+
304
+ $validScope = array(T_CLASS);
305
+ if ($strict === false) {
306
+ $validScope[] = T_INTERFACE;
307
+ $validScope[] = T_TRAIT;
308
+ }
309
+
310
+ // Check for class scope.
311
+ foreach ($tokens[$stackPtr]['conditions'] as $pointer => $type) {
312
+ if (in_array($type, $validScope, true)) {
313
+ return true;
314
+ }
315
+ }
316
+
317
+ return false;
318
+ }
319
+
320
+
321
+ /**
322
+ * Returns the fully qualified class name for a new class instantiation.
323
+ *
324
+ * Returns an empty string if the class name could not be reliably inferred.
325
+ *
326
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
327
+ * @param int $stackPtr The position of a T_NEW token.
328
+ *
329
+ * @return string
330
+ */
331
+ public function getFQClassNameFromNewToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
332
+ {
333
+ $tokens = $phpcsFile->getTokens();
334
+
335
+ // Check for the existence of the token.
336
+ if (isset($tokens[$stackPtr]) === false) {
337
+ return '';
338
+ }
339
+
340
+ if ($tokens[$stackPtr]['code'] !== T_NEW) {
341
+ return '';
342
+ }
343
+
344
+ $find = array(
345
+ T_NS_SEPARATOR,
346
+ T_STRING,
347
+ T_NAMESPACE,
348
+ T_WHITESPACE,
349
+ );
350
+
351
+ $start = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
352
+ $end = $phpcsFile->findNext($find, ($start + 1), null, true, null, true);
353
+ $className = $phpcsFile->getTokensAsString($start, ($end - $start));
354
+ $className = trim($className);
355
+
356
+ return $this->getFQName($phpcsFile, $stackPtr, $className);
357
+ }
358
+
359
+
360
+ /**
361
+ * Returns the fully qualified name of the class that the specified class extends.
362
+ *
363
+ * Returns an empty string if the class does not extend another class or if
364
+ * the class name could not be reliably inferred.
365
+ *
366
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
367
+ * @param int $stackPtr The position of a T_CLASS token.
368
+ *
369
+ * @return string
370
+ */
371
+ public function getFQExtendedClassName(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
372
+ {
373
+ $tokens = $phpcsFile->getTokens();
374
+
375
+ // Check for the existence of the token.
376
+ if (isset($tokens[$stackPtr]) === false) {
377
+ return '';
378
+ }
379
+
380
+ if ($tokens[$stackPtr]['code'] !== T_CLASS) {
381
+ return '';
382
+ }
383
+
384
+ $extends = $phpcsFile->findExtendedClassName($stackPtr);
385
+ if (empty($extends) || is_string($extends) === false) {
386
+ return '';
387
+ }
388
+
389
+ return $this->getFQName($phpcsFile, $stackPtr, $extends);
390
+ }
391
+
392
+
393
+ /**
394
+ * Returns the class name for the static usage of a class.
395
+ * This can be a call to a method, the use of a property or constant.
396
+ *
397
+ * Returns an empty string if the class name could not be reliably inferred.
398
+ *
399
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
400
+ * @param int $stackPtr The position of a T_NEW token.
401
+ *
402
+ * @return string
403
+ */
404
+ public function getFQClassNameFromDoubleColonToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
405
+ {
406
+ $tokens = $phpcsFile->getTokens();
407
+
408
+ // Check for the existence of the token.
409
+ if (isset($tokens[$stackPtr]) === false) {
410
+ return '';
411
+ }
412
+
413
+ if ($tokens[$stackPtr]['code'] !== T_DOUBLE_COLON) {
414
+ return '';
415
+ }
416
+
417
+ // Nothing to do if 'parent' or 'static' as we don't know how far the class tree extends.
418
+ if (in_array($tokens[$stackPtr - 1]['code'], array(T_PARENT, T_STATIC), true)) {
419
+ return '';
420
+ }
421
+
422
+ // Get the classname from the class declaration if self is used.
423
+ if ($tokens[$stackPtr - 1]['code'] === T_SELF) {
424
+ $classDeclarationPtr = $phpcsFile->findPrevious(T_CLASS, $stackPtr - 1);
425
+ if ($classDeclarationPtr === false) {
426
+ return '';
427
+ }
428
+ $className = $phpcsFile->getDeclarationName($classDeclarationPtr);
429
+ return $this->getFQName($phpcsFile, $classDeclarationPtr, $className);
430
+ }
431
+
432
+ $find = array(
433
+ T_NS_SEPARATOR,
434
+ T_STRING,
435
+ T_NAMESPACE,
436
+ T_WHITESPACE,
437
+ );
438
+
439
+ $start = ($phpcsFile->findPrevious($find, $stackPtr - 1, null, true, null, true) + 1);
440
+ $className = $phpcsFile->getTokensAsString($start, ($stackPtr - $start));
441
+ $className = trim($className);
442
+
443
+ return $this->getFQName($phpcsFile, $stackPtr, $className);
444
+ }
445
+
446
+
447
+ /**
448
+ * Get the Fully Qualified name for a class/function/constant etc.
449
+ *
450
+ * Checks if a class/function/constant name is already fully qualified and
451
+ * if not, enrich it with the relevant namespace information.
452
+ *
453
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
454
+ * @param int $stackPtr The position of the token.
455
+ * @param string $name The class / function / constant name.
456
+ *
457
+ * @return string
458
+ */
459
+ public function getFQName(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $name)
460
+ {
461
+ if (strpos($name, '\\' ) === 0) {
462
+ // Already fully qualified.
463
+ return $name;
464
+ }
465
+
466
+ // Remove the namespace keyword if used.
467
+ if (strpos($name, 'namespace\\') === 0) {
468
+ $name = substr($name, 10);
469
+ }
470
+
471
+ $namespace = $this->determineNamespace($phpcsFile, $stackPtr);
472
+
473
+ if ($namespace === '') {
474
+ return '\\' . $name;
475
+ }
476
+ else {
477
+ return '\\' . $namespace . '\\' . $name;
478
+ }
479
+ }
480
+
481
+
482
+ /**
483
+ * Is the class/function/constant name namespaced or global ?
484
+ *
485
+ * @param string $FQName Fully Qualified name of a class, function etc.
486
+ * I.e. should always start with a `\` !
487
+ *
488
+ * @return bool True if namespaced, false if global.
489
+ */
490
+ public function isNamespaced($FQName) {
491
+ if (strpos($FQName, '\\') !== 0) {
492
+ throw new PHP_CodeSniffer_Exception('$FQName must be a fully qualified name');
493
+ }
494
+
495
+ return (strpos(substr($FQName, 1), '\\') !== false);
496
+ }
497
+
498
+
499
+ /**
500
+ * Determine the namespace name an arbitrary token lives in.
501
+ *
502
+ * @param PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
503
+ * @param int $stackPtr The token position for which to determine the namespace.
504
+ *
505
+ * @return string Namespace name or empty string if it couldn't be determined or no namespace applies.
506
+ */
507
+ public function determineNamespace(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
508
+ {
509
+ $tokens = $phpcsFile->getTokens();
510
+
511
+ // Check for the existence of the token.
512
+ if (isset($tokens[$stackPtr]) === false) {
513
+ return '';
514
+ }
515
+
516
+ // Check for scoped namespace {}.
517
+ if (empty($tokens[$stackPtr]['conditions']) === false) {
518
+ foreach ($tokens[$stackPtr]['conditions'] as $pointer => $type) {
519
+ if ($type === T_NAMESPACE) {
520
+ $namespace = $this->getDeclaredNamespaceName($phpcsFile, $pointer);
521
+ if ($namespace !== false) {
522
+ return $namespace;
523
+ }
524
+ }
525
+ break; // We only need to check the highest level condition.
526
+ }
527
+ }
528
+
529
+ /*
530
+ * Not in a scoped namespace, so let's see if we can find a non-scoped namespace instead.
531
+ * Keeping in mind that:
532
+ * - there can be multiple non-scoped namespaces in a file (bad practice, but it happens).
533
+ * - the namespace keyword can also be used as part of a function/method call and such.
534
+ * - that a non-named namespace resolves to the global namespace.
535
+ */
536
+ $previousNSToken = $stackPtr;
537
+ $namespace = false;
538
+ do {
539
+ $previousNSToken = $phpcsFile->findPrevious(T_NAMESPACE, $previousNSToken -1);
540
+
541
+ // Stop if we encounter a scoped namespace declaration as we already know we're not in one.
542
+ if (empty($tokens[$previousNSToken]['scope_condition']) === false && $tokens[$previousNSToken]['scope_condition'] = $previousNSToken) {
543
+ break;
544
+ }
545
+ $namespace = $this->getDeclaredNamespaceName($phpcsFile, $previousNSToken);
546
+
547
+ } while ($namespace === false && $previousNSToken !== false);
548
+
549
+ // If we still haven't got a namespace, return an empty string.
550
+ if ($namespace === false) {
551
+ return '';
552
+ }
553
+ else {
554
+ return $namespace;
555
+ }
556
+ }
557
+
558
+ /**
559
+ * Get the complete namespace name for a namespace declaration.
560
+ *
561
+ * For hierarchical namespaces, the name will be composed of several tokens,
562
+ * i.e. MyProject\Sub\Level which will be returned together as one string.
563
+ *
564
+ * @param PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
565
+ * @param int|bool $stackPtr The position of a T_NAMESPACE token.
566
+ *
567
+ * @return string|false Namespace name or false if not a namespace declaration.
568
+ * Namespace name can be an empty string for global namespace declaration.
569
+ */
570
+ public function getDeclaredNamespaceName(PHP_CodeSniffer_File $phpcsFile, $stackPtr )
571
+ {
572
+ $tokens = $phpcsFile->getTokens();
573
+
574
+ // Check for the existence of the token.
575
+ if ($stackPtr === false || isset($tokens[$stackPtr]) === false) {
576
+ return false;
577
+ }
578
+
579
+ if ($tokens[$stackPtr]['code'] !== T_NAMESPACE) {
580
+ return false;
581
+ }
582
+
583
+ if ($tokens[$stackPtr + 1]['code'] === T_NS_SEPARATOR) {
584
+ // Not a namespace declaration, but use of, i.e. namespace\someFunction();
585
+ return false;
586
+ }
587
+
588
+ $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
589
+ if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) {
590
+ // Declaration for global namespace when using multiple namespaces in a file.
591
+ // I.e.: namespace {}
592
+ return '';
593
+ }
594
+
595
+ // Ok, this should be a namespace declaration, so get all the parts together.
596
+ $validTokens = array(
597
+ T_STRING,
598
+ T_NS_SEPARATOR,
599
+ T_WHITESPACE,
600
+ );
601
+
602
+ $namespaceName = '';
603
+ while(in_array($tokens[$nextToken]['code'], $validTokens, true) === true) {
604
+ $namespaceName .= trim($tokens[$nextToken]['content']);
605
+ $nextToken++;
606
+ }
607
+
608
+ return $namespaceName;
609
+ }
610
+
611
+
612
+ /**
613
+ * Returns the method parameters for the specified T_FUNCTION token.
614
+ *
615
+ * Each parameter is in the following format:
616
+ *
617
+ * <code>
618
+ * 0 => array(
619
+ * 'name' => '$var', // The variable name.
620
+ * 'pass_by_reference' => false, // Passed by reference.
621
+ * 'type_hint' => string, // Type hint for array or custom type
622
+ * )
623
+ * </code>
624
+ *
625
+ * Parameters with default values have an additional array index of
626
+ * 'default' with the value of the default as a string.
627
+ *
628
+ * {@internal Duplicate of same method as contained in the `PHP_CodeSniffer_File`
629
+ * class, but with some improvements which were only introduced in PHPCS 2.7.
630
+ * Once the minimum supported PHPCS version for this sniff library goes beyond
631
+ * that, this method can be removed and calls to it replaced with
632
+ * `$phpcsFile->getMethodParameters($stackPtr)` calls.}}
633
+ *
634
+ * @param PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
635
+ * @param int $stackPtr The position in the stack of the T_FUNCTION token
636
+ * to acquire the parameters for.
637
+ *
638
+ * @return array
639
+ * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of
640
+ * type T_FUNCTION.
641
+ */
642
+ public function getMethodParameters(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
643
+ {
644
+ $tokens = $phpcsFile->getTokens();
645
+
646
+ // Check for the existence of the token.
647
+ if (isset($tokens[$stackPtr]) === false) {
648
+ return false;
649
+ }
650
+
651
+ if ($tokens[$stackPtr]['code'] !== T_FUNCTION) {
652
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION');
653
+ }
654
+
655
+ $opener = $tokens[$stackPtr]['parenthesis_opener'];
656
+ $closer = $tokens[$stackPtr]['parenthesis_closer'];
657
+
658
+ $vars = array();
659
+ $currVar = null;
660
+ $paramStart = ($opener + 1);
661
+ $defaultStart = null;
662
+ $paramCount = 0;
663
+ $passByReference = false;
664
+ $variableLength = false;
665
+ $typeHint = '';
666
+
667
+ for ($i = $paramStart; $i <= $closer; $i++) {
668
+ // Check to see if this token has a parenthesis or bracket opener. If it does
669
+ // it's likely to be an array which might have arguments in it. This
670
+ // could cause problems in our parsing below, so lets just skip to the
671
+ // end of it.
672
+ if (isset($tokens[$i]['parenthesis_opener']) === true) {
673
+ // Don't do this if it's the close parenthesis for the method.
674
+ if ($i !== $tokens[$i]['parenthesis_closer']) {
675
+ $i = ($tokens[$i]['parenthesis_closer'] + 1);
676
+ }
677
+ }
678
+
679
+ if (isset($tokens[$i]['bracket_opener']) === true) {
680
+ // Don't do this if it's the close parenthesis for the method.
681
+ if ($i !== $tokens[$i]['bracket_closer']) {
682
+ $i = ($tokens[$i]['bracket_closer'] + 1);
683
+ }
684
+ }
685
+
686
+ switch ($tokens[$i]['code']) {
687
+ case T_BITWISE_AND:
688
+ $passByReference = true;
689
+ break;
690
+ case T_VARIABLE:
691
+ $currVar = $i;
692
+ break;
693
+ case T_ELLIPSIS:
694
+ $variableLength = true;
695
+ break;
696
+ case T_ARRAY_HINT:
697
+ case T_CALLABLE:
698
+ $typeHint = $tokens[$i]['content'];
699
+ break;
700
+ case T_SELF:
701
+ case T_PARENT:
702
+ case T_STATIC:
703
+ // Self is valid, the others invalid, but were probably intended as type hints.
704
+ if (isset($defaultStart) === false) {
705
+ $typeHint = $tokens[$i]['content'];
706
+ }
707
+ break;
708
+ case T_STRING:
709
+ // This is a string, so it may be a type hint, but it could
710
+ // also be a constant used as a default value.
711
+ $prevComma = false;
712
+ for ($t = $i; $t >= $opener; $t--) {
713
+ if ($tokens[$t]['code'] === T_COMMA) {
714
+ $prevComma = $t;
715
+ break;
716
+ }
717
+ }
718
+
719
+ if ($prevComma !== false) {
720
+ $nextEquals = false;
721
+ for ($t = $prevComma; $t < $i; $t++) {
722
+ if ($tokens[$t]['code'] === T_EQUAL) {
723
+ $nextEquals = $t;
724
+ break;
725
+ }
726
+ }
727
+
728
+ if ($nextEquals !== false) {
729
+ break;
730
+ }
731
+ }
732
+
733
+ if ($defaultStart === null) {
734
+ $typeHint .= $tokens[$i]['content'];
735
+ }
736
+ break;
737
+ case T_NS_SEPARATOR:
738
+ // Part of a type hint or default value.
739
+ if ($defaultStart === null) {
740
+ $typeHint .= $tokens[$i]['content'];
741
+ }
742
+ break;
743
+ case T_CLOSE_PARENTHESIS:
744
+ case T_COMMA:
745
+ // If it's null, then there must be no parameters for this
746
+ // method.
747
+ if ($currVar === null) {
748
+ continue;
749
+ }
750
+
751
+ $vars[$paramCount] = array();
752
+ $vars[$paramCount]['name'] = $tokens[$currVar]['content'];
753
+
754
+ if ($defaultStart !== null) {
755
+ $vars[$paramCount]['default']
756
+ = $phpcsFile->getTokensAsString(
757
+ $defaultStart,
758
+ ($i - $defaultStart)
759
+ );
760
+ }
761
+
762
+ $rawContent = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart)));
763
+
764
+ $vars[$paramCount]['pass_by_reference'] = $passByReference;
765
+ $vars[$paramCount]['variable_length'] = $variableLength;
766
+ $vars[$paramCount]['type_hint'] = $typeHint;
767
+ $vars[$paramCount]['raw'] = $rawContent;
768
+
769
+ // Reset the vars, as we are about to process the next parameter.
770
+ $defaultStart = null;
771
+ $paramStart = ($i + 1);
772
+ $passByReference = false;
773
+ $variableLength = false;
774
+ $typeHint = '';
775
+
776
+ $paramCount++;
777
+ break;
778
+ case T_EQUAL:
779
+ $defaultStart = ($i + 1);
780
+ break;
781
+ }//end switch
782
+ }//end for
783
+
784
+ return $vars;
785
+
786
+ }//end getMethodParameters()
787
+
788
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php CHANGED
@@ -45,35 +45,39 @@ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPComp
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  $tokens = $phpcsFile->getTokens();
48
-
49
  $ignore = array(
50
  T_DOUBLE_COLON,
51
  T_OBJECT_OPERATOR,
52
  T_FUNCTION,
53
  T_CONST,
54
  );
55
-
56
  $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
57
  if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
58
  // Not a call to a PHP function.
59
  return;
60
  }
61
-
62
  $function = strtolower($tokens[$stackPtr]['content']);
63
-
64
  if ($function === 'define') {
65
  $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, null, null, true);
66
  if ($openParenthesis === false) {
67
- return false;
68
  }
69
-
70
  $comma = $phpcsFile->findNext(T_COMMA, $openParenthesis, $tokens[$openParenthesis]['parenthesis_closer']);
71
-
 
 
 
 
72
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $comma, $tokens[$openParenthesis]['parenthesis_closer']);
73
-
74
  if ($array !== false) {
75
  if ($this->supportsAbove('7.0')) {
76
- return false;
77
  } else {
78
  $phpcsFile->addError('Constant arrays using define are not allowed in PHP 5.6 or earlier', $array);
79
  }
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  $tokens = $phpcsFile->getTokens();
48
+
49
  $ignore = array(
50
  T_DOUBLE_COLON,
51
  T_OBJECT_OPERATOR,
52
  T_FUNCTION,
53
  T_CONST,
54
  );
55
+
56
  $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
57
  if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
58
  // Not a call to a PHP function.
59
  return;
60
  }
61
+
62
  $function = strtolower($tokens[$stackPtr]['content']);
63
+
64
  if ($function === 'define') {
65
  $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, null, null, true);
66
  if ($openParenthesis === false) {
67
+ return;
68
  }
69
+
70
  $comma = $phpcsFile->findNext(T_COMMA, $openParenthesis, $tokens[$openParenthesis]['parenthesis_closer']);
71
+
72
+ if ($comma === false) {
73
+ return;
74
+ }
75
+
76
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $comma, $tokens[$openParenthesis]['parenthesis_closer']);
77
+
78
  if ($array !== false) {
79
  if ($this->supportsAbove('7.0')) {
80
+ return;
81
  } else {
82
  $phpcsFile->addError('Constant arrays using define are not allowed in PHP 5.6 or earlier', $array);
83
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php CHANGED
@@ -25,16 +25,20 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
25
  * @var bool
26
  */
27
  protected $patternMatch = false;
28
-
29
  /**
30
  * A list of forbidden functions with their alternatives.
31
  *
32
- * The array lists : version number with 0 (deprecated) or 1 (forbidden) and an alternative function.
33
- * If no alternative exists, it is NULL. IE, the function should just not be used.
34
  *
35
- * @var array(string => array(string => int|string|null))
36
  */
37
- public $forbiddenFunctions = array(
 
 
 
 
38
  'call_user_method' => array(
39
  '5.3' => false,
40
  '5.4' => false,
@@ -70,6 +74,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
70
  '5.4' => false,
71
  '5.5' => false,
72
  '5.6' => false,
 
73
  'alternative' => 'preg_match'
74
  ),
75
  'ereg_replace' => array(
@@ -77,6 +82,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
77
  '5.4' => false,
78
  '5.5' => false,
79
  '5.6' => false,
 
80
  'alternative' => 'preg_replace'
81
  ),
82
  'eregi' => array(
@@ -84,6 +90,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
84
  '5.4' => false,
85
  '5.5' => false,
86
  '5.6' => false,
 
87
  'alternative' => 'preg_match'
88
  ),
89
  'eregi_replace' => array(
@@ -91,6 +98,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
91
  '5.4' => false,
92
  '5.5' => false,
93
  '5.6' => false,
 
94
  'alternative' => 'preg_replace'
95
  ),
96
  'imagepsbbox' => array(
@@ -122,9 +130,8 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
122
  'alternative' => null
123
  ),
124
  'import_request_variables' => array(
 
125
  '5.4' => true,
126
- '5.5' => true,
127
- '5.6' => false,
128
  'alternative' => null
129
  ),
130
  'ldap_sort' => array(
@@ -143,58 +150,68 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
143
  '5.4' => false,
144
  '5.5' => false,
145
  '5.6' => false,
146
- 'alternative' => 'mysql_select_db and mysql_query'
 
147
  ),
148
  'mysql_escape_string' => array(
149
  '5.3' => false,
150
  '5.4' => false,
151
  '5.5' => false,
152
  '5.6' => false,
153
- 'alternative' => 'mysql_real_escape_string'
 
154
  ),
155
  'mysql_list_dbs' => array(
156
  '5.4' => false,
157
  '5.5' => false,
158
  '5.6' => false,
 
159
  'alternative' => null
160
  ),
161
  'mysqli_bind_param' => array(
 
162
  '5.4' => true,
163
  '5.5' => true,
164
  '5.6' => true,
165
  'alternative' => 'mysqli_stmt_bind_param'
166
  ),
167
  'mysqli_bind_result' => array(
 
168
  '5.4' => true,
169
  '5.5' => true,
170
  '5.6' => true,
171
  'alternative' => 'mysqli_stmt_bind_result'
172
  ),
173
  'mysqli_client_encoding' => array(
 
174
  '5.4' => true,
175
  '5.5' => true,
176
  '5.6' => true,
177
  'alternative' => 'mysqli_character_set_name'
178
  ),
179
  'mysqli_fetch' => array(
 
180
  '5.4' => true,
181
  '5.5' => true,
182
  '5.6' => true,
183
  'alternative' => 'mysqli_stmt_fetch'
184
  ),
185
  'mysqli_param_count' => array(
 
186
  '5.4' => true,
187
  '5.5' => true,
188
  '5.6' => true,
189
  'alternative' => 'mysqli_stmt_param_count'
190
  ),
191
  'mysqli_get_metadata' => array(
 
192
  '5.4' => true,
193
  '5.5' => true,
194
  '5.6' => true,
195
  'alternative' => 'mysqli_stmt_result_metadata'
196
  ),
197
  'mysqli_send_long_data' => array(
 
198
  '5.4' => true,
199
  '5.5' => true,
200
  '5.6' => true,
@@ -250,6 +267,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
250
  '5.4' => false,
251
  '5.5' => false,
252
  '5.6' => false,
 
253
  'alternative' => 'preg_split'
254
  ),
255
  'spliti' => array(
@@ -257,6 +275,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
257
  '5.4' => false,
258
  '5.5' => false,
259
  '5.6' => false,
 
260
  'alternative' => 'preg_split'
261
  ),
262
  'sql_regcase' => array(
@@ -264,6 +283,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
264
  '5.4' => false,
265
  '5.5' => false,
266
  '5.6' => false,
 
267
  'alternative' => null
268
  ),
269
  'php_logo_guid' => array(
@@ -610,15 +630,12 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
610
  '5.6' => false,
611
  'alternative' => 'OCI-Lob::writeTemporary'
612
  ),
 
 
 
 
613
  );
614
 
615
- /**
616
- * If true, an error will be thrown; otherwise a warning.
617
- *
618
- * @var bool
619
- */
620
- public $error = false;
621
-
622
  /**
623
  * Returns an array of tokens this test wants to listen for.
624
  *
@@ -629,18 +646,18 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
629
  // Everyone has had a chance to figure out what forbidden functions
630
  // they want to check for, so now we can cache out the list.
631
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
632
-
633
  if ($this->patternMatch === true) {
634
  foreach ($this->forbiddenFunctionNames as $i => $name) {
635
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
636
  }
637
  }
638
-
639
  return array(T_STRING);
640
-
641
  }//end register()
642
-
643
-
644
  /**
645
  * Processes this test, when one of its tokens is encountered.
646
  *
@@ -699,7 +716,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
699
  }//end process()
700
 
701
  /**
702
- * Generates the error or wanrning for this sniff.
703
  *
704
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
705
  * @param int $stackPtr The position of the forbidden function
@@ -717,7 +734,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
717
 
718
  $error = '';
719
 
720
- $this->error = false;
721
  $previousVersionStatus = null;
722
  foreach ($this->forbiddenFunctions[$pattern] as $version => $forbidden) {
723
  if ($this->supportsAbove($version)) {
@@ -725,7 +742,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
725
  if ($previousVersionStatus !== $forbidden) {
726
  $previousVersionStatus = $forbidden;
727
  if ($forbidden === true) {
728
- $this->error = true;
729
  $error .= 'forbidden';
730
  } else {
731
  $error .= 'discouraged';
@@ -743,7 +760,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
743
  $error .= '; use ' . $this->forbiddenFunctions[$pattern]['alternative'] . ' instead';
744
  }
745
 
746
- if ($this->error === true) {
747
  $phpcsFile->addError($error, $stackPtr);
748
  } else {
749
  $phpcsFile->addWarning($error, $stackPtr);
25
  * @var bool
26
  */
27
  protected $patternMatch = false;
28
+
29
  /**
30
  * A list of forbidden functions with their alternatives.
31
  *
32
+ * The array lists : version number with false (deprecated) or true (forbidden) and an alternative function.
33
+ * If no alternative exists, it is NULL, i.e, the function should just not be used.
34
  *
35
+ * @var array(string => array(string => bool|string|null))
36
  */
37
+ protected $forbiddenFunctions = array(
38
+ 'php_check_syntax' => array(
39
+ '5.0.5' => true,
40
+ 'alternative' => null
41
+ ),
42
  'call_user_method' => array(
43
  '5.3' => false,
44
  '5.4' => false,
74
  '5.4' => false,
75
  '5.5' => false,
76
  '5.6' => false,
77
+ '7.0' => true,
78
  'alternative' => 'preg_match'
79
  ),
80
  'ereg_replace' => array(
82
  '5.4' => false,
83
  '5.5' => false,
84
  '5.6' => false,
85
+ '7.0' => true,
86
  'alternative' => 'preg_replace'
87
  ),
88
  'eregi' => array(
90
  '5.4' => false,
91
  '5.5' => false,
92
  '5.6' => false,
93
+ '7.0' => true,
94
  'alternative' => 'preg_match'
95
  ),
96
  'eregi_replace' => array(
98
  '5.4' => false,
99
  '5.5' => false,
100
  '5.6' => false,
101
+ '7.0' => true,
102
  'alternative' => 'preg_replace'
103
  ),
104
  'imagepsbbox' => array(
130
  'alternative' => null
131
  ),
132
  'import_request_variables' => array(
133
+ '5.3' => false,
134
  '5.4' => true,
 
 
135
  'alternative' => null
136
  ),
137
  'ldap_sort' => array(
150
  '5.4' => false,
151
  '5.5' => false,
152
  '5.6' => false,
153
+ '7.0' => true,
154
+ 'alternative' => 'mysqli_select_db and mysqli_query'
155
  ),
156
  'mysql_escape_string' => array(
157
  '5.3' => false,
158
  '5.4' => false,
159
  '5.5' => false,
160
  '5.6' => false,
161
+ '7.0' => true,
162
+ 'alternative' => 'mysqli_real_escape_string'
163
  ),
164
  'mysql_list_dbs' => array(
165
  '5.4' => false,
166
  '5.5' => false,
167
  '5.6' => false,
168
+ '7.0' => true,
169
  'alternative' => null
170
  ),
171
  'mysqli_bind_param' => array(
172
+ '5.3' => false,
173
  '5.4' => true,
174
  '5.5' => true,
175
  '5.6' => true,
176
  'alternative' => 'mysqli_stmt_bind_param'
177
  ),
178
  'mysqli_bind_result' => array(
179
+ '5.3' => false,
180
  '5.4' => true,
181
  '5.5' => true,
182
  '5.6' => true,
183
  'alternative' => 'mysqli_stmt_bind_result'
184
  ),
185
  'mysqli_client_encoding' => array(
186
+ '5.3' => false,
187
  '5.4' => true,
188
  '5.5' => true,
189
  '5.6' => true,
190
  'alternative' => 'mysqli_character_set_name'
191
  ),
192
  'mysqli_fetch' => array(
193
+ '5.3' => false,
194
  '5.4' => true,
195
  '5.5' => true,
196
  '5.6' => true,
197
  'alternative' => 'mysqli_stmt_fetch'
198
  ),
199
  'mysqli_param_count' => array(
200
+ '5.3' => false,
201
  '5.4' => true,
202
  '5.5' => true,
203
  '5.6' => true,
204
  'alternative' => 'mysqli_stmt_param_count'
205
  ),
206
  'mysqli_get_metadata' => array(
207
+ '5.3' => false,
208
  '5.4' => true,
209
  '5.5' => true,
210
  '5.6' => true,
211
  'alternative' => 'mysqli_stmt_result_metadata'
212
  ),
213
  'mysqli_send_long_data' => array(
214
+ '5.3' => false,
215
  '5.4' => true,
216
  '5.5' => true,
217
  '5.6' => true,
267
  '5.4' => false,
268
  '5.5' => false,
269
  '5.6' => false,
270
+ '7.0' => true,
271
  'alternative' => 'preg_split'
272
  ),
273
  'spliti' => array(
275
  '5.4' => false,
276
  '5.5' => false,
277
  '5.6' => false,
278
+ '7.0' => true,
279
  'alternative' => 'preg_split'
280
  ),
281
  'sql_regcase' => array(
283
  '5.4' => false,
284
  '5.5' => false,
285
  '5.6' => false,
286
+ '7.0' => true,
287
  'alternative' => null
288
  ),
289
  'php_logo_guid' => array(
630
  '5.6' => false,
631
  'alternative' => 'OCI-Lob::writeTemporary'
632
  ),
633
+ 'mysqli_get_cache_stats' => array(
634
+ '5.4' => true,
635
+ 'alternative' => null
636
+ ),
637
  );
638
 
 
 
 
 
 
 
 
639
  /**
640
  * Returns an array of tokens this test wants to listen for.
641
  *
646
  // Everyone has had a chance to figure out what forbidden functions
647
  // they want to check for, so now we can cache out the list.
648
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
649
+
650
  if ($this->patternMatch === true) {
651
  foreach ($this->forbiddenFunctionNames as $i => $name) {
652
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
653
  }
654
  }
655
+
656
  return array(T_STRING);
657
+
658
  }//end register()
659
+
660
+
661
  /**
662
  * Processes this test, when one of its tokens is encountered.
663
  *
716
  }//end process()
717
 
718
  /**
719
+ * Generates the error or warning for this sniff.
720
  *
721
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
722
  * @param int $stackPtr The position of the forbidden function
734
 
735
  $error = '';
736
 
737
+ $isError = false;
738
  $previousVersionStatus = null;
739
  foreach ($this->forbiddenFunctions[$pattern] as $version => $forbidden) {
740
  if ($this->supportsAbove($version)) {
742
  if ($previousVersionStatus !== $forbidden) {
743
  $previousVersionStatus = $forbidden;
744
  if ($forbidden === true) {
745
+ $isError = true;
746
  $error .= 'forbidden';
747
  } else {
748
  $error .= 'discouraged';
760
  $error .= '; use ' . $this->forbiddenFunctions[$pattern]['alternative'] . ' instead';
761
  }
762
 
763
+ if ($isError === true) {
764
  $phpcsFile->addError($error, $stackPtr);
765
  } else {
766
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php CHANGED
@@ -23,20 +23,70 @@
23
  class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
- * A list of deprecated INI directives
 
 
 
27
  *
28
  * @var array(string)
29
  */
30
  protected $deprecatedIniDirectives = array(
31
- 'define_syslog_variables' => array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  '5.3' => false,
33
  '5.4' => true
34
  ),
35
- 'register_globals' => array(
36
  '5.3' => false,
37
  '5.4' => true
38
  ),
39
- 'register_long_arrays' => array(
 
 
 
 
40
  '5.3' => false,
41
  '5.4' => true
42
  ),
@@ -52,56 +102,58 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
52
  '5.3' => false,
53
  '5.4' => true
54
  ),
55
- 'allow_call_time_pass_reference' => array(
56
- '5.3' => false,
57
- '5.4' => true
58
  ),
59
- 'highlight.bg' => array(
60
  '5.3' => false,
61
  '5.4' => true
62
  ),
63
- 'session.bug_compat_42' => array(
64
  '5.3' => false,
65
  '5.4' => true
66
  ),
67
- 'session.bug_compat_warn' => array(
68
  '5.3' => false,
69
  '5.4' => true
70
  ),
71
- 'y2k_compliance' => array(
72
  '5.3' => false,
73
  '5.4' => true
74
  ),
75
- 'zend.ze1_compatibility_mode' => array(
76
  '5.3' => false,
77
  '5.4' => true
78
  ),
79
- 'safe_mode' => array(
80
  '5.3' => false,
81
  '5.4' => true
82
  ),
83
- 'safe_mode_gid' => array(
84
  '5.3' => false,
85
  '5.4' => true
86
  ),
87
- 'safe_mode_include_dir' => array(
88
  '5.3' => false,
89
  '5.4' => true
90
  ),
91
- 'safe_mode_exec_dir' => array(
92
  '5.3' => false,
93
  '5.4' => true
94
  ),
95
- 'safe_mode_allowed_env_vars' => array(
96
  '5.3' => false,
97
  '5.4' => true
98
  ),
99
- 'safe_mode_protected_env_vars' => array(
100
  '5.3' => false,
101
  '5.4' => true
102
  ),
 
103
  'always_populate_raw_post_data' => array(
104
- '5.6' => false
 
105
  ),
106
  'iconv.input_encoding' => array(
107
  '5.6' => false
@@ -121,10 +173,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
121
  'mbstring.internal_encoding' => array(
122
  '5.6' => false
123
  ),
124
- 'always_populate_raw_post_data' => array(
125
- '5.6' => false,
126
- '7.0' => true
127
- ),
128
  'asp_tags' => array(
129
  '7.0' => true
130
  ),
@@ -156,7 +205,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
156
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
157
  {
158
  $tokens = $phpcsFile->getTokens();
159
-
160
  $isError = false;
161
 
162
  $ignore = array(
@@ -176,30 +225,37 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
176
  if ($function != 'ini_get' && $function != 'ini_set') {
177
  return;
178
  }
179
- $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
180
- if (in_array(str_replace("'", "", $tokens[$iniToken]['content']), array_keys($this->deprecatedIniDirectives)) === false) {
 
 
181
  return;
182
  }
183
 
184
  $error = '';
185
 
186
- foreach ($this->deprecatedIniDirectives[str_replace("'", "", $tokens[$iniToken]['content'])] as $version => $forbidden)
187
  {
188
- if ($this->supportsAbove($version)) {
189
- if ($forbidden === true) {
190
- $isError = true;
191
- $error .= " forbidden";
192
- } else {
193
- $isError = false;
194
- $error .= " deprecated";
 
 
 
195
  }
196
- $error .= " from PHP " . $version . " and";
197
  }
198
  }
199
 
200
  if (strlen($error) > 0) {
201
- $error = "INI directive " . $tokens[$iniToken]['content'] . " is" . $error;
202
  $error = substr($error, 0, strlen($error) - 4) . ".";
 
 
 
203
 
204
  if ($isError === true) {
205
  $phpcsFile->addError($error, $stackPtr);
23
  class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
+ * A list of deprecated INI directives.
27
+ *
28
+ * version => false means the directive was deprecated in that version.
29
+ * version => true means it was removed in that version.
30
  *
31
  * @var array(string)
32
  */
33
  protected $deprecatedIniDirectives = array(
34
+ 'fbsql.batchSize' => array(
35
+ '5.1' => true,
36
+ 'alternative' => 'fbsql.batchsize',
37
+ ),
38
+
39
+ 'ifx.allow_persistent' => array(
40
+ '5.2.1' => true
41
+ ),
42
+ 'ifx.blobinfile' => array(
43
+ '5.2.1' => true
44
+ ),
45
+ 'ifx.byteasvarchar' => array(
46
+ '5.2.1' => true
47
+ ),
48
+ 'ifx.charasvarchar' => array(
49
+ '5.2.1' => true
50
+ ),
51
+ 'ifx.default_host' => array(
52
+ '5.2.1' => true
53
+ ),
54
+ 'ifx.default_password' => array(
55
+ '5.2.1' => true
56
+ ),
57
+ 'ifx.default_user' => array(
58
+ '5.2.1' => true
59
+ ),
60
+ 'ifx.max_links' => array(
61
+ '5.2.1' => true
62
+ ),
63
+ 'ifx.max_persistent' => array(
64
+ '5.2.1' => true
65
+ ),
66
+ 'ifx.nullformat' => array(
67
+ '5.2.1' => true
68
+ ),
69
+ 'ifx.textasvarchar' => array(
70
+ '5.2.1' => true
71
+ ),
72
+
73
+ 'zend.ze1_compatibility_mode' => array(
74
+ '5.3' => true,
75
+ ),
76
+
77
+ 'allow_call_time_pass_reference' => array(
78
  '5.3' => false,
79
  '5.4' => true
80
  ),
81
+ 'define_syslog_variables' => array(
82
  '5.3' => false,
83
  '5.4' => true
84
  ),
85
+ 'detect_unicode' => array(
86
+ '5.4' => true,
87
+ 'alternative' => 'zend.detect_unicode',
88
+ ),
89
+ 'highlight.bg' => array(
90
  '5.3' => false,
91
  '5.4' => true
92
  ),
102
  '5.3' => false,
103
  '5.4' => true
104
  ),
105
+ 'mbstring.script_encoding' => array(
106
+ '5.4' => true,
107
+ 'alternative' => 'zend.script_encoding',
108
  ),
109
+ 'register_globals' => array(
110
  '5.3' => false,
111
  '5.4' => true
112
  ),
113
+ 'register_long_arrays' => array(
114
  '5.3' => false,
115
  '5.4' => true
116
  ),
117
+ 'safe_mode' => array(
118
  '5.3' => false,
119
  '5.4' => true
120
  ),
121
+ 'safe_mode_allowed_env_vars' => array(
122
  '5.3' => false,
123
  '5.4' => true
124
  ),
125
+ 'safe_mode_exec_dir' => array(
126
  '5.3' => false,
127
  '5.4' => true
128
  ),
129
+ 'safe_mode_gid' => array(
130
  '5.3' => false,
131
  '5.4' => true
132
  ),
133
+ 'safe_mode_include_dir' => array(
134
  '5.3' => false,
135
  '5.4' => true
136
  ),
137
+ 'safe_mode_protected_env_vars' => array(
138
  '5.3' => false,
139
  '5.4' => true
140
  ),
141
+ 'session.bug_compat_42' => array(
142
  '5.3' => false,
143
  '5.4' => true
144
  ),
145
+ 'session.bug_compat_warn' => array(
146
  '5.3' => false,
147
  '5.4' => true
148
  ),
149
+ 'y2k_compliance' => array(
150
  '5.3' => false,
151
  '5.4' => true
152
  ),
153
+
154
  'always_populate_raw_post_data' => array(
155
+ '5.6' => false,
156
+ '7.0' => true
157
  ),
158
  'iconv.input_encoding' => array(
159
  '5.6' => false
173
  'mbstring.internal_encoding' => array(
174
  '5.6' => false
175
  ),
176
+
 
 
 
177
  'asp_tags' => array(
178
  '7.0' => true
179
  ),
205
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
206
  {
207
  $tokens = $phpcsFile->getTokens();
208
+
209
  $isError = false;
210
 
211
  $ignore = array(
225
  if ($function != 'ini_get' && $function != 'ini_set') {
226
  return;
227
  }
228
+
229
+ $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
230
+ $filteredToken = trim($tokens[$iniToken]['content'], '\'"');
231
+ if (isset($this->deprecatedIniDirectives[$filteredToken]) === false) {
232
  return;
233
  }
234
 
235
  $error = '';
236
 
237
+ foreach ($this->deprecatedIniDirectives[$filteredToken] as $version => $forbidden)
238
  {
239
+ if ($version !== 'alternative') {
240
+ if ($this->supportsAbove($version)) {
241
+ if ($forbidden === true) {
242
+ $isError = ($function != 'ini_get') ?: false;
243
+ $error .= " forbidden";
244
+ } else {
245
+ $isError = false;
246
+ $error .= " deprecated";
247
+ }
248
+ $error .= " from PHP " . $version . " and";
249
  }
 
250
  }
251
  }
252
 
253
  if (strlen($error) > 0) {
254
+ $error = "INI directive '" . $filteredToken . "' is" . $error;
255
  $error = substr($error, 0, strlen($error) - 4) . ".";
256
+ if (isset($this->deprecatedIniDirectives[$filteredToken]['alternative'])) {
257
+ $error .= " Use '" . $this->deprecatedIniDirectives[$filteredToken]['alternative'] . "' instead.";
258
+ }
259
 
260
  if ($isError === true) {
261
  $phpcsFile->addError($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_DeprecatedNewReferenceSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = false;
34
-
35
  /**
36
  * Returns an array of tokens this test wants to listen for.
37
  *
25
  class PHPCompatibility_Sniffs_PHP_DeprecatedNewReferenceSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * Returns an array of tokens this test wants to listen for.
30
  *
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php CHANGED
@@ -17,13 +17,30 @@
17
  * @author Koen Eelen <koen.eelen@cu.be>
18
  */
19
  class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends PHPCompatibility_Sniff {
 
20
  public function register()
21
  {
22
  return array(T_CLASS);
23
 
24
  }//end register()
25
 
26
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  $tokens = $phpcsFile->getTokens();
28
 
29
  $class = $tokens[$stackPtr];
@@ -33,30 +50,34 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends P
33
  }
34
 
35
  $scopeCloser = $class['scope_closer'];
 
36
 
37
- //get the name of the class
38
- $classNamePos = $phpcsFile->findNext(T_STRING, $stackPtr);
39
- $className = $tokens[$classNamePos]['content'];
40
 
41
  $nextFunc = $stackPtr;
42
  $newConstructorFound = false;
43
  $oldConstructorFound = false;
 
44
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
45
- $funcNamePos = $phpcsFile->findNext(T_STRING, $nextFunc);
46
-
47
- if ($tokens[$funcNamePos]['content'] === '__construct') {
 
 
 
48
  $newConstructorFound = true;
49
  }
50
 
51
- if ($this->supportsAbove('7.0')) {
52
- if ($funcNamePos !== false && $tokens[$funcNamePos]['content'] === $className) {
53
- $oldConstructorFound = true;
54
- }
55
  }
56
  }
57
-
58
  if ($newConstructorFound === false && $oldConstructorFound === true) {
59
- $phpcsFile->addError('Deprecated PHP4 style constructor are not supported since PHP7', $funcNamePos);
60
  }
61
  }
62
  }
17
  * @author Koen Eelen <koen.eelen@cu.be>
18
  */
19
  class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends PHPCompatibility_Sniff {
20
+
21
  public function register()
22
  {
23
  return array(T_CLASS);
24
 
25
  }//end register()
26
 
27
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
28
+ {
29
+ if ($this->supportsAbove('7.0') === false) {
30
+ return;
31
+ }
32
+
33
+ if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
34
+ /*
35
+ * Namespaced methods with the same name as the class are treated as
36
+ * regular methods, so we can bow out if we're in a namespace.
37
+ *
38
+ * Note: the exception to this is PHP 5.3.0-5.3.2. This is currently
39
+ * not dealt with.
40
+ */
41
+ return;
42
+ }
43
+
44
  $tokens = $phpcsFile->getTokens();
45
 
46
  $class = $tokens[$stackPtr];
50
  }
51
 
52
  $scopeCloser = $class['scope_closer'];
53
+ $className = $phpcsFile->getDeclarationName($stackPtr);
54
 
55
+ if (empty($className) || is_string($className) === false) {
56
+ return;
57
+ }
58
 
59
  $nextFunc = $stackPtr;
60
  $newConstructorFound = false;
61
  $oldConstructorFound = false;
62
+ $oldConstructorPos = false;
63
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
64
+ $funcName = $phpcsFile->getDeclarationName($nextFunc);
65
+ if (empty($funcName) || is_string($funcName) === false) {
66
+ continue;
67
+ }
68
+
69
+ if ($funcName === '__construct') {
70
  $newConstructorFound = true;
71
  }
72
 
73
+ if ($funcName === $className) {
74
+ $oldConstructorFound = true;
75
+ $oldConstructorPos = $phpcsFile->findNext(T_STRING, $nextFunc);
 
76
  }
77
  }
78
+
79
  if ($newConstructorFound === false && $oldConstructorFound === true) {
80
+ $phpcsFile->addError('Deprecated PHP4 style constructor are not supported since PHP7', $oldConstructorPos);
81
  }
82
  }
83
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = true;
34
-
35
  /**
36
  * Returns an array of tokens this test wants to listen for.
37
  *
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * Returns an array of tokens this test wants to listen for.
30
  *
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php CHANGED
@@ -29,13 +29,6 @@
29
  class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends PHPCompatibility_Sniff
30
  {
31
 
32
- /**
33
- * If true, an error will be thrown; otherwise a warning.
34
- *
35
- * @var bool
36
- */
37
- protected $error = true;
38
-
39
  /**
40
  * Returns an array of tokens this test wants to listen for.
41
  *
@@ -133,38 +126,38 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends
133
  // positives to not identifying a pass-by-reference call at all.
134
  // The blacklist may not yet be complete.
135
  switch ($tokens[$tokenBefore]['code']) {
136
- case T_LNUMBER:
137
- case T_VARIABLE:
138
- case T_CLOSE_SQUARE_BRACKET:
139
- case T_CLOSE_PARENTHESIS:
140
  // In these cases T_BITWISE_AND represents
141
  // the bitwise and operator.
142
- continue;
143
-
144
- // Unfortunately the tokenizer fails to recognize global constants,
145
- // class-constants and -attributes. Any of these are returned is
146
- // treated as T_STRING.
147
- // So we step back another token and check if it is a class
148
- // operator (-> or ::), which means we have a false positive.
149
- // Global constants still remain uncovered.
150
- case T_STRING:
151
- $tokenBeforePlus = $phpcsFile->findPrevious(
152
- PHP_CodeSniffer_Tokens::$emptyTokens,
153
- ($tokenBefore - 1),
154
- null,
155
- true
156
- );
157
- if( T_DOUBLE_COLON === $tokens[$tokenBeforePlus]['code'] ||
158
- T_OBJECT_OPERATOR === $tokens[$tokenBeforePlus]['code']
159
- ) {
160
  continue;
161
- }
162
-
163
- default:
164
- // T_BITWISE_AND represents a pass-by-reference.
165
- $error = 'Using a call-time pass-by-reference is prohibited since php 5.4';
166
- $phpcsFile->addError($error, $tokenBefore, 'NotAllowed');
167
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
169
  }//end if
170
  }//end while
29
  class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends PHPCompatibility_Sniff
30
  {
31
 
 
 
 
 
 
 
 
32
  /**
33
  * Returns an array of tokens this test wants to listen for.
34
  *
126
  // positives to not identifying a pass-by-reference call at all.
127
  // The blacklist may not yet be complete.
128
  switch ($tokens[$tokenBefore]['code']) {
 
 
 
 
129
  // In these cases T_BITWISE_AND represents
130
  // the bitwise and operator.
131
+ case T_LNUMBER:
132
+ case T_VARIABLE:
133
+ case T_CLOSE_SQUARE_BRACKET:
134
+ case T_CLOSE_PARENTHESIS:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  continue;
136
+
137
+ // Unfortunately the tokenizer fails to recognize global constants,
138
+ // class-constants and -attributes. Any of these are returned is
139
+ // treated as T_STRING.
140
+ // So we step back another token and check if it is a class
141
+ // operator (-> or ::), which means we have a false positive.
142
+ // Global constants still remain uncovered.
143
+ case T_STRING:
144
+ $tokenBeforePlus = $phpcsFile->findPrevious(
145
+ PHP_CodeSniffer_Tokens::$emptyTokens,
146
+ ($tokenBefore - 1),
147
+ null,
148
+ true
149
+ );
150
+ if( T_DOUBLE_COLON === $tokens[$tokenBeforePlus]['code'] ||
151
+ T_OBJECT_OPERATOR === $tokens[$tokenBeforePlus]['code']
152
+ ) {
153
+ continue;
154
+ }
155
+
156
+ default:
157
+ // T_BITWISE_AND represents a pass-by-reference.
158
+ $error = 'Using a call-time pass-by-reference is prohibited since php 5.4';
159
+ $phpcsFile->addError($error, $tokenBefore, 'NotAllowed');
160
+ break;
161
  }
162
  }//end if
163
  }//end while
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php CHANGED
@@ -23,6 +23,13 @@
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPCompatibility_Sniff
24
  {
25
 
 
 
 
 
 
 
 
26
  /**
27
  * Returns an array of tokens this test wants to listen for.
28
  *
@@ -30,6 +37,17 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPC
30
  */
31
  public function register()
32
  {
 
 
 
 
 
 
 
 
 
 
 
33
  return array(T_LIST);
34
  }
35
 
@@ -47,31 +65,24 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPC
47
  if ($this->supportsAbove('7.0')) {
48
  $tokens = $phpcsFile->getTokens();
49
 
50
- $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false);
51
- $close = $phpcsFile->findNext(T_CLOSE_PARENTHESIS, $stackPtr, null, false);
52
-
 
 
 
53
  $error = true;
54
- for ($cnt = $open + 1; $cnt < $close; $cnt++) {
55
- if ($tokens[$cnt]['type'] != 'T_WHITESPACE' && $tokens[$cnt]['type'] != 'T_COMMA') {
56
- $error = false;
 
 
57
  }
58
  }
59
-
60
- if ($open !== false && $close !== false) {
61
- if (
62
- $close - $open == 1
63
- ||
64
- (
65
- $close - $open > 2
66
- &&
67
- $error === true
68
- )
69
- ) {
70
- $error = sprintf(
71
- "Empty list() assignments are not allowed since PHP 7.0"
72
- );
73
- $phpcsFile->addError($error, $stackPtr);
74
- }
75
  }
76
  }
77
  }
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPCompatibility_Sniff
24
  {
25
 
26
+ /**
27
+ * List of tokens to disregard when determining whether the list() is empty.
28
+ *
29
+ * @var array
30
+ */
31
+ protected $ignoreTokens = array();
32
+
33
  /**
34
  * Returns an array of tokens this test wants to listen for.
35
  *
37
  */
38
  public function register()
39
  {
40
+ // Set up a list of tokens to disregard when determining whether the list() is empty.
41
+ // Only needs to be set up once.
42
+ $this->ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens;
43
+ if (version_compare(PHP_CodeSniffer::VERSION, '2.0', '<')) {
44
+ $this->ignoreTokens = array_combine($this->ignoreTokens, $this->ignoreTokens);
45
+ }
46
+ $this->ignoreTokens[T_COMMA] = T_COMMA;
47
+ $this->ignoreTokens[T_OPEN_PARENTHESIS] = T_OPEN_PARENTHESIS;
48
+ $this->ignoreTokens[T_CLOSE_PARENTHESIS] = T_CLOSE_PARENTHESIS;
49
+
50
+
51
  return array(T_LIST);
52
  }
53
 
65
  if ($this->supportsAbove('7.0')) {
66
  $tokens = $phpcsFile->getTokens();
67
 
68
+ $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
69
+ if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
70
+ return;
71
+ }
72
+
73
+ $close = $tokens[$open]['parenthesis_closer'];
74
  $error = true;
75
+ if(($close - $open) > 1) {
76
+ for ($cnt = $open + 1; $cnt < $close; $cnt++) {
77
+ if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
78
+ $error = false;
79
+ }
80
  }
81
  }
82
+
83
+ if ($error === true) {
84
+ $error = 'Empty list() assignments are not allowed since PHP 7.0';
85
+ $phpcsFile->addError($error, $stackPtr);
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
  }
88
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php CHANGED
@@ -23,13 +23,6 @@
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff extends PHPCompatibility_Sniff
24
  {
25
 
26
- /**
27
- * If true, an error will be thrown; otherwise a warning.
28
- *
29
- * @var bool
30
- */
31
- protected $error = true;
32
-
33
  /**
34
  * Returns an array of tokens this test wants to listen for.
35
  *
@@ -60,15 +53,12 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff e
60
  return;
61
  }
62
 
63
- // Get function name.
64
- $methodName = $phpcsFile->getDeclarationName($stackPtr);
65
-
66
  // Get all parameters from method signature.
67
  $paramNames = array();
68
  foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
69
  $paramNames[] = strtolower($param['name']);
70
  }
71
-
72
  if (count($paramNames) != count(array_unique($paramNames))) {
73
  $phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
74
  }
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff extends PHPCompatibility_Sniff
24
  {
25
 
 
 
 
 
 
 
 
26
  /**
27
  * Returns an array of tokens this test wants to listen for.
28
  *
53
  return;
54
  }
55
 
 
 
 
56
  // Get all parameters from method signature.
57
  $paramNames = array();
58
  foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
59
  $paramNames[] = strtolower($param['name']);
60
  }
61
+
62
  if (count($paramNames) != count(array_unique($paramNames))) {
63
  $phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
64
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = true;
34
-
35
  /**
36
  * List of tokens to register
37
  *
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * List of tokens to register
30
  *
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php CHANGED
@@ -103,11 +103,15 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
103
  );
104
 
105
  /**
106
- * If true, an error will be thrown; otherwise a warning.
 
107
  *
108
- * @var bool
109
  */
110
- protected $error = true;
 
 
 
111
 
112
  /**
113
  * targetedTokens
@@ -170,10 +174,18 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
170
  return;
171
  }
172
 
 
 
 
 
 
 
 
 
173
  if (isset($tokens[$stackPtr - 2]) && $tokens[$stackPtr - 2]['type'] == 'T_NEW' && $tokens[$stackPtr - 1]['type'] == 'T_WHITESPACE' && $tokens[$stackPtr]['type'] == 'T_ANON_CLASS') {
174
  return;
175
  }
176
-
177
  if ($this->supportsAbove($this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])])) {
178
  $error = "Function name, class name, namespace name or constant name can not be reserved keyword '" . $tokens[$stackPtr + 2]['content'] . "' (since version " . $this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])] . ")";
179
  $phpcsFile->addError($error, $stackPtr);
103
  );
104
 
105
  /**
106
+ * A list of keywords that can follow use statements.
107
+ * Mentions since which version it's not allowed
108
  *
109
+ * @var array(string => string)
110
  */
111
+ protected $validUseNames = array(
112
+ 'const',
113
+ 'function',
114
+ );
115
 
116
  /**
117
  * targetedTokens
174
  return;
175
  }
176
 
177
+ // PHP 5.6 allows for use const and use function
178
+ if ($this->supportsAbove('5.6')
179
+ && $tokens[$stackPtr]['type'] == 'T_USE'
180
+ && in_array(strtolower($tokens[$stackPtr + 2]['content']), $this->validUseNames)
181
+ ) {
182
+ return;
183
+ }
184
+
185
  if (isset($tokens[$stackPtr - 2]) && $tokens[$stackPtr - 2]['type'] == 'T_NEW' && $tokens[$stackPtr - 1]['type'] == 'T_WHITESPACE' && $tokens[$stackPtr]['type'] == 'T_ANON_CLASS') {
186
  return;
187
  }
188
+
189
  if ($this->supportsAbove($this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])])) {
190
  $error = "Function name, class name, namespace name or constant name can not be reserved keyword '" . $tokens[$stackPtr + 2]['content'] . "' (since version " . $this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])] . ")";
191
  $phpcsFile->addError($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php CHANGED
@@ -12,7 +12,7 @@
12
  /**
13
  * PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshift.
14
  *
15
- * Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0
16
  *
17
  * @category PHP
18
  * @package PHPCompatibility
@@ -21,13 +21,6 @@
21
  class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPCompatibility_Sniff
22
  {
23
 
24
- /**
25
- * If true, an error will be thrown; otherwise a warning.
26
- *
27
- * @var bool
28
- */
29
- protected $error = true;
30
-
31
  /**
32
  * Returns an array of tokens this test wants to listen for.
33
  *
@@ -52,7 +45,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPComp
52
  {
53
  if ($this->supportsAbove('7.0')) {
54
  $tokens = $phpcsFile->getTokens();
55
-
56
  $nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr, null, false, null, true);
57
  if ($tokens[$nextNumber - 1]['code'] == T_MINUS) {
58
  $error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
12
  /**
13
  * PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshift.
14
  *
15
+ * Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0
16
  *
17
  * @category PHP
18
  * @package PHPCompatibility
21
  class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPCompatibility_Sniff
22
  {
23
 
 
 
 
 
 
 
 
24
  /**
25
  * Returns an array of tokens this test wants to listen for.
26
  *
45
  {
46
  if ($this->supportsAbove('7.0')) {
47
  $tokens = $phpcsFile->getTokens();
48
+
49
  $nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr, null, false, null, true);
50
  if ($tokens[$nextNumber - 1]['code'] == T_MINUS) {
51
  $error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php CHANGED
@@ -23,13 +23,6 @@
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff extends PHPCompatibility_Sniff
24
  {
25
 
26
- /**
27
- * If true, an error will be thrown; otherwise a warning.
28
- *
29
- * @var bool
30
- */
31
- protected $error = true;
32
-
33
  /**
34
  * Returns an array of tokens this test wants to listen for.
35
  *
@@ -52,25 +45,28 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff
52
  */
53
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
  {
55
- if ($this->supportsAbove('7.0')) {
56
- $tokens = $phpcsFile->getTokens();
57
-
58
- $defaultToken = $stackPtr;
59
- $defaultCount = 0;
60
- if (isset($tokens[$stackPtr]['scope_closer'])) {
61
- while ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT, T_SWITCH), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
62
- if ($tokens[$defaultToken]['type'] == 'T_SWITCH') {
63
- $defaultToken = $tokens[$defaultToken]['scope_closer'];
64
- } else {
65
- $defaultCount++;
66
- }
67
- }
68
-
69
- if ($defaultCount > 1) {
70
- $phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
71
- }
72
  }
73
  }
 
 
 
 
74
  }//end process()
75
 
76
  }//end class
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff extends PHPCompatibility_Sniff
24
  {
25
 
 
 
 
 
 
 
 
26
  /**
27
  * Returns an array of tokens this test wants to listen for.
28
  *
45
  */
46
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
47
  {
48
+ if ($this->supportsAbove('7.0') === false) {
49
+ return;
50
+ }
51
+
52
+ $tokens = $phpcsFile->getTokens();
53
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
54
+ return;
55
+ }
56
+
57
+ $defaultToken = $stackPtr;
58
+ $defaultCount = 0;
59
+ $targetLevel = $tokens[$stackPtr]['level'] + 1;
60
+ while ($defaultCount < 2 && $defaultToken = $phpcsFile->findNext(array(T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
61
+ // Same level or one below (= two default cases after each other).
62
+ if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
63
+ $defaultCount++;
 
64
  }
65
  }
66
+
67
+ if ($defaultCount > 1) {
68
+ $phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
69
+ }
70
  }//end process()
71
 
72
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff.
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category PHP
8
+ * @package PHPCompatibility
9
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
10
+ */
11
+
12
+ /**
13
+ * PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff.
14
+ *
15
+ * @category PHP
16
+ * @package PHPCompatibility
17
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
+ */
19
+ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibility_Sniff
20
+ {
21
+
22
+ /**
23
+ * A list of PHP internal interfaces, not intended to be implemented by userland classes.
24
+ *
25
+ * The array lists : the error message to use.
26
+ *
27
+ * @var array(string => string)
28
+ */
29
+ protected $internalInterfaces = array(
30
+ 'Traversable' => 'shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.',
31
+ 'DateTimeInterface' => 'is intended for type hints only and is not implementable.',
32
+ 'Throwable' => 'cannot be implemented directly, extend the Exception class instead.',
33
+ );
34
+
35
+
36
+ /**
37
+ * Returns an array of tokens this test wants to listen for.
38
+ *
39
+ * @return array
40
+ */
41
+ public function register()
42
+ {
43
+ // Handle case-insensitivity of class names.
44
+ $keys = array_keys( $this->internalInterfaces );
45
+ $keys = array_map( 'strtolower', $keys );
46
+ $this->internalInterfaces = array_combine( $keys, $this->internalInterfaces );
47
+
48
+ return array(T_CLASS);
49
+
50
+ }//end register()
51
+
52
+
53
+ /**
54
+ * Processes this test, when one of its tokens is encountered.
55
+ *
56
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+ * @param int $stackPtr The position of the current token in
58
+ * the stack passed in $tokens.
59
+ *
60
+ * @return void
61
+ */
62
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
+ {
64
+ $interfaces = $this->findImplementedInterfaceNames($phpcsFile, $stackPtr);
65
+
66
+ if (is_array($interfaces) === false || $interfaces === array()) {
67
+ return;
68
+ }
69
+
70
+ foreach ($interfaces as $interface) {
71
+ $lcInterface = strtolower($interface);
72
+ if (isset($this->internalInterfaces[$lcInterface]) === true) {
73
+ $error = 'The interface %s %s';
74
+ $data = array(
75
+ $interface,
76
+ $this->internalInterfaces[$lcInterface],
77
+ );
78
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
79
+ }
80
+ }
81
+
82
+ }//end process()
83
+
84
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff extends PHPCompatibility_Sniff
18
+ {
19
+ /**
20
+ * Returns an array of tokens this test wants to listen for.
21
+ *
22
+ * @return array
23
+ */
24
+ public function register()
25
+ {
26
+ return array(T_STATIC);
27
+
28
+ }//end register()
29
+
30
+
31
+ /**
32
+ * Processes this test, when one of its tokens is encountered.
33
+ *
34
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
35
+ * @param int $stackPtr The position of the current token in the
36
+ * stack passed in $tokens.
37
+ *
38
+ * @return void
39
+ */
40
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
41
+ {
42
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
43
+ if ($nextNonEmpty === false) {
44
+ return;
45
+ }
46
+
47
+ $tokens = $phpcsFile->getTokens();
48
+ if ($tokens[$nextNonEmpty]['code'] !== T_DOUBLE_COLON) {
49
+ return;
50
+ }
51
+
52
+ $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
53
+
54
+ if ($inClass === true && $this->supportsBelow('5.2') === true) {
55
+ $error = 'Late static binding is not supported in PHP 5.2 or earlier.';
56
+ $phpcsFile->addError($error, $stackPtr, 'Found');
57
+ }
58
+
59
+ if ($inClass === false) {
60
+ $error = 'Late static binding is not supported outside of class scope.';
61
+ $phpcsFile->addError($error, $stackPtr, 'OutsideClassScope');
62
+ }
63
+
64
+ }//end process()
65
+
66
+
67
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php CHANGED
@@ -60,18 +60,15 @@ class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff
60
  */
61
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
62
  {
63
- if ($this->supportsAbove('5.3')) {
64
- $tokens = $phpcsFile->getTokens();
 
65
 
66
- if ($tokens[$stackPtr]['type'] == 'T_VARIABLE'
67
- && in_array(substr($tokens[$stackPtr]['content'], 1), $this->deprecated)
68
- ) {
69
- $error = sprintf(
70
- "The use of long predefined variables has been deprecated in 5.3 and removed in 5.4; Found '%s'",
71
- $tokens[$stackPtr]['content']
72
- );
73
- $phpcsFile->addWarning($error, $stackPtr);
74
- }
75
  }
76
  }
77
  }
60
  */
61
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
62
  {
63
+ if ($this->supportsAbove('5.3') === false) {
64
+ return;
65
+ }
66
 
67
+ $tokens = $phpcsFile->getTokens();
68
+ if (in_array(substr($tokens[$stackPtr]['content'], 1), $this->deprecated, true)) {
69
+ $error = "The use of long predefined variables has been deprecated in 5.3 and removed in 5.4; Found '%s'";
70
+ $data = array($tokens[$stackPtr]['content']);
71
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
 
 
 
 
72
  }
73
  }
74
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php CHANGED
@@ -46,15 +46,14 @@ class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibil
46
  */
47
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48
  {
49
- $tokens = $phpcsFile->getTokens();
50
  $whitespace = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, $stackPtr + 2);
51
- $class = $phpcsFile->findNext(T_ANON_CLASS, $stackPtr + 2, $stackPtr + 3);
52
- if ($whitespace == false || $class == false) {
53
- return false;
54
  }
55
-
56
  if ($this->supportsAbove('7.0')) {
57
- return false;
58
  } else {
59
  $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr);
60
  }
46
  */
47
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48
  {
 
49
  $whitespace = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, $stackPtr + 2);
50
+ $class = $phpcsFile->findNext(T_ANON_CLASS, $stackPtr + 2, $stackPtr + 3);
51
+ if ($whitespace === false || $class === false) {
52
+ return;
53
  }
54
+
55
  if ($this->supportsAbove('7.0')) {
56
+ return;
57
  } else {
58
  $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr);
59
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php CHANGED
@@ -133,10 +133,6 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
133
  '5.3' => false,
134
  '5.4' => true
135
  ),
136
- 'JsonSerializable' => array(
137
- '5.3' => false,
138
- '5.4' => true
139
- ),
140
  'SessionHandler' => array(
141
  '5.3' => false,
142
  '5.4' => true
@@ -190,14 +186,6 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
190
  );
191
 
192
 
193
- /**
194
- * If true, an error will be thrown; otherwise a warning.
195
- *
196
- * @var bool
197
- */
198
- protected $error = false;
199
-
200
-
201
  /**
202
  * Returns an array of tokens this test wants to listen for.
203
  *
@@ -205,7 +193,11 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
205
  */
206
  public function register()
207
  {
208
- return array(T_NEW);
 
 
 
 
209
 
210
  }//end register()
211
 
@@ -221,39 +213,45 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
221
  */
222
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
223
  {
224
- $tokens = $phpcsFile->getTokens();
225
- if (
226
- $tokens[$stackPtr + 2]['type'] == 'T_STRING'
227
- &&
228
- (
229
- $tokens[$stackPtr + 3]['type'] == 'T_OPEN_PARENTHESIS'
230
- ||
231
- (
232
- $tokens[$stackPtr + 3]['type'] == 'T_WHITESPACE'
233
- &&
234
- $tokens[$stackPtr + 4]['type'] == 'T_OPEN_PARENTHESIS'
235
- )
236
- )
237
- ) {
238
- $className = $tokens[$stackPtr + 2]['content'];
239
- if (array_key_exists($className, $this->newClasses) === false) {
240
- return;
241
- }
242
- $this->addError($phpcsFile, $stackPtr, $className);
243
  }
244
 
 
 
 
 
 
 
 
 
 
245
 
 
246
 
247
  }//end process()
248
 
249
 
250
  /**
251
- * Generates the error or wanrning for this sniff.
252
  *
253
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
254
  * @param int $stackPtr The position of the function
255
  * in the token array.
256
- * @param string $function The name of the function.
257
  * @param string $pattern The pattern used for the match.
258
  *
259
  * @return void
@@ -266,11 +264,11 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
266
 
267
  $error = '';
268
 
269
- $this->error = false;
270
  foreach ($this->newClasses[$pattern] as $version => $present) {
271
  if ($this->supportsBelow($version)) {
272
  if ($present === false) {
273
- $this->error = true;
274
  $error .= 'not present in PHP version ' . $version . ' or earlier';
275
  }
276
  }
@@ -278,7 +276,7 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
278
  if (strlen($error) > 0) {
279
  $error = 'The built-in class ' . $className . ' is ' . $error;
280
 
281
- if ($this->error === true) {
282
  $phpcsFile->addError($error, $stackPtr);
283
  } else {
284
  $phpcsFile->addWarning($error, $stackPtr);
133
  '5.3' => false,
134
  '5.4' => true
135
  ),
 
 
 
 
136
  'SessionHandler' => array(
137
  '5.3' => false,
138
  '5.4' => true
186
  );
187
 
188
 
 
 
 
 
 
 
 
 
189
  /**
190
  * Returns an array of tokens this test wants to listen for.
191
  *
193
  */
194
  public function register()
195
  {
196
+ return array(
197
+ T_NEW,
198
+ T_CLASS,
199
+ T_DOUBLE_COLON,
200
+ );
201
 
202
  }//end register()
203
 
213
  */
214
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
215
  {
216
+ $tokens = $phpcsFile->getTokens();
217
+ $FQClassName = '';
218
+
219
+ if ($tokens[$stackPtr]['type'] === 'T_NEW') {
220
+ $FQClassName = $this->getFQClassNameFromNewToken($phpcsFile, $stackPtr);
221
+ }
222
+ else if ($tokens[$stackPtr]['type'] === 'T_CLASS') {
223
+ $FQClassName = $this->getFQExtendedClassName($phpcsFile, $stackPtr);
224
+ }
225
+ else if ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') {
226
+ $FQClassName = $this->getFQClassNameFromDoubleColonToken($phpcsFile, $stackPtr);
227
+ }
228
+
229
+ if ($FQClassName === '') {
230
+ return;
 
 
 
 
231
  }
232
 
233
+ if ($this->isNamespaced($FQClassName) === true) {
234
+ return;
235
+ }
236
+
237
+ $className = substr($FQClassName, 1); // Remove global namespace indicator.
238
+
239
+ if (array_key_exists($className, $this->newClasses) === false) {
240
+ return;
241
+ }
242
 
243
+ $this->addError($phpcsFile, $stackPtr, $className);
244
 
245
  }//end process()
246
 
247
 
248
  /**
249
+ * Generates the error or warning for this sniff.
250
  *
251
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
252
  * @param int $stackPtr The position of the function
253
  * in the token array.
254
+ * @param string $className The name of the class.
255
  * @param string $pattern The pattern used for the match.
256
  *
257
  * @return void
264
 
265
  $error = '';
266
 
267
+ $isError = false;
268
  foreach ($this->newClasses[$pattern] as $version => $present) {
269
  if ($this->supportsBelow($version)) {
270
  if ($present === false) {
271
+ $isError = true;
272
  $error .= 'not present in PHP version ' . $version . ' or earlier';
273
  }
274
  }
276
  if (strlen($error) > 0) {
277
  $error = 'The built-in class ' . $className . ' is ' . $error;
278
 
279
+ if ($isError === true) {
280
  $phpcsFile->addError($error, $stackPtr);
281
  } else {
282
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_Sniff
18
+ {
19
+
20
+ /**
21
+ * A list of new execution directives
22
+ *
23
+ * The array lists : version number with false (not present) or true (present).
24
+ * If the execution order is conditional, add the condition as a string to the version nr.
25
+ * If's sufficient to list the first version where the execution directive appears.
26
+ *
27
+ * @var array(string => array(string => int|string|null))
28
+ */
29
+ protected $newDirectives = array (
30
+ 'ticks' => array(
31
+ '3.1' => false,
32
+ '4.0' => true,
33
+ 'valid_value_callback' => 'isNumeric',
34
+ ),
35
+ 'encoding' => array(
36
+ '5.2' => false,
37
+ '5.3' => '--enable-zend-multibyte', // Directive ignored unless.
38
+ '5.4' => true,
39
+ 'valid_value_callback' => 'validEncoding',
40
+ ),
41
+ 'strict_types' => array(
42
+ '5.6' => false,
43
+ '7.0' => true,
44
+ 'valid_values' => array(1),
45
+ ),
46
+ );
47
+
48
+
49
+ /**
50
+ * Tokens to ignore when trying to find the value for the directive.
51
+ *
52
+ * @var array
53
+ */
54
+ protected $ignoreTokens = array();
55
+
56
+
57
+ /**
58
+ * Returns an array of tokens this test wants to listen for.
59
+ *
60
+ * @return array
61
+ */
62
+ public function register()
63
+ {
64
+ $this->ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens;
65
+ $this->ignoreTokens[T_EQUAL] = T_EQUAL;
66
+
67
+ return array(T_DECLARE);
68
+ }//end register()
69
+
70
+
71
+ /**
72
+ * Processes this test, when one of its tokens is encountered.
73
+ *
74
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
75
+ * @param int $stackPtr The position of the current token in
76
+ * the stack passed in $tokens.
77
+ *
78
+ * @return void
79
+ */
80
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
81
+ {
82
+ $tokens = $phpcsFile->getTokens();
83
+
84
+ if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === true) {
85
+ $openParenthesis = $tokens[$stackPtr]['parenthesis_opener'];
86
+ $closeParenthesis = $tokens[$stackPtr]['parenthesis_closer'];
87
+ }
88
+ else {
89
+ if (version_compare(PHP_CodeSniffer::VERSION, '2.0', '>=')) {
90
+ return;
91
+ }
92
+
93
+ // Deal with PHPCS 1.x which does not set the parenthesis properly for declare statements.
94
+ $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true);
95
+ if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
96
+ return;
97
+ }
98
+ $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
99
+ }
100
+
101
+ $directivePtr = $phpcsFile->findNext(T_STRING, ($openParenthesis + 1), $closeParenthesis, false);
102
+ if ($directivePtr === false) {
103
+ return;
104
+ }
105
+
106
+ $directiveContent = $tokens[$directivePtr]['content'];
107
+
108
+ if (isset($this->newDirectives[$directiveContent]) === false) {
109
+ $error = 'Declare can only be used with the directives %s. Found: %s';
110
+ $data = array(
111
+ implode(', ', array_keys($this->newDirectives)),
112
+ $directiveContent,
113
+ );
114
+ $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
115
+ }
116
+ else {
117
+ // Check for valid directive for version.
118
+ $this->maybeAddError($phpcsFile, $stackPtr, $directiveContent);
119
+
120
+ // Check for valid directive value.
121
+ $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
122
+ if ($valuePtr === false) {
123
+ return;
124
+ }
125
+
126
+ $this->addErrorOnInvalidValue($phpcsFile, $valuePtr, $directiveContent);
127
+ }
128
+
129
+ }//end process()
130
+
131
+
132
+ /**
133
+ * Generates a error or warning for this sniff.
134
+ *
135
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
136
+ * @param int $stackPtr The position of the declare statement
137
+ * in the token array.
138
+ * @param string $directive The directive.
139
+ *
140
+ * @return void
141
+ */
142
+ protected function maybeAddError($phpcsFile, $stackPtr, $directive)
143
+ {
144
+ $isError = false;
145
+ $notInVersion = '';
146
+ $conditionalVersion = '';
147
+ foreach ($this->newDirectives[$directive] as $version => $present) {
148
+ if (strpos($version, 'valid_') === false && $this->supportsBelow($version)) {
149
+ if ($present === false) {
150
+ $isError = true;
151
+ $notInVersion = $version;
152
+ }
153
+ else if (is_string($present)) {
154
+ // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
155
+ $conditionalVersion = $version;
156
+ }
157
+ }
158
+ }
159
+ if ($notInVersion !== '' || $conditionalVersion !== '') {
160
+ if ($isError === true && $notInVersion !== '') {
161
+ $error = 'Directive %s is not present in PHP version %s or earlier';
162
+ $errorCode = $directive . 'Found';
163
+ $data = array(
164
+ $directive,
165
+ $notInVersion,
166
+ );
167
+
168
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
169
+ }
170
+ else if($conditionalVersion !== '') {
171
+ $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
172
+ $errorCode = $directive . 'Found';
173
+ $data = array(
174
+ $directive,
175
+ $conditionalVersion,
176
+ $this->newDirectives[$directive][$conditionalVersion],
177
+ );
178
+
179
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
180
+ }
181
+ }
182
+
183
+ }//end maybeAddError()
184
+
185
+
186
+ /**
187
+ * Generates a error or warning for this sniff.
188
+ *
189
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
190
+ * @param int $stackPtr The position of the execution directive value
191
+ * in the token array.
192
+ * @param string $directive The directive.
193
+ *
194
+ * @return void
195
+ */
196
+ protected function addErrorOnInvalidValue($phpcsFile, $stackPtr, $directive)
197
+ {
198
+ $tokens = $phpcsFile->getTokens();
199
+
200
+ $value = $tokens[$stackPtr]['content'];
201
+ if ($tokens[$stackPtr]['code'] === T_CONSTANT_ENCAPSED_STRING) {
202
+ $value = trim($value, '\'"');
203
+ }
204
+
205
+ $isError = false;
206
+ if (isset($this->newDirectives[$directive]['valid_values'])) {
207
+ if (in_array($value, $this->newDirectives[$directive]['valid_values']) === false) {
208
+ $isError = true;
209
+ }
210
+ }
211
+ else if (isset($this->newDirectives[$directive]['valid_value_callback'])) {
212
+ $valid = call_user_func(array($this, $this->newDirectives[$directive]['valid_value_callback']), $value);
213
+ if ($valid === false) {
214
+ $isError = true;
215
+ }
216
+ }
217
+
218
+ if ($isError === true) {
219
+ $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
220
+ $data = array(
221
+ $directive,
222
+ $value,
223
+ );
224
+ $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveValueFound', $data);
225
+ }
226
+ }// addErrorOnInvalidValue()
227
+
228
+
229
+ /**
230
+ * Check whether a value is numeric.
231
+ *
232
+ * Callback function to test whether the value for an execution directive is valid.
233
+ *
234
+ * @param mixed $value The value to test.
235
+ *
236
+ * @return bool
237
+ */
238
+ protected function isNumeric($value)
239
+ {
240
+ return is_numeric($value);
241
+ }
242
+
243
+
244
+ /**
245
+ * Check whether a value is valid encoding.
246
+ *
247
+ * Callback function to test whether the value for an execution directive is valid.
248
+ *
249
+ * @param mixed $value The value to test.
250
+ *
251
+ * @return bool
252
+ */
253
+ protected function validEncoding($value)
254
+ {
255
+ $encodings = array();
256
+ if (function_exists('mb_list_encodings')) {
257
+ $encodings = mb_list_encodings();
258
+ }
259
+
260
+ if (empty($encodings)) {
261
+ // If we can't test the encoding, let it pass through.
262
+ return true;
263
+ }
264
+
265
+ if (in_array($value, $encodings, true)) {
266
+ return true;
267
+ }
268
+ else {
269
+ return false;
270
+ }
271
+ }
272
+
273
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php CHANGED
@@ -25,7 +25,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHP
25
  {
26
  return array(T_STRING);
27
  }//end register()
28
-
29
  /**
30
  * Processes this test, when one of its tokens is encountered.
31
  *
@@ -51,7 +51,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHP
51
  // Not a call to a PHP function.
52
  return;
53
  }
54
-
55
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
56
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
57
  if ($tokens[$closeParenthesis + 1]['type'] == 'T_OPEN_SQUARE_BRACKET') {
25
  {
26
  return array(T_STRING);
27
  }//end register()
28
+
29
  /**
30
  * Processes this test, when one of its tokens is encountered.
31
  *
51
  // Not a call to a PHP function.
52
  return;
53
  }
54
+
55
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
56
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
57
  if ($tokens[$closeParenthesis + 1]['type'] == 'T_OPEN_SQUARE_BRACKET') {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php CHANGED
@@ -23,7 +23,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
-
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
@@ -33,19 +33,524 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
33
  *
34
  * @var array
35
  */
36
- public $newFunctionParameters = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  'dirname' => array(
38
  1 => array(
39
- 'name' => 'depth',
40
  '5.6' => false,
41
  '7.0' => true
42
  ),
43
  ),
44
- 'unserialize' => array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  1 => array(
46
  'name' => 'options',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  '5.6' => false,
48
- '7.0' => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ),
50
  ),
51
  'session_start' => array(
@@ -53,27 +558,163 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
53
  'name' => 'options',
54
  '5.6' => false,
55
  '7.0' => true
56
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ),
58
  'strstr' => array(
59
  2 => array(
60
  'name' => 'before_needle',
61
  '5.2' => false,
62
  '5.3' => true
63
- )
64
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  );
66
 
67
 
68
  /**
69
- * If true, an error will be thrown; otherwise a warning.
70
  *
71
- * @var bool
72
- */
73
- public $error = false;
74
-
75
- /**
76
- *
77
  * @var array
78
  */
79
  private $newFunctionParametersNames;
@@ -89,16 +730,16 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
89
  // Everyone has had a chance to figure out what forbidden functions
90
  // they want to check for, so now we can cache out the list.
91
  $this->newFunctionParametersNames = array_keys($this->newFunctionParameters);
92
-
93
  if ($this->patternMatch === true) {
94
  foreach ($this->newFunctionParametersNames as $i => $name) {
95
  $this->newFunctionParametersNames[$i] = '/'.$name.'/i';
96
  }
97
  }
98
-
99
  return array(T_STRING);
100
  }//end register()
101
-
102
  /**
103
  * Processes this test, when one of its tokens is encountered.
104
  *
@@ -130,34 +771,33 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
130
  if (in_array($function, $this->newFunctionParametersNames) === false) {
131
  return;
132
  }
133
-
134
- if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
135
- $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
136
-
137
- $nextComma = $stackPtr + 1;
138
- $cnt = 0;
139
- while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
140
- if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
141
- continue;
142
- }
143
- if (isset($this->newFunctionParameters[$function][$cnt])) {
144
- $this->addError($phpcsFile, $nextComma, $function, $cnt);
145
- }
146
- $cnt++;
147
  }
148
-
149
  }
 
150
  }//end process()
151
 
152
 
153
  /**
154
- * Generates the error or wanrning for this sniff.
155
  *
156
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
157
- * @param int $stackPtr The position of the function
158
- * in the token array.
159
- * @param string $function The name of the function.
160
- * @param string $pattern The pattern used for the match.
161
  *
162
  * @return void
163
  */
@@ -165,20 +805,19 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
165
  {
166
  $error = '';
167
 
168
- $this->error = false;
169
  foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
170
- if ($version != 'name' && $this->supportsBelow($version)) {
171
- if ($present === false) {
172
- $this->error = true;
173
- $error .= 'in PHP version ' . $version . ' or earlier';
174
- }
175
  }
176
  }
177
-
178
  if (strlen($error) > 0) {
179
- $error = 'The function ' . $function . ' does not have a parameter ' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;
180
 
181
- if ($this->error === true) {
182
  $phpcsFile->addError($error, $stackPtr);
183
  } else {
184
  $phpcsFile->addWarning($error, $stackPtr);
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
+
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
33
  *
34
  * @var array
35
  */
36
+ protected $newFunctionParameters = array(
37
+ 'array_filter' => array(
38
+ 2 => array(
39
+ 'name' => 'flag',
40
+ '5.5' => false,
41
+ '5.6' => true
42
+ ),
43
+ ),
44
+ 'array_slice' => array(
45
+ 1 => array(
46
+ 'name' => 'preserve_keys',
47
+ '5.0.1' => false,
48
+ '5.0.2' => true
49
+ ),
50
+ ),
51
+ 'array_unique' => array(
52
+ 1 => array(
53
+ 'name' => 'sort_flags',
54
+ '5.2.8' => false,
55
+ '5.2.9' => true
56
+ ),
57
+ ),
58
+ 'assert' => array(
59
+ 1 => array(
60
+ 'name' => 'description',
61
+ '5.4.7' => false,
62
+ '5.4.8' => true
63
+ ),
64
+ ),
65
+ 'base64_decode' => array(
66
+ 1 => array(
67
+ 'name' => 'strict',
68
+ '5.1' => false,
69
+ '5.2' => true
70
+ ),
71
+ ),
72
+ 'class_implements' => array(
73
+ 1 => array(
74
+ 'name' => 'autoload',
75
+ '5.0' => false,
76
+ '5.1' => true
77
+ ),
78
+ ),
79
+ 'class_parents' => array(
80
+ 1 => array(
81
+ 'name' => 'autoload',
82
+ '5.0' => false,
83
+ '5.1' => true
84
+ ),
85
+ ),
86
+ 'clearstatcache' => array(
87
+ 0 => array(
88
+ 'name' => 'clear_realpath_cache',
89
+ '5.2' => false,
90
+ '5.3' => true
91
+ ),
92
+ 1 => array(
93
+ 'name' => 'filename',
94
+ '5.2' => false,
95
+ '5.3' => true
96
+ ),
97
+ ),
98
+ 'copy' => array(
99
+ 2 => array(
100
+ 'name' => 'context',
101
+ '5.2' => false,
102
+ '5.3' => true
103
+ ),
104
+ ),
105
+ 'curl_multi_info_read' => array(
106
+ 1 => array(
107
+ 'name' => 'msgs_in_queue',
108
+ '5.1' => false,
109
+ '5.2' => true
110
+ ),
111
+ ),
112
+ 'debug_backtrace' => array(
113
+ 0 => array(
114
+ 'name' => 'options',
115
+ '5.2.4' => false,
116
+ '5.2.5' => true
117
+ ),
118
+ 1 => array(
119
+ 'name' => 'limit',
120
+ '5.3' => false,
121
+ '5.4' => true
122
+ ),
123
+ ),
124
+ 'debug_print_backtrace' => array(
125
+ 0 => array(
126
+ 'name' => 'options',
127
+ '5.3.5' => false,
128
+ '5.3.6' => true
129
+ ),
130
+ 1 => array(
131
+ 'name' => 'limit',
132
+ '5.3' => false,
133
+ '5.4' => true
134
+ ),
135
+ ),
136
  'dirname' => array(
137
  1 => array(
138
+ 'name' => 'levels',
139
  '5.6' => false,
140
  '7.0' => true
141
  ),
142
  ),
143
+ 'dns_get_record' => array(
144
+ 4 => array(
145
+ 'name' => 'raw',
146
+ '5.3' => false,
147
+ '5.4' => true
148
+ ),
149
+ ),
150
+ 'fgetcsv' => array(
151
+ 4 => array(
152
+ 'name' => 'escape',
153
+ '5.2' => false,
154
+ '5.3' => true
155
+ ),
156
+ ),
157
+ 'fputcsv' => array(
158
+ 4 => array(
159
+ 'name' => 'escape_char',
160
+ '5.5.3' => false,
161
+ '5.5.4' => true
162
+ ),
163
+ ),
164
+ 'file_get_contents' => array(
165
+ 3 => array(
166
+ 'name' => 'offset',
167
+ '5.0' => false,
168
+ '5.1' => true
169
+ ),
170
+ 4 => array(
171
+ 'name' => 'maxlen',
172
+ '5.0' => false,
173
+ '5.1' => true
174
+ ),
175
+ ),
176
+ 'filter_input_array' => array(
177
+ 2 => array(
178
+ 'name' => 'add_empty',
179
+ '5.3' => false,
180
+ '5.4' => true
181
+ ),
182
+ ),
183
+ 'filter_var_array' => array(
184
+ 2 => array(
185
+ 'name' => 'add_empty',
186
+ '5.3' => false,
187
+ '5.4' => true
188
+ ),
189
+ ),
190
+ 'gettimeofday' => array(
191
+ 0 => array(
192
+ 'name' => 'return_float',
193
+ '5.0' => false,
194
+ '5.1' => true
195
+ ),
196
+ ),
197
+ 'get_html_translation_table' => array(
198
+ 2 => array(
199
+ 'name' => 'encoding',
200
+ '5.3.3' => false,
201
+ '5.3.4' => true
202
+ ),
203
+ ),
204
+ 'get_loaded_extensions' => array(
205
+ 0 => array(
206
+ 'name' => 'zend_extensions',
207
+ '5.2.3' => false,
208
+ '5.2.4' => true
209
+ ),
210
+ ),
211
+ 'gzcompress' => array(
212
+ 2 => array(
213
+ 'name' => 'encoding',
214
+ '5.3' => false,
215
+ '5.4' => true
216
+ ),
217
+ ),
218
+ 'gzdeflate' => array(
219
+ 2 => array(
220
+ 'name' => 'encoding',
221
+ '5.3' => false,
222
+ '5.4' => true
223
+ ),
224
+ ),
225
+ 'htmlentities' => array(
226
+ 3 => array(
227
+ 'name' => 'double_encode',
228
+ '5.2.2' => false,
229
+ '5.2.3' => true
230
+ ),
231
+ ),
232
+ 'htmlspecialchars' => array(
233
+ 3 => array(
234
+ 'name' => 'double_encode',
235
+ '5.2.2' => false,
236
+ '5.2.3' => true
237
+ ),
238
+ ),
239
+ 'http_build_query' => array(
240
+ 2 => array(
241
+ 'name' => 'arg_separator',
242
+ '5.1.1' => false,
243
+ '5.1.2' => true
244
+ ),
245
+ 3 => array(
246
+ 'name' => 'enc_type',
247
+ '5.3' => false,
248
+ '5.4' => true
249
+ ),
250
+ ),
251
+ 'idn_to_ascii' => array(
252
+ 2 => array(
253
+ 'name' => 'variant',
254
+ '5.3' => false,
255
+ '5.4' => true
256
+ ),
257
+ 3 => array(
258
+ 'name' => 'idna_info',
259
+ '5.3' => false,
260
+ '5.4' => true
261
+ ),
262
+ ),
263
+ 'idn_to_utf8' => array(
264
+ 2 => array(
265
+ 'name' => 'variant',
266
+ '5.3' => false,
267
+ '5.4' => true
268
+ ),
269
+ 3 => array(
270
+ 'name' => 'idna_info',
271
+ '5.3' => false,
272
+ '5.4' => true
273
+ ),
274
+ ),
275
+ 'imagecolorset' => array(
276
+ 5 => array(
277
+ 'name' => 'alpha',
278
+ '5.3' => false,
279
+ '5.4' => true
280
+ ),
281
+ ),
282
+ 'imagepng' => array(
283
+ 2 => array(
284
+ 'name' => 'quality',
285
+ '5.1.1' => false,
286
+ '5.1.2' => true
287
+ ),
288
+ 3 => array(
289
+ 'name' => 'filters',
290
+ '5.1.2' => false,
291
+ '5.1.3' => true
292
+ ),
293
+ ),
294
+ 'imagerotate' => array(
295
+ 3 => array(
296
+ 'name' => 'ignore_transparent',
297
+ '5.0' => false,
298
+ '5.1' => true
299
+ ),
300
+ ),
301
+ 'imap_open' => array(
302
+ 4 => array(
303
+ 'name' => 'n_retries',
304
+ '5.1' => false,
305
+ '5.2' => true
306
+ ),
307
+ 5 => array(
308
+ 'name' => 'params',
309
+ '5.3.1' => false,
310
+ '5.3.2' => true
311
+ ),
312
+ ),
313
+ 'imap_reopen' => array(
314
+ 3 => array(
315
+ 'name' => 'n_retries',
316
+ '5.1' => false,
317
+ '5.2' => true
318
+ ),
319
+ ),
320
+ 'ini_get_all' => array(
321
+ 1 => array(
322
+ 'name' => 'details',
323
+ '5.2' => false,
324
+ '5.3' => true
325
+ ),
326
+ ),
327
+ 'is_a' => array(
328
+ 2 => array(
329
+ 'name' => 'allow_string',
330
+ '5.3.8' => false,
331
+ '5.3.9' => true
332
+ ),
333
+ ),
334
+ 'is_subclass_of' => array(
335
+ 2 => array(
336
+ 'name' => 'allow_string',
337
+ '5.3.8' => false,
338
+ '5.3.9' => true
339
+ ),
340
+ ),
341
+ 'iterator_to_array' => array(
342
+ 1 => array(
343
+ 'name' => 'use_keys',
344
+ '5.2' => false,
345
+ '5.2.1' => true
346
+ ),
347
+ ),
348
+ 'json_decode' => array(
349
+ 2 => array(
350
+ 'name' => 'depth',
351
+ '5.2' => false,
352
+ '5.3' => true
353
+ ),
354
+ 3 => array(
355
+ 'name' => 'options',
356
+ '5.3' => false,
357
+ '5.4' => true
358
+ ),
359
+ ),
360
+ 'json_encode' => array(
361
  1 => array(
362
  'name' => 'options',
363
+ '5.2' => false,
364
+ '5.3' => true
365
+ ),
366
+ 2 => array(
367
+ 'name' => 'depth',
368
+ '5.4' => false,
369
+ '5.5' => true
370
+ ),
371
+ ),
372
+ 'memory_get_peak_usage' => array(
373
+ 0 => array(
374
+ 'name' => 'real_usage',
375
+ '5.1' => false,
376
+ '5.2' => true
377
+ ),
378
+ ),
379
+ 'memory_get_usage' => array(
380
+ 0 => array(
381
+ 'name' => 'real_usage',
382
+ '5.1' => false,
383
+ '5.2' => true
384
+ ),
385
+ ),
386
+ 'mb_encode_numericentity' => array(
387
+ 3 => array(
388
+ 'name' => 'is_hex',
389
+ '5.3' => false,
390
+ '5.4' => true
391
+ ),
392
+ ),
393
+ 'mb_strrpos' => array(
394
+ /*
395
+ * Note: the actual position is 2, but the original 3rd
396
+ * parameter 'encoding' was moved to the 4th position.
397
+ * So the only way to detect if offset is used is when
398
+ * both offset and encoding are set.
399
+ */
400
+ 3 => array(
401
+ 'name' => 'offset',
402
+ '5.1' => false,
403
+ '5.2' => true
404
+ ),
405
+ ),
406
+ 'mssql_connect' => array(
407
+ 3 => array(
408
+ 'name' => 'new_link',
409
+ '5.0' => false,
410
+ '5.1' => true
411
+ ),
412
+ ),
413
+ 'mysqli_commit' => array(
414
+ 1 => array(
415
+ 'name' => 'flags',
416
+ '5.4' => false,
417
+ '5.5' => true
418
+ ),
419
+ 2 => array(
420
+ 'name' => 'name',
421
+ '5.4' => false,
422
+ '5.5' => true
423
+ ),
424
+ ),
425
+ 'mysqli_rollback' => array(
426
+ 1 => array(
427
+ 'name' => 'flags',
428
+ '5.4' => false,
429
+ '5.5' => true
430
+ ),
431
+ 2 => array(
432
+ 'name' => 'name',
433
+ '5.4' => false,
434
+ '5.5' => true
435
+ ),
436
+ ),
437
+ 'nl2br' => array(
438
+ 1 => array(
439
+ 'name' => 'is_xhtml',
440
+ '5.2' => false,
441
+ '5.3' => true
442
+ ),
443
+ ),
444
+ 'openssl_decrypt' => array(
445
+ 4 => array(
446
+ 'name' => 'iv',
447
+ '5.3.2' => false,
448
+ '5.3.3' => true
449
+ ),
450
+ ),
451
+ 'openssl_encrypt' => array(
452
+ 4 => array(
453
+ 'name' => 'iv',
454
+ '5.3.2' => false,
455
+ '5.3.3' => true
456
+ ),
457
+ ),
458
+ 'openssl_pkcs7_verify' => array(
459
+ 5 => array(
460
+ 'name' => 'content',
461
+ '5.0' => false,
462
+ '5.1' => true
463
+ ),
464
+ ),
465
+ 'openssl_seal' => array(
466
+ 4 => array(
467
+ 'name' => 'method',
468
+ '5.2' => false,
469
+ '5.3' => true
470
+ ),
471
+ ),
472
+ 'openssl_verify' => array(
473
+ 3 => array(
474
+ 'name' => 'signature_alg',
475
+ '5.1' => false,
476
+ '5.2' => true
477
+ ),
478
+ ),
479
+ 'parse_ini_file' => array(
480
+ 2 => array(
481
+ 'name' => 'scanner_mode',
482
+ '5.2' => false,
483
+ '5.3' => true
484
+ ),
485
+ ),
486
+ 'parse_url' => array(
487
+ 1 => array(
488
+ 'name' => 'component',
489
+ '5.1.1' => false,
490
+ '5.1.2' => true
491
+ ),
492
+ ),
493
+ 'pg_lo_create' => array(
494
+ 1 => array(
495
+ 'name' => 'object_id',
496
+ '5.2' => false,
497
+ '5.3' => true
498
+ ),
499
+ ),
500
+ 'pg_lo_import' => array(
501
+ 2 => array(
502
+ 'name' => 'object_id',
503
+ '5.2' => false,
504
+ '5.3' => true
505
+ ),
506
+ ),
507
+ 'preg_replace' => array(
508
+ 4 => array(
509
+ 'name' => 'count',
510
+ '5.0' => false,
511
+ '5.1' => true
512
+ ),
513
+ ),
514
+ 'preg_replace_callback' => array(
515
+ 4 => array(
516
+ 'name' => 'count',
517
+ '5.0' => false,
518
+ '5.1' => true
519
+ ),
520
+ ),
521
+ 'round' => array(
522
+ 2 => array(
523
+ 'name' => 'mode',
524
+ '5.2' => false,
525
+ '5.3' => true
526
+ ),
527
+ ),
528
+ 'sem_acquire' => array(
529
+ 1 => array(
530
+ 'name' => 'nowait',
531
  '5.6' => false,
532
+ '5.6.1' => true
533
+ ),
534
+ ),
535
+ 'session_regenerate_id' => array(
536
+ 0 => array(
537
+ 'name' => 'delete_old_session',
538
+ '5.0' => false,
539
+ '5.1' => true
540
+ ),
541
+ ),
542
+ 'session_set_cookie_params' => array(
543
+ 4 => array(
544
+ 'name' => 'httponly',
545
+ '5.1' => false,
546
+ '5.2' => true
547
+ ),
548
+ ),
549
+ 'session_set_save_handler' => array(
550
+ 6 => array(
551
+ 'name' => 'create_sid',
552
+ '5.5' => false,
553
+ '5.5.1' => true
554
  ),
555
  ),
556
  'session_start' => array(
558
  'name' => 'options',
559
  '5.6' => false,
560
  '7.0' => true
561
+ ),
562
+ ),
563
+ 'setcookie' => array(
564
+ 6 => array(
565
+ 'name' => 'httponly',
566
+ '5.1' => false,
567
+ '5.2' => true
568
+ ),
569
+ ),
570
+ 'setrawcookie' => array(
571
+ 6 => array(
572
+ 'name' => 'httponly',
573
+ '5.1' => false,
574
+ '5.2' => true
575
+ ),
576
+ ),
577
+ 'simplexml_load_file' => array(
578
+ 4 => array(
579
+ 'name' => 'is_prefix',
580
+ '5.1' => false,
581
+ '5.2' => true
582
+ ),
583
+ ),
584
+ 'simplexml_load_string' => array(
585
+ 4 => array(
586
+ 'name' => 'is_prefix',
587
+ '5.1' => false,
588
+ '5.2' => true
589
+ ),
590
+ ),
591
+ 'spl_autoload_register' => array(
592
+ 2 => array(
593
+ 'name' => 'prepend',
594
+ '5.2' => false,
595
+ '5.3' => true
596
+ ),
597
+ ),
598
+ 'stream_context_create' => array(
599
+ 1 => array(
600
+ 'name' => 'params',
601
+ '5.2' => false,
602
+ '5.3' => true
603
+ ),
604
+ ),
605
+ 'stream_copy_to_stream' => array(
606
+ 3 => array(
607
+ 'name' => 'offset',
608
+ '5.0' => false,
609
+ '5.1' => true
610
+ ),
611
+ ),
612
+ 'stream_get_contents' => array(
613
+ 2 => array(
614
+ 'name' => 'offset',
615
+ '5.0' => false,
616
+ '5.1' => true
617
+ ),
618
+ ),
619
+ 'stream_wrapper_register' => array(
620
+ 2 => array(
621
+ 'name' => 'flags',
622
+ '5.2.3' => false,
623
+ '5.2.4' => true
624
+ ),
625
+ ),
626
+ 'stristr' => array(
627
+ 2 => array(
628
+ 'name' => 'before_needle',
629
+ '5.2' => false,
630
+ '5.3' => true
631
+ ),
632
  ),
633
  'strstr' => array(
634
  2 => array(
635
  'name' => 'before_needle',
636
  '5.2' => false,
637
  '5.3' => true
638
+ ),
639
+ ),
640
+ 'str_word_count' => array(
641
+ 2 => array(
642
+ 'name' => 'charlist',
643
+ '5.0' => false,
644
+ '5.1' => true
645
+ ),
646
+ ),
647
+ 'substr_count' => array(
648
+ 2 => array(
649
+ 'name' => 'offset',
650
+ '5.0' => false,
651
+ '5.1' => true
652
+ ),
653
+ 3 => array(
654
+ 'name' => 'length',
655
+ '5.0' => false,
656
+ '5.1' => true
657
+ ),
658
+ ),
659
+ 'sybase_connect' => array(
660
+ 5 => array(
661
+ 'name' => 'new',
662
+ '5.2' => false,
663
+ '5.3' => true
664
+ ),
665
+ ),
666
+ 'timezone_transitions_get' => array(
667
+ 1 => array(
668
+ 'name' => 'timestamp_begin',
669
+ '5.2' => false,
670
+ '5.3' => true
671
+ ),
672
+ 2 => array(
673
+ 'name' => 'timestamp_end',
674
+ '5.2' => false,
675
+ '5.3' => true
676
+ ),
677
+ ),
678
+ 'timezone_identifiers_list' => array(
679
+ 0 => array(
680
+ 'name' => 'what',
681
+ '5.2' => false,
682
+ '5.3' => true
683
+ ),
684
+ 1 => array(
685
+ 'name' => 'country',
686
+ '5.2' => false,
687
+ '5.3' => true
688
+ ),
689
+ ),
690
+ 'token_get_all' => array(
691
+ 1 => array(
692
+ 'name' => 'flags',
693
+ '5.6' => false,
694
+ '7.0' => true
695
+ ),
696
+ ),
697
+ 'ucwords' => array(
698
+ 1 => array(
699
+ 'name' => 'delimiters',
700
+ '5.4.31' => false,
701
+ '5.5.15' => false,
702
+ '5.4.32' => true,
703
+ '5.5.16' => true
704
+ ),
705
+ ),
706
+ 'unserialize' => array(
707
+ 1 => array(
708
+ 'name' => 'options',
709
+ '5.6' => false,
710
+ '7.0' => true
711
+ ),
712
+ ),
713
  );
714
 
715
 
716
  /**
 
717
  *
 
 
 
 
 
 
718
  * @var array
719
  */
720
  private $newFunctionParametersNames;
730
  // Everyone has had a chance to figure out what forbidden functions
731
  // they want to check for, so now we can cache out the list.
732
  $this->newFunctionParametersNames = array_keys($this->newFunctionParameters);
733
+
734
  if ($this->patternMatch === true) {
735
  foreach ($this->newFunctionParametersNames as $i => $name) {
736
  $this->newFunctionParametersNames[$i] = '/'.$name.'/i';
737
  }
738
  }
739
+
740
  return array(T_STRING);
741
  }//end register()
742
+
743
  /**
744
  * Processes this test, when one of its tokens is encountered.
745
  *
771
  if (in_array($function, $this->newFunctionParametersNames) === false) {
772
  return;
773
  }
774
+
775
+ $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
776
+ if ($parameterCount === 0) {
777
+ return;
778
+ }
779
+
780
+ // If the parameter count returned > 0, we know there will be valid open parenthesis.
781
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
782
+ $parameterOffsetFound = $parameterCount - 1;
783
+
784
+ foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) {
785
+ if ($offset <= $parameterOffsetFound) {
786
+ $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
787
  }
 
788
  }
789
+
790
  }//end process()
791
 
792
 
793
  /**
794
+ * Generates the error or warning for this sniff.
795
  *
796
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
797
+ * @param int $stackPtr The position of the function
798
+ * in the token array.
799
+ * @param string $function The name of the function.
800
+ * @param int $parameterLocation The parameter position within the function call.
801
  *
802
  * @return void
803
  */
805
  {
806
  $error = '';
807
 
808
+ $isError = false;
809
  foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
810
+ if ($version != 'name' && $present === false && $this->supportsBelow($version)) {
811
+ $isError = true;
812
+ $error .= 'in PHP version ' . $version . ' or earlier';
813
+ break;
 
814
  }
815
  }
816
+
817
  if (strlen($error) > 0) {
818
+ $error = 'The function ' . $function . ' does not have a parameter "' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . '" ' . $error;
819
 
820
+ if ($isError === true) {
821
  $phpcsFile->addError($error, $stackPtr);
822
  } else {
823
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php CHANGED
@@ -23,7 +23,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
-
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
@@ -32,7 +32,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
32
  *
33
  * @var array(string => array(string => int|string|null))
34
  */
35
- public $forbiddenFunctions = array(
36
  'array_fill_keys' => array(
37
  '5.1' => false,
38
  '5.2' => true
@@ -105,14 +105,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
105
  '5.1' => false,
106
  '5.2' => true
107
  ),
108
- 'swfmovie::namedanchor' => array(
109
- '5.1' => false,
110
- '5.2' => true
111
- ),
112
- 'swfmovie::protect' => array(
113
- '5.1' => false,
114
- '5.2' => true
115
- ),
116
  'openssl_csr_get_public_key' => array(
117
  '5.1' => false,
118
  '5.2' => true
@@ -322,14 +314,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
322
  '5.2' => false,
323
  '5.3' => true
324
  ),
325
- 'streamWrapper::stream_cast' => array(
326
- '5.2' => false,
327
- '5.3' => true
328
- ),
329
- 'streamWrapper::stream_set_option' => array(
330
- '5.2' => false,
331
- '5.3' => true
332
- ),
333
  'date_add' => array(
334
  '5.2' => false,
335
  '5.3' => true
@@ -382,6 +366,10 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
382
  '5.2' => false,
383
  '5.3' => true
384
  ),
 
 
 
 
385
  'mysqli_fetch_all' => array(
386
  '5.2' => false,
387
  '5.3' => true
@@ -434,6 +422,22 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
434
  '5.2' => false,
435
  '5.3' => true
436
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  'enchant_broker_describe' => array(
438
  '5.2' => false,
439
  '5.3' => true
@@ -1080,14 +1084,83 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1080
  '5.4' => false,
1081
  '5.5' => true
1082
  ),
1083
- 'SplFixedArray::_wakup' => array(
1084
- '5.4' => false,
1085
- '5.5' => true
 
1086
  ),
1087
- 'Closure::call' => array(
1088
- '5.6' => false,
1089
- '7.0' => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1090
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1091
  'random_bytes' => array(
1092
  '5.6' => false,
1093
  '7.0' => true
@@ -1100,10 +1173,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1100
  '5.6' => false,
1101
  '7.0' => true
1102
  ),
1103
- 'Generator::getReturn' => array(
1104
- '5.6' => false,
1105
- '7.0' => true
1106
- ),
1107
  'gmp_random_seed' => array(
1108
  '5.6' => false,
1109
  '7.0' => true
@@ -1128,34 +1197,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1128
  '5.6' => false,
1129
  '7.0' => true
1130
  ),
1131
- 'ReflectionParameter::getType' => array(
1132
- '5.6' => false,
1133
- '7.0' => true
1134
- ),
1135
- '' => array(
1136
- '5.6' => false,
1137
- '7.0' => true
1138
- ),
1139
- 'ReflectionParameter::hasType' => array(
1140
- '5.6' => false,
1141
- '7.0' => true
1142
- ),
1143
- 'ReflectionFunctionAbstract::getReturnType' => array(
1144
- '5.6' => false,
1145
- '7.0' => true
1146
- ),
1147
- 'ReflectionFunctionAbstract::hasReturnType' => array(
1148
- '5.6' => false,
1149
- '7.0' => true
1150
- ),
1151
- 'ZipArchive::setCompressionIndex' => array(
1152
- '5.6' => false,
1153
- '7.0' => true
1154
- ),
1155
- 'ZipArchive::setCompressionName' => array(
1156
- '5.6' => false,
1157
- '7.0' => true
1158
- ),
1159
  'inflate_add' => array(
1160
  '5.6' => false,
1161
  '7.0' => true
@@ -1176,18 +1217,11 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1176
 
1177
 
1178
  /**
1179
- * If true, an error will be thrown; otherwise a warning.
1180
  *
1181
- * @var bool
1182
- */
1183
- public $error = false;
1184
-
1185
- /**
1186
- *
1187
- * @var unknown
1188
  */
1189
  private $forbiddenFunctionNames;
1190
-
1191
 
1192
  /**
1193
  * Returns an array of tokens this test wants to listen for.
@@ -1199,17 +1233,19 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1199
  // Everyone has had a chance to figure out what forbidden functions
1200
  // they want to check for, so now we can cache out the list.
1201
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
1202
-
 
 
1203
  if ($this->patternMatch === true) {
1204
  foreach ($this->forbiddenFunctionNames as $i => $name) {
1205
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
1206
  }
1207
  }
1208
-
1209
  return array(T_STRING);
1210
-
1211
  }//end register()
1212
-
1213
  /**
1214
  * Processes this test, when one of its tokens is encountered.
1215
  *
@@ -1235,6 +1271,10 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1235
  // Not a call to a PHP function.
1236
  return;
1237
  }
 
 
 
 
1238
 
1239
  $function = strtolower($tokens[$stackPtr]['content']);
1240
  $pattern = null;
@@ -1243,7 +1283,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1243
  $count = 0;
1244
  $pattern = preg_replace(
1245
  $this->forbiddenFunctionNames,
1246
- $this->forbiddenFunctionsNames,
1247
  $function,
1248
  1,
1249
  $count
@@ -1261,13 +1301,13 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1261
  }
1262
  }
1263
 
1264
- $this->addError($phpcsFile, $stackPtr, $function, $pattern);
1265
 
1266
  }//end process()
1267
 
1268
 
1269
  /**
1270
- * Generates the error or wanrning for this sniff.
1271
  *
1272
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
1273
  * @param int $stackPtr The position of the function
@@ -1280,16 +1320,16 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1280
  protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
1281
  {
1282
  if ($pattern === null) {
1283
- $pattern = $function;
1284
  }
1285
 
1286
  $error = '';
1287
 
1288
- $this->error = false;
1289
  foreach ($this->forbiddenFunctions[$pattern] as $version => $present) {
1290
  if ($this->supportsBelow($version)) {
1291
  if ($present === false) {
1292
- $this->error = true;
1293
  $error .= 'not present in PHP version ' . $version . ' or earlier';
1294
  }
1295
  }
@@ -1297,7 +1337,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1297
  if (strlen($error) > 0) {
1298
  $error = 'The function ' . $function . ' is ' . $error;
1299
 
1300
- if ($this->error === true) {
1301
  $phpcsFile->addError($error, $stackPtr);
1302
  } else {
1303
  $phpcsFile->addWarning($error, $stackPtr);
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
+
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
32
  *
33
  * @var array(string => array(string => int|string|null))
34
  */
35
+ protected $forbiddenFunctions = array(
36
  'array_fill_keys' => array(
37
  '5.1' => false,
38
  '5.2' => true
105
  '5.1' => false,
106
  '5.2' => true
107
  ),
 
 
 
 
 
 
 
 
108
  'openssl_csr_get_public_key' => array(
109
  '5.1' => false,
110
  '5.2' => true
314
  '5.2' => false,
315
  '5.3' => true
316
  ),
 
 
 
 
 
 
 
 
317
  'date_add' => array(
318
  '5.2' => false,
319
  '5.3' => true
366
  '5.2' => false,
367
  '5.3' => true
368
  ),
369
+ 'mysqli_get_cache_stats' => array(
370
+ '5.2' => false,
371
+ '5.3' => true
372
+ ),
373
  'mysqli_fetch_all' => array(
374
  '5.2' => false,
375
  '5.3' => true
422
  '5.2' => false,
423
  '5.3' => true
424
  ),
425
+ 'asinh' => array(
426
+ '5.2' => false,
427
+ '5.3' => true
428
+ ),
429
+ 'atanh' => array(
430
+ '5.2' => false,
431
+ '5.3' => true
432
+ ),
433
+ 'expm1' => array(
434
+ '5.2' => false,
435
+ '5.3' => true
436
+ ),
437
+ 'log1p' => array(
438
+ '5.2' => false,
439
+ '5.3' => true
440
+ ),
441
  'enchant_broker_describe' => array(
442
  '5.2' => false,
443
  '5.3' => true
1084
  '5.4' => false,
1085
  '5.5' => true
1086
  ),
1087
+
1088
+ 'gmp_root' => array(
1089
+ '5.5' => false,
1090
+ '5.6' => true
1091
  ),
1092
+ 'gmp_rootrem' => array(
1093
+ '5.5' => false,
1094
+ '5.6' => true
1095
+ ),
1096
+ 'hash_equals' => array(
1097
+ '5.5' => false,
1098
+ '5.6' => true
1099
+ ),
1100
+ 'ldap_escape' => array(
1101
+ '5.5' => false,
1102
+ '5.6' => true
1103
+ ),
1104
+ 'ldap_modify_batch' => array(
1105
+ '5.4.25' => false,
1106
+ '5.5.9' => false,
1107
+ '5.4.26' => true,
1108
+ '5.5.10' => true,
1109
+ '5.6.0' => true,
1110
+ ),
1111
+ 'mysqli_get_links_stats' => array(
1112
+ '5.5' => false,
1113
+ '5.6' => true
1114
+ ),
1115
+ 'openssl_get_cert_locations' => array(
1116
+ '5.5' => false,
1117
+ '5.6' => true
1118
+ ),
1119
+ 'openssl_x509_fingerprint' => array(
1120
+ '5.5' => false,
1121
+ '5.6' => true
1122
+ ),
1123
+ 'openssl_spki_new' => array(
1124
+ '5.5' => false,
1125
+ '5.6' => true
1126
+ ),
1127
+ 'openssl_spki_verify' => array(
1128
+ '5.5' => false,
1129
+ '5.6' => true
1130
+ ),
1131
+ 'openssl_spki_export_challenge' => array(
1132
+ '5.5' => false,
1133
+ '5.6' => true
1134
+ ),
1135
+ 'openssl_spki_export' => array(
1136
+ '5.5' => false,
1137
+ '5.6' => true
1138
  ),
1139
+ 'pg_connect_poll' => array(
1140
+ '5.5' => false,
1141
+ '5.6' => true
1142
+ ),
1143
+ 'pg_consume_input' => array(
1144
+ '5.5' => false,
1145
+ '5.6' => true
1146
+ ),
1147
+ 'pg_flush' => array(
1148
+ '5.5' => false,
1149
+ '5.6' => true
1150
+ ),
1151
+ 'pg_socket' => array(
1152
+ '5.5' => false,
1153
+ '5.6' => true
1154
+ ),
1155
+ 'session_abort' => array(
1156
+ '5.5' => false,
1157
+ '5.6' => true
1158
+ ),
1159
+ 'session_reset' => array(
1160
+ '5.5' => false,
1161
+ '5.6' => true
1162
+ ),
1163
+
1164
  'random_bytes' => array(
1165
  '5.6' => false,
1166
  '7.0' => true
1173
  '5.6' => false,
1174
  '7.0' => true
1175
  ),
 
 
 
 
1176
  'gmp_random_seed' => array(
1177
  '5.6' => false,
1178
  '7.0' => true
1197
  '5.6' => false,
1198
  '7.0' => true
1199
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1200
  'inflate_add' => array(
1201
  '5.6' => false,
1202
  '7.0' => true
1217
 
1218
 
1219
  /**
 
1220
  *
1221
+ * @var array
 
 
 
 
 
 
1222
  */
1223
  private $forbiddenFunctionNames;
1224
+
1225
 
1226
  /**
1227
  * Returns an array of tokens this test wants to listen for.
1233
  // Everyone has had a chance to figure out what forbidden functions
1234
  // they want to check for, so now we can cache out the list.
1235
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
1236
+ $this->forbiddenFunctionNames = array_map('strtolower', $this->forbiddenFunctionNames);
1237
+ $this->forbiddenFunctions = array_combine($this->forbiddenFunctionNames, $this->forbiddenFunctions);
1238
+
1239
  if ($this->patternMatch === true) {
1240
  foreach ($this->forbiddenFunctionNames as $i => $name) {
1241
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
1242
  }
1243
  }
1244
+
1245
  return array(T_STRING);
1246
+
1247
  }//end register()
1248
+
1249
  /**
1250
  * Processes this test, when one of its tokens is encountered.
1251
  *
1271
  // Not a call to a PHP function.
1272
  return;
1273
  }
1274
+ else if($tokens[$prevToken]['code'] === T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === T_STRING) {
1275
+ // Namespaced function.
1276
+ return;
1277
+ }
1278
 
1279
  $function = strtolower($tokens[$stackPtr]['content']);
1280
  $pattern = null;
1283
  $count = 0;
1284
  $pattern = preg_replace(
1285
  $this->forbiddenFunctionNames,
1286
+ $this->forbiddenFunctionNames,
1287
  $function,
1288
  1,
1289
  $count
1301
  }
1302
  }
1303
 
1304
+ $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content'], $pattern);
1305
 
1306
  }//end process()
1307
 
1308
 
1309
  /**
1310
+ * Generates the error or warning for this sniff.
1311
  *
1312
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
1313
  * @param int $stackPtr The position of the function
1320
  protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
1321
  {
1322
  if ($pattern === null) {
1323
+ $pattern = strtolower($function);
1324
  }
1325
 
1326
  $error = '';
1327
 
1328
+ $isError = false;
1329
  foreach ($this->forbiddenFunctions[$pattern] as $version => $present) {
1330
  if ($this->supportsBelow($version)) {
1331
  if ($present === false) {
1332
+ $isError = true;
1333
  $error .= 'not present in PHP version ' . $version . ' or earlier';
1334
  }
1335
  }
1337
  if (strlen($error) > 0) {
1338
  $error = 'The function ' . $function . ' is ' . $error;
1339
 
1340
+ if ($isError === true) {
1341
  $phpcsFile->addError($error, $stackPtr);
1342
  } else {
1343
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php CHANGED
@@ -28,10 +28,178 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
28
  * @var array(string)
29
  */
30
  protected $newIniDirectives = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  'allow_url_include' => array(
32
  '5.1' => false,
33
  '5.2' => true
34
  ),
 
 
 
 
 
 
 
 
35
  'pcre.backtrack_limit' => array(
36
  '5.1' => false,
37
  '5.2' => true
@@ -44,21 +212,52 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
44
  '5.1' => false,
45
  '5.2' => true
46
  ),
 
 
 
 
 
 
 
47
  'max_input_nesting_level' => array(
48
  '5.1' => false,
49
  '5.2' => false,
50
- '5.2.2' => true
51
  ),
52
 
53
- 'user_ini.filename' => array(
 
 
 
 
 
 
 
 
 
 
 
 
54
  '5.2' => false,
55
  '5.3' => true,
56
  ),
57
- 'user_ini.cache_ttl' => array(
58
  '5.2' => false,
59
  '5.3' => true,
60
  ),
61
- 'exit_on_timeout' => array(
 
 
 
 
 
 
 
 
 
 
 
 
62
  '5.2' => false,
63
  '5.3' => true,
64
  ),
@@ -66,10 +265,72 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
66
  '5.2' => false,
67
  '5.3' => true,
68
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  'request_order' => array(
70
  '5.2' => false,
71
  '5.3' => true,
72
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  'cli.pager' => array(
75
  '5.3' => false,
@@ -83,19 +344,23 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
83
  '5.3' => false,
84
  '5.4' => true,
85
  ),
86
- 'max_input_vars' => array(
87
  '5.3' => false,
88
  '5.4' => true,
89
  ),
90
- 'zend.multibyte' => array(
91
  '5.3' => false,
92
  '5.4' => true,
93
  ),
94
- 'zend.script_encoding' => array(
95
  '5.3' => false,
96
  '5.4' => true,
97
  ),
98
- 'zend.signal_check' => array(
 
 
 
 
99
  '5.3' => false,
100
  '5.4' => true,
101
  ),
@@ -119,7 +384,7 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
119
  '5.3' => false,
120
  '5.4' => true,
121
  ),
122
- 'enable_post_data_reading' => array(
123
  '5.3' => false,
124
  '5.4' => true,
125
  ),
@@ -127,6 +392,27 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
127
  '5.3' => false,
128
  '5.4' => true,
129
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  'intl.use_exceptions' => array(
132
  '5.4' => false,
@@ -136,7 +422,46 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
136
  '5.4' => false,
137
  '5.5' => true,
138
  ),
 
 
 
 
 
 
 
 
 
 
 
 
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  );
141
 
142
  /**
@@ -180,25 +505,30 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
180
  if ($function != 'ini_get' && $function != 'ini_set') {
181
  return;
182
  }
183
- $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
184
 
185
- $filteredToken = str_replace(array('"', "'"), array("", ""), $tokens[$iniToken]['content']);
186
- if (in_array($filteredToken, array_keys($this->newIniDirectives)) === false) {
 
187
  return;
188
  }
189
 
190
  $error = '';
191
 
192
  foreach ($this->newIniDirectives[$filteredToken] as $version => $present) {
193
- if ($this->supportsBelow($version)) {
194
- if ($present === true) {
195
- $error .= " not available before version " . $version;
 
 
196
  }
197
  }
198
  }
199
 
200
  if (strlen($error) > 0) {
201
  $error = "INI directive '" . $filteredToken . "' is" . $error;
 
 
 
202
 
203
  $phpcsFile->addWarning($error, $stackPtr);
204
  }
@@ -206,4 +536,4 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
206
  }//end process()
207
 
208
 
209
- }//end class
28
  * @var array(string)
29
  */
30
  protected $newIniDirectives = array(
31
+ 'auto_globals_jit' => array(
32
+ '4.4' => false,
33
+ '5.0' => true,
34
+ ),
35
+ 'com.code_page' => array(
36
+ '4.4' => false,
37
+ '5.0' => true,
38
+ ),
39
+ 'date.default_latitude' => array(
40
+ '4.4' => false,
41
+ '5.0' => true,
42
+ ),
43
+ 'date.default_longitude' => array(
44
+ '4.4' => false,
45
+ '5.0' => true,
46
+ ),
47
+ 'date.sunrise_zenith' => array(
48
+ '4.4' => false,
49
+ '5.0' => true,
50
+ ),
51
+ 'date.sunset_zenith' => array(
52
+ '4.4' => false,
53
+ '5.0' => true,
54
+ ),
55
+ 'ibase.default_charset' => array(
56
+ '4.4' => false,
57
+ '5.0' => true,
58
+ ),
59
+ 'ibase.default_db' => array(
60
+ '4.4' => false,
61
+ '5.0' => true,
62
+ ),
63
+ 'mail.force_extra_parameters' => array(
64
+ '4.4' => false,
65
+ '5.0' => true,
66
+ ),
67
+ 'mime_magic.debug' => array(
68
+ '4.4' => false,
69
+ '5.0' => true,
70
+ ),
71
+ 'mysqli.max_links' => array(
72
+ '4.4' => false,
73
+ '5.0' => true,
74
+ ),
75
+ 'mysqli.default_port' => array(
76
+ '4.4' => false,
77
+ '5.0' => true,
78
+ ),
79
+ 'mysqli.default_socket' => array(
80
+ '4.4' => false,
81
+ '5.0' => true,
82
+ ),
83
+ 'mysqli.default_host' => array(
84
+ '4.4' => false,
85
+ '5.0' => true,
86
+ ),
87
+ 'mysqli.default_user' => array(
88
+ '4.4' => false,
89
+ '5.0' => true,
90
+ ),
91
+ 'mysqli.default_pw' => array(
92
+ '4.4' => false,
93
+ '5.0' => true,
94
+ ),
95
+ 'report_zend_debug' => array(
96
+ '4.4' => false,
97
+ '5.0' => true,
98
+ ),
99
+ 'session.hash_bits_per_character' => array(
100
+ '4.4' => false,
101
+ '5.0' => true,
102
+ ),
103
+ 'session.hash_function' => array(
104
+ '4.4' => false,
105
+ '5.0' => true,
106
+ ),
107
+ 'soap.wsdl_cache_dir' => array(
108
+ '4.4' => false,
109
+ '5.0' => true,
110
+ ),
111
+ 'soap.wsdl_cache_enabled' => array(
112
+ '4.4' => false,
113
+ '5.0' => true,
114
+ ),
115
+ 'soap.wsdl_cache_ttl' => array(
116
+ '4.4' => false,
117
+ '5.0' => true,
118
+ ),
119
+ 'sqlite.assoc_case' => array(
120
+ '4.4' => false,
121
+ '5.0' => true,
122
+ ),
123
+ 'tidy.clean_output' => array(
124
+ '4.4' => false,
125
+ '5.0' => true,
126
+ ),
127
+ 'tidy.default_config' => array(
128
+ '4.4' => false,
129
+ '5.0' => true,
130
+ ),
131
+ 'zend.ze1_compatibility_mode' => array(
132
+ '4.4' => false,
133
+ '5.0' => true,
134
+ ),
135
+
136
+ 'date.timezone' => array(
137
+ '5.0' => false,
138
+ '5.1' => true,
139
+ ),
140
+ 'detect_unicode' => array(
141
+ '5.0' => false,
142
+ '5.1' => true,
143
+ ),
144
+ 'fbsql.batchsize' => array(
145
+ '5.0' => false,
146
+ '5.1' => true,
147
+ 'alternative' => 'fbsql.batchSize',
148
+ ),
149
+ 'realpath_cache_size' => array(
150
+ '5.0' => false,
151
+ '5.1' => true,
152
+ ),
153
+ 'realpath_cache_ttl' => array(
154
+ '5.0' => false,
155
+ '5.1' => true,
156
+ ),
157
+
158
+ 'mbstring.strict_detection' => array(
159
+ '5.0' => false,
160
+ '5.1' => false,
161
+ '5.1.2' => true,
162
+ ),
163
+ 'mssql.charset' => array(
164
+ '5.0' => false,
165
+ '5.1' => false,
166
+ '5.1.2' => true,
167
+ ),
168
+
169
+ 'gd.jpeg_ignore_warning' => array(
170
+ '5.0' => false,
171
+ '5.1' => false,
172
+ '5.1.3' => true,
173
+ ),
174
+
175
+ 'fbsql.show_timestamp_decimals' => array(
176
+ '5.0' => false,
177
+ '5.1' => false,
178
+ '5.1.5' => true,
179
+ ),
180
+ 'soap.wsdl_cache' => array(
181
+ '5.0' => false,
182
+ '5.1' => false,
183
+ '5.1.5' => true,
184
+ ),
185
+ 'soap.wsdl_cache_limit' => array(
186
+ '5.0' => false,
187
+ '5.1' => false,
188
+ '5.1.5' => true,
189
+ ),
190
+
191
  'allow_url_include' => array(
192
  '5.1' => false,
193
  '5.2' => true
194
  ),
195
+ 'filter.default' => array(
196
+ '5.1' => false,
197
+ '5.2' => true,
198
+ ),
199
+ 'filter.default_flags' => array(
200
+ '5.1' => false,
201
+ '5.2' => true,
202
+ ),
203
  'pcre.backtrack_limit' => array(
204
  '5.1' => false,
205
  '5.2' => true
212
  '5.1' => false,
213
  '5.2' => true
214
  ),
215
+
216
+ 'cgi.check_shebang_line' => array(
217
+ '5.1' => false,
218
+ '5.2' => false,
219
+ '5.2.1' => true
220
+ ),
221
+
222
  'max_input_nesting_level' => array(
223
  '5.1' => false,
224
  '5.2' => false,
225
+ '5.2.3' => true
226
  ),
227
 
228
+ 'mysqli.allow_local_infile' => array(
229
+ '5.1' => false,
230
+ '5.2' => false,
231
+ '5.2.4' => true,
232
+ ),
233
+
234
+ 'max_file_uploads' => array(
235
+ '5.1' => false,
236
+ '5.2' => false,
237
+ '5.2.12' => true,
238
+ ),
239
+
240
+ 'cgi.discard_path' => array(
241
  '5.2' => false,
242
  '5.3' => true,
243
  ),
244
+ 'exit_on_timeout' => array(
245
  '5.2' => false,
246
  '5.3' => true,
247
  ),
248
+ 'intl.default_locale' => array(
249
+ '5.2' => false,
250
+ '5.3' => true,
251
+ ),
252
+ 'intl.error_level' => array(
253
+ '5.2' => false,
254
+ '5.3' => true,
255
+ ),
256
+ 'mail.add_x_header' => array(
257
+ '5.2' => false,
258
+ '5.3' => true,
259
+ ),
260
+ 'mail.log' => array(
261
  '5.2' => false,
262
  '5.3' => true,
263
  ),
265
  '5.2' => false,
266
  '5.3' => true,
267
  ),
268
+ 'mysqli.allow_persistent' => array(
269
+ '5.2' => false,
270
+ '5.3' => true,
271
+ ),
272
+ 'mysqli.cache_size' => array(
273
+ '5.2' => false,
274
+ '5.3' => true,
275
+ ),
276
+ 'mysqli.max_persistent' => array(
277
+ '5.2' => false,
278
+ '5.3' => true,
279
+ ),
280
+ 'mysqlnd.collect_memory_statistics' => array(
281
+ '5.2' => false,
282
+ '5.3' => true,
283
+ ),
284
+ 'mysqlnd.collect_statistics' => array(
285
+ '5.2' => false,
286
+ '5.3' => true,
287
+ ),
288
+ 'mysqlnd.debug' => array(
289
+ '5.2' => false,
290
+ '5.3' => true,
291
+ ),
292
+ 'mysqlnd.net_read_buffer_size' => array(
293
+ '5.2' => false,
294
+ '5.3' => true,
295
+ ),
296
+ 'odbc.default_cursortype' => array(
297
+ '5.2' => false,
298
+ '5.3' => true,
299
+ ),
300
  'request_order' => array(
301
  '5.2' => false,
302
  '5.3' => true,
303
  ),
304
+ 'user_ini.cache_ttl' => array(
305
+ '5.2' => false,
306
+ '5.3' => true,
307
+ ),
308
+ 'user_ini.filename' => array(
309
+ '5.2' => false,
310
+ '5.3' => true,
311
+ ),
312
+ 'zend.enable_gc' => array(
313
+ '5.2' => false,
314
+ '5.3' => true,
315
+ ),
316
+
317
+ 'curl.cainfo' => array(
318
+ '5.2' => false,
319
+ '5.3' => false,
320
+ '5.3.7' => true,
321
+ ),
322
+
323
+ 'max_input_vars' => array(
324
+ '5.2' => false,
325
+ '5.3' => false,
326
+ '5.3.9' => true,
327
+ ),
328
+
329
+ 'sqlite3.extension_dir' => array(
330
+ '5.2' => false,
331
+ '5.3' => false,
332
+ '5.3.11' => true,
333
+ ),
334
 
335
  'cli.pager' => array(
336
  '5.3' => false,
344
  '5.3' => false,
345
  '5.4' => true,
346
  ),
347
+ 'enable_post_data_reading' => array(
348
  '5.3' => false,
349
  '5.4' => true,
350
  ),
351
+ 'mysqlnd.mempool_default_size' => array(
352
  '5.3' => false,
353
  '5.4' => true,
354
  ),
355
+ 'mysqlnd.net_cmd_buffer_size' => array(
356
  '5.3' => false,
357
  '5.4' => true,
358
  ),
359
+ 'mysqlnd.net_read_timeout' => array(
360
+ '5.3' => false,
361
+ '5.4' => true,
362
+ ),
363
+ 'phar.cache_list' => array(
364
  '5.3' => false,
365
  '5.4' => true,
366
  ),
384
  '5.3' => false,
385
  '5.4' => true,
386
  ),
387
+ 'session.upload_progress.prefix' => array(
388
  '5.3' => false,
389
  '5.4' => true,
390
  ),
392
  '5.3' => false,
393
  '5.4' => true,
394
  ),
395
+ 'zend.detect_unicode' => array(
396
+ '5.3' => false,
397
+ '5.4' => true,
398
+ 'alternative' => 'detect_unicode',
399
+ ),
400
+ 'zend.multibyte' => array(
401
+ '5.3' => false,
402
+ '5.4' => true,
403
+ ),
404
+ 'zend.script_encoding' => array(
405
+ '5.3' => false,
406
+ '5.4' => true,
407
+ ),
408
+ 'zend.signal_check' => array(
409
+ '5.3' => false,
410
+ '5.4' => true,
411
+ ),
412
+ 'mysqlnd.log_mask' => array(
413
+ '5.3' => false,
414
+ '5.4' => true,
415
+ ),
416
 
417
  'intl.use_exceptions' => array(
418
  '5.4' => false,
422
  '5.4' => false,
423
  '5.5' => true,
424
  ),
425
+ 'mysqlnd.trace_alloc' => array(
426
+ '5.4' => false,
427
+ '5.5' => true,
428
+ ),
429
+ 'sys_temp_dir' => array(
430
+ '5.4' => false,
431
+ '5.5' => true,
432
+ ),
433
+ 'xsl.security_prefs' => array(
434
+ '5.4' => false,
435
+ '5.5' => true,
436
+ ),
437
 
438
+ 'session.use_strict_mode' => array(
439
+ '5.4' => false,
440
+ '5.5' => false,
441
+ '5.5.2' => true,
442
+ ),
443
+
444
+ 'mysqli.rollback_on_cached_plink' => array(
445
+ '5.5' => false,
446
+ '5.6' => true,
447
+ ),
448
+
449
+ 'assert.exception' => array(
450
+ '5.6' => false,
451
+ '7.0' => true,
452
+ ),
453
+ 'pcre.jit' => array(
454
+ '5.6' => false,
455
+ '7.0' => true,
456
+ ),
457
+ 'session.lazy_write' => array(
458
+ '5.6' => false,
459
+ '7.0' => true,
460
+ ),
461
+ 'zend.assertions' => array(
462
+ '5.6' => false,
463
+ '7.0' => true,
464
+ ),
465
  );
466
 
467
  /**
505
  if ($function != 'ini_get' && $function != 'ini_set') {
506
  return;
507
  }
 
508
 
509
+ $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
510
+ $filteredToken = trim($tokens[$iniToken]['content'], '\'"');
511
+ if (isset($this->newIniDirectives[$filteredToken]) === false) {
512
  return;
513
  }
514
 
515
  $error = '';
516
 
517
  foreach ($this->newIniDirectives[$filteredToken] as $version => $present) {
518
+ if ($version !== 'alternative') {
519
+ if ($this->supportsBelow($version)) {
520
+ if ($present === true) {
521
+ $error .= " not available before version " . $version;
522
+ }
523
  }
524
  }
525
  }
526
 
527
  if (strlen($error) > 0) {
528
  $error = "INI directive '" . $filteredToken . "' is" . $error;
529
+ if (isset($this->newIniDirectives[$filteredToken]['alternative'])) {
530
+ $error .= ". This directive was previously called '" . $this->newIniDirectives[$filteredToken]['alternative'] . "'.";
531
+ }
532
 
533
  $phpcsFile->addWarning($error, $stackPtr);
534
  }
536
  }//end process()
537
 
538
 
539
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_NewInterfacesSniff.
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category PHP
8
+ * @package PHPCompatibility
9
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
10
+ */
11
+
12
+ /**
13
+ * PHPCompatibility_Sniffs_PHP_NewInterfacesSniff.
14
+ *
15
+ * @category PHP
16
+ * @package PHPCompatibility
17
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
+ */
19
+ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sniff
20
+ {
21
+
22
+ /**
23
+ * A list of new interfaces, not present in older versions.
24
+ *
25
+ * The array lists : version number with false (not present) or true (present).
26
+ * If's sufficient to list the first version where the interface appears.
27
+ *
28
+ * @var array(string => array(string => int|string|null))
29
+ */
30
+ protected $newInterfaces = array(
31
+ 'Countable' => array(
32
+ '5.0' => false,
33
+ '5.1' => true
34
+ ),
35
+ 'OuterIterator' => array(
36
+ '5.0' => false,
37
+ '5.1' => true
38
+ ),
39
+ 'RecursiveIterator' => array(
40
+ '5.0' => false,
41
+ '5.1' => true
42
+ ),
43
+ 'SeekableIterator' => array(
44
+ '5.0' => false,
45
+ '5.1' => true
46
+ ),
47
+ 'Serializable' => array(
48
+ '5.0' => false,
49
+ '5.1' => true,
50
+ ),
51
+ 'SplObserver' => array(
52
+ '5.0' => false,
53
+ '5.1' => true
54
+ ),
55
+ 'SplSubject' => array(
56
+ '5.0' => false,
57
+ '5.1' => true
58
+ ),
59
+
60
+ 'JsonSerializable' => array(
61
+ '5.3' => false,
62
+ '5.4' => true
63
+ ),
64
+ 'SessionHandlerInterface' => array(
65
+ '5.3' => false,
66
+ '5.4' => true
67
+ ),
68
+
69
+ );
70
+
71
+ /**
72
+ * A list of methods which cannot be used in combination with particular interfaces.
73
+ *
74
+ * @var array(string => array(string => string))
75
+ */
76
+ protected $unsupportedMethods = array(
77
+ 'Serializable' => array(
78
+ '__sleep' => 'http://php.net/serializable',
79
+ '__wakeup' => 'http://php.net/serializable',
80
+ ),
81
+ );
82
+
83
+ /**
84
+ * Returns an array of tokens this test wants to listen for.
85
+ *
86
+ * @return array
87
+ */
88
+ public function register()
89
+ {
90
+ // Handle case-insensitivity of class names.
91
+ $keys = array_keys( $this->newInterfaces );
92
+ $keys = array_map( 'strtolower', $keys );
93
+ $this->newInterfaces = array_combine( $keys, $this->newInterfaces );
94
+
95
+ $keys = array_keys( $this->unsupportedMethods );
96
+ $keys = array_map( 'strtolower', $keys );
97
+ $this->unsupportedMethods = array_combine( $keys, $this->unsupportedMethods );
98
+
99
+ return array(T_CLASS);
100
+
101
+ }//end register()
102
+
103
+
104
+ /**
105
+ * Processes this test, when one of its tokens is encountered.
106
+ *
107
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
108
+ * @param int $stackPtr The position of the current token in
109
+ * the stack passed in $tokens.
110
+ *
111
+ * @return void
112
+ */
113
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
114
+ {
115
+ $interfaces = $this->findImplementedInterfaceNames($phpcsFile, $stackPtr);
116
+
117
+ if (is_array($interfaces) === false || $interfaces === array()) {
118
+ return;
119
+ }
120
+
121
+ $tokens = $phpcsFile->getTokens();
122
+ $checkMethods = false;
123
+
124
+ if(isset($tokens[$stackPtr]['scope_closer'])) {
125
+ $checkMethods = true;
126
+ $scopeCloser = $tokens[$stackPtr]['scope_closer'];
127
+ }
128
+
129
+ foreach ($interfaces as $interface) {
130
+ $lcInterface = strtolower($interface);
131
+ if (isset($this->newInterfaces[$lcInterface]) === true) {
132
+ $this->addError($phpcsFile, $stackPtr, $interface);
133
+ }
134
+
135
+ if ($checkMethods === true && isset($this->unsupportedMethods[$lcInterface]) === true) {
136
+ $nextFunc = $stackPtr;
137
+ while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
138
+ $funcNamePos = $phpcsFile->findNext(T_STRING, $nextFunc);
139
+ $funcName = strtolower($tokens[$funcNamePos]['content']);
140
+
141
+ if (isset($this->unsupportedMethods[$lcInterface][$funcName]) === true) {
142
+ $error = 'Classes that implement interface %s do not support the method %s(). See %s';
143
+ $data = array(
144
+ $interface,
145
+ $tokens[$funcNamePos]['content'],
146
+ $this->unsupportedMethods[$lcInterface][$funcName],
147
+ );
148
+ $phpcsFile->addError($error, $funcNamePos, 'UnsupportedMethod', $data);
149
+ }
150
+ }
151
+ }
152
+ }
153
+
154
+ }//end process()
155
+
156
+
157
+ /**
158
+ * Generates the error or warning for this sniff.
159
+ *
160
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
161
+ * @param int $stackPtr The position of the function
162
+ * in the token array.
163
+ * @param string $interface The name of the interface.
164
+ * @param string $pattern The pattern used for the match.
165
+ *
166
+ * @return void
167
+ */
168
+ protected function addError($phpcsFile, $stackPtr, $interface, $pattern=null)
169
+ {
170
+ if ($pattern === null) {
171
+ $pattern = strtolower($interface);
172
+ }
173
+
174
+ $error = '';
175
+
176
+ $isError = false;
177
+ foreach ($this->newInterfaces[$pattern] as $version => $present) {
178
+ if ($this->supportsBelow($version)) {
179
+ if ($present === false) {
180
+ $isError = true;
181
+ $error .= 'not present in PHP version ' . $version . ' or earlier';
182
+ }
183
+ }
184
+ }
185
+
186
+ if (strlen($error) > 0) {
187
+ $error = 'The built-in interface ' . $interface . ' is ' . $error;
188
+
189
+ if ($isError === true) {
190
+ $phpcsFile->addError($error, $stackPtr);
191
+ } else {
192
+ $phpcsFile->addWarning($error, $stackPtr);
193
+ }
194
+ }
195
+
196
+ }//end addError()
197
+
198
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php CHANGED
@@ -28,6 +28,9 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
28
  * The array lists : version number with false (not present) or true (present).
29
  * If's sufficient to list the first version where the keyword appears.
30
  *
 
 
 
31
  * @var array(string => array(string => int|string|null))
32
  */
33
  protected $newKeywords = array(
@@ -39,7 +42,8 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
39
  'T_CONST' => array(
40
  '5.2' => false,
41
  '5.3' => true,
42
- 'description' => '"const" keyword'
 
43
  ),
44
  'T_CALLABLE' => array(
45
  '5.3' => false,
@@ -109,14 +113,6 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
109
  );
110
 
111
 
112
- /**
113
- * If true, an error will be thrown; otherwise a warning.
114
- *
115
- * @var bool
116
- */
117
- protected $error = false;
118
-
119
-
120
  /**
121
  * Returns an array of tokens this test wants to listen for.
122
  *
@@ -162,19 +158,34 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
162
  &&
163
  $tokens[$prevToken]['type'] != 'T_CLASS'
164
  ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['type']);
166
  }
167
  }//end process()
168
 
169
 
170
  /**
171
- * Generates the error or wanrning for this sniff.
172
  *
173
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
174
- * @param int $stackPtr The position of the function
175
- * in the token array.
176
- * @param string $function The name of the function.
177
- * @param string $pattern The pattern used for the match.
178
  *
179
  * @return void
180
  */
@@ -186,11 +197,15 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
186
 
187
  $error = '';
188
 
189
- $this->error = false;
190
  foreach ($this->newKeywords[$pattern] as $version => $present) {
 
 
 
 
191
  if ($this->supportsBelow($version)) {
192
  if ($present === false) {
193
- $this->error = true;
194
  $error .= 'not present in PHP version ' . $version . ' or earlier';
195
  }
196
  }
@@ -198,7 +213,7 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
198
  if (strlen($error) > 0) {
199
  $error = $this->newKeywords[$keywordName]['description'] . ' is ' . $error;
200
 
201
- if ($this->error === true) {
202
  $phpcsFile->addError($error, $stackPtr);
203
  } else {
204
  $phpcsFile->addWarning($error, $stackPtr);
28
  * The array lists : version number with false (not present) or true (present).
29
  * If's sufficient to list the first version where the keyword appears.
30
  *
31
+ * If you add a condition, make sure to add the appropriate logic for it as well as
32
+ * this will not resolve itself automatically.
33
+ *
34
  * @var array(string => array(string => int|string|null))
35
  */
36
  protected $newKeywords = array(
42
  'T_CONST' => array(
43
  '5.2' => false,
44
  '5.3' => true,
45
+ 'description' => '"const" keyword',
46
+ 'condition' => 'T_CLASS', // Keyword is only new when not in class context.
47
  ),
48
  'T_CALLABLE' => array(
49
  '5.3' => false,
113
  );
114
 
115
 
 
 
 
 
 
 
 
 
116
  /**
117
  * Returns an array of tokens this test wants to listen for.
118
  *
158
  &&
159
  $tokens[$prevToken]['type'] != 'T_CLASS'
160
  ) {
161
+ // Skip based on special conditions.
162
+ if (
163
+ isset($this->newKeywords[$tokens[$stackPtr]['type']]['condition'])
164
+ &&
165
+ (empty($tokens[$stackPtr]['conditions']) === false
166
+ &&
167
+ is_array($tokens[$stackPtr]['conditions']))
168
+ ) {
169
+ foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condType) {
170
+ if ($condType === constant($this->newKeywords[$tokens[$stackPtr]['type']]['condition'])) {
171
+ return;
172
+ }
173
+ }
174
+ }
175
+
176
  $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['type']);
177
  }
178
  }//end process()
179
 
180
 
181
  /**
182
+ * Generates the error or warning for this sniff.
183
  *
184
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
185
+ * @param int $stackPtr The position of the function
186
+ * in the token array.
187
+ * @param string $keywordName The name of the keyword.
188
+ * @param string $pattern The pattern used for the match.
189
  *
190
  * @return void
191
  */
197
 
198
  $error = '';
199
 
200
+ $isError = false;
201
  foreach ($this->newKeywords[$pattern] as $version => $present) {
202
+ if (in_array($version, array('condition', 'description'), true)) {
203
+ continue;
204
+ }
205
+
206
  if ($this->supportsBelow($version)) {
207
  if ($present === false) {
208
+ $isError = true;
209
  $error .= 'not present in PHP version ' . $version . ' or earlier';
210
  }
211
  }
213
  if (strlen($error) > 0) {
214
  $error = $this->newKeywords[$keywordName]['description'] . ' is ' . $error;
215
 
216
+ if ($isError === true) {
217
  $phpcsFile->addError($error, $stackPtr);
218
  } else {
219
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php CHANGED
@@ -40,32 +40,74 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
40
  '5.5' => false,
41
  '5.6' => true,
42
  'description' => 'power operator (**)'
43
- ),
44
  'T_POW_EQUAL' => array(
45
  '5.5' => false,
46
  '5.6' => true,
47
  'description' => 'power assignment operator (**=)'
 
 
 
 
 
48
  ),
49
  'T_SPACESHIP' => array(
50
  '5.6' => false,
51
  '7.0' => true,
52
  'description' => 'spaceship operator (<=>)'
53
- ),
54
  'T_COALESCE' => array(
55
  '5.6' => false,
56
  '7.0' => true,
57
  'description' => 'null coalescing operator (??)'
58
- ),
59
  );
60
 
61
 
62
  /**
63
- * If true, an error will be thrown; otherwise a warning.
 
 
64
  *
65
- * @var bool
66
  */
67
- protected $error = false;
 
 
 
 
 
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  /**
71
  * Returns an array of tokens this test wants to listen for.
@@ -79,9 +121,11 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
79
  if (defined($token)) {
80
  $tokens[] = constant($token);
81
  }
 
 
 
82
  }
83
  return $tokens;
84
-
85
  }//end register()
86
 
87
 
@@ -96,34 +140,49 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
96
  */
97
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
98
  {
99
- $tokens = $phpcsFile->getTokens();
100
- $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['type']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }//end process()
102
 
103
 
104
  /**
105
  * Generates the error or warning for this sniff.
106
  *
107
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
108
- * @param int $stackPtr The position of the function
109
- * in the token array.
110
- * @param string $function The name of the function.
111
  *
112
  * @return void
113
  */
114
- protected function addError($phpcsFile, $stackPtr, $keywordName, $pattern=null)
115
  {
116
- if ($pattern === null) {
117
- $pattern = $keywordName;
118
- }
119
-
120
  $error = '';
121
 
122
- $this->error = false;
123
- foreach ($this->newConstructs[$pattern] as $version => $present) {
124
  if ($this->supportsBelow($version)) {
125
  if ($present === false) {
126
- $this->error = true;
127
  $error .= 'not present in PHP version ' . $version . ' or earlier';
128
  }
129
  }
@@ -131,7 +190,7 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
131
  if (strlen($error) > 0) {
132
  $error = $this->newConstructs[$keywordName]['description'] . ' is ' . $error;
133
 
134
- if ($this->error === true) {
135
  $phpcsFile->addError($error, $stackPtr);
136
  } else {
137
  $phpcsFile->addWarning($error, $stackPtr);
40
  '5.5' => false,
41
  '5.6' => true,
42
  'description' => 'power operator (**)'
43
+ ), // identified in PHPCS 1.5 as T_MULTIPLY + T_MULTIPLY
44
  'T_POW_EQUAL' => array(
45
  '5.5' => false,
46
  '5.6' => true,
47
  'description' => 'power assignment operator (**=)'
48
+ ), // identified in PHPCS 1.5 as T_MULTIPLY + T_MUL_EQUAL
49
+ 'T_ELLIPSIS' => array(
50
+ '5.5' => false,
51
+ '5.6' => true,
52
+ 'description' => 'variadic functions using ...'
53
  ),
54
  'T_SPACESHIP' => array(
55
  '5.6' => false,
56
  '7.0' => true,
57
  'description' => 'spaceship operator (<=>)'
58
+ ), // identified in PHPCS 1.5 as T_IS_SMALLER_OR_EQUAL + T_GREATER_THAN
59
  'T_COALESCE' => array(
60
  '5.6' => false,
61
  '7.0' => true,
62
  'description' => 'null coalescing operator (??)'
63
+ ), // identified in PHPCS 1.5 as T_INLINE_THEN + T_INLINE_THEN
64
  );
65
 
66
 
67
  /**
68
+ * A list of new language constructs which are not recognized in PHPCS 1.x.
69
+ *
70
+ * The array lists an alternative token to listen for.
71
  *
72
+ * @var array(string => int)
73
  */
74
+ protected $newConstructsPHPCSCompat = array(
75
+ 'T_POW' => T_MULTIPLY,
76
+ 'T_POW_EQUAL' => T_MUL_EQUAL,
77
+ 'T_SPACESHIP' => T_GREATER_THAN,
78
+ 'T_COALESCE' => T_INLINE_THEN,
79
+ );
80
 
81
+ /**
82
+ * Translation table for PHPCS 1.x tokens.
83
+ *
84
+ * The 'before' index lists the token which would have to be directly before the
85
+ * token found for it to be one of the new language constructs.
86
+ * The 'real_token' index indicates which language construct was found in that case.
87
+ *
88
+ * {@internal 'before' was choosen rather than 'after' as that allowed for a 1-on-1
89
+ * translation list with the current tokens.}}
90
+ *
91
+ * @var array(string => array(string => string))
92
+ */
93
+ protected $PHPCSCompatTranslate = array(
94
+ 'T_MULTIPLY' => array(
95
+ 'before' => 'T_MULTIPLY',
96
+ 'real_token' => 'T_POW',
97
+ ),
98
+ 'T_MUL_EQUAL' => array(
99
+ 'before' => 'T_MULTIPLY',
100
+ 'real_token' => 'T_POW_EQUAL',
101
+ ),
102
+ 'T_GREATER_THAN' => array(
103
+ 'before' => 'T_IS_SMALLER_OR_EQUAL',
104
+ 'real_token' => 'T_SPACESHIP',
105
+ ),
106
+ 'T_INLINE_THEN' => array(
107
+ 'before' => 'T_INLINE_THEN',
108
+ 'real_token' => 'T_COALESCE',
109
+ ),
110
+ );
111
 
112
  /**
113
  * Returns an array of tokens this test wants to listen for.
121
  if (defined($token)) {
122
  $tokens[] = constant($token);
123
  }
124
+ else if(isset($this->newConstructsPHPCSCompat[$token])) {
125
+ $tokens[] = $this->newConstructsPHPCSCompat[$token];
126
+ }
127
  }
128
  return $tokens;
 
129
  }//end register()
130
 
131
 
140
  */
141
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
142
  {
143
+ $tokens = $phpcsFile->getTokens();
144
+ $tokenType = $tokens[$stackPtr]['type'];
145
+
146
+ // Translate pre-PHPCS 2.0 tokens for new constructs to the actual construct.
147
+ if (isset($this->newConstructs[$tokenType]) === false) {
148
+ if (
149
+ isset($this->PHPCSCompatTranslate[$tokenType])
150
+ &&
151
+ $tokens[$stackPtr - 1]['type'] === $this->PHPCSCompatTranslate[$tokenType]['before']
152
+ ) {
153
+ $tokenType = $this->PHPCSCompatTranslate[$tokenType]['real_token'];
154
+ }
155
+ }
156
+
157
+ // If the translation did not yield one of the tokens we are looking for, bow out.
158
+ if (isset($this->newConstructs[$tokenType]) === false) {
159
+ return;
160
+ }
161
+
162
+ $this->addError($phpcsFile, $stackPtr, $tokenType);
163
+
164
  }//end process()
165
 
166
 
167
  /**
168
  * Generates the error or warning for this sniff.
169
  *
170
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
171
+ * @param int $stackPtr The position of the function
172
+ * in the token array.
173
+ * @param string $keywordName The name of the keyword.
174
  *
175
  * @return void
176
  */
177
+ protected function addError($phpcsFile, $stackPtr, $keywordName)
178
  {
 
 
 
 
179
  $error = '';
180
 
181
+ $isError = false;
182
+ foreach ($this->newConstructs[$keywordName] as $version => $present) {
183
  if ($this->supportsBelow($version)) {
184
  if ($present === false) {
185
+ $isError = true;
186
  $error .= 'not present in PHP version ' . $version . ' or earlier';
187
  }
188
  }
190
  if (strlen($error) > 0) {
191
  $error = $this->newConstructs[$keywordName]['description'] . ' is ' . $error;
192
 
193
+ if ($isError === true) {
194
  $phpcsFile->addError($error, $stackPtr);
195
  } else {
196
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff.
12
+ *
13
+ * Warns for non-magic behaviour of magic methods prior to becoming magic.
14
+ *
15
+ * @category PHP
16
+ * @package PHPCompatibility
17
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
+ */
19
+ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_Sniff
20
+ {
21
+
22
+ /**
23
+ * A list of new magic methods, not considered magic in older versions.
24
+ *
25
+ * Method names in the array should be all *lowercase*.
26
+ * The array lists : version number with false (not magic) or true (magic).
27
+ * If's sufficient to list the first version where the method became magic.
28
+ *
29
+ * @var array(string => array(string => int|string|null))
30
+ */
31
+ protected $newMagicMethods = array(
32
+ '__get' => array( // verified
33
+ '4.4' => false,
34
+ '5.0' => true,
35
+ ),
36
+
37
+ '__isset' => array( // verified
38
+ '5.0' => false,
39
+ '5.1' => true,
40
+ ),
41
+ '__unset' => array( // verified
42
+ '5.0' => false,
43
+ '5.1' => true,
44
+ ),
45
+ '__set_state' => array( // verified
46
+ '5.0' => false,
47
+ '5.1' => true,
48
+ ),
49
+
50
+ '__callstatic' => array( // verified
51
+ '5.2' => false,
52
+ '5.3' => true,
53
+ ),
54
+ '__invoke' => array( // verified
55
+ '5.2' => false,
56
+ '5.3' => true,
57
+ ),
58
+
59
+ '__debuginfo' => array( // verified
60
+ '5.5' => false,
61
+ '5.6' => true,
62
+ ),
63
+
64
+ // Special case - only became properly magical in 5.2.0,
65
+ // before that it was only called for echo and print.
66
+ '__tostring' => array(
67
+ '5.1' => false,
68
+ '5.2' => true,
69
+ '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.',
70
+ ),
71
+ );
72
+
73
+
74
+ /**
75
+ * Returns an array of tokens this test wants to listen for.
76
+ *
77
+ * @return array
78
+ */
79
+ public function register()
80
+ {
81
+ return array(T_FUNCTION);
82
+
83
+ }//end register()
84
+
85
+
86
+ /**
87
+ * Processes this test, when one of its tokens is encountered.
88
+ *
89
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
90
+ * @param int $stackPtr The position of the current token in the
91
+ * stack passed in $tokens.
92
+ *
93
+ * @return void
94
+ */
95
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
96
+ {
97
+ $functionName = $phpcsFile->getDeclarationName($stackPtr);
98
+ $functionNameLc = strtolower($functionName);
99
+
100
+ if (isset($this->newMagicMethods[$functionNameLc]) === false) {
101
+ return;
102
+ }
103
+
104
+ if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
105
+ return;
106
+ }
107
+
108
+ $lastVersionBelow = '';
109
+ foreach ($this->newMagicMethods[$functionNameLc] as $version => $magic) {
110
+ if ($version !== 'message' && $magic === false && $this->supportsBelow($version)) {
111
+ $lastVersionBelow = $version;
112
+ }
113
+ }
114
+
115
+ if ($lastVersionBelow !== '') {
116
+ $error = 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
117
+ if (empty($this->newMagicMethods[$functionNameLc]['message']) === false) {
118
+ $error = $this->newMagicMethods[$functionNameLc]['message'];
119
+ }
120
+
121
+ $data = array(
122
+ $functionName,
123
+ $lastVersionBelow,
124
+ );
125
+
126
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
127
+ }
128
+
129
+ }//end process()
130
+
131
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php CHANGED
@@ -49,14 +49,6 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
49
  );
50
 
51
 
52
- /**
53
- * If true, an error will be thrown; otherwise a warning.
54
- *
55
- * @var bool
56
- */
57
- protected $error = false;
58
-
59
-
60
  /**
61
  * Returns an array of tokens this test wants to listen for.
62
  *
@@ -91,7 +83,7 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
91
 
92
 
93
  /**
94
- * Generates the error or wanrning for this sniff.
95
  *
96
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
97
  * @param int $stackPtr The position of the function
@@ -109,11 +101,11 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
109
 
110
  $error = '';
111
 
112
- $this->error = false;
113
  foreach ($this->newTypes[$pattern] as $version => $present) {
114
  if ($this->supportsBelow($version)) {
115
  if ($present === false) {
116
- $this->error = true;
117
  $error .= 'not present in PHP version ' . $version . ' or earlier';
118
  }
119
  }
@@ -121,7 +113,7 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
121
  if (strlen($error) > 0) {
122
  $error = $this->newTypes[$typeName]['description'] . ' is ' . $error;
123
 
124
- if ($this->error === true) {
125
  $phpcsFile->addError($error, $stackPtr);
126
  } else {
127
  $phpcsFile->addWarning($error, $stackPtr);
49
  );
50
 
51
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Returns an array of tokens this test wants to listen for.
54
  *
83
 
84
 
85
  /**
86
+ * Generates the error or warning for this sniff.
87
  *
88
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
89
  * @param int $stackPtr The position of the function
101
 
102
  $error = '';
103
 
104
+ $isError = false;
105
  foreach ($this->newTypes[$pattern] as $version => $present) {
106
  if ($this->supportsBelow($version)) {
107
  if ($present === false) {
108
+ $isError = true;
109
  $error .= 'not present in PHP version ' . $version . ' or earlier';
110
  }
111
  }
113
  if (strlen($error) > 0) {
114
  $error = $this->newTypes[$typeName]['description'] . ' is ' . $error;
115
 
116
+ if ($isError === true) {
117
  $phpcsFile->addError($error, $stackPtr);
118
  } else {
119
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php CHANGED
@@ -26,35 +26,46 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
26
  * @var array(string => array(string => int|string|null))
27
  */
28
  protected $newTypes = array (
29
- 'int' => array(
30
- '5.6' => false,
31
- '7.0' => true,
32
- 'description' => 'int type'
33
- ),
34
- 'float' => array(
35
- '5.6' => false,
36
- '7.0' => true,
37
- 'description' => 'float type'
38
- ),
39
- 'bool' => array(
40
- '5.6' => false,
41
- '7.0' => true,
42
- 'description' => 'bool type'
43
- ),
44
- 'string' => array(
45
- '5.6' => false,
46
- '7.0' => true,
47
- 'description' => 'string type'
48
- ),
49
- );
 
 
 
 
50
 
51
 
52
  /**
53
- * If true, an error will be thrown; otherwise a warning.
54
  *
55
- * @var bool
 
 
56
  */
57
- protected $error = false;
 
 
 
 
 
58
 
59
 
60
  /**
@@ -79,23 +90,42 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
79
  */
80
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
81
  {
82
- $tokens = $phpcsFile->getTokens();
83
-
84
- // Get function name.
85
- $methodName = $phpcsFile->getDeclarationName($stackPtr);
86
-
87
  // Get all parameters from method signature.
88
- $paramNames = array();
89
- foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
90
- if (in_array($param['type_hint'], array_keys($this->newTypes))) {
 
 
 
 
 
 
 
 
 
 
91
  $this->addError($phpcsFile, $stackPtr, $param['type_hint']);
92
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
  }//end process()
95
 
96
 
97
  /**
98
- * Generates the error or wanrning for this sniff.
99
  *
100
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
101
  * @param int $stackPtr The position of the function
@@ -113,19 +143,19 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
113
 
114
  $error = '';
115
 
116
- $this->error = false;
117
  foreach ($this->newTypes[$pattern] as $version => $present) {
118
  if ($this->supportsBelow($version)) {
119
  if ($present === false) {
120
- $this->error = true;
121
  $error .= 'not present in PHP version ' . $version . ' or earlier';
122
  }
123
  }
124
  }
125
  if (strlen($error) > 0) {
126
- $error = $this->newTypes[$typeName]['description'] . ' is ' . $error;
127
 
128
- if ($this->error === true) {
129
  $phpcsFile->addError($error, $stackPtr);
130
  } else {
131
  $phpcsFile->addWarning($error, $stackPtr);
26
  * @var array(string => array(string => int|string|null))
27
  */
28
  protected $newTypes = array (
29
+ 'array' => array(
30
+ '5.0' => false,
31
+ '5.1' => true,
32
+ ),
33
+ 'callable' => array(
34
+ '5.3' => false,
35
+ '5.4' => true,
36
+ ),
37
+ 'int' => array(
38
+ '5.6' => false,
39
+ '7.0' => true,
40
+ ),
41
+ 'float' => array(
42
+ '5.6' => false,
43
+ '7.0' => true,
44
+ ),
45
+ 'bool' => array(
46
+ '5.6' => false,
47
+ '7.0' => true,
48
+ ),
49
+ 'string' => array(
50
+ '5.6' => false,
51
+ '7.0' => true,
52
+ ),
53
+ );
54
 
55
 
56
  /**
57
+ * Invalid types
58
  *
59
+ * The array lists : the invalid type hint => what was probably intended/alternative.
60
+ *
61
+ * @var array(string => string)
62
  */
63
+ protected $invalidTypes = array (
64
+ 'parent' => 'self',
65
+ 'static' => 'self',
66
+ 'boolean' => 'bool',
67
+ 'integer' => 'int',
68
+ );
69
 
70
 
71
  /**
90
  */
91
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
92
  {
 
 
 
 
 
93
  // Get all parameters from method signature.
94
+ $paramNames = $this->getMethodParameters($phpcsFile, $stackPtr);
95
+ $supportsPHP4 = $this->supportsBelow('4.4');
96
+
97
+ foreach ($paramNames as $param) {
98
+ if ($param['type_hint'] === '') {
99
+ continue;
100
+ }
101
+
102
+ if ($supportsPHP4 === true) {
103
+ $error = 'Type hints were not present in PHP 4.4 or earlier.';
104
+ $phpcsFile->addError($error, $stackPtr, 'TypeHintFound');
105
+ }
106
+ else if (isset($this->newTypes[$param['type_hint']])) {
107
  $this->addError($phpcsFile, $stackPtr, $param['type_hint']);
108
  }
109
+ else if (isset($this->invalidTypes[$param['type_hint']])) {
110
+ $error = "'%s' is not a valid type declaration. Did you mean %s ?";
111
+ $data = array(
112
+ $param['type_hint'],
113
+ $this->invalidTypes[$param['type_hint']],
114
+ );
115
+ $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHintFound', $data);
116
+ }
117
+ else if ($param['type_hint'] === 'self') {
118
+ if ($this->inClassScope($phpcsFile, $stackPtr) === false) {
119
+ $error = "'self' type cannot be used outside of class scope";
120
+ $phpcsFile->addError($error, $stackPtr, 'SelfOutsideClassScopeFound');
121
+ }
122
+ }
123
  }
124
  }//end process()
125
 
126
 
127
  /**
128
+ * Generates the error or warning for this sniff.
129
  *
130
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
131
  * @param int $stackPtr The position of the function
143
 
144
  $error = '';
145
 
146
+ $isError = false;
147
  foreach ($this->newTypes[$pattern] as $version => $present) {
148
  if ($this->supportsBelow($version)) {
149
  if ($present === false) {
150
+ $isError = true;
151
  $error .= 'not present in PHP version ' . $version . ' or earlier';
152
  }
153
  }
154
  }
155
  if (strlen($error) > 0) {
156
+ $error = "'{$typeName}' type declaration is " . $error;
157
 
158
+ if ($isError === true) {
159
  $phpcsFile->addError($error, $stackPtr);
160
  } else {
161
  $phpcsFile->addWarning($error, $stackPtr);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php CHANGED
@@ -13,7 +13,7 @@
13
  /**
14
  * PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff.
15
  *
16
- * Prohibits the use of static magic methods as well as protected or private magic methods
17
  *
18
  * @category PHP
19
  * @package PHPCompatibility
@@ -24,18 +24,53 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
24
  {
25
 
26
  /**
27
- * A list of magic methods that must be public and not be static
 
 
 
 
 
 
28
  *
29
  * @var array(string)
30
  */
31
  protected $magicMethods = array(
32
- '__get',
33
- '__set',
34
- '__isset',
35
- '__unset',
36
- '__call'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  );
38
 
 
39
  /**
40
  * Returns an array of tokens this test wants to listen for.
41
  *
@@ -43,7 +78,7 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
43
  */
44
  public function register()
45
  {
46
- return array(T_CLASS, T_INTERFACE);
47
 
48
  }//end register()
49
 
@@ -59,96 +94,69 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
59
  */
60
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
  {
62
- if ($this->supportsAbove('5.3')) {
63
- $tokens = $phpcsFile->getTokens();
64
-
65
- // Find all the functions in this class or interface
66
-
67
- // Use the scope closer to limit the sniffing within the scope of
68
- // this class or interface
69
- $classScopeCloser = (isset($tokens[$stackPtr]['scope_closer']))
70
- ? $tokens[$stackPtr]['scope_closer']
71
- : $stackPtr + 1;
72
-
73
- $functionPtr = $stackPtr;
74
-
75
- while ($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) {
76
-
77
- // Get the scope closer for this function in order to know how
78
- // to advance to the next function.
79
- // If no body of function (e.g. for interfaces), there is
80
- // no closing curly brace; advance the pointer differently
81
- $scopeCloser = isset($tokens[$functionToken]['scope_closer'])
82
- ? $tokens[$functionToken]['scope_closer']
83
- : $functionToken + 1;
84
 
85
- $scopeToken = false;
86
- $staticToken = false;
87
 
88
- $nameToken = $phpcsFile->findNext(T_WHITESPACE, $functionToken + 1, $classScopeCloser, true);
89
- if (in_array($tokens[$nameToken]['content'], $this->magicMethods) === false) {
90
- $functionPtr = $scopeCloser;
91
- continue;
92
- }
93
 
94
- // What is the token before the function token?
95
- $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, $functionToken - 1, null, true);
96
- if (in_array($tokens[$prevToken]['code'], array(T_PUBLIC, T_PROTECTED, T_PRIVATE))) {
97
- $scopeToken = $prevToken;
98
- } elseif ($tokens[$prevToken]['code'] == T_STATIC) {
99
- $staticToken = $prevToken;
100
- } else {
101
- // no scope or static modifiers, this function is okay
102
- $functionPtr = $scopeCloser;
103
- continue;
104
- }
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- // What is the token before that one?
107
- $prevPrevToken = $phpcsFile->findPrevious(T_WHITESPACE, $prevToken - 1, null, true);
108
- if (in_array($tokens[$prevPrevToken]['code'], array(T_PUBLIC, T_PROTECTED, T_PRIVATE))) {
109
- $scopeToken = $prevPrevToken;
110
- } elseif ($tokens[$prevPrevToken]['code'] == T_STATIC) {
111
- $staticToken = $prevPrevToken;
112
- }
113
 
114
- $isPublic = ($scopeToken !== false && $tokens[$scopeToken]['type'] != 'T_PUBLIC') ? false : true;
115
- $isStatic = ($staticToken === false) ? false : true;
 
 
 
 
 
116
 
117
- if ($isPublic && !$isStatic) {
118
- $functionPtr = $scopeCloser;
119
- continue;
120
- }
121
 
122
- // Summarize what the problems are
123
- if (!$isPublic && $isStatic) {
124
- $error = sprintf(
125
- "Magic methods must be public and cannot be static (since PHP 5.3)! Found static %s function %s",
126
- $tokens[$scopeToken]['content'],
127
- $tokens[$nameToken]['content']
128
- );
129
- $phpcsFile->addError($error, $functionToken);
130
- } else {
131
- if (!$isPublic) {
132
- $error = sprintf(
133
- "Magic methods must be public (since PHP 5.3)! Found %s function %s",
134
- $tokens[$scopeToken]['content'],
135
- $tokens[$nameToken]['content']
136
- );
137
- $phpcsFile->addError($error, $functionToken);
138
- }
139
-
140
- if ($isStatic) {
141
- $error = sprintf(
142
- "Magic methods cannot be static (since PHP 5.3)! Found static function %s",
143
- $tokens[$nameToken]['content']
144
- );
145
- $phpcsFile->addError($error, $functionToken);
146
- }
147
  }
 
 
 
148
 
149
- // Advance to next function
150
- $functionPtr = $scopeCloser;
151
  }
 
 
 
152
  }
153
 
154
  }//end process()
13
  /**
14
  * PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff.
15
  *
16
+ * Verifies the use of the correct visibility and static properties of magic methods.
17
  *
18
  * @category PHP
19
  * @package PHPCompatibility
24
  {
25
 
26
  /**
27
+ * A list of PHP magic methods and their visibility and static requirements.
28
+ *
29
+ * Method names in the array should be all *lowercase*.
30
+ * Visibility can be either 'public', 'protected' or 'private'.
31
+ * Static can be either 'true' - *must* be static, or 'false' - *must* be non-static.
32
+ * When a method does not have a specific requirement for either visibility or static,
33
+ * do *not* add the key.
34
  *
35
  * @var array(string)
36
  */
37
  protected $magicMethods = array(
38
+ '__get' => array(
39
+ 'visibility' => 'public',
40
+ 'static' => false,
41
+ ),
42
+ '__set' => array(
43
+ 'visibility' => 'public',
44
+ 'static' => false,
45
+ ),
46
+ '__isset' => array(
47
+ 'visibility' => 'public',
48
+ 'static' => false,
49
+ ),
50
+ '__unset' => array(
51
+ 'visibility' => 'public',
52
+ 'static' => false,
53
+ ),
54
+ '__call' => array(
55
+ 'visibility' => 'public',
56
+ 'static' => false,
57
+ ),
58
+ '__callstatic' => array(
59
+ 'visibility' => 'public',
60
+ 'static' => true,
61
+ ),
62
+ '__sleep' => array(
63
+ 'visibility' => 'public',
64
+ ),
65
+ '__tostring' => array(
66
+ 'visibility' => 'public',
67
+ ),
68
+ '__set_state' => array(
69
+ 'static' => true,
70
+ ),
71
  );
72
 
73
+
74
  /**
75
  * Returns an array of tokens this test wants to listen for.
76
  *
78
  */
79
  public function register()
80
  {
81
+ return array(T_CLASS, T_INTERFACE, T_TRAIT);
82
 
83
  }//end register()
84
 
94
  */
95
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
96
  {
97
+ // Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
98
+ if ($this->supportsAbove('5.3') === false) {
99
+ return;
100
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ $tokens = $phpcsFile->getTokens();
 
103
 
104
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
105
+ return;
106
+ }
 
 
107
 
108
+ $classScopeCloser = $tokens[$stackPtr]['scope_closer'];
109
+ $functionPtr = $stackPtr;
110
+
111
+ // Find all the functions in this class or interface.
112
+ while ($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) {
113
+ /*
114
+ * Get the scope closer for this function in order to know how
115
+ * to advance to the next function.
116
+ * If no body of function (e.g. for interfaces), there is
117
+ * no closing curly brace; advance the pointer differently.
118
+ */
119
+ $scopeCloser = isset($tokens[$functionToken]['scope_closer'])
120
+ ? $tokens[$functionToken]['scope_closer']
121
+ : $functionToken + 1;
122
+
123
+
124
+ $methodName = $phpcsFile->getDeclarationName($functionToken);
125
+ $methodNameLc = strtolower($methodName);
126
+ if (isset($this->magicMethods[$methodNameLc]) === false) {
127
+ $functionPtr = $scopeCloser;
128
+ continue;
129
+ }
130
 
131
+ $methodProperties = $phpcsFile->getMethodProperties($functionToken);
 
 
 
 
 
 
132
 
133
+ if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
134
+ $error = 'Visibility for magic method %s must be %s. Found: %s';
135
+ $data = array(
136
+ $methodName,
137
+ $this->magicMethods[$methodNameLc]['visibility'],
138
+ $methodProperties['scope'],
139
+ );
140
 
141
+ $phpcsFile->addError($error, $functionToken, 'MethodVisibility', $data);
142
+ }
 
 
143
 
144
+ if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
145
+ $error = 'Magic method %s cannot be defined as static.';
146
+ $errorCode = 'MethodStatic';
147
+ if ( $this->magicMethods[$methodNameLc]['static'] === true ) {
148
+ $error = 'Magic method %s must be defined as static.';
149
+ $errorCode = 'MethodNonStatic';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  }
151
+ $data = array(
152
+ $methodName,
153
+ );
154
 
155
+ $phpcsFile->addError($error, $functionToken, $errorCode, $data);
 
156
  }
157
+
158
+ // Advance to next function.
159
+ $functionPtr = $scopeCloser;
160
  }
161
 
162
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php CHANGED
@@ -3,7 +3,7 @@
3
  * PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff
4
  *
5
  * Discourages use of superglobals as parameters for functions.
6
- *
7
  * PHP version 5.4
8
  *
9
  * @category PHP
@@ -11,9 +11,12 @@
11
  * @author Declan Kelly <declankelly90@gmail.com>
12
  * @copyright 2015 Declan Kelly
13
  */
14
- class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff implements PHP_CodeSniffer_Sniff {
 
15
  /**
16
  * List of superglobals as an array of strings.
 
 
17
  */
18
  protected $superglobals = array(
19
  '$GLOBALS',
@@ -28,44 +31,44 @@ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff implements PH
28
  );
29
 
30
  /**
31
- * Returns array of tokens, in this case array containing
32
- * T_FUNCTION
33
  *
34
  * @return array
35
  */
36
  public function register() {
 
 
 
37
  return array(T_FUNCTION);
38
  }
39
 
40
  /**
41
  * Processes the test.
42
- *
43
  * @param PHP_CodeSniffer_file $phpcsFile The file being scanned.
44
  * @param int $stackPtr The position of the current token
45
  *
46
  * @return void
47
  */
48
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
49
- if (
50
- is_null(PHP_CodeSniffer::getConfigData('testVersion'))
51
- ||
52
- (
53
- !is_null(PHP_CodeSniffer::getConfigData('testVersion'))
54
- &&
55
- version_compare(PHP_CodeSniffer::getConfigData('testVersion'), '5.4') >= 0
56
- )
57
- ) {
58
- $tokens = $phpcsFile->getTokens();
59
- $openBracket = $tokens[$stackPtr]['parenthesis_opener'];
60
- $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
61
 
62
- for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
63
- $variable = $tokens[$i]['content'];
64
- if (in_array($variable, $this->superglobals)) {
65
- $phpcsFile->addError("Parameter shadowing super global ($variable) causes fatal error since PHP 5.4", $i);
66
- }
67
  }
68
-
69
  }
70
  }
71
- }
3
  * PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff
4
  *
5
  * Discourages use of superglobals as parameters for functions.
6
+ *
7
  * PHP version 5.4
8
  *
9
  * @category PHP
11
  * @author Declan Kelly <declankelly90@gmail.com>
12
  * @copyright 2015 Declan Kelly
13
  */
14
+ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff extends PHPCompatibility_Sniff
15
+ {
16
  /**
17
  * List of superglobals as an array of strings.
18
+ *
19
+ * @var array
20
  */
21
  protected $superglobals = array(
22
  '$GLOBALS',
31
  );
32
 
33
  /**
34
+ * Register the tokens to listen for.
 
35
  *
36
  * @return array
37
  */
38
  public function register() {
39
+ // Prepare for case-insensitive compare.
40
+ $this->superglobals = array_map('strtolower', $this->superglobals);
41
+
42
  return array(T_FUNCTION);
43
  }
44
 
45
  /**
46
  * Processes the test.
47
+ *
48
  * @param PHP_CodeSniffer_file $phpcsFile The file being scanned.
49
  * @param int $stackPtr The position of the current token
50
  *
51
  * @return void
52
  */
53
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
54
+ if ($this->supportsAbove('5.4') === false) {
55
+ return;
56
+ }
57
+
58
+ // Get all parameters from function signature.
59
+ $parameters = $phpcsFile->getMethodParameters($stackPtr);
60
+ if (empty($parameters) || is_array($parameters) === false) {
61
+ return;
62
+ }
63
+
64
+ foreach ($parameters as $param) {
65
+ $paramNameLc = strtolower($param['name']);
66
 
67
+ if (in_array($paramNameLc, $this->superglobals, true)) {
68
+ $error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
69
+ $data = array($param['name']);
70
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
71
  }
 
72
  }
73
  }
74
+ }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php CHANGED
@@ -23,11 +23,14 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
23
  {
24
 
25
  /**
26
- * If true, an error will be thrown; otherwise a warning.
27
  *
28
- * @var bool
29
  */
30
- public $error = false;
 
 
 
31
 
32
  /**
33
  * Returns an array of tokens this test wants to listen for.
@@ -53,7 +56,10 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
53
  if ($this->supportsAbove('5.5')) {
54
  $tokens = $phpcsFile->getTokens();
55
 
56
- if ($tokens[$stackPtr]['content'] == "preg_replace") {
 
 
 
57
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
58
 
59
  if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
@@ -82,6 +88,9 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
82
 
83
  $doublesSeparators = array(
84
  '{' => '}',
 
 
 
85
  );
86
 
87
  $regex = substr($regex, 1, -1);
23
  {
24
 
25
  /**
26
+ * Functions to check for.
27
  *
28
+ * @var array
29
  */
30
+ protected $functions = array(
31
+ 'preg_replace' => true,
32
+ 'preg_filter' => true,
33
+ );
34
 
35
  /**
36
  * Returns an array of tokens this test wants to listen for.
56
  if ($this->supportsAbove('5.5')) {
57
  $tokens = $phpcsFile->getTokens();
58
 
59
+ if ( isset($this->functions[$tokens[$stackPtr]['content']]) === false ) {
60
+ return;
61
+ } else {
62
+
63
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
64
 
65
  if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
88
 
89
  $doublesSeparators = array(
90
  '{' => '}',
91
+ '[' => ']',
92
+ '(' => ')',
93
+ '<' => '>',
94
  );
95
 
96
  $regex = substr($regex, 1, -1);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedExtensionsSniff.php CHANGED
@@ -22,6 +22,22 @@
22
  */
23
  class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_Sniff
24
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  /**
27
  * A list of removed extensions with their alternative, if any
@@ -32,20 +48,24 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
32
  protected $removedExtensions = array(
33
  'activescript' => array(
34
  '5.0' => 1,
35
- '5.1' => 1,
36
- '5.2' => 1,
37
  '5.3' => 0,
38
  '5.4' => 0,
39
  '5.5' => 0,
 
 
40
  'alternative' => 'pecl/activescript'
41
  ),
42
  'cpdf' => array(
43
  '5.0' => 1,
44
- '5.1' => 1,
45
- '5.2' => 1,
46
  '5.3' => 0,
47
  '5.4' => 0,
48
  '5.5' => 0,
 
 
49
  'alternative' => 'pecl/pdflib'
50
  ),
51
  'dbase' => array(
@@ -55,6 +75,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
55
  '5.3' => 0,
56
  '5.4' => 0,
57
  '5.5' => 0,
 
 
58
  'alternative' => null
59
  ),
60
  'dbx' => array(
@@ -64,6 +86,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
64
  '5.3' => 0,
65
  '5.4' => 0,
66
  '5.5' => 0,
 
 
67
  'alternative' => 'pecl/dbx'
68
  ),
69
  'dio' => array(
@@ -73,11 +97,20 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
73
  '5.3' => 0,
74
  '5.4' => 0,
75
  '5.5' => 0,
 
 
76
  'alternative' => 'pecl/dio'
77
  ),
78
  'ereg' => array(
 
 
 
 
 
 
 
79
  '7.0' => 0,
80
- 'alternative' => null
81
  ),
82
  'fam' => array(
83
  '5.0' => 1,
@@ -86,6 +119,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
86
  '5.3' => 0,
87
  '5.4' => 0,
88
  '5.5' => 0,
 
 
89
  'alternative' => null
90
  ),
91
  'fbsql' => array(
@@ -95,6 +130,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
95
  '5.3' => 0,
96
  '5.4' => 0,
97
  '5.5' => 0,
 
 
98
  'alternative' => null
99
  ),
100
  'fdf' => array(
@@ -104,6 +141,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
104
  '5.3' => 0,
105
  '5.4' => 0,
106
  '5.5' => 0,
 
 
107
  'alternative' => 'pecl/fdf'
108
  ),
109
  'filepro' => array(
@@ -113,6 +152,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
113
  '5.3' => 0,
114
  '5.4' => 0,
115
  '5.5' => 0,
 
 
116
  'alternative' => null
117
  ),
118
  'hw_api' => array(
@@ -122,6 +163,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
122
  '5.3' => 0,
123
  '5.4' => 0,
124
  '5.5' => 0,
 
 
125
  'alternative' => null
126
  ),
127
  'ingres' => array(
@@ -131,15 +174,19 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
131
  '5.3' => 0,
132
  '5.4' => 0,
133
  '5.5' => 0,
 
 
134
  'alternative' => 'pecl/ingres'
135
  ),
136
  'ircg' => array(
137
  '5.0' => 1,
138
- '5.1' => 1,
139
- '5.2' => 1,
140
  '5.3' => 0,
141
  '5.4' => 0,
142
  '5.5' => 0,
 
 
143
  'alternative' => null
144
  ),
145
  'mcve' => array(
@@ -149,6 +196,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
149
  '5.3' => 0,
150
  '5.4' => 0,
151
  '5.5' => 0,
 
 
152
  'alternative' => 'pecl/mvce'
153
  ),
154
  'ming' => array(
@@ -158,6 +207,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
158
  '5.3' => 0,
159
  '5.4' => 0,
160
  '5.5' => 0,
 
 
161
  'alternative' => 'pecl/ming'
162
  ),
163
  'mnogosearch' => array(
@@ -167,6 +218,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
167
  '5.3' => 0,
168
  '5.4' => 0,
169
  '5.5' => 0,
 
 
170
  'alternative' => null
171
  ),
172
  'msql' => array(
@@ -176,6 +229,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
176
  '5.3' => 0,
177
  '5.4' => 0,
178
  '5.5' => 0,
 
 
179
  'alternative' => null
180
  ),
181
  'mssql' => array(
@@ -200,15 +255,19 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
200
  '5.3' => 0,
201
  '5.4' => 0,
202
  '5.5' => 0,
 
 
203
  'alternative' => 'pecl/ncurses'
204
  ),
205
  'oracle' => array(
206
  '5.0' => 1,
207
- '5.1' => 1,
208
- '5.2' => 1,
209
  '5.3' => 0,
210
  '5.4' => 0,
211
  '5.5' => 0,
 
 
212
  'alternative' => 'oci8 or pdo_oci'
213
  ),
214
  'ovrimos' => array(
@@ -218,6 +277,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
218
  '5.3' => 0,
219
  '5.4' => 0,
220
  '5.5' => 0,
 
 
221
  'alternative' => null
222
  ),
223
  'pfpro' => array(
@@ -227,6 +288,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
227
  '5.3' => 0,
228
  '5.4' => 0,
229
  '5.5' => 0,
 
 
230
  'alternative' => null
231
  ),
232
  'sqlite' => array(
@@ -236,6 +299,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
236
  '5.3' => 1,
237
  '5.4' => 0,
238
  '5.5' => 0,
 
 
239
  'alternative' => null
240
  ),
241
  'sybase' => array(
@@ -245,6 +310,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
245
  '5.3' => 0,
246
  '5.4' => 0,
247
  '5.5' => 0,
 
 
248
  'alternative' => 'sybase_ct'
249
  ),
250
  'sybase_ct' => array(
@@ -258,15 +325,19 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
258
  '5.3' => 0,
259
  '5.4' => 0,
260
  '5.5' => 0,
 
 
261
  'alternative' => 'pecl/ffi'
262
  ),
263
  'yp' => array(
264
  '5.0' => 1,
265
- '5.1' => 1,
266
- '5.2' => 1,
267
  '5.3' => 0,
268
  '5.4' => 0,
269
  '5.5' => 0,
 
 
270
  'alternative' => null
271
  ),
272
  );
@@ -327,17 +398,26 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
327
  return;
328
  }
329
 
 
 
 
 
 
330
  foreach ($this->removedExtensions as $extension => $versionList) {
331
  if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
332
  $error = '';
333
  $isErrored = false;
 
334
  foreach ($versionList as $version => $status) {
335
  if ($version != 'alternative') {
336
  if ($status == -1 || $status == 0) {
337
  if ($this->supportsAbove($version)) {
338
  switch ($status) {
339
  case -1:
340
- $error .= 'deprecated since PHP ' . $version . ' and ';
 
 
 
341
  break;
342
  case 0:
343
  $isErrored = true;
@@ -365,4 +445,35 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
365
 
366
  }//end process()
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  }//end class
22
  */
23
  class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_Sniff
24
  {
25
+ /**
26
+ * A list of functions to whitelist, if any.
27
+ *
28
+ * This is intended for projects using functions which start with the same
29
+ * prefix as one of the removed extensions.
30
+ *
31
+ * This property can be set from the ruleset, like so:
32
+ * <rule ref="PHPCompatibility.PHP.RemovedExtensions">
33
+ * <properties>
34
+ * <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
35
+ * </properties>
36
+ * </rule>
37
+ *
38
+ * @var array
39
+ */
40
+ public $functionWhitelist;
41
 
42
  /**
43
  * A list of removed extensions with their alternative, if any
48
  protected $removedExtensions = array(
49
  'activescript' => array(
50
  '5.0' => 1,
51
+ '5.1' => 0,
52
+ '5.2' => 0,
53
  '5.3' => 0,
54
  '5.4' => 0,
55
  '5.5' => 0,
56
+ '5.6' => 0,
57
+ '7.0' => 0,
58
  'alternative' => 'pecl/activescript'
59
  ),
60
  'cpdf' => array(
61
  '5.0' => 1,
62
+ '5.1' => 0,
63
+ '5.2' => 0,
64
  '5.3' => 0,
65
  '5.4' => 0,
66
  '5.5' => 0,
67
+ '5.6' => 0,
68
+ '7.0' => 0,
69
  'alternative' => 'pecl/pdflib'
70
  ),
71
  'dbase' => array(
75
  '5.3' => 0,
76
  '5.4' => 0,
77
  '5.5' => 0,
78
+ '5.6' => 0,
79
+ '7.0' => 0,
80
  'alternative' => null
81
  ),
82
  'dbx' => array(
86
  '5.3' => 0,
87
  '5.4' => 0,
88
  '5.5' => 0,
89
+ '5.6' => 0,
90
+ '7.0' => 0,
91
  'alternative' => 'pecl/dbx'
92
  ),
93
  'dio' => array(
97
  '5.3' => 0,
98
  '5.4' => 0,
99
  '5.5' => 0,
100
+ '5.6' => 0,
101
+ '7.0' => 0,
102
  'alternative' => 'pecl/dio'
103
  ),
104
  'ereg' => array(
105
+ '5.0' => 1,
106
+ '5.1' => 1,
107
+ '5.2' => 1,
108
+ '5.3' => -1,
109
+ '5.4' => -1,
110
+ '5.5' => -1,
111
+ '5.6' => -1,
112
  '7.0' => 0,
113
+ 'alternative' => 'pcre'
114
  ),
115
  'fam' => array(
116
  '5.0' => 1,
119
  '5.3' => 0,
120
  '5.4' => 0,
121
  '5.5' => 0,
122
+ '5.6' => 0,
123
+ '7.0' => 0,
124
  'alternative' => null
125
  ),
126
  'fbsql' => array(
130
  '5.3' => 0,
131
  '5.4' => 0,
132
  '5.5' => 0,
133
+ '5.6' => 0,
134
+ '7.0' => 0,
135
  'alternative' => null
136
  ),
137
  'fdf' => array(
141
  '5.3' => 0,
142
  '5.4' => 0,
143
  '5.5' => 0,
144
+ '5.6' => 0,
145
+ '7.0' => 0,
146
  'alternative' => 'pecl/fdf'
147
  ),
148
  'filepro' => array(
152
  '5.3' => 0,
153
  '5.4' => 0,
154
  '5.5' => 0,
155
+ '5.6' => 0,
156
+ '7.0' => 0,
157
  'alternative' => null
158
  ),
159
  'hw_api' => array(
163
  '5.3' => 0,
164
  '5.4' => 0,
165
  '5.5' => 0,
166
+ '5.6' => 0,
167
+ '7.0' => 0,
168
  'alternative' => null
169
  ),
170
  'ingres' => array(
174
  '5.3' => 0,
175
  '5.4' => 0,
176
  '5.5' => 0,
177
+ '5.6' => 0,
178
+ '7.0' => 0,
179
  'alternative' => 'pecl/ingres'
180
  ),
181
  'ircg' => array(
182
  '5.0' => 1,
183
+ '5.1' => 0,
184
+ '5.2' => 0,
185
  '5.3' => 0,
186
  '5.4' => 0,
187
  '5.5' => 0,
188
+ '5.6' => 0,
189
+ '7.0' => 0,
190
  'alternative' => null
191
  ),
192
  'mcve' => array(
196
  '5.3' => 0,
197
  '5.4' => 0,
198
  '5.5' => 0,
199
+ '5.6' => 0,
200
+ '7.0' => 0,
201
  'alternative' => 'pecl/mvce'
202
  ),
203
  'ming' => array(
207
  '5.3' => 0,
208
  '5.4' => 0,
209
  '5.5' => 0,
210
+ '5.6' => 0,
211
+ '7.0' => 0,
212
  'alternative' => 'pecl/ming'
213
  ),
214
  'mnogosearch' => array(
218
  '5.3' => 0,
219
  '5.4' => 0,
220
  '5.5' => 0,
221
+ '5.6' => 0,
222
+ '7.0' => 0,
223
  'alternative' => null
224
  ),
225
  'msql' => array(
229
  '5.3' => 0,
230
  '5.4' => 0,
231
  '5.5' => 0,
232
+ '5.6' => 0,
233
+ '7.0' => 0,
234
  'alternative' => null
235
  ),
236
  'mssql' => array(
255
  '5.3' => 0,
256
  '5.4' => 0,
257
  '5.5' => 0,
258
+ '5.6' => 0,
259
+ '7.0' => 0,
260
  'alternative' => 'pecl/ncurses'
261
  ),
262
  'oracle' => array(
263
  '5.0' => 1,
264
+ '5.1' => 0,
265
+ '5.2' => 0,
266
  '5.3' => 0,
267
  '5.4' => 0,
268
  '5.5' => 0,
269
+ '5.6' => 0,
270
+ '7.0' => 0,
271
  'alternative' => 'oci8 or pdo_oci'
272
  ),
273
  'ovrimos' => array(
277
  '5.3' => 0,
278
  '5.4' => 0,
279
  '5.5' => 0,
280
+ '5.6' => 0,
281
+ '7.0' => 0,
282
  'alternative' => null
283
  ),
284
  'pfpro' => array(
288
  '5.3' => 0,
289
  '5.4' => 0,
290
  '5.5' => 0,
291
+ '5.6' => 0,
292
+ '7.0' => 0,
293
  'alternative' => null
294
  ),
295
  'sqlite' => array(
299
  '5.3' => 1,
300
  '5.4' => 0,
301
  '5.5' => 0,
302
+ '5.6' => 0,
303
+ '7.0' => 0,
304
  'alternative' => null
305
  ),
306
  'sybase' => array(
310
  '5.3' => 0,
311
  '5.4' => 0,
312
  '5.5' => 0,
313
+ '5.6' => 0,
314
+ '7.0' => 0,
315
  'alternative' => 'sybase_ct'
316
  ),
317
  'sybase_ct' => array(
325
  '5.3' => 0,
326
  '5.4' => 0,
327
  '5.5' => 0,
328
+ '5.6' => 0,
329
+ '7.0' => 0,
330
  'alternative' => 'pecl/ffi'
331
  ),
332
  'yp' => array(
333
  '5.0' => 1,
334
+ '5.1' => 0,
335
+ '5.2' => 0,
336
  '5.3' => 0,
337
  '5.4' => 0,
338
  '5.5' => 0,
339
+ '5.6' => 0,
340
+ '7.0' => 0,
341
  'alternative' => null
342
  ),
343
  );
398
  return;
399
  }
400
 
401
+ if($this->isWhiteListed(strtolower($tokens[$stackPtr]['content'])) === true){
402
+ // Function is whitelisted.
403
+ return;
404
+ }
405
+
406
  foreach ($this->removedExtensions as $extension => $versionList) {
407
  if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
408
  $error = '';
409
  $isErrored = false;
410
+ $isDeprecated = false;
411
  foreach ($versionList as $version => $status) {
412
  if ($version != 'alternative') {
413
  if ($status == -1 || $status == 0) {
414
  if ($this->supportsAbove($version)) {
415
  switch ($status) {
416
  case -1:
417
+ if($isDeprecated === false ) {
418
+ $error .= 'deprecated since PHP ' . $version . ' and ';
419
+ $isDeprecated = true;
420
+ }
421
  break;
422
  case 0:
423
  $isErrored = true;
445
 
446
  }//end process()
447
 
448
+ /**
449
+ * Is the current function being checked whitelisted ?
450
+ *
451
+ * Parsing the list late as it may be provided as a property, but also inline.
452
+ *
453
+ * @param string $content Content of the current token.
454
+ *
455
+ * @return bool
456
+ */
457
+ protected function isWhiteListed($content) {
458
+ if (isset($this->functionWhitelist) === false) {
459
+ return false;
460
+ }
461
+
462
+ if (is_string($this->functionWhitelist) === true) {
463
+ if (strpos($this->functionWhitelist, ',') !== false) {
464
+ $this->functionWhitelist = explode(',', $this->functionWhitelist);
465
+ } else {
466
+ $this->functionWhitelist = (array) $this->functionWhitelist;
467
+ }
468
+ }
469
+
470
+ if (is_array($this->functionWhitelist) === true) {
471
+ $this->functionWhitelist = array_map('strtolower',$this->functionWhitelist);
472
+ return in_array($content, $this->functionWhitelist, true);
473
+ }
474
+
475
+ return false;
476
+
477
+ }//end isWhiteListed()
478
+
479
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php CHANGED
@@ -23,42 +23,48 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
-
27
  /**
28
- * A list of Removed function parameters, not present in older versions.
29
  *
30
- * The array lists : version number with false (not present) or true (present).
31
  * The index is the location of the parameter in the parameter list, starting at 0 !
32
- * If's sufficient to list the first version where the function appears.
33
  *
34
  * @var array
35
  */
36
- public $removedFunctionParameters = array(
37
- 'mktime' => array(
38
  6 => array(
39
  'name' => 'is_dst',
40
- '5.1' => true,
41
- '7.0' => false
42
  ),
43
  ),
44
- 'gmmktime' => array(
 
 
 
 
 
 
 
 
 
 
 
 
45
  6 => array(
46
  'name' => 'is_dst',
47
- '7.0' => false
 
48
  ),
49
  ),
50
  );
51
 
52
 
53
  /**
54
- * If true, an error will be thrown; otherwise a warning.
55
  *
56
- * @var bool
57
- */
58
- public $error = false;
59
-
60
- /**
61
- *
62
  * @var array
63
  */
64
  private $removedFunctionParametersNames;
@@ -74,16 +80,16 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
74
  // Everyone has had a chance to figure out what forbidden functions
75
  // they want to check for, so now we can cache out the list.
76
  $this->removedFunctionParametersNames = array_keys($this->removedFunctionParameters);
77
-
78
  if ($this->patternMatch === true) {
79
  foreach ($this->removedFunctionParametersNames as $i => $name) {
80
  $this->removedFunctionParametersNames[$i] = '/'.$name.'/i';
81
  }
82
  }
83
-
84
  return array(T_STRING);
85
  }//end register()
86
-
87
  /**
88
  * Processes this test, when one of its tokens is encountered.
89
  *
@@ -115,53 +121,33 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
115
  if (in_array($function, $this->removedFunctionParametersNames) === false) {
116
  return;
117
  }
118
-
119
- if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
120
- $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
121
- $openParenthesis = $tokens[$closeParenthesis]['parenthesis_opener'];
122
-
123
- $nextItem = $phpcsFile->findNext(array(), $openParenthesis + 1, $closeParenthesis, true);
124
- if (isset($tokens[$nextItem]['nested_parenthesis'])) {
125
- $parenthesisCount = count($tokens[$nextItem]['nested_parenthesis']);
126
- } else {
127
- $parenthesisCount = 0;
128
- }
129
 
130
- $nextComma = $stackPtr + 1;
131
- $cnt = 0;
132
- while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
133
- if (
134
- $tokens[$nextComma]['type'] == 'T_COMMA'
135
- &&
136
- isset($tokens[$nextComma]['nested_parenthesis'])
137
- &&
138
- count($tokens[$nextComma]['nested_parenthesis']) != $parenthesisCount
139
- ) {
140
- continue;
141
- }
142
-
143
- if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
144
- continue;
145
- }
146
-
147
- if (isset($this->removedFunctionParameters[$function][$cnt])) {
148
- $this->addError($phpcsFile, $nextComma, $function, $cnt);
149
- }
150
- $cnt++;
151
  }
152
-
153
  }
 
154
  }//end process()
155
 
156
 
157
  /**
158
- * Generates the error or wanrning for this sniff.
159
  *
160
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
161
- * @param int $stackPtr The position of the function
162
- * in the token array.
163
- * @param string $function The name of the function.
164
- * @param string $pattern The pattern used for the match.
165
  *
166
  * @return void
167
  */
@@ -169,23 +155,37 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
169
  {
170
  $error = '';
171
 
172
- $this->error = false;
 
173
  foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
174
  if ($version != 'name' && $this->supportsAbove($version)) {
175
- if ($present === false) {
176
- $this->error = true;
177
- $error .= 'in PHP version ' . $version . ' or later';
 
 
 
 
 
 
 
178
  }
179
  }
180
  }
181
-
182
- if (strlen($error) > 0) {
183
- $error = 'The function ' . $function . ' does not have a parameter ' . $this->removedFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;
184
 
185
- if ($this->error === true) {
186
- $phpcsFile->addError($error, $stackPtr);
 
 
 
 
 
 
 
 
 
187
  } else {
188
- $phpcsFile->addWarning($error, $stackPtr);
189
  }
190
  }
191
 
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
+
27
  /**
28
+ * A list of removed function parameters, which were present in older versions.
29
  *
30
+ * The array lists : version number with true (deprecated and false (removed).
31
  * The index is the location of the parameter in the parameter list, starting at 0 !
32
+ * If's sufficient to list the first version where the function was deprecated/removed.
33
  *
34
  * @var array
35
  */
36
+ protected $removedFunctionParameters = array(
37
+ 'gmmktime' => array(
38
  6 => array(
39
  'name' => 'is_dst',
40
+ '5.1' => true, // deprecated
41
+ '7.0' => false,
42
  ),
43
  ),
44
+ 'ldap_first_attribute' => array(
45
+ 2 => array(
46
+ 'name' => 'ber_identifier',
47
+ '5.2.4' => false,
48
+ ),
49
+ ),
50
+ 'ldap_next_attribute' => array(
51
+ 2 => array(
52
+ 'name' => 'ber_identifier',
53
+ '5.2.4' => false,
54
+ ),
55
+ ),
56
+ 'mktime' => array(
57
  6 => array(
58
  'name' => 'is_dst',
59
+ '5.1' => true, // deprecated
60
+ '7.0' => false,
61
  ),
62
  ),
63
  );
64
 
65
 
66
  /**
 
67
  *
 
 
 
 
 
 
68
  * @var array
69
  */
70
  private $removedFunctionParametersNames;
80
  // Everyone has had a chance to figure out what forbidden functions
81
  // they want to check for, so now we can cache out the list.
82
  $this->removedFunctionParametersNames = array_keys($this->removedFunctionParameters);
83
+
84
  if ($this->patternMatch === true) {
85
  foreach ($this->removedFunctionParametersNames as $i => $name) {
86
  $this->removedFunctionParametersNames[$i] = '/'.$name.'/i';
87
  }
88
  }
89
+
90
  return array(T_STRING);
91
  }//end register()
92
+
93
  /**
94
  * Processes this test, when one of its tokens is encountered.
95
  *
121
  if (in_array($function, $this->removedFunctionParametersNames) === false) {
122
  return;
123
  }
 
 
 
 
 
 
 
 
 
 
 
124
 
125
+ $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
126
+ if ($parameterCount === 0) {
127
+ return;
128
+ }
129
+
130
+ // If the parameter count returned > 0, we know there will be valid open parenthesis.
131
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
132
+ $parameterOffsetFound = $parameterCount - 1;
133
+
134
+ foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) {
135
+ if ($offset <= $parameterOffsetFound) {
136
+ $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
 
 
 
 
 
 
 
 
137
  }
 
138
  }
139
+
140
  }//end process()
141
 
142
 
143
  /**
144
+ * Generates the error or warning for this sniff.
145
  *
146
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
147
+ * @param int $stackPtr The position of the function
148
+ * in the token array.
149
+ * @param string $function The name of the function.
150
+ * @param int $parameterLocation The parameter position within the function call.
151
  *
152
  * @return void
153
  */
155
  {
156
  $error = '';
157
 
158
+ $isError = false;
159
+ $previousStatus = null;
160
  foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
161
  if ($version != 'name' && $this->supportsAbove($version)) {
162
+
163
+ if ($previousStatus !== $present) {
164
+ $previousStatus = $present;
165
+ if ($present === false) {
166
+ $isError = true;
167
+ $error .= 'removed';
168
+ } else {
169
+ $error .= 'deprecated';
170
+ }
171
+ $error .= ' in PHP version ' . $version . ' and ';
172
  }
173
  }
174
  }
 
 
 
175
 
176
+ if (strlen($error) > 0) {
177
+ $error = 'The "%s" parameter for function %s was ' . $error;
178
+ $error = substr($error, 0, strlen($error) - 5);
179
+ $errorCode = 'RemovedParameter';
180
+ $data = array(
181
+ $this->removedFunctionParameters[$function][$parameterLocation]['name'],
182
+ $function,
183
+ );
184
+
185
+ if ($isError === true) {
186
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
187
  } else {
188
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
189
  }
190
  }
191
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php CHANGED
@@ -56,43 +56,48 @@ class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompati
56
  */
57
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58
  {
59
- $tokens = $phpcsFile->getTokens();
60
-
61
- foreach ($this->removedGlobalVariables as $variable => $versionList) {
62
- if (strtolower($tokens[$stackPtr]['content']) == '$' . strtolower($variable)) {
63
- $error = '';
64
- $isErrored = false;
65
- foreach ($versionList as $version => $status) {
66
- if ($version != 'alternative') {
67
- if ($status == -1 || $status == 0) {
68
- if ($this->supportsAbove($version)) {
69
- switch ($status) {
70
- case -1:
71
- $error .= 'deprecated since PHP ' . $version . ' and ';
72
- break;
73
- case 0:
74
- $isErrored = true;
75
- $error .= 'removed since PHP ' . $version . ' and ';
76
- break 2;
77
- }
78
- }
79
- }
80
- }
81
- }
82
- if (strlen($error) > 0) {
83
- $error = "Global variable '" . $variable . "' is " . $error;
84
- $error = substr($error, 0, strlen($error) - 5);
85
- if (!is_null($versionList['alternative'])) {
86
- $error .= ' - use ' . $versionList['alternative'] . ' instead.';
87
- }
88
- if ($isErrored === true) {
89
- $phpcsFile->addError($error, $stackPtr);
90
- } else {
91
- $phpcsFile->addWarning($error, $stackPtr);
92
  }
93
  }
94
  }
95
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  }//end process()
98
 
56
  */
57
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58
  {
59
+ $tokens = $phpcsFile->getTokens();
60
+ $varNameUc = strtoupper(substr($tokens[$stackPtr]['content'], 1));
61
+
62
+ if (isset($this->removedGlobalVariables[$varNameUc]) === false) {
63
+ return;
64
+ }
65
+
66
+ $versionList = $this->removedGlobalVariables[$varNameUc];
67
+
68
+ $error = '';
69
+ $isError = false;
70
+ foreach ($versionList as $version => $status) {
71
+ if ($version !== 'alternative' && ($status === -1 || $status === 0)) {
72
+ if ($this->supportsAbove($version)) {
73
+ switch ($status) {
74
+ case -1:
75
+ $error .= 'deprecated since PHP ' . $version . ' and ';
76
+ break;
77
+ case 0:
78
+ $isError = true;
79
+ $error .= 'removed since PHP ' . $version . ' and ';
80
+ break 2;
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
  }
83
  }
84
  }
85
+ if (strlen($error) > 0) {
86
+ $error = "Global variable '%s' is " . $error;
87
+ $error = substr($error, 0, strlen($error) - 5);
88
+ $data = array(
89
+ $tokens[$stackPtr]['content']
90
+ );
91
+ if (isset($versionList['alternative'])) {
92
+ $error .= ' - use %s instead.';
93
+ $data[] = $versionList['alternative'];
94
+ }
95
+ if ($isError === true) {
96
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
97
+ } else {
98
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
99
+ }
100
+ }
101
 
102
  }//end process()
103
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = true;
34
-
35
  /**
36
  * List of functions using the algorithm as parameter (always the first parameter)
37
  *
25
  class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * List of functions using the algorithm as parameter (always the first parameter)
30
  *
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Wim Godden <wim.godden@cu.be>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Wim Godden <wim.godden@cu.be>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extends PHPCompatibility_Sniff
18
+ {
19
+
20
+ /**
21
+ * A list of function parameters, which were required in older versions and became optional later on.
22
+ *
23
+ * The array lists : version number with true (required) and false (optional).
24
+ *
25
+ * The index is the location of the parameter in the parameter list, starting at 0 !
26
+ * If's sufficient to list the last version in which the parameter was still required.
27
+ *
28
+ * @var array
29
+ */
30
+ protected $functionParameters = array(
31
+ 'preg_match_all' => array(
32
+ 2 => array(
33
+ 'name' => 'matches',
34
+ '5.3' => true,
35
+ '5.4' => false,
36
+ ),
37
+ ),
38
+ 'stream_socket_enable_crypto' => array(
39
+ 2 => array(
40
+ 'name' => 'crypto_type',
41
+ '5.5' => true,
42
+ '5.6' => false,
43
+ ),
44
+ ),
45
+ );
46
+
47
+
48
+ /**
49
+ * Returns an array of tokens this test wants to listen for.
50
+ *
51
+ * @return array
52
+ */
53
+ public function register()
54
+ {
55
+ return array(T_STRING);
56
+ }//end register()
57
+
58
+ /**
59
+ * Processes this test, when one of its tokens is encountered.
60
+ *
61
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
62
+ * @param int $stackPtr The position of the current token in
63
+ * the stack passed in $tokens.
64
+ *
65
+ * @return void
66
+ */
67
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
+ {
69
+ $tokens = $phpcsFile->getTokens();
70
+
71
+ $ignore = array(
72
+ T_DOUBLE_COLON,
73
+ T_OBJECT_OPERATOR,
74
+ T_FUNCTION,
75
+ T_CONST,
76
+ );
77
+
78
+ $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
79
+ if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
80
+ // Not a call to a PHP function.
81
+ return;
82
+ }
83
+
84
+ $function = strtolower($tokens[$stackPtr]['content']);
85
+
86
+ if (isset($this->functionParameters[$function]) === false) {
87
+ return;
88
+ }
89
+
90
+ $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
91
+ if ($parameterCount === 0) {
92
+ return;
93
+ }
94
+
95
+ // If the parameter count returned > 0, we know there will be valid open parenthesis.
96
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
97
+ $parameterOffsetFound = $parameterCount - 1;
98
+ $requiredVersion = null;
99
+ $parameterName = null;
100
+
101
+ foreach($this->functionParameters[$function] as $offset => $parameterDetails) {
102
+ if ($offset > $parameterOffsetFound) {
103
+ foreach ($parameterDetails as $version => $present) {
104
+ if ($version !== 'name' && $present === true && $this->supportsBelow($version)) {
105
+ $requiredVersion = $version;
106
+ $parameterName = $parameterDetails['name'];
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ if (isset($requiredVersion, $parameterName)) {
113
+
114
+ $error = 'The "%s" parameter for function %s is missing, but was required for PHP version %s and lower';
115
+ $errorCode = 'MissingRequiredParameter';
116
+ $data = array(
117
+ $parameterName,
118
+ $function,
119
+ $requiredVersion,
120
+ );
121
+ $phpcsFile->addError($error, $openParenthesis, $errorCode, $data);
122
+ }
123
+
124
+ }//end process()
125
+
126
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ShortArraySniff.php CHANGED
@@ -56,4 +56,4 @@ class PHPCompatibility_Sniffs_PHP_ShortArraySniff extends PHPCompatibility_Sniff
56
  }
57
  }//end process()
58
 
59
- }//end class
56
  }
57
  }//end process()
58
 
59
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ValidIntegersSniff.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_ValidIntegersSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_ValidIntegersSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_ValidIntegersSniff extends PHPCompatibility_Sniff
18
+ {
19
+ protected $isLowPHPVersion = false;
20
+
21
+ /**
22
+ * Returns an array of tokens this test wants to listen for.
23
+ *
24
+ * @return array
25
+ */
26
+ public function register()
27
+ {
28
+ $this->isLowPHPVersion = version_compare(phpversion(), '5.4', '<');
29
+
30
+ return array(
31
+ T_LNUMBER, // Binary, octal integers.
32
+ T_CONSTANT_ENCAPSED_STRING, // Hex numeric string.
33
+ );
34
+
35
+ }//end register()
36
+
37
+
38
+ /**
39
+ * Processes this test, when one of its tokens is encountered.
40
+ *
41
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
42
+ * @param int $stackPtr The position of the current token in
43
+ * the stack.
44
+ *
45
+ * @return void
46
+ */
47
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48
+ {
49
+ $tokens = $phpcsFile->getTokens();
50
+ $token = $tokens[$stackPtr];
51
+
52
+ if ($this->couldBeBinaryInteger($tokens, $stackPtr) === true) {
53
+ if ($this->supportsBelow('5.3')) {
54
+ $error = 'Binary integer literals were not present in PHP version 5.3 or earlier. Found: %s';
55
+ if ($this->isLowPHPVersion === false) {
56
+ $data = array($token['content']);
57
+ }
58
+ else {
59
+ $data = array($this->getBinaryInteger($phpcsFile, $tokens, $stackPtr));
60
+ }
61
+ $phpcsFile->addError($error, $stackPtr, 'BinaryIntegerFound', $data);
62
+ }
63
+
64
+ if ($this->isInvalidBinaryInteger($tokens, $stackPtr) === true) {
65
+ $error = 'Invalid binary integer detected. Found: %s';
66
+ $data = array($this->getBinaryInteger($phpcsFile, $tokens, $stackPtr));
67
+ $phpcsFile->addError($error, $stackPtr, 'InvalidBinaryIntegerFound', $data);
68
+ }
69
+ return;
70
+ }
71
+
72
+ $data = array( $token['content'] );
73
+ if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) {
74
+ $error = 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s';
75
+ $isError = $this->supportsAbove('7.0');
76
+
77
+ if ($isError === true) {
78
+ $phpcsFile->addError($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
79
+ } else {
80
+ $phpcsFile->addWarning($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
81
+ }
82
+
83
+ return;
84
+ }
85
+
86
+ if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) {
87
+ $error = 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s';
88
+ $isError = $this->supportsAbove('7.0');
89
+
90
+ if ($isError === true) {
91
+ $phpcsFile->addError($error, $stackPtr, 'HexNumericStringFound', $data);
92
+ } else {
93
+ $phpcsFile->addWarning($error, $stackPtr, 'HexNumericStringFound', $data);
94
+ }
95
+ return;
96
+ }
97
+
98
+ }//end process()
99
+
100
+
101
+ /**
102
+ * Could the current token an potentially be a binary integer ?
103
+ *
104
+ * @param array $token Token stack.
105
+ * @param int $stackPtr The current position in the token stack.
106
+ *
107
+ * @return bool
108
+ */
109
+ private function couldBeBinaryInteger($tokens, $stackPtr) {
110
+ $token = $tokens[$stackPtr];
111
+
112
+ if ($token['code'] !== T_LNUMBER) {
113
+ return false;
114
+ }
115
+
116
+ if ($this->isLowPHPVersion === false) {
117
+ return (preg_match('`^0b[0-1]+$`D', $token['content']) === 1);
118
+ }
119
+ // Pre-5.4, binary strings are tokenized as T_LNUMBER (0) + T_STRING ("b01010101").
120
+ // At this point, we don't yet care whether it's a valid binary int, that's a separate check.
121
+ else {
122
+ return($token['content'] === '0' && $tokens[$stackPtr+1]['code'] === T_STRING && preg_match('`^b[0-9]+$`D', $tokens[$stackPtr+1]['content']) === 1);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Is the current token an invalid binary integer ?
128
+ *
129
+ * @param array $token Token stack.
130
+ * @param int $stackPtr The current position in the token stack.
131
+ *
132
+ * @return bool
133
+ */
134
+ private function isInvalidBinaryInteger($tokens, $stackPtr) {
135
+ if ($this->couldBeBinaryInteger($tokens, $stackPtr) === false) {
136
+ return false;
137
+ }
138
+
139
+ if ($this->isLowPHPVersion === false) {
140
+ // If it's an invalid binary int, the token will be split into two T_LNUMBER tokens.
141
+ return ($tokens[$stackPtr+1]['code'] === T_LNUMBER);
142
+ }
143
+ else {
144
+ return (preg_match('`^b[0-1]+$`D', $tokens[$stackPtr+1]['content']) === 0);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Retrieve the content of the tokens which together look like a binary integer.
150
+ *
151
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
152
+ * @param array $token Token stack.
153
+ * @param int $stackPtr The position of the current token in
154
+ * the stack.
155
+ *
156
+ * @return string
157
+ */
158
+ private function getBinaryInteger(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) {
159
+ $length = 2; // PHP < 5.4 T_LNUMBER + T_STRING
160
+
161
+ if ($this->isLowPHPVersion === false) {
162
+ $i = $stackPtr;
163
+ while ($tokens[$i]['code'] === T_LNUMBER) {
164
+ $i++;
165
+ }
166
+ $length = ($i - $stackPtr);
167
+ }
168
+
169
+ return $phpcsFile->getTokensAsString($stackPtr, $length);
170
+ }
171
+
172
+ /**
173
+ * Is the current token an invalid octal integer ?
174
+ *
175
+ * @param array $token Token stack.
176
+ * @param int $stackPtr The current position in the token stack.
177
+ *
178
+ * @return bool
179
+ */
180
+ private function isInvalidOctalInteger($tokens, $stackPtr) {
181
+ $token = $tokens[$stackPtr];
182
+
183
+ if ($token['code'] === T_LNUMBER && preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $token['content']) === 1) {
184
+ return true;
185
+ }
186
+
187
+ return false;
188
+ }
189
+
190
+ /**
191
+ * Is the current token a hexidecimal numeric string ?
192
+ *
193
+ * @param array $token Token stack.
194
+ * @param int $stackPtr The current position in the token stack.
195
+ *
196
+ * @return bool
197
+ */
198
+ private function isHexidecimalNumericString($tokens, $stackPtr) {
199
+ $token = $tokens[$stackPtr];
200
+
201
+ if ($token['code'] === T_CONSTANT_ENCAPSED_STRING && preg_match('`^([\'"])0x[a-f0-9]+\1$`iD', $token['content']) === 1) {
202
+ return true;
203
+ }
204
+
205
+ return false;
206
+ }
207
+
208
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/ruleset.xml CHANGED
@@ -1,5 +1,23 @@
1
  <?xml version="1.0"?>
2
 
3
- <ruleset name="PHPCompatibility_CodeSniffer">
4
- <description>Coding Standard that checks for PHP version compatibility.</description>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  </ruleset>
1
  <?xml version="1.0"?>
2
 
3
+ <ruleset name="PHPCompatibility">
4
+ <description>Coding Standard that checks for PHP version compatibility.</description>
5
+
6
+ <!-- This rule covers checking for non-magic methods using __ prefix. -->
7
+ <!-- Covers part 2 of issue 64: https://github.com/wimg/PHPCompatibility/issues/64 -->
8
+ <rule ref="Generic.NamingConventions.CamelCapsFunctionName">
9
+ <exclude name="Generic.NamingConventions.CamelCapsFunctionName.NotCamelCaps" />
10
+ <exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps" />
11
+ </rule>
12
+ <rule ref="Generic.NamingConventions.CamelCapsFunctionName.MethodDoubleUnderscore">
13
+ <type>warning</type>
14
+ <!-- Original message: Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore -->
15
+ <message>Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use</message>
16
+ </rule>
17
+ <rule ref="Generic.NamingConventions.CamelCapsFunctionName.FunctionDoubleUnderscore">
18
+ <type>warning</type>
19
+ <!-- Original message: Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore -->
20
+ <message>Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use</message>
21
+ </rule>
22
+
23
  </ruleset>
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php CHANGED
@@ -336,6 +336,7 @@ class PSR2_Sniffs_Classes_ClassDeclarationSniff extends PEAR_Sniffs_Classes_Clas
336
  } else if ($tokens[($className - 1)]['code'] !== T_NS_SEPARATOR
337
  || $tokens[($className - 2)]['code'] !== T_STRING
338
  ) {
 
339
  if ($tokens[($className - 1)]['code'] === T_COMMA
340
  || ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR
341
  && $tokens[($className - 2)]['code'] === T_COMMA)
@@ -369,7 +370,8 @@ class PSR2_Sniffs_Classes_ClassDeclarationSniff extends PEAR_Sniffs_Classes_Clas
369
  }//end if
370
  }//end if
371
 
372
- if ($tokens[($className + 1)]['code'] !== T_NS_SEPARATOR
 
373
  && $tokens[($className + 1)]['code'] !== T_COMMA
374
  ) {
375
  if ($i !== ($classCount - 1)) {
336
  } else if ($tokens[($className - 1)]['code'] !== T_NS_SEPARATOR
337
  || $tokens[($className - 2)]['code'] !== T_STRING
338
  ) {
339
+ // Not part of a longer fully qualified class name.
340
  if ($tokens[($className - 1)]['code'] === T_COMMA
341
  || ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR
342
  && $tokens[($className - 2)]['code'] === T_COMMA)
370
  }//end if
371
  }//end if
372
 
373
+ if ($checkingImplements === true
374
+ && $tokens[($className + 1)]['code'] !== T_NS_SEPARATOR
375
  && $tokens[($className + 1)]['code'] !== T_COMMA
376
  ) {
377
  if ($i !== ($classCount - 1)) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PSR2_Sniffs_Methods_FunctionClosingBraceSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * PSR2_Sniffs_Methods_FunctionClosingBraceSniff.
17
+ *
18
+ * Checks that the closing brace of a function goes directly after the body.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class PSR2_Sniffs_Methods_FunctionClosingBraceSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+
32
+ /**
33
+ * Returns an array of tokens this test wants to listen for.
34
+ *
35
+ * @return array
36
+ */
37
+ public function register()
38
+ {
39
+ return array(
40
+ T_FUNCTION,
41
+ T_CLOSURE,
42
+ );
43
+
44
+ }//end register()
45
+
46
+
47
+ /**
48
+ * Processes this test, when one of its tokens is encountered.
49
+ *
50
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
+ * @param int $stackPtr The position of the current token
52
+ * in the stack passed in $tokens.
53
+ *
54
+ * @return void
55
+ */
56
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
57
+ {
58
+ $tokens = $phpcsFile->getTokens();
59
+
60
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
61
+ // Probably an interface method.
62
+ return;
63
+ }
64
+
65
+ $closeBrace = $tokens[$stackPtr]['scope_closer'];
66
+ $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true);
67
+ $found = ($tokens[$closeBrace]['line'] - $tokens[$prevContent]['line'] - 1);
68
+
69
+ if ($found < 0) {
70
+ // Brace isn't on a new line, so not handled by us.
71
+ return;
72
+ }
73
+
74
+ if ($found === 0) {
75
+ // All is good.
76
+ return;
77
+ }
78
+
79
+ $error = 'Function closing brace must go on the next line following the body; found %s blank lines before brace';
80
+ $data = array($found);
81
+ $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeClose', $data);
82
+
83
+ if ($fix === true) {
84
+ $phpcsFile->fixer->beginChangeset();
85
+ for ($i = ($prevContent + 1); $i < $closeBrace; $i++) {
86
+ if ($tokens[$i]['line'] === $tokens[$prevContent]['line']) {
87
+ continue;
88
+ }
89
+
90
+ // Don't remove any identation before the brace.
91
+ if ($tokens[$i]['line'] === $tokens[$closeBrace]['line']) {
92
+ break;
93
+ }
94
+
95
+ $phpcsFile->fixer->replaceToken($i, '');
96
+ }
97
+
98
+ $phpcsFile->fixer->endChangeset();
99
+ }
100
+
101
+ }//end process()
102
+
103
+
104
+ }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/ruleset.xml CHANGED
@@ -109,6 +109,7 @@
109
  <!-- checked in Methods/MethodDeclarationSniff -->
110
 
111
  <!-- Method names MUST NOT be declared with a space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. -->
 
112
  <rule ref="Squiz.Functions.FunctionDeclaration"/>
113
  <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
114
 
109
  <!-- checked in Methods/MethodDeclarationSniff -->
110
 
111
  <!-- Method names MUST NOT be declared with a space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. -->
112
+ <!-- checked in Methods/FunctionClosingBraceSniff -->
113
  <rule ref="Squiz.Functions.FunctionDeclaration"/>
114
  <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
115
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php CHANGED
@@ -120,11 +120,11 @@ class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff
120
 
121
  $phpcsFile->fixer->endChangeset();
122
  }
123
-
124
- // We can return here because there is nothing else to check. All code
125
- // below can assume that the array is not empty.
126
- return;
127
  }
 
 
 
 
128
  }
129
 
130
  if ($tokens[$arrayStart]['line'] === $tokens[$arrayEnd]['line']) {
@@ -855,7 +855,7 @@ class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff
855
 
856
  if ($fix === true) {
857
  // Find the end of the line and put a comma there.
858
- for ($i = ($index['value'] + 1); $i < $phpcsFile->numTokens; $i++) {
859
  if ($tokens[$i]['line'] > $valueLine) {
860
  break;
861
  }
120
 
121
  $phpcsFile->fixer->endChangeset();
122
  }
 
 
 
 
123
  }
124
+
125
+ // We can return here because there is nothing else to check. All code
126
+ // below can assume that the array is not empty.
127
+ return;
128
  }
129
 
130
  if ($tokens[$arrayStart]['line'] === $tokens[$arrayEnd]['line']) {
855
 
856
  if ($fix === true) {
857
  // Find the end of the line and put a comma there.
858
+ for ($i = ($index['value'] + 1); $i < $arrayEnd; $i++) {
859
  if ($tokens[$i]['line'] > $valueLine) {
860
  break;
861
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php CHANGED
@@ -30,6 +30,13 @@
30
  class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
 
 
 
 
 
 
 
33
 
34
  /**
35
  * Returns an array of tokens this test wants to listen for.
@@ -57,6 +64,16 @@ class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
57
  */
58
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
59
  {
 
 
 
 
 
 
 
 
 
 
60
  $tokens = $phpcsFile->getTokens();
61
 
62
  // If it's an inline comment, return.
@@ -169,9 +186,18 @@ class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
169
  $error = 'Block comment text must start on a new line';
170
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoNewLine');
171
  if ($fix === true) {
 
 
 
 
 
 
 
 
 
172
  $comment = preg_replace(
173
  '/^(\s*\/\*\*?)/',
174
- '$1'.$phpcsFile->eolChar.' ',
175
  $tokens[$stackPtr]['content'],
176
  1
177
  );
@@ -179,7 +205,7 @@ class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
179
  }
180
 
181
  return;
182
- }
183
 
184
  $starColumn = ($tokens[$stackPtr]['column'] + 3);
185
 
@@ -209,10 +235,18 @@ class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
209
  $error = 'First line of comment not aligned correctly; expected %s but found %s';
210
  $fix = $phpcsFile->addFixableError($error, $commentLines[1], 'FirstLineIndent', $data);
211
  if ($fix === true) {
212
- $newContent = str_repeat(' ', $starColumn).ltrim($content);
213
- $phpcsFile->fixer->replaceToken($commentLines[1], $newContent);
 
 
 
 
 
 
 
 
214
  }
215
- }
216
 
217
  if (preg_match('/^\p{Ll}/u', $commentText) === 1) {
218
  $error = 'Block comments must start with a capital letter';
@@ -252,10 +286,18 @@ class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
252
  $error = 'Comment line indented incorrectly; expected at least %s but found %s';
253
  $fix = $phpcsFile->addFixableError($error, $line, 'LineIndent', $data);
254
  if ($fix === true) {
255
- $newContent = str_repeat(' ', $starColumn).ltrim($tokens[$line]['content']);
256
- $phpcsFile->fixer->replaceToken($line, $newContent);
 
 
 
 
 
 
 
 
257
  }
258
- }
259
  }//end foreach
260
 
261
  // Finally, test the last line is correct.
30
  class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
33
+ /**
34
+ * The --tab-width CLI value that is being used.
35
+ *
36
+ * @var int
37
+ */
38
+ private $_tabWidth = null;
39
+
40
 
41
  /**
42
  * Returns an array of tokens this test wants to listen for.
64
  */
65
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
  {
67
+ if ($this->_tabWidth === null) {
68
+ $cliValues = $phpcsFile->phpcs->cli->getCommandLineValues();
69
+ if (isset($cliValues['tabWidth']) === false || $cliValues['tabWidth'] === 0) {
70
+ // We have no idea how wide tabs are, so assume 4 spaces for fixing.
71
+ $this->_tabWidth = 4;
72
+ } else {
73
+ $this->_tabWidth = $cliValues['tabWidth'];
74
+ }
75
+ }
76
+
77
  $tokens = $phpcsFile->getTokens();
78
 
79
  // If it's an inline comment, return.
186
  $error = 'Block comment text must start on a new line';
187
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoNewLine');
188
  if ($fix === true) {
189
+ $indent = '';
190
+ if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
191
+ if (isset($tokens[($stackPtr - 1)]['orig_content']) === true) {
192
+ $indent = $tokens[($stackPtr - 1)]['orig_content'];
193
+ } else {
194
+ $indent = $tokens[($stackPtr - 1)]['content'];
195
+ }
196
+ }
197
+
198
  $comment = preg_replace(
199
  '/^(\s*\/\*\*?)/',
200
+ '$1'.$phpcsFile->eolChar.$indent,
201
  $tokens[$stackPtr]['content'],
202
  1
203
  );
205
  }
206
 
207
  return;
208
+ }//end if
209
 
210
  $starColumn = ($tokens[$stackPtr]['column'] + 3);
211
 
235
  $error = 'First line of comment not aligned correctly; expected %s but found %s';
236
  $fix = $phpcsFile->addFixableError($error, $commentLines[1], 'FirstLineIndent', $data);
237
  if ($fix === true) {
238
+ if (isset($tokens[$commentLines[1]]['orig_content']) === true
239
+ && $tokens[$commentLines[1]]['orig_content'][0] === "\t"
240
+ ) {
241
+ // Line is indented using tabs.
242
+ $padding = str_repeat("\t", floor($starColumn / $this->_tabWidth));
243
+ } else {
244
+ $padding = str_repeat(' ', $starColumn);
245
+ }
246
+
247
+ $phpcsFile->fixer->replaceToken($commentLines[1], $padding.ltrim($content));
248
  }
249
+ }//end if
250
 
251
  if (preg_match('/^\p{Ll}/u', $commentText) === 1) {
252
  $error = 'Block comments must start with a capital letter';
286
  $error = 'Comment line indented incorrectly; expected at least %s but found %s';
287
  $fix = $phpcsFile->addFixableError($error, $line, 'LineIndent', $data);
288
  if ($fix === true) {
289
+ if (isset($tokens[$line]['orig_content']) === true
290
+ && $tokens[$line]['orig_content'][0] === "\t"
291
+ ) {
292
+ // Line is indented using tabs.
293
+ $padding = str_repeat("\t", floor($starColumn / $this->_tabWidth));
294
+ } else {
295
+ $padding = str_repeat(' ', $starColumn);
296
+ }
297
+
298
+ $phpcsFile->fixer->replaceToken($line, $padding.ltrim($tokens[$line]['content']));
299
  }
300
+ }//end if
301
  }//end foreach
302
 
303
  // Finally, test the last line is correct.
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php CHANGED
@@ -84,17 +84,16 @@ class Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff extends PHP_CodeSniff
84
  return;
85
  }
86
 
87
- // Find the position where the current function scope ends.
88
- $currScopeEnd = 0;
89
- if (isset($tokens[$currScope]['scope_closer']) === true) {
90
- $currScopeEnd = $tokens[$currScope]['scope_closer'];
91
- }
92
 
93
  // Find all the exception type token within the current scope.
94
  $throwTokens = array();
95
  $currPos = $stackPtr;
96
- if ($currScopeEnd !== 0) {
97
- while ($currPos < $currScopeEnd && $currPos !== false) {
 
 
 
98
  /*
99
  If we can't find a NEW, we are probably throwing
100
  a variable, so we ignore it, but they still need to
@@ -136,10 +135,14 @@ class Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff extends PHP_CodeSniff
136
  }
137
  }//end if
138
  }//end if
 
 
 
 
139
 
140
- $currPos = $phpcsFile->findNext(T_THROW, ($currPos + 1), $currScopeEnd);
141
- }//end while
142
- }//end if
143
 
144
  // Only need one @throws tag for each type of exception thrown.
145
  $throwTokens = array_unique($throwTokens);
84
  return;
85
  }
86
 
87
+ $currScopeEnd = $tokens[$currScope]['scope_closer'];
 
 
 
 
88
 
89
  // Find all the exception type token within the current scope.
90
  $throwTokens = array();
91
  $currPos = $stackPtr;
92
+ $foundThrows = false;
93
+ while ($currPos < $currScopeEnd && $currPos !== false) {
94
+ if ($phpcsFile->hasCondition($currPos, T_CLOSURE) === false) {
95
+ $foundThrows = true;
96
+
97
  /*
98
  If we can't find a NEW, we are probably throwing
99
  a variable, so we ignore it, but they still need to
135
  }
136
  }//end if
137
  }//end if
138
+ }//end if
139
+
140
+ $currPos = $phpcsFile->findNext(T_THROW, ($currPos + 1), $currScopeEnd);
141
+ }//end while
142
 
143
+ if ($foundThrows === false) {
144
+ return;
145
+ }
146
 
147
  // Only need one @throws tag for each type of exception thrown.
148
  $throwTokens = array_unique($throwTokens);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php CHANGED
@@ -311,7 +311,7 @@ class Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff implements
311
  $nextToken++;
312
  }
313
 
314
- if ($nextToken !== $nextParam) {
315
  // There was a type hint, so check the spacing between
316
  // the hint and the variable as well.
317
  $hint = $tokens[$nextToken]['content'];
311
  $nextToken++;
312
  }
313
 
314
+ if ($tokens[$nextToken]['code'] !== T_ELLIPSIS && $nextToken !== $nextParam) {
315
  // There was a type hint, so check the spacing between
316
  // the hint and the variable as well.
317
  $hint = $tokens[$nextToken]['content'];
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php CHANGED
@@ -30,6 +30,25 @@
30
  class Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  /**
35
  * Returns an array of tokens this test wants to listen for.
@@ -95,11 +114,10 @@ class Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sni
95
  }
96
 
97
  // Make sure it is an inbuilt PHP function.
98
- // PHP_CodeSniffer doesn't include/require any files, so no
99
- // user defined global functions can exist, except for
100
- // PHP_CodeSniffer ones.
101
  $content = $tokens[$stackPtr]['content'];
102
- if (function_exists($content) === false) {
103
  return;
104
  }
105
 
30
  class Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
33
+ /**
34
+ * String -> int hash map of all php built in function names
35
+ *
36
+ * @var array
37
+ */
38
+ private $_builtInFunctions;
39
+
40
+
41
+ /**
42
+ * Construct the LowercasePHPFunctionSniff
43
+ */
44
+ public function __construct()
45
+ {
46
+
47
+ $allFunctions = get_defined_functions();
48
+ $this->_builtInFunctions = array_flip($allFunctions['internal']);
49
+
50
+ }//end __construct()
51
+
52
 
53
  /**
54
  * Returns an array of tokens this test wants to listen for.
114
  }
115
 
116
  // Make sure it is an inbuilt PHP function.
117
+ // PHP_CodeSniffer can possibly include user defined functions
118
+ // through the use of vendor/autoload.php.
 
119
  $content = $tokens[$stackPtr]['content'];
120
+ if (isset($this->_builtInFunctions[strtolower($content)]) === false) {
121
  return;
122
  }
123
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php CHANGED
@@ -111,19 +111,19 @@ class Squiz_Sniffs_PHP_NonExecutableCodeSniff implements PHP_CodeSniffer_Sniff
111
  $owner = $tokens[$stackPtr]['scope_condition'];
112
  if ($tokens[$owner]['code'] === T_CASE || $tokens[$owner]['code'] === T_DEFAULT) {
113
  // This token closes the scope of a CASE or DEFAULT statement
114
- // so any code between this token and the next CASE, DEFAULT or
115
  // end of SWITCH token will not be executable.
 
116
  $next = $phpcsFile->findNext(
117
  array(
118
  T_CASE,
119
  T_DEFAULT,
120
  T_CLOSE_CURLY_BRACKET,
121
  ),
122
- ($stackPtr + 1)
123
  );
124
 
125
  if ($next !== false) {
126
- $end = $phpcsFile->findNext(array(T_SEMICOLON), ($stackPtr + 1));
127
  $lastLine = $tokens[$end]['line'];
128
  for ($i = ($stackPtr + 1); $i < $next; $i++) {
129
  if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
111
  $owner = $tokens[$stackPtr]['scope_condition'];
112
  if ($tokens[$owner]['code'] === T_CASE || $tokens[$owner]['code'] === T_DEFAULT) {
113
  // This token closes the scope of a CASE or DEFAULT statement
114
+ // so any code between this statement and the next CASE, DEFAULT or
115
  // end of SWITCH token will not be executable.
116
+ $end = $phpcsFile->findEndOfStatement($stackPtr);
117
  $next = $phpcsFile->findNext(
118
  array(
119
  T_CASE,
120
  T_DEFAULT,
121
  T_CLOSE_CURLY_BRACKET,
122
  ),
123
+ ($end + 1)
124
  );
125
 
126
  if ($next !== false) {
 
127
  $lastLine = $tokens[$end]['line'];
128
  for ($i = ($stackPtr + 1); $i < $next; $i++) {
129
  if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
vendor/squizlabs/php_codesniffer/phpcs.xml.dist CHANGED
@@ -8,7 +8,6 @@
8
 
9
  <exclude-pattern>*/Tests/*</exclude-pattern>
10
 
11
- <arg name="report" value="summary"/>
12
  <arg value="np"/>
13
 
14
  <rule ref="PHPCS"/>
8
 
9
  <exclude-pattern>*/Tests/*</exclude-pattern>
10
 
 
11
  <arg value="np"/>
12
 
13
  <rule ref="PHPCS"/>
vendor/wimg/php-compatibility/.coveralls.yml CHANGED
@@ -1,3 +1,3 @@
1
  src_dir: Sniffs
2
  coverage_clover: build/logs/clover.xml
3
- json_path: build/logs/coveralls-upload.json
1
  src_dir: Sniffs
2
  coverage_clover: build/logs/clover.xml
3
+ json_path: build/logs/coveralls-upload.json
vendor/wimg/php-compatibility/.scrutinizer.yml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ filter:
2
+ excluded_paths:
3
+ - 'Tests/sniff-examples/*'
4
+
5
+ tools:
6
+ php_sim: true
7
+ php_pdepend: true
8
+ php_analyzer: true
9
+ sensiolabs_security_checker: true
10
+
11
+ checks:
12
+ php: true
vendor/wimg/php-compatibility/README.md CHANGED
@@ -20,8 +20,8 @@ Thanks to [![WPEngine](https://cu.be/img/wpengine.png)](http://wpengine.com) for
20
  Installation (method 1)
21
  -----------------------
22
 
23
- * Install [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) with `pear install PHP_CodeSniffer` (PHP_CodeSniffer 1.5.1 or later is required for full support, notices may be thrown on older versions).
24
- * Checkout this repository as `PHPCompatibility` into the `PHP/CodeSniffer/Standards` directory.
25
 
26
 
27
  Installation in Composer project (method 2)
@@ -32,8 +32,9 @@ Installation in Composer project (method 2)
32
  ```json
33
  "require-dev": {
34
  "squizlabs/php_codesniffer": "*",
35
- "wimg/php-compatibility": "dev-master",
36
- "simplyadmire/composer-plugins" : "@dev"
 
37
  },
38
 
39
  ```
@@ -50,6 +51,50 @@ Using the compatibility sniffs
50
 
51
  More information can be found on Wim Godden's [blog](http://techblog.wimgodden.be/tag/codesniffer).
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  Running the Sniff Tests
54
  -----------------------
55
  All the sniffs are fully tested with PHPUnit tests. In order to run the tests
20
  Installation (method 1)
21
  -----------------------
22
 
23
+ * Install [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) with `pear install PHP_CodeSniffer` (PHP_CodeSniffer 1.5.1 is required for 90% of the sniffs, 2.6 or later is required for full support, notices may be thrown on older versions).
24
+ * Checkout the latest release from https://github.com/wimg/PHPCompatibility/releases into the `PHP/CodeSniffer/Standards/PHPCompatibility` directory.
25
 
26
 
27
  Installation in Composer project (method 2)
32
  ```json
33
  "require-dev": {
34
  "squizlabs/php_codesniffer": "*",
35
+ "wimg/php-compatibility": "*",
36
+ "simplyadmire/composer-plugins" : "@dev",
37
+ "prefer-stable" : true
38
  },
39
 
40
  ```
51
 
52
  More information can be found on Wim Godden's [blog](http://techblog.wimgodden.be/tag/codesniffer).
53
 
54
+ Using a custom ruleset
55
+ ------------------------------
56
+ Alternatively, you can add PHPCompatibility to a custom PHPCS ruleset.
57
+
58
+ ```xml
59
+ <?xml version="1.0"?>
60
+ <ruleset name="Custom ruleset">
61
+ <description>My rules for PHP_CodeSniffer</description>
62
+
63
+ <!-- Run against the PHPCompatibility ruleset -->
64
+ <rule ref="PHPCompatibility" />
65
+
66
+ <!-- Run against a second ruleset -->
67
+ <rule ref="PSR2" />
68
+
69
+ </ruleset>
70
+ ```
71
+
72
+ You can also set the `testVersion` from within the ruleset:
73
+ ```xml
74
+ <arg name="testVersion" value="5.3-5.5"/>
75
+ ```
76
+
77
+ Other advanced options, such as changing the message type or severity, as described in the [PHPCS Annotated ruleset](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) wiki page are, of course, also supported.
78
+
79
+
80
+ ##### PHPCompatibility specific options
81
+
82
+ At this moment, there is one sniff which has a property which can be set via the ruleset. More custom properties may become available in the future.
83
+
84
+ The `PHPCompatibility.PHP.RemovedExtensions` sniff checks for removed extensions based on the function prefix used for these extensions.
85
+ This might clash with userland function using the same function prefix.
86
+
87
+ To whitelist userland functions, you can pass a comma-delimited list of function names to the sniff.
88
+ ```xml
89
+ <!-- Whitelist the mysql_to_rfc3339() and mysql_another_function() functions. -->
90
+ <rule ref="PHPCompatibility.PHP.RemovedExtensions">
91
+ <properties>
92
+ <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
93
+ </properties>
94
+ </rule>
95
+ ```
96
+
97
+
98
  Running the Sniff Tests
99
  -----------------------
100
  All the sniffs are fully tested with PHPUnit tests. In order to run the tests
vendor/wimg/php-compatibility/Sniff.php CHANGED
@@ -41,38 +41,43 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
41
  private function getTestVersion()
42
  {
43
  /**
44
- * var $testVersion will hold an array containing min/max version of PHP
45
  * that we are checking against (see above). If only a single version
46
  * number is specified, then this is used as both the min and max.
47
  */
48
- static $arrTestVersions;
49
 
50
- if (!isset($testVersion)) {
51
- $testVersion = PHP_CodeSniffer::getConfigData('testVersion');
52
- $testVersion = trim($testVersion);
53
 
54
- $arrTestVersions = array(null, null);
 
 
55
  if (preg_match('/^\d+\.\d+$/', $testVersion)) {
56
- $arrTestVersions = array($testVersion, $testVersion);
57
  }
58
  elseif (preg_match('/^(\d+\.\d+)\s*-\s*(\d+\.\d+)$/', $testVersion,
59
  $matches))
60
  {
61
- if (version_compare($matches[1], $matches[2], ">")) {
62
  trigger_error("Invalid range in testVersion setting: '"
63
  . $testVersion . "'", E_USER_WARNING);
64
  }
65
  else {
66
- $arrTestVersions = array($matches[1], $matches[2]);
67
  }
68
  }
69
- elseif (!$testVersion == "") {
70
  trigger_error("Invalid testVersion setting: '" . $testVersion
71
  . "'", E_USER_WARNING);
72
  }
73
  }
74
 
75
- return $arrTestVersions;
 
 
 
 
 
76
  }
77
 
78
  public function supportsAbove($phpVersion)
@@ -103,4 +108,681 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
103
  }
104
  }//end supportsBelow()
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }//end class
41
  private function getTestVersion()
42
  {
43
  /**
44
+ * var $arrTestVersions will hold an array containing min/max version of PHP
45
  * that we are checking against (see above). If only a single version
46
  * number is specified, then this is used as both the min and max.
47
  */
48
+ static $arrTestVersions = array();
49
 
50
+ $testVersion = trim(PHP_CodeSniffer::getConfigData('testVersion'));
 
 
51
 
52
+ if (!isset($arrTestVersions[$testVersion]) && !empty($testVersion)) {
53
+
54
+ $arrTestVersions[$testVersion] = array(null, null);
55
  if (preg_match('/^\d+\.\d+$/', $testVersion)) {
56
+ $arrTestVersions[$testVersion] = array($testVersion, $testVersion);
57
  }
58
  elseif (preg_match('/^(\d+\.\d+)\s*-\s*(\d+\.\d+)$/', $testVersion,
59
  $matches))
60
  {
61
+ if (version_compare($matches[1], $matches[2], '>')) {
62
  trigger_error("Invalid range in testVersion setting: '"
63
  . $testVersion . "'", E_USER_WARNING);
64
  }
65
  else {
66
+ $arrTestVersions[$testVersion] = array($matches[1], $matches[2]);
67
  }
68
  }
69
+ elseif (!$testVersion == '') {
70
  trigger_error("Invalid testVersion setting: '" . $testVersion
71
  . "'", E_USER_WARNING);
72
  }
73
  }
74
 
75
+ if (isset($arrTestVersions[$testVersion])) {
76
+ return $arrTestVersions[$testVersion];
77
+ }
78
+ else {
79
+ return array(null, null);
80
+ }
81
  }
82
 
83
  public function supportsAbove($phpVersion)
108
  }
109
  }//end supportsBelow()
110
 
111
+ /**
112
+ * Returns the name(s) of the interface(s) that the specified class implements.
113
+ *
114
+ * Returns FALSE on error or if there are no implemented interface names.
115
+ *
116
+ * {@internal Duplicate of same method as introduced in PHPCS 2.7.
117
+ * Once the minimum supported PHPCS version for this sniff library goes beyond
118
+ * that, this method can be removed and call to it replaced with
119
+ * `$phpcsFile->findImplementedInterfaceNames($stackPtr)` calls.}}
120
+ *
121
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
122
+ * @param int $stackPtr The position of the class token.
123
+ *
124
+ * @return array|false
125
+ */
126
+ public function findImplementedInterfaceNames($phpcsFile, $stackPtr)
127
+ {
128
+ $tokens = $phpcsFile->getTokens();
129
+
130
+ // Check for the existence of the token.
131
+ if (isset($tokens[$stackPtr]) === false) {
132
+ return false;
133
+ }
134
+
135
+ if ($tokens[$stackPtr]['code'] !== T_CLASS) {
136
+ return false;
137
+ }
138
+
139
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
140
+ return false;
141
+ }
142
+
143
+ $classOpenerIndex = $tokens[$stackPtr]['scope_opener'];
144
+ $implementsIndex = $phpcsFile->findNext(T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
145
+ if ($implementsIndex === false) {
146
+ return false;
147
+ }
148
+
149
+ $find = array(
150
+ T_NS_SEPARATOR,
151
+ T_STRING,
152
+ T_WHITESPACE,
153
+ T_COMMA,
154
+ );
155
+
156
+ $end = $phpcsFile->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true);
157
+ $name = $phpcsFile->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1));
158
+ $name = trim($name);
159
+
160
+ if ($name === '') {
161
+ return false;
162
+ } else {
163
+ $names = explode(',', $name);
164
+ $names = array_map('trim', $names);
165
+ return $names;
166
+ }
167
+
168
+ }//end findImplementedInterfaceNames()
169
+
170
+
171
+ /**
172
+ * Checks if a function call has parameters.
173
+ *
174
+ * Expects to be passed the T_STRING stack pointer for the function call.
175
+ * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
176
+ *
177
+ * @link https://github.com/wimg/PHPCompatibility/issues/120
178
+ * @link https://github.com/wimg/PHPCompatibility/issues/152
179
+ *
180
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
181
+ * @param int $stackPtr The position of the function call token.
182
+ *
183
+ * @return bool
184
+ */
185
+ public function doesFunctionCallHaveParameters(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
186
+ {
187
+ $tokens = $phpcsFile->getTokens();
188
+
189
+ // Check for the existence of the token.
190
+ if (isset($tokens[$stackPtr]) === false) {
191
+ return false;
192
+ }
193
+
194
+ if ($tokens[$stackPtr]['code'] !== T_STRING) {
195
+ return false;
196
+ }
197
+
198
+ // Next non-empty token should be the open parenthesis.
199
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
200
+ if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) {
201
+ return false;
202
+ }
203
+
204
+ if (isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
205
+ return false;
206
+ }
207
+
208
+ $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
209
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $openParenthesis + 1, $closeParenthesis + 1, true);
210
+
211
+ if ($nextNonEmpty === $closeParenthesis) {
212
+ // No parameters.
213
+ return false;
214
+ }
215
+
216
+ return true;
217
+ }
218
+
219
+
220
+ /**
221
+ * Count the number of parameters a function call has been passed.
222
+ *
223
+ * Expects to be passed the T_STRING stack pointer for the function call.
224
+ * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
225
+ *
226
+ * @link https://github.com/wimg/PHPCompatibility/issues/111
227
+ * @link https://github.com/wimg/PHPCompatibility/issues/114
228
+ * @link https://github.com/wimg/PHPCompatibility/issues/151
229
+ *
230
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
231
+ * @param int $stackPtr The position of the function call token.
232
+ *
233
+ * @return int
234
+ */
235
+ public function getFunctionCallParameterCount(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
236
+ {
237
+ if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) {
238
+ return 0;
239
+ }
240
+
241
+ // Ok, we know we have a T_STRING with parameters and valid open & close parenthesis.
242
+ $tokens = $phpcsFile->getTokens();
243
+
244
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
245
+ $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
246
+
247
+ // Which nesting level is the one we are interested in ?
248
+ $nestedParenthesisCount = 1;
249
+ if (isset($tokens[$openParenthesis]['nested_parenthesis'])) {
250
+ $nestedParenthesisCount = count($tokens[$openParenthesis]['nested_parenthesis']) + 1;
251
+ }
252
+
253
+ $nextComma = $openParenthesis;
254
+ $cnt = 0;
255
+ while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
256
+ // Ignore comma's at a lower nesting level.
257
+ if (
258
+ $tokens[$nextComma]['type'] == 'T_COMMA'
259
+ &&
260
+ isset($tokens[$nextComma]['nested_parenthesis'])
261
+ &&
262
+ count($tokens[$nextComma]['nested_parenthesis']) != $nestedParenthesisCount
263
+ ) {
264
+ continue;
265
+ }
266
+
267
+ // Ignore closing parenthesis if not 'ours'.
268
+ if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
269
+ continue;
270
+ }
271
+
272
+ $cnt++;
273
+ }
274
+
275
+ return $cnt;
276
+ }
277
+
278
+
279
+ /**
280
+ * Verify whether a token is within a class scope.
281
+ *
282
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
283
+ * @param int $stackPtr The position of the token.
284
+ * @param bool $strict Whether to strictly check for the T_CLASS
285
+ * scope or also accept interfaces and traits
286
+ * as scope.
287
+ *
288
+ * @return bool True if within class scope, false otherwise.
289
+ */
290
+ public function inClassScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
291
+ {
292
+ $tokens = $phpcsFile->getTokens();
293
+
294
+ // Check for the existence of the token.
295
+ if (isset($tokens[$stackPtr]) === false) {
296
+ return false;
297
+ }
298
+
299
+ // No conditions = no scope.
300
+ if (empty($tokens[$stackPtr]['conditions'])) {
301
+ return false;
302
+ }
303
+
304
+ $validScope = array(T_CLASS);
305
+ if ($strict === false) {
306
+ $validScope[] = T_INTERFACE;
307
+ $validScope[] = T_TRAIT;
308
+ }
309
+
310
+ // Check for class scope.
311
+ foreach ($tokens[$stackPtr]['conditions'] as $pointer => $type) {
312
+ if (in_array($type, $validScope, true)) {
313
+ return true;
314
+ }
315
+ }
316
+
317
+ return false;
318
+ }
319
+
320
+
321
+ /**
322
+ * Returns the fully qualified class name for a new class instantiation.
323
+ *
324
+ * Returns an empty string if the class name could not be reliably inferred.
325
+ *
326
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
327
+ * @param int $stackPtr The position of a T_NEW token.
328
+ *
329
+ * @return string
330
+ */
331
+ public function getFQClassNameFromNewToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
332
+ {
333
+ $tokens = $phpcsFile->getTokens();
334
+
335
+ // Check for the existence of the token.
336
+ if (isset($tokens[$stackPtr]) === false) {
337
+ return '';
338
+ }
339
+
340
+ if ($tokens[$stackPtr]['code'] !== T_NEW) {
341
+ return '';
342
+ }
343
+
344
+ $find = array(
345
+ T_NS_SEPARATOR,
346
+ T_STRING,
347
+ T_NAMESPACE,
348
+ T_WHITESPACE,
349
+ );
350
+
351
+ $start = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
352
+ $end = $phpcsFile->findNext($find, ($start + 1), null, true, null, true);
353
+ $className = $phpcsFile->getTokensAsString($start, ($end - $start));
354
+ $className = trim($className);
355
+
356
+ return $this->getFQName($phpcsFile, $stackPtr, $className);
357
+ }
358
+
359
+
360
+ /**
361
+ * Returns the fully qualified name of the class that the specified class extends.
362
+ *
363
+ * Returns an empty string if the class does not extend another class or if
364
+ * the class name could not be reliably inferred.
365
+ *
366
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
367
+ * @param int $stackPtr The position of a T_CLASS token.
368
+ *
369
+ * @return string
370
+ */
371
+ public function getFQExtendedClassName(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
372
+ {
373
+ $tokens = $phpcsFile->getTokens();
374
+
375
+ // Check for the existence of the token.
376
+ if (isset($tokens[$stackPtr]) === false) {
377
+ return '';
378
+ }
379
+
380
+ if ($tokens[$stackPtr]['code'] !== T_CLASS) {
381
+ return '';
382
+ }
383
+
384
+ $extends = $phpcsFile->findExtendedClassName($stackPtr);
385
+ if (empty($extends) || is_string($extends) === false) {
386
+ return '';
387
+ }
388
+
389
+ return $this->getFQName($phpcsFile, $stackPtr, $extends);
390
+ }
391
+
392
+
393
+ /**
394
+ * Returns the class name for the static usage of a class.
395
+ * This can be a call to a method, the use of a property or constant.
396
+ *
397
+ * Returns an empty string if the class name could not be reliably inferred.
398
+ *
399
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
400
+ * @param int $stackPtr The position of a T_NEW token.
401
+ *
402
+ * @return string
403
+ */
404
+ public function getFQClassNameFromDoubleColonToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
405
+ {
406
+ $tokens = $phpcsFile->getTokens();
407
+
408
+ // Check for the existence of the token.
409
+ if (isset($tokens[$stackPtr]) === false) {
410
+ return '';
411
+ }
412
+
413
+ if ($tokens[$stackPtr]['code'] !== T_DOUBLE_COLON) {
414
+ return '';
415
+ }
416
+
417
+ // Nothing to do if 'parent' or 'static' as we don't know how far the class tree extends.
418
+ if (in_array($tokens[$stackPtr - 1]['code'], array(T_PARENT, T_STATIC), true)) {
419
+ return '';
420
+ }
421
+
422
+ // Get the classname from the class declaration if self is used.
423
+ if ($tokens[$stackPtr - 1]['code'] === T_SELF) {
424
+ $classDeclarationPtr = $phpcsFile->findPrevious(T_CLASS, $stackPtr - 1);
425
+ if ($classDeclarationPtr === false) {
426
+ return '';
427
+ }
428
+ $className = $phpcsFile->getDeclarationName($classDeclarationPtr);
429
+ return $this->getFQName($phpcsFile, $classDeclarationPtr, $className);
430
+ }
431
+
432
+ $find = array(
433
+ T_NS_SEPARATOR,
434
+ T_STRING,
435
+ T_NAMESPACE,
436
+ T_WHITESPACE,
437
+ );
438
+
439
+ $start = ($phpcsFile->findPrevious($find, $stackPtr - 1, null, true, null, true) + 1);
440
+ $className = $phpcsFile->getTokensAsString($start, ($stackPtr - $start));
441
+ $className = trim($className);
442
+
443
+ return $this->getFQName($phpcsFile, $stackPtr, $className);
444
+ }
445
+
446
+
447
+ /**
448
+ * Get the Fully Qualified name for a class/function/constant etc.
449
+ *
450
+ * Checks if a class/function/constant name is already fully qualified and
451
+ * if not, enrich it with the relevant namespace information.
452
+ *
453
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
454
+ * @param int $stackPtr The position of the token.
455
+ * @param string $name The class / function / constant name.
456
+ *
457
+ * @return string
458
+ */
459
+ public function getFQName(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $name)
460
+ {
461
+ if (strpos($name, '\\' ) === 0) {
462
+ // Already fully qualified.
463
+ return $name;
464
+ }
465
+
466
+ // Remove the namespace keyword if used.
467
+ if (strpos($name, 'namespace\\') === 0) {
468
+ $name = substr($name, 10);
469
+ }
470
+
471
+ $namespace = $this->determineNamespace($phpcsFile, $stackPtr);
472
+
473
+ if ($namespace === '') {
474
+ return '\\' . $name;
475
+ }
476
+ else {
477
+ return '\\' . $namespace . '\\' . $name;
478
+ }
479
+ }
480
+
481
+
482
+ /**
483
+ * Is the class/function/constant name namespaced or global ?
484
+ *
485
+ * @param string $FQName Fully Qualified name of a class, function etc.
486
+ * I.e. should always start with a `\` !
487
+ *
488
+ * @return bool True if namespaced, false if global.
489
+ */
490
+ public function isNamespaced($FQName) {
491
+ if (strpos($FQName, '\\') !== 0) {
492
+ throw new PHP_CodeSniffer_Exception('$FQName must be a fully qualified name');
493
+ }
494
+
495
+ return (strpos(substr($FQName, 1), '\\') !== false);
496
+ }
497
+
498
+
499
+ /**
500
+ * Determine the namespace name an arbitrary token lives in.
501
+ *
502
+ * @param PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
503
+ * @param int $stackPtr The token position for which to determine the namespace.
504
+ *
505
+ * @return string Namespace name or empty string if it couldn't be determined or no namespace applies.
506
+ */
507
+ public function determineNamespace(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
508
+ {
509
+ $tokens = $phpcsFile->getTokens();
510
+
511
+ // Check for the existence of the token.
512
+ if (isset($tokens[$stackPtr]) === false) {
513
+ return '';
514
+ }
515
+
516
+ // Check for scoped namespace {}.
517
+ if (empty($tokens[$stackPtr]['conditions']) === false) {
518
+ foreach ($tokens[$stackPtr]['conditions'] as $pointer => $type) {
519
+ if ($type === T_NAMESPACE) {
520
+ $namespace = $this->getDeclaredNamespaceName($phpcsFile, $pointer);
521
+ if ($namespace !== false) {
522
+ return $namespace;
523
+ }
524
+ }
525
+ break; // We only need to check the highest level condition.
526
+ }
527
+ }
528
+
529
+ /*
530
+ * Not in a scoped namespace, so let's see if we can find a non-scoped namespace instead.
531
+ * Keeping in mind that:
532
+ * - there can be multiple non-scoped namespaces in a file (bad practice, but it happens).
533
+ * - the namespace keyword can also be used as part of a function/method call and such.
534
+ * - that a non-named namespace resolves to the global namespace.
535
+ */
536
+ $previousNSToken = $stackPtr;
537
+ $namespace = false;
538
+ do {
539
+ $previousNSToken = $phpcsFile->findPrevious(T_NAMESPACE, $previousNSToken -1);
540
+
541
+ // Stop if we encounter a scoped namespace declaration as we already know we're not in one.
542
+ if (empty($tokens[$previousNSToken]['scope_condition']) === false && $tokens[$previousNSToken]['scope_condition'] = $previousNSToken) {
543
+ break;
544
+ }
545
+ $namespace = $this->getDeclaredNamespaceName($phpcsFile, $previousNSToken);
546
+
547
+ } while ($namespace === false && $previousNSToken !== false);
548
+
549
+ // If we still haven't got a namespace, return an empty string.
550
+ if ($namespace === false) {
551
+ return '';
552
+ }
553
+ else {
554
+ return $namespace;
555
+ }
556
+ }
557
+
558
+ /**
559
+ * Get the complete namespace name for a namespace declaration.
560
+ *
561
+ * For hierarchical namespaces, the name will be composed of several tokens,
562
+ * i.e. MyProject\Sub\Level which will be returned together as one string.
563
+ *
564
+ * @param PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
565
+ * @param int|bool $stackPtr The position of a T_NAMESPACE token.
566
+ *
567
+ * @return string|false Namespace name or false if not a namespace declaration.
568
+ * Namespace name can be an empty string for global namespace declaration.
569
+ */
570
+ public function getDeclaredNamespaceName(PHP_CodeSniffer_File $phpcsFile, $stackPtr )
571
+ {
572
+ $tokens = $phpcsFile->getTokens();
573
+
574
+ // Check for the existence of the token.
575
+ if ($stackPtr === false || isset($tokens[$stackPtr]) === false) {
576
+ return false;
577
+ }
578
+
579
+ if ($tokens[$stackPtr]['code'] !== T_NAMESPACE) {
580
+ return false;
581
+ }
582
+
583
+ if ($tokens[$stackPtr + 1]['code'] === T_NS_SEPARATOR) {
584
+ // Not a namespace declaration, but use of, i.e. namespace\someFunction();
585
+ return false;
586
+ }
587
+
588
+ $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
589
+ if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) {
590
+ // Declaration for global namespace when using multiple namespaces in a file.
591
+ // I.e.: namespace {}
592
+ return '';
593
+ }
594
+
595
+ // Ok, this should be a namespace declaration, so get all the parts together.
596
+ $validTokens = array(
597
+ T_STRING,
598
+ T_NS_SEPARATOR,
599
+ T_WHITESPACE,
600
+ );
601
+
602
+ $namespaceName = '';
603
+ while(in_array($tokens[$nextToken]['code'], $validTokens, true) === true) {
604
+ $namespaceName .= trim($tokens[$nextToken]['content']);
605
+ $nextToken++;
606
+ }
607
+
608
+ return $namespaceName;
609
+ }
610
+
611
+
612
+ /**
613
+ * Returns the method parameters for the specified T_FUNCTION token.
614
+ *
615
+ * Each parameter is in the following format:
616
+ *
617
+ * <code>
618
+ * 0 => array(
619
+ * 'name' => '$var', // The variable name.
620
+ * 'pass_by_reference' => false, // Passed by reference.
621
+ * 'type_hint' => string, // Type hint for array or custom type
622
+ * )
623
+ * </code>
624
+ *
625
+ * Parameters with default values have an additional array index of
626
+ * 'default' with the value of the default as a string.
627
+ *
628
+ * {@internal Duplicate of same method as contained in the `PHP_CodeSniffer_File`
629
+ * class, but with some improvements which were only introduced in PHPCS 2.7.
630
+ * Once the minimum supported PHPCS version for this sniff library goes beyond
631
+ * that, this method can be removed and calls to it replaced with
632
+ * `$phpcsFile->getMethodParameters($stackPtr)` calls.}}
633
+ *
634
+ * @param PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
635
+ * @param int $stackPtr The position in the stack of the T_FUNCTION token
636
+ * to acquire the parameters for.
637
+ *
638
+ * @return array
639
+ * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of
640
+ * type T_FUNCTION.
641
+ */
642
+ public function getMethodParameters(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
643
+ {
644
+ $tokens = $phpcsFile->getTokens();
645
+
646
+ // Check for the existence of the token.
647
+ if (isset($tokens[$stackPtr]) === false) {
648
+ return false;
649
+ }
650
+
651
+ if ($tokens[$stackPtr]['code'] !== T_FUNCTION) {
652
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION');
653
+ }
654
+
655
+ $opener = $tokens[$stackPtr]['parenthesis_opener'];
656
+ $closer = $tokens[$stackPtr]['parenthesis_closer'];
657
+
658
+ $vars = array();
659
+ $currVar = null;
660
+ $paramStart = ($opener + 1);
661
+ $defaultStart = null;
662
+ $paramCount = 0;
663
+ $passByReference = false;
664
+ $variableLength = false;
665
+ $typeHint = '';
666
+
667
+ for ($i = $paramStart; $i <= $closer; $i++) {
668
+ // Check to see if this token has a parenthesis or bracket opener. If it does
669
+ // it's likely to be an array which might have arguments in it. This
670
+ // could cause problems in our parsing below, so lets just skip to the
671
+ // end of it.
672
+ if (isset($tokens[$i]['parenthesis_opener']) === true) {
673
+ // Don't do this if it's the close parenthesis for the method.
674
+ if ($i !== $tokens[$i]['parenthesis_closer']) {
675
+ $i = ($tokens[$i]['parenthesis_closer'] + 1);
676
+ }
677
+ }
678
+
679
+ if (isset($tokens[$i]['bracket_opener']) === true) {
680
+ // Don't do this if it's the close parenthesis for the method.
681
+ if ($i !== $tokens[$i]['bracket_closer']) {
682
+ $i = ($tokens[$i]['bracket_closer'] + 1);
683
+ }
684
+ }
685
+
686
+ switch ($tokens[$i]['code']) {
687
+ case T_BITWISE_AND:
688
+ $passByReference = true;
689
+ break;
690
+ case T_VARIABLE:
691
+ $currVar = $i;
692
+ break;
693
+ case T_ELLIPSIS:
694
+ $variableLength = true;
695
+ break;
696
+ case T_ARRAY_HINT:
697
+ case T_CALLABLE:
698
+ $typeHint = $tokens[$i]['content'];
699
+ break;
700
+ case T_SELF:
701
+ case T_PARENT:
702
+ case T_STATIC:
703
+ // Self is valid, the others invalid, but were probably intended as type hints.
704
+ if (isset($defaultStart) === false) {
705
+ $typeHint = $tokens[$i]['content'];
706
+ }
707
+ break;
708
+ case T_STRING:
709
+ // This is a string, so it may be a type hint, but it could
710
+ // also be a constant used as a default value.
711
+ $prevComma = false;
712
+ for ($t = $i; $t >= $opener; $t--) {
713
+ if ($tokens[$t]['code'] === T_COMMA) {
714
+ $prevComma = $t;
715
+ break;
716
+ }
717
+ }
718
+
719
+ if ($prevComma !== false) {
720
+ $nextEquals = false;
721
+ for ($t = $prevComma; $t < $i; $t++) {
722
+ if ($tokens[$t]['code'] === T_EQUAL) {
723
+ $nextEquals = $t;
724
+ break;
725
+ }
726
+ }
727
+
728
+ if ($nextEquals !== false) {
729
+ break;
730
+ }
731
+ }
732
+
733
+ if ($defaultStart === null) {
734
+ $typeHint .= $tokens[$i]['content'];
735
+ }
736
+ break;
737
+ case T_NS_SEPARATOR:
738
+ // Part of a type hint or default value.
739
+ if ($defaultStart === null) {
740
+ $typeHint .= $tokens[$i]['content'];
741
+ }
742
+ break;
743
+ case T_CLOSE_PARENTHESIS:
744
+ case T_COMMA:
745
+ // If it's null, then there must be no parameters for this
746
+ // method.
747
+ if ($currVar === null) {
748
+ continue;
749
+ }
750
+
751
+ $vars[$paramCount] = array();
752
+ $vars[$paramCount]['name'] = $tokens[$currVar]['content'];
753
+
754
+ if ($defaultStart !== null) {
755
+ $vars[$paramCount]['default']
756
+ = $phpcsFile->getTokensAsString(
757
+ $defaultStart,
758
+ ($i - $defaultStart)
759
+ );
760
+ }
761
+
762
+ $rawContent = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart)));
763
+
764
+ $vars[$paramCount]['pass_by_reference'] = $passByReference;
765
+ $vars[$paramCount]['variable_length'] = $variableLength;
766
+ $vars[$paramCount]['type_hint'] = $typeHint;
767
+ $vars[$paramCount]['raw'] = $rawContent;
768
+
769
+ // Reset the vars, as we are about to process the next parameter.
770
+ $defaultStart = null;
771
+ $paramStart = ($i + 1);
772
+ $passByReference = false;
773
+ $variableLength = false;
774
+ $typeHint = '';
775
+
776
+ $paramCount++;
777
+ break;
778
+ case T_EQUAL:
779
+ $defaultStart = ($i + 1);
780
+ break;
781
+ }//end switch
782
+ }//end for
783
+
784
+ return $vars;
785
+
786
+ }//end getMethodParameters()
787
+
788
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php CHANGED
@@ -45,35 +45,39 @@ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPComp
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  $tokens = $phpcsFile->getTokens();
48
-
49
  $ignore = array(
50
  T_DOUBLE_COLON,
51
  T_OBJECT_OPERATOR,
52
  T_FUNCTION,
53
  T_CONST,
54
  );
55
-
56
  $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
57
  if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
58
  // Not a call to a PHP function.
59
  return;
60
  }
61
-
62
  $function = strtolower($tokens[$stackPtr]['content']);
63
-
64
  if ($function === 'define') {
65
  $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, null, null, true);
66
  if ($openParenthesis === false) {
67
- return false;
68
  }
69
-
70
  $comma = $phpcsFile->findNext(T_COMMA, $openParenthesis, $tokens[$openParenthesis]['parenthesis_closer']);
71
-
 
 
 
 
72
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $comma, $tokens[$openParenthesis]['parenthesis_closer']);
73
-
74
  if ($array !== false) {
75
  if ($this->supportsAbove('7.0')) {
76
- return false;
77
  } else {
78
  $phpcsFile->addError('Constant arrays using define are not allowed in PHP 5.6 or earlier', $array);
79
  }
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  $tokens = $phpcsFile->getTokens();
48
+
49
  $ignore = array(
50
  T_DOUBLE_COLON,
51
  T_OBJECT_OPERATOR,
52
  T_FUNCTION,
53
  T_CONST,
54
  );
55
+
56
  $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
57
  if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
58
  // Not a call to a PHP function.
59
  return;
60
  }
61
+
62
  $function = strtolower($tokens[$stackPtr]['content']);
63
+
64
  if ($function === 'define') {
65
  $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, null, null, true);
66
  if ($openParenthesis === false) {
67
+ return;
68
  }
69
+
70
  $comma = $phpcsFile->findNext(T_COMMA, $openParenthesis, $tokens[$openParenthesis]['parenthesis_closer']);
71
+
72
+ if ($comma === false) {
73
+ return;
74
+ }
75
+
76
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $comma, $tokens[$openParenthesis]['parenthesis_closer']);
77
+
78
  if ($array !== false) {
79
  if ($this->supportsAbove('7.0')) {
80
+ return;
81
  } else {
82
  $phpcsFile->addError('Constant arrays using define are not allowed in PHP 5.6 or earlier', $array);
83
  }
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php CHANGED
@@ -25,16 +25,20 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
25
  * @var bool
26
  */
27
  protected $patternMatch = false;
28
-
29
  /**
30
  * A list of forbidden functions with their alternatives.
31
  *
32
- * The array lists : version number with 0 (deprecated) or 1 (forbidden) and an alternative function.
33
- * If no alternative exists, it is NULL. IE, the function should just not be used.
34
  *
35
- * @var array(string => array(string => int|string|null))
36
  */
37
- public $forbiddenFunctions = array(
 
 
 
 
38
  'call_user_method' => array(
39
  '5.3' => false,
40
  '5.4' => false,
@@ -70,6 +74,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
70
  '5.4' => false,
71
  '5.5' => false,
72
  '5.6' => false,
 
73
  'alternative' => 'preg_match'
74
  ),
75
  'ereg_replace' => array(
@@ -77,6 +82,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
77
  '5.4' => false,
78
  '5.5' => false,
79
  '5.6' => false,
 
80
  'alternative' => 'preg_replace'
81
  ),
82
  'eregi' => array(
@@ -84,6 +90,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
84
  '5.4' => false,
85
  '5.5' => false,
86
  '5.6' => false,
 
87
  'alternative' => 'preg_match'
88
  ),
89
  'eregi_replace' => array(
@@ -91,6 +98,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
91
  '5.4' => false,
92
  '5.5' => false,
93
  '5.6' => false,
 
94
  'alternative' => 'preg_replace'
95
  ),
96
  'imagepsbbox' => array(
@@ -122,9 +130,8 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
122
  'alternative' => null
123
  ),
124
  'import_request_variables' => array(
 
125
  '5.4' => true,
126
- '5.5' => true,
127
- '5.6' => false,
128
  'alternative' => null
129
  ),
130
  'ldap_sort' => array(
@@ -143,58 +150,68 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
143
  '5.4' => false,
144
  '5.5' => false,
145
  '5.6' => false,
146
- 'alternative' => 'mysql_select_db and mysql_query'
 
147
  ),
148
  'mysql_escape_string' => array(
149
  '5.3' => false,
150
  '5.4' => false,
151
  '5.5' => false,
152
  '5.6' => false,
153
- 'alternative' => 'mysql_real_escape_string'
 
154
  ),
155
  'mysql_list_dbs' => array(
156
  '5.4' => false,
157
  '5.5' => false,
158
  '5.6' => false,
 
159
  'alternative' => null
160
  ),
161
  'mysqli_bind_param' => array(
 
162
  '5.4' => true,
163
  '5.5' => true,
164
  '5.6' => true,
165
  'alternative' => 'mysqli_stmt_bind_param'
166
  ),
167
  'mysqli_bind_result' => array(
 
168
  '5.4' => true,
169
  '5.5' => true,
170
  '5.6' => true,
171
  'alternative' => 'mysqli_stmt_bind_result'
172
  ),
173
  'mysqli_client_encoding' => array(
 
174
  '5.4' => true,
175
  '5.5' => true,
176
  '5.6' => true,
177
  'alternative' => 'mysqli_character_set_name'
178
  ),
179
  'mysqli_fetch' => array(
 
180
  '5.4' => true,
181
  '5.5' => true,
182
  '5.6' => true,
183
  'alternative' => 'mysqli_stmt_fetch'
184
  ),
185
  'mysqli_param_count' => array(
 
186
  '5.4' => true,
187
  '5.5' => true,
188
  '5.6' => true,
189
  'alternative' => 'mysqli_stmt_param_count'
190
  ),
191
  'mysqli_get_metadata' => array(
 
192
  '5.4' => true,
193
  '5.5' => true,
194
  '5.6' => true,
195
  'alternative' => 'mysqli_stmt_result_metadata'
196
  ),
197
  'mysqli_send_long_data' => array(
 
198
  '5.4' => true,
199
  '5.5' => true,
200
  '5.6' => true,
@@ -250,6 +267,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
250
  '5.4' => false,
251
  '5.5' => false,
252
  '5.6' => false,
 
253
  'alternative' => 'preg_split'
254
  ),
255
  'spliti' => array(
@@ -257,6 +275,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
257
  '5.4' => false,
258
  '5.5' => false,
259
  '5.6' => false,
 
260
  'alternative' => 'preg_split'
261
  ),
262
  'sql_regcase' => array(
@@ -264,6 +283,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
264
  '5.4' => false,
265
  '5.5' => false,
266
  '5.6' => false,
 
267
  'alternative' => null
268
  ),
269
  'php_logo_guid' => array(
@@ -610,15 +630,12 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
610
  '5.6' => false,
611
  'alternative' => 'OCI-Lob::writeTemporary'
612
  ),
 
 
 
 
613
  );
614
 
615
- /**
616
- * If true, an error will be thrown; otherwise a warning.
617
- *
618
- * @var bool
619
- */
620
- public $error = false;
621
-
622
  /**
623
  * Returns an array of tokens this test wants to listen for.
624
  *
@@ -629,18 +646,18 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
629
  // Everyone has had a chance to figure out what forbidden functions
630
  // they want to check for, so now we can cache out the list.
631
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
632
-
633
  if ($this->patternMatch === true) {
634
  foreach ($this->forbiddenFunctionNames as $i => $name) {
635
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
636
  }
637
  }
638
-
639
  return array(T_STRING);
640
-
641
  }//end register()
642
-
643
-
644
  /**
645
  * Processes this test, when one of its tokens is encountered.
646
  *
@@ -699,7 +716,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
699
  }//end process()
700
 
701
  /**
702
- * Generates the error or wanrning for this sniff.
703
  *
704
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
705
  * @param int $stackPtr The position of the forbidden function
@@ -717,7 +734,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
717
 
718
  $error = '';
719
 
720
- $this->error = false;
721
  $previousVersionStatus = null;
722
  foreach ($this->forbiddenFunctions[$pattern] as $version => $forbidden) {
723
  if ($this->supportsAbove($version)) {
@@ -725,7 +742,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
725
  if ($previousVersionStatus !== $forbidden) {
726
  $previousVersionStatus = $forbidden;
727
  if ($forbidden === true) {
728
- $this->error = true;
729
  $error .= 'forbidden';
730
  } else {
731
  $error .= 'discouraged';
@@ -743,7 +760,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
743
  $error .= '; use ' . $this->forbiddenFunctions[$pattern]['alternative'] . ' instead';
744
  }
745
 
746
- if ($this->error === true) {
747
  $phpcsFile->addError($error, $stackPtr);
748
  } else {
749
  $phpcsFile->addWarning($error, $stackPtr);
25
  * @var bool
26
  */
27
  protected $patternMatch = false;
28
+
29
  /**
30
  * A list of forbidden functions with their alternatives.
31
  *
32
+ * The array lists : version number with false (deprecated) or true (forbidden) and an alternative function.
33
+ * If no alternative exists, it is NULL, i.e, the function should just not be used.
34
  *
35
+ * @var array(string => array(string => bool|string|null))
36
  */
37
+ protected $forbiddenFunctions = array(
38
+ 'php_check_syntax' => array(
39
+ '5.0.5' => true,
40
+ 'alternative' => null
41
+ ),
42
  'call_user_method' => array(
43
  '5.3' => false,
44
  '5.4' => false,
74
  '5.4' => false,
75
  '5.5' => false,
76
  '5.6' => false,
77
+ '7.0' => true,
78
  'alternative' => 'preg_match'
79
  ),
80
  'ereg_replace' => array(
82
  '5.4' => false,
83
  '5.5' => false,
84
  '5.6' => false,
85
+ '7.0' => true,
86
  'alternative' => 'preg_replace'
87
  ),
88
  'eregi' => array(
90
  '5.4' => false,
91
  '5.5' => false,
92
  '5.6' => false,
93
+ '7.0' => true,
94
  'alternative' => 'preg_match'
95
  ),
96
  'eregi_replace' => array(
98
  '5.4' => false,
99
  '5.5' => false,
100
  '5.6' => false,
101
+ '7.0' => true,
102
  'alternative' => 'preg_replace'
103
  ),
104
  'imagepsbbox' => array(
130
  'alternative' => null
131
  ),
132
  'import_request_variables' => array(
133
+ '5.3' => false,
134
  '5.4' => true,
 
 
135
  'alternative' => null
136
  ),
137
  'ldap_sort' => array(
150
  '5.4' => false,
151
  '5.5' => false,
152
  '5.6' => false,
153
+ '7.0' => true,
154
+ 'alternative' => 'mysqli_select_db and mysqli_query'
155
  ),
156
  'mysql_escape_string' => array(
157
  '5.3' => false,
158
  '5.4' => false,
159
  '5.5' => false,
160
  '5.6' => false,
161
+ '7.0' => true,
162
+ 'alternative' => 'mysqli_real_escape_string'
163
  ),
164
  'mysql_list_dbs' => array(
165
  '5.4' => false,
166
  '5.5' => false,
167
  '5.6' => false,
168
+ '7.0' => true,
169
  'alternative' => null
170
  ),
171
  'mysqli_bind_param' => array(
172
+ '5.3' => false,
173
  '5.4' => true,
174
  '5.5' => true,
175
  '5.6' => true,
176
  'alternative' => 'mysqli_stmt_bind_param'
177
  ),
178
  'mysqli_bind_result' => array(
179
+ '5.3' => false,
180
  '5.4' => true,
181
  '5.5' => true,
182
  '5.6' => true,
183
  'alternative' => 'mysqli_stmt_bind_result'
184
  ),
185
  'mysqli_client_encoding' => array(
186
+ '5.3' => false,
187
  '5.4' => true,
188
  '5.5' => true,
189
  '5.6' => true,
190
  'alternative' => 'mysqli_character_set_name'
191
  ),
192
  'mysqli_fetch' => array(
193
+ '5.3' => false,
194
  '5.4' => true,
195
  '5.5' => true,
196
  '5.6' => true,
197
  'alternative' => 'mysqli_stmt_fetch'
198
  ),
199
  'mysqli_param_count' => array(
200
+ '5.3' => false,
201
  '5.4' => true,
202
  '5.5' => true,
203
  '5.6' => true,
204
  'alternative' => 'mysqli_stmt_param_count'
205
  ),
206
  'mysqli_get_metadata' => array(
207
+ '5.3' => false,
208
  '5.4' => true,
209
  '5.5' => true,
210
  '5.6' => true,
211
  'alternative' => 'mysqli_stmt_result_metadata'
212
  ),
213
  'mysqli_send_long_data' => array(
214
+ '5.3' => false,
215
  '5.4' => true,
216
  '5.5' => true,
217
  '5.6' => true,
267
  '5.4' => false,
268
  '5.5' => false,
269
  '5.6' => false,
270
+ '7.0' => true,
271
  'alternative' => 'preg_split'
272
  ),
273
  'spliti' => array(
275
  '5.4' => false,
276
  '5.5' => false,
277
  '5.6' => false,
278
+ '7.0' => true,
279
  'alternative' => 'preg_split'
280
  ),
281
  'sql_regcase' => array(
283
  '5.4' => false,
284
  '5.5' => false,
285
  '5.6' => false,
286
+ '7.0' => true,
287
  'alternative' => null
288
  ),
289
  'php_logo_guid' => array(
630
  '5.6' => false,
631
  'alternative' => 'OCI-Lob::writeTemporary'
632
  ),
633
+ 'mysqli_get_cache_stats' => array(
634
+ '5.4' => true,
635
+ 'alternative' => null
636
+ ),
637
  );
638
 
 
 
 
 
 
 
 
639
  /**
640
  * Returns an array of tokens this test wants to listen for.
641
  *
646
  // Everyone has had a chance to figure out what forbidden functions
647
  // they want to check for, so now we can cache out the list.
648
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
649
+
650
  if ($this->patternMatch === true) {
651
  foreach ($this->forbiddenFunctionNames as $i => $name) {
652
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
653
  }
654
  }
655
+
656
  return array(T_STRING);
657
+
658
  }//end register()
659
+
660
+
661
  /**
662
  * Processes this test, when one of its tokens is encountered.
663
  *
716
  }//end process()
717
 
718
  /**
719
+ * Generates the error or warning for this sniff.
720
  *
721
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
722
  * @param int $stackPtr The position of the forbidden function
734
 
735
  $error = '';
736
 
737
+ $isError = false;
738
  $previousVersionStatus = null;
739
  foreach ($this->forbiddenFunctions[$pattern] as $version => $forbidden) {
740
  if ($this->supportsAbove($version)) {
742
  if ($previousVersionStatus !== $forbidden) {
743
  $previousVersionStatus = $forbidden;
744
  if ($forbidden === true) {
745
+ $isError = true;
746
  $error .= 'forbidden';
747
  } else {
748
  $error .= 'discouraged';
760
  $error .= '; use ' . $this->forbiddenFunctions[$pattern]['alternative'] . ' instead';
761
  }
762
 
763
+ if ($isError === true) {
764
  $phpcsFile->addError($error, $stackPtr);
765
  } else {
766
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php CHANGED
@@ -23,20 +23,70 @@
23
  class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
- * A list of deprecated INI directives
 
 
 
27
  *
28
  * @var array(string)
29
  */
30
  protected $deprecatedIniDirectives = array(
31
- 'define_syslog_variables' => array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  '5.3' => false,
33
  '5.4' => true
34
  ),
35
- 'register_globals' => array(
36
  '5.3' => false,
37
  '5.4' => true
38
  ),
39
- 'register_long_arrays' => array(
 
 
 
 
40
  '5.3' => false,
41
  '5.4' => true
42
  ),
@@ -52,56 +102,58 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
52
  '5.3' => false,
53
  '5.4' => true
54
  ),
55
- 'allow_call_time_pass_reference' => array(
56
- '5.3' => false,
57
- '5.4' => true
58
  ),
59
- 'highlight.bg' => array(
60
  '5.3' => false,
61
  '5.4' => true
62
  ),
63
- 'session.bug_compat_42' => array(
64
  '5.3' => false,
65
  '5.4' => true
66
  ),
67
- 'session.bug_compat_warn' => array(
68
  '5.3' => false,
69
  '5.4' => true
70
  ),
71
- 'y2k_compliance' => array(
72
  '5.3' => false,
73
  '5.4' => true
74
  ),
75
- 'zend.ze1_compatibility_mode' => array(
76
  '5.3' => false,
77
  '5.4' => true
78
  ),
79
- 'safe_mode' => array(
80
  '5.3' => false,
81
  '5.4' => true
82
  ),
83
- 'safe_mode_gid' => array(
84
  '5.3' => false,
85
  '5.4' => true
86
  ),
87
- 'safe_mode_include_dir' => array(
88
  '5.3' => false,
89
  '5.4' => true
90
  ),
91
- 'safe_mode_exec_dir' => array(
92
  '5.3' => false,
93
  '5.4' => true
94
  ),
95
- 'safe_mode_allowed_env_vars' => array(
96
  '5.3' => false,
97
  '5.4' => true
98
  ),
99
- 'safe_mode_protected_env_vars' => array(
100
  '5.3' => false,
101
  '5.4' => true
102
  ),
 
103
  'always_populate_raw_post_data' => array(
104
- '5.6' => false
 
105
  ),
106
  'iconv.input_encoding' => array(
107
  '5.6' => false
@@ -121,10 +173,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
121
  'mbstring.internal_encoding' => array(
122
  '5.6' => false
123
  ),
124
- 'always_populate_raw_post_data' => array(
125
- '5.6' => false,
126
- '7.0' => true
127
- ),
128
  'asp_tags' => array(
129
  '7.0' => true
130
  ),
@@ -156,7 +205,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
156
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
157
  {
158
  $tokens = $phpcsFile->getTokens();
159
-
160
  $isError = false;
161
 
162
  $ignore = array(
@@ -176,30 +225,37 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
176
  if ($function != 'ini_get' && $function != 'ini_set') {
177
  return;
178
  }
179
- $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
180
- if (in_array(str_replace("'", "", $tokens[$iniToken]['content']), array_keys($this->deprecatedIniDirectives)) === false) {
 
 
181
  return;
182
  }
183
 
184
  $error = '';
185
 
186
- foreach ($this->deprecatedIniDirectives[str_replace("'", "", $tokens[$iniToken]['content'])] as $version => $forbidden)
187
  {
188
- if ($this->supportsAbove($version)) {
189
- if ($forbidden === true) {
190
- $isError = true;
191
- $error .= " forbidden";
192
- } else {
193
- $isError = false;
194
- $error .= " deprecated";
 
 
 
195
  }
196
- $error .= " from PHP " . $version . " and";
197
  }
198
  }
199
 
200
  if (strlen($error) > 0) {
201
- $error = "INI directive " . $tokens[$iniToken]['content'] . " is" . $error;
202
  $error = substr($error, 0, strlen($error) - 4) . ".";
 
 
 
203
 
204
  if ($isError === true) {
205
  $phpcsFile->addError($error, $stackPtr);
23
  class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
+ * A list of deprecated INI directives.
27
+ *
28
+ * version => false means the directive was deprecated in that version.
29
+ * version => true means it was removed in that version.
30
  *
31
  * @var array(string)
32
  */
33
  protected $deprecatedIniDirectives = array(
34
+ 'fbsql.batchSize' => array(
35
+ '5.1' => true,
36
+ 'alternative' => 'fbsql.batchsize',
37
+ ),
38
+
39
+ 'ifx.allow_persistent' => array(
40
+ '5.2.1' => true
41
+ ),
42
+ 'ifx.blobinfile' => array(
43
+ '5.2.1' => true
44
+ ),
45
+ 'ifx.byteasvarchar' => array(
46
+ '5.2.1' => true
47
+ ),
48
+ 'ifx.charasvarchar' => array(
49
+ '5.2.1' => true
50
+ ),
51
+ 'ifx.default_host' => array(
52
+ '5.2.1' => true
53
+ ),
54
+ 'ifx.default_password' => array(
55
+ '5.2.1' => true
56
+ ),
57
+ 'ifx.default_user' => array(
58
+ '5.2.1' => true
59
+ ),
60
+ 'ifx.max_links' => array(
61
+ '5.2.1' => true
62
+ ),
63
+ 'ifx.max_persistent' => array(
64
+ '5.2.1' => true
65
+ ),
66
+ 'ifx.nullformat' => array(
67
+ '5.2.1' => true
68
+ ),
69
+ 'ifx.textasvarchar' => array(
70
+ '5.2.1' => true
71
+ ),
72
+
73
+ 'zend.ze1_compatibility_mode' => array(
74
+ '5.3' => true,
75
+ ),
76
+
77
+ 'allow_call_time_pass_reference' => array(
78
  '5.3' => false,
79
  '5.4' => true
80
  ),
81
+ 'define_syslog_variables' => array(
82
  '5.3' => false,
83
  '5.4' => true
84
  ),
85
+ 'detect_unicode' => array(
86
+ '5.4' => true,
87
+ 'alternative' => 'zend.detect_unicode',
88
+ ),
89
+ 'highlight.bg' => array(
90
  '5.3' => false,
91
  '5.4' => true
92
  ),
102
  '5.3' => false,
103
  '5.4' => true
104
  ),
105
+ 'mbstring.script_encoding' => array(
106
+ '5.4' => true,
107
+ 'alternative' => 'zend.script_encoding',
108
  ),
109
+ 'register_globals' => array(
110
  '5.3' => false,
111
  '5.4' => true
112
  ),
113
+ 'register_long_arrays' => array(
114
  '5.3' => false,
115
  '5.4' => true
116
  ),
117
+ 'safe_mode' => array(
118
  '5.3' => false,
119
  '5.4' => true
120
  ),
121
+ 'safe_mode_allowed_env_vars' => array(
122
  '5.3' => false,
123
  '5.4' => true
124
  ),
125
+ 'safe_mode_exec_dir' => array(
126
  '5.3' => false,
127
  '5.4' => true
128
  ),
129
+ 'safe_mode_gid' => array(
130
  '5.3' => false,
131
  '5.4' => true
132
  ),
133
+ 'safe_mode_include_dir' => array(
134
  '5.3' => false,
135
  '5.4' => true
136
  ),
137
+ 'safe_mode_protected_env_vars' => array(
138
  '5.3' => false,
139
  '5.4' => true
140
  ),
141
+ 'session.bug_compat_42' => array(
142
  '5.3' => false,
143
  '5.4' => true
144
  ),
145
+ 'session.bug_compat_warn' => array(
146
  '5.3' => false,
147
  '5.4' => true
148
  ),
149
+ 'y2k_compliance' => array(
150
  '5.3' => false,
151
  '5.4' => true
152
  ),
153
+
154
  'always_populate_raw_post_data' => array(
155
+ '5.6' => false,
156
+ '7.0' => true
157
  ),
158
  'iconv.input_encoding' => array(
159
  '5.6' => false
173
  'mbstring.internal_encoding' => array(
174
  '5.6' => false
175
  ),
176
+
 
 
 
177
  'asp_tags' => array(
178
  '7.0' => true
179
  ),
205
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
206
  {
207
  $tokens = $phpcsFile->getTokens();
208
+
209
  $isError = false;
210
 
211
  $ignore = array(
225
  if ($function != 'ini_get' && $function != 'ini_set') {
226
  return;
227
  }
228
+
229
+ $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
230
+ $filteredToken = trim($tokens[$iniToken]['content'], '\'"');
231
+ if (isset($this->deprecatedIniDirectives[$filteredToken]) === false) {
232
  return;
233
  }
234
 
235
  $error = '';
236
 
237
+ foreach ($this->deprecatedIniDirectives[$filteredToken] as $version => $forbidden)
238
  {
239
+ if ($version !== 'alternative') {
240
+ if ($this->supportsAbove($version)) {
241
+ if ($forbidden === true) {
242
+ $isError = ($function != 'ini_get') ?: false;
243
+ $error .= " forbidden";
244
+ } else {
245
+ $isError = false;
246
+ $error .= " deprecated";
247
+ }
248
+ $error .= " from PHP " . $version . " and";
249
  }
 
250
  }
251
  }
252
 
253
  if (strlen($error) > 0) {
254
+ $error = "INI directive '" . $filteredToken . "' is" . $error;
255
  $error = substr($error, 0, strlen($error) - 4) . ".";
256
+ if (isset($this->deprecatedIniDirectives[$filteredToken]['alternative'])) {
257
+ $error .= " Use '" . $this->deprecatedIniDirectives[$filteredToken]['alternative'] . "' instead.";
258
+ }
259
 
260
  if ($isError === true) {
261
  $phpcsFile->addError($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_DeprecatedNewReferenceSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = false;
34
-
35
  /**
36
  * Returns an array of tokens this test wants to listen for.
37
  *
25
  class PHPCompatibility_Sniffs_PHP_DeprecatedNewReferenceSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * Returns an array of tokens this test wants to listen for.
30
  *
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php CHANGED
@@ -17,13 +17,30 @@
17
  * @author Koen Eelen <koen.eelen@cu.be>
18
  */
19
  class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends PHPCompatibility_Sniff {
 
20
  public function register()
21
  {
22
  return array(T_CLASS);
23
 
24
  }//end register()
25
 
26
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  $tokens = $phpcsFile->getTokens();
28
 
29
  $class = $tokens[$stackPtr];
@@ -33,30 +50,34 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends P
33
  }
34
 
35
  $scopeCloser = $class['scope_closer'];
 
36
 
37
- //get the name of the class
38
- $classNamePos = $phpcsFile->findNext(T_STRING, $stackPtr);
39
- $className = $tokens[$classNamePos]['content'];
40
 
41
  $nextFunc = $stackPtr;
42
  $newConstructorFound = false;
43
  $oldConstructorFound = false;
 
44
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
45
- $funcNamePos = $phpcsFile->findNext(T_STRING, $nextFunc);
46
-
47
- if ($tokens[$funcNamePos]['content'] === '__construct') {
 
 
 
48
  $newConstructorFound = true;
49
  }
50
 
51
- if ($this->supportsAbove('7.0')) {
52
- if ($funcNamePos !== false && $tokens[$funcNamePos]['content'] === $className) {
53
- $oldConstructorFound = true;
54
- }
55
  }
56
  }
57
-
58
  if ($newConstructorFound === false && $oldConstructorFound === true) {
59
- $phpcsFile->addError('Deprecated PHP4 style constructor are not supported since PHP7', $funcNamePos);
60
  }
61
  }
62
  }
17
  * @author Koen Eelen <koen.eelen@cu.be>
18
  */
19
  class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends PHPCompatibility_Sniff {
20
+
21
  public function register()
22
  {
23
  return array(T_CLASS);
24
 
25
  }//end register()
26
 
27
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
28
+ {
29
+ if ($this->supportsAbove('7.0') === false) {
30
+ return;
31
+ }
32
+
33
+ if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
34
+ /*
35
+ * Namespaced methods with the same name as the class are treated as
36
+ * regular methods, so we can bow out if we're in a namespace.
37
+ *
38
+ * Note: the exception to this is PHP 5.3.0-5.3.2. This is currently
39
+ * not dealt with.
40
+ */
41
+ return;
42
+ }
43
+
44
  $tokens = $phpcsFile->getTokens();
45
 
46
  $class = $tokens[$stackPtr];
50
  }
51
 
52
  $scopeCloser = $class['scope_closer'];
53
+ $className = $phpcsFile->getDeclarationName($stackPtr);
54
 
55
+ if (empty($className) || is_string($className) === false) {
56
+ return;
57
+ }
58
 
59
  $nextFunc = $stackPtr;
60
  $newConstructorFound = false;
61
  $oldConstructorFound = false;
62
+ $oldConstructorPos = false;
63
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
64
+ $funcName = $phpcsFile->getDeclarationName($nextFunc);
65
+ if (empty($funcName) || is_string($funcName) === false) {
66
+ continue;
67
+ }
68
+
69
+ if ($funcName === '__construct') {
70
  $newConstructorFound = true;
71
  }
72
 
73
+ if ($funcName === $className) {
74
+ $oldConstructorFound = true;
75
+ $oldConstructorPos = $phpcsFile->findNext(T_STRING, $nextFunc);
 
76
  }
77
  }
78
+
79
  if ($newConstructorFound === false && $oldConstructorFound === true) {
80
+ $phpcsFile->addError('Deprecated PHP4 style constructor are not supported since PHP7', $oldConstructorPos);
81
  }
82
  }
83
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = true;
34
-
35
  /**
36
  * Returns an array of tokens this test wants to listen for.
37
  *
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * Returns an array of tokens this test wants to listen for.
30
  *
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php CHANGED
@@ -29,13 +29,6 @@
29
  class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends PHPCompatibility_Sniff
30
  {
31
 
32
- /**
33
- * If true, an error will be thrown; otherwise a warning.
34
- *
35
- * @var bool
36
- */
37
- protected $error = true;
38
-
39
  /**
40
  * Returns an array of tokens this test wants to listen for.
41
  *
@@ -133,38 +126,38 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends
133
  // positives to not identifying a pass-by-reference call at all.
134
  // The blacklist may not yet be complete.
135
  switch ($tokens[$tokenBefore]['code']) {
136
- case T_LNUMBER:
137
- case T_VARIABLE:
138
- case T_CLOSE_SQUARE_BRACKET:
139
- case T_CLOSE_PARENTHESIS:
140
  // In these cases T_BITWISE_AND represents
141
  // the bitwise and operator.
142
- continue;
143
-
144
- // Unfortunately the tokenizer fails to recognize global constants,
145
- // class-constants and -attributes. Any of these are returned is
146
- // treated as T_STRING.
147
- // So we step back another token and check if it is a class
148
- // operator (-> or ::), which means we have a false positive.
149
- // Global constants still remain uncovered.
150
- case T_STRING:
151
- $tokenBeforePlus = $phpcsFile->findPrevious(
152
- PHP_CodeSniffer_Tokens::$emptyTokens,
153
- ($tokenBefore - 1),
154
- null,
155
- true
156
- );
157
- if( T_DOUBLE_COLON === $tokens[$tokenBeforePlus]['code'] ||
158
- T_OBJECT_OPERATOR === $tokens[$tokenBeforePlus]['code']
159
- ) {
160
  continue;
161
- }
162
-
163
- default:
164
- // T_BITWISE_AND represents a pass-by-reference.
165
- $error = 'Using a call-time pass-by-reference is prohibited since php 5.4';
166
- $phpcsFile->addError($error, $tokenBefore, 'NotAllowed');
167
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
169
  }//end if
170
  }//end while
29
  class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends PHPCompatibility_Sniff
30
  {
31
 
 
 
 
 
 
 
 
32
  /**
33
  * Returns an array of tokens this test wants to listen for.
34
  *
126
  // positives to not identifying a pass-by-reference call at all.
127
  // The blacklist may not yet be complete.
128
  switch ($tokens[$tokenBefore]['code']) {
 
 
 
 
129
  // In these cases T_BITWISE_AND represents
130
  // the bitwise and operator.
131
+ case T_LNUMBER:
132
+ case T_VARIABLE:
133
+ case T_CLOSE_SQUARE_BRACKET:
134
+ case T_CLOSE_PARENTHESIS:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  continue;
136
+
137
+ // Unfortunately the tokenizer fails to recognize global constants,
138
+ // class-constants and -attributes. Any of these are returned is
139
+ // treated as T_STRING.
140
+ // So we step back another token and check if it is a class
141
+ // operator (-> or ::), which means we have a false positive.
142
+ // Global constants still remain uncovered.
143
+ case T_STRING:
144
+ $tokenBeforePlus = $phpcsFile->findPrevious(
145
+ PHP_CodeSniffer_Tokens::$emptyTokens,
146
+ ($tokenBefore - 1),
147
+ null,
148
+ true
149
+ );
150
+ if( T_DOUBLE_COLON === $tokens[$tokenBeforePlus]['code'] ||
151
+ T_OBJECT_OPERATOR === $tokens[$tokenBeforePlus]['code']
152
+ ) {
153
+ continue;
154
+ }
155
+
156
+ default:
157
+ // T_BITWISE_AND represents a pass-by-reference.
158
+ $error = 'Using a call-time pass-by-reference is prohibited since php 5.4';
159
+ $phpcsFile->addError($error, $tokenBefore, 'NotAllowed');
160
+ break;
161
  }
162
  }//end if
163
  }//end while
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php CHANGED
@@ -23,6 +23,13 @@
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPCompatibility_Sniff
24
  {
25
 
 
 
 
 
 
 
 
26
  /**
27
  * Returns an array of tokens this test wants to listen for.
28
  *
@@ -30,6 +37,17 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPC
30
  */
31
  public function register()
32
  {
 
 
 
 
 
 
 
 
 
 
 
33
  return array(T_LIST);
34
  }
35
 
@@ -47,31 +65,24 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPC
47
  if ($this->supportsAbove('7.0')) {
48
  $tokens = $phpcsFile->getTokens();
49
 
50
- $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false);
51
- $close = $phpcsFile->findNext(T_CLOSE_PARENTHESIS, $stackPtr, null, false);
52
-
 
 
 
53
  $error = true;
54
- for ($cnt = $open + 1; $cnt < $close; $cnt++) {
55
- if ($tokens[$cnt]['type'] != 'T_WHITESPACE' && $tokens[$cnt]['type'] != 'T_COMMA') {
56
- $error = false;
 
 
57
  }
58
  }
59
-
60
- if ($open !== false && $close !== false) {
61
- if (
62
- $close - $open == 1
63
- ||
64
- (
65
- $close - $open > 2
66
- &&
67
- $error === true
68
- )
69
- ) {
70
- $error = sprintf(
71
- "Empty list() assignments are not allowed since PHP 7.0"
72
- );
73
- $phpcsFile->addError($error, $stackPtr);
74
- }
75
  }
76
  }
77
  }
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPCompatibility_Sniff
24
  {
25
 
26
+ /**
27
+ * List of tokens to disregard when determining whether the list() is empty.
28
+ *
29
+ * @var array
30
+ */
31
+ protected $ignoreTokens = array();
32
+
33
  /**
34
  * Returns an array of tokens this test wants to listen for.
35
  *
37
  */
38
  public function register()
39
  {
40
+ // Set up a list of tokens to disregard when determining whether the list() is empty.
41
+ // Only needs to be set up once.
42
+ $this->ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens;
43
+ if (version_compare(PHP_CodeSniffer::VERSION, '2.0', '<')) {
44
+ $this->ignoreTokens = array_combine($this->ignoreTokens, $this->ignoreTokens);
45
+ }
46
+ $this->ignoreTokens[T_COMMA] = T_COMMA;
47
+ $this->ignoreTokens[T_OPEN_PARENTHESIS] = T_OPEN_PARENTHESIS;
48
+ $this->ignoreTokens[T_CLOSE_PARENTHESIS] = T_CLOSE_PARENTHESIS;
49
+
50
+
51
  return array(T_LIST);
52
  }
53
 
65
  if ($this->supportsAbove('7.0')) {
66
  $tokens = $phpcsFile->getTokens();
67
 
68
+ $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
69
+ if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
70
+ return;
71
+ }
72
+
73
+ $close = $tokens[$open]['parenthesis_closer'];
74
  $error = true;
75
+ if(($close - $open) > 1) {
76
+ for ($cnt = $open + 1; $cnt < $close; $cnt++) {
77
+ if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
78
+ $error = false;
79
+ }
80
  }
81
  }
82
+
83
+ if ($error === true) {
84
+ $error = 'Empty list() assignments are not allowed since PHP 7.0';
85
+ $phpcsFile->addError($error, $stackPtr);
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
  }
88
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php CHANGED
@@ -23,13 +23,6 @@
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff extends PHPCompatibility_Sniff
24
  {
25
 
26
- /**
27
- * If true, an error will be thrown; otherwise a warning.
28
- *
29
- * @var bool
30
- */
31
- protected $error = true;
32
-
33
  /**
34
  * Returns an array of tokens this test wants to listen for.
35
  *
@@ -60,15 +53,12 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff e
60
  return;
61
  }
62
 
63
- // Get function name.
64
- $methodName = $phpcsFile->getDeclarationName($stackPtr);
65
-
66
  // Get all parameters from method signature.
67
  $paramNames = array();
68
  foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
69
  $paramNames[] = strtolower($param['name']);
70
  }
71
-
72
  if (count($paramNames) != count(array_unique($paramNames))) {
73
  $phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
74
  }
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff extends PHPCompatibility_Sniff
24
  {
25
 
 
 
 
 
 
 
 
26
  /**
27
  * Returns an array of tokens this test wants to listen for.
28
  *
53
  return;
54
  }
55
 
 
 
 
56
  // Get all parameters from method signature.
57
  $paramNames = array();
58
  foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
59
  $paramNames[] = strtolower($param['name']);
60
  }
61
+
62
  if (count($paramNames) != count(array_unique($paramNames))) {
63
  $phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
64
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = true;
34
-
35
  /**
36
  * List of tokens to register
37
  *
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * List of tokens to register
30
  *
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesSniff.php CHANGED
@@ -103,11 +103,15 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
103
  );
104
 
105
  /**
106
- * If true, an error will be thrown; otherwise a warning.
 
107
  *
108
- * @var bool
109
  */
110
- protected $error = true;
 
 
 
111
 
112
  /**
113
  * targetedTokens
@@ -170,10 +174,18 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
170
  return;
171
  }
172
 
 
 
 
 
 
 
 
 
173
  if (isset($tokens[$stackPtr - 2]) && $tokens[$stackPtr - 2]['type'] == 'T_NEW' && $tokens[$stackPtr - 1]['type'] == 'T_WHITESPACE' && $tokens[$stackPtr]['type'] == 'T_ANON_CLASS') {
174
  return;
175
  }
176
-
177
  if ($this->supportsAbove($this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])])) {
178
  $error = "Function name, class name, namespace name or constant name can not be reserved keyword '" . $tokens[$stackPtr + 2]['content'] . "' (since version " . $this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])] . ")";
179
  $phpcsFile->addError($error, $stackPtr);
103
  );
104
 
105
  /**
106
+ * A list of keywords that can follow use statements.
107
+ * Mentions since which version it's not allowed
108
  *
109
+ * @var array(string => string)
110
  */
111
+ protected $validUseNames = array(
112
+ 'const',
113
+ 'function',
114
+ );
115
 
116
  /**
117
  * targetedTokens
174
  return;
175
  }
176
 
177
+ // PHP 5.6 allows for use const and use function
178
+ if ($this->supportsAbove('5.6')
179
+ && $tokens[$stackPtr]['type'] == 'T_USE'
180
+ && in_array(strtolower($tokens[$stackPtr + 2]['content']), $this->validUseNames)
181
+ ) {
182
+ return;
183
+ }
184
+
185
  if (isset($tokens[$stackPtr - 2]) && $tokens[$stackPtr - 2]['type'] == 'T_NEW' && $tokens[$stackPtr - 1]['type'] == 'T_WHITESPACE' && $tokens[$stackPtr]['type'] == 'T_ANON_CLASS') {
186
  return;
187
  }
188
+
189
  if ($this->supportsAbove($this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])])) {
190
  $error = "Function name, class name, namespace name or constant name can not be reserved keyword '" . $tokens[$stackPtr + 2]['content'] . "' (since version " . $this->invalidNames[strtolower($tokens[$stackPtr + 2]['content'])] . ")";
191
  $phpcsFile->addError($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php CHANGED
@@ -12,7 +12,7 @@
12
  /**
13
  * PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshift.
14
  *
15
- * Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0
16
  *
17
  * @category PHP
18
  * @package PHPCompatibility
@@ -21,13 +21,6 @@
21
  class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPCompatibility_Sniff
22
  {
23
 
24
- /**
25
- * If true, an error will be thrown; otherwise a warning.
26
- *
27
- * @var bool
28
- */
29
- protected $error = true;
30
-
31
  /**
32
  * Returns an array of tokens this test wants to listen for.
33
  *
@@ -52,7 +45,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPComp
52
  {
53
  if ($this->supportsAbove('7.0')) {
54
  $tokens = $phpcsFile->getTokens();
55
-
56
  $nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr, null, false, null, true);
57
  if ($tokens[$nextNumber - 1]['code'] == T_MINUS) {
58
  $error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
12
  /**
13
  * PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshift.
14
  *
15
+ * Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0
16
  *
17
  * @category PHP
18
  * @package PHPCompatibility
21
  class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPCompatibility_Sniff
22
  {
23
 
 
 
 
 
 
 
 
24
  /**
25
  * Returns an array of tokens this test wants to listen for.
26
  *
45
  {
46
  if ($this->supportsAbove('7.0')) {
47
  $tokens = $phpcsFile->getTokens();
48
+
49
  $nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr, null, false, null, true);
50
  if ($tokens[$nextNumber - 1]['code'] == T_MINUS) {
51
  $error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php CHANGED
@@ -23,13 +23,6 @@
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff extends PHPCompatibility_Sniff
24
  {
25
 
26
- /**
27
- * If true, an error will be thrown; otherwise a warning.
28
- *
29
- * @var bool
30
- */
31
- protected $error = true;
32
-
33
  /**
34
  * Returns an array of tokens this test wants to listen for.
35
  *
@@ -52,25 +45,28 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff
52
  */
53
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
  {
55
- if ($this->supportsAbove('7.0')) {
56
- $tokens = $phpcsFile->getTokens();
57
-
58
- $defaultToken = $stackPtr;
59
- $defaultCount = 0;
60
- if (isset($tokens[$stackPtr]['scope_closer'])) {
61
- while ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT, T_SWITCH), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
62
- if ($tokens[$defaultToken]['type'] == 'T_SWITCH') {
63
- $defaultToken = $tokens[$defaultToken]['scope_closer'];
64
- } else {
65
- $defaultCount++;
66
- }
67
- }
68
-
69
- if ($defaultCount > 1) {
70
- $phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
71
- }
72
  }
73
  }
 
 
 
 
74
  }//end process()
75
 
76
  }//end class
23
  class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff extends PHPCompatibility_Sniff
24
  {
25
 
 
 
 
 
 
 
 
26
  /**
27
  * Returns an array of tokens this test wants to listen for.
28
  *
45
  */
46
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
47
  {
48
+ if ($this->supportsAbove('7.0') === false) {
49
+ return;
50
+ }
51
+
52
+ $tokens = $phpcsFile->getTokens();
53
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
54
+ return;
55
+ }
56
+
57
+ $defaultToken = $stackPtr;
58
+ $defaultCount = 0;
59
+ $targetLevel = $tokens[$stackPtr]['level'] + 1;
60
+ while ($defaultCount < 2 && $defaultToken = $phpcsFile->findNext(array(T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
61
+ // Same level or one below (= two default cases after each other).
62
+ if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
63
+ $defaultCount++;
 
64
  }
65
  }
66
+
67
+ if ($defaultCount > 1) {
68
+ $phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
69
+ }
70
  }//end process()
71
 
72
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/InternalInterfacesSniff.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff.
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category PHP
8
+ * @package PHPCompatibility
9
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
10
+ */
11
+
12
+ /**
13
+ * PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff.
14
+ *
15
+ * @category PHP
16
+ * @package PHPCompatibility
17
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
+ */
19
+ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibility_Sniff
20
+ {
21
+
22
+ /**
23
+ * A list of PHP internal interfaces, not intended to be implemented by userland classes.
24
+ *
25
+ * The array lists : the error message to use.
26
+ *
27
+ * @var array(string => string)
28
+ */
29
+ protected $internalInterfaces = array(
30
+ 'Traversable' => 'shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.',
31
+ 'DateTimeInterface' => 'is intended for type hints only and is not implementable.',
32
+ 'Throwable' => 'cannot be implemented directly, extend the Exception class instead.',
33
+ );
34
+
35
+
36
+ /**
37
+ * Returns an array of tokens this test wants to listen for.
38
+ *
39
+ * @return array
40
+ */
41
+ public function register()
42
+ {
43
+ // Handle case-insensitivity of class names.
44
+ $keys = array_keys( $this->internalInterfaces );
45
+ $keys = array_map( 'strtolower', $keys );
46
+ $this->internalInterfaces = array_combine( $keys, $this->internalInterfaces );
47
+
48
+ return array(T_CLASS);
49
+
50
+ }//end register()
51
+
52
+
53
+ /**
54
+ * Processes this test, when one of its tokens is encountered.
55
+ *
56
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+ * @param int $stackPtr The position of the current token in
58
+ * the stack passed in $tokens.
59
+ *
60
+ * @return void
61
+ */
62
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
+ {
64
+ $interfaces = $this->findImplementedInterfaceNames($phpcsFile, $stackPtr);
65
+
66
+ if (is_array($interfaces) === false || $interfaces === array()) {
67
+ return;
68
+ }
69
+
70
+ foreach ($interfaces as $interface) {
71
+ $lcInterface = strtolower($interface);
72
+ if (isset($this->internalInterfaces[$lcInterface]) === true) {
73
+ $error = 'The interface %s %s';
74
+ $data = array(
75
+ $interface,
76
+ $this->internalInterfaces[$lcInterface],
77
+ );
78
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
79
+ }
80
+ }
81
+
82
+ }//end process()
83
+
84
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/LateStaticBindingSniff.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff extends PHPCompatibility_Sniff
18
+ {
19
+ /**
20
+ * Returns an array of tokens this test wants to listen for.
21
+ *
22
+ * @return array
23
+ */
24
+ public function register()
25
+ {
26
+ return array(T_STATIC);
27
+
28
+ }//end register()
29
+
30
+
31
+ /**
32
+ * Processes this test, when one of its tokens is encountered.
33
+ *
34
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
35
+ * @param int $stackPtr The position of the current token in the
36
+ * stack passed in $tokens.
37
+ *
38
+ * @return void
39
+ */
40
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
41
+ {
42
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
43
+ if ($nextNonEmpty === false) {
44
+ return;
45
+ }
46
+
47
+ $tokens = $phpcsFile->getTokens();
48
+ if ($tokens[$nextNonEmpty]['code'] !== T_DOUBLE_COLON) {
49
+ return;
50
+ }
51
+
52
+ $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
53
+
54
+ if ($inClass === true && $this->supportsBelow('5.2') === true) {
55
+ $error = 'Late static binding is not supported in PHP 5.2 or earlier.';
56
+ $phpcsFile->addError($error, $stackPtr, 'Found');
57
+ }
58
+
59
+ if ($inClass === false) {
60
+ $error = 'Late static binding is not supported outside of class scope.';
61
+ $phpcsFile->addError($error, $stackPtr, 'OutsideClassScope');
62
+ }
63
+
64
+ }//end process()
65
+
66
+
67
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/LongArraysSniff.php CHANGED
@@ -60,18 +60,15 @@ class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff
60
  */
61
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
62
  {
63
- if ($this->supportsAbove('5.3')) {
64
- $tokens = $phpcsFile->getTokens();
 
65
 
66
- if ($tokens[$stackPtr]['type'] == 'T_VARIABLE'
67
- && in_array(substr($tokens[$stackPtr]['content'], 1), $this->deprecated)
68
- ) {
69
- $error = sprintf(
70
- "The use of long predefined variables has been deprecated in 5.3 and removed in 5.4; Found '%s'",
71
- $tokens[$stackPtr]['content']
72
- );
73
- $phpcsFile->addWarning($error, $stackPtr);
74
- }
75
  }
76
  }
77
  }
60
  */
61
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
62
  {
63
+ if ($this->supportsAbove('5.3') === false) {
64
+ return;
65
+ }
66
 
67
+ $tokens = $phpcsFile->getTokens();
68
+ if (in_array(substr($tokens[$stackPtr]['content'], 1), $this->deprecated, true)) {
69
+ $error = "The use of long predefined variables has been deprecated in 5.3 and removed in 5.4; Found '%s'";
70
+ $data = array($tokens[$stackPtr]['content']);
71
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
 
 
 
 
72
  }
73
  }
74
  }
vendor/wimg/php-compatibility/Sniffs/PHP/NewAnonymousClassesSniff.php CHANGED
@@ -46,15 +46,14 @@ class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibil
46
  */
47
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48
  {
49
- $tokens = $phpcsFile->getTokens();
50
  $whitespace = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, $stackPtr + 2);
51
- $class = $phpcsFile->findNext(T_ANON_CLASS, $stackPtr + 2, $stackPtr + 3);
52
- if ($whitespace == false || $class == false) {
53
- return false;
54
  }
55
-
56
  if ($this->supportsAbove('7.0')) {
57
- return false;
58
  } else {
59
  $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr);
60
  }
46
  */
47
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48
  {
 
49
  $whitespace = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, $stackPtr + 2);
50
+ $class = $phpcsFile->findNext(T_ANON_CLASS, $stackPtr + 2, $stackPtr + 3);
51
+ if ($whitespace === false || $class === false) {
52
+ return;
53
  }
54
+
55
  if ($this->supportsAbove('7.0')) {
56
+ return;
57
  } else {
58
  $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr);
59
  }
vendor/wimg/php-compatibility/Sniffs/PHP/NewClassesSniff.php CHANGED
@@ -133,10 +133,6 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
133
  '5.3' => false,
134
  '5.4' => true
135
  ),
136
- 'JsonSerializable' => array(
137
- '5.3' => false,
138
- '5.4' => true
139
- ),
140
  'SessionHandler' => array(
141
  '5.3' => false,
142
  '5.4' => true
@@ -190,14 +186,6 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
190
  );
191
 
192
 
193
- /**
194
- * If true, an error will be thrown; otherwise a warning.
195
- *
196
- * @var bool
197
- */
198
- protected $error = false;
199
-
200
-
201
  /**
202
  * Returns an array of tokens this test wants to listen for.
203
  *
@@ -205,7 +193,11 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
205
  */
206
  public function register()
207
  {
208
- return array(T_NEW);
 
 
 
 
209
 
210
  }//end register()
211
 
@@ -221,39 +213,45 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
221
  */
222
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
223
  {
224
- $tokens = $phpcsFile->getTokens();
225
- if (
226
- $tokens[$stackPtr + 2]['type'] == 'T_STRING'
227
- &&
228
- (
229
- $tokens[$stackPtr + 3]['type'] == 'T_OPEN_PARENTHESIS'
230
- ||
231
- (
232
- $tokens[$stackPtr + 3]['type'] == 'T_WHITESPACE'
233
- &&
234
- $tokens[$stackPtr + 4]['type'] == 'T_OPEN_PARENTHESIS'
235
- )
236
- )
237
- ) {
238
- $className = $tokens[$stackPtr + 2]['content'];
239
- if (array_key_exists($className, $this->newClasses) === false) {
240
- return;
241
- }
242
- $this->addError($phpcsFile, $stackPtr, $className);
243
  }
244
 
 
 
 
 
 
 
 
 
 
245
 
 
246
 
247
  }//end process()
248
 
249
 
250
  /**
251
- * Generates the error or wanrning for this sniff.
252
  *
253
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
254
  * @param int $stackPtr The position of the function
255
  * in the token array.
256
- * @param string $function The name of the function.
257
  * @param string $pattern The pattern used for the match.
258
  *
259
  * @return void
@@ -266,11 +264,11 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
266
 
267
  $error = '';
268
 
269
- $this->error = false;
270
  foreach ($this->newClasses[$pattern] as $version => $present) {
271
  if ($this->supportsBelow($version)) {
272
  if ($present === false) {
273
- $this->error = true;
274
  $error .= 'not present in PHP version ' . $version . ' or earlier';
275
  }
276
  }
@@ -278,7 +276,7 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
278
  if (strlen($error) > 0) {
279
  $error = 'The built-in class ' . $className . ' is ' . $error;
280
 
281
- if ($this->error === true) {
282
  $phpcsFile->addError($error, $stackPtr);
283
  } else {
284
  $phpcsFile->addWarning($error, $stackPtr);
133
  '5.3' => false,
134
  '5.4' => true
135
  ),
 
 
 
 
136
  'SessionHandler' => array(
137
  '5.3' => false,
138
  '5.4' => true
186
  );
187
 
188
 
 
 
 
 
 
 
 
 
189
  /**
190
  * Returns an array of tokens this test wants to listen for.
191
  *
193
  */
194
  public function register()
195
  {
196
+ return array(
197
+ T_NEW,
198
+ T_CLASS,
199
+ T_DOUBLE_COLON,
200
+ );
201
 
202
  }//end register()
203
 
213
  */
214
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
215
  {
216
+ $tokens = $phpcsFile->getTokens();
217
+ $FQClassName = '';
218
+
219
+ if ($tokens[$stackPtr]['type'] === 'T_NEW') {
220
+ $FQClassName = $this->getFQClassNameFromNewToken($phpcsFile, $stackPtr);
221
+ }
222
+ else if ($tokens[$stackPtr]['type'] === 'T_CLASS') {
223
+ $FQClassName = $this->getFQExtendedClassName($phpcsFile, $stackPtr);
224
+ }
225
+ else if ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') {
226
+ $FQClassName = $this->getFQClassNameFromDoubleColonToken($phpcsFile, $stackPtr);
227
+ }
228
+
229
+ if ($FQClassName === '') {
230
+ return;
 
 
 
 
231
  }
232
 
233
+ if ($this->isNamespaced($FQClassName) === true) {
234
+ return;
235
+ }
236
+
237
+ $className = substr($FQClassName, 1); // Remove global namespace indicator.
238
+
239
+ if (array_key_exists($className, $this->newClasses) === false) {
240
+ return;
241
+ }
242
 
243
+ $this->addError($phpcsFile, $stackPtr, $className);
244
 
245
  }//end process()
246
 
247
 
248
  /**
249
+ * Generates the error or warning for this sniff.
250
  *
251
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
252
  * @param int $stackPtr The position of the function
253
  * in the token array.
254
+ * @param string $className The name of the class.
255
  * @param string $pattern The pattern used for the match.
256
  *
257
  * @return void
264
 
265
  $error = '';
266
 
267
+ $isError = false;
268
  foreach ($this->newClasses[$pattern] as $version => $present) {
269
  if ($this->supportsBelow($version)) {
270
  if ($present === false) {
271
+ $isError = true;
272
  $error .= 'not present in PHP version ' . $version . ' or earlier';
273
  }
274
  }
276
  if (strlen($error) > 0) {
277
  $error = 'The built-in class ' . $className . ' is ' . $error;
278
 
279
+ if ($isError === true) {
280
  $phpcsFile->addError($error, $stackPtr);
281
  } else {
282
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_Sniff
18
+ {
19
+
20
+ /**
21
+ * A list of new execution directives
22
+ *
23
+ * The array lists : version number with false (not present) or true (present).
24
+ * If the execution order is conditional, add the condition as a string to the version nr.
25
+ * If's sufficient to list the first version where the execution directive appears.
26
+ *
27
+ * @var array(string => array(string => int|string|null))
28
+ */
29
+ protected $newDirectives = array (
30
+ 'ticks' => array(
31
+ '3.1' => false,
32
+ '4.0' => true,
33
+ 'valid_value_callback' => 'isNumeric',
34
+ ),
35
+ 'encoding' => array(
36
+ '5.2' => false,
37
+ '5.3' => '--enable-zend-multibyte', // Directive ignored unless.
38
+ '5.4' => true,
39
+ 'valid_value_callback' => 'validEncoding',
40
+ ),
41
+ 'strict_types' => array(
42
+ '5.6' => false,
43
+ '7.0' => true,
44
+ 'valid_values' => array(1),
45
+ ),
46
+ );
47
+
48
+
49
+ /**
50
+ * Tokens to ignore when trying to find the value for the directive.
51
+ *
52
+ * @var array
53
+ */
54
+ protected $ignoreTokens = array();
55
+
56
+
57
+ /**
58
+ * Returns an array of tokens this test wants to listen for.
59
+ *
60
+ * @return array
61
+ */
62
+ public function register()
63
+ {
64
+ $this->ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens;
65
+ $this->ignoreTokens[T_EQUAL] = T_EQUAL;
66
+
67
+ return array(T_DECLARE);
68
+ }//end register()
69
+
70
+
71
+ /**
72
+ * Processes this test, when one of its tokens is encountered.
73
+ *
74
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
75
+ * @param int $stackPtr The position of the current token in
76
+ * the stack passed in $tokens.
77
+ *
78
+ * @return void
79
+ */
80
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
81
+ {
82
+ $tokens = $phpcsFile->getTokens();
83
+
84
+ if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === true) {
85
+ $openParenthesis = $tokens[$stackPtr]['parenthesis_opener'];
86
+ $closeParenthesis = $tokens[$stackPtr]['parenthesis_closer'];
87
+ }
88
+ else {
89
+ if (version_compare(PHP_CodeSniffer::VERSION, '2.0', '>=')) {
90
+ return;
91
+ }
92
+
93
+ // Deal with PHPCS 1.x which does not set the parenthesis properly for declare statements.
94
+ $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true);
95
+ if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
96
+ return;
97
+ }
98
+ $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
99
+ }
100
+
101
+ $directivePtr = $phpcsFile->findNext(T_STRING, ($openParenthesis + 1), $closeParenthesis, false);
102
+ if ($directivePtr === false) {
103
+ return;
104
+ }
105
+
106
+ $directiveContent = $tokens[$directivePtr]['content'];
107
+
108
+ if (isset($this->newDirectives[$directiveContent]) === false) {
109
+ $error = 'Declare can only be used with the directives %s. Found: %s';
110
+ $data = array(
111
+ implode(', ', array_keys($this->newDirectives)),
112
+ $directiveContent,
113
+ );
114
+ $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
115
+ }
116
+ else {
117
+ // Check for valid directive for version.
118
+ $this->maybeAddError($phpcsFile, $stackPtr, $directiveContent);
119
+
120
+ // Check for valid directive value.
121
+ $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
122
+ if ($valuePtr === false) {
123
+ return;
124
+ }
125
+
126
+ $this->addErrorOnInvalidValue($phpcsFile, $valuePtr, $directiveContent);
127
+ }
128
+
129
+ }//end process()
130
+
131
+
132
+ /**
133
+ * Generates a error or warning for this sniff.
134
+ *
135
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
136
+ * @param int $stackPtr The position of the declare statement
137
+ * in the token array.
138
+ * @param string $directive The directive.
139
+ *
140
+ * @return void
141
+ */
142
+ protected function maybeAddError($phpcsFile, $stackPtr, $directive)
143
+ {
144
+ $isError = false;
145
+ $notInVersion = '';
146
+ $conditionalVersion = '';
147
+ foreach ($this->newDirectives[$directive] as $version => $present) {
148
+ if (strpos($version, 'valid_') === false && $this->supportsBelow($version)) {
149
+ if ($present === false) {
150
+ $isError = true;
151
+ $notInVersion = $version;
152
+ }
153
+ else if (is_string($present)) {
154
+ // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
155
+ $conditionalVersion = $version;
156
+ }
157
+ }
158
+ }
159
+ if ($notInVersion !== '' || $conditionalVersion !== '') {
160
+ if ($isError === true && $notInVersion !== '') {
161
+ $error = 'Directive %s is not present in PHP version %s or earlier';
162
+ $errorCode = $directive . 'Found';
163
+ $data = array(
164
+ $directive,
165
+ $notInVersion,
166
+ );
167
+
168
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
169
+ }
170
+ else if($conditionalVersion !== '') {
171
+ $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
172
+ $errorCode = $directive . 'Found';
173
+ $data = array(
174
+ $directive,
175
+ $conditionalVersion,
176
+ $this->newDirectives[$directive][$conditionalVersion],
177
+ );
178
+
179
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
180
+ }
181
+ }
182
+
183
+ }//end maybeAddError()
184
+
185
+
186
+ /**
187
+ * Generates a error or warning for this sniff.
188
+ *
189
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
190
+ * @param int $stackPtr The position of the execution directive value
191
+ * in the token array.
192
+ * @param string $directive The directive.
193
+ *
194
+ * @return void
195
+ */
196
+ protected function addErrorOnInvalidValue($phpcsFile, $stackPtr, $directive)
197
+ {
198
+ $tokens = $phpcsFile->getTokens();
199
+
200
+ $value = $tokens[$stackPtr]['content'];
201
+ if ($tokens[$stackPtr]['code'] === T_CONSTANT_ENCAPSED_STRING) {
202
+ $value = trim($value, '\'"');
203
+ }
204
+
205
+ $isError = false;
206
+ if (isset($this->newDirectives[$directive]['valid_values'])) {
207
+ if (in_array($value, $this->newDirectives[$directive]['valid_values']) === false) {
208
+ $isError = true;
209
+ }
210
+ }
211
+ else if (isset($this->newDirectives[$directive]['valid_value_callback'])) {
212
+ $valid = call_user_func(array($this, $this->newDirectives[$directive]['valid_value_callback']), $value);
213
+ if ($valid === false) {
214
+ $isError = true;
215
+ }
216
+ }
217
+
218
+ if ($isError === true) {
219
+ $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
220
+ $data = array(
221
+ $directive,
222
+ $value,
223
+ );
224
+ $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveValueFound', $data);
225
+ }
226
+ }// addErrorOnInvalidValue()
227
+
228
+
229
+ /**
230
+ * Check whether a value is numeric.
231
+ *
232
+ * Callback function to test whether the value for an execution directive is valid.
233
+ *
234
+ * @param mixed $value The value to test.
235
+ *
236
+ * @return bool
237
+ */
238
+ protected function isNumeric($value)
239
+ {
240
+ return is_numeric($value);
241
+ }
242
+
243
+
244
+ /**
245
+ * Check whether a value is valid encoding.
246
+ *
247
+ * Callback function to test whether the value for an execution directive is valid.
248
+ *
249
+ * @param mixed $value The value to test.
250
+ *
251
+ * @return bool
252
+ */
253
+ protected function validEncoding($value)
254
+ {
255
+ $encodings = array();
256
+ if (function_exists('mb_list_encodings')) {
257
+ $encodings = mb_list_encodings();
258
+ }
259
+
260
+ if (empty($encodings)) {
261
+ // If we can't test the encoding, let it pass through.
262
+ return true;
263
+ }
264
+
265
+ if (in_array($value, $encodings, true)) {
266
+ return true;
267
+ }
268
+ else {
269
+ return false;
270
+ }
271
+ }
272
+
273
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php CHANGED
@@ -25,7 +25,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHP
25
  {
26
  return array(T_STRING);
27
  }//end register()
28
-
29
  /**
30
  * Processes this test, when one of its tokens is encountered.
31
  *
@@ -51,7 +51,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHP
51
  // Not a call to a PHP function.
52
  return;
53
  }
54
-
55
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
56
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
57
  if ($tokens[$closeParenthesis + 1]['type'] == 'T_OPEN_SQUARE_BRACKET') {
25
  {
26
  return array(T_STRING);
27
  }//end register()
28
+
29
  /**
30
  * Processes this test, when one of its tokens is encountered.
31
  *
51
  // Not a call to a PHP function.
52
  return;
53
  }
54
+
55
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
56
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
57
  if ($tokens[$closeParenthesis + 1]['type'] == 'T_OPEN_SQUARE_BRACKET') {
vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionParametersSniff.php CHANGED
@@ -23,7 +23,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
-
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
@@ -33,19 +33,524 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
33
  *
34
  * @var array
35
  */
36
- public $newFunctionParameters = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  'dirname' => array(
38
  1 => array(
39
- 'name' => 'depth',
40
  '5.6' => false,
41
  '7.0' => true
42
  ),
43
  ),
44
- 'unserialize' => array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  1 => array(
46
  'name' => 'options',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  '5.6' => false,
48
- '7.0' => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ),
50
  ),
51
  'session_start' => array(
@@ -53,27 +558,163 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
53
  'name' => 'options',
54
  '5.6' => false,
55
  '7.0' => true
56
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ),
58
  'strstr' => array(
59
  2 => array(
60
  'name' => 'before_needle',
61
  '5.2' => false,
62
  '5.3' => true
63
- )
64
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  );
66
 
67
 
68
  /**
69
- * If true, an error will be thrown; otherwise a warning.
70
  *
71
- * @var bool
72
- */
73
- public $error = false;
74
-
75
- /**
76
- *
77
  * @var array
78
  */
79
  private $newFunctionParametersNames;
@@ -89,16 +730,16 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
89
  // Everyone has had a chance to figure out what forbidden functions
90
  // they want to check for, so now we can cache out the list.
91
  $this->newFunctionParametersNames = array_keys($this->newFunctionParameters);
92
-
93
  if ($this->patternMatch === true) {
94
  foreach ($this->newFunctionParametersNames as $i => $name) {
95
  $this->newFunctionParametersNames[$i] = '/'.$name.'/i';
96
  }
97
  }
98
-
99
  return array(T_STRING);
100
  }//end register()
101
-
102
  /**
103
  * Processes this test, when one of its tokens is encountered.
104
  *
@@ -130,34 +771,33 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
130
  if (in_array($function, $this->newFunctionParametersNames) === false) {
131
  return;
132
  }
133
-
134
- if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
135
- $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
136
-
137
- $nextComma = $stackPtr + 1;
138
- $cnt = 0;
139
- while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
140
- if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
141
- continue;
142
- }
143
- if (isset($this->newFunctionParameters[$function][$cnt])) {
144
- $this->addError($phpcsFile, $nextComma, $function, $cnt);
145
- }
146
- $cnt++;
147
  }
148
-
149
  }
 
150
  }//end process()
151
 
152
 
153
  /**
154
- * Generates the error or wanrning for this sniff.
155
  *
156
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
157
- * @param int $stackPtr The position of the function
158
- * in the token array.
159
- * @param string $function The name of the function.
160
- * @param string $pattern The pattern used for the match.
161
  *
162
  * @return void
163
  */
@@ -165,20 +805,19 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
165
  {
166
  $error = '';
167
 
168
- $this->error = false;
169
  foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
170
- if ($version != 'name' && $this->supportsBelow($version)) {
171
- if ($present === false) {
172
- $this->error = true;
173
- $error .= 'in PHP version ' . $version . ' or earlier';
174
- }
175
  }
176
  }
177
-
178
  if (strlen($error) > 0) {
179
- $error = 'The function ' . $function . ' does not have a parameter ' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;
180
 
181
- if ($this->error === true) {
182
  $phpcsFile->addError($error, $stackPtr);
183
  } else {
184
  $phpcsFile->addWarning($error, $stackPtr);
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
+
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
33
  *
34
  * @var array
35
  */
36
+ protected $newFunctionParameters = array(
37
+ 'array_filter' => array(
38
+ 2 => array(
39
+ 'name' => 'flag',
40
+ '5.5' => false,
41
+ '5.6' => true
42
+ ),
43
+ ),
44
+ 'array_slice' => array(
45
+ 1 => array(
46
+ 'name' => 'preserve_keys',
47
+ '5.0.1' => false,
48
+ '5.0.2' => true
49
+ ),
50
+ ),
51
+ 'array_unique' => array(
52
+ 1 => array(
53
+ 'name' => 'sort_flags',
54
+ '5.2.8' => false,
55
+ '5.2.9' => true
56
+ ),
57
+ ),
58
+ 'assert' => array(
59
+ 1 => array(
60
+ 'name' => 'description',
61
+ '5.4.7' => false,
62
+ '5.4.8' => true
63
+ ),
64
+ ),
65
+ 'base64_decode' => array(
66
+ 1 => array(
67
+ 'name' => 'strict',
68
+ '5.1' => false,
69
+ '5.2' => true
70
+ ),
71
+ ),
72
+ 'class_implements' => array(
73
+ 1 => array(
74
+ 'name' => 'autoload',
75
+ '5.0' => false,
76
+ '5.1' => true
77
+ ),
78
+ ),
79
+ 'class_parents' => array(
80
+ 1 => array(
81
+ 'name' => 'autoload',
82
+ '5.0' => false,
83
+ '5.1' => true
84
+ ),
85
+ ),
86
+ 'clearstatcache' => array(
87
+ 0 => array(
88
+ 'name' => 'clear_realpath_cache',
89
+ '5.2' => false,
90
+ '5.3' => true
91
+ ),
92
+ 1 => array(
93
+ 'name' => 'filename',
94
+ '5.2' => false,
95
+ '5.3' => true
96
+ ),
97
+ ),
98
+ 'copy' => array(
99
+ 2 => array(
100
+ 'name' => 'context',
101
+ '5.2' => false,
102
+ '5.3' => true
103
+ ),
104
+ ),
105
+ 'curl_multi_info_read' => array(
106
+ 1 => array(
107
+ 'name' => 'msgs_in_queue',
108
+ '5.1' => false,
109
+ '5.2' => true
110
+ ),
111
+ ),
112
+ 'debug_backtrace' => array(
113
+ 0 => array(
114
+ 'name' => 'options',
115
+ '5.2.4' => false,
116
+ '5.2.5' => true
117
+ ),
118
+ 1 => array(
119
+ 'name' => 'limit',
120
+ '5.3' => false,
121
+ '5.4' => true
122
+ ),
123
+ ),
124
+ 'debug_print_backtrace' => array(
125
+ 0 => array(
126
+ 'name' => 'options',
127
+ '5.3.5' => false,
128
+ '5.3.6' => true
129
+ ),
130
+ 1 => array(
131
+ 'name' => 'limit',
132
+ '5.3' => false,
133
+ '5.4' => true
134
+ ),
135
+ ),
136
  'dirname' => array(
137
  1 => array(
138
+ 'name' => 'levels',
139
  '5.6' => false,
140
  '7.0' => true
141
  ),
142
  ),
143
+ 'dns_get_record' => array(
144
+ 4 => array(
145
+ 'name' => 'raw',
146
+ '5.3' => false,
147
+ '5.4' => true
148
+ ),
149
+ ),
150
+ 'fgetcsv' => array(
151
+ 4 => array(
152
+ 'name' => 'escape',
153
+ '5.2' => false,
154
+ '5.3' => true
155
+ ),
156
+ ),
157
+ 'fputcsv' => array(
158
+ 4 => array(
159
+ 'name' => 'escape_char',
160
+ '5.5.3' => false,
161
+ '5.5.4' => true
162
+ ),
163
+ ),
164
+ 'file_get_contents' => array(
165
+ 3 => array(
166
+ 'name' => 'offset',
167
+ '5.0' => false,
168
+ '5.1' => true
169
+ ),
170
+ 4 => array(
171
+ 'name' => 'maxlen',
172
+ '5.0' => false,
173
+ '5.1' => true
174
+ ),
175
+ ),
176
+ 'filter_input_array' => array(
177
+ 2 => array(
178
+ 'name' => 'add_empty',
179
+ '5.3' => false,
180
+ '5.4' => true
181
+ ),
182
+ ),
183
+ 'filter_var_array' => array(
184
+ 2 => array(
185
+ 'name' => 'add_empty',
186
+ '5.3' => false,
187
+ '5.4' => true
188
+ ),
189
+ ),
190
+ 'gettimeofday' => array(
191
+ 0 => array(
192
+ 'name' => 'return_float',
193
+ '5.0' => false,
194
+ '5.1' => true
195
+ ),
196
+ ),
197
+ 'get_html_translation_table' => array(
198
+ 2 => array(
199
+ 'name' => 'encoding',
200
+ '5.3.3' => false,
201
+ '5.3.4' => true
202
+ ),
203
+ ),
204
+ 'get_loaded_extensions' => array(
205
+ 0 => array(
206
+ 'name' => 'zend_extensions',
207
+ '5.2.3' => false,
208
+ '5.2.4' => true
209
+ ),
210
+ ),
211
+ 'gzcompress' => array(
212
+ 2 => array(
213
+ 'name' => 'encoding',
214
+ '5.3' => false,
215
+ '5.4' => true
216
+ ),
217
+ ),
218
+ 'gzdeflate' => array(
219
+ 2 => array(
220
+ 'name' => 'encoding',
221
+ '5.3' => false,
222
+ '5.4' => true
223
+ ),
224
+ ),
225
+ 'htmlentities' => array(
226
+ 3 => array(
227
+ 'name' => 'double_encode',
228
+ '5.2.2' => false,
229
+ '5.2.3' => true
230
+ ),
231
+ ),
232
+ 'htmlspecialchars' => array(
233
+ 3 => array(
234
+ 'name' => 'double_encode',
235
+ '5.2.2' => false,
236
+ '5.2.3' => true
237
+ ),
238
+ ),
239
+ 'http_build_query' => array(
240
+ 2 => array(
241
+ 'name' => 'arg_separator',
242
+ '5.1.1' => false,
243
+ '5.1.2' => true
244
+ ),
245
+ 3 => array(
246
+ 'name' => 'enc_type',
247
+ '5.3' => false,
248
+ '5.4' => true
249
+ ),
250
+ ),
251
+ 'idn_to_ascii' => array(
252
+ 2 => array(
253
+ 'name' => 'variant',
254
+ '5.3' => false,
255
+ '5.4' => true
256
+ ),
257
+ 3 => array(
258
+ 'name' => 'idna_info',
259
+ '5.3' => false,
260
+ '5.4' => true
261
+ ),
262
+ ),
263
+ 'idn_to_utf8' => array(
264
+ 2 => array(
265
+ 'name' => 'variant',
266
+ '5.3' => false,
267
+ '5.4' => true
268
+ ),
269
+ 3 => array(
270
+ 'name' => 'idna_info',
271
+ '5.3' => false,
272
+ '5.4' => true
273
+ ),
274
+ ),
275
+ 'imagecolorset' => array(
276
+ 5 => array(
277
+ 'name' => 'alpha',
278
+ '5.3' => false,
279
+ '5.4' => true
280
+ ),
281
+ ),
282
+ 'imagepng' => array(
283
+ 2 => array(
284
+ 'name' => 'quality',
285
+ '5.1.1' => false,
286
+ '5.1.2' => true
287
+ ),
288
+ 3 => array(
289
+ 'name' => 'filters',
290
+ '5.1.2' => false,
291
+ '5.1.3' => true
292
+ ),
293
+ ),
294
+ 'imagerotate' => array(
295
+ 3 => array(
296
+ 'name' => 'ignore_transparent',
297
+ '5.0' => false,
298
+ '5.1' => true
299
+ ),
300
+ ),
301
+ 'imap_open' => array(
302
+ 4 => array(
303
+ 'name' => 'n_retries',
304
+ '5.1' => false,
305
+ '5.2' => true
306
+ ),
307
+ 5 => array(
308
+ 'name' => 'params',
309
+ '5.3.1' => false,
310
+ '5.3.2' => true
311
+ ),
312
+ ),
313
+ 'imap_reopen' => array(
314
+ 3 => array(
315
+ 'name' => 'n_retries',
316
+ '5.1' => false,
317
+ '5.2' => true
318
+ ),
319
+ ),
320
+ 'ini_get_all' => array(
321
+ 1 => array(
322
+ 'name' => 'details',
323
+ '5.2' => false,
324
+ '5.3' => true
325
+ ),
326
+ ),
327
+ 'is_a' => array(
328
+ 2 => array(
329
+ 'name' => 'allow_string',
330
+ '5.3.8' => false,
331
+ '5.3.9' => true
332
+ ),
333
+ ),
334
+ 'is_subclass_of' => array(
335
+ 2 => array(
336
+ 'name' => 'allow_string',
337
+ '5.3.8' => false,
338
+ '5.3.9' => true
339
+ ),
340
+ ),
341
+ 'iterator_to_array' => array(
342
+ 1 => array(
343
+ 'name' => 'use_keys',
344
+ '5.2' => false,
345
+ '5.2.1' => true
346
+ ),
347
+ ),
348
+ 'json_decode' => array(
349
+ 2 => array(
350
+ 'name' => 'depth',
351
+ '5.2' => false,
352
+ '5.3' => true
353
+ ),
354
+ 3 => array(
355
+ 'name' => 'options',
356
+ '5.3' => false,
357
+ '5.4' => true
358
+ ),
359
+ ),
360
+ 'json_encode' => array(
361
  1 => array(
362
  'name' => 'options',
363
+ '5.2' => false,
364
+ '5.3' => true
365
+ ),
366
+ 2 => array(
367
+ 'name' => 'depth',
368
+ '5.4' => false,
369
+ '5.5' => true
370
+ ),
371
+ ),
372
+ 'memory_get_peak_usage' => array(
373
+ 0 => array(
374
+ 'name' => 'real_usage',
375
+ '5.1' => false,
376
+ '5.2' => true
377
+ ),
378
+ ),
379
+ 'memory_get_usage' => array(
380
+ 0 => array(
381
+ 'name' => 'real_usage',
382
+ '5.1' => false,
383
+ '5.2' => true
384
+ ),
385
+ ),
386
+ 'mb_encode_numericentity' => array(
387
+ 3 => array(
388
+ 'name' => 'is_hex',
389
+ '5.3' => false,
390
+ '5.4' => true
391
+ ),
392
+ ),
393
+ 'mb_strrpos' => array(
394
+ /*
395
+ * Note: the actual position is 2, but the original 3rd
396
+ * parameter 'encoding' was moved to the 4th position.
397
+ * So the only way to detect if offset is used is when
398
+ * both offset and encoding are set.
399
+ */
400
+ 3 => array(
401
+ 'name' => 'offset',
402
+ '5.1' => false,
403
+ '5.2' => true
404
+ ),
405
+ ),
406
+ 'mssql_connect' => array(
407
+ 3 => array(
408
+ 'name' => 'new_link',
409
+ '5.0' => false,
410
+ '5.1' => true
411
+ ),
412
+ ),
413
+ 'mysqli_commit' => array(
414
+ 1 => array(
415
+ 'name' => 'flags',
416
+ '5.4' => false,
417
+ '5.5' => true
418
+ ),
419
+ 2 => array(
420
+ 'name' => 'name',
421
+ '5.4' => false,
422
+ '5.5' => true
423
+ ),
424
+ ),
425
+ 'mysqli_rollback' => array(
426
+ 1 => array(
427
+ 'name' => 'flags',
428
+ '5.4' => false,
429
+ '5.5' => true
430
+ ),
431
+ 2 => array(
432
+ 'name' => 'name',
433
+ '5.4' => false,
434
+ '5.5' => true
435
+ ),
436
+ ),
437
+ 'nl2br' => array(
438
+ 1 => array(
439
+ 'name' => 'is_xhtml',
440
+ '5.2' => false,
441
+ '5.3' => true
442
+ ),
443
+ ),
444
+ 'openssl_decrypt' => array(
445
+ 4 => array(
446
+ 'name' => 'iv',
447
+ '5.3.2' => false,
448
+ '5.3.3' => true
449
+ ),
450
+ ),
451
+ 'openssl_encrypt' => array(
452
+ 4 => array(
453
+ 'name' => 'iv',
454
+ '5.3.2' => false,
455
+ '5.3.3' => true
456
+ ),
457
+ ),
458
+ 'openssl_pkcs7_verify' => array(
459
+ 5 => array(
460
+ 'name' => 'content',
461
+ '5.0' => false,
462
+ '5.1' => true
463
+ ),
464
+ ),
465
+ 'openssl_seal' => array(
466
+ 4 => array(
467
+ 'name' => 'method',
468
+ '5.2' => false,
469
+ '5.3' => true
470
+ ),
471
+ ),
472
+ 'openssl_verify' => array(
473
+ 3 => array(
474
+ 'name' => 'signature_alg',
475
+ '5.1' => false,
476
+ '5.2' => true
477
+ ),
478
+ ),
479
+ 'parse_ini_file' => array(
480
+ 2 => array(
481
+ 'name' => 'scanner_mode',
482
+ '5.2' => false,
483
+ '5.3' => true
484
+ ),
485
+ ),
486
+ 'parse_url' => array(
487
+ 1 => array(
488
+ 'name' => 'component',
489
+ '5.1.1' => false,
490
+ '5.1.2' => true
491
+ ),
492
+ ),
493
+ 'pg_lo_create' => array(
494
+ 1 => array(
495
+ 'name' => 'object_id',
496
+ '5.2' => false,
497
+ '5.3' => true
498
+ ),
499
+ ),
500
+ 'pg_lo_import' => array(
501
+ 2 => array(
502
+ 'name' => 'object_id',
503
+ '5.2' => false,
504
+ '5.3' => true
505
+ ),
506
+ ),
507
+ 'preg_replace' => array(
508
+ 4 => array(
509
+ 'name' => 'count',
510
+ '5.0' => false,
511
+ '5.1' => true
512
+ ),
513
+ ),
514
+ 'preg_replace_callback' => array(
515
+ 4 => array(
516
+ 'name' => 'count',
517
+ '5.0' => false,
518
+ '5.1' => true
519
+ ),
520
+ ),
521
+ 'round' => array(
522
+ 2 => array(
523
+ 'name' => 'mode',
524
+ '5.2' => false,
525
+ '5.3' => true
526
+ ),
527
+ ),
528
+ 'sem_acquire' => array(
529
+ 1 => array(
530
+ 'name' => 'nowait',
531
  '5.6' => false,
532
+ '5.6.1' => true
533
+ ),
534
+ ),
535
+ 'session_regenerate_id' => array(
536
+ 0 => array(
537
+ 'name' => 'delete_old_session',
538
+ '5.0' => false,
539
+ '5.1' => true
540
+ ),
541
+ ),
542
+ 'session_set_cookie_params' => array(
543
+ 4 => array(
544
+ 'name' => 'httponly',
545
+ '5.1' => false,
546
+ '5.2' => true
547
+ ),
548
+ ),
549
+ 'session_set_save_handler' => array(
550
+ 6 => array(
551
+ 'name' => 'create_sid',
552
+ '5.5' => false,
553
+ '5.5.1' => true
554
  ),
555
  ),
556
  'session_start' => array(
558
  'name' => 'options',
559
  '5.6' => false,
560
  '7.0' => true
561
+ ),
562
+ ),
563
+ 'setcookie' => array(
564
+ 6 => array(
565
+ 'name' => 'httponly',
566
+ '5.1' => false,
567
+ '5.2' => true
568
+ ),
569
+ ),
570
+ 'setrawcookie' => array(
571
+ 6 => array(
572
+ 'name' => 'httponly',
573
+ '5.1' => false,
574
+ '5.2' => true
575
+ ),
576
+ ),
577
+ 'simplexml_load_file' => array(
578
+ 4 => array(
579
+ 'name' => 'is_prefix',
580
+ '5.1' => false,
581
+ '5.2' => true
582
+ ),
583
+ ),
584
+ 'simplexml_load_string' => array(
585
+ 4 => array(
586
+ 'name' => 'is_prefix',
587
+ '5.1' => false,
588
+ '5.2' => true
589
+ ),
590
+ ),
591
+ 'spl_autoload_register' => array(
592
+ 2 => array(
593
+ 'name' => 'prepend',
594
+ '5.2' => false,
595
+ '5.3' => true
596
+ ),
597
+ ),
598
+ 'stream_context_create' => array(
599
+ 1 => array(
600
+ 'name' => 'params',
601
+ '5.2' => false,
602
+ '5.3' => true
603
+ ),
604
+ ),
605
+ 'stream_copy_to_stream' => array(
606
+ 3 => array(
607
+ 'name' => 'offset',
608
+ '5.0' => false,
609
+ '5.1' => true
610
+ ),
611
+ ),
612
+ 'stream_get_contents' => array(
613
+ 2 => array(
614
+ 'name' => 'offset',
615
+ '5.0' => false,
616
+ '5.1' => true
617
+ ),
618
+ ),
619
+ 'stream_wrapper_register' => array(
620
+ 2 => array(
621
+ 'name' => 'flags',
622
+ '5.2.3' => false,
623
+ '5.2.4' => true
624
+ ),
625
+ ),
626
+ 'stristr' => array(
627
+ 2 => array(
628
+ 'name' => 'before_needle',
629
+ '5.2' => false,
630
+ '5.3' => true
631
+ ),
632
  ),
633
  'strstr' => array(
634
  2 => array(
635
  'name' => 'before_needle',
636
  '5.2' => false,
637
  '5.3' => true
638
+ ),
639
+ ),
640
+ 'str_word_count' => array(
641
+ 2 => array(
642
+ 'name' => 'charlist',
643
+ '5.0' => false,
644
+ '5.1' => true
645
+ ),
646
+ ),
647
+ 'substr_count' => array(
648
+ 2 => array(
649
+ 'name' => 'offset',
650
+ '5.0' => false,
651
+ '5.1' => true
652
+ ),
653
+ 3 => array(
654
+ 'name' => 'length',
655
+ '5.0' => false,
656
+ '5.1' => true
657
+ ),
658
+ ),
659
+ 'sybase_connect' => array(
660
+ 5 => array(
661
+ 'name' => 'new',
662
+ '5.2' => false,
663
+ '5.3' => true
664
+ ),
665
+ ),
666
+ 'timezone_transitions_get' => array(
667
+ 1 => array(
668
+ 'name' => 'timestamp_begin',
669
+ '5.2' => false,
670
+ '5.3' => true
671
+ ),
672
+ 2 => array(
673
+ 'name' => 'timestamp_end',
674
+ '5.2' => false,
675
+ '5.3' => true
676
+ ),
677
+ ),
678
+ 'timezone_identifiers_list' => array(
679
+ 0 => array(
680
+ 'name' => 'what',
681
+ '5.2' => false,
682
+ '5.3' => true
683
+ ),
684
+ 1 => array(
685
+ 'name' => 'country',
686
+ '5.2' => false,
687
+ '5.3' => true
688
+ ),
689
+ ),
690
+ 'token_get_all' => array(
691
+ 1 => array(
692
+ 'name' => 'flags',
693
+ '5.6' => false,
694
+ '7.0' => true
695
+ ),
696
+ ),
697
+ 'ucwords' => array(
698
+ 1 => array(
699
+ 'name' => 'delimiters',
700
+ '5.4.31' => false,
701
+ '5.5.15' => false,
702
+ '5.4.32' => true,
703
+ '5.5.16' => true
704
+ ),
705
+ ),
706
+ 'unserialize' => array(
707
+ 1 => array(
708
+ 'name' => 'options',
709
+ '5.6' => false,
710
+ '7.0' => true
711
+ ),
712
+ ),
713
  );
714
 
715
 
716
  /**
 
717
  *
 
 
 
 
 
 
718
  * @var array
719
  */
720
  private $newFunctionParametersNames;
730
  // Everyone has had a chance to figure out what forbidden functions
731
  // they want to check for, so now we can cache out the list.
732
  $this->newFunctionParametersNames = array_keys($this->newFunctionParameters);
733
+
734
  if ($this->patternMatch === true) {
735
  foreach ($this->newFunctionParametersNames as $i => $name) {
736
  $this->newFunctionParametersNames[$i] = '/'.$name.'/i';
737
  }
738
  }
739
+
740
  return array(T_STRING);
741
  }//end register()
742
+
743
  /**
744
  * Processes this test, when one of its tokens is encountered.
745
  *
771
  if (in_array($function, $this->newFunctionParametersNames) === false) {
772
  return;
773
  }
774
+
775
+ $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
776
+ if ($parameterCount === 0) {
777
+ return;
778
+ }
779
+
780
+ // If the parameter count returned > 0, we know there will be valid open parenthesis.
781
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
782
+ $parameterOffsetFound = $parameterCount - 1;
783
+
784
+ foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) {
785
+ if ($offset <= $parameterOffsetFound) {
786
+ $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
787
  }
 
788
  }
789
+
790
  }//end process()
791
 
792
 
793
  /**
794
+ * Generates the error or warning for this sniff.
795
  *
796
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
797
+ * @param int $stackPtr The position of the function
798
+ * in the token array.
799
+ * @param string $function The name of the function.
800
+ * @param int $parameterLocation The parameter position within the function call.
801
  *
802
  * @return void
803
  */
805
  {
806
  $error = '';
807
 
808
+ $isError = false;
809
  foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
810
+ if ($version != 'name' && $present === false && $this->supportsBelow($version)) {
811
+ $isError = true;
812
+ $error .= 'in PHP version ' . $version . ' or earlier';
813
+ break;
 
814
  }
815
  }
816
+
817
  if (strlen($error) > 0) {
818
+ $error = 'The function ' . $function . ' does not have a parameter "' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . '" ' . $error;
819
 
820
+ if ($isError === true) {
821
  $phpcsFile->addError($error, $stackPtr);
822
  } else {
823
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionsSniff.php CHANGED
@@ -23,7 +23,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
-
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
@@ -32,7 +32,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
32
  *
33
  * @var array(string => array(string => int|string|null))
34
  */
35
- public $forbiddenFunctions = array(
36
  'array_fill_keys' => array(
37
  '5.1' => false,
38
  '5.2' => true
@@ -105,14 +105,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
105
  '5.1' => false,
106
  '5.2' => true
107
  ),
108
- 'swfmovie::namedanchor' => array(
109
- '5.1' => false,
110
- '5.2' => true
111
- ),
112
- 'swfmovie::protect' => array(
113
- '5.1' => false,
114
- '5.2' => true
115
- ),
116
  'openssl_csr_get_public_key' => array(
117
  '5.1' => false,
118
  '5.2' => true
@@ -322,14 +314,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
322
  '5.2' => false,
323
  '5.3' => true
324
  ),
325
- 'streamWrapper::stream_cast' => array(
326
- '5.2' => false,
327
- '5.3' => true
328
- ),
329
- 'streamWrapper::stream_set_option' => array(
330
- '5.2' => false,
331
- '5.3' => true
332
- ),
333
  'date_add' => array(
334
  '5.2' => false,
335
  '5.3' => true
@@ -382,6 +366,10 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
382
  '5.2' => false,
383
  '5.3' => true
384
  ),
 
 
 
 
385
  'mysqli_fetch_all' => array(
386
  '5.2' => false,
387
  '5.3' => true
@@ -434,6 +422,22 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
434
  '5.2' => false,
435
  '5.3' => true
436
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  'enchant_broker_describe' => array(
438
  '5.2' => false,
439
  '5.3' => true
@@ -1080,14 +1084,83 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1080
  '5.4' => false,
1081
  '5.5' => true
1082
  ),
1083
- 'SplFixedArray::_wakup' => array(
1084
- '5.4' => false,
1085
- '5.5' => true
 
1086
  ),
1087
- 'Closure::call' => array(
1088
- '5.6' => false,
1089
- '7.0' => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1090
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1091
  'random_bytes' => array(
1092
  '5.6' => false,
1093
  '7.0' => true
@@ -1100,10 +1173,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1100
  '5.6' => false,
1101
  '7.0' => true
1102
  ),
1103
- 'Generator::getReturn' => array(
1104
- '5.6' => false,
1105
- '7.0' => true
1106
- ),
1107
  'gmp_random_seed' => array(
1108
  '5.6' => false,
1109
  '7.0' => true
@@ -1128,34 +1197,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1128
  '5.6' => false,
1129
  '7.0' => true
1130
  ),
1131
- 'ReflectionParameter::getType' => array(
1132
- '5.6' => false,
1133
- '7.0' => true
1134
- ),
1135
- '' => array(
1136
- '5.6' => false,
1137
- '7.0' => true
1138
- ),
1139
- 'ReflectionParameter::hasType' => array(
1140
- '5.6' => false,
1141
- '7.0' => true
1142
- ),
1143
- 'ReflectionFunctionAbstract::getReturnType' => array(
1144
- '5.6' => false,
1145
- '7.0' => true
1146
- ),
1147
- 'ReflectionFunctionAbstract::hasReturnType' => array(
1148
- '5.6' => false,
1149
- '7.0' => true
1150
- ),
1151
- 'ZipArchive::setCompressionIndex' => array(
1152
- '5.6' => false,
1153
- '7.0' => true
1154
- ),
1155
- 'ZipArchive::setCompressionName' => array(
1156
- '5.6' => false,
1157
- '7.0' => true
1158
- ),
1159
  'inflate_add' => array(
1160
  '5.6' => false,
1161
  '7.0' => true
@@ -1176,18 +1217,11 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1176
 
1177
 
1178
  /**
1179
- * If true, an error will be thrown; otherwise a warning.
1180
  *
1181
- * @var bool
1182
- */
1183
- public $error = false;
1184
-
1185
- /**
1186
- *
1187
- * @var unknown
1188
  */
1189
  private $forbiddenFunctionNames;
1190
-
1191
 
1192
  /**
1193
  * Returns an array of tokens this test wants to listen for.
@@ -1199,17 +1233,19 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1199
  // Everyone has had a chance to figure out what forbidden functions
1200
  // they want to check for, so now we can cache out the list.
1201
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
1202
-
 
 
1203
  if ($this->patternMatch === true) {
1204
  foreach ($this->forbiddenFunctionNames as $i => $name) {
1205
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
1206
  }
1207
  }
1208
-
1209
  return array(T_STRING);
1210
-
1211
  }//end register()
1212
-
1213
  /**
1214
  * Processes this test, when one of its tokens is encountered.
1215
  *
@@ -1235,6 +1271,10 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1235
  // Not a call to a PHP function.
1236
  return;
1237
  }
 
 
 
 
1238
 
1239
  $function = strtolower($tokens[$stackPtr]['content']);
1240
  $pattern = null;
@@ -1243,7 +1283,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1243
  $count = 0;
1244
  $pattern = preg_replace(
1245
  $this->forbiddenFunctionNames,
1246
- $this->forbiddenFunctionsNames,
1247
  $function,
1248
  1,
1249
  $count
@@ -1261,13 +1301,13 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1261
  }
1262
  }
1263
 
1264
- $this->addError($phpcsFile, $stackPtr, $function, $pattern);
1265
 
1266
  }//end process()
1267
 
1268
 
1269
  /**
1270
- * Generates the error or wanrning for this sniff.
1271
  *
1272
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
1273
  * @param int $stackPtr The position of the function
@@ -1280,16 +1320,16 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1280
  protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
1281
  {
1282
  if ($pattern === null) {
1283
- $pattern = $function;
1284
  }
1285
 
1286
  $error = '';
1287
 
1288
- $this->error = false;
1289
  foreach ($this->forbiddenFunctions[$pattern] as $version => $present) {
1290
  if ($this->supportsBelow($version)) {
1291
  if ($present === false) {
1292
- $this->error = true;
1293
  $error .= 'not present in PHP version ' . $version . ' or earlier';
1294
  }
1295
  }
@@ -1297,7 +1337,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1297
  if (strlen($error) > 0) {
1298
  $error = 'The function ' . $function . ' is ' . $error;
1299
 
1300
- if ($this->error === true) {
1301
  $phpcsFile->addError($error, $stackPtr);
1302
  } else {
1303
  $phpcsFile->addWarning($error, $stackPtr);
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
+
27
  /**
28
  * A list of new functions, not present in older versions.
29
  *
32
  *
33
  * @var array(string => array(string => int|string|null))
34
  */
35
+ protected $forbiddenFunctions = array(
36
  'array_fill_keys' => array(
37
  '5.1' => false,
38
  '5.2' => true
105
  '5.1' => false,
106
  '5.2' => true
107
  ),
 
 
 
 
 
 
 
 
108
  'openssl_csr_get_public_key' => array(
109
  '5.1' => false,
110
  '5.2' => true
314
  '5.2' => false,
315
  '5.3' => true
316
  ),
 
 
 
 
 
 
 
 
317
  'date_add' => array(
318
  '5.2' => false,
319
  '5.3' => true
366
  '5.2' => false,
367
  '5.3' => true
368
  ),
369
+ 'mysqli_get_cache_stats' => array(
370
+ '5.2' => false,
371
+ '5.3' => true
372
+ ),
373
  'mysqli_fetch_all' => array(
374
  '5.2' => false,
375
  '5.3' => true
422
  '5.2' => false,
423
  '5.3' => true
424
  ),
425
+ 'asinh' => array(
426
+ '5.2' => false,
427
+ '5.3' => true
428
+ ),
429
+ 'atanh' => array(
430
+ '5.2' => false,
431
+ '5.3' => true
432
+ ),
433
+ 'expm1' => array(
434
+ '5.2' => false,
435
+ '5.3' => true
436
+ ),
437
+ 'log1p' => array(
438
+ '5.2' => false,
439
+ '5.3' => true
440
+ ),
441
  'enchant_broker_describe' => array(
442
  '5.2' => false,
443
  '5.3' => true
1084
  '5.4' => false,
1085
  '5.5' => true
1086
  ),
1087
+
1088
+ 'gmp_root' => array(
1089
+ '5.5' => false,
1090
+ '5.6' => true
1091
  ),
1092
+ 'gmp_rootrem' => array(
1093
+ '5.5' => false,
1094
+ '5.6' => true
1095
+ ),
1096
+ 'hash_equals' => array(
1097
+ '5.5' => false,
1098
+ '5.6' => true
1099
+ ),
1100
+ 'ldap_escape' => array(
1101
+ '5.5' => false,
1102
+ '5.6' => true
1103
+ ),
1104
+ 'ldap_modify_batch' => array(
1105
+ '5.4.25' => false,
1106
+ '5.5.9' => false,
1107
+ '5.4.26' => true,
1108
+ '5.5.10' => true,
1109
+ '5.6.0' => true,
1110
+ ),
1111
+ 'mysqli_get_links_stats' => array(
1112
+ '5.5' => false,
1113
+ '5.6' => true
1114
+ ),
1115
+ 'openssl_get_cert_locations' => array(
1116
+ '5.5' => false,
1117
+ '5.6' => true
1118
+ ),
1119
+ 'openssl_x509_fingerprint' => array(
1120
+ '5.5' => false,
1121
+ '5.6' => true
1122
+ ),
1123
+ 'openssl_spki_new' => array(
1124
+ '5.5' => false,
1125
+ '5.6' => true
1126
+ ),
1127
+ 'openssl_spki_verify' => array(
1128
+ '5.5' => false,
1129
+ '5.6' => true
1130
+ ),
1131
+ 'openssl_spki_export_challenge' => array(
1132
+ '5.5' => false,
1133
+ '5.6' => true
1134
+ ),
1135
+ 'openssl_spki_export' => array(
1136
+ '5.5' => false,
1137
+ '5.6' => true
1138
  ),
1139
+ 'pg_connect_poll' => array(
1140
+ '5.5' => false,
1141
+ '5.6' => true
1142
+ ),
1143
+ 'pg_consume_input' => array(
1144
+ '5.5' => false,
1145
+ '5.6' => true
1146
+ ),
1147
+ 'pg_flush' => array(
1148
+ '5.5' => false,
1149
+ '5.6' => true
1150
+ ),
1151
+ 'pg_socket' => array(
1152
+ '5.5' => false,
1153
+ '5.6' => true
1154
+ ),
1155
+ 'session_abort' => array(
1156
+ '5.5' => false,
1157
+ '5.6' => true
1158
+ ),
1159
+ 'session_reset' => array(
1160
+ '5.5' => false,
1161
+ '5.6' => true
1162
+ ),
1163
+
1164
  'random_bytes' => array(
1165
  '5.6' => false,
1166
  '7.0' => true
1173
  '5.6' => false,
1174
  '7.0' => true
1175
  ),
 
 
 
 
1176
  'gmp_random_seed' => array(
1177
  '5.6' => false,
1178
  '7.0' => true
1197
  '5.6' => false,
1198
  '7.0' => true
1199
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1200
  'inflate_add' => array(
1201
  '5.6' => false,
1202
  '7.0' => true
1217
 
1218
 
1219
  /**
 
1220
  *
1221
+ * @var array
 
 
 
 
 
 
1222
  */
1223
  private $forbiddenFunctionNames;
1224
+
1225
 
1226
  /**
1227
  * Returns an array of tokens this test wants to listen for.
1233
  // Everyone has had a chance to figure out what forbidden functions
1234
  // they want to check for, so now we can cache out the list.
1235
  $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
1236
+ $this->forbiddenFunctionNames = array_map('strtolower', $this->forbiddenFunctionNames);
1237
+ $this->forbiddenFunctions = array_combine($this->forbiddenFunctionNames, $this->forbiddenFunctions);
1238
+
1239
  if ($this->patternMatch === true) {
1240
  foreach ($this->forbiddenFunctionNames as $i => $name) {
1241
  $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
1242
  }
1243
  }
1244
+
1245
  return array(T_STRING);
1246
+
1247
  }//end register()
1248
+
1249
  /**
1250
  * Processes this test, when one of its tokens is encountered.
1251
  *
1271
  // Not a call to a PHP function.
1272
  return;
1273
  }
1274
+ else if($tokens[$prevToken]['code'] === T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === T_STRING) {
1275
+ // Namespaced function.
1276
+ return;
1277
+ }
1278
 
1279
  $function = strtolower($tokens[$stackPtr]['content']);
1280
  $pattern = null;
1283
  $count = 0;
1284
  $pattern = preg_replace(
1285
  $this->forbiddenFunctionNames,
1286
+ $this->forbiddenFunctionNames,
1287
  $function,
1288
  1,
1289
  $count
1301
  }
1302
  }
1303
 
1304
+ $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content'], $pattern);
1305
 
1306
  }//end process()
1307
 
1308
 
1309
  /**
1310
+ * Generates the error or warning for this sniff.
1311
  *
1312
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
1313
  * @param int $stackPtr The position of the function
1320
  protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
1321
  {
1322
  if ($pattern === null) {
1323
+ $pattern = strtolower($function);
1324
  }
1325
 
1326
  $error = '';
1327
 
1328
+ $isError = false;
1329
  foreach ($this->forbiddenFunctions[$pattern] as $version => $present) {
1330
  if ($this->supportsBelow($version)) {
1331
  if ($present === false) {
1332
+ $isError = true;
1333
  $error .= 'not present in PHP version ' . $version . ' or earlier';
1334
  }
1335
  }
1337
  if (strlen($error) > 0) {
1338
  $error = 'The function ' . $function . ' is ' . $error;
1339
 
1340
+ if ($isError === true) {
1341
  $phpcsFile->addError($error, $stackPtr);
1342
  } else {
1343
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NewIniDirectivesSniff.php CHANGED
@@ -28,10 +28,178 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
28
  * @var array(string)
29
  */
30
  protected $newIniDirectives = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  'allow_url_include' => array(
32
  '5.1' => false,
33
  '5.2' => true
34
  ),
 
 
 
 
 
 
 
 
35
  'pcre.backtrack_limit' => array(
36
  '5.1' => false,
37
  '5.2' => true
@@ -44,21 +212,52 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
44
  '5.1' => false,
45
  '5.2' => true
46
  ),
 
 
 
 
 
 
 
47
  'max_input_nesting_level' => array(
48
  '5.1' => false,
49
  '5.2' => false,
50
- '5.2.2' => true
51
  ),
52
 
53
- 'user_ini.filename' => array(
 
 
 
 
 
 
 
 
 
 
 
 
54
  '5.2' => false,
55
  '5.3' => true,
56
  ),
57
- 'user_ini.cache_ttl' => array(
58
  '5.2' => false,
59
  '5.3' => true,
60
  ),
61
- 'exit_on_timeout' => array(
 
 
 
 
 
 
 
 
 
 
 
 
62
  '5.2' => false,
63
  '5.3' => true,
64
  ),
@@ -66,10 +265,72 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
66
  '5.2' => false,
67
  '5.3' => true,
68
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  'request_order' => array(
70
  '5.2' => false,
71
  '5.3' => true,
72
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  'cli.pager' => array(
75
  '5.3' => false,
@@ -83,19 +344,23 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
83
  '5.3' => false,
84
  '5.4' => true,
85
  ),
86
- 'max_input_vars' => array(
87
  '5.3' => false,
88
  '5.4' => true,
89
  ),
90
- 'zend.multibyte' => array(
91
  '5.3' => false,
92
  '5.4' => true,
93
  ),
94
- 'zend.script_encoding' => array(
95
  '5.3' => false,
96
  '5.4' => true,
97
  ),
98
- 'zend.signal_check' => array(
 
 
 
 
99
  '5.3' => false,
100
  '5.4' => true,
101
  ),
@@ -119,7 +384,7 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
119
  '5.3' => false,
120
  '5.4' => true,
121
  ),
122
- 'enable_post_data_reading' => array(
123
  '5.3' => false,
124
  '5.4' => true,
125
  ),
@@ -127,6 +392,27 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
127
  '5.3' => false,
128
  '5.4' => true,
129
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  'intl.use_exceptions' => array(
132
  '5.4' => false,
@@ -136,7 +422,46 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
136
  '5.4' => false,
137
  '5.5' => true,
138
  ),
 
 
 
 
 
 
 
 
 
 
 
 
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  );
141
 
142
  /**
@@ -180,25 +505,30 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
180
  if ($function != 'ini_get' && $function != 'ini_set') {
181
  return;
182
  }
183
- $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
184
 
185
- $filteredToken = str_replace(array('"', "'"), array("", ""), $tokens[$iniToken]['content']);
186
- if (in_array($filteredToken, array_keys($this->newIniDirectives)) === false) {
 
187
  return;
188
  }
189
 
190
  $error = '';
191
 
192
  foreach ($this->newIniDirectives[$filteredToken] as $version => $present) {
193
- if ($this->supportsBelow($version)) {
194
- if ($present === true) {
195
- $error .= " not available before version " . $version;
 
 
196
  }
197
  }
198
  }
199
 
200
  if (strlen($error) > 0) {
201
  $error = "INI directive '" . $filteredToken . "' is" . $error;
 
 
 
202
 
203
  $phpcsFile->addWarning($error, $stackPtr);
204
  }
@@ -206,4 +536,4 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
206
  }//end process()
207
 
208
 
209
- }//end class
28
  * @var array(string)
29
  */
30
  protected $newIniDirectives = array(
31
+ 'auto_globals_jit' => array(
32
+ '4.4' => false,
33
+ '5.0' => true,
34
+ ),
35
+ 'com.code_page' => array(
36
+ '4.4' => false,
37
+ '5.0' => true,
38
+ ),
39
+ 'date.default_latitude' => array(
40
+ '4.4' => false,
41
+ '5.0' => true,
42
+ ),
43
+ 'date.default_longitude' => array(
44
+ '4.4' => false,
45
+ '5.0' => true,
46
+ ),
47
+ 'date.sunrise_zenith' => array(
48
+ '4.4' => false,
49
+ '5.0' => true,
50
+ ),
51
+ 'date.sunset_zenith' => array(
52
+ '4.4' => false,
53
+ '5.0' => true,
54
+ ),
55
+ 'ibase.default_charset' => array(
56
+ '4.4' => false,
57
+ '5.0' => true,
58
+ ),
59
+ 'ibase.default_db' => array(
60
+ '4.4' => false,
61
+ '5.0' => true,
62
+ ),
63
+ 'mail.force_extra_parameters' => array(
64
+ '4.4' => false,
65
+ '5.0' => true,
66
+ ),
67
+ 'mime_magic.debug' => array(
68
+ '4.4' => false,
69
+ '5.0' => true,
70
+ ),
71
+ 'mysqli.max_links' => array(
72
+ '4.4' => false,
73
+ '5.0' => true,
74
+ ),
75
+ 'mysqli.default_port' => array(
76
+ '4.4' => false,
77
+ '5.0' => true,
78
+ ),
79
+ 'mysqli.default_socket' => array(
80
+ '4.4' => false,
81
+ '5.0' => true,
82
+ ),
83
+ 'mysqli.default_host' => array(
84
+ '4.4' => false,
85
+ '5.0' => true,
86
+ ),
87
+ 'mysqli.default_user' => array(
88
+ '4.4' => false,
89
+ '5.0' => true,
90
+ ),
91
+ 'mysqli.default_pw' => array(
92
+ '4.4' => false,
93
+ '5.0' => true,
94
+ ),
95
+ 'report_zend_debug' => array(
96
+ '4.4' => false,
97
+ '5.0' => true,
98
+ ),
99
+ 'session.hash_bits_per_character' => array(
100
+ '4.4' => false,
101
+ '5.0' => true,
102
+ ),
103
+ 'session.hash_function' => array(
104
+ '4.4' => false,
105
+ '5.0' => true,
106
+ ),
107
+ 'soap.wsdl_cache_dir' => array(
108
+ '4.4' => false,
109
+ '5.0' => true,
110
+ ),
111
+ 'soap.wsdl_cache_enabled' => array(
112
+ '4.4' => false,
113
+ '5.0' => true,
114
+ ),
115
+ 'soap.wsdl_cache_ttl' => array(
116
+ '4.4' => false,
117
+ '5.0' => true,
118
+ ),
119
+ 'sqlite.assoc_case' => array(
120
+ '4.4' => false,
121
+ '5.0' => true,
122
+ ),
123
+ 'tidy.clean_output' => array(
124
+ '4.4' => false,
125
+ '5.0' => true,
126
+ ),
127
+ 'tidy.default_config' => array(
128
+ '4.4' => false,
129
+ '5.0' => true,
130
+ ),
131
+ 'zend.ze1_compatibility_mode' => array(
132
+ '4.4' => false,
133
+ '5.0' => true,
134
+ ),
135
+
136
+ 'date.timezone' => array(
137
+ '5.0' => false,
138
+ '5.1' => true,
139
+ ),
140
+ 'detect_unicode' => array(
141
+ '5.0' => false,
142
+ '5.1' => true,
143
+ ),
144
+ 'fbsql.batchsize' => array(
145
+ '5.0' => false,
146
+ '5.1' => true,
147
+ 'alternative' => 'fbsql.batchSize',
148
+ ),
149
+ 'realpath_cache_size' => array(
150
+ '5.0' => false,
151
+ '5.1' => true,
152
+ ),
153
+ 'realpath_cache_ttl' => array(
154
+ '5.0' => false,
155
+ '5.1' => true,
156
+ ),
157
+
158
+ 'mbstring.strict_detection' => array(
159
+ '5.0' => false,
160
+ '5.1' => false,
161
+ '5.1.2' => true,
162
+ ),
163
+ 'mssql.charset' => array(
164
+ '5.0' => false,
165
+ '5.1' => false,
166
+ '5.1.2' => true,
167
+ ),
168
+
169
+ 'gd.jpeg_ignore_warning' => array(
170
+ '5.0' => false,
171
+ '5.1' => false,
172
+ '5.1.3' => true,
173
+ ),
174
+
175
+ 'fbsql.show_timestamp_decimals' => array(
176
+ '5.0' => false,
177
+ '5.1' => false,
178
+ '5.1.5' => true,
179
+ ),
180
+ 'soap.wsdl_cache' => array(
181
+ '5.0' => false,
182
+ '5.1' => false,
183
+ '5.1.5' => true,
184
+ ),
185
+ 'soap.wsdl_cache_limit' => array(
186
+ '5.0' => false,
187
+ '5.1' => false,
188
+ '5.1.5' => true,
189
+ ),
190
+
191
  'allow_url_include' => array(
192
  '5.1' => false,
193
  '5.2' => true
194
  ),
195
+ 'filter.default' => array(
196
+ '5.1' => false,
197
+ '5.2' => true,
198
+ ),
199
+ 'filter.default_flags' => array(
200
+ '5.1' => false,
201
+ '5.2' => true,
202
+ ),
203
  'pcre.backtrack_limit' => array(
204
  '5.1' => false,
205
  '5.2' => true
212
  '5.1' => false,
213
  '5.2' => true
214
  ),
215
+
216
+ 'cgi.check_shebang_line' => array(
217
+ '5.1' => false,
218
+ '5.2' => false,
219
+ '5.2.1' => true
220
+ ),
221
+
222
  'max_input_nesting_level' => array(
223
  '5.1' => false,
224
  '5.2' => false,
225
+ '5.2.3' => true
226
  ),
227
 
228
+ 'mysqli.allow_local_infile' => array(
229
+ '5.1' => false,
230
+ '5.2' => false,
231
+ '5.2.4' => true,
232
+ ),
233
+
234
+ 'max_file_uploads' => array(
235
+ '5.1' => false,
236
+ '5.2' => false,
237
+ '5.2.12' => true,
238
+ ),
239
+
240
+ 'cgi.discard_path' => array(
241
  '5.2' => false,
242
  '5.3' => true,
243
  ),
244
+ 'exit_on_timeout' => array(
245
  '5.2' => false,
246
  '5.3' => true,
247
  ),
248
+ 'intl.default_locale' => array(
249
+ '5.2' => false,
250
+ '5.3' => true,
251
+ ),
252
+ 'intl.error_level' => array(
253
+ '5.2' => false,
254
+ '5.3' => true,
255
+ ),
256
+ 'mail.add_x_header' => array(
257
+ '5.2' => false,
258
+ '5.3' => true,
259
+ ),
260
+ 'mail.log' => array(
261
  '5.2' => false,
262
  '5.3' => true,
263
  ),
265
  '5.2' => false,
266
  '5.3' => true,
267
  ),
268
+ 'mysqli.allow_persistent' => array(
269
+ '5.2' => false,
270
+ '5.3' => true,
271
+ ),
272
+ 'mysqli.cache_size' => array(
273
+ '5.2' => false,
274
+ '5.3' => true,
275
+ ),
276
+ 'mysqli.max_persistent' => array(
277
+ '5.2' => false,
278
+ '5.3' => true,
279
+ ),
280
+ 'mysqlnd.collect_memory_statistics' => array(
281
+ '5.2' => false,
282
+ '5.3' => true,
283
+ ),
284
+ 'mysqlnd.collect_statistics' => array(
285
+ '5.2' => false,
286
+ '5.3' => true,
287
+ ),
288
+ 'mysqlnd.debug' => array(
289
+ '5.2' => false,
290
+ '5.3' => true,
291
+ ),
292
+ 'mysqlnd.net_read_buffer_size' => array(
293
+ '5.2' => false,
294
+ '5.3' => true,
295
+ ),
296
+ 'odbc.default_cursortype' => array(
297
+ '5.2' => false,
298
+ '5.3' => true,
299
+ ),
300
  'request_order' => array(
301
  '5.2' => false,
302
  '5.3' => true,
303
  ),
304
+ 'user_ini.cache_ttl' => array(
305
+ '5.2' => false,
306
+ '5.3' => true,
307
+ ),
308
+ 'user_ini.filename' => array(
309
+ '5.2' => false,
310
+ '5.3' => true,
311
+ ),
312
+ 'zend.enable_gc' => array(
313
+ '5.2' => false,
314
+ '5.3' => true,
315
+ ),
316
+
317
+ 'curl.cainfo' => array(
318
+ '5.2' => false,
319
+ '5.3' => false,
320
+ '5.3.7' => true,
321
+ ),
322
+
323
+ 'max_input_vars' => array(
324
+ '5.2' => false,
325
+ '5.3' => false,
326
+ '5.3.9' => true,
327
+ ),
328
+
329
+ 'sqlite3.extension_dir' => array(
330
+ '5.2' => false,
331
+ '5.3' => false,
332
+ '5.3.11' => true,
333
+ ),
334
 
335
  'cli.pager' => array(
336
  '5.3' => false,
344
  '5.3' => false,
345
  '5.4' => true,
346
  ),
347
+ 'enable_post_data_reading' => array(
348
  '5.3' => false,
349
  '5.4' => true,
350
  ),
351
+ 'mysqlnd.mempool_default_size' => array(
352
  '5.3' => false,
353
  '5.4' => true,
354
  ),
355
+ 'mysqlnd.net_cmd_buffer_size' => array(
356
  '5.3' => false,
357
  '5.4' => true,
358
  ),
359
+ 'mysqlnd.net_read_timeout' => array(
360
+ '5.3' => false,
361
+ '5.4' => true,
362
+ ),
363
+ 'phar.cache_list' => array(
364
  '5.3' => false,
365
  '5.4' => true,
366
  ),
384
  '5.3' => false,
385
  '5.4' => true,
386
  ),
387
+ 'session.upload_progress.prefix' => array(
388
  '5.3' => false,
389
  '5.4' => true,
390
  ),
392
  '5.3' => false,
393
  '5.4' => true,
394
  ),
395
+ 'zend.detect_unicode' => array(
396
+ '5.3' => false,
397
+ '5.4' => true,
398
+ 'alternative' => 'detect_unicode',
399
+ ),
400
+ 'zend.multibyte' => array(
401
+ '5.3' => false,
402
+ '5.4' => true,
403
+ ),
404
+ 'zend.script_encoding' => array(
405
+ '5.3' => false,
406
+ '5.4' => true,
407
+ ),
408
+ 'zend.signal_check' => array(
409
+ '5.3' => false,
410
+ '5.4' => true,
411
+ ),
412
+ 'mysqlnd.log_mask' => array(
413
+ '5.3' => false,
414
+ '5.4' => true,
415
+ ),
416
 
417
  'intl.use_exceptions' => array(
418
  '5.4' => false,
422
  '5.4' => false,
423
  '5.5' => true,
424
  ),
425
+ 'mysqlnd.trace_alloc' => array(
426
+ '5.4' => false,
427
+ '5.5' => true,
428
+ ),
429
+ 'sys_temp_dir' => array(
430
+ '5.4' => false,
431
+ '5.5' => true,
432
+ ),
433
+ 'xsl.security_prefs' => array(
434
+ '5.4' => false,
435
+ '5.5' => true,
436
+ ),
437
 
438
+ 'session.use_strict_mode' => array(
439
+ '5.4' => false,
440
+ '5.5' => false,
441
+ '5.5.2' => true,
442
+ ),
443
+
444
+ 'mysqli.rollback_on_cached_plink' => array(
445
+ '5.5' => false,
446
+ '5.6' => true,
447
+ ),
448
+
449
+ 'assert.exception' => array(
450
+ '5.6' => false,
451
+ '7.0' => true,
452
+ ),
453
+ 'pcre.jit' => array(
454
+ '5.6' => false,
455
+ '7.0' => true,
456
+ ),
457
+ 'session.lazy_write' => array(
458
+ '5.6' => false,
459
+ '7.0' => true,
460
+ ),
461
+ 'zend.assertions' => array(
462
+ '5.6' => false,
463
+ '7.0' => true,
464
+ ),
465
  );
466
 
467
  /**
505
  if ($function != 'ini_get' && $function != 'ini_set') {
506
  return;
507
  }
 
508
 
509
+ $iniToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null);
510
+ $filteredToken = trim($tokens[$iniToken]['content'], '\'"');
511
+ if (isset($this->newIniDirectives[$filteredToken]) === false) {
512
  return;
513
  }
514
 
515
  $error = '';
516
 
517
  foreach ($this->newIniDirectives[$filteredToken] as $version => $present) {
518
+ if ($version !== 'alternative') {
519
+ if ($this->supportsBelow($version)) {
520
+ if ($present === true) {
521
+ $error .= " not available before version " . $version;
522
+ }
523
  }
524
  }
525
  }
526
 
527
  if (strlen($error) > 0) {
528
  $error = "INI directive '" . $filteredToken . "' is" . $error;
529
+ if (isset($this->newIniDirectives[$filteredToken]['alternative'])) {
530
+ $error .= ". This directive was previously called '" . $this->newIniDirectives[$filteredToken]['alternative'] . "'.";
531
+ }
532
 
533
  $phpcsFile->addWarning($error, $stackPtr);
534
  }
536
  }//end process()
537
 
538
 
539
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewInterfacesSniff.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_NewInterfacesSniff.
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category PHP
8
+ * @package PHPCompatibility
9
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
10
+ */
11
+
12
+ /**
13
+ * PHPCompatibility_Sniffs_PHP_NewInterfacesSniff.
14
+ *
15
+ * @category PHP
16
+ * @package PHPCompatibility
17
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
+ */
19
+ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sniff
20
+ {
21
+
22
+ /**
23
+ * A list of new interfaces, not present in older versions.
24
+ *
25
+ * The array lists : version number with false (not present) or true (present).
26
+ * If's sufficient to list the first version where the interface appears.
27
+ *
28
+ * @var array(string => array(string => int|string|null))
29
+ */
30
+ protected $newInterfaces = array(
31
+ 'Countable' => array(
32
+ '5.0' => false,
33
+ '5.1' => true
34
+ ),
35
+ 'OuterIterator' => array(
36
+ '5.0' => false,
37
+ '5.1' => true
38
+ ),
39
+ 'RecursiveIterator' => array(
40
+ '5.0' => false,
41
+ '5.1' => true
42
+ ),
43
+ 'SeekableIterator' => array(
44
+ '5.0' => false,
45
+ '5.1' => true
46
+ ),
47
+ 'Serializable' => array(
48
+ '5.0' => false,
49
+ '5.1' => true,
50
+ ),
51
+ 'SplObserver' => array(
52
+ '5.0' => false,
53
+ '5.1' => true
54
+ ),
55
+ 'SplSubject' => array(
56
+ '5.0' => false,
57
+ '5.1' => true
58
+ ),
59
+
60
+ 'JsonSerializable' => array(
61
+ '5.3' => false,
62
+ '5.4' => true
63
+ ),
64
+ 'SessionHandlerInterface' => array(
65
+ '5.3' => false,
66
+ '5.4' => true
67
+ ),
68
+
69
+ );
70
+
71
+ /**
72
+ * A list of methods which cannot be used in combination with particular interfaces.
73
+ *
74
+ * @var array(string => array(string => string))
75
+ */
76
+ protected $unsupportedMethods = array(
77
+ 'Serializable' => array(
78
+ '__sleep' => 'http://php.net/serializable',
79
+ '__wakeup' => 'http://php.net/serializable',
80
+ ),
81
+ );
82
+
83
+ /**
84
+ * Returns an array of tokens this test wants to listen for.
85
+ *
86
+ * @return array
87
+ */
88
+ public function register()
89
+ {
90
+ // Handle case-insensitivity of class names.
91
+ $keys = array_keys( $this->newInterfaces );
92
+ $keys = array_map( 'strtolower', $keys );
93
+ $this->newInterfaces = array_combine( $keys, $this->newInterfaces );
94
+
95
+ $keys = array_keys( $this->unsupportedMethods );
96
+ $keys = array_map( 'strtolower', $keys );
97
+ $this->unsupportedMethods = array_combine( $keys, $this->unsupportedMethods );
98
+
99
+ return array(T_CLASS);
100
+
101
+ }//end register()
102
+
103
+
104
+ /**
105
+ * Processes this test, when one of its tokens is encountered.
106
+ *
107
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
108
+ * @param int $stackPtr The position of the current token in
109
+ * the stack passed in $tokens.
110
+ *
111
+ * @return void
112
+ */
113
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
114
+ {
115
+ $interfaces = $this->findImplementedInterfaceNames($phpcsFile, $stackPtr);
116
+
117
+ if (is_array($interfaces) === false || $interfaces === array()) {
118
+ return;
119
+ }
120
+
121
+ $tokens = $phpcsFile->getTokens();
122
+ $checkMethods = false;
123
+
124
+ if(isset($tokens[$stackPtr]['scope_closer'])) {
125
+ $checkMethods = true;
126
+ $scopeCloser = $tokens[$stackPtr]['scope_closer'];
127
+ }
128
+
129
+ foreach ($interfaces as $interface) {
130
+ $lcInterface = strtolower($interface);
131
+ if (isset($this->newInterfaces[$lcInterface]) === true) {
132
+ $this->addError($phpcsFile, $stackPtr, $interface);
133
+ }
134
+
135
+ if ($checkMethods === true && isset($this->unsupportedMethods[$lcInterface]) === true) {
136
+ $nextFunc = $stackPtr;
137
+ while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
138
+ $funcNamePos = $phpcsFile->findNext(T_STRING, $nextFunc);
139
+ $funcName = strtolower($tokens[$funcNamePos]['content']);
140
+
141
+ if (isset($this->unsupportedMethods[$lcInterface][$funcName]) === true) {
142
+ $error = 'Classes that implement interface %s do not support the method %s(). See %s';
143
+ $data = array(
144
+ $interface,
145
+ $tokens[$funcNamePos]['content'],
146
+ $this->unsupportedMethods[$lcInterface][$funcName],
147
+ );
148
+ $phpcsFile->addError($error, $funcNamePos, 'UnsupportedMethod', $data);
149
+ }
150
+ }
151
+ }
152
+ }
153
+
154
+ }//end process()
155
+
156
+
157
+ /**
158
+ * Generates the error or warning for this sniff.
159
+ *
160
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
161
+ * @param int $stackPtr The position of the function
162
+ * in the token array.
163
+ * @param string $interface The name of the interface.
164
+ * @param string $pattern The pattern used for the match.
165
+ *
166
+ * @return void
167
+ */
168
+ protected function addError($phpcsFile, $stackPtr, $interface, $pattern=null)
169
+ {
170
+ if ($pattern === null) {
171
+ $pattern = strtolower($interface);
172
+ }
173
+
174
+ $error = '';
175
+
176
+ $isError = false;
177
+ foreach ($this->newInterfaces[$pattern] as $version => $present) {
178
+ if ($this->supportsBelow($version)) {
179
+ if ($present === false) {
180
+ $isError = true;
181
+ $error .= 'not present in PHP version ' . $version . ' or earlier';
182
+ }
183
+ }
184
+ }
185
+
186
+ if (strlen($error) > 0) {
187
+ $error = 'The built-in interface ' . $interface . ' is ' . $error;
188
+
189
+ if ($isError === true) {
190
+ $phpcsFile->addError($error, $stackPtr);
191
+ } else {
192
+ $phpcsFile->addWarning($error, $stackPtr);
193
+ }
194
+ }
195
+
196
+ }//end addError()
197
+
198
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewKeywordsSniff.php CHANGED
@@ -28,6 +28,9 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
28
  * The array lists : version number with false (not present) or true (present).
29
  * If's sufficient to list the first version where the keyword appears.
30
  *
 
 
 
31
  * @var array(string => array(string => int|string|null))
32
  */
33
  protected $newKeywords = array(
@@ -39,7 +42,8 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
39
  'T_CONST' => array(
40
  '5.2' => false,
41
  '5.3' => true,
42
- 'description' => '"const" keyword'
 
43
  ),
44
  'T_CALLABLE' => array(
45
  '5.3' => false,
@@ -109,14 +113,6 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
109
  );
110
 
111
 
112
- /**
113
- * If true, an error will be thrown; otherwise a warning.
114
- *
115
- * @var bool
116
- */
117
- protected $error = false;
118
-
119
-
120
  /**
121
  * Returns an array of tokens this test wants to listen for.
122
  *
@@ -162,19 +158,34 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
162
  &&
163
  $tokens[$prevToken]['type'] != 'T_CLASS'
164
  ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['type']);
166
  }
167
  }//end process()
168
 
169
 
170
  /**
171
- * Generates the error or wanrning for this sniff.
172
  *
173
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
174
- * @param int $stackPtr The position of the function
175
- * in the token array.
176
- * @param string $function The name of the function.
177
- * @param string $pattern The pattern used for the match.
178
  *
179
  * @return void
180
  */
@@ -186,11 +197,15 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
186
 
187
  $error = '';
188
 
189
- $this->error = false;
190
  foreach ($this->newKeywords[$pattern] as $version => $present) {
 
 
 
 
191
  if ($this->supportsBelow($version)) {
192
  if ($present === false) {
193
- $this->error = true;
194
  $error .= 'not present in PHP version ' . $version . ' or earlier';
195
  }
196
  }
@@ -198,7 +213,7 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
198
  if (strlen($error) > 0) {
199
  $error = $this->newKeywords[$keywordName]['description'] . ' is ' . $error;
200
 
201
- if ($this->error === true) {
202
  $phpcsFile->addError($error, $stackPtr);
203
  } else {
204
  $phpcsFile->addWarning($error, $stackPtr);
28
  * The array lists : version number with false (not present) or true (present).
29
  * If's sufficient to list the first version where the keyword appears.
30
  *
31
+ * If you add a condition, make sure to add the appropriate logic for it as well as
32
+ * this will not resolve itself automatically.
33
+ *
34
  * @var array(string => array(string => int|string|null))
35
  */
36
  protected $newKeywords = array(
42
  'T_CONST' => array(
43
  '5.2' => false,
44
  '5.3' => true,
45
+ 'description' => '"const" keyword',
46
+ 'condition' => 'T_CLASS', // Keyword is only new when not in class context.
47
  ),
48
  'T_CALLABLE' => array(
49
  '5.3' => false,
113
  );
114
 
115
 
 
 
 
 
 
 
 
 
116
  /**
117
  * Returns an array of tokens this test wants to listen for.
118
  *
158
  &&
159
  $tokens[$prevToken]['type'] != 'T_CLASS'
160
  ) {
161
+ // Skip based on special conditions.
162
+ if (
163
+ isset($this->newKeywords[$tokens[$stackPtr]['type']]['condition'])
164
+ &&
165
+ (empty($tokens[$stackPtr]['conditions']) === false
166
+ &&
167
+ is_array($tokens[$stackPtr]['conditions']))
168
+ ) {
169
+ foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condType) {
170
+ if ($condType === constant($this->newKeywords[$tokens[$stackPtr]['type']]['condition'])) {
171
+ return;
172
+ }
173
+ }
174
+ }
175
+
176
  $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['type']);
177
  }
178
  }//end process()
179
 
180
 
181
  /**
182
+ * Generates the error or warning for this sniff.
183
  *
184
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
185
+ * @param int $stackPtr The position of the function
186
+ * in the token array.
187
+ * @param string $keywordName The name of the keyword.
188
+ * @param string $pattern The pattern used for the match.
189
  *
190
  * @return void
191
  */
197
 
198
  $error = '';
199
 
200
+ $isError = false;
201
  foreach ($this->newKeywords[$pattern] as $version => $present) {
202
+ if (in_array($version, array('condition', 'description'), true)) {
203
+ continue;
204
+ }
205
+
206
  if ($this->supportsBelow($version)) {
207
  if ($present === false) {
208
+ $isError = true;
209
  $error .= 'not present in PHP version ' . $version . ' or earlier';
210
  }
211
  }
213
  if (strlen($error) > 0) {
214
  $error = $this->newKeywords[$keywordName]['description'] . ' is ' . $error;
215
 
216
+ if ($isError === true) {
217
  $phpcsFile->addError($error, $stackPtr);
218
  } else {
219
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NewLanguageConstructsSniff.php CHANGED
@@ -40,32 +40,74 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
40
  '5.5' => false,
41
  '5.6' => true,
42
  'description' => 'power operator (**)'
43
- ),
44
  'T_POW_EQUAL' => array(
45
  '5.5' => false,
46
  '5.6' => true,
47
  'description' => 'power assignment operator (**=)'
 
 
 
 
 
48
  ),
49
  'T_SPACESHIP' => array(
50
  '5.6' => false,
51
  '7.0' => true,
52
  'description' => 'spaceship operator (<=>)'
53
- ),
54
  'T_COALESCE' => array(
55
  '5.6' => false,
56
  '7.0' => true,
57
  'description' => 'null coalescing operator (??)'
58
- ),
59
  );
60
 
61
 
62
  /**
63
- * If true, an error will be thrown; otherwise a warning.
 
 
64
  *
65
- * @var bool
66
  */
67
- protected $error = false;
 
 
 
 
 
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  /**
71
  * Returns an array of tokens this test wants to listen for.
@@ -79,9 +121,11 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
79
  if (defined($token)) {
80
  $tokens[] = constant($token);
81
  }
 
 
 
82
  }
83
  return $tokens;
84
-
85
  }//end register()
86
 
87
 
@@ -96,34 +140,49 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
96
  */
97
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
98
  {
99
- $tokens = $phpcsFile->getTokens();
100
- $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['type']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }//end process()
102
 
103
 
104
  /**
105
  * Generates the error or warning for this sniff.
106
  *
107
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
108
- * @param int $stackPtr The position of the function
109
- * in the token array.
110
- * @param string $function The name of the function.
111
  *
112
  * @return void
113
  */
114
- protected function addError($phpcsFile, $stackPtr, $keywordName, $pattern=null)
115
  {
116
- if ($pattern === null) {
117
- $pattern = $keywordName;
118
- }
119
-
120
  $error = '';
121
 
122
- $this->error = false;
123
- foreach ($this->newConstructs[$pattern] as $version => $present) {
124
  if ($this->supportsBelow($version)) {
125
  if ($present === false) {
126
- $this->error = true;
127
  $error .= 'not present in PHP version ' . $version . ' or earlier';
128
  }
129
  }
@@ -131,7 +190,7 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
131
  if (strlen($error) > 0) {
132
  $error = $this->newConstructs[$keywordName]['description'] . ' is ' . $error;
133
 
134
- if ($this->error === true) {
135
  $phpcsFile->addError($error, $stackPtr);
136
  } else {
137
  $phpcsFile->addWarning($error, $stackPtr);
40
  '5.5' => false,
41
  '5.6' => true,
42
  'description' => 'power operator (**)'
43
+ ), // identified in PHPCS 1.5 as T_MULTIPLY + T_MULTIPLY
44
  'T_POW_EQUAL' => array(
45
  '5.5' => false,
46
  '5.6' => true,
47
  'description' => 'power assignment operator (**=)'
48
+ ), // identified in PHPCS 1.5 as T_MULTIPLY + T_MUL_EQUAL
49
+ 'T_ELLIPSIS' => array(
50
+ '5.5' => false,
51
+ '5.6' => true,
52
+ 'description' => 'variadic functions using ...'
53
  ),
54
  'T_SPACESHIP' => array(
55
  '5.6' => false,
56
  '7.0' => true,
57
  'description' => 'spaceship operator (<=>)'
58
+ ), // identified in PHPCS 1.5 as T_IS_SMALLER_OR_EQUAL + T_GREATER_THAN
59
  'T_COALESCE' => array(
60
  '5.6' => false,
61
  '7.0' => true,
62
  'description' => 'null coalescing operator (??)'
63
+ ), // identified in PHPCS 1.5 as T_INLINE_THEN + T_INLINE_THEN
64
  );
65
 
66
 
67
  /**
68
+ * A list of new language constructs which are not recognized in PHPCS 1.x.
69
+ *
70
+ * The array lists an alternative token to listen for.
71
  *
72
+ * @var array(string => int)
73
  */
74
+ protected $newConstructsPHPCSCompat = array(
75
+ 'T_POW' => T_MULTIPLY,
76
+ 'T_POW_EQUAL' => T_MUL_EQUAL,
77
+ 'T_SPACESHIP' => T_GREATER_THAN,
78
+ 'T_COALESCE' => T_INLINE_THEN,
79
+ );
80
 
81
+ /**
82
+ * Translation table for PHPCS 1.x tokens.
83
+ *
84
+ * The 'before' index lists the token which would have to be directly before the
85
+ * token found for it to be one of the new language constructs.
86
+ * The 'real_token' index indicates which language construct was found in that case.
87
+ *
88
+ * {@internal 'before' was choosen rather than 'after' as that allowed for a 1-on-1
89
+ * translation list with the current tokens.}}
90
+ *
91
+ * @var array(string => array(string => string))
92
+ */
93
+ protected $PHPCSCompatTranslate = array(
94
+ 'T_MULTIPLY' => array(
95
+ 'before' => 'T_MULTIPLY',
96
+ 'real_token' => 'T_POW',
97
+ ),
98
+ 'T_MUL_EQUAL' => array(
99
+ 'before' => 'T_MULTIPLY',
100
+ 'real_token' => 'T_POW_EQUAL',
101
+ ),
102
+ 'T_GREATER_THAN' => array(
103
+ 'before' => 'T_IS_SMALLER_OR_EQUAL',
104
+ 'real_token' => 'T_SPACESHIP',
105
+ ),
106
+ 'T_INLINE_THEN' => array(
107
+ 'before' => 'T_INLINE_THEN',
108
+ 'real_token' => 'T_COALESCE',
109
+ ),
110
+ );
111
 
112
  /**
113
  * Returns an array of tokens this test wants to listen for.
121
  if (defined($token)) {
122
  $tokens[] = constant($token);
123
  }
124
+ else if(isset($this->newConstructsPHPCSCompat[$token])) {
125
+ $tokens[] = $this->newConstructsPHPCSCompat[$token];
126
+ }
127
  }
128
  return $tokens;
 
129
  }//end register()
130
 
131
 
140
  */
141
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
142
  {
143
+ $tokens = $phpcsFile->getTokens();
144
+ $tokenType = $tokens[$stackPtr]['type'];
145
+
146
+ // Translate pre-PHPCS 2.0 tokens for new constructs to the actual construct.
147
+ if (isset($this->newConstructs[$tokenType]) === false) {
148
+ if (
149
+ isset($this->PHPCSCompatTranslate[$tokenType])
150
+ &&
151
+ $tokens[$stackPtr - 1]['type'] === $this->PHPCSCompatTranslate[$tokenType]['before']
152
+ ) {
153
+ $tokenType = $this->PHPCSCompatTranslate[$tokenType]['real_token'];
154
+ }
155
+ }
156
+
157
+ // If the translation did not yield one of the tokens we are looking for, bow out.
158
+ if (isset($this->newConstructs[$tokenType]) === false) {
159
+ return;
160
+ }
161
+
162
+ $this->addError($phpcsFile, $stackPtr, $tokenType);
163
+
164
  }//end process()
165
 
166
 
167
  /**
168
  * Generates the error or warning for this sniff.
169
  *
170
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
171
+ * @param int $stackPtr The position of the function
172
+ * in the token array.
173
+ * @param string $keywordName The name of the keyword.
174
  *
175
  * @return void
176
  */
177
+ protected function addError($phpcsFile, $stackPtr, $keywordName)
178
  {
 
 
 
 
179
  $error = '';
180
 
181
+ $isError = false;
182
+ foreach ($this->newConstructs[$keywordName] as $version => $present) {
183
  if ($this->supportsBelow($version)) {
184
  if ($present === false) {
185
+ $isError = true;
186
  $error .= 'not present in PHP version ' . $version . ' or earlier';
187
  }
188
  }
190
  if (strlen($error) > 0) {
191
  $error = $this->newConstructs[$keywordName]['description'] . ' is ' . $error;
192
 
193
+ if ($isError === true) {
194
  $phpcsFile->addError($error, $stackPtr);
195
  } else {
196
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NewMagicMethodsSniff.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff.
12
+ *
13
+ * Warns for non-magic behaviour of magic methods prior to becoming magic.
14
+ *
15
+ * @category PHP
16
+ * @package PHPCompatibility
17
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
+ */
19
+ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_Sniff
20
+ {
21
+
22
+ /**
23
+ * A list of new magic methods, not considered magic in older versions.
24
+ *
25
+ * Method names in the array should be all *lowercase*.
26
+ * The array lists : version number with false (not magic) or true (magic).
27
+ * If's sufficient to list the first version where the method became magic.
28
+ *
29
+ * @var array(string => array(string => int|string|null))
30
+ */
31
+ protected $newMagicMethods = array(
32
+ '__get' => array( // verified
33
+ '4.4' => false,
34
+ '5.0' => true,
35
+ ),
36
+
37
+ '__isset' => array( // verified
38
+ '5.0' => false,
39
+ '5.1' => true,
40
+ ),
41
+ '__unset' => array( // verified
42
+ '5.0' => false,
43
+ '5.1' => true,
44
+ ),
45
+ '__set_state' => array( // verified
46
+ '5.0' => false,
47
+ '5.1' => true,
48
+ ),
49
+
50
+ '__callstatic' => array( // verified
51
+ '5.2' => false,
52
+ '5.3' => true,
53
+ ),
54
+ '__invoke' => array( // verified
55
+ '5.2' => false,
56
+ '5.3' => true,
57
+ ),
58
+
59
+ '__debuginfo' => array( // verified
60
+ '5.5' => false,
61
+ '5.6' => true,
62
+ ),
63
+
64
+ // Special case - only became properly magical in 5.2.0,
65
+ // before that it was only called for echo and print.
66
+ '__tostring' => array(
67
+ '5.1' => false,
68
+ '5.2' => true,
69
+ '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.',
70
+ ),
71
+ );
72
+
73
+
74
+ /**
75
+ * Returns an array of tokens this test wants to listen for.
76
+ *
77
+ * @return array
78
+ */
79
+ public function register()
80
+ {
81
+ return array(T_FUNCTION);
82
+
83
+ }//end register()
84
+
85
+
86
+ /**
87
+ * Processes this test, when one of its tokens is encountered.
88
+ *
89
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
90
+ * @param int $stackPtr The position of the current token in the
91
+ * stack passed in $tokens.
92
+ *
93
+ * @return void
94
+ */
95
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
96
+ {
97
+ $functionName = $phpcsFile->getDeclarationName($stackPtr);
98
+ $functionNameLc = strtolower($functionName);
99
+
100
+ if (isset($this->newMagicMethods[$functionNameLc]) === false) {
101
+ return;
102
+ }
103
+
104
+ if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
105
+ return;
106
+ }
107
+
108
+ $lastVersionBelow = '';
109
+ foreach ($this->newMagicMethods[$functionNameLc] as $version => $magic) {
110
+ if ($version !== 'message' && $magic === false && $this->supportsBelow($version)) {
111
+ $lastVersionBelow = $version;
112
+ }
113
+ }
114
+
115
+ if ($lastVersionBelow !== '') {
116
+ $error = 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
117
+ if (empty($this->newMagicMethods[$functionNameLc]['message']) === false) {
118
+ $error = $this->newMagicMethods[$functionNameLc]['message'];
119
+ }
120
+
121
+ $data = array(
122
+ $functionName,
123
+ $lastVersionBelow,
124
+ );
125
+
126
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
127
+ }
128
+
129
+ }//end process()
130
+
131
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php CHANGED
@@ -49,14 +49,6 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
49
  );
50
 
51
 
52
- /**
53
- * If true, an error will be thrown; otherwise a warning.
54
- *
55
- * @var bool
56
- */
57
- protected $error = false;
58
-
59
-
60
  /**
61
  * Returns an array of tokens this test wants to listen for.
62
  *
@@ -91,7 +83,7 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
91
 
92
 
93
  /**
94
- * Generates the error or wanrning for this sniff.
95
  *
96
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
97
  * @param int $stackPtr The position of the function
@@ -109,11 +101,11 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
109
 
110
  $error = '';
111
 
112
- $this->error = false;
113
  foreach ($this->newTypes[$pattern] as $version => $present) {
114
  if ($this->supportsBelow($version)) {
115
  if ($present === false) {
116
- $this->error = true;
117
  $error .= 'not present in PHP version ' . $version . ' or earlier';
118
  }
119
  }
@@ -121,7 +113,7 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
121
  if (strlen($error) > 0) {
122
  $error = $this->newTypes[$typeName]['description'] . ' is ' . $error;
123
 
124
- if ($this->error === true) {
125
  $phpcsFile->addError($error, $stackPtr);
126
  } else {
127
  $phpcsFile->addWarning($error, $stackPtr);
49
  );
50
 
51
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Returns an array of tokens this test wants to listen for.
54
  *
83
 
84
 
85
  /**
86
+ * Generates the error or warning for this sniff.
87
  *
88
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
89
  * @param int $stackPtr The position of the function
101
 
102
  $error = '';
103
 
104
+ $isError = false;
105
  foreach ($this->newTypes[$pattern] as $version => $present) {
106
  if ($this->supportsBelow($version)) {
107
  if ($present === false) {
108
+ $isError = true;
109
  $error .= 'not present in PHP version ' . $version . ' or earlier';
110
  }
111
  }
113
  if (strlen($error) > 0) {
114
  $error = $this->newTypes[$typeName]['description'] . ' is ' . $error;
115
 
116
+ if ($isError === true) {
117
  $phpcsFile->addError($error, $stackPtr);
118
  } else {
119
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php CHANGED
@@ -26,35 +26,46 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
26
  * @var array(string => array(string => int|string|null))
27
  */
28
  protected $newTypes = array (
29
- 'int' => array(
30
- '5.6' => false,
31
- '7.0' => true,
32
- 'description' => 'int type'
33
- ),
34
- 'float' => array(
35
- '5.6' => false,
36
- '7.0' => true,
37
- 'description' => 'float type'
38
- ),
39
- 'bool' => array(
40
- '5.6' => false,
41
- '7.0' => true,
42
- 'description' => 'bool type'
43
- ),
44
- 'string' => array(
45
- '5.6' => false,
46
- '7.0' => true,
47
- 'description' => 'string type'
48
- ),
49
- );
 
 
 
 
50
 
51
 
52
  /**
53
- * If true, an error will be thrown; otherwise a warning.
54
  *
55
- * @var bool
 
 
56
  */
57
- protected $error = false;
 
 
 
 
 
58
 
59
 
60
  /**
@@ -79,23 +90,42 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
79
  */
80
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
81
  {
82
- $tokens = $phpcsFile->getTokens();
83
-
84
- // Get function name.
85
- $methodName = $phpcsFile->getDeclarationName($stackPtr);
86
-
87
  // Get all parameters from method signature.
88
- $paramNames = array();
89
- foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
90
- if (in_array($param['type_hint'], array_keys($this->newTypes))) {
 
 
 
 
 
 
 
 
 
 
91
  $this->addError($phpcsFile, $stackPtr, $param['type_hint']);
92
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
  }//end process()
95
 
96
 
97
  /**
98
- * Generates the error or wanrning for this sniff.
99
  *
100
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
101
  * @param int $stackPtr The position of the function
@@ -113,19 +143,19 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
113
 
114
  $error = '';
115
 
116
- $this->error = false;
117
  foreach ($this->newTypes[$pattern] as $version => $present) {
118
  if ($this->supportsBelow($version)) {
119
  if ($present === false) {
120
- $this->error = true;
121
  $error .= 'not present in PHP version ' . $version . ' or earlier';
122
  }
123
  }
124
  }
125
  if (strlen($error) > 0) {
126
- $error = $this->newTypes[$typeName]['description'] . ' is ' . $error;
127
 
128
- if ($this->error === true) {
129
  $phpcsFile->addError($error, $stackPtr);
130
  } else {
131
  $phpcsFile->addWarning($error, $stackPtr);
26
  * @var array(string => array(string => int|string|null))
27
  */
28
  protected $newTypes = array (
29
+ 'array' => array(
30
+ '5.0' => false,
31
+ '5.1' => true,
32
+ ),
33
+ 'callable' => array(
34
+ '5.3' => false,
35
+ '5.4' => true,
36
+ ),
37
+ 'int' => array(
38
+ '5.6' => false,
39
+ '7.0' => true,
40
+ ),
41
+ 'float' => array(
42
+ '5.6' => false,
43
+ '7.0' => true,
44
+ ),
45
+ 'bool' => array(
46
+ '5.6' => false,
47
+ '7.0' => true,
48
+ ),
49
+ 'string' => array(
50
+ '5.6' => false,
51
+ '7.0' => true,
52
+ ),
53
+ );
54
 
55
 
56
  /**
57
+ * Invalid types
58
  *
59
+ * The array lists : the invalid type hint => what was probably intended/alternative.
60
+ *
61
+ * @var array(string => string)
62
  */
63
+ protected $invalidTypes = array (
64
+ 'parent' => 'self',
65
+ 'static' => 'self',
66
+ 'boolean' => 'bool',
67
+ 'integer' => 'int',
68
+ );
69
 
70
 
71
  /**
90
  */
91
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
92
  {
 
 
 
 
 
93
  // Get all parameters from method signature.
94
+ $paramNames = $this->getMethodParameters($phpcsFile, $stackPtr);
95
+ $supportsPHP4 = $this->supportsBelow('4.4');
96
+
97
+ foreach ($paramNames as $param) {
98
+ if ($param['type_hint'] === '') {
99
+ continue;
100
+ }
101
+
102
+ if ($supportsPHP4 === true) {
103
+ $error = 'Type hints were not present in PHP 4.4 or earlier.';
104
+ $phpcsFile->addError($error, $stackPtr, 'TypeHintFound');
105
+ }
106
+ else if (isset($this->newTypes[$param['type_hint']])) {
107
  $this->addError($phpcsFile, $stackPtr, $param['type_hint']);
108
  }
109
+ else if (isset($this->invalidTypes[$param['type_hint']])) {
110
+ $error = "'%s' is not a valid type declaration. Did you mean %s ?";
111
+ $data = array(
112
+ $param['type_hint'],
113
+ $this->invalidTypes[$param['type_hint']],
114
+ );
115
+ $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHintFound', $data);
116
+ }
117
+ else if ($param['type_hint'] === 'self') {
118
+ if ($this->inClassScope($phpcsFile, $stackPtr) === false) {
119
+ $error = "'self' type cannot be used outside of class scope";
120
+ $phpcsFile->addError($error, $stackPtr, 'SelfOutsideClassScopeFound');
121
+ }
122
+ }
123
  }
124
  }//end process()
125
 
126
 
127
  /**
128
+ * Generates the error or warning for this sniff.
129
  *
130
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
131
  * @param int $stackPtr The position of the function
143
 
144
  $error = '';
145
 
146
+ $isError = false;
147
  foreach ($this->newTypes[$pattern] as $version => $present) {
148
  if ($this->supportsBelow($version)) {
149
  if ($present === false) {
150
+ $isError = true;
151
  $error .= 'not present in PHP version ' . $version . ' or earlier';
152
  }
153
  }
154
  }
155
  if (strlen($error) > 0) {
156
+ $error = "'{$typeName}' type declaration is " . $error;
157
 
158
+ if ($isError === true) {
159
  $phpcsFile->addError($error, $stackPtr);
160
  } else {
161
  $phpcsFile->addWarning($error, $stackPtr);
vendor/wimg/php-compatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php CHANGED
@@ -13,7 +13,7 @@
13
  /**
14
  * PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff.
15
  *
16
- * Prohibits the use of static magic methods as well as protected or private magic methods
17
  *
18
  * @category PHP
19
  * @package PHPCompatibility
@@ -24,18 +24,53 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
24
  {
25
 
26
  /**
27
- * A list of magic methods that must be public and not be static
 
 
 
 
 
 
28
  *
29
  * @var array(string)
30
  */
31
  protected $magicMethods = array(
32
- '__get',
33
- '__set',
34
- '__isset',
35
- '__unset',
36
- '__call'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  );
38
 
 
39
  /**
40
  * Returns an array of tokens this test wants to listen for.
41
  *
@@ -43,7 +78,7 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
43
  */
44
  public function register()
45
  {
46
- return array(T_CLASS, T_INTERFACE);
47
 
48
  }//end register()
49
 
@@ -59,96 +94,69 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
59
  */
60
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
  {
62
- if ($this->supportsAbove('5.3')) {
63
- $tokens = $phpcsFile->getTokens();
64
-
65
- // Find all the functions in this class or interface
66
-
67
- // Use the scope closer to limit the sniffing within the scope of
68
- // this class or interface
69
- $classScopeCloser = (isset($tokens[$stackPtr]['scope_closer']))
70
- ? $tokens[$stackPtr]['scope_closer']
71
- : $stackPtr + 1;
72
-
73
- $functionPtr = $stackPtr;
74
-
75
- while ($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) {
76
-
77
- // Get the scope closer for this function in order to know how
78
- // to advance to the next function.
79
- // If no body of function (e.g. for interfaces), there is
80
- // no closing curly brace; advance the pointer differently
81
- $scopeCloser = isset($tokens[$functionToken]['scope_closer'])
82
- ? $tokens[$functionToken]['scope_closer']
83
- : $functionToken + 1;
84
 
85
- $scopeToken = false;
86
- $staticToken = false;
87
 
88
- $nameToken = $phpcsFile->findNext(T_WHITESPACE, $functionToken + 1, $classScopeCloser, true);
89
- if (in_array($tokens[$nameToken]['content'], $this->magicMethods) === false) {
90
- $functionPtr = $scopeCloser;
91
- continue;
92
- }
93
 
94
- // What is the token before the function token?
95
- $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, $functionToken - 1, null, true);
96
- if (in_array($tokens[$prevToken]['code'], array(T_PUBLIC, T_PROTECTED, T_PRIVATE))) {
97
- $scopeToken = $prevToken;
98
- } elseif ($tokens[$prevToken]['code'] == T_STATIC) {
99
- $staticToken = $prevToken;
100
- } else {
101
- // no scope or static modifiers, this function is okay
102
- $functionPtr = $scopeCloser;
103
- continue;
104
- }
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- // What is the token before that one?
107
- $prevPrevToken = $phpcsFile->findPrevious(T_WHITESPACE, $prevToken - 1, null, true);
108
- if (in_array($tokens[$prevPrevToken]['code'], array(T_PUBLIC, T_PROTECTED, T_PRIVATE))) {
109
- $scopeToken = $prevPrevToken;
110
- } elseif ($tokens[$prevPrevToken]['code'] == T_STATIC) {
111
- $staticToken = $prevPrevToken;
112
- }
113
 
114
- $isPublic = ($scopeToken !== false && $tokens[$scopeToken]['type'] != 'T_PUBLIC') ? false : true;
115
- $isStatic = ($staticToken === false) ? false : true;
 
 
 
 
 
116
 
117
- if ($isPublic && !$isStatic) {
118
- $functionPtr = $scopeCloser;
119
- continue;
120
- }
121
 
122
- // Summarize what the problems are
123
- if (!$isPublic && $isStatic) {
124
- $error = sprintf(
125
- "Magic methods must be public and cannot be static (since PHP 5.3)! Found static %s function %s",
126
- $tokens[$scopeToken]['content'],
127
- $tokens[$nameToken]['content']
128
- );
129
- $phpcsFile->addError($error, $functionToken);
130
- } else {
131
- if (!$isPublic) {
132
- $error = sprintf(
133
- "Magic methods must be public (since PHP 5.3)! Found %s function %s",
134
- $tokens[$scopeToken]['content'],
135
- $tokens[$nameToken]['content']
136
- );
137
- $phpcsFile->addError($error, $functionToken);
138
- }
139
-
140
- if ($isStatic) {
141
- $error = sprintf(
142
- "Magic methods cannot be static (since PHP 5.3)! Found static function %s",
143
- $tokens[$nameToken]['content']
144
- );
145
- $phpcsFile->addError($error, $functionToken);
146
- }
147
  }
 
 
 
148
 
149
- // Advance to next function
150
- $functionPtr = $scopeCloser;
151
  }
 
 
 
152
  }
153
 
154
  }//end process()
13
  /**
14
  * PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff.
15
  *
16
+ * Verifies the use of the correct visibility and static properties of magic methods.
17
  *
18
  * @category PHP
19
  * @package PHPCompatibility
24
  {
25
 
26
  /**
27
+ * A list of PHP magic methods and their visibility and static requirements.
28
+ *
29
+ * Method names in the array should be all *lowercase*.
30
+ * Visibility can be either 'public', 'protected' or 'private'.
31
+ * Static can be either 'true' - *must* be static, or 'false' - *must* be non-static.
32
+ * When a method does not have a specific requirement for either visibility or static,
33
+ * do *not* add the key.
34
  *
35
  * @var array(string)
36
  */
37
  protected $magicMethods = array(
38
+ '__get' => array(
39
+ 'visibility' => 'public',
40
+ 'static' => false,
41
+ ),
42
+ '__set' => array(
43
+ 'visibility' => 'public',
44
+ 'static' => false,
45
+ ),
46
+ '__isset' => array(
47
+ 'visibility' => 'public',
48
+ 'static' => false,
49
+ ),
50
+ '__unset' => array(
51
+ 'visibility' => 'public',
52
+ 'static' => false,
53
+ ),
54
+ '__call' => array(
55
+ 'visibility' => 'public',
56
+ 'static' => false,
57
+ ),
58
+ '__callstatic' => array(
59
+ 'visibility' => 'public',
60
+ 'static' => true,
61
+ ),
62
+ '__sleep' => array(
63
+ 'visibility' => 'public',
64
+ ),
65
+ '__tostring' => array(
66
+ 'visibility' => 'public',
67
+ ),
68
+ '__set_state' => array(
69
+ 'static' => true,
70
+ ),
71
  );
72
 
73
+
74
  /**
75
  * Returns an array of tokens this test wants to listen for.
76
  *
78
  */
79
  public function register()
80
  {
81
+ return array(T_CLASS, T_INTERFACE, T_TRAIT);
82
 
83
  }//end register()
84
 
94
  */
95
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
96
  {
97
+ // Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
98
+ if ($this->supportsAbove('5.3') === false) {
99
+ return;
100
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ $tokens = $phpcsFile->getTokens();
 
103
 
104
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
105
+ return;
106
+ }
 
 
107
 
108
+ $classScopeCloser = $tokens[$stackPtr]['scope_closer'];
109
+ $functionPtr = $stackPtr;
110
+
111
+ // Find all the functions in this class or interface.
112
+ while ($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) {
113
+ /*
114
+ * Get the scope closer for this function in order to know how
115
+ * to advance to the next function.
116
+ * If no body of function (e.g. for interfaces), there is
117
+ * no closing curly brace; advance the pointer differently.
118
+ */
119
+ $scopeCloser = isset($tokens[$functionToken]['scope_closer'])
120
+ ? $tokens[$functionToken]['scope_closer']
121
+ : $functionToken + 1;
122
+
123
+
124
+ $methodName = $phpcsFile->getDeclarationName($functionToken);
125
+ $methodNameLc = strtolower($methodName);
126
+ if (isset($this->magicMethods[$methodNameLc]) === false) {
127
+ $functionPtr = $scopeCloser;
128
+ continue;
129
+ }
130
 
131
+ $methodProperties = $phpcsFile->getMethodProperties($functionToken);
 
 
 
 
 
 
132
 
133
+ if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
134
+ $error = 'Visibility for magic method %s must be %s. Found: %s';
135
+ $data = array(
136
+ $methodName,
137
+ $this->magicMethods[$methodNameLc]['visibility'],
138
+ $methodProperties['scope'],
139
+ );
140
 
141
+ $phpcsFile->addError($error, $functionToken, 'MethodVisibility', $data);
142
+ }
 
 
143
 
144
+ if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
145
+ $error = 'Magic method %s cannot be defined as static.';
146
+ $errorCode = 'MethodStatic';
147
+ if ( $this->magicMethods[$methodNameLc]['static'] === true ) {
148
+ $error = 'Magic method %s must be defined as static.';
149
+ $errorCode = 'MethodNonStatic';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  }
151
+ $data = array(
152
+ $methodName,
153
+ );
154
 
155
+ $phpcsFile->addError($error, $functionToken, $errorCode, $data);
 
156
  }
157
+
158
+ // Advance to next function.
159
+ $functionPtr = $scopeCloser;
160
  }
161
 
162
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php CHANGED
@@ -3,7 +3,7 @@
3
  * PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff
4
  *
5
  * Discourages use of superglobals as parameters for functions.
6
- *
7
  * PHP version 5.4
8
  *
9
  * @category PHP
@@ -11,9 +11,12 @@
11
  * @author Declan Kelly <declankelly90@gmail.com>
12
  * @copyright 2015 Declan Kelly
13
  */
14
- class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff implements PHP_CodeSniffer_Sniff {
 
15
  /**
16
  * List of superglobals as an array of strings.
 
 
17
  */
18
  protected $superglobals = array(
19
  '$GLOBALS',
@@ -28,44 +31,44 @@ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff implements PH
28
  );
29
 
30
  /**
31
- * Returns array of tokens, in this case array containing
32
- * T_FUNCTION
33
  *
34
  * @return array
35
  */
36
  public function register() {
 
 
 
37
  return array(T_FUNCTION);
38
  }
39
 
40
  /**
41
  * Processes the test.
42
- *
43
  * @param PHP_CodeSniffer_file $phpcsFile The file being scanned.
44
  * @param int $stackPtr The position of the current token
45
  *
46
  * @return void
47
  */
48
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
49
- if (
50
- is_null(PHP_CodeSniffer::getConfigData('testVersion'))
51
- ||
52
- (
53
- !is_null(PHP_CodeSniffer::getConfigData('testVersion'))
54
- &&
55
- version_compare(PHP_CodeSniffer::getConfigData('testVersion'), '5.4') >= 0
56
- )
57
- ) {
58
- $tokens = $phpcsFile->getTokens();
59
- $openBracket = $tokens[$stackPtr]['parenthesis_opener'];
60
- $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
61
 
62
- for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
63
- $variable = $tokens[$i]['content'];
64
- if (in_array($variable, $this->superglobals)) {
65
- $phpcsFile->addError("Parameter shadowing super global ($variable) causes fatal error since PHP 5.4", $i);
66
- }
67
  }
68
-
69
  }
70
  }
71
- }
3
  * PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff
4
  *
5
  * Discourages use of superglobals as parameters for functions.
6
+ *
7
  * PHP version 5.4
8
  *
9
  * @category PHP
11
  * @author Declan Kelly <declankelly90@gmail.com>
12
  * @copyright 2015 Declan Kelly
13
  */
14
+ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff extends PHPCompatibility_Sniff
15
+ {
16
  /**
17
  * List of superglobals as an array of strings.
18
+ *
19
+ * @var array
20
  */
21
  protected $superglobals = array(
22
  '$GLOBALS',
31
  );
32
 
33
  /**
34
+ * Register the tokens to listen for.
 
35
  *
36
  * @return array
37
  */
38
  public function register() {
39
+ // Prepare for case-insensitive compare.
40
+ $this->superglobals = array_map('strtolower', $this->superglobals);
41
+
42
  return array(T_FUNCTION);
43
  }
44
 
45
  /**
46
  * Processes the test.
47
+ *
48
  * @param PHP_CodeSniffer_file $phpcsFile The file being scanned.
49
  * @param int $stackPtr The position of the current token
50
  *
51
  * @return void
52
  */
53
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
54
+ if ($this->supportsAbove('5.4') === false) {
55
+ return;
56
+ }
57
+
58
+ // Get all parameters from function signature.
59
+ $parameters = $phpcsFile->getMethodParameters($stackPtr);
60
+ if (empty($parameters) || is_array($parameters) === false) {
61
+ return;
62
+ }
63
+
64
+ foreach ($parameters as $param) {
65
+ $paramNameLc = strtolower($param['name']);
66
 
67
+ if (in_array($paramNameLc, $this->superglobals, true)) {
68
+ $error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
69
+ $data = array($param['name']);
70
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
71
  }
 
72
  }
73
  }
74
+ }
vendor/wimg/php-compatibility/Sniffs/PHP/PregReplaceEModifierSniff.php CHANGED
@@ -23,11 +23,14 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
23
  {
24
 
25
  /**
26
- * If true, an error will be thrown; otherwise a warning.
27
  *
28
- * @var bool
29
  */
30
- public $error = false;
 
 
 
31
 
32
  /**
33
  * Returns an array of tokens this test wants to listen for.
@@ -53,7 +56,10 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
53
  if ($this->supportsAbove('5.5')) {
54
  $tokens = $phpcsFile->getTokens();
55
 
56
- if ($tokens[$stackPtr]['content'] == "preg_replace") {
 
 
 
57
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
58
 
59
  if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
@@ -82,6 +88,9 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
82
 
83
  $doublesSeparators = array(
84
  '{' => '}',
 
 
 
85
  );
86
 
87
  $regex = substr($regex, 1, -1);
23
  {
24
 
25
  /**
26
+ * Functions to check for.
27
  *
28
+ * @var array
29
  */
30
+ protected $functions = array(
31
+ 'preg_replace' => true,
32
+ 'preg_filter' => true,
33
+ );
34
 
35
  /**
36
  * Returns an array of tokens this test wants to listen for.
56
  if ($this->supportsAbove('5.5')) {
57
  $tokens = $phpcsFile->getTokens();
58
 
59
+ if ( isset($this->functions[$tokens[$stackPtr]['content']]) === false ) {
60
+ return;
61
+ } else {
62
+
63
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
64
 
65
  if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
88
 
89
  $doublesSeparators = array(
90
  '{' => '}',
91
+ '[' => ']',
92
+ '(' => ')',
93
+ '<' => '>',
94
  );
95
 
96
  $regex = substr($regex, 1, -1);
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedExtensionsSniff.php CHANGED
@@ -22,6 +22,22 @@
22
  */
23
  class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_Sniff
24
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  /**
27
  * A list of removed extensions with their alternative, if any
@@ -32,20 +48,24 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
32
  protected $removedExtensions = array(
33
  'activescript' => array(
34
  '5.0' => 1,
35
- '5.1' => 1,
36
- '5.2' => 1,
37
  '5.3' => 0,
38
  '5.4' => 0,
39
  '5.5' => 0,
 
 
40
  'alternative' => 'pecl/activescript'
41
  ),
42
  'cpdf' => array(
43
  '5.0' => 1,
44
- '5.1' => 1,
45
- '5.2' => 1,
46
  '5.3' => 0,
47
  '5.4' => 0,
48
  '5.5' => 0,
 
 
49
  'alternative' => 'pecl/pdflib'
50
  ),
51
  'dbase' => array(
@@ -55,6 +75,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
55
  '5.3' => 0,
56
  '5.4' => 0,
57
  '5.5' => 0,
 
 
58
  'alternative' => null
59
  ),
60
  'dbx' => array(
@@ -64,6 +86,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
64
  '5.3' => 0,
65
  '5.4' => 0,
66
  '5.5' => 0,
 
 
67
  'alternative' => 'pecl/dbx'
68
  ),
69
  'dio' => array(
@@ -73,11 +97,20 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
73
  '5.3' => 0,
74
  '5.4' => 0,
75
  '5.5' => 0,
 
 
76
  'alternative' => 'pecl/dio'
77
  ),
78
  'ereg' => array(
 
 
 
 
 
 
 
79
  '7.0' => 0,
80
- 'alternative' => null
81
  ),
82
  'fam' => array(
83
  '5.0' => 1,
@@ -86,6 +119,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
86
  '5.3' => 0,
87
  '5.4' => 0,
88
  '5.5' => 0,
 
 
89
  'alternative' => null
90
  ),
91
  'fbsql' => array(
@@ -95,6 +130,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
95
  '5.3' => 0,
96
  '5.4' => 0,
97
  '5.5' => 0,
 
 
98
  'alternative' => null
99
  ),
100
  'fdf' => array(
@@ -104,6 +141,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
104
  '5.3' => 0,
105
  '5.4' => 0,
106
  '5.5' => 0,
 
 
107
  'alternative' => 'pecl/fdf'
108
  ),
109
  'filepro' => array(
@@ -113,6 +152,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
113
  '5.3' => 0,
114
  '5.4' => 0,
115
  '5.5' => 0,
 
 
116
  'alternative' => null
117
  ),
118
  'hw_api' => array(
@@ -122,6 +163,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
122
  '5.3' => 0,
123
  '5.4' => 0,
124
  '5.5' => 0,
 
 
125
  'alternative' => null
126
  ),
127
  'ingres' => array(
@@ -131,15 +174,19 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
131
  '5.3' => 0,
132
  '5.4' => 0,
133
  '5.5' => 0,
 
 
134
  'alternative' => 'pecl/ingres'
135
  ),
136
  'ircg' => array(
137
  '5.0' => 1,
138
- '5.1' => 1,
139
- '5.2' => 1,
140
  '5.3' => 0,
141
  '5.4' => 0,
142
  '5.5' => 0,
 
 
143
  'alternative' => null
144
  ),
145
  'mcve' => array(
@@ -149,6 +196,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
149
  '5.3' => 0,
150
  '5.4' => 0,
151
  '5.5' => 0,
 
 
152
  'alternative' => 'pecl/mvce'
153
  ),
154
  'ming' => array(
@@ -158,6 +207,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
158
  '5.3' => 0,
159
  '5.4' => 0,
160
  '5.5' => 0,
 
 
161
  'alternative' => 'pecl/ming'
162
  ),
163
  'mnogosearch' => array(
@@ -167,6 +218,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
167
  '5.3' => 0,
168
  '5.4' => 0,
169
  '5.5' => 0,
 
 
170
  'alternative' => null
171
  ),
172
  'msql' => array(
@@ -176,6 +229,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
176
  '5.3' => 0,
177
  '5.4' => 0,
178
  '5.5' => 0,
 
 
179
  'alternative' => null
180
  ),
181
  'mssql' => array(
@@ -200,15 +255,19 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
200
  '5.3' => 0,
201
  '5.4' => 0,
202
  '5.5' => 0,
 
 
203
  'alternative' => 'pecl/ncurses'
204
  ),
205
  'oracle' => array(
206
  '5.0' => 1,
207
- '5.1' => 1,
208
- '5.2' => 1,
209
  '5.3' => 0,
210
  '5.4' => 0,
211
  '5.5' => 0,
 
 
212
  'alternative' => 'oci8 or pdo_oci'
213
  ),
214
  'ovrimos' => array(
@@ -218,6 +277,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
218
  '5.3' => 0,
219
  '5.4' => 0,
220
  '5.5' => 0,
 
 
221
  'alternative' => null
222
  ),
223
  'pfpro' => array(
@@ -227,6 +288,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
227
  '5.3' => 0,
228
  '5.4' => 0,
229
  '5.5' => 0,
 
 
230
  'alternative' => null
231
  ),
232
  'sqlite' => array(
@@ -236,6 +299,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
236
  '5.3' => 1,
237
  '5.4' => 0,
238
  '5.5' => 0,
 
 
239
  'alternative' => null
240
  ),
241
  'sybase' => array(
@@ -245,6 +310,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
245
  '5.3' => 0,
246
  '5.4' => 0,
247
  '5.5' => 0,
 
 
248
  'alternative' => 'sybase_ct'
249
  ),
250
  'sybase_ct' => array(
@@ -258,15 +325,19 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
258
  '5.3' => 0,
259
  '5.4' => 0,
260
  '5.5' => 0,
 
 
261
  'alternative' => 'pecl/ffi'
262
  ),
263
  'yp' => array(
264
  '5.0' => 1,
265
- '5.1' => 1,
266
- '5.2' => 1,
267
  '5.3' => 0,
268
  '5.4' => 0,
269
  '5.5' => 0,
 
 
270
  'alternative' => null
271
  ),
272
  );
@@ -327,17 +398,26 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
327
  return;
328
  }
329
 
 
 
 
 
 
330
  foreach ($this->removedExtensions as $extension => $versionList) {
331
  if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
332
  $error = '';
333
  $isErrored = false;
 
334
  foreach ($versionList as $version => $status) {
335
  if ($version != 'alternative') {
336
  if ($status == -1 || $status == 0) {
337
  if ($this->supportsAbove($version)) {
338
  switch ($status) {
339
  case -1:
340
- $error .= 'deprecated since PHP ' . $version . ' and ';
 
 
 
341
  break;
342
  case 0:
343
  $isErrored = true;
@@ -365,4 +445,35 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
365
 
366
  }//end process()
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  }//end class
22
  */
23
  class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_Sniff
24
  {
25
+ /**
26
+ * A list of functions to whitelist, if any.
27
+ *
28
+ * This is intended for projects using functions which start with the same
29
+ * prefix as one of the removed extensions.
30
+ *
31
+ * This property can be set from the ruleset, like so:
32
+ * <rule ref="PHPCompatibility.PHP.RemovedExtensions">
33
+ * <properties>
34
+ * <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
35
+ * </properties>
36
+ * </rule>
37
+ *
38
+ * @var array
39
+ */
40
+ public $functionWhitelist;
41
 
42
  /**
43
  * A list of removed extensions with their alternative, if any
48
  protected $removedExtensions = array(
49
  'activescript' => array(
50
  '5.0' => 1,
51
+ '5.1' => 0,
52
+ '5.2' => 0,
53
  '5.3' => 0,
54
  '5.4' => 0,
55
  '5.5' => 0,
56
+ '5.6' => 0,
57
+ '7.0' => 0,
58
  'alternative' => 'pecl/activescript'
59
  ),
60
  'cpdf' => array(
61
  '5.0' => 1,
62
+ '5.1' => 0,
63
+ '5.2' => 0,
64
  '5.3' => 0,
65
  '5.4' => 0,
66
  '5.5' => 0,
67
+ '5.6' => 0,
68
+ '7.0' => 0,
69
  'alternative' => 'pecl/pdflib'
70
  ),
71
  'dbase' => array(
75
  '5.3' => 0,
76
  '5.4' => 0,
77
  '5.5' => 0,
78
+ '5.6' => 0,
79
+ '7.0' => 0,
80
  'alternative' => null
81
  ),
82
  'dbx' => array(
86
  '5.3' => 0,
87
  '5.4' => 0,
88
  '5.5' => 0,
89
+ '5.6' => 0,
90
+ '7.0' => 0,
91
  'alternative' => 'pecl/dbx'
92
  ),
93
  'dio' => array(
97
  '5.3' => 0,
98
  '5.4' => 0,
99
  '5.5' => 0,
100
+ '5.6' => 0,
101
+ '7.0' => 0,
102
  'alternative' => 'pecl/dio'
103
  ),
104
  'ereg' => array(
105
+ '5.0' => 1,
106
+ '5.1' => 1,
107
+ '5.2' => 1,
108
+ '5.3' => -1,
109
+ '5.4' => -1,
110
+ '5.5' => -1,
111
+ '5.6' => -1,
112
  '7.0' => 0,
113
+ 'alternative' => 'pcre'
114
  ),
115
  'fam' => array(
116
  '5.0' => 1,
119
  '5.3' => 0,
120
  '5.4' => 0,
121
  '5.5' => 0,
122
+ '5.6' => 0,
123
+ '7.0' => 0,
124
  'alternative' => null
125
  ),
126
  'fbsql' => array(
130
  '5.3' => 0,
131
  '5.4' => 0,
132
  '5.5' => 0,
133
+ '5.6' => 0,
134
+ '7.0' => 0,
135
  'alternative' => null
136
  ),
137
  'fdf' => array(
141
  '5.3' => 0,
142
  '5.4' => 0,
143
  '5.5' => 0,
144
+ '5.6' => 0,
145
+ '7.0' => 0,
146
  'alternative' => 'pecl/fdf'
147
  ),
148
  'filepro' => array(
152
  '5.3' => 0,
153
  '5.4' => 0,
154
  '5.5' => 0,
155
+ '5.6' => 0,
156
+ '7.0' => 0,
157
  'alternative' => null
158
  ),
159
  'hw_api' => array(
163
  '5.3' => 0,
164
  '5.4' => 0,
165
  '5.5' => 0,
166
+ '5.6' => 0,
167
+ '7.0' => 0,
168
  'alternative' => null
169
  ),
170
  'ingres' => array(
174
  '5.3' => 0,
175
  '5.4' => 0,
176
  '5.5' => 0,
177
+ '5.6' => 0,
178
+ '7.0' => 0,
179
  'alternative' => 'pecl/ingres'
180
  ),
181
  'ircg' => array(
182
  '5.0' => 1,
183
+ '5.1' => 0,
184
+ '5.2' => 0,
185
  '5.3' => 0,
186
  '5.4' => 0,
187
  '5.5' => 0,
188
+ '5.6' => 0,
189
+ '7.0' => 0,
190
  'alternative' => null
191
  ),
192
  'mcve' => array(
196
  '5.3' => 0,
197
  '5.4' => 0,
198
  '5.5' => 0,
199
+ '5.6' => 0,
200
+ '7.0' => 0,
201
  'alternative' => 'pecl/mvce'
202
  ),
203
  'ming' => array(
207
  '5.3' => 0,
208
  '5.4' => 0,
209
  '5.5' => 0,
210
+ '5.6' => 0,
211
+ '7.0' => 0,
212
  'alternative' => 'pecl/ming'
213
  ),
214
  'mnogosearch' => array(
218
  '5.3' => 0,
219
  '5.4' => 0,
220
  '5.5' => 0,
221
+ '5.6' => 0,
222
+ '7.0' => 0,
223
  'alternative' => null
224
  ),
225
  'msql' => array(
229
  '5.3' => 0,
230
  '5.4' => 0,
231
  '5.5' => 0,
232
+ '5.6' => 0,
233
+ '7.0' => 0,
234
  'alternative' => null
235
  ),
236
  'mssql' => array(
255
  '5.3' => 0,
256
  '5.4' => 0,
257
  '5.5' => 0,
258
+ '5.6' => 0,
259
+ '7.0' => 0,
260
  'alternative' => 'pecl/ncurses'
261
  ),
262
  'oracle' => array(
263
  '5.0' => 1,
264
+ '5.1' => 0,
265
+ '5.2' => 0,
266
  '5.3' => 0,
267
  '5.4' => 0,
268
  '5.5' => 0,
269
+ '5.6' => 0,
270
+ '7.0' => 0,
271
  'alternative' => 'oci8 or pdo_oci'
272
  ),
273
  'ovrimos' => array(
277
  '5.3' => 0,
278
  '5.4' => 0,
279
  '5.5' => 0,
280
+ '5.6' => 0,
281
+ '7.0' => 0,
282
  'alternative' => null
283
  ),
284
  'pfpro' => array(
288
  '5.3' => 0,
289
  '5.4' => 0,
290
  '5.5' => 0,
291
+ '5.6' => 0,
292
+ '7.0' => 0,
293
  'alternative' => null
294
  ),
295
  'sqlite' => array(
299
  '5.3' => 1,
300
  '5.4' => 0,
301
  '5.5' => 0,
302
+ '5.6' => 0,
303
+ '7.0' => 0,
304
  'alternative' => null
305
  ),
306
  'sybase' => array(
310
  '5.3' => 0,
311
  '5.4' => 0,
312
  '5.5' => 0,
313
+ '5.6' => 0,
314
+ '7.0' => 0,
315
  'alternative' => 'sybase_ct'
316
  ),
317
  'sybase_ct' => array(
325
  '5.3' => 0,
326
  '5.4' => 0,
327
  '5.5' => 0,
328
+ '5.6' => 0,
329
+ '7.0' => 0,
330
  'alternative' => 'pecl/ffi'
331
  ),
332
  'yp' => array(
333
  '5.0' => 1,
334
+ '5.1' => 0,
335
+ '5.2' => 0,
336
  '5.3' => 0,
337
  '5.4' => 0,
338
  '5.5' => 0,
339
+ '5.6' => 0,
340
+ '7.0' => 0,
341
  'alternative' => null
342
  ),
343
  );
398
  return;
399
  }
400
 
401
+ if($this->isWhiteListed(strtolower($tokens[$stackPtr]['content'])) === true){
402
+ // Function is whitelisted.
403
+ return;
404
+ }
405
+
406
  foreach ($this->removedExtensions as $extension => $versionList) {
407
  if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
408
  $error = '';
409
  $isErrored = false;
410
+ $isDeprecated = false;
411
  foreach ($versionList as $version => $status) {
412
  if ($version != 'alternative') {
413
  if ($status == -1 || $status == 0) {
414
  if ($this->supportsAbove($version)) {
415
  switch ($status) {
416
  case -1:
417
+ if($isDeprecated === false ) {
418
+ $error .= 'deprecated since PHP ' . $version . ' and ';
419
+ $isDeprecated = true;
420
+ }
421
  break;
422
  case 0:
423
  $isErrored = true;
445
 
446
  }//end process()
447
 
448
+ /**
449
+ * Is the current function being checked whitelisted ?
450
+ *
451
+ * Parsing the list late as it may be provided as a property, but also inline.
452
+ *
453
+ * @param string $content Content of the current token.
454
+ *
455
+ * @return bool
456
+ */
457
+ protected function isWhiteListed($content) {
458
+ if (isset($this->functionWhitelist) === false) {
459
+ return false;
460
+ }
461
+
462
+ if (is_string($this->functionWhitelist) === true) {
463
+ if (strpos($this->functionWhitelist, ',') !== false) {
464
+ $this->functionWhitelist = explode(',', $this->functionWhitelist);
465
+ } else {
466
+ $this->functionWhitelist = (array) $this->functionWhitelist;
467
+ }
468
+ }
469
+
470
+ if (is_array($this->functionWhitelist) === true) {
471
+ $this->functionWhitelist = array_map('strtolower',$this->functionWhitelist);
472
+ return in_array($content, $this->functionWhitelist, true);
473
+ }
474
+
475
+ return false;
476
+
477
+ }//end isWhiteListed()
478
+
479
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php CHANGED
@@ -23,42 +23,48 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
-
27
  /**
28
- * A list of Removed function parameters, not present in older versions.
29
  *
30
- * The array lists : version number with false (not present) or true (present).
31
  * The index is the location of the parameter in the parameter list, starting at 0 !
32
- * If's sufficient to list the first version where the function appears.
33
  *
34
  * @var array
35
  */
36
- public $removedFunctionParameters = array(
37
- 'mktime' => array(
38
  6 => array(
39
  'name' => 'is_dst',
40
- '5.1' => true,
41
- '7.0' => false
42
  ),
43
  ),
44
- 'gmmktime' => array(
 
 
 
 
 
 
 
 
 
 
 
 
45
  6 => array(
46
  'name' => 'is_dst',
47
- '7.0' => false
 
48
  ),
49
  ),
50
  );
51
 
52
 
53
  /**
54
- * If true, an error will be thrown; otherwise a warning.
55
  *
56
- * @var bool
57
- */
58
- public $error = false;
59
-
60
- /**
61
- *
62
  * @var array
63
  */
64
  private $removedFunctionParametersNames;
@@ -74,16 +80,16 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
74
  // Everyone has had a chance to figure out what forbidden functions
75
  // they want to check for, so now we can cache out the list.
76
  $this->removedFunctionParametersNames = array_keys($this->removedFunctionParameters);
77
-
78
  if ($this->patternMatch === true) {
79
  foreach ($this->removedFunctionParametersNames as $i => $name) {
80
  $this->removedFunctionParametersNames[$i] = '/'.$name.'/i';
81
  }
82
  }
83
-
84
  return array(T_STRING);
85
  }//end register()
86
-
87
  /**
88
  * Processes this test, when one of its tokens is encountered.
89
  *
@@ -115,53 +121,33 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
115
  if (in_array($function, $this->removedFunctionParametersNames) === false) {
116
  return;
117
  }
118
-
119
- if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
120
- $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
121
- $openParenthesis = $tokens[$closeParenthesis]['parenthesis_opener'];
122
-
123
- $nextItem = $phpcsFile->findNext(array(), $openParenthesis + 1, $closeParenthesis, true);
124
- if (isset($tokens[$nextItem]['nested_parenthesis'])) {
125
- $parenthesisCount = count($tokens[$nextItem]['nested_parenthesis']);
126
- } else {
127
- $parenthesisCount = 0;
128
- }
129
 
130
- $nextComma = $stackPtr + 1;
131
- $cnt = 0;
132
- while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
133
- if (
134
- $tokens[$nextComma]['type'] == 'T_COMMA'
135
- &&
136
- isset($tokens[$nextComma]['nested_parenthesis'])
137
- &&
138
- count($tokens[$nextComma]['nested_parenthesis']) != $parenthesisCount
139
- ) {
140
- continue;
141
- }
142
-
143
- if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
144
- continue;
145
- }
146
-
147
- if (isset($this->removedFunctionParameters[$function][$cnt])) {
148
- $this->addError($phpcsFile, $nextComma, $function, $cnt);
149
- }
150
- $cnt++;
151
  }
152
-
153
  }
 
154
  }//end process()
155
 
156
 
157
  /**
158
- * Generates the error or wanrning for this sniff.
159
  *
160
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
161
- * @param int $stackPtr The position of the function
162
- * in the token array.
163
- * @param string $function The name of the function.
164
- * @param string $pattern The pattern used for the match.
165
  *
166
  * @return void
167
  */
@@ -169,23 +155,37 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
169
  {
170
  $error = '';
171
 
172
- $this->error = false;
 
173
  foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
174
  if ($version != 'name' && $this->supportsAbove($version)) {
175
- if ($present === false) {
176
- $this->error = true;
177
- $error .= 'in PHP version ' . $version . ' or later';
 
 
 
 
 
 
 
178
  }
179
  }
180
  }
181
-
182
- if (strlen($error) > 0) {
183
- $error = 'The function ' . $function . ' does not have a parameter ' . $this->removedFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;
184
 
185
- if ($this->error === true) {
186
- $phpcsFile->addError($error, $stackPtr);
 
 
 
 
 
 
 
 
 
187
  } else {
188
- $phpcsFile->addWarning($error, $stackPtr);
189
  }
190
  }
191
 
23
  * @var bool
24
  */
25
  protected $patternMatch = false;
26
+
27
  /**
28
+ * A list of removed function parameters, which were present in older versions.
29
  *
30
+ * The array lists : version number with true (deprecated and false (removed).
31
  * The index is the location of the parameter in the parameter list, starting at 0 !
32
+ * If's sufficient to list the first version where the function was deprecated/removed.
33
  *
34
  * @var array
35
  */
36
+ protected $removedFunctionParameters = array(
37
+ 'gmmktime' => array(
38
  6 => array(
39
  'name' => 'is_dst',
40
+ '5.1' => true, // deprecated
41
+ '7.0' => false,
42
  ),
43
  ),
44
+ 'ldap_first_attribute' => array(
45
+ 2 => array(
46
+ 'name' => 'ber_identifier',
47
+ '5.2.4' => false,
48
+ ),
49
+ ),
50
+ 'ldap_next_attribute' => array(
51
+ 2 => array(
52
+ 'name' => 'ber_identifier',
53
+ '5.2.4' => false,
54
+ ),
55
+ ),
56
+ 'mktime' => array(
57
  6 => array(
58
  'name' => 'is_dst',
59
+ '5.1' => true, // deprecated
60
+ '7.0' => false,
61
  ),
62
  ),
63
  );
64
 
65
 
66
  /**
 
67
  *
 
 
 
 
 
 
68
  * @var array
69
  */
70
  private $removedFunctionParametersNames;
80
  // Everyone has had a chance to figure out what forbidden functions
81
  // they want to check for, so now we can cache out the list.
82
  $this->removedFunctionParametersNames = array_keys($this->removedFunctionParameters);
83
+
84
  if ($this->patternMatch === true) {
85
  foreach ($this->removedFunctionParametersNames as $i => $name) {
86
  $this->removedFunctionParametersNames[$i] = '/'.$name.'/i';
87
  }
88
  }
89
+
90
  return array(T_STRING);
91
  }//end register()
92
+
93
  /**
94
  * Processes this test, when one of its tokens is encountered.
95
  *
121
  if (in_array($function, $this->removedFunctionParametersNames) === false) {
122
  return;
123
  }
 
 
 
 
 
 
 
 
 
 
 
124
 
125
+ $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
126
+ if ($parameterCount === 0) {
127
+ return;
128
+ }
129
+
130
+ // If the parameter count returned > 0, we know there will be valid open parenthesis.
131
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
132
+ $parameterOffsetFound = $parameterCount - 1;
133
+
134
+ foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) {
135
+ if ($offset <= $parameterOffsetFound) {
136
+ $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
 
 
 
 
 
 
 
 
137
  }
 
138
  }
139
+
140
  }//end process()
141
 
142
 
143
  /**
144
+ * Generates the error or warning for this sniff.
145
  *
146
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
147
+ * @param int $stackPtr The position of the function
148
+ * in the token array.
149
+ * @param string $function The name of the function.
150
+ * @param int $parameterLocation The parameter position within the function call.
151
  *
152
  * @return void
153
  */
155
  {
156
  $error = '';
157
 
158
+ $isError = false;
159
+ $previousStatus = null;
160
  foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
161
  if ($version != 'name' && $this->supportsAbove($version)) {
162
+
163
+ if ($previousStatus !== $present) {
164
+ $previousStatus = $present;
165
+ if ($present === false) {
166
+ $isError = true;
167
+ $error .= 'removed';
168
+ } else {
169
+ $error .= 'deprecated';
170
+ }
171
+ $error .= ' in PHP version ' . $version . ' and ';
172
  }
173
  }
174
  }
 
 
 
175
 
176
+ if (strlen($error) > 0) {
177
+ $error = 'The "%s" parameter for function %s was ' . $error;
178
+ $error = substr($error, 0, strlen($error) - 5);
179
+ $errorCode = 'RemovedParameter';
180
+ $data = array(
181
+ $this->removedFunctionParameters[$function][$parameterLocation]['name'],
182
+ $function,
183
+ );
184
+
185
+ if ($isError === true) {
186
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
187
  } else {
188
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
189
  }
190
  }
191
 
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php CHANGED
@@ -56,43 +56,48 @@ class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompati
56
  */
57
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58
  {
59
- $tokens = $phpcsFile->getTokens();
60
-
61
- foreach ($this->removedGlobalVariables as $variable => $versionList) {
62
- if (strtolower($tokens[$stackPtr]['content']) == '$' . strtolower($variable)) {
63
- $error = '';
64
- $isErrored = false;
65
- foreach ($versionList as $version => $status) {
66
- if ($version != 'alternative') {
67
- if ($status == -1 || $status == 0) {
68
- if ($this->supportsAbove($version)) {
69
- switch ($status) {
70
- case -1:
71
- $error .= 'deprecated since PHP ' . $version . ' and ';
72
- break;
73
- case 0:
74
- $isErrored = true;
75
- $error .= 'removed since PHP ' . $version . ' and ';
76
- break 2;
77
- }
78
- }
79
- }
80
- }
81
- }
82
- if (strlen($error) > 0) {
83
- $error = "Global variable '" . $variable . "' is " . $error;
84
- $error = substr($error, 0, strlen($error) - 5);
85
- if (!is_null($versionList['alternative'])) {
86
- $error .= ' - use ' . $versionList['alternative'] . ' instead.';
87
- }
88
- if ($isErrored === true) {
89
- $phpcsFile->addError($error, $stackPtr);
90
- } else {
91
- $phpcsFile->addWarning($error, $stackPtr);
92
  }
93
  }
94
  }
95
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  }//end process()
98
 
56
  */
57
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58
  {
59
+ $tokens = $phpcsFile->getTokens();
60
+ $varNameUc = strtoupper(substr($tokens[$stackPtr]['content'], 1));
61
+
62
+ if (isset($this->removedGlobalVariables[$varNameUc]) === false) {
63
+ return;
64
+ }
65
+
66
+ $versionList = $this->removedGlobalVariables[$varNameUc];
67
+
68
+ $error = '';
69
+ $isError = false;
70
+ foreach ($versionList as $version => $status) {
71
+ if ($version !== 'alternative' && ($status === -1 || $status === 0)) {
72
+ if ($this->supportsAbove($version)) {
73
+ switch ($status) {
74
+ case -1:
75
+ $error .= 'deprecated since PHP ' . $version . ' and ';
76
+ break;
77
+ case 0:
78
+ $isError = true;
79
+ $error .= 'removed since PHP ' . $version . ' and ';
80
+ break 2;
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
  }
83
  }
84
  }
85
+ if (strlen($error) > 0) {
86
+ $error = "Global variable '%s' is " . $error;
87
+ $error = substr($error, 0, strlen($error) - 5);
88
+ $data = array(
89
+ $tokens[$stackPtr]['content']
90
+ );
91
+ if (isset($versionList['alternative'])) {
92
+ $error .= ' - use %s instead.';
93
+ $data[] = $versionList['alternative'];
94
+ }
95
+ if ($isError === true) {
96
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
97
+ } else {
98
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
99
+ }
100
+ }
101
 
102
  }//end process()
103
 
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php CHANGED
@@ -25,13 +25,6 @@
25
  class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
- /**
29
- * If true, an error will be thrown; otherwise a warning.
30
- *
31
- * @var bool
32
- */
33
- protected $error = true;
34
-
35
  /**
36
  * List of functions using the algorithm as parameter (always the first parameter)
37
  *
25
  class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_Sniff
26
  {
27
 
 
 
 
 
 
 
 
28
  /**
29
  * List of functions using the algorithm as parameter (always the first parameter)
30
  *
vendor/wimg/php-compatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Wim Godden <wim.godden@cu.be>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Wim Godden <wim.godden@cu.be>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extends PHPCompatibility_Sniff
18
+ {
19
+
20
+ /**
21
+ * A list of function parameters, which were required in older versions and became optional later on.
22
+ *
23
+ * The array lists : version number with true (required) and false (optional).
24
+ *
25
+ * The index is the location of the parameter in the parameter list, starting at 0 !
26
+ * If's sufficient to list the last version in which the parameter was still required.
27
+ *
28
+ * @var array
29
+ */
30
+ protected $functionParameters = array(
31
+ 'preg_match_all' => array(
32
+ 2 => array(
33
+ 'name' => 'matches',
34
+ '5.3' => true,
35
+ '5.4' => false,
36
+ ),
37
+ ),
38
+ 'stream_socket_enable_crypto' => array(
39
+ 2 => array(
40
+ 'name' => 'crypto_type',
41
+ '5.5' => true,
42
+ '5.6' => false,
43
+ ),
44
+ ),
45
+ );
46
+
47
+
48
+ /**
49
+ * Returns an array of tokens this test wants to listen for.
50
+ *
51
+ * @return array
52
+ */
53
+ public function register()
54
+ {
55
+ return array(T_STRING);
56
+ }//end register()
57
+
58
+ /**
59
+ * Processes this test, when one of its tokens is encountered.
60
+ *
61
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
62
+ * @param int $stackPtr The position of the current token in
63
+ * the stack passed in $tokens.
64
+ *
65
+ * @return void
66
+ */
67
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
+ {
69
+ $tokens = $phpcsFile->getTokens();
70
+
71
+ $ignore = array(
72
+ T_DOUBLE_COLON,
73
+ T_OBJECT_OPERATOR,
74
+ T_FUNCTION,
75
+ T_CONST,
76
+ );
77
+
78
+ $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
79
+ if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
80
+ // Not a call to a PHP function.
81
+ return;
82
+ }
83
+
84
+ $function = strtolower($tokens[$stackPtr]['content']);
85
+
86
+ if (isset($this->functionParameters[$function]) === false) {
87
+ return;
88
+ }
89
+
90
+ $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
91
+ if ($parameterCount === 0) {
92
+ return;
93
+ }
94
+
95
+ // If the parameter count returned > 0, we know there will be valid open parenthesis.
96
+ $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
97
+ $parameterOffsetFound = $parameterCount - 1;
98
+ $requiredVersion = null;
99
+ $parameterName = null;
100
+
101
+ foreach($this->functionParameters[$function] as $offset => $parameterDetails) {
102
+ if ($offset > $parameterOffsetFound) {
103
+ foreach ($parameterDetails as $version => $present) {
104
+ if ($version !== 'name' && $present === true && $this->supportsBelow($version)) {
105
+ $requiredVersion = $version;
106
+ $parameterName = $parameterDetails['name'];
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ if (isset($requiredVersion, $parameterName)) {
113
+
114
+ $error = 'The "%s" parameter for function %s is missing, but was required for PHP version %s and lower';
115
+ $errorCode = 'MissingRequiredParameter';
116
+ $data = array(
117
+ $parameterName,
118
+ $function,
119
+ $requiredVersion,
120
+ );
121
+ $phpcsFile->addError($error, $openParenthesis, $errorCode, $data);
122
+ }
123
+
124
+ }//end process()
125
+
126
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/ShortArraySniff.php CHANGED
@@ -56,4 +56,4 @@ class PHPCompatibility_Sniffs_PHP_ShortArraySniff extends PHPCompatibility_Sniff
56
  }
57
  }//end process()
58
 
59
- }//end class
56
  }
57
  }//end process()
58
 
59
+ }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/ValidIntegersSniff.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHPCompatibility_Sniffs_PHP_ValidIntegersSniff.
4
+ *
5
+ * @category PHP
6
+ * @package PHPCompatibility
7
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
8
+ */
9
+
10
+ /**
11
+ * PHPCompatibility_Sniffs_PHP_ValidIntegersSniff.
12
+ *
13
+ * @category PHP
14
+ * @package PHPCompatibility
15
+ * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
+ */
17
+ class PHPCompatibility_Sniffs_PHP_ValidIntegersSniff extends PHPCompatibility_Sniff
18
+ {
19
+ protected $isLowPHPVersion = false;
20
+
21
+ /**
22
+ * Returns an array of tokens this test wants to listen for.
23
+ *
24
+ * @return array
25
+ */
26
+ public function register()
27
+ {
28
+ $this->isLowPHPVersion = version_compare(phpversion(), '5.4', '<');
29
+
30
+ return array(
31
+ T_LNUMBER, // Binary, octal integers.
32
+ T_CONSTANT_ENCAPSED_STRING, // Hex numeric string.
33
+ );
34
+
35
+ }//end register()
36
+
37
+
38
+ /**
39
+ * Processes this test, when one of its tokens is encountered.
40
+ *
41
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
42
+ * @param int $stackPtr The position of the current token in
43
+ * the stack.
44
+ *
45
+ * @return void
46
+ */
47
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48
+ {
49
+ $tokens = $phpcsFile->getTokens();
50
+ $token = $tokens[$stackPtr];
51
+
52
+ if ($this->couldBeBinaryInteger($tokens, $stackPtr) === true) {
53
+ if ($this->supportsBelow('5.3')) {
54
+ $error = 'Binary integer literals were not present in PHP version 5.3 or earlier. Found: %s';
55
+ if ($this->isLowPHPVersion === false) {
56
+ $data = array($token['content']);
57
+ }
58
+ else {
59
+ $data = array($this->getBinaryInteger($phpcsFile, $tokens, $stackPtr));
60
+ }
61
+ $phpcsFile->addError($error, $stackPtr, 'BinaryIntegerFound', $data);
62
+ }
63
+
64
+ if ($this->isInvalidBinaryInteger($tokens, $stackPtr) === true) {
65
+ $error = 'Invalid binary integer detected. Found: %s';
66
+ $data = array($this->getBinaryInteger($phpcsFile, $tokens, $stackPtr));
67
+ $phpcsFile->addError($error, $stackPtr, 'InvalidBinaryIntegerFound', $data);
68
+ }
69
+ return;
70
+ }
71
+
72
+ $data = array( $token['content'] );
73
+ if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) {
74
+ $error = 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s';
75
+ $isError = $this->supportsAbove('7.0');
76
+
77
+ if ($isError === true) {
78
+ $phpcsFile->addError($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
79
+ } else {
80
+ $phpcsFile->addWarning($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
81
+ }
82
+
83
+ return;
84
+ }
85
+
86
+ if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) {
87
+ $error = 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s';
88
+ $isError = $this->supportsAbove('7.0');
89
+
90
+ if ($isError === true) {
91
+ $phpcsFile->addError($error, $stackPtr, 'HexNumericStringFound', $data);
92
+ } else {
93
+ $phpcsFile->addWarning($error, $stackPtr, 'HexNumericStringFound', $data);
94
+ }
95
+ return;
96
+ }
97
+
98
+ }//end process()
99
+
100
+
101
+ /**
102
+ * Could the current token an potentially be a binary integer ?
103
+ *
104
+ * @param array $token Token stack.
105
+ * @param int $stackPtr The current position in the token stack.
106
+ *
107
+ * @return bool
108
+ */
109
+ private function couldBeBinaryInteger($tokens, $stackPtr) {
110
+ $token = $tokens[$stackPtr];
111
+
112
+ if ($token['code'] !== T_LNUMBER) {
113
+ return false;
114
+ }
115
+
116
+ if ($this->isLowPHPVersion === false) {
117
+ return (preg_match('`^0b[0-1]+$`D', $token['content']) === 1);
118
+ }
119
+ // Pre-5.4, binary strings are tokenized as T_LNUMBER (0) + T_STRING ("b01010101").
120
+ // At this point, we don't yet care whether it's a valid binary int, that's a separate check.
121
+ else {
122
+ return($token['content'] === '0' && $tokens[$stackPtr+1]['code'] === T_STRING && preg_match('`^b[0-9]+$`D', $tokens[$stackPtr+1]['content']) === 1);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Is the current token an invalid binary integer ?
128
+ *
129
+ * @param array $token Token stack.
130
+ * @param int $stackPtr The current position in the token stack.
131
+ *
132
+ * @return bool
133
+ */
134
+ private function isInvalidBinaryInteger($tokens, $stackPtr) {
135
+ if ($this->couldBeBinaryInteger($tokens, $stackPtr) === false) {
136
+ return false;
137
+ }
138
+
139
+ if ($this->isLowPHPVersion === false) {
140
+ // If it's an invalid binary int, the token will be split into two T_LNUMBER tokens.
141
+ return ($tokens[$stackPtr+1]['code'] === T_LNUMBER);
142
+ }
143
+ else {
144
+ return (preg_match('`^b[0-1]+$`D', $tokens[$stackPtr+1]['content']) === 0);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Retrieve the content of the tokens which together look like a binary integer.
150
+ *
151
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
152
+ * @param array $token Token stack.
153
+ * @param int $stackPtr The position of the current token in
154
+ * the stack.
155
+ *
156
+ * @return string
157
+ */
158
+ private function getBinaryInteger(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) {
159
+ $length = 2; // PHP < 5.4 T_LNUMBER + T_STRING
160
+
161
+ if ($this->isLowPHPVersion === false) {
162
+ $i = $stackPtr;
163
+ while ($tokens[$i]['code'] === T_LNUMBER) {
164
+ $i++;
165
+ }
166
+ $length = ($i - $stackPtr);
167
+ }
168
+
169
+ return $phpcsFile->getTokensAsString($stackPtr, $length);
170
+ }
171
+
172
+ /**
173
+ * Is the current token an invalid octal integer ?
174
+ *
175
+ * @param array $token Token stack.
176
+ * @param int $stackPtr The current position in the token stack.
177
+ *
178
+ * @return bool
179
+ */
180
+ private function isInvalidOctalInteger($tokens, $stackPtr) {
181
+ $token = $tokens[$stackPtr];
182
+
183
+ if ($token['code'] === T_LNUMBER && preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $token['content']) === 1) {
184
+ return true;
185
+ }
186
+
187
+ return false;
188
+ }
189
+
190
+ /**
191
+ * Is the current token a hexidecimal numeric string ?
192
+ *
193
+ * @param array $token Token stack.
194
+ * @param int $stackPtr The current position in the token stack.
195
+ *
196
+ * @return bool
197
+ */
198
+ private function isHexidecimalNumericString($tokens, $stackPtr) {
199
+ $token = $tokens[$stackPtr];
200
+
201
+ if ($token['code'] === T_CONSTANT_ENCAPSED_STRING && preg_match('`^([\'"])0x[a-f0-9]+\1$`iD', $token['content']) === 1) {
202
+ return true;
203
+ }
204
+
205
+ return false;
206
+ }
207
+
208
+ }//end class
vendor/wimg/php-compatibility/ruleset.xml CHANGED
@@ -1,5 +1,23 @@
1
  <?xml version="1.0"?>
2
 
3
- <ruleset name="PHPCompatibility_CodeSniffer">
4
- <description>Coding Standard that checks for PHP version compatibility.</description>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  </ruleset>
1
  <?xml version="1.0"?>
2
 
3
+ <ruleset name="PHPCompatibility">
4
+ <description>Coding Standard that checks for PHP version compatibility.</description>
5
+
6
+ <!-- This rule covers checking for non-magic methods using __ prefix. -->
7
+ <!-- Covers part 2 of issue 64: https://github.com/wimg/PHPCompatibility/issues/64 -->
8
+ <rule ref="Generic.NamingConventions.CamelCapsFunctionName">
9
+ <exclude name="Generic.NamingConventions.CamelCapsFunctionName.NotCamelCaps" />
10
+ <exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps" />
11
+ </rule>
12
+ <rule ref="Generic.NamingConventions.CamelCapsFunctionName.MethodDoubleUnderscore">
13
+ <type>warning</type>
14
+ <!-- Original message: Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore -->
15
+ <message>Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use</message>
16
+ </rule>
17
+ <rule ref="Generic.NamingConventions.CamelCapsFunctionName.FunctionDoubleUnderscore">
18
+ <type>warning</type>
19
+ <!-- Original message: Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore -->
20
+ <message>Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use</message>
21
+ </rule>
22
+
23
  </ruleset>
wpengine-phpcompat.php CHANGED
@@ -4,12 +4,13 @@ Plugin Name: PHP Compatibility Checker
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
- Version: 1.1.2
8
  Author URI: https://wpengine.com
9
- */
 
10
 
11
  // Exit if this file is directly accessed
12
- if ( ! defined( 'ABSPATH' ) ) exit;
13
 
14
  require_once( __DIR__ . '/vendor/autoload.php' );
15
 
@@ -117,7 +118,7 @@ class WPEngine_PHPCompat {
117
  ) );
118
 
119
  if ( 0 < count( $jobs ) ) {
120
- $active_job = $jobs[ 0 ]->post_title;
121
  }
122
 
123
  $to_encode = array(
@@ -157,7 +158,7 @@ class WPEngine_PHPCompat {
157
  array(
158
  'labels' => array(
159
  'name' => __( 'Jobs' ),
160
- 'singular_name' => __( 'Job' )
161
  ),
162
  'public' => false,
163
  'has_archive' => false,
@@ -185,12 +186,29 @@ class WPEngine_PHPCompat {
185
  // Scripts
186
  wp_enqueue_script( 'wpephpcompat-handlebars', plugins_url( '/src/js/handlebars.js', __FILE__ ), array( 'jquery' ) );
187
  wp_enqueue_script( 'wpephpcompat-download', plugins_url( '/src/js/download.min.js', __FILE__ ) );
188
- wp_enqueue_script( 'wpephpcompat', plugins_url( '/src/js/run.js', __FILE__ ), array('jquery', 'wpephpcompat-handlebars', 'wpephpcompat-download') );
189
 
190
  // Progress Bar
191
  wp_enqueue_script( 'jquery-ui-progressbar' );
192
  wp_enqueue_style( 'jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
 
196
  /**
@@ -202,7 +220,7 @@ class WPEngine_PHPCompat {
202
  */
203
  function create_menu() {
204
  // Create Tools sub-menu.
205
- $this->page = add_submenu_page( 'tools.php', 'PHP Compatibility', 'PHP Compatibility', 'manage_options', __FILE__, array( self::instance(), 'settings_page' ) );
206
  }
207
 
208
  /**
@@ -222,35 +240,36 @@ class WPEngine_PHPCompat {
222
  ?>
223
  <div class="wrap">
224
  <div style="float: left;">
225
- <h2>WP Engine PHP Compatibility Checker</h2>
226
  </div>
227
  <div style="float: right; margin-top: 10px; text-align: right;">
228
- <input type="checkbox" id="developermode" name="developermode" value="yes">Developer mode
229
  </div>
230
  <br><br>
231
- <h3 class="title clear">Scan Options</h3>
232
  <table class="form-table">
233
  <tbody>
234
  <tr>
235
- <th scope="row"><label for="phptest_version">PHP Version</label></th>
236
  <td>
237
  <label><input type="radio" name="phptest_version" value="7.0" <?php checked( $test_version, '7.0', true ); ?>> PHP 7.0</label><br>
 
238
  <label><input type="radio" name="phptest_version" value="5.5" <?php checked( $test_version, '5.5', true ); ?>> PHP 5.5</label><br>
239
  <label><input type="radio" name="phptest_version" value="5.4" <?php checked( $test_version, '5.4', true ); ?>> PHP 5.4</label><br>
240
  <label><input type="radio" name="phptest_version" value="5.3" <?php checked( $test_version, '5.3', true ); ?>> PHP 5.3</label>
241
  </td>
242
  </tr>
243
  <tr>
244
- <th scope="row"><label for="active_plugins">Only Active</label></th>
245
- <td><label><input type="radio" name="active_plugins" value="yes" <?php checked( $only_active, 'yes', true ); ?>> Only scan active plugins and themes</label><br>
246
- <label><input type="radio" name="active_plugins" value="no" <?php checked( $only_active, 'no', true ); ?>> Scan all plugins and themes</label>
247
  </td>
248
  </tr>
249
  </tbody>
250
  </table>
251
  <p>
252
  <div style="display: none;" id="wpe-progress">
253
- <label for="">Progress</label>
254
  <div id="progressbar"></div>
255
  <div id="wpe-progress-count"></div>
256
  <div id="wpe-progress-active"></div>
@@ -261,17 +280,17 @@ class WPEngine_PHPCompat {
261
 
262
  <!-- Area for developer results. -->
263
  <div style="display: none;" id="developerMode">
264
- <b>Test Results:</b>
265
  <textarea readonly="readonly" id="testResults"></textarea>
266
  </div>
267
 
268
  <div id="footer" style="display: none;">
269
- Note: Warnings are not currently an issue, but they could be in the future.<br>
270
- <a id="downloadReport" href="#">Download Report</a>
271
  </div>
272
  </p>
273
  <p>
274
- <input style="float: left;" name="run" id="runButton" type="button" value="Run" class="button-primary" />
275
  <div style="display:none; visibility: visible; float: none;" class="spinner"></div>
276
  </p>
277
  </div>
@@ -284,17 +303,16 @@ class WPEngine_PHPCompat {
284
  </div>
285
  <div class="inner-right">
286
  <h3 style="margin: 0px;">{{plugin_name}}</h3>
287
- {{#if skipped}}Unknown{{else if passed}}PHP {{test_version}} compatible.{{else}}<b>Not</b> PHP {{test_version}} compatible.{{/if}}<br>
288
  {{update}}<br>
289
- <textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details">view details</a>
290
  </div>
291
  <?php $update_url = site_url( 'wp-admin/update-core.php' , 'admin' ); ?>
292
- <div style="float:right;">{{#if updateAvailable}}<div class="badge wpe-update"><a href="<?php echo esc_url( $update_url ); ?>">Update Available</a></div>{{/if}}{{#if warnings}}<div class="badge warnings">{{warnings}} Warnings</div>{{/if}}{{#if errors}}<div class="badge errors">{{errors}} Errors</div>{{/if}}</div>
293
  </div>
294
  </script>
295
  <?php
296
  }
297
-
298
  }
299
  // Register the WPEngine_PHPCompat instance
300
  WPEngine_PHPCompat::init();
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
+ Version: 1.2.0
8
  Author URI: https://wpengine.com
9
+ Text Domain: php-compatibility-checker
10
+ */
11
 
12
  // Exit if this file is directly accessed
13
+ if ( ! defined( 'ABSPATH' ) ) { exit; }
14
 
15
  require_once( __DIR__ . '/vendor/autoload.php' );
16
 
118
  ) );
119
 
120
  if ( 0 < count( $jobs ) ) {
121
+ $active_job = $jobs[0]->post_title;
122
  }
123
 
124
  $to_encode = array(
158
  array(
159
  'labels' => array(
160
  'name' => __( 'Jobs' ),
161
+ 'singular_name' => __( 'Job' ),
162
  ),
163
  'public' => false,
164
  'has_archive' => false,
186
  // Scripts
187
  wp_enqueue_script( 'wpephpcompat-handlebars', plugins_url( '/src/js/handlebars.js', __FILE__ ), array( 'jquery' ) );
188
  wp_enqueue_script( 'wpephpcompat-download', plugins_url( '/src/js/download.min.js', __FILE__ ) );
189
+ wp_enqueue_script( 'wpephpcompat', plugins_url( '/src/js/run.js', __FILE__ ), array( 'jquery', 'wpephpcompat-handlebars', 'wpephpcompat-download' ) );
190
 
191
  // Progress Bar
192
  wp_enqueue_script( 'jquery-ui-progressbar' );
193
  wp_enqueue_style( 'jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
194
 
195
+ /**
196
+ * i18n strings
197
+ *
198
+ * These translated strings can be access in jquery with window.wpephpcompat object.
199
+ */
200
+ $strings = array(
201
+ 'name' => __( 'Name', 'php-compatibility-checker' ),
202
+ 'compatible' => __( 'compatible', 'php-compatibility-checker' ),
203
+ 'are_not' => __( 'plugins/themes are not compatible', 'php-compatibility-checker' ),
204
+ 'is_not' => __( 'Your WordPress install is not PHP', 'php-compatibility-checker' ),
205
+ 'out_of' => __( 'out of', 'php-compatibility-checker' ),
206
+ 'run' => __( 'Run', 'php-compatibility-checker' ),
207
+ 'rerun' => __( 'Re-run', 'php-compatibility-checker' ),
208
+ 'your_wp' => __( 'Your WordPress install is', 'php-compatibility-checker' ),
209
+ );
210
+
211
+ wp_localize_script( 'wpephpcompat', 'wpephpcompat', $strings );
212
  }
213
 
214
  /**
220
  */
221
  function create_menu() {
222
  // Create Tools sub-menu.
223
+ $this->page = add_submenu_page( 'tools.php', __( 'PHP Compatibility', 'php-compatibility-checker' ), __( 'PHP Compatibility', 'php-compatibility-checker' ), 'manage_options', __FILE__, array( self::instance(), 'settings_page' ) );
224
  }
225
 
226
  /**
240
  ?>
241
  <div class="wrap">
242
  <div style="float: left;">
243
+ <h2><?php esc_attr_e( 'WP Engine PHP Compatibility Checker', 'php-compatibility-checker' ); ?></h2>
244
  </div>
245
  <div style="float: right; margin-top: 10px; text-align: right;">
246
+ <input type="checkbox" id="developermode" name="developermode" value="yes" /><?php esc_attr_e( 'Developer mode', 'php-compatibility-checker' ); ?>
247
  </div>
248
  <br><br>
249
+ <h3 class="title clear"><?php esc_attr_e( 'Scan Options', 'php-compatibility-checker' ); ?></h3>
250
  <table class="form-table">
251
  <tbody>
252
  <tr>
253
+ <th scope="row"><label for="phptest_version"><?php esc_attr_e( 'PHP Version', 'php-compatibility-checker' ); ?></label></th>
254
  <td>
255
  <label><input type="radio" name="phptest_version" value="7.0" <?php checked( $test_version, '7.0', true ); ?>> PHP 7.0</label><br>
256
+ <label><input type="radio" name="phptest_version" value="5.6" <?php checked( $test_version, '5.6', true ); ?>> PHP 5.6</label><br>
257
  <label><input type="radio" name="phptest_version" value="5.5" <?php checked( $test_version, '5.5', true ); ?>> PHP 5.5</label><br>
258
  <label><input type="radio" name="phptest_version" value="5.4" <?php checked( $test_version, '5.4', true ); ?>> PHP 5.4</label><br>
259
  <label><input type="radio" name="phptest_version" value="5.3" <?php checked( $test_version, '5.3', true ); ?>> PHP 5.3</label>
260
  </td>
261
  </tr>
262
  <tr>
263
+ <th scope="row"><label for="active_plugins"><?php esc_attr_e( 'Only Active', 'php-compatibility-checker' ); ?></label></th>
264
+ <td><label><input type="radio" name="active_plugins" value="yes" <?php checked( $only_active, 'yes', true ); ?> /> <?php esc_attr_e( 'Only scan active plugins and themes', 'php-compatibility-checker' ); ?></label><br>
265
+ <label><input type="radio" name="active_plugins" value="no" <?php checked( $only_active, 'no', true ); ?> /> <?php esc_attr_e( 'Scan all plugins and themes', 'php-compatibility-checker' ); ?></label>
266
  </td>
267
  </tr>
268
  </tbody>
269
  </table>
270
  <p>
271
  <div style="display: none;" id="wpe-progress">
272
+ <label for=""><?php esc_attr_e( 'Progress', 'php-compatibility-checker' ); ?></label>
273
  <div id="progressbar"></div>
274
  <div id="wpe-progress-count"></div>
275
  <div id="wpe-progress-active"></div>
280
 
281
  <!-- Area for developer results. -->
282
  <div style="display: none;" id="developerMode">
283
+ <b><?php esc_attr_e( 'Test Results:', 'php-compatibility-checker' ); ?></b>
284
  <textarea readonly="readonly" id="testResults"></textarea>
285
  </div>
286
 
287
  <div id="footer" style="display: none;">
288
+ <?php esc_attr_e( 'Note: Warnings are not currently an issue, but they could be in the future.', 'php-compatibility-checker' ); ?><br>
289
+ <a id="downloadReport" href="#"><?php esc_attr_e( 'Download Report', 'php-compatibility-checker' ); ?></a>
290
  </div>
291
  </p>
292
  <p>
293
+ <input style="float: left;" name="run" id="runButton" type="button" value="<?php esc_attr_e( 'Run', 'php-compatibility-checker' ); ?>" class="button-primary" />
294
  <div style="display:none; visibility: visible; float: none;" class="spinner"></div>
295
  </p>
296
  </div>
303
  </div>
304
  <div class="inner-right">
305
  <h3 style="margin: 0px;">{{plugin_name}}</h3>
306
+ {{#if skipped}}<?php esc_attr_e( 'Unknown', 'php-compatibility-checker' ); ?>{{else if passed}}PHP {{test_version}} <?php esc_attr_e( 'compatible', 'php-compatibility-checker' ); ?>.{{else}}<b><?php esc_attr_e( 'Not', 'php-compatibility-checker' ); ?></b> PHP {{test_version}} <?php esc_attr_e( 'compatible', 'php-compatibility-checker' ); ?>.{{/if}}<br>
307
  {{update}}<br>
308
+ <textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details"><?php esc_attr_e( 'view details', 'php-compatibility-checker' ); ?></a>
309
  </div>
310
  <?php $update_url = site_url( 'wp-admin/update-core.php' , 'admin' ); ?>
311
+ <div style="float:right;">{{#if updateAvailable}}<div class="badge wpe-update"><a href="<?php echo esc_url( $update_url ); ?>"><?php esc_attr_e( 'Update Available', 'php-compatibility-checker' ); ?></a></div>{{/if}}{{#if warnings}}<div class="badge warnings">{{warnings}} <?php esc_attr_e( 'Warnings', 'php-compatibility-checker' ); ?></div>{{/if}}{{#if errors}}<div class="badge errors">{{errors}} <?php esc_attr_e( 'Errors', 'php-compatibility-checker' ); ?></div>{{/if}}</div>
312
  </div>
313
  </script>
314
  <?php
315
  }
 
316
  }
317
  // Register the WPEngine_PHPCompat instance
318
  WPEngine_PHPCompat::init();