Use PHP 8.0 union types #89
Labels
platform/php-7.4
Issues related specifically to running php-cypher-dsl on PHP 7.4
subject/typing
Issues related to the type system
type/enhancement
New feature or request
type/refactoring
A refactoring that should be applied to make the code easier to understand
Milestone
PHP 8.0 introduces the concept of union types, which allows us to explicitly type a function with multiple different types. php-cypher-dsl currently polyfills this feature through the
ErrorTrait
trait. However, there are a few problems with this polyfill approach:Therefore, I want to propose to drop support for PHP 7.4 and start using PHP 8.0 union types. Implementing this is relatively straightforward:
ErrorTrait
trait.The
ErrorTrait
trait also has a method for checking whether the type of each value in an array is allowed. This is currently not supported through PHP's type system. There are two options to fix this:array
type in signatures, orI think the first option is best. Type checking of arrays is only used in a few places (five times throughout the entire library), and it adds complexity and overhead. Most usages can also be replaced by typed variadic parameters.
The text was updated successfully, but these errors were encountered: