Skip to content

Nullable non-empty-string is coerced as nullable string #9

@EmilMassey

Description

@EmilMassey

I'm unable to use shape with nullable non-empty-string (as well as union(null(), non_empty_string()). I'm not sure if the issue is in the extension or in the phpstan itself.

/** @param array{foo: non-empty-string, bar: non-empty-string|null} $arr */
function test(array $arr) {}

$arr = shape([
  'foo' => non_empty_string(),
  'bar' => nullable(non_empty_string()),
])->coerce($input);

test($arr);

Expects: array{foo: non-empty-string, bar: non-empty-string|null}, array{foo: non-empty-string, bar: string|null}. given

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions