I was developing a Joomla! "Module" where I had written the following lines of codes in my "helper.php" file:

$i = 0;
$lists[] = array();

foreach($files as $file)
{
    $lists[$i]->image = JPath::clean( $path.'/'.$file, '/' ); // This line was triggering Waring Message
    $i++;
}

While testing this module in my development PC, my test Joomla! site was giving me the following error:

Warning: Attempt to assign property of non-object in D:\xampp\htdocs\j315\modules\mod_newsschedule\helper.php on line 51

The error occurs because $lists[$i] has not been defined yet as an object and PHP instantiated a default object (of type stdClass) implicitely. To solve this problem I just rewrite the line and my problem was solved.

$lists[$i] = new stdClass();

My final code looked like the following and the warning message was gone:

i = 0;
$lists[] = array();

foreach($files as $file)
{
    $lists[$i] = new stdClass();
    $lists[$i]->image = JPath::clean( $path.'/'.$file, '/' );
    $i++;
}

Hope this helps.

N.B. : Xampp 1.8.1 32-bit was using for my development environment.

Other articles of this category: