This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 234898 - @property doesn't work on interfaces
Summary: @property doesn't work on interfaces
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 17:12 UTC by JanKunzmann
Modified: 2013-09-03 14:12 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description JanKunzmann 2013-08-23 17:12:00 UTC
The @property phpDoc tag doesn't work on interfaces.

It might sound like a silly idea to have properties defined on an interface, but the phpDoc manual explicitly allows it and it is in fact very useful for particular marker interfaces.
Comment 1 Ondrej Brejla 2013-08-23 17:25:16 UTC
Definitely enhancement, not sure if I want to implement it, because it's a logical nonsense... Ifaces can't have properties, sorry ;) But I'll discuss it with my colleague.
Comment 2 JanKunzmann 2013-08-26 10:32:59 UTC
Let me give you some more pro's for this:

Magic properties are, strictly seen, just syntactic sugar for getters and setters; most people use them to reduce coding overhead and it becomes particularly useful on auto-generated code (ORM layers like Doctrine 1 do it a lot). You are allowed to define getters and setters on an interface, so why not magic properties as well?

It's possible to define __get/__set on an interface to force the implementing class to provide the magic methods. There's no other way to assure which properties these magic methods have to take care of, so adding @property on the interface at least gives the programmer a hint.

Some project follow an "every class has its interface" paradigm and use only the interfaces as typehints; this allows better dependency injection and unit testing, and would help to mimic the missing package/namespace scope of PHP (public methods of a class not defined in the interface are of package scope). To allow those projects proper reflection in the IDE, the @property must be defined on the interface level.

Finally, phpDoc states explicitly that @property is supported on classes _and_ interfaces. (uhm... what about traits...?)
Comment 3 dagguh 2013-09-03 14:12:46 UTC
Just because something is allowed, doesn't mean it is good, e.g. LSB, multiple paradigms, type juggling, etc. in PHP
Magic methods also are undesirable.