-
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
【Unsolicited PR】I changed the download method to testable. #1239
【Unsolicited PR】I changed the download method to testable. #1239
Conversation
7ffc987
to
dcbb8dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By and large, I'm ok with this change. However, you're duplicating a lot of code by extending Message and not Response. That's a maintenance issue. Please extend the Response class, and remove any duplicate methods that don't have a reason for being overridden.
system/HTTP/DownloadResponse.php
Outdated
{ | ||
if ($this->file !== null) | ||
{ | ||
throw new BadMethodCallException('When setting filepath can not set binary.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update the exception style. This would probably be best added to FrameworkException and called like:
throw FrameworkException::forInvalidFilePath(lang(''));
Also - notice the error should be localized, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
fixed.
* @return string | ||
*/ | ||
public function getReason(): string | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this method overriding the base method?
use CodeIgniter\Files\File; | ||
use Config\Mimes; | ||
|
||
class DownloadResponse extends Message implements ResponseInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be simpler to extend Response and not duplicate a number of the methods here, especially with slightly different implementations? Seems like a maintenance issue.
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
…ption Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Since it was in interface, I added setCache, but if you think that it is unnecessary later, delete setCache method. Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
It was unknown. Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
24c2cbf
to
0dc623b
Compare
That's a good point. I looked at the flow there, and you're right it would be simpler to extend Message directly for this. In that case - I can't imagine all of those duplicate methods are actually used to force a download? Please take a look and see how much you can get rid of from the original Response class. |
Certainly, by inheriting the Respone class you can erase many methods from the DownloadResponse class. Reusable methods.
Method that needs to be changed so that it can not be called.
Methods that need to be overwritten.
Overwrite is unnecessary because it is closed but DownloadResponse does not need unnecessary methods.
I feel that there are many methods that need to be changed so that they can not be called. |
Excuse me. Is that what you are saying does not need to implement RequestInterface? |
da37bff
to
ae314e6
Compare
I assume you mean If so - we still need to implement ResponseInterface - however the interface only requires 9 methods. |
Sorry...
Why do you think need to implements the |
Simply because it is a Response and should be cast as such. While we may or may not do any checks on that currently, we might in the future and no sense not following the interface now. Besides, this should still go through the |
I understand. but, add 13 unnecessary methods when extend the Response class. |
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
c576f91
to
0e30902
Compare
All I said is that it should implement the ResponseInterface. It's not necessary to extend the Response class itself. Extending Message is fine, as long as you implement the ResponseInterface interface. That interface only has 9 methods specified, I think. A few might be unnecessary, in which case maybe throwing an exception so the developer can correct his code? |
Sure. |
Response -> ResponseInterface
All have been corrected. |
Merged very very very thanks.❤️ |
I think Response::download method is not testable.
because use exit and echo.
my solution is following.
Checklist: