totten / civix

CiviCRM Extension Builder
http://civicrm.org/
Other
56 stars 56 forks source link

php codesniffer warnings #294

Closed jofranz closed 1 year ago

jofranz commented 1 year ago

phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 7.4-8.1

Civix version: 23.02.1

FILE: de.systopia.xcm/mixin/polyfill.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------
 52 | WARNING | Closures / anonymous functions only have access to $this if used within a class or when bound to an object using bindTo(). Please verify.
 56 | WARNING | Closures / anonymous functions only have access to $this if used within a class or when bound to an object using bindTo(). Please verify.
----------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: de.systopia.xcm/mixin/smarty-v2@1.0.0.mixin.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------
 25 | WARNING | Closures / anonymous functions only have access to $this if used within a class or when bound to an object using bindTo(). Please verify.
----------------------------------------------------------------------------------------------------------------------------------------------------------
totten commented 1 year ago

For polyfill.php, the usage of $this looks fine to me. But I wouldn't be surprised if their pattern-matcher was little off. (This is an anonymous class inside an anonymous function... which is not very common.)

For smarty-v2@1.0.0, that probably is a latent bug (i.e. code is wrong; but currently I can't see a symptom). Fortunately, Eileen posted an update for smarty-v2@1.0.1 which incidentally fixes that. So I'll update the backport to use it.

totten commented 1 year ago

Thanks for reporting @jofranz. v23.03.0 is up and should include a fix for the smarty-v2 issue.

The polyfill.php is more awkward - since it looks like a false-negative to me. A few ways to go: