Edit report at https://bugs.php.net/bug.php?id=60911&edit=1

 ID:                 60911
 Updated by:         g...@php.net
 Reported by:        da...@php.net
 Summary:            Confusing error message when extending traits
-Status:             Assigned
+Status:             Closed
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   OSX 10.7.2
 PHP Version:        5.4.0RC6
 Assigned To:        gron
 Block user comment: N
 Private report:     N

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2012-03-04 18:33:26] g...@php.net

Automatic comment from SVN on behalf of gron
Revision: http://svn.php.net/viewvc/?view=revision&revision=323892
Log: Fixed Bug #60911 (Confusing error message when extending traits)

------------------------------------------------------------------------
[2012-01-31 10:05:35] g...@php.net

I would still change the error message to include the hint to 'use'.
See attached patch.

------------------------------------------------------------------------
[2012-01-31 10:01:57] g...@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] larue...@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] da...@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

Reply via email to