Hoa central
Public Member Functions | List of all members
Hoa\Devtools\Resource\PHPCSFixer\Fixer\PhpdocThrows Class Reference
Inheritance diagram for Hoa\Devtools\Resource\PHPCSFixer\Fixer\PhpdocThrows:

Public Member Functions

 fix (SplFileInfo $file, $content)
 
 getDescription ()
 
 getName ()
 
 getLevel ()
 

Detailed Description

Class .

Transform @throw to @throws.

Definition at line 53 of file PhpdocThrows.php.

Member Function Documentation

Hoa\Devtools\Resource\PHPCSFixer\Fixer\PhpdocThrows::fix ( SplFileInfo  $file,
  $content 
)

Definition at line 55 of file PhpdocThrows.php.

56  {
57  $tokens = Tokens::fromCode($content);
58 
59  foreach ($tokens->findGivenKind(T_DOC_COMMENT) as $token) {
60  $docBlock = new DocBlock($token->getContent());
61  $annotations = $docBlock->getAnnotationsOfType('throw');
62 
63  if (empty($annotations)) {
64  continue;
65  }
66 
67  foreach ($annotations as $annotation) {
68  $line = $docBlock->getLine($annotation->getStart());
69  $line->setContent(
70  str_replace(
71  '@throw ',
72  '@throws',
73  $line->getContent()
74  )
75  );
76  }
77 
78  $token->setContent($docBlock->getContent());
79  }
80 
81  return $tokens->generateCode();
82  }
$content
Definition: Hoa.php:119
Hoa\Devtools\Resource\PHPCSFixer\Fixer\PhpdocThrows::getDescription ( )

Definition at line 84 of file PhpdocThrows.php.

85  {
86  return 'Replace `@throw` by `@throws`.';
87  }
Hoa\Devtools\Resource\PHPCSFixer\Fixer\PhpdocThrows::getLevel ( )

Definition at line 94 of file PhpdocThrows.php.

95  {
96  return FixerInterface::CONTRIB_LEVEL;
97  }
Hoa\Devtools\Resource\PHPCSFixer\Fixer\PhpdocThrows::getName ( )

Definition at line 89 of file PhpdocThrows.php.

90  {
91  return 'phpdoc_throws';
92  }

The documentation for this class was generated from the following file: