stecman / symfony-console-completion

Automatic tab-key completion for Symfony console application options, arguments and parameters
MIT License
420 stars 26 forks source link

Allow methods as callbacks. #9

Closed pjcdawkins closed 9 years ago

pjcdawkins commented 9 years ago

A callback in PHP can legitimately be an array, such as array($object, 'myMethod') or array('className', 'myStaticMethod'). Completion::run() didn't allow this because it interpreted the callback directly as an array of results.

stecman commented 9 years ago

Nice, thanks. In theory this could cause an issue with two strings referring to a static class method (eg. ['DateTime', 'createFromFormat']), though by the looks of it PHP only considers an array of two strings callable if they match exactly to an existing method. It's easy enough to extend Completion in that case, so I'm not worried about it.

pjcdawkins commented 9 years ago

Yes, it's also easy enough to make a callback returning your array in that case.