Skip to content

Commit 248a58f

Browse files
committed
map: document that strict built-ins throw TypeError on null/numeric elements
Same note as SmartString's map(): elements arrive raw in their original types, so built-ins that require a string fatal on null or numbers - chain ->map('strval') first.
1 parent 015e2a5 commit 248a58f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/SmartArrayBase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ public function implode(string $separator = ''): SmartString|string
893893
* because extra arguments break them: strtoupper() throws ArgumentCountError,
894894
* intval() would read $key as its $base parameter.
895895
*
896+
* Built-ins that require a string throw TypeError on null or numeric elements;
897+
* chain ->map('strval') first to convert.
898+
*
896899
* $rows->map(strtoupper(...)); // ($value) only - internal function
897900
* $rows->map('strtoupper'); // ($value) only - internal function
898901
* $rows->map(fn($v) => ucfirst($v)); // ($value, $key) - unused args are ignored

0 commit comments

Comments
 (0)