Re: Countable Type Hint

From: Date: Tue, 22 Nov 2016 03:41:54 +0000
Subject: Re: Countable Type Hint
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-97111@lists.php.net to get a copy of this message
Hi! > Nothing prevents it? As far as I'm aware there's no current way to type > hint Countable or array. No, there's not - as there's no way to make other complex type conditions as type. You still can check for it, or just use count(). > How would one add an interface that includes Countable and arrays? You can not add interface that includes multiple types. Neither should you, that's not what interfaces are for. Inventing one-off complex type expressions for one-off cases just makes language more complex and less consistent. It's not a good direction to develop, and it serves very narrow use case which can easily be served by simple code. -- Stas Malyshev smalyshev@gmail.com

« previous php.internals (#97111) next »