Skip to content

Test version logic #142

@jrfnl

Description

@jrfnl

Before I start debugging/changing things around, I'd like to check what the intended behaviour is of the testVersion logic.

It was always my understanding that if you provided a specific version or version range, you'd only get the notices which were relevant for those versions.
And if you didn't provide a testVersion, you'd get all the notices no matter what, i.e. this would currently translate to the range 5.0-7.0.

In practice, that is not how it currently works.

The below comment is in the PHPCompatibility_Sniff abstract base class. The explanation in the comment is not in line with what my understanding was, but also not in line with how it currently works.

/* The testVersion configuration variable may be in any of the following formats:
 * 1) Omitted/empty, in which case no version is specified.  This effectively
 *    disables all the checks provided by this standard.
 * 2) A single PHP version number, e.g. "5.4" in which case the standard checks that
 *    the code will run on that version of PHP (no deprecated features or newer
 *    features being used).
 * 3) A range, e.g. "5.0-5.5", in which case the standard checks the code will run
 *    on all PHP versions in that range, and that it doesn't use any features that
 *    were deprecated by the final version in the list, or which were not available
 *    for the first version in the list.
 * PHP version numbers should always be in Major.Minor format.  Both "5", "5.3.2"
 * would be treated as invalid, and ignored.
 * This standard doesn't support checking against PHP4, so the minimum version that
 * is recognised is "5.0".
 */

This is what the functions currently return:
Image

So my question specifically is what the intended behaviour is when no testVersion has been provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions