/** * 处理赋值语句右边的三元表达式 * @param unknown $part * @param unknown $dataFlow */ public static function ternaryHandler($type, $part, $dataFlow) { $ter_symbol = new MutipleSymbol(); $ter_symbol->setItemByNode($part); if ($type == 'right') { $dataFlow->setValue($ter_symbol); } }
/** * 根据AST node获取相应的symbol * @param unknown $node */ public static function getSymbolByNode($node) { if ($node && SymbolUtils::isValue($node)) { //在DataFlow加入Location以及name $vs = new ValueSymbol(); $vs->setValueByNode($node); return $vs; } elseif ($node && SymbolUtils::isVariable($node)) { //加入dataFlow $vars = new VariableSymbol(); $vars->setNameByNode($node); $vars->setValue($node); return $vars; } elseif ($node && SymbolUtils::isArrayDimFetch($node)) { //加入dataFlow $arr = new ArrayDimFetchSymbol(); $arr->setValue($node); return $arr; } elseif ($node && SymbolUtils::isConcat($node)) { $concat = new ConcatSymbol(); $concat->setItemByNode($node); return $concat; } elseif ($node && $node->getType() == "Scalar_Encapsed") { $arr = array(); $symbol = new MutipleSymbol(); foreach ($node->parts as $item) { if (is_object($item) && self::isValue($item) == false) { $sym = self::getSymbolByNode($item); array_push($arr, $sym); } } $symbol->setSymbols($arr); return $symbol; } else { return null; } }