Skip to content
Prev Previous commit
Next Next commit
Add a stubs file for Coordinator
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 15, 2022
commit c1b931a16c0de6df88de9171f0c65f35235dca77
15 changes: 0 additions & 15 deletions lib/Service/UserMigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ class UserMigrationService {
protected ContainerInterface $container;

// Allow use of the private Coordinator class here to get and run registered migrators
/**
* @psalm-suppress UndefinedClass
*/
protected Coordinator $coordinator;

public function __construct(
Expand All @@ -72,9 +69,6 @@ public function __construct(
ITempManager $tempManager,
IUserManager $userManager,
ContainerInterface $container,
/**
* @psalm-suppress UndefinedClass
*/
Coordinator $coordinator
) {
$this->root = $rootFolder;
Expand All @@ -83,9 +77,6 @@ public function __construct(
$this->tempManager = $tempManager;
$this->userManager = $userManager;
$this->container = $container;
/**
* @psalm-suppress UndefinedClass
*/
$this->coordinator = $coordinator;
}

Expand Down Expand Up @@ -136,9 +127,6 @@ public function export(IUser $user, ?OutputInterface $output = null): string {
);

// Run exports of registered migrators
/**
* @psalm-suppress UndefinedClass
*/
$context = $this->coordinator->getRegistrationContext();

if ($context !== null) {
Expand Down Expand Up @@ -169,9 +157,6 @@ public function import(string $path, ?OutputInterface $output = null): void {
$this->importFiles($user, $importSource, $output);

// Run imports of registered migrators
/**
* @psalm-suppress UndefinedClass
*/
$context = $this->coordinator->getRegistrationContext();

if ($context !== null) {
Expand Down
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<extraFiles>
<directory name="vendor" />
</extraFiles>
<stubs>
<file name="tests/stubs/stub.phpstub" preloadClasses="true"/>
</stubs>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
Expand Down
55 changes: 55 additions & 0 deletions tests/stubs/stub.phpstub
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Côme Chilliet <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

use OCP\UserMigration\IMigrator as IUserMigrator;

namespace OC\AppFramework\Bootstrap {
class Coordinator {
public function getRegistrationContext(): ?RegistrationContext {}
}

class RegistrationContext {
/**
* @return ServiceRegistration<IUserMigrator>[]
*/
public function getUserMigrators(): array {}
}

/**
* @psalm-immutable
* @template T
*/
class ServiceRegistration extends ARegistration {
/**
* @psalm-return class-string<T>
*/
public function getService(): string {}
}

/**
* @psalm-immutable
*/
abstract class ARegistration {
public function getAppId(): string {}
}
}