Track:
Coder
Experience:
Intermediate The lack of proper namespacing for PHP functions and classes is causing lots of problems for Drupal:
- A PHP library could redeclare a function or class that already exists in Drupal - causing PHP to abort.
- In a magic function / hook implementation there is ambiguity of where the module name ends and the hook name begins, e.g. views_comment_load() - is the hook 'comment_load' or 'load'?
- Modules can inadvertently implement a hook for some other module.
- Multiple modules can 'invent' the same hook, expecting it to do different things.
These problems can be fixed through a combination of 2 methods:
- Using PHP 5.3 namespaces: http://php.net/manual/en/language.namespaces.php
- Redesigning the magic function / hook implementation naming system using __
See http://bluedroplet.com/blog/proposal-fixing-php-namespacing-drupal-8
Discussions about namespacing are ongoing, so the proposal may be different by Drupalcon.
Older discussions: http://drupal.org/node/867772 http://drupal.org/node/548470
Intended audience:
Anyone who writes Drupal code.
Core developers.
Crell. (specific enough?)
(21 votes)