Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 161239

Summary: support for oop method overloading (__call) for php5
Product: z_Archived Reporter: Sang Uk Seong <sang>
Component: PDTAssignee: PHP UI <php.ui-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: exceptione, info, spektom, vadim.p
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
sample code
none
BugContent... bugzilla doesn't save anything in content... none

Description Sang Uk Seong CLA 2006-10-17 10:43:14 EDT
some reason, content of my bug is not submitted.

based on http://us2.php.net/manual/en/language.oop5.overloading.php and http://us2.php.net/manual/en/language.oop5.overloading.php, I set up in AbstractClass to handle all setter calls and getter calls from __call() method.

code assist of course cannnot see our dynamic getters and setters at the point.

I know it won't be easy to implement this feature but this should be something PHP IDE needs to detect somehow -- since php offers this feature :)

I have AbstractDefaultClass that contains following methods:

    /**
     * Dynmaic function call to set getter/setter
     * all variable must start lower case and mixed mode
     * e.g. property testPropertyName->getTestPropertyName()
     * @param string $method method of function call
     * @param Array $arguments String array arguments
     * @return Mixed
     */
    public function __call($method, $arguments) {

        // allow isXXX for boolean
        if ($method[0] == "i" && $method[1] == "s") {
            $prefix = "is";
            $property = strtolower(substr($method, 2, 1)) . substr($method, 3);
        } else {
            $prefix = strtolower(substr($method, 0, 3));
            $property = strtolower(substr($method, 3, 1)) . substr($method, 4);
        }

        if (empty($prefix) || empty($property)) {
            return;
        }

        if (($prefix == "is" && is_bool($this->$property)) ||
            ($prefix == "get" && isset($this->$property))) {
            return $this->$property;
        }

        if ($prefix == "set") {
            $this->$property = $arguments[0];
        }
    }

It would be nice that PHP IDE recognize this handler and offer code assist if a class extending this AbstractDefaultClass...
Comment 1 Sang Uk Seong CLA 2006-10-17 10:43:54 EDT
based on http://us2.php.net/manual/en/language.oop5.overloading.php and http://us2.php.net/manual/en/language.oop5.overloading.php, I set up in AbstractClass to handle all setter calls and getter calls from __call() method.

code assist of course cannnot see our dynamic getters and setters at the point.

I know it won't be easy to implement this feature but this should be something PHP IDE needs to detect somehow -- since php offers this feature :)

It would be nice that PHP IDE recognize this handler and offer code assist if a class extending this AbstractDefaultClass...
Comment 2 Sang Uk Seong CLA 2006-10-17 10:44:35 EDT
some reason it doesn't save my bug content... or I don't see it?
Comment 3 Sang Uk Seong CLA 2006-10-17 10:45:24 EDT
some reason, content of my bug is not submitted.

based on http://us2.php.net/manual/en/language.oop5.overloading.php and http://us2.php.net/manual/en/language.oop5.overloading.php, I set up in AbstractClass to handle all setter calls and getter calls from __call() method.

code assist of course cannnot see our dynamic getters and setters at the point.

I know it won't be easy to implement this feature but this should be something PHP IDE needs to detect somehow -- since php offers this feature :)

I have AbstractDefaultClass that contains following methods:

    /**
     * Dynmaic function call to set getter/setter
     * all variable must start lower case and mixed mode
     * e.g. property testPropertyName->getTestPropertyName()
     * @param string $method method of function call
     * @param Array $arguments String array arguments
     * @return Mixed
     */
    public function __call($method, $arguments) {

        // allow isXXX for boolean
        if ($method[0] == "i" && $method[1] == "s") {
            $prefix = "is";
            $property = strtolower(substr($method, 2, 1)) . substr($method, 3);
        } else {
            $prefix = strtolower(substr($method, 0, 3));
            $property = strtolower(substr($method, 3, 1)) . substr($method, 4);
        }

        if (empty($prefix) || empty($property)) {
            return;
        }

        if (($prefix == "is" && is_bool($this->$property)) ||
            ($prefix == "get" && isset($this->$property))) {
            return $this->$property;
        }

        if ($prefix == "set") {
            $this->$property = $arguments[0];
        }
    }

It would be nice that PHP IDE recognize this handler and offer code assist if a class extending this AbstractDefaultClass...
Comment 4 Sang Uk Seong CLA 2006-10-17 10:47:05 EDT
Created attachment 52126 [details]
sample code

some reason, content of my bug is not submitted.

based on http://us2.php.net/manual/en/language.oop5.overloading.php and http://us2.php.net/manual/en/language.oop5.overloading.php, I set up in AbstractClass to handle all setter calls and getter calls from __call() method.

code assist of course cannnot see our dynamic getters and setters at the point.

I know it won't be easy to implement this feature but this should be something PHP IDE needs to detect somehow -- since php offers this feature :)

I have AbstractDefaultClass that contains following methods:

It would be nice that PHP IDE recognize this handler and offer code assist if a class extending this AbstractDefaultClass...
Comment 5 Sang Uk Seong CLA 2006-10-17 10:48:39 EDT
Created attachment 52127 [details]
BugContent... bugzilla doesn't save anything in content...
Comment 6 Michael Spector CLA 2007-10-08 10:31:49 EDT
(In reply to comment #0)
skipped...
> 
> It would be nice that PHP IDE recognize this handler and offer code assist if a
> class extending this AbstractDefaultClass...
> 

I'm not sure I understand what should be suggested in code completion?
Do you mean PDT should detect method names from your __call() by parsing it?


Comment 7 exceptione CLA 2009-01-19 11:13:30 EST
(In reply to comment #6)
I think he meant someting like @method? [http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.method.pkg.html]

If that is the case, this bug can be closed since pdt 2.0.0 supports this.
Comment 8 Michael Spector CLA 2009-06-06 10:08:37 EDT
Yes, PDT 2.x supports @method tags. 
Comment 9 Vadim Punski CLA 2009-12-29 09:12:08 EST
closing.