@@ -441,19 +441,30 @@ private function addService($id, $definition)
441
441
$ this ->referenceVariables = array ();
442
442
$ this ->variableCount = 0 ;
443
443
444
- $ return = '' ;
444
+ $ return = array ();
445
+
445
446
if ($ definition ->isSynthetic ()) {
446
- $ return = sprintf ( '@throws RuntimeException always since this service is expected to be injected dynamically ' ) ;
447
+ $ return[] = '@throws RuntimeException always since this service is expected to be injected dynamically ' ;
447
448
} elseif ($ class = $ definition ->getClass ()) {
448
- $ return = sprintf ("@return %s A %s instance. " , 0 === strpos ($ class , '% ' ) ? 'Object ' : $ class , $ class );
449
+ $ return[] = sprintf ("@return %s A %s instance. " , 0 === strpos ($ class , '% ' ) ? 'object ' : $ class , $ class );
449
450
} elseif ($ definition ->getFactoryClass ()) {
450
- $ return = sprintf ('@return Object An instance returned by %s::%s(). ' , $ definition ->getFactoryClass (), $ definition ->getFactoryMethod ());
451
+ $ return[] = sprintf ('@return object An instance returned by %s::%s(). ' , $ definition ->getFactoryClass (), $ definition ->getFactoryMethod ());
451
452
} elseif ($ definition ->getFactoryService ()) {
452
- $ return = sprintf ('@return Object An instance returned by %s::%s(). ' , $ definition ->getFactoryService (), $ definition ->getFactoryMethod ());
453
+ $ return [] = sprintf ('@return object An instance returned by %s::%s(). ' , $ definition ->getFactoryService (), $ definition ->getFactoryMethod ());
454
+ }
455
+
456
+ $ scope = $ definition ->getScope ();
457
+ if (!in_array ($ scope , array (ContainerInterface::SCOPE_CONTAINER , ContainerInterface::SCOPE_PROTOTYPE ))) {
458
+ if ($ return && 0 === strpos ($ return [count ($ return ) - 1 ], '@return ' )) {
459
+ $ return [] = '' ;
460
+ }
461
+ $ return [] = sprintf ("@throws InactiveScopeException when the '%s' service is requested while the '%s' scope is not active " , $ id , $ scope );
453
462
}
454
463
464
+ $ return = implode ("\n * " , $ return );
465
+
455
466
$ doc = '' ;
456
- if (ContainerInterface::SCOPE_PROTOTYPE !== $ definition -> getScope () ) {
467
+ if (ContainerInterface::SCOPE_PROTOTYPE !== $ scope ) {
457
468
$ doc .= <<<EOF
458
469
459
470
*
@@ -484,8 +495,7 @@ protected function get{$name}Service()
484
495
485
496
EOF ;
486
497
487
- $ scope = $ definition ->getScope ();
488
- if (ContainerInterface::SCOPE_CONTAINER !== $ scope && ContainerInterface::SCOPE_PROTOTYPE !== $ scope ) {
498
+ if (!in_array ($ scope , array (ContainerInterface::SCOPE_CONTAINER , ContainerInterface::SCOPE_PROTOTYPE ))) {
489
499
$ code .= <<<EOF
490
500
if (!isset( \$this->scopedServices[' $ scope'])) {
491
501
throw new InactiveScopeException(' $ id', ' $ scope');
0 commit comments