diff --git a/rector.php b/rector.php index dbcefaf6..94ade3df 100644 --- a/rector.php +++ b/rector.php @@ -2,15 +2,17 @@ declare(strict_types=1); -use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; +use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\Config\RectorConfig; use Rector\Doctrine\Set\DoctrineSetList; +use Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; +use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; return static function (RectorConfig $rectorConfig): void { $rectorConfig->symfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml'); @@ -31,6 +33,10 @@ return static function (RectorConfig $rectorConfig): void { // register a single rule //$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + $rectorConfig->rules([ + DeclareStrictTypesRector::class, + ]); + // define sets of rules $rectorConfig->sets([ //PHP rules @@ -49,4 +55,9 @@ return static function (RectorConfig $rectorConfig): void { PHPUnitLevelSetList::UP_TO_PHPUNIT_90, PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]); + + $rectorConfig->skip([ + AddDoesNotPerformAssertionToNonAssertingTestRector::class, + CountArrayToEmptyArrayComparisonRector::class, + ]); }; diff --git a/src/Command/BackupCommand.php b/src/Command/BackupCommand.php index d68afb67..ef7d038f 100644 --- a/src/Command/BackupCommand.php +++ b/src/Command/BackupCommand.php @@ -1,5 +1,7 @@ . */ - namespace App\Command; use Symfony\Component\Console\Attribute\AsCommand; @@ -187,4 +189,4 @@ class CheckRequirementsCommand extends Command } -} \ No newline at end of file +} diff --git a/src/Command/Migrations/ImportPartKeeprCommand.php b/src/Command/Migrations/ImportPartKeeprCommand.php index 20269c0a..98272440 100644 --- a/src/Command/Migrations/ImportPartKeeprCommand.php +++ b/src/Command/Migrations/ImportPartKeeprCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command\Migrations; use Symfony\Component\Console\Attribute\AsCommand; @@ -141,4 +143,4 @@ class ImportPartKeeprCommand extends Command $io->success('Imported '.$count.' parts.'); } -} \ No newline at end of file +} diff --git a/src/Command/User/ConvertToSAMLUserCommand.php b/src/Command/User/ConvertToSAMLUserCommand.php index d59b00a4..b023a1ba 100644 --- a/src/Command/User/ConvertToSAMLUserCommand.php +++ b/src/Command/User/ConvertToSAMLUserCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command\User; use Symfony\Component\Console\Attribute\AsCommand; @@ -105,4 +107,4 @@ class ConvertToSAMLUserCommand extends Command return 0; } -} \ No newline at end of file +} diff --git a/src/Command/User/UpgradePermissionsSchemaCommand.php b/src/Command/User/UpgradePermissionsSchemaCommand.php index 758a7903..4947fd5c 100644 --- a/src/Command/User/UpgradePermissionsSchemaCommand.php +++ b/src/Command/User/UpgradePermissionsSchemaCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command\User; use Symfony\Component\Console\Attribute\AsCommand; diff --git a/src/Command/User/UserEnableCommand.php b/src/Command/User/UserEnableCommand.php index 182e8558..00753e94 100644 --- a/src/Command/User/UserEnableCommand.php +++ b/src/Command/User/UserEnableCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command\User; use Symfony\Component\Console\Attribute\AsCommand; @@ -99,4 +101,4 @@ class UserEnableCommand extends Command return self::SUCCESS; } -} \ No newline at end of file +} diff --git a/src/Command/User/UserListCommand.php b/src/Command/User/UserListCommand.php index cec70461..ca56c994 100644 --- a/src/Command/User/UserListCommand.php +++ b/src/Command/User/UserListCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command\User; use Symfony\Component\Console\Attribute\AsCommand; @@ -93,4 +95,4 @@ class UserListCommand extends Command return self::SUCCESS; } -} \ No newline at end of file +} diff --git a/src/Command/User/UsersPermissionsCommand.php b/src/Command/User/UsersPermissionsCommand.php index d78b0725..b4bcd99a 100644 --- a/src/Command/User/UsersPermissionsCommand.php +++ b/src/Command/User/UsersPermissionsCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command\User; use Symfony\Component\Console\Attribute\AsCommand; diff --git a/src/Command/VersionCommand.php b/src/Command/VersionCommand.php index 76f7db70..d2ce75e1 100644 --- a/src/Command/VersionCommand.php +++ b/src/Command/VersionCommand.php @@ -1,4 +1,7 @@ . */ - namespace App\Command; use Symfony\Component\Console\Attribute\AsCommand; @@ -60,4 +62,4 @@ class VersionCommand extends Command return Command::SUCCESS; } -} \ No newline at end of file +} diff --git a/src/Controller/PartImportExportController.php b/src/Controller/PartImportExportController.php index b5d4c4e1..326ea923 100644 --- a/src/Controller/PartImportExportController.php +++ b/src/Controller/PartImportExportController.php @@ -1,4 +1,7 @@ . */ - namespace App\Controller; use App\Entity\Parts\Part; @@ -121,4 +123,4 @@ class PartImportExportController extends AbstractController return $entityExporter->exportEntityFromRequest($parts, $request); } -} \ No newline at end of file +} diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php index 44e770e3..a15ce97f 100644 --- a/src/Controller/ProjectController.php +++ b/src/Controller/ProjectController.php @@ -1,4 +1,7 @@ . */ - namespace App\Controller; use App\DataTables\ProjectBomEntriesDataTable; @@ -262,4 +264,4 @@ class ProjectController extends AbstractController 'form' => $form, ]); } -} \ No newline at end of file +} diff --git a/src/Controller/RedirectController.php b/src/Controller/RedirectController.php index aef346d9..40c2c051 100644 --- a/src/Controller/RedirectController.php +++ b/src/Controller/RedirectController.php @@ -50,7 +50,7 @@ class RedirectController extends AbstractController //Check if a user has set a preferred language setting: $user = $this->getUser(); - if (($user instanceof User) && !empty($user->getLanguage())) { + if (($user instanceof User) && ($user->getLanguage() !== null && $user->getLanguage() !== '')) { $locale = $user->getLanguage(); } diff --git a/src/Controller/SelectAPIController.php b/src/Controller/SelectAPIController.php index 8691b967..c403ab82 100644 --- a/src/Controller/SelectAPIController.php +++ b/src/Controller/SelectAPIController.php @@ -1,4 +1,7 @@ . */ - namespace App\Controller; use App\Entity\Base\AbstractNamedDBElement; diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php index a40b9440..c14e1a13 100644 --- a/src/Controller/ToolsController.php +++ b/src/Controller/ToolsController.php @@ -1,4 +1,7 @@ . */ - namespace App\Controller; use App\Services\Attachments\AttachmentPathResolver; diff --git a/src/Controller/UserSettingsController.php b/src/Controller/UserSettingsController.php index 2d36d368..2597cfce 100644 --- a/src/Controller/UserSettingsController.php +++ b/src/Controller/UserSettingsController.php @@ -81,7 +81,7 @@ class UserSettingsController extends AbstractController throw new RuntimeException('You can not remove U2F keys from SAML users!'); } - if (empty($user->getBackupCodes())) { + if ($user->getBackupCodes() === []) { $this->addFlash('error', 'tfa_backup.no_codes_enabled'); throw new RuntimeException('You do not have any backup codes enabled, therefore you can not view them!'); @@ -361,7 +361,7 @@ class UserSettingsController extends AbstractController 'attr' => [ 'class' => 'btn-danger', ], - 'disabled' => empty($user->getBackupCodes()), + 'disabled' => $user->getBackupCodes() === [], ])->getForm(); $backup_form->handleRequest($request); diff --git a/src/Controller/WebauthnKeyRegistrationController.php b/src/Controller/WebauthnKeyRegistrationController.php index cf273626..f2323510 100644 --- a/src/Controller/WebauthnKeyRegistrationController.php +++ b/src/Controller/WebauthnKeyRegistrationController.php @@ -1,4 +1,7 @@ . */ - namespace App\Controller; use App\Entity\UserSystem\User; @@ -95,4 +97,4 @@ class WebauthnKeyRegistrationController extends AbstractController ] ); } -} \ No newline at end of file +} diff --git a/src/DataTables/Adapters/CustomFetchJoinORMAdapter.php b/src/DataTables/Adapters/CustomFetchJoinORMAdapter.php index 9f6d83d0..0c4d4349 100644 --- a/src/DataTables/Adapters/CustomFetchJoinORMAdapter.php +++ b/src/DataTables/Adapters/CustomFetchJoinORMAdapter.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Adapters; use Doctrine\ORM\QueryBuilder; @@ -50,4 +52,4 @@ class CustomFetchJoinORMAdapter extends FetchJoinORMAdapter return $paginator->count(); } -} \ No newline at end of file +} diff --git a/src/DataTables/Column/PrettyBoolColumn.php b/src/DataTables/Column/PrettyBoolColumn.php index ffddeac5..912a9122 100644 --- a/src/DataTables/Column/PrettyBoolColumn.php +++ b/src/DataTables/Column/PrettyBoolColumn.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Column; use Omines\DataTablesBundle\Column\AbstractColumn; @@ -60,4 +62,4 @@ class PrettyBoolColumn extends AbstractColumn throw new \RuntimeException('Unexpected value!'); } -} \ No newline at end of file +} diff --git a/src/DataTables/Column/RowClassColumn.php b/src/DataTables/Column/RowClassColumn.php index c583cf2f..1bfbecee 100644 --- a/src/DataTables/Column/RowClassColumn.php +++ b/src/DataTables/Column/RowClassColumn.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Column; use Omines\DataTablesBundle\Column\AbstractColumn; @@ -55,4 +57,4 @@ class RowClassColumn extends AbstractColumn { return $value; } -} \ No newline at end of file +} diff --git a/src/DataTables/Column/SIUnitNumberColumn.php b/src/DataTables/Column/SIUnitNumberColumn.php index 61e1999c..eec033dc 100644 --- a/src/DataTables/Column/SIUnitNumberColumn.php +++ b/src/DataTables/Column/SIUnitNumberColumn.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Column; use App\Services\Formatters\SIFormatter; @@ -49,4 +51,4 @@ class SIUnitNumberColumn extends AbstractColumn return htmlspecialchars($this->formatter->format((float) $value, $this->options['unit'], $this->options['precision'])); } -} \ No newline at end of file +} diff --git a/src/DataTables/Column/SelectColumn.php b/src/DataTables/Column/SelectColumn.php index c26e916c..18d4193d 100644 --- a/src/DataTables/Column/SelectColumn.php +++ b/src/DataTables/Column/SelectColumn.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Column; use Omines\DataTablesBundle\Column\AbstractColumn; @@ -56,4 +58,4 @@ class SelectColumn extends AbstractColumn //Return empty string, as it this column is filled by datatables on client side return ''; } -} \ No newline at end of file +} diff --git a/src/DataTables/ErrorDataTable.php b/src/DataTables/ErrorDataTable.php index 6bb66841..3aaf11d1 100644 --- a/src/DataTables/ErrorDataTable.php +++ b/src/DataTables/ErrorDataTable.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables; use App\DataTables\Column\RowClassColumn; @@ -78,4 +80,4 @@ class ErrorDataTable implements DataTableTypeInterface $error_table->handleRequest($request); return $error_table->getResponse(); } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/AttachmentFilter.php b/src/DataTables/Filters/AttachmentFilter.php index 5fc38296..9e32a840 100644 --- a/src/DataTables/Filters/AttachmentFilter.php +++ b/src/DataTables/Filters/AttachmentFilter.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters; use App\DataTables\Filters\Constraints\BooleanConstraint; @@ -102,4 +104,4 @@ class AttachmentFilter implements FilterInterface -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/CompoundFilterTrait.php b/src/DataTables/Filters/CompoundFilterTrait.php index 24a9f46c..dc16bc2b 100644 --- a/src/DataTables/Filters/CompoundFilterTrait.php +++ b/src/DataTables/Filters/CompoundFilterTrait.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters; use Doctrine\Common\Collections\Collection; @@ -70,4 +72,4 @@ trait CompoundFilterTrait $filter->apply($queryBuilder); } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/AbstractConstraint.php b/src/DataTables/Filters/Constraints/AbstractConstraint.php index 2ef89c8e..4dc79a41 100644 --- a/src/DataTables/Filters/Constraints/AbstractConstraint.php +++ b/src/DataTables/Filters/Constraints/AbstractConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use App\DataTables\Filters\FilterInterface; @@ -45,4 +47,4 @@ abstract class AbstractConstraint implements FilterInterface { $this->identifier = $identifier ?? $this->generateParameterIdentifier($property); } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/BooleanConstraint.php b/src/DataTables/Filters/Constraints/BooleanConstraint.php index 2810c26e..1f971b0a 100644 --- a/src/DataTables/Filters/Constraints/BooleanConstraint.php +++ b/src/DataTables/Filters/Constraints/BooleanConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -61,4 +63,4 @@ class BooleanConstraint extends AbstractConstraint $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier, '=', $this->value); } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/ChoiceConstraint.php b/src/DataTables/Filters/Constraints/ChoiceConstraint.php index 9aa6ebbc..aea35571 100644 --- a/src/DataTables/Filters/Constraints/ChoiceConstraint.php +++ b/src/DataTables/Filters/Constraints/ChoiceConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -68,7 +70,7 @@ class ChoiceConstraint extends AbstractConstraint public function isEnabled(): bool { - return !empty($this->operator); + return $this->operator !== ''; } public function apply(QueryBuilder $queryBuilder): void @@ -91,4 +93,4 @@ class ChoiceConstraint extends AbstractConstraint throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/DateTimeConstraint.php b/src/DataTables/Filters/Constraints/DateTimeConstraint.php index 39eaaa1d..1ded472e 100644 --- a/src/DataTables/Filters/Constraints/DateTimeConstraint.php +++ b/src/DataTables/Filters/Constraints/DateTimeConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; /** @@ -25,4 +27,4 @@ namespace App\DataTables\Filters\Constraints; */ class DateTimeConstraint extends NumberConstraint { -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/EntityConstraint.php b/src/DataTables/Filters/Constraints/EntityConstraint.php index 2a17552d..df8a670c 100644 --- a/src/DataTables/Filters/Constraints/EntityConstraint.php +++ b/src/DataTables/Filters/Constraints/EntityConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use App\Entity\Base\AbstractDBElement; @@ -112,7 +114,7 @@ class EntityConstraint extends AbstractConstraint public function isEnabled(): bool { - return !empty($this->operator); + return $this->operator !== null && $this->operator !== ''; } public function apply(QueryBuilder $queryBuilder): void @@ -167,4 +169,4 @@ class EntityConstraint extends AbstractConstraint } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/FilterTrait.php b/src/DataTables/Filters/Constraints/FilterTrait.php index 8244eac3..583fa98a 100644 --- a/src/DataTables/Filters/Constraints/FilterTrait.php +++ b/src/DataTables/Filters/Constraints/FilterTrait.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -71,4 +73,4 @@ trait FilterTrait $queryBuilder->setParameter($parameterIdentifier, $value); } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/InstanceOfConstraint.php b/src/DataTables/Filters/Constraints/InstanceOfConstraint.php index 879e2321..582a1b90 100644 --- a/src/DataTables/Filters/Constraints/InstanceOfConstraint.php +++ b/src/DataTables/Filters/Constraints/InstanceOfConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -75,7 +77,7 @@ class InstanceOfConstraint extends AbstractConstraint public function isEnabled(): bool { - return !empty($this->operator); + return $this->operator !== ''; } public function apply(QueryBuilder $queryBuilder): void @@ -107,4 +109,4 @@ class InstanceOfConstraint extends AbstractConstraint throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/IntConstraint.php b/src/DataTables/Filters/Constraints/IntConstraint.php index 601f6aa8..3fc5cce5 100644 --- a/src/DataTables/Filters/Constraints/IntConstraint.php +++ b/src/DataTables/Filters/Constraints/IntConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -35,4 +37,4 @@ class IntConstraint extends NumberConstraint parent::apply($queryBuilder); } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/NumberConstraint.php b/src/DataTables/Filters/Constraints/NumberConstraint.php index b87a6cc4..e1c741ea 100644 --- a/src/DataTables/Filters/Constraints/NumberConstraint.php +++ b/src/DataTables/Filters/Constraints/NumberConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -82,7 +84,7 @@ class NumberConstraint extends AbstractConstraint public function isEnabled(): bool { return $this->value1 !== null - && !empty($this->operator); + && ($this->operator !== null && $this->operator !== ''); } public function apply(QueryBuilder $queryBuilder): void @@ -108,4 +110,4 @@ class NumberConstraint extends AbstractConstraint $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier . '2', '<=', $this->value2); } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/Part/LessThanDesiredConstraint.php b/src/DataTables/Filters/Constraints/Part/LessThanDesiredConstraint.php index 34d5c157..3bdd7cf8 100644 --- a/src/DataTables/Filters/Constraints/Part/LessThanDesiredConstraint.php +++ b/src/DataTables/Filters/Constraints/Part/LessThanDesiredConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints\Part; use App\DataTables\Filters\Constraints\BooleanConstraint; @@ -44,4 +46,4 @@ class LessThanDesiredConstraint extends BooleanConstraint $queryBuilder->andHaving('amountSum >= part.minamount'); } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/Part/ParameterConstraint.php b/src/DataTables/Filters/Constraints/Part/ParameterConstraint.php index 2d431faf..00eba1c2 100644 --- a/src/DataTables/Filters/Constraints/Part/ParameterConstraint.php +++ b/src/DataTables/Filters/Constraints/Part/ParameterConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints\Part; use App\DataTables\Filters\Constraints\AbstractConstraint; @@ -72,19 +74,19 @@ class ParameterConstraint extends AbstractConstraint ->from(PartParameter::class, $this->alias) ->where($this->alias . '.element = part'); - if (!empty($this->name)) { + if ($this->name !== '') { $paramName = $this->generateParameterIdentifier('params.name'); $subqb->andWhere($this->alias . '.name = :' . $paramName); $queryBuilder->setParameter($paramName, $this->name); } - if (!empty($this->symbol)) { + if ($this->symbol !== '') { $paramName = $this->generateParameterIdentifier('params.symbol'); $subqb->andWhere($this->alias . '.symbol = :' . $paramName); $queryBuilder->setParameter($paramName, $this->symbol); } - if (!empty($this->unit)) { + if ($this->unit !== '') { $paramName = $this->generateParameterIdentifier('params.unit'); $subqb->andWhere($this->alias . '.unit = :' . $paramName); $queryBuilder->setParameter($paramName, $this->unit); @@ -147,4 +149,4 @@ class ParameterConstraint extends AbstractConstraint } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/Part/ParameterValueConstraint.php b/src/DataTables/Filters/Constraints/Part/ParameterValueConstraint.php index 1451713b..469c18c6 100644 --- a/src/DataTables/Filters/Constraints/Part/ParameterValueConstraint.php +++ b/src/DataTables/Filters/Constraints/Part/ParameterValueConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints\Part; use App\DataTables\Filters\Constraints\NumberConstraint; @@ -141,4 +143,4 @@ class ParameterValueConstraint extends NumberConstraint //For all other cases use the default implementation parent::apply($queryBuilder); } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/Part/TagsConstraint.php b/src/DataTables/Filters/Constraints/Part/TagsConstraint.php index 1c44255f..acd04745 100644 --- a/src/DataTables/Filters/Constraints/Part/TagsConstraint.php +++ b/src/DataTables/Filters/Constraints/Part/TagsConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints\Part; use Doctrine\ORM\Query\Expr\Orx; @@ -74,7 +76,7 @@ class TagsConstraint extends AbstractConstraint public function isEnabled(): bool { return $this->value !== null - && !empty($this->operator); + && ($this->operator !== null && $this->operator !== ''); } /** @@ -141,4 +143,4 @@ class TagsConstraint extends AbstractConstraint return; } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/Constraints/TextConstraint.php b/src/DataTables/Filters/Constraints/TextConstraint.php index 22e02fea..60f83328 100644 --- a/src/DataTables/Filters/Constraints/TextConstraint.php +++ b/src/DataTables/Filters/Constraints/TextConstraint.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters\Constraints; use Doctrine\ORM\QueryBuilder; @@ -72,7 +74,7 @@ class TextConstraint extends AbstractConstraint public function isEnabled(): bool { return $this->value !== null - && !empty($this->operator); + && ($this->operator !== null && $this->operator !== ''); } public function apply(QueryBuilder $queryBuilder): void @@ -115,4 +117,4 @@ class TextConstraint extends AbstractConstraint $queryBuilder->setParameter($this->identifier, $this->value); } } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/FilterInterface.php b/src/DataTables/Filters/FilterInterface.php index 1abbdc30..bead3fda 100644 --- a/src/DataTables/Filters/FilterInterface.php +++ b/src/DataTables/Filters/FilterInterface.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters; use Doctrine\ORM\QueryBuilder; @@ -31,4 +33,4 @@ interface FilterInterface * @return void */ public function apply(QueryBuilder $queryBuilder): void; -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/LogFilter.php b/src/DataTables/Filters/LogFilter.php index 416a9464..db9576ae 100644 --- a/src/DataTables/Filters/LogFilter.php +++ b/src/DataTables/Filters/LogFilter.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters; use App\DataTables\Filters\Constraints\ChoiceConstraint; @@ -97,4 +99,4 @@ class LogFilter implements FilterInterface } -} \ No newline at end of file +} diff --git a/src/DataTables/Filters/PartFilter.php b/src/DataTables/Filters/PartFilter.php index 92032a28..1419687a 100644 --- a/src/DataTables/Filters/PartFilter.php +++ b/src/DataTables/Filters/PartFilter.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters; use App\DataTables\Filters\Constraints\BooleanConstraint; diff --git a/src/DataTables/Filters/PartSearchFilter.php b/src/DataTables/Filters/PartSearchFilter.php index 7ddaf86e..b94d805a 100644 --- a/src/DataTables/Filters/PartSearchFilter.php +++ b/src/DataTables/Filters/PartSearchFilter.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Filters; use Doctrine\ORM\Query\Expr; @@ -121,7 +123,7 @@ class PartSearchFilter implements FilterInterface $fields_to_search = $this->getFieldsToSearch(); //If we have nothing to search for, do nothing - if ($fields_to_search === [] || empty($this->keyword)) { + if ($fields_to_search === [] || $this->keyword === '') { return; } @@ -302,4 +304,4 @@ class PartSearchFilter implements FilterInterface } -} \ No newline at end of file +} diff --git a/src/DataTables/Helpers/PartDataTableHelper.php b/src/DataTables/Helpers/PartDataTableHelper.php index df29f35b..8499e303 100644 --- a/src/DataTables/Helpers/PartDataTableHelper.php +++ b/src/DataTables/Helpers/PartDataTableHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables\Helpers; use App\Entity\ProjectSystem\Project; @@ -83,4 +85,4 @@ class PartDataTableHelper $title ); } -} \ No newline at end of file +} diff --git a/src/DataTables/ProjectBomEntriesDataTable.php b/src/DataTables/ProjectBomEntriesDataTable.php index 6397ae06..1870c262 100644 --- a/src/DataTables/ProjectBomEntriesDataTable.php +++ b/src/DataTables/ProjectBomEntriesDataTable.php @@ -1,4 +1,7 @@ . */ - namespace App\DataTables; use App\DataTables\Column\EntityColumn; @@ -88,7 +90,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface } if($context->getPart() instanceof Part) { $tmp = $this->partDataTableHelper->renderName($context->getPart()); - if(!empty($context->getName())) { + if($context->getName() !== null && $context->getName() !== '') { $tmp .= '
'.htmlspecialchars($context->getName()).''; } return $tmp; @@ -183,4 +185,4 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface { } -} \ No newline at end of file +} diff --git a/src/Doctrine/Purger/ResetAutoIncrementPurgerFactory.php b/src/Doctrine/Purger/ResetAutoIncrementPurgerFactory.php index 00152718..4d78e0f0 100644 --- a/src/Doctrine/Purger/ResetAutoIncrementPurgerFactory.php +++ b/src/Doctrine/Purger/ResetAutoIncrementPurgerFactory.php @@ -1,4 +1,7 @@ . */ - namespace App\Doctrine\Purger; use Doctrine\Bundle\FixturesBundle\Purger\PurgerFactory; @@ -35,4 +37,4 @@ class ResetAutoIncrementPurgerFactory implements PurgerFactory return $purger; } -} \ No newline at end of file +} diff --git a/src/Doctrine/SQLiteRegexExtension.php b/src/Doctrine/SQLiteRegexExtension.php index 3482348e..b5839c63 100644 --- a/src/Doctrine/SQLiteRegexExtension.php +++ b/src/Doctrine/SQLiteRegexExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Doctrine; use App\Exceptions\InvalidRegexException; @@ -55,4 +57,4 @@ class SQLiteRegexExtension } } } -} \ No newline at end of file +} diff --git a/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareDriver.php b/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareDriver.php index 046672d9..5501b231 100644 --- a/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareDriver.php +++ b/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareDriver.php @@ -1,4 +1,7 @@ . */ - namespace App\Doctrine\SetSQLMode; use Doctrine\DBAL\Driver\Connection; @@ -40,4 +42,4 @@ class SetSQLModeMiddlewareDriver extends AbstractDriverMiddleware return parent::connect($params); } -} \ No newline at end of file +} diff --git a/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareWrapper.php b/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareWrapper.php index 20632b56..34320fa5 100644 --- a/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareWrapper.php +++ b/src/Doctrine/SetSQLMode/SetSQLModeMiddlewareWrapper.php @@ -1,4 +1,7 @@ . */ - namespace App\Doctrine\SetSQLMode; use Doctrine\DBAL\Driver; @@ -33,4 +35,4 @@ class SetSQLModeMiddlewareWrapper implements Middleware { return new SetSQLModeMiddlewareDriver($driver); } -} \ No newline at end of file +} diff --git a/src/Doctrine/Types/BigDecimalType.php b/src/Doctrine/Types/BigDecimalType.php index 83307ee8..6c7bf614 100644 --- a/src/Doctrine/Types/BigDecimalType.php +++ b/src/Doctrine/Types/BigDecimalType.php @@ -1,4 +1,7 @@ . */ - namespace App\Doctrine\Types; use Brick\Math\BigDecimal; diff --git a/src/Doctrine/Types/TinyIntType.php b/src/Doctrine/Types/TinyIntType.php index 951417db..9b2fc7a9 100644 --- a/src/Doctrine/Types/TinyIntType.php +++ b/src/Doctrine/Types/TinyIntType.php @@ -1,4 +1,7 @@ . */ - namespace App\Doctrine\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -44,4 +46,4 @@ class TinyIntType extends Type //We use the comment, so that doctrine migrations can properly detect, that nothing has changed and no migration is needed. return true; } -} \ No newline at end of file +} diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index ae701ccd..cd979d78 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -182,7 +182,7 @@ abstract class Attachment extends AbstractNamedDBElement public function isExternal(): bool { //When path is empty, this attachment can not be external - if (empty($this->path)) { + if ($this->path === '') { return false; } @@ -236,7 +236,7 @@ abstract class Attachment extends AbstractNamedDBElement return null; } - if (!empty($this->original_filename)) { + if ($this->original_filename !== null && $this->original_filename !== '') { return strtolower(pathinfo($this->original_filename, PATHINFO_EXTENSION)); } @@ -302,7 +302,7 @@ abstract class Attachment extends AbstractNamedDBElement } //If we have a stored original filename, then use it - if (!empty($this->original_filename)) { + if ($this->original_filename !== null && $this->original_filename !== '') { return $this->original_filename; } @@ -411,7 +411,7 @@ abstract class Attachment extends AbstractNamedDBElement public function setURL(?string $url): self { //Only set if the URL is not empty - if (!empty($url)) { + if ($url !== null && $url !== '') { if (str_contains($url, '%BASE%') || str_contains($url, '%MEDIA%')) { throw new InvalidArgumentException('You can not reference internal files via the url field! But nice try!'); } diff --git a/src/Entity/Base/PartsContainingRepositoryInterface.php b/src/Entity/Base/PartsContainingRepositoryInterface.php index 16932677..f852bc35 100644 --- a/src/Entity/Base/PartsContainingRepositoryInterface.php +++ b/src/Entity/Base/PartsContainingRepositoryInterface.php @@ -1,4 +1,7 @@ . */ - namespace App\Entity\Base; use App\Entity\Parts\Part; diff --git a/src/Entity/Contracts/LogWithNewDataInterface.php b/src/Entity/Contracts/LogWithNewDataInterface.php index 0ecad0f2..c4128cb7 100644 --- a/src/Entity/Contracts/LogWithNewDataInterface.php +++ b/src/Entity/Contracts/LogWithNewDataInterface.php @@ -1,4 +1,7 @@ . */ - namespace App\Entity\Contracts; interface LogWithNewDataInterface @@ -38,4 +40,4 @@ interface LogWithNewDataInterface * @return $this */ public function setNewData(array $new_data): self; -} \ No newline at end of file +} diff --git a/src/Entity/LogSystem/PartStockChangedLogEntry.php b/src/Entity/LogSystem/PartStockChangedLogEntry.php index 5ac1c953..9ffded62 100644 --- a/src/Entity/LogSystem/PartStockChangedLogEntry.php +++ b/src/Entity/LogSystem/PartStockChangedLogEntry.php @@ -1,4 +1,7 @@ . */ - namespace App\Entity\LogSystem; use App\Entity\Parts\PartLot; @@ -64,7 +66,7 @@ class PartStockChangedLogEntry extends AbstractLogEntry 'n' => $new_stock, 'p' => $new_total_part_instock, ]); - if (!empty($comment)) { + if ($comment !== '') { $this->extra['c'] = mb_strimwidth($comment, 0, self::COMMENT_MAX_LENGTH, '...'); } @@ -201,4 +203,4 @@ class PartStockChangedLogEntry extends AbstractLogEntry default => throw new \InvalidArgumentException('Invalid short type: '.$short_type), }; } -} \ No newline at end of file +} diff --git a/src/Entity/Parameters/AbstractParameter.php b/src/Entity/Parameters/AbstractParameter.php index 1a090b78..4a5cb40a 100644 --- a/src/Entity/Parameters/AbstractParameter.php +++ b/src/Entity/Parameters/AbstractParameter.php @@ -394,7 +394,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement protected function formatWithUnit(float $value, string $format = '%g'): string { $str = sprintf($format, $value); - if (!empty($this->unit)) { + if ($this->unit !== '') { return $str.' '.$this->unit; } diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 4fef18f2..04432f89 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -147,7 +147,7 @@ class Part extends AttachmentContainingDBElement //Ensure that the part name fullfills the regex of the category if ($this->category instanceof Category) { $regex = $this->category->getPartnameRegex(); - if (!empty($regex) && !preg_match($regex, $this->name)) { + if ($regex !== '' && !preg_match($regex, $this->name)) { $context->buildViolation('part.name.must_match_category_regex') ->atPath('name') ->setParameter('%regex%', $regex) diff --git a/src/Entity/Parts/PartTraits/ProjectTrait.php b/src/Entity/Parts/PartTraits/ProjectTrait.php index 5d627a70..6fd076bf 100644 --- a/src/Entity/Parts/PartTraits/ProjectTrait.php +++ b/src/Entity/Parts/PartTraits/ProjectTrait.php @@ -1,5 +1,7 @@ mountnames) && count($uniq_mountnames) !== (int) round ($this->quantity)) { + if ($this->mountnames !== '' && count($uniq_mountnames) !== (int) round ($this->quantity)) { $context->buildViolation('project.bom_entry.mountnames_quantity_mismatch') ->atPath('mountnames') ->addViolation(); diff --git a/src/Entity/UserSystem/PermissionData.php b/src/Entity/UserSystem/PermissionData.php index 998dfead..c8330f3b 100644 --- a/src/Entity/UserSystem/PermissionData.php +++ b/src/Entity/UserSystem/PermissionData.php @@ -1,4 +1,7 @@ . */ - namespace App\Entity\UserSystem; use Doctrine\DBAL\Types\Types; @@ -228,4 +230,4 @@ final class PermissionData implements \JsonSerializable return $this; } -} \ No newline at end of file +} diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 98665781..8f57c370 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -500,7 +500,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe { $tmp = $this->getFirstName(); //Don't add a space, if the name has only one part (it would look strange) - if (!empty($this->getFirstName()) && !empty($this->getLastName())) { + if ($this->getFirstName() !== null && $this->getFirstName() !== '' && ($this->getLastName() !== null && $this->getLastName() !== '')) { $tmp .= ' '; } $tmp .= $this->getLastName(); diff --git a/src/Entity/UserSystem/WebauthnKey.php b/src/Entity/UserSystem/WebauthnKey.php index 2098bd67..3acc6ba8 100644 --- a/src/Entity/UserSystem/WebauthnKey.php +++ b/src/Entity/UserSystem/WebauthnKey.php @@ -1,4 +1,7 @@ . */ - namespace App\Entity\UserSystem; use Doctrine\DBAL\Types\Types; @@ -89,4 +91,4 @@ class WebauthnKey extends BasePublicKeyCredentialSource $registration->getOtherUI() ); } -} \ No newline at end of file +} diff --git a/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php b/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php index f66a96e5..262f196d 100644 --- a/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php +++ b/src/EventSubscriber/LogSystem/EventLoggerSubscriber.php @@ -146,7 +146,7 @@ class EventLoggerSubscriber implements EventSubscriber $uow = $em->getUnitOfWork(); // If we have added any ElementCreatedLogEntries added in postPersist, we flush them here. $uow->computeChangeSets(); - if ($uow->hasPendingInsertions() || !empty($uow->getScheduledEntityUpdates())) { + if ($uow->hasPendingInsertions() || $uow->getScheduledEntityUpdates() !== []) { $em->flush(); } diff --git a/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php b/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php index 8e3af891..07ec8ea4 100644 --- a/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php +++ b/src/EventSubscriber/LogSystem/LogDBMigrationSubscriber.php @@ -55,8 +55,8 @@ class LogDBMigrationSubscriber implements EventSubscriber $this->new_version = (string) $aliasResolver->resolveVersionAlias('current'); //After everything is done, write the results to DB log - $this->old_version = empty($this->old_version) ? 'legacy/empty' : $this->old_version; - $this->new_version = empty($this->new_version) ? 'unknown' : $this->new_version; + $this->old_version = $this->old_version === null || $this->old_version === '' ? 'legacy/empty' : $this->old_version; + $this->new_version = $this->new_version === '' ? 'unknown' : $this->new_version; try { $log = new DatabaseUpdatedLogEntry($this->old_version, $this->new_version); diff --git a/src/EventSubscriber/UserSystem/SetUserTimezoneSubscriber.php b/src/EventSubscriber/UserSystem/SetUserTimezoneSubscriber.php index 277cf62d..10ecaddf 100644 --- a/src/EventSubscriber/UserSystem/SetUserTimezoneSubscriber.php +++ b/src/EventSubscriber/UserSystem/SetUserTimezoneSubscriber.php @@ -43,12 +43,12 @@ final class SetUserTimezoneSubscriber implements EventSubscriberInterface //Check if the user has set a timezone $user = $this->security->getUser(); - if ($user instanceof User && !empty($user->getTimezone())) { + if ($user instanceof User && ($user->getTimezone() !== null && $user->getTimezone() !== '')) { $timezone = $user->getTimezone(); } //Fill with default value if needed - if (null === $timezone && !empty($this->default_timezone)) { + if (null === $timezone && $this->default_timezone !== '') { $timezone = $this->default_timezone; } diff --git a/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php b/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php index 3997c050..6e81ec85 100644 --- a/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php +++ b/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php @@ -1,4 +1,7 @@ . */ - namespace App\EventSubscriber\UserSystem; use Symfony\Bundle\SecurityBundle\Security; @@ -68,4 +70,4 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface { return [KernelEvents::REQUEST => 'onRequest']; } -} \ No newline at end of file +} diff --git a/src/Exceptions/InvalidRegexException.php b/src/Exceptions/InvalidRegexException.php index e2dcd68e..aaa2a897 100644 --- a/src/Exceptions/InvalidRegexException.php +++ b/src/Exceptions/InvalidRegexException.php @@ -1,4 +1,7 @@ . */ - namespace App\Exceptions; use Doctrine\DBAL\Exception\DriverException; @@ -69,4 +71,4 @@ class InvalidRegexException extends \RuntimeException return new self($reason); } -} \ No newline at end of file +} diff --git a/src/Form/AdminPages/ProjectAdminForm.php b/src/Form/AdminPages/ProjectAdminForm.php index ebe01599..2d4683c9 100644 --- a/src/Form/AdminPages/ProjectAdminForm.php +++ b/src/Form/AdminPages/ProjectAdminForm.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\AdminPages; use App\Entity\Base\AbstractNamedDBElement; @@ -59,4 +61,4 @@ class ProjectAdminForm extends BaseEntityAdminForm ], ]); } -} \ No newline at end of file +} diff --git a/src/Form/AttachmentFormType.php b/src/Form/AttachmentFormType.php index dd05a0e5..71c0bedd 100644 --- a/src/Form/AttachmentFormType.php +++ b/src/Form/AttachmentFormType.php @@ -144,7 +144,7 @@ class AttachmentFormType extends AbstractType } //If the name is empty, use the original file name as attachment name - if (empty($attachment->getName())) { + if ($attachment->getName() === '') { $attachment->setName($file->getClientOriginalName()); } }, 100000); diff --git a/src/Form/Filters/AttachmentFilterType.php b/src/Form/Filters/AttachmentFilterType.php index 9908b542..92cb20b6 100644 --- a/src/Form/Filters/AttachmentFilterType.php +++ b/src/Form/Filters/AttachmentFilterType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters; use App\DataTables\Filters\AttachmentFilter; @@ -114,4 +116,4 @@ class AttachmentFilterType extends AbstractType 'label' => 'filter.discard', ]); } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/BooleanConstraintType.php b/src/Form/Filters/Constraints/BooleanConstraintType.php index 0c431a21..6669b5a7 100644 --- a/src/Form/Filters/Constraints/BooleanConstraintType.php +++ b/src/Form/Filters/Constraints/BooleanConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\BooleanConstraint; @@ -51,4 +53,4 @@ class BooleanConstraintType extends AbstractType //Remove the label from the compound form, as the checkbox already has a label $view->vars['label'] = false; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/ChoiceConstraintType.php b/src/Form/Filters/Constraints/ChoiceConstraintType.php index 16014c7f..70d37b08 100644 --- a/src/Form/Filters/Constraints/ChoiceConstraintType.php +++ b/src/Form/Filters/Constraints/ChoiceConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\ChoiceConstraint; @@ -63,4 +65,4 @@ class ChoiceConstraintType extends AbstractType ]); } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/DateTimeConstraintType.php b/src/Form/Filters/Constraints/DateTimeConstraintType.php index 56cde796..ffd3aafd 100644 --- a/src/Form/Filters/Constraints/DateTimeConstraintType.php +++ b/src/Form/Filters/Constraints/DateTimeConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\DateTimeConstraint; @@ -90,4 +92,4 @@ class DateTimeConstraintType extends AbstractType $view->vars['text_suffix'] = $options['text_suffix']; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/InstanceOfConstraintType.php b/src/Form/Filters/Constraints/InstanceOfConstraintType.php index af15117d..02de15e5 100644 --- a/src/Form/Filters/Constraints/InstanceOfConstraintType.php +++ b/src/Form/Filters/Constraints/InstanceOfConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\InstanceOfConstraint; @@ -40,4 +42,4 @@ class InstanceOfConstraintType extends AbstractType { return ChoiceConstraintType::class; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/NumberConstraintType.php b/src/Form/Filters/Constraints/NumberConstraintType.php index 38b9539c..ad792fa0 100644 --- a/src/Form/Filters/Constraints/NumberConstraintType.php +++ b/src/Form/Filters/Constraints/NumberConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\NumberConstraint; @@ -95,4 +97,4 @@ class NumberConstraintType extends AbstractType { $view->vars['text_suffix'] = $options['text_suffix']; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/ParameterConstraintType.php b/src/Form/Filters/Constraints/ParameterConstraintType.php index 10c58429..52fbc726 100644 --- a/src/Form/Filters/Constraints/ParameterConstraintType.php +++ b/src/Form/Filters/Constraints/ParameterConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\Part\ParameterConstraint; @@ -75,4 +77,4 @@ class ParameterConstraintType extends AbstractType } }); } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/ParameterValueConstraintType.php b/src/Form/Filters/Constraints/ParameterValueConstraintType.php index a99fd2a4..01fbca5c 100644 --- a/src/Form/Filters/Constraints/ParameterValueConstraintType.php +++ b/src/Form/Filters/Constraints/ParameterValueConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; class ParameterValueConstraintType extends NumberConstraintType @@ -48,4 +50,4 @@ class ParameterValueConstraintType extends NumberConstraintType { return NumberConstraintType::class; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/StructuralEntityConstraintType.php b/src/Form/Filters/Constraints/StructuralEntityConstraintType.php index 7396c54a..5191881b 100644 --- a/src/Form/Filters/Constraints/StructuralEntityConstraintType.php +++ b/src/Form/Filters/Constraints/StructuralEntityConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\EntityConstraint; @@ -70,4 +72,4 @@ class StructuralEntityConstraintType extends AbstractType parent::buildView($view, $form, $options); $view->vars['text_suffix'] = $options['text_suffix']; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/TagsConstraintType.php b/src/Form/Filters/Constraints/TagsConstraintType.php index 5fbf348c..0a7661dd 100644 --- a/src/Form/Filters/Constraints/TagsConstraintType.php +++ b/src/Form/Filters/Constraints/TagsConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\Part\TagsConstraint; @@ -68,4 +70,4 @@ class TagsConstraintType extends AbstractType 'required' => false, ]); } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/TextConstraintType.php b/src/Form/Filters/Constraints/TextConstraintType.php index 517fe980..492278d2 100644 --- a/src/Form/Filters/Constraints/TextConstraintType.php +++ b/src/Form/Filters/Constraints/TextConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\TextConstraint; @@ -76,4 +78,4 @@ class TextConstraintType extends AbstractType $view->vars['text_suffix'] = $options['text_suffix']; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/Constraints/UserEntityConstraintType.php b/src/Form/Filters/Constraints/UserEntityConstraintType.php index cf646fe9..8c82e0d8 100644 --- a/src/Form/Filters/Constraints/UserEntityConstraintType.php +++ b/src/Form/Filters/Constraints/UserEntityConstraintType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters\Constraints; use App\DataTables\Filters\Constraints\EntityConstraint; @@ -65,4 +67,4 @@ class UserEntityConstraintType extends AbstractType parent::buildView($view, $form, $options); $view->vars['text_suffix'] = $options['text_suffix']; } -} \ No newline at end of file +} diff --git a/src/Form/Filters/LogFilterType.php b/src/Form/Filters/LogFilterType.php index 45e6cccf..16d2c7aa 100644 --- a/src/Form/Filters/LogFilterType.php +++ b/src/Form/Filters/LogFilterType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters; use App\DataTables\Filters\LogFilter; @@ -168,4 +170,4 @@ class LogFilterType extends AbstractType 'label' => 'filter.discard', ]); } -} \ No newline at end of file +} diff --git a/src/Form/Filters/PartFilterType.php b/src/Form/Filters/PartFilterType.php index fceb3c16..5533189c 100644 --- a/src/Form/Filters/PartFilterType.php +++ b/src/Form/Filters/PartFilterType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Filters; use App\DataTables\Filters\Constraints\Part\ParameterConstraint; @@ -277,4 +279,4 @@ class PartFilterType extends AbstractType ]); } -} \ No newline at end of file +} diff --git a/src/Form/ProjectSystem/ProjectBOMEntryCollectionType.php b/src/Form/ProjectSystem/ProjectBOMEntryCollectionType.php index 5f4e5210..53ec5f70 100644 --- a/src/Form/ProjectSystem/ProjectBOMEntryCollectionType.php +++ b/src/Form/ProjectSystem/ProjectBOMEntryCollectionType.php @@ -1,5 +1,7 @@ false, ]); } -} \ No newline at end of file +} diff --git a/src/Form/ProjectSystem/ProjectBOMEntryType.php b/src/Form/ProjectSystem/ProjectBOMEntryType.php index 35a00e67..cac362fb 100644 --- a/src/Form/ProjectSystem/ProjectBOMEntryType.php +++ b/src/Form/ProjectSystem/ProjectBOMEntryType.php @@ -1,5 +1,7 @@ ProjectBOMEntry::class, ]); } -} \ No newline at end of file +} diff --git a/src/Form/ProjectSystem/ProjectBuildType.php b/src/Form/ProjectSystem/ProjectBuildType.php index 77260fcb..82489471 100644 --- a/src/Form/ProjectSystem/ProjectBuildType.php +++ b/src/Form/ProjectSystem/ProjectBuildType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\ProjectSystem; use Symfony\Bundle\SecurityBundle\Security; @@ -153,7 +155,7 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface if (!$lot) { //When the user selected "Create new lot", create a new lot $lot = new PartLot(); $description = 'Build ' . date('Y-m-d H:i:s'); - if (!empty($data->getComment())) { + if ($data->getComment() !== '') { $description .= ' (' . $data->getComment() . ')'; } $lot->setDescription($description); @@ -166,4 +168,4 @@ class ProjectBuildType extends AbstractType implements DataMapperInterface //This has to be set after the builds part lot, so that it can disable the option $data->setAddBuildsToBuildsPart($forms['addBuildsToBuildsPart']->getData()); } -} \ No newline at end of file +} diff --git a/src/Form/Type/BigDecimalMoneyType.php b/src/Form/Type/BigDecimalMoneyType.php index 3c7d252f..189416ff 100644 --- a/src/Form/Type/BigDecimalMoneyType.php +++ b/src/Form/Type/BigDecimalMoneyType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type; use Brick\Math\BigDecimal; diff --git a/src/Form/Type/BigDecimalNumberType.php b/src/Form/Type/BigDecimalNumberType.php index b236cfe0..c225f0a4 100644 --- a/src/Form/Type/BigDecimalNumberType.php +++ b/src/Form/Type/BigDecimalNumberType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type; use Brick\Math\BigDecimal; diff --git a/src/Form/Type/Helper/StructuralEntityChoiceHelper.php b/src/Form/Type/Helper/StructuralEntityChoiceHelper.php index 57fb9237..e1f9d4b7 100644 --- a/src/Form/Type/Helper/StructuralEntityChoiceHelper.php +++ b/src/Form/Type/Helper/StructuralEntityChoiceHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type\Helper; use App\Entity\Attachments\Attachment; @@ -82,7 +84,7 @@ class StructuralEntityChoiceHelper ; } - if ($choice instanceof AttachmentType && !empty($choice->getFiletypeFilter())) { + if ($choice instanceof AttachmentType && $choice->getFiletypeFilter() !== '') { $tmp += ['data-filetype_filter' => $choice->getFiletypeFilter()]; } @@ -96,7 +98,7 @@ class StructuralEntityChoiceHelper public function generateChoiceAttrCurrency(Currency $choice, Options|array $options): array { $tmp = $this->generateChoiceAttr($choice, $options); - $symbol = empty($choice->getIsoCode()) ? null : Currencies::getSymbol($choice->getIsoCode()); + $symbol = $choice->getIsoCode() === null || $choice->getIsoCode() === '' ? null : Currencies::getSymbol($choice->getIsoCode()); $tmp['data-short'] = $options['short'] ? $symbol : $choice->getName(); return $tmp + [ @@ -147,4 +149,4 @@ class StructuralEntityChoiceHelper return null; } -} \ No newline at end of file +} diff --git a/src/Form/Type/Helper/StructuralEntityChoiceLoader.php b/src/Form/Type/Helper/StructuralEntityChoiceLoader.php index fe7b71dd..c2d35d92 100644 --- a/src/Form/Type/Helper/StructuralEntityChoiceLoader.php +++ b/src/Form/Type/Helper/StructuralEntityChoiceLoader.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type\Helper; use App\Repository\StructuralDBElementRepository; @@ -84,4 +86,4 @@ class StructuralEntityChoiceLoader extends AbstractChoiceLoader return $this->additional_element; } -} \ No newline at end of file +} diff --git a/src/Form/Type/PartLotSelectType.php b/src/Form/Type/PartLotSelectType.php index 6c1de117..8eff5122 100644 --- a/src/Form/Type/PartLotSelectType.php +++ b/src/Form/Type/PartLotSelectType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type; use App\Entity\Parts\Storelocation; @@ -51,4 +53,4 @@ class PartLotSelectType extends AbstractType ->setParameter('part', $options['part']) ]); } -} \ No newline at end of file +} diff --git a/src/Form/Type/PartSelectType.php b/src/Form/Type/PartSelectType.php index 43f5c44d..34b8fc7c 100644 --- a/src/Form/Type/PartSelectType.php +++ b/src/Form/Type/PartSelectType.php @@ -1,5 +1,7 @@ getData(); } -} \ No newline at end of file +} diff --git a/src/Form/Type/RichTextEditorType.php b/src/Form/Type/RichTextEditorType.php index ab81eeb7..50683b0c 100644 --- a/src/Form/Type/RichTextEditorType.php +++ b/src/Form/Type/RichTextEditorType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type; use Symfony\Component\Form\AbstractType; @@ -61,4 +63,4 @@ class RichTextEditorType extends AbstractType { return TextareaType::class; } -} \ No newline at end of file +} diff --git a/src/Form/Type/ThemeChoiceType.php b/src/Form/Type/ThemeChoiceType.php index 79e7644b..7cdc0aa9 100644 --- a/src/Form/Type/ThemeChoiceType.php +++ b/src/Form/Type/ThemeChoiceType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type; use Symfony\Component\Form\AbstractType; @@ -45,4 +47,4 @@ class ThemeChoiceType extends AbstractType ]); } -} \ No newline at end of file +} diff --git a/src/Form/Type/UserSelectType.php b/src/Form/Type/UserSelectType.php index cfc501ee..cc16d724 100644 --- a/src/Form/Type/UserSelectType.php +++ b/src/Form/Type/UserSelectType.php @@ -1,4 +1,7 @@ . */ - namespace App\Form\Type; use App\Entity\UserSystem\User; @@ -40,4 +42,4 @@ class UserSelectType extends AbstractType { return StructuralEntityType::class; } -} \ No newline at end of file +} diff --git a/src/Helpers/Projects/ProjectBuildRequest.php b/src/Helpers/Projects/ProjectBuildRequest.php index 29b5f14f..09dca3aa 100644 --- a/src/Helpers/Projects/ProjectBuildRequest.php +++ b/src/Helpers/Projects/ProjectBuildRequest.php @@ -1,4 +1,7 @@ . */ - namespace App\Helpers\Projects; use App\Entity\Parts\Part; @@ -283,4 +285,4 @@ final class ProjectBuildRequest { return $this->number_of_builds; } -} \ No newline at end of file +} diff --git a/src/Helpers/Trees/TreeViewNodeIterator.php b/src/Helpers/Trees/TreeViewNodeIterator.php index 073218c0..ab8b4907 100644 --- a/src/Helpers/Trees/TreeViewNodeIterator.php +++ b/src/Helpers/Trees/TreeViewNodeIterator.php @@ -40,7 +40,7 @@ final class TreeViewNodeIterator extends ArrayIterator implements RecursiveItera /** @var TreeViewNode $element */ $element = $this->current(); - return !empty($element->getNodes()); + return $element->getNodes() !== null && $element->getNodes() !== []; } public function getChildren(): TreeViewNodeIterator diff --git a/src/Kernel.php b/src/Kernel.php index a406b6c8..97c7a69e 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -1,4 +1,7 @@ . */ - namespace App; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; diff --git a/src/Migration/AbstractMultiPlatformMigration.php b/src/Migration/AbstractMultiPlatformMigration.php index 48fff8bd..54e3b529 100644 --- a/src/Migration/AbstractMultiPlatformMigration.php +++ b/src/Migration/AbstractMultiPlatformMigration.php @@ -1,4 +1,7 @@ . */ - namespace App\Migration; use Doctrine\DBAL\Connection; @@ -88,7 +90,7 @@ abstract class AbstractMultiPlatformMigration extends AbstractMigration */ public function getInitalAdminPW(): string { - if (empty($this->admin_pw)) { + if ($this->admin_pw === '') { if (!empty($_ENV['INITIAL_ADMIN_PW'])) { $this->admin_pw = $_ENV['INITIAL_ADMIN_PW']; } else { @@ -104,7 +106,7 @@ abstract class AbstractMultiPlatformMigration extends AbstractMigration { parent::postUp($schema); - if (!empty($this->admin_pw)) { + if ($this->admin_pw !== '') { $this->logger->warning(''); $this->logger->warning('The initial password for the "admin" user is: '.$this->admin_pw.''); $this->logger->warning(''); diff --git a/src/Repository/AbstractPartsContainingRepository.php b/src/Repository/AbstractPartsContainingRepository.php index 0603ce06..cbfdee6a 100644 --- a/src/Repository/AbstractPartsContainingRepository.php +++ b/src/Repository/AbstractPartsContainingRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository; use App\Entity\Base\AbstractPartsContainingDBElement; diff --git a/src/Repository/ParameterRepository.php b/src/Repository/ParameterRepository.php index 694d6bb2..7c978bad 100644 --- a/src/Repository/ParameterRepository.php +++ b/src/Repository/ParameterRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository; class ParameterRepository extends DBElementRepository @@ -46,4 +48,4 @@ class ParameterRepository extends DBElementRepository return $qb->getQuery()->getArrayResult(); } -} \ No newline at end of file +} diff --git a/src/Repository/Parts/CategoryRepository.php b/src/Repository/Parts/CategoryRepository.php index c472d8d6..8e270047 100644 --- a/src/Repository/Parts/CategoryRepository.php +++ b/src/Repository/Parts/CategoryRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; use App\Entity\Parts\Category; diff --git a/src/Repository/Parts/DeviceRepository.php b/src/Repository/Parts/DeviceRepository.php index e7555f2b..442c91e5 100644 --- a/src/Repository/Parts/DeviceRepository.php +++ b/src/Repository/Parts/DeviceRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; @@ -49,4 +51,4 @@ class DeviceRepository extends StructuralDBElementRepository //Prevent user from deleting devices, to not accidentally remove filled devices from old versions return 1; } -} \ No newline at end of file +} diff --git a/src/Repository/Parts/FootprintRepository.php b/src/Repository/Parts/FootprintRepository.php index 72c25003..355cb1bb 100644 --- a/src/Repository/Parts/FootprintRepository.php +++ b/src/Repository/Parts/FootprintRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; use App\Entity\Parts\Footprint; diff --git a/src/Repository/Parts/ManufacturerRepository.php b/src/Repository/Parts/ManufacturerRepository.php index aa4d8fec..a47142d4 100644 --- a/src/Repository/Parts/ManufacturerRepository.php +++ b/src/Repository/Parts/ManufacturerRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; use App\Entity\Parts\Manufacturer; diff --git a/src/Repository/Parts/MeasurementUnitRepository.php b/src/Repository/Parts/MeasurementUnitRepository.php index 80d32743..1c9b106b 100644 --- a/src/Repository/Parts/MeasurementUnitRepository.php +++ b/src/Repository/Parts/MeasurementUnitRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; use App\Entity\Parts\MeasurementUnit; diff --git a/src/Repository/Parts/StorelocationRepository.php b/src/Repository/Parts/StorelocationRepository.php index c0c432be..e6eea9a5 100644 --- a/src/Repository/Parts/StorelocationRepository.php +++ b/src/Repository/Parts/StorelocationRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; use App\Entity\Parts\Part; diff --git a/src/Repository/Parts/SupplierRepository.php b/src/Repository/Parts/SupplierRepository.php index 0a2e2c8f..6dc995f1 100644 --- a/src/Repository/Parts/SupplierRepository.php +++ b/src/Repository/Parts/SupplierRepository.php @@ -1,4 +1,7 @@ . */ - namespace App\Repository\Parts; use App\Entity\Parts\Part; diff --git a/src/Repository/StructuralDBElementRepository.php b/src/Repository/StructuralDBElementRepository.php index 0f2dcdea..04da15ac 100644 --- a/src/Repository/StructuralDBElementRepository.php +++ b/src/Repository/StructuralDBElementRepository.php @@ -142,10 +142,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository private function getNewEntityFromCache(string $name, ?AbstractStructuralDBElement $parent): ?AbstractStructuralDBElement { $key = $parent instanceof AbstractStructuralDBElement ? $parent->getFullPath('%->%').'%->%'.$name : $name; - if (isset($this->new_entity_cache[$key])) { - return $this->new_entity_cache[$key]; - } - return null; + return $this->new_entity_cache[$key] ?? null; } private function setNewEntityToCache(AbstractStructuralDBElement $entity): void diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 62bf71f9..95426775 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -62,7 +62,7 @@ final class UserRepository extends NamedDBElementRepository implements PasswordU */ public function findByEmailOrName(string $name_or_password): ?User { - if (empty($name_or_password)) { + if ($name_or_password === '') { return null; } diff --git a/src/Security/EnsureSAMLUserForSAMLLoginChecker.php b/src/Security/EnsureSAMLUserForSAMLLoginChecker.php index 674d7e26..f230cf71 100644 --- a/src/Security/EnsureSAMLUserForSAMLLoginChecker.php +++ b/src/Security/EnsureSAMLUserForSAMLLoginChecker.php @@ -1,4 +1,7 @@ . */ - namespace App\Security; use App\Entity\UserSystem\User; @@ -58,4 +60,4 @@ class EnsureSAMLUserForSAMLLoginChecker implements EventSubscriberInterface throw new CustomUserMessageAccountStatusException($this->translator->trans('saml.error.cannot_login_saml_user_locally', [], 'security')); } } -} \ No newline at end of file +} diff --git a/src/Security/SamlUserFactory.php b/src/Security/SamlUserFactory.php index 924e4e5e..d5c68146 100644 --- a/src/Security/SamlUserFactory.php +++ b/src/Security/SamlUserFactory.php @@ -1,4 +1,7 @@ . */ - namespace App\Security; use App\Entity\UserSystem\Group; @@ -148,4 +150,4 @@ class SamlUserFactory implements SamlUserFactoryInterface, EventSubscriberInterf AuthenticationSuccessEvent::class => 'onAuthenticationSuccess', ]; } -} \ No newline at end of file +} diff --git a/src/Security/Voter/ParameterVoter.php b/src/Security/Voter/ParameterVoter.php index 486decda..6f752518 100644 --- a/src/Security/Voter/ParameterVoter.php +++ b/src/Security/Voter/ParameterVoter.php @@ -1,4 +1,7 @@ . */ - namespace App\Security\Voter; use Symfony\Bundle\SecurityBundle\Security; @@ -115,4 +117,4 @@ class ParameterVoter extends ExtendedVoter //Allow class name as subject return false; } -} \ No newline at end of file +} diff --git a/src/Serializer/BigNumberNormalizer.php b/src/Serializer/BigNumberNormalizer.php index 87619849..b97b9b64 100644 --- a/src/Serializer/BigNumberNormalizer.php +++ b/src/Serializer/BigNumberNormalizer.php @@ -1,4 +1,7 @@ . */ - namespace App\Serializer; use Brick\Math\BigNumber; @@ -49,4 +51,4 @@ class BigNumberNormalizer implements NormalizerInterface BigNumber::class => true, ]; } -} \ No newline at end of file +} diff --git a/src/Serializer/PartNormalizer.php b/src/Serializer/PartNormalizer.php index 67b4066f..28b6e252 100644 --- a/src/Serializer/PartNormalizer.php +++ b/src/Serializer/PartNormalizer.php @@ -1,4 +1,7 @@ . */ - namespace App\Serializer; use App\Entity\Parts\Part; @@ -180,4 +182,4 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface Part::class => false, ]; } -} \ No newline at end of file +} diff --git a/src/Serializer/StructuralElementDenormalizer.php b/src/Serializer/StructuralElementDenormalizer.php index c5130ef4..ce6f91ca 100644 --- a/src/Serializer/StructuralElementDenormalizer.php +++ b/src/Serializer/StructuralElementDenormalizer.php @@ -1,4 +1,7 @@ . */ - namespace App\Serializer; use App\Entity\Base\AbstractStructuralDBElement; @@ -94,4 +96,4 @@ class StructuralElementDenormalizer implements DenormalizerInterface AbstractStructuralDBElement::class => false, ]; } -} \ No newline at end of file +} diff --git a/src/Serializer/StructuralElementFromNameDenormalizer.php b/src/Serializer/StructuralElementFromNameDenormalizer.php index 670bcdc1..e0d29606 100644 --- a/src/Serializer/StructuralElementFromNameDenormalizer.php +++ b/src/Serializer/StructuralElementFromNameDenormalizer.php @@ -1,4 +1,7 @@ . */ - namespace App\Serializer; use App\Entity\Base\AbstractStructuralDBElement; @@ -74,4 +76,4 @@ class StructuralElementFromNameDenormalizer implements DenormalizerInterface AbstractStructuralDBElement::class => false ]; } -} \ No newline at end of file +} diff --git a/src/Serializer/StructuralElementNormalizer.php b/src/Serializer/StructuralElementNormalizer.php index c1931ffe..0c7f2ca5 100644 --- a/src/Serializer/StructuralElementNormalizer.php +++ b/src/Serializer/StructuralElementNormalizer.php @@ -1,4 +1,7 @@ . */ - namespace App\Serializer; use App\Entity\Base\AbstractStructuralDBElement; @@ -34,8 +36,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; class StructuralElementNormalizer implements NormalizerInterface { public function __construct( - #[Autowire(service: ObjectNormalizer::class)] - private NormalizerInterface $normalizer + #[Autowire(service: ObjectNormalizer::class)]private readonly NormalizerInterface $normalizer ) { } @@ -69,4 +70,4 @@ class StructuralElementNormalizer implements NormalizerInterface AbstractStructuralDBElement::class => true, ]; } -} \ No newline at end of file +} diff --git a/src/Services/Attachments/AttachmentManager.php b/src/Services/Attachments/AttachmentManager.php index 3057b5b1..4429179e 100644 --- a/src/Services/Attachments/AttachmentManager.php +++ b/src/Services/Attachments/AttachmentManager.php @@ -64,7 +64,7 @@ class AttachmentManager */ public function toAbsoluteFilePath(Attachment $attachment): ?string { - if (empty($attachment->getPath())) { + if ($attachment->getPath() === '') { return null; } @@ -98,7 +98,7 @@ class AttachmentManager */ public function isFileExisting(Attachment $attachment): bool { - if (empty($attachment->getPath())) { + if ($attachment->getPath() === '') { return false; } diff --git a/src/Services/Attachments/AttachmentSubmitHandler.php b/src/Services/Attachments/AttachmentSubmitHandler.php index 1266ae27..d422649e 100644 --- a/src/Services/Attachments/AttachmentSubmitHandler.php +++ b/src/Services/Attachments/AttachmentSubmitHandler.php @@ -95,7 +95,7 @@ class AttachmentSubmitHandler public function isValidFileExtension(AttachmentType $attachment_type, UploadedFile $uploadedFile): bool { //Only validate if the attachment type has specified a filetype filter: - if (empty($attachment_type->getFiletypeFilter())) { + if ($attachment_type->getFiletypeFilter() === '') { return true; } @@ -212,7 +212,7 @@ class AttachmentSubmitHandler //Determine the old filepath $old_path = $this->pathResolver->placeholderToRealPath($attachment->getPath()); - if (empty($old_path) || !file_exists($old_path)) { + if ($old_path === null || $old_path === '' || !file_exists($old_path)) { return $attachment; } $filename = basename($old_path); @@ -357,7 +357,7 @@ class AttachmentSubmitHandler //Check if we have an extension given $pathinfo = pathinfo($filename); - if (!empty($pathinfo['extension'])) { + if ($pathinfo['extension'] !== '') { $new_ext = $pathinfo['extension']; } else { //Otherwise we have to guess the extension for the new file, based on its content $new_ext = $this->mimeTypes->getExtensions($this->mimeTypes->guessMimeType($tmp_path))[0] ?? 'tmp'; diff --git a/src/Services/Attachments/AttachmentURLGenerator.php b/src/Services/Attachments/AttachmentURLGenerator.php index 0efbf1e6..afbfade3 100644 --- a/src/Services/Attachments/AttachmentURLGenerator.php +++ b/src/Services/Attachments/AttachmentURLGenerator.php @@ -119,7 +119,7 @@ class AttachmentURLGenerator throw new InvalidArgumentException('Thumbnail creation only works for picture attachments!'); } - if ($attachment->isExternal() && !empty($attachment->getURL())) { + if ($attachment->isExternal() && ($attachment->getURL() !== null && $attachment->getURL() !== '')) { return $attachment->getURL(); } diff --git a/src/Services/Attachments/BuiltinAttachmentsFinder.php b/src/Services/Attachments/BuiltinAttachmentsFinder.php index 21be0730..b009cf60 100644 --- a/src/Services/Attachments/BuiltinAttachmentsFinder.php +++ b/src/Services/Attachments/BuiltinAttachmentsFinder.php @@ -120,7 +120,7 @@ class BuiltinAttachmentsFinder */ public function find(string $keyword, array $options = [], ?array $base_list = []): array { - if (empty($base_list)) { + if ($base_list === null || $base_list === []) { $base_list = $this->getListOfRessources(); } diff --git a/src/Services/Attachments/FileTypeFilterTools.php b/src/Services/Attachments/FileTypeFilterTools.php index c7ef3ab1..cb815797 100644 --- a/src/Services/Attachments/FileTypeFilterTools.php +++ b/src/Services/Attachments/FileTypeFilterTools.php @@ -173,6 +173,6 @@ class FileTypeFilterTools { $extension = strtolower($extension); - return empty($filter) || in_array($extension, $this->resolveFileExtensions($filter), false); + return $filter === '' || in_array($extension, $this->resolveFileExtensions($filter), false); } } diff --git a/src/Services/ElementTypeNameGenerator.php b/src/Services/ElementTypeNameGenerator.php index 2fb81c1b..e9b24d23 100644 --- a/src/Services/ElementTypeNameGenerator.php +++ b/src/Services/ElementTypeNameGenerator.php @@ -146,7 +146,7 @@ class ElementTypeNameGenerator public function formatLabelHTMLForEntity(AbstractDBElement $entity, bool $include_associated = false): string { //The element is existing - if ($entity instanceof NamedElementInterface && !empty($entity->getName())) { + if ($entity instanceof NamedElementInterface && $entity->getName() !== '') { try { $tmp = sprintf( '%s', diff --git a/src/Services/Formatters/MoneyFormatter.php b/src/Services/Formatters/MoneyFormatter.php index fbe4fc39..d49b77cf 100644 --- a/src/Services/Formatters/MoneyFormatter.php +++ b/src/Services/Formatters/MoneyFormatter.php @@ -46,7 +46,7 @@ class MoneyFormatter public function format(string|float $value, ?Currency $currency = null, int $decimals = 5, bool $show_all_digits = false): string { $iso_code = $this->base_currency; - if ($currency instanceof Currency && !empty($currency->getIsoCode())) { + if ($currency instanceof Currency && ($currency->getIsoCode() !== null && $currency->getIsoCode() !== '')) { $iso_code = $currency->getIsoCode(); } diff --git a/src/Services/ImportExportSystem/BOMImporter.php b/src/Services/ImportExportSystem/BOMImporter.php index 7227c419..89b62660 100644 --- a/src/Services/ImportExportSystem/BOMImporter.php +++ b/src/Services/ImportExportSystem/BOMImporter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem; use App\Entity\ProjectSystem\Project; @@ -135,4 +137,4 @@ class BOMImporter return $bom_entries; } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php b/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php index 4ff9c189..f221ee89 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem\PartKeeprImporter; class MySQLDumpXMLConverter @@ -107,4 +109,4 @@ class MySQLDumpXMLConverter return $row_data; } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php index 31939d31..d53566c0 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem\PartKeeprImporter; use App\Doctrine\Purger\ResetAutoIncrementORMPurger; @@ -268,4 +270,4 @@ class PKDatastructureImporter return $count; } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelper.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelper.php index d51bc225..f36e48ce 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelper.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem\PartKeeprImporter; use App\Doctrine\Purger\ResetAutoIncrementORMPurger; @@ -64,4 +66,4 @@ class PKImportHelper { return $this->getDatabaseSchemaVersion($data) === '20170601175559'; } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php index 54ecae63..70237114 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem\PartKeeprImporter; use Doctrine\ORM\Id\AssignedGenerator; @@ -233,4 +235,4 @@ trait PKImportHelperTrait $property->setAccessible(true); $property->setValue($entity, $date); } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php index e192eefa..b8e8272e 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem\PartKeeprImporter; use App\Entity\Attachments\ProjectAttachment; @@ -144,4 +146,4 @@ class PKOptionalImporter return is_countable($users_data) ? count($users_data) : 0; } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php index c3d1f31e..a1b9aeed 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ImportExportSystem\PartKeeprImporter; use App\Entity\Attachments\PartAttachment; @@ -311,4 +313,4 @@ class PKPartImporter throw new \RuntimeException(sprintf('Could not find unit with ID %s', $id)); } -} \ No newline at end of file +} diff --git a/src/Services/LabelSystem/PlaceholderProviders/BarcodeProvider.php b/src/Services/LabelSystem/PlaceholderProviders/BarcodeProvider.php index 868f8038..eb413518 100644 --- a/src/Services/LabelSystem/PlaceholderProviders/BarcodeProvider.php +++ b/src/Services/LabelSystem/PlaceholderProviders/BarcodeProvider.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LabelSystem\PlaceholderProviders; use App\Entity\LabelSystem\LabelOptions; @@ -68,4 +70,4 @@ final class BarcodeProvider implements PlaceholderProviderInterface return null; } -} \ No newline at end of file +} diff --git a/src/Services/LabelSystem/PlaceholderProviders/StorelocationProvider.php b/src/Services/LabelSystem/PlaceholderProviders/StorelocationProvider.php index 18a4c7d2..95654eca 100644 --- a/src/Services/LabelSystem/PlaceholderProviders/StorelocationProvider.php +++ b/src/Services/LabelSystem/PlaceholderProviders/StorelocationProvider.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LabelSystem\PlaceholderProviders; use App\Entity\UserSystem\User; @@ -39,4 +41,4 @@ class StorelocationProvider implements PlaceholderProviderInterface return null; } -} \ No newline at end of file +} diff --git a/src/Services/LogSystem/EventCommentNeededHelper.php b/src/Services/LogSystem/EventCommentNeededHelper.php index 3738b330..8440f199 100644 --- a/src/Services/LogSystem/EventCommentNeededHelper.php +++ b/src/Services/LogSystem/EventCommentNeededHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LogSystem; /** @@ -53,4 +55,4 @@ class EventCommentNeededHelper return in_array($comment_type, $this->enforce_change_comments_for, true); } -} \ No newline at end of file +} diff --git a/src/Services/LogSystem/LogDataFormatter.php b/src/Services/LogSystem/LogDataFormatter.php index 46dae945..f15fcdc6 100644 --- a/src/Services/LogSystem/LogDataFormatter.php +++ b/src/Services/LogSystem/LogDataFormatter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LogSystem; use App\Entity\LogSystem\AbstractLogEntry; @@ -148,4 +150,4 @@ class LogDataFormatter { return $data ? $this->translator->trans('true') : $this->translator->trans('false'); } -} \ No newline at end of file +} diff --git a/src/Services/LogSystem/LogDiffFormatter.php b/src/Services/LogSystem/LogDiffFormatter.php index 500e1a72..5828185c 100644 --- a/src/Services/LogSystem/LogDiffFormatter.php +++ b/src/Services/LogSystem/LogDiffFormatter.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LogSystem; use Jfcherng\Diff\DiffHelper; @@ -72,4 +74,4 @@ class LogDiffFormatter return sprintf('%s', $difference); } } -} \ No newline at end of file +} diff --git a/src/Services/LogSystem/LogEntryExtraFormatter.php b/src/Services/LogSystem/LogEntryExtraFormatter.php index 017de1e0..6ace35e8 100644 --- a/src/Services/LogSystem/LogEntryExtraFormatter.php +++ b/src/Services/LogSystem/LogEntryExtraFormatter.php @@ -68,7 +68,7 @@ class LogEntryExtraFormatter $str .= ''.$this->translator->trans($key).': '; } $str .= $value; - if (!empty($str)) { + if ($str !== '') { $tmp[] = $str; } } @@ -91,7 +91,7 @@ class LogEntryExtraFormatter $str .= ''.$this->translator->trans($key).': '; } $str .= $value; - if (!empty($str)) { + if ($str !== '') { $tmp[] = $str; } } @@ -184,7 +184,7 @@ class LogEntryExtraFormatter $context->getNewStock(), ($context->getNewStock() > $context->getOldStock() ? '+' : '-'). $context->getChangeAmount(), ); - if (!empty($context->getComment())) { + if ($context->getComment() !== '') { $array['log.part_stock_changed.comment'] = htmlspecialchars($context->getComment()); } if ($context->getInstockChangeType() === PartStockChangedLogEntry::TYPE_MOVE) { diff --git a/src/Services/LogSystem/LogLevelHelper.php b/src/Services/LogSystem/LogLevelHelper.php index efc8dd93..5cc13db8 100644 --- a/src/Services/LogSystem/LogLevelHelper.php +++ b/src/Services/LogSystem/LogLevelHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LogSystem; use App\Entity\LogSystem\AbstractLogEntry; @@ -60,4 +62,4 @@ class LogLevelHelper default => '', }; } -} \ No newline at end of file +} diff --git a/src/Services/LogSystem/LogTargetHelper.php b/src/Services/LogSystem/LogTargetHelper.php index abd57674..540f2b45 100644 --- a/src/Services/LogSystem/LogTargetHelper.php +++ b/src/Services/LogSystem/LogTargetHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\LogSystem; use App\Entity\Attachments\Attachment; @@ -82,4 +84,4 @@ class LogTargetHelper //Otherwise we can return a label for the target return $this->elementTypeNameGenerator->formatLabelHTMLForEntity($target, $options['show_associated']); } -} \ No newline at end of file +} diff --git a/src/Services/Misc/ConsoleInfoHelper.php b/src/Services/Misc/ConsoleInfoHelper.php index 8aea004e..f529f74a 100644 --- a/src/Services/Misc/ConsoleInfoHelper.php +++ b/src/Services/Misc/ConsoleInfoHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\Misc; class ConsoleInfoHelper @@ -47,17 +49,7 @@ class ConsoleInfoHelper return $user['name']; } - //Try to retrieve the name via the environment variable Username (Windows) - if (isset($_SERVER['USERNAME'])) { - return $_SERVER['USERNAME']; - } - - //Try to retrieve the name via the environment variable USER (Linux) - if (isset($_SERVER['USER'])) { - return $_SERVER['USER']; - } - //Otherwise we can't determine the username - return null; + return $_SERVER['USERNAME'] ?? $_SERVER['USER'] ?? null; } -} \ No newline at end of file +} diff --git a/src/Services/Misc/DBInfoHelper.php b/src/Services/Misc/DBInfoHelper.php index f2c638ff..eb75a254 100644 --- a/src/Services/Misc/DBInfoHelper.php +++ b/src/Services/Misc/DBInfoHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\Misc; use Doctrine\DBAL\Exception; diff --git a/src/Services/Misc/RangeParser.php b/src/Services/Misc/RangeParser.php index 2ff98477..f1a5db5b 100644 --- a/src/Services/Misc/RangeParser.php +++ b/src/Services/Misc/RangeParser.php @@ -71,7 +71,7 @@ class RangeParser $ranges[] = $this->generateMinMaxRange($matches[1], $matches[2]); } elseif (is_numeric($number)) { $ranges[] = [(int) $number]; - } elseif (empty($number)) { //Allow empty tokens + } elseif ($number === '') { //Allow empty tokens continue; } else { throw new InvalidArgumentException('Invalid range encoutered: '.$number); diff --git a/src/Services/Parameters/ParameterExtractor.php b/src/Services/Parameters/ParameterExtractor.php index 077101c8..9eaf946a 100644 --- a/src/Services/Parameters/ParameterExtractor.php +++ b/src/Services/Parameters/ParameterExtractor.php @@ -97,7 +97,7 @@ class ParameterExtractor $value = trim($value); //Don't allow empty names or values (these are a sign of an invalid extracted string) - if (empty($name) || empty($value)) { + if ($name === '' || $value === '') { return null; } diff --git a/src/Services/Parts/PartLotWithdrawAddHelper.php b/src/Services/Parts/PartLotWithdrawAddHelper.php index 07f4bc04..8e2d2d28 100644 --- a/src/Services/Parts/PartLotWithdrawAddHelper.php +++ b/src/Services/Parts/PartLotWithdrawAddHelper.php @@ -1,5 +1,7 @@ eventLogger->log($event); //Apply the comment also to global events, so it gets associated with the elementChanged log entry - if (!$this->eventCommentHelper->isMessageSet() && !empty($comment)) { + if (!$this->eventCommentHelper->isMessageSet() && ($comment !== null && $comment !== '')) { $this->eventCommentHelper->setMessage($comment); } @@ -125,7 +127,7 @@ final class PartLotWithdrawAddHelper $this->eventLogger->log($event); //Apply the comment also to global events, so it gets associated with the elementChanged log entry - if (!$this->eventCommentHelper->isMessageSet() && !empty($comment)) { + if (!$this->eventCommentHelper->isMessageSet() && ($comment !== null && $comment !== '')) { $this->eventCommentHelper->setMessage($comment); } @@ -179,8 +181,8 @@ final class PartLotWithdrawAddHelper $this->eventLogger->log($event); //Apply the comment also to global events, so it gets associated with the elementChanged log entry - if (!$this->eventCommentHelper->isMessageSet() && !empty($comment)) { + if (!$this->eventCommentHelper->isMessageSet() && ($comment !== null && $comment !== '')) { $this->eventCommentHelper->setMessage($comment); } } -} \ No newline at end of file +} diff --git a/src/Services/Parts/PartsTableActionHandler.php b/src/Services/Parts/PartsTableActionHandler.php index d4af56ae..c97357e0 100644 --- a/src/Services/Parts/PartsTableActionHandler.php +++ b/src/Services/Parts/PartsTableActionHandler.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\Parts; use Symfony\Bundle\SecurityBundle\Security; diff --git a/src/Services/ProjectSystem/ProjectBuildHelper.php b/src/Services/ProjectSystem/ProjectBuildHelper.php index b9ffc374..256958f2 100644 --- a/src/Services/ProjectSystem/ProjectBuildHelper.php +++ b/src/Services/ProjectSystem/ProjectBuildHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\ProjectSystem; use App\Entity\Parts\Part; @@ -149,4 +151,4 @@ class ProjectBuildHelper $this->withdraw_add_helper->add($buildRequest->getBuildsPartLot(), $buildRequest->getNumberOfBuilds(), $message); } } -} \ No newline at end of file +} diff --git a/src/Services/ProjectSystem/ProjectBuildPartHelper.php b/src/Services/ProjectSystem/ProjectBuildPartHelper.php index 446f5f55..218f456e 100644 --- a/src/Services/ProjectSystem/ProjectBuildPartHelper.php +++ b/src/Services/ProjectSystem/ProjectBuildPartHelper.php @@ -1,5 +1,7 @@ . */ - namespace App\Services\Tools; use App\Entity\PriceInformations\Currency; diff --git a/src/Services/Trees/SidebarTreeUpdater.php b/src/Services/Trees/SidebarTreeUpdater.php index 16853d7e..0d7ccee9 100644 --- a/src/Services/Trees/SidebarTreeUpdater.php +++ b/src/Services/Trees/SidebarTreeUpdater.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\Trees; use Symfony\Contracts\Cache\CacheInterface; @@ -51,4 +53,4 @@ final class SidebarTreeUpdater return new \DateTime(); }); } -} \ No newline at end of file +} diff --git a/src/Services/Trees/ToolsTreeBuilder.php b/src/Services/Trees/ToolsTreeBuilder.php index 201c5fd3..d1c01063 100644 --- a/src/Services/Trees/ToolsTreeBuilder.php +++ b/src/Services/Trees/ToolsTreeBuilder.php @@ -68,20 +68,20 @@ class ToolsTreeBuilder $item->tag(['tree_tools', 'groups', $this->keyGenerator->generateKey()]); $tree = []; - if (!empty($this->getToolsNode())) { + if ($this->getToolsNode() !== []) { $tree[] = (new TreeViewNode($this->translator->trans('tree.tools.tools'), null, $this->getToolsNode())) ->setIcon('fa-fw fa-treeview fa-solid fa-toolbox'); } - if (!empty($this->getEditNodes())) { + if ($this->getEditNodes() !== []) { $tree[] = (new TreeViewNode($this->translator->trans('tree.tools.edit'), null, $this->getEditNodes())) ->setIcon('fa-fw fa-treeview fa-solid fa-pen-to-square'); } - if (!empty($this->getShowNodes())) { + if ($this->getShowNodes() !== []) { $tree[] = (new TreeViewNode($this->translator->trans('tree.tools.show'), null, $this->getShowNodes())) ->setIcon('fa-fw fa-treeview fa-solid fa-eye'); } - if (!empty($this->getSystemNodes())) { + if ($this->getSystemNodes() !== []) { $tree[] = (new TreeViewNode($this->translator->trans('tree.tools.system'), null, $this->getSystemNodes())) ->setIcon('fa-fw fa-treeview fa-solid fa-server'); } diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index dd2db178..ca93873c 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -105,11 +105,11 @@ class TreeViewGenerator $item->setSelected(true); } - if (!empty($item->getNodes())) { + if ($item->getNodes() !== null && $item->getNodes() !== []) { $item->addTag((string) count($item->getNodes())); } - if (!empty($href_type) && null !== $item->getId()) { + if ($href_type !== '' && null !== $item->getId()) { $entity = $this->em->getPartialReference($class, $item->getId()); $item->setHref($this->urlGenerator->getURL($entity, $href_type)); } diff --git a/src/Services/UserSystem/PasswordResetManager.php b/src/Services/UserSystem/PasswordResetManager.php index d479fb51..2349297b 100644 --- a/src/Services/UserSystem/PasswordResetManager.php +++ b/src/Services/UserSystem/PasswordResetManager.php @@ -63,7 +63,7 @@ class PasswordResetManager $expiration_date->add(date_interval_create_from_date_string('1 day')); $user->setPwResetExpires($expiration_date); - if (!empty($user->getEmail())) { + if ($user->getEmail() !== null && $user->getEmail() !== '') { $address = new Address($user->getEmail(), $user->getFullName()); $mail = new TemplatedEmail(); $mail->to($address); diff --git a/src/Services/UserSystem/PermissionPresetsHelper.php b/src/Services/UserSystem/PermissionPresetsHelper.php index bf9aad8a..d12eb1ef 100644 --- a/src/Services/UserSystem/PermissionPresetsHelper.php +++ b/src/Services/UserSystem/PermissionPresetsHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\UserSystem; use App\Entity\UserSystem\PermissionData; @@ -181,4 +183,4 @@ class PermissionPresetsHelper $this->permissionResolver->setAllPermissions($perm_holder, PermissionData::ALLOW); return $perm_holder; } -} \ No newline at end of file +} diff --git a/src/Services/UserSystem/PermissionSchemaUpdater.php b/src/Services/UserSystem/PermissionSchemaUpdater.php index b939fa86..29ce332d 100644 --- a/src/Services/UserSystem/PermissionSchemaUpdater.php +++ b/src/Services/UserSystem/PermissionSchemaUpdater.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\UserSystem; use App\Entity\UserSystem\Group; @@ -138,4 +140,4 @@ class PermissionSchemaUpdater $holder->getPermissions()->removePermission('devices'); } } -} \ No newline at end of file +} diff --git a/src/Services/UserSystem/TFA/BackupCodeManager.php b/src/Services/UserSystem/TFA/BackupCodeManager.php index 70226946..07484618 100644 --- a/src/Services/UserSystem/TFA/BackupCodeManager.php +++ b/src/Services/UserSystem/TFA/BackupCodeManager.php @@ -40,7 +40,7 @@ class BackupCodeManager */ public function enableBackupCodes(User $user): void { - if (empty($user->getBackupCodes())) { + if ($user->getBackupCodes() === []) { $this->regenerateBackupCodes($user); } } diff --git a/src/Services/UserSystem/UserAvatarHelper.php b/src/Services/UserSystem/UserAvatarHelper.php index 73de40f7..5e14b34b 100644 --- a/src/Services/UserSystem/UserAvatarHelper.php +++ b/src/Services/UserSystem/UserAvatarHelper.php @@ -1,4 +1,7 @@ . */ - namespace App\Services\UserSystem; use Imagine\Exception\RuntimeException; @@ -115,7 +117,7 @@ class UserAvatarHelper private function getGravatar(User $user, int $s = 80, string $d = 'identicon', string $r = 'g'): string { $email = $user->getEmail(); - if (empty($email)) { + if ($email === null || $email === '') { $email = 'Part-DB'; } @@ -161,4 +163,4 @@ class UserAvatarHelper return $attachment; } -} \ No newline at end of file +} diff --git a/src/Twig/AttachmentExtension.php b/src/Twig/AttachmentExtension.php index beb1295c..fd93de9a 100644 --- a/src/Twig/AttachmentExtension.php +++ b/src/Twig/AttachmentExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Twig; use App\Entity\Attachments\Attachment; @@ -41,4 +43,4 @@ final class AttachmentExtension extends AbstractExtension new TwigFunction('ext_to_fa_icon', fn(string $extension): string => $this->FAIconGenerator->fileExtensionToFAType($extension)), ]; } -} \ No newline at end of file +} diff --git a/src/Twig/BarcodeExtension.php b/src/Twig/BarcodeExtension.php index 5e8984d2..ae1973e3 100644 --- a/src/Twig/BarcodeExtension.php +++ b/src/Twig/BarcodeExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Twig; use Com\Tecnick\Barcode\Barcode; diff --git a/src/Twig/EntityExtension.php b/src/Twig/EntityExtension.php index 92d69631..a3737c08 100644 --- a/src/Twig/EntityExtension.php +++ b/src/Twig/EntityExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Twig; use App\Entity\Attachments\Attachment; @@ -123,4 +125,4 @@ final class EntityExtension extends AbstractExtension return false; } -} \ No newline at end of file +} diff --git a/src/Twig/LogExtension.php b/src/Twig/LogExtension.php index dde70e18..34dad988 100644 --- a/src/Twig/LogExtension.php +++ b/src/Twig/LogExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Twig; use App\Entity\LogSystem\AbstractLogEntry; @@ -40,4 +42,4 @@ final class LogExtension extends AbstractExtension new TwigFunction('format_log_diff', fn($old_data, $new_data): string => $this->logDiffFormatter->formatDiff($old_data, $new_data), ['is_safe' => ['html']]), ]; } -} \ No newline at end of file +} diff --git a/src/Twig/MiscExtension.php b/src/Twig/MiscExtension.php index 32080df2..1edef7a3 100644 --- a/src/Twig/MiscExtension.php +++ b/src/Twig/MiscExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Twig; use Twig\TwigFunction; @@ -38,4 +40,4 @@ final class MiscExtension extends AbstractExtension ), ]; } -} \ No newline at end of file +} diff --git a/src/Twig/TwigCoreExtension.php b/src/Twig/TwigCoreExtension.php index d4b14c83..0443b847 100644 --- a/src/Twig/TwigCoreExtension.php +++ b/src/Twig/TwigCoreExtension.php @@ -1,4 +1,7 @@ . */ - namespace App\Twig; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; @@ -68,4 +70,4 @@ final class TwigCoreExtension extends AbstractExtension return $this->objectNormalizer->normalize($object, null); } -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php index 62231ea8..76acb25a 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThanValidator.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\BigDecimal; use Brick\Math\BigDecimal; diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php index 3e4c8444..b6df06d0 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalGreaterThenOrEqualValidator.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\BigDecimal; use Brick\Math\BigDecimal; diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php b/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php index bb4e61eb..de66eea3 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\BigDecimal; use Symfony\Component\Validator\Constraints\GreaterThan; diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php b/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php index 1e6558a2..30042fe2 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\BigDecimal; use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; diff --git a/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php b/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php index a9858730..ba89900f 100644 --- a/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php +++ b/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\BigDecimal; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; @@ -46,4 +48,4 @@ trait BigNumberConstraintTrait return $options; } -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php b/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php index b0c99947..05ed48e9 100644 --- a/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php +++ b/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\ProjectSystem; use Symfony\Component\Validator\Constraint; @@ -33,4 +35,4 @@ class ValidProjectBuildRequest extends Constraint { return self::CLASS_CONSTRAINT; } -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequestValidator.php b/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequestValidator.php index 08350f55..e5de07d2 100644 --- a/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequestValidator.php +++ b/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequestValidator.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints\ProjectSystem; use App\Entity\Parts\PartLot; @@ -79,4 +81,4 @@ class ValidProjectBuildRequestValidator extends ConstraintValidator } } } -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/ValidTheme.php b/src/Validator/Constraints/ValidTheme.php index 70a32a20..03e0d35b 100644 --- a/src/Validator/Constraints/ValidTheme.php +++ b/src/Validator/Constraints/ValidTheme.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints; use Symfony\Component\Validator\Constraint; @@ -29,4 +31,4 @@ use Symfony\Component\Validator\Constraint; class ValidTheme extends Constraint { public string $message = 'validator.selected_theme_is_invalid'; -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/ValidThemeValidator.php b/src/Validator/Constraints/ValidThemeValidator.php index 03e6212f..5d222934 100644 --- a/src/Validator/Constraints/ValidThemeValidator.php +++ b/src/Validator/Constraints/ValidThemeValidator.php @@ -1,4 +1,7 @@ . */ - namespace App\Validator\Constraints; use Symfony\Component\Validator\Constraint; @@ -48,4 +50,4 @@ class ValidThemeValidator extends ConstraintValidator ->addViolation(); } } -} \ No newline at end of file +} diff --git a/tests/DataTables/Filters/CompoundFilterTraitTest.php b/tests/DataTables/Filters/CompoundFilterTraitTest.php index e73e639a..93f3c1e1 100644 --- a/tests/DataTables/Filters/CompoundFilterTraitTest.php +++ b/tests/DataTables/Filters/CompoundFilterTraitTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\DataTables\Filters; use App\DataTables\Filters\CompoundFilterTrait; diff --git a/tests/DataTables/Filters/Constraints/FilterTraitTest.php b/tests/DataTables/Filters/Constraints/FilterTraitTest.php index baec64ed..1e32fdd8 100644 --- a/tests/DataTables/Filters/Constraints/FilterTraitTest.php +++ b/tests/DataTables/Filters/Constraints/FilterTraitTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\DataTables\Filters\Constraints; use App\DataTables\Filters\Constraints\FilterTrait; diff --git a/tests/Entity/UserSystem/PermissionDataTest.php b/tests/Entity/UserSystem/PermissionDataTest.php index d1f0ed59..4fd8c5ce 100644 --- a/tests/Entity/UserSystem/PermissionDataTest.php +++ b/tests/Entity/UserSystem/PermissionDataTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Entity\UserSystem; use App\Entity\UserSystem\PermissionData; diff --git a/tests/Helpers/Projects/ProjectBuildRequestTest.php b/tests/Helpers/Projects/ProjectBuildRequestTest.php index 801efd4b..c561613d 100644 --- a/tests/Helpers/Projects/ProjectBuildRequestTest.php +++ b/tests/Helpers/Projects/ProjectBuildRequestTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Helpers\Projects; use App\Entity\Parts\MeasurementUnit; diff --git a/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php b/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php index 434527d8..c9a14426 100644 --- a/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php +++ b/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Security; use App\Entity\UserSystem\User; diff --git a/tests/Security/SamlUserFactoryTest.php b/tests/Security/SamlUserFactoryTest.php index 663b8627..7780b4be 100644 --- a/tests/Security/SamlUserFactoryTest.php +++ b/tests/Security/SamlUserFactoryTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Security; use App\Entity\UserSystem\User; diff --git a/tests/Serializer/BigNumberNormalizerTest.php b/tests/Serializer/BigNumberNormalizerTest.php index c0cb6070..6e3ed79b 100644 --- a/tests/Serializer/BigNumberNormalizerTest.php +++ b/tests/Serializer/BigNumberNormalizerTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Serializer; use App\Serializer\BigNumberNormalizer; diff --git a/tests/Serializer/PartNormalizerTest.php b/tests/Serializer/PartNormalizerTest.php index f19d4c6b..979254d8 100644 --- a/tests/Serializer/PartNormalizerTest.php +++ b/tests/Serializer/PartNormalizerTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Serializer; use App\Entity\Parts\Part; diff --git a/tests/Serializer/StructuralElementDenormalizerTest.php b/tests/Serializer/StructuralElementDenormalizerTest.php index be0a9e61..19cf4ea8 100644 --- a/tests/Serializer/StructuralElementDenormalizerTest.php +++ b/tests/Serializer/StructuralElementDenormalizerTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Serializer; use App\Entity\Parts\Category; diff --git a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php index 4349c2a7..918c0339 100644 --- a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php +++ b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Serializer; use App\Entity\Parts\Category; diff --git a/tests/Serializer/StructuralElementNormalizerTest.php b/tests/Serializer/StructuralElementNormalizerTest.php index 0974e670..8d4df05a 100644 --- a/tests/Serializer/StructuralElementNormalizerTest.php +++ b/tests/Serializer/StructuralElementNormalizerTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Serializer; use App\Entity\Parts\Category; diff --git a/tests/Services/ImportExportSystem/BOMImporterTest.php b/tests/Services/ImportExportSystem/BOMImporterTest.php index 1ccb8275..b7379537 100644 --- a/tests/Services/ImportExportSystem/BOMImporterTest.php +++ b/tests/Services/ImportExportSystem/BOMImporterTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\ImportExportSystem; use App\Entity\ProjectSystem\Project; diff --git a/tests/Services/ImportExportSystem/EntityExporterTest.php b/tests/Services/ImportExportSystem/EntityExporterTest.php index b57b22a3..004971ab 100644 --- a/tests/Services/ImportExportSystem/EntityExporterTest.php +++ b/tests/Services/ImportExportSystem/EntityExporterTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\ImportExportSystem; use App\Entity\Parts\Category; diff --git a/tests/Services/LogSystem/EventCommentNeededHelperTest.php b/tests/Services/LogSystem/EventCommentNeededHelperTest.php index 9cfabd6a..2fb3e123 100644 --- a/tests/Services/LogSystem/EventCommentNeededHelperTest.php +++ b/tests/Services/LogSystem/EventCommentNeededHelperTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\LogSystem; use App\Services\LogSystem\EventCommentNeededHelper; diff --git a/tests/Services/Misc/MySQLDumpXMLConverterTest.php b/tests/Services/Misc/MySQLDumpXMLConverterTest.php index b666597a..98614b4b 100644 --- a/tests/Services/Misc/MySQLDumpXMLConverterTest.php +++ b/tests/Services/Misc/MySQLDumpXMLConverterTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\Misc; use App\Services\ImportExportSystem\PartKeeprImporter\MySQLDumpXMLConverter; diff --git a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php index bbc9eb41..b88e86e8 100644 --- a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php +++ b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php @@ -1,5 +1,7 @@ . */ - namespace App\Tests\Services\ProjectSystem; use App\Entity\Parts\Part; diff --git a/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php b/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php index 92c22b44..4baa7cf3 100644 --- a/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php +++ b/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\ProjectSystem; use App\Entity\ProjectSystem\Project; diff --git a/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php b/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php index 82376298..1acadd14 100644 --- a/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php +++ b/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\UserSystem; use App\Entity\UserSystem\PermissionData; diff --git a/tests/Twig/EntityExtensionTest.php b/tests/Twig/EntityExtensionTest.php index 530047ef..86e42542 100644 --- a/tests/Twig/EntityExtensionTest.php +++ b/tests/Twig/EntityExtensionTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Twig; use App\Entity\Attachments\PartAttachment; diff --git a/tests/Twig/TwigCoreExtensionTest.php b/tests/Twig/TwigCoreExtensionTest.php index 67961fe1..47283520 100644 --- a/tests/Twig/TwigCoreExtensionTest.php +++ b/tests/Twig/TwigCoreExtensionTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Twig; use App\Twig\TwigCoreExtension; diff --git a/tests/Twig/UserExtensionTest.php b/tests/Twig/UserExtensionTest.php index e818f447..1344bbc5 100644 --- a/tests/Twig/UserExtensionTest.php +++ b/tests/Twig/UserExtensionTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Twig; use App\Twig\UserExtension; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3181151d..ecec14bf 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,15 +1,14 @@ bootEnv(dirname(__DIR__).'/.env'); } - if ($_SERVER['APP_DEBUG']) { umask(0000); } diff --git a/tests/symfony-container.php b/tests/symfony-container.php index f4b63872..be2ff108 100644 --- a/tests/symfony-container.php +++ b/tests/symfony-container.php @@ -1,10 +1,9 @@ boot(); - return $appKernel->getContainer();