# [RFC][Accepted] Scalar Type Declarations V0.5

- Thread: https://externals.io/message/85091
- Original archive: https://news-web.php.net/php.internals/85091
- Started by Anthony Ferrara on 2015-03-16T21:03:19+00:00
- Messages: 42
- RFC: Scalar Type Hints v0.5 (Implemented (PHP 7.0)) — https://externals.io/rfc/scalar_type_hints_v5.md
- Page 1 of 2: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/85091.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #85091 — Anthony Ferrara — 2015-03-16T21:03:19+00:00

URL: https://externals.io/message/85091#85091

All,

Voting has been closed on the scalar type declarations v0.5 RFC:

https://wiki.php.net/rfc/scalar_type_hints_v5

At a final score of 108:48, it has been accepted for PHP 7.

Thank you.

Anthony

---

## #85092 — Trevor Suarez — 2015-03-16T21:09:59+00:00

URL: https://externals.io/message/85091#85092 · In reply to: #85091

> All,
>
> Voting has been closed on the scalar type declarations v0.5 RFC:
>
> https://wiki.php.net/rfc/scalar_type_hints_v5
>
> At a final score of 108:48, it has been accepted for PHP 7.
>
> Thank you.
>
> Anthony
>
> --
> 
> 
>
>
Wow, 156 votes.

As a non-internals developer that's been watching this RFC process for
quite some time, I'd just like to say thank you. Thank you to you Anthony,
and to Andrea, and to the entire collection of dedicated internals
developers and community members who worked so hard to make this possible.
This is a HUGE win for PHP. I can't wait to start using PHP 7. :)

Oh, and Congratulations!

- Trevor

---

## #85093 — Larry Garfield — 2015-03-16T21:55:51+00:00

URL: https://externals.io/message/85091#85093 · In reply to: #85091

> All,
>
> Voting has been closed on the scalar type declarations v0.5 RFC:
>
> https://wiki.php.net/rfc/scalar_type_hints_v5
>
> At a final score of 108:48, it has been accepted for PHP 7.
>
> Thank you.
>
> Anthony

Huzzah! Huge props to everyone that made this happen, especially Andrea 
for figuring out how to actually do it and Anthony for impressive 
perseverance.

Does this mean this RFC can/should be withdrawn as redundant:

https://wiki.php.net/rfc/reserve_more_types_in_php_7

--Larry Garfield

---

## #85095 — Jonathan Wage — 2015-03-16T22:01:03+00:00

URL: https://externals.io/message/85091#85095 · In reply to: #85091

Thank you Andrea and Anthony. Your efforts are much appreciated!

- Jon

On Mon, Mar 16, 2015 at 4:03 PM, Anthony Ferrara <ircmaxell@gmail.com>
wrote:

> All,
>
> Voting has been closed on the scalar type declarations v0.5 RFC:
>
> https://wiki.php.net/rfc/scalar_type_hints_v5
>
> At a final score of 108:48, it has been accepted for PHP 7.
>
> Thank you.
>
> Anthony
>
> --
> 
> 
>
>


-- 
Connect with me on *http://twitter.com/jwage* <http://twitter.com/jwage

---

## #85099 — Chris Harvey — 2015-03-16T22:05:44+00:00

URL: https://externals.io/message/85091#85099 · In reply to: #85091

Congratulations Anthony, and to Andrea for her initial proposal.

Finally, we have scalar type hints in PHP.

PHP 7 is going to be a real game changer!

Chris

> 
> 
> All,
> 
> Voting has been closed on the scalar type declarations v0.5 RFC:
> 
> https://wiki.php.net/rfc/scalar_type_hints_v5
> 
> At a final score of 108:48, it has been accepted for PHP 7.
> 
> Thank you.
> 
> Anthony

---

## #85105 — andre.romcke@ez.no — 2015-03-16T23:02:43+00:00

URL: https://externals.io/message/85091#85105 · In reply to: #85099

Congratulations Antony, Andrea and (yes) Zeev!
Thanks to everyone involved, this is a great step forwards and a perfect wrap for PHP 7.0 RFC proposal freeze :)


André


> 
> 
> Congratulations Anthony, and to Andrea for her initial proposal.
> 
> Finally, we have scalar type hints in PHP.
> 
> PHP 7 is going to be a real game changer!
> 
> Chris
> 
> > […]

---

## #85109 — Yasuo Ohgaki — 2015-03-17T01:45:42+00:00

URL: https://externals.io/message/85091#85109 · In reply to: #85091

Hi Anthony,

On Tue, Mar 17, 2015 at 6:03 AM, Anthony Ferrara <ircmaxell@gmail.com>
wrote:

> Voting has been closed on the scalar type declarations v0.5 RFC:
>
> https://wiki.php.net/rfc/scalar_type_hints_v5
>
> At a final score of 108:48, it has been accepted for PHP 7.
>

Congratulations. Even though I dislike "stirct_types" part, I appreciate
your efforts.

Since weakly typed mode is too weak to be useful for detecting possible
errors and
strict type mode is overridden by any caller(parent script), it's still
reasonable to have
CoerciveSTH RFC. I hope many of us see the benefits of the RFC also.

BTW, I suggest to remove the word "strict" from "strict_types" at least as
it is
not strict at all if caller(parent script) does not specify
"strict_types=1".

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #85111 — Xinchen Hui — 2015-03-17T02:42:20+00:00

URL: https://externals.io/message/85091#85111 · In reply to: #85109

> Hi Anthony,
>
> On Tue, Mar 17, 2015 at 6:03 AM, Anthony Ferrara <ircmaxell@gmail.com>
> wrote:
>
> > […]
>
> Congratulations. Even though I dislike "stirct_types" part, I appreciate
> your efforts.
Same here.

anyway, I think there is no time doing any changes on this.

Let's wait and see, how the community use this "strict_types"..

anyway,  I am glad this thread is finally done.

thanks
>
> Since weakly typed mode is too weak to be useful for detecting possible
> errors and
> strict type mode is overridden by any caller(parent script), it's still
> reasonable to have
> CoerciveSTH RFC. I hope many of us see the benefits of the RFC also.
>
> BTW, I suggest to remove the word "strict" from "strict_types" at least as
> it is
> not strict at all if caller(parent script) does not specify
> "strict_types=1".
>
> Regards,
>
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net



-- 
Xinchen Hui
@Laruence
http://www.laruence.com/

---

## #85112 — Stanislav Malyshev — 2015-03-17T02:50:58+00:00

URL: https://externals.io/message/85091#85112 · In reply to: #85091

Hi!

> Voting has been closed on the scalar type declarations v0.5 RFC:
> 
> https://wiki.php.net/rfc/scalar_type_hints_v5
> 
> At a final score of 108:48, it has been accepted for PHP 7.
> 
> Thank you.

Despite my previous disagreement with this RFC, I'd like to thank
Anthony for all his work on it and persistence and congratulate us all
for finally arriving at the decision. I'd like also to thank everybody
who contributed to the discussion and participated in the probably most
representative vote ever held.

Let's get on the road for PHP 7 GA and make it the best PHP release ever.
-- 
Stas Malyshev
smalyshev@gmail.com

---

## #85117 — Lester Caine — 2015-03-17T08:37:49+00:00

URL: https://externals.io/message/85091#85117 · In reply to: #85112

> Let's get on the road for PHP 7 GA and make it the best PHP release ever.

To help towards that end, can someone who understands what is wanted
from the weak type hint mode actually produce a summary of that as it is
very difficult to extract just what has now been agreed for that area of
type hinting. A base that can be used to review some of the other
discussions to put that to bed. Others might appreciate a similar
summary of the 'type_error' mode as well? As a base for the
documentation on the user manual updates?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #85127 — Leigh — 2015-03-17T17:04:09+00:00

URL: https://externals.io/message/85091#85127 · In reply to: #85117

> To help towards that end, can someone who understands what is wanted
> from the weak type hint mode actually produce a summary of that as it is
> very difficult to extract just what has now been agreed for that area of
> type hinting. A base that can be used to review some of the other
> discussions to put that to bed. Others might appreciate a similar
> summary of the 'type_error' mode as well? As a base for the
> documentation on the user manual updates?


Not sure what is "difficult to extract"

https://wiki.php.net/rfc/scalar_type_hints_v5#behaviour_of_weak_type_checks

It's all right there...

---

## #85157 — andre.romcke@ez.no — 2015-03-17T23:53:35+00:00

URL: https://externals.io/message/85091#85157 · In reply to: #85127

> 
> 
> 
> 
> > […]
> 
> 
> Not sure what is "difficult to extract"
> 
> https://wiki.php.net/rfc/scalar_type_hints_v5#behaviour_of_weak_type_checks
> 
> It's all right there...


That part answers what has been agreed (or rather accepted), but not who the
weak mode is for, and why.

Tried to sum that up last week when there was still discussions on this:
http://share.ez.no/blogs/core-development-team/php-7-sth-from-user-perspective

TL;DR;  weak mode is for api consumers, aka normal php users, while strict is
 for the actual target users of this features: api (library/framework) creators.

Post also argues for why Zeev's adjustments to weak sth handling should still
be done, as well as arguing for disallowing/fixing closure hint in strict mode.


ar

---

## #85163 — Yasuo Ohgaki — 2015-03-18T04:25:38+00:00

URL: https://externals.io/message/85091#85163 · In reply to: #85157

Hi Andre,



> TL;DR;  weak mode is for api consumers, aka normal php users, while strict
> is
>  for the actual target users of this features: api (library/framework)
> creators.
>

How could it possible?

On Mon, Mar 16, 2015 at 2:49 PM, Dennis Birkholz <dennis@birkholz.biz>
 wrote:

> Am 16.03.2015 um 06:28 schrieb Xinchen Hui:
> > […]
>
> that is not right and has been discussed a thousand times over.
> The declare changes the rules only for function calls in the file it is
> declared in.
>
> so:
> lib.php:
> <?php
>         declare(strict_types = 1);
>         function foo(int $a) {
>         // no function call here
>         }
> ?>
> The declare here does just nothing.
>
> <?php
>         require "lib.php";
>         foo("123"); // will work
> ?>
>
> <?php
>         declare(strict_types = 1);
>         require "lib.php";
>         foo("123"); // will give an error
> ?>
>
> Very easy, explained a thousand times over. Bringing up the same false
> arguments up again and again does really not help the discussion.
>

I didn't have my time to spent for the patch. So I don't verify this
by myself, but it seems common sense for this RFC.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #85164 — Pierre Joye — 2015-03-18T04:35:11+00:00

URL: https://externals.io/message/85091#85164 · In reply to: #85163

> I didn't have my time to spent for the patch. So I don't verify this
> by myself, but it seems common sense for this RFC.

So you voted against it without knowing how it actually works or aims to
work? I suggest you to do it now then, before going further with this
discussion :)

---

## #85165 — Yasuo Ohgaki — 2015-03-18T04:44:22+00:00

URL: https://externals.io/message/85091#85165 · In reply to: #85164

Hi Pierre,



> 
>
> > […]
>
> So you voted against it without knowing how it actually works or aims to
> work? I suggest you to do it now then, before going further with this
> discussion :)
>
I know we are better to play with patch before vote.
I played with Zeev's patch and I was sure it's better ;)

How many of voters spend enough time for both patches before vote?

The reason I admit that I didn't spent time to play with the patch is
following behavior does not make sense to me much and I have
doubt for it.

lib.php:
<?php
        declare(strict_types = 1);
        function foo(int $a) {
        // no function call here
        }
?>
The declare here does just nothing.

<?php
        require "lib.php";
        foo("123"); // will work
?>

<?php
        declare(strict_types = 1);
        require "lib.php";
        foo("123"); // will give an error
?>

Could someone knowledgeable shed light on this?

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #85168 — David Muir — 2015-03-18T07:46:22+00:00

URL: https://externals.io/message/85091#85168 · In reply to: #85165

> 
> 
> Hi Pierre,
> 
> > […]
> I know we are better to play with patch before vote.
> I played with Zeev's patch and I was sure it's better ;)
> 
> How many of voters spend enough time for both patches before vote?
> 
> The reason I admit that I didn't spent time to play with the patch is
> following behavior does not make sense to me much and I have
> doubt for it.
> 
> lib.php:
> <?php
>        declare(strict_types = 1);
>        function foo(int $a) {
>        // no function call here
>        }
> ?>
> The declare here does just nothing.

Correct. There are no function calls in the file, so there's nothing for declare strict to act on.

> 
> <?php
>        require "lib.php";
>        foo("123"); // will work
> ?>
> 
> <?php
>        declare(strict_types = 1);
>        require "lib.php";
>        foo("123"); // will give an error
> ?>
> 
> Could someone knowledgeable shed light on this?
> 
> Regards,
> 
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net

Shed light on what exactly? Why it behaves this way?

The second file passes because it is in the default weak mode, so it will coerce to an int, so the type hint is satisfied.

The third file will error because you have asked it to error when you pass the wrong scalar type to a function.

David

---

## #85174 — Zeev Suraski — 2015-03-18T09:13:47+00:00

URL: https://externals.io/message/85091#85174 · In reply to: #85165

> -----Original Message-----
> From: yohgaki@gmail.com [mailto:yohgaki@gmail.com] On Behalf Of Yasuo
> Ohgaki
> Sent: Wednesday, March 18, 2015 6:44 AM
> To: Pierre Joye
> Cc: PHP internals; Leigh; André Rømcke; Lester Caine
> Subject: Re: [PHP-DEV] [RFC][Accepted] Scalar Type Declarations V0.5
>
> Hi Pierre,
>
> On Wed, Mar 18, 2015 at 1:35 PM, Pierre Joye <pierre.php@gmail.com>
> wrote:
>
> > […]
> I know we are better to play with patch before vote.
> I played with Zeev's patch and I was sure it's better ;)
>
> How many of voters spend enough time for both patches before vote?

Apparently very few.  In terms of people who actually reported their
findings or explicitly said they played with it here on internals, perhaps a
handful.

FWIW, as someone who did play with the patch (both patches, of course), I'm
not sure why people are claiming you don't understand the RFC.  Your
comments in the code are 100% accurate, which means you understood exactly
how it works.

Zeev

---

## #85175 — Zeev Suraski — 2015-03-18T09:43:17+00:00

URL: https://externals.io/message/85091#85175

> FWIW, as someone who did play with the patch (both patches, of course),
> I'm not sure why people are claiming you don't understand the RFC.  Your
> comments in the code are 100% accurate, which means you understood
> exactly how it works.

Josh Di Fabio just pointed out to me that the code in question wasn't
actually written by you but by Dennis Birkholz, so my statement was
incorrect.
Still, from what you said it appears to me you still understood the behavior
but disagreed with it.  I know that at least on my end, that was definitely
the case.

Zeev

---

## #85176 — pajousek@gmail.com — 2015-03-18T09:55:57+00:00

URL: https://externals.io/message/85091#85176 · In reply to: #85091

> All,
>
> Voting has been closed on the scalar type declarations v0.5 RFC:
>
> https://wiki.php.net/rfc/scalar_type_hints_v5
>
> At a final score of 108:48, it has been accepted for PHP 7.
>
> Thank you.
>
> Anthony
>
> --
> 
> 
>

Hello,

how will these examples work btw?

// a.php
<?php
declare(strict_types=1);
function foo($fn) {
    $fn("1");
};

// b.php
<?php
require 'a.php';
foo(function (int $a) { return $a * 2; });



// c.php
<?php
function foo($fn) {
    $fn("1");
};

// d.php
<?php
declare(strict_types=1);
require 'c.php';
foo(function (int $a) { return $a * 2; });

I can't find this in the RFC. I'd intuitively expect error in the
first example and the second one to work OK.

But at the same time, if there will be an error in the first example,
it is IMHO a huge flaw with this RFC. :/


Regards
Pavel Kouril

---

## #85177 — Pierre Joye — 2015-03-18T10:01:35+00:00

URL: https://externals.io/message/85091#85177 · In reply to: #85176

>
> On Mon, Mar 16, 2015 at 10:03 PM, Anthony Ferrara <ircmaxell@gmail.com>
wrote:
> > […]
>
> Hello,
>
> how will these examples work btw?
>
> // a.php
> <?php
> declare(strict_types=1);
> function foo($fn) {
>     $fn("1");
> };
>
> // b.php
> <?php
> require 'a.php';
> foo(function (int $a) { return $a * 2; });
>
>
>
> // c.php
> <?php
> function foo($fn) {
>     $fn("1");
> };
>
> // d.php
> <?php
> declare(strict_types=1);
> require 'c.php';
> foo(function (int $a) { return $a * 2; });
>
> I can't find this in the RFC. I'd intuitively expect error in the
> first example and the second one to work OK.
>
> But at the same time, if there will be an error in the first example,
> it is IMHO a huge flaw with this RFC. :/

Git clone, compile, try, report.

It sounds pretty straight forward to me instead of asking the same
questions (in various form but it ends to the same answer).

And the patch should be applied sooner rather than later. So we can fix
bugs if there are actual ones in the current implementation.

---

## #85178 — pajousek@gmail.com — 2015-03-18T10:05:38+00:00

URL: https://externals.io/message/85091#85178 · In reply to: #85177

>
> 
> > […]
>
> Git clone, compile, try, report.
>
> It sounds pretty straight forward to me instead of asking the same questions
> (in various form but it ends to the same answer).
>
> And the patch should be applied sooner rather than later. So we can fix bugs
> if there are actual ones in the current implementation.

Hello,

if I had time to set up the compilation of PHP on Windows, I'd do it -
but I don't. I wanted to try it myself via http://3v4l.org/, but it
unfortunately doesn't support multiple files.

Regards
Pavel Kouril

---

## #85180 — Florian Margaine — 2015-03-18T11:05:42+00:00

URL: https://externals.io/message/85091#85180 · In reply to: #85178

Hi,

Le 18 mars 2015 11:06, "Pavel Kouřil" <pajousek@gmail.com> a écrit :
>
> On Wed, Mar 18, 2015 at 11:01 AM, Pierre Joye <pierre.php@gmail.com>
wrote:
> > […]
questions
> > […]
bugs
> > […]
>
> Hello,
>
> if I had time to set up the compilation of PHP on Windows, I'd do it -
> but I don't. I wanted to try it myself via http://3v4l.org/, but it
> unfortunately doesn't support multiple files.

You can emulate multiple files support by using eval().

>
> Regards
> Pavel Kouril
>
> --
> 
> 
>

Cheers,
Florian Margaine

---

## #85181 — Patrick ALLAERT — 2015-03-18T11:12:07+00:00

URL: https://externals.io/message/85091#85181 · In reply to: #85176

Le mer. 18 mars 2015 à 10:56, Pavel Kouřil <pajousek@gmail.com> a écrit :

> Hello,
>
> how will these examples work btw?
>
> // a.php
> <?php
> declare(strict_types=1);
> function foo($fn) {
>     $fn("1");
> };
>
> // b.php
> <?php
> require 'a.php';
> foo(function (int $a) { return $a * 2; });
>
>
>
> // c.php
> <?php
> function foo($fn) {
>     $fn("1");
> };
>
> // d.php
> <?php
> declare(strict_types=1);
> require 'c.php';
> foo(function (int $a) { return $a * 2; });
>
> I can't find this in the RFC. I'd intuitively expect error in the
> first example and the second one to work OK.
>

Your intuition is correct.


> But at the same time, if there will be an error in the first example,
> it is IMHO a huge flaw with this RFC. :/
>

Flaw vs. design choice. This is one of the reason that this aspect, amongst
others, has been very debated.

---

## #85182 — pajousek@gmail.com — 2015-03-18T11:31:17+00:00

URL: https://externals.io/message/85091#85182 · In reply to: #85181

On Wednesday, March 18, 2015, Patrick ALLAERT <patrickallaert@php.net>
wrote:
> Le mer. 18 mars 2015 à 10:56, Pavel Kouřil <pajousek@gmail.com> a écrit :
> > […]
>
> Your intuition is correct.
>
> > […]
>
> Flaw vs. design choice. This is one of the reason that this aspect,
amongst others, has been very debated.

But if it works this way, the strict mode isn't optional and users of a
library NEED to care which mode the library uses?

---

## #85185 — Nikita Nefedov — 2015-03-18T12:13:34+00:00

URL: https://externals.io/message/85091#85185 · In reply to: #85182

>
> On Wednesday, March 18, 2015, Patrick ALLAERT <patrickallaert@php.net>
> wrote:
> > […]
:
> > […]
> amongst others, has been very debated.
>
> But if it works this way, the strict mode isn't optional and users of a
> library NEED to care which mode the library uses?

If library chose to use strict mode then the odds are it will take care of
passing right types to callbacks and interfaced methods.

Saying that strict mode isn't optional is not true, I don't see why you
have made this conclusion.

---

Next page: https://externals.io/message/85091.md?page=2
