diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 338a7ea..becca87 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -1,8 +1,14 @@ name: Bump version + on: push: branches: - master + +permissions: + actions: read + contents: write + jobs: bump-version: runs-on: ubuntu-latest @@ -11,19 +17,29 @@ jobs: with: fetch-depth: '0' - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.42.0 + uses: anothrNick/github-tag-action@1.44.0 id: version env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} WITH_V: true DEFAULT_BUMP: patch - name: Create release + uses: actions/github-script@v6 if: ${{ steps.version.outputs.new_tag }} != "" - uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + RELEASE_TAG: ${{ steps.version.outputs.new_tag }} with: - tag_name: ${{ steps.version.outputs.new_tag }} - release_name: Release ${{ steps.version.outputs.new_tag }} - draft: false - prerelease: false + script: | + try { + await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + } catch (error) { + core.setFailed(error.message); + } diff --git a/composer.json b/composer.json index 81164f9..b67ff0d 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,9 @@ "jacobsteringa/odoo-client": "<=0.3.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.32 || ^1.0.0", - "squizlabs/php_codesniffer": "^3.5" + "phpstan/phpstan": "^1", + "squizlabs/php_codesniffer": "^3.5", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-symfony": "^1" } } diff --git a/phpstan.neon b/phpstan.neon index 9c9d643..03df571 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,5 +2,5 @@ parameters: level: max paths: - . - excludes_analyse: + excludePaths: - vendor diff --git a/src/Odoo/Odoo.php b/src/Odoo/Odoo.php index 867b702..92643ee 100644 --- a/src/Odoo/Odoo.php +++ b/src/Odoo/Odoo.php @@ -34,9 +34,9 @@ class Odoo /** * Unique identifier for current user * - * @var integer + * @var integer|null */ - protected $uid; + protected $uid = null; /** * Current users username @@ -112,7 +112,7 @@ public function version(): array { $response = $this->getClient('common')->call('version'); - return $response; + return is_array($response) ? $response : []; } /** @@ -120,7 +120,7 @@ public function version(): array * * @return string Current timezone */ - public function timezone(): string + public function timezone(): ?string { $params = [ $this->database, @@ -128,7 +128,9 @@ public function timezone(): string $this->password ]; - return $this->getClient('common')->call('timezone_get', $params); + $response = $this->getClient('common')->call('timezone_get', $params); + + return is_string($response) ? $response : null; } /** @@ -153,7 +155,7 @@ public function search(string $model, array $data, int $offset = 0, int $limit = $response = $this->getClient('object')->call('execute', $params); - return $response; + return is_array($response) ? $response : []; } /** @@ -164,7 +166,7 @@ public function search(string $model, array $data, int $offset = 0, int $limit = * * @return integer Created model id */ - public function create(string $model, array $data): int + public function create(string $model, array $data): ?int { $params = $this->buildParams([ $model, @@ -174,7 +176,7 @@ public function create(string $model, array $data): int $response = $this->getClient('object')->call('execute', $params); - return $response; + return is_int($response) ? $response : null; } /** @@ -197,7 +199,7 @@ public function read(string $model, array $ids, array $fields = []): array $response = $this->getClient('object')->call('execute', $params); - return $response; + return is_array($response) ? $response : []; } /** @@ -229,7 +231,7 @@ public function searchRead( $response = $this->getClient('object')->call('execute', $params); - return $response; + return is_array($response) ? $response : []; } /** @@ -252,7 +254,7 @@ public function write(string $model, array $ids, array $fields): array $response = $this->getClient('object')->call('execute', $params); - return $response; + return is_array($response) ? $response : []; } /** @@ -271,7 +273,9 @@ public function unlink(string $model, array $ids): bool $ids ]); - return $this->getClient('object')->call('execute', $params); + $response = $this->getClient('object')->call('execute', $params); + + return is_bool($response) ? $response : false; } /** @@ -302,6 +306,7 @@ public function getReport(string $model, array $ids, string $type = 'qweb-pdf'): $state = false; while (!$state) { + /** @var array */ $report = $client->call( 'report_get', $this->buildParams([$reportId]) @@ -401,16 +406,18 @@ protected function getClient(?string $path = null): XmlRpcClient * * @return int $uid */ - protected function uid(): int + protected function uid(): ?int { if ($this->uid === null) { $client = $this->getClient('common'); - $this->uid = $client->call('login', [ + $response = $client->call('login', [ $this->database, $this->user, $this->password ]); + + $this->uid = is_int($response) ? $response : null; } return $this->uid;