From a9b4e3bdd69e6ebd2738dff57cbfd7747301b058 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Wed, 28 Feb 2024 23:49:34 +0530 Subject: [PATCH] replace usage of enum with a class and update gh workflows gh workflows now check run the check on php 8.0 in addition to 8.1 and 8.2. Also, --no-cache option for psalm Signed-off-by: Anupam Kumar --- .github/workflows/lint-php-cs.yml | 2 +- .github/workflows/lint-php.yml | 2 +- .github/workflows/phpunit.yml | 2 +- .github/workflows/psalm.yml | 2 +- composer.json | 6 +- composer.lock | 194 +++++++++--------- lib/Command/Prompt.php | 14 +- lib/Service/LangRopeService.php | 9 +- .../ScopedContextChatProvider.php | 11 +- lib/Type/ScopeType.php | 28 +++ stubs/appapi-public-functions.php | 4 +- tests/bootstrap.php | 6 +- 12 files changed, 158 insertions(+), 122 deletions(-) create mode 100644 lib/Type/ScopeType.php diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml index f708ba0..869be32 100644 --- a/.github/workflows/lint-php-cs.yml +++ b/.github/workflows/lint-php-cs.yml @@ -45,7 +45,7 @@ jobs: strategy: matrix: - php-versions: [ "8.1", "8.2" ] + php-versions: [ "8.0", "8.1", "8.2" ] steps: - name: Checkout diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index b039b9a..24c7c8d 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -47,7 +47,7 @@ jobs: strategy: matrix: - php-versions: [ "8.1", "8.2" ] + php-versions: [ "8.0", "8.1", "8.2" ] name: php-lint diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index b1dd380..a0ee58b 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -33,7 +33,7 @@ jobs: # do not stop on another job's failure fail-fast: false matrix: - php-versions: [ "8.1", "8.2" ] + php-versions: [ '8.0', '8.1', '8.2' ] databases: ['sqlite'] server-versions: ['master'] diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 7bf9fda..cd7b4b9 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -30,7 +30,7 @@ jobs: strategy: matrix: - php-versions: [ '8.1', '8.2' ] + php-versions: [ '8.0', '8.1', '8.2' ] server-versions: [ 'dev-master', 'dev-stable28' ] fail-fast: false diff --git a/composer.json b/composer.json index a88e5da..74b9d70 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^8.1 || ^8.2" + "php": "^8.0 || ^8.1 || ^8.2" }, "require-dev": { "nextcloud/coding-standard": "^1.1", @@ -32,7 +32,7 @@ "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 --threads=1", + "psalm": "psalm.phar --threads=1 --no-cache", "psalm:update-baseline": "psalm.phar --threads=1 --update-baseline", "psalm:update-baseline:force": "psalm.phar --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml", "psalm:clear": "psalm.phar --clear-cache && psalm.phar --clear-global-cache", @@ -43,7 +43,7 @@ "optimize-autoloader": true, "classmap-authoritative": true, "platform": { - "php": "8.1" + "php": "8.0" } }, "autoload": { diff --git a/composer.lock b/composer.lock index 928856a..1bae7a7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,35 +4,35 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d14cc787257d1330ec3946fddb768a4a", + "content-hash": "c1a2f80751dce3989e8623a45a4b8567", "packages": [], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "2.0.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^11", + "doctrine/coding-standard": "^9 || ^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.9.4", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.27", - "vimeo/psalm": "^5.4" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" }, "type": "library", "autoload": { @@ -59,7 +59,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" }, "funding": [ { @@ -75,7 +75,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:23:10+00:00" + "time": "2022-12-30T00:15:36+00:00" }, { "name": "myclabs/deep-copy", @@ -138,16 +138,16 @@ }, { "name": "nextcloud/coding-standard", - "version": "v1.1.1", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "55def702fb9a37a219511e1d8c6fe8e37164c1fb" + "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/55def702fb9a37a219511e1d8c6fe8e37164c1fb", - "reference": "55def702fb9a37a219511e1d8c6fe8e37164c1fb", + "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", + "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", "shasum": "" }, "require": { @@ -173,9 +173,9 @@ "description": "Nextcloud coding standards for the php cs fixer", "support": { "issues": "https://github.com/nextcloud/coding-standard/issues", - "source": "https://github.com/nextcloud/coding-standard/tree/v1.1.1" + "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.1" }, - "time": "2023-06-01T12:05:01+00:00" + "time": "2024-02-01T14:54:37+00:00" }, { "name": "nextcloud/ocp", @@ -183,12 +183,12 @@ "source": { "type": "git", "url": "https://github.com/nextcloud-deps/ocp.git", - "reference": "b181e45adf657379da6f1cd453218a277cc5210a" + "reference": "439198343dcc5bce91a7ceeb981348df26529b71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/b181e45adf657379da6f1cd453218a277cc5210a", - "reference": "b181e45adf657379da6f1cd453218a277cc5210a", + "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/439198343dcc5bce91a7ceeb981348df26529b71", + "reference": "439198343dcc5bce91a7ceeb981348df26529b71", "shasum": "" }, "require": { @@ -220,20 +220,20 @@ "issues": "https://github.com/nextcloud-deps/ocp/issues", "source": "https://github.com/nextcloud-deps/ocp/tree/master" }, - "time": "2024-01-30T00:32:11+00:00" + "time": "2024-02-29T00:31:54+00:00" }, { "name": "nikic/php-parser", - "version": "v5.0.0", + "version": "v5.0.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc" + "reference": "2218c2252c874a4624ab2f613d86ac32d227bc69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc", - "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/2218c2252c874a4624ab2f613d86ac32d227bc69", + "reference": "2218c2252c874a4624ab2f613d86ac32d227bc69", "shasum": "" }, "require": { @@ -276,9 +276,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.1" }, - "time": "2024-01-07T17:17:35+00:00" + "time": "2024-02-21T19:24:10+00:00" }, { "name": "phar-io/manifest", @@ -764,16 +764,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.16", + "version": "9.6.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" + "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", - "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1a156980d78a6666721b7e8e8502fe210b587fcd", + "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd", "shasum": "" }, "require": { @@ -847,7 +847,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.17" }, "funding": [ { @@ -863,20 +863,20 @@ "type": "tidelift" } ], - "time": "2024-01-19T07:03:14+00:00" + "time": "2024-02-23T13:14:51+00:00" }, { "name": "psalm/phar", - "version": "5.21.0", + "version": "5.22.2", "source": { "type": "git", "url": "https://github.com/psalm/phar.git", - "reference": "c8d6ba1f9d64ce66da9cbbfe707dc272750693e9" + "reference": "380b34d2b19c5a48a201e6f84fab5388c5eced49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/psalm/phar/zipball/c8d6ba1f9d64ce66da9cbbfe707dc272750693e9", - "reference": "c8d6ba1f9d64ce66da9cbbfe707dc272750693e9", + "url": "https://api.github.com/repos/psalm/phar/zipball/380b34d2b19c5a48a201e6f84fab5388c5eced49", + "reference": "380b34d2b19c5a48a201e6f84fab5388c5eced49", "shasum": "" }, "require": { @@ -896,9 +896,9 @@ "description": "Composer-based Psalm Phar", "support": { "issues": "https://github.com/psalm/phar/issues", - "source": "https://github.com/psalm/phar/tree/5.21.0" + "source": "https://github.com/psalm/phar/tree/5.22.2" }, - "time": "2024-01-30T23:18:33+00:00" + "time": "2024-02-22T23:45:18+00:00" }, { "name": "psr/clock", @@ -1107,12 +1107,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "b1ef8f464be59fa15bf9b4956be3e17a75c4dd03" + "reference": "cca68bc8c5e35d0bc657c6c47bd40d28184abd87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/b1ef8f464be59fa15bf9b4956be3e17a75c4dd03", - "reference": "b1ef8f464be59fa15bf9b4956be3e17a75c4dd03", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/cca68bc8c5e35d0bc657c6c47bd40d28184abd87", + "reference": "cca68bc8c5e35d0bc657c6c47bd40d28184abd87", "shasum": "" }, "conflict": { @@ -1157,7 +1157,7 @@ "barrelstrength/sprout-forms": "<3.9", "barryvdh/laravel-translation-manager": "<0.6.2", "barzahlen/barzahlen-php": "<2.0.1", - "baserproject/basercms": "<4.8", + "baserproject/basercms": "<5.0.9", "bassjobsen/bootstrap-3-typeahead": ">4.0.2", "bigfork/silverstripe-form-capture": ">=3,<3.1.1", "billz/raspap-webgui": "<2.9.5", @@ -1166,12 +1166,13 @@ "bolt/bolt": "<3.7.2", "bolt/core": "<=4.2", "bottelet/flarepoint": "<2.2.1", + "bref/bref": "<2.1.13", "brightlocal/phpwhois": "<=4.2.5", "brotkrueml/codehighlight": "<2.7", "brotkrueml/schema": "<1.13.1|>=2,<2.5.1", "brotkrueml/typo3-matomo-integration": "<1.3.2", "buddypress/buddypress": "<7.2.1", - "bugsnag/bugsnag-laravel": "<2.0.2", + "bugsnag/bugsnag-laravel": ">=2,<2.0.2", "bytefury/crater": "<6.0.2", "cachethq/cachet": "<2.5.1", "cakephp/cakephp": "<3.10.3|>=4,<4.0.10|>=4.1,<4.1.4|>=4.2,<4.2.12|>=4.3,<4.3.11|>=4.4,<4.4.10", @@ -1186,20 +1187,20 @@ "cesnet/simplesamlphp-module-proxystatistics": "<3.1", "chriskacerguis/codeigniter-restserver": "<=2.7.1", "civicrm/civicrm-core": ">=4.2,<4.2.9|>=4.3,<4.3.3", - "ckeditor/ckeditor": "<4.17", + "ckeditor/ckeditor": "<4.24", "cockpit-hq/cockpit": "<=2.6.3", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<3.1.9", "codeigniter4/framework": "<=4.4.2", "codeigniter4/shield": "<1.0.0.0-beta8", "codiad/codiad": "<=2.8.4", - "composer/composer": "<1.10.27|>=2,<2.2.22|>=2.3,<2.6.4", - "concrete5/concrete5": "<9.2.3", + "composer/composer": "<1.10.27|>=2,<2.2.23|>=2.3,<2.7", + "concrete5/concrete5": "<9.2.5", "concrete5/core": "<8.5.8|>=9,<9.1", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/contao": ">=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", "contao/core": ">=2,<3.5.39", - "contao/core-bundle": "<4.9.42|>=4.10,<4.13.28|>=5,<5.1.10", + "contao/core-bundle": ">=3,<3.5.35|>=4,<4.9.42|>=4.10,<4.13.28|>=5,<5.1.10", "contao/listing-bundle": ">=4,<4.4.8", "contao/managed-edition": "<=1.5", "corveda/phpsandbox": "<1.3.5", @@ -1215,11 +1216,11 @@ "dbrisinajumi/d2files": "<1", "dcat/laravel-admin": "<=2.1.3.0-beta", "derhansen/fe_change_pwd": "<2.0.5|>=3,<3.0.3", - "derhansen/sf_event_mgt": "<4.3.1|>=5,<5.1.1", + "derhansen/sf_event_mgt": "<4.3.1|>=5,<5.1.1|>=7,<7.4", "desperado/xml-bundle": "<=0.1.7", "directmailteam/direct-mail": "<6.0.3|>=7,<7.0.3|>=8,<9.5.2", "doctrine/annotations": "<1.2.7", - "doctrine/cache": "<1.3.2|>=1.4,<1.4.2", + "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", "doctrine/common": "<2.4.3|>=2.5,<2.5.1", "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2|>=3,<3.1.4", "doctrine/doctrine-bundle": "<1.5.2", @@ -1230,8 +1231,8 @@ "dolibarr/dolibarr": "<18.0.2", "dompdf/dompdf": "<2.0.4", "doublethreedigital/guest-entries": "<3.1.2", - "drupal/core": "<9.5.11|>=10,<10.0.11|>=10.1,<10.1.4", - "drupal/drupal": ">=6,<6.38|>=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", + "drupal/core": ">=6,<6.38|>=7,<7.96|>=8,<10.1.8|>=10.2,<10.2.2", + "drupal/drupal": ">=5,<5.11|>=6,<6.38|>=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", "duncanmcclean/guest-entries": "<3.1.2", "dweeves/magmi": "<=0.7.24", "ec-cube/ec-cube": "<2.4.4", @@ -1242,6 +1243,7 @@ "elijaa/phpmemcacheadmin": "<=1.3", "encore/laravel-admin": "<=1.8.19", "endroid/qr-code-bundle": "<3.4.2", + "enhavo/enhavo-app": "<=0.13.1", "enshrined/svg-sanitize": "<0.15", "erusev/parsedown": "<1.7.2", "ether/logs": "<3.0.4", @@ -1301,8 +1303,8 @@ "funadmin/funadmin": "<=3.2|>=3.3.2,<=3.3.3", "gaoming13/wechat-php-sdk": "<=1.10.2", "genix/cms": "<=1.1.11", - "getgrav/grav": "<=1.7.42.1", - "getkirby/cms": "<3.5.8.3-dev|>=3.6,<3.6.6.3-dev|>=3.7,<3.7.5.2-dev|>=3.8,<3.8.4.1-dev|>=3.9,<3.9.6", + "getgrav/grav": "<1.7.44", + "getkirby/cms": "<4.1.1", "getkirby/kirby": "<=2.5.12", "getkirby/panel": "<2.5.14", "getkirby/starterkit": "<=3.7.0.2", @@ -1314,7 +1316,7 @@ "gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3", "gree/jose": "<2.2.1", "gregwar/rst": "<1.0.3", - "grumpydictator/firefly-iii": "<6.1.1", + "grumpydictator/firefly-iii": "<6.1.7", "gugoan/economizzer": "<=0.9.0.0-beta1", "guzzlehttp/guzzle": "<6.5.8|>=7,<7.4.5", "guzzlehttp/psr7": "<1.9.1|>=2,<2.4.5", @@ -1336,7 +1338,7 @@ "ibexa/user": ">=4,<4.4.3", "icecoder/icecoder": "<=8.1", "idno/known": "<=1.3.1", - "illuminate/auth": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.10", + "illuminate/auth": "<5.5.10", "illuminate/cookie": ">=4,<=4.0.11|>=4.1,<=4.1.99999|>=4.2,<=4.2.99999|>=5,<=5.0.99999|>=5.1,<=5.1.99999|>=5.2,<=5.2.99999|>=5.3,<=5.3.99999|>=5.4,<=5.4.99999|>=5.5,<=5.5.49|>=5.6,<=5.6.99999|>=5.7,<=5.7.99999|>=5.8,<=5.8.99999|>=6,<6.18.31|>=7,<7.22.4", "illuminate/database": "<6.20.26|>=7,<7.30.5|>=8,<8.40", "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", @@ -1359,7 +1361,7 @@ "joomla/archive": "<1.1.12|>=2,<2.0.1", "joomla/filesystem": "<1.6.2|>=2,<2.0.1", "joomla/filter": "<1.4.4|>=2,<2.0.1", - "joomla/framework": ">=2.5.4,<=3.8.12", + "joomla/framework": "<1.5.7|>=2.5.4,<=3.8.12", "joomla/input": ">=2,<2.0.2", "joomla/joomla-cms": ">=2.5,<3.9.12", "joomla/session": "<1.3.1", @@ -1408,11 +1410,11 @@ "magneto/core": "<1.9.4.4-dev", "maikuolan/phpmussel": ">=1,<1.6", "mainwp/mainwp": "<=4.4.3.3", - "mantisbt/mantisbt": "<=2.25.7", + "mantisbt/mantisbt": "<2.26.1", "marcwillmann/turn": "<0.3.3", "matyhtf/framework": "<3.0.6", "mautic/core": "<4.3", - "mediawiki/core": ">=1.27,<1.27.6|>=1.29,<1.29.3|>=1.30,<1.30.2|>=1.31,<1.31.9|>=1.32,<1.32.6|>=1.32.99,<1.33.3|>=1.33.99,<1.34.3|>=1.34.99,<1.35", + "mediawiki/core": "<1.36.2", "mediawiki/matomo": "<2.4.3", "mediawiki/semantic-media-wiki": "<4.0.2", "melisplatform/melis-asset-manager": "<5.0.1", @@ -1420,7 +1422,7 @@ "melisplatform/melis-front": "<5.0.1", "mezzio/mezzio-swoole": "<3.7|>=4,<4.3", "mgallegos/laravel-jqgrid": "<=1.3", - "microsoft/microsoft-graph": ">=1.16,<1.109.1|>=2.0.0.0-RC1-dev,<2.0.1", + "microsoft/microsoft-graph": ">=1.16,<1.109.1|>=2,<2.0.1", "microsoft/microsoft-graph-beta": "<2.0.1", "microsoft/microsoft-graph-core": "<2.0.2", "microweber/microweber": "<=2.0.4", @@ -1431,7 +1433,7 @@ "mojo42/jirafeau": "<4.4", "mongodb/mongodb": ">=1,<1.9.2", "monolog/monolog": ">=1.8,<1.12", - "moodle/moodle": "<4.3.0.0-RC2-dev", + "moodle/moodle": "<4.3.3", "mos/cimage": "<0.7.19", "movim/moxl": ">=0.8,<=0.10", "mpdf/mpdf": "<=7.1.7", @@ -1465,11 +1467,11 @@ "october/system": "<1.0.476|>=1.1,<1.1.12|>=2,<2.2.34|>=3,<3.5.2", "omeka/omeka-s": "<4.0.3", "onelogin/php-saml": "<2.10.4", - "oneup/uploader-bundle": "<1.9.3|>=2,<2.1.5", + "oneup/uploader-bundle": ">=1,<1.9.3|>=2,<2.1.5", "open-web-analytics/open-web-analytics": "<1.7.4", "opencart/opencart": "<=3.0.3.7|>=4,<4.0.2.3-dev", "openid/php-openid": "<2.3", - "openmage/magento-lts": "<20.2", + "openmage/magento-lts": "<20.5", "opensource-workshop/connect-cms": "<1.7.2|>=2,<2.3.2", "orchid/platform": ">=9,<9.4.4|>=14.0.0.0-alpha4,<14.5", "oro/calendar-bundle": ">=4.2,<=4.2.6|>=5,<=5.0.6|>=5.1,<5.1.1", @@ -1487,12 +1489,13 @@ "passbolt/passbolt_api": "<2.11", "paypal/merchant-sdk-php": "<3.12", "pear/archive_tar": "<1.4.14", + "pear/auth": "<1.2.4", "pear/crypt_gpg": "<1.6.7", "pear/pear": "<=1.10.1", "pegasus/google-for-jobs": "<1.5.1|>=2,<2.1.1", "personnummer/personnummer": "<3.0.2", "phanan/koel": "<5.1.4", - "phenx/php-svg-lib": "<0.5.1", + "phenx/php-svg-lib": "<0.5.2", "php-mod/curl": "<2.3.2", "phpbb/phpbb": "<3.2.10|>=3.3,<3.3.1", "phpems/phpems": ">=6,<=6.1.3", @@ -1500,25 +1503,25 @@ "phpmailer/phpmailer": "<6.5", "phpmussel/phpmussel": ">=1,<1.6", "phpmyadmin/phpmyadmin": "<5.2.1", - "phpmyfaq/phpmyfaq": "<=3.1.7", + "phpmyfaq/phpmyfaq": "<3.2.5", "phpoffice/phpexcel": "<1.8", "phpoffice/phpspreadsheet": "<1.16", "phpseclib/phpseclib": "<2.0.31|>=3,<3.0.34", "phpservermon/phpservermon": "<3.6", "phpsysinfo/phpsysinfo": "<3.4.3", - "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5,<5.6.3", + "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3", "phpwhois/phpwhois": "<=4.2.5", "phpxmlrpc/extras": "<0.6.1", "phpxmlrpc/phpxmlrpc": "<4.9.2", "pi/pi": "<=2.5", - "pimcore/admin-ui-classic-bundle": "<1.3.2", + "pimcore/admin-ui-classic-bundle": "<1.3.4", "pimcore/customer-management-framework-bundle": "<4.0.6", "pimcore/data-hub": "<1.2.4", "pimcore/demo": "<10.3", "pimcore/ecommerce-framework-bundle": "<1.0.10", "pimcore/perspective-editor": "<1.5.1", "pimcore/pimcore": "<11.1.1", - "pixelfed/pixelfed": "<=0.11.4", + "pixelfed/pixelfed": "<0.11.11", "plotly/plotly.js": "<2.25.2", "pocketmine/bedrock-protocol": "<8.0.2", "pocketmine/pocketmine-mp": "<=4.23|>=5,<5.3.1", @@ -1529,7 +1532,7 @@ "prestashop/blockwishlist": ">=2,<2.1.1", "prestashop/contactform": ">=1.0.1,<4.3", "prestashop/gamification": "<2.3.2", - "prestashop/prestashop": "<8.1.3", + "prestashop/prestashop": "<8.1.4", "prestashop/productcomments": "<5.0.2", "prestashop/ps_emailsubscription": "<2.6.1", "prestashop/ps_facetedsearch": "<3.4.1", @@ -1552,17 +1555,18 @@ "rap2hpoutre/laravel-log-viewer": "<0.13", "react/http": ">=0.7,<1.9", "really-simple-plugins/complianz-gdpr": "<6.4.2", + "redaxo/source": "<=5.15.1", "remdex/livehelperchat": "<3.99", "reportico-web/reportico": "<=7.1.21", "rhukster/dom-sanitizer": "<1.0.7", "rmccue/requests": ">=1.6,<1.8", - "robrichards/xmlseclibs": "<3.0.4", + "robrichards/xmlseclibs": ">=1,<3.0.4", "roots/soil": "<4.1", "rudloff/alltube": "<3.0.3", "s-cart/core": "<6.9", "s-cart/s-cart": "<6.9", "sabberworm/php-css-parser": ">=1,<1.0.1|>=2,<2.0.1|>=3,<3.0.1|>=4,<4.0.1|>=5,<5.0.9|>=5.1,<5.1.3|>=5.2,<5.2.1|>=6,<6.0.2|>=7,<7.0.4|>=8,<8.0.1|>=8.1,<8.1.1|>=8.2,<8.2.1|>=8.3,<8.3.1", - "sabre/dav": "<1.7.11|>=1.8,<1.8.9", + "sabre/dav": ">=1.6,<1.7.11|>=1.8,<1.8.9", "scheb/two-factor-bundle": "<3.26|>=4,<4.11", "sensiolabs/connect": "<4.2.3", "serluck/phpwhois": "<=4.2.6", @@ -1582,7 +1586,7 @@ "silverstripe/comments": ">=1.3,<1.9.99|>=2,<2.9.99|>=3,<3.1.1", "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", "silverstripe/framework": "<4.13.39|>=5,<5.1.11", - "silverstripe/graphql": "<3.8.2|>=4,<4.3.7|>=5,<5.1.3", + "silverstripe/graphql": ">=2,<2.0.5|>=3,<3.8.2|>=4,<4.3.7|>=5,<5.1.3", "silverstripe/hybridsessions": ">=1,<2.4.1|>=2.5,<2.5.1", "silverstripe/recipe-cms": ">=4.5,<4.5.3", "silverstripe/registry": ">=2.1,<2.1.2|>=2.2,<2.2.1", @@ -1593,7 +1597,7 @@ "silverstripe/userforms": "<3", "silverstripe/versioned-admin": ">=1,<1.11.1", "simple-updates/phpwhois": "<=1", - "simplesamlphp/saml2": "<1.15.4|>=2,<2.3.8|>=3,<3.1.4|==5.0.0.0-alpha12", + "simplesamlphp/saml2": "<1.10.6|>=2,<2.3.8|>=3,<3.1.4|==5.0.0.0-alpha12", "simplesamlphp/simplesamlphp": "<1.18.6", "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", "simplesamlphp/simplesamlphp-module-openid": "<1", @@ -1615,12 +1619,12 @@ "spoonity/tcpdf": "<6.2.22", "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", "ssddanbrown/bookstack": "<22.02.3", - "statamic/cms": "<4.36", + "statamic/cms": "<4.46", "stormpath/sdk": "<9.9.99", "studio-42/elfinder": "<2.1.62", "subhh/libconnect": "<7.0.8|>=8,<8.1", "sukohi/surpass": "<1", - "sulu/sulu": "<1.6.44|>=2,<2.2.18|>=2.3,<2.3.8|==2.4.0.0-RC1|>=2.5,<2.5.10", + "sulu/sulu": "<1.6.44|>=2,<2.4.16|>=2.5,<2.5.12", "sumocoders/framework-user-bundle": "<1.4", "superbig/craft-audit": "<3.0.2", "swag/paypal": "<5.4.4", @@ -1630,7 +1634,7 @@ "sylius/grid": ">=1,<1.1.19|>=1.2,<1.2.18|>=1.3,<1.3.13|>=1.4,<1.4.5|>=1.5,<1.5.1", "sylius/grid-bundle": "<1.10.1", "sylius/paypal-plugin": ">=1,<1.2.4|>=1.3,<1.3.1", - "sylius/resource-bundle": "<1.3.14|>=1.4,<1.4.7|>=1.5,<1.5.2|>=1.6,<1.6.4", + "sylius/resource-bundle": ">=1,<1.3.14|>=1.4,<1.4.7|>=1.5,<1.5.2|>=1.6,<1.6.4", "sylius/sylius": "<1.9.10|>=1.10,<1.10.11|>=1.11,<1.11.2", "symbiote/silverstripe-multivaluefield": ">=3,<3.0.99", "symbiote/silverstripe-queuedjobs": ">=3,<3.0.2|>=3.1,<3.1.4|>=4,<4.0.7|>=4.1,<4.1.2|>=4.2,<4.2.4|>=4.3,<4.3.3|>=4.4,<4.4.3|>=4.5,<4.5.1|>=4.6,<4.6.4", @@ -1659,7 +1663,7 @@ "symfony/security-guard": ">=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", "symfony/security-http": ">=2.3,<2.3.41|>=2.4,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.2.12|>=4.3,<4.3.8|>=4.4,<4.4.7|>=5,<5.0.7|>=5.1,<5.2.8|>=5.3,<5.3.2|>=5.4,<5.4.31|>=6,<6.3.8", "symfony/serializer": ">=2,<2.0.11|>=4.1,<4.4.35|>=5,<5.3.12", - "symfony/symfony": "<4.4.51|>=5,<5.4.31|>=6,<6.3.8", + "symfony/symfony": ">=2,<4.4.51|>=5,<5.4.31|>=6,<6.3.8", "symfony/translation": ">=2,<2.0.17", "symfony/twig-bridge": ">=2,<4.4.51|>=5,<5.4.31|>=6,<6.3.8", "symfony/ux-autocomplete": "<2.11.2", @@ -1667,7 +1671,7 @@ "symfony/var-exporter": ">=4.2,<4.2.12|>=4.3,<4.3.8", "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", "symfony/webhook": ">=6.3,<6.3.8", - "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", + "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7|>=2.2.0.0-beta1,<2.2.0.0-beta2", "symphonycms/symphony-2": "<2.6.4", "t3/dce": "<0.11.5|>=2.2,<2.6.2", "t3g/svg-sanitizer": "<1.0.3", @@ -1689,17 +1693,20 @@ "topthink/framework": "<6.0.14", "topthink/think": "<=6.1.1", "topthink/thinkphp": "<=3.2.3", + "torrentpier/torrentpier": "<=2.4.1", "tpwd/ke_search": "<4.0.3|>=4.1,<4.6.6|>=5,<5.0.2", "tribalsystems/zenario": "<=9.4.59197", "truckersmp/phpwhois": "<=4.3.1", "ttskch/pagination-service-provider": "<1", "twig/twig": "<1.44.7|>=2,<2.15.3|>=3,<3.4.3", "typo3/cms": "<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", - "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/cms-core": "<8.7.55|>=9,<9.5.44|>=10,<10.4.41|>=11,<11.5.33|>=12,<12.4.8", + "typo3/cms-backend": "<4.1.14|>=4.2,<4.2.15|>=4.3,<4.3.7|>=4.4,<4.4.4|>=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", + "typo3/cms-core": "<=8.7.56|>=9,<=9.5.45|>=10,<=10.4.42|>=11,<=11.5.34|>=12,<=12.4.10|==13", "typo3/cms-extbase": "<6.2.24|>=7,<7.6.8|==8.1.1", + "typo3/cms-fluid": "<4.3.4|>=4.4,<4.4.1", "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/cms-install": ">=12.2,<12.4.8", + "typo3/cms-frontend": "<4.3.9|>=4.4,<4.4.5", + "typo3/cms-install": "<4.1.14|>=4.2,<4.2.16|>=4.3,<4.3.9|>=4.4,<4.4.5|>=12.2,<12.4.8", "typo3/cms-rte-ckeditor": ">=9.5,<9.5.42|>=10,<10.4.39|>=11,<11.5.30", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", "typo3/html-sanitizer": ">=1,<=1.5.2|>=2,<=2.1.3", @@ -1734,7 +1741,7 @@ "winter/wn-system-module": "<1.2.4", "wintercms/winter": "<1.2.3", "woocommerce/woocommerce": "<6.6", - "wp-cli/wp-cli": "<2.5", + "wp-cli/wp-cli": ">=0.12,<2.5", "wp-graphql/wp-graphql": "<=1.14.5", "wpanel/wpanel4-cms": "<=4.3.1", "wpcloud/wp-stateless": "<3.2", @@ -1757,12 +1764,13 @@ "yikesinc/yikes-inc-easy-mailchimp-extender": "<6.8.6", "yoast-seo-for-typo3/yoast_seo": "<7.2.3", "yourls/yourls": "<=1.8.2", + "yuan1994/tpadmin": "<=1.3.12", "zencart/zencart": "<=1.5.7.0-beta", "zendesk/zendesk_api_client_php": "<2.2.11", - "zendframework/zend-cache": "<2.4.8|>=2.5,<2.5.3", + "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", - "zendframework/zend-db": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.10|>=2.3,<2.3.5", + "zendframework/zend-db": "<2.2.10|>=2.3,<2.3.5", "zendframework/zend-developer-tools": ">=1.2.2,<1.2.3", "zendframework/zend-diactoros": "<1.8.4", "zendframework/zend-feed": "<2.10.3", @@ -1787,11 +1795,11 @@ "zendframework/zendservice-slideshare": "<2.0.2", "zendframework/zendservice-technorati": "<2.0.2", "zendframework/zendservice-windowsazure": "<2.0.2", - "zendframework/zendxml": "<1.0.1", + "zendframework/zendxml": ">=1,<1.0.1", "zenstruck/collection": "<0.2.1", "zetacomponents/mail": "<1.8.2", "zf-commons/zfc-user": "<1.2.2", - "zfcampus/zf-apigility-doctrine": "<1.0.3", + "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", "zfr/zfr-oauth2-server-module": "<0.1.2", "zoujingli/thinkadmin": "<=6.1.53" }, @@ -1831,7 +1839,7 @@ "type": "tidelift" } ], - "time": "2024-01-31T12:06:01+00:00" + "time": "2024-02-27T22:04:41+00:00" }, { "name": "sebastian/cli-parser", @@ -2857,11 +2865,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.1 || ^8.2" + "php": "^8.0 || ^8.1 || ^8.2" }, "platform-dev": [], "platform-overrides": { - "php": "8.1" + "php": "8.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/lib/Command/Prompt.php b/lib/Command/Prompt.php index 1d5da0f..6924fc9 100644 --- a/lib/Command/Prompt.php +++ b/lib/Command/Prompt.php @@ -12,9 +12,9 @@ namespace OCA\ContextChat\Command; -use OCA\ContextChat\Service\ScopeType; use OCA\ContextChat\TextProcessing\ContextChatTaskType; use OCA\ContextChat\TextProcessing\ScopedContextChatTaskType; +use OCA\ContextChat\Type\ScopeType; use OCP\TextProcessing\FreePromptTaskType; use OCP\TextProcessing\IManager; use OCP\TextProcessing\Task; @@ -55,13 +55,13 @@ protected function configure() { 'context-sources', null, InputOption::VALUE_REQUIRED, - 'Context sources to use', + 'Context sources to use (as a comma-separated list without brackets)', ) ->addOption( 'context-providers', null, InputOption::VALUE_REQUIRED, - 'Context provider to use', + 'Context providers to use (as a comma-separated list without brackets)', ); } @@ -83,15 +83,19 @@ protected function execute(InputInterface $input, OutputInterface $output) { if ($noContext) { $task = new Task(FreePromptTaskType::class, $prompt, 'context_chat', $userId); } elseif (!empty($contextSources)) { + $contextSources = preg_replace('/\s*,+\s*/', ',', $contextSources); + $contextSourcesArray = array_filter(explode(',', $contextSources), fn ($source) => !empty($source)); $task = new Task(ScopedContextChatTaskType::class, json_encode([ 'scopeType' => ScopeType::SOURCE, - 'scopeList' => explode(',', $contextSources), + 'scopeList' => $contextSourcesArray, 'prompt' => $prompt, ]), 'context_chat', $userId); } elseif (!empty($contextProviders)) { + $contextProviders = preg_replace('/\s*,+\s*/', ',', $contextProviders); + $contextProvidersArray = array_filter(explode(',', $contextProviders), fn ($source) => !empty($source)); $task = new Task(ScopedContextChatTaskType::class, json_encode([ 'scopeType' => ScopeType::PROVIDER, - 'scopeList' => explode(',', $contextProviders), + 'scopeList' => $contextProvidersArray, 'prompt' => $prompt, ]), 'context_chat', $userId); } else { diff --git a/lib/Service/LangRopeService.php b/lib/Service/LangRopeService.php index 1f57d1e..7040110 100644 --- a/lib/Service/LangRopeService.php +++ b/lib/Service/LangRopeService.php @@ -27,11 +27,6 @@ use Psr\Log\LoggerInterface; use RuntimeException; -enum ScopeType: string { - case PROVIDER = 'provider'; - case SOURCE = 'source'; -} - class LangRopeService { public function __construct( private LoggerInterface $logger, @@ -195,11 +190,11 @@ public function query(string $userId, string $prompt, bool $useContext = true): /** * @param string $userId * @param string $prompt - * @param ScopeType $scopeType + * @param string $scopeType * @param array $scopeList * @return array */ - public function scopedQuery(string $userId, string $prompt, ScopeType $scopeType, array $scopeList): array { + public function scopedQuery(string $userId, string $prompt, string $scopeType, array $scopeList): array { $params = [ 'query' => $prompt, 'userId' => $userId, diff --git a/lib/TextProcessing/ScopedContextChatProvider.php b/lib/TextProcessing/ScopedContextChatProvider.php index 60398ba..3768e92 100644 --- a/lib/TextProcessing/ScopedContextChatProvider.php +++ b/lib/TextProcessing/ScopedContextChatProvider.php @@ -4,7 +4,7 @@ namespace OCA\ContextChat\TextProcessing; use OCA\ContextChat\Service\LangRopeService; -use OCA\ContextChat\Service\ScopeType; +use OCA\ContextChat\Type\ScopeType; use OCP\IL10N; use OCP\TextProcessing\IProvider; use OCP\TextProcessing\IProviderWithUserId; @@ -63,15 +63,16 @@ public function process(string $prompt): string { throw new \RuntimeException('Invalid JSON string, expected { "scopeType": string, "scopeList": list[string], "prompt": string }'); } - $scopeTypeEnum = ScopeType::tryFrom($parsedData['scopeType']); - if ($scopeTypeEnum === null) { - throw new \RuntimeException('Invalid scope type: ' . $parsedData['scopeType']); + try { + ScopeType::validate($parsedData['scopeType']); + } catch (\InvalidArgumentException $e) { + throw new \RuntimeException($e->getMessage(), intval($e->getCode()), $e); } $response = $this->langRopeService->scopedQuery( $this->userId, $parsedData['prompt'], - $scopeTypeEnum, + $parsedData['scopeType'], $parsedData['scopeList'], ); diff --git a/lib/Type/ScopeType.php b/lib/Type/ScopeType.php new file mode 100644 index 0000000..7ab58bd --- /dev/null +++ b/lib/Type/ScopeType.php @@ -0,0 +1,28 @@ + + * @copyright Anupam Kumar 2023 + */ + +declare(strict_types=1); + +namespace OCA\ContextChat\Type; + +class ScopeType { + public const PROVIDER = 'provider'; + public const SOURCE = 'source'; + + public static function validate(string $scopeType): void { + $relection = new \ReflectionClass(self::class); + if (!in_array($scopeType, $relection->getConstants())) { + throw new \InvalidArgumentException( + "Invalid scope type: {$scopeType}, should be one of: [" . implode(', ', $relection->getConstants()) . ']' + ); + } + } +} diff --git a/stubs/appapi-public-functions.php b/stubs/appapi-public-functions.php index 100682f..f61350e 100644 --- a/stubs/appapi-public-functions.php +++ b/stubs/appapi-public-functions.php @@ -5,8 +5,8 @@ namespace OCA\AppAPI { class PublicFunctions { public function __construct( - private readonly \OCA\AppAPI\Service\ExAppService $exAppService, - private readonly \OCA\AppAPI\Service\AppAPIService $service, + private \OCA\AppAPI\Service\ExAppService $exAppService, + private \OCA\AppAPI\Service\AppAPIService $service, ) { } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 27c39d4..8783da4 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,9 +3,9 @@ require_once __DIR__ . '/../../../tests/bootstrap.php'; require_once __DIR__ . '/../vendor/autoload.php'; -use \OCA\ContextChat\AppInfo\Application; -use \OCP\App\IAppManager; -use \OCP\Server; +use OCA\ContextChat\AppInfo\Application; +use OCP\App\IAppManager; +use OCP\Server; Server::get(IAppManager::class)->loadApp(Application::APP_ID); OC_Hook::clear();