Fixed some return type deprecation messages

This commit is contained in:
Jan Böhmer 2023-04-15 19:33:39 +02:00
parent 558440168d
commit 1cee1abe00
37 changed files with 70 additions and 70 deletions

View file

@ -69,7 +69,7 @@ class ImportPartKeeprCommand extends Command
$this->addOption('--import-users', null, InputOption::VALUE_NONE, 'Import users (passwords will not be imported).');
}
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

View file

@ -64,7 +64,7 @@ class ProjectController extends AbstractController
/**
* @Route("/{id}/info", name="project_info", requirements={"id"="\d+"})
*/
public function info(Project $project, Request $request, ProjectBuildHelper $buildHelper)
public function info(Project $project, Request $request, ProjectBuildHelper $buildHelper): Response
{
$this->denyAccessUnlessGranted('read', $project);

View file

@ -38,7 +38,7 @@ use Omines\DataTablesBundle\Adapter\Doctrine\FetchJoinORMAdapter;
*/
class CustomFetchJoinORMAdapter extends FetchJoinORMAdapter
{
public function getCount(QueryBuilder $queryBuilder, $identifier)
public function getCount(QueryBuilder $queryBuilder, $identifier): ?int
{
$qb_without_group_by = clone $queryBuilder;

View file

@ -41,7 +41,7 @@ class PrettyBoolColumn extends AbstractColumn
return (bool) $value;
}
public function render($value, $context)
public function render($value, $context): string
{
if ($value === true) {
return '<span class="badge bg-success"><i class="fa-solid fa-circle-check fa-fw"></i> '

View file

@ -27,7 +27,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class RowClassColumn extends AbstractColumn
{
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): self
{
parent::configureOptions($resolver);

View file

@ -33,7 +33,7 @@ class SIUnitNumberColumn extends AbstractColumn
$this->formatter = $formatter;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): self
{
parent::configureOptions($resolver);

View file

@ -28,7 +28,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class SelectColumn extends AbstractColumn
{
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): self
{
parent::configureOptions($resolver);
@ -48,7 +48,7 @@ class SelectColumn extends AbstractColumn
return $value;
}
public function render($value, $context)
public function render($value, $context): string
{
//Return empty string, as it this column is filled by datatables on client side
return '';

View file

@ -49,7 +49,7 @@ class SQLiteRegexExtension implements EventSubscriberInterface
}
}
public function getSubscribedEvents()
public function getSubscribedEvents(): array
{
return[
Events::postConnect

View file

@ -29,17 +29,17 @@ use Doctrine\DBAL\Types\Type;
class TinyIntType extends Type
{
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return 'TINYINT';
}
public function getName()
public function getName(): string
{
return 'tinyint';
}
public function requiresSQLCommentHint(AbstractPlatform $platform)
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
//We use the comment, so that doctrine migrations can properly detect, that nothing has changed and no migration is needed.
return true;

View file

@ -41,7 +41,7 @@ class InstanceOfConstraintType extends AbstractType
$resolver->setDefault('data_class', InstanceOfConstraint::class);
}
public function getParent()
public function getParent(): string
{
return ChoiceConstraintType::class;
}

View file

@ -8,7 +8,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ProjectBOMEntryCollectionType extends AbstractType
{
public function getParent()
public function getParent(): string
{
return CollectionType::class;
}
@ -28,7 +28,7 @@ class ProjectBOMEntryCollectionType extends AbstractType
]);
}
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'project_bom_entry_collection';
}

View file

@ -93,7 +93,7 @@ class ProjectBOMEntryType extends AbstractType
}
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'project_bom_entry';
}

View file

@ -31,7 +31,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PartLotSelectType extends AbstractType
{
public function getParent()
public function getParent(): string
{
return EntityType::class;
}

View file

@ -117,7 +117,7 @@ class PartSelectType extends AbstractType implements DataMapperInterface
]);
}
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'part_select';
}

View file

@ -34,7 +34,7 @@ class ThemeChoiceType extends AbstractType
$this->available_themes = $available_themes;
}
public function getParent()
public function getParent(): string
{
return ChoiceType::class;
}

View file

@ -40,7 +40,7 @@ class UserSelectType extends AbstractType
]);
}
public function getParent()
public function getParent(): string
{
return StructuralEntityType::class;
}

View file

@ -37,7 +37,7 @@ class EnsureSAMLUserForSAMLLoginChecker implements EventSubscriberInterface
$this->translator = $translator;
}
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
AuthenticationSuccessEvent::class => 'onAuthenticationSuccess',

View file

@ -118,7 +118,7 @@ class ParameterVoter extends ExtendedVoter
return $this->resolver->inherit($user, $param, $attribute) ?? false;
}
protected function supports(string $attribute, $subject)
protected function supports(string $attribute, $subject): bool
{
if (is_a($subject, AbstractParameter::class, true)) {
//These are the allowed attributes

View file

@ -43,7 +43,7 @@ class StructuralElementDenormalizer implements ContextAwareDenormalizerInterface
$this->entityManager = $entityManager;
}
public function supportsDenormalization($data, string $type, string $format = null, array $context = [])
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return is_array($data)
&& is_subclass_of($type, AbstractStructuralDBElement::class)

View file

@ -37,7 +37,7 @@ class StructuralElementFromNameDenormalizer implements DenormalizerInterface, Ca
$this->em = $em;
}
public function supportsDenormalization($data, string $type, string $format = null)
public function supportsDenormalization($data, string $type, string $format = null): bool
{
return is_string($data) && is_subclass_of($type, AbstractStructuralDBElement::class);
}

View file

@ -32,7 +32,7 @@ final class MiscExtension extends AbstractExtension
$this->eventCommentNeededHelper = $eventCommentNeededHelper;
}
public function getFunctions()
public function getFunctions(): array
{
return [
new \Twig\TwigFunction('event_comment_needed',

View file

@ -54,7 +54,7 @@ final class TwigCoreExtension extends AbstractExtension
];
}
public function getFilters()
public function getFilters(): array
{
return [
/* Converts the given object to an array representation of the public/accessible properties */

View file

@ -26,7 +26,7 @@ use PHPUnit\Framework\TestCase;
class PermissionDataTest extends TestCase
{
public function testGetSetIs()
public function testGetSetIs(): void
{
$perm_data = new PermissionData();
@ -60,7 +60,7 @@ class PermissionDataTest extends TestCase
$this->assertFalse($perm_data->isPermissionSet('p1', 'op1'));
}
public function testJSONSerialization()
public function testJSONSerialization(): void
{
$perm_data = new PermissionData();
@ -99,7 +99,7 @@ class PermissionDataTest extends TestCase
}
public function testFromJSON()
public function testFromJSON(): void
{
$json = json_encode([
'perm1' => [
@ -120,7 +120,7 @@ class PermissionDataTest extends TestCase
$this->assertFalse($perm_data->getPermissionValue('perm2', 'op2'));
}
public function testResetPermissions()
public function testResetPermissions(): void
{
$data = new PermissionData();
@ -147,7 +147,7 @@ class PermissionDataTest extends TestCase
$this->assertFalse($data->isPermissionSet('perm1', 'op3'));
}
public function testGetSchemaVersion()
public function testGetSchemaVersion(): void
{
$data = new PermissionData();
@ -159,7 +159,7 @@ class PermissionDataTest extends TestCase
$this->assertEquals(12345, $data->getSchemaVersion());
}
public function testIsAnyOperationOfPermissionSet()
public function testIsAnyOperationOfPermissionSet(): void
{
$data = new PermissionData();
@ -170,7 +170,7 @@ class PermissionDataTest extends TestCase
$this->assertTrue($data->isAnyOperationOfPermissionSet('perm1'));
}
public function testGetAllDefinedOperationsOfPermission()
public function testGetAllDefinedOperationsOfPermission(): void
{
$data = new PermissionData();
@ -185,7 +185,7 @@ class PermissionDataTest extends TestCase
$data->getAllDefinedOperationsOfPermission('perm1'));
}
public function testSetAllOperationsOfPermission()
public function testSetAllOperationsOfPermission(): void
{
$data = new PermissionData();
@ -200,7 +200,7 @@ class PermissionDataTest extends TestCase
$data->getAllDefinedOperationsOfPermission('perm1'));
}
public function testRemovePermission()
public function testRemovePermission(): void
{
$data = new PermissionData();

View file

@ -115,7 +115,7 @@ class ProjectBuildRequestTest extends TestCase
$this->project1->addBomEntry($this->bom_entry1c);
}
public function testInitialization()
public function testInitialization(): void
{
//The values should be already prefilled correctly
$request = new ProjectBuildRequest($this->project1, 10);
@ -127,19 +127,19 @@ class ProjectBuildRequestTest extends TestCase
$this->assertEquals(2.5, $request->getLotWithdrawAmount($this->lot2));
}
public function testGetNumberOfBuilds()
public function testGetNumberOfBuilds(): void
{
$build_request = new ProjectBuildRequest($this->project1, 5);
$this->assertEquals(5, $build_request->getNumberOfBuilds());
}
public function testGetProject()
public function testGetProject(): void
{
$build_request = new ProjectBuildRequest($this->project1, 5);
$this->assertEquals($this->project1, $build_request->getProject());
}
public function testGetNeededAmountForBOMEntry()
public function testGetNeededAmountForBOMEntry(): void
{
$build_request = new ProjectBuildRequest($this->project1, 5);
$this->assertEquals(10, $build_request->getNeededAmountForBOMEntry($this->bom_entry1a));
@ -147,7 +147,7 @@ class ProjectBuildRequestTest extends TestCase
$this->assertEquals(20, $build_request->getNeededAmountForBOMEntry($this->bom_entry1c));
}
public function testGetSetLotWithdrawAmount()
public function testGetSetLotWithdrawAmount(): void
{
$build_request = new ProjectBuildRequest($this->project1, 5);
@ -160,7 +160,7 @@ class ProjectBuildRequestTest extends TestCase
$this->assertEquals(3, $build_request->getLotWithdrawAmount($this->lot1b));
}
public function testGetWithdrawAmountSum()
public function testGetWithdrawAmountSum(): void
{
//The sum of all withdraw amounts for an BOM entry (over all lots of the associated part) should be correct
$build_request = new ProjectBuildRequest($this->project1, 5);

View file

@ -37,7 +37,7 @@ class SamlUserFactoryTest extends WebTestCase
$this->service = self::getContainer()->get(SamlUserFactory::class);
}
public function testCreateUser()
public function testCreateUser(): void
{
$user = $this->service->createUser('sso_user', [
'email' => ['j.doe@invalid.invalid'],
@ -63,7 +63,7 @@ class SamlUserFactoryTest extends WebTestCase
$this->assertEquals('j.doe@invalid.invalid', $user->getEmail());
}
public function testMapSAMLRolesToLocalGroupID()
public function testMapSAMLRolesToLocalGroupID(): void
{
$mapping = [
'admin' => 2, //This comes first, as this should have higher priority

View file

@ -39,13 +39,13 @@ class BigNumberNormalizerTest extends WebTestCase
$this->service = self::getContainer()->get(BigNumberNormalizer::class);
}
public function testNormalize()
public function testNormalize(): void
{
$bigDecimal = BigDecimal::of('1.23456789');
$this->assertSame('1.23456789', $this->service->normalize($bigDecimal));
}
public function testSupportsNormalization()
public function testSupportsNormalization(): void
{
//Normalizer must only support BigNumber objects (and child classes)
$this->assertFalse($this->service->supportsNormalization(new \stdClass()));

View file

@ -41,14 +41,14 @@ class PartNormalizerTest extends WebTestCase
$this->service = self::getContainer()->get(PartNormalizer::class);
}
public function testSupportsNormalization()
public function testSupportsNormalization(): void
{
//Normalizer must only support Part objects (and child classes)
$this->assertFalse($this->service->supportsNormalization(new \stdClass()));
$this->assertTrue($this->service->supportsNormalization(new Part()));
}
public function testNormalize()
public function testNormalize(): void
{
$part = new Part();
$part->setName('Test Part');
@ -70,7 +70,7 @@ class PartNormalizerTest extends WebTestCase
$this->assertArrayNotHasKey('type', $data);
}
public function testSupportsDenormalization()
public function testSupportsDenormalization(): void
{
//Normalizer must only support Part type with array as input
$this->assertFalse($this->service->supportsDenormalization(new \stdClass(), Part::class));
@ -79,7 +79,7 @@ class PartNormalizerTest extends WebTestCase
$this->assertTrue($this->service->supportsDenormalization(['a' => 'b'], Part::class));
}
public function testDenormalize()
public function testDenormalize(): void
{
$input = [
'name' => 'Test Part',

View file

@ -42,7 +42,7 @@ class StructuralElementNormalizerTest extends WebTestCase
$this->service = self::getContainer()->get(StructuralElementNormalizer::class);
}
public function testNormalize()
public function testNormalize(): void
{
$category1 = (new Category())->setName('Category 1');
$category11 = (new Category())->setName('Category 1.1');
@ -65,7 +65,7 @@ class StructuralElementNormalizerTest extends WebTestCase
$this->assertArrayNotHasKey('type', $data11);
}
public function testSupportsNormalization()
public function testSupportsNormalization(): void
{
//Normalizer must only support StructuralElement objects (and child classes)
$this->assertFalse($this->service->supportsNormalization(new \stdClass()));

View file

@ -140,7 +140,7 @@ class AttachmentPathResolverTest extends WebTestCase
$this->assertSame($expected, $this->service->realPathToPlaceholder($param, $old_method));
}
public function germanFootprintPathdDataProvider()
public function germanFootprintPathdDataProvider(): ?\Generator
{
self::bootKernel();
$this->projectDir_orig = realpath(self::$kernel->getProjectDir());

View file

@ -25,7 +25,7 @@ use PHPUnit\Framework\TestCase;
class EventCommentNeededHelperTest extends TestCase
{
public function testIsCommentNeeded()
public function testIsCommentNeeded(): void
{
$service = new EventCommentNeededHelper(['part_edit', 'part_create']);
$this->assertTrue($service->isCommentNeeded('part_edit'));
@ -34,7 +34,7 @@ class EventCommentNeededHelperTest extends TestCase
$this->assertFalse($service->isCommentNeeded('part_stock_operation'));
}
public function testIsCommentNeededInvalidTypeException()
public function testIsCommentNeededInvalidTypeException(): void
{
$service = new EventCommentNeededHelper(['part_edit', 'part_create']);
$this->expectException(\InvalidArgumentException::class);

View file

@ -26,7 +26,7 @@ use PHPUnit\Framework\TestCase;
class MySQLDumpXMLConverterTest extends TestCase
{
public function testConvertMySQLDumpXMLDataToArrayStructure()
public function testConvertMySQLDumpXMLDataToArrayStructure(): void
{
$service = new MySQLDumpXMLConverter();

View file

@ -89,7 +89,7 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
$this->lotWithUnknownInstock->setStorageLocation($this->storageLocation);
}
public function testCanWithdraw()
public function testCanWithdraw(): void
{
//Normal lots should be withdrawable
$this->assertTrue($this->service->canWithdraw($this->partLot1));
@ -103,7 +103,7 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
$this->assertFalse($this->service->canWithdraw($this->lotWithUnknownInstock));
}
public function testCanAdd()
public function testCanAdd(): void
{
//Normal lots should be addable
$this->assertTrue($this->service->canAdd($this->partLot1));
@ -116,7 +116,7 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
$this->assertFalse($this->service->canAdd($this->lotWithUnknownInstock));
}
public function testAdd()
public function testAdd(): void
{
//Add 5 to lot 1
$this->service->add($this->partLot1, 5, "Test");
@ -132,7 +132,7 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
}
public function testWithdraw()
public function testWithdraw(): void
{
//Withdraw 5 from lot 1
$this->service->withdraw($this->partLot1, 5, "Test");
@ -143,7 +143,7 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
$this->assertEquals(0, $this->partLot2->getAmount());
}
public function testMove()
public function testMove(): void
{
//Move 5 from lot 1 to lot 2
$this->service->move($this->partLot1, $this->partLot2, 5, "Test");

View file

@ -39,7 +39,7 @@ class ProjectBuildHelperTest extends WebTestCase
$this->service = self::getContainer()->get(ProjectBuildHelper::class);
}
public function testGetMaximumBuildableCountForBOMEntryNonPartBomEntry()
public function testGetMaximumBuildableCountForBOMEntryNonPartBomEntry(): void
{
$bom_entry = new ProjectBOMEntry();
$bom_entry->setPart(null);
@ -50,7 +50,7 @@ class ProjectBuildHelperTest extends WebTestCase
$this->service->getMaximumBuildableCountForBOMEntry($bom_entry);
}
public function testGetMaximumBuildableCountForBOMEntry()
public function testGetMaximumBuildableCountForBOMEntry(): void
{
$project_bom_entry = new ProjectBOMEntry();
$project_bom_entry->setQuantity(10);
@ -74,7 +74,7 @@ class ProjectBuildHelperTest extends WebTestCase
$this->assertEquals(0, $this->service->getMaximumBuildableCountForBOMEntry($project_bom_entry));
}
public function testGetMaximumBuildableCount()
public function testGetMaximumBuildableCount(): void
{
$project = new Project();

View file

@ -56,7 +56,7 @@ class PermissionSchemaUpdaterTest extends WebTestCase
$this->service = self::$container->get(PermissionSchemaUpdater::class);
}
public function testIsSchemaUpdateNeeded()
public function testIsSchemaUpdateNeeded(): void
{
$perm_data = new PermissionData();
$perm_data->setSchemaVersion(0);
@ -70,7 +70,7 @@ class PermissionSchemaUpdaterTest extends WebTestCase
self::assertFalse($this->service->isSchemaUpdateNeeded($user));
}
public function testUpgradeSchema()
public function testUpgradeSchema(): void
{
$perm_data = new PermissionData();
$perm_data->setSchemaVersion(0);
@ -84,7 +84,7 @@ class PermissionSchemaUpdaterTest extends WebTestCase
self::assertFalse($this->service->upgradeSchema($user));
}
public function testUpgradeSchemaToVersion1()
public function testUpgradeSchemaToVersion1(): void
{
$perm_data = new PermissionData();
$perm_data->setSchemaVersion(0);
@ -98,7 +98,7 @@ class PermissionSchemaUpdaterTest extends WebTestCase
self::assertEquals(PermissionData::ALLOW, $user->getPermissions()->getPermissionValue('parts_stock', 'withdraw'));
}
public function testUpgradeSchemaToVersion2()
public function testUpgradeSchemaToVersion2(): void
{
$perm_data = new PermissionData();
$perm_data->setSchemaVersion(1);

View file

@ -51,7 +51,7 @@ class EntityExtensionTest extends WebTestCase
$this->service = self::getContainer()->get(EntityExtension::class);
}
public function testGetEntityType()
public function testGetEntityType(): void
{
$this->assertEquals('part', $this->service->getEntityType(new Part()));
$this->assertEquals('footprint', $this->service->getEntityType(new Footprint()));

View file

@ -55,7 +55,7 @@ class TwigCoreExtensionTest extends WebTestCase
private $test3 = 5;
private $test4 = 7;
public function getTest4()
public function getTest4(): int
{
return $this->test4;
}

View file

@ -34,7 +34,7 @@ class UserExtensionTest extends WebTestCase
$this->service = self::getContainer()->get(UserExtension::class);
}
public function removeeLocaleFromPathDataSet()
public function removeeLocaleFromPathDataSet(): ?\Generator
{
yield ['/', '/de/'];
yield ['/test', '/de/test'];