Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use phpstan callable definitions #216

Merged
merged 1 commit into from Apr 6, 2019
Merged

Use phpstan callable definitions #216

merged 1 commit into from Apr 6, 2019

Conversation

@adaamz
Copy link
Contributor

adaamz commented Mar 15, 2019

  • new feature
  • BC break? no

Hi,
are you interested in definition for callables like phpstan does?
format is like in php (without parameter names) callable(params): return_type

If you are interested I can change other classes/packages.

@dg

This comment has been minimized.

Copy link
Member

dg commented Mar 15, 2019

Is it supported by IDEs?

@adaamz

This comment has been minimized.

Copy link
Contributor Author

adaamz commented Mar 15, 2019

PhpStorm "supports" intersection workaround in format
callable[]&(callable(Form): void)[]

I do not have other IDEs like Eclipse or NetBeans...

@dg

This comment has been minimized.

Copy link
Member

dg commented Apr 4, 2019

It seems good.

@adaamz adaamz force-pushed the adaamz:patch-1 branch from 570811b to 1f477b6 Apr 5, 2019
@adaamz adaamz changed the title Form: use phpstan callable definition Use phpstan callable definitions Apr 5, 2019
@adaamz

This comment has been minimized.

Copy link
Contributor Author

adaamz commented Apr 5, 2019

Fixed union on Form::onSuccess.
Used phpstan syntax in other classes - SubmitButton and Container.

@ondrejmirtes

This comment has been minimized.

Copy link
Contributor

ondrejmirtes commented Apr 5, 2019

👍 from me

@dg

This comment has been minimized.

Copy link
Member

dg commented Apr 6, 2019

Thanks! Can you post PR for Application too?

@dg dg merged commit e2c8d4b into nette:master Apr 6, 2019
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@adaamz adaamz deleted the adaamz:patch-1 branch Apr 7, 2019
dg added a commit that referenced this pull request Apr 9, 2019
dg added a commit that referenced this pull request Jul 8, 2019
@ondrejmirtes

This comment has been minimized.

Copy link
Contributor

ondrejmirtes commented Nov 26, 2019

This isn't exactly typesafe, we'd like to use:

// $form is our own CustomForm extending Nette\Forms\Form
$form->onSuccess[] = function (CustomForm $form): void {
});

Since in onSuccess there's callable(\Nette\Forms\Form), it's not typesafe to ask for a subtype in the callable. Nette might pass a different instance in there. I'm gonna experiment with callable(static) instead.

No need to change anything in Nette - phpstan-nette extension for PHPStan 0.12. will contain the fixed stub :) (Yeah, I've added support for custom phpDoc stubs to fix 3rd party phpDocs.)

@dg

This comment has been minimized.

Copy link
Member

dg commented Nov 26, 2019

This callable(Form) exists for PHPStan only, so there is no problem to change it to callable(static)

@ondrejmirtes

This comment has been minimized.

Copy link
Contributor

ondrejmirtes commented Nov 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.