You are here

public static function FunctionCommentSniff::suggestType in Coder 8.2

Same name and namespace in other branches
  1. 8.3 coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php \Drupal\Sniffs\Commenting\FunctionCommentSniff::suggestType()
  2. 8.3.x coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php \Drupal\Sniffs\Commenting\FunctionCommentSniff::suggestType()

Returns a valid variable type for param/var tag.

Parameters

string $type The variable type to process.:

Return value

string

3 calls to FunctionCommentSniff::suggestType()
FunctionCommentSniff::processParams in coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php
Process the function parameter comments.
FunctionCommentSniff::processReturn in coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php
Process the return comment of this function comment.
VariableCommentSniff::processMemberVar in coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php
Called to process class member vars.

File

coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php, line 928

Class

FunctionCommentSniff
Parses and verifies the doc comments for functions. Largely copied from PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff.

Namespace

Drupal\Sniffs\Commenting

Code

public static function suggestType($type) {
  if (isset(static::$invalidTypes[$type]) === true) {
    return static::$invalidTypes[$type];
  }
  if ($type === '$this') {
    return $type;
  }
  $type = preg_replace('/[^a-zA-Z0-9_\\\\[\\]]/', '', $type);
  return $type;
}