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

tempestphp / tempest-framework / 12021710761

25 Nov 2024 06:54PM UTC coverage: 79.441% (-2.6%) from 81.993%
12021710761

push

github

web-flow
ci: close stale issues and pull requests

7879 of 9918 relevant lines covered (79.44%)

61.32 hits per line

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

85.29
/src/Tempest/Reflection/src/MethodReflector.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Reflection;
6

7
use Generator;
8
use ReflectionMethod as PHPReflectionMethod;
9

10
final readonly class MethodReflector implements Reflector
11
{
12
    use HasAttributes;
13

14
    public function __construct(
421✔
15
        private PHPReflectionMethod $reflectionMethod,
16
    ) {
17
    }
421✔
18

19
    public static function fromParts(string|object $class, string $name): self
7✔
20
    {
21
        return new self(new PHPReflectionMethod($class, $name));
7✔
22
    }
23

24
    public function getReflection(): PHPReflectionMethod
398✔
25
    {
26
        return $this->reflectionMethod;
398✔
27
    }
28

29
    /** @return Generator|\Tempest\Reflection\ParameterReflector[] */
30
    public function getParameters(): Generator
406✔
31
    {
32
        foreach ($this->reflectionMethod->getParameters() as $parameter) {
406✔
33
            yield new ParameterReflector($parameter);
405✔
34
        }
35
    }
36

37
    public function invokeArgs(object|null $object, array $args = []): mixed
387✔
38
    {
39
        return $this->reflectionMethod->invokeArgs($object, $args);
387✔
40
    }
41

42
    public function getReturnType(): TypeReflector
392✔
43
    {
44
        return new TypeReflector($this->reflectionMethod->getReturnType());
392✔
45
    }
46

47
    public function getDeclaringClass(): ClassReflector
401✔
48
    {
49
        return new ClassReflector($this->reflectionMethod->getDeclaringClass());
401✔
50
    }
51

52
    public function getName(): string
397✔
53
    {
54
        return $this->reflectionMethod->getName();
397✔
55
    }
56

57
    public function getShortName(): string
388✔
58
    {
59
        $string = $this->getDeclaringClass()->getShortName() . '::' . $this->getName() . '(';
388✔
60

61
        $parameters = [];
388✔
62

63
        foreach ($this->getParameters() as $parameter) {
388✔
64
            $parameters[] = $parameter->getType()->getShortName() . ' $' . $parameter->getName();
388✔
65
        }
66

67
        $string .= implode(', ', $parameters);
388✔
68

69
        return $string . ')';
388✔
70
    }
71

72
    public function __serialize(): array
×
73
    {
74
        return [
×
75
            'class' => $this->reflectionMethod->getDeclaringClass()->getName(),
×
76
            'method' => $this->reflectionMethod->getName(),
×
77
        ];
×
78
    }
79

80
    public function __unserialize(array $data): void
382✔
81
    {
82
        $this->reflectionMethod = new PHPReflectionMethod(
382✔
83
            objectOrMethod: $data['class'],
382✔
84
            method: $data['method'],
382✔
85
        );
382✔
86
    }
87
}
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