We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
PHP's type system dissected? - George Peter Banyard
PHP's type system demystified: Learn about subtyping, invariance, union and intersection types, and more, and discover how to improve PHP's handling of numeric strings, objects, and complex data types.
- Type system is complex and has many edge cases. George argues that PHP’s type system is not as simple as people think, and that many features are not well documented or understood.
- The concept of subtyping is crucial to understand how types relate to each other. George explains that a subtype is a type that is a “subset” of another type.
- The Liskov Substitution Principle (LSP) states that subtypes must be substitutable for their base types. However, PHP’s type system does not always enforce this principle.
- George emphasizes the importance of understanding the concept of invariance, which is the property that a type’s behavior remains the same even when its internal state changes.
- The concept of union types is also discussed, which allows a type to have multiple possible values.
- George criticizes PHP’s handling of numeric strings, which can be converted to integers or floats, leading to unexpected behavior.
- He also criticizes the handling of increment and decrement operators on objects, which can lead to unexpected behavior.
- George argues that PHP’s type system is overly complex and some features are not well documented or understood.
- He also discusses the concept of intersection types, which allow multiple types to be combined into a single type.
- George argues that intersection types are more powerful than union types because they allow more flexibility and precision in type definitions.
- He also discusses the concept of DNF types, which are a type of type that can be defined in disjunctive normal form.
- George argues that PHP’s type system is not well suited for handling complex data types and that the language needs to be improved in this area.
- He also discusses the importance of understanding the concept of subtyping and the Liskov Substitution Principle.
- George argues that PHP’s type system is difficult to understand and that the language needs to be simplified.
- He also discusses the concept of type aliases, which can be used to rename types.
- George argues that type aliases are not well supported in PHP and that the language needs to be improved in this area.
- He also discusses the concept of nullable types, which can be used to indicate that a type may be null.
- George argues that nullable types are not well supported in PHP and that the language needs to be improved in this area.
- He also discusses the concept of iterable types, which can be used to iterate over a collection of values.
- George argues that iterable types are not well supported in PHP and that the language needs to be improved in this area.