PhpCsFixer\Tokenizer\Tokens::clearCache PHP Method

clearCache() public static method

Clear cache - one position or all of them.
public static clearCache ( string | null $key = null )
$key string | null position to clear, when null clear all
    public static function clearCache($key = null)
    {
        if (null === $key) {
            self::$cache = array();
            return;
        }
        if (self::hasCache($key)) {
            unset(self::$cache[$key]);
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param int    $expected
  * @param string $code
  * @param int    $index
  *
  * @dataProvider provideCommentBlockStartDetectionCases
  */
 public function testCommentBlockStartDetection($expected, $code, $index)
 {
     Tokens::clearCache();
     $tokens = Tokens::fromCode($code);
     $fixer = $this->getFixer();
     $method = new \ReflectionMethod($fixer, 'findCommentBlockStart');
     $method->setAccessible(true);
     if ($expected !== ($result = $method->invoke($fixer, $tokens, $index))) {
         $this->fail(sprintf('Expected index %d (%s) got index %d (%s).', $expected, $tokens[$expected]->toJson(), $result, $tokens[$result]->toJson()));
     }
 }
All Usage Examples Of PhpCsFixer\Tokenizer\Tokens::clearCache