Changed:
- double-quotes to single - more space around concated strings - removed TODO as there is sadly no IOException in PHP
This commit is contained in:
parent
ff5673e2d8
commit
88cdb695b1
3 changed files with 19 additions and 19 deletions
|
@ -130,7 +130,6 @@ class DomainPatternBlocklist
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @todo maybe throw more explicit exception
|
|
||||||
*/
|
*/
|
||||||
public function exportToFile(string $filename)
|
public function exportToFile(string $filename)
|
||||||
{
|
{
|
||||||
|
@ -148,6 +147,7 @@ class DomainPatternBlocklist
|
||||||
* Appends to the local block list all the patterns from the provided list that weren't already present.
|
* Appends to the local block list all the patterns from the provided list that weren't already present.
|
||||||
*
|
*
|
||||||
* @param array $blocklist
|
* @param array $blocklist
|
||||||
|
*
|
||||||
* @return int The number of patterns actually added to the block list
|
* @return int The number of patterns actually added to the block list
|
||||||
*/
|
*/
|
||||||
public function append(array $blocklist): int
|
public function append(array $blocklist): int
|
||||||
|
|
|
@ -290,7 +290,7 @@ class XML
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
|
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
|
||||||
// http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
|
// http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
|
||||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
||||||
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
||||||
|
@ -300,7 +300,7 @@ class XML
|
||||||
if (! $xml_values) {
|
if (! $xml_values) {
|
||||||
Logger::debug('Xml::toArray: libxml: parse error: ' . $contents);
|
Logger::debug('Xml::toArray: libxml: parse error: ' . $contents);
|
||||||
foreach (libxml_get_errors() as $err) {
|
foreach (libxml_get_errors() as $err) {
|
||||||
Logger::debug('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message);
|
Logger::debug('libxml: parse: ' . $err->code . ' at ' . $err->line . ':' . $err->column . ' : ' . $err->message);
|
||||||
}
|
}
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
return [];
|
return [];
|
||||||
|
@ -350,7 +350,7 @@ class XML
|
||||||
}
|
}
|
||||||
$tag = strtolower($tag);
|
$tag = strtolower($tag);
|
||||||
|
|
||||||
if ($type == "open") { // The starting of the tag '<tag>'
|
if ($type == 'open') { // The starting of the tag '<tag>'
|
||||||
$parent[$level-1] = &$current;
|
$parent[$level-1] = &$current;
|
||||||
if (!is_array($current) || (!in_array($tag, array_keys($current)))) { // Insert New tag
|
if (!is_array($current) || (!in_array($tag, array_keys($current)))) { // Insert New tag
|
||||||
$current[$tag] = $result;
|
$current[$tag] = $result;
|
||||||
|
@ -377,7 +377,7 @@ class XML
|
||||||
$last_item_index = $repeated_tag_index[$tag . '_' . $level]-1;
|
$last_item_index = $repeated_tag_index[$tag . '_' . $level]-1;
|
||||||
$current = &$current[$tag][$last_item_index];
|
$current = &$current[$tag][$last_item_index];
|
||||||
}
|
}
|
||||||
} elseif ($type == "complete") { // Tags that ends in 1 line '<tag />'
|
} elseif ($type == 'complete') { // Tags that ends in 1 line '<tag />'
|
||||||
//See if the key is already taken.
|
//See if the key is already taken.
|
||||||
if (!isset($current[$tag])) { //New Key
|
if (!isset($current[$tag])) { //New Key
|
||||||
$current[$tag] = $result;
|
$current[$tag] = $result;
|
||||||
|
@ -452,7 +452,7 @@ class XML
|
||||||
if (!$suppress_log) {
|
if (!$suppress_log) {
|
||||||
Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]);
|
Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]);
|
||||||
foreach (libxml_get_errors() as $err) {
|
foreach (libxml_get_errors() as $err) {
|
||||||
Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]);
|
Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ':' . $err->column, 'message' => $err->message]);
|
||||||
}
|
}
|
||||||
Logger::debug('Erroring XML string', ['xml' => $s]);
|
Logger::debug('Erroring XML string', ['xml' => $s]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue