diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0b3dedb..a040bb9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,47 +1,46 @@ -name: Run tests +name: Run lint and tests on: pull_request: types: - opened - reopened - ready_for_review + workflow_dispatch: env: + PHP_VERSION: 8.3 PHP_EXTENSIONS: mbstring - PHP_TOOLS: composer:v2, phpunit:9.5 + PHP_TOOLS: composer:v2, phpunit:11 + +permissions: + id-token: write + contents: read jobs: run-tests: if: ${{ !github.event.pull_request.draft }} runs-on: ubuntu-latest - - strategy: - matrix: - php-version: - - 7.4 - steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install PHP + - name: Install PHP ${{ env.PHP_VERSION }} uses: shivammathur/setup-php@v2 with: coverage: none - php-version: ${{ matrix.php-version }} + php-version: ${{ env.PHP_VERSION }} extensions: ${{ env.PHP_EXTENSIONS }} tools: ${{ env.PHP_TOOLS }} - - - name: Determine composer cache directory - id: determine-composer-cache-directory - run: echo "::set-output name=directory::$(composer config cache-dir)" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 with: - path: ${{ steps.determine-composer-cache-directory.outputs.directory }} - key: php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }} - restore-keys: php-${{ matrix.php-version }}-composer- + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- # TODO test direct env php with github actios - name: Add config/env.test.php diff --git a/Readme.md b/Readme.md index 25aed9d..dcab949 100644 --- a/Readme.md +++ b/Readme.md @@ -8,13 +8,13 @@ Todos os passos e processos referentes à integração com o sistema de captura #### Pré-requisitos -- PHP `>=7.4` +- PHP `^8.2` #### Composer add composer.json ``` -"edson-nascimento/getnet-php": "^2.0" +"edson-nascimento/getnet-php": "^3.0" ``` ou execute ```base diff --git a/composer.json b/composer.json index 3d40e18..1567cc9 100644 --- a/composer.json +++ b/composer.json @@ -5,12 +5,12 @@ "license":"MIT", "type":"library", "require":{ - "php": ">=7.4" + "php": "^8.2" }, "require-dev":{ - "phpunit/phpunit":"^9", - "phpstan/phpstan":"^1.8.0", - "kint-php/kint":"^3.3", + "phpunit/phpunit": "^11.1.2", + "phpstan/phpstan": "^1.10.67", + "kint-php/kint": "^5.1.0", "monolog/monolog":"*" }, "autoload":{ diff --git a/phpstan.neon b/phpstan.neon index 86baff6..ce4b30a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,15 @@ parameters: level: 5 + phpVersion: 80300 + checkFunctionNameCase: true + checkInternalClassCaseSensitivity: true + reportMaybesInPropertyPhpDocTypes: true + checkExplicitMixedMissingReturn: true + reportMaybesInMethodSignatures: true + reportStaticMethodSignatures: true + checkTooWideReturnTypesInProtectedAndPublicMethods: true + checkDynamicProperties: true + reportAlwaysTrueInLastCondition: true paths: - src - tests diff --git a/phpunit.xml b/phpunit.xml index 907c058..6e5550c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,12 +1,20 @@ - + colors="true" + backupGlobals="false" + cacheResult="false" + cacheDirectory="cache/phpunit" + backupStaticProperties="false" + displayDetailsOnIncompleteTests="true" + displayDetailsOnSkippedTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" +> tests diff --git a/src/Getnet/API/BaseResponse.php b/src/Getnet/API/BaseResponse.php index dd25266..2bc7a75 100644 --- a/src/Getnet/API/BaseResponse.php +++ b/src/Getnet/API/BaseResponse.php @@ -43,7 +43,7 @@ class BaseResponse implements \JsonSerializable * * @return array */ - public function jsonSerialize() + public function jsonSerialize(): mixed { return get_object_vars($this); } @@ -272,7 +272,7 @@ public function getStatus() $this->status = Transaction::STATUS_ERROR; } elseif ($this->status_code == 500) { $this->status = Transaction::STATUS_ERROR; - } elseif ($this->status_code == 1 || isset($this->redirect_url)) { + } elseif ($this->status_code == 1 || (property_exists($this, 'redirect_url') && isset($this->redirect_url))) { $this->status = Transaction::STATUS_PENDING; } elseif (isset($this->status_label)) { // TODO check why diff --git a/src/Getnet/API/TraitEntity.php b/src/Getnet/API/TraitEntity.php index f96c571..c698002 100644 --- a/src/Getnet/API/TraitEntity.php +++ b/src/Getnet/API/TraitEntity.php @@ -4,7 +4,7 @@ trait TraitEntity { - public function jsonSerialize() + public function jsonSerialize(): mixed { $entity = clone $this; @@ -14,12 +14,8 @@ public function jsonSerialize() return $entity->toArray(); } - - /** - * - * @return array - */ - public function toArray() + + public function toArray(): array { $vars = get_object_vars($this); @@ -32,11 +28,7 @@ public function toArray() return $vars; } - /** - * - * @return false|string - */ - public function toJSON($hiddenNull = true) + public function toJSON($hiddenNull = true): string|false { if ($hiddenNull) { return json_encode($this); @@ -52,7 +44,7 @@ public function populateByArray(array $body, array $blockFields = []) $this->{$prop} = $value; } } - + return $this; }