|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77291 magic methods inherited from a trait may be ignored
Submitted: 2018-12-13 07:10 UTC Modified: 2019-01-07 22:53 UTC
From: tandrewbennett at hotmail dot com Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 7.3.0 OS: Ubuntu 16.04
Private report: No CVE-ID: None
 [2018-12-13 07:10 UTC] tandrewbennett at hotmail dot com
The __isset() magic method is no longer invoked on a class if implemented via a Trait.

Test script:
trait AccessibleProperties
    public function __isset($property)
        return property_exists($this, $property);

    public function __get($property)
        if (property_exists($this, $property)) {
            return $this->$property;

class Foo {
    use AccessibleProperties;

    protected $a = 'Some value';

$foo = new Foo;
$foo->a;        // this works: returns 'Some value'
isset($foo->a); // this doesn't work: returns false


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-13 09:31 UTC]
-Status: Open +Status: Feedback
 [2018-12-13 09:31 UTC]
This appears to work for me on PHP 7.3.0

Please can you try with OPCache disabled, and/or disabling any non-core extensions you have enabled?
 [2018-12-13 23:32 UTC] tandrewbennett at hotmail dot com
-Status: Feedback +Status: Open
 [2018-12-13 23:32 UTC] tandrewbennett at hotmail dot com
So this seems to go beyond the scope of what I originally thought. I think this is somehow related to autoloading (but I'm not quite sure). I've created a sample app to reproduce the error:

git clone
CD into the app
composer install

If you rename Foo to a class that has two words (e.g FooBar) this error goes away! Alternatively, if you set the PSR-4 namespace in composer.json to something with two words it also goes away.
 [2018-12-14 00:34 UTC] tandrewbennett at hotmail dot com
Also, here is an updated version from (wrapping in namespaces triggers the error) if you don't want to clone down the demo repo I created.
 [2018-12-14 19:13 UTC]
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2018-12-14 19:13 UTC]
Thanks for reporting this issue, and for providing a simple

This regression has been introduced with commit 43aca31[1].  It is
not particularly related to namespaces, and does not only affect
__isset(), but rather all magic methods which are inherited from a
trait, whose name has the same length as the class name, see, for
instance, <>.
 [2018-12-14 19:30 UTC]
The following pull request has been associated:

Patch Name: Fix #77291: magic methods inherited from a trait may be ignored
On GitHub:
 [2018-12-16 12:43 UTC]
Automatic comment on behalf of
Log: Fix #77291: magic methods inherited from a trait may be ignored
 [2018-12-16 12:43 UTC]
-Status: Analyzed +Status: Closed
 [2019-01-07 22:53 UTC]
-Summary: __isset() magic method doesn't work if implemented via a trait. +Summary: magic methods inherited from a trait may be ignored
 [2019-01-07 22:53 UTC]
To clarify: the length of the class name is supposed to mean the
resolved class name as would be provided by the magic ::class
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 15:01:29 2023 UTC