• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jojo1981 / json-ast-builder / 17578687754

09 Sep 2025 09:48AM UTC coverage: 35.019%. Remained the same
17578687754

push

github

jojo1981
Fix: Make compatible with PHP versions: ^8.0|^8.1|^8.2|^8.3|^8.4. Closes #1
https://github.com/jojo1981/json-ast-builder/issues/1

161 of 407 new or added lines in 17 files covered. (39.56%)

290 existing lines in 25 files now uncovered.

374 of 1068 relevant lines covered (35.02%)

3.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.1
/src/Lexer/Token.php
1
<?php
2
/*
3
 * This file is part of the jojo1981/json-ast-builder package
4
 *
5
 * Copyright (c) 2019 Joost Nijhuis <jnijhuis81@gmail.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed in the root of the source code
9
 */
10
declare(strict_types=1);
11

12
namespace Jojo1981\JsonAstBuilder\Lexer;
13

14
use function sprintf;
15

16
/**
17
 * @package Jojo1981\JsonAstBuilder\Lexer
18
 */
19
final class Token
20
{
21
    /** @var int */
22
    private int $type;
23

24
    /** @var string */
25
    private string $name;
26

27
    /** @var int */
28
    private int $position;
29

30
    /** @var int */
31
    private int $lineNumber;
32

33
    /** @var int */
34
    private int $linePosition;
35

36
    /** @var string|null */
37
    private ?string $lexeme;
38

39
    /**
40
     * @param int $type
41
     * @param string $name
42
     * @param int $position
43
     * @param int $lineNumber
44
     * @param int $linePosition
45
     * @param string|null $lexeme
46
     */
47
    public function __construct(
48
        int $type,
49
        string $name,
50
        int $position,
51
        int $lineNumber,
52
        int $linePosition,
53
        ?string $lexeme = null
54
    ) {
55
        $this->type = $type;
10✔
56
        $this->name = $name;
10✔
57
        $this->position = $position;
10✔
58
        $this->lineNumber = $lineNumber;
10✔
59
        $this->linePosition = $linePosition;
10✔
60
        $this->lexeme = $lexeme;
10✔
61
    }
62

63
    /**
64
     * @return int
65
     */
66
    public function getType(): int
67
    {
68
        return $this->type;
10✔
69
    }
70

71
    /**
72
     * @return string
73
     */
74
    public function getName(): string
75
    {
UNCOV
76
        return $this->name;
×
77
    }
78

79
    /**
80
     * @return int
81
     */
82
    public function getPosition(): int
83
    {
UNCOV
84
        return $this->position;
×
85
    }
86

87
    /**
88
     * @return int
89
     */
90
    public function getLineNumber(): int
91
    {
UNCOV
92
        return $this->lineNumber;
×
93
    }
94

95
    /**
96
     * @return int
97
     */
98
    public function getLinePosition(): int
99
    {
UNCOV
100
        return $this->linePosition;
×
101
    }
102

103
    /**
104
     * @return string|null
105
     */
106
    public function getLexeme(): ?string
107
    {
108
        return $this->lexeme;
5✔
109
    }
110

111
    /**
112
     * @return string
113
     */
114
    public function __toString(): string
115
    {
NEW
116
        return sprintf(
×
UNCOV
117
            '<%s[%d]> = \'%s\', [%d] [%d:%d]',
×
UNCOV
118
            $this->name,
×
UNCOV
119
            $this->type,
×
120
            $this->lexeme,
×
121
            $this->position,
×
122
            $this->lineNumber,
×
123
            $this->linePosition
×
124
        );
×
125
    }
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc