• Resolved jengreen115

    (@jengreen115)


    My company has ran PHP Codesniffer for PHP 5.6 on all of our WordPress sites and all are coming back with PHP Codesniffer errors. Many of the errors pertain to plugins (which are out of our hands), but many of the errors pertain to WP Core as well. A few examples:

    FILE: /home/site/site.org/public_html/wp-includes/Text/Diff.php
    ———————————————————————-
    FOUND 1 ERROR AFFECTING 1 LINE
    ———————————————————————-
    128 | ERROR | ‘clone’ is a reserved keyword introduced in PHP
    | | version 5.0 and cannot be invoked as a function
    | | (T_CLONE)
    ———————————————————————-

    FILE: …/site/site.org/public_html/wp-includes/class-phpmailer.php
    ———————————————————————-
    FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
    ———————————————————————-
    674 | WARNING | INI directive ‘safe_mode’ is deprecated from PHP
    | | 5.3 and forbidden from PHP 5.4.
    1357 | WARNING | INI directive ‘safe_mode’ is deprecated from PHP
    | | 5.3 and forbidden from PHP 5.4.
    2526 | ERROR | The use of function set_magic_quotes_runtime is
    | | discouraged from PHP version 5.3 and forbidden from
    | | PHP version 5.4
    2531 | WARNING | INI directive ‘magic_quotes_runtime’ is deprecated
    | | from PHP 5.3 and forbidden from PHP 5.4.
    2538 | ERROR | The use of function set_magic_quotes_runtime is
    | | discouraged from PHP version 5.3 and forbidden from
    | | PHP version 5.4
    2540 | WARNING | INI directive ‘magic_quotes_runtime’ is deprecated
    | | from PHP 5.3 and forbidden from PHP 5.4.
    ———————————————————————-

    Does anyone know why errors might still be popping up in this report if our core has been updated to 4.5.2 and WordPress claims it’s compatible with PHP 7?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator James Huff

    (@macmanx)

    WordPress is compatible up to PHP 7 (and further, really), but it’s also compatible *back* to a minimum of PHP 5.2.4, which is why your sniffer is finding code deprecated since PHP 5.3 and 5.4.

    In order to provide the same functionality offered by PHP 5.6 and 7.0, some deprecated functions still exist for those using older versions of PHP.

    In very loose terms, many things in WordPress are written like “If PHP is 5.6, use [this elegant and modern string of code]. Else, if PHP is older, use [this deprecated string].”

    https://www.ads-software.com/about/requirements/

    Thread Starter jengreen115

    (@jengreen115)

    Thank you James!

    Moderator James Huff

    (@macmanx)

    You’re welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Codesniffer Errors’ is closed to new replies.