Skip to content
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

Require PHP 8.1 #788

Merged
merged 2 commits into from
Oct 27, 2023
Merged
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
14 changes: 2 additions & 12 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ jobs:
os:
- "ubuntu-20.04"
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
stability:
- "stable"
symfony-version:
Expand All @@ -39,19 +38,10 @@ jobs:
include:
- dependencies: "lowest"
os: "ubuntu-20.04"
php-version: "7.4"
php-version: "8.1"
driver-version: "1.5.0"
stability: "stable"
symfony-version: "5.4.*"
exclude:
- php-version: "7.4"
symfony-version: "6.2.*"
- php-version: "7.4"
symfony-version: "6.3.*"
- php-version: "8.0"
symfony-version: "6.2.*"
- php-version: "8.0"
symfony-version: "6.3.*"

services:
mongodb:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"

steps:
- name: "Checkout code"
Expand Down
8 changes: 1 addition & 7 deletions APM/PSRCommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ final class PSRCommandLogger implements CommandLoggerInterface
{
private bool $registered = false;

private ?LoggerInterface $logger;

private string $prefix;

public function __construct(?LoggerInterface $logger, string $prefix = 'MongoDB command: ')
public function __construct(private ?LoggerInterface $logger, private string $prefix = 'MongoDB command: ')
{
$this->logger = $logger;
$this->prefix = $prefix;
}

public function register(): void
Expand Down
5 changes: 1 addition & 4 deletions APM/StopwatchCommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ final class StopwatchCommandLogger implements CommandLoggerInterface
{
private bool $registered = false;

private ?Stopwatch $stopwatch;

public function __construct(?Stopwatch $stopwatch)
public function __construct(private ?Stopwatch $stopwatch)
{
$this->stopwatch = $stopwatch;
}

public function register(): void
Expand Down
5 changes: 1 addition & 4 deletions CacheWarmer/HydratorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
*/
class HydratorCacheWarmer implements CacheWarmerInterface
{
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
public function __construct(private ContainerInterface $container)
{
$this->container = $container;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions CacheWarmer/PersistentCollectionCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@
*/
class PersistentCollectionCacheWarmer implements CacheWarmerInterface
{
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
public function __construct(private ContainerInterface $container)
{
$this->container = $container;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions CacheWarmer/ProxyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
*/
class ProxyCacheWarmer implements CacheWarmerInterface
{
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
public function __construct(private ContainerInterface $container)
{
$this->container = $container;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions Command/LoadDataFixturesDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@
*/
class LoadDataFixturesDoctrineODMCommand extends DoctrineODMCommand
{
private ?SymfonyFixturesLoaderInterface $fixturesLoader;

public function __construct(?ManagerRegistry $registry = null, ?KernelInterface $kernel = null, ?SymfonyFixturesLoaderInterface $fixturesLoader = null)
public function __construct(?ManagerRegistry $registry = null, ?KernelInterface $kernel = null, private ?SymfonyFixturesLoaderInterface $fixturesLoader = null)
{
parent::__construct($registry);

$this->fixturesLoader = $fixturesLoader;
}

/** @return bool */
Expand Down
5 changes: 1 addition & 4 deletions DataCollector/CommandDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@

class CommandDataCollector extends DataCollector
{
private CommandLogger $commandLogger;

public function __construct(CommandLogger $commandLogger)
public function __construct(private CommandLogger $commandLogger)
{
$this->commandLogger = $commandLogger;
}

public function collect(Request $request, Response $response, ?Throwable $exception = null): void
Expand Down
5 changes: 2 additions & 3 deletions DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
*/
class DoctrineMongoDBExtension extends AbstractDoctrineExtension
{
/** @var string */
private static $odmVersion;
private static ?string $odmVersion = null;

/** @internal */
public const CONFIGURATION_TAG = 'doctrine.odm.configuration';
Expand Down Expand Up @@ -658,7 +657,7 @@
if (self::$odmVersion === null) {
try {
self::$odmVersion = PrettyVersions::getVersion('doctrine/mongodb-odm')->getPrettyVersion();
} catch (Throwable $t) {
} catch (Throwable) {

Check warning on line 660 in DependencyInjection/DoctrineMongoDBExtension.php

View check run for this annotation

Codecov / codecov/patch

DependencyInjection/DoctrineMongoDBExtension.php#L660

Added line #L660 was not covered by tests
return 'unknown';
}
}
Expand Down
2 changes: 1 addition & 1 deletion Form/DoctrineMongoDBTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
foreach ($this->registry->getManagers() as $name => $dm) {
try {
return $this->cache[$class] = [$dm->getClassMetadata($class), $name];
} catch (MappingException $e) {
} catch (MappingException) {

Check warning on line 185 in Form/DoctrineMongoDBTypeGuesser.php

View check run for this annotation

Codecov / codecov/patch

Form/DoctrineMongoDBTypeGuesser.php#L185

Added line #L185 was not covered by tests
// not an entity or mapped super class
}
}
Expand Down
6 changes: 3 additions & 3 deletions Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function addFixtures(array $fixtures): void

public function addFixture(FixtureInterface $fixture): void
{
$class = get_class($fixture);
$class = $fixture::class;
$this->loadedFixtures[$class] = $fixture;

$reflection = new ReflectionClass($fixture);
Expand Down Expand Up @@ -106,7 +106,7 @@ public function getFixtures(array $groups = [])
$filteredFixtures = [];
foreach ($fixtures as $fixture) {
foreach ($groups as $group) {
$fixtureClass = get_class($fixture);
$fixtureClass = $fixture::class;
if (isset($this->groupsFixtureMapping[$group][$fixtureClass])) {
$filteredFixtures[$fixtureClass] = $fixture;

Expand Down Expand Up @@ -145,7 +145,7 @@ private function validateDependencies(array $fixtures, FixtureInterface $fixture

foreach ($dependenciesClasses as $class) {
if (! array_key_exists($class, $fixtures)) {
throw new RuntimeException(sprintf('Fixture "%s" was declared as a dependency for fixture "%s", but it was not included in any of the loaded fixture groups.', $class, get_class($fixture)));
throw new RuntimeException(sprintf('Fixture "%s" was declared as a dependency for fixture "%s", but it was not included in any of the loaded fixture groups.', $class, $fixture::class));
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions ManagerConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
*/
class ManagerConfigurator
{
/** @var array */
private array $enabledFilters = [];

/**
* Construct.
*
* @param array $enabledFilters
*/
public function __construct(array $enabledFilters)
public function __construct(private array $enabledFilters = [])
{
$this->enabledFilters = $enabledFilters;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ManagerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

try {
return $objectManager->getConfiguration()->getDocumentNamespace($alias);
} catch (MongoDBException $e) {
} catch (MongoDBException) {

Check warning on line 49 in ManagerRegistry.php

View check run for this annotation

Codecov / codecov/patch

ManagerRegistry.php#L49

Added line #L49 was not covered by tests
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Compatibility
=============

The current version of this bundle has the following requirements:
* PHP 7.4 or newer is required
* PHP 8.1 or newer is required
* `ext-mongodb` 1.5 or newer
* Symfony 5.4 or newer is required

Expand Down
5 changes: 1 addition & 4 deletions Repository/ContainerRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ final class ContainerRepositoryFactory implements RepositoryFactory
/** @var array<string, ObjectRepository> */
private array $managedRepositories = [];

private ContainerInterface $container;

/** @param ContainerInterface $container A service locator containing the repositories */
public function __construct(ContainerInterface $container)
public function __construct(private ContainerInterface $container)
{
$this->container = $container;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public function testAnnotationsBundleMappingDetection(): void
$this->assertEquals('Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\AnnotationsBundle\Document', $calls[0][1][1]);
}

/** @requires PHP 8.0 */
public function testAttributesBundleMappingDetection(): void
{
if (! class_exists(AttributeDriver::class)) {
Expand Down
1 change: 0 additions & 1 deletion Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function testParameterOverride(string $option, string $parameter, string
$this->assertEquals($value, $container->getParameter('doctrine_mongodb.odm.' . $parameter));
}

/** @requires PHP 8 */
public function testAsDocumentListenerAttribute(): void
{
$container = $this->getContainer('DocumentListenerBundle');
Expand Down
5 changes: 1 addition & 4 deletions Tests/DocumentValueResolverFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
use function sys_get_temp_dir;
use function uniqid;

/**
* @requires PHP 8.0
* @requires function \Symfony\Bridge\Doctrine\Attribute\MapEntity::__construct
*/
/** @requires function \Symfony\Bridge\Doctrine\Attribute\MapEntity::__construct */
class DocumentValueResolverFunctionalTest extends WebTestCase
{
public function testWithoutConfiguration(): void
Expand Down
11 changes: 5 additions & 6 deletions Tests/FixtureIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use function array_map;
use function assert;
use function get_class;
use function sprintf;
use function sys_get_temp_dir;
use function uniqid;
Expand All @@ -51,7 +50,7 @@ public function testFixturesLoader(): void

$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => $fixture::class, $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -82,7 +81,7 @@ public function testFixturesLoaderWhenFixtureHasDependencyThatIsNotYetLoaded():

$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => $fixture::class, $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -138,7 +137,7 @@ public function testFixturesLoaderWithGroupsOptionViaInterface(): void

$actualFixtures = $loader->getFixtures(['staging']);
$this->assertCount(1, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => $fixture::class, $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -227,7 +226,7 @@ public function testLoadFixturesViaGroupWithFulfilledDependency(): void
$actualFixtures = $loader->getFixtures(['fulfilledDependencyGroup']);

$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => $fixture::class, $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -258,7 +257,7 @@ public function testLoadFixturesByShortName(): void
$actualFixtures = $loader->getFixtures(['OtherFixtures']);

$this->assertCount(1, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => $fixture::class, $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ final class DocumentValueResolverController
{
#[Route(path: '/user/{id}', name: 'tv_user_show')]
public function showUserByDefault(
User $user
User $user,
): Response {
return new Response($user->getId());
}

#[Route(path: '/user_with_identifier/{identifier}', name: 'tv_user_show_with_identifier')]
public function showUserWithMapping(
#[MapDocument(mapping: ['identifier' => 'id'])]
User $user
User $user,
): Response {
return new Response($user->getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

class RequiredConstructorArgsFixtures implements ODMFixtureInterface
{
/** @param mixed $fooRequiredArg */
public function __construct($fooRequiredArg)
public function __construct(mixed $fooRequiredArg)
{
}

Expand Down
8 changes: 2 additions & 6 deletions Tests/Fixtures/Form/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
/** @ODM\Document */
class Category
{
/**
* @ODM\Id
*
* @var ObjectId|string|null
*/
protected $id;
/** @ODM\Id */
protected ObjectId|string|null $id;

/** @ODM\Field(type="string") */
public string $name;
Expand Down
3 changes: 1 addition & 2 deletions Tests/Fixtures/Form/Guesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ class Guesser
*/
public array $collectionField;

/** @var mixed */
public $nonMappedField;
public mixed $nonMappedField;
}
Loading