/** * Process the var tag * * @param integer $commentStart The position in the stack where the comment started * @param integer $commentEnd The position in the stack where the comment ended * @return void */ public function processVar($commentStart, $commentEnd) { $var = $this->commentParser->getVar(); if ($var !== null) { $errorPos = $commentStart + $var->getLine(); $index = array_keys($this->commentParser->getTagOrders(), 'var'); if (count($index) > 1) { $this->currentFile->addError("Le tag @version doit être présent une seule fois dans le commentaire de variable", $errorPos, 'OneVersionTagVariableComment'); return; } if ($index[0] !== 1) { $this->currentFile->addError("Le tag @version doit être présent une seule fois dans le commentaire de variable", $errorPos, 'OneVersionTagVariableComment'); } $content = $var->getContent(); if (empty($content) === true) { $this->currentFile->addError("Le tag @type doit être suivi du type de variable", $errorPos, 'TypeMissingVarTagVariableComment'); return; } else { $suggestedType = PHP_CodeSniffer::suggestType($content); if ($content !== $suggestedType) { $this->currentFile->addError('Le tag @type devrait être suivi de "' . $suggestedType . '", "' . $content . '" trouvé', $errorPos, 'ExpectedFoundVarTagVariableComment'); } } $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); if ($spacing !== $this->space) { $this->currentFile->addError($this->space . ' espace(s) attendu(s), ' . $spacing . ' trouvé(s)', $errorPos, 'ExpectedSpacesFoundVarTagVariableComment'); } } else { $this->currentFile->addError('Le tag @var est manquant dans le commentaire de variable', $commentEnd, 'MissingVarTagVariableComment'); } }
/** * Process the var tag * * @param integer $commentStart The position in the stack where the comment started * @param integer $commentEnd The position in the stack where the comment ended * @return void */ public function processVar($commentStart, $commentEnd) { $var = $this->commentParser->getVar(); if ($var !== null) { $errorPos = $commentStart + $var->getLine(); $index = array_keys($this->commentParser->getTagOrders(), 'var'); if (count($index) > 1) { $this->currentFile->addEvent('ONE_VERSION_TAG_VARIABLE_COMMENT', array(), $errorPos); return; } if ($index[0] !== 1) { $this->currentFile->addEvent('ONE_VERSION_TAG_VARIABLE_COMMENT', array(), $errorPos); } $content = $var->getContent(); if (empty($content) === true) { $this->currentFile->addEvent('TYPE_MISSING_VAR_TAG_VARIABLE_COMMENT', array(), $errorPos); return; } else { $suggestedType = PHP_CodeSniffer::suggestType($content); if ($content !== $suggestedType) { $this->currentFile->addEvent('EXPECTED_FOUND_VAR_TAG_VARIABLE_COMMENT', array('suggestedyype' => $suggestedType, 'content' => $content), $errorPos); } } $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); if ($spacing !== $this->space) { $this->currentFile->addEvent('EXPECTED_SPACES_FOUND_VAR_TAG_VARIABLE_COMMENT', array('space' => $this->space, 'spacing' => $spacing), $errorPos); } } else { $this->currentFile->addEvent('MISSING_VAR_TAG_VARIABLE_COMMENT', array(), $commentEnd); } }
protected function processVar($errorPos) { $var = $this->commentParser->getVar()->getContent(); // Check type $r = $this->checkType($var, $this->allowedParamTypes, 'var'); if (true !== $r) { $this->currentFile->addError($this->getReqPrefix('REQ.PHP.3.5.15') . $r, $errorPos); } }
/** * Process the var tag. * * @param int $commentStart The position in the stack where the comment started. * @param int $commentEnd The position in the stack where the comment ended. * * @return void */ protected function processVar($commentStart, $commentEnd) { $var = $this->commentParser->getVar(); if ($var !== null) { $errorPos = $commentStart + $var->getLine(); $index = array_keys($this->commentParser->getTagOrders(), 'var'); if (count($index) > 1) { $error = 'Only 1 @var tag is allowed in variable comment'; $this->currentFile->addError($error, $errorPos, 'DuplicateVar'); return; } if ($index[0] !== 1) { $error = 'The @var tag must be the first tag in a variable comment'; $this->currentFile->addError($error, $errorPos, 'VarOrder'); } $content = $var->getContent(); if (empty($content) === true) { $error = 'Var type missing for @var tag in variable comment'; $this->currentFile->addError($error, $errorPos, 'MissingVarType'); return; } else { $suggestedType = PHP_CodeSniffer::suggestType($content); if ($suggestedType !== $content) { // hotfix - somehow they do not like "int" and "bool". switch ($content) { case 'int': $suggestedType = 'int'; break; case 'bool': $suggestedType = 'bool'; break; default: } } if ($content !== $suggestedType) { $error = 'Expected "%s"; found "%s" for @var tag in variable comment'; $data = array($suggestedType, $content); $this->currentFile->addError($error, $errorPos, 'IncorrectVarType', $data); } } $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); if ($spacing !== 1) { $error = '@var tag indented incorrectly; expected 1 space but found %s'; $data = array($spacing); $this->currentFile->addError($error, $errorPos, 'VarIndent', $data); } } else { $error = 'Missing @var tag in variable comment'; $this->currentFile->addError($error, $commentEnd, 'MissingVar'); } //end if }
/** * Process the var tag. * * @param int $commentStart The position in the stack where the comment started. * @param int $commentEnd The position in the stack where the comment ended. * * @return void */ protected function processVar($commentStart, $commentEnd) { $var = $this->commentParser->getVar(); if ($var !== null) { $errorPos = $commentStart + $var->getLine(); $index = array_keys($this->commentParser->getTagOrders(), 'var'); if (count($index) > 1) { $error = 'Only 1 @var tag is allowed in variable comment'; $this->currentFile->addError($error, $errorPos); return; } if ($index[0] !== 1) { $error = 'The @var tag must be the first tag in a variable comment'; $this->currentFile->addError($error, $errorPos); } $content = $var->getContent(); if (empty($content) === true) { $error = 'Var type missing for @var tag in variable comment'; $this->currentFile->addError($error, $errorPos); return; } else { $suggestedType = PHP_CodeSniffer::suggestType($content); if ($content !== $suggestedType) { $error = "Expected \"{$suggestedType}\"; found \"{$content}\" for @var tag in variable comment"; $this->currentFile->addError($error, $errorPos); } } $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); if ($spacing !== 3) { $error = '@var tag indented incorrectly. '; $error .= "Expected 3 spaces but found {$spacing}."; $this->currentFile->addError($error, $errorPos); } } else { $error = 'Missing @var tag in variable comment'; $this->currentFile->addError($error, $commentEnd); } //end if }