Example #1
0
 public function detectPropertyMocks($this_i = 0)
 {
     $tok = $this->getTokenize();
     //echo $tok->dumpAllTokens();
     $propertyMap = ReflectionClass::getForClass($this->class)->getPropertyTypeMap();
     $mocks = array();
     while ($this_i = $tok->findAfter($this_i, T_VARIABLE)) {
         if (!$this_i) {
             break;
         }
         $objVarName = $tok->getStringAt($this_i);
         if ('$this' !== $objVarName) {
             continue;
         }
         if (T_OBJECT_OPERATOR !== $tok->getTokenTypeAt(++$this_i)) {
             continue;
         }
         $possiblePropertyName = $tok->getStringAt(++$this_i);
         if (empty($propertyMap[$possiblePropertyName])) {
             continue;
         }
         // and now actual method proxy detection
         if (T_OBJECT_OPERATOR !== $tok->getTokenTypeAt(++$this_i)) {
             continue;
         }
         $possibleMethodName = $tok->getStringAt(++$this_i);
         if ('(' !== $tok->getCharAt(++$this_i)) {
             continue;
         }
         $mocks[$propertyMap[$possiblePropertyName]][] = $possibleMethodName;
     }
     return $mocks;
 }