Browse Source

chore: Tokens::setCode - further improvements to cache (#8053)

Dariusz Rumiński 9 months ago
parent
commit
837bdbada8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      src/Tokenizer/Tokens.php

+ 2 - 3
src/Tokenizer/Tokens.php

@@ -1047,6 +1047,8 @@ class Tokens extends \SplFixedArray
 
         // clear memory
         $this->setSize(0);
+        $this->blockStartCache = [];
+        $this->blockEndCache = [];
 
         $tokens = token_get_all($code, TOKEN_PARSE);
 
@@ -1056,9 +1058,6 @@ class Tokens extends \SplFixedArray
             $this[$index] = new Token($token);
         }
 
-        $this->blockStartCache = [];
-        $this->blockEndCache = [];
-
         $this->applyTransformers();
 
         $this->foundTokenKinds = [];