Bug->Req #60911 [Opn->Wfx]: Confusing error message when extending traits
| From: | laruence@php.net | Date: | Tue, 31 Jan 2012 04:02:34 +0000 |
| Subject: | Bug->Req #60911 [Opn->Wfx]: Confusing error message when extending traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-166992@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60911&edit=1
ID: 60911
Updated by: laruence@php.net
Reported by: davey@php.net
Summary: Confusing error message when extending traits
-Status: Open
+Status: Wont fix
-Type: Bug
+Type: Feature/Change Request
Package: *General Issues
Operating System: OSX 10.7.2
PHP Version: 5.4.0RC6
Block user comment: N
Private report: N
New Comment:
actually this is difficult to achieve, think about:
a.php
<?php
trait Foo { }
?>
index.php
<?php
require "a.php";
trait Bar extends Foo { }
?>
then you can not get any info of Foo while parsing index.php
Previous Comments:
------------------------------------------------------------------------
[2012-01-28 05:23:52] davey@php.net
Description:
------------
While I know it should not be possible to have a trait extend another trait, the
error message is confusing, stating that you are trying to extend a class.
I understand that "use" is the correct answer to the problem the script is trying
to solve.
Test script:
---------------
<?php
trait Foo { }
trait Bar extends Foo { }
Expected result:
----------------
Fatal error: A trait (Bar) cannot extend a trait (Foo) in ...
Better yet:
Fatal error: A trait (Bar) cannot extend a trait (Foo), use "use" instead in ...
or some such.
Actual result:
--------------
Fatal error: A trait (Bar) cannot extend a class in ...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60911&edit=1