Skip to content

incorrect error "$this" can no longer be unset #3965

@WanWizard

Description

@WanWizard

Describe the bug

Running ~/.composer/vendor/bin/phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 8.5 on my codebase.

I get the error ""$this" can no longer be unset since PHP 7.1.", but this is not what is happening in the code, see the offending line below.

Code sample

unset(static::$_cached_objects[get_called_class()][static::implode_pk($this)]);

To reproduce

Steps to reproduce the behavior:

  1. Create a php file containing the given line
  2. Run phpcs with the given line
  3. See error message displayed
---------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------
 1730 | ERROR | "$this" can no longer be unset since PHP 7.1.
---------------------------------------------------------------------------------

Expected behavior

Not being shown this error, $this is not being unset on this line, it is used as an argument to a function.

Versions (please complete the following information)

Operating System [e.g., Windows 10, MacOS 10.15]
PHP version [8.5.0]
PHP_CodeSniffer version [3.13.5 stable]
Standard PHPCompatibility]
Install type Composer, local]

Additional context

Add any other context about the problem here.

Please confirm:

  • I have searched the issue list and am not opening a duplicate issue.
  • 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.

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