Skip to content

PHPStan callable definitions do not support custom mapped types #224

@jiripudil

Description

@jiripudil

Version: dev-master

Bug Description

The callable definitions introduced in #216 fail to support custom mapped types:

class MappedValues { public string $name; } $form = new Nette\Forms\Form(); $form–>addText('name', 'Name'); $form->setMappedType(MappedValues::class); $form->onSuccess[] = function (Form $form, MappedValues $values) {};

produces

Array (array<(callable(Nette\Forms\Form, array): void)|(callable(Nette\Forms\Form, Nette\Utils\ArrayHash): void)>) does not accept Closure(Nette\Forms\Form, MappedValues): void. 

I don't know how the variance works there, but neither adding callable(Form, object) nor class MappedValues extends ArrayHash seemed to help. Perhaps @ondrejmirtes or @JanTvrdik could chime in please?

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