slimphp / Slim-Psr7

PSR-7 implementation for use with Slim 4
MIT License
133 stars 45 forks source link

PHP uncaught TypeError: strtolower() expects parameter 1 to be string, int given #262

Closed reformed closed 2 years ago

reformed commented 2 years ago

My PHP error log is showing an uncaught TypeError in Headers.php on line 184: https://github.com/slimphp/Slim-Psr7/blob/1726c664ac200c663799f8339f810ad0cde28803/src/Headers.php#L181

PHP Fatal error: Uncaught TypeError: strtolower() expects parameter 1 to be string, int given in C:\Apache24\htdocs\vendor\slim\psr7\src\Headers.php:184

The $headers array is assumed to have all string keys. This can likely be fixed by simply casting $name on line 184 as string.

nbayramberdiyev commented 2 years ago

A header field name must be an RFC 7230 compatible string. Even if we cast the header field name to string, you'll still get InvalidArgumentException unless you provide a valid HTTP header.

reformed commented 2 years ago

Regardless of valid or invalid HTTP headers, the PHP function strtolower expects a string input. It is on you to ensure that only a string is passed to this function.