Bug #75607 [Opn->Ver]: b/c break in traits causes fatal error
| From: | pmmaga@php.net | Date: | Fri, 01 Dec 2017 21:31:49 +0000 |
| Subject: | Bug #75607 [Opn->Ver]: b/c break in traits causes fatal error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212873@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75607&edit=1
ID: 75607
Updated by: pmmaga@php.net
Reported by: stuart at stuartherbert dot com
Summary: b/c break in traits causes fatal error
-Status: Open
+Status: Verified
Type: Bug
Package: Class/Object related
Operating System: Ubuntu 17.10
PHP Version: 7.2.0
-Assigned To:
+Assigned To: pmmaga
Block user comment: N
Private report: N
New Comment:
I've added a PR with a fix for the issue.
Previous Comments:
------------------------------------------------------------------------
[2017-11-30 21:41:38] stuart at stuartherbert dot com
Description:
------------
In 7.2.0, using two traits that define the same static property cause a fatal error. Only static
properties are affected.
I've put this up on https://3v4l.org/oi4ns to show the
behaviour on different PHP versions.
I couldn't find this documented in the PHP 7.2.0 release notes / migration guide.
Test script:
---------------
https://3v4l.org/oi4ns
<?php
trait T1
{
public static $prop1 = 1;
}
trait T2
{
public static $prop1 = 1;
}
class Base
{
use T1;
}
class Child extends base
{
use T2;
}
Expected result:
----------------
Expected behaviour:
- no fatal errors, no warnings, code executes
Actual result:
--------------
Actual behaviour:
- fatal error: Fatal error: Base and T2 define the same property ($prop1) in the composition of
Child. However, the definition differs and is considered incompatible. Class was composed in
/in/oi4ns on line 18
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75607&edit=1