| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Charcoal\App; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | // Module `charcoal-config` dependencies | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use \Charcoal\Config\AbstractConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | // Module `charcoal-core` dependencies | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use \Charcoal\Translation\TranslationConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | // Intra-module (`charcoal-app`) dependencies | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use \Charcoal\App\Language\Language; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | * Charcoal App configuration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class AppConfig extends AbstractConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     * @var array $routes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $routes = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     * @var array $routables | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $routables = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     * @var array $modules | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     private $modules = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     * @param array $routes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     * @return AppConfig Chainable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public function set_routes(array $routes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->routes = $routes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function routes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         return $this->routes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     * @param array $routes | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     * @return AppConfig Chainable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function set_routables(array $routables) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->routables = $routables; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     public function routables() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         return $this->routables; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     * @param array $modules | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     * @return AppConfig Chainable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public function set_modules(array $modules) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $this->modules = $modules; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     public function modules() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         return $this->modules; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     * Set the application's available languages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     * @param  Language[] $lang | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     * @return self | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 93 |  |  |     */ | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |     public function set_languages(array $languages) | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |         $this->languages = $languages; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     * Add or update an available language to the application | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     * @param  Language $lang | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     public function add_language(Language $lang) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->languages[$lang->ident()] = $lang; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     * Get the application's list of available languages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     * @return Language[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     public function languages() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         return $this->languages; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     * Set the application's global TranslationConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     * @param  array|TranslationConfig $translation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 128 |  | View Code Duplication |     public function set_translation($translation) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         if ($translation instanceof TranslationConfig) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             $this->translation_config = $translation; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         } elseif (is_array($translation)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             $this->translation_config = new TranslationConfig($translation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     * Get the application's global TranslationConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     * @return TranslationConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     public function translation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         return $this->translation_config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 147 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 148 |  |  |  | 
            
                        
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.