From 67b44e3c9091f1e5968f032a2473d758247db0bd Mon Sep 17 00:00:00 2001
From: Joas Schilling <coding@schilljs.com>
Date: Mon, 26 Sep 2022 20:23:20 +0200
Subject: [PATCH 1/2] Migrate to nextcloud/OCP package in stable24

Signed-off-by: Joas Schilling <coding@schilljs.com>
---
 .github/workflows/psalm.yml                | 30 ++++++++
 .github/workflows/static-analysis.yml      | 27 -------
 .github/workflows/update-nextcloud-ocp.yml | 65 ++++++++++++++++
 composer.json                              | 61 ++++++++-------
 composer.lock                              | 87 +++++++++++-----------
 5 files changed, 173 insertions(+), 97 deletions(-)
 create mode 100644 .github/workflows/psalm.yml
 delete mode 100644 .github/workflows/static-analysis.yml
 create mode 100644 .github/workflows/update-nextcloud-ocp.yml

diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml
new file mode 100644
index 00000000000..ff271c1e716
--- /dev/null
+++ b/.github/workflows/psalm.yml
@@ -0,0 +1,30 @@
+name: Static analysis
+
+on:
+  pull_request:
+  push:
+    branches:
+      - master
+      - main
+      - stable*
+
+jobs:
+  static-analysis:
+    runs-on: ubuntu-latest
+
+    name: Nextcloud ${{ matrix.ocp-version }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Set up php
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: 7.4
+          coverage: none
+
+      - name: Install dependencies
+        run: composer i
+
+      - name: Run coding standards check
+        run: composer run psalm
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
deleted file mode 100644
index e2caf4ca3d9..00000000000
--- a/.github/workflows/static-analysis.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-name: Static analysis
-
-on: [pull_request]
-
-jobs:
-  static-psalm-analysis:
-      runs-on: ubuntu-latest
-      strategy:
-          matrix:
-              ocp-version: [ 'dev-stable24' ]
-              php-version: [ '7.4', '8.0', '8.1' ]
-      name: Nextcloud ${{ matrix.ocp-version }}
-      steps:
-          - name: Checkout
-            uses: actions/checkout@master
-          - name: Set up php
-            uses: shivammathur/setup-php@master
-            with:
-                php-version: ${{ matrix.php-version }}
-                tools: composer:v1
-                coverage: none
-          - name: Install dependencies
-            run: composer i
-          - name: Install dependencies
-            run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}
-          - name: Run coding standards check
-            run: composer run psalm
diff --git a/.github/workflows/update-nextcloud-ocp.yml b/.github/workflows/update-nextcloud-ocp.yml
new file mode 100644
index 00000000000..a396b6f875b
--- /dev/null
+++ b/.github/workflows/update-nextcloud-ocp.yml
@@ -0,0 +1,65 @@
+# This workflow is provided via the organization template repository
+#
+# https://github.com/nextcloud/.github
+# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
+
+name: Update nextcloud/ocp
+
+on:
+  workflow_dispatch:
+  schedule:
+    - cron: "5 4 * * 0"
+
+jobs:
+  update-nextcloud-ocp:
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        branches: ["master", "stable25", "stable24", "stable23"]
+
+    name: update-nextcloud-ocp-${{ matrix.branches }}
+
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          ref: ${{ matrix.branches }}
+          submodules: true
+
+      - name: Set up php7.4
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: 7.4
+          extensions: ctype,curl,dom,fileinfo,gd,intl,json,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
+          coverage: none
+
+      - name: Composer install
+        run: composer install
+
+      - name: Composer update nextcloud/ocp
+        run: composer require --dev nextcloud/ocp:dev-${{ matrix.branches }}
+        continue-on-error: true
+
+      - name: Reset checkout dirs
+        run: |
+          git clean -f 3rdparty
+          git clean -f vendor
+          git checkout 3rdparty vendor
+        continue-on-error: true
+
+      - name: Create Pull Request
+        uses: peter-evans/create-pull-request@v3
+        with:
+          token: ${{ secrets.COMMAND_BOT_PAT }}
+          commit-message: Update psalm baseline
+          committer: GitHub <noreply@github.com>
+          author: nextcloud-command <nextcloud-command@users.noreply.github.com>
+          signoff: true
+          branch: automated/noid/${{ matrix.branches }}-update-nextcloud-ocp
+          title: "[${{ matrix.branches }}] Update nextcloud/ocp dependency"
+          body: |
+            Auto-generated update of [nextcloud/ocp](https://github.com/nextcloud-deps/ocp/) dependency
+          labels: |
+            dependencies
+            3. to review
diff --git a/composer.json b/composer.json
index bacde0e1489..dbfca4a144e 100644
--- a/composer.json
+++ b/composer.json
@@ -1,30 +1,35 @@
 {
-    "name": "nextcloud/text",
-    "type": "project",
-    "require-dev": {
-        "roave/security-advisories": "dev-master",
-        "christophwurst/nextcloud": "dev-master",
-        "jakub-onderka/php-parallel-lint": "^1.0.0",
-        "nextcloud/coding-standard": "^1.0.0",
-        "psalm/phar": "^4.3",
-        "phpunit/phpunit": "^9.5",
-        "ext-mbstring": "*"
-    },
-    "license": "AGPLv3",
-    "authors": [
-        {
-            "name": "Julius Härtl",
-            "email": "jus@bitgrid.net"
-        }
-    ],
-    "require": {
-      "php": "^7.3|^8.0"
-    },
-    "scripts": {
-      "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
-      "cs:check": "php-cs-fixer fix --dry-run --diff",
-      "cs:fix": "php-cs-fixer fix",
-      "psalm": "psalm.phar",
-      "test:unit": "phpunit -c tests/phpunit.xml"
-    }
+	"name": "nextcloud/text",
+	"type": "project",
+	"require-dev": {
+		"roave/security-advisories": "dev-master",
+		"jakub-onderka/php-parallel-lint": "^1.0.0",
+		"nextcloud/coding-standard": "^1.0.0",
+		"psalm/phar": "^4.3",
+		"phpunit/phpunit": "^9.5",
+		"ext-mbstring": "*",
+		"nextcloud/ocp": "dev-stable24"
+	},
+	"license": "AGPLv3",
+	"authors": [
+		{
+			"name": "Julius Härtl",
+			"email": "jus@bitgrid.net"
+		}
+	],
+	"require": {
+		"php": "^7.3|^8.0"
+	},
+	"scripts": {
+		"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
+		"cs:check": "php-cs-fixer fix --dry-run --diff",
+		"cs:fix": "php-cs-fixer fix",
+		"psalm": "psalm.phar",
+		"test:unit": "phpunit -c tests/phpunit.xml"
+	},
+	"autoload-dev": {
+		"psr-4": {
+			"OCP\\": "vendor/nextcloud/ocp/OCP"
+		}
+	}
 }
diff --git a/composer.lock b/composer.lock
index 5dd55876d22..267727617ed 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,48 +4,9 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "f1e6d917d90ebc09298a5f9bf178784e",
+    "content-hash": "200a06cb2817192ec0fb40affcff1085",
     "packages": [],
     "packages-dev": [
-        {
-            "name": "christophwurst/nextcloud",
-            "version": "dev-master",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/ChristophWurst/nextcloud_composer.git",
-                "reference": "b802513b81fb8ef64a294e07ba458b7fa623aa36"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/b802513b81fb8ef64a294e07ba458b7fa623aa36",
-                "reference": "b802513b81fb8ef64a294e07ba458b7fa623aa36",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.4 || ~8.0 || ~8.1",
-                "psr/container": "^1.1.1",
-                "psr/event-dispatcher": "^1.0",
-                "psr/log": "^1.1"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "25.0.0-dev"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "AGPL-3.0-or-later"
-            ],
-            "authors": [
-                {
-                    "name": "Christoph Wurst",
-                    "email": "christoph@winzerhof-wurst.at"
-                }
-            ],
-            "description": "Composer package containing Nextcloud's public API (classes, interfaces)",
-            "time": "2022-06-08T01:58:16+00:00"
-        },
         {
             "name": "composer/pcre",
             "version": "3.0.0",
@@ -682,6 +643,48 @@
             "description": "Nextcloud coding standards for the php cs fixer",
             "time": "2021-11-10T08:44:10+00:00"
         },
+        {
+            "name": "nextcloud/ocp",
+            "version": "dev-stable24",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/nextcloud-deps/ocp.git",
+                "reference": "55af8ca3c8530d23aa1aecf4e149bea04fa47207"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/55af8ca3c8530d23aa1aecf4e149bea04fa47207",
+                "reference": "55af8ca3c8530d23aa1aecf4e149bea04fa47207",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.4 || ~8.0 || ~8.1",
+                "psr/container": "^1.1.1",
+                "psr/event-dispatcher": "^1.0",
+                "psr/log": "^1.1"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "24.0.0-dev"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "AGPL-3.0-or-later"
+            ],
+            "authors": [
+                {
+                    "name": "Christoph Wurst",
+                    "email": "christoph@winzerhof-wurst.at"
+                }
+            ],
+            "description": "Composer package containing Nextcloud's public API (classes, interfaces)",
+            "support": {
+                "source": "https://github.com/nextcloud-deps/ocp/tree/stable24"
+            },
+            "time": "2022-08-23T02:31:47+00:00"
+        },
         {
             "name": "nikic/php-parser",
             "version": "v4.14.0",
@@ -4542,7 +4545,7 @@
     "minimum-stability": "stable",
     "stability-flags": {
         "roave/security-advisories": 20,
-        "christophwurst/nextcloud": 20
+        "nextcloud/ocp": 20
     },
     "prefer-stable": false,
     "prefer-lowest": false,
@@ -4552,5 +4555,5 @@
     "platform-dev": {
         "ext-mbstring": "*"
     },
-    "plugin-api-version": "1.1.0"
+    "plugin-api-version": "2.3.0"
 }

From 21f0425be4d7d591b8b311867c1e7e4af14e9b4c Mon Sep 17 00:00:00 2001
From: Joas Schilling <coding@schilljs.com>
Date: Tue, 27 Sep 2022 07:55:09 +0200
Subject: [PATCH 2/2] More package rename

Signed-off-by: Joas Schilling <coding@schilljs.com>
---
 psalm.xml                | 2 +-
 tests/psalm-baseline.xml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/psalm.xml b/psalm.xml
index dbfd50a208c..b93ed82c3b2 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -10,7 +10,7 @@
         <directory name="lib" />
     </projectFiles>
     <extraFiles>
-        <directory name="vendor/christophwurst/nextcloud" />
+        <directory name="vendor/nextcloud/ocp" />
     </extraFiles>
     	<issueHandlers>
 		<UndefinedClass>
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
index 6f49585fda9..e915cf8190e 100644
--- a/tests/psalm-baseline.xml
+++ b/tests/psalm-baseline.xml
@@ -191,7 +191,7 @@
       <code>\OC\User\NoUserException</code>
     </UndefinedDocblockClass>
   </file>
-  <file src="vendor/christophwurst/nextcloud/OCP/BackgroundJob/TimedJob.php">
+  <file src="vendor/nextcloud/ocp/OCP/BackgroundJob/TimedJob.php">
     <ImplementedParamTypeMismatch occurrences="1">
       <code>$jobList</code>
     </ImplementedParamTypeMismatch>