Types, Type Hinting, Casting

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Types, Type Hinting, Casting

Post by kaisellgren »

I'm a bit confused, when will PHP support type hinting? I thought 5.3 was supposed to support parameter type hinting, but apparently not.

I am also wondering what you guys do when you have a situation where a method returns binary data. Do you define the return type to be binary or string or what? For example:

Code: Select all

/**
* @return binary
*/
function something()
{
 return (binary) $something;
}
or do you just use string (since there is no binary type)? What about situations where you accept string/binary data for a parameter, do you use string, binary or mixed? I'm talking about the PHPDoc syntax @param and @return that specifies the type.

The difference between binary and string is simple: a string is encoded in Unicode in PHP 6+.

Oh and if anyone is running PHP 6, can you confirm that

Code: Select all

echo strlen((string) ((binary) "è"));
returns 1?
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Re: Types, Type Hinting, Casting

Post by jason »

User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Types, Type Hinting, Casting

Post by kaisellgren »

It doesn't really tell anything, or are you hinting at some comments?
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Re: Types, Type Hinting, Casting

Post by jason »

It was just in response to your first question about type hinting.
I'm a bit confused, when will PHP support type hinting? I thought 5.3 was supposed to support parameter type hinting, but apparently not.
Maybe your asking for something different, but I figured that was what you were looking for.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Types, Type Hinting, Casting

Post by daedalus__ »

i don't think you can hint primitive types. and i think that there is a distinct type for binary strings in php6.

and i dont use php doc either so can't help you there sorry P:
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Types, Type Hinting, Casting

Post by kaisellgren »

The manual says nothing about type hint support (except for the obvious array + object that has been around for quite some time).

I found one interesting post by Ilia http://ilia.ws/archives/207-Type-Hintin ... usion.html

So it seems no one knows the answer.

I'm still interested in hearing your PHPDoc preferences though.
Post Reply