Skip to content

Commit

Permalink
fix phan PhanUndeclaredMethod for stable10
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jul 12, 2019
1 parent 130ad4c commit 7798c05
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/encryption/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function registerServices() {
$container->registerService('Crypt',
function (IAppContainer $c) {
$server = $c->getServer();
'@phan-var \OC\Server $server';

if ($this->config->getAppValue('encryption', 'hsm.url', '') !== '') {
$this->config->setAppValue('crypto.engine', 'internal', 'hsm');
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/lib/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private function getSourceScanner() {
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
$sourceScanner = $this->getSourceScanner();
if ($sourceScanner instanceof NoopScanner) {
'@phan-var \OC\Files\Storage\Storage $this->storage';
list(, $internalPath) = $this->storage->resolvePath($path);
return $sourceScanner->scan($internalPath, $recursive, $reuse, $lock);
} else {
Expand All @@ -90,6 +91,7 @@ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $loc
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
$sourceScanner = $this->getSourceScanner();
if ($sourceScanner instanceof NoopScanner) {
'@phan-var \OC\Files\Storage\Storage $this->storage';
list(, $internalPath) = $this->storage->resolvePath($file);
return parent::scan($internalPath, self::SCAN_SHALLOW, $reuseExisting, $lock);
} else {
Expand Down
2 changes: 2 additions & 0 deletions apps/provisioning_api/lib/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function getGroup($parameters) {
$isSubadminOfGroup = false;
$group = $this->groupManager->get($groupId);
if ($group !== null) {
'@phan-var \OC\Group\Manager $this->groupManager';
$isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group);
}

Expand Down Expand Up @@ -178,6 +179,7 @@ public function getSubAdminsOfGroup($parameters) {
return new OC_OCS_Result(null, 101, 'Group does not exist');
}

'@phan-var \OC\Group\Manager $this->groupManager';
$subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup);
// New class returns IUser[] so convert back
$uids = [];
Expand Down
4 changes: 3 additions & 1 deletion lib/private/DB/MySqlSchemaColumnDefinitionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $eventA
$this->_platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
}

$version = \OC::$server->getDatabaseConnection()->getDatabaseVersionString();
$databaseConnection = \OC::$server->getDatabaseConnection();
'@phan-var \OC\DB\Connection $databaseConnection';
$version = $databaseConnection->getDatabaseVersionString();
$mariadb = \stripos($version, 'mariadb') !== false;
if ($mariadb && \version_compare($this->getMariaDbMysqlVersionNumber($version), '10.2.7', '>=')) {
$tableColumn = $eventArgs->getTableColumn();
Expand Down
1 change: 1 addition & 0 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceIntern

// living on different buckets?
/** @var ObjectStoreStorage $sourceStorage */
'@phan-var ObjectStoreStorage $sourceStorage';
if ($this->getBucket() !== $sourceStorage->getBucket()) {
return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ public function opendir($path) {
*/
public function readdir($handle) {
$fsLocal = new Local(['datadir' => '/']);
// ToDo: Local does not have readdir - what is happening here?
/* @phan-suppress-next-line PhanUndeclaredMethod */
return $fsLocal->readdir($handle);
}

Expand Down
1 change: 1 addition & 0 deletions lib/private/Group/MetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ protected function getGroups($search = '') {
} else {
$userObject = $this->userSession->getUser();
if ($userObject !== null) {
'@phan-var \OC\Group\Manager $this->groupManager';
$groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($userObject);
} else {
$groups = [];
Expand Down
4 changes: 4 additions & 0 deletions lib/private/Share/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,8 @@ public static function getItems($itemType, $item = null, $shareType = null, $sha
// see github issue #10588 for more details
// Need to find a solution which works for all back-ends
$collectionBackend = self::getBackend($row['item_type']);
// and need to sort out exactly what class or interface this always is
/* @phan-suppress-next-line PhanUndeclaredMethod */
$sharedParents = $collectionBackend->getParents($row['item_source']);
foreach ($sharedParents as $parent) {
$collectionItems[] = $parent;
Expand All @@ -2058,6 +2060,8 @@ public static function getItems($itemType, $item = null, $shareType = null, $sha
// Need to find a solution which works for all back-ends
$collectionItems = [];
$collectionBackend = self::getBackend('folder');
// and need to sort out exactly what class or interface this always is
/* @phan-suppress-next-line PhanUndeclaredMethod */
$sharedParents = $collectionBackend->getParents($item, $shareWith, $uidOwner);
foreach ($sharedParents as $parent) {
$collectionItems[] = $parent;
Expand Down
37 changes: 25 additions & 12 deletions settings/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ private function formatUserForIndex(IUser $user, array $userGroups = null) {
$restorePossible = true;
}

'@phan-var \OC\Group\Manager $this->groupManager';
$subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
foreach ($subAdminGroups as $key => $subAdminGroup) {
$subAdminGroups[$key] = $subAdminGroup->getGID();
Expand Down Expand Up @@ -311,7 +312,9 @@ public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backe
$users[] = $this->formatUserForIndex($user);
}
} else {
$subAdminOfGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser());
$groupManager = $this->groupManager;
'@phan-var \OC\Group\Manager $groupManager';
$subAdminOfGroups = $groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser());
// New class returns IGroup[] so convert back
$gids = [];
foreach ($subAdminOfGroups as $group) {
Expand Down Expand Up @@ -416,12 +419,14 @@ public function create($username, $password, array $groups= [], $email='') {
continue;
}

'@phan-var \OC\Group\Manager $this->groupManager';
if (!$this->groupManager->getSubAdmin()->isSubAdminofGroup($currentUser, $groupObject)) {
unset($groups[$key]);
}
}
}

'@phan-var \OC\Group\Manager $this->groupManager';
if (empty($groups)) {
$groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($currentUser);
// New class returns IGroup[] so convert back
Expand Down Expand Up @@ -754,6 +759,7 @@ public function destroy($id) {
);
}

'@phan-var \OC\Group\Manager $this->groupManager';
if (!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
return new DataResponse(
[
Expand Down Expand Up @@ -806,17 +812,20 @@ public function setMailAddress($id, $mailAddress) {
$user = $this->userManager->get($id);

if ($userId !== $id
&& !$this->isAdmin
&& !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
return new DataResponse(
[
'status' => 'error',
'data' => [
'message' => (string)$this->l10n->t('Forbidden')
]
],
Http::STATUS_FORBIDDEN
);
&& !$this->isAdmin) {
$groupManager = $this->groupManager;
'@phan-var \OC\Group\Manager $groupManager';
if (!$groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
return new DataResponse(
[
'status' => 'error',
'data' => [
'message' => (string)$this->l10n->t('Forbidden')
]
],
Http::STATUS_FORBIDDEN
);
}
}

if ($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) {
Expand Down Expand Up @@ -927,6 +936,7 @@ public function stats() {
}
}
} else {
'@phan-var \OC\Group\Manager $this->groupManager';
$groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser());

$uniqueUsers = [];
Expand Down Expand Up @@ -964,6 +974,7 @@ public function setDisplayName($username, $displayName) {
}

$user = $this->userManager->get($username);
'@phan-var \OC\Group\Manager $this->groupManager';

if ($user === null ||
!$user->canChangeDisplayName() ||
Expand Down Expand Up @@ -1052,6 +1063,7 @@ public function sendEmail($userId, $mailAddress) {
*/
public function setEmailAddress($id, $mailAddress) {
$user = $this->userManager->get($id);
'@phan-var \OC\Group\Manager $this->groupManager';
if ($this->isAdmin ||
($this->groupManager->getSubAdmin()->isSubAdmin($this->userSession->getUser()) &&
$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) ||
Expand Down Expand Up @@ -1132,6 +1144,7 @@ public function changeMail($token, $userId) {
public function setEnabled($id, $enabled) {
$userId = $this->userSession->getUser()->getUID();
$user = $this->userManager->get($id);
'@phan-var \OC\Group\Manager $this->groupManager';

if ($userId === $id ||
(!$this->isAdmin &&
Expand Down

0 comments on commit 7798c05

Please sign in to comment.