From 097041a43ade83a4e6e0351a3c4926a04e985374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 14 Feb 2026 23:33:40 +0100 Subject: [PATCH] Ran rector --- config/packages/doctrine.php | 4 +++- rector.php | 2 -- src/Controller/PartController.php | 7 ++++--- src/DataTables/Filters/PartSearchFilter.php | 2 +- .../UserSystem/PartUniqueIpnSubscriber.php | 2 ++ .../InfoProviderSystem/FieldToProviderMappingType.php | 3 ++- src/Services/ImportExportSystem/BOMImporter.php | 10 ++++++---- src/Services/ImportExportSystem/EntityExporter.php | 3 ++- src/Services/ImportExportSystem/EntityImporter.php | 5 +++-- .../InfoProviderSystem/DTOs/BulkSearchResponseDTO.php | 3 ++- .../InfoProviderSystem/Providers/BuerklinProvider.php | 2 +- src/Services/System/BackupManager.php | 6 ++++-- src/Validator/Constraints/UniquePartIpnConstraint.php | 2 ++ src/Validator/Constraints/UniquePartIpnValidator.php | 2 ++ 14 files changed, 34 insertions(+), 19 deletions(-) diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php index 47584ed7..e5be011f 100644 --- a/config/packages/doctrine.php +++ b/config/packages/doctrine.php @@ -20,12 +20,14 @@ declare(strict_types=1); +use Symfony\Config\DoctrineConfig; + /** * This class extends the default doctrine ORM configuration to enable native lazy objects on PHP 8.4+. * We have to do this in a PHP file, because the yaml file does not support conditionals on PHP version. */ -return static function(\Symfony\Config\DoctrineConfig $doctrine) { +return static function(DoctrineConfig $doctrine) { //On PHP 8.4+ we can use native lazy objects, which are much more efficient than proxies. if (PHP_VERSION_ID >= 80400) { $doctrine->orm()->enableNativeLazyObjects(true); diff --git a/rector.php b/rector.php index 936b447e..3444f60c 100644 --- a/rector.php +++ b/rector.php @@ -36,8 +36,6 @@ return RectorConfig::configure() PHPUnitSetList::PHPUNIT_90, PHPUnitSetList::PHPUNIT_110, PHPUnitSetList::PHPUNIT_CODE_QUALITY, - - ]) ->withRules([ diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index d9fcd7f1..b4f46a27 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Controller; +use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob; use App\DataTables\LogDataTable; use App\Entity\Attachments\AttachmentUpload; use App\Entity\Parts\Category; @@ -151,7 +152,7 @@ final class PartController extends AbstractController $jobId = $request->query->get('jobId'); $bulkJob = null; if ($jobId) { - $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); // Verify user owns this job if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) { $bulkJob = null; @@ -172,7 +173,7 @@ final class PartController extends AbstractController throw $this->createAccessDeniedException('Invalid CSRF token'); } - $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); if (!$bulkJob || $bulkJob->getCreatedBy() !== $this->getUser()) { throw $this->createNotFoundException('Bulk import job not found'); } @@ -338,7 +339,7 @@ final class PartController extends AbstractController $jobId = $request->query->get('jobId'); $bulkJob = null; if ($jobId) { - $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); // Verify user owns this job if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) { $bulkJob = null; diff --git a/src/DataTables/Filters/PartSearchFilter.php b/src/DataTables/Filters/PartSearchFilter.php index c0951d3a..9f6734e5 100644 --- a/src/DataTables/Filters/PartSearchFilter.php +++ b/src/DataTables/Filters/PartSearchFilter.php @@ -160,7 +160,7 @@ class PartSearchFilter implements FilterInterface if ($search_dbId) { $expressions[] = $queryBuilder->expr()->eq('part.id', ':id_exact'); $queryBuilder->setParameter('id_exact', (int) $this->keyword, - \Doctrine\DBAL\ParameterType::INTEGER); + ParameterType::INTEGER); } //Guard condition diff --git a/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php b/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php index ecc25b4f..690448a5 100644 --- a/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php +++ b/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php @@ -1,5 +1,7 @@ 'width: 80px;' ], 'constraints' => [ - new \Symfony\Component\Validator\Constraints\Range(['min' => 1, 'max' => 10]), + new Range(['min' => 1, 'max' => 10]), ], ]); } diff --git a/src/Services/ImportExportSystem/BOMImporter.php b/src/Services/ImportExportSystem/BOMImporter.php index 8a91c825..abf72d74 100644 --- a/src/Services/ImportExportSystem/BOMImporter.php +++ b/src/Services/ImportExportSystem/BOMImporter.php @@ -22,6 +22,8 @@ declare(strict_types=1); */ namespace App\Services\ImportExportSystem; +use App\Entity\Parts\Supplier; +use App\Entity\PriceInformations\Orderdetail; use App\Entity\Parts\Part; use App\Entity\ProjectSystem\Project; use App\Entity\ProjectSystem\ProjectBOMEntry; @@ -275,7 +277,7 @@ class BOMImporter $mapped_entries = []; // Collect all mapped entries for validation // Fetch suppliers once for efficiency - $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); $supplierSPNKeys = []; $suppliersByName = []; // Map supplier names to supplier objects foreach ($suppliers as $supplier) { @@ -371,7 +373,7 @@ class BOMImporter if ($supplier_spn !== null) { // Query for orderdetails with matching supplier and SPN - $orderdetail = $this->entityManager->getRepository(\App\Entity\PriceInformations\Orderdetail::class) + $orderdetail = $this->entityManager->getRepository(Orderdetail::class) ->findOneBy([ 'supplier' => $supplier, 'supplierpartnr' => $supplier_spn, @@ -535,7 +537,7 @@ class BOMImporter ]; // Add dynamic supplier fields based on available suppliers in the database - $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); foreach ($suppliers as $supplier) { $supplierName = $supplier->getName(); $targets[$supplierName . ' SPN'] = [ @@ -570,7 +572,7 @@ class BOMImporter ]; // Add supplier-specific patterns - $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); foreach ($suppliers as $supplier) { $supplierName = $supplier->getName(); $supplierLower = strtolower($supplierName); diff --git a/src/Services/ImportExportSystem/EntityExporter.php b/src/Services/ImportExportSystem/EntityExporter.php index 70feb8e6..9ed027ae 100644 --- a/src/Services/ImportExportSystem/EntityExporter.php +++ b/src/Services/ImportExportSystem/EntityExporter.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Services\ImportExportSystem; +use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Helpers\FilenameSanatizer; @@ -177,7 +178,7 @@ class EntityExporter $colIndex = 1; foreach ($columns as $column) { - $cellCoordinate = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex) . $rowIndex; + $cellCoordinate = Coordinate::stringFromColumnIndex($colIndex) . $rowIndex; $worksheet->setCellValue($cellCoordinate, $column); $colIndex++; } diff --git a/src/Services/ImportExportSystem/EntityImporter.php b/src/Services/ImportExportSystem/EntityImporter.php index a89be9dc..7b928d6c 100644 --- a/src/Services/ImportExportSystem/EntityImporter.php +++ b/src/Services/ImportExportSystem/EntityImporter.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Services\ImportExportSystem; +use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Parts\Category; @@ -419,14 +420,14 @@ class EntityImporter 'worksheet_title' => $worksheet->getTitle() ]); - $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn); + $highestColumnIndex = Coordinate::columnIndexFromString($highestColumn); for ($row = 1; $row <= $highestRow; $row++) { $rowData = []; // Read all columns using numeric index for ($colIndex = 1; $colIndex <= $highestColumnIndex; $colIndex++) { - $col = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex); + $col = Coordinate::stringFromColumnIndex($colIndex); try { $cellValue = $worksheet->getCell("{$col}{$row}")->getCalculatedValue(); $rowData[] = $cellValue ?? ''; diff --git a/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php b/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php index 58e9e240..3db09de3 100644 --- a/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Services\InfoProviderSystem\DTOs; +use Doctrine\ORM\Exception\ORMException; use App\Entity\Parts\Part; use Doctrine\ORM\EntityManagerInterface; use Traversable; @@ -176,7 +177,7 @@ readonly class BulkSearchResponseDTO implements \ArrayAccess, \IteratorAggregate * @param array $data * @param EntityManagerInterface $entityManager * @return BulkSearchResponseDTO - * @throws \Doctrine\ORM\Exception\ORMException + * @throws ORMException */ public static function fromSerializableRepresentation(array $data, EntityManagerInterface $entityManager): BulkSearchResponseDTO { diff --git a/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php b/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php index aa165bfe..c2291107 100644 --- a/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php +++ b/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php @@ -365,7 +365,7 @@ class BuerklinProvider implements BatchInfoProviderInterface, URLHandlerInfoProv * - prefers 'zoom' format, then 'product' format, then all others * * @param array|null $images - * @return \App\Services\InfoProviderSystem\DTOs\FileDTO[] + * @return FileDTO[] */ private function getProductImages(?array $images): array { diff --git a/src/Services/System/BackupManager.php b/src/Services/System/BackupManager.php index 9bdc7f71..4946bc24 100644 --- a/src/Services/System/BackupManager.php +++ b/src/Services/System/BackupManager.php @@ -22,6 +22,8 @@ declare(strict_types=1); namespace App\Services\System; +use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shivas\VersioningBundle\Service\VersionManagerInterface; @@ -334,7 +336,7 @@ readonly class BackupManager $params = $connection->getParams(); $platform = $connection->getDatabasePlatform(); - if ($platform instanceof \Doctrine\DBAL\Platforms\AbstractMySQLPlatform) { + if ($platform instanceof AbstractMySQLPlatform) { // Use mysql command to import - need to use shell to handle input redirection $mysqlCmd = 'mysql'; if (isset($params['host'])) { @@ -361,7 +363,7 @@ readonly class BackupManager if (!$process->isSuccessful()) { throw new \RuntimeException('MySQL import failed: ' . $process->getErrorOutput()); } - } elseif ($platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform) { + } elseif ($platform instanceof PostgreSQLPlatform) { // Use psql command to import $psqlCmd = 'psql'; if (isset($params['host'])) { diff --git a/src/Validator/Constraints/UniquePartIpnConstraint.php b/src/Validator/Constraints/UniquePartIpnConstraint.php index ca32f9ef..652f2bcd 100644 --- a/src/Validator/Constraints/UniquePartIpnConstraint.php +++ b/src/Validator/Constraints/UniquePartIpnConstraint.php @@ -1,5 +1,7 @@