Problem/Motivation
Running GrumPHP compatibility test returns 2 errors
php_compatibility
=================
FILE: ...atpickr/src/Plugin/Field/FieldWidget/DateTimeFlatPickrWidget.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
388 | ERROR | "$this" can no longer be used in a plain function or
| | method since PHP 7.1.
| | (PHPCompatibility.Variables.ForbiddenThisUseContexts.OutsideObjectContext)
410 | ERROR | "$this" can no longer be used in a plain function or
| | method since PHP 7.1.
| | (PHPCompatibility.Variables.ForbiddenThisUseContexts.OutsideObjectContext)
Steps to reproduce
On PHP 8.0 run PHP compatibility test for this module.
Proposed resolution
Replace $this->t with new TranslatableMarkup
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | validate-does-not-need-to-be-static-3272728-9.patch | 1.15 KB | nagy.balint |
Issue fork datetime_flatpickr-3272728
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
tmaiochi commentedI'll work on this!
Comment #4
tmaiochi commentedI replaced
$this->t with new TranslatableMarkupas proposed resolution, Kindly review it!Comment #5
deiviic commentedI suggested
new TranslatableMarkupbecause that was in the method itself but after reading a little, it seems justt()could be used. Not sure what would be the better option..Comment #6
avpadernoComment #7
avpadernoSince the element validation handler is added with
'#element_validate' => [[$this, 'fieldSettingsHourElementValidate'],]it is wrong to definefieldSettingsHourElementValidate()as static method.Comment #8
nagy.balint commentedI'll check, maybe indeed those do not need to be static.
Comment #9
nagy.balint commentedComment #11
nagy.balint commentedThanks!