| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Gacela\Console\Domain\AllAppModules; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Gacela\Framework\ClassResolver\Config\ConfigNotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Gacela\Framework\ClassResolver\Config\ConfigResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Gacela\Framework\ClassResolver\DependencyProvider\DependencyProviderNotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Gacela\Framework\ClassResolver\DependencyProvider\DependencyProviderResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Gacela\Framework\ClassResolver\Factory\FactoryNotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Gacela\Framework\ClassResolver\Factory\FactoryResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use ReflectionClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use function strlen; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | final class AppModuleCreator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 | 8 |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         private FactoryResolver $factoryResolver, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         private ConfigResolver $configResolver, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         private DependencyProviderResolver $dependencyProviderResolver, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 8 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @param class-string $facadeClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 8 |  |     public function fromClass(string $facadeClass): AppModule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 8 |  |         return new AppModule( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 8 |  |             $this->fullModuleName($facadeClass), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 8 |  |             $this->moduleName($facadeClass), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 8 |  |             $facadeClass, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 8 |  |             $this->findFactory($facadeClass), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 8 |  |             $this->findConfig($facadeClass), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 8 |  |             $this->findDependencyProvider($facadeClass), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 8 |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param class-string $facadeClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 8 |  |     private function fullModuleName(string $facadeClass): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 8 |  |         $moduleNameIndex = strrpos($facadeClass, '\\') ?: strlen($facadeClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 8 |  |         return substr($facadeClass, 0, $moduleNameIndex); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @param class-string $facadeClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 8 |  |     private function moduleName(string $facadeClass): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 8 |  |         $fullModuleName = $this->fullModuleName($facadeClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 8 |  |         $moduleName = strrchr($fullModuleName, '\\') ?: $fullModuleName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 8 |  |         return ltrim($moduleName, '\\'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @param class-string $facadeClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 8 |  |     private function findFactory(string $facadeClass): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 8 |  |             $resolver = $this->factoryResolver->resolve($facadeClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 8 |  |             if ((new ReflectionClass($resolver))->isAnonymous()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 4 |  |                 throw new FactoryNotFoundException($facadeClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 7 |  |             return $resolver::class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 4 |  |         } catch (FactoryNotFoundException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 4 |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @param class-string $facadeClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 8 |  |     private function findConfig(string $facadeClass): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 8 |  |             $resolver = $this->configResolver->resolve($facadeClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 8 |  |             if ((new ReflectionClass($resolver))->isAnonymous()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 6 |  |                 throw new ConfigNotFoundException($facadeClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 5 |  |             return $resolver::class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 | 6 |  |         } catch (ConfigNotFoundException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 6 |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @param class-string $facadeClass | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 102 | 8 |  |     private function findDependencyProvider(string $facadeClass): ?string | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |         try { | 
            
                                                                        
                            
            
                                    
            
            
                | 105 | 8 |  |             $resolver = $this->dependencyProviderResolver->resolve($facadeClass); | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 107 | 7 |  |             if ((new ReflectionClass($resolver))->isAnonymous()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |                 throw new DependencyProviderNotFoundException($resolver); | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 110 | 7 |  |             return $resolver::class; | 
            
                                                                        
                            
            
                                    
            
            
                | 111 | 4 |  |         } catch (DependencyProviderNotFoundException $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 112 | 4 |  |             return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 115 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 116 |  |  |  | 
            
                        
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.