[wp-trac] [WordPress Trac] #46152: Add PHPCompatibility checks to test suite

WordPress Trac noreply at wordpress.org
Wed Jan 30 21:28:18 UTC 2019


#46152: Add PHPCompatibility checks to test suite
------------------------------+-------------------------------
 Reporter:  desrosj           |       Owner:  (none)
     Type:  feature request   |      Status:  new
 Priority:  normal            |   Milestone:  Future Release
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:  coding-standards
------------------------------+-------------------------------

Comment (by desrosj):

 [attachment:"46152.diff"] does the following:

 - Adds the packages through Composer.
 - Adds a `compatibility` script to Composer to run only PHP compatibility
 checks.
 - Adds a `php-compatibility.xml.dist` file to configure the command as
 needed.

 To start, I have copied the file exclusion/inclusion rules from core's
 main PHPCS configuration file. These checks are a bit different than
 coding standards, though. Coding standards shouldn't necessarily be
 followed within included libraries because it makes keeping them up to
 date more difficult. But the included libraries should always adhere to
 the project's PHP requirements.

 @jrf I would love your feedback on this. I am new to this ruleset, so I am
 sure that there are some great ways to make the implementation simpler.

 Currently, there are a large handful of warnings and errors. We'll need to
 look into each and determine if a change to the codebase is needed, or if
 the check should be disabled in the ruleset. Below is what `composer run
 compatibility` currently outputs:


 {{{
 PHP CODE SNIFFER REPORT SUMMARY
 ----------------------------------------------------------------------
 FILE                                                  ERRORS  WARNINGS
 ----------------------------------------------------------------------
 src/_index.php                                        1       0
 src/wp-mail.php                                       1       0
 src/wp-settings.php                                   2       0
 src/xmlrpc.php                                        5       0
 src/wp-admin/ms-delete-site.php                       1       0
 ...-admin/includes/class-automatic-upgrader-skin.php  0       1
 src/wp-admin/includes/class-bulk-upgrader-skin.php    1       0
 ...wp-admin/includes/class-wp-ajax-upgrader-skin.php  0       3
 ...n/includes/class-wp-plugin-install-list-table.php  1       0
 src/wp-admin/includes/class-wp-upgrader-skin.php      1       0
 src/wp-admin/includes/media.php                       0       1
 src/wp-admin/includes/schema.php                      0       1
 src/wp-admin/includes/upgrade.php                     0       1
 src/wp-admin/user/about.php                           1       0
 ...ontent/themes/twentyfifteen/inc/template-tags.php  1       0
 ...twentynineteen/template-parts/content/content.php  1       0
 src/wp-content/themes/twentyten/author.php            1       0
 src/wp-content/themes/twentytwelve/index.php          1       0
 src/wp-includes/author-template.php                   0       1
 src/wp-includes/capabilities.php                      1       0
 src/wp-includes/class-wp-network-query.php            1       0
 src/wp-includes/cron.php                              0       1
 src/wp-includes/functions.php                         0       7
 src/wp-includes/general-template.php                  0       1
 src/wp-includes/load.php                              0       1
 src/wp-includes/plugin.php                            0       6
 src/wp-includes/spl-autoload-compat.php               0       1
 src/wp-includes/wp-db.php                             26      1
 ...s/customize/class-wp-customize-themes-section.php  1       0
 src/wp-includes/pomo/streams.php                      0       1
 src/wp-includes/rest-api/class-wp-rest-server.php     4       0
 ...points/class-wp-rest-post-statuses-controller.php  1       0
 tests/phpunit/includes/plural-form-function.php       0       1
 tests/phpunit/tests/admin/includesFile.php            0       1
 tests/phpunit/tests/ajax/Compression.php              1       0
 tests/phpunit/tests/comment/wpListComments.php        1       0
 tests/phpunit/tests/db/charset.php                    1       0
 tests/phpunit/tests/formatting/SanitizeMimeType.php   1       0
 tests/phpunit/tests/formatting/WPTexturize.php        2       0
 tests/phpunit/tests/http/curl.php                     1       0
 tests/phpunit/tests/multisite/getSite.php             1       0
 tests/phpunit/tests/option/option.php                 0       1
 tests/phpunit/tests/option/siteOption.php             0       1
 tests/phpunit/tests/option/updateOption.php           0       1
 tests/phpunit/tests/pomo/mo.php                       0       1
 tests/phpunit/tests/post/output.php                   1       0
 tests/phpunit/tests/rewrite/oldDateRedirect.php       1       0
 tests/phpunit/tests/user/wpSendUserRequest.php        1       0
 ----------------------------------------------------------------------
 A TOTAL OF 63 ERRORS AND 33 WARNINGS WERE FOUND IN 48 FILES
 ----------------------------------------------------------------------

 Time: 23.78 secs; Memory: 6MB


 PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
 ----------------------------------------------------------------------
 SOURCE                                                           COUNT
 ----------------------------------------------------------------------
 PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedR  27
 Internal.Exception                                               20
 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValu  13
 PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames  9
 PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.htt  9
 PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames  4
 PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_fu  3
 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValu  2
 PHPCompatibility.Miscellaneous.ValidIntegers.HexNumericStringFo  2
 PHPCompatibility.FunctionNameRestrictions.RemovedMagicAutoload.  1
 PHPCompatibility.FunctionUse.RemovedFunctions.create_functionDe  1
 PHPCompatibility.IniDirectives.RemovedIniDirectives.magic_quote  1
 PHPCompatibility.IniDirectives.RemovedIniDirectives.magic_quote  1
 PHPCompatibility.IniDirectives.RemovedIniDirectives.register_gl  1
 PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDe  1
 PHPCompatibility.Lists.AssignmentOrder.Affected                  1
 ----------------------------------------------------------------------
 A TOTAL OF 96 SNIFF VIOLATIONS WERE FOUND IN 16 SOURCES
 ----------------------------------------------------------------------
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46152#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list