tempestphp / tempest-framework

The PHP framework that gets out of your way 🌊
https://tempestphp.com
MIT License
884 stars 63 forks source link

Refactor container::call magic to router for route binding #11

Closed brendt closed 8 months ago

brendt commented 8 months ago

I think this might be solved with #135 because it adds the ability to autowire built-in types. I'll need to test once that PR is merged.

aidan-casey commented 8 months ago

We probably need to do a little work to get this working. I'm not sure it's a bad idea to add a method caller to the container though.

brendt commented 8 months ago

I did some testing, this implementation is still required as you expected. It's fine for now, we can improve method calling via the container at a later phase, and I'll keep it at is. Moving this logic to anywhere outside of the container (as I originally intended) didn't make any sense.

aidan-casey commented 8 months ago

I'll refactor the current autowire stuff to work with methods soon.

Do you prefer the parameter based approach we have today or something chainable?

Example:

$container
    ->call($object|"Class")
    ->method('__invoke')
    ->with(...$params);
brendt commented 8 months ago

I think it'll be easier to keep it in one method