mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Improved typing and phpdoc type annotations
This commit is contained in:
parent
3817ba774d
commit
b7c8ca2a48
39 changed files with 189 additions and 129 deletions
|
@ -77,19 +77,20 @@ final class LabelTextReplacer
|
|||
}
|
||||
|
||||
/**
|
||||
* Replaces all placeholders in the input lines.
|
||||
* Replaces all placeholders in the input lines.
|
||||
*
|
||||
* @param string $lines The input lines that should be replaced
|
||||
* @param object $target the object that should be used as source for the informations
|
||||
* @param object $target the object that should be used as source for the information
|
||||
*
|
||||
* @return string the Lines with replaced informations
|
||||
* @return string the Lines with replaced information
|
||||
*/
|
||||
public function replace(string $lines, object $target): string
|
||||
{
|
||||
$patterns = [
|
||||
'/(\[\[[A-Z_0-9]+\]\])/' => fn($match) => $this->handlePlaceholder($match[0], $target),
|
||||
'/(\[\[[A-Z_0-9]+\]\])/' => fn($match): string => $this->handlePlaceholder($match[0], $target),
|
||||
];
|
||||
|
||||
return preg_replace_callback_array($patterns, $lines);
|
||||
return preg_replace_callback_array($patterns, $lines) ?? throw new \RuntimeException('Could not replace placeholders!');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue