Re: [PHP-DEV] [Concept] Magic Casting

2016-12-05 Thread Rowan Collins
On 2 December 2016 13:37:20 GMT+00:00, Alex Bowers wrote: >Hello All, > >In PHP we currently have the ability to type hint classes in method >signatures, however, sometimes it would be useful to convert the items >to a >different instance / type. > >An example is collections and arrays. If impleme

Re: [PHP-DEV] [Concept] Magic Casting

2016-12-02 Thread Ivan Enderlin
Hello :-), Casting is already a very large surface of unsafety and bugs. Adding “magic” before this is like multiplying the surface by infinite. The only goal I see here is to save a `new Collection(…)`, and this is not a sufficient reason from my point of view. If `array` was a type, and `I

[PHP-DEV] [Concept] Magic Casting

2016-12-02 Thread Alex Bowers
Hello All, In PHP we currently have the ability to type hint classes in method signatures, however, sometimes it would be useful to convert the items to a different instance / type. An example is collections and arrays. If implemented properly, an array and a collection could be used interchangea