Bug #73647 [NEW]: stdClass is not inherited if the class definition doesn't explicit it.

From: Date: Sat, 03 Dec 2016 21:04:56 +0000
Subject: Bug #73647 [NEW]: stdClass is not inherited if the class definition doesn't explicit it.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205748@lists.php.net to get a copy of this message
From: klaussantana at gmail dot com Operating system: any PHP version: 7.0.13 Package: Scripting Engine problem Bug Type: Bug Bug description:stdClass is not inherited if the class definition doesn't explicit it. Description: ------------ For some reason, if you not explicit extends a class from stdClass it will not pass the instanceof test. Test script: --------------- <?PHP /**** * stdClass Inheritance Failure * ================================================================================ * * This example shows how stdClass is not inherited in classes definitions that * do not explicit it. * */ class InstableDefinition {} class StableDefinition extends stdClass {} class AnotherInstableDefinition extends InstableDefinition {} class AnotherStableDefinition extends StableDefinition {} $Objects = [ 'Instable Object' => new InstableDefinition, 'Stable Object' => new StableDefinition, 'Another Instable Object' => new AnotherInstableDefinition, 'Another Stable Object' => new AnotherStableDefinition, ]; foreach ( $Objects as $Object ) { $ObjectClass = get_class($Object); $ObjectStandard = $Object instanceof stdClass; $ObjectEvaluates = $ObjectStandard ? 'does' : "doesn't"; echo "The {$ObjectClass} class objects {$ObjectEvaluates} instance from stdClass." .PHP_EOL; } echo 'All these tests ran under PHP version ' .PHP_VERSION .'.' .PHP_EOL; Expected result: ---------------- The InstableDefinition class objects does instance from stdClass. The StableDefinition class objects does instance from stdClass. The AnotherInstableDefinition class objects does instance from stdClass. The AnotherStableDefinition class objects does instance from stdClass. All these tests ran under PHP version 7.0.13. Actual result: -------------- The InstableDefinition class objects doesn't instance from stdClass. The StableDefinition class objects does instance from stdClass. The AnotherInstableDefinition class objects doesn't instance from stdClass. The AnotherStableDefinition class objects does instance from stdClass. All these tests ran under PHP version 7.0.13. -- Edit bug report at https://bugs.php.net/bug.php?id=73647&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73647&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73647&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73647&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73647&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73647&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73647&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73647&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73647&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73647&r=support Expected behavior: https://bugs.php.net/fix.php?id=73647&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73647&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73647&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73647&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73647&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73647&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73647&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73647&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73647&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73647&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73647&r=mysqlcfg

« previous php.bugs (#205748) next »