Review main Merged

84416[TASK] Avoid implicitly nullable class method parameter

Stefan Bürk CR +2 V +2 Easy +10 −4 updated 05/27/24, 12:52

Commit message

With PHP 8.4 marking method parameter implicitly nullable
is depreacted and will emit a `E_DEPRECATED` warning. One
recommended way to resolve this, is making it explicitly
nullable using the `?` nullable operator. [1]

In cases, where are implicitly nullable parameter exists
before not-nullable parameters in a method or constructor,
making it explicitly nullable will emit a

  Optional parameter <paramname> declared before required
  parameter <paramname> is implicitly treated as a required
  parameter

since PHP 8.0 [2].

This change adds the `?` nullable operator and removes the
null default value for the first parameter, which mitigates
both issues.

This prepares the way towards PHP 8.4 compatibility.

[1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated
[2] https://php.watch/versions/8.0/deprecate-required-param-after-optional

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Benjamin Franzke +1
    • Oliver Klee +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Benjamin Franzke +1
    • Oliver Klee +1
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1013

  1. Stefan Bürk uploaded patch set 1 05/26/24, 20:58

  2. core-ci voted on patch set 1 V +1 05/26/24, 21:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58291

  3. Stefan Bürk uploaded patch set 2 V +1 05/26/24, 21:21

  4. core-ci voted on patch set 2 V -1 05/26/24, 21:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58296

  5. Benjamin Franzke commented on patch set 2 CR -1 05/27/24, 08:16

    FileStorageIndexingAdditionalFieldProvider.php:63

    This should still trigger the mentioned 8.4 deprecation, as it is not marked nullable. I think the signature could/should just be changed to: ``` protected function getAllStoragesField( ?FileStorageIndexingTask $task, array $taskInfo ): array ```

    FileStorageIndexingAdditionalFieldProvider.php:63

    why is this now passed by reference?
  6. Stefan Bürk uploaded patch set 3 CR -1 V -1 05/27/24, 10:23

  7. Stefan Bürk commented on patch set 3 05/27/24, 10:23

    FileStorageIndexingAdditionalFieldProvider.php:63 Reply

    Adopted from calling method. Call by reference not needed here, ack.

    FileStorageIndexingAdditionalFieldProvider.php:63 Reply

    Forgot to add the nullable operator `?`. However, changed to your suggestion.
  8. core-ci voted on patch set 3 V +1 05/27/24, 10:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58334

  9. Oliver Klee voted on patch set 3 CR +1 V +1 05/27/24, 10:34

  10. Benjamin Franzke voted on patch set 3 CR +1 V +1 05/27/24, 12:07

  11. Christian Kuhn voted on patch set 3 CR +1 V +1 05/27/24, 12:11

  12. Stefan Bürk voted on patch set 3 CR +2 V +2 05/27/24, 12:17

  13. Stefan Bürk merged patch set 4 05/27/24, 12:52