This project is not covered by Drupal’s security advisory policy.

Detected possibly uninitialized variables

This module is extension for the Coder module and it uses slightly modified php-initialized tool from Jakub Vrána to detect uninitialized variables. I have been using this tool for year now and based on my experience I must admit it helps me to find a lot of bugs, despite it generates also significant number of false positives. It allows to quickly find bugs in the completely unknown code because you can focus only on the parts which generated the warnings. E.g. finding 10 uninitialized variables in the thousand lines of the Media module including 2 regular bugs took me about half an hour.

You can try the original implementation online at author's website:

Tool for those who loves or hates developing for Drupal

The module aims to reduce number of notices which Drupal generates - especially the contrib modules - when E_ALL error reporting mode is enabled, because using php variables without initialization seems to be a common habit in the Drupal world and it can be seen even in the core. When you want to begin some serious development with E_ALL or E_STRICT error reporting enabled, you often need to spend half day or more to fix bugs in ten other modules before you just begin with your module development.


  1. Download Coder module and its dependencies and enable
  2. Download this module
  3. Download the modified php-initialized tool from branch "no-include" (*) and place it to coder_initialized/php-initialized directory.

Note (*): php-initialized tool is released under Apache license, version 2.0 which isn't compatible with the Drupal's GNU GPL v2 license so it can't be distributed together with the module due to policy.

Todo list:

  • Drush integration
  • Use Libraries API
  • Better Drupal integration
  • Reduce false positives
  • Integrate php-initialized tests


What kind of errors the php-initialized tool detects?

// Uninitialized variable $items
function my_module_menu() {
  $items[] = array(
    'title' => 'My page',
  return $items;

// Uninitialized variable $output
foreach ($items as $item) {
  $output .= $item->title . ', ';

// Forgotten variables $v and $k
$output = '';
foreach ($items as $key => $value) {
  $output .= $k . ' => ' . $v;

False positives

There are significant number of false positives which I want to reduce in the future development.

if ($a = 1) {
  $b = 1;
else {
  $b = 2;

// $b is detected as unitialized
$c = $b;


Project information

  • chart icon627 downloads
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.