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

ExtensionsExtension: Fix type hint of RC #209

Merged
merged 2 commits into from Jul 19, 2019

Conversation

@janbarasek
Copy link
Contributor

janbarasek commented Jul 18, 2019

  • bug fix
  • BC break? no

Fix type hint and solve error:

------ --------------------------------------------------------------------- 
  Line   DI/Extensions/ExtensionsExtension.php                                
 ------ --------------------------------------------------------------------- 
  34     Parameter #2 $extension of method Nette\DI\Compiler::addExtension()  
         expects Nette\DI\CompilerExtension, object given.                    
 ------ --------------------------------------------------------------------- 
@dg dg force-pushed the nette:master branch 2 times, most recently from edf67d2 to b365d4c Jul 19, 2019
@@ -30,8 +30,9 @@ public function loadConfiguration()
$name = null;
}
if ($class instanceof Nette\DI\Definitions\Statement) {
$rc = new \ReflectionClass($class->getEntity());
$this->compiler->addExtension($name, $rc->newInstanceArgs($class->arguments));
/** @var Nette\DI\CompilerExtension $rcExtension */

This comment has been minimized.

Copy link
@dg

dg Jul 19, 2019

Member

In fact, we don't know if the $rcExtension is CompilerExtension, and it is expected that it might throw a TypeError.

This comment has been minimized.

Copy link
@mabar

mabar Jul 19, 2019

Contributor

Btw, it is better to use assert($rcExtension instanceof CompilerExtension)
Locally defined annotations are hack to satisfy IDE

This comment has been minimized.

Copy link
@dg

dg Jul 19, 2019

Member

Ideally, there should be checking and throwing an exception.

This comment has been minimized.

Copy link
@mabar

mabar Jul 19, 2019

Contributor

assert should be used instead of local annotations for internal behavior, to be exact.

This comment has been minimized.

Copy link
@janbarasek

janbarasek Jul 19, 2019

Author Contributor

I implemented exception, but I'm not sure about the message.

@dg dg force-pushed the nette:master branch 3 times, most recently from 89b7ae6 to c60c7ff Jul 19, 2019
…ception.
@dg dg force-pushed the nette:master branch 2 times, most recently from fecd1fb to 15978c3 Jul 19, 2019
@dg dg merged commit 061f042 into nette:master Jul 19, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on janbarasek-extension-rc-type at 93.102%
Details
dg added a commit that referenced this pull request Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.