Skip to content

Commit

Permalink
Merge pull request #3900 from nextcloud/tests/static-circles
Browse files Browse the repository at this point in the history
Fix static analysis by stubbing more circle methods
  • Loading branch information
juliusknorr authored Jul 5, 2022
2 parents 00120a6 + f03ffd1 commit 227c962
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 55 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
</TooManyArguments>
</file>
<file src="lib/Service/CirclesService.php">
<UndefinedClass occurrences="1"/>
<RedundantCondition occurrences="1">
<code>$member !== null</code>
</RedundantCondition>
</file>
<file src="lib/Service/FileService.php">
<RedundantCondition occurrences="2">
Expand Down
111 changes: 63 additions & 48 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,61 @@ declare(strict_types=1);
*/

namespace OCA\Circles\Model {
class Member {
public const LEVEL_NONE = 0;
public const LEVEL_MEMBER = 1;
public const LEVEL_MODERATOR = 4;
public const LEVEL_ADMIN = 8;
public const LEVEL_OWNER = 9;

public const TYPE_SINGLE = 0;
public const TYPE_USER = 1;
public const TYPE_GROUP = 2;
public const TYPE_MAIL = 4;
public const TYPE_CONTACT = 8;
public const TYPE_CIRCLE = 16;
public const TYPE_APP = 10000;

public const ALLOWING_ALL_TYPES = 31;

public const APP_CIRCLES = 10001;
public const APP_OCC = 10002;
public const APP_DEFAULT = 11000;
}

class Circle {
public function getUniqueId(): string {}
public function getDisplayName(): string {}
public function getOwner(): string {}
public function getSingleId(): string {}
public function getInheritedMembers(): array {}
}
class Member {
public const LEVEL_NONE = 0;
public const LEVEL_MEMBER = 1;
public const LEVEL_MODERATOR = 4;
public const LEVEL_ADMIN = 8;
public const LEVEL_OWNER = 9;

public const TYPE_SINGLE = 0;
public const TYPE_USER = 1;
public const TYPE_GROUP = 2;
public const TYPE_MAIL = 4;
public const TYPE_CONTACT = 8;
public const TYPE_CIRCLE = 16;
public const TYPE_APP = 10000;

public const ALLOWING_ALL_TYPES = 31;

public const APP_CIRCLES = 10001;
public const APP_OCC = 10002;
public const APP_DEFAULT = 11000;

public function getLevel(): int {}
}

class Circle {
public function getUniqueId(): string {}
public function getDisplayName(): string {}
public function getOwner(): string {}
public function getSingleId(): string {}
public function getInheritedMembers(): array {}
public function getInitiator(): Member {}
}

class FederatedUser {
}
}

namespace OCA\Circles\Model\Probes {
class CircleProble {
public function __construct() {}
}
class CircleProbe {
public function __construct() {}
public function mustBeMember(bool $must = true): self {}
}
}

namespace OCA\Circles {
class CirclesManager {
}
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\FederatedUser;
use OCA\Circles\Model\Probes\CircleProbe;
class CirclesManager {
public function startSuperSession(): void {}
public function startSession(?FederatedUser $federatedUser = null): void {}
public function getCircles(?CircleProbe $probe = null): array {}
public function getCircle(string $singleId, ?CircleProbe $probe = null): Circle {}
public function getFederatedUser(string $federatedId, int $type = Member::TYPE_SINGLE): FederatedUser {}
}
}

namespace {
Expand Down Expand Up @@ -328,10 +343,10 @@ namespace OC\Files\Mount {
protected $class;
protected $storageId;
protected $rootId = null;

/** @var int|null */
protected $mountId;

/**
* @param string|\OCP\Files\Storage\IStorage $storage
* @param string $mountpoint
Expand All @@ -344,7 +359,7 @@ namespace OC\Files\Mount {
public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
throw new \Exception('stub');
}

/**
* get complete path to the mount point, relative to data/
*
Expand All @@ -353,7 +368,7 @@ namespace OC\Files\Mount {
public function getMountPoint() {
throw new \Exception('stub');
}

/**
* Sets the mount point path, relative to data/
*
Expand All @@ -362,43 +377,43 @@ namespace OC\Files\Mount {
public function setMountPoint($mountPoint) {
throw new \Exception('stub');
}

/**
* @return \OCP\Files\Storage\IStorage
*/
public function getStorage() {
throw new \Exception('stub');
}

/**
* @return string
*/
public function getStorageId() {
throw new \Exception('stub');
}

/**
* @return int
*/
public function getNumericStorageId() {
throw new \Exception('stub');
}

/**
* @param string $path
* @return string
*/
public function getInternalPath($path) {
throw new \Exception('stub');
}

/**
* @param callable $wrapper
*/
public function wrapStorage($wrapper) {
throw new \Exception('stub');
}

/**
* Get a mount option
*
Expand All @@ -409,7 +424,7 @@ namespace OC\Files\Mount {
public function getOption($name, $default) {
throw new \Exception('stub');
}

/**
* Get all options for the mount
*
Expand All @@ -418,18 +433,18 @@ namespace OC\Files\Mount {
public function getOptions() {
throw new \Exception('stub');
}

/**
* @return int
*/
public function getStorageRootId() {
throw new \Exception('stub');
}

public function getMountId() {
throw new \Exception('stub');
}

public function getMountType() {
throw new \Exception('stub');
}
Expand Down

0 comments on commit 227c962

Please sign in to comment.