Nyholm / psr7

A super lightweight PSR-7 implementation
MIT License
1.16k stars 75 forks source link

Fixed deprecation messages for PHP 8.1 #196

Closed luisfn closed 2 years ago

luisfn commented 2 years ago

Just added return types to ServerRequest class where they were not specified. The goal is to fixes deprecation messages on PHP8.1 as the ones below:

 1x: Method "Psr\Http\Message\ServerRequestInterface::withUploadedFiles()" might add "static" as a native return type declaration in the future. Do the same in implementation "Nyholm\Psr7\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in OAuth2GenerateTokenActionTest::testItCallsSuccessfullyOauth2GenerateTokenEndpointTest from App\Tests\Functional\Action

  1x: Method "Psr\Http\Message\ServerRequestInterface::withCookieParams()" might add "static" as a native return type declaration in the future. Do the same in implementation "Nyholm\Psr7\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in OAuth2GenerateTokenActionTest::testItCallsSuccessfullyOauth2GenerateTokenEndpointTest from App\Tests\Functional\Action

  1x: Method "Psr\Http\Message\ServerRequestInterface::withQueryParams()" might add "static" as a native return type declaration in the future. Do the same in implementation "Nyholm\Psr7\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in OAuth2GenerateTokenActionTest::testItCallsSuccessfullyOauth2GenerateTokenEndpointTest from App\Tests\Functional\Action

  1x: Method "Psr\Http\Message\ServerRequestInterface::getParsedBody()" might add "array|object|null" as a native return type declaration in the future. Do the same in implementation "Nyholm\Psr7\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in OAuth2GenerateTokenActionTest::testItCallsSuccessfullyOauth2GenerateTokenEndpointTest from App\Tests\Functional\Action

  1x: Method "Psr\Http\Message\ServerRequestInterface::withParsedBody()" might add "static" as a native return type declaration in the future. Do the same in implementation "Nyholm\Psr7\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in OAuth2GenerateTokenActionTest::testItCallsSuccessfullyOauth2GenerateTokenEndpointTest from App\Tests\Functional\Action

Please let me know if adjustments are needed

This will fix #195

luisfn commented 2 years ago

No sure how to fix the BC, as the class already have some methods using static as return types, should be ok for the targeted PHP versions. WDYT?

Nyholm commented 2 years ago

Thank you. We can solve this in different ways, right? Static will help the very brave people that extend this class even though it is marked as @final. Could we be a little less forward and do #ReturnTypeWillChange?

andrew-demb commented 2 years ago

These deprecation messages triggered from symfony/error-handler. I want just to mention - if will be used way with "#[ReturnTypeWillChange]" (and no return types), it won't get rid from deprecations - phpdoc with types will be needed too.

Nyholm commented 2 years ago

Okey. Could we add php doc too then?

andrew-demb commented 2 years ago

To get rid PHP8.1 and symfony/error-handler deprecations it should be one of these: 1) return types 2) phpdoc + attribute

Nyholm commented 2 years ago

Okey. Thank you. I sugget to do number 2 (phpdoc + attribute). That will also make sure the BC job is not failing and we are sure to not have any side effects

jokaorgua commented 2 years ago

any progress? @Nyholm

Nyholm commented 2 years ago

Oh. I missed the PR. I think it looks all good. I'll look now.