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

Minor: Missing callable typehints #1656

Closed rbairwell closed 8 years ago

rbairwell commented 8 years ago

Slim3 appears (according to the composer.json) to only support PHP 5.5 upwards - which means the "callable" type hint/declaration ( http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration ) is valid as it was introduced in 5.4.

Would it, therefore, be possible to have all callables (such as Slim\App::map ) typehinted as such? I can try and do this myself and make a PR, but I'd like to check first that it was just something that was missed rather than an actual decision not to typehint callables.

akrabat commented 8 years ago

map() takes a string too…

$app->get('/', 'Application/HomeAction');
rbairwell commented 8 years ago

Yep, but string typehint is only PHP 7+ . map takes array, string, callable.

akrabat commented 8 years ago

map takes array, string, callable|string

rbairwell commented 8 years ago

Ah, sorry, so it does. My mistake. I'll see if I can do a PR to make it clearer (document it as callable|string or keep it as "mixed" and add comment that can be string or callable?)

daniel-mueller commented 8 years ago

https://github.com/slimphp/Slim/pull/1735