Skip to content

Commit 0a3506d

Browse files
committed
fix(DirMask): Fix return types
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent ff69bf3 commit 0a3506d

2 files changed

Lines changed: 105 additions & 108 deletions

File tree

lib/Storage/DirMask.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace OCA\Guests\Storage;
2323

2424
use OC\Files\Storage\Wrapper\PermissionsMask;
25+
use OCP\Files\Cache\ICache;
2526

2627
/**
2728
* While PermissionMask can mask a whole storage this can
@@ -100,9 +101,6 @@ public function getPermissions($path): int {
100101
}
101102
}
102103

103-
/**
104-
* @psalm-suppress ParamNameMismatch
105-
*/
106104
public function rename($source, $target): bool {
107105
if (!$this->isUpdatable($source)) {
108106
return false;
@@ -123,9 +121,6 @@ public function rename($source, $target): bool {
123121
return false;
124122
}
125123

126-
/**
127-
* @psalm-suppress ParamNameMismatch
128-
*/
129124
public function copy($source, $target): bool {
130125
if (!$this->isReadable($source)) {
131126
return false;
@@ -162,10 +157,7 @@ public function mkdir($path): bool {
162157
}
163158
}
164159

165-
/**
166-
* @psalm-suppress MethodSignatureMustProvideReturnType
167-
*/
168-
public function rmdir($path) {
160+
public function rmdir($path): bool {
169161
if ($this->checkPath($path)) {
170162
return parent::rmdir($path);
171163
} else {
@@ -181,20 +173,14 @@ public function unlink($path): bool {
181173
}
182174
}
183175

184-
/**
185-
* @psalm-suppress MethodSignatureMustProvideReturnType
186-
*/
187-
public function file_put_contents($path, $data) {
176+
public function file_put_contents($path, $data): int|float|false {
188177
if ($this->checkPath($path)) {
189178
return parent::file_put_contents($path, $data);
190179
} else {
191180
return $this->storage->file_put_contents($path, $data);
192181
}
193182
}
194183

195-
/**
196-
* @psalm-suppress MethodSignatureMustProvideReturnType
197-
*/
198184
public function fopen($path, $mode) {
199185
if ($this->checkPath($path)) {
200186
return parent::fopen($path, $mode);
@@ -203,10 +189,7 @@ public function fopen($path, $mode) {
203189
}
204190
}
205191

206-
/**
207-
* @psalm-suppress MethodSignatureMustProvideReturnType
208-
*/
209-
public function getCache($path = '', $storage = null) {
192+
public function getCache($path = '', $storage = null): ICache {
210193
if (!$storage) {
211194
$storage = $this;
212195
}

tests/stub.php

Lines changed: 101 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -587,197 +587,211 @@ public function getMountType() {
587587

588588
namespace OC\Files\Storage\Wrapper{
589589

590+
use OCP\Files\Cache\ICache;
591+
use OCP\Files\Cache\IPropagator;
592+
use OCP\Files\Cache\IScanner;
593+
use OCP\Files\Cache\IUpdater;
594+
use OCP\Files\Cache\IWatcher;
595+
use OCP\Files\Storage;
590596
use OCP\Files\Storage\IStorage;
597+
use OCP\Lock\ILockingProvider;
591598

592599
class Wrapper implements IStorage {
593600
/**
594601
* @var \OCP\Files\Storage\IStorage $storage
595602
*/
596603
protected $storage;
597604

598-
599-
public function __construct(array $parameters) {
605+
/**
606+
* @param array $parameters
607+
*/
608+
public function __construct($parameters) {
600609
}
601610

602-
public function getWrapperStorage(): ?IStorage {
611+
public function getWrapperStorage(): IStorage {
603612
}
604613

605-
public function getId() {
614+
public function getId(): string {
606615
}
607616

608-
public function mkdir($path) {
617+
public function mkdir($path): bool {
609618
}
610619

611-
public function rmdir($path) {
620+
public function rmdir($path): bool {
612621
}
613622

614623
public function opendir($path) {
615-
throw new \Exception('stub');
616624
}
617625

618-
public function is_dir($path) {
619-
throw new \Exception('stub');
626+
public function is_dir($path): bool {
620627
}
621628

622-
public function is_file($path) {
623-
throw new \Exception('stub');
629+
public function is_file($path): bool {
624630
}
625631

626-
public function stat($path) {
627-
throw new \Exception('stub');
632+
public function stat($path): array|false {
628633
}
629634

630-
public function filetype($path) {
631-
throw new \Exception('stub');
635+
public function filetype($path): string|false {
632636
}
633637

634-
public function filesize($path) {
635-
throw new \Exception('stub');
638+
public function filesize($path): int|float|false {
636639
}
637640

638-
public function isCreatable($path) {
639-
throw new \Exception('stub');
641+
public function isCreatable($path): bool {
640642
}
641643

642-
public function isReadable($path) {
643-
throw new \Exception('stub');
644+
public function isReadable($path): bool {
644645
}
645646

646-
public function isUpdatable($path) {
647-
throw new \Exception('stub');
647+
public function isUpdatable($path): bool {
648648
}
649649

650-
public function isDeletable($path) {
651-
throw new \Exception('stub');
650+
public function isDeletable($path): bool {
652651
}
653652

654-
public function isSharable($path) {
655-
throw new \Exception('stub');
653+
public function isSharable($path): bool {
656654
}
657655

658-
public function getPermissions($path) {
659-
throw new \Exception('stub');
656+
public function getPermissions($path): int {
660657
}
661658

662-
public function file_exists($path) {
663-
throw new \Exception('stub');
659+
public function file_exists($path): bool {
664660
}
665661

666-
public function filemtime($path) {
667-
throw new \Exception('stub');
662+
public function filemtime($path): int|false {
668663
}
669664

670-
public function file_get_contents($path) {
671-
throw new \Exception('stub');
665+
public function file_get_contents($path): string|false {
672666
}
673667

674-
public function file_put_contents($path, $data) {
675-
throw new \Exception('stub');
668+
public function file_put_contents($path, $data): int|float|false {
676669
}
677670

678-
public function unlink($path) {
679-
throw new \Exception('stub');
671+
public function unlink($path): bool {
680672
}
681673

682-
public function rename($path1, $path2) {
683-
throw new \Exception('stub');
674+
public function rename($source, $target): bool {
684675
}
685676

686-
public function copy($path1, $path2) {
687-
throw new \Exception('stub');
677+
public function copy($source, $target): bool {
688678
}
689679

690680
public function fopen($path, $mode) {
691-
throw new \Exception('stub');
692681
}
693682

694-
public function getMimeType($path) {
695-
throw new \Exception('stub');
683+
public function getMimeType($path): string|false {
696684
}
697685

698-
public function hash($type, $path, $raw = false) {
699-
throw new \Exception('stub');
686+
public function hash($type, $path, $raw = false): string|false {
700687
}
701688

702-
public function free_space($path) {
703-
throw new \Exception('stub');
689+
public function free_space($path): int|float|false {
704690
}
705691

706-
public function touch($path, $mtime = null) {
707-
throw new \Exception('stub');
692+
public function touch($path, $mtime = null): bool {
708693
}
709694

710-
public function getLocalFile($path) {
711-
throw new \Exception('stub');
695+
public function getLocalFile($path): string|false {
712696
}
713697

714-
public function hasUpdated($path, $time) {
715-
throw new \Exception('stub');
698+
public function hasUpdated($path, $time): bool {
716699
}
717700

718-
public function getETag($path) {
719-
throw new \Exception('stub');
701+
public function getCache($path = '', $storage = null): ICache {
720702
}
721703

722-
public function isLocal() {
723-
throw new \Exception('stub');
704+
public function getScanner($path = '', $storage = null): IScanner {
724705
}
725706

726-
public function instanceOfStorage($class) {
727-
throw new \Exception('stub');
707+
public function getOwner($path): string|false {
728708
}
729709

730-
public function getDirectDownload($path) {
731-
throw new \Exception('stub');
710+
public function getWatcher($path = '', $storage = null): IWatcher {
732711
}
733712

734-
public function verifyPath($path, $fileName) {
735-
throw new \Exception('stub');
713+
public function getPropagator($storage = null): IPropagator {
736714
}
737715

738-
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
739-
throw new \Exception('stub');
716+
public function getUpdater($storage = null): IUpdater {
740717
}
741718

742-
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
743-
throw new \Exception('stub');
719+
public function getStorageCache(): \OC\Files\Cache\Storage {
744720
}
745721

746-
public function test() {
747-
throw new \Exception('stub');
722+
public function getETag($path): string|false {
748723
}
749724

750-
public function getAvailability() {
751-
throw new \Exception('stub');
725+
public function test(): bool {
752726
}
753727

754-
public function setAvailability($isAvailable) {
755-
throw new \Exception('stub');
728+
public function isLocal(): bool {
756729
}
757730

758-
public function getOwner($path) {
759-
throw new \Exception('stub');
731+
public function instanceOfStorage($class): bool {
760732
}
761733

762-
public function getCache() {
763-
throw new \Exception('stub');
734+
/**
735+
* @psalm-template T of IStorage
736+
* @psalm-param class-string<T> $class
737+
* @psalm-return T|null
738+
*/
739+
public function getInstanceOfStorage(string $class): ?IStorage {
764740
}
765741

766-
public function getPropagator() {
767-
throw new \Exception('stub');
742+
/**
743+
* Pass any methods custom to specific storage implementations to the wrapped storage
744+
*
745+
* @param string $method
746+
* @param array $args
747+
* @return mixed
748+
*/
749+
public function __call($method, $args) {
768750
}
769751

770-
public function getScanner() {
771-
throw new \Exception('stub');
752+
public function getDirectDownload($path): array|false {
753+
}
754+
755+
public function getAvailability(): array {
756+
}
757+
758+
public function setAvailability($isAvailable): void {
759+
}
760+
761+
public function verifyPath($path, $fileName): void {
762+
}
763+
764+
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
765+
}
766+
767+
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
768+
}
769+
770+
public function getMetaData($path): ?array {
771+
}
772+
773+
public function acquireLock($path, $type, ILockingProvider $provider): void {
774+
}
775+
776+
public function releaseLock($path, $type, ILockingProvider $provider): void {
777+
}
778+
779+
public function changeLock($path, $type, ILockingProvider $provider): void {
780+
}
781+
782+
public function needsPartFile(): bool {
783+
}
784+
785+
public function writeStream(string $path, $stream, ?int $size = null): int {
772786
}
773787

774-
public function getUpdater() {
788+
public function getDirectoryContent($directory): \Traversable|false {
775789
}
776790

777-
public function getWatcher() {
791+
public function isWrapperOf(IStorage $storage): bool {
778792
}
779793

780-
public function setOwner(?string $user) : void {
794+
public function setOwner(?string $user): void {
781795
}
782796
}
783797

0 commit comments

Comments
 (0)