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 150454 - Code completion should understand the magic _call() function if a return type is defined using the phpdoc comments
Summary: Code completion should understand the magic _call() function if a return type...
Status: REOPENED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 blocker with 3 votes (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-17 00:09 UTC by mariuskarthaus
Modified: 2015-01-08 22:49 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Demo of missing code completion when using magic methods (337 bytes, text/plain)
2012-02-19 10:42 UTC, str
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mariuskarthaus 2008-10-17 00:09:00 UTC
First let me say the code completion is very good! I like the way that the phpdoc style comments avtively help the IDE
to complete your code for OO programming. However I make a lot of use of the magic function __CALL() in PHP to write
catch-all functionality in classes and netbeans does not understand this. 

What I'd like to see is that if the code completion cannot find the function I'm calling in an object, to look at the
__call function, like PHP does.

Bogus example that uses the magic __call function of PHP to call any table from a database without creating a seperate
function for all the tables in the database:

<?php

# for example we use the __call function of the class 'DB' to create an object from a tuple from the 'users' table
# without the need to create a seperate function for each table in the database, that is why they call it a magic
function ;)

$DB=new DB();
$user=$DB->users($userID);

$user-> {I need code completion here to know that we are dealing with an object of type DBObject, and function foo() exists}

class DB {
    
    # database stuff here
    
    /**
     * This function looks at the way it it called to determine what table to get the object from
     * 
     * @return DBObject This returns a DBObject, but netbeans does not know this because I use a magic function instead
of a static function 
     */
    function __call($call,$args) {
       # do stuff here to find the right tuple 
       return new DBObject($stuff); 
    }
}

class DBObject {
    
    # object stuff here
    function foo(){}
}

?>

I hope this enhancement will make it into netbeans,
keep up the good work!

Regards,
Marius Karthaus
Comment 1 Tomasz Slota 2010-02-10 08:45:06 UTC
reassigning to default owner
Comment 2 Filip Zamboj 2010-09-15 12:27:00 UTC
batch reassigning
Comment 3 str 2011-11-13 20:52:26 UTC
Same goes to __callStatic()
Comment 4 Ondrej Brejla 2012-02-08 14:55:58 UTC
You should use @method PHPdoc annotations for class declaration PHPDoc block to provide magic functions and their return types.
Comment 5 str 2012-02-08 15:20:36 UTC
obrejla: This will not work if you have to deal with variable method names (in the sense that any identifier could name a method).
Comment 6 Ondrej Brejla 2012-02-09 10:59:12 UTC
Not sure that I understand what you are talking about. Give me just a simple use case (snippet of code) which is not working in NB. Thanks a lot.
Comment 7 str 2012-02-19 10:42:37 UTC
Created attachment 115915 [details]
Demo of missing code completion when using magic methods

This is a simple demo where the Netbeans code completion does not work very well. Off course I know the reason why it does not work for b() but there should be a way to enable code completion for every possible method name.

A potential use-case could for example be a wrapper for an array.
Comment 8 bauer01 2015-01-08 22:49:59 UTC
it would be very nice feature +1