Code Completion on type hinting with interfaces |
Site Admin
|
Hello David,
Thanks for your words regarding PHPED. Sure, this issue will be addressed and I'm adding it to our plans with rather high priority. Thanks for the code sample too. It may make sense for you to try intermediate builds so you'd make sure that we're on the same page regarding Code completion improvements. -dmitri. |
||||||||||||
|
Site Admin
|
works in 4042
hmm... myObj2 has no hi() method... yes, I do understand that it comes with myObj2 interface, but isn't it too quirky |
||||||||||||||||
|
|
Suppose that I have 2 concrete classes that extend the class myObj2. I can't instantiate myObj2 objects directly (it's an abstract class) so I need to instantiate the other 2 concrete classes derived from myObj2. If I need a method that operates on both 2 concrete classes in a similar fashion, then the code will look something like this:
Hopefully you see how I'm trying to use an abstract class (that doesn't explicitly declare a function) as a type hint David |
||||||||||||||
|
Site Admin
|
what you're trying to explain was clear from the first code sample.
I'm talking about ambiguity of the language. Either you need interfaces or abstract classes. Effectively they are the SAME. Using them together makes very little sense to me. In particular, why don't you pass the interface instead of abstract class? Alternatively, why don't you forget of the interface and add all abstract methods into your abstract class? Both variants would work fine in PHPED. |
||||||||||||
|
|
The reason why I'm using interfaces and abstract classes is because I may need to derive an abstract class from multiple interfaces and extend another class as an abstract class that is the basis for more extension. I can't have a class extend two classes but I can have it implement more than one interface. On the same principle I may need to derive a class from an abstract class (with all it's class data members) and also from another interface that is unrelated. So while I do agree with you that functionally interfaces and abstract classes are more or less the same, language wise I can't extend 3 abstract classes like I can implement 3 interfaces. Likewise if I implement everything as interfaces, then I cannot have a class data member propagate down the inheritance tree-I'll need to redeclare the data member every time which doesn't work too well with static variables and I cannot define method bodies like I can in abstract classes. An example of this would be:
It's a rather long example but I hope it shows where I'm coming from David |
||||||||||||||
|
Code Completion on type hinting with interfaces |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by