/** * @param string $source * @return array */ public function analyse($source) { $warnings = array(); $functions = $this->extractSprintfFloatFormatFunctionCalls($source); foreach ($functions as $function) { $token = $function['token']; if (!isset($warnings[$token[2]])) { $warnings[$token[2]] = LintWarning::make($source, $token[2], $this); } } return array_values($warnings); }
/** * @param string $source * @return array */ public function analyse($source) { $warnings = array(); $tokens = token_get_all($source); foreach ($tokens as $token) { if (is_array($token)) { if ($token[0] === $this->getToken()) { // we found the token // only need to create a new warning if one doesn't already exist for this line if (!isset($warnings[$token[2]])) { $warnings[$token[2]] = LintWarning::make($source, $token[2], $this); } } } } return array_values($warnings); }
/** * @param string $source * @return array */ public function analyse($source) { $warnings = array(); $tokens = token_get_all($source); foreach ($tokens as $token) { if (is_array($token)) { if ($token[0] === T_STRING && strcasecmp($token[1], $this->getFunctionName()) === 0) { // we found a call to the function // only need to create a new warning if one doesn't already exist for this line if (!isset($warnings[$token[2]])) { $warnings[$token[2]] = LintWarning::make($source, $token[2], $this); } } } } return array_values($warnings); }
/** * @param string $source * @return array */ public function analyse($source) { $warnings = array(); $tokens = token_get_all($source); foreach ($tokens as $token) { if (is_array($token)) { if ($token[0] === T_DOC_COMMENT) { // we found a doc style comment // find matching phpdoc annotations $annotations = $this->getMatchingAnnotationsFromComment($token[1], $this->getAnnotationCriteria()); if (count($annotations) > 0) { // only need to create a new warning if one doesn't already exist for this line if (!isset($warnings[$token[2]])) { $warnings[$token[2]] = LintWarning::make($source, $token[2], $this); } } } } } return array_values($warnings); }
/** * @param string $source * @return array */ public function analyse($source) { // simple tokens come back as strings and don't contain any line data // therefore, we keep track of line numbers separately and assume that if a simple token is found, it must // appear on the last recorded line numbers $warnings = array(); $tokens = token_get_all($source); $line = 1; foreach ($tokens as $token) { if (is_array($token)) { $line = $token[2]; // keep track of line number } else { if ($token === $this->getToken()) { // we found the token // only need to create a new warning if one doesn't already exist for this line if (!isset($warnings[$line])) { $warnings[$line] = LintWarning::make($source, $line, $this); } } } } return array_values($warnings); }