From: bouanto at gmail dot com Operating system: all PHP version: 5.4.6RC1 Package: Unknown/Other Function Bug Type: Feature/Change Request Bug description:Named function parameters
Description: ------------ Hello! I know this feature request has been made a few times in the last years, but I want to reopen this request to add arguments in favor to this feature request. It would be really nice for developper to be able to call a function like this: func($param1 => 'value1', $param2 => 'value2'); or a similar way. The func function would be defined that way: function func(...$options) {} or another syntax. This way, we've got not problem with documentation if we compare to the "array- way". The goal of this syntax is to simplify the function call and get shorter code. Not convinced? Let's compare two web framework: one in a language that support named function parameters and one that doesn't. Drupal (PHP) and Django (Python). Drupal uses the "array-way" as you recommend. Here is the way Drupal allows us to create a database table model: http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_schema/7 (go down to the code section) And look at the "named-parameter-way" in Django in the Test script. The code is almost five times shorter in python, because of the use of named parameters. It is the primary reason to include this syntax in PHP: we can get shorter and cleaner code. Thanks for considering this feature request once again. And I hope you will do the right choice now. I am open to argumentation. Test script: --------------- Python code almost equivalent to the Drupal code: from datetime import datetime from django.db import models class Node(models.Model): vid = models.PositiveIntegerField(default=0, null=False, unique=True) changed = models.DateTimeField(default=datetime.now, db_index=True, null=False) created = models.DateTimeField(default=datetime.now, db_index=True, null=False) type = models.CharField(default='', max_length=32, null=False) title = models.CharField(default='', max_length=255, null=False) revision = models.ForeignKey('NodeRevision') author = models.ForeignKey('User') -- Edit bug report at https://bugs.php.net/bug.php?id=62787&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62787&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62787&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62787&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62787&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62787&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62787&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62787&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62787&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62787&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62787&r=support Expected behavior: https://bugs.php.net/fix.php?id=62787&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62787&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62787&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62787&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62787&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62787&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62787&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62787&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62787&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62787&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62787&r=mysqlcfg