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 hint of Phalcon\Mvc\Model::getEventsManager() #15008

Closed
sergeyklay opened this issue May 4, 2020 · 1 comment · Fixed by #15009
Closed

[BUG]: Incorrect return type hint of Phalcon\Mvc\Model::getEventsManager() #15008

sergeyklay opened this issue May 4, 2020 · 1 comment · Fixed by #15009
Assignees
Labels
bug A bug report status: low Low

Comments

@sergeyklay
Copy link
Contributor

The current implementation of Phalcon\Mvc\Model::getEventsManager implies that method must return a Phalcon\Events\ManagerInterface instance:

cphalcon/phalcon/Mvc/Model.zep

Lines 1702 to 1705 in 930fc08

public function getEventsManager() -> <EventsManagerInterface>
{
return this->modelsManager->getCustomEventsManager(this);
}

however, Manger::getCustomEventsManager may return boolean FALSE:

public function getCustomEventsManager(<ModelInterface> model) -> <EventsManagerInterface> | bool
{
var eventsManager;
if !fetch eventsManager, this->customEventsManager[get_class_lower(model)] {
return false;
}
return eventsManager;
}

This leads to a fatal error:

PHP Fatal error:
Return value of Phalcon\Mvc\Model::getEventsManager()
must implement interface Phalcon\Events\ManagerInterface,
bool returned in Unknown on line 0
@sergeyklay
Copy link
Contributor Author

Fixed in 4.0.x branch

@sergeyklay sergeyklay self-assigned this May 7, 2020
@niden niden added this to Phalcon v5 Aug 25, 2022
@niden niden moved this to Released in 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.

1 participant