Skip to content

Union types#20

Merged
WendellAdriel merged 12 commits intophp-strictus:mainfrom
hungthai1401:union-types
Jun 23, 2023
Merged

Union types#20
WendellAdriel merged 12 commits intophp-strictus:mainfrom
hungthai1401:union-types

Conversation

@hungthai1401
Copy link
Member

@hungthai1401 hungthai1401 commented Jun 13, 2023

Hi @WendellAdriel ,
This PR introduces union types. I use flow chart to explain my implementation.

flowchart TD
    A[StrictusUnion] --> B{Validate Types}
    B -->|Yes| C{Validate Value}
    B -->|No| Z[StrictusTypeException]
    C -->|Yes| D{Detect Value Type}
    C -->|No| Z[StrictusTypeException]
    D -->|Int| E[StrictusInteger]
    D -->|String| G[StrictusString]
    D -->|Float| H[StrictusFloat]
    D -->|Boolean| I[StrictusBoolean]
    D -->|Array| K[StrictusArray]
    D -->|Object| L[StrictusObject]
    D -->|Class| M[StrictusInstance]
    D -->|Enum| N[StrictusEnum]
    D -->|No| Z[StrictusTypeException]
    A[StrictusUnion] --> F[Update Value] --> O{Immutable}
    O -->|Yes| Y[ImmutableStrictusException]
    O -->|No| C
Loading

Greetings and thanks,
Thai

Copy link
Member

@WendellAdriel WendellAdriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the changes requested, you need to add the needed docs for the Union types

@WendellAdriel
Copy link
Member

@hungthai1401 thanks for the PR.
I added some observations.

Also, please beware that as we put in the Contributing Guide, before creating a whole new feature that's a big change like this one, an issue or a discussion should be used to discuss it first. We have a discussion open on this topic, before sending the PR you could have sent your idea there first.

@hungthai1401
Copy link
Member Author

@WendellAdriel I got it. I have fixed your comments

@hungthai1401
Copy link
Member Author

@WendellAdriel I have fixed them

Copy link
Member

@WendellAdriel WendellAdriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the help with this, @hungthai1401!!!

@WendellAdriel WendellAdriel merged commit 3c03491 into php-strictus:main Jun 23, 2023
@hungthai1401
Copy link
Member Author

@WendellAdriel hope we can develop more features!!!

@hungthai1401 hungthai1401 deleted the union-types branch June 26, 2023 10:00
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

Successfully merging this pull request may close these issues.

2 participants