From e6664a6253f02fe8533fcb75da530f12b6ff568a Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Thu, 27 Aug 2026 17:22:55 +0200 Subject: [PATCH] fix: make FlowMigration project clients pass phpstan against manage-api ^10 CI on main has been red since c4ef6b4. #111 bumped the manage-api client to ^10, where getProject() and createProjectStorageToken() take int rather than string, and #113 added FlowMigration passing the project id through as a string. Both were green on their own; together they are not. Cast at the manage-api boundary rather than retyping the pipeline: projectId is a string all the way from the CLI input through BatchRunner, ProjectResult and the test fakes, and threading int through all of that is a bigger change than this bug warrants. The two remaining errors were $tokenInfo['token'] being mixed, since the token info is array. Pulled into a local with an is_string() assert, the same way the other commands in this repo narrow API responses, which also drops the duplicate array access. Co-Authored-By: Claude Opus 5 (1M context) --- .../Command/FlowMigration/ProjectClientsFactory.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Keboola/Console/Command/FlowMigration/ProjectClientsFactory.php b/src/Keboola/Console/Command/FlowMigration/ProjectClientsFactory.php index e335411..495ce9c 100644 --- a/src/Keboola/Console/Command/FlowMigration/ProjectClientsFactory.php +++ b/src/Keboola/Console/Command/FlowMigration/ProjectClientsFactory.php @@ -38,7 +38,7 @@ public function __construct(ManageClient $manageClient, string $connectionUrl, s */ public function getProject(string $projectId): array { - return $this->manageClient->getProject($projectId); + return $this->manageClient->getProject((int) $projectId); } public function createProjectClients(string $projectId): ProjectClients @@ -47,7 +47,7 @@ public function createProjectClients(string $projectId): ProjectClients // (with a runWithTokenId copied from the source trigger, i.e. another token) and // notification subscriptions, and a migration failing halfway through is worse than a // short-lived privileged token. Restricting this only risks the component missing something. - $tokenInfo = $this->manageClient->createProjectStorageToken($projectId, [ + $tokenInfo = $this->manageClient->createProjectStorageToken((int) $projectId, [ 'description' => self::TOKEN_DESCRIPTION, 'expiresIn' => self::TOKEN_EXPIRES_IN_SECONDS, 'canManageBuckets' => true, @@ -56,14 +56,17 @@ public function createProjectClients(string $projectId): ProjectClients 'canPurgeTrash' => true, ]); + $token = $tokenInfo['token']; + assert(is_string($token)); + $storageClient = new StorageClient([ 'url' => $this->connectionUrl, - 'token' => $tokenInfo['token'], + 'token' => $token, ]); return new ProjectClients( new Components($storageClient), - new JobQueueClient($this->queueApiUrl, $tokenInfo['token']) + new JobQueueClient($this->queueApiUrl, $token) ); } }