Re: Weird error with PHP7: Cannot access property
| From: | Christoph Becker | Date: | Wed, 04 May 2016 15:05:46 +0000 |
| Subject: | Re: Weird error with PHP7: Cannot access property | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325576@lists.php.net to get a copy of this message | ||
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:
<https://github.com/php/php-src/blob/php-7.0.6/Zend/zend_object_handlers.c#L368>
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
<https://bugs.php.net/>.
> 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.
<https://nikic.github.io/2015/05/05/Internal-value-representation-in-PHP-7-part-1.html>.
> 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
<http://schlueters.de/blog/archives/125-do-not-use-php-references.html>.
--
Christoph M. Becker