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 200773

Summary: @return self to allow return subclass in parent function
Product: php Reporter: RiaD
Component: EditorAssignee: Petr Pisl <ppisl>
Status: RESOLVED DUPLICATE    
Severity: normal CC: tmysik
Priority: P3    
Version: 7.0.1   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description RiaD 2011-08-09 04:45:00 UTC
First example:

I have some main class, and some subclasses, I have static method to return instance

    class dad{
        public function __construct($arg){
        }

        /**
        * @return self
        */
        public static function get($arg){
            return new static($arg);
        }
    }

    class son exteneds dad{
        public function __construct($arg){
        }

        public function sonFunc(){
            
        }
    }

    class daughter extends dad{
        public function __construct($arg){
        }

        public function daughterFunc(){
            
        }
    }

Now, I want make Netbeans IDE know, that son::get() return son, daughter::get() returns daughter  to correct codecompletion

Other example is chaining:

    class a{
        /**
        * @return self
        */
        public function x(){
            //return $this, it's not always a, it may be subclass
        }   
    }
Comment 1 Ondrej Brejla 2011-12-05 14:48:50 UTC

*** This bug has been marked as a duplicate of bug 196565 ***