Giter Club home page Giter Club logo

Comments (7)

n0nag0n avatar n0nag0n commented on June 8, 2024 2

So you are correct, but these aren't actually named parameters. If you check out the code in https://github.com/flightphp/core/blob/master/flight/Engine.php#L525-L527 it calls $this->dispatcher->execute() which takes the params that were pulled out of the url via regex. It passes those in and eventually calls call_user_func_array() at https://github.com/flightphp/core/blob/master/flight/core/Dispatcher.php#L354 which has no concept of named parameters or what order things should be passed in as.

So I wouldn't call this as much a bug as much as maybe a misunderstanding? The only way I could possibly see this happening is if the framework uses reflection to determine how you called your parameters and what you named your variables and if they match up then it would reorder them (or remove them) from the $params variable. That would be a good size performance hit though it if did that. Reflection is fun, but it ain't cheap 😅 It would also add complexity cause what if you typed your variable name wrong? What if you only had 1 of the 4 variables in your URL? What about typing and what if you accidentally typed your variable wrong and it kept coming through as an int? (I guess that's a problem right now too...)

Might be worth visiting in the future, I'd have to think about it and if it'd be worth it. It's the reason why the middlewares have an array of params instead of individual params because a grouped middleware might have routes with different numbers of params in their.

from core.

starfishpatkhoo avatar starfishpatkhoo commented on June 8, 2024 1

While it would be a nice convenience, I don't think it is worth the time and effort on this one.. ^_^ .. dependency injectors are around for a reason... Leave it as parameters in order.. Even if one doesn't use dependency injectors, can add a few extra lines and use a closure to pass to another function in the "appropriate" order..

I just think that usually when I read "Named Parameters", it has a specific meaning. So maybe just need to update the docs and/or give it a new name.. 🤣

from core.

fadrian06 avatar fadrian06 commented on June 8, 2024 1

on the other hand it is true that reordering the parameters based on the url pattern may require reflection which is quite expensive, and to implement more flags in flight, we will end with 40 configuration flags in no time xD

from core.

n0nag0n avatar n0nag0n commented on June 8, 2024 1

Yeah true....we'll get the documentation corrected and close this issue for now.

from core.

krmu avatar krmu commented on June 8, 2024

+1 for this idea!

from core.

fadrian06 avatar fadrian06 commented on June 8, 2024

@n0nag0n Parameter capture is done with normal groups ( ) or with named groups (?<>) ???

from core.

fadrian06 avatar fadrian06 commented on June 8, 2024

On the one hand, it is true that named parameters are quite confusing if they are actually positional parameters... so we are sorry for the confusion in the documentation.

from core.

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.