Bug #77291 [Fbk->Opn]: __isset() magic method doesn't work if implemented via a trait.

From: Date: Thu, 13 Dec 2018 23:32:30 +0000
Subject: Bug #77291 [Fbk->Opn]: __isset() magic method doesn't work if implemented via a trait.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218437@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77291&edit=1 ID: 77291 User updated by: tandrewbennett at hotmail dot com Reported by: tandrewbennett at hotmail dot com Summary: __isset() magic method doesn't work if implemented via a trait. -Status: Feedback +Status: Open Type: Bug Package: *General Issues Operating System: Ubuntu 16.04 PHP Version: 7.3.0 Block user comment: N Private report: N New Comment: 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 git@github.com:tabennett/php-7.3.0-error.git CD into the app composer install vendor/bin/phpunit 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. Previous Comments: ------------------------------------------------------------------------ [2018-12-13 09:31:04] danack@php.net This appears to work for me on PHP 7.3.0 https://3v4l.org/i9Lpv Please can you try with OPCache disabled, and/or disabling any non-core extensions you have enabled? ------------------------------------------------------------------------ [2018-12-13 07:10:11] tandrewbennett at hotmail dot com Description: ------------ 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77291&edit=1

« previous php.bugs (#218437) next »