Skip to content

Deprecated syntax: array property values in ruleset.xml for PHPCS #210

@michaelmeneses

Description

@michaelmeneses

Problem

A deprecated syntax is present in ruleset.xml for the property ignoreIndentationTokens under the sniff Generic.WhiteSpace.ScopeIndent. The current approach passes an array of values as a comma-separated string:

<property name="ignoreIndentationTokens" type="array" value="T_CLOSE_TAG"/>

Details

  • Passing an array of values to a property using a comma-separated string was deprecated in PHP_CodeSniffer 3.3.0.
  • Support for this syntax will be removed in PHPCS 4.0.0.
  • The correct approach is to pass array values via <element [key="..." ]value="..."> nodes instead.

Reference Warning

DEPRECATED: Passing an array of values to a property using a comma-separated string was deprecated in PHP_CodeSniffer 3.3.0. Support will be removed in PHPCS 4.0.0. The deprecated syntax was used for property "ignoreIndentationTokens" for sniff "Generic.WhiteSpace.ScopeIndent". Pass array values via <element [key="..." ]value="..."> nodes instead.

Suggested Solution

  • Refactor the ruleset.xml to use the new syntax for array properties.
  • Example:
    <rule ref="Generic.WhiteSpace.ScopeIndent">
        <properties>
            <property name="ignoreIndentationTokens" type="array">
                <element value="T_CLOSE_TAG"/>
            </property>
        </properties>
    </rule>
  • Review other array properties in the file for similar issues.

Impact

  • This change ensures compatibility with upcoming PHPCS versions and prevents future errors.

References:

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