Skip to content

Commit

Permalink
feature #274 Allow Symfony 7 (bocharsky-bw)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the main branch.

Discussion
----------

Allow Symfony 7

Commits
-------

5bf467a Allow Symfony 7
  • Loading branch information
weaverryan committed Dec 1, 2023
2 parents 9906ceb + 5bf467a commit 2b42822
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 28 deletions.
10 changes: 5 additions & 5 deletions composer.json
Expand Up @@ -7,15 +7,15 @@
"require": {
"php": ">=7.2.5",
"ext-json": "*",
"symfony/config": "^5.4 | ^6.0",
"symfony/dependency-injection": "^5.4 | ^6.0",
"symfony/config": "^5.4 | ^6.0 | ^7.0",
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0",
"symfony/deprecation-contracts": "^2.2 | ^3.0",
"symfony/http-kernel": "^5.4 | ^6.0"
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0"
},
"require-dev": {
"doctrine/orm": "^2.7",
"symfony/framework-bundle": "^5.4 | ^6.0",
"symfony/phpunit-bridge": "^5.4 | ^6.0",
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0",
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0",
"doctrine/doctrine-bundle": "^2.0.3",
"doctrine/annotations": "^1.0"
},
Expand Down
26 changes: 4 additions & 22 deletions psalm.xml
Expand Up @@ -51,30 +51,12 @@
<RawObjectIteration errorLevel="info"/>

<InvalidStringClass errorLevel="info"/>
<PossiblyUndefinedMethod>
<errorLevel type="suppress">
<file name="src/DependencyInjection/Configuration.php"/>
</errorLevel>
</PossiblyUndefinedMethod>
<PossiblyNullReference>

<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<file name="src/DependencyInjection/Configuration.php"/>
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::integerNode" />
</errorLevel>
</PossiblyNullReference>
<PossiblyNullArgument>
<errorLevel type="suppress">
<file name="src/DependencyInjection/SymfonyCastsResetPasswordExtension.php"/>
</errorLevel>
</PossiblyNullArgument>
<InvalidReturnType>
<errorLevel type="suppress">
<file name="src/Persistence/Fake/FakeResetPasswordInternalRepository.php"/>
</errorLevel>
</InvalidReturnType>
<TooManyArguments>
<errorLevel type="suppress">
<file name="src/Model/ResetPasswordToken.php"/>
</errorLevel>
</TooManyArguments>
</UndefinedInterfaceMethod>
</issueHandlers>
</psalm>
Expand Up @@ -27,6 +27,9 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('reset_password_services.xml');

$configuration = $this->getConfiguration($configs, $container);
if (!$configuration) {
throw new \Exception('Configuration is not expected to be null');
}

$config = $this->processConfiguration($configuration, $configs);

Expand Down
3 changes: 3 additions & 0 deletions src/Model/ResetPasswordToken.php
Expand Up @@ -143,6 +143,9 @@ public function getExpiresAtIntervalInstance(): \DateInterval
return $this->expiresAt->diff($createdAtTime);
}

/**
* @psalm-suppress UndefinedFunction
*/
private function triggerDeprecation(): void
{
trigger_deprecation(
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/Entity/ResetPasswordTestFixtureRequest.php
Expand Up @@ -20,6 +20,7 @@
*
* @ORM\Entity(repositoryClass="SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\ResetPasswordTestFixtureRequestRepository")
*/
#[ORM\Entity(repositoryClass: "SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\ResetPasswordTestFixtureRequestRepository")]
final class ResetPasswordTestFixtureRequest implements ResetPasswordRequestInterface
{
/**
Expand All @@ -29,26 +30,33 @@ final class ResetPasswordTestFixtureRequest implements ResetPasswordRequestInter
*
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
public $id;

/**
* @ORM\Column(type="string", nullable=true)
*/
#[ORM\Column(type: 'string', nullable: true)]
public $selector;

/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
public $expiresAt;

/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
public $requestedAt;

/**
* @ORM\ManyToOne(targetEntity="ResetPasswordTestFixtureUser")
*/
#[ORM\ManyToOne(targetEntity: 'ResetPasswordTestFixtureUser')]
public $user;

public function getRequestedAt(): \DateTimeInterface
Expand Down
4 changes: 4 additions & 0 deletions tests/Fixtures/Entity/ResetPasswordTestFixtureUser.php
Expand Up @@ -19,6 +19,7 @@
*
* @ORM\Entity()
*/
#[ORM\Entity]
final class ResetPasswordTestFixtureUser
{
/**
Expand All @@ -28,5 +29,8 @@ final class ResetPasswordTestFixtureUser
*
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
}
7 changes: 6 additions & 1 deletion tests/ResetPasswordTestKernel.php
Expand Up @@ -91,7 +91,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
'mappings' => [
'App' => [
'is_bundle' => false,
'type' => 'annotation',
'type' => self::shouldUseAttributes() ? 'attribute' : 'annotation',
'dir' => 'tests/Fixtures/Entity/',
'prefix' => 'SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\Entity',
'alias' => 'App',
Expand Down Expand Up @@ -141,4 +141,9 @@ public function getLogDir(): string
{
return sys_get_temp_dir().'/logs'.spl_object_hash($this);
}

public static function shouldUseAttributes(): bool
{
return Kernel::VERSION_ID >= 70000;
}
}

0 comments on commit 2b42822

Please sign in to comment.