Open Danack opened 9 years ago
Interesting. Should be doable as function are the easiest lookups, no inheritance etc. Are you still stuck on jdk6 by the way?
Are you still stuck on jdk6 by the way?
Yep. Long story, short version - I don't like upgrading my OS.
Feel free to drop support for it though if there's any good reason for doing so - there's probably only a handful of people who are still on it.
No real biggy, the only difference is the javascript callback handling is different for testing purposes and making sure I have jdk6 installed.
On 11 August 2015 at 18:48, Danack notifications@github.com wrote:
Are you still stuck on jdk6 by the way?
Yep. Long story, short version - I don't like upgrading my OS.
Feel free to drop support for it though if there's any good reason for doing so - there's probably only a handful of people who are still on it.
— Reply to this email directly or view it on GitHub https://github.com/pbyrne84/DynamicReturnTypePlugin/issues/48#issuecomment-129989106 .
It seems like I can only do the constant string based stuff eg.
$injector->execute('globalFunctionName'); $injector->execute('MyStaticClass::myStaticMethod'); $injector->execute('MyClass::myInstanceMethod');
This potentially doable in 7 $injector->execute(function(){});
if $injector->execute(function() : Type{}); Is supported by php and phpstorm // phpstorm seems to lose the type on this, I do not have php7 to check at the mo if the following is valid.
$x = function() : \DOMDocument { return new \DOMDocument(); };
//Type is lost $document = $x();
That is an issue in phpstorm as being able to define anonymous function return types has not been doable before. Possibly fig should look at making it phpdoc expressive in a format like mozilla arrow functions/typescript/scala https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions ie something like @param ( Int,Int) => \DomDocument $varName
Phpstorm follows fig standards so there is similar isuses with there is to expresss generics in php (actually the whole reason I wrote this plugin).
I'd had to look into ( should be doable at some point ) $injector->execute('ClassThatHasMagicInvoke'); with $injector->execute($instanceOfClassThatHasMagicInvoke);
These ones are more difficult as I have to parse the array $injector->execute(['MyStaticClass', 'myStaticMethod']); $injector->execute(['MyChildStaticClass', 'parent::myStaticMethod']);
//This I am unsure of do to things in arrays get a bit lost $injector->execute([$objectInstance, 'methodName']);
I had a bundle of fun setting my dev enviroment up which is what has taken me a while. Kind of nuked itself.
What are your priorities in how you use auryn? Your example was a hard coded function which is the easiest but probably is the most limiting.
Alright I checked $x = function() : \DOMDocument { return new \DOMDocument(); }; on https://3v4l.org/ and it told me I was making stuff up on everything.
I lie, now it works
IMO - don't both worrying at all about 'relative' method names like:
$injector->execute(['MyChildStaticClass', 'parent::myStaticMethod']);
They are absolutely moronic and I'm hoping to get them removed from PHP 8. I have draft of and RFC here to tidy callables up, and part of it is to get rid of them, as they change meaning where you call them from.
What are your priorities in how you use auryn?
tbh right now I'm off doing some marginally crazy stuff that probably wouldn't benefit from this, as it's dynamically dispatching absolutely everything.
However for people who are not quite as crazy, I think the ones that would be most useful would be the simple ones i.e.
$injector->execute('globalFunctionName'); $injector->execute('MyStaticClass::myStaticMethod'); $injector->execute('MyClass::myInstanceMethod');
Followed by:
$injector->execute([$objectInstance, 'methodName']);
I use the Auryn dependency injection library. As well as creating objects, it can also be used to execute code.
It would be awesome if the DynamicReturnTypePlugin could have the ability to look at the return type of the executed code. e.g.
$cacheInstance is 'obviously' going to be of the type
Cache
but PHPStorm won't show this.Any chance this can be added?