Skip to content

Commit

Permalink
Merge pull request #788 from franmomu/require_php81
Browse files Browse the repository at this point in the history
Require PHP 8.1
  • Loading branch information
malarzm authored Oct 27, 2023
2 parents 1d3edae + c519eba commit e8bc048
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 99 deletions.
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 @@ private static function getODMVersion(): string
if (self::$odmVersion === null) {
try {
self::$odmVersion = PrettyVersions::getVersion('doctrine/mongodb-odm')->getPrettyVersion();
} catch (Throwable $t) {
} catch (Throwable) {
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 @@ protected function getMetadata($class)
foreach ($this->registry->getManagers() as $name => $dm) {
try {
return $this->cache[$class] = [$dm->getClassMetadata($class), $name];
} catch (MappingException $e) {
} catch (MappingException) {
// 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 @@ public function getAliasNamespace($alias)

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

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

0 comments on commit e8bc048

Please sign in to comment.