bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

[php 8] Base::instance()->status() - Error raised for 'unknown' HTTP status codes #1220

Closed pauljherring closed 3 years ago

pauljherring commented 3 years ago
$ /usr/bin/php8.0 -r '$f3=require("lib/fatfree/lib/base.php"); error_reporting(0); $f3->status(550);'
Fatal error: Uncaught Error: Undefined constant self::HTTP_550 in /var/www/html/site/lib/fatfree/lib/base.php:1205
Stack trace:
#0 /var/www/html/site/lib/fatfree/lib/base.php(1205): constant()
#1 Command line code(1): Base->status()
#2 {main}
  thrown

===================================
ERROR 500 - Internal Server Error
Fatal error: Uncaught Error: Undefined constant self::HTTP_550 in /var/www/html/site/lib/fatfree/lib/base.php:1205
Stack trace:
#0 /var/www/html/site/lib/fatfree/lib/base.php(1205): constant()
#1 Command line code(1): Base->status()
#2 {main}
  thrown

(Substitute any other number that isn't specifically defined in https://github.com/bcosca/fatfree/blob/master/lib/base.php#L52)

Rayne commented 3 years ago

Feel free to create a pull request against bcosca/fatfree-core that is adding missing standardized status codes. As far as I know there is no feature to add custom status codes. If you want to send a custom code, use header() and handle further processing manually.