demos-europe / edt

Enables your PHP application to expose its entities as REST resources using the feature rich JSON:API specification as API. How and to whom your entities are exposed is highly customizable while minimizing boilerplate code.
MIT License
2 stars 1 forks source link

Prefer `non-empty-list` over variable length argument lists #151

Open joorei opened 3 months ago

joorei commented 3 months ago

Before the commitment on phpstan and its types, signatures like the following were used to ensure that at least one value was provided.

function(string $head, string... $tail)

This has no serious drawbacks, but using the following approach is more simple and conveys the intention better, even though it will not automatically provide a "break hard, break early" behavior:

/**
 * @param non-empty-list<string> $values
 */
function(array $values)

The signatures that need to be adjusted are marked with (#151) in the source code.