| 1 |  |  | <?php namespace App\Providers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Illuminate\Http\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Routing\Router; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  | class RouteServiceProvider extends ServiceProvider | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |      * This namespace is applied to the controller routes in your routes file. | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |      * In addition, it is set as the URL generator's root namespace. | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |      * @var string | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     protected $namespace = 'App\Http\Controllers'; | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |      * Define your route model bindings, pattern filters, etc. | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     public function boot() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 31 |  |         app('router')->patterns([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             'provider' => 'twitter|google|facebook', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 31 |  |             'token' => '[a-zA-Z0-9-]+' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 31 |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 31 |  |         parent::boot(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 31 | 31 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 | 31 |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * Define the routes for the application. | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     public function map() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->mapApiRoutes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->mapWebRoutes(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 39 | 31 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 41 | 31 |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 42 | 31 |  |      * Define the "api" routes for the application. | 
            
                                                                        
                            
            
                                    
            
            
                | 43 | 31 |  |      * These routes are typically stateless. | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     protected function mapApiRoutes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         app('router')->group([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 31 |  |             'middleware' => 'api', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 31 |  |             'namespace' => $this->namespace, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             'prefix' => 'api/v1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ], function (Router $router) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             $router->post('login', 'Auth\LoginController@login'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             $router->post('logout', 'Auth\LoginController@logout')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             $router->post('register', 'Auth\RegisterController@register'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 31 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 31 |  |             $router->post('password/email', 'Auth\PasswordController@sendPasswordResetLink'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             $router->post('password/reset', 'Auth\PasswordController@resetPassword'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 31 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 31 |  |             $router->get('activation', 'Auth\ActivateController@requestActivationCode')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             $router->get('activation/{token}', 'Auth\ActivateController@activate')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             $router->post('activation', 'Auth\ActivateController@activate')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         }); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 66 | 31 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 67 | 31 |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 68 | 31 |  |      * Define the "web" routes for the application. | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |      * These routes all receive session state, CSRF protection, etc. | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     protected function mapWebRoutes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 31 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 31 |  |         app('router')->group([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 31 |  |             'middleware' => 'web', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 31 |  |             'namespace' => $this->namespace, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 31 |  |         ], function (Router $router) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             $defaultLocale = config('app.locale'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 31 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             //----------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 31 |  |             // Non-localized, generic routes (such as those for admin panel etc). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 31 |  |             //----------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 31 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 31 |  |             $router->get('/oauth/to/{provider}', ['uses' => 'Auth\LoginController@handleOAuthRedirect', 'as' => 'oauth.to']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 31 |  |             $router->get('/oauth/from/{provider}', ['uses' => 'Auth\LoginController@handleOAuthReturn', 'as' => 'oauth.from']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 31 |  |             //----------------------------------------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             // Register localized routes with locale-prefices (in case of default locale, no prefix is attached). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 31 |  |             //----------------------------------------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 31 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 31 |  |             foreach (config('app.locales') as $prefix => $localeName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 31 |  |                 app('translator')->setLocale($prefix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                 // Localized routes. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 31 |  |                 $router->group(compact('namespace', 'middleware', 'prefix'), function (Router $router) use ($prefix) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 31 |  |                     $this->localizeWebRoutes($router, $prefix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 31 |  |                 }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 31 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             /*------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 31 |  |              | Default, non-localized home | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 31 |  |              *-----------------------------------*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             $router->get('', 'HomeController@index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         }); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |      * @param \Illuminate\Routing\Router $router | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |      * @param string                     $prefix | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     protected function localizeWebRoutes(Router $router, $prefix = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $router->get('login', ['uses' => 'Auth\LoginController@showLoginForm', 'as' => empty($prefix) ?: $prefix . '.login']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $router->post('login', 'Auth\LoginController@loginViaWeb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $router->get('logout', ['uses' => 'Auth\LoginController@logout', 'as' => empty($prefix) ?: $prefix . '.logout']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         $router->get('register', ['uses' => 'Auth\RegisterController@showRegistrationForm', 'as' => empty($prefix) ?: $prefix . '.register']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $router->post('register', 'Auth\RegisterController@register'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $router->get('password/email', ['uses' => 'Auth\PasswordController@requestPasswordResetLink', 'as' => empty($prefix) ?: $prefix . '.password.email']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         $router->post('password/email', 'Auth\PasswordController@sendPasswordResetLink'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $router->get('password/reset/{token}', ['uses' => 'Auth\PasswordController@showPasswordResetForm', 'as' => empty($prefix) ?: $prefix . '.password.reset']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $router->post('password/reset', 'Auth\PasswordController@resetPassword'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $router->get('activation', ['uses' => 'Auth\ActivateController@requestActivationCode', 'as' => empty($prefix) ?: $prefix . '.activation.request']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $router->get('activation/{token}', ['uses' => 'Auth\ActivateController@activate', 'as' => empty($prefix) ?: $prefix . '.activation.complete']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $router->post('activation', 'Auth\ActivateController@activate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $router->resource('files', 'FilesController', ['only' => ['index', 'create', 'store', 'show', 'destroy']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $router->get('', ['uses' => 'HomeController@index', 'as' => empty($prefix) ?: $prefix . '.home']); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 132 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 133 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 134 |  |  |  | 
            
                        
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.