Understanding the notice
The message means that a property is being set which is accessed with a magic accessor - it's not going to actually do anything. It is equivalent to this:
<?php
class Foo {
function __get($prop) {
return [];
}
}
$foo = new Foo;
$foo->bar['zum'] = "x";
print_r($foo->bar); // []
In this contrived example the property "bar" does not exist, and so the magic getter is called returning an empty array - the code is attempting to append/write to this magic-getter-returned-value and emits the same notice:
Notice: Indirect modification of overloaded property Foo::$bar has no effect in /tmp/overload-example.php on line 12
As shown by the print_r
call, the value of $foo->bar
has not changed.
The normal solution is to declare the property so that the magic getter is not used i.e.:
class Foo {
public $bar = []; // Now it can be modified.
However in this case that's not the most appropriate thing to do.
Helpers changed from 1.x to 2.x
The constructor for all helpers changed in 2.x which is in the migration guide. Read the migration guide in detail, especially if you encounter a problem.
In 1.3 all helpers extend the helper class, it doesn't have a constructor, and does not keep a reference to the view. In 2.x all helpers extend the same class but do have a constructor and do keep a reference to the view class. There are 2 steps related to this error to upgrade the helper to be 2.x compatible
Change the constructor:
There is no need to repeat logic the parent constructor is doing for you so just call __loadHooks
(if necessary):
function __construct(View $View, $settings = array()) {
$this->__loadHooks();
return parent::__construct($View, $settings);
}
Change references to $this->View
All helpers have access to the view instance, just find and replace in your helper code replacing this:
$this->_View
With this:
$this->View