diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d7bed9b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "deps" + allow: + - dependency-type: "direct" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "deps" diff --git a/.github/workflows/netlicensing-php-demo.yml b/.github/workflows/netlicensing-php-demo.yml new file mode 100644 index 0000000..2c386af --- /dev/null +++ b/.github/workflows/netlicensing-php-demo.yml @@ -0,0 +1,57 @@ +name: PHP Client - Demo Test + +on: + push: + branches: + - master + - feature/** + pull_request: + branches: + - master + - feature/** + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + php-version: ['8.2', '8.3', '8.4'] + + steps: + - uses: actions/checkout@v5 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + tools: composer:v2 + + - name: Validate composer manifests + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php-version }}- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Run PHPUnit + run: vendor/bin/phpunit --testsuite "Application Test Suite" + + - name: Run demo scenario (latest PHP) + if: matrix.php-version == '8.4' + run: | + cd demo + php NetLicensingDemo.php diff --git a/.github/workflows/netlicensing-php-dependency-test.yml b/.github/workflows/netlicensing-php-dependency-test.yml new file mode 100644 index 0000000..cf52230 --- /dev/null +++ b/.github/workflows/netlicensing-php-dependency-test.yml @@ -0,0 +1,34 @@ +name: PHP Client - Dependency Test + +on: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +permissions: + contents: read + +jobs: + dependency-check: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + php-version: ['8.4'] + + steps: + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + + - name: Bootstrap temporary project + run: | + composer create-project --no-interaction --prefer-dist composer/semver netlicensing-php-dependency + + - name: Require NetLicensing client + working-directory: netlicensing-php-dependency + run: | + composer require --no-interaction labs64/netlicensingclient-php + composer show labs64/netlicensingclient-php diff --git a/.github/workflows/netlicensing-php-dependency.yml b/.github/workflows/netlicensing-php-dependency.yml deleted file mode 100644 index d308852..0000000 --- a/.github/workflows/netlicensing-php-dependency.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: PHP Client - Dependency Test - -on: - schedule: - - cron: '*/30 * * * *' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Init project - run: | - composer create-project composer/semver netlicensing-php-dependency - - - name: Install dependencies - run: | - composer require labs64/netlicensingclient-php - composer install --prefer-dist --no-progress --no-suggest diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 86fa270..0000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: PHP Composer - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - 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- - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md - - - name: Run test suite - run: | - cd ./demo - php ./NetLicensingDemo.php diff --git a/.gitignore b/.gitignore index 7f8b48f..fbdf153 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ Thumbs.db .buildpath .project .settings* +.phpunit.cache diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 411fec1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: php - -php: - - 7.0 - - 7.1 - -before_script: - - composer update - - cd demo - - php NetLicensingDemo.php - - cd .. - -script: - - vendor/bin/phpunit diff --git a/README.md b/README.md index 12bd38f..0453e28 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # [Labs64 NetLicensing](https://netlicensing.io) Client (PHP) -[![Build Status](https://travis-ci.org/Labs64/NetLicensingClient-php.svg?branch=master)](https://travis-ci.org/Labs64/NetLicensingClient-php) +[![PHP Client - Demo Test](https://github.com/Labs64/NetLicensingClient-php/actions/workflows/netlicensing-php-demo.yml/badge.svg)](https://github.com/Labs64/NetLicensingClient-php/actions/workflows/netlicensing-php-demo.yml) [![Latest Stable Version](https://poser.pugx.org/labs64/netlicensingclient-php/v/stable)](https://packagist.org/packages/labs64/netlicensingclient-php) [![Total Downloads](https://poser.pugx.org/labs64/netlicensingclient-php/downloads)](https://packagist.org/packages/labs64/netlicensingclient-php) [![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/Labs64/NetLicensingClient-php/blob/master/LICENSE) @@ -24,7 +24,7 @@ $ composer require labs64/netlicensingclient-php ``` { "require": { - "labs64/netlicensingclient-php": "^2.5.0" + "labs64/netlicensingclient-php": "^2.6.0" } } ``` @@ -46,6 +46,6 @@ Labs64 NetLicensing Client (PHP) is licensed under the Apache License, Version 2 Visit Labs64 NetLicensing at https://netlicensing.io [Labs64 NetLicensing]: https://netlicensing.io -[RESTful API]: http://l64.cc/nl10 +[RESTful API]: https://netlicensing.io/wiki/restful-api [GitHub project]: https://github.com/Labs64/NetLicensingClient-php [PSR-2 Coding Standard]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md diff --git a/common/Constants.php b/common/Constants.php index e13f25c..8a88687 100644 --- a/common/Constants.php +++ b/common/Constants.php @@ -11,7 +11,7 @@ class Constants { - const NETLICENSING_VERSION = '2.5.0'; + const NETLICENSING_VERSION = '2.6.0'; const NUMBER = 'number'; const CASCADE = 'forceCascade'; diff --git a/composer.json b/composer.json index 31b89c2..284afaa 100644 --- a/composer.json +++ b/composer.json @@ -37,17 +37,17 @@ "docs": "https://netlicensing.io/wiki/" }, "require": { - "php": ">=7.4", - "php-curl-class/php-curl-class": "^11.0.0", + "php": ">=8.2", + "php-curl-class/php-curl-class": "^11.0.0 || ^12.0.0", "fr3d/xmldsig": "^3.0", "ext-mbstring": "*", "ext-json": "*", "ext-dom": "*" }, "require-dev": { - "phpunit/phpunit": "~6.5.14", - "fzaninotto/faker": "^v1.9.2", - "wp-cli/php-cli-tools": "^v0.11.11" + "phpunit/phpunit": "^10.5", + "fakerphp/faker": "^1.23", + "wp-cli/php-cli-tools": "^0.12" }, "autoload": { "files": [ diff --git a/demo/NetLicensingDemo.php b/demo/NetLicensingDemo.php index b89f3f4..72121a0 100644 --- a/demo/NetLicensingDemo.php +++ b/demo/NetLicensingDemo.php @@ -863,7 +863,7 @@ public function createLicense() $license->setStartDate('now'); $license->setActive(true); - $this->license = LicenseService::create($this->context, $this->licensee->getNumber(), $this->licenseeTemplate->getNumber(), null, $license); + $this->license = LicenseService::create($this->context, $this->licensee->getNumber(), $this->licenseeTemplate->getNumber(), $license); //output $headers = ['Number', 'Name']; @@ -941,7 +941,7 @@ public function updateLicense() $this->license->setName($this->faker->sentence(6, true)); - $this->license = LicenseService::update($this->context, $this->license->getNumber(), null, $this->license); + $this->license = LicenseService::update($this->context, $this->license->getNumber(), $this->license); //output $headers = ['Number', 'Name']; @@ -1263,9 +1263,9 @@ private function error($apiMethod, Exception $exception) exit(); } - private function table(array $headers, array $rows = null) + private function table(array $headers, ?array $rows = null) { - $table = new Table($headers, $rows, null); + $table = new Table($headers, $rows ?? []); $table->display(); } diff --git a/entity/BaseEntity.php b/entity/BaseEntity.php index 07719fb..f654973 100644 --- a/entity/BaseEntity.php +++ b/entity/BaseEntity.php @@ -87,7 +87,7 @@ public function __get(string $key) * @param mixed $value * @return void */ - public function __set(string $key, $value) + public function __set(string $key, mixed $value): void { $this->setProperty($key, $value); } diff --git a/entity/LicenseTransactionJoin.php b/entity/LicenseTransactionJoin.php index b7b3cb0..cff5ed7 100644 --- a/entity/LicenseTransactionJoin.php +++ b/entity/LicenseTransactionJoin.php @@ -14,7 +14,7 @@ class LicenseTransactionJoin protected ?License $license = null; - public function __construct(Transaction $transaction = null, License $license = null) + public function __construct(?Transaction $transaction = null, ?License $license = null) { $this->transaction = $transaction; $this->license = $license; diff --git a/entity/traits/Properties.php b/entity/traits/Properties.php index 5d47953..4b1a6c9 100644 --- a/entity/traits/Properties.php +++ b/entity/traits/Properties.php @@ -43,7 +43,7 @@ trait Properties * @return mixed * @throws Exception */ - public function getProperty(string $property, $default = null) + public function getProperty(string $property, mixed $default = null): mixed { if (!$property) return $default; @@ -76,7 +76,7 @@ public function getProperties(): array * @param mixed $value * @return $this */ - public function setProperty(string $property, $value) + public function setProperty(string $property, mixed $value): static { $this->properties[$property] = ($this->hasCast($property)) ? $this->castSetProperty($property, $value) : $value; return $this; @@ -89,7 +89,7 @@ public function setProperty(string $property, $value) * @param $value * @return $this */ - public function addProperty($property, $value) + public function addProperty(string $property, mixed $value): static { $this->setProperty($property, $value); return $this; @@ -103,7 +103,7 @@ public function addProperty($property, $value) * @param bool $sync * @return $this */ - public function setProperties(array $properties, $sync = false) + public function setProperties(array $properties, bool $sync = false): static { $this->properties = []; @@ -129,7 +129,7 @@ public function setProperties(array $properties, $sync = false) * @param $property * @return $this */ - public function removeProperty($property) + public function removeProperty(string $property): static { unset($this->properties[$property]); return $this; @@ -142,7 +142,7 @@ public function removeProperty($property) * @param mixed $default * @return mixed */ - public function getOriginal(string $property = null, $default = null) + public function getOriginal(?string $property = null, mixed $default = null): mixed { if (is_null($property)) return $this->original; return $this->original[$property] ?? $default; @@ -154,7 +154,7 @@ public function getOriginal(string $property = null, $default = null) * * @return $this */ - public function syncOriginal() + public function syncOriginal(): static { $this->original = $this->properties; return $this; @@ -166,7 +166,7 @@ public function syncOriginal() * @param string $property * @return $this */ - public function syncOriginalProperty(string $property) + public function syncOriginalProperty(string $property): static { $this->original[$property] = $this->properties[$property]; return $this; @@ -179,7 +179,7 @@ public function syncOriginalProperty(string $property) * @param array|string|null $types * @return bool */ - public function hasCast(string $property, $types = null): bool + public function hasCast(string $property, array|string|null $types = null): bool { if (array_key_exists($property, $this->casts)) { return !$types || in_array($this->getCastType($property), (array)$types, true); @@ -205,7 +205,7 @@ protected function getCastType(string $property): string * @param array|string|null $attributes * @return bool */ - public function isClean($attributes = null): bool + public function isClean(array|string|null $attributes = null): bool { return !$this->isDirty(...func_get_args()); } @@ -216,7 +216,7 @@ public function isClean($attributes = null): bool * @param array|string|null $properties * @return bool */ - public function isDirty($properties = null): bool + public function isDirty(array|string|null $properties = null): bool { $dirty = $this->getDirty(); @@ -291,7 +291,7 @@ protected function originalIsNumericallyEquivalent(string $property): bool * @return mixed * @throws Exception */ - protected function castGetProperty(string $property, $value) + protected function castGetProperty(string $property, mixed $value): mixed { if (is_null($value)) { return null; @@ -331,7 +331,7 @@ protected function castGetProperty(string $property, $value) * @param mixed $value * @return mixed */ - protected function castSetProperty(string $property, $value) + protected function castSetProperty(string $property, mixed $value): mixed { if (is_null($value)) { return null; @@ -382,7 +382,7 @@ protected function fromJson(string $value, bool $asObject = false) * @param $value * @return string */ - protected function asDateTime($value): string + protected function asDateTime(mixed $value): string { // If the value is already a DateTime instance, we will just skip the rest of diff --git a/phpunit.xml b/phpunit.xml index 8ec950c..be31f49 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,12 +1,15 @@ - + - - ./tests - + ./tests diff --git a/service/LicenseService.php b/service/LicenseService.php index afe940b..e8c17e3 100644 --- a/service/LicenseService.php +++ b/service/LicenseService.php @@ -29,21 +29,21 @@ class LicenseService * license template that the license is created from * @param string $licenseTemplateNumber * + * non-null properties will be taken for the new object, null properties will either stay null, or will + * be set to a default value, depending on property. + * @param License $license + * * For privileged logins specifies transaction for the license creation. For regular logins new * transaction always created implicitly, and the operation will be in a separate transaction. * Transaction is generated with the provided transactionNumber, or, if transactionNumber is null, with * auto-generated number. * @param null|string $transactionNumber * - * non-null properties will be taken for the new object, null properties will either stay null, or will - * be set to a default value, depending on property. - * @param License $license - * * @return License|null * @throws MalformedArgumentsException * @throws RestException */ - public static function create(Context $context, string $licenseeNumber, string $licenseTemplateNumber, string $transactionNumber = null, License $license): ?License + public static function create(Context $context, string $licenseeNumber, string $licenseTemplateNumber, License $license, ?string $transactionNumber = null): ?License { CheckUtils::paramNotEmpty($licenseeNumber, Constants::LICENSEE_NUMBER); CheckUtils::paramNotEmpty($licenseTemplateNumber, Constants::LICENSE_TEMPLATE_NUMBER); @@ -111,7 +111,7 @@ public static function get(Context $context, string $number): ?License * @return Page * @throws RestException */ - public static function getList(Context $context, $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; @@ -146,19 +146,19 @@ public static function getList(Context $context, $filter = null): Page * license number * @param string $number * + * non-null properties will be updated to the provided values, null properties will stay unchanged. + * @param License $license + * * transaction for the license update. Created implicitly if transactionNumber is null. In this case the * operation will be in a separate transaction. * @param string|null $transactionNumber * - * non-null properties will be updated to the provided values, null properties will stay unchanged. - * @param License $license - * * return updated license. * @return License|null * @throws MalformedArgumentsException * @throws RestException */ - public static function update(Context $context, string $number, string $transactionNumber = null, License $license): ?License + public static function update(Context $context, string $number, License $license, ?string $transactionNumber = null): ?License { CheckUtils::paramNotEmpty($number, Constants::NUMBER); diff --git a/service/LicenseTemplateService.php b/service/LicenseTemplateService.php index 620a11d..3137a60 100644 --- a/service/LicenseTemplateService.php +++ b/service/LicenseTemplateService.php @@ -100,7 +100,7 @@ public static function get(Context $context, string $number): ?LicenseTemplate * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/LicenseeService.php b/service/LicenseeService.php index c959c6b..d72eb69 100644 --- a/service/LicenseeService.php +++ b/service/LicenseeService.php @@ -102,7 +102,7 @@ public static function get(Context $context, string $number): ?Licensee * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/NetLicensingService.php b/service/NetLicensingService.php index 004ef63..2252a98 100644 --- a/service/NetLicensingService.php +++ b/service/NetLicensingService.php @@ -214,7 +214,7 @@ protected function validateRestUrl($restUrl): bool * @param Context $context * @throws RestException */ - private function configure(Context $context) + private function configure(Context $context): void { if (!$context->getSecurityMode()) { throw new RestException('Security mode must be specified'); diff --git a/service/PaymentMethodService.php b/service/PaymentMethodService.php index 0c34a64..25abc18 100644 --- a/service/PaymentMethodService.php +++ b/service/PaymentMethodService.php @@ -31,7 +31,7 @@ class PaymentMethodService * @throws MalformedArgumentsException * @throws RestException */ - public static function get(Context $context, $number): ?PaymentMethod + public static function get(Context $context, string $number): ?PaymentMethod { CheckUtils::paramNotEmpty($number, Constants::NUMBER); @@ -62,7 +62,7 @@ public static function get(Context $context, $number): ?PaymentMethod * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/ProductModuleService.php b/service/ProductModuleService.php index 15b954e..76e63e4 100644 --- a/service/ProductModuleService.php +++ b/service/ProductModuleService.php @@ -100,7 +100,7 @@ public static function get(Context $context, string $number): ?ProductModule * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/ProductService.php b/service/ProductService.php index 484227a..d75b52f 100644 --- a/service/ProductService.php +++ b/service/ProductService.php @@ -92,7 +92,7 @@ public static function get(Context $context, string $number): ?Product * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/TokenService.php b/service/TokenService.php index edd201c..953316b 100644 --- a/service/TokenService.php +++ b/service/TokenService.php @@ -91,7 +91,7 @@ public static function get(Context $context, string $number): ?Token * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/TransactionService.php b/service/TransactionService.php index f2a1623..280f8a8 100644 --- a/service/TransactionService.php +++ b/service/TransactionService.php @@ -69,7 +69,7 @@ public static function create(Context $context, Transaction $transaction): ?Tran * @throws MalformedArgumentsException * @throws RestException */ - public static function get(Context $context, $number): ?Transaction + public static function get(Context $context, string $number): ?Transaction { CheckUtils::paramNotEmpty($number, Constants::NUMBER); @@ -100,7 +100,7 @@ public static function get(Context $context, $number): ?Transaction * @return Page * @throws RestException */ - public static function getList(Context $context, string $filter = null): Page + public static function getList(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/UtilityService.php b/service/UtilityService.php index 37afbe2..82d12b6 100644 --- a/service/UtilityService.php +++ b/service/UtilityService.php @@ -89,7 +89,7 @@ public static function listLicensingModels(Context $context): Page * @return Page * @throws RestException */ - public static function listCountries(Context $context, string $filter = null): Page + public static function listCountries(Context $context, ?string $filter = null): Page { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; diff --git a/service/ValidationService.php b/service/ValidationService.php index eda7411..3fe300f 100644 --- a/service/ValidationService.php +++ b/service/ValidationService.php @@ -53,7 +53,7 @@ static public function validate(Context $context, string $number, ValidationPara * @throws MalformedArgumentsException * @throws RestException */ - static public function retrieveValidationFile(Context $context, string $number, ValidationParameters $validationParameters) + static public function retrieveValidationFile(Context $context, string $number, ValidationParameters $validationParameters): mixed { CheckUtils::paramNotEmpty($number, Constants::NUMBER); diff --git a/vo/Context.php b/vo/Context.php index f3f25c2..77e3957 100644 --- a/vo/Context.php +++ b/vo/Context.php @@ -125,7 +125,7 @@ public function getValues(): array * @param mixed $value * @return $this */ - public function setValue(string $key, $value): Context + public function setValue(string $key, mixed $value): Context { $this->values[$key] = $value; return $this; @@ -179,7 +179,7 @@ public function __get(string $key) * @param mixed $value * @return void */ - public function __set(string $key, $value) + public function __set(string $key, mixed $value): void { $this->setValue($key, $value); } @@ -190,7 +190,7 @@ public function __set(string $key, $value) * @param string $key * @return bool */ - public function __isset(string $key) + public function __isset(string $key): bool { return !is_null($this->getValue($key)); } @@ -201,7 +201,7 @@ public function __isset(string $key) * @param string $key * @return void */ - public function __unset(string $key) + public function __unset(string $key): void { unset($this->values[$key]); } diff --git a/vo/Page.php b/vo/Page.php index d1cf2c8..f726ae9 100644 --- a/vo/Page.php +++ b/vo/Page.php @@ -123,7 +123,7 @@ public function hasNext(): bool * @param mixed $offset * @return bool */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return array_key_exists($offset, $this->content); } @@ -134,7 +134,7 @@ public function offsetExists($offset): bool * @param mixed $offset * @return mixed */ - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->content[$offset]; } @@ -146,7 +146,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { if (is_null($offset)) { $this->content[] = $value; @@ -161,7 +161,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->content[$offset]); } diff --git a/vo/ValidationParameters.php b/vo/ValidationParameters.php index b9a1192..32772a3 100644 --- a/vo/ValidationParameters.php +++ b/vo/ValidationParameters.php @@ -52,7 +52,7 @@ public function getLicenseeProperties(): array * @param $value * @return $this */ - public function setLicenseeProperty(string $key, $value): ValidationParameters + public function setLicenseeProperty(string $key, mixed $value): ValidationParameters { $this->licenseeProperties[$key] = $value; @@ -65,9 +65,9 @@ public function setLicenseeProperty(string $key, $value): ValidationParameters * @param string $key * @return mixed */ - public function getLicenseeProperty(string $key) + public function getLicenseeProperty(string $key): mixed { - return $this->licenseeProperties[$key]; + return $this->licenseeProperties[$key] ?? null; } /** @@ -87,9 +87,10 @@ public function setLicenseeName(string $licenseeName): ValidationParameters return $this; } - public function getLicenseeName() + public function getLicenseeName(): ?string { - return $this->getLicenseeProperty(Constants::LICENSEE_PROP_LICENSEE_NAME); + $value = $this->getLicenseeProperty(Constants::LICENSEE_PROP_LICENSEE_NAME); + return is_string($value) ? $value : null; } /** @@ -111,9 +112,10 @@ public function setLicenseeSecret(string $licenseeSecret): ValidationParameters /** * @deprecated use 'NodeLocked' licensing model instead */ - public function getLicenseeSecret() + public function getLicenseeSecret(): ?string { - return $this->getLicenseeProperty(Constants::LICENSE_PROP_LICENSEE_SECRET); + $value = $this->getLicenseeProperty(Constants::LICENSE_PROP_LICENSEE_SECRET); + return is_string($value) ? $value : null; } public function getParameters(): array @@ -121,7 +123,7 @@ public function getParameters(): array return $this->parameters; } - public function getProductModuleValidationParameters($productModuleNumber) + public function getProductModuleValidationParameters(string $productModuleNumber): array { if (empty($this->parameters[$productModuleNumber])) { $this->parameters[$productModuleNumber] = array(); @@ -129,7 +131,7 @@ public function getProductModuleValidationParameters($productModuleNumber) return $this->parameters[$productModuleNumber]; } - public function setProductModuleValidationParameters($productModuleNumber, $productModuleParameters) + public function setProductModuleValidationParameters(string $productModuleNumber, array $productModuleParameters): void { if (empty($this->parameters[$productModuleNumber])) { $this->parameters[$productModuleNumber] = array(); diff --git a/vo/ValidationResults.php b/vo/ValidationResults.php index 9300872..ebf1a49 100644 --- a/vo/ValidationResults.php +++ b/vo/ValidationResults.php @@ -32,18 +32,18 @@ public function getValidations(): array return $this->validators; } - public function getProductModuleValidation($productModuleNumber) + public function getProductModuleValidation(string $productModuleNumber): mixed { return $this->validators[$productModuleNumber] ?? null; } - public function setProductModuleValidation($productModuleNumber, $productModuleValidation): ValidationResults + public function setProductModuleValidation(string $productModuleNumber, mixed $productModuleValidation): ValidationResults { $this->validators[$productModuleNumber] = $productModuleValidation; return $this; } - public function __toString() + public function __toString(): string { $data = 'ValidationResult [';