Re: Countable Type Hint

From: Date: Thu, 17 Nov 2016 14:06:04 +0000
Subject: Re: Countable Type Hint
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-96952@lists.php.net to get a copy of this message
On Thu, Nov 17, 2016 at 2:01 PM Craig Duncan <php@duncanc.co.uk> wrote: > On 17 November 2016 at 13:50, Josh Di Fabio <joshdifabio@gmail.com> wrote: > > What's the benefit of such an interface? Why not simply ask for `int > $count` in your param list instead? > > > Using the example from my original email, it's a bit awkward to always > have to pass the count of a countable: > handle_records($result, count($result)); > > The number of items in a countable can be established from the countable, > asking for it as a additional parameter doesn't make much sense to me > > Apologies, I thought you were simply proposing the following: interface Countable { function count(): int; } But you're actually proposing the following as well? interface Arraylike extends Iterator, Countable { } I can see the use of an interface which combines Iterator and Countable, but not Countable on its own.

« previous php.internals (#96952) next »