Skip to content

Fatal error: Uncaught Error: Call to undefined method ReflectionUnionType::getName() #211

@CarlosCardenasNegro

Description

@CarlosCardenasNegro

Apparently DICE does not allow including a UNION type parameter in the _construct of the class because on line 257 of the code it tries to create a checking function ('is...) and the returned string is 'ReflectionUnionType' and when calling the getName() method it crashes with this message because said class does not have that function.
My test class:

class Test {
    
    private string|array|null $_name;
    private string|array|null $_type;
    
    public function __construct(string|array|null $name, string|array|null $type) {
        $this->_name = $name;
        $this->_type = $type;
 ....

My Test:

$rule = ['shared' => true, 'constructParams' => ['Carlos', 'Admin']];

$dice = $dice->addRule(Test::class, $rule);
$test = $dice->create(Test::class);

.. will crash...

If you replace the UNION with a unique type, e.g.: string or array everything goes well...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions