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

Drop support for anonymous functions #18

Closed
mindplay-dk opened this issue May 3, 2018 · 1 comment
Closed

Drop support for anonymous functions #18

mindplay-dk opened this issue May 3, 2018 · 1 comment
Milestone

Comments

@mindplay-dk
Copy link
Owner

As of PHP 7.0, support for anonymous functions is no longer required - we now have support for anonymous classes that actually implement the middleware-interface, which is much cleaner and safer.

As middleman already requires 7.0, we can drop support for function in the next major release.

Documentation should be updated to use anonymous classes instead of functions.

When support for legacy PSR-15 interfaces is removed as well, we should be able to get rid of all conditionals in the dispatcher and go completely strict on type-safety.

@mindplay-dk mindplay-dk added this to the 4.0 milestone May 3, 2018
@mindplay-dk
Copy link
Owner Author

Okay, so PHP 7 did introduce anonymous classes, and they probably are both safer and cleaner - but, unfortunately, they do not support closure, as anonymous functions do, which makes them incredibly verbose and inconvenient where closure is required, e.g. forcing you to declare a constructor and initialize private properties, where functions let you do the same with just a use declaration.

In PHP 8, short arrow functions make this even more convenient.

Also, this feature isn't complex, it's literally two lines of code.

I'm keeping support for closures and dropping this change from the roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant