Skip to content

Optional property return type with a default value is nullable #33

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

Closed
wol-soft opened this issue Feb 3, 2021 · 0 comments
Closed

Optional property return type with a default value is nullable #33

wol-soft opened this issue Feb 3, 2021 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@wol-soft
Copy link
Owner

wol-soft commented Feb 3, 2021

Only applies if the option implicitNull is not enabled. If no default value is provided the property must be nullable (value is null if no value is provided). If implicitNull is enabled the return type must also be nullable as optional properties with this option accept null.

{
    "type": "object",
    "properties": {
        "test": {
            "type": "boolean",
            "default": false
    }
}

Expected interface:

public function getTest(): bool;

Generated interface:

public function getTest(): ?bool;
@wol-soft wol-soft added the bug Something isn't working label Feb 3, 2021
wol-soft added a commit that referenced this issue Feb 4, 2021
…d implicitNull is disabled (#33)

Render mixed as type annotation for properties which don't provide type information
Fix the output of generated files (contained double slashes for top level classes)
@wol-soft wol-soft self-assigned this Feb 4, 2021
@wol-soft wol-soft added this to the 0.20.0 milestone Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant