Hoa central
NoBlankLinesBeforeEntity.php
Go to the documentation of this file.
1 <?php
2 
38 
39 use SplFileInfo;
43 
52 class NoBlankLinesBeforeEntity extends AbstractLinesBeforeNamespaceFixer
53 {
54  public function fix(SplFileInfo $file, $content)
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  }
75 
76  public function getDescription()
77  {
78  return 'Remove blank lines before entity declarations.';
79  }
80 
81  public function getName()
82  {
83  return 'no_blank_lines_before_entity';
84  }
85 
86  public function getLevel()
87  {
88  return FixerInterface::CONTRIB_LEVEL;
89  }
90 }
$content
Definition: Hoa.php:119