Skip to content

Commit db59c8e

Browse files
committed
Add test to ensure fromArray casts mixed scalars to strings
1 parent 29ee488 commit db59c8e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/Unit/Usage/Example/ArrayOfStringsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@
7575
expect(fn() => new ArrayOfStrings($bad))
7676
->toThrow(StringTypeException::class, 'Expected array of StringNonEmpty or Undefined instance');
7777
});
78+
79+
it('casts mixed scalars to strings in fromArray', function (): void {
80+
// Without explicit (string) cast inside fromArray, this would fail under strict types
81+
$a = ArrayOfStrings::fromArray([123, 45.6, '789']);
82+
expect($a->toArray())->toBe(['123', '45.6', '789']);
83+
});

0 commit comments

Comments
 (0)