Comments (7)
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.
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.
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.
Yeah true....we'll get the documentation corrected and close this issue for now.
from core.
+1 for this idea!
from core.
@n0nag0n Parameter capture is done with normal groups ( ) or with named groups (?<>) ???
from core.
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)
- Handling of URLs with encoded slashes (/)
- Have URL parameters available when setting streaming headers HOT 2
- Upgrade from 3.2.0 to 3.6.1 breaks Flight::json ? HOT 2
- [Docs > Routing] Method Routing HOT 6
- [Refactor] Flight::get() need to be renamed HOT 2
- [Views] register method : no autocomplete / intelsense HOT 3
- get_input_data HOT 3
- Comments before begin php tag returns json with garbage HOT 4
- FYI, minor bug with streamWithHeaders() HOT 11
- Multiple renders keeps the previous state When I render multiple views as components, they keep the state of previous arguments passed to them instead of reinitialize with default value each render.
- Inject Middleware constructor arguments using the DI Container HOT 4
- Proposal of compact syntax for Flight::route HOT 7
- View class steroids 🙌🏽 HOT 1
- How to stop the request process when there is an issue in the Middleware? HOT 8
- Simplify PHP version constraint HOT 4
- Flight::group lacks nesting support for organizing routes hierarchically. Adding this feature will enhance route management flexibility. HOT 3
- Wrong request method response HOT 2
- Including version number of Flight in Flight.php root file HOT 3
- How to show custom page for 500 error? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.