Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Antnee opened this issue Aug 19, 2016 · 4 comments
Closed

Comments

@Antnee
Copy link
Contributor

Antnee commented Aug 19, 2016

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.

use Psr\Http\Message\ServerRequestInterface as Request;

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
Copy link
Owner

akrabat commented Aug 22, 2016

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
Copy link
Contributor Author

Antnee commented Aug 22, 2016

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
Copy link
Owner

akrabat commented Aug 22, 2016

That's a really valid point!

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

@Antnee
Copy link
Contributor Author

Antnee commented Aug 22, 2016

That's a really valid point!

Someone will disagree :)

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants