Re: Introducing "Array Of" RFC

From: Date: Thu, 16 Jan 2014 10:04:42 +0000
Subject: Re: Introducing "Array Of" RFC
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-71173@lists.php.net to get a copy of this message
On 15 January 2014 21:24, Lars Strojny <lars@strojny.net> wrote: > Given I hint for Foo[], and pass [new Foo(), new Bar(), new Baz()] it will > only inform me about Bar violating Foo. I would like to have a more descriptive > error message that contains both Bar and Baz. While I see where you're coming from with this, it's non-trial to implement this in a sane way, both in code and to handle every possible scenario in a logical way. Suppose I pass an array or 10000 objects which instances of 10000 different classes which do not satisfy the type hint? I guess you'd want to do something like <= 3 offenders - give their class names and indices > 3 offenders - give an error along the lines "passed array elements are completely > wrong" (or maybe report first three and append a "and other errors") ...but IMO the complexity this would add is not worth the effort. From a consistency point of view it should just use the same error logic as the shiny new variadics feature - which also bails out at the first offender. Thanks, Chris

« previous php.internals (#71173) next »