| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Alpixel\Bundle\CMSBundle\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Sonata\AdminBundle\Admin\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | class BaseAdmin extends Admin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     protected $realLocales; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     protected $cmsTypes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     protected $cmsEntityTypes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     protected function getRealLocales() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         if (!empty($this->realLocales)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |             return $this->realLocales; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $container = $this->getConfigurationPool()->getContainer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         $realLocales = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         if ($container->hasParameter('lunetics_locale.allowed_locales')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             $locales = $container->getParameter('lunetics_locale.allowed_locales'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             foreach ($locales as $val) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |                 $this->realLocales[$val] = $val; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |             $locale = $container->getParameter('default_locale'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             $this->realLocales[$locale] = $locale; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         return $this->realLocales; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     protected function getCMSTypes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         if (!empty($this->cmsTypes)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             return $this->cmsTypes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $container       = $this->getConfigurationPool()->getContainer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $types           = $container->getParameter('alpixel_cms.content_types'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->cmsTypes  = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         foreach ($types as $key => $array) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             $this->cmsTypes[$array['class']] = $array['title']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return $this->cmsTypes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 50 |  |  |     protected function getCMSEntityTypes() | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 52 |  |  |         if (!empty($this->cmsEntityTypes)) { | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |             return $this->cmsEntityTypes; | 
            
                                                        
            
                                    
            
            
                | 54 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 56 |  |  |         $cmsTypes             = $this->getCMSTypes(); | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |         $this->cmsEntityTypes = []; | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |         foreach ($cmsTypes as $class => $title) { | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |             $type = lcfirst(substr($class, (strrpos($class, '\\') + 1) , strlen($class))); | 
            
                                                        
            
                                    
            
            
                | 60 |  |  |             $this->cmsEntityTypes[$type] = $title; | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |         return $this->cmsEntityTypes; | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 65 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |  | 
            
                        
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.