mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 03:44:36 +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
|
@ -55,10 +55,10 @@ class HistoryHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements that are associated with the argument.
|
||||
* The returned array contains the given element.
|
||||
* Returns an array containing all elements that are associated with the argument.
|
||||
* The returned array contains the given element.
|
||||
*
|
||||
* @psalm-return array<AbstractParameter|array-key, mixed>
|
||||
* @return AbstractDBElement[]
|
||||
*/
|
||||
public function getAssociatedElements(AbstractDBElement $element): array
|
||||
{
|
||||
|
|
|
@ -57,7 +57,11 @@ class LogDiffFormatter
|
|||
]);
|
||||
}
|
||||
|
||||
private function diffNumeric($old_data, $new_data): string
|
||||
/**
|
||||
* @param numeric $old_data
|
||||
* @param numeric $new_data
|
||||
*/
|
||||
private function diffNumeric(int|float|string $old_data, int|float|string $new_data): string
|
||||
{
|
||||
if ((!is_numeric($old_data)) || (!is_numeric($new_data))) {
|
||||
throw new \InvalidArgumentException('The given data is not numeric.');
|
||||
|
|
|
@ -232,16 +232,17 @@ class TimeTravel
|
|||
{
|
||||
$reflection = new ReflectionClass($element::class);
|
||||
$property = $reflection->getProperty($field);
|
||||
$property->setAccessible(true);
|
||||
|
||||
return $property->getValue($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null|object $new_value
|
||||
*/
|
||||
protected function setField(AbstractDBElement $element, string $field, mixed $new_value): void
|
||||
{
|
||||
$reflection = new ReflectionClass($element::class);
|
||||
$property = $reflection->getProperty($field);
|
||||
$property->setAccessible(true);
|
||||
|
||||
$property->setValue($element, $new_value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue