Skip to content

The parameter and property types are not correctly returned when they are nullable #153

@jenky

Description

@jenky

Version: 4.1.3

Bug Description

getType does not return correct type

Steps To Reproduce

$class = new ClassType('Hello');

$method = $class->addMethod('greeting');

$param = $method->addParameter('name', null)
    ->setType('string')
    ->setNullable();

echo $param->getType(); // "string"

The class was generated correctly

class Hello
{
        public function greeting(?string $name = null)
        {
        }
}

Expected Behavior

$param->getType() should return ?string or null|string instead of string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions