-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Dev: using filter_*
functions instead direct access to global variables
#4968
Comments
The current test/product code is heavily depends on the suprer global variables. |
@kenjis please see manual, it's only example to display: |
Sorry, I know If we use |
@WinterSilence What is your point? |
@ kenjis one test = one request, change globals in test is bad practice |
@WinterSilence CI4 has a lot of (test/production) code that depends on super global variables. |
@kenjis i don't check all test, but if they are written correctly, then it must be work fine. |
it's not correct tests. You can keep "pure" request data if any user or vendor library can change they. I didn't say that the right decisions are easy. And I didn't say that it's enough to replace global variables with a call |
How do you fix the test (and product code)? |
But super globals change per test. If we can't change them, we can't write enough test cases.
Do you mean mock the class to test? And how do you mock the IncomingRequest?
It is not unit testing. We need fast unit tests. |
@kenjis One test = one request - see @backupglobals
What do you think this is? |
I think injecting the superglobals data into By the way, what do you want to achieve with this $request->setGlobal('get', filter_input_array(INPUT_GET)); |
No feedback. So I close. I'm still not sure this should be implemented or not, but before implementing this we need to rework all classes that handles the super globals. |
@kenjis sorry, miss your answer
I want keep initial data of request. Now request data can be changed by vendor/user code, framework must ignore this changes. If developer wants to make changes, then he must do so by explicitly changing the corresponding method or property. |
Example:
As you can see
filter_input_array()
return initial data, it's better use in CI because users (or vendor packages) can change globals before calling CI methods.If there are no objections, then I will replace direct access to global variables everywhere. I will write sniff to fix this problem in future too.
The text was updated successfully, but these errors were encountered: