Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Positive: Vantage #275

Open
AlexGStapleton opened this issue Jun 21, 2020 · 6 comments
Open

False Positive: Vantage #275

AlexGStapleton opened this issue Jun 21, 2020 · 6 comments

Comments

@AlexGStapleton
Copy link

AlexGStapleton commented Jun 21, 2020

Related Vantage Issue
File

PHP Compatability Checker isn't detecting classes and incorrectly flagging code as a result of this. If we're doing something wrong by modern standards we would be more than happy to update our code.

FILE: /home1/EDITED/EDITED/wp-content/themes/vantage/inc/widgets.php
-----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 45 ERRORS AND 1 WARNING AFFECTING 31 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------
12 | WARNING | Function name "__construct" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.
126 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
127 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
127 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
130 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
131 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
131 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
134 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
135 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
135 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
138 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
139 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
139 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
142 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
143 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
143 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
155 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
156 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
156 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
159 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
160 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
160 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
163 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
164 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
164 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
167 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
168 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
168 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
176 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
177 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
177 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
184 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
185 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
185 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
188 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
189 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
189 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
192 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
193 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
193 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
198 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
199 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
199 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
205 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
206 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
206 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
----------------------------------------------------------------------------------------------------------------
@jrfnl
Copy link

jrfnl commented Jun 21, 2020

@AlexGStapleton I've ran some tests with the underlying tooling (PHPCompatibility) and for the life of me, I can not reproduce these results at all.

I've tested with the current version as well as numerous older versions as far back as releases from 2017 and still can not reproduce this.

I'd be curious to know what version of the plugin you are using and on which version of PHP the setup is being run.

Either way, I suspect this is either a problem with a severely out of date plugin or a problem within this plugin itself.

Once I know the plugin version and the PHP version used, I can run a last test to confirm.

@AlexGStapleton
Copy link
Author

We've had trouble getting the plugin to not timeout when checking Vantage (and our other plugins) so we had to rely on the users install which was able to reliably run the tests without it timing out. The plugin version they have installed is 1.5.0, and the PHP version they're currently using is 7.1.14. The tests were run against PHP 7.3. We had another user report the same results and they were using PHP 7.2.22 - unsure of the plugin version or what version they were testing against.

@jrfnl
Copy link

jrfnl commented Jun 21, 2020

@AlexGStapleton Thanks for that information.

I've now able to reproduce the issue with:

  • Any PHP version
  • And the locked dependencies of the plugin at v1.5.0:
    • PHPCS 2.9.2
    • PHPCompatibility 9.2.0

The problem is a bug in PHPCS itself which doesn't exist in any of the more recent PHPCS versions (tested with 3.02 and up) and which external standards cannot work-around as the token information provided by PHPCS is basically wrong (in certain circumstances).

In other words: the solution is for the plugin to upgrade the PHPCS version used.

PHPCS 2.9.2 was released in November 2018 as a afterthought as PHPCS 3.0.0 was already released in May 2017 and the current version is 3.5.5 (April 2020), so the PHPCS version used by the plugin is sorely out of date.

The bug is triggered because the code in the file uses inline control structures without braces:

if(!empty($icon_styles)) echo ' icon-color-set'

So, in the mean time, if you want to prevent further notices from your users: use braces with your control structures.

@AlexGStapleton
Copy link
Author

@jrfnl Using the provided feedback I was able to get Vantage to pass. Thanks for helping out with this, we really appreciate it. :)

@AlexGStapleton
Copy link
Author

@jrfnl I'm unsure if you want to use this issue for tracking the PHPCS issue or not so I'm going to reopen it. Please feel free to close or adjust accordingly.

@jrfnl
Copy link

jrfnl commented Jun 22, 2020

@AlexGStapleton Nothing for me to keep track of. Maybe for one of the plugin maintainers though,

For your perspective: I'm not directly involved with this project. I am the maintainer of the underlying tooling and there's nothing I can do there for this issue ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants