Skip to content

Commit

Permalink
[!!!][TASK] Add native type declarations to GU array methods
Browse files Browse the repository at this point in the history
Resolves: #101453
Related: #101305
Releases: main
Change-Id: I34598bfe33ac385f82c78cb5ee74686523a07ade
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75083
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan B�rk <stefan@buerk.tech>
  • Loading branch information
oliverklee authored and sbuerk committed Jul 28, 2023
1 parent 6a6b59f commit 3af7d2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 6 additions & 6 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -731,7 +731,7 @@ public static function isValidUrl(string $url): bool
* @param bool $removeEmptyValues If set, all empty values (='') will NOT be set in output
* @return array<int, int> Exploded values, all converted to integers
*/
public static function intExplode($delimiter, $string, $removeEmptyValues = false)
public static function intExplode(string $delimiter, string $string, bool $removeEmptyValues = false): array
{
$result = explode($delimiter, $string);
foreach ($result as $key => &$value) {
Expand Down Expand Up @@ -763,7 +763,7 @@ public static function intExplode($delimiter, $string, $removeEmptyValues = fals
*
* @return list<string> Exploded values
*/
public static function revExplode($delimiter, $string, $limit = 0)
public static function revExplode(string $delimiter, string $string, int $limit = 0): array
{
// 2 is the (currently, as of 2014-02) most-used value for `$limit` in the core, therefore we check it first
if ($limit === 2) {
Expand Down Expand Up @@ -798,9 +798,9 @@ public static function revExplode($delimiter, $string, $limit = 0)
* @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
public static function trimExplode(string $delim, string $string, bool $removeEmptyValues = false, int $limit = 0): array
{
$result = explode($delim, (string)$string);
$result = explode($delim, $string);
if ($removeEmptyValues) {
// Remove items that are just whitespace, but leave whitespace intact for the rest.
$result = array_values(array_filter($result, static fn (string $item): bool => trim($item) !== ''));
Expand Down Expand Up @@ -836,7 +836,7 @@ public static function trimExplode($delim, $string, $removeEmptyValues = false,
* @return string Imploded result, fx. &param[key][key2]=value2&param[key][key3]=value3
* @see explodeUrl2Array()
*/
public static function implodeArrayForUrl($name, array $theArray, $str = '', $skipBlank = false, $rawurlencodeParamName = false)
public static function implodeArrayForUrl(string $name, array $theArray, string $str = '', bool $skipBlank = false, bool $rawurlencodeParamName = false): string
{
foreach ($theArray as $Akey => $AVal) {
$thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
Expand Down Expand Up @@ -869,7 +869,7 @@ public static function implodeArrayForUrl($name, array $theArray, $str = '', $sk
* @return array<array-key, string> Array of values. All values AND keys are rawurldecoded() as they properly should be. But this means that any implosion of the array again must rawurlencode it!
* @see implodeArrayForUrl()
*/
public static function explodeUrl2Array($string)
public static function explodeUrl2Array(string $string): array
{
$output = [];
$p = explode('&', $string);
Expand Down
Expand Up @@ -2,11 +2,11 @@

.. _breaking-101305-1689059968:

================================================================================================
Breaking: #101305 - Introduce type declarations for networking-related methods in GeneralUtility
================================================================================================
==================================================================================
Breaking: #101305 - Introduce type declarations for some methods in GeneralUtility
==================================================================================

See :issue:`101305`
See :issue:`101305`, :issue:`101453`

Description
===========
Expand All @@ -18,12 +18,17 @@ methods of :php:`\TYPO3\CMS\Core\Utility\GeneralUtility`:
- :php:`cmpIP`
- :php:`cmpIPv4`
- :php:`cmpIPv6`
- :php:`explodeUrl2Array`
- :php:`getUrl`
- :php:`implodeArrayForUrl`
- :php:`intExplode`
- :php:`isOnCurrentHost`
- :php:`isValidUrl`
- :php:`locationHeaderUrl`
- :php:`normalizeIPv6`
- :php:`revExplode`
- :php:`sanitizeLocalUrl`
- :php:`trimExplode`
- :php:`validEmail`
- :php:`validIP`
- :php:`validIPv4`
Expand Down

0 comments on commit 3af7d2e

Please sign in to comment.