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

 ID:                 60145
 Updated by:         g...@php.net
 Reported by:        ninzya at inbox dot lv
 Summary:            interface + use trait yields error for the abstract
                     class?
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Any
 PHP Version:        5.4.0beta2
 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.

Fixed with SVN rev 318625.


Previous Comments:
------------------------------------------------------------------------
[2011-11-01 00:39:05] g...@php.net

Automatic comment from SVN on behalf of gron
Revision: http://svn.php.net/viewvc/?view=revision&revision=318625
Log: Fixed Bug #60145 (Usage of trait's use statement inside interfaces not 
properly checked.)

------------------------------------------------------------------------
[2011-10-26 20:28:38] ninzya at inbox dot lv

Description:
------------
The code in the test script contains one trait and an interface, that uses this 
trait ("use TestTrait"). What I was trying to do here is to see how PHP behaves 
if 
i include "use" statement inside interface definition.

Suprisingly, test script produces very interesting result - I get a fatal error 
with the following text: "Class TestInterface contains 1 abstract method and 
must 
therefore be declared abstract or implement the remaining methods 
(TestInterface::b)". It looks like PHP's compiler messes up when I mix 
interfaces 
together with "use" statement and somehow treats "TestInterface" as an abstract 
class.

I didn't go deeper to look into the problem as it's pretty clear that something 
is 
wrong here. In my opinion, PHP should not allow usage of "use" statment inside 
interface defitions.

Test script:
---------------
trait TestTrait {

}

interface TestInterface {
        use TestTrait;

        public function b();

}

Expected result:
----------------
PHP Fatal error: use of "use" statement in interfaces is not allowed.

Actual result:
--------------
PHP Fatal error: Class TestInterface contains 1 abstract method and must 
therefore 
be declared abstract or implement the remaining methods (TestInterface::b).


------------------------------------------------------------------------



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

Reply via email to