Web lists-archives.com

[PHP] Re: Weird error with PHP7: Cannot access property

On 04.05.2016 at 06:25, Côme Chilliet wrote:

> I’m working on a PHP software, FusionDirectory.
> It works fine with PHP 5 but I’m getting strange errors with PHP-7.
> As far as I know it does not use anything that is mentionned in the migration guide.
> I get this error:
> Uncaught Error: Cannot access  property filter::$initial in /usr/share/fusiondirectory/include/class_filter.inc:425

I found the double space between "access" and "property" remarkable (I
suppose that it is actually part of PHP's error message, and not a typo
in your mail).  So I did a search in php-src, and found the the line
where this message is likely to be generated:

Apparently, zend_visibility_string() returns "" here instead of the
supposed "public".  There might be a bug in PHP-7.  To track the issue
down it might be useful, if you see what happens when you explicitly
declare the variable as pulic (i.e. `public $initial` instead of `var
$initial`).  In any case, consider to file a bug report on

> The other weird thing I’m getting is a lot of errors about using an integer as an object, in most classes using a config member, usually initialized like this:
>  function __construct (&$config, $dn = NULL, $object = NULL)
>  {
>  $this->config = &$config;
> Is there a change in the reference system in PHP7?

Actually, the internal representation of values has completely been
overhauled, see e.g.

> This worked fine before, and now config is turning to an integer at some point, I’m not sure how to debug this.

I'm not sure either.  Usually, I prefer to avoid references at all, see

Christoph M. Becker

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php