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

Summary: @property doesn't work on interfaces
Product: php Reporter: JanKunzmann
Component: RefactoringAssignee: Ondrej Brejla <obrejla>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.3   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

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.