Hi Ben & Internals, I spent most of today and yesterday just getting used to the parser language. I was able to implement the basic syntax on most of the constructs, just to get a partial proof of concept going.
https://github.com/orolyn/php-src/commit/ee731240eab1e5986152cadaaca6d3e5b921ba7d The generic patterns aren't actually used, this simply "allows" them to be present. Also I haven't yet cleaned up the memory leaks. The hitch I ran into however was function calls. add_to_collection<MyClass>($collection, $object); // Sorry for the rather pointless example. This potentially matches an expression, therefore yacc can't use it. Another (minor) but annoying issue is that nested generics need to be written like: A<T<V> > // Note the space before the last '>' Else it will match T_SL I don't know if either of these issues can be neatly corrected, ##parsers told me it was impossible without some major hackery, so this might warrant discussion on the tokens used to define generic delimitation. Anyway see parsable example below. Dominic <?php // T = placeholder for syntax texting interface Y {} interface Z extends Y<T> {} class K {} class A extends K<T> implements Y, Z<T<T> > { public function add<T>(K<J> > $a): Y<T> { } } function sample<T>(A<T> $a) { echo 'OK' . PHP_EOL; } sample(new A());