Skip to content

Removed obsolete parentheses around the new calls #2978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Command/Utils/CheckDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function getNamespaceDirectories(): array
{
// Find all main namespace directories under 'tools' directory
$finder = (new Finder())
$finder = new Finder()
->depth(1)
->ignoreDotFiles(true)
->directories()
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/JWTCreatedSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function setLocalizationData(array &$payload, UserInterface $user): void
private function setExpiration(array &$payload): void
{
// Set new exp value for JWT
$payload['exp'] = (new DateTime('+1 day', new DateTimeZone('UTC')))->getTimestamp();
$payload['exp'] = new DateTime('+1 day', new DateTimeZone('UTC'))->getTimestamp();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/HealthzRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function create(): Entity
public function cleanup(): int
{
// Determine date
$date = (new DateTimeImmutable(timezone: new DateTimeZone('UTC')))
$date = new DateTimeImmutable(timezone: new DateTimeZone('UTC'))
->sub(new DateInterval('P7D'));

// Create query builder
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/LogRequestRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
public function cleanHistory(): int
{
// Determine date
$date = (new DateTimeImmutable(timezone: new DateTimeZone('UTC')))
$date = new DateTimeImmutable(timezone: new DateTimeZone('UTC'))
->sub(new DateInterval('P3Y'));

// Create query builder and define delete query
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/Traits/RepositoryMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function findByAdvanced(
*/
RepositoryHelper::resetParameterCount();

$iterator = (new Paginator($queryBuilder, true))->getIterator();
$iterator = new Paginator($queryBuilder, true)->getIterator();

assert($iterator instanceof ArrayIterator);

Expand Down
2 changes: 1 addition & 1 deletion src/Rest/RestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getDtoForEntity(
* @var RestDtoInterface $restDto
* @var class-string<RestDtoInterface> $dtoClass
*/
$restDto = (new $dtoClass())
$restDto = new $dtoClass()
->setId($id);

if ($patch === true) {
Expand Down
2 changes: 1 addition & 1 deletion tests/DataFixtures/ORM/LoadApiKeyData.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getOrder(): int
private function createApiKey(ObjectManager $manager, ?string $role = null): bool
{
// Create new entity
$entity = (new ApiKey())
$entity = new ApiKey()
->setDescription('ApiKey Description: ' . ($role === null ? '' : $this->rolesService->getShort($role)))
->setToken(str_pad($role === null ? '' : $this->rolesService->getShort($role), 40, '_'));

Expand Down
2 changes: 1 addition & 1 deletion tests/DataFixtures/ORM/LoadRoleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getOrder(): int
private function createRole(ObjectManager $manager, string $role): bool
{
// Create new Role entity
$entity = (new Role($role))
$entity = new Role($role)
->setDescription('Description - ' . $role);

// Persist entity
Expand Down
2 changes: 1 addition & 1 deletion tests/DataFixtures/ORM/LoadUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function createUser(ObjectManager $manager, ?string $role = null): bool
$suffix = $role === null ? '' : '-' . $this->rolesService->getShort($role);

// Create new entity
$entity = (new User())
$entity = new User()
->setUsername('john' . $suffix)
->setFirstName('John')
->setLastName('Doe')
Expand Down
2 changes: 1 addition & 1 deletion tests/DataFixtures/ORM/LoadUserGroupData.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function createUserGroup(ObjectManager $manager, string $role): bool
$roleReference = $this->getReference('Role-' . $this->rolesService->getShort($role), Role::class);

// Create new entity
$entity = (new UserGroup())
$entity = new UserGroup()
->setRole($roleReference)
->setName($this->rolesService->getRoleLabel($role));

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Repository/HealthzRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testThatReadValueMethodReturnsExpectedWithEmptyDatabase(): void
public function testThatCreateValueReturnsExpected(): void
{
self::assertEqualsWithDelta(
(new DateTimeImmutable('now', new DateTimeZone('utc')))->getTimestamp(),
new DateTimeImmutable('now', new DateTimeZone('utc'))->getTimestamp(),
$this->getRepository()->create()->getCreatedAt()->getTimestamp(),
1,
);
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/AutoMapper/GenericRestRequestMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testThatMapToObjectThrowsAnExceptionIfSourceIsAnArray(): void

$resource = $this->getMockBuilder(UserGroupResource::class)->disableOriginalConstructor()->getMock();

(new RequestMapper($resource))->mapToObject([], new stdClass());
new RequestMapper($resource)->mapToObject([], new stdClass());
}

/**
Expand All @@ -53,7 +53,7 @@ public function testThatMapToObjectThrowsAnExceptionIfSourceIsNotRequestObject()

$resource = $this->getMockBuilder(UserGroupResource::class)->disableOriginalConstructor()->getMock();

(new RequestMapper($resource))->mapToObject(new stdClass(), new stdClass());
new RequestMapper($resource)->mapToObject(new stdClass(), new stdClass());
}

/**
Expand All @@ -69,7 +69,7 @@ public function testThatMapToObjectThrowsAnExceptionIfDestinationIsNotRestDtoInt

$resource = $this->getMockBuilder(UserGroupResource::class)->disableOriginalConstructor()->getMock();

(new RequestMapper($resource))->mapToObject(new Request(), new stdClass());
new RequestMapper($resource)->mapToObject(new Request(), new stdClass());
}

/**
Expand All @@ -85,7 +85,7 @@ public function testThatMapToObjectThrowsAnExceptionIfThereIsNotPropertiesToConv

$mockRestDtoInterface = $this->getMockBuilder(RestDtoInterface::class)->getMock();

(new TestRestRequestMapperWithoutProperties())->mapToObject(new Request(), $mockRestDtoInterface);
new TestRestRequestMapperWithoutProperties()->mapToObject(new Request(), $mockRestDtoInterface);
}

/**
Expand All @@ -100,7 +100,7 @@ public function testThatMapToObjectWorksAsExpected(): void
]);

/** @var TestRestRequestMapperDto $transformedObject */
$transformedObject = (new TestRestRequestMapper())->mapToObject($request, new TestRestRequestMapperDto());
$transformedObject = new TestRestRequestMapper()->mapToObject($request, new TestRestRequestMapperDto());

self::assertSame('someValue', $transformedObject->getSomeProperty());
self::assertSame('fbzrGenafsbezInyhr', $transformedObject->getSomeTransformProperty());
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Compiler/StopwatchCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testThatFindTaggedServiceIdsMethodIsCalled(): void
->method('findTaggedServiceIds')
->willReturn([]);

(new StopwatchCompilerPass())->process($container);
new StopwatchCompilerPass()->process($container);
}

#[TestDox('Test that no other container methods are called when tagged service is not supported')]
Expand All @@ -54,7 +54,7 @@ public function testThatIfServiceStartsWithAppNoOtherContainerMethodsAreCalled()
->expects(self::never())
->method('setDefinition');

(new StopwatchCompilerPass())->process($container);
new StopwatchCompilerPass()->process($container);
}

public function testThatAllExpectedContainerMethodsAreCalled(): void
Expand All @@ -80,6 +80,6 @@ public function testThatAllExpectedContainerMethodsAreCalled(): void
->method('setDefinition')
->with('App\Foo.stopwatch');

(new StopwatchCompilerPass())->process($container);
new StopwatchCompilerPass()->process($container);
}
}
2 changes: 1 addition & 1 deletion tests/Integration/Controller/HealthzControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testThatInvokeMethodIsCallingExpectedMethods(): void
),
);

$response = (new HealthzController($responseHandler, $healthzService))($request);
$response = new HealthzController($responseHandler, $healthzService)($request);
$content = $response->getContent();

self::assertSame(200, $response->getStatusCode());
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Controller/IndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IndexControllerTest extends KernelTestCase
#[TestDox('Test that `__invoke` method returns proper response')]
public function testThatInvokeMethodReturnsExpectedResponse(): void
{
$response = (new IndexController())();
$response = new IndexController()();
$content = $response->getContent();

self::assertSame(200, $response->getStatusCode());
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Controller/VersionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testThatInvokeMethodIsCallingExpectedMethods(): void
->method('get')
->willReturn('1.0.0');

$response = (new VersionController($version))();
$response = new VersionController($version)();
$content = $response->getContent();

self::assertSame(200, $response->getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GetTokenControllerTest extends KernelTestCase
public function testThatGetTokenThrowsAnException(): void
{
try {
(new GetTokenController())();
new GetTokenController()();
} catch (Throwable $exception) {
self::assertInstanceOf(HttpException::class, $exception);
self::assertSame(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testThatInvokeMethodCallsExpectedServiceMethods(): void
->method('getLanguages')
->willReturn(['fi', 'en']);

$response = (new LanguageController($Localization))();
$response = new LanguageController($Localization)();
$content = $response->getContent();

self::assertSame(200, $response->getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testThatInvokeMethodCallsExpectedServiceMethods(): void
->method('getLocales')
->willReturn(['fi', 'en']);

$response = (new LocaleController($Localization))();
$response = new LocaleController($Localization)();
$content = $response->getContent();

self::assertSame(200, $response->getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testThatInvokeMethodCallsExpectedServiceMethods(): void
],
]);

$response = (new TimeZoneController($Localization))();
$response = new TimeZoneController($Localization)();
$content = $response->getContent();

self::assertSame(200, $response->getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
)
->willReturn('{}');

(new GroupsController($serializer))($user);
new GroupsController($serializer)($user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->with(['foo', 'bar'])
->willReturn(['foo', 'bar']);

(new IndexController($serializer, $rolesService))($user);
new IndexController($serializer, $rolesService)($user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->with($user->getRoles())
->willReturn([]);

(new RolesController($rolesService))->__invoke($user);
new RolesController($rolesService)->__invoke($user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->method('createResponse')
->with($request, $role, $resource);

(new FindOneRoleController($resource))
new FindOneRoleController($resource)
->setResponseHandler($responseHandler)
->__invoke($request, 'role');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->with([$role->getId()])
->willReturn([$role]);

(new InheritedRolesController($rolesService))($role);
new InheritedRolesController($rolesService)($role);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();

$user = new User();
$userGroup = (new UserGroup())->setRole(new Role('role'));
$userGroup = new UserGroup()->setRole(new Role('role'));

$userResource
->expects($this->once())
Expand All @@ -55,7 +55,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->method('serialize')
->willReturn('[]');

(new AttachUserGroupController($userResource, $userGroupResource, $serializer))($user, $userGroup);
new AttachUserGroupController($userResource, $userGroupResource, $serializer)($user, $userGroup);

self::assertTrue(
$user->getUserGroups()->contains($userGroup),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testThatInvokeMethodThrowsAnExceptionIfUserTriesToDeleteHimself(
$request = Request::create('/');
$user = new User();

(new DeleteUserController($resource))($request, $user, $user);
new DeleteUserController($resource)($request, $user, $user);
}

/**
Expand All @@ -83,7 +83,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->method('createResponse')
->with($request, $requestUser, $resource);

(new DeleteUserController($resource))
new DeleteUserController($resource)
->setResponseHandler($responseHandler)
->__invoke($request, $requestUser, $loggedInUser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
$userGroupResource = $this->getMockBuilder(UserGroupResource::class)->disableOriginalConstructor()->getMock();
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();

$userGroup = (new UserGroup())->setRole(new Role('role'));
$user = (new User())->addUserGroup($userGroup);
$userGroup = new UserGroup()->setRole(new Role('role'));
$user = new User()->addUserGroup($userGroup);

$userResource
->expects($this->once())
Expand All @@ -55,7 +55,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->method('serialize')
->willReturn('[]');

(new DetachUserGroupController($userResource, $userGroupResource, $serializer))($user, $userGroup);
new DetachUserGroupController($userResource, $userGroupResource, $serializer)($user, $userGroup);

self::assertFalse(
$user->getUserGroups()->contains($userGroup),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
)
->willReturn('[]');

(new UserGroupsController($serializer))($user);
new UserGroupsController($serializer)($user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->with($user->getRoles())
->willReturn([]);

(new UserRolesController($rolesService))->__invoke($user);
new UserRolesController($rolesService)->__invoke($user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
$userGroupResource = $this->getMockBuilder(UserGroupResource::class)->disableOriginalConstructor()->getMock();
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();

$userGroup = (new UserGroup())->setRole(new Role('role'));
$userGroup = new UserGroup()->setRole(new Role('role'));
$user = new User();

$userResource
Expand All @@ -55,7 +55,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->method('serialize')
->willReturn('[]');

(new AttachUserController($userResource, $userGroupResource, $serializer))($userGroup, $user);
new AttachUserController($userResource, $userGroupResource, $serializer)($userGroup, $user);

self::assertTrue(
$user->getUserGroups()->contains($userGroup),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
$userGroupResource = $this->getMockBuilder(UserGroupResource::class)->disableOriginalConstructor()->getMock();
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();

$userGroup = (new UserGroup())->setRole(new Role('role'));
$user = (new User())->addUserGroup($userGroup);
$userGroup = new UserGroup()->setRole(new Role('role'));
$user = new User()->addUserGroup($userGroup);

$userResource
->expects($this->once())
Expand All @@ -55,7 +55,7 @@ public function testThatInvokeMethodCallsExpectedMethods(): void
->method('serialize')
->willReturn('[]');

(new DetachUserController($userResource, $userGroupResource, $serializer))($userGroup, $user);
new DetachUserController($userResource, $userGroupResource, $serializer)($userGroup, $user);

self::assertFalse(
$user->getUserGroups()->contains($userGroup),
Expand Down
Loading
Loading