Merge branch 'master' into settings-bundle

This commit is contained in:
Jan Böhmer 2024-06-24 21:15:14 +02:00
commit 3e657a7cac
305 changed files with 7543 additions and 4274 deletions

View file

@ -28,6 +28,7 @@ use Com\Tecnick\Barcode\Barcode;
/**
* This function is used to generate barcodes of various types using arbitrary (text) content.
* @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeHelperTest
*/
class BarcodeHelper
{
@ -66,7 +67,7 @@ class BarcodeHelper
{
$svg = $this->barcodeAsSVG($content, $type);
$base64 = $this->dataUri($svg, 'image/svg+xml');
$alt_text = $alt_text ?? $content;
$alt_text ??= $content;
return '<img src="'.$base64.'" width="'.$width.'" style="min-height: 25px;" alt="'.$alt_text.'"/>';
}

View file

@ -48,7 +48,7 @@ use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;
/**
* @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeNormalizerTest
* @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeScanHelperTest
*/
final class BarcodeScanHelper
{

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -17,7 +20,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Services\LabelSystem;
use Dompdf\Dompdf;
@ -36,10 +38,8 @@ class DompdfFactory implements DompdfFactoryInterface
private function createDirectoryIfNotExisting(string $path): void
{
if (!is_dir($path)) {
if (!mkdir($concurrentDirectory = $path, 0777, true) && !is_dir($concurrentDirectory)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
if (!is_dir($path) && (!mkdir($concurrentDirectory = $path, 0777, true) && !is_dir($concurrentDirectory))) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
}
@ -51,4 +51,4 @@ class DompdfFactory implements DompdfFactoryInterface
'tempDir' => $this->tmpDirectory,
]);
}
}
}

View file

@ -49,7 +49,7 @@ use App\Services\LabelSystem\Barcodes\BarcodeHelper;
use InvalidArgumentException;
/**
* @see \App\Tests\Services\LabelSystem\BarcodeGeneratorTest
* @see \App\Tests\Services\LabelSystem\LabelBarcodeGeneratorTest
*/
final class LabelBarcodeGenerator
{

View file

@ -97,7 +97,7 @@ final class LabelExampleElementsGenerator
$lot->setDescription('Example Lot');
$lot->setComment('Lot comment');
$lot->setExpirationDate(new DateTime('+1 days'));
$lot->setExpirationDate(new \DateTimeImmutable('+1 day'));
$lot->setStorageLocation($this->getStructuralData(StorageLocation::class));
$lot->setAmount(123);
$lot->setOwner($this->getUser());

View file

@ -86,7 +86,7 @@ final class GlobalProviders implements PlaceholderProviderInterface
return 'anonymous';
}
$now = new DateTime();
$now = new \DateTimeImmutable();
if ('[[DATETIME]]' === $placeholder) {
$formatter = IntlDateFormatter::create(

View file

@ -119,7 +119,7 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[DESCRIPTION_T]]' === $placeholder) {
return strip_tags($parsedown->line($part->getDescription()));
return strip_tags((string) $parsedown->line($part->getDescription()));
}
if ('[[COMMENT]]' === $placeholder) {
@ -127,7 +127,7 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[COMMENT_T]]' === $placeholder) {
return strip_tags($parsedown->line($part->getComment()));
return strip_tags((string) $parsedown->line($part->getComment()));
}
return null;

View file

@ -52,7 +52,7 @@ final class StructuralDBElementProvider implements PlaceholderProviderInterface
return $label_target->getComment();
}
if ('[[COMMENT_T]]' === $placeholder) {
return strip_tags($label_target->getComment());
return strip_tags((string) $label_target->getComment());
}
if ('[[FULL_PATH]]' === $placeholder) {
return $label_target->getFullPath();

View file

@ -42,7 +42,6 @@ declare(strict_types=1);
namespace App\Services\LabelSystem\PlaceholderProviders;
use App\Entity\Contracts\TimeStampableInterface;
use DateTime;
use IntlDateFormatter;
use Locale;
@ -57,11 +56,11 @@ final class TimestampableElementProvider implements PlaceholderProviderInterface
$formatter = new IntlDateFormatter(Locale::getDefault(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
if ('[[LAST_MODIFIED]]' === $placeholder) {
return $formatter->format($label_target->getLastModified() ?? new DateTime());
return $formatter->format($label_target->getLastModified() ?? new \DateTimeImmutable());
}
if ('[[CREATION_DATE]]' === $placeholder) {
return $formatter->format($label_target->getAddedDate() ?? new DateTime());
return $formatter->format($label_target->getAddedDate() ?? new \DateTimeImmutable());
}
}