Re: What do we need strict scalar type hints for?

From: Date: Mon, 02 Feb 2015 16:47:49 +0000
Subject: Re: What do we need strict scalar type hints for?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-81606@lists.php.net to get a copy of this message
Hi Dmitry, It's preferred to have flexible scalars, that way we can interchange between a numerical string or an integer. Over defining on such things loses the powerfulness of PHP. So scalar typehints are detrimental rather than useful. Saying something is a scalar or not, is useful however! :) A use case would be where scalar type hints are detrimental are: I implement an API that returns integers for entity ids, like 2,3,4,5,6. and my web-frontend handles this fine because it's a scalar. Then, you want to convert entity ids to UUID. This would break your entire web frontend application since it's no longer "integer" whereas the concept of $id is good enough. Did this make sense? TL;DR - I am against such proposals. Many thanks, Paul On Mon, Feb 2, 2015 at 9:12 AM, Dmitry Stogov <dmitry@zend.com> wrote: > hi, > > could you please write down few use cases, when strict scalar type hints > are really useful. > > Thanks. Dmitry. >

« previous php.internals (#81606) next »