@@ -188,7 +188,7 @@ public function getByType(string $class, bool $throw = false)
188188 $ class = Helpers::normalizeClass ($ class );
189189
190190 if ($ this ->currentService !== null
191- && is_a ($ this ->definitions [$ this ->currentService ]->getClass (), $ class , true )
191+ && is_a ($ this ->definitions [$ this ->currentService ]->getType (), $ class , true )
192192 ) {
193193 return $ this ->currentService ;
194194 }
@@ -277,7 +277,7 @@ public function getClassList(): array
277277 public function prepareClassList ()
278278 {
279279 unset($ this ->definitions [self ::THIS_CONTAINER ]);
280- $ this ->addDefinition (self ::THIS_CONTAINER )->setClass (Container::class);
280+ $ this ->addDefinition (self ::THIS_CONTAINER )->setType (Container::class);
281281
282282 $ this ->classList = false ;
283283
@@ -288,7 +288,7 @@ public function prepareClassList()
288288 }
289289
290290 if ($ def ->isDynamic ()) {
291- if (!$ def ->getClass ()) {
291+ if (!$ def ->getType ()) {
292292 throw new ServiceCreationException ("Type is missing in definition of service ' $ name'. " );
293293 }
294294 $ def ->setFactory (null );
@@ -297,10 +297,10 @@ public function prepareClassList()
297297
298298 // complete class-factory pairs
299299 if (!$ def ->getEntity ()) {
300- if (!$ def ->getClass ()) {
300+ if (!$ def ->getType ()) {
301301 throw new ServiceCreationException ("Factory and type are missing in definition of service ' $ name'. " );
302302 }
303- $ def ->setFactory ($ def ->getClass (), ($ factory = $ def ->getFactory ()) ? $ factory ->arguments : []);
303+ $ def ->setFactory ($ def ->getType (), ($ factory = $ def ->getFactory ()) ? $ factory ->arguments : []);
304304 }
305305
306306 // auto-disable autowiring for aliases
@@ -320,7 +320,7 @@ public function prepareClassList()
320320 // build auto-wiring list
321321 $ this ->classList = $ preferred = [];
322322 foreach ($ this ->definitions as $ name => $ def ) {
323- if ($ class = $ def ->getImplement () ?: $ def ->getClass ()) {
323+ if ($ class = $ def ->getImplement () ?: $ def ->getType ()) {
324324 $ defAutowired = $ def ->getAutowired ();
325325 if (is_array ($ defAutowired )) {
326326 foreach ($ defAutowired as $ k => $ aclass ) {
@@ -377,22 +377,22 @@ private function resolveImplement(ServiceDefinition $def, $name)
377377 $ def ->setImplementMode ($ rc ->hasMethod ('create ' ) ? $ def ::IMPLEMENT_MODE_CREATE : $ def ::IMPLEMENT_MODE_GET );
378378 $ methodName = Reflection::toString ($ method ) . '() ' ;
379379
380- if (!$ def ->getClass () && !$ def ->getEntity ()) {
380+ if (!$ def ->getType () && !$ def ->getEntity ()) {
381381 $ returnType = Helpers::getReturnType ($ method );
382382 if (!$ returnType ) {
383383 throw new ServiceCreationException ("Method $ methodName used in service ' $ name' has not return type hint or annotation @return. " );
384384 } elseif (!class_exists ($ returnType )) {
385385 throw new ServiceCreationException ("Check a type hint or annotation @return of the $ methodName method used in service ' $ name', class ' $ returnType' cannot be found. " );
386386 }
387- $ def ->setClass ($ returnType );
387+ $ def ->setType ($ returnType );
388388 }
389389
390390 if ($ rc ->hasMethod ('get ' )) {
391391 if ($ method ->getParameters ()) {
392392 throw new ServiceCreationException ("Method $ methodName used in service ' $ name' must have no arguments. " );
393393 }
394394 if (!$ def ->getEntity ()) {
395- $ def ->setFactory ('@ \\' . ltrim ($ def ->getClass (), '\\' ));
395+ $ def ->setFactory ('@ \\' . ltrim ($ def ->getType (), '\\' ));
396396 } elseif (!$ this ->getServiceName ($ def ->getFactory ()->getEntity ())) {
397397 throw new ServiceCreationException ("Invalid factory in service ' $ name' definition. " );
398398 }
@@ -401,7 +401,7 @@ private function resolveImplement(ServiceDefinition $def, $name)
401401 if (!$ def ->parameters ) {
402402 $ ctorParams = [];
403403 if (!$ def ->getEntity ()) {
404- $ def ->setFactory ($ def ->getClass (), $ def ->getFactory () ? $ def ->getFactory ()->arguments : []);
404+ $ def ->setFactory ($ def ->getType (), $ def ->getFactory () ? $ def ->getFactory ()->arguments : []);
405405 }
406406 if (($ class = $ this ->resolveEntityClass ($ def ->getFactory (), [$ name => 1 ]))
407407 && ($ ctor = (new ReflectionClass ($ class ))->getConstructor ())
@@ -445,12 +445,12 @@ private function resolveServiceClass($name, array $recursive = [])
445445
446446 $ def = $ this ->definitions [$ name ];
447447 $ factoryClass = $ def ->getFactory () ? $ this ->resolveEntityClass ($ def ->getFactory ()->getEntity (), $ recursive ) : null ; // call always to check entities
448- if ($ class = $ def ->getClass () ?: $ factoryClass ) {
448+ if ($ class = $ def ->getType () ?: $ factoryClass ) {
449449 if (!class_exists ($ class ) && !interface_exists ($ class )) {
450450 throw new ServiceCreationException ("Class or interface ' $ class' used in service ' $ name' not found. " );
451451 }
452452 $ class = Helpers::normalizeClass ($ class );
453- $ def ->setClass ($ class );
453+ $ def ->setType ($ class );
454454 if (count ($ recursive ) === 1 ) {
455455 $ this ->addDependency (new ReflectionClass ($ factoryClass ?: $ class ));
456456 }
@@ -502,7 +502,7 @@ private function resolveEntityClass($entity, array $recursive = [])
502502 return $ service ;
503503 }
504504 return $ this ->definitions [$ service ]->getImplement ()
505- ?: $ this ->definitions [$ service ]->getClass ()
505+ ?: $ this ->definitions [$ service ]->getType ()
506506 ?: $ this ->resolveServiceClass ($ service , $ recursive );
507507
508508 } elseif (is_string ($ entity )) { // class
@@ -621,7 +621,7 @@ public function completeStatement(Statement $statement): Statement
621621 }
622622 } elseif ($ class = empty ($ service ) || $ entity [1 ] === 'create '
623623 ? $ this ->resolveEntityClass ($ entity [0 ])
624- : $ this ->definitions [$ service ]->getClass ()
624+ : $ this ->definitions [$ service ]->getType ()
625625 ) {
626626 $ arguments = $ this ->autowireArguments ($ class , $ entity [1 ], $ arguments );
627627 }
@@ -640,7 +640,7 @@ public function completeStatement(Statement $statement): Statement
640640 if (!isset ($ pair [1 ])) { // @service
641641 $ val = '@ ' . $ name ;
642642 } elseif (preg_match ('#^[A-Z][A-Z0-9_]*\z# ' , $ pair [1 ], $ m )) { // @service::CONSTANT
643- $ val = self ::literal ($ this ->getDefinition ($ name )->getClass () . ':: ' . $ pair [1 ]);
643+ $ val = self ::literal ($ this ->getDefinition ($ name )->getType () . ':: ' . $ pair [1 ]);
644644 } else { // @service::property
645645 $ val = new Statement (['@ ' . $ name , '$ ' . $ pair [1 ]]);
646646 }
0 commit comments