Data not returned / rendered in simple module I built a simple module to find the files in a folder and display them.  However no "content" is rendered and I get warnings from a core-include file.  Here is the module file:

&lt;?php
function composer_example_menu() {
    $items = array();

    $items['composerExample/composer_example'] = array(
        'title' =&gt; 'Composer Demo',
        'page callback' =&gt; 'get_current_files', // 'call_back_function_name',
        'access arguments' =&gt; array('access content'),
        'type' =&gt; MENU_CALLBACK,
    );

    return $items;
}

/**
 * A utility function to return the array of current SplFileInfo objects
 */
function get_current_files()
{

  require __DIR__.'/../../../../../vendor/autoload.php';

    // the "files" directory
    $dir = drupal_realpath(file_default_scheme() . '://');

    $finder = new \Symfony\Component\Finder\Finder();
    $finder-&gt;in($dir)
        -&gt;name('*.txt')
    ;
    $files = array();
    foreach ($finder as $file) {
        $files[] = $file-&gt;getFilename();
    }
  return $files;


The Warnings  I get:


  Warning: Invalid argument supplied for foreach() in element_children() (line 6583 of /Applications/MAMP/htdocs/drupal-7.51/includes/common.inc).
  Warning: Illegal string offset '#children' in drupal_render() (line 6040 of /Applications/MAMP/htdocs/drupal-7.51/includes/common.inc).
  Warning: Illegal string offset '#children' in drupal_render() (line 6050 of /Applications/MAMP/htdocs/drupal-7.51/includes/common.inc).
  Warning: Illegal string offset '#children' in drupal_render() (line 6088 of /Applications/MAMP/htdocs/drupal-7.51/includes/common.inc).
  Warning: Illegal string offset '#printed' in drupal_render() (line 6095 of /Applications/MAMP/htdocs/drupal-7.51/includes/common.inc).
The value returned from the page callback will be passed into the function stated in delivery callback.

The default value of delivery callback is drupal_deliver_html_page().


  "delivery callback": The function to call to package the result of the page callback function and send it to the browser. Defaults to drupal_deliver_html_page() unless a value is inherited from a parent menu item. Note that this function is called even if the access checks fail, so any custom delivery callback function should take that into account. See drupal_deliver_html_page() for an example.


So you cannot output the $files directly. You have to return a render array if you want to keep using the default delivery callback.