From b8a7b48278d2b1cfb19fd2e26b9375b3c4f83bb5 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 21 Jan 2025 12:28:37 +0100 Subject: [PATCH] Allow `int` parts in `StringUtil::joinNonEmpty` --- CHANGELOG.md | 6 ++++++ src/StringUtil.php | 2 +- tests/StringUtilTest.php | 10 +++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8904380..26c1deb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/php-utils/releases). ## Unreleased +## v5.11.0 + +### Added + +- Allow `int` parts in `StringUtil::joinNonEmpty` + ## v5.10.0 ### Added diff --git a/src/StringUtil.php b/src/StringUtil.php index e3a291f..7e41148 100644 --- a/src/StringUtil.php +++ b/src/StringUtil.php @@ -21,7 +21,7 @@ class StringUtil /** https://en.wikipedia.org/wiki/Byte_order_mark#UTF-32 */ public const UTF_32_LITTLE_ENDIAN_BOM = "\xFF\xFE\x00\x00"; - /** @param iterable $parts */ + /** @param iterable $parts */ public static function joinNonEmpty(string $glue, iterable $parts): string { $nonEmptyParts = []; diff --git a/tests/StringUtilTest.php b/tests/StringUtilTest.php index 5cf423e..c0ac9bc 100644 --- a/tests/StringUtilTest.php +++ b/tests/StringUtilTest.php @@ -12,7 +12,7 @@ final class StringUtilTest extends TestCase /** * @dataProvider joinNonEmpty * - * @param iterable $parts + * @param iterable $parts */ #[DataProvider('joinNonEmpty')] public function testJoinNonEmpty(string $expectedJoined, string $glue, iterable $parts): void @@ -23,12 +23,12 @@ public function testJoinNonEmpty(string $expectedJoined, string $glue, iterable ); } - /** @return iterable}> */ + /** @return iterable}> */ public static function joinNonEmpty(): iterable { - yield ['a b', ' ', ['a', null, '', 'b']]; - yield ['ab', '', ['a', null, '', 'b']]; - yield ['a,b', ',', new Collection(['a', null, '', 'b'])]; + yield ['a b 0', ' ', ['a', null, 'b', '', 0]]; + yield ['ab1', '', ['a', null, '', 'b', 1]]; + yield ['a,b,2', ',', new Collection(['a', 'b', 2, null, ''])]; } /** @dataProvider shortenFirstname */