| Conditions | 5 | 
| Paths | 7 | 
| Total Lines | 34 | 
| Code Lines | 21 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 27 | public static function getInstance($name, array $args = [])  | 
            ||
| 28 |     { | 
            ||
| 29 | $psc = PropertySetConfig::getConfig();  | 
            ||
| 30 | $class = $psc->getClassName($name);  | 
            ||
| 31 | |||
| 32 |         if (null === $class || !class_exists($class)) { | 
            ||
| 33 | return null;  | 
            ||
| 34 | }  | 
            ||
| 35 | |||
| 36 | $config = $psc->getArgs($name);  | 
            ||
| 37 | |||
| 38 |         try { | 
            ||
| 39 | $r = new ReflectionClass($class);  | 
            ||
| 40 | $ps = $r->newInstance();  | 
            ||
| 41 | |||
| 42 |             if (!$ps instanceof PropertySetInterface) { | 
            ||
| 43 | $errMsg = sprintf(  | 
            ||
| 44 | 'Объект должен реализовывать интерфейс %s',  | 
            ||
| 45 | PropertySetInterface::class  | 
            ||
| 46 | );  | 
            ||
| 47 | throw new RuntimeException($errMsg);  | 
            ||
| 48 | }  | 
            ||
| 49 | |||
| 50 | $ps->init($config, $args);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 51 | |||
| 52 | return $ps;  | 
            ||
| 53 |         } catch (\Exception $e) { | 
            ||
| 54 | $errMsg = sprintf(  | 
            ||
| 55 | 'Ошибка при создание сервиса %s',  | 
            ||
| 56 | $name  | 
            ||
| 57 | );  | 
            ||
| 58 | throw new RuntimeException($errMsg);  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | }  | 
            ||
| 62 | 
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.