Project

General

Profile

Actions

Bug #94799

closed

Using PHP 7.4 syntax in a 7.2 compatible TYPO3 version example

Added by Tomas Norre Mikkelsen over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-08-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The example https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.5.x/Important-94484-IntroduceHTMLSanitizer.html#php-api uses PHP 7.4 syntax

...$this->globalAttrs

I would prefer having PHP 7.2 compatible syntax, as this is introduced in a TYPO3 Version that still supports PHP 7.2

In general, I'm a little unsure about the example.

As I see it, the `withTags` and the `withAttrs` should both be arrays of Tags and Attrs respectively. That's not the case how I read the example.

Actions #1

Updated by Oliver Hader over 3 years ago

Variadic functions and the splat operator ... has been introduced with PHP 5.6 already, see https://www.php.net/manual/en/migration56.new-features.php

https://3v4l.org/eLAaH#v5.6.40

Actions #2

Updated by Oliver Hader over 3 years ago

  • Parent task set to #94787
Actions #3

Updated by Oliver Hader over 3 years ago

The general benefit of using variadic is type-safety, just compare the following examples which would do the same:

$items = [new Subject('a'), new Subject('b'), new Subject('c')];

function processArray(array $subjects) { ... }
processArray($items);

function processVariadic(Subject ...$subjects) { ... }
processVariadic(...$subjects);
// not using array wrapped in [] here
processVariadic(new Subject('a'), new Subject('b'), new Subject('c'));
Actions #4

Updated by Oliver Hader over 3 years ago

  • Status changed from New to Needs Feedback
Actions #5

Updated by Tomas Norre Mikkelsen over 3 years ago

ok. My bad. Strange that my PHPStorm complained about it, and said it could switch to PHP 7.4.

I Will look into before give more feedback

Actions #6

Updated by Tomas Norre Mikkelsen over 3 years ago

Please close this again, I was wrong.

I didn't find the option to close it myself.

Actions #7

Updated by Oliver Hader over 3 years ago

  • Status changed from Needs Feedback to Closed

Thanks for your feedback. Closed issue as requested.

Actions #8

Updated by Oliver Hader over 3 years ago

  • Parent task deleted (#94787)
Actions

Also available in: Atom PDF