-
Website
http://blog.perplexedlabs.com/ -
Original page
http://www.perplexedlabs.com/2009/04/22/php-named-parameters/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
Max "WorldMaker" Battcher
1 comment · 1 points
-
TJ Mapes
1 comment · 1 points
-
Traveller_Adventure
1 comment · 2 points
-
Joe Devon
1 comment · 1 points
-
Shai
1 comment · 1 points
-
-
Popular Threads
-
Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)
4 weeks ago · 1 comment
-
Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)
how is this clearer than just making every function in your object have a signature such as:
function foo($opts=array()) { return $blah; }
yes, you get some default named parameter value handling from some boilerplate code ... but it appears you're limiting what kinds of parameters you are able to pass around ... imho this looks like over-engineering that'll lead to coding yourself into a corner.
Because PHP doesn't natively support true named parameter passing this is mostly a "hack".
Also, because PHP is loosely typed and you can't specify that a certain method parameter only accept an Object, I can't think of any way to handle that special case.
I wouldn't suggest this solution be adopted for general programming in PHP however there are some specific cases where this can be very useful. One of them would be in the creation of Rails like helper methods for a view (which is where I'm using it now in my own projects).
This is not python, it is PHP, get used to it having his own ways(most of them bad ways)