KS5005
Un valore ha un tipo sbagliato per ciò che gli viene fatto. Ad esempio ->upper() su un numero. Convertilo prima: $n->to_string()->upper().
Un parametro di callback dichiarato action: fn richiede una funzione. Passare action: null produce un errore sull'argomento. Passa un riferimento come action: @on_connect o una lambda come action: fn(session) => @read_status($session). In una funzione di script, action: fn? = null accetta esplicitamente un callback mancante o null.
Lo stesso codice segnala avvisi per aritmetica e argomenti che possono fallire solo quando lo script viene eseguito:
<let name="name" value="'Joan'" />
<let name="total" value="$name - 1" /> <!-- warning: '-' needs a number here, but $name holds the text 'Joan' -->
<set name="total" value="[1, 2] + 3" /> <!-- warning: + joins two lists. Use ->push(3) -->
<echo value="'ab'->repeat('x')" /> <!-- warning: the 'count' argument needs a number -->$name = 'Joan'
$total = $name - 1 // warning: '-' needs a number here, but $name holds the text 'Joan'
$total = [1, 2] + 3 // warning: + joins two lists. Use ->push(3)
echo 'ab'->repeat('x') // warning: the 'count' argument needs a numberIl testo che si legge come numero viene convertito ('5' - 1 vale 4), + unisce testi e 'ab' * 3 ripete un testo, quindi nessuno di questi genera un avviso. Il controllo interviene solo quando il valore è certo: testo scritto nel codice o una variabile che contiene sempre solo quello.