Add normalize_path helper function#7718
Add normalize_path helper function#7718paulbalandan wants to merge 3 commits intocodeigniter4:developfrom
normalize_path helper function#7718Conversation
MGatner
left a comment
There was a problem hiding this comment.
Looks good to me! Is there any reason to move this to a helper and make it more generally available?
|
Trait should be used in a limited way. See https://matthiasnoback.nl/2022/07/when-to-use-a-trait/ I also think helper is the way to go in this case. |
|
Noback is my guy! If you haven't read his books they are amazing. His blog is sort of a telescoped version of specific topics. |
87cf216 to
fd54020
Compare
PathNormalizerTraitnormalize_path helper function
| protected function define(): void | ||
| { | ||
| $this->add(SUPPORTPATH . 'Files/baker/banana.php'); | ||
| $this->add(normalize_path(SUPPORTPATH . 'Files/baker/banana.php')); |
There was a problem hiding this comment.
Do you write product code like this?
There was a problem hiding this comment.
I don't get it. Do you want me instead to normalize the add method? I mean do the logic of normalizing there?
There was a problem hiding this comment.
Probably I don't write code like that, and I don't want to recommend the code like that.
So it seems not good code even in test code.
I'm not sure normalizing in the add() is good or not.
Is it impossible to pass the test only normalizing the output?
| $files->add([ | ||
| $this->directory . 'apple.php', | ||
| SUPPORTPATH . 'Files/baker/banana.php', | ||
| normalize_path(SUPPORTPATH . 'Files/baker/banana.php'), |
There was a problem hiding this comment.
Do you write product code like this?
|
I'll just start anew with this. I also forgot what happened in the past. |
Description
This PR adds the
normalize_pathto enable uniform testing of path-sensitive tests. I put this againstdevelopas this function is meant for testing, but can be used for non-testing as well. (Also I need this against develop as this will fix the errors identified in #7491 ).In the context of tests, when to use
$nativemode is based on:So, it's basically a matter of taste/choice.
Checklist: