Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php  | 
            ||
| 13 | class MenuManager extends BaseManager  | 
            ||
| 14 | { | 
            ||
| 15 | /** @var PageView */  | 
            ||
| 16 | private $siteMenu;  | 
            ||
| 17 | |||
| 18 | 8 | public function __construct()  | 
            |
| 24 | |||
| 25 | /**  | 
            ||
| 26 | * An array representing the website's menu structure with children and grandchildren made from static PageViews  | 
            ||
| 27 | *  | 
            ||
| 28 | * @return JailObject[]  | 
            ||
| 29 | */  | 
            ||
| 30 | 8 | public function getSiteMenu ()  | 
            |
| 31 |     { | 
            ||
| 32 | 8 | $jailedMenu = array();  | 
            |
| 33 | |||
| 34 | 8 | foreach ($this->siteMenu as $key => $value)  | 
            |
| 35 |         { | 
            ||
| 36 | // If it's an array, it means the parent is hidden from the site menu therefore its children should be too  | 
            ||
| 37 | 7 | if (is_array($this->siteMenu[$key]))  | 
            |
| 38 |             { | 
            ||
| 39 | 1 | continue;  | 
            |
| 40 | }  | 
            ||
| 41 | |||
| 42 | 7 | $jailedMenu[$key] = $value->createJail();  | 
            |
| 43 | }  | 
            ||
| 44 | |||
| 45 | 8 | return $jailedMenu;  | 
            |
| 46 | }  | 
            ||
| 47 | |||
| 48 | /**  | 
            ||
| 49 | * @param PageView[] $pageViews  | 
            ||
| 50 | */  | 
            ||
| 51 | 8 | public function buildFromPageViews ($pageViews)  | 
            |
| 58 | |||
| 59 | /**  | 
            ||
| 60 | * @param PageView $pageView  | 
            ||
| 61 | */  | 
            ||
| 62 | 8 | public function addToSiteMenu (&$pageView)  | 
            |
| 115 | }  | 
            ||
| 116 | 
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..