Hi,

I am facing the following error after PHP7.2 upgrade.

FILE: ...ules/contrib/rules_conditional/includes/rules_conditional.ui.inc
----------------------------------------------------------------------
FOUND 20 ERRORS AFFECTING 17 LINES
----------------------------------------------------------------------
69 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
72 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
72 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
83 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
83 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
83 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
89 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
90 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
104 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
105 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
115 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
116 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
126 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
235 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
237 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
241 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
244 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
247 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
258 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
270 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.

Comments

Aish17895 created an issue. See original summary.

tr’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

These appear to be false positives. There is nothing wrong with those uses of $this. Notably, they are NOT occurring in a "plain function". The first two errors, for example, use $this in a class constructor, which is not only allowed but is almost mandatory for OO code.

If that's the output of some Drupal-integrated script, then you should report this as a false positive for that project.

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)