Skip to content

Commit

Permalink
Fix multiple bugs with PHP 8.2 and 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex committed Nov 16, 2023
1 parent b13559e commit 96c0c52
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/Models/BooleanSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function parseUserQueryNames(string $input): string {
$name = trim($matches['search'][$i]);
if (!empty($queries[$name])) {
$fromS[] = $matches[0][$i];
$toS[] = '(' . trim($queries[$name]->getSearch()) . ')';
$toS[] = '(' . trim($queries[$name]->getSearch()->getRawInput()) . ')';
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ private function parseUserQueryIds(string $input): string {
$id = (int)(trim($matches['search'][$i])) - 1;
if (!empty($queries[$id])) {
$fromS[] = $matches[0][$i];
$toS[] = '(' . trim($queries[$id]->getSearch()) . ')';
$toS[] = '(' . trim($queries[$id]->getSearch()->getRawInput()) . ')';
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,11 @@ public static function getContentByParsing(string $url, string $path, array $att
}

$content = '';
$nodes = $xpath->query(new Gt\CssXPath\Translator($path));
$nodes = $xpath->query((new Gt\CssXPath\Translator($path))->asXPath());
if ($nodes != false) {
foreach ($nodes as $node) {
if (!empty($attributes['path_entries_filter'])) {
$filterednodes = $xpath->query(new Gt\CssXPath\Translator($attributes['path_entries_filter']), $node) ?: [];
$filterednodes = $xpath->query((new Gt\CssXPath\Translator($attributes['path_entries_filter']))->asXPath(), $node) ?: [];
foreach ($filterednodes as $filterednode) {
$filterednode->parentNode->removeChild($filterednode);
}
Expand Down
10 changes: 5 additions & 5 deletions cli/i18n/I18nFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function load(): array {
}

/**
* @param array<string,array<array<string>>> $i18n
* @param array<string,array<string,array<string,I18nValue>>> $i18n
*/
public function dump(array $i18n): void {
foreach ($i18n as $language => $file) {
Expand Down Expand Up @@ -67,7 +67,7 @@ private function process(string $filename): array {
} catch (ParseError $ex) {
if (defined('STDERR')) {
fwrite(STDERR, "Error while processing: $filename\n");
fwrite(STDERR, $ex);
fwrite(STDERR, $ex->getMessage());
}
die(1);
}
Expand Down Expand Up @@ -110,7 +110,7 @@ private function flatten(array $translation, string $prefix = ''): array {
* The first key is dropped since it represents the filename and we have
* no use of it.
*
* @param array<string> $translation
* @param array<string,I18nValue> $translation
* @return array<string,array<string,I18nValue>>
*/
private function unflatten(array $translation): array {
Expand All @@ -120,7 +120,7 @@ private function unflatten(array $translation): array {
foreach ($translation as $compoundKey => $value) {
$keys = explode('.', $compoundKey);
array_shift($keys);
eval("\$a['" . implode("']['", $keys) . "'] = '" . addcslashes($value, "'") . "';");
eval("\$a['" . implode("']['", $keys) . "'] = '" . addcslashes($value->__toString(), "'") . "';");
}

return $a;
Expand All @@ -133,7 +133,7 @@ private function unflatten(array $translation): array {
* translation file. The array is first converted to a string then some
* formatting regexes are applied to match the original content.
*
* @param array<string> $translation
* @param array<string,I18nValue> $translation
*/
private function format(array $translation): string {
$translation = var_export($this->unflatten($translation), true);
Expand Down
6 changes: 5 additions & 1 deletion cli/i18n/I18nValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ class I18nValue {
private string $value;
private ?string $state = null;

public function __construct(string $data) {
/** @param I18nValue|string $data */
public function __construct($data) {
if ($data instanceof I18nValue) {
$data = $data->__toString();
}
$data = explode(' -> ', $data);

$this->value = array_shift($data);
Expand Down

0 comments on commit 96c0c52

Please sign in to comment.