hphp/compiler/analysis/class_scope.cpp
// This method removes trait abstract methods that are either:
//   1) implemented by other traits
//   2) duplicate
This method removes trait abstract methods that are either:
1) implemented by other traits
2) duplicate
This method removes trait abstract methods that are either : 1 ) implemented by other traits 2 ) duplicate
void ClassScope::removeSpareTraitAbstractMethods(AnalysisResultPtr ar) {
  assert(Option::WholeProgram);
  for (MethodToTraitListMap::iterator iter = m_importMethToTraitMap.begin();
       iter != m_importMethToTraitMap.end(); iter++) {
    TraitMethodList& tMethList = iter->second;
    bool hasNonAbstractMeth = false;
    unsigned countAbstractMeths = 0;
    for (TraitMethodList::const_iterator traitMethIter = tMethList.begin();
         traitMethIter != tMethList.end(); traitMethIter++) {
      ModifierExpressionPtr modifiers = traitMethIter->m_modifiers ?
        traitMethIter->m_modifiers : traitMethIter->m_method->getModifiers();
      if (!(modifiers->isAbstract())) {
        hasNonAbstractMeth = true;
      } else {
        countAbstractMeths++;
      }
    }
    if (hasNonAbstractMeth || countAbstractMeths > 1) {
      bool firstAbstractMeth = true;
      for (TraitMethodList::iterator nextTraitIter = tMethList.begin();
           nextTraitIter != tMethList.end(); ) {
        TraitMethodList::iterator traitIter = nextTraitIter++;
        ModifierExpressionPtr modifiers = traitIter->m_modifiers ?
          traitIter->m_modifiers : traitIter->m_method->getModifiers();
        if (modifiers->isAbstract()) {
          if (hasNonAbstractMeth || !firstAbstractMeth) {
            tMethList.erase(traitIter);
          }
          firstAbstractMeth = false;
        }
      }
    }
  }
}
void ClassScope :: removeSpareTraitAbstractMethods ( AnalysisResultPtr ar ) { assert ( Option :: WholeProgram ) ; for ( MethodToTraitListMap :: iterator iter = m_importMethToTraitMap . begin ( ) ; iter != m_importMethToTraitMap . end ( ) ; iter ++ ) { TraitMethodList & tMethList = iter -> second ; bool hasNonAbstractMeth = false ; unsigned countAbstractMeths = 0 ; for ( TraitMethodList :: const_iterator traitMethIter = tMethList . begin ( ) ; traitMethIter != tMethList . end ( ) ; traitMethIter ++ ) { ModifierExpressionPtr modifiers = traitMethIter -> m_modifiers ? traitMethIter -> m_modifiers : traitMethIter -> m_method -> getModifiers ( ) ; if ( ! ( modifiers -> isAbstract ( ) ) ) { hasNonAbstractMeth = true ; } else { countAbstractMeths ++ ; } } if ( hasNonAbstractMeth || countAbstractMeths > 1 ) { bool firstAbstractMeth = true ; for ( TraitMethodList :: iterator nextTraitIter = tMethList . begin ( ) ; nextTraitIter != tMethList . end ( ) ; ) { TraitMethodList :: iterator traitIter = nextTraitIter ++ ; ModifierExpressionPtr modifiers = traitIter -> m_modifiers ? traitIter -> m_modifiers : traitIter -> m_method -> getModifiers ( ) ; if ( modifiers -> isAbstract ( ) ) { if ( hasNonAbstractMeth || ! firstAbstractMeth ) { tMethList . erase ( traitIter ) ; } firstAbstractMeth = false ; } } } } }
This method removes trait abstract methods that are either:
1) implemented by other traits
2) duplicate
This method removes trait abstract methods that are either : 1 ) implemented by other traits 2 ) duplicate
// Erase spare abstract declarations