pbyrne84 / DynamicReturnTypePlugin

135 stars 7 forks source link

Add return type is array of objects? #17

Closed Danack closed 10 years ago

Danack commented 10 years ago

Hi,

If possible, please could you add a flag to the meta data entries that indicate that the a function will return an array* of objects rather than a single object, to support code like:

class mockTest {
    function foo() { }
}

function mockObjects($classname) {
    $objects = array(
        new $classname(),
        new $classname(),
        new $classname()
    );

    return $objects;
}

$objects = mockObjects('mockTest');

//$objects is currently type-hinted to be of type 'mockTest' rather than 'mockTest[]' 

cheers Dan

pbyrne84 commented 10 years ago

Interesting, I'll see what I can do. Back to the PsiViewer I go :)

pbyrne84 commented 10 years ago

I couldn't find a way so I asked Alexy http://devnet.jetbrains.com/message/5513098#5513098

pbyrne84 commented 10 years ago

Better late than never https://github.com/pbyrne84/DynamicReturnTypePlugin/blob/master/deploy/DynamicReturnTypePlugin.zip

You should just be able to set up a mask like this

, { "function": "\mockObjects", "position": 0, "mask" : "%s[]" }

pbyrne84 commented 10 years ago

Should be done for your edge case, not class constants though at the mo