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 245872 - Problem with PHP navigator. Class annotations generate code error hints and method duplicates in navigator.
Summary: Problem with PHP navigator. Class annotations generate code error hints and m...
Status: REOPENED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: All All
: P4 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-22 11:29 UTC by geo.leu
Modified: 2014-07-22 12:56 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch (2.69 KB, patch)
2014-07-22 12:56 UTC, Ondrej Brejla
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description geo.leu 2014-07-22 11:29:56 UTC
Declaring a method in a class and also puting @method annotation for that method , in the class docblock it will generate and error hint for that file (either near the @method annotation or at the method declaration line number) . Also when using the class method/property annotations , in the navigator there will be duplicate properties/methods . I think this is where the cause of the bug is . Netbeans interprets the @method annotation and the normal method declaration as being the same (2x declarations, redeclaration).  
  
So basically there are 2 bugs : one that the @method annotation generates an error hint (red circle) and the other one that navigator shows duplicate method/propery declarations.
Comment 1 Ondrej Brejla 2014-07-22 11:35:21 UTC
It "is" method redeclaration. You shoudn't use @method annotation if there is a real method declared in a class. @method annotation is just for "magic" methods.

This is really wrong:

<?php
/**
 * @method void functionName() Description
 */
class ClassName {

    function functionName() {
        
    }

}
?>
Comment 2 geo.leu 2014-07-22 11:52:43 UTC
(In reply to Ondrej Brejla from comment #1)
> It "is" method redeclaration. You shoudn't use @method annotation if there
> is a real method declared in a class. @method annotation is just for "magic"
> methods.
> 
> This is really wrong:
> 
> <?php
> /**
>  * @method void functionName() Description
>  */
> class ClassName {
> 
>     function functionName() {
>         
>     }
> 
> }
> ?>

This is not wrong because i need anotations for a proxy object (helps alot in this case) . Class anotation should not just be magic method helpers. Annotations are there to provide information about a code block. But if this is considered the standard for netbeans is ok . 

P.S. : magic methods are wrong, proxy objects with private methods/properties should be used instead. Ofcourse depends on the design style. In my case, class annotations would help alot with my proxy objects.
Comment 3 geo.leu 2014-07-22 12:18:56 UTC
(In reply to Ondrej Brejla from comment #1)
> It "is" method redeclaration. You shoudn't use @method annotation if there
> is a real method declared in a class. @method annotation is just for "magic"
> methods.
> 
> This is really wrong:
> 
> <?php
> /**
>  * @method void functionName() Description
>  */
> class ClassName {
> 
>     function functionName() {
>         
>     }
> 
> }
> ?>

Another thing to note . Magic methods are not just for undeclared methods . They are also for declared methods but innaccesible (private/protected scope). Using class anotation would help by showing code hinting . The code hint will show that the method is accessible , and the __call() magic method will take care of the calling circumstance. Any way you will look at it, the class annotation's logic seems buggy (using proxys or magic methods) . 

I think you should review the whole thing about class annotations (at least @method @property annotations)
Comment 4 geo.leu 2014-07-22 12:21:44 UTC
This is not resolved. Are you seriously closing this without rechecking the logic ? Please review my replys.
Comment 5 Ondrej Brejla 2014-07-22 12:46:41 UTC
@method annotation exposes public api of the class. If you declared "private foo()" in a class, there is no need to expose it by @method and hide that call into __call() method. It's ugly. You can change the method access modifier to public and do all needed checks inside it.

But yes, I understand your problem, but I don't think that I want to implement it, because that approach doesn't seem to be nice. That code is overcomplicated then. But I'll think about it once again later, so leaving as P4 as a reminder. Thanks.
Comment 6 Ondrej Brejla 2014-07-22 12:56:42 UTC
Created attachment 148204 [details]
Patch

It disables checking of magic methods by "redeclaration" hint.