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

overblog / GraphQLBundle / 21577605669

29 Jan 2026 07:39AM UTC coverage: 98.546%. Remained the same
21577605669

push

github

web-flow
Test on PHP 8.5 (#1237)

* Test on PHP 8.5

* fix remove dummy attribute

4541 of 4608 relevant lines covered (98.55%)

76.57 hits per line

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

95.83
/src/Config/Parser/MetadataParser/TypeGuesser/TypeHintTypeGuesser.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Overblog\GraphQLBundle\Config\Parser\MetadataParser\TypeGuesser;
6

7
use ReflectionClass;
8
use ReflectionMethod;
9
use ReflectionNamedType;
10
use ReflectionParameter;
11
use ReflectionProperty;
12
use Reflector;
13

14
final class TypeHintTypeGuesser extends PhpTypeGuesser
15
{
16
    public function getName(): string
17
    {
18
        return 'Type Hint';
56✔
19
    }
20

21
    public function supports(Reflector $reflector): bool
22
    {
23
        return $reflector instanceof ReflectionProperty || $reflector instanceof ReflectionParameter || $reflector instanceof ReflectionMethod;
101✔
24
    }
25

26
    /**
27
     * @param ReflectionProperty|ReflectionParameter|ReflectionMethod $reflector
28
     */
29
    public function guessType(ReflectionClass $reflectionClass, Reflector $reflector, array $filterGraphQLTypes = []): ?string
30
    {
31
        $type = null;
101✔
32
        $hasDefaultValue = false;
101✔
33

34
        switch (true) {
35
            case $reflector instanceof ReflectionParameter:
101✔
36
                /** @var ReflectionParameter $reflector */
37
                $hasDefaultValue = $reflector->isDefaultValueAvailable();
98✔
38
                // no break
39
            case $reflector instanceof ReflectionProperty:
101✔
40
                /** @var ReflectionProperty $reflector */
41
                $type = $reflector->hasType() ? $reflector->getType() : null;
101✔
42

43
                break;
101✔
44
            case $reflector instanceof ReflectionMethod:
98✔
45
                /** @var ReflectionMethod $reflector */
46
                $type = $reflector->hasReturnType() ? $reflector->getReturnType() : null;
98✔
47
                break;
98✔
48
        }
49
        /** @var ReflectionNamedType|null $type */
50
        if (!$type) {
101✔
51
            throw new TypeGuessingException('No type-hint');
56✔
52
        }
53

54
        $sType = $type->getName();
101✔
55
        if ($type->isBuiltin()) {
101✔
56
            $gqlType = $this->resolveTypeFromPhpType($sType);
101✔
57
            if (null === $gqlType) {
101✔
58
                throw new TypeGuessingException(sprintf('No corresponding GraphQL type found for builtin type "%s"', $sType));
54✔
59
            }
60
        } else {
61
            $gqlType = $this->map->resolveType($sType, $filterGraphQLTypes);
98✔
62
            if (null === $gqlType) {
98✔
63
                throw new TypeGuessingException(sprintf('No corresponding GraphQL %s found for class "%s"', $filterGraphQLTypes ? implode(',', $filterGraphQLTypes) : 'object', $sType));
×
64
            }
65
        }
66
        $nullable = $hasDefaultValue || $type->allowsNull();
101✔
67

68
        return sprintf('%s%s', $gqlType, $nullable ? '' : '!');
101✔
69
    }
70
}
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