pbyrne84 / DynamicReturnTypePlugin

135 stars 7 forks source link

Not working with constants #56

Closed tobeorla closed 8 years ago

tobeorla commented 8 years ago

First: ¡Thanks for creating this plugin!

Having: DummyClass.php

<?php

namespace Example;

class DummyClass {

    const MESSAGE = "hi";

    public static function say ($message) {
        echo $message;
    }
}

dynamicReturnTypeMeta.json

{
  "methodCalls": [
    {
      "class": "\\Example\\DummyClass",
      "method": "say",
      "position" : 0,
      "fileReturnTypeReplacementCall": ["test.js", "replaceTag"]
    }
  ]
}

test.js

//noinspection JSUnusedGlobalSymbols
/**
 * @type{com.ptby.dynamicreturntypeplugin.scripting.api.ExecutingScriptApi}
 */
var api;

//noinspection JSUnusedGlobalSymbols
function replaceTag (namespace, className) {
    return 'Laravel\\Service\\Sender';
}

If i send an string var, it wil work:

<?php

namespace House;

use \Example\DummyClass;

DummyClass::say("this works")->[Sender methods suggest appears]

If i send a constant, it won't:

<?php

namespace House;

use \Example\DummyClass;

DummyClass::say(DummyClass::MESSAGE)->[no suggestions]

This will also work:

<?php

namespace House;

use \Example\DummyClass;

DummyClass::say(DummyClass::MESSAGE . "")->[Sender methods suggest appears]
pbyrne84 commented 8 years ago

Okay, thanks for the good example. I'll have a look soon. I need to upgrade all my environment to idea 15 etc and deal with the kotlin deprecations.

tobeorla commented 8 years ago

¡¡Thanks!! And again, ¡Thank you for creating this plugin!

pbyrne84 commented 8 years ago

Okay there is a build here https://github.com/pbyrne84/DynamicReturnTypePlugin/tree/a39ee89e49a22636b5e91c2729e84969847d7e8c/deploy that should fix it. Just replace the DynamicReturnTypePlugin folder on you machine with this ones contents. I'll do a release when I go back to work at the beginning of next year.

tobeorla commented 8 years ago

Now it works, thanks!! Closing issue