From 532ca5b270bd88476483089f9a87f68d829fb113 Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Jul 2024 17:27:55 +0200 Subject: [PATCH 1/4] refactor github workflow --- .github/workflows/main.yml | 53 +++++++++++++++++++++++++++++++++++ .github/workflows/php.yml | 57 -------------------------------------- 2 files changed, 53 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..991e937 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,53 @@ +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: "read" + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # composer validation + composer: + name: "composer config validation" + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - name: "Validate composer.json" + run: "composer validate --strict" + # PHP lint and PHPStan for different PHP versions + php: + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.1" + - "8.2" + - "8.3" + name: "PHP ${{ matrix.php-version }}" + steps: + - name: "git checkout" + uses: "actions/checkout@v3" + - name: "setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "xdebug" + - name: "check PHP version" + run: "php -v" + - name: "lint PHP files" + run: "php -l src/" +# - name: "install composer dependencies" +# run: "composer install --prefer-dist --no-progress" +# # PHPStan +# - name: "PHPStan static analysis" +# uses: "php-actions/phpstan@v3" +# with: +# php_version: "${{ matrix.php-version }}" +# configuration: "phpstan.neon" +# path: "exceptions/ src/ tests/" diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 50859ac..0000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: "PHP" -on: - push: - branches: - - "main" - pull_request: - branches: - - "main" -permissions: - contents: "read" -jobs: - # PHP lint for different PHP versions - build: - runs-on: "ubuntu-latest" - strategy: - matrix: - php-version: - - "7.4" - - "8.1" - name: "PHP ${{ matrix.php-version }}" - steps: - - # git checkout - name: "git checkout" - uses: "actions/checkout@v3" - - # Setup PHP - name: "Setup PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - coverage: "xdebug" - - # Check PHP version - name: "Check PHP version" - run: "php -v" - - # Lint PHP files - name: "Lint PHP files" - run: | - for file in $(find src/ -type f -name '*.php'); do - echo -n "==> ${file}: "; - php -l "${file}"; - done - - # Validate composer.json and composer.lock - name: "Validate composer.json and composer.lock" - run: "composer validate --strict" - - # Cache Composer packages - name: "Cache Composer packages" - id: "composer-cache" - uses: "actions/cache@v3" - with: - path: "vendor" - key: "${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}" - restore-keys: "${{ runner.os }}-php-" - - # Install dependencies - name: "Install composer dependencies" - run: "composer install --prefer-dist --no-progress" - - # PHP_CodeSniffer - name: "PHP_CodeSniffer" - run: "php vendor/bin/phpcs" From 1fe1c18e161db6c6d76c33fb0d8ecf8d7a5c8eb3 Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Jul 2024 17:28:52 +0200 Subject: [PATCH 2/4] update composer dependencies for PHP ^8.1 and require current dev-main versions of interfaces and commons --- composer.json | 6 +- composer.lock | 351 ++++++++++++++++++++++++++++---------------------- 2 files changed, 197 insertions(+), 160 deletions(-) diff --git a/composer.json b/composer.json index b1230d2..417f1d1 100644 --- a/composer.json +++ b/composer.json @@ -13,12 +13,12 @@ "homepage": "https://php-sap.github.io/", "minimum-stability": "stable", "require": { - "php": ">=7.4", + "php": "^8.1", "ext-json": "*", "phpunit/phpunit": "^9.6", "kba-team/memory-container": "^2.0", - "php-sap/interfaces": "^4.0", - "php-sap/common": "^5.0" + "php-sap/interfaces": "dev-main", + "php-sap/common": "dev-main" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 410708c..9053058 100644 --- a/composer.lock +++ b/composer.lock @@ -4,34 +4,34 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7b6d1b7a6aa488026cc6db5580fef3b6", + "content-hash": "2064ea1f411c3025129981495f22ad5f", "packages": [ { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "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" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -58,7 +58,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -74,7 +74,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "kba-team/memory-container", @@ -126,16 +126,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -143,11 +143,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -173,7 +174,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -181,29 +182,31 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v5.1.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -211,7 +214,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -235,26 +238,27 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2024-07-01T20:03:41+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -295,9 +299,15 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -352,27 +362,29 @@ }, { "name": "php-sap/common", - "version": "v5.0.0", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/php-sap/common.git", - "reference": "1afaf2588e615f4ef784d9404bf4ae089e311ea9" + "reference": "490cfb015a307b70eee00902e9870c410e536383" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-sap/common/zipball/1afaf2588e615f4ef784d9404bf4ae089e311ea9", - "reference": "1afaf2588e615f4ef784d9404bf4ae089e311ea9", + "url": "https://api.github.com/repos/php-sap/common/zipball/490cfb015a307b70eee00902e9870c410e536383", + "reference": "490cfb015a307b70eee00902e9870c410e536383", "shasum": "" }, "require": { "ext-json": "*", - "php": ">=7.4", - "php-sap/interfaces": "^4.0" + "php": "^8.1", + "php-sap/datetime": "^1.5", + "php-sap/interfaces": "dev-main" }, "require-dev": { "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.7" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -399,26 +411,26 @@ ], "support": { "issues": "https://github.com/php-sap/common/issues", - "source": "https://github.com/php-sap/common/tree/v5.0.0" + "source": "https://github.com/php-sap/common/tree/main" }, - "time": "2023-10-19T13:19:33+00:00" + "time": "2024-07-31T13:30:11+00:00" }, { "name": "php-sap/datetime", - "version": "v1.4.2", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/php-sap/datetime.git", - "reference": "6f6d21e90af497d0342eb30204dcc5f31d801a4d" + "reference": "53c0557e87964914a332e288204b9f841e9364dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-sap/datetime/zipball/6f6d21e90af497d0342eb30204dcc5f31d801a4d", - "reference": "6f6d21e90af497d0342eb30204dcc5f31d801a4d", + "url": "https://api.github.com/repos/php-sap/datetime/zipball/53c0557e87964914a332e288204b9f841e9364dd", + "reference": "53c0557e87964914a332e288204b9f841e9364dd", "shasum": "" }, "require": { - "php": ">=7.4" + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6", @@ -454,28 +466,27 @@ ], "support": { "issues": "https://github.com/php-sap/datetime/issues", - "source": "https://github.com/php-sap/datetime/tree/v1.4.2" + "source": "https://github.com/php-sap/datetime/tree/v1.5.0" }, - "time": "2023-10-18T15:32:07+00:00" + "time": "2024-07-23T15:05:47+00:00" }, { "name": "php-sap/interfaces", - "version": "v4.0.0", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/php-sap/interfaces.git", - "reference": "f0ab5f7b37e6d0f909ea85685ce82d2d787527d8" + "reference": "d4ae1038eb26251f5e32eb6429cdf4f40d2ab422" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-sap/interfaces/zipball/f0ab5f7b37e6d0f909ea85685ce82d2d787527d8", - "reference": "f0ab5f7b37e6d0f909ea85685ce82d2d787527d8", + "url": "https://api.github.com/repos/php-sap/interfaces/zipball/d4ae1038eb26251f5e32eb6429cdf4f40d2ab422", + "reference": "d4ae1038eb26251f5e32eb6429cdf4f40d2ab422", "shasum": "" }, "require": { "ext-json": "*", - "php": ">=7.4", - "php-sap/datetime": "^1.4" + "php": "^8.1" }, "conflict": { "kba-team/php-sap": "*" @@ -483,6 +494,7 @@ "require-dev": { "squizlabs/php_codesniffer": "^3.7" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -509,29 +521,29 @@ ], "support": { "issues": "https://github.com/php-sap/interfaces/issues", - "source": "https://github.com/php-sap/interfaces/tree/v4.0.0" + "source": "https://github.com/php-sap/interfaces/tree/main" }, - "time": "2023-10-17T14:58:09+00:00" + "time": "2024-07-30T12:11:01+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -581,7 +593,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" }, "funding": [ { @@ -589,7 +601,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2024-03-02T06:37:42+00:00" }, { "name": "phpunit/php-file-iterator", @@ -834,45 +846,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.13", + "version": "9.6.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" + "reference": "49d7820565836236411f5dc002d16dd689cde42f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/49d7820565836236411f5dc002d16dd689cde42f", + "reference": "49d7820565836236411f5dc002d16dd689cde42f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.31", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -917,7 +929,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.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.20" }, "funding": [ { @@ -933,7 +945,7 @@ "type": "tidelift" } ], - "time": "2023-09-19T05:39:22+00:00" + "time": "2024-07-10T11:45:39+00:00" }, { "name": "psr/container", @@ -985,16 +997,16 @@ }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -1029,7 +1041,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -1037,7 +1049,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -1226,20 +1238,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1271,7 +1283,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -1279,20 +1291,20 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -1337,7 +1349,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -1345,7 +1357,7 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", @@ -1412,16 +1424,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -1477,7 +1489,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -1485,20 +1497,20 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.6", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -1541,7 +1553,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -1549,24 +1561,24 @@ "type": "github" } ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1598,7 +1610,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -1606,7 +1618,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -1785,16 +1797,16 @@ }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -1806,7 +1818,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1827,8 +1839,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -1836,7 +1847,7 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", @@ -1949,16 +1960,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -1987,7 +1998,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -1995,22 +2006,22 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2024-03-03T12:36:25+00:00" } ], "packages-dev": [ { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.10.2", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017", "shasum": "" }, "require": { @@ -2020,11 +2031,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -2039,31 +2050,57 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-07-21T23:26:44+00:00" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "php-sap/interfaces": 20, + "php-sap/common": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4", + "php": "^8.1", "ext-json": "*" }, "platform-dev": [], From afbc2bad13b8b7b97b8af0056305dba8d5915601 Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Jul 2024 17:29:25 +0200 Subject: [PATCH 3/4] add .uuid files to git ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 48b8bf9..ce0f837 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor/ +.uuid From fd0c4ce557040c67a3cba8b5f4b0d152e67bd10c Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Jul 2024 18:10:12 +0200 Subject: [PATCH 4/4] adapt classes for PHP 8 --- src/AbstractSapRfcTestCase.php | 86 ++++++++++++++++++++++++++-------- src/AbstractTestCase.php | 66 +++++++++++++++----------- src/SapRfcModuleMocks.php | 55 +++++++++------------- 3 files changed, 125 insertions(+), 82 deletions(-) diff --git a/src/AbstractSapRfcTestCase.php b/src/AbstractSapRfcTestCase.php index 6c2f80e..e5390f1 100644 --- a/src/AbstractSapRfcTestCase.php +++ b/src/AbstractSapRfcTestCase.php @@ -1,13 +1,25 @@ expectException(\phpsap\interfaces\exceptions\IConnectionFailedException::class); + $this->expectException(IConnectionFailedException::class); $saprfc->invoke(); } /** * Test SAP RFC connection type B configuration. + * @return void + * @throws IConnectionFailedException + * @throws IFunctionCallException + * @throws IIncompleteConfigException + * @throws IInvalidArgumentException + * @throws IUnknownFunctionException */ - public function testConnectionConfigTypeB() + public function testConnectionConfigTypeB(): void { if (!extension_loaded(static::getModuleName())) { //load functions mocking SAP RFC module functions or class methods @@ -88,7 +112,7 @@ public function testConnectionConfigTypeB() /** * Try to establish a connection, which should fail because of example.com. */ - $this->expectException(\phpsap\interfaces\exceptions\IConnectionFailedException::class); + $this->expectException(IConnectionFailedException::class); $saprfc->invoke(); } @@ -99,8 +123,14 @@ abstract protected function mockSuccessfulRfcPing(); /** * Test a successful SAP remote function call to RFC_PING. + * @return void + * @throws IConnectionFailedException + * @throws IFunctionCallException + * @throws IIncompleteConfigException + * @throws IInvalidArgumentException + * @throws IUnknownFunctionException */ - public function testSuccessfulRfcPing() + public function testSuccessfulRfcPing(): void { if (!extension_loaded(static::getModuleName())) { //load functions mocking SAP RFC module functions or class methods @@ -119,9 +149,9 @@ public function testSuccessfulRfcPing() /** * Data provider for incomplete configurations. - * @return array + * @return array> */ - public static function provideIncompleteConfig() + public static function provideIncompleteConfig(): array { return [ [new ConfigTypeA()], @@ -182,15 +212,21 @@ public static function provideIncompleteConfig() /** * Test a failed connection attempt using either the module or its mockup. - * @param \phpsap\interfaces\Config\IConfiguration $config - * @dataProvider provideIncompleteConfig + * @param IConfiguration $config + * @return void + * @throws IConnectionFailedException + * @throws IFunctionCallException + * @throws IIncompleteConfigException + * @throws IInvalidArgumentException + * @throws IUnknownFunctionException + * @dataProvider provideIncompleteConfig */ - public function testIncompleteConfig($config) + public function testIncompleteConfig(IConfiguration $config): void { /** * Connection with empty configuration will be considered incomplete. */ - $this->expectException(\phpsap\exceptions\IncompleteConfigException::class); + $this->expectException(IncompleteConfigException::class); static::newSapRfc('RFC_PING', null, $config, static::getApi('RFC_PING')) ->invoke(); } @@ -201,9 +237,15 @@ public function testIncompleteConfig($config) abstract protected function mockUnknownFunctionException(); /** - * Test invoking an unknown function an receiving an exception. + * Test invoking an unknown function and receiving an exception. + * @return void + * @throws IConnectionFailedException + * @throws IFunctionCallException + * @throws IIncompleteConfigException + * @throws IInvalidArgumentException + * @throws IUnknownFunctionException */ - public function testUnknownFunctionException() + public function testUnknownFunctionException(): void { if (!extension_loaded(static::getModuleName())) { //load functions mocking SAP RFC module functions or class methods @@ -214,7 +256,7 @@ public function testUnknownFunctionException() //load a valid config $config = static::getActualSapConfig(); } - $this->expectException(\phpsap\exceptions\UnknownFunctionException::class); + $this->expectException(UnknownFunctionException::class); $this->expectExceptionMessage('Unknown function RFC_PINGG'); static::newSapRfc('RFC_PINGG', null, $config)->invoke(); } @@ -227,8 +269,10 @@ abstract protected function mockRemoteFunctionCallWithParametersAndResults(); /** * Test successful SAP remote function call with parameters and results. + * @return void + * @throws IInvalidArgumentException */ - public function testRemoteFunctionCallWithParametersAndResults() + public function testRemoteFunctionCallWithParametersAndResults(): void { if (!extension_loaded(static::getModuleName())) { //load functions mocking SAP RFC module functions or class methods @@ -240,7 +284,7 @@ public function testRemoteFunctionCallWithParametersAndResults() $config = static::getActualSapConfig(); } //prepare a DateTime object for testing SAP date and time. - $testDateTime = new \DateTime('2019-10-30 10:20:30'); + $testDateTime = new DateTime('2019-10-30 10:20:30'); //prepare function call parameter $test_in = [ 'RFCFLOAT' => 70.11, @@ -290,13 +334,13 @@ public function testRemoteFunctionCallWithParametersAndResults() static::assertArrayHasKey('RFCTIME', $test_out, 'Missing RFCTIME in TEST_OUT!'); static::assertArrayHasKey('RFCDATE', $test_out, 'Missing RFCDATE in TEST_OUT!'); static::assertInstanceOf( - \DateInterval::class, + DateInterval::class, $test_out['RFCTIME'], 'Test OUT of RFCTIME is not DateInterval!' ); static::assertSame($testDateTime->format('H:i:s'), $test_out['RFCTIME']->format('%H:%i:%s')); static::assertInstanceOf( - \DateTime::class, + DateTime::class, $test_out['RFCDATE'], 'Test OUT of RFCDATE is not DateTime!' ); @@ -342,8 +386,10 @@ abstract protected function mockFailedRemoteFunctionCallWithParameters(); /** * Test a failed remote function call with parameters. + * @return void + * @throws IInvalidArgumentException */ - public function testFailedRemoteFunctionCallWithParameters() + public function testFailedRemoteFunctionCallWithParameters(): void { if (!extension_loaded(static::getModuleName())) { //load functions mocking SAP RFC module functions or class methods @@ -354,7 +400,7 @@ public function testFailedRemoteFunctionCallWithParameters() //load a valid config $config = static::getActualSapConfig(); } - $this->expectException(\phpsap\exceptions\FunctionCallException::class); + $this->expectException(FunctionCallException::class); $this->expectExceptionMessage('Function call RFC_READ_TABLE failed'); static::newSapRfc('RFC_READ_TABLE') ->setConfiguration($config) diff --git a/src/AbstractTestCase.php b/src/AbstractTestCase.php index 37dada5..556adae 100644 --- a/src/AbstractTestCase.php +++ b/src/AbstractTestCase.php @@ -1,15 +1,19 @@ 'sap.example.com', 'sysnr' => '001', 'client' => '002', @@ -39,7 +43,7 @@ abstract class AbstractTestCase extends TestCase * @param array $data * @param string $dataName */ - public function __construct($name = null, array $data = [], $dataName = '') + public function __construct(?string $name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); SapRfcModuleMocks::requireFile(static::getModuleTemplateFile()); @@ -50,23 +54,23 @@ public function __construct($name = null, array $data = [], $dataName = '') * Get a sample SAP config. * @return ConfigTypeA */ - public static function getSampleSapConfig() + public static function getSampleSapConfig(): ConfigTypeA { return new ConfigTypeA(static::$sampleSapConfig); } /** * Load an actual sap configuration. - * @return ConfigTypeA|ConfigTypeB + * @return IConfiguration */ - public static function getActualSapConfig() + public static function getActualSapConfig(): IConfiguration { /** * Actual implementation has to return the path of a valid configuration file. */ $configFile = static::getSapConfigFile(); if (file_exists($configFile) !== true) { - throw new \RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'Cannot find config file %s!', $configFile )); @@ -75,7 +79,7 @@ public static function getActualSapConfig() * Try to read the configuration file. */ if (($configJson = file_get_contents($configFile)) === false) { - throw new \RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'Cannot read from config file %s!', $configFile )); @@ -84,20 +88,20 @@ public static function getActualSapConfig() * Let the Config* classes decide what to do with the given string. * In case the string is not JSON, an exception will be thrown. */ - return ConfigCommon::jsonDecode($configJson); + return ConfigTypeA::jsonDecode($configJson); } /** * Load an actual SAP remote function call API description from file. * @param string $remoteFunction - * @return \phpsap\classes\Api\RemoteApi + * @return RemoteApi */ - public static function getApi($remoteFunction) + public static function getApi(string $remoteFunction): RemoteApi { $file = __DIR__ . DIRECTORY_SEPARATOR; $file .= sprintf('%s.json', $remoteFunction); if (file_exists($file) !== true) { - throw new \RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'Cannot find SAP remote function API file %s!', $file )); @@ -106,7 +110,7 @@ public static function getApi($remoteFunction) * Try to read the configuration file. */ if (($json = file_get_contents($file)) === false) { - throw new \RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'Cannot read from SAP remote function API file %s!', $file )); @@ -120,14 +124,14 @@ public static function getApi($remoteFunction) * defined. In case no SAP remote function call API has been defined, it will be * queried on the fly by connecting to the SAP remote system. In order to * connect to the SAP remote system, you need a connection configuration. - * @param string $name SAP remote function name. - * @param array|null $params SAP remote function call parameters. Default: null - * @param \phpsap\interfaces\Config\IConfiguration|null $config Connection configuration. Default: null - * @param \phpsap\interfaces\Api\IApi|null $api SAP remote function call API. Default: null + * @param string $name SAP remote function name. + * @param array|null $params SAP remote function call parameters. Default: null + * @param IConfiguration|null $config Connection configuration. Default: null + * @param IApi|null $api SAP remote function call API. Default: null * @return IFunction - * @throws \phpsap\interfaces\exceptions\IInvalidArgumentException + * @throws IInvalidArgumentException */ - public static function newSapRfc($name, array $params = null, IConfiguration $config = null, IApi $api = null) + public static function newSapRfc(string $name, array $params = null, IConfiguration $config = null, IApi $api = null): IFunction { $class = static::getClassName(); return new $class($name, $params, $config, $api); @@ -135,10 +139,10 @@ public static function newSapRfc($name, array $params = null, IConfiguration $co /** * Mock a SAP RFC module specific function or method. - * @param string $name - * @param \Closure $logic + * @param string $name + * @param Closure $logic */ - public static function mock($name, $logic) + public static function mock(string $name, Closure $logic): void { SapRfcModuleMocks::singleton()->mock($name, $logic); } @@ -147,29 +151,35 @@ public static function mock($name, $logic) * Return the name of the class, used for testing. * @return string */ - abstract public static function getClassName(); + public static function getClassName(): string + { + throw new LogicException(sprintf('Unimplemented %s::%s()', static::class, __FUNCTION__)); + } /** * Get the name of the PHP module. * @return string */ - abstract public static function getModuleName(); + abstract public static function getModuleName(): string; /** * Get the path to the PHP/SAP configuration file. * @return string */ - abstract public static function getSapConfigFile(); + public static function getSapConfigFile(): string + { + throw new LogicException(sprintf('Unimplemented %s::%s()', static::class, __FUNCTION__)); + } /** * Get the path to the filename containing the SAP RFC module mockups. * @return string */ - abstract public static function getModuleTemplateFile(); + abstract public static function getModuleTemplateFile(): string; /** * Get an array of valid SAP RFC module function or class method names. * @return array */ - abstract public static function getValidModuleFunctions(); + abstract public static function getValidModuleFunctions(): array; } diff --git a/src/SapRfcModuleMocks.php b/src/SapRfcModuleMocks.php index df3b462..26f9e89 100644 --- a/src/SapRfcModuleMocks.php +++ b/src/SapRfcModuleMocks.php @@ -1,18 +1,13 @@ validateId($name); - if (!is_object($logic) && ! $logic instanceof \Closure) { - throw new \InvalidArgumentException('Expect function to be closure!'); - } $this->set($nameValid, $logic); } /** * Validate an ID for the other methods. - * @param mixed $name The function name to validate. + * @param string $id The function name to validate. * @return string - * @throws \InvalidArgumentException The function name was no string or an empty + * @throws InvalidArgumentException The function name was no string or an empty * string, or not in the list of templates. */ - protected function validateId($name): string + protected function validateId(string $id): string { - $return = parent::validateId($name); + $return = parent::validateId($id); if (!in_array($return, static::$validModuleFunctions, true)) { - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '%s function not defined in template.', $return )); @@ -106,7 +93,7 @@ protected function validateId($name): string public function __construct() { if (static::$requireFile === null) { - throw new \RuntimeException('No module logic template file defined!'); + throw new RuntimeException('No module logic template file defined!'); } require_once static::$requireFile; }