Based on conversations here and elsewhere on the internet, I'd like to
put forward a rough gameplan for scalar types which I hope addresses
most concerns. This is back-of-the-napkin and I'm not asking for a
committed yes/no, just pre-rfc set of thoughts.
Please don't get hung up on specific names
On Tue, Feb 17, 2015 at 11:03 PM, Sara Golemon wrote:
> Based on conversations here and elsewhere on the internet, I'd like to
> put forward a rough gameplan for scalar types which I hope addresses
> most concerns. This is back-of-the-napkin and I'm not asking for a
> committed yes/no, just pre-
On 02/17/2015 04:35 PM, Nikita Popov wrote:
> I don't buy into Rasmus arguments about internal functions. They concern
> one particular edge case (int->float coercion) and I doubt they have much
> relevance if applied to codebases with pervasive use of typehints (where
> you can be reasonably sure
On Tue, Feb 17, 2015 at 4:35 PM, Nikita Popov wrote:
> I don't like the way this is heading with regards to internal functions.
> Apart from better inter-compatibility, the primary appeal of Andrea's
> proposal was that we have the option to make not only userland function
> calls strict, but inte
On Wed, Feb 18, 2015 at 1:53 AM, Rasmus Lerdorf wrote:
> On 02/17/2015 04:35 PM, Nikita Popov wrote:
> > I don't buy into Rasmus arguments about internal functions. They concern
> > one particular edge case (int->float coercion) and I doubt they have much
> > relevance if applied to codebases wit
On Tue, Feb 17, 2015 at 5:05 PM, Nikita Popov wrote:
> This is exactly what I fear will happen with an arginfo based approach. If
> even fundamental aspects like the "123" vs 123 (or true vs 1) distinction
> are suppressed for internal functions, this isn't a strict typing mode, it's
> just a weak
On Wed, Feb 18, 2015 at 4:05 AM, Nikita Popov wrote:
> On Wed, Feb 18, 2015 at 1:53 AM, Rasmus Lerdorf
> wrote:
>
> > On 02/17/2015 04:35 PM, Nikita Popov wrote:
> > > I don't buy into Rasmus arguments about internal functions. They
> concern
> > > one particular edge case (int->float coercion)
> -Original Message-
> From: Nikita Popov [mailto:nikita@gmail.com]
> Sent: Wednesday, February 18, 2015 3:06 AM
> To: Rasmus Lerdorf
> Cc: Sara Golemon; PHP internals
> Subject: Re: [PHP-DEV] Scalar Type Hints v0.4
>
> The inability to implicitly cast "1
Hi,
On Wed, Feb 18, 2015 at 9:00 AM, Zeev Suraski wrote:
>> -Original Message-
>> From: Nikita Popov [mailto:nikita@gmail.com]
>> Sent: Wednesday, February 18, 2015 3:06 AM
>> To: Rasmus Lerdorf
>> Cc: Sara Golemon; PHP internals
>> Subject:
On 18/02/15 09:14, Andrey Andreev wrote:
> That is especially bad when such identifiers are in fact generated as
> integers first so that they are incremental, but the
> program/database/business logic requires them to be fixed-length
> strings and/or in hexadecimal format. In such cases, even sile
Hi,
On Wed, Feb 18, 2015 at 11:54 AM, Lester Caine wrote:
> On 18/02/15 09:14, Andrey Andreev wrote:
>> That is especially bad when such identifiers are in fact generated as
>> integers first so that they are incremental, but the
>> program/database/business logic requires them to be fixed-length
> -Ursprüngliche Nachricht-
> Von: Zeev Suraski [mailto:z...@zend.com]
> Gesendet: Mittwoch, 18. Februar 2015 08:00
> An: Nikita Popov; Rasmus Lerdorf
> Cc: Sara Golemon; PHP internals
> Betreff: RE: [PHP-DEV] Scalar Type Hints v0.4
>
> > -Original Message-
On 17/02/15 23:03, Sara Golemon wrote:
> 1) Introduce scalar types for primitives: bool, int, float, string,
> resource, object (we already have array)
> 1a) Introduce meta-types as pre-defined unions (we can add custom
> unions in a later rfc). A possible list may be as follows (again, we
> can
Nikita Popov wrote on 18/02/2015 00:35:
I don't like the way this is heading with regards to internal functions.
Apart from better inter-compatibility, the primary appeal of Andrea's
proposal was that we have the option to make not only userland function
calls strict, but internal ones as well. W
Michael Wallner wrote on 18/02/2015 11:19:
On 17/02/15 23:03, Sara Golemon wrote:
1) Introduce scalar types for primitives: bool, int, float, string,
resource, object (we already have array)
1a) Introduce meta-types as pre-defined unions (we can add custom
unions in a later rfc). A possible li
On 18/02/15 12:31, Rowan Collins wrote:
> Michael Wallner wrote on 18/02/2015 11:19:
>> On 17/02/15 23:03, Sara Golemon wrote:
>>
>>> 1) Introduce scalar types for primitives: bool, int, float, string,
>>> resource, object (we already have array)
>>> 1a) Introduce meta-types as pre-defined unions (
Michael Wallner wrote on 18/02/2015 11:39:
On 18/02/15 12:31, Rowan Collins wrote:
Michael Wallner wrote on 18/02/2015 11:19:
On 17/02/15 23:03, Sara Golemon wrote:
1) Introduce scalar types for primitives: bool, int, float, string,
resource, object (we already have array)
1a) Introduce meta-
Hi Andrey,
> De : Andrey Andreev [mailto:n...@devilix.net]
>
> I too am curious about the potential issue with "123" to 123
> specifically, although it could be seen as a subset of another problem
> that is solved with strict hints - numeric-character string
> identifiers being erroneously treated
> Consider the following signature:
>
> function foo(int $bar) {}
>
> In the case of a *string* representation of a hexadecimal number, the
> following would error only on the last iteration with a weak hint, and on
> the
> very first if it was a strict hint:
>
> for ($i = 0; $i < 11; $i++)
Hi,
>
> Octal is something that can often be miss converted since it IS the same
> as an integer with only a '0' in front in PHP. But that is not something
> that can be fixed with the current proposals?
What do you propose ? Considering leading zero as octal indicator is not an
option, IMO. If y
Hi,
On Wed, Feb 18, 2015 at 2:27 PM, François Laupretre wrote:
> Hi Andrey,
>
>> De : Andrey Andreev [mailto:n...@devilix.net]
>>
>> I too am curious about the potential issue with "123" to 123
>> specifically, although it could be seen as a subset of another problem
>> that is solved with strict
2015-02-18 12:45 GMT+01:00 Rowan Collins :
> Michael Wallner wrote on 18/02/2015 11:39:
>
>> On 18/02/15 12:31, Rowan Collins wrote:
>>
>>> Michael Wallner wrote on 18/02/2015 11:19:
>>>
On 17/02/15 23:03, Sara Golemon wrote:
1) Introduce scalar types for primitives: bool, int, flo
> De : Andrey Andreev [mailto:n...@devilix.net]
>
> Consider the following signature:
>
> function foo(int $bar) {}
>
> In the case of a *string* representation of a hexadecimal number, the
> following would error only on the last iteration with a weak hint, and
> on the very first if it was
> -Original Message-
> From: Robert Stoll [mailto:p...@tutteli.ch]
> Sent: Wednesday, February 18, 2015 1:14 PM
> To: 'Zeev Suraski'; 'Nikita Popov'; 'Rasmus Lerdorf'
> Cc: 'Sara Golemon'; 'PHP internals'
> Subject: AW:
Hi Zeev,
On Wed, Feb 18, 2015 at 2:31 PM, Zeev Suraski wrote:
>> Consider the following signature:
>>
>> function foo(int $bar) {}
>>
>> In the case of a *string* representation of a hexadecimal number, the
>> following would error only on the last iteration with a weak hint, and on
>> the
>>
On 17 February 2015 at 22:03, Sara Golemon wrote:
> Based on conversations here and elsewhere on the internet, I'd like to
> put forward a rough gameplan for scalar types which I hope addresses
> most concerns. This is back-of-the-napkin and I'm not asking for a
> committed yes/no, just pre-rfc s
Leigh wrote on 18/02/2015 13:10:
3b) Internal impact: Again, behavior remains unchanged unless the
>ZEND_ARG_INFO struct has been modified to add proper typehints. If
>typehints have been added, then the more aggressive coersion rules
>apply during typehint validation.
This leaves us in a state
> De : Robert Stoll [mailto:p...@tutteli.ch]
>
> Strict mode is useful in the sense that it prevents unnecessary implicit
> conversions (which are costly) and it improves readability.
> Following an example:
>
> function foo(string $x, int $y){
> bar(1);
> return strstr($x,"hello", $y);
> }
>
On 18 February 2015 at 13:18, Rowan Collins wrote:
>> This leaves us in a state where some functions will have defined types
>> with their aggressive coersion rules and some will not, and we can't
>> expect users to remember which set of functions have been updated or
>> not.
>
> That's precisely
Hi François,
On Wed, Feb 18, 2015 at 3:02 PM, François Laupretre wrote:
>> De : Andrey Andreev [mailto:n...@devilix.net]
>>
>> Consider the following signature:
>>
>> function foo(int $bar) {}
>>
>> In the case of a *string* representation of a hexadecimal number, the
>> following would error
Hi Michael,
The case of null is a little special.
As a type hint, we need it for return and union types only.
Considering union types, they were clearly left out of scope for 7.0 and I
personally won't propose pre-defined union types before the general case for
unions is designed. Conversion t
Hi Nikita,
>
> I don't like the way this is heading with regards to internal functions.
> Apart from better inter-compatibility, the primary appeal of Andrea's
> proposal was that we have the option to make not only userland function
> calls strict, but internal ones as well. With these modificatio
Leigh wrote on 18/02/2015 13:31:
On 18 February 2015 at 13:18, Rowan Collins wrote:
This leaves us in a state where some functions will have defined types
with their aggressive coersion rules and some will not, and we can't
expect users to remember which set of functions have been updated or
no
On 18/02/15 12:33, François Laupretre wrote:
>> Octal is something that can often be miss converted since it IS the same
>> > as an integer with only a '0' in front in PHP. But that is not something
>> > that can be fixed with the current proposals?
> What do you propose ? Considering leading zero
On 18 February 2015 at 14:40, Lester Caine wrote:
> But my favourite is still
> '\143\141\164' == "\143\141\164" which is false, but I doubt many would
> know why?
Pretty sure one of the first things PHP devs learn is that single
quoted strings only accept \' and \\ as escape sequences.
--
PHP
Hi all,
On 18 February 2015 at 09:14, Andrey Andreev wrote:
> Hi,
>
> On Wed, Feb 18, 2015 at 9:00 AM, Zeev Suraski wrote:
>> I am wondering what the point is indeed with preventing "123" to 123. So
>> far, all the concrete use cases people brought up had to do with "Apple" or
>> "100 dogs", bu
> -Ursprüngliche Nachricht-
> Von: Zeev Suraski [mailto:z...@zend.com]
> Gesendet: Mittwoch, 18. Februar 2015 14:03
> An: Robert Stoll
> Cc: Sara Golemon; PHP internals
> Betreff: RE: [PHP-DEV] Scalar Type Hints v0.4
>
> > -Original Message-
>
On 18 February 2015 at 13:30, François Laupretre wrote:
> Actually, your example is partially invalid because strict-typing radicals
> now propose to add a (int -> float) exception to so-called strict mode (which
> proves the approach is flawed, IMHO).
Careful, it helps not to call folk "radic
> -Original Message-
> From: Pádraic Brady [mailto:padraic.br...@gmail.com]
> Sent: Wednesday, February 18, 2015 4:50 PM
> To: Andrey Andreev
> Cc: Zeev Suraski; Nikita Popov; Rasmus Lerdorf; Sara Golemon; PHP
> internals
> Subject: Re: [PHP-DEV] Scalar Type Hints v0
> De : Lazare Inepologlou [mailto:linep...@gmail.com]
>
> So, yes it would be nice null not to be included in scalars. Instead, we
> could have a union type like scalar? = scalar|null
That's roughly the idea. However, IMO, the general mechanism for union types
needs to be defined before we start
On 18/02/15 14:59, Pádraic Brady wrote:
> I wouldn't necessarily mind int->float - it's lossless assuming one way only.
Assuming int is not 64 bit ;)
--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.
> De : Leigh [mailto:lei...@gmail.com]
>
> Can we keep a 0) of "reserve names for future use in-case of RFC
> failure" option.
Reserving names is only needed as long as we keep keywords sharing the same
naming space as classes. This is a mistake from the past and, as long as we
keep it, each new
> De : Rowan Collins [mailto:rowan.coll...@gmail.com]
> That's precisely the case for every existing user-defined function.
> Switching to PHP 7 won't suddenly add type hints to every function in
> every library and every existing bespoke code base, so there is no way
> to avoid that thought proces
Hi Sara (and thanks for continuing the work!)
Le Tue Feb 17 2015 at 23:04:20, Sara Golemon a écrit :
[...]
> 2) Define a way to enable "strict mode" (we'll be weak by default).
>
[...]
> 3) Tighten up coersion rules for weak mode. i.e. "10 dogs" for an int
> is a violation, but "10" is accepta
> De : Zeev Suraski [mailto:z...@zend.com]
>
> If we do implement the single-mode, stricter-than-pure-weak and
> weaker-than-pure-strict ruleset, we could introduce a new set of conversion
> functions, along the lines of safe_int(), that would follow the same rules
> as the corresponding type hints
> De : Pádraic Brady [mailto:padraic.br...@gmail.com]
>
> However, “123” is exceptional. It’s redefining an integer as “ an
> integer or a string comprised wholly of digits without leading zeroes,
> with an optional leading hyphen, and representing an integer up to
> PHP_INT_MAX”
Add leading zeros
On Tue, Feb 17, 2015 at 5:05 PM, Nikita Popov wrote:
> On Wed, Feb 18, 2015 at 1:53 AM, Rasmus Lerdorf wrote:
>
>> On 02/17/2015 04:35 PM, Nikita Popov wrote:
>> > I don't buy into Rasmus arguments about internal functions. They concern
>> > one particular edge case (int->float coercion) and I do
François Laupretre wrote on 18/02/2015 15:47:
De : Leigh [mailto:lei...@gmail.com]
Can we keep a 0) of "reserve names for future use in-case of RFC
failure" option.
Reserving names is only needed as long as we keep keywords sharing the same
naming space as classes. This is a mistake from the p
> De : Pádraic Brady [mailto:padraic.br...@gmail.com]
>
> Careful, it helps not to call folk "radicals" if you intend to pursue
> a compromise with them ;).
Sorry, english is not my native language, and 'radical' may be offensive.
I was just looking for a word for people who consider providing tw
> De : Zeev Suraski [mailto:z...@zend.com]
>
> That means that "42" can coerce into int, and "42.2" can coerce into float,
> and int can coerce into float - but not vice versa.
I was wondering : should we systematically reject float to int, or should we
accept it when range fits and fractional pa
> De : Patrick ALLAERT [mailto:patrickalla...@php.net]
> ini_set("coercion_reporting", COERCION_ERROR); // Fail in case of
> potentially bad coercion
>
> foo(7);
> // int(7)
> foo("7");
> // int(7)
> foo("7 dogs");
> // Catchable fatal error: Unsafe coercion transformin
On 02/18/2015 08:51 AM, François Laupretre wrote:
>> De : Pádraic Brady [mailto:padraic.br...@gmail.com]
>>
>> Careful, it helps not to call folk "radicals" if you intend to pursue
>> a compromise with them ;).
>
> Sorry, english is not my native language, and 'radical' may be offensive.
>
> I wa
> On 18 בפבר׳ 2015, at 19:50, Rasmus Lerdorf wrote:
>
> On 02/18/2015 08:51 AM, François Laupretre wrote:
>>> De : Pádraic Brady [mailto:padraic.br...@gmail.com]
>>>
>>> Careful, it helps not to call folk "radicals" if you intend to pursue
>>> a compromise with them ;).
>>
>> Sorry, english is
> De : Rowan Collins [mailto:rowan.coll...@gmail.com]
>
> What if we defined the types as names in the \PHP namespace, but defined
> a slightly different algorithm for resolving typehints vs other uses:
>
> function foo(\PHP\types\numeric $a) // unambiguous but unwieldy
> function foo(\My\Namespac
On Wed, Feb 18, 2015 at 7:34 AM, Patrick ALLAERT wrote:
> Regarding 2) and 3):
> An option might be to implement "weak mode" only and configure the coercion
> rules "reporting" in a similar way than with the error_reporting
> configuration entry.
>
> ini_set("coercion_reporting", 0); // curren
> De : Patrick ALLAERT [mailto:patrickalla...@php.net]
>
> The biggest advantage, IMHO, is that you get the exact same result whether
> you do:
>
> foo((int) $value);
>
> or:
>
> foo($value);
>
> ... whatever the mode you are in.
Wrong. Parameter parsing rules are much more restrictive
On 18/02/15 17:55, Zeev Suraski wrote:
> We can limit ourselves to values below that limit. If you deal with values
> above it, be explicit about casting.
This is exactly my problem ...
Databases are using 64bit primary keys more and more, and having to
worry about going over some limit is the ve
François Laupretre wrote on 18/02/2015 18:05:
De : Rowan Collins [mailto:rowan.coll...@gmail.com]
What if we defined the types as names in the \PHP namespace, but defined
a slightly different algorithm for resolving typehints vs other uses:
function foo(\PHP\types\numeric $a) // unambiguous but
> De : Rowan Collins [mailto:rowan.coll...@gmail.com]
>
> They'd use whatever (non-reserved) namespace the implementer wanted.
> e.g.
>
> namespace Symfony\Component\TypeChecking;
>
> basicType nonNegativeInt extends PHP\types\int {
> public function isValid(int $value) {
> return
Le Wed Feb 18 2015 at 18:35:02, François Laupretre a
écrit :
> > De : Patrick ALLAERT [mailto:patrickalla...@php.net]
> > ini_set("coercion_reporting", COERCION_ERROR); // Fail in case of
> > potentially bad coercion
> >
> > foo(7);
> > // int(7)
> > foo("7");
> > // int(7)
>
Le Wed Feb 18 2015 at 19:10:54, Sara Golemon a écrit :
> On Wed, Feb 18, 2015 at 7:34 AM, Patrick ALLAERT
> wrote:
> > Regarding 2) and 3):
> > An option might be to implement "weak mode" only and configure the
> coercion
> > rules "reporting" in a similar way than with the error_reporting
> > c
> De : Patrick ALLAERT [mailto:patrickalla...@php.net]
> > My point is that it potentially imposes new warnings on foreign code.
>
> Eureka :)
>
> That's what happened when I introduced the "Array to string conversion":
> lot of people complained about it and many frameworks had to fix various
>
Le Thu Feb 19 2015 at 00:38:25, François Laupretre a
écrit :
>
> > Why can't strictness follow that path?
>
> Because strictness is not the overall objective the PHP language is aiming
> to.
I cannot agree more with that.
> If it was the case, your mechanism would be fine, but deprecating ZPP
so important.
Regards
François
De : Patrick ALLAERT [mailto:patrickalla...@php.net]
Envoyé : jeudi 19 février 2015 11:07
À : franc...@php.net; Sara Golemon
Cc : PHP internals
Objet : Re: [PHP-DEV] Scalar Type Hints v0.4
Le Thu Feb 19 2015 at 00:38:25, François Laupretre a écrit
Le Wed Feb 18 2015 at 19:10:08, François Laupretre a
écrit :
> > De : Patrick ALLAERT [mailto:patrickalla...@php.net]
> >
> > The biggest advantage, IMHO, is that you get the exact same result
> whether
> > you do:
> >
> > foo((int) $value);
> >
> > or:
> >
> > foo($value);
> >
> > ... wh
[mailto:patrickalla...@php.net]
Envoyé : jeudi 19 février 2015 13:46
À : franc...@php.net; Sara Golemon; PHP internals
Objet : Re: [PHP-DEV] Scalar Type Hints v0.4
Le Wed Feb 18 2015 at 19:10:08, François Laupretre a écrit :
> De : Patrick ALLAERT [mailto:patrickalla...@php.net]
>
> The biggest
Le Thu Feb 19 2015 at 00:38:25, François Laupretre a
écrit :
> This is definitely not the same case as generating a notice on array to
> string (and why did you generate a notice instead of E_DEPRECATE, we would
> be rid of this crap now).
>
I haven't decided that without discussing [1] it.
E_D
2015-02-19 12:26 GMT+01:00 François Laupretre :
> Hi Patrick,
>
> I know you didn’t decide it alone, but the right solution, IMO, would have
> been to E_DEPRECATE nonsense conversions. That’s what we are currently doing
> for ZPP conversions (https://wiki.php.net/rfc/zpp-conversion-rules). I also
>
68 matches
Mail list logo