TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-31-2010, 05:23 AM   #1 (permalink)
The Wanderer
 
andformore's Avatar
 
Join Date: Dec 2009
Posts: 17
Thanks: 2
andformore is on a distinguished road
Default Type Hinting in PHP 6

So, as far as i understand, php 5.whatever we're currently on supports type hinting in classes when you're dealing either with arrays or objects. But, it doesn't allow us to declare variable types of methods which accept strings, ints, booleans, and these basic types.

I read somewhere that there is a debate over whether or not they should include this in php 6. What do you all think?

Personally, I think it would be nice to have the option of writing classes this way just because I think it makes the code more self documenting and easier to deal with for future developers or my future self who might have no idea what i was doing when i wrote something.

I don't know what the downside would be.

Thoughts?
__________________
Something interesting... If you visit one of my sites today, you'll probably double my unique visitors for the day! Shameless Plugs:
My Blog My Octopus Game My Flash Card Website
andformore is offline  
Reply With Quote
Old 02-01-2010, 01:12 AM   #2 (permalink)
The Contributor
 
ryanmr's Avatar
 
Join Date: Jun 2008
Location: Twin Cities, Minnesota, USA
Posts: 44
Thanks: 3
ryanmr is on a distinguished road
Default

I think a part of PHP's beauty is that it does not have strong typing, or a distinction between types of objects and primitives.

Doing Java development shows the contrast between the two ideologies. In one, you can document things easily and do many things quickly and dynamically. In the other, you have the assurance that what you specify is what is (usually).

Type Hinting is enough for most purposes, and simple naming convention with mixed type checking should be enough for primitives.
__________________
blog twitter ifupdown
ryanmr is offline  
Reply With Quote
Old 02-01-2010, 02:25 AM   #3 (permalink)
The Wanderer
 
andformore's Avatar
 
Join Date: Dec 2009
Posts: 17
Thanks: 2
andformore is on a distinguished road
Default

I agree that its very nice not to be forced to declare variable types in PHP, and this feature is definitely an asset.

That being said, I think the option to declare them in class methods would be beneficial, so that I don't have to manually check its type later. I think its cleaner too, than naming variables like $intMyVar.

I do agree though that PHP's flexibility with variables is a beautiful thing about it
__________________
Something interesting... If you visit one of my sites today, you'll probably double my unique visitors for the day! Shameless Plugs:
My Blog My Octopus Game My Flash Card Website
andformore is offline  
Reply With Quote
Old 02-01-2010, 05:52 AM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

I'm a C programmer, so naturally I am for fairly tight type hinting. I find it one of PHPs major flaws, I like being able to know what type the variable is.
__________________

Village Idiot is offline  
Reply With Quote
Old 02-02-2010, 10:36 PM   #5 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

VI, it's called a feature, not a flaw.
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM
what are all the subjects in php? sarmenhb General 7 01-21-2008 05:41 PM
Using Type Juggling/Type Casting to Modify Data Types Wildhoney Tips & Tricks 6 11-30-2007 02:44 AM
Uploading Files with PHP daz Absolute Beginners 3 09-30-2007 06:23 PM


All times are GMT. The time now is 09:54 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design