From 179d6c46d5d89f7597b567b2ace070c0cab93e12 Mon Sep 17 00:00:00 2001 From: Ante Laca Date: Sat, 23 Dec 2023 06:18:11 +0100 Subject: [PATCH] PHP 8.2 compatibility (#7147) Co-authored-by: Ante Laca --- give.php | 12 ++++++++++++ includes/admin/abstract-admin-settings-page.php | 1 + includes/class-give-donate-form.php | 1 + includes/class-give-donor.php | 1 + src/Donors/Repositories/DonorRepositoryProxy.php | 1 + src/Framework/FieldsAPI/Option.php | 1 + src/Framework/QueryBuilder/Clauses/From.php | 9 ++++++--- src/Framework/QueryBuilder/Clauses/Join.php | 5 ++++- src/Framework/QueryBuilder/Clauses/Select.php | 5 ++++- 9 files changed, 31 insertions(+), 5 deletions(-) diff --git a/give.php b/give.php index 21b28daff9..63a3e06302 100644 --- a/give.php +++ b/give.php @@ -170,6 +170,18 @@ final class Give */ public $stripe; + /** + * @var Give_DB_Customers + * @deprecated use give()->donors instead + */ + public $customers; + + /** + * @var Give_DB_Customer_Meta + * @deprecated use give()->donor_meta instead + */ + public $customer_meta; + /** * @since 2.8.0 * diff --git a/includes/admin/abstract-admin-settings-page.php b/includes/admin/abstract-admin-settings-page.php index e1360e9e5b..40fc411cb9 100644 --- a/includes/admin/abstract-admin-settings-page.php +++ b/includes/admin/abstract-admin-settings-page.php @@ -20,6 +20,7 @@ * * @sine 1.8 */ + #[\AllowDynamicProperties] class Give_Settings_Page { /** diff --git a/includes/class-give-donate-form.php b/includes/class-give-donate-form.php index cbc1d322b5..293668043c 100644 --- a/includes/class-give-donate-form.php +++ b/includes/class-give-donate-form.php @@ -30,6 +30,7 @@ * @property $earnings * @property $post_type */ +#[\AllowDynamicProperties] class Give_Donate_Form { /** diff --git a/includes/class-give-donor.php b/includes/class-give-donor.php index 9cdb071945..21c123493e 100644 --- a/includes/class-give-donor.php +++ b/includes/class-give-donor.php @@ -21,6 +21,7 @@ * * @since 1.0 */ +#[\AllowDynamicProperties] class Give_Donor { /** diff --git a/src/Donors/Repositories/DonorRepositoryProxy.php b/src/Donors/Repositories/DonorRepositoryProxy.php index d4d24e820e..798039ce91 100644 --- a/src/Donors/Repositories/DonorRepositoryProxy.php +++ b/src/Donors/Repositories/DonorRepositoryProxy.php @@ -17,6 +17,7 @@ * * @throws InvalidArgumentException */ +#[\AllowDynamicProperties] class DonorRepositoryProxy { const SHARED_METHODS = ['insert', 'update', 'delete']; diff --git a/src/Framework/FieldsAPI/Option.php b/src/Framework/FieldsAPI/Option.php index 01e1a6a020..1f24488c18 100644 --- a/src/Framework/FieldsAPI/Option.php +++ b/src/Framework/FieldsAPI/Option.php @@ -56,6 +56,7 @@ public function getValue() /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return [ diff --git a/src/Framework/QueryBuilder/Clauses/From.php b/src/Framework/QueryBuilder/Clauses/From.php index 8eb3db827f..595b399aab 100644 --- a/src/Framework/QueryBuilder/Clauses/From.php +++ b/src/Framework/QueryBuilder/Clauses/From.php @@ -20,12 +20,15 @@ class From public $alias; /** - * @param string|RawSQL $table - * @param string|null $alias + * @param string|RawSQL $table + * @param string|null $alias */ public function __construct($table, $alias = null) { $this->table = QueryBuilder::prefixTable($table); - $this->alias = trim($alias); + + if ( ! is_null($alias)) { + $this->alias = trim($alias); + } } } diff --git a/src/Framework/QueryBuilder/Clauses/Join.php b/src/Framework/QueryBuilder/Clauses/Join.php index 69f4220ae3..f6bbb73c64 100644 --- a/src/Framework/QueryBuilder/Clauses/Join.php +++ b/src/Framework/QueryBuilder/Clauses/Join.php @@ -35,7 +35,10 @@ public function __construct($joinType, $table, $alias = null) { $this->table = QueryBuilder::prefixTable($table); $this->joinType = $this->getJoinType($joinType); - $this->alias = trim($alias); + + if ( ! is_null($alias)) { + $this->alias = trim($alias); + } } /** diff --git a/src/Framework/QueryBuilder/Clauses/Select.php b/src/Framework/QueryBuilder/Clauses/Select.php index 5bdedaa76e..1b523cf452 100644 --- a/src/Framework/QueryBuilder/Clauses/Select.php +++ b/src/Framework/QueryBuilder/Clauses/Select.php @@ -24,6 +24,9 @@ class Select public function __construct($column, $alias = null) { $this->column = trim($column); - $this->alias = trim($alias); + + if ( ! is_null($alias)) { + $this->alias = trim($alias); + } } }