@@ -300,7 +300,7 @@ public static function loadDefinitions(ContainerBuilder $builder, array $service
300300 : $ builder ->addDefinition ($ name );
301301
302302 try {
303- static ::loadDefinition ($ definition , $ def );
303+ static ::loadDefinition ($ definition , $ def, $ name );
304304 } catch (\Exception $ e ) {
305305 throw new ServiceCreationException ("Service ' $ name': " . $ e ->getMessage (), 0 , $ e );
306306 }
@@ -312,7 +312,7 @@ public static function loadDefinitions(ContainerBuilder $builder, array $service
312312 * Parses single service definition from configuration.
313313 * @return void
314314 */
315- public static function loadDefinition (ServiceDefinition $ definition , $ config )
315+ public static function loadDefinition (ServiceDefinition $ definition , $ config, string $ name = null )
316316 {
317317 if ($ config === null ) {
318318 return ;
@@ -345,7 +345,9 @@ public static function loadDefinition(ServiceDefinition $definition, $config)
345345
346346 if (array_key_exists ('class ' , $ config )) {
347347 Validators::assertField ($ config , 'class ' , 'string|Nette\DI\Statement|null ' );
348- if (!$ config ['class ' ] instanceof Statement) {
348+ if ($ config ['class ' ] instanceof Statement) {
349+ trigger_error ("Service ' $ name': option 'class' should be changed to 'factory'. " , E_USER_DEPRECATED );
350+ } else {
349351 $ definition ->setClass ($ config ['class ' ]);
350352 }
351353 $ definition ->setFactory ($ config ['class ' ]);
0 commit comments