Skip to content

Assert\Type constraint on natively typed property : is it useless ? #54330

Answered by MatTheCat
gnutix asked this question in Q&A
Discussion options

You must be logged in to vote

General Kenobi 🤖

There are only two behaviors when setting a value to a differently-typed property: either it crashes, or the value is silently converted to the property type (false being converted to an empty string e.g.).

That means the only case where the property is assigned, you’re guaranteed its value has the correct type. As such, the Type constraint won’t serve any purpose.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gnutix
Comment options

@MatTheCat
Comment options

@gnutix
Comment options

Answer selected by gnutix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants