@@ -8025,6 +8025,7 @@ public function format($source)
80258025 $docBlocks = [];
80268026 $declares = [];
80278027 $namespaceBlock = '';
8028+ $sawTopFileSection = false;
80288029 $useBlocks = [
80298030 'class' => [],
80308031 'function' => [],
@@ -8045,12 +8046,18 @@ public function format($source)
80458046 }
80468047
80478048 if (T_COMMENT === $id) {
8049+ if ($sawTopFileSection) {
8050+ break;
8051+ }
80488052 $prefixComments[] = trim($text);
80498053 ++$idx;
80508054 continue;
80518055 }
80528056
80538057 if (T_DOC_COMMENT === $id) {
8058+ if ($sawTopFileSection) {
8059+ break;
8060+ }
80548061 $docBlocks[] = trim($text);
80558062 ++$idx;
80568063 continue;
@@ -8062,18 +8069,21 @@ public function format($source)
80628069 }
80638070 list($declareText, $idx) = $this->accumulateStatement($tokens, $idx);
80648071 $declares[] = trim($declareText);
8072+ $sawTopFileSection = true;
80658073 continue;
80668074 }
80678075
80688076 if (T_NAMESPACE === $id) {
80698077 list($namespaceBlock, $idx) = $this->accumulateStatement($tokens, $idx);
80708078 $namespaceBlock = trim($namespaceBlock);
8079+ $sawTopFileSection = true;
80718080 continue;
80728081 }
80738082
80748083 if (T_USE === $id) {
80758084 list($useText, $idx) = $this->accumulateStatement($tokens, $idx);
80768085 $useText = trim($useText);
8086+ $sawTopFileSection = true;
80778087 if (0 === stripos($useText, 'use function ')) {
80788088 $useBlocks['function'][] = $useText;
80798089 } elseif (0 === stripos($useText, 'use const ')) {
0 commit comments