zircote / swagger-php

A php swagger annotation and parsing library
http://zircote.github.io/swagger-php/
Apache License 2.0
5.03k stars 933 forks source link

Update `jsonSerialize` return #1575

Closed AurelienPillevesse closed 2 months ago

AurelienPillevesse commented 3 months ago

When I execute my test with the last version of packages + PHP 8.3, I have warnings like this one :

1x: Method "JsonSerializable::jsonSerialize()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "OpenApi\Annotations\AbstractAnnotation" now to avoid errors or add an explicit @return annotation to suppress this message.

DerManoMann commented 3 months ago

Looks like you might have to put all changes into a single PR.

Also, tool did you use to get this warning? I was under the impression that the attribute would take care of this issue.

AurelienPillevesse commented 3 months ago

I use :

In my composer.lock, I have zircote/swagger-php : 4.9.0

DerManoMann commented 3 months ago

So is the warning from PHP itself or from a static analyser or similar?

AurelienPillevesse commented 3 months ago

It happens when I run my tests with phpunit but it seems to be a PHP warning itself no ?

AurelienPillevesse commented 3 months ago

What about bumping the php version to 8.1 in my commit to make all tests pass (or in another one) ? Because 7.x versions are not maintained anymore (and everything will be green for this PR) : see https://github.com/zircote/swagger-php/pull/1577

DerManoMann commented 3 months ago

It would be good to get more details as I cannot see those warnings running the swagger-php tests itself. It would be great if you could provide perhaps a screenshot or the full output from your tests.

deluxetom commented 2 months ago

I started to see the same warning messages with PHP 8.3 (using symfony 7 and NelmioApiDoc bundle)

andrew-demb commented 2 months ago

Error triggered from symfony/error-handler - https://github.com/symfony/error-handler/blob/cf97429887e40480c847bfeb6c3991e1e2c086ab/DebugClassLoader.php#L586

It can be fixed with added phpdoc tag @return mixed to avoid BC break about added native return type or bumping min PHP version

AurelienPillevesse commented 2 months ago

Added phpdoc in the Abstract class, will be enough I think

DerManoMann commented 2 months ago

Sorry, got kind of confused about which PR does what. As you can see from my PR there is also a change in the cs-fixer config required. Happy for you to update your PR or use mine.

DerManoMann commented 2 months ago

Thanks @AurelienPillevesse

AurelienPillevesse commented 2 months ago

@DerManoMann do you think it's possible to release a new tag to fix this issue ?