mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #2909 from woocommerce/PCP-4028-fix-php-notices-related-to-settings-mapping
Fix PHP notices related to settings-mapping (4028)
This commit is contained in:
commit
10f251c73f
2 changed files with 144 additions and 46 deletions
|
@ -5,7 +5,7 @@
|
|||
* @package WooCommerce\PayPalCommerce\WcGateway\Settings
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
@ -18,44 +18,46 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|||
*/
|
||||
class Settings implements ContainerInterface {
|
||||
|
||||
const KEY = 'woocommerce-ppcp-settings';
|
||||
const KEY = 'woocommerce-ppcp-settings';
|
||||
|
||||
const CONNECTION_TAB_ID = 'ppcp-connection';
|
||||
const PAY_LATER_TAB_ID = 'ppcp-pay-later';
|
||||
|
||||
const PAY_LATER_TAB_ID = 'ppcp-pay-later';
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $settings = array();
|
||||
private array $settings = array();
|
||||
|
||||
/**
|
||||
* The list of selected default button locations.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $default_button_locations;
|
||||
protected array $default_button_locations;
|
||||
|
||||
/**
|
||||
* The list of selected default pay later button locations.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $default_pay_later_button_locations;
|
||||
protected array $default_pay_later_button_locations;
|
||||
|
||||
/**
|
||||
* The list of selected default pay later messaging locations.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $default_pay_later_messaging_locations;
|
||||
protected array $default_pay_later_messaging_locations;
|
||||
|
||||
/**
|
||||
* The default ACDC gateway title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_dcc_gateway_title;
|
||||
protected string $default_dcc_gateway_title;
|
||||
|
||||
/**
|
||||
* A helper for mapping the new/old settings.
|
||||
|
@ -67,11 +69,17 @@ class Settings implements ContainerInterface {
|
|||
/**
|
||||
* Settings constructor.
|
||||
*
|
||||
* @param string[] $default_button_locations The list of selected default button locations.
|
||||
* @param string $default_dcc_gateway_title The default ACDC gateway title.
|
||||
* @param string[] $default_pay_later_button_locations The list of selected default pay later button locations.
|
||||
* @param string[] $default_pay_later_messaging_locations The list of selected default pay later messaging locations.
|
||||
* @param SettingsMapHelper $settings_map_helper A helper for mapping the new/old settings.
|
||||
* @param string[] $default_button_locations The list of selected default
|
||||
* button locations.
|
||||
* @param string $default_dcc_gateway_title The default ACDC gateway
|
||||
* title.
|
||||
* @param string[] $default_pay_later_button_locations The list of selected default
|
||||
* pay later button locations.
|
||||
* @param string[] $default_pay_later_messaging_locations The list of selected default
|
||||
* pay later messaging
|
||||
* locations.
|
||||
* @param SettingsMapHelper $settings_map_helper A helper for mapping the
|
||||
* new/old settings.
|
||||
*/
|
||||
public function __construct(
|
||||
array $default_button_locations,
|
||||
|
@ -90,10 +98,11 @@ class Settings implements ContainerInterface {
|
|||
/**
|
||||
* Returns the value for an id.
|
||||
*
|
||||
* @param string $id The value identificator.
|
||||
* @throws NotFoundException When nothing was found.
|
||||
*
|
||||
* @param string $id The value identifier.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws NotFoundException When nothing was found.
|
||||
*/
|
||||
public function get( $id ) {
|
||||
if ( ! $this->has( $id ) ) {
|
||||
|
@ -106,23 +115,24 @@ class Settings implements ContainerInterface {
|
|||
/**
|
||||
* Whether a value exists.
|
||||
*
|
||||
* @param string $id The value identificator.
|
||||
* @param string $id The value identifier.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has( $id ) {
|
||||
public function has( string $id ) {
|
||||
if ( $this->settings_map_helper->has_mapped_key( $id ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->load();
|
||||
|
||||
return array_key_exists( $id, $this->settings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value.
|
||||
*
|
||||
* @param string $id The value identificator.
|
||||
* @param string $id The value identifier.
|
||||
* @param mixed $value The value.
|
||||
*/
|
||||
public function set( $id, $value ) {
|
||||
|
@ -142,7 +152,7 @@ class Settings implements ContainerInterface {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function load(): bool {
|
||||
private function load() : bool {
|
||||
if ( $this->settings ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -175,6 +185,7 @@ class Settings implements ContainerInterface {
|
|||
}
|
||||
$this->settings[ $key ] = $value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue