diff --git a/phalcon/mvc/micro.zep b/phalcon/mvc/micro.zep index 028ca1e137f..4de7caf37a0 100644 --- a/phalcon/mvc/micro.zep +++ b/phalcon/mvc/micro.zep @@ -997,7 +997,7 @@ class Micro extends Injectable implements \ArrayAccess */ if typeof returnedValue == "string" { let response = dependencyInjector->getShared("response"); - if !response->isSent() { + if this->isSendable(response) { response->setContent(returnedValue); response->send(); } @@ -1007,19 +1007,26 @@ class Micro extends Injectable implements \ArrayAccess * Check if the returned object is already a response */ if typeof returnedValue == "object" { - if returnedValue instanceof ResponseInterface { - /** - * Automatically send the response - */ - if !returnedValue->isSent() { - returnedValue->send(); - } + /** + * Automatically send the response + */ + if this->isSendable(returnedValue) { + returnedValue->send(); } } return returnedValue; } + /** + * @param object response + * @return bool + **/ + private function isSendable(response) -> boolean + { + return response instanceof ResponseInterface && method_exists(response, "isSent") && !response->isSent(); + } + /** * Stops the middleware execution avoiding than other middlewares be executed */