Browse Source

Remove code parameter from HTTPException constructor

- Remove duplicate HTTPException->httpcode class variable
pull/7068/head
Hypolite Petovan 3 years ago
parent
commit
8eba329111
  1. 14
      src/Network/HTTPException.php
  2. 10
      src/Network/HTTPException/AcceptedException.php
  3. 2
      src/Network/HTTPException/BadGatewayException.php
  4. 2
      src/Network/HTTPException/BadRequestException.php
  5. 2
      src/Network/HTTPException/ConflictException.php
  6. 2
      src/Network/HTTPException/ExpectationFailedException.php
  7. 4
      src/Network/HTTPException/ForbiddenException.php
  8. 2
      src/Network/HTTPException/GatewayTimeoutException.php
  9. 2
      src/Network/HTTPException/GoneException.php
  10. 2
      src/Network/HTTPException/ImATeapotException.php
  11. 2
      src/Network/HTTPException/InternalServerErrorException.php
  12. 2
      src/Network/HTTPException/LenghtRequiredException.php
  13. 2
      src/Network/HTTPException/MethodNotAllowedException.php
  14. 10
      src/Network/HTTPException/NoContentException.php
  15. 2
      src/Network/HTTPException/NonAcceptableException.php
  16. 5
      src/Network/HTTPException/NotFoundException.php
  17. 2
      src/Network/HTTPException/NotImplementedException.php
  18. 10
      src/Network/HTTPException/OKException.php
  19. 2
      src/Network/HTTPException/PreconditionFailedException.php
  20. 2
      src/Network/HTTPException/ServiceUnavaiableException.php
  21. 2
      src/Network/HTTPException/TooManyRequestsException.php
  22. 2
      src/Network/HTTPException/UnauthorizedException.php
  23. 2
      src/Network/HTTPException/UnprocessableEntityException.php
  24. 2
      src/Network/HTTPException/UnsupportedMediaTypeException.php

14
src/Network/HTTPException.php

@ -3,7 +3,7 @@
/**
* Throwable exceptions to return HTTP status code
*
* This list of Exception has be extracted from
* This list of Exception has been extracted from
* here http://racksburg.com/choosing-an-http-status-code/
*/
@ -11,17 +11,17 @@ namespace Friendica\Network;
use Exception;
class HTTPException extends Exception
abstract class HTTPException extends Exception
{
var $httpcode = 200;
var $httpdesc = "";
public $httpdesc = '';
public function __construct($message = '', $code = 0, Exception $previous = null)
public function __construct($message = '', Exception $previous = null)
{
if ($this->httpdesc == '') {
parent::__construct($message, $this->code, $previous);
if (empty($this->httpdesc)) {
$classname = str_replace('Exception', '', str_replace('Friendica\Network\HTTPException\\', '', get_class($this)));
$this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', $classname);
}
parent::__construct($message, $code, $previous);
}
}

10
src/Network/HTTPException/AcceptedException.php

@ -0,0 +1,10 @@
<?php
namespace Friendica\Network\HTTPException;
use Friendica\Network\HTTPException;
class AcceptedException extends HTTPException
{
protected $code = 202;
}

2
src/Network/HTTPException/BadGatewayException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class BadGatewayException extends HTTPException
{
var $httpcode = 502;
protected $code = 502;
}

2
src/Network/HTTPException/BadRequestException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class BadRequestException extends HTTPException
{
var $httpcode = 400;
protected $code = 400;
}

2
src/Network/HTTPException/ConflictException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class ConflictException extends HTTPException
{
var $httpcode = 409;
protected $code = 409;
}

2
src/Network/HTTPException/ExpectationFailedException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class ExpectationFailedException extends HTTPException
{
var $httpcode = 417;
protected $code = 417;
}

4
src/Network/HTTPException/ForbiddenException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class ForbiddenException extends HTTPException
{
var $httpcode = 403;
}
protected $code = 403;
}

2
src/Network/HTTPException/GatewayTimeoutException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class GatewayTimeoutException extends HTTPException
{
var $httpcode = 504;
protected $code = 504;
}

2
src/Network/HTTPException/GoneException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class GoneException extends HTTPException
{
var $httpcode = 410;
protected $code = 410;
}

2
src/Network/HTTPException/ImATeapotException.php

@ -6,6 +6,6 @@ use Friendica\Network\HTTPException;
class ImATeapotException extends HTTPException
{
var $httpcode = 418;
protected $code = 418;
var $httpdesc = "I'm A Teapot";
}

2
src/Network/HTTPException/InternalServerErrorException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class InternalServerErrorException extends HTTPException
{
var $httpcode = 500;
protected $code = 500;
}

2
src/Network/HTTPException/LenghtRequiredException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class LenghtRequiredException extends HTTPException
{
var $httpcode = 411;
protected $code = 411;
}

2
src/Network/HTTPException/MethodNotAllowedException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class MethodNotAllowedException extends HTTPException
{
var $httpcode = 405;
protected $code = 405;
}

10
src/Network/HTTPException/NoContentException.php

@ -0,0 +1,10 @@
<?php
namespace Friendica\Network\HTTPException;
use Friendica\Network\HTTPException;
class NoContentException extends HTTPException
{
protected $code = 204;
}

2
src/Network/HTTPException/NonAcceptableException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class NonAcceptableException extends HTTPException
{
var $httpcode = 406;
protected $code = 406;
}

5
src/Network/HTTPException/NotFoundException.php

@ -4,6 +4,7 @@ namespace Friendica\Network\HTTPException;
use Friendica\Network\HTTPException;
class NotFoundException extends HTTPException {
var $httpcode = 404;
class NotFoundException extends HTTPException
{
protected $code = 404;
}

2
src/Network/HTTPException/NotImplementedException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class NotImplementedException extends HTTPException
{
var $httpcode = 501;
protected $code = 501;
}

10
src/Network/HTTPException/OKException.php

@ -0,0 +1,10 @@
<?php
namespace Friendica\Network\HTTPException;
use Friendica\Network\HTTPException;
class OKException extends HTTPException
{
protected $code = 200;
}

2
src/Network/HTTPException/PreconditionFailedException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class PreconditionFailedException extends HTTPException
{
var $httpcode = 412;
protected $code = 412;
}

2
src/Network/HTTPException/ServiceUnavaiableException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class ServiceUnavaiableException extends HTTPException
{
var $httpcode = 503;
protected $code = 503;
}

2
src/Network/HTTPException/TooManyRequestsException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class TooManyRequestsException extends HTTPException
{
var $httpcode = 429;
protected $code = 429;
}

2
src/Network/HTTPException/UnauthorizedException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class UnauthorizedException extends HTTPException
{
var $httpcode = 401;
protected $code = 401;
}

2
src/Network/HTTPException/UnprocessableEntityException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class UnprocessableEntityException extends HTTPException
{
var $httpcode = 422;
protected $code = 422;
}

2
src/Network/HTTPException/UnsupportedMediaTypeException.php

@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
class UnsupportedMediaTypeException extends HTTPException
{
var $httpcode = 415;
protected $code = 415;
}

Loading…
Cancel
Save