OSInet library converted to PSR0 / PSR1

Over the last few days, I finally decided to revisit the old OSInet PHP library, to dust it off somehow, and convert the class-based parts to PSR0 and the whole to what seems to be liable to become PSR1 at some point.

This library contains a zoo of function helping with PHP-GTK development, and three packages with their demo application:

Class Grapher
Build a graph of inheritance and interface implementations on a directory (and subdirectories) of PHP code
This package uses the Drupal Grammar Paser to parse code, and includes a Drush 5 plugin for easy use within a Drupal site, but can also be used to parse non-Drupal code, as long as the Grammar Parser - which does not depend on Drupal either - is installed in the include path.
It is a more complete version of the Drupal-only Class Grapher sandbox on
In the current version, graphs are generated using GraphViz. An extension to a client-side visualization tool like the Infovis toolkit should come someday. Suggestions for other client-side libraries welcome (please comment!).
Open Document Calc reader
This package provides a few classes and methods to extract the content of OpenDocument (LibreOffice,, ...) spreadsheets.
Finite State Machine
This package is used to build applications designed around a finite state machine, and is mostly intended for use in PHP-GTK applications, to provide asynchronous processing.
The demo application uses the PHP FTP extension to expose its asynchronous notifications in a PHP-GTK UI

Optimizing strings in PHP ?

Every so often, I get asked about whether it is really worth it to chase double quotes and constructs like print "foo $bar baz", and replace them with something like echo 'foo', $bar, 'baz', or even to remove all those big heredoc strings so convenient for large texts.

Of course, most of the time, spending hours to fine comb code in search of this will result in less of a speedup than rethinking just one SQL query, but the answer is still that, yes, in the infinitesimal scale, there is something to be gained. Even with string reformatting ? Yes, even that. But only if you are not using an optimizer.

Just don't take my word for it, Sara Golemon explained it years ago with her "How long is a piece of string" post, in 2006.

Debug vanilla

Most of the time, when working on some piece of code, I'll resort to the configured debugger in my current Zend Studio configuration. And you probably do too :-)

However, I often have to access debug-type information on live sites where installing a debugger is out of the question, and I find myself often resorting to parameter dumps like the following:
// lazy version for simple cases
function foo_bar($x, $y, $z) {
// [...]

// less lazy version for more hairy cases
function foo_baz($x, $y, $z) {
dsm(array('in foo_baz, x' => $x, 'y' => $y, 'z' => $z));
// ...

You've probably being using it too and, of course, after the first few dozen times, it becomes a bit used. So here's a tiny snippet that makes such dumps simpler to type and use :

A Gray code generator in PHP

For a recent case, I had to define the behaviour of a system with a lot of independent conditions to check, which could trigger any number of a set of messages and actions on data, and all of this based on a plain english (i.e. non algorithmic) description of the data, which only covered the most commons scenarios for these conditions, leaving lots of undefined combinations of inputs. What's one to do in such cases ?

Formatting PHP code in Eclipse PDT and Zend Neon

By default, the current Eclipse-based PHP IDE (PDT) uses an indenting style based on One True Brace, and the upcoming Zend Neon version happens to be also Eclipse-based. For developers working with OSInet Drupal modules or PHP-GTK code, or anyone wishing to apply the OSInet coding style, or another form of Whitesmiths / Symbian PHP formatting, Eclipse allows for customizing the bracing/commenting style by hand-tuning, o