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\MetaData::getDI() #15011

Closed
sergeyklay opened this issue May 5, 2020 · 1 comment · Fixed by #15012
Closed

[BUG]: Incorrect return type hint of Phalcon\Mvc\Model\MetaData::getDI() #15011

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

Comments

@sergeyklay
Copy link
Contributor

sergeyklay commented May 5, 2020

The current implementation of Phalcon\Mvc\Model\MetaData::getDI implies that method must return a Phalcon\Di\DiInterface instance:

public function getDI() -> <DiInterface>
{
return this->container;
}

however, MetaData::$container may be NULL:

protected container;

This lead to a fatal error:

use Phalcon\Mvc\Model\MetaData\Memory;

$metadata = new Memory();
$metadata->getDI();
PHP Fatal error:
Return value of Phalcon\Mvc\Model\MetaData::getDI()
must implement interface Phalcon\Di\DiInterface, null returned

The problem also is that this class implement InjectionAwareInterface which does not declare this method as nullable:

/**
* Returns the internal dependency injector
*/
public function getDI() -> <DiInterface>;

@sergeyklay sergeyklay self-assigned this May 5, 2020
sergeyklay added a commit that referenced this issue May 5, 2020
@sergeyklay sergeyklay linked a pull request May 5, 2020 that will close this issue
5 tasks
@sergeyklay
Copy link
Contributor Author

Fixed in 4.0.x branch

niden pushed a commit that referenced this issue May 16, 2020
@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.

1 participant