akrabat / slim3-skeleton

Simple Slim Framework 3 skeleton with Twig & Monolog
BSD 3-Clause "New" or "Revised" License
345 stars 99 forks source link

Request/Response objects in example action are incorrectly type hinted #34

Closed Antnee closed 8 years ago

Antnee commented 8 years ago

Rob,

I'm not sure if it's deliberate or not, but I noticed that the example action suggests that the Request and Response objects are PSR-7, but they're actually Slim\Http\Request and Slim\Http\Response respectively.

https://github.com/akrabat/slim3-skeleton/blob/da0be2131cc895f51dfba30a349bac4034229a39/app/src/Action/HomeAction.php#L6

use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;

should be

use Slim\Http\Request;
use Slim\Http\Response;

The documentation states:

Because this is a common task, Slim’s built-in PSR 7 implementation also provides these proprietary methods that return true or false

So it's not technically a PSR-7 implementation. I'll submit a PR in case this isn't deliberate :)

akrabat commented 8 years ago

It's intentional in the sense that I wanted to point out that the Request and Response could be any implementation of PSR-7, such as Diactoros'.

You're right though, that in practice they are going to be Slim's implementation in the action.

Antnee commented 8 years ago

I thought that might be the case. Personally, I find that I use the additional methods (now that I know that they're there and not just the PSR-7 ones) so I always change my declarations. Spoke to a few people at PHP MiNDS the other week who didn't realise that those methods were available because their IDE wasn't suggesting them. I'm a little confused how methods like getParam() isn't in PSR-7 to be honest

akrabat commented 8 years ago

That's a really valid point!

(& yeah, there's a number of methods that I wish was in the actual spec!)

Antnee commented 8 years ago

That's a really valid point!

Someone will disagree :)

Thanks