1 / 15

What Does PHP 5.3 Mean for Drupal?

What Does PHP 5.3 Mean for Drupal?. C.M. Lubinski Drupal Camp Chicago 2010-06-26. And you are . . . ?. C.M. Lubinski By Day: PHP Developer By Night: Drupal Enthusiast By Interest: Language Connoisseur cmc on #cdmug. What's all this then?. New Features, Top Five-ish

malia
Download Presentation

What Does PHP 5.3 Mean for Drupal?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What Does PHP 5.3 Mean for Drupal? C.M. Lubinski Drupal Camp Chicago 2010-06-26

  2. And you are . . . ? C.M. Lubinski • By Day: PHP Developer • By Night: Drupal Enthusiast • By Interest: Language Connoisseur • cmc on #cdmug

  3. What's all this then? • New Features, Top Five-ish • Problems and Incompatibilities • Hopes and Realities of Drupal Core

  4. Number Five: Garbage Collection PHP < 5.3 • Reference Counting • Does Not Catch Cyclic References • Example: Doubly-Linked List • Not a big problem for Drupal New Functions • gc_enable / gc_disable / gc_enabled • gc_collect_cycles

  5. Number Four: Date/Time Changes DateInterval • Object with fields for each unit • DateTime->add/sub • DateTime->diff • Not as intelligent as one would hope DatePeriod • "Traversable" (i.e. foreach-able) • Constructors: • Start, Interval, Number of Occurrences • Start, Interval, End • ISO String

  6. Number Three: New SPL Classes Data Structures • SplDoublyLinkedList • SplStack • SplQueue, SplPriorityQueue • SplHeap, SplMinHeap, SplMaxHeap • SplFixedArray Iterators • FilesystemIterator • GlobIterator • MultipleIterator • etc.

  7. Number Two: Anonymous Functions and Closures Anonymous Function • A function that can be passed as a variable • An object which can be called Closure ("use") • An anonymous function with state • Cannot be serialized Use Cases • Anywhere a callback is needed • Sort • String Replacement • *Not* Drupal Menu Callbacks

  8. Number One point Five: __invoke() • Treat an object as a function • Can be used as a callback • Serializable closure Use Cases • Factories • Track Generated Instances • Compound Function (e.g. SQL query) • Conciseness

  9. Number One: Namespaces • Modularize Code • Can Alias a Namespace • class_name() includes absolute path • Offers OO Benefits Without Objects • Not Dynamic • Cannot • use 'Drupal\Modules\' . $module_name; • Can • $func = 'Drupal\Modules\' . $module_name . '\Hooks\menu';  

  10. But That's Not All! • PHAR, the PHP archive • MySQL driver is now native • ?: • Improvements to static classes/methods • array_replace • Faster! • Even more

  11. Not Without Its Problems: GOTO     goto 'beginning'; logic: the logical progression of the program.     exit(); beginning: GOTO makes code     goto 'stringy'; point: to the point where it's hard to understand     goto 'logic'; stringy: needlessly unreadable     goto 'point';

  12. Incompatibilities: Ereg is Dead • Represents regular expressions for egrep • Defined in 1986 • Not as powerful (or fast) as preg_* • No \w, \s, etc. • No lazy evaluation • No "look-around"s •  Converting is simple • Wrap previous regex is appropriate delimiter • split is also dead

  13. Incompatibilities: By-Reference • Call-time pass-by-reference has been deprecated • Don't use references when calling functions • Except call_user_func_array  • Caused many issues with D6 • allow_call_time_pass_reference in php.ini

  14. 5.3 and Drupal Core Drupal 6 • Still Supports PHP4 • Drupal >= 6.14 Supports PHP 5.3 • Contrib does not Drupal 7 • Requires PHP 5.2 • Contrib will have better support for 5.3 • Use the "php" option in module.info • "Mapper" functions will still be needed Drupal 8 • Here's Hoping

  15. References, Questions and a Book http://us2.php.net/migration53http://drupal.org/node/360605 Thanks!CM Lubinskihttp://cmlubinski.info

More Related