Req #60911 [Wfx->Asn]: Confusing error message when extending traits
| From: | gron@php.net | Date: | Tue, 31 Jan 2012 10:05:35 +0000 |
| Subject: | Req #60911 [Wfx->Asn]: Confusing error message when extending traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167000@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: gron@php.net
Reported by: davey@php.net
Summary: Confusing error message when extending traits
-Status: Wont fix
+Status: Assigned
Type: Feature/Change Request
Package: *General Issues
Operating System: OSX 10.7.2
PHP Version: 5.4.0RC6
-Assigned To:
+Assigned To: gron
Block user comment: N
Private report: N
New Comment:
I would still change the error message to include the hint to 'use'.
See attached patch.
Previous Comments:
------------------------------------------------------------------------
[2012-01-31 10:01:57] gron@php.net
The following patch has been added/updated:
Patch Name: extend-error-msg.patch
Revision: 1328004117
URL: https://bugs.php.net/patch-display.php?bug=60911&patch=extend-error-msg.patch&revision=1328004117
------------------------------------------------------------------------
[2012-01-31 04:02:34] laruence@php.net
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
------------------------------------------------------------------------
[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