1010namespace Nette \DI \Definitions ;
1111
1212use Nette ;
13- use Nette \DI \Definitions \Reference ;
1413use Nette \DI \ServiceCreationException ;
1514use Nette \PhpGenerator \Helpers as PhpHelpers ;
1615
@@ -64,7 +63,9 @@ public function setType(?string $type)
6463 */
6564 public function setFactory ($ factory , array $ args = [])
6665 {
67- $ this ->factory = $ factory instanceof Statement ? $ factory : new Statement ($ factory , $ args );
66+ $ this ->factory = $ factory instanceof Statement
67+ ? $ factory
68+ : new Statement ($ factory , $ args );
6869 return $ this ;
6970 }
7071
@@ -127,7 +128,9 @@ public function getSetup(): array
127128 */
128129 public function addSetup ($ entity , array $ args = [])
129130 {
130- $ this ->setup [] = $ entity instanceof Statement ? $ entity : new Statement ($ entity , $ args );
131+ $ this ->setup [] = $ entity instanceof Statement
132+ ? $ entity
133+ : new Statement ($ entity , $ args );
131134 return $ this ;
132135 }
133136
@@ -204,7 +207,10 @@ public function complete(Nette\DI\Resolver $resolver): void
204207 $ this ->factory = $ resolver ->completeStatement ($ this ->factory );
205208
206209 foreach ($ this ->setup as &$ setup ) {
207- if (is_string ($ setup ->getEntity ()) && strpbrk ($ setup ->getEntity (), ':@? \\' ) === false ) { // auto-prepend @self
210+ if (
211+ is_string ($ setup ->getEntity ())
212+ && strpbrk ($ setup ->getEntity (), ':@? \\' ) === false
213+ ) { // auto-prepend @self
208214 $ setup = new Statement ([new Reference (Reference::SELF ), $ setup ->getEntity ()], $ setup ->arguments );
209215 }
210216 $ setup = $ resolver ->completeStatement ($ setup , true );
@@ -228,7 +234,8 @@ public function generateMethod(Nette\PhpGenerator\Method $method, Nette\DI\PhpGe
228234 && !(is_array ($ entity ) && $ entity [0 ] instanceof Reference && $ entity [0 ]->getValue () === Nette \DI \ContainerBuilder::THIS_CONTAINER )
229235 && !(is_string ($ entity ) && preg_match ('#^[\w \\\\]+$#D ' , $ entity ) && is_subclass_of ($ entity , $ type ))
230236 ) {
231- $ code .= PhpHelpers::formatArgs ("if (! \$service instanceof $ type) { \n"
237+ $ code .= PhpHelpers::formatArgs (
238+ "if (! \$service instanceof $ type) { \n"
232239 . "\tthrow new Nette \\UnexpectedValueException(?); \n} \n" ,
233240 ["Unable to create service ' {$ this ->getName ()}', value returned by factory is not $ type type. " ]
234241 );
0 commit comments