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

Public Member Functions

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

Detailed Description

Class .

Remove blank lines before entity declarations (class, interface, trait etc.).

Definition at line 52 of file NoBlankLinesBeforeEntity.php.

Member Function Documentation

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

Definition at line 54 of file NoBlankLinesBeforeEntity.php.

55  {
56  $tokens = Tokens::fromCode($content);
57 
58  foreach ($tokens as $index => $token) {
59  if ($token->isGivenKind(T_CLASS) ||
60  $token->isGivenKind(T_INTERFACE) ||
61  $token->isGivenKind(T_TRAIT)) {
62  $docCommentIndex = $tokens->getTokenOfKindSibling(
63  $index,
64  -1,
65  [[T_DOC_COMMENT]],
66  false
67  );
68  $firstSignificantIndex = $tokens->getNextNonWhitespace($docCommentIndex);
69  $this->fixLinesBeforeNamespace($tokens, $firstSignificantIndex, 1);
70  }
71  }
72 
73  return $tokens->generateCode();
74  }
$content
Definition: Hoa.php:119
Hoa\Devtools\Resource\PHPCSFixer\Fixer\NoBlankLinesBeforeEntity::getDescription ( )

Definition at line 76 of file NoBlankLinesBeforeEntity.php.

77  {
78  return 'Remove blank lines before entity declarations.';
79  }
Hoa\Devtools\Resource\PHPCSFixer\Fixer\NoBlankLinesBeforeEntity::getLevel ( )

Definition at line 86 of file NoBlankLinesBeforeEntity.php.

87  {
88  return FixerInterface::CONTRIB_LEVEL;
89  }
Hoa\Devtools\Resource\PHPCSFixer\Fixer\NoBlankLinesBeforeEntity::getName ( )

Definition at line 81 of file NoBlankLinesBeforeEntity.php.

82  {
83  return 'no_blank_lines_before_entity';
84  }

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