Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty array is not supported #306

Open
danog opened this issue Dec 27, 2022 · 0 comments
Open

Empty array is not supported #306

danog opened this issue Dec 27, 2022 · 0 comments

Comments

@danog
Copy link
Contributor

danog commented Dec 27, 2022

<?php

use CuyZ\Valinor\MapperBuilder;

require 'vendor/autoload.php';

final class a {

    /**
     * @param array{a: int}|array<never, never> $a
     */
    public function __construct(
        public readonly array $a,
    ) {
    }
}

(new MapperBuilder)->mapper()->map(a::class, []);

Throws:

PHP Fatal error:  Uncaught CuyZ\Valinor\Mapper\TypeTreeMapperError: Could not map type `a`. An error occurred at path *root*: Cannot be empty and must be filled with a value matching type `array{a: int}|array<never, never>`. in /home/daniil/repos/valinor/src/Mapper/TypeTreeMapper.php:29
@danog danog changed the title Union of shaped array with empty array is not collapsed into all-optional array Empty array is not supported Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant