‪TYPO3CMS  ‪main
AbstractToken.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 abstract class ‪AbstractToken implements ‪TokenInterface
26 {
27  protected int ‪$line = 0;
28  protected int ‪$column = 0;
29 
30  public function ‪__construct(
31  private readonly ‪TokenType $type,
32  protected readonly string $value,
33  int ‪$line = 0,
34  int ‪$column = 0
35  ) {
36  // No constructor property promotion for $line and $column: We don't serialize
37  // these two and want to still default them to 0 (zero) when unserialized.
38  $this->line = ‪$line;
39  $this->column = ‪$column;
40  }
41 
42  public function ‪__toString(): string
43  {
44  return $this->value;
45  }
46 
52  public function ‪__serialize(): array
53  {
54  return [
55  'type' => $this->type,
56  'value' => $this->value,
57  ];
58  }
59 
60  public function ‪getType(): ‪TokenType
61  {
62  return $this->type;
63  }
64 
65  public function ‪getValue(): string
66  {
67  return $this->value;
68  }
69 
70  public function ‪getLine(): int
71  {
72  return ‪$this->line;
73  }
74 
75  public function ‪getColumn(): int
76  {
77  return ‪$this->column;
78  }
79 }
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token
Definition: AbstractToken.php:18
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\$column
‪int $column
Definition: AbstractToken.php:28
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\TokenType
‪TokenType
Definition: TokenType.php:26
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\$line
‪int $line
Definition: AbstractToken.php:27
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\__serialize
‪__serialize()
Definition: AbstractToken.php:52
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\__construct
‪__construct(private readonly TokenType $type, protected readonly string $value, int $line=0, int $column=0)
Definition: AbstractToken.php:30
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\__toString
‪__toString()
Definition: AbstractToken.php:42
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\getColumn
‪getColumn()
Definition: AbstractToken.php:75
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\TokenInterface
Definition: TokenInterface.php:62
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\getLine
‪getLine()
Definition: AbstractToken.php:70
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\getValue
‪getValue()
Definition: AbstractToken.php:65
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken\getType
‪getType()
Definition: AbstractToken.php:60
‪TYPO3\CMS\Core\TypoScript\Tokenizer\Token\AbstractToken
Definition: AbstractToken.php:26