Skip to content

SubmitButton::$onClick type causes problems for PHPStan users #265

Description

@ondrejmirtes

Version: 3.1.0

/cc @adaamz @milo @dg

This commit 2fce9b9 changed SubmitButton::$onClick type to:

/** @var callable[]&((callable(Nette\Forms\Form|SubmitButton, array|object): void)|(callable(array|object): void))[]

Which means "pass a callable that's ready to accept either Nette\Forms\Form or SubmitButton". But users usually pass in a callable that only accepts "SubmitButton" and it looks like SubmitButton will only ever be passed as an argument:

Nette\Utils\Arrays::invoke($this->onClick, $this);

This change causes PHPStan to report this error on valid code:

Array (array<callable(Nette\Forms\Controls\SubmitButton|Nette\Forms\Form, array|object): void>) does not accept Closure(Nette\Forms\Controls\SubmitButton, array): void.

Is my train of thought correct? Or should user's callables be ready to accept Form instance in some cases too?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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