slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

Typo in Slim/App::respond() #1895

Closed dinacel closed 8 years ago

dinacel commented 8 years ago

I've didn't review the code, so I don't know if there's side effects:

https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L389

if (isset($contentLength)) {

is always true, because l.383:

$contentLength = $response->getHeaderLine('Content-Length');

JoeBengalen commented 8 years ago

But getHeaderLine could return empty and the getSize could return null, so isset(null) == false

https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L383 https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L385

dinacel commented 8 years ago

My bad, I didn't know that isset(null) == false

l1905 commented 8 years ago

isset(null) == false may be unreadable code, why not use is_null(null)?