Skip to content

Commit 9c8edd5

Browse files
committed
Fix .{_format} to {._format}
1 parent 881036e commit 9c8edd5

File tree

20 files changed

+47
-66
lines changed

20 files changed

+47
-66
lines changed

features/user/me.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Feature: Add a /me endpoint
1212
When I send a "GET" request to "/me"
1313
Then the response status code should be 200
1414
And the JSON should be valid according to the schema file "user.schema.json"
15-
And the JSON node "_metadata.mercureSubscribeTopics[0]" should be equal to "http://example.com:80/_/component_groups/{id}.{_format}"
15+
And the JSON node "_metadata.mercureSubscribeTopics[0]" should be equal to "http://example.com:80/_/component_groups/{id}{._format}"
1616

1717
Scenario: I can retrieve the current logged in user object
1818
When I send a "GET" request to "/me"

src/ApiPlatform/Metadata/Resource/UserResourceMetadataCollectionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
4949
if ($operations) {
5050
foreach ($operations as $operation) {
5151
if ($operation instanceof Get) {
52-
$newOperation = (new HttpOperation(HttpOperation::METHOD_GET, '/me.{_format}'))
52+
$newOperation = (new HttpOperation(HttpOperation::METHOD_GET, '/me{._format}'))
5353
->withShortName($operation->getShortName());
5454
$operations->add(
5555
'me',

src/Command/UserCreateCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Silverback\ApiComponentsBundle\Command;
1515

16-
use Exception;
1716
use Silverback\ApiComponentsBundle\Factory\User\UserFactory;
1817
use Symfony\Component\Console\Attribute\AsCommand;
1918
use Symfony\Component\Console\Command\Command;
@@ -139,7 +138,7 @@ private static function getNotEmptyValidator(string $label): callable
139138
{
140139
return static function (string $string) use ($label) {
141140
if (empty($string)) {
142-
throw new Exception($label . ' can not be empty');
141+
throw new \Exception($label . ' can not be empty');
143142
}
144143

145144
return $string;

src/DependencyInjection/SilverbackApiComponentsExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Silverback\ApiComponentsBundle\DependencyInjection;
1515

16-
use Exception;
1716
use Ramsey\Uuid\Doctrine\UuidType;
1817
use Silverback\ApiComponentsBundle\AttributeReader\UploadableAttributeReader;
1918
use Silverback\ApiComponentsBundle\Doctrine\Extension\ORM\RoutableExtension;
@@ -64,7 +63,7 @@
6463
class SilverbackApiComponentsExtension extends Extension implements PrependExtensionInterface
6564
{
6665
/**
67-
* @throws Exception
66+
* @throws \Exception
6867
*/
6968
public function load(array $configs, ContainerBuilder $container): void
7069
{
@@ -229,7 +228,7 @@ private function setMailerServiceArguments(ContainerBuilder $container, array $c
229228
}
230229

231230
/**
232-
* @throws Exception
231+
* @throws \Exception
233232
*/
234233
private function loadServiceConfig(ContainerBuilder $container): void
235234
{

src/Entity/Core/Route.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
#[Patch(requirements: REQUIREMENTS, security: SECURITY)]
6363
#[Get(requirements: ['id' => "(?!.+\/redirects$).+"], security: SECURITY)]
6464
// Custom endpoints
65-
#[Post(uriTemplate: '/routes/generate.{_format}', validationContext: ['groups' => ['Route:generate:write']])]
66-
#[Get(uriTemplate: '/routes/{id}/redirects.{_format}', defaults: ['_api_item_operation_name' => 'route_redirects'], requirements: REQUIREMENTS, normalizationContext: ['groups' => ['Route:redirect:read']], security: SECURITY)]
67-
#[Get(uriTemplate: '/routes_manifest/{id}.{_format}', defaults: ['_api_item_operation_name' => 'route_resources'], requirements: REQUIREMENTS, normalizationContext: ['groups' => ['Route:manifest:read']], security: SECURITY)]
65+
#[Post(uriTemplate: '/routes/generate{._format}', validationContext: ['groups' => ['Route:generate:write']])]
66+
#[Get(uriTemplate: '/routes/{id}/redirects{._format}', defaults: ['_api_item_operation_name' => 'route_redirects'], requirements: REQUIREMENTS, normalizationContext: ['groups' => ['Route:redirect:read']], security: SECURITY)]
67+
#[Get(uriTemplate: '/routes_manifest/{id}{._format}', defaults: ['_api_item_operation_name' => 'route_resources'], requirements: REQUIREMENTS, normalizationContext: ['groups' => ['Route:manifest:read']], security: SECURITY)]
6868
#[Silverback\Timestamped]
6969
class Route
7070
{

src/Entity/User/AbstractUser.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace Silverback\ApiComponentsBundle\Entity\User;
1515

1616
use ApiPlatform\Metadata\ApiProperty;
17-
use DateTime;
1817
use Lexik\Bundle\JWTAuthenticationBundle\Security\User\JWTUserInterface;
1918
use Ramsey\Uuid\Uuid;
2019
use Silverback\ApiComponentsBundle\Annotation as Silverback;
@@ -74,15 +73,15 @@ abstract class AbstractUser implements SymfonyUserInterface, PasswordAuthenticat
7473
public ?string $plainNewPasswordConfirmationToken = null;
7574

7675
#[ApiProperty(readable: false, writable: false)]
77-
protected ?DateTime $passwordRequestedAt = null;
76+
protected ?\DateTime $passwordRequestedAt = null;
7877

7978
#[UserPassword(message: 'You have not entered your current password correctly. Please try again.', groups: ['User:password:change'])]
8079
#[ApiProperty(readable: false)]
8180
#[Groups(['User:input'])]
8281
protected ?string $oldPassword = null;
8382

8483
#[ApiProperty(readable: false, writable: false)]
85-
protected ?DateTime $passwordUpdatedAt = null;
84+
protected ?\DateTime $passwordUpdatedAt = null;
8685

8786
#[Assert\NotBlank(allowNull: true, groups: ['User:emailAddress', 'Default'])]
8887
#[Assert\Email]
@@ -97,7 +96,7 @@ abstract class AbstractUser implements SymfonyUserInterface, PasswordAuthenticat
9796

9897
#[ApiProperty(readable: false, writable: false)]
9998
#[Groups(['User:output'])]
100-
protected ?DateTime $newEmailAddressChangeRequestedAt = null;
99+
protected ?\DateTime $newEmailAddressChangeRequestedAt = null;
101100

102101
#[ApiProperty(readable: false, writable: false)]
103102
public ?string $plainNewEmailConfirmationToken = null;
@@ -115,7 +114,7 @@ abstract class AbstractUser implements SymfonyUserInterface, PasswordAuthenticat
115114
public ?string $plainEmailAddressVerifyToken = null;
116115

117116
#[ApiProperty(readable: false, writable: false)]
118-
protected ?DateTime $emailLastUpdatedAt = null;
117+
protected ?\DateTime $emailLastUpdatedAt = null;
119118

120119
/**
121120
* `final` to make `createFromPayload` safe. Could instead make an interface? Or abstract and force child to define constructor?
@@ -221,12 +220,12 @@ public function setNewPasswordConfirmationToken(?string $newPasswordConfirmation
221220
return $this;
222221
}
223222

224-
public function getPasswordRequestedAt(): ?DateTime
223+
public function getPasswordRequestedAt(): ?\DateTime
225224
{
226225
return $this->passwordRequestedAt;
227226
}
228227

229-
public function setPasswordRequestedAt(?DateTime $passwordRequestedAt): self
228+
public function setPasswordRequestedAt(?\DateTime $passwordRequestedAt): self
230229
{
231230
$this->passwordRequestedAt = $passwordRequestedAt;
232231

@@ -272,7 +271,7 @@ public function setNewEmailConfirmationToken(?string $newEmailConfirmationToken)
272271
return $this;
273272
}
274273

275-
public function getNewEmailAddressChangeRequestedAt(): ?DateTime
274+
public function getNewEmailAddressChangeRequestedAt(): ?\DateTime
276275
{
277276
return $this->newEmailAddressChangeRequestedAt;
278277
}
@@ -303,7 +302,7 @@ public function isPasswordRequestLimitReached($ttl): bool
303302
{
304303
$lastRequest = $this->getPasswordRequestedAt();
305304

306-
return $lastRequest instanceof DateTime &&
305+
return $lastRequest instanceof \DateTime &&
307306
$lastRequest->getTimestamp() + $ttl > time();
308307
}
309308

src/Entity/User/UserInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
namespace Silverback\ApiComponentsBundle\Entity\User;
1515

16-
use Serializable;
1716
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;
1817

19-
interface UserInterface extends Serializable, BaseUserInterface
18+
interface UserInterface extends \Serializable, BaseUserInterface
2019
{
2120
public function getId(): ?int;
2221

src/Entity/Utility/TimestampedTrait.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313

1414
namespace Silverback\ApiComponentsBundle\Entity\Utility;
1515

16-
use DateTime;
17-
use DateTimeImmutable;
18-
1916
/**
2017
* @author Daniel West <daniel@silverback.is>
2118
*/
2219
trait TimestampedTrait
2320
{
24-
public ?DateTimeImmutable $createdAt = null;
21+
public ?\DateTimeImmutable $createdAt = null;
2522

26-
public ?DateTime $modifiedAt = null;
23+
public ?\DateTime $modifiedAt = null;
2724

2825
/** @return static */
29-
public function setCreatedAt(DateTimeImmutable $createdAt)
26+
public function setCreatedAt(\DateTimeImmutable $createdAt)
3027
{
3128
if (!$this->createdAt) {
3229
$this->createdAt = $createdAt;
@@ -35,20 +32,20 @@ public function setCreatedAt(DateTimeImmutable $createdAt)
3532
return $this;
3633
}
3734

38-
public function getCreatedAt(): ?DateTimeImmutable
35+
public function getCreatedAt(): ?\DateTimeImmutable
3936
{
4037
return $this->createdAt;
4138
}
4239

4340
/** @return static */
44-
public function setModifiedAt(DateTime $modifiedAt)
41+
public function setModifiedAt(\DateTime $modifiedAt)
4542
{
4643
$this->modifiedAt = $modifiedAt;
4744

4845
return $this;
4946
}
5047

51-
public function getModifiedAt(): ?DateTime
48+
public function getModifiedAt(): ?\DateTime
5249
{
5350
return $this->modifiedAt;
5451
}

src/EventListener/Api/RouteEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function onPostValidate(ViewEvent $event): void
4343
if (
4444
empty($data) ||
4545
!$data instanceof Route ||
46-
'_api_/routes/generate.{_format}_post' !== $operationName
46+
'_api_/routes/generate{._format}_post' !== $operationName
4747
) {
4848
return;
4949
}

src/Helper/Form/FormCachePurger.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace Silverback\ApiComponentsBundle\Helper\Form;
1515

16-
use DateTime;
1716
use Doctrine\ORM\EntityManagerInterface;
18-
use ReflectionClass;
1917
use Silverback\ApiComponentsBundle\Entity\Component\Form;
2018
use Silverback\ApiComponentsBundle\Event\CommandLogEvent;
2119
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -63,8 +61,8 @@ public function clear($cacheDir = null): void
6361
private function updateFormTimestamp(Form $form): void
6462
{
6563
$formClass = $form->formType;
66-
$reflector = new ReflectionClass($formClass);
67-
$dateTime = new DateTime();
64+
$reflector = new \ReflectionClass($formClass);
65+
$dateTime = new \DateTime();
6866
$timestamp = filemtime($reflector->getFileName());
6967

7068
$this->dispatcher->dispatch(new CommandLogEvent(sprintf('<info>Checking timestamp for %s</info>', $formClass)));

0 commit comments

Comments
 (0)