Skip to content

Commit

Permalink
[TASK] Improve return type annotations for GU::trimExplode
Browse files Browse the repository at this point in the history
This particularly helps PHPStan in extensions that call those methods
detect unnecessary checks for empty strings if
`GU::trimExplode` is called with `$removeEmptyValues = true`.

Used command:

> ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #101395
Related: #99147
Releases: main, 12.4, 11.5
Change-Id: I6945cc0698b0777a05cb9327b342aa9aa7dee098
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80137
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
oliverklee authored and lolli42 committed Jul 25, 2023
1 parent 414b3e9 commit b60bc41
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Build/phpstan/phpstan-baseline.neon
Expand Up @@ -246,12 +246,12 @@ parameters:
path: ../../typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php

-
message: "#^Offset 'tables_modify' on array\\{tables_select\\: array\\<string, mixed\\>, tables_modify\\: array\\<string, mixed\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#"
message: "#^Offset 'tables_modify' on array\\{tables_select\\: array\\<non\\-empty\\-string, mixed\\>, tables_modify\\: array\\<non\\-empty\\-string, mixed\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: ../../typo3/sysext/beuser/Classes/Service/UserInformationService.php

-
message: "#^Offset 'tables_select' on array\\{tables_select\\: array\\<string, mixed\\>, tables_modify\\: array\\<string, mixed\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#"
message: "#^Offset 'tables_select' on array\\{tables_select\\: array\\<non\\-empty\\-string, mixed\\>, tables_modify\\: array\\<non\\-empty\\-string, mixed\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: ../../typo3/sysext/beuser/Classes/Service/UserInformationService.php

Expand Down
1 change: 1 addition & 0 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -925,6 +925,7 @@ public static function revExplode($delimiter, $string, $limit = 0)
* the last element containing the rest of string. If the limit parameter is negative, all components
* except the last -limit are returned.
* @return list<string> Exploded values
* @phpstan-return ($removeEmptyValues is true ? list<non-empty-string> : list<string>) Exploded values
*/
public static function trimExplode($delim, $string, $removeEmptyValues = false, $limit = 0): array
{
Expand Down

0 comments on commit b60bc41

Please sign in to comment.