Skip to content

4.x PHP_CodeSniffer\Util\Common::$allowedTypes structure changed without documentation #1143

Open
@InvisibleSmiley

Description

@InvisibleSmiley

Describe the bug

4.x PHP_CodeSniffer\Util\Common::$allowedTypes used to be list<string>, now it's array<string, string> (due to it being a copy of the new ALLOWED_TYPES constant). In other words, the key type changed from non-negative-int to non-empty-string and of course all key values changed as well.

The change is not documented in current version of the developer upgrade guide.

Since the property is public static, this potentially affects usages anywhere, not just in subclasses and read contexts.

Context analysis

The change was probably made with good intentions, to micro-tune performance (replace in_array by isset).

The fact that it is a BC break (that either needs to be documented or avoided) was probably missed.

Expected behavior

The change is either (partly) reverted or properly documented.

Versions

PHP_CodeSniffer version 4.x branch

Confirmations

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the master branch of PHP_CodeSniffer. (does not apply)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions