Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Incorrect return type hints for Phalcon\Http\Response #14983

Closed
sergeyklay opened this issue May 2, 2020 · 4 comments · Fixed by #14985
Closed

[BUG]: Incorrect return type hints for Phalcon\Http\Response #14983

sergeyklay opened this issue May 2, 2020 · 4 comments · Fixed by #14985
Assignees
Labels
bug A bug report status: low Low

Comments

@sergeyklay
Copy link
Contributor

sergeyklay commented May 2, 2020

There is no restriction for content data type:

public function __construct(content = null, code = null, status = null)
{
/**
* A Phalcon\Http\Response\Headers bag is temporary used to manage the headers before sent them to the client
*/
let this->headers = new Headers();
let this->content = content;
if code !== null {
this->setStatusCode(code, status);
}
}

But Phalcon\Http\Response::getContent has to return string:

public function getContent() -> string
{
return this->content;
}

The following code leads to a fatal error:

$response = new Response(['user' => 'jeremy']);
$response->getContent();
PHP Fatal error:
Return value of Phalcon\Http\Response::getContent()
must be of the type string, array returned in Unknown on line 0
@sergeyklay sergeyklay added bug A bug report status: unverified Unverified and removed status: unverified Unverified labels May 2, 2020
@sergeyklay sergeyklay self-assigned this May 2, 2020
@sergeyklay
Copy link
Contributor Author

/cc @jenovateurs

@sergeyklay
Copy link
Contributor Author

Fixed in 4.0.x branch

@sergeyklay sergeyklay linked a pull request May 3, 2020 that will close this issue
5 tasks
@jenovateurs
Copy link
Contributor

Well done @sergeyklay :-)

@sergeyklay
Copy link
Contributor Author

Thank you

@niden niden moved this to Released in Phalcon v5 Aug 25, 2022
@niden niden added this to Phalcon v5 Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants