error_get_last() returns NULL after valid error in Drush
Drush sets an error handler via set_error_handler('drush_error_handler');.  This interferes with the operation of error_get_last()`, as php resets the last error when the error handler is called; error_get_last() always returns NULL with an error handler, even if it is the first function called in the handler.

Since there is no way to disable the Drush error handler, this prevents the use of error_get_last() in Drush command files.  For a quick test, you could always temporarily comment out the call to set_error_handler in Drush.