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

Typed Function Calls #70

Closed
apfritts opened this issue Dec 8, 2014 · 3 comments
Closed

Typed Function Calls #70

apfritts opened this issue Dec 8, 2014 · 3 comments
Milestone

Comments

@apfritts
Copy link

apfritts commented Dec 8, 2014

Hi!

We're interested in adding typed function calls to Pux and contributing them back to the project. Taking this example from the docs:

$mux->get('/product/:id', ['ProductController','itemAction'] , [
    'require' => [ 'id' => '\d+', ],
    'default' => [ 'id' => '1', ]
]);

would become:

$mux->get('/product/:id', ['ProductController','itemAction'] , [
    'require' => [ 'id' => Pux\Mux::TYPE_INTEGER, ],
    'default' => [ 'id' => '1', ]
]);

This would automatically match against \d+ and result in a call to as ProductionController()->itemAction( (int) $id) instead of passing a string type.

Why?

This will simplify controller logic and allow invalid input to be sent to a 404 page instead of through controller logic.

It also allows folks to start converting over to Hack / HHVM for other performance gains.

Any concerns over this feature? Will this have any impact on the C extension (which we don't use so I wouldn't be adding any code in).

@c9s
Copy link
Owner

c9s commented Mar 3, 2015

Hi @apfritts

Sorry I think I missed the mail. overall, I like this proposal, PRs will be welcomed. And yes, it will impact the C extension since the API is slightly different, but that's fine, we can add the C implementation later.

@c9s
Copy link
Owner

c9s commented Aug 17, 2015

I like this type constraint idea, do you have any updates? just a friendly ping. :)

@c9s c9s modified the milestone: 2.0 Aug 17, 2015
@apfritts
Copy link
Author

apfritts commented Feb 4, 2022

Closing this out. I don't work in PHP and ... this has been open for far too long... sorry team!

@apfritts apfritts closed this as completed Feb 4, 2022
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

2 participants