Watch Chris Holland's International PHP Conference session

A Case for Generics in PHP

JAXenter Editorial Team

Avoiding surprise-ducks at run-time… PHP 7 has brought us improved support for types, making us less reliant upon annotations. Yet we still can’t say function foo() : User[] What makes an array of users so special? What if we’d like to return a HashMap of a given key & value? We’ll explore use cases for defining composite objects and leveraging generics to avoid repeating ourselves.

In 2016, Ben Scholzen and Rasmus Schultz drafted an RFC for “Generics in PHP”. Having worked with these constructs in Java and C# in past lives, Chris Holland can offer several examples of practical use-cases for them, and help bolster a case for their adoption in PHP. In the end, we should arrive at how they would nicely complement the most recent enhancements to PHP 7’s type system.


phpChris Holland leads a small software engineering team at an HR company. Throughout a career spanning more than twenty years, Chris has held Sr. engineering and leadership roles for small and large successful publicly-traded companies such as EarthLink and Internet Brands, serving business models across content, commerce, travel and finance on a wide variety of technology stacks including PHP/LAMP, Java/J2EE and C#/.Net, catering to audiences of over 100 million monthly visitors.

    PHP Conference Whitepaper

    The ultimate PHP Knowledge

    PHP Whitepaper Selection

    In our exclusive IPC Whitepaper Selection, we have compiled over 40 pages of combined knowledge. Here you will find everything about the topics Security, PHP Core, Architecture, PHP Frameworks, CMS, and Web Development. Download it to be able to expand your expertise about what’s happening in the world of PHP.

Inline Feedbacks
View all comments