mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 11:24:31 +02:00
Fixed some psalm issues.
This commit is contained in:
parent
eb9b24d5d7
commit
cb0aa7bc7a
32 changed files with 217 additions and 148 deletions
|
@ -60,7 +60,10 @@ class AmountFormatter
|
|||
}
|
||||
|
||||
/**
|
||||
* Formats the given value using the measurement unit and options.
|
||||
* Formats the given value using the measurement unit and options.
|
||||
*
|
||||
* @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
|
||||
* If set to null, it is assumed that the part amount is measured in pieces.
|
||||
*
|
||||
* @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
|
||||
* If set to null, it is assumed that the part amount is measured in pieces.
|
||||
|
@ -69,7 +72,7 @@ class AmountFormatter
|
|||
*
|
||||
* @throws InvalidArgumentException thrown if $value is not numeric
|
||||
*/
|
||||
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
|
||||
public function format(float $value, ?MeasurementUnit $unit = null, array $options = [])
|
||||
{
|
||||
if (! is_numeric($value)) {
|
||||
throw new InvalidArgumentException('$value must be an numeric value!');
|
||||
|
|
|
@ -55,13 +55,15 @@ class PartPreviewGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of attachments that can be used for previewing the part ordered by priority.
|
||||
* The priority is: Part MasterAttachment -> Footprint MasterAttachment -> Category MasterAttachment
|
||||
* -> Storelocation Attachment -> MeasurementUnit Attachment -> ManufacturerAttachment.
|
||||
* Returns a list of attachments that can be used for previewing the part ordered by priority.
|
||||
* The priority is: Part MasterAttachment -> Footprint MasterAttachment -> Category MasterAttachment
|
||||
* -> Storelocation Attachment -> MeasurementUnit Attachment -> ManufacturerAttachment.
|
||||
*
|
||||
* @param Part $part the part for which the attachments should be determined
|
||||
*
|
||||
* @return Attachment[]
|
||||
* @return (Attachment|null)[]
|
||||
*
|
||||
* @psalm-return list<Attachment|null>
|
||||
*/
|
||||
public function getPreviewAttachments(Part $part): array
|
||||
{
|
||||
|
|
|
@ -77,9 +77,10 @@ class EntityExporter
|
|||
}
|
||||
|
||||
/**
|
||||
* Exports an Entity or an array of entities to multiple file formats.
|
||||
* Exports an Entity or an array of entities to multiple file formats.
|
||||
*
|
||||
* @param Request $request the request that should be used for option resolving
|
||||
* @param AbstractNamedDBElement|object[] $entity
|
||||
*
|
||||
* @return Response the generated response containing the exported data
|
||||
*
|
||||
|
|
|
@ -187,7 +187,7 @@ class EntityURLGenerator
|
|||
throw new EntityNotSupportedException('The given entity is not supported yet!');
|
||||
}
|
||||
|
||||
public function viewURL($entity): string
|
||||
public function viewURL(Attachment $entity): ?string
|
||||
{
|
||||
if ($entity instanceof Attachment) {
|
||||
if ($entity->isExternal()) { //For external attachments, return the link to external path
|
||||
|
@ -201,7 +201,7 @@ class EntityURLGenerator
|
|||
throw new EntityNotSupportedException('The given entity is not supported yet!');
|
||||
}
|
||||
|
||||
public function downloadURL($entity): string
|
||||
public function downloadURL($entity): ?string
|
||||
{
|
||||
if ($entity instanceof Attachment) {
|
||||
if ($entity->isExternal()) { //For external attachments, return the link to external path
|
||||
|
|
|
@ -35,10 +35,12 @@ 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.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @psalm-return array<\App\Entity\Parameters\AbstractParameter|array-key, mixed>
|
||||
*/
|
||||
public function getAssociatedElements(AbstractDBElement $element): array
|
||||
{
|
||||
|
|
|
@ -209,6 +209,9 @@ class TimeTravel
|
|||
return $property->getValue($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|int|null $new_value
|
||||
*/
|
||||
protected function setField(AbstractDBElement $element, string $field, $new_value): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(get_class($element));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue