-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix(IStorage): Use false instead of bool intersection type to match implementations #48219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be continued…
80f8557
to
03e9653
Compare
I hope I fixed all the weird typings, but please take another look. |
03e9653
to
27d8eff
Compare
27d8eff
to
19faaa3
Compare
Signed-off-by: provokateurin <[email protected]>
Signed-off-by: provokateurin <[email protected]>
Signed-off-by: provokateurin <[email protected]>
Signed-off-by: provokateurin <[email protected]>
19faaa3
to
ad548d7
Compare
Signed-off-by: provokateurin <[email protected]>
…mplementations Signed-off-by: provokateurin <[email protected]>
ad548d7
to
227609a
Compare
This breaks all apps that have a storage wrapper. At least it should be documented |
@@ -823,7 +750,7 @@ public function writeStream(string $path, $stream, ?int $size = null): int { | |||
return $count; | |||
} | |||
|
|||
public function getDirectoryContent($directory): \Traversable { | |||
public function getDirectoryContent($directory): \Traversable|false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this change, can you explain why the |false
?
There is no return false
in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I thought I remembered that one of the implementations returns false so every implementation has to handle it, but I was wrong. The only error handling I could find was done using exceptions, so I will revert this.
After the PR nextcloud/server#48219 the signatore of this method was changed and now is necessary to have return typing. Problem fixed: ``` Declaration of OCA\\GroupQuota\\Wrapper\\GroupQuotaWrapper::getCache($path = '', $storage = null) must be compatible with OC\\Files\\Storage\\Wrapper\\Wrapper::getCache($path = '', $storage = null): OCP\\Files\\Cache\\ICache at /var/www/html/apps-writable/groupquota/lib/Wrapper/GroupQuotaWrapper.php#35 ``` Server version affected: >= 31 Signed-off-by: Vitor Mattos <[email protected]>
After the PR nextcloud/server#48219 the signatore of this method was changed and now is necessary to have return typing. Problem fixed: ``` Declaration of OCA\\GroupQuota\\Wrapper\\GroupQuotaWrapper::getCache($path = '', $storage = null) must be compatible with OC\\Files\\Storage\\Wrapper\\Wrapper::getCache($path = '', $storage = null): OCP\\Files\\Cache\\ICache at /var/www/html/apps-writable/groupquota/lib/Wrapper/GroupQuotaWrapper.php#35 ``` Server version affected: >= 31 Signed-off-by: Vitor Mattos <[email protected]>
Summary
This adds strong return types to all implementations to match the interface.
The changes escalated a bit, but everything should be fixed at once.
It also fixes some bugs in poorly implemented storages.
Technically this is a breaking change due to changing the signature, but I only did that for private classes and the fix is completely backwards compatible.
The temporary pain of adding the return types to all implementations is justified by fixing all these type mismatches for once.
This change should also allow us to actually add the strong return types to IStorage since all implementations should also be extending Common which already has them.
Please don't hate me for this change 🙈
I was not able to test files_external due to the terrible test setup which I can not get working locally, so let's see what CI has to say.
Checklist