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

voku / Simple-PHP-Code-Parser / 24216249039

09 Apr 2026 10:22PM UTC coverage: 83.154% (-0.1%) from 83.261%
24216249039

Pull #77

github

web-flow
Merge d4e4fa4d7 into 61474a112
Pull Request #77: Add php-parser v5 compatibility (^4.18 || ^5)

7 of 10 new or added lines in 3 files covered. (70.0%)

25 existing lines in 2 files now uncovered.

1545 of 1858 relevant lines covered (83.15%)

43.89 hits per line

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

80.0
/src/voku/SimplePhpParser/Model/BasePHPElement.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace voku\SimplePhpParser\Model;
6

7
use PhpParser\Node;
8
use PhpParser\Node\Name;
9
use PhpParser\Node\Stmt\Namespace_;
10
use PhpParser\NodeAbstract;
11
use voku\SimplePhpParser\Parsers\Helper\ParserContainer;
12

13
abstract class BasePHPElement
14
{
15
    public string $name = '';
16

17
    /**
18
     * @var string[]
19
     */
20
    public array $parseError = [];
21

22
    public ?int $line = null;
23

24
    public ?string $file = null;
25

26
    public ?int $pos = null;
27

28
    public ParserContainer $parserContainer;
29

30
    public function __construct(ParserContainer $parserContainer)
31
    {
32
        $this->parserContainer = $parserContainer;
146✔
33
    }
34

35
    /**
36
     * @param \Reflector $object
37
     *
38
     * @return $this
39
     */
40
    abstract public function readObjectFromReflection($object);
41

42
    /**
43
     * @param \PhpParser\NodeAbstract      $mixed_1
44
     * @param \PhpParser\NodeAbstract|null $mixed_2
45
     *
46
     * @return $this
47
     */
48
    abstract public function readObjectFromPhpNode($mixed_1, $mixed_2 = null);
49

50
    protected function getConstantFQN(NodeAbstract $node, string $nodeName): string
51
    {
52
        $parent = $node->getAttribute('parent');
81✔
53
        if (
54
            $parent instanceof Namespace_
81✔
55
            &&
56
            $parent->name instanceof Name
81✔
57
        ) {
58
            $namespace = '\\' . \implode('\\', $parent->name->getParts()) . '\\';
×
59
        } else {
60
            $namespace = '';
81✔
61
        }
62

63
        return $namespace . $nodeName;
81✔
64
    }
65

66
    /**
67
     * @param \PhpParser\Node|string $node
68
     *
69
     * @return string
70
     *
71
     * @psalm-return class-string
72
     */
73
    protected static function getFQN($node): string
74
    {
75
        // init
76
        $fqn = '';
142✔
77

78
        if (
79
            $node instanceof \PhpParser\Node
142✔
80
            &&
81
            \property_exists($node, 'namespacedName')
142✔
82
        ) {
83
            if ($node->namespacedName) {
142✔
84
                $fqn = \implode('\\', $node->namespacedName->getParts());
142✔
85
            } elseif (\property_exists($node, 'name') && $node->name) {
4✔
86
                var_dump($node->name);
×
87
                $fqn =  $node->name->name;
×
88
            }
89
        }
90

91
        /** @noinspection PhpSillyAssignmentInspection - hack for phpstan */
92
        /** @var class-string $fqn */
93
        $fqn = $fqn;
142✔
94

95
        return $fqn;
142✔
96
    }
97

98
    protected function prepareNode(Node $node): void
99
    {
100
        $this->line = method_exists($node, 'getStartLine')
146✔
101
            ? $node->getStartLine()
146✔
NEW
UNCOV
102
            : $node->getLine(); // @phpstan-ignore-line getLine() was removed in PHP-Parser v5
×
103
    }
104
}
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

© 2026 Coveralls, Inc