Get the latest tech news

PHP compile time generics: yay or nay?


The PHP Foundation — Supporting, Advancing, and Developing the PHP Language

Arnaud and Larry Garfield did further investigation afterward into introducing a "module" system that would help PHP's compiler see more code at once, and thus be able to do type inference more readily, but sadly that also ran into many challenging edge cases. Initially, it was intended as an alternative to the never parameters RFC, offering a better solution to the case of an interface that doesn't need to specify a particular type, but implementing classes do. As noted above, though, typing against a generic that is part of a union, like public function setRepository(Repository<UserEntity>|null $repo) {}, is probably possible in a follow-up RFC.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of php

php

Photo of yay

yay

Photo of nay

nay

Related news:

News photo

After 30 years PHP still evolving: Team adds pipe operator, considers generics

News photo

Exploring Coroutines in PHP

News photo

Show HN: I reinvented PHP in TypeScript (demo)