Closed iDiegoNL closed 3 months ago
Try updating to v5.0.1. I just changed the return type:
https://github.com/stechstudio/laravel-zipstream/commit/35408de79089fe6c3abb039e13594646d3ab5714
That work for PHPStan?
Whoops I had changed the return type on make
but not makeFromDisk
. v5.0.2 tagged
Thanks a lot for the quick fix! However, 5.0.2 doesn't seem to be tagged yet haha
Ha. I tagged it locally, that's not good enough? ;-)
Pushed the tag now.
According to the readme, the following is possible:
However, PHPStan fails with the following error:
Call to an undefined method STS\ZipStream\Contracts\FileContract::setFilesize().
This is becausemakeFromDisk()
returns aFileContract
, and that contract doesn't have asetFileSize()
function.It works fine in reality, since it actually returns a
File
class (that implements the contract), and that class does have thesetFilesize()
method. As a workaround to get my PHPStan to pass for now, I have split the snippet up so I can manually typehint it:However, it would still be nice for this to get fixed. From what I can see,
makeFromDisk
can just directly useFile
as its return type? Because both of the classes that it can return (S3File
andLocalFile
) both extend theFile
class. I can create a PR if this is the desired solution.