Skip to content

Inconsistent behavior of PHP_CodeSniffer_File::findEndOfStatement #1203

@nkovacs

Description

@nkovacs

PHP_CodeSniffer_File::findEndOfStatement sometimes returns end token, but sometimes it returns the last not empty token before that.

E.g. if $start is new:

  • in [new Datetime] it returns ].
  • in array(new Datetime) it returnsDatetime.
  • in new Datetime; it returns ;.

The difference between array() and [] is probably a mistake, because [] was added later in 4df216f, but I don't understand why there's a difference at all.
The examples above are from a sniff that adds () to new. If findEndOfStatement consistently returned the last non-empty statement (like it does for array(new Datetime)), I could insert the () after that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions