php-http / httplug

HTTPlug, the HTTP client abstraction for PHP
http://httplug.io
MIT License
2.57k stars 39 forks source link

HttpException create method self vs static #152

Closed mieszkomalawski closed 5 years ago

mieszkomalawski commented 5 years ago
Q A
Bug? no
New Feature? yes
Version 1.1.0

Actual Behavior

method create returns HttpException instance

Expected Behavior

Should return an instance of calling class eg ServerErrorException::create() should return ServerErrorException

Steps to Reproduce

call ServerErrorException::create()

Possible Solutions

Change self to static keyword in create method of HttpException class

dbu commented 5 years ago

ServerErrorException is not part of this repository - did you extend HttpException in your code? but you are correct, this seems unexpected. HttpException could have been made final, but we did not, and it seems okay to extend it.

can you create a pull request to change the exception to use new static instead of new self? and until we release a fixed version, you can overwrite the create method in your extending class, as a workaround - but we should fix it in the HttpException, it is quite unexpected behaviour.