PhpToken_extension.phpt 524 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Extending the PhpToken class
  3. --EXTENSIONS--
  4. tokenizer
  5. --FILE--
  6. <?php
  7. $code = <<<'PHP'
  8. <?PHP
  9. FUNCTION FOO() {
  10. ECHO "bar";
  11. }
  12. PHP;
  13. class MyPhpToken extends PhpToken {
  14. public int $extra = 123;
  15. public function getLoweredText(): string {
  16. return strtolower($this->text);
  17. }
  18. }
  19. foreach (MyPhpToken::tokenize($code) as $token) {
  20. echo $token->getLoweredText();
  21. if ($token->extra !== 123) {
  22. echo "Missing property!\n";
  23. }
  24. }
  25. ?>
  26. --EXPECT--
  27. <?php
  28. function foo() {
  29. echo "bar";
  30. }