Giter Site home page Giter Site logo

Comments (9)

awildeep avatar awildeep commented on May 22, 2024

I think this could be a good recipe. Doing this by default I think is slightly confusing to someone who is used to closures in PHP right now. If we default this behavior, then we have BC issues.

It is too bad we can't define the variable on creation of the closure.

from silex.

igorw avatar igorw commented on May 22, 2024

What kind of BC issues? Closure use-statements will still work.

from silex.

stof avatar stof commented on May 22, 2024

@awildeep the point is that this requires changes in the core so it cannot be done as a recipe.

from silex.

stof avatar stof commented on May 22, 2024

@igorw the issue would be for routes. If the app is passed as first argument by the Application and you don't update your code, you have an issue because you expect to get the first routing placeholder as first argument.

from silex.

awildeep avatar awildeep commented on May 22, 2024

@stof; Yea I see your point. I didn't catch it before in a quick glance.

@igorw; stof explained my BC issue. For some clarity if I have existing code like:

$app->get('/test/{variable}', function ($variable) use ($app) { ....});

It would change to this:

$app->get('/test/{variable}', function ($app, $variable) { ....});

This effectively forces any existing code to need to be reworked, thus breaking BC. Not a big deal to me right now as this is a fairly simple change, but existing developers may not know how to handle the change and cause a lot of issue tickets after they upgrade.

Just as a side note: I like this change and I am for it, if I gave you a negative impression my bad. I am just concerned about existing applications.

from silex.

igorw avatar igorw commented on May 22, 2024

No, my suggestion is to use a param converter, and check if there is a $app argument. So it will be injected based on the name (or the type, through type hinting).

from silex.

awildeep avatar awildeep commented on May 22, 2024

Edited; I removed my question, no need to ask it.

Also; this is much better than I thought it was. I guess this will encourage developers to always name their application object $app more as well for consistency.

from silex.

 avatar commented on May 22, 2024

Hello there, this is already possible thanks to @fabpot.

See: 934bf3e

from silex.

igorw avatar igorw commented on May 22, 2024

Yep, it works through type hinting, which I suggested as an alternative. Closing this, thanks!

from silex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.