Refactor and make scriptengine switchable to groovy

Notes for phpstorm operation can be found here https://github.com/pbyrne84/DynamicReturnTypePluginTestEnvironment/blob/local_config/GroovyReplacementCallback.groovy