phpcs errors - $this in plain function, DateTimeInterface not implementable

Created on 13 March 2023, over 1 year ago
Updated 20 September 2023, 9 months ago

Problem/Motivation

phpcs using PHP 8.1 outputs the following errors:

FILE: /var/www/html/web/modules/contrib/smart_date/modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php
----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------
 339 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/smart_date/src/TypedData/Plugin/DataType/SmartDate.php
--------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
 17 | ERROR | The interface DateTimeInterface is intended for type hints only and is not implementable.
--------------------------------------------------------------------------------------------------------

The latter is just because phpcs thinks the DateTimeInterface used there is the PHP global interface.

Proposed resolution

Attached patch fixes these errors.

πŸ“Œ Task
Status

Needs review

Version

3.7

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada bgilhome Victoria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bgilhome
  • πŸ‡ΊπŸ‡ΈUnited States a_handan

    I've created a new patch based on bgilhome's work on the original patch. This new patch should be compatible with the 4.1.x branch (I had issues with composer when trying to apply the original patch on a 4.0 or above version). Please review

Production build 0.69.0 2024