From 63a02083b87287602fbdf2d61d44477984ccbe09 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Mon, 24 Apr 2023 17:37:44 +0200 Subject: [PATCH] PHP8 compatibility --- htdocs/core/lib/bank.lib.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 2 +- .../includes/stripe/stripe-php/lib/Collection.php | 8 +++++--- .../stripe/stripe-php/lib/StripeObject.php | 12 ++++++------ .../stripe-php/lib/Util/CaseInsensitiveArray.php | 14 ++++++++------ htdocs/includes/stripe/stripe-php/lib/Util/Set.php | 3 ++- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 736b200bea3..4e8d9969c3c 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -318,7 +318,7 @@ function getIbanHumanReadable(Account $account) { if ($account->getCountryCode() == 'FR') { require_once DOL_DOCUMENT_ROOT.'/includes/php-iban/oophp-iban.php'; - $ibantoprint = preg_replace('/[^a-zA-Z0-9]/', '', $account->iban); + $ibantoprint = preg_replace('/[^a-zA-Z0-9]/', '', empty($account->iban)?'':$account->iban); $iban = new PHP_IBAN\IBAN($ibantoprint); return $iban->HumanFormat(); } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 153773a6519..182f15b5aa5 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -414,7 +414,7 @@ if ($outputalsopricetotalwithtax) { if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlines') { $situationinvoicelinewithparent = 0; - if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) { + if (isset($line->fk_prev_id) && in_array($object->element, array('facture', 'facturedet'))) { if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice // Set constant to disallow editing during a situation cycle $situationinvoicelinewithparent = 1; diff --git a/htdocs/includes/stripe/stripe-php/lib/Collection.php b/htdocs/includes/stripe/stripe-php/lib/Collection.php index 899299d3dad..ab4536041d6 100644 --- a/htdocs/includes/stripe/stripe-php/lib/Collection.php +++ b/htdocs/includes/stripe/stripe-php/lib/Collection.php @@ -2,6 +2,8 @@ namespace Stripe; +use Traversable; + /** * Class Collection. * @@ -47,7 +49,7 @@ class Collection extends StripeObject implements \Countable, \IteratorAggregate $this->filters = $filters; } - public function offsetGet($k) + public function offsetGet($k): mixed { if (\is_string($k)) { return parent::offsetGet($k); @@ -107,7 +109,7 @@ class Collection extends StripeObject implements \Countable, \IteratorAggregate /** * @return int the number of objects in the current page */ - public function count() + public function count(): int { return \count($this->data); } @@ -116,7 +118,7 @@ class Collection extends StripeObject implements \Countable, \IteratorAggregate * @return \ArrayIterator an iterator that can be used to iterate * across objects in the current page */ - public function getIterator() + public function getIterator(): Traversable { return new \ArrayIterator($this->data); } diff --git a/htdocs/includes/stripe/stripe-php/lib/StripeObject.php b/htdocs/includes/stripe/stripe-php/lib/StripeObject.php index eca01a00e90..8bb146138b1 100644 --- a/htdocs/includes/stripe/stripe-php/lib/StripeObject.php +++ b/htdocs/includes/stripe/stripe-php/lib/StripeObject.php @@ -194,28 +194,28 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable } // ArrayAccess methods - public function offsetSet($k, $v) + public function offsetSet($k, $v): void { $this->{$k} = $v; } - public function offsetExists($k) + public function offsetExists($k): bool { return \array_key_exists($k, $this->_values); } - public function offsetUnset($k) + public function offsetUnset($k): void { unset($this->{$k}); } - public function offsetGet($k) + public function offsetGet($k): mixed { return \array_key_exists($k, $this->_values) ? $this->_values[$k] : null; } // Countable method - public function count() + public function count(): int { return \count($this->_values); } @@ -419,7 +419,7 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable } } - public function jsonSerialize() + public function jsonSerialize(): mixed { return $this->toArray(); } diff --git a/htdocs/includes/stripe/stripe-php/lib/Util/CaseInsensitiveArray.php b/htdocs/includes/stripe/stripe-php/lib/Util/CaseInsensitiveArray.php index 670ab0b6a7e..c1aad379438 100644 --- a/htdocs/includes/stripe/stripe-php/lib/Util/CaseInsensitiveArray.php +++ b/htdocs/includes/stripe/stripe-php/lib/Util/CaseInsensitiveArray.php @@ -2,6 +2,8 @@ namespace Stripe\Util; +use Traversable; + /** * CaseInsensitiveArray is an array-like class that ignores case for keys. * @@ -21,17 +23,17 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \IteratorAggrega $this->container = \array_change_key_case($initial_array, \CASE_LOWER); } - public function count() + public function count(): int { return \count($this->container); } - public function getIterator() + public function getIterator(): Traversable { return new \ArrayIterator($this->container); } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $offset = static::maybeLowercase($offset); if (null === $offset) { @@ -41,20 +43,20 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \IteratorAggrega } } - public function offsetExists($offset) + public function offsetExists($offset): bool { $offset = static::maybeLowercase($offset); return isset($this->container[$offset]); } - public function offsetUnset($offset) + public function offsetUnset($offset): void { $offset = static::maybeLowercase($offset); unset($this->container[$offset]); } - public function offsetGet($offset) + public function offsetGet($offset): mixed { $offset = static::maybeLowercase($offset); diff --git a/htdocs/includes/stripe/stripe-php/lib/Util/Set.php b/htdocs/includes/stripe/stripe-php/lib/Util/Set.php index 017f9297856..54b363cd4b3 100644 --- a/htdocs/includes/stripe/stripe-php/lib/Util/Set.php +++ b/htdocs/includes/stripe/stripe-php/lib/Util/Set.php @@ -4,6 +4,7 @@ namespace Stripe\Util; use ArrayIterator; use IteratorAggregate; +use Traversable; class Set implements IteratorAggregate { @@ -37,7 +38,7 @@ class Set implements IteratorAggregate return \array_keys($this->_elts); } - public function getIterator() + public function getIterator(): Traversable { return new ArrayIterator($this->toArray()); }