On 20/04/2016 22:02, Jesse Schalken wrote:
"instanceof" implies to me that the right hand side is a class/interface name, since that's what's expected with the "instanceof" operator, rather than a type. If I can do "Foo<T instanceof array<Bar>>" I would expect to be able to do "if ($t instanceof array<Bar>) ...", but I can't.
I'm not quite sure what bounds would mean for anything other than classes or interfaces. A generic type that specified that its type parameter must be an int seems to me to be a non-generic type, because nothing other than an int "is int". How is "class Foo<T is int> { public function __construct(T $arg) { ... } }" different from just saying "class Foo { public function __construct(int $arg) { ... } }"? (Unless there were some kind of overloading, such that you could also have Foo<T is float>, but please let's not go there...)
Note that generic arrays are out of scope of the current RFC anyway, so it's possible that "$t instanceof array<Bar>" could be added at the same time as "Foo<T instanceof array<Bar>>", presumably with the meaning that "array<SubClassOfBar>" would be considered to pass the check.
Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php