Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

$reflectionNamedType in AbstractComplexType can be null #168

@TomAshe

Description

@TomAshe

In this block in AbstractComplexType:

        $setterMethodName = "set{$name}";
        $reflectionClass = new ReflectionClass($this);
        if ($reflectionClass->hasMethod($setterMethodName)) {
            $reflectionNamedType = $reflectionClass->getMethod($setterMethodName)->getParameters()[0]->getType();
            /* @var $reflectionNamedType ReflectionNamedType */
            $parameterClassName = $reflectionNamedType->getName();

            if (class_exists($parameterClassName)) {
                $this->$setterMethodName(new $parameterClassName);
                return $this->values[$name];
            }
        }

The variable $reflectionNamedType will be null if the parameter doesn't have an explicit type set, e.g. for the property setter: public function setCode($code).

This throws an uncaught error.

Seems either all the setters need to have the type set for their parameters, e.g. public function setCode(string $code) or else a check should be made to see if $reflectionNamedType is not null before calling ->getName() on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions