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

voku / Simple-PHP-Code-Parser / 5709606856

pending completion
5709606856

push

github

voku
[+]: ci: run test with PHP 8.2

1305 of 1592 relevant lines covered (81.97%)

7.61 hits per line

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

83.33
/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;
20✔
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');
11✔
53
        if (
54
            $parent instanceof Namespace_
11✔
55
            &&
56
            $parent->name instanceof Name
11✔
57
        ) {
58
            $namespace = '\\' . \implode('\\', $parent->name->getParts()) . '\\';
×
59
        } else {
60
            $namespace = '';
11✔
61
        }
62

63
        return $namespace . $nodeName;
11✔
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 = '';
19✔
77

78
        if (
79
            $node instanceof \PhpParser\Node
19✔
80
            &&
81
            \property_exists($node, 'namespacedName')
19✔
82
        ) {
83
            if ($node->namespacedName) {
19✔
84
                $fqn = \implode('\\', $node->namespacedName->getParts());
19✔
85
            } elseif (\property_exists($node, 'name') && $node->name) {
1✔
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;
19✔
94

95
        return $fqn;
19✔
96
    }
97

98
    protected function prepareNode(Node $node): void
99
    {
100
        $this->line = $node->getLine();
20✔
101
    }
102
}
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