Psalm correctly detects that substr() may lead to an empty string:
Psalm output (using commit [16b24bd](https://github.com/vimeo/psalm/commit/16b24bd)):
INFO: [LessSpecificReturnStatement](https://psalm.dev/129) - 8:12 - The type 'string' is more general than the declared return type 'non-empty-string' for cut_to_4_chars
INFO: [MoreSpecificReturnType](https://psalm.dev/070) - 5:12 - The declared return type 'non-empty-string' for cut_to_4_chars is more specific than the inferred return type 'string'
I'm wondering if it's worth expanding the substr() signature so that it detects the non-empty-string case for a 0 index, and a positive length.
Given following snippet ( https://psalm.dev/r/7528930261 ) :
Psalm correctly detects that
substr()
may lead to an empty string:I'm wondering if it's worth expanding the
substr()
signature so that it detects thenon-empty-string
case for a0
index, and a positive length.