-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Fix behavior for controller actions with union types #20352
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
base: master
Are you sure you want to change the base?
Conversation
! fix yii\web\Controller::bindActionParams behaviour for union types o some refactoring in the process
o cleanup, changelog
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20352 +/- ##
============================================
- Coverage 64.43% 64.37% -0.06%
- Complexity 11445 11468 +23
============================================
Files 433 433
Lines 37455 37501 +46
============================================
+ Hits 24135 24143 +8
- Misses 13320 13358 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Does |
Would you please measure performance impact w/ phpbench if possible? |
- remove needless class_exists call
! fix issue when handling parameter with string type, add according test
I haven't set up PHPBench for this (and don't have the time to atm), but from some rudimentary testing, it seems like there's no performance impact when no union types are used, but for an action with two union type parameters, it took about 1.5x the time the old version took. |
This fixes the behaviour for
yii\web\Controller::bindActionParams
when a function parameter has a union type.In effect, this fixes two issues:
string|int
), if the parameter value is a string containing a numeric value (such as'1'
), the result will be the numeric value ((int)1
here) rather than the string.int|array
), if the parameter value is an array, the controller no longer throws aBadRequestHttpException
, fixing "Bad request" for array parameter with union type #20351.