-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove some 'not defined' notices in importer code #399
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,11 +168,19 @@ function import_file( $file_path, $params ) | |
|
||
// first: set the count | ||
$params['total_tx_count'] = 0; | ||
foreach ($config->payments as $payment_spec) { | ||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path)->length; | ||
if (!empty($config->payments)) { | ||
foreach ($config->payments as $payment_spec) { | ||
if (!empty($payment_spec->path)) { | ||
$params['total_tx_count'] += (int) $this->xpath->query($payment_spec->path)->length; | ||
} | ||
} | ||
} | ||
foreach ($config->payment_lines as $payment_spec) { | ||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path)->length; | ||
if (!empty($config->payment_lines)) { | ||
foreach ($config->payment_lines as $payment_spec) { | ||
if (!empty($payment_spec->path)) { | ||
$params['total_tx_count'] += (int) $this->xpath->query($payment_spec->path)->length; | ||
} | ||
} | ||
} | ||
|
||
// then: run the importer | ||
|
@@ -185,11 +193,15 @@ function import_file( $file_path, $params ) | |
// first: set the count | ||
$params['total_tx_count'] = 0; | ||
foreach ($statements as $statement) { | ||
foreach ($config->payments as $payment_spec) { | ||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path, $statement)->length; | ||
if (!empty($config->payments)) { | ||
foreach ($config->payments as $payment_spec) { | ||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path, $statement)->length; | ||
} | ||
} | ||
foreach ($config->payment_lines as $payment_spec) { | ||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path, $statement)->length; | ||
if (!empty($config->payment_lines)) { | ||
foreach ($config->payment_lines as $payment_spec) { | ||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path, $statement)->length; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -315,7 +327,12 @@ protected function filterMatches($payment_node, $filter) { | |
*/ | ||
protected function import_payment($payment_spec, $payment_node, $stmt_data, $index, $params) { | ||
$config = $this->_plugin_config; | ||
$progress = ((float)$index / (float) $params['total_tx_count']); | ||
$total_tx_count = (float) $params['total_tx_count'] ?? 1.0; | ||
if ($total_tx_count) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this condition necessary now that there's a null-coalescing default of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might also use some brackets, too. If I get that right, he type cast will always cause a non- |
||
$progress = ((float)$index / ((float) $params['total_tx_count'] ?? 0.0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if so, this should read |
||
} else { | ||
$progress = 0; | ||
} | ||
|
||
$raw_data = $payment_node->ownerDocument->saveXML($payment_node); | ||
$raw_data = preg_replace("/>\s+</", "><", $raw_data); // 'flatten' raw_data | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As
empty()
doesn't check for the statement being an array/iterable, I suppose$config->payments
is guaranteed to always be an array if it's not empty?