-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ContainerBuilder::resolveEntityClass() checking whether factory is ca…
…llable counts with interfaces and traits [Closes #32]
- Loading branch information
Showing
3 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\DI\ContainerBuilder and generated factories errors. | ||
* @phpversion 5.4 | ||
*/ | ||
|
||
use Nette\DI, | ||
Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
trait Bad1 | ||
{ | ||
function method() {} | ||
} | ||
|
||
Assert::exception(function() { | ||
$builder = new DI\ContainerBuilder; | ||
$builder->addDefinition('one')->setFactory('Bad1::method'); | ||
$builder->generateClasses(); | ||
}, 'Nette\InvalidStateException', "Factory 'Bad1::method' used in service 'one' is not callable."); |
$refClass->isTrait()
will never be true because$reflection->getDeclaringClass()
does not return traits. Use the new method from nette/reflection instead. That should fix problems with use statements and return annotations as well.