Issues (31)

Helper/PropertyHelper.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Helper;
6
7
use FRZB\Component\RequestMapper\Exception\InvalidPropertyTypeException;
8
use JetBrains\PhpStorm\Immutable;
9
10
/** @internal */
11
#[Immutable]
12
final class PropertyHelper
13
{
14
    private function __construct()
15
    {
16
    }
17
18
    public static function getName(\ReflectionProperty|\ReflectionParameter $property): string
19
    {
20 19
        return SerializerHelper::getSerializedNameAttribute($property)->getSerializedName();
21
    }
22
23 19
    public static function getTypeName(\ReflectionProperty|\ReflectionParameter $property): ?string
24
    {
25
        $type = $property->getType();
26
27
        $typeName = match (true) {
28
            $type instanceof \ReflectionIntersectionType => throw InvalidPropertyTypeException::notSupported(\ReflectionIntersectionType::class),
0 ignored issues
show
The type ReflectionIntersectionType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29 19
            $type instanceof \ReflectionUnionType => throw InvalidPropertyTypeException::notSupported(\ReflectionUnionType::class),
30 19
            $type instanceof \ReflectionNamedType => $type->getName(),
0 ignored issues
show
The method getName() does not exist on ReflectionType. It seems like you code against a sub-type of ReflectionType such as ReflectionNamedType. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
            $type instanceof \ReflectionNamedType => $type->/** @scrutinizer ignore-call */ getName(),
Loading history...
31 19
            default => null,
32 19
        };
33
34 19
        return StringHelper::removeNotWordCharacters($typeName ?? '');
35
    }
36
}
37