nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.
https://doc.nette.org/php-generator
Other
2.11k stars 138 forks source link

Support union type in `Type::nullable()` #141

Closed GromNaN closed 1 year ago

GromNaN commented 1 year ago

I did some benchmarks. in_array vs preg_replace approaches are almost identical in terms of performance (very fast). Got the simplest implementation with explode, in_array and array_diff.

dg commented 1 year ago

Thanks

dg commented 1 year ago

I've tweaked it a bit, to make it work case insensitive, because theoretically you can write Null or NULL in PHP, and to throw an exception on intersection type.