diff --git a/.drone.jsonnet b/.drone.jsonnet index 8a63018647d0..7243e61059a6 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -44,7 +44,7 @@ local pipelines = [ depends_on=standard_deps ) for php in [ - '7.1', + '7.1', '7.2', '7.3', ] ] + [ # diff --git a/.drone.yml b/.drone.yml index f6f1dc2f1f03..b7e040d992c1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -240,6 +240,166 @@ trigger: depends_on: - install-dependencies +--- +kind: pipeline +name: phan-php7.2 + +platform: + os: linux + arch: amd64 + +steps: +- name: cache-restore + pull: always + image: plugins/s3-cache:1 + settings: + access_key: + from_secret: cache_s3_access_key + endpoint: + from_secret: cache_s3_endpoint + restore: true + secret_key: + from_secret: cache_s3_secret_key + when: + instance: + - drone.owncloud.services + - drone.owncloud.com + +- name: composer-install + pull: always + image: owncloudci/php:7.2 + commands: + - make install-composer-deps + environment: + COMPOSER_HOME: /drone/src/.cache/composer + +- name: vendorbin-install + pull: always + image: owncloudci/php:7.2 + commands: + - make vendor-bin-deps + environment: + COMPOSER_HOME: /drone/src/.cache/composer + +- name: yarn-install + pull: always + image: owncloudci/php:7.2 + commands: + - make install-nodejs-deps + environment: + NPM_CONFIG_CACHE: /drone/src/.cache/npm + YARN_CACHE_FOLDER: /drone/src/.cache/yarn + bower_storage__packages: /drone/src/.cache/bower + +- name: install-server + pull: always + image: owncloudci/php:7.2 + commands: + - bash tests/drone/install-server.sh + - php occ a:l + - php occ config:system:set trusted_domains 1 --value=server + - php occ log:manage --level 2 + - php occ config:list + - php occ security:certificates:import /drone/server.crt + - php occ security:certificates + environment: + DB_TYPE: sqlite + +- name: php-phan + pull: always + image: owncloudci/php:7.2 + commands: + - make test-php-phan + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- install-dependencies + +--- +kind: pipeline +name: phan-php7.3 + +platform: + os: linux + arch: amd64 + +steps: +- name: cache-restore + pull: always + image: plugins/s3-cache:1 + settings: + access_key: + from_secret: cache_s3_access_key + endpoint: + from_secret: cache_s3_endpoint + restore: true + secret_key: + from_secret: cache_s3_secret_key + when: + instance: + - drone.owncloud.services + - drone.owncloud.com + +- name: composer-install + pull: always + image: owncloudci/php:7.3 + commands: + - make install-composer-deps + environment: + COMPOSER_HOME: /drone/src/.cache/composer + +- name: vendorbin-install + pull: always + image: owncloudci/php:7.3 + commands: + - make vendor-bin-deps + environment: + COMPOSER_HOME: /drone/src/.cache/composer + +- name: yarn-install + pull: always + image: owncloudci/php:7.3 + commands: + - make install-nodejs-deps + environment: + NPM_CONFIG_CACHE: /drone/src/.cache/npm + YARN_CACHE_FOLDER: /drone/src/.cache/yarn + bower_storage__packages: /drone/src/.cache/bower + +- name: install-server + pull: always + image: owncloudci/php:7.3 + commands: + - bash tests/drone/install-server.sh + - php occ a:l + - php occ config:system:set trusted_domains 1 --value=server + - php occ log:manage --level 2 + - php occ config:list + - php occ security:certificates:import /drone/server.crt + - php occ security:certificates + environment: + DB_TYPE: sqlite + +- name: php-phan + pull: always + image: owncloudci/php:7.3 + commands: + - make test-php-phan + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- install-dependencies + --- kind: pipeline name: stan-php7.1 @@ -12813,6 +12973,8 @@ depends_on: - install-dependencies - coding-standard - phan-php7.1 +- phan-php7.2 +- phan-php7.3 - stan-php7.1 - test-javascript - litmus-php7.1 diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index 0ae28c9c7612..0140d62bac01 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -60,6 +60,7 @@ public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10 public function updateShares(array $add, array $remove) { /** @var CalDavBackend $calDavBackend */ $calDavBackend = $this->caldavBackend; + '@phan-var CalDavBackend $calDavBackend'; $calDavBackend->updateShares($this, $add, $remove); } @@ -78,6 +79,7 @@ public function updateShares(array $add, array $remove) { public function getShares() { /** @var CalDavBackend $calDavBackend */ $calDavBackend = $this->caldavBackend; + '@phan-var CalDavBackend $calDavBackend'; return $calDavBackend->getShares($this->getResourceId()); } @@ -139,6 +141,7 @@ public function getACL() { /** @var CalDavBackend $calDavBackend */ $calDavBackend = $this->caldavBackend; + '@phan-var CalDavBackend $calDavBackend'; return $calDavBackend->applyShareAcl($this->getResourceId(), $acl); } @@ -166,6 +169,7 @@ public function delete() { /** @var CalDavBackend $calDavBackend */ $calDavBackend = $this->caldavBackend; + '@phan-var CalDavBackend $calDavBackend'; $calDavBackend->updateShares($this, [], [ $principal ]); @@ -253,6 +257,7 @@ public function calendarQuery(array $filters) { * @return string|null */ public function setPublishStatus($value) { + '@phan-var CalDavBackend $this->calDavBackend'; $publicUri = $this->caldavBackend->setPublishStatus($value, $this); $this->calendarInfo['publicuri'] = $publicUri; return $publicUri; @@ -262,6 +267,7 @@ public function setPublishStatus($value) { * @return mixed $value */ public function getPublishStatus() { + '@phan-var CalDavBackend $this->calDavBackend'; return $this->caldavBackend->getPublishStatus($this); } diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php index e905715005a2..15420ea96657 100644 --- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php +++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php @@ -181,6 +181,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response) // If there's no ACL support, we allow everything if ($acl) { + '@phan-var \OCA\DAV\Connector\Sabre\DavAclPlugin $acl'; $acl->checkPrivileges($path, '{DAV:}write'); } @@ -209,6 +210,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response) // If there's no ACL support, we allow everything if ($acl) { + '@phan-var \OCA\DAV\Connector\Sabre\DavAclPlugin $acl'; $acl->checkPrivileges($path, '{DAV:}write'); } diff --git a/apps/dav/lib/CardDAV/AddressBook.php b/apps/dav/lib/CardDAV/AddressBook.php index 02a85981c3ae..92fb8ad155c5 100644 --- a/apps/dav/lib/CardDAV/AddressBook.php +++ b/apps/dav/lib/CardDAV/AddressBook.php @@ -47,9 +47,10 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { * @return void */ public function updateShares(array $add, array $remove) { - /** @var CardDavBackend $carddavBackend */ - $carddavBackend = $this->carddavBackend; - $carddavBackend->updateShares($this, $add, $remove); + /** @var CardDavBackend $cardDavBackend */ + $cardDavBackend = $this->carddavBackend; + '@phan-var CardDavBackend $cardDavBackend'; + $cardDavBackend->updateShares($this, $add, $remove); } /** @@ -65,9 +66,10 @@ public function updateShares(array $add, array $remove) { * @return array */ public function getShares() { - /** @var CardDavBackend $carddavBackend */ - $carddavBackend = $this->carddavBackend; - return $carddavBackend->getShares($this->getResourceId()); + /** @var CardDavBackend $cardDavBackend */ + $cardDavBackend = $this->carddavBackend; + '@phan-var CardDavBackend $cardDavBackend'; + return $cardDavBackend->getShares($this->getResourceId()); } public function getACL() { @@ -104,9 +106,10 @@ public function getACL() { ]; } - /** @var CardDavBackend $carddavBackend */ - $carddavBackend = $this->carddavBackend; - return $carddavBackend->applyShareAcl($this->getResourceId(), $acl); + /** @var CardDavBackend $cardDavBackend */ + $cardDavBackend = $this->carddavBackend; + '@phan-var CardDavBackend $cardDavBackend'; + return $cardDavBackend->applyShareAcl($this->getResourceId(), $acl); } public function getChildACL() { @@ -149,6 +152,7 @@ public function delete() { /** @var CardDavBackend $cardDavBackend */ $cardDavBackend = $this->carddavBackend; + '@phan-var CardDavBackend $cardDavBackend'; $cardDavBackend->updateShares($this, [], [ $principal ]); @@ -167,6 +171,7 @@ public function propPatch(PropPatch $propPatch) { public function getContactsGroups() { /** @var CardDavBackend $cardDavBackend */ $cardDavBackend = $this->carddavBackend; + '@phan-var CardDavBackend $cardDavBackend'; return $cardDavBackend->collectCardProperties($this->getResourceId(), 'CATEGORIES'); } diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php index 2ae803ff82f5..7ce10f04e31e 100644 --- a/apps/dav/lib/CardDAV/ImageExportPlugin.php +++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php @@ -80,6 +80,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response) // Checking ACL, if available. if ($aclPlugin = $this->server->getPlugin('acl')) { /** @var \Sabre\DAVACL\Plugin $aclPlugin */ + '@phan-var \Sabre\DAVACL\Plugin $aclPlugin'; $aclPlugin->checkPrivileges($path, '{DAV:}read'); } diff --git a/apps/dav/lib/Connector/Sabre/AutorenamePlugin.php b/apps/dav/lib/Connector/Sabre/AutorenamePlugin.php index 80b41e34c405..1fb181c595d4 100644 --- a/apps/dav/lib/Connector/Sabre/AutorenamePlugin.php +++ b/apps/dav/lib/Connector/Sabre/AutorenamePlugin.php @@ -95,6 +95,7 @@ public function handlePut(RequestInterface $request, ResponseInterface $response return; } + '@phan-var ObjectTree $this->server->tree'; $view = $this->server->tree->getView(); list($nodePath, $nodeName) = \Sabre\Uri\split($node->getPath()); $newName = \OC_Helper::buildNotExistingFileNameForView($nodePath, $nodeName, $view); diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index cf0db53557ca..05ca7c91a316 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -276,6 +276,7 @@ public function getSharePermissions($user) { if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { /** @var \OCA\Files_Sharing\SharedStorage $storage */ + '@phan-var \OCA\Files_Sharing\SharedStorage $storage'; $permissions = (int)$storage->getShare()->getPermissions(); } else { $permissions = $storage->getPermissions($path); diff --git a/apps/dav/lib/Connector/Sabre/QuotaPlugin.php b/apps/dav/lib/Connector/Sabre/QuotaPlugin.php index f4a6f0bd3800..e0227b341efb 100644 --- a/apps/dav/lib/Connector/Sabre/QuotaPlugin.php +++ b/apps/dav/lib/Connector/Sabre/QuotaPlugin.php @@ -93,9 +93,11 @@ public function handleBeforeMove($source, $destination) { // get target node for proper path conversion if ($this->server->tree->nodeExists($destination)) { $destinationNode = $this->server->tree->getNodeForPath($destination); + '@phan-var Node $destinationNode'; $path = $destinationNode->getPath(); } else { $parentNode = $this->server->tree->getNodeForPath(\dirname($destination)); + '@phan-var Node $parentNode'; $path = $parentNode->getPath(); } diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index 95d8c875d2b8..f8a9d8b09681 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -132,6 +132,7 @@ public function createServer($baseUri, // ensure the skeleton is copied // Try to obtain User Folder $userFolder = \OC::$server->getUserFolder(); + '@phan-var \OCA\DAV\Connector\Sabre\Node $userFolder'; /** @var \OC\Files\View $view */ $view = $viewCallBack($server); diff --git a/apps/dav/lib/Connector/Sabre/TagsPlugin.php b/apps/dav/lib/Connector/Sabre/TagsPlugin.php index f4115a6d2ab7..52216b90ea7a 100644 --- a/apps/dav/lib/Connector/Sabre/TagsPlugin.php +++ b/apps/dav/lib/Connector/Sabre/TagsPlugin.php @@ -220,6 +220,7 @@ public function handleGetProperties( $folderContent = $node->getChildren(); $fileIds[] = (int)$node->getId(); foreach ($folderContent as $info) { + '@phan-var \OCA\DAV\Connector\Sabre\Node $info'; $fileIds[] = (int)$info->getId(); } $tags = $this->getTagger()->getTagsForObjects($fileIds); diff --git a/apps/dav/lib/DAV/CopyPlugin.php b/apps/dav/lib/DAV/CopyPlugin.php index 2d876c832d58..ba1e92ed3f82 100644 --- a/apps/dav/lib/DAV/CopyPlugin.php +++ b/apps/dav/lib/DAV/CopyPlugin.php @@ -84,6 +84,7 @@ public function httpCopy(RequestInterface $request, ResponseInterface $response) return false; } + '@phan-var ICopySource $sourceNode'; $sourceNode->copy($destinationNode->getFileInfo()->getPath()); $this->server->emit('afterBind', [$copyInfo['destination']]); diff --git a/apps/dav/lib/DAV/FileCustomPropertiesBackend.php b/apps/dav/lib/DAV/FileCustomPropertiesBackend.php index ddcfec8bba60..5b61b7368876 100644 --- a/apps/dav/lib/DAV/FileCustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/FileCustomPropertiesBackend.php @@ -71,6 +71,7 @@ class FileCustomPropertiesBackend extends AbstractCustomPropertiesBackend { public function beforeDelete($path) { try { $node = $this->getNodeForPath($path); + '@phan-var \OCA\DAV\Connector\Sabre\Node $node'; if ($node !== null && $node->getId()) { if ($this->deletedItemsCache === null) { $this->deletedItemsCache = new CappedMemoryCache(); @@ -137,6 +138,7 @@ public function move($source, $destination) { * @inheritdoc */ protected function getProperties($path, INode $node, array $requestedProperties) { + '@phan-var \OCA\DAV\Connector\Sabre\Node $node'; $fileId = $node->getId(); if ($this->offsetGet($fileId) === null) { // TODO: chunking if more than 1000 properties @@ -162,6 +164,7 @@ protected function getProperties($path, INode $node, array $requestedProperties) */ protected function updateProperties($path, INode $node, $changedProperties) { $existingProperties = $this->getProperties($path, $node, []); + '@phan-var \OCA\DAV\Connector\Sabre\Node $node'; $fileId = $node->getId(); $deleteStatement = self::DELETE_BY_ID_AND_NAME_STMT; $insertStatement = self::INSERT_BY_ID_STMT; @@ -232,6 +235,7 @@ protected function loadChildrenProperties(INode $node, $requestedProperties) { $childrenIds = []; // pre-fill cache foreach ($childNodes as $childNode) { + '@phan-var \OCA\DAV\Connector\Sabre\Node $childNode'; $childId = $childNode->getId(); if ($childId) { $childrenIds[] = $childId; diff --git a/apps/dav/lib/DAV/FileCustomPropertiesPlugin.php b/apps/dav/lib/DAV/FileCustomPropertiesPlugin.php index 4c5718c49481..1c135fdfcd66 100644 --- a/apps/dav/lib/DAV/FileCustomPropertiesPlugin.php +++ b/apps/dav/lib/DAV/FileCustomPropertiesPlugin.php @@ -56,6 +56,7 @@ public function beforeUnbind($path) { if ($pathFilter && !$pathFilter($path)) { return; } + '@phan-var \OCA\DAV\DAV\FileCustomPropertiesBackend $this->backend'; $this->backend->beforeDelete($path); } } diff --git a/apps/dav/lib/DAV/Sharing/Plugin.php b/apps/dav/lib/DAV/Sharing/Plugin.php index 9e9f5f6267bd..aadf0d0e0092 100644 --- a/apps/dav/lib/DAV/Sharing/Plugin.php +++ b/apps/dav/lib/DAV/Sharing/Plugin.php @@ -158,6 +158,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response) // If there's no ACL support, we allow everything if ($acl) { /** @var \Sabre\DAVACL\Plugin $acl */ + '@phan-var \Sabre\DAVACL\Plugin $acl'; $acl->checkPrivileges($path, '{DAV:}write'); } diff --git a/apps/dav/lib/DAV/ViewOnlyPlugin.php b/apps/dav/lib/DAV/ViewOnlyPlugin.php index 7bfa1dc700f4..c00f8886a2f3 100644 --- a/apps/dav/lib/DAV/ViewOnlyPlugin.php +++ b/apps/dav/lib/DAV/ViewOnlyPlugin.php @@ -100,6 +100,7 @@ public function checkViewOnly( } // Extract extra permissions /** @var \OCA\Files_Sharing\SharedStorage $storage */ + '@phan-var \OCA\Files_Sharing\SharedStorage $storage'; $share = $storage->getShare(); // Check if read-only and on whether permission can download is both set and disabled. diff --git a/apps/dav/lib/Files/FileLocksBackend.php b/apps/dav/lib/Files/FileLocksBackend.php index 3ba5d065c02b..fa8da07bc284 100644 --- a/apps/dav/lib/Files/FileLocksBackend.php +++ b/apps/dav/lib/Files/FileLocksBackend.php @@ -77,6 +77,7 @@ public function getLocks($uri, $returnChildLocks) { } /** @var IPersistentLockingStorage $storage */ + '@phan-var IPersistentLockingStorage $storage'; $locks = $storage->getLocks($node->getFileInfo()->getInternalPath(), $returnChildLocks); } catch (NotFound $e) { if ($uri === '') { @@ -104,6 +105,7 @@ public function getLocks($uri, $returnChildLocks) { } /** @var IPersistentLockingStorage $storage */ + '@phan-var IPersistentLockingStorage $storage'; $locks = $storage->getLocks($node->getFileInfo()->getInternalPath() . '/' . $childPath, $returnChildLocks); } @@ -179,6 +181,7 @@ public function lock($uri, Locks\LockInfo $lockInfo) { } /** @var IPersistentLockingStorage $storage */ + '@phan-var IPersistentLockingStorage $storage'; $lock = $storage->lockNodePersistent($node->getFileInfo()->getInternalPath(), [ 'token' => $lockInfo->token, 'scope' => $lockInfo->scope === Locks\LockInfo::EXCLUSIVE ? ILock::LOCK_SCOPE_EXCLUSIVE : ILock::LOCK_SCOPE_SHARED, @@ -219,6 +222,7 @@ public function unlock($uri, Locks\LockInfo $lockInfo) { } /** @var IPersistentLockingStorage $storage */ + '@phan-var IPersistentLockingStorage $storage'; return $storage->unlockNodePersistent($node->getFileInfo()->getInternalPath(), [ 'token' => $lockInfo->token ]); diff --git a/apps/dav/lib/Files/PreviewPlugin.php b/apps/dav/lib/Files/PreviewPlugin.php index 251ca0a8f290..30e58e4d58c2 100644 --- a/apps/dav/lib/Files/PreviewPlugin.php +++ b/apps/dav/lib/Files/PreviewPlugin.php @@ -102,6 +102,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response) // Checking ACL, if available. if ($aclPlugin = $this->server->getPlugin('acl')) { /** @var \Sabre\DAVACL\Plugin $aclPlugin */ + '@phan-var \Sabre\DAVACL\Plugin $aclPlugin'; $aclPlugin->checkPrivileges($path, '{DAV:}read'); } diff --git a/apps/dav/lib/Meta/MetaPlugin.php b/apps/dav/lib/Meta/MetaPlugin.php index a8a1f819d8f2..207870cb423d 100644 --- a/apps/dav/lib/Meta/MetaPlugin.php +++ b/apps/dav/lib/Meta/MetaPlugin.php @@ -88,6 +88,7 @@ public function handleGetProperties(PropFind $propFind, INode $node) { $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->get($uid . '/files/'); + '@phan-var \OC\Files\Node\Folder $baseFolder'; $files = $baseFolder->getById($fileId); if (!$files) { return null; diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index cc0df081ebd8..70e26444f298 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -1066,6 +1066,7 @@ public function getAccepted($remote, $shareWith) { 'remoteshare.received', new GenericEvent('', ['remote' => $remote]) ); + '@phan-var GenericEvent $event'; if ($event->getArgument('autoAddServers')) { return false; } diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index c262179f9482..aba6dedf569b 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -502,6 +502,7 @@ protected function formatExecTime() { protected function reconnectToDatabase(OutputInterface $output) { /** @var Connection | IDBConnection $connection*/ $connection = \OC::$server->getDatabaseConnection(); + '@phan-var Connection | IDBConnection $connection'; try { $connection->close(); } catch (\Exception $ex) { diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php index e91d2ef98175..e8bcf8f968f0 100644 --- a/apps/files/lib/Command/TransferOwnership.php +++ b/apps/files/lib/Command/TransferOwnership.php @@ -315,6 +315,7 @@ private function restoreShares(OutputInterface $output) { */ if ($share->getSharedWith() === $this->destinationUser) { $provider = $this->shareProviderFactory->getProviderForType($share->getShareType()); + '@phan-var \OC\Share20\DefaultShareProvider $provider'; foreach ($provider->getChildren($share) as $child) { $childShares[] = $child->getId(); } diff --git a/apps/files/lib/Command/VerifyChecksums.php b/apps/files/lib/Command/VerifyChecksums.php index b9aff3a4fe91..e535220fc26a 100644 --- a/apps/files/lib/Command/VerifyChecksums.php +++ b/apps/files/lib/Command/VerifyChecksums.php @@ -174,6 +174,7 @@ public function execute(InputInterface $input, OutputInterface $output) { private function walkNodes(array $nodes, \Closure $callBack) { foreach ($nodes as $node) { if ($node->getType() === FileInfo::TYPE_FOLDER) { + '@phan-var \OCP\Files\Folder $node'; $this->walkNodes($node->getDirectoryListing(), $callBack); } else { $callBack($node); diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 6f950c2eb26d..5b87055941db 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -218,7 +218,9 @@ public function index($dir = '', $view = '', $fileid = null, $details = null) { $user = $this->userSession->getUser()->getUID(); - $navItems = \OCA\Files\App::getNavigationManager()->getAll(); + $navigationManager = \OCA\Files\App::getNavigationManager(); + '@phan-var \OC\NavigationManager $navigationManager'; + $navItems = $navigationManager->getAll(); \usort($navItems, function ($item1, $item2) { return $item1['order'] - $item2['order']; }); @@ -283,6 +285,7 @@ public function index($dir = '', $view = '', $fileid = null, $details = null) { public function showFile($fileId, $details = null) { $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->get($uid . '/files/'); + '@phan-var \OCP\Files\Folder $baseFolder'; $files = $baseFolder->getById($fileId); $params = []; diff --git a/apps/files_external/lib/Controller/UserGlobalStoragesController.php b/apps/files_external/lib/Controller/UserGlobalStoragesController.php index 352aa444491f..becc9be4c183 100644 --- a/apps/files_external/lib/Controller/UserGlobalStoragesController.php +++ b/apps/files_external/lib/Controller/UserGlobalStoragesController.php @@ -83,7 +83,9 @@ public function __construct( * @NoAdminRequired */ public function index() { - $storages = $this->service->getUniqueStorages(); + $service = $this->service; + '@phan-var \OCP\Files\External\Service\IUserGlobalStoragesService $service'; + $storages = $service->getUniqueStorages(); // remove configuration data, this must be kept private foreach ($storages as $storage) { @@ -158,6 +160,7 @@ public function update( $authMechanism = $storage->getAuthMechanism(); if ($authMechanism instanceof IUserProvided) { $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); + '@phan-var \OCP\Files\External\Auth\AuthMechanism $authMechanism'; $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); } else { return new DataResponse( diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 1f91d5943994..0586a60f382f 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -309,6 +309,7 @@ public function rename($source, $target) { private function removeFromCache($path) { $path = \trim($path, '/'); // TODO The CappedCache does not really clear by prefix. It just clears all. + '@phan-var \OC\Cache\CappedMemoryCache $this->statCache'; $this->statCache->clear($path); } /** diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php index 86d205a12ab4..b636d9cc3833 100644 --- a/apps/files_sharing/ajax/external.php +++ b/apps/files_sharing/ajax/external.php @@ -89,6 +89,7 @@ * @var \OCA\Files_Sharing\External\Storage $storage */ $storage = $mount->getStorage(); +'@phan-var \OCA\Files_Sharing\External\Storage $storage'; try { // check if storage exists $storage->checkStorageAvailability(); diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php index c49d1fe2ee48..fc5f3910ce0e 100644 --- a/apps/files_sharing/lib/Scanner.php +++ b/apps/files_sharing/lib/Scanner.php @@ -46,6 +46,7 @@ public function getData($path) { if ($data === null) { return null; } + '@phan-var \OC\Files\Storage\Storage $this->storage'; list($sourceStorage, $internalPath) = $this->storage->resolvePath($path); $data['permissions'] = $sourceStorage->getPermissions($internalPath); return $data; @@ -57,6 +58,7 @@ private function getSourceScanner() { } if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { /** @var \OC\Files\Storage\Storage $storage */ + '@phan-var \OC\Files\Storage\Storage $this->storage'; list($storage) = $this->storage->resolvePath(''); $this->sourceScanner = $storage->getScanner(); return $this->sourceScanner; @@ -73,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 { @@ -88,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 { diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index c74815179adf..93f7158523f1 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -202,6 +202,7 @@ public function isTargetAllowed($target) { $shareManager = \OC::$server->getShareManager(); // FIXME: make it stop earlier in '/$userId/files' while ($targetNode !== null && $targetNode->getPath() !== '/') { + '@phan-var \OC\Share20\Manager $shareManager'; $shares = $shareManager->getSharesByPath($targetNode); foreach ($shares as $share) { @@ -231,6 +232,7 @@ public function moveMount($target) { } $relTargetPath = $this->stripUserFilesPath($target); + /* @phan-suppress-next-line PhanUndeclaredMethod */ $share = $this->getStorage()->getShare(); $result = true; @@ -238,6 +240,7 @@ public function moveMount($target) { try { $this->updateFileTarget($relTargetPath, $share); $this->setMountPoint($target); + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->getStorage()->setMountPoint($relTargetPath); } catch (\Exception $e) { \OCP\Util::writeLog('files_sharing', @@ -257,6 +260,7 @@ public function removeMount() { $mountManager = \OC\Files\Filesystem::getMountManager(); /** @var $storage \OCA\Files_Sharing\SharedStorage */ $storage = $this->getStorage(); + '@phan-var \OCA\Files_Sharing\SharedStorage $storage'; $result = $storage->unshareStorage(); $mountManager->removeMount($this->mountPoint); diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 9743a3afe22d..e762385cd0c9 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -462,8 +462,13 @@ public function getLocks($internalPath, $returnChildLocks = false) { $locks = parent::getLocks($this->getSourcePath($internalPath), $returnChildLocks); return \array_map(function (ILock $lock) { // TODO: if path starts with rootpath + /* @phan-suppress-next-line PhanUndeclaredMethod */ $mountedPath = \substr($lock->getPath(), \strlen($this->rootPath)+1); + // FixMe: setDavUserId does not seem to exist anywhere + /* @phan-suppress-next-line PhanUndeclaredMethod */ $lock->setDavUserId($this->user); + // FixMe: setAbsoluteDavPath does not seem to exist anywhere + /* @phan-suppress-next-line PhanUndeclaredMethod */ $lock->setAbsoluteDavPath($this->getMountPoint() . '/' .$mountedPath); return $lock; }, $locks); diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 69e9f3c80db7..1f6740209a17 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -102,6 +102,7 @@ private static function renameChildren($oldPath, $newPath) { if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) { $mountPoint = $mount->getMountPoint(); $target = \str_replace($absOldPath, $absNewPath, $mountPoint); + '@phan-var \OCA\Files_Sharing\SharedMount $mount'; $mount->moveMount($target); } } diff --git a/apps/files_sharing/lib/ViewOnly.php b/apps/files_sharing/lib/ViewOnly.php index 58ff2e7f2b47..f1ae258e5986 100644 --- a/apps/files_sharing/lib/ViewOnly.php +++ b/apps/files_sharing/lib/ViewOnly.php @@ -103,6 +103,7 @@ private function checkFileInfo(Node $fileInfo) { // Extract extra permissions /** @var \OCA\Files_Sharing\SharedStorage $storage */ + '@phan-var \OCA\Files_Sharing\SharedStorage $storage'; $share = $storage->getShare(); // Check if read-only and on whether permission can download is both set and disabled. diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php index bc23f934c4c3..69b7616f6c6a 100644 --- a/apps/files_trashbin/ajax/preview.php +++ b/apps/files_trashbin/ajax/preview.php @@ -51,8 +51,10 @@ $userFolder = \OC::$server->getRootFolder()->getUserFolder(\OC_User::getUser()); /** @var \OCP\Files\Folder $trashFolder */ $trashFolder = $userFolder->getParent()->get('files_trashbin/files'); + '@phan-var \OCP\Files\Folder $trashFolder'; /** @var \OCP\Files\File | \OCP\Files\IPreviewNode $file */ $fileNode = $trashFolder->get($file); + '@phan-var \OCP\Files\FileInfo | \OCP\Files\IPreviewNode $fileNode'; if ($fileNode->getType() === \OCP\Files\FileInfo::TYPE_FOLDER) { $mimetype = 'httpd/unix-directory'; diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php index 116a7f3ea10f..a3a6b1582bec 100644 --- a/apps/files_trashbin/lib/Storage.php +++ b/apps/files_trashbin/lib/Storage.php @@ -73,6 +73,7 @@ public static function preRenameHook($params) { $sourceInternalPath = $mount1->getInternalPath($absolutePath1); // check whether this is a cross-storage move from a *local* shared storage if ($sourceInternalPath !== '' && $sourceStorage !== $targetStorage && $sourceStorage->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) { + '@phan-var \OCA\Files_Sharing\SharedStorage $sourceStorage'; $ownerPath = $sourceStorage->getSourcePath($sourceInternalPath); $owner = $sourceStorage->getOwner($sourceInternalPath); if ($owner !== null && $owner !== '' && $ownerPath !== null && \substr($ownerPath, 0, 6) === 'files/') { diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 0ce3f268e6d1..0093f4ab9054 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -392,6 +392,7 @@ private static function retainVersions($filename, $owner, $ownerPath, $timestamp * deleted due to move operation to trashbin. */ if ($sourceStorage !== null) { + '@phan-var \OCA\Files_Trashbin\Storage $sourceStorage'; $copyKeysResult = $sourceStorage->retainKeys($filename, $owner, $ownerPath, $timestamp, $sourceStorage); } @@ -1073,6 +1074,7 @@ public static function registerHooks() { public function resolvePrivateLink($uid, $fileId) { if ($this->rootFolder->nodeExists($uid . '/files_trashbin/files/')) { $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); + '@phan-var \OCP\Files\Folder $baseFolder'; $files = $baseFolder->getById($fileId); if (!empty($files)) { $params['view'] = 'trashbin'; diff --git a/apps/provisioning_api/lib/Groups.php b/apps/provisioning_api/lib/Groups.php index f71ccc10aa22..f5dcbea79431 100644 --- a/apps/provisioning_api/lib/Groups.php +++ b/apps/provisioning_api/lib/Groups.php @@ -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); } @@ -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 = []; diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index 6f9fd3e8b8a2..01741fae147a 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -200,6 +200,7 @@ protected function readPassword(InputInterface $input, OutputInterface $output) if ($input->isInteractive()) { /** @var $dialog \Symfony\Component\Console\Helper\QuestionHelper */ $dialog = $this->getHelperSet()->get('question'); + '@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; $q = new Question('Enter a password to access a target database: ', false); $q->setHidden(true); $password = $dialog->ask($input, $output, $q); @@ -248,6 +249,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { } /** @var $dialog \Symfony\Component\Console\Helper\QuestionHelper */ $dialog = $this->getHelperSet()->get('question'); + '@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; $continue = $dialog->ask($input, $output, new Question('Continue with the conversion (y/n)? [n] ', false)); if ($continue !== 'y') { return; diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index ef82e0e89b85..1ca2248c9f1d 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -136,6 +136,7 @@ protected function validateInput(InputInterface $input, OutputInterface $output, if ($dbPass === null) { /** @var $dialog \Symfony\Component\Console\Helper\QuestionHelper */ $dialog = $this->getHelperSet()->get('question'); + '@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; $q = new Question("What is the password to access the database with user <$dbUser>?", false); $q->setHidden(true); $dbPass = $dialog->ask($input, $output, $q); @@ -145,6 +146,7 @@ protected function validateInput(InputInterface $input, OutputInterface $output, if ($adminPassword === null) { /** @var $dialog \Symfony\Component\Console\Helper\QuestionHelper */ $dialog = $this->getHelperSet()->get('question'); + '@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; $q = new Question("What is the password you like to use for the admin account <$adminLogin>?", false); $q->setHidden(true); $adminPassword = $dialog->ask($input, $output, $q); diff --git a/core/Command/Maintenance/Mimetype/UpdateDB.php b/core/Command/Maintenance/Mimetype/UpdateDB.php index 9dd82601bb27..bc4869d00bce 100644 --- a/core/Command/Maintenance/Mimetype/UpdateDB.php +++ b/core/Command/Maintenance/Mimetype/UpdateDB.php @@ -61,6 +61,7 @@ protected function configure() { } protected function execute(InputInterface $input, OutputInterface $output) { + '@phan-var \OC\Files\MimetypeDetector $this->mimetypeDetector'; $mappings = $this->mimetypeDetector->getAllMappings(); $totalFilecacheUpdates = 0; @@ -82,6 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { } if (!$existing || $input->getOption('repair-filecache')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $touchedFilecacheRows = $this->mimetypeLoader->updateFilecache($ext, $mimetypeId); if ($touchedFilecacheRows > 0) { $output->writeln('Updated '.$touchedFilecacheRows.' filecache rows for mimetype "'.$mimetype.'"'); diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index d70019618bf5..4a3d9665fc1f 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -117,6 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { } elseif (($email === '') && $input->isInteractive()) { /** @var $dialog \Symfony\Component\Console\Helper\QuestionHelper */ $dialog = $this->getHelperSet()->get('question'); + '@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; $q = new Question('Enter password: ', false); $q->setHidden(true); $password = $dialog->ask($input, $output, $q); diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index c7b4c53836d4..b8c69dec4df1 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -144,6 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { } elseif ($input->isInteractive()) { /** @var $dialog \Symfony\Component\Console\Helper\QuestionHelper */ $dialog = $this->getHelperSet()->get('question'); + '@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; if (\OCP\App::isEnabled('encryption')) { $output->writeln( diff --git a/core/Command/User/SyncBackend.php b/core/Command/User/SyncBackend.php index ae92a6853333..0aa093edbaa4 100644 --- a/core/Command/User/SyncBackend.php +++ b/core/Command/User/SyncBackend.php @@ -220,6 +220,7 @@ private function syncMultipleUsers( $p = new ProgressBar($output); $max = null; if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS) && $input->getOption('showCount')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $max = $backend->countUsers(); } $p->start($max); diff --git a/core/js/config.php b/core/js/config.php index 8c20c08ac238..a176f4991f88 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -80,6 +80,9 @@ $dataLocation = false; } +$previewManager = \OC::$server->getPreviewManager(); +'@phan-var \OC\PreviewManager $previewManager'; + $array = [ "oc_debug" => $config->getSystemValue('debug', false) ? 'true' : 'false', "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false', @@ -174,7 +177,7 @@ 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(), 'previewsEnabled' => \OC::$server->getConfig()->getSystemValue('enable_previews', true) === true, - 'enabledPreviewProviders' => \OC::$server->getPreviewManager()->getSupportedMimes() + 'enabledPreviewProviders' => $previewManager->getSupportedMimes() ] ], "oc_defaults" => [ diff --git a/core/register_command.php b/core/register_command.php index 97c7ba9cf006..e9e2453c6a32 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -32,7 +32,8 @@ * */ -/** @var $application Symfony\Component\Console\Application */ +/** @var Symfony\Component\Console\Application $application */ +'@phan-var \Symfony\Component\Console\Application $application'; $application->add(new OC\Core\Command\Status); $application->add(new OC\Core\Command\Check(\OC::$server->getConfig())); $application->add(new OC\Core\Command\L10n\CreateJs()); diff --git a/lib/base.php b/lib/base.php index 36201b2f468d..92090b54ba91 100644 --- a/lib/base.php +++ b/lib/base.php @@ -398,6 +398,7 @@ private static function printUpgradePage() { /** @var \OC\App\AppManager $appManager */ $appManager = \OC::$server->getAppManager(); + '@phan-var \OC\App\AppManager $appManager'; $tmpl = new OC_Template('', 'update.admin', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); @@ -818,6 +819,7 @@ protected static function registerAutoloaderCache() { if ($instanceId) { try { $memcacheFactory = \OC::$server->getMemCacheFactory(); + '@phan-var \OC\MemCache\Factory $memcacheFactory'; self::$loader->setMemoryCache($memcacheFactory->createLocal('Autoloader')); } catch (\Exception $ex) { } diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index ac345bd7e603..54396545bede 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -115,6 +115,7 @@ public function __construct(IUserSession $userSession = null, // TODO we have no public API for this if (\method_exists($this->memCacheFactory, 'createLocal')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->appInfo = $this->memCacheFactory->createLocal('app-info'); } if ($this->appInfo === null || $this->appInfo instanceof NullCache) { diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 5bf9872130dc..ad00c931a307 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -66,6 +66,7 @@ public function __construct($appName, $urlParams = []) { /** @var \OC\ServerContainer $server */ $server = $this->getServer(); + '@phan-var \OC\ServerContainer $server'; $server->registerAppContainer($appName, $this); // aliases @@ -105,7 +106,9 @@ public function __construct($appName, $urlParams = []) { }); $this->registerService('OC\\CapabilitiesManager', function ($c) { - return $this->getServer()->getCapabilitiesManager(); + $server = $this->getServer(); + '@phan-var \OC\Server $server'; + return $server->getCapabilitiesManager(); }); $this->registerService('OCP\Comments\ICommentsManager', function ($c) { @@ -376,6 +379,8 @@ public function __construct($appName, $urlParams = []) { }); $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { + // ToDo: DIServer is in DIContainer and not in SimpleContainer + /* @phan-suppress-next-line PhanUndeclaredMethod */ $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); $userSession = $app->getServer()->getUserSession(); $urlGenerator = $app->getServer()->getURLGenerator(); diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index cdccba2b5d3c..cf596529c359 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -96,6 +96,7 @@ public function loadCommands(InputInterface $input, OutputInterface $output) { if (\OCP\Util::needUpgrade()) { throw new NeedsUpdateException(); } elseif ($this->config->getSystemValue('maintenance', false)) { + '@phan-var \Symfony\Component\Console\Output\ConsoleOutputInterface $output'; $errOutput = $output->getErrorOutput(); $errOutput->writeln('ownCloud is in maintenance mode - no app have been loaded' . PHP_EOL); } else { diff --git a/lib/private/DB/MySqlSchemaColumnDefinitionListener.php b/lib/private/DB/MySqlSchemaColumnDefinitionListener.php index 6dbcc8ddd9bd..091ed3cb6dba 100644 --- a/lib/private/DB/MySqlSchemaColumnDefinitionListener.php +++ b/lib/private/DB/MySqlSchemaColumnDefinitionListener.php @@ -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(); diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index 1a5aa60d6123..25270ef48c9e 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -198,6 +198,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = } } // Only update metadata that has changed + '@phan-var \OC\Files\Cache\CacheEntry $cacheData'; $newData = \array_diff_assoc($data, $cacheData->getData()); } else { $newData = $data; diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 74d13f964337..2c5948fcd730 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -191,6 +191,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { * remove all entries for files that are stored on the storage from the cache */ public function clear() { + '@phan-var \OC\Files\Cache\Cache $this->cache'; $this->cache->clear(); } @@ -270,6 +271,7 @@ public function calculateFolderSize($path, $entry = null) { * @return int[] */ public function getAll() { + '@phan-var \OC\Files\Cache\Cache $this->cache'; return $this->cache->getAll(); } diff --git a/lib/private/Files/Config/LazyStorageMountInfo.php b/lib/private/Files/Config/LazyStorageMountInfo.php index d5f35a5e456e..8019cb942195 100644 --- a/lib/private/Files/Config/LazyStorageMountInfo.php +++ b/lib/private/Files/Config/LazyStorageMountInfo.php @@ -47,6 +47,7 @@ public function __construct(IUser $user, IMountPoint $mount) { public function getStorageId() { if (!$this->storageId) { if (\method_exists($this->mount, 'getStorageNumericId')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->storageId = $this->mount->getStorageNumericId(); } else { $storage = $this->mount->getStorage(); diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index f6308eb4d7fb..5e9444d264fa 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -94,6 +94,7 @@ public function getMountsForUser(IUser $user) { new View('/' . $user->getUID() . '/files'), $takenMountpoints ); + /* @phan-suppress-next-line PhanUndeclaredMethod */ if ($mount->moveMount($newMountpoint)) { $fsMountManager = Filesystem::getMountManager(); if ($fsMountManager->findIn($mountpoint)) { diff --git a/lib/private/Files/External/ConfigAdapter.php b/lib/private/Files/External/ConfigAdapter.php index 2ebf2e1cbe2a..0bdc538382a8 100644 --- a/lib/private/Files/External/ConfigAdapter.php +++ b/lib/private/Files/External/ConfigAdapter.php @@ -125,7 +125,10 @@ private function constructStorage(IStorageConfig $storageConfig) { public function getMountsForUser(IUser $user, IStorageFactory $loader) { $mounts = []; + // setUser is in UserTrait. + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->userStoragesService->setUser($user); + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->userGlobalStoragesService->setUser($user); foreach ($this->userGlobalStoragesService->getUniqueStorages() as $storage) { @@ -174,7 +177,10 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) { $mounts[$storage->getMountPoint()] = $mount; } + // resetUser is in UserTrait. + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->userStoragesService->resetUser(); + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->userGlobalStoragesService->resetUser(); return $mounts; diff --git a/lib/private/Files/External/LegacyUtil.php b/lib/private/Files/External/LegacyUtil.php index 49b384177266..af23885dee13 100644 --- a/lib/private/Files/External/LegacyUtil.php +++ b/lib/private/Files/External/LegacyUtil.php @@ -55,7 +55,9 @@ public static function getAbsoluteMountPoints($uid) { $mountPoints = []; $userGlobalStoragesService = \OC::$server->getUserGlobalStoragesService(); + '@phan-var \OC\Files\External\Service\UserGlobalStoragesService $userGlobalStoragesService'; $userStoragesService = \OC::$server->getUserStoragesService(); + '@phan-var \OC\Files\External\Service\UserStoragesService $userStoragesService'; $user = \OC::$server->getUserManager()->get($uid); $userGlobalStoragesService->setUser($user); diff --git a/lib/private/Files/External/Service/StoragesService.php b/lib/private/Files/External/Service/StoragesService.php index 46e045159f10..5e6ffdb1e753 100644 --- a/lib/private/Files/External/Service/StoragesService.php +++ b/lib/private/Files/External/Service/StoragesService.php @@ -396,8 +396,9 @@ public function updateStorage(IStorageConfig $updatedStorage) { $oldStorage = $this->getStorageConfigFromDBMount($existingMount); - if ($oldStorage->getBackend() instanceof InvalidBackend) { - throw new NotFoundException('Storage config with id "' . $id . '" and backend id "' . $oldStorage->getBackend()->getInvalidId() . '" cannot be edited due to missing backend'); + $oldStorageBackend = $oldStorage->getBackend(); + if ($oldStorageBackend instanceof InvalidBackend) { + throw new NotFoundException('Storage config with id "' . $id . '" and backend id "' . $oldStorageBackend->getInvalidId() . '" cannot be edited due to missing backend'); } $removedUsers = \array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers()); @@ -539,6 +540,7 @@ private function getStorageId(IStorageConfig $storageConfig) { // auth mechanism should fire first $storage = $storageConfig->getBackend()->wrapStorage($storage); $storage = $storageConfig->getAuthMechanism()->wrapStorage($storage); + '@phan-var \OC\Files\Storage\Storage $storage'; return $storage->getStorageCache()->getNumericId(); } catch (\Exception $e) { diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index 279925cff199..ec7b2515c150 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -432,6 +432,7 @@ public static function initMountPoints($user = '') { /** @var \OC\Files\Config\MountProviderCollection $mountConfigManager */ $mountConfigManager = \OC::$server->getMountProviderCollection(); + '@phan-var \OC\Files\Config\MountProviderCollection $mountConfigManager'; // home mounts are handled seperate since we need to ensure this is mounted before we call the other mount providers $homeMount = $mountConfigManager->getHomeMountForUser($userObject); diff --git a/lib/private/Files/Meta/MetaVersionCollection.php b/lib/private/Files/Meta/MetaVersionCollection.php index b14d15fd80da..9d38e17d5e6c 100644 --- a/lib/private/Files/Meta/MetaVersionCollection.php +++ b/lib/private/Files/Meta/MetaVersionCollection.php @@ -75,6 +75,7 @@ public function getDirectoryListing() { return []; } /** @var IVersionedStorage | Storage $storage */ + '@phan-var IVersionedStorage | Storage $storage'; $versions = $storage->getVersions($internalPath); return \array_values(\array_map(function ($version) use ($storage, $node, $internalPath) { if (!isset($version['mimetype'])) { @@ -102,6 +103,7 @@ public function get($path) { throw new NotFoundException(); } /** @var IVersionedStorage | Storage $storage */ + '@phan-var IVersionedStorage | Storage $storage'; $version = $storage->getVersion($internalPath, $versionId); if ($version === null) { throw new NotFoundException(); diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index ef2f78f3901f..8dccd4d4439f 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -95,6 +95,9 @@ public function __construct($storage, $mountpoint, $arguments = null, $loader = // FIXME: this should also check for IStorage, and the public Storage interface if ($storage instanceof Storage) { $this->class = \get_class($storage); + // IStorageFactory does not have wrap + // But StorageFactory does have wrap + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->storage = $this->loader->wrap($this, $storage); } else { // Update old classes to new namespace diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index b5d02b26f307..6882194f4088 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -168,6 +168,8 @@ public function getMountByNumericStorageId($numericId) { * @param \OC\Files\Mount\MountPoint $mount */ public function unMount($mount) { + // ToDo: why doesn't this call removeMount ? + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->mountManager->remove($mount); } @@ -367,6 +369,7 @@ public function getUserFolder($userId) { try { $folder = $folder->get($dir); } catch (NotFoundException $e) { + '@phan-var \OC\Files\Node\Folder $folder'; $folder = $folder->newFolder($dir); } diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 300a49a66953..4be1ee5c880b 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -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); } diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 5d18b9b6bfdc..0a0d8fbaa137 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -196,6 +196,8 @@ public function opendir($path) { $this->init(); $path = $this->cleanPath($path); try { + // client propfind is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $response = $this->client->propfind( $this->encodePath($path), [], @@ -253,6 +255,8 @@ protected function propfind($path) { if ($cachedResponse === null || $cachedResponse === true) { $this->init(); try { + // client propfind is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $response = $this->client->propfind( $this->encodePath($path), [ @@ -426,6 +430,8 @@ public function free_space($path) { $path = $this->cleanPath($path); try { // TODO: cacheable ? + // client propfind is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $response = $this->client->propfind($this->encodePath($path), ['{DAV:}quota-available-bytes']); if ($response === false) { return FileInfo::SPACE_UNKNOWN; @@ -452,8 +458,12 @@ public function touch($path, $mtime = null) { if ($this->file_exists($path)) { try { $this->statCache->remove($path); + // client proppatch is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->client->proppatch($this->encodePath($path), ['{DAV:}lastmodified' => $mtime]); // non-owncloud clients might not have accepted the property, need to recheck it + // client propfind is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $response = $this->client->propfind($this->encodePath($path), ['{DAV:}getlastmodified'], 0); if ($response === false) { // file disappeared since ? @@ -530,6 +540,8 @@ public function rename($path1, $path2) { // needs trailing slash in destination $path2 = \rtrim($path2, '/') . '/'; } + // client request is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->client->request( 'MOVE', $this->encodePath($path1), @@ -562,6 +574,8 @@ public function copy($path1, $path2) { // needs trailing slash in destination $path2 = \rtrim($path2, '/') . '/'; } + // client request is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $this->client->request( 'COPY', $this->encodePath($path1), @@ -659,6 +673,8 @@ private function encodePath($path) { private function simpleResponse($method, $path, $body, $expected) { $path = $this->cleanPath($path); try { + // client request is in \OC\HTTP\Client + /* @phan-suppress-next-line PhanUndeclaredMethod */ $response = $this->client->request($method, $this->encodePath($path), $body); return $response['statusCode'] == $expected; } catch (ClientHttpException $e) { diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 16009a66a0e8..d5ae0e3794bc 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -445,6 +445,7 @@ public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceIntern * @var \OC\Files\Storage\Local $sourceStorage */ $rootStorage = new Local(['datadir' => '/']); + '@phan-var \OC\Files\Storage\Local $sourceStorage'; return $rootStorage->copy($sourceStorage->getSourcePath($sourceInternalPath), $this->getSourcePath($targetInternalPath)); } diff --git a/lib/private/Files/Storage/LocalTempFileTrait.php b/lib/private/Files/Storage/LocalTempFileTrait.php index 0826035a1125..ccad0b8afd95 100644 --- a/lib/private/Files/Storage/LocalTempFileTrait.php +++ b/lib/private/Files/Storage/LocalTempFileTrait.php @@ -62,6 +62,7 @@ protected function removeCachedFile($path) { * @return string */ protected function toTmpFile($path) { //no longer in the storage api, still useful here + '@phan-var \OC\Files\Storage\Common $this'; $source = $this->fopen($path, 'r'); if (!$source) { return false; diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 99b2a04ab852..3aebe7476f00 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -403,6 +403,7 @@ public function free_space($path) { * @return array */ public function search($query) { + '@phan-var \OC\Files\Storage\Common $this->storage'; return $this->storage->search($query); } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 7ea225660f50..5d3fda9bb2c2 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -145,6 +145,7 @@ public function filesize($path) { $size = $this->unencryptedSize[$fullPath]; // update file cache if ($info instanceof ICacheEntry) { + '@phan-var \OC\Files\Cache\CacheEntry $info'; $info = $info->getData(); $info['encrypted'] = $info['encryptedVersion']; } else { diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index dc4e23fa6d46..ef0a4237552e 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -335,7 +335,9 @@ public function free_space($path) { * @return array */ public function search($query) { - return $this->getWrapperStorage()->search($query); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->search($query); } /** @@ -508,7 +510,9 @@ public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceIntern * @since 10.0.9 */ public function getContentOfVersion($internalPath, $versionId) { - return $this->getWrapperStorage()->getContentOfVersion($this->getSourcePath($internalPath), $versionId); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->getContentOfVersion($this->getSourcePath($internalPath), $versionId); } /** @@ -520,7 +524,9 @@ public function getContentOfVersion($internalPath, $versionId) { * @since 10.0.9 */ public function restoreVersion($internalPath, $versionId) { - return $this->getWrapperStorage()->restoreVersion($this->getSourcePath($internalPath), $versionId); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->restoreVersion($this->getSourcePath($internalPath), $versionId); } /** @@ -531,7 +537,9 @@ public function restoreVersion($internalPath, $versionId) { * @since 10.0.9 */ public function saveVersion($internalPath) { - return $this->getWrapperStorage()->saveVersion($this->getSourcePath($internalPath)); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->saveVersion($this->getSourcePath($internalPath)); } /** @@ -542,7 +550,9 @@ public function saveVersion($internalPath) { * @since 10.0.9 */ public function getVersions($internalPath) { - return $this->getWrapperStorage()->getVersions($this->getSourcePath($internalPath)); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->getVersions($this->getSourcePath($internalPath)); } /** @@ -554,6 +564,8 @@ public function getVersions($internalPath) { * @since 10.0.9 */ public function getVersion($internalPath, $versionId) { - return $this->getWrapperStorage()->getVersion($this->getSourcePath($internalPath), $versionId); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->getVersion($this->getSourcePath($internalPath), $versionId); } } diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 4fc36c54f7c1..11d2259ffe94 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -336,7 +336,9 @@ public function free_space($path) { * @return array */ public function search($query) { - return $this->getWrapperStorage()->search($query); + $wrapperStorage = $this->getWrapperStorage(); + '@phan-var \OC\Files\Storage\Common $wrapperStorage'; + return $wrapperStorage->search($query); } /** @@ -618,6 +620,7 @@ public function changeLock($path, $type, ILockingProvider $provider) { public function lockNodePersistent($internalPath, array $lockInfo) { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IPersistentLockingStorage::class)) { + '@phan-var \OCP\Files\Storage\IPersistentLockingStorage $storage'; return $storage->lockNodePersistent($internalPath, $lockInfo); } return false; @@ -626,6 +629,7 @@ public function lockNodePersistent($internalPath, array $lockInfo) { public function unlockNodePersistent($internalPath, array $lockInfo) { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IPersistentLockingStorage::class)) { + '@phan-var \OCP\Files\Storage\IPersistentLockingStorage $storage'; $storage->unlockNodePersistent($internalPath, $lockInfo); } } @@ -633,6 +637,7 @@ public function unlockNodePersistent($internalPath, array $lockInfo) { public function getLocks($internalPath, $returnChildLocks = false) { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IPersistentLockingStorage::class)) { + '@phan-var \OCP\Files\Storage\IPersistentLockingStorage $storage'; return $storage->getLocks($internalPath, $returnChildLocks); } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 1e83fc074023..d77646fff703 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -391,6 +391,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); } @@ -836,6 +838,7 @@ public function rename($path1, $path2) { /** * @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1 */ + '@phan-var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1'; $sourceMountPoint = $mount1->getMountPoint(); $result = $mount1->moveMount($absolutePath2); $manager->moveMount($sourceMountPoint, $mount1->getMountPoint()); diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index 4486bdb22938..73e28073c386 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -177,6 +177,7 @@ protected function getGroupObject($gid, $displayName = null) { $backends = []; foreach ($this->backends as $backend) { if ($backend->implementsActions(\OC\Group\Backend::GROUP_DETAILS)) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $groupData = $backend->getGroupDetails($gid); if (\is_array($groupData)) { // take the display name from the first backend that has a non-null one @@ -218,6 +219,7 @@ public function createGroup($gid) { $this->eventDispatcher->dispatch('group.preCreate', new GenericEvent(null, ['gid' => $gid])); foreach ($this->backends as $backend) { if ($backend->implementsActions(\OC\Group\Backend::CREATE_GROUP)) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $backend->createGroup($gid); $group = $this->getGroupObject($gid); $this->emit('\OC\Group', 'postCreate', [$group]); diff --git a/lib/private/Group/MetaData.php b/lib/private/Group/MetaData.php index 39907ed8f1c1..657e52765e69 100644 --- a/lib/private/Group/MetaData.php +++ b/lib/private/Group/MetaData.php @@ -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 = []; diff --git a/lib/private/Repair/Apps.php b/lib/private/Repair/Apps.php index 069c4289aa9f..aa5ea8ca9df7 100644 --- a/lib/private/Repair/Apps.php +++ b/lib/private/Repair/Apps.php @@ -368,6 +368,8 @@ private function fixMarketAppState(IOutput $output) { try { // Prepare oc_jobs for older ownCloud version fixes https://github.com/owncloud/update-testing/issues/5 $connection = \OC::$server->getDatabaseConnection(); + // IDBConnection does not have getPrefix, but Conection does + '@phan-var \OC\DB\Connection $connection'; $toSchema = $connection->createSchema(); $this->changeSchema($toSchema, ['tablePrefix' => $connection->getPrefix()]); $connection->migrateToSchema($toSchema); diff --git a/lib/private/Repair/InnoDB.php b/lib/private/Repair/InnoDB.php index e37a97ed3230..450df03bd83a 100644 --- a/lib/private/Repair/InnoDB.php +++ b/lib/private/Repair/InnoDB.php @@ -47,6 +47,8 @@ public function run(IOutput $output) { $tables = $this->getAllMyIsamTables($connection); if (\is_array($tables)) { foreach ($tables as $table) { + // On a MySqlPlatform we should have an exec method + /* @phan-suppress-next-line PhanUndeclaredMethod */ $connection->exec("ALTER TABLE $table ENGINE=InnoDB;"); $output->info("Fixed $table"); } diff --git a/lib/private/Repair/MoveAvatarIntoSubFolder.php b/lib/private/Repair/MoveAvatarIntoSubFolder.php index df27e288812a..73a5dd42c90c 100644 --- a/lib/private/Repair/MoveAvatarIntoSubFolder.php +++ b/lib/private/Repair/MoveAvatarIntoSubFolder.php @@ -128,6 +128,7 @@ private function moveAvatars(IOutput $out, IUser $user) { } catch (NotFoundException $e) { $oldAvatarFile = $this->rootFolder->get("{$brokenPath}/avatar.png"); } + '@phan-var \OC\Files\Node\File $oldAvatarFile'; $avatar->set($oldAvatarFile->getContent()); // Delete old avatars path only if it does not contain any other items diff --git a/lib/private/Repair/MoveAvatarOutsideHome.php b/lib/private/Repair/MoveAvatarOutsideHome.php index 4e87da46fa2c..efc8b2176bb6 100644 --- a/lib/private/Repair/MoveAvatarOutsideHome.php +++ b/lib/private/Repair/MoveAvatarOutsideHome.php @@ -118,11 +118,13 @@ private function moveAvatars(IOutput $out, IUser $user) { // call get instead of getUserFolder to avoid needless skeleton copy /** @var Folder $oldAvatarFolder */ $oldAvatarFolder = $this->rootFolder->get('/' . $userId . '/avatars/'); + '@phan-var \OCP\Files\Folder $oldAvatarFolder'; try { $oldAvatarFile = $oldAvatarFolder->get('/avatar.jpg'); } catch (NotFoundException $e) { $oldAvatarFile = $oldAvatarFolder->get('/avatar.png'); } + '@phan-var \OC\Files\Node\File $oldAvatarFile'; $newAvatarStorage = $this->rootFolder->get('/avatars/')->getStorage(); $avatar = new Avatar($newAvatarStorage, $this->l, $user, $this->logger); $avatar->set($oldAvatarFile->getContent()); diff --git a/lib/private/Repair/UpdateCertificateStore.php b/lib/private/Repair/UpdateCertificateStore.php index d74a42d7c328..89cac6758453 100644 --- a/lib/private/Repair/UpdateCertificateStore.php +++ b/lib/private/Repair/UpdateCertificateStore.php @@ -82,6 +82,10 @@ public function run(IOutput $out) { */ // Regenerate the certificates $certificateManager = $this->server->getCertificateManager($uid); + // ICertificateManager does not have createCertificateBundle + // But CertificateManager has createCertificateBundle + // ToDo: sort that out + '@phan-var \OC\Security\CertificateManager $certificateManager'; $certificateManager->createCertificateBundle(); } } diff --git a/lib/private/Server.php b/lib/private/Server.php index 7ea856b67ce5..b0af15835d4d 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -723,6 +723,7 @@ public function __construct($webRoot, \OC\Config $config) { if ($config->getSystemValue('filelocking.enabled', true) or (\defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { /** @var \OC\Memcache\Factory $memcacheFactory */ $memcacheFactory = $c->getMemCacheFactory(); + '@phan-var \OC\Memcache\Factory $memcacheFactory'; $memcache = $memcacheFactory->createLocking('lock'); if (!($memcache instanceof \OC\Memcache\NullCache)) { return new MemcacheLockingProvider($memcache, $ttl); diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 8bedba676ed3..a0b066278a28 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -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; @@ -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; diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 5c9ac03a52e2..46c30d96e13c 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -130,6 +130,7 @@ public function create(\OCP\Share\IShare $share) { } if (\method_exists($share, 'getParent')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $qb->setValue('parent', $qb->createNamedParameter($share->getParent())); } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 987966aeabf6..26c9f2e61c7e 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -583,7 +583,14 @@ protected function setLinkParent(\OCP\Share\IShare $share) { if (\method_exists($share, 'setParent')) { $storage = $share->getNode()->getStorage(); if ($storage->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { - $share->setParent($storage->getShareId()); + // ISharedStorage does not mention getShareId + // getShareId is in SharedStorage + // FixMe: need to be sure that we always have a SharedStorage + '@phan-var \OCA\Files_Sharing\SharedStorage $storage'; + $shareId = $storage->getShareId(); + // We know that setParent exists because we checked method_exists + /* @phan-suppress-next-line PhanUndeclaredMethod */ + $share->setParent($shareId); } }; } @@ -813,6 +820,10 @@ public function transferShare(IShare $share, $oldOwner, $newOwner, $finalTarget, $provider = $this->factory->getProviderForType($share->getShareType()); //Try to get the children transferred and then delete the parent + // IShareProvider does not have getChildren + // But DefaultShareProvider has getChildren and getChildren has a comment + // FIXME: remove once https://github.com/owncloud/core/pull/21660 is in + /* @phan-suppress-next-line PhanUndeclaredMethod */ foreach ($provider->getChildren($share) as $child) { $this->transferShare($child, $oldOwner, $newOwner, $finalTarget, true); } @@ -1012,6 +1023,10 @@ protected function deleteChildren(\OCP\Share\IShare $share) { $provider = $this->factory->getProviderForType($share->getShareType()); + // IShareProvider does not have getChildren + // But DefaultShareProvider has getChildren and getChildren has a comment + // FIXME: remove once https://github.com/owncloud/core/pull/21660 is in + /* @phan-suppress-next-line PhanUndeclaredMethod */ foreach ($provider->getChildren($share) as $child) { $deletedChildren = $this->deleteChildren($child); $deletedShares = \array_merge($deletedShares, $deletedChildren); @@ -1041,6 +1056,7 @@ protected static function formatUnshareHookParams(\OCP\Share\IShare $share) { 'itemSource' => $share->getNodeId(), 'shareType' => $shareType, 'shareWith' => $sharedWith, + /* @phan-suppress-next-line PhanUndeclaredMethod */ 'itemparent' => \method_exists($share, 'getParent') ? $share->getParent() : '', 'uidOwner' => $share->getSharedBy(), 'fileSource' => $share->getNodeId(), diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 18f7862cd8ef..71c1e50c69d7 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -57,6 +57,9 @@ public function __construct(IServerContainer $serverContainer) { */ protected function defaultShareProvider() { if ($this->defaultProvider === null) { + // serverContainer really has to be more than just an IServerContainer + // because getLazyRootFolder() is only in \OC\Server + '@phan-var \OC\Server $this->serverContainer'; $this->defaultProvider = new DefaultShareProvider( $this->serverContainer->getDatabaseConnection(), $this->serverContainer->getUserManager(), diff --git a/lib/private/SubAdmin.php b/lib/private/SubAdmin.php index 92f598bcb064..cb0b9963f0e5 100644 --- a/lib/private/SubAdmin.php +++ b/lib/private/SubAdmin.php @@ -53,7 +53,9 @@ class SubAdmin extends PublicEmitter { public function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConn) { + '@phan-var \OC\User\Manager $userManager'; $this->userManager = $userManager; + '@phan-var \OC\Group\Manager $groupManager'; $this->groupManager = $groupManager; $this->dbConn = $dbConn; diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 8c8bafe925c9..3e24b65d1d5f 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -249,6 +249,7 @@ public function checkPassword($loginName, $password) { foreach ($this->backends as $backend) { if ($backend->implementsActions(Backend::CHECK_PASSWORD)) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $uid = $backend->checkPassword($loginName, $password); if ($uid !== false) { $account = $this->syncService->createOrSyncAccount($uid, $backend); @@ -377,6 +378,7 @@ public function createUser($uid, $password) { foreach ($this->backends as $backend) { if ($backend->implementsActions(Backend::CREATE_USER)) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $backend->createUser($uid, $password); $user = $this->createUserFromBackend($uid, $password, $backend); return $user === null ? false : $user; diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 34d723d0b9b8..3d7be70c5a52 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -185,6 +185,7 @@ public function setDisplayName($displayName) { $backend = $this->account->getBackendInstance(); if ($backend->implementsActions(Backend::SET_DISPLAYNAME)) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ $backend->setDisplayName($this->account->getUserId(), $displayName); } @@ -305,6 +306,7 @@ public function setPassword($password, $recoveryPassword = null) { if ($this->canChangePassword()) { /** @var IChangePasswordBackend $backend */ $backend = $this->account->getBackendInstance(); + '@phan-var IChangePasswordBackend $backend'; $result = $backend->setPassword($this->getUID(), $password); if ($result) { if ($this->emitter) { @@ -355,6 +357,7 @@ public function canChangeAvatar() { return false; } if ($backend->implementsActions(Backend::PROVIDE_AVATAR)) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ return $backend->canChangeAvatar($this->getUID()); } return true; diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index ba8d4ba1ec78..028c1245f1da 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -612,6 +612,7 @@ public static function getAppVersion($appId) { public static function getAppInfo($appId, $path = false) { /** @var \OC\App\AppManager $am */ $am = \OC::$server->getAppManager(); + '@phan-var \OC\App\AppManager $am'; if ($path) { return $am->getAppInfoByPath($appId); } diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php index d57f87ff0e15..c6767b20556f 100644 --- a/lib/private/legacy/defaults.php +++ b/lib/private/legacy/defaults.php @@ -129,6 +129,7 @@ public function getSyncClientUrl() { */ public function getiOSClientUrl() { if ($this->themeExist('getiOSClientUrl')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ return $this->theme->getiOSClientUrl(); } else { return $this->defaultiOSClientUrl; @@ -141,6 +142,7 @@ public function getiOSClientUrl() { */ public function getiTunesAppId() { if ($this->themeExist('getiTunesAppId')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ return $this->theme->getiTunesAppId(); } else { return $this->defaultiTunesAppId; @@ -153,6 +155,7 @@ public function getiTunesAppId() { */ public function getAndroidClientUrl() { if ($this->themeExist('getAndroidClientUrl')) { + /* @phan-suppress-next-line PhanUndeclaredMethod */ return $this->theme->getAndroidClientUrl(); } else { return $this->defaultAndroidClientUrl; diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php index 98d02ca8398d..bd3439ddfc2f 100644 --- a/lib/private/legacy/files.php +++ b/lib/private/legacy/files.php @@ -175,6 +175,7 @@ public static function get($dir, $files, $params = null) { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); OC::$server->getLogger()->logException($ex); $l = \OC::$server->getL10N('core'); + /* @phan-suppress-next-line PhanUndeclaredMethod */ $hint = \method_exists($ex, 'getHint') ? $ex->getHint() : ''; \OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint); } catch (\OCP\Files\ForbiddenException $ex) { @@ -189,6 +190,7 @@ public static function get($dir, $files, $params = null) { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); OC::$server->getLogger()->logException($ex); $l = \OC::$server->getL10N('core'); + /* @phan-suppress-next-line PhanUndeclaredMethod */ $hint = \method_exists($ex, 'getHint') ? $ex->getHint() : ''; if ($event->hasArgument('message')) { $hint .= ' ' . $event->getArgument('message'); diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php index e1fda31de728..aed0d00c3b38 100644 --- a/lib/private/legacy/helper.php +++ b/lib/private/legacy/helper.php @@ -593,6 +593,7 @@ public static function getStorageInfo($path, $rootInfo = null) { $sourceStorage = $storage; if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { $includeExtStorage = false; + '@phan-var \OCA\Files_Sharing\SharedStorage $storage'; $sourceStorage = $storage->getSourceStorage(); } if ($includeExtStorage) { @@ -605,7 +606,8 @@ public static function getStorageInfo($path, $rootInfo = null) { // TODO: need a better way to get total space from storage if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')) { - /** @var \OC\Files\Storage\Wrapper\Quota $storage */ + /** @var \OC\Files\Storage\Wrapper\Quota $sourceStorage */ + '@phan-var \OC\Files\Storage\Wrapper\Quota $sourceStorage'; $quota = $sourceStorage->getQuota(); } $free = $sourceStorage->free_space(''); diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 9b74049fe922..440378c2f445 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -159,6 +159,7 @@ public static function setupFS($user = '') { \OC\Files\Filesystem::addStorageWrapper('mount_options', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { if ($storage->instanceOfStorage('\OC\Files\Storage\Common')) { /** @var \OC\Files\Storage\Common $storage */ + '@phan-var \OC\Files\Storage\Common $storage'; $storage->setMountOptions($mount->getOptions()); } return $storage; diff --git a/lib/public/AppFramework/OCSController.php b/lib/public/AppFramework/OCSController.php index 7a3a06c48036..75d4162b8e78 100644 --- a/lib/public/AppFramework/OCSController.php +++ b/lib/public/AppFramework/OCSController.php @@ -136,6 +136,7 @@ public function buildResponse($response, $format = 'json') { } /** @var OCSResponse $resp */ $resp = parent::buildResponse($response, $format); + '@phan-var \OCP\AppFramework\Http\OCSResponse $resp'; $script = $this->request->getScriptName(); if (\substr($script, -11) === '/ocs/v2.php') { diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php index b43264e088fd..24dbd19e2f63 100644 --- a/settings/Controller/UsersController.php +++ b/settings/Controller/UsersController.php @@ -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(); @@ -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) { @@ -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 @@ -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( [ @@ -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)) { @@ -927,6 +936,7 @@ public function stats() { } } } else { + '@phan-var \OC\Group\Manager $this->groupManager'; $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser()); $uniqueUsers = []; @@ -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() || @@ -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)) || @@ -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 && diff --git a/vendor-bin/phan/composer.json b/vendor-bin/phan/composer.json index 883fcd7ea6f5..ded450e98a95 100644 --- a/vendor-bin/phan/composer.json +++ b/vendor-bin/phan/composer.json @@ -1,5 +1,5 @@ { "require": { - "phan/phan": "0.12.11" + "phan/phan": "^1.3" } }