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

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mhl2014
Copy link

@mhl2014 mhl2014 commented May 28, 2024

⚠️ 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.

…ta` exception instead of returning an "empty" `FileAttributes` instance.

Added test for new functionality and modified existing test ('can work with meta date') to not invoke visibility method.
@mhl2014 mhl2014 marked this pull request as draft May 28, 2024 09:47
@mhl2014
Copy link
Author

mhl2014 commented May 28, 2024

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.

…ception in case the MIME type detector cannot determine the MIME type of the file, ie. it returns null.

Added tests to ensure this functions properly.
Updated 'can work with meta date' test because the `mimeType` method can now throw.
@mhl2014 mhl2014 marked this pull request as ready for review May 28, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants