Bug #79867 [NEW]: Incorrect constructor promotion

From: Date: Thu, 16 Jul 2020 20:31:47 +0000
Subject: Bug #79867 [NEW]: Incorrect constructor promotion
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228081@lists.php.net to get a copy of this message
From: slavcopost at gmail dot com Operating system: * PHP version: 8.0.0alpha2 Package: *General Issues Bug Type: Bug Bug description:Incorrect constructor promotion Description: ------------ Confusing with constructor promostion result. I got warning where I shouldn't, as far I undestand the RFC. snippet: https://3v4l.org/SKTie Test script: --------------- <?php class A { public function __construct( public $a = 1 ) {} } class B extends A { public function __construct( public string $b = 'hello' ) {} } $b = new B(); var_dump($b->a, $b->b); Expected result: ---------------- As far I understand it's the same code after deshugaring w/o any warnings with output ``` NULL string(5) "hello" ``` snippet: https://3v4l.org/HM5s0 ```php <?php class A { public function __construct( public $a = 1 ) {} } class B extends A { public function __construct( public string $b = 'hello' ) {} } $b = new B(); var_dump($b->a, $b->b); ``` Actual result: -------------- Warning: Undefined property: B::$a in /in/SKTie on line 16 NULL string(5) "hello" -- Edit bug report at https://bugs.php.net/bug.php?id=79867&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79867&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79867&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79867&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79867&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79867&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79867&r=support Expected behavior: https://bugs.php.net/fix.php?id=79867&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79867&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79867&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79867&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79867&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79867&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79867&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79867&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79867&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79867&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79867&r=mysqlcfg

« previous php.bugs (#228081) next »