From 1ce385cd6ef6fd39b579d6f567aec105f693c0a1 Mon Sep 17 00:00:00 2001 From: Kirill Fuks Date: Mon, 4 Sep 2023 12:59:22 +0200 Subject: [PATCH 1/4] fix: uninitialized properties which can cause errors --- src/RequestBuilder/PostgrestRequestBuilder.php | 1 + src/Response/Exceptions/PostgrestErrorException.php | 10 +++++----- src/Response/PostgrestResponse.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/RequestBuilder/PostgrestRequestBuilder.php b/src/RequestBuilder/PostgrestRequestBuilder.php index d2c180a..51f8fe4 100644 --- a/src/RequestBuilder/PostgrestRequestBuilder.php +++ b/src/RequestBuilder/PostgrestRequestBuilder.php @@ -53,6 +53,7 @@ final public function __construct( 'Content-Profile' => $this->schemaName, ]; $this->filters = []; + $this->method = ''; $this->body = null; $this->helper = new Helper(); } diff --git a/src/Response/Exceptions/PostgrestErrorException.php b/src/Response/Exceptions/PostgrestErrorException.php index 62ae551..ee62771 100644 --- a/src/Response/Exceptions/PostgrestErrorException.php +++ b/src/Response/Exceptions/PostgrestErrorException.php @@ -14,15 +14,15 @@ */ class PostgrestErrorException extends Exception { - private ?int $statusCode; + private ?int $statusCode = null; - private ?string $reasonPhrase; + private ?string $reasonPhrase = null; - private ?string $responseBody; + private ?string $responseBody = null; - private ?string $postgrestErrorCode; + private ?string $postgrestErrorCode = null; - private ?string $postgrestErrorMessage; + private ?string $postgrestErrorMessage = null; /** * Create a new PostgrestErrorException. diff --git a/src/Response/PostgrestResponse.php b/src/Response/PostgrestResponse.php index b263987..30cda52 100644 --- a/src/Response/PostgrestResponse.php +++ b/src/Response/PostgrestResponse.php @@ -28,7 +28,7 @@ class PostgrestResponse /** * @var array */ - private array $location; + private array $location = []; private int $contentRangeStart = 0; From 14a6931a940a2d265ac16e2fc840101a664e87d1 Mon Sep 17 00:00:00 2001 From: Kirill Fuks Date: Mon, 4 Sep 2023 13:16:17 +0200 Subject: [PATCH 2/4] fix: wrong branch name for coverage report --- .github/workflows/create-coverage-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-coverage-report.yml b/.github/workflows/create-coverage-report.yml index 056ce07..dde1094 100644 --- a/.github/workflows/create-coverage-report.yml +++ b/.github/workflows/create-coverage-report.yml @@ -13,7 +13,7 @@ on: - "**" pull_request: branches: - - "main" + - "master" paths: - "src/**.php" - "tests/**.php" From afd809956489a7903023fd4f314c000e10faa7e5 Mon Sep 17 00:00:00 2001 From: Kirill Fuks Date: Mon, 4 Sep 2023 13:16:44 +0200 Subject: [PATCH 3/4] chore: add changelog entry for pr fix --- CHANGELOG.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index db6fa98..9e457cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,36 @@ Versioning `__. `[Unreleased] `_ ----------------------------------------------------------- +Added +~~~~~ + +- n/a + +Changed +~~~~~~~ + +- n/a + +Deprecated +~~~~~~~~~~ + +- n/a + +Removed +~~~~~~~ + +- n/a + +Fixed +~~~~~ + +- Initialize properties with default values, to avoid errors when calling methods before setting properties + +Security +~~~~~~~~ + +- n/a + `[0.0.1] `_ - 2023-07-24 ------------------------------------------------------------------------ From f92bf64311c4c0ef02e7e61fcac8915bf528fff6 Mon Sep 17 00:00:00 2001 From: Kirill Fuks Date: Mon, 4 Sep 2023 13:17:28 +0200 Subject: [PATCH 4/4] fix: ommit version from composer.json file as it can cause errors when using with git tags --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 4f3eb62..e9f2c42 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,6 @@ "description": "PostgREST client for PHP. This library provides a synchronous and asynchronous interface to PostgREST.", "type": "library", "license": "BSD-3-Clause", - "version": "0.0.1", "authors": [ { "name": "Kirill Fuks",