| Methods |
public
|
__construct(array<string, array{Expr, Type}> $sureTypes = [], array<string, array{Expr, Type}> $sureNotTypes = [])
|
#
|
public
|
setAlwaysOverwriteTypes(): self
Normally, $sureTypes in truthy context are used to intersect with the pre-existing type.
And $sureNotTypes are used to remove type from the pre-existing type. Example: By default, non-empty-string intersected with '' (ConstantStringType) will lead to NeverType.
Because it's not possible to narrow non-empty-string to an empty string. In rare cases, a type-specifying extension might want to overwrite the pre-existing types
without taking the pre-existing types into consideration. In that case it should also call setAlwaysOverwriteTypes() on
the returned object. ! Only do this if you're certain. Otherwise, this is a source of common bugs. !
Normally, $sureTypes in truthy context are used to intersect with the pre-existing type.
And $sureNotTypes are used to remove type from the pre-existing type. Example: By default, non-empty-string intersected with '' (ConstantStringType) will lead to NeverType.
Because it's not possible to narrow non-empty-string to an empty string. In rare cases, a type-specifying extension might want to overwrite the pre-existing types
without taking the pre-existing types into consideration. In that case it should also call setAlwaysOverwriteTypes() on
the returned object. ! Only do this if you're certain. Otherwise, this is a source of common bugs. !
|
#
|
public
|
setRootExpr(?Expr $rootExpr): self
|
#
|
public
|
getSureTypes(): array<string, array{Expr, Type}>
|
#
|
public
|
getSureNotTypes(): array<string, array{Expr, Type}>
|
#
|
public
|
intersectWith(SpecifiedTypes $other): self
The either-branch merge: the result holds when at least one side holds
(the falsey narrowing of &&, the truthy narrowing of ||). Same-kind
constraints merge exactly (sure: union of values, sure-not: intersection
of removed types); an expression constrained with different kinds on the
two sides becomes an alternative-form entry - (sure ?? current) minus subtract per side, united at the application point. An expression
constrained on only one side is unconstrained in the merge.
The either-branch merge: the result holds when at least one side holds
(the falsey narrowing of &&, the truthy narrowing of ||). Same-kind
constraints merge exactly (sure: union of values, sure-not: intersection
of removed types); an expression constrained with different kinds on the
two sides becomes an alternative-form entry - (sure ?? current) minus subtract per side, united at the application point. An expression
constrained on only one side is unconstrained in the merge.
|
#
|
public
|
unionWith(SpecifiedTypes $other): self
|
#
|