mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-08 01:14:34 +02:00
Applied rector with PHP8.1 migration rules
This commit is contained in:
parent
dc6a67c2f0
commit
7ee01d9a05
303 changed files with 1228 additions and 3465 deletions
|
@ -29,25 +29,14 @@ class LogDataFormatter
|
|||
{
|
||||
private const STRING_MAX_LENGTH = 1024;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
private EntityManagerInterface $entityManager;
|
||||
private ElementTypeNameGenerator $elementTypeNameGenerator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, EntityManagerInterface $entityManager, ElementTypeNameGenerator $elementTypeNameGenerator)
|
||||
public function __construct(private readonly TranslatorInterface $translator, private readonly EntityManagerInterface $entityManager, private readonly ElementTypeNameGenerator $elementTypeNameGenerator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->elementTypeNameGenerator = $elementTypeNameGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given data of a log entry as HTML
|
||||
* @param mixed $data
|
||||
* @param AbstractLogEntry $logEntry
|
||||
* @param string $fieldName
|
||||
* @return string
|
||||
*/
|
||||
public function formatData($data, AbstractLogEntry $logEntry, string $fieldName): string
|
||||
public function formatData(mixed $data, AbstractLogEntry $logEntry, string $fieldName): string
|
||||
{
|
||||
if (is_string($data)) {
|
||||
$tmp = '<span class="text-muted user-select-none">"</span>' . mb_strimwidth(htmlspecialchars($data), 0, self::STRING_MAX_LENGTH, ) . '<span class="text-muted user-select-none">"</span>';
|
||||
|
@ -55,9 +44,8 @@ class LogDataFormatter
|
|||
//Show special characters and line breaks
|
||||
$tmp = preg_replace('/\n/', '<span class="text-muted user-select-none">\\n</span><br>', $tmp);
|
||||
$tmp = preg_replace('/\r/', '<span class="text-muted user-select-none">\\r</span>', $tmp);
|
||||
$tmp = preg_replace('/\t/', '<span class="text-muted user-select-none">\\t</span>', $tmp);
|
||||
|
||||
return $tmp;
|
||||
return preg_replace('/\t/', '<span class="text-muted user-select-none">\\t</span>', $tmp);
|
||||
}
|
||||
|
||||
if (is_bool($data)) {
|
||||
|
@ -126,7 +114,7 @@ class LogDataFormatter
|
|||
}
|
||||
|
||||
|
||||
} catch (\InvalidArgumentException|\ReflectionException $exception) {
|
||||
} catch (\InvalidArgumentException|\ReflectionException) {
|
||||
return '<i>unknown target class</i>: ' . $id;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +135,7 @@ class LogDataFormatter
|
|||
|
||||
try {
|
||||
$dateTime = new \DateTime($date, new \DateTimeZone($timezone));
|
||||
} catch (\Exception $exception) {
|
||||
} catch (\Exception) {
|
||||
return '<i>unknown DateTime format</i>';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue