Problem/Motivation

getWidth() and getHeigth() methods in the image system shoud return int or null, but getimagesize() returns an array with width and height as strings.

This causes problems because the returned type is not as expected and any downstream code that uses strict typing may fail with TypeErrors.

Proposed resolution

Build around the process for adding new arguments described in https://www.drupal.org/about/core/policies/core-change-policies/how-to-d... to extend it to manage return typehints:

  1. pre-typehint the return types in the interfaces so that in Drupal 12 these could be finalized
  2. add an issue to do the change to the interfaces in next major
  3. typehint return types in implementing classes
  4. add tests where appropriate

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3470913

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

mondrake created an issue. See original summary.

mondrake’s picture

Issue summary: View changes

mondrake’s picture

Issue summary: View changes
Status: Active » Needs review
andypost’s picture

Looks good but probably needs 12.x issue to remove commented out type and phpcs:disable

mondrake’s picture

Issue summary: View changes
mondrake’s picture

andypost’s picture

Thanks, looks ready except phpcs:disable Drupal.Commenting probably as docs said

mondrake’s picture

Fixed, thank you

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

* : ?int */;

Not super familiar with examples like this but know I've seen it in parameters before.

Code wise believe this is good. But can a CR be added just in case there are some this may impact later.

mondrake’s picture

Status: Needs work » Postponed

I think it's better wait on Symfony's [ErrorHandler] Add support for @return-type-will-change PR at this stage, that will provide a clear deprecation message for the need to introduce the typehint.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.