@@ -358,7 +358,13 @@ private function addServiceReturn($id, $definition)
358358 */
359359 private function addServiceInstance ($ id , $ definition )
360360 {
361- $ class = $ this ->dumpValue ($ definition ->getClass ());
361+ $ class = $ definition ->getClass ();
362+
363+ if ('\\' === substr ($ class , 0 , 1 )) {
364+ $ class = substr ($ class , 1 );
365+ }
366+
367+ $ class = $ this ->dumpValue ($ class );
362368
363369 if (0 === strpos ($ class , "' " ) && !preg_match ('/^ \'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*( \\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)* \'$/ ' , $ class )) {
364370 throw new InvalidArgumentException (sprintf ('"%s" is not a valid class name for the "%s" service. ' , $ class , $ id ));
@@ -539,7 +545,7 @@ private function addService($id, $definition)
539545 if ($ definition ->isSynthetic ()) {
540546 $ return [] = '@throws RuntimeException always since this service is expected to be injected dynamically ' ;
541547 } elseif ($ class = $ definition ->getClass ()) {
542- $ return [] = sprintf ('@return %s A %s instance. ' , 0 === strpos ($ class , '% ' ) ? 'object ' : '\\' .$ class , $ class );
548+ $ return [] = sprintf ('@return %s A %s instance. ' , 0 === strpos ($ class , '% ' ) ? 'object ' : '\\' .ltrim ( $ class , '\\' ), ltrim ( $ class, '\\' ) );
543549 } elseif ($ definition ->getFactoryClass ()) {
544550 $ return [] = sprintf ('@return object An instance returned by %s::%s(). ' , $ definition ->getFactoryClass (), $ definition ->getFactoryMethod ());
545551 } elseif ($ definition ->getFactoryService ()) {
0 commit comments