spatie / flysystem-dropbox

A flysystem driver for Dropbox that uses the v2 API
https://freek.dev/734-dropbox-will-turn-off-v1-of-their-api-soon-its-time-to-update-your-php-application
MIT License
343 stars 50 forks source link

Changed visibility getter to throw instead of returning an "empty" FileAttributes instance #97

Open mhl2014 opened 5 months ago

mhl2014 commented 5 months ago

⚠️ BREAKING CHANGE

The current implementation of the visibility method in the adapter returns an instance of FileAttributes with its visibility field set to null since visibility isn't supported. The problem is that Flysystem v3's visibility method's signature only allows for a string to be returned, not null. This causes a TypeError: League\Flysystem\Filesystem::visibility(): Return value must be of type string, null returned, when invoking the visibility method on a Filesystem instance that uses this adapter.

Although the changed code still aligns with the public API and documentation, this should be considered a breaking change. Previously, the visibility method ALWAYS returned a FileAttributes instance, but now it will ALWAYS throw an exception.

EDIT: I've also noticed an essentially identical problem with the mimeType method. The MIME type detector will return null in case it cannot determine the MIME Type. However, this causes a TypeError when called from the Filesystem::mimeType method, because it may only return a string.

mhl2014 commented 5 months ago

I've just noticed that there's essentially the same problem with the mimeType method. I'll fix that as well and re-open the pull request.