summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-19 19:10:03 +0200
committerChristian Grothoff <christian@grothoff.org>2020-10-19 19:10:03 +0200
commit051ca7e41d2fbad9f18fec76c314670bcd6a27f4 (patch)
tree87b9ce167ac46e352d7ed6757d83e9ed86c2bfa2
parente00ad679a3943dd1b52a635055a7436dfd1f6328 (diff)
downloadwoocommerce-taler-051ca7e41d2fbad9f18fec76c314670bcd6a27f4.tar.gz
woocommerce-taler-051ca7e41d2fbad9f18fec76c314670bcd6a27f4.tar.bz2
woocommerce-taler-051ca7e41d2fbad9f18fec76c314670bcd6a27f4.zip
fix remaining phpcs warnings/errors
-rw-r--r--plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php52
1 files changed, 36 insertions, 16 deletions
diff --git a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
index 5121992..aa5493e 100644
--- a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
+++ b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
@@ -114,11 +114,15 @@ function gnutaler_init_gateway_class() {
class WC_GNUTaler_Gateway extends WC_Payment_Gateway {
/**
+ * Cached handle to logging class.
+ *
* @var Plugin loggger.
*/
private static $logger = false;
/**
+ * True if logging is enabled in our configuration.
+ *
* @var Is logging enabled?
*/
private static $log_enabled = false;
@@ -249,6 +253,11 @@ function gnutaler_init_gateway_class() {
* Called when WC sends out the e-mail notification for refunds.
* Adds a Taler-specific notice for where to click to obtain
* the refund.
+ *
+ * @param WC_Order $wc_order The order.
+ * @param bool $sent_to_admin Not well documented by WooCommerce.
+ * @param string $plain_text The plain text of the email.
+ * @param string $email Target email address.
*/
public function add_content_refund_email( $wc_order, $sent_to_admin, $plain_text, $email ) {
if ( 'customer_refunded_order' === $email->id ) {
@@ -278,12 +287,16 @@ function gnutaler_init_gateway_class() {
if ( empty( self::$log ) ) {
self::$log = wc_get_logger();
}
- self::$log->clear( 'gnutaler' );
+ self::$log->clear( 'gnutaler' );
}
return $saved;
}
+ /**
+ * Required function to add the fields we want to show in the
+ * payment method selection dialog. We show none.
+ */
public function payment_fields() {
// We do not have any.
}
@@ -384,9 +397,10 @@ function gnutaler_init_gateway_class() {
* Sends a request to a GNU Taler Backend over HTTP and returns the result.
* The request can be sent as POST, GET, PUT or another method.
*
- * @param $method - POST, GET, PUT or another method.
- * @param $url - URL for the request to make to the GNU Taler Backend.
- * @param $body - The content of the request (for POST).
+ * @param string $method POST, GET, PUT or another method.
+ * @param string $url URL for the request to make to the GNU Taler Backend.
+ * @param string $body The content of the request (for POST).
+ *
* @return array The return array will either have the successful return value or a detailed error message.
*/
private function call_api( $method, $url, $body ): array {
@@ -485,8 +499,9 @@ function gnutaler_init_gateway_class() {
/**
* Verifying if the url to the backend given in the plugin options is valid or not.
*
- * @param $url - URL to the backend
- * @param $ecurrency - expected currency of the order
+ * @param string $url URL to the backend.
+ * @param string $ecurrency expected currency of the order.
+ *
* @return bool - Returns if valid or not.
*/
private function verify_backend_url( $url, $ecurrency ): bool {
@@ -594,7 +609,8 @@ function gnutaler_init_gateway_class() {
* If the payment process finished successfully the user is being redirected to its GNU Taler Wallet.
* If an error occurs it returns void and throws an error.
*
- * @param $order_id - ID of the order to get the Order from the WooCommerce Webshop
+ * @param string $order_id ID of the order to get the Order from the WooCommerce Webshop.
+ *
* @return array|void - Array with result => success and redirection url otherwise it returns void.
*/
public function process_payment( $order_id ) {
@@ -688,7 +704,8 @@ function gnutaler_init_gateway_class() {
/**
* Converts the order into a JSON format that can be send to the GNU Taler Backend.
*
- * @param $order_id - To get the order from the WooCommerce Webshop
+ * @param string $order_id ID of the order to get the Order from the WooCommerce Webshop.
+ *
* @return array - return the JSON Format.
*/
public function convert_to_checkout_json( $order_id ): array {
@@ -697,7 +714,7 @@ function gnutaler_init_gateway_class() {
$wc_order_currency = $wc_order->get_currency();
$wc_cart = WC()->cart->get_cart();
$wc_order_id = $wc_order->get_order_key() . '-' . $wc_order->get_order_number();
- $wc_order_products_array = $this->mutate_products_to_json_format( $wc_cart, $wc_order_currency, $wc_order );
+ $wc_order_products_array = $this->mutate_products_to_json_format( $wc_cart, $wc_order_currency );
$refund_delay = $this->get_option( 'GNU_Taler_refund_delay' );
$order_json = array(
'order' => array(
@@ -730,11 +747,12 @@ function gnutaler_init_gateway_class() {
/**
* Mutates the products in the cart into a format which can be included in a JSON file.
*
- * @param $wc_cart - The content of the WooCommerce Cart.
- * @param $wc_order_currency - The currency the WooCommerce Webshop uses.
+ * @param WC_Cart $wc_cart The content of the WooCommerce Cart.
+ * @param string $wc_order_currency The currency the WooCommerce Webshop uses.
+ *
* @return array - Returns an array of products.
*/
- private function mutate_products_to_json_format( $wc_cart, $wc_order_currency, $wc_order ): array {
+ private function mutate_products_to_json_format( $wc_cart, $wc_order_currency ): array {
$wc_order_products_array = array();
foreach ( $wc_cart as $product ) {
$wc_order_products_array[] = array(
@@ -753,7 +771,8 @@ function gnutaler_init_gateway_class() {
* If the refund request is finished successfully it returns an refund url, which can be send to the customer to finish the refund transaction.
* If an error it will throw a WP_Error message and inform the system administrator.
*
- * @param $wc_order
+ * @param WC_Order $wc_order The WooCommerce order object we are processing.
+ *
* @return array
*/
private function mutate_shipping_information_to_json_format( $wc_order ): array {
@@ -799,9 +818,10 @@ function gnutaler_init_gateway_class() {
* If the refund request is finished successfully it returns an refund url, which can be send to the customer to finish the refund transaction.
* If an error it will throw a WP_Error message and inform the system administrator.
*
- * @param $order_id - Order id for logging.
- * @param null $amount - Amount that is requested to be refunded.
- * @param string $reason - Reason for the refund request.
+ * @param string $order_id Order id for logging.
+ * @param string $amount Amount that is requested to be refunded.
+ * @param string $reason Reason for the refund request.
+ *
* @return bool|WP_Error - Returns true or throws an WP_Error message in case of error.
*/
public function process_refund( $order_id, $amount = null, $reason = '' ) {