Problem/Motivation

PHPCS give me this error when checking php8.3 compatibility :

The interface DateTimeInterface is intended for type hints only and is not implementable.

Steps to reproduce

Install module and run :
phpcs -p web/module/contrib/smart_date --standard="PHPCompatibility" --runtime-set testVersion "8.3" --extensions="php,module,inc,install,test,profile,theme"

Proposed resolution

Remove "implements DateTimeInterface" since it's defined in the Timestamp class

Issue fork smart_date-3505835

Command icon 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

arwillame created an issue. See original summary.

arwillame’s picture

Status: Active » Needs review

mandclu made their first commit to this issue’s fork.

mandclu’s picture

Status: Needs review » Fixed

Thanks for identifying this, and for providing a fix. Merged in.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rory downes’s picture

Hi,
I am aware that this ticket is closed as fixed and indeed the scan no longer reports this error.

However, I was scanning my whole code base and saw it appear in core and reported here:

https://www.drupal.org/project/drupal/issues/3128454#comment-13761766

I have linked to the final comment where contributors have found that this is actually an issue of phpcs as it is referring to the global /TimeTimeInterface rather than core's DateTimeInterface. They declared that it did not need to be fixed in Drupal core and thus presumeably not in this module either but instead in phpcs which needs to take into account namespace.

I am not sure myself and so thought it worth bringing it up for consideration.

Regards Rory