ZS DLTK error - Interface cannot be implemented by Trait.

General discussion on Zend Studio
Post Reply
ausdev6000
Posts: 17
Joined: Sat Nov 26, 2011 7:59 am

ZS DLTK error - Interface cannot be implemented by Trait.

Post by ausdev6000 » Tue Jul 17, 2012 9:09 am

Issue: Zend Studio fails to recognise that a method in an interface has been implemented by a trait.
This code runs fine in practice, so Zend Studio should not report an error.

This error is discouraging trait use for me.
ZS20120625 wrote: Class 'AClass' must implement inherited abstract method 'test(...)'
AClass.php

Code: Select all

<?php
namespace ZSB;
class AClass implements BInterface {
    use CTrait;
} 
BInterface.php

Code: Select all

<?php
namespace ZSB;
interface BInterface {
    public function test();
} 
CTrait.php

Code: Select all

<?php
namespace ZSB;
trait CTrait {
    public function test() { echo 'Works fine'; }
} 

ausdev6000
Posts: 17
Joined: Sat Nov 26, 2011 7:59 am

Re: ZS DLTK error - Interface cannot be implemented by Trait

Post by ausdev6000 » Tue Jul 17, 2012 9:55 am

Zend Studio has other problems with trait support as well.
The following apply at least to Traits in a namespace.
  • Resolving to a declaration. Zend Studio cannot resolve traits, causing the following errors.
  • If a trait that does not exist is used there is no error.
  • Pressing F3 to open the Trait doesn't work, though it works on Classes and Interfaces.
  • Hovering over the trait name where it is used in a class does not display the trait's name. It displays "Occurrence of 'CTrait'" instead of trait icon ZSB\CTrait.
  • Traits do not appear in the Outline window for a Class.
Additionally, Traits are treated like Classes or Interfaces when they are clearly not suited:
  • There is no New -> Trait right-click context menu item.
  • Hovering over the trait name where the trait is defined shows the class icon.
  • There isn't an icon for traits.
  • The New -> Class wizard allows you to choose a Trait in the Superclass Browse menu.
  • If you attempt extends CTrait the error given is "Cannot extend from interface 'CTrait'", while attempting implements reports it as not found.

jaimz
Posts: 17
Joined: Tue Nov 02, 2010 3:18 am

Re: ZS DLTK error - Interface cannot be implemented by Trait

Post by jaimz » Mon Aug 27, 2012 5:55 pm

I just wanted to expand on this. (and give it a bump because traits are broken in zend studio 9)

I created a trait with abstract methods:

Code: Select all

<?php
trait awesomeTrait
{
	abstract public function coolMethod();
}
when I do this, Zend Studio flags THE TRAIT as containing errors, the message is:
Description Resource Path Location Type
Class 'awesomeTrait' must implement inherited abstract method 'coolMethod(...)' dataObject.php /MyAwesomeTrait.php line 2 DLTK Problem
ALSO! when you right click on a class that is using the awesomeTrait trait, you can't see the abstract trait methods in the "Override / implement methods" dialog

it's almost as if the person responsible for making ZS9 work with traits decided that people weren't going to use them much so there was no need to put forth the effort. It's a bit upsetting, it's completely opposite of what I've come to expect from Zend Studio :(

ausdev6000
Posts: 17
Joined: Sat Nov 26, 2011 7:59 am

Re: ZS DLTK error - Interface cannot be implemented by Trait

Post by ausdev6000 » Tue Aug 28, 2012 4:32 am

I'm hoping the silence from Zend means they're working on something hard, like moving to the new Eclipse version.

storeman
Posts: 1
Joined: Wed Sep 22, 2010 2:20 pm

Re: ZS DLTK error - Interface cannot be implemented by Trait

Post by storeman » Thu Jun 06, 2013 1:52 pm

Same here, hopefully this will be solved soon.

Post Reply