# Annoucing PHP 5.4 Alpha 1

- Thread: https://externals.io/message/49283
- Original archive: https://news-web.php.net/php.internals/49283
- Started by Kalle Sommer Nielsen on 2010-08-10T22:03:51+00:00
- Messages: 88
- Page 1 of 4: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/49283.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

---

## #49283 — Kalle Sommer Nielsen — 2010-08-10T22:03:51+00:00

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

Greetings hackers

I spoke with Derick today, and we both agreed on releasing an alpha of
PHP 5.4 to show the public what we have been working since 5.3. We are
going to release an alpha at september 2nd, which meaning packaging is
going to happen on 1st September (SVN tag, Windows binaries, etc.)

With Traits, interned strings/hash table optimizations, array deref.,
type hinting, and more we both (me and Derick) belive we are ready for
an alpha in September already. So I ask you geeks please make sure
things are somewhat usable for the first public release of PHP 5.4 and
post RFC's for inclusion in this alpha. If there is any questions
regarding 5.4, then please email both me and Derick at our respective
@php.net addresses and lets get this thing going ;-)

I will spend out an email after the Alpha regarding a roadmap, with
such things as PECL extensions in and out, possible RFC's, magic
quotes and so forth.

-- 
regards,

Kalle Sommer Nielsen
kalle@php.net

---

## #49284 — johannes@schlueters.de — 2010-08-10T22:11:08+00:00

URL: https://externals.io/message/49283#49284 · In reply to: #49283

> type hinting

For the record: I consider the current implementation as (one of) the
biggest mistakes in the last ten years.

johannes

---

## #49285 — Arvids Godjuks — 2010-08-10T22:25:28+00:00

URL: https://externals.io/message/49283#49285 · In reply to: #49284

Total thumbs up on that.
http://schlueters.de/blog/archives/139-Scalar-type-hints-in-PHP-trunk.html
just tells it all. A total epic fail.

2010/8/11 Johannes Schlüter <johannes@schlueters.de>:
> 
> > […]
>
> For the record: I consider the current implementation as (one of) the
> biggest mistakes in the last ten years.
>
> johannes

---

## #49286 — Brian Moon — 2010-08-10T22:30:53+00:00

URL: https://externals.io/message/49283#49286 · In reply to: #49285

> 2010/8/11 Johannes Schlüter<johannes@schlueters.de>:
> > […]

Is there a summary of what we ended up with? I got so tired of all the 
complaining on the the many threads I lost track. What are all the type 
hints we can use in a function definition in trunk?

-- 

Brian.
--------
http://brian.moonspot.net/

---

## #49287 — Derick Rethans — 2010-08-10T22:32:26+00:00

URL: https://externals.io/message/49283#49287 · In reply to: #49284

> 
> > […]
> 
> For the record: I consider the current implementation as (one of) the
> biggest mistakes in the last ten years.

I will try to sum up my view point once more:

1. right now we *have* strict type checks for classes and arrays in the 
   form of "classname" or "array"
2. the strict scalary type hint patch reuses this same syntax in the 
   form of <type-name> to do the same thing in function arguments
3. we have casting type hints in the rest of the code in the form of 
   "(int)".

Some people don't like strict typehints, but the syntax as it currently 
is regarding type hints is *consistent*. Now, to allow both strict and 
casting hints, the logical step seems to be, to give the weak typehint 
advocates their tool as well:

4. We add casting typehings to function arguments in the form of "(int)" 
   so that that is consistent as well. We would need to figure out 
   whether we want:
   a. warnings on conversions (my choice)
   b. no warnings

This:

- keeps the syntax consistent
- allows both strict and weak typehints

Should make everybody happy (enough), right? 

regards,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

---

## #49288 — Rasmus Lerdorf — 2010-08-10T22:32:38+00:00

URL: https://externals.io/message/49283#49288 · In reply to: #49286

> > […]
> 
> Is there a summary of what we ended up with? I got so tired of all the
> complaining on the the many threads I lost track. What are all the type
> hints we can use in a function definition in trunk?

They aren't hints.  It is strict typing and in its current form I would
ask you guys not to call the 5.4 release PHP.  Because it won't be.

-Rasmus

---

## #49289 — Stas Malyshev — 2010-08-10T22:34:41+00:00

URL: https://externals.io/message/49283#49289 · In reply to: #49283

Hi!

> With Traits, interned strings/hash table optimizations, array deref.,
> type hinting, and more we both (me and Derick) belive we are ready for

Please do not call strict typing "type hinting".
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #49290 — Stas Malyshev — 2010-08-10T22:46:40+00:00

URL: https://externals.io/message/49283#49290 · In reply to: #49287

Hi!

> 1. right now we *have* strict type checks for classes and arrays in the
>     form of "classname" or "array"

Because classes and arrays were never intechangeable types and there was 
never implicit or explicit conversion between SplRecursiveTreeIterator 
and Zend_Pdf_Generator - it doesn't even make sense to suggest it. There 
always was conversion between int and string or int and bool. These two 
things are completely different.

> 2. the strict scalary type hint patch reuses this same syntax in the
>     form of<type-name>  to do the same thing in function arguments

It's not a good thing. As I mentioned, primitive types and classes are 
very different in their use cases and established patterns in PHP. 
Primitive types are largely interchangeable, classes are not. (As for 
arrays, arrays really should be a class by their usage patterns etc. but 
for historic reasons... you know)

> 3. we have casting type hints in the rest of the code in the form of
>     "(int)".

Just to make it simpler and less confusing, of course. It's nothing like 
language having two features that look almost exactly the same but work 
in different way, and using plenty of ()s is an added bonus for all Lisp 
fans out there.

> Some people don't like strict typehints, but the syntax as it currently
> is regarding type hints is *consistent*. Now, to allow both strict and
> casting hints, the logical step seems to be, to give the weak typehint
> advocates their tool as well:

Calling something that works completely differently from all the 
established patterns of PHP - like internal functions, etc. - 
"*consistent*" requires totally new definition of this word.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #49291 — Stas Malyshev — 2010-08-10T22:47:23+00:00

URL: https://externals.io/message/49283#49291 · In reply to: #49284

Hi!

> For the record: I consider the current implementation as (one of) the
> biggest mistakes in the last ten years.

I agree completely. The fact that obvious absence of consensus is 
ignored and we are releasing feature that clearly has no consensus 
behind it as a part of an official release - when we have killed much 
lesser things for much lesser reasons - I think it is a very bad 
development.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #49292 — Scott MacVicar — 2010-08-10T22:50:56+00:00

URL: https://externals.io/message/49283#49292 · In reply to: #49284

> 
> > […]
> 
> For the record: I consider the current implementation as (one of) the
> biggest mistakes in the last ten years.
> 
> johannes

I'm happy to see a more strict implementation, but I think our numeric handling needs changed. We silently fall between them all in PHP. Sure we can guarantee array, null, bool, resource, string etc but not the numeric types.

I think we should hold off on the Alpha until we're agreed with thats happening with that.

- S

---

## #49293 — Arvids Godjuks — 2010-08-10T22:53:27+00:00

URL: https://externals.io/message/49283#49293 · In reply to: #49287

Well, the thing is objects and arrays are complex types, so you can't
pass anything exept array to an array type hint, it just dosen't make
sence. Not everything can be converted to array and vice-versa. Same
with objects - every object is it's own type.

But the primitive types behave differently. It's because that they are
primitive, they easily convert from one to other back and fourth. I
don't see the need to be strict as really that feature will be used so
rearly, that it doesn't cost the effort. Really, any framework using
strict hints? How do you expect them to receive data from HTTP and
databases. It would require to write conversion rules for all data
they receive so it would be passed in the right type to the API. It's
just nuts.
The more realistic way is you define a function/method with the params
and wrap it into try {} catch {} block. If data is converted with the
data loss: for exmple you expect a numeric ID, but get a string of
chars - fetch the error and display an error message of a wrong ID.
Just the same way we do now - check for is_numeric and display the
error. This way the feature will be used. Strict types for dynamic
language is a non-sence.

Stop making things more complicated.

2010/8/11 Derick Rethans <derick@php.net>:
> 
>
> > […]
>
> I will try to sum up my view point once more:
>
> 1. right now we *have* strict type checks for classes and arrays in the
>   form of "classname" or "array"
> 2. the strict scalary type hint patch reuses this same syntax in the
>   form of <type-name> to do the same thing in function arguments
> 3. we have casting type hints in the rest of the code in the form of
>   "(int)".
>
> Some people don't like strict typehints, but the syntax as it currently
> is regarding type hints is *consistent*. Now, to allow both strict and
> casting hints, the logical step seems to be, to give the weak typehint
> advocates their tool as well:
>
> 4. We add casting typehings to function arguments in the form of "(int)"
>   so that that is consistent as well. We would need to figure out
>   whether we want:
>   a. warnings on conversions (my choice)
>   b. no warnings
>
> This:
>
> - keeps the syntax consistent
> - allows both strict and weak typehints
>
> Should make everybody happy (enough), right?
>
> regards,
> Derick
>
> --
> http://derickrethans.nl | http://xdebug.org
> Like Xdebug? Consider a donation: http://xdebug.org/donate.php
> twitter: @derickr and @xdebug

---

## #49294 — Sascha Schumann — 2010-08-10T23:04:29+00:00

URL: https://externals.io/message/49283#49294 · In reply to: #49288

> They aren't hints.  It is strict typing and in its current form I would
> ask you guys not to call the 5.4 release PHP.  Because it won't be.

    Fully agreed.

    I'd suggest "NoPHP".  "AntiPHP" might also work.

    - Sascha

---

## #49295 — Victor Bolshov — 2010-08-10T23:08:37+00:00

URL: https://externals.io/message/49283#49295 · In reply to: #49290

Having two similar syntaxes that work differently - would make the
situation even worse that it is now - I beleive. And I totally agree
with Rasmus - strict typed language mustnt be called PHP. (Just a poor
user's notice to all of you internals' geeks out there)

2010/8/11 Stas Malyshev <smalyshev@sugarcrm.com>:
> Hi!
>
> > […]
>
> Because classes and arrays were never intechangeable types and there was
> never implicit or explicit conversion between SplRecursiveTreeIterator and
> Zend_Pdf_Generator - it doesn't even make sense to suggest it. There always
> was conversion between int and string or int and bool. These two things are
> completely different.
>
> > […]
>
> It's not a good thing. As I mentioned, primitive types and classes are very
> different in their use cases and established patterns in PHP. Primitive
> types are largely interchangeable, classes are not. (As for arrays, arrays
> really should be a class by their usage patterns etc. but for historic
> reasons... you know)
>
> > […]
>
> Just to make it simpler and less confusing, of course. It's nothing like
> language having two features that look almost exactly the same but work in
> different way, and using plenty of ()s is an added bonus for all Lisp fans
> out there.
>
> > […]
>
> Calling something that works completely differently from all the established
> patterns of PHP - like internal functions, etc. - "*consistent*" requires
> totally new definition of this word.
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> 
> 
>
>



-- 
С уважением,
Виктор

---

## #49296 — Josh Davis — 2010-08-10T23:42:07+00:00

URL: https://externals.io/message/49283#49296 · In reply to: #49293

Derick's point was about consistency. The approach described in his
mail is consistent with current syntax and mechanism(s). Current
typehints do not apply any kind of conversion, so treating scalar
hints the same way is consistent with the current mechanism.

Reusing the typecasting syntax for typecasting "hints" makes them more
familiar to the users, and it is less ambiguous than a typehint that
sometimes also typecasts. Plus, it allows for both "strict"
typechecking and the more relaxed typecasting thing instead of forcing
one. And all of that with a syntax that feels familiar.

That, I believe, was his point.

-JD

---

## #49297 — Stas Malyshev — 2010-08-10T23:50:34+00:00

URL: https://externals.io/message/49283#49297 · In reply to: #49296

Hi!

> Derick's point was about consistency. The approach described in his
> mail is consistent with current syntax and mechanism(s). Current

No it is not. There's no functions that produce errors when fed 1 
instead of boolean "true" - all internal functions convert.

> typehints do not apply any kind of conversion, so treating scalar
> hints the same way is consistent with the current mechanism.

Current hints do not apply conversion because conversion does not exist. 
There can be no conversion between different classes.

> Reusing the typecasting syntax for typecasting "hints" makes them more
> familiar to the users, and it is less ambiguous than a typehint that
> sometimes also typecasts. Plus, it allows for both "strict"

That's exactly how internal functions worked in PHP for 10 years - 
"sometimes" (meaning when the type is wrong) typecast. That's how the 
rest of the language worked for 10 years in situations like $a = $b+1.
How it's "ambiguous" - what are two options that you are confused 
between and can't choose?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #49299 — Arvids Godjuks — 2010-08-11T00:13:52+00:00

URL: https://externals.io/message/49283#49299 · In reply to: #49296

Yes, I understand the point of his post. But as you know - the perfect
world and the real world rearly meat together.
Just read the prevoius themes - majority was on the typecasting hints
for the primitive types. We even layed the rules quite in detail.
The thing is it will be pain in the ass to use strict typing just
because the data comes in string representation from almost everywhere
(PDO with mysqlnd makes a step to the right types from the database,
but that's more an exception than a rule for now). I just don't think
that there will be any sizeable codebase using the strict typing
because one way or other the authors will just get fedup with
converting data back and forth.
Not to mention it just breaks the logic of the language. As Stas just
wrote, people know from day one that if you feed "1" to a function
expecting int, it will work just fine. In fact, the whole language and
all internal functions work that way. The strict types will just break
that pattern. Most of times when using some API I don't give a damn
about what I get from the HTTP. I just do the blody $page =
isset($_GET['page']) ? (int)$_GET['page'] : 0; to get an int. If user
tries to do something by tampering with page params - he can do that
as long as he want's.
What that means, when strict typing is used, most of us will just do
the blody conversion, because we don't wan't to get a fatal error,
even if that's catchable.
Converting hint will give us a warning, convert the value and off we
go - log a warning, do the stuff so the user is happy. We see the
error in the logs, check it, apply a fix and done with it.

It's one thing if "12blabla" makes into 12 int (sure I want to get a
warning in the logs) or 1 becomes 1.0 for float (totally safe and
sound). It would be good to see say 5 convert to true for bool - it's
totally fine (again log an error/warning, this should be fixed).
And it's totally different when we expect an array or an object of
some type as a param. The handling of these structures just totally
differes. To work with them you use different syntax, different
aproaches. You can't substitute an array with something, same with
objects. They should fit perfectly.

It's not the reason to implement primitive type hinting like array and
object type hints just because arrays and objects are done that way.
Objects and arrays have a specific use syntax with special language
constructs. If I expect an array - it should be an array or I will get
a fatal error when trying to access an index for an int give, or try
to access a method for the wrong object. But you can easilly expect a
string and get an int instead, silently convert it to string and work
as expected.

Remember the main PHP principle? KISS. So keep it, blody hell, simple!
Let the type hints to cast types when it's possible for primitive
types! Personally I don't want to remember that there are two ways of
defining a type hint and dig for bugs when others ment strict type
hint, but wrote a typecasting one and forgot to make some checks
before passing the argument relying on the hint.

2010/8/11 Josh Davis <phpwnd@gmail.com>:
> Derick's point was about consistency. The approach described in his
> mail is consistent with current syntax and mechanism(s). Current
> typehints do not apply any kind of conversion, so treating scalar
> hints the same way is consistent with the current mechanism.
>
> Reusing the typecasting syntax for typecasting "hints" makes them more
> familiar to the users, and it is less ambiguous than a typehint that
> sometimes also typecasts. Plus, it allows for both "strict"
> typechecking and the more relaxed typecasting thing instead of forcing
> one. And all of that with a syntax that feels familiar.
>
> That, I believe, was his point.
>
> -JD

---

## #49300 — Josh Davis — 2010-08-11T00:28:56+00:00

URL: https://externals.io/message/49283#49300 · In reply to: #49297

> Hi!
>
> > […]
>
> No it is not. There's no functions that produce errors when fed 1 instead of
> boolean "true" - all internal functions convert.

First of all, I am talking about the typehinting syntax and mechanism
here. As Derick pointed out, current typehints are strict.

Secondly, I don't support amalgaming userland with internal functions.
If I was to treat those internal functions as if they were written in
userland, I'd say that they don't use scalar typehints, specifically
for the reason you mentionned. Internal functions just typecast
whatever you throw at them, no question asked.

> That's exactly how internal functions worked in PHP for 10 years -
> "sometimes" (meaning when the type is wrong) typecast. That's how the rest

Again, I'm not talking about internal functions but typehinting. Now,
when a userland developer uses typehints it means they expect a
variable of a certain type to be passed. If they want typecasting,
Derick proposes a convenient way to do that.

> How it's "ambiguous"

The current typehinting system does not typecast. Changing that
behaviour makes it ambiguous. It introduces a new behaviour grafted
onto the old mechanism and without a new syntax.

---

## #49301 — Josh Davis — 2010-08-11T00:36:20+00:00

URL: https://externals.io/message/49283#49301 · In reply to: #49299

> Remember the main PHP principle? KISS. So keep it, blody hell, simple!

Please try to realize that what you find simple may not appear as
simple to everybody else. To me, typechecking is very simple: if type
equals typehint then ok else error. Very simple. Describing the rules
used when juggling types takes several pages of the PHP manual and
some conversions are undefined. And from what I understand, the
proposed typecasting typehints use slightly different rules. I'm sure
you understand how one could see that as "not simple."

---

## #49302 — Stas Malyshev — 2010-08-11T00:50:55+00:00

URL: https://externals.io/message/49283#49302 · In reply to: #49300

Hi!

> First of all, I am talking about the typehinting syntax and mechanism
> here. As Derick pointed out, current typehints are strict.

Talking about "strict" vs. "non-strict" for class types is meaningless. 
You can consider them non-strict if you want - they convert if the 
conversion is available, just like the rest of PHP, with only note that 
conversion is *never* available.
But it's just a semantic game because we are talking about different 
things here. Using the same syntax just confused you to think they are 
the same, but in PHP they are not. There are some languages where 
there's no primitive types or primitive types aren't different from 
classes - but PHP, for better or worse, as of now is not one of them.

> Secondly, I don't support amalgaming userland with internal functions.
> If I was to treat those internal functions as if they were written in
> userland, I'd say that they don't use scalar typehints, specifically
> for the reason you mentionned. Internal functions just typecast
> whatever you throw at them, no question asked.

Again, it's just semantic games - you can call it "typehints" or not, 
your choice, but the fact is they did not fixate on the bitwise 
representation of the types - and we shouldn't start fixating on that 
now. They accept "1" when numeric value is needed, why can't you?

> Again, I'm not talking about internal functions but typehinting. Now,
> when a userland developer uses typehints it means they expect a
> variable of a certain type to be passed. If they want typecasting,
> Derick proposes a convenient way to do that.

That's exactly what is wrong with it - developer should NOT expect 
"variable of certain type to be passed" (if we are talking about 
primitive types), because PHP is not a strictly typed language, it's a 
dynamic language. There could be strictly typed language with PHP 
syntax, no problem, but that would a) require much more than just 
function parameters and b) not be PHP.

> The current typehinting system does not typecast. Changing that
> behaviour makes it ambiguous. It introduces a new behaviour grafted
> onto the old mechanism and without a new syntax.

It does not change any behavior - right now there's two sets of objects 
in PHP - primitive types and classes. Values of primitive types can be 
converted into another type, implicitly or explicitly, objects of 
classes can not.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #49303 — Stas Malyshev — 2010-08-11T00:53:28+00:00

URL: https://externals.io/message/49283#49303

Hi!

> Might be the time to rename what we currently call "type hinting" then.
> Because what we currently have is strict typing as well.

Maybe. The term "hint" was inexact from the start, as hint means 
(Collins English Dictionary):

1. a suggestion or implication given in an indirect or subtle manner he 
dropped a hint
2. a helpful piece of advice or practical suggestion
3. a small amount; trace

That's clearly not what is going on - there's nothing subtle or indirect 
there and there's not a suggestion - it's a strict and unequivocal 
definition of type expected for the function call.

But with its use in 5.3 it didn't matter since it was clear what we are 
talking about and there was no possibility of confusion. Right now what 
we have is a classic strict typing, albeit not required for all places 
but f(int $f) in PHP would be the same as f(int i) in C, so calling them 
differently would only lead to confusion. Maybe we should have called it 
"parameter typing" or something like that from the start. It didn't seem 
important back then because everybody agreed what it means. Obviously it 
is no longer the case.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #49304 — Ilia Alshanetsky — 2010-08-11T01:41:56+00:00

URL: https://externals.io/message/49283#49304 · In reply to: #49303

Sounds like a reasonable name change. PHP never really had
"type-hinting" since even array or Object type "hints" would throw out
any value that didn't precisely match the requested type by the
method/function declaration.


> Hi!
>
> > […]
>
> Maybe. The term "hint" was inexact from the start, as hint means (Collins
> English Dictionary):
>
> 1. a suggestion or implication given in an indirect or subtle manner he
> dropped a hint
> 2. a helpful piece of advice or practical suggestion
> 3. a small amount; trace
>
> That's clearly not what is going on - there's nothing subtle or indirect
> there and there's not a suggestion - it's a strict and unequivocal
> definition of type expected for the function call.
>
> But with its use in 5.3 it didn't matter since it was clear what we are
> talking about and there was no possibility of confusion. Right now what we
> have is a classic strict typing, albeit not required for all places but
> f(int $f) in PHP would be the same as f(int i) in C, so calling them
> differently would only lead to confusion. Maybe we should have called it
> "parameter typing" or something like that from the start. It didn't seem
> important back then because everybody agreed what it means. Obviously it is
> no longer the case.
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227

---

## #49305 — Ilia Alshanetsky — 2010-08-11T01:46:38+00:00

URL: https://externals.io/message/49283#49305 · In reply to: #49294

Sascha,

Does this mean @group authorizes use of "NoPHP" as a name for a
derivative PHP version (gotta ask according to the license) ? ;-)


> > […]
>
>    Fully agreed.
>
>    I'd suggest "NoPHP".  "AntiPHP" might also work.
>
>    - Sascha

---

## #49308 — Josh Davis — 2010-08-11T04:03:45+00:00

URL: https://externals.io/message/49283#49308 · In reply to: #49302

> Hi!
>
> > […]
>
> Talking about "strict" vs. "non-strict" for class types is meaningless.

By "strict" typehints I meant that no typecasting occurs. Personally
I'm not fan of the "strict" vs "weak" denomination used here either.
I'd rather call them typechecking vs smartcasting.

> can consider them non-strict if you want - they convert if the conversion is
> available, just like the rest of PHP, with only note that conversion is
> *never* available.
> But it's just a semantic game because we are talking about different things
> here. Using the same syntax just confused you to think they are the same,
> but in PHP they are not. There are some languages where there's no primitive
> types or primitive types aren't different from classes - but PHP, for better
> or worse, as of now is not one of them.

I'm sorry but I have no idea what you're talking about there =\ PHP
has a bunch of different types, the current type hinting (typechecking
as per aforementionned denomination) ensures that the argument is the
right type and I hope that adding scalar type hints will not change
that.

> Again, it's just semantic games - you can call it "typehints" or not, your
> choice, but the fact is they did not fixate on the bitwise representation of
> the types - and we shouldn't start fixating on that now. They accept "1"
> when numeric value is needed, why can't you?

I very much can, it's just not my intention. I want to be able to use
type hinting/type checking as a sanity check. If I write a method
whose signature is foo(int $n) I signal my intention to only accept
integers. If a boolean somehow finds its way to that method, it means
that something wrong happened. If I wanted to accept any type of
variable then I wouldn't use a type hint and I would validate the
input with the filter extension. Or I would use type casting.

TL;DR version: "int $n" in the definition means I want an integer. If
I wanted any kind of variable but I wanted it to somehow represent a
number then I would look for a hint such as "number $n". I guess that
"(int) $n" is close enough, since that's what's being used everywhere
else.

> That's exactly what is wrong with it - developer should NOT expect "variable
> of certain type to be passed" (if we are talking about primitive types),
> because PHP is not a strictly typed language, it's a dynamic language.

If PHP was meant to prevent programmers from controlling the type of
their variables then I'm afraid there's been a misunderstanding and
I'd say that extending a feature called "type hinting" to cover all of
PHP's primitive types will only make it worse. I have always thought
that controlling the type of the variables used in userland was my
prerogative, and I suspect that quite a few users were led to believe
the same thing.

Derick's proposal allows for those users to control the type of their
variables and allows for those who care about the content of their
variables more than their type to do that as well.

> It does not change any behavior - right now there's two sets of objects in
> PHP - primitive types and classes. Values of primitive types can be
> converted into another type, implicitly or explicitly, objects of classes
> can not.

As a PHP user, I have no such notion I'm afraid. From my point of
view, there's not two sets of objects, there's about ~8 types, PHP's
core functions and operators do not care too much about those types
and convert them internally. That's all the users see.

I'm not sure what you meant by "objects of classes can not [be
converted into another type]". Arrays can be cast as booleans (false
is empty, true otherwise), objects can be cast as arrays (properties
become keys) and strings to objects (with a single property called
"scalar", leaving everybody wondering what's going on there.)

TL;DR: I always thought PHP would help me control the type of my
variables instead of forcing my userland code to mirror PHP's internal
functions.

PS: I think I've just figured out what you meant by "conversion". Were
you talking about the internal conversion rules used by PHP's internal
functions? Are those described somewhere in the manual?

---

## #49309 — Robert Cummings — 2010-08-11T04:41:01+00:00

URL: https://externals.io/message/49283#49309 · In reply to: #49308

> 
> > […]
>
> By "strict" typehints I meant that no typecasting occurs. Personally
> I'm not fan of the "strict" vs "weak" denomination used here either.
> I'd rather call them typechecking vs smartcasting.

I'd prefer jugglehints... since I'd like PHP to coerce whatever I pass 
as a parameter to the "hinted" type. This is the PHP way... type 
juggling to save the developer the hassle. If I set a jugglehint of 
"int" then I would expect the value to be coerced to an integer 
regardless of whether 12.0, 12, "12", or "12 brown cows" is passed. The 
process of type juggling is well documented and has been for years. Why 
change that?

Cheers,
Rob.
-- 
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

---

## #49310 — Michael Wallner — 2010-08-11T05:42:43+00:00

URL: https://externals.io/message/49283#49310 · In reply to: #49283

> Greetings hackers
>
> I spoke with Derick today, and we both agreed on releasing an alpha of
> PHP 5.4 to show the public what we have been working since 5.3. We are
> going to release an alpha at september 2nd, which meaning packaging is
> going to happen on 1st September (SVN tag, Windows binaries, etc.)

This is not going to be PHP as we know it.  It's something hybrid,
something anomalistic. I won't officially support this BS, no matter what.

Sorry,
Mike

---

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